Problem:


Score : 200 points

Problem Statement

We have sticks numbered 1, \cdots, N. The length of Stick i (1 \leq i \leq N) is L_i.

In how many ways can we choose three of the sticks with different lengths that can form a triangle?

That is, find the number of triples of integers (i, j, k) (1 \leq i < j < k \leq N) that satisfy both of the following conditions:

L_i, L_j, and L_k are all different.

There exists a triangle whose sides have lengths L_i, L_j, and L_k.

Constraints

1 \leq N \leq 100

1 \leq L_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
L_1 L_2 \cdots L_N

Output

Print the number of ways to choose three of the sticks with different lengths that can form a triangle.

Sample Input 1

5
4 4 9 7 5

Sample Output 1

5

The following five triples (i, j, k) satisfy the conditions: (1, 3, 4), (1, 4, 5), (2, 3, 4), (2, 4, 5), and (3, 4, 5).

Sample Input 2

6
4 5 4 3 3 5

Sample Output 2

8

We have two sticks for each of the lengths 3, 4, and 5. To satisfy the first condition, we have to choose one from each length.

There is a triangle whose sides have lengths 3, 4, and 5, so we have 2 ^ 3 = 8 triples (i, j, k) that satisfy the conditions.

Sample Input 3

10
9 4 6 1 9 6 10 6 6 8

Sample Output 3

39

Sample Input 4

2
1 1

Sample Output 4

0

No triple (i, j, k) satisfies 1 \leq i < j < k \leq N, so we should print 0.



Sample input:
5
4 4 9 7 5


Sample output:
5

Submission status: Accepted

Solution code:
import math

result=0
n=int(input())
rml=[]

li=list(map(int,input().split()))
for i in range(len(li)-1):
    for j in range(i+len(li)):
        rml.append(j)

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if li[i]+li[j]<=li[k] or li[i]==li[j]:
                continue
            if li[j]+li[k]<=li[i] or li[j]==li[k]:
                continue
            if li[k]+li[i]<=li[j] or li[k]==li[i]:
                continue
            #print(i+1,j+1,k+1)
            result+=1
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import factorial
n = int(input())
l = list(map(int, input().split()))
l.sort()
disabled = 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] or l[i] == l[j] or l[j] == l[k]:
                    disabled += 1
if n >= 3:
    print(int(factorial(n) / factorial(3) / factorial(n-3) - disabled))
else:
    print("0")

Submission status: Accepted

Solution code:
a = int(input())
b = list(map(int,input().split()))
b.sort()
d = 0
 
if a <= 2:
  print("0")
else :
  for i in range(len(b)):
    for j in range(i+1,len(b)):
      for k in range(j+1,len(b)):
        if b[i]+b[j] > b[k] and b[i] != b[j] and b[j] != b[k]:
          d += 1
  print(str(d))

Submission status: Accepted

Solution code:

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

ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        if a==b:
            continue
        for k in range(j+1,N):
            #print(i,j,k)
            c = L[k]
            if a==c or b==c:
                continue
            if (a+b)>c and (b+c)>a and (c+a)>b:
                #print(i,j,k)
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
if N<=2:
  print(0)
else:
  ans=0
  for i in range(N-2):
    for j in range(i+1,N-1):
      for k in range(j+1,N):
        if L[i] !=L[j] and L[i]!=L[k] and L[j]!=L[k]:
          ma=max(L[i],L[j],L[k])
          mi=min(L[i],L[j],L[k])
          nu=L[i]+L[j]+L[k]-ma-mi
          if ma<mi+nu:
            ans+=1
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations as ic
N = int(input())
L = map(int, input().split())
A = list(ic(L, 3))
ans = 0
for i in A:
  if 2 * max(i) - sum(i) < 0 and len(set(i)) == 3:
    ans += 1
else:
  print(ans)

Submission status: Accepted

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


def solve():
    cnt=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                if L[i]!=L[j]!=L[k] and L[i]+L[j]>L[k]:
                    cnt+=1
    print(cnt)
if __name__ == "__main__":
    n = int(input())
    L = list(map(int,input().split()))
    L.sort()
    solve()

Submission status: Accepted

Solution code:
def sides(a,b,c):
  if a + b > c:
    return True
  return False
res = 0
N = int(input())
nums = list(map(int,input().split()))
nums = sorted(nums)
for x in range(N-2):
  for y in range(x+1,N-1):
    for z in range(y+1,N):
      if nums[x] != nums[y] and nums[x] != nums[z] and nums[y] != nums[z] and sides(nums[x],nums[y],nums[z]):
        res += 1
print(res)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    #print(L)
    ans = 0

    for i in range(N-2):
        #jの探索
        j = i + 1
        while True:
            if L[i] != L[j]:
                break
            else:
                j += 1
                if j == N-1:
                    return ans

        while (j < N-1):
            #hの探索
            h = j+1
            while True:
                if L[j] != L[h]:
                    break
                else:
                    h += 1
                    if h == N:
                        break
            if h == N:
                break

            while (h < N):
                if (L[i] + L[j]) > L[h]:
                    #print(i,j,h)
                    ans += 1
                    h += 1
                else:
                    break
            j += 1

    return ans

print(main())

Submission status: Accepted

Solution code:
import itertools

N = int(input())
L = list(map(int,input().split()))
 
l_list = list(itertools.combinations(L, 3))

res = 0
 
for tri in l_list:
  l = list(tri)
  l.sort()
  if (len(l) != len(set(l))):
    continue
  if (l[0] + l[1] > l[2]):
  	res += 1
    
print(res)

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


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

Submission status: Accepted

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

Submission status: Accepted

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

ans=0

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

Submission status: Accepted

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

a.sort()
ans = 0

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

Submission status: Accepted

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

A.sort()
counter = 0
for i in A:
  second = [m for m in A if i < m]
  for j in second:
    third = [n for n in second if j < n]
    if len(third) > 0:
      for k in third:
        if i + j > k:
          counter += 1
print(counter)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import itertools
n = int(input())
i_list = list(map(int, input().split()))
answer = 0

for i in itertools.combinations(i_list, 3):
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[2] + i[0] > i[1] and i[0] != i[1] and i[1] != i[2] and i[2] != i[0]:
        answer += 1
print(answer)

Submission status: Accepted

Solution code:
N = int(input())

A = map(int, input().split())

A = sorted(A, reverse=True)

c = 0
for l in range(N-2):
    for m in range(l+1, N-1):
        for n in range(m+1, N):
            if A[l] < A[m] + A[n] and A[l] != A[m] != A[n]:
                c+=1

print(c)

Submission status: Accepted

Solution code:
N = int(input())
A = map(int, input().split())
A = sorted(A, reverse = False)
count = 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]) and (A[k] < A[i] + A[j]):
                count += 1

print (count)

Submission status: Accepted

Solution code:
r=int(input())
x=list(map(int,input().split()))
setx=list(set(x))
setx.sort()
cx=[]
for i in setx:
    cx.append(x.count(i))
ans=0
A=0
while A<=len(setx)-3:
    B=A+1
    while B<=len(setx)-2:
        C=B+1
        while C<=len(setx)-1:
            if setx[A]+setx[B]>setx[C]:
                ans+=cx[A]*cx[B]*cx[C]
            C+=1
        B+=1
    A+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

d = {}

for i in x:
    d[i] = d.get(i, 0) + 1
    
ans = 0
l = list(d.keys())
l = sorted(l)
#print(l)
for i in range(len(l)-2):
    for j in range(i+1, len(l)-1):
        for k in range(j+1, len(l)):
            if l[k] < l[i] + l[j]:
                #print(l[i], l[j], l[k])
                ans += d[l[i]]*d[l[j]]*d[l[k]]
            
            else:
                break
            
print(ans)

Submission status: Accepted

Solution code:
def factorial_cor(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact
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 k != i:
        if i + j > k:
          if j + k > i:
            if k + i > j:
              ans += 1
              
              
          
print(ans // factorial_cor(3))

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

Solution code:
import itertools

n=int(input())
l=list(map(int,input().split()))
a=[]
for i in itertools.combinations(l,3):
    b=list(i)
    if b[0]+b[1]>b[2] and b[1]+b[2]>b[0] and b[0]+b[2]>b[1] and len(list(set(b)))==len(b):
        a.append(i)
print(len(a))

Submission status: Accepted

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

L.sort()
cnt=0

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] and L[b]!=L[c] and L[c]!=L[a]:
                if L[a] + L[b] > L[c]:
                    cnt+=1

print(cnt)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    sticks = sorted(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):
                l1, l2, l3 = sticks[i], sticks[j], sticks[k]
                if l1 != l2 and l1 != l3 and l2 != l3:
                    if l1 + l2 > l3:
                        count += 1

    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from bisect import bisect_right,bisect_left
N= int(input())
L = list(map(int,input().split()))
ans=0

L.sort()

for i in range(N-1,1,-1):
    a = L[i]
    b_list = L[:bisect_right(L,(a-1))]
    for j in range(len(b_list)-1,0,-1):
        b = b_list[j]
        c_list = b_list[:bisect_right(b_list,(b-1))]
        for k in c_list:
            if k > a-b:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    L = sorted([int(x) for x in input().strip().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[k] != L[i] and L[k] != L[j] and L[i] + L[j] > L[k]:
                    ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def IsTri(a, b, c):
    return (a != b) & (b != c) & (c != a) & ((a + b) > c) & ((b + c) > a) & ((c + a) > b)

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

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

print(cnt)

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

Submission status: Accepted

Solution code:
import itertools

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

comb = []
for i in itertools.combinations(L, 3):
    comb.append(i)
count = 0
for i in range(len(comb)):
    if comb[i][0] - comb[i][1] != 0 and comb[i][0] - comb[i][2] != 0 and comb[i][1] - comb[i][2] != 0:
        if sorted(comb[i])[-1] - sorted(comb[i])[-2] < sorted(comb[i])[-3]:
            count += 1

print(count)

Submission status: Accepted

Solution code:
import itertools as it

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

tuple_comb = it.combinations(range(N), 3)
ans = 0
for tup in tuple_comb:
    i, j, k = tup
    if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
        continue
    if L[i] + L[j] <= L[k] or L[j] + L[k] <= L[i] or L[k] + L[i] <= L[j]:
        continue
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

l.sort()

ans = 0

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

print(ans)

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    n,*L = get_all_int()

    ans = 0

    for i in range(n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                
                a,b,c = L[i],L[j],L[k]
                # log(i,j,k,a,b,c)

                if len({a,b,c}) != 3:
                    continue

                if a+b <= c:
                    continue
                if a+c <= b:
                    continue
                if b+c <= a:
                    continue
                ans += 1
    
    print(ans)

main()

Submission status: Accepted

Solution code:
N=int(input())
Array = list(map(int, input().strip().split()))
array=list(set(Array))
array.sort()
n=len(array)
f=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for w in range(j+1,n):
            if array[i]+array[j]>array[w]:
                f+=Array.count(array[i])*Array.count(array[j])*Array.count(array[w])
print(f)

Submission status: Accepted

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

    for i in range(0, n - 2):
        for j in range(i + 1, n - 1):
            for k in range(j + 1, n):

                # 辺の長さが同じ場合は却下
                if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                    continue
                # 三角形になるにはa+b>c,b+c>a,c+a>b
                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)

if __name__ == '__main__':
    abc175_b()

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
NumberList = []
CountList = []
for i in L:
    if i in NumberList:
        index = NumberList.index(i) #iがNumberListのどこにあるのか？
        CountList[index] += 1
    else:
        NumberList.append(i)
        CountList.append(1)

End = len(NumberList)

Total = 0
for i in range(0, End-2):
    for j in range(i+1, End-1):
        for l in range(j+1, End):
            if NumberList[i] + NumberList[j] > NumberList[l] and NumberList[j] + NumberList[l] > NumberList[i] and NumberList[l] + NumberList[i] > NumberList[j]:
                Count = CountList[i] * CountList[j] * CountList[l]
                Total += Count
            else:
                pass

print(Total)

Submission status: Accepted

Solution code:
from numba import jit

@jit
def abc175_b():
    n = int(input())
    l = list(map(int, input().split(' ')))
    cnt = 0

    for i in range(0, n - 2):
        for j in range(i + 1, n):
            for k in range(j + 1, n):

                # 辺の長さが同じ場合は却下
                if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                    continue
                # 三角形になるにはa+b>c,b+c>a,c+a>b
                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)

if __name__ == '__main__':
    abc175_b()

Submission status: Accepted

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

    for i in range(0, n - 2):
        for j in range(i + 1, n):
            for k in range(j + 1, n):

                # 辺の長さが同じ場合は却下
                if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                    continue
                # 三角形になるにはa+b>c,b+c>a,c+a>b
                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)

if __name__ == '__main__':
    abc175_b()

Submission status: Accepted

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

    for i in range(0, n - 2):
        for j in range(i + 1, n):
            for k in range(j + 1, n):

                # 辺の長さが同じ場合は却下
                if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                    continue
                # 三角形になるにはa+b>c
                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)

if __name__ == '__main__':
    abc175_b()

Submission status: Accepted

Solution code:
n = int(input())
arr = list(map(int,input().strip().split(" ")))

ans = 0

for i in range(n):
    for j in range(i+1,n):
        if arr[i] == arr[j]:
            continue
        for k in range(j+1,n):
            if arr[i]==arr[k] or arr[j] == arr[k]:
                continue
            a = [arr[i],arr[j],arr[k]]
            a.sort()
            
            if a[0]+a[1]>a[2]:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
from itertools import combinations

n = int(input())
nums = list(map(int, input().split()))
count = 0
for i in combinations(nums,3):
    if len(np.unique(i)) == 3:
        sorts = np.sort(i)
        if sorts[2] < sorts[1] + sorts[0]:
            count +=1 
print(count)

Submission status: Accepted

Solution code:
from itertools import combinations

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

answer = 0
for c in combinations(li_l, 3):
    so = sorted(list(c))

    if (so[0] + so[1]) > so[2] and len(set(so)) == 3:
        answer += 1
print(answer)

Submission status: Accepted

Solution code:
N=int(input())
L= list(map(int,input().split()))
L_sorted=sorted(L,reverse=False)
count=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            Li=L_sorted[i]
            Lj=L_sorted[j]
            Lk=L_sorted[k]
            if Li!=Lj!=Lk and Li+Lj>Lk:
                count+=1

print(count)

Submission status: Accepted

Solution code:
import bisect
import numpy as np
n=int(input())
l=list(map(int, input().split()))
l=np.array(l)
l.sort()
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    if l[j]==l[i]:
      continue
    ans+=bisect.bisect_left(l, l[i]+l[j])-bisect.bisect_right(l, l[j]) #n未満の個数を数える
print(ans)

Submission status: Accepted

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

def cond_1(i, j):
  return True if L[i] != L[j] else False

def cond_2(i, j, k):
  return True if L[i]+L[j]>L[k] and L[i]+L[k]>L[j] and L[j]+L[k]>L[i] else False

ret = 0

for i in range(0, N):
  for j in range(i+1, N):
    if cond_1(i, j): # condition 1
      for k in range(j+1, N):
        if cond_1(i, k) and cond_1(j, k): # condition 1
          if cond_2(i, j, k):
            ret += 1

print(ret)

Submission status: Accepted

Solution code:

    


import collections
if __name__=='__main__':
    n = int(input())
    arr = list(map(int,input().split()))
    arr.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 arr[i]!=arr[j] and arr[j]!=arr[k] and arr[i]+arr[j]>arr[k]:
                    c+=1
    print(c)

Submission status: Accepted

Solution code:
n = int(input())
if n < 3:
  print(0)
else:
  s = 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):
        m = max(s[i], s[j], s[k])
        su = s[i] + s[j] + s[k]
        if m < su - m and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
          c += 1
  print(c)

Submission status: Accepted

Solution code:
n=int(input())
boulist=list(map(int,input().split()))
boulist.sort(reverse=True)

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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


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

    ans = 0
    for i in range(N):
        for j in range(i, N):
            for k in range(j, N):
                tmp = [L[i], L[j], L[k]]
                tmp.sort()
                if len(tmp) == len(set(tmp)) and tmp[0] + tmp[1] > tmp[2]:
                    ans += 1
    print(ans)


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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      a = l[i]
      b = l[j]
      c = l[k]      
      
      if a == b or b == c or c == a:
        continue
        
      if a + b > c:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
import math

n = int(input())
arr = list(map(int, input().split()))
ans = 0
for a in range(n):
    for b in range(a+1, n):
        for c in range(b+1, n):
            if(arr[a]<arr[b]+arr[c] and arr[b]<arr[a]+arr[c] and arr[c]<arr[a]+arr[b]
               and arr[a]!= arr[b] and arr[a]!= arr[c] and arr[b]!= arr[c]):
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
Li = list(map(int, input().split()))
count = 0
lnum = 0
mnum = 0
nnum = 0

for l in Li:
    mnum = lnum
    for m in Li[lnum:N]:
        if l == m:
            mnum += 1
            continue
        for n in Li[mnum:N]:
            if m != n and l != n:
                d = [l, m, n]
                d.sort()
                if d[2] < (d[0] + d[1]):
                    count += 1

        mnum += 1

    lnum += 1

print(count)

Submission status: Accepted

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

for x in lists:
    for y in lists:
        for z in lists:
            if x + y > z and x + z > y and y + z > x and x < y and y < z:
                a += 1
               
            else:
                continue
               
            
print(a)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
num = 0
if N < 3:
   num=0
else:
   for i in range(N-2):
       for j in range(i+1, N-1):
          for k in range(j+1, N):
             if not(L[i]==L[j] or L[j]==L[k] or L[k]==L[i]):
                if (L[i]-L[j] < L[k]) and (L[j]-L[i]<L[k])and(L[k]<L[j]+L[i]):
                   num=num+1
print(num)

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,n,1):
        if l[i] == l[j]:
            continue
        for k in range(j,n,1):
            if l[i] == l[k] or l[j] == l[k]:
                continue
            elif l[i]>=l[j]+l[k] or l[j]>=l[i]+l[k] or l[k]>=l[i]+l[j]:
                continue
            c += 1

print(c)

Submission status: Accepted

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


def solve(N: int, L: "List[int]"):
    L = sorted(L)
    answer = 0
    for i in range(len(L)-1, 1, -1):
        a = L[i]
        for j in range(i-1, 0, -1):
            b = L[j]
            if a == b:
                continue
            for k in range(j-1, -1, -1):
                c = L[k]
                if b == c:
                    continue
                if b + c <= a:
                    break
                answer += 1


    return answer

def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, L)
    print(answer)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from itertools import combinations

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

for p in combinations(L, 3):
    p = sorted(p)
    c += (len(p)==len(set(p)) and p[2]<p[0]+p[1])
print(c)

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 abs(l[j]-l[k])<l[i] 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()))
count = 0

for i in range(len(L)):
#  print(i)
  for j in range(i + 1, len(L)):
#    print('	:' + str(j))
    for k in range(j + 1, len(L)):
#      print('		:' + str(k))
#      print(tmp)
      if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
        tmp = [L[i] ,L[j], L[k]]
        tmp.sort()
        if tmp[0] + tmp[1] > tmp[2]:
          count += 1
print(count)

Submission status: Accepted

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

for i in range(len(L)):
#  print(i)
  for j in range(i + 1, len(L)):
#    print('	:' + str(j))
    for k in range(j + 1, len(L)):
#      print('		:' + str(k))
      tmp = [L[i] ,L[j], L[k]]
      tmp.sort()
#      print(tmp)
      if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
        if tmp[0] + tmp[1] > tmp[2]:
          count += 1
print(count)