Problem:


Score : 200 points

Problem Statement

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

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

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

L_i, L_j, and L_k are all different.

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

Constraints

1 \leq N \leq 100

1 \leq L_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
L_1 L_2 \cdots L_N

Output

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

Sample Input 1

5
4 4 9 7 5

Sample Output 1

5

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

Sample Input 2

6
4 5 4 3 3 5

Sample Output 2

8

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

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

Sample Input 3

10
9 4 6 1 9 6 10 6 6 8

Sample Output 3

39

Sample Input 4

2
1 1

Sample Output 4

0

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



Sample input:
5
4 4 9 7 5


Sample output:
5

Submission status: Accepted

Solution code:
n = int(input())
total = 0

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

for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            B = [A[i], A[j], A[k]]
            if len(set(B)) == 3 and (max(B) < sum(B) - max(B)):
                total += 1

print(total)

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(n):
        for k in range(n):
            if i != j and j != k and k != i and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                nagasa = sorted([l[i],l[j],l[k]])
                if nagasa[0] + nagasa[1] > nagasa[2]:
                    cnt += 1
print(cnt // 6)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

cnt = 0
l.sort()

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

print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
from bisect import bisect_left
from itertools import product
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def LF(): return list(map(float, input().split()))
def LC(): return [c for c in input().split()]
def LLI(n): return [LI() for _ in range(n)]
def NSTR(n): return [input() for _ in range(n)]

def array2d(N, M, initial=0):
    return [[initial]*M for _ in range(N)]

def copy2d(orig, N, M):
    ret = array2d(N, M)
    for i in range(N):
        for j in range(M):
            ret[i][j] = orig[i][j]
    return ret


INF = float("inf")
MOD = 10**9 + 7


def main():
    N = INT()
    L = LI()
    L.sort()
    counter = 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]:
                    continue
                if L[i]+L[j] > L[k]:
                    counter += 1
                    # print(L[i], L[j], L[k])
    print(counter)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for i in range(len(L)):
    for j in range(len(L)):
        for k in range(len(L)):
            if i < j < k:
                if L[i] == L[j] or L[i] == L[k] or L[j] == L[k]:
                    continue
                if L[i] + L[j] + L [k] <= max(L[i], L[j], L[k]) * 2:
                    continue
                ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/bin/python3

def main():

    # 変数宣言
    cnt = 0

    # 標準入力からデータの受け取り
    n = int(input())
    l_list = list(map(int, input().split()))
    l_list.sort()

    # 提示条件成立判定＆カウント
    for i in range(0, n - 2):
        for j in range(i + 1, n -1):
            for k in range(j + 1, n):
                if (not((l_list[i] != l_list[j]) and (l_list[i] != l_list[k]) and (l_list[j] != l_list[k]))):
                    continue
                if (not((l_list[i] < l_list[j] + l_list[k]) and (l_list[j] < l_list[i] + l_list[k]) and (l_list[k] < l_list[i] + l_list[j]))):
                    continue
                cnt += 1
    # 結果表示
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a=int(input())

row=sorted(map(int,input().split()))

cnt=0

for i in range(len(row)):
  for j in range(i+1,len(row)):
    for k in range(j+1,len(row)):
      if row[i]!=row[j] and row[j]!=row[k] and row[i]!=row[k]:
        if (abs(row[j]-row[i]) < row[k]) and (row[k] < row[j]+row[i]):
          cnt+=1

print(cnt)

Submission status: Accepted

Solution code:
from collections import defaultdict
import itertools

N = int(input())

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

dic = defaultdict(int)

for num in L:
    dic[num] += 1

set_L = set(L)

comb = list(itertools.combinations(set_L, 3))

ans = 0
for a,b,c in comb:
    if a+b <= c or b+c<=a or c+a <= b: continue
    ans += dic[a] * dic[b] * dic[c]

print(ans)

Submission status: Accepted

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

if len(l) < 3:
    print(0)
    exit()

count = 0

for i in range(0, (n - 2)):
    for j in range((i + 1), (n - 1)):
        if l[i] == l[j]:
            continue
        for k in range((j + 1), n):
            if l[j] == l[k]:
                continue

            if l[i] + l[j] > l[k]:
                count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
ls = sorted(list(map(int, input().split())))
cnt = 0
for i in range(len(ls) - 2):
    a = ls[i]
    for j in range(i+1, len(ls) - 1):
        b = ls[j]
        for k in range(j+1, len(ls)):
            c = ls[k]
            if a==b or a==c or b==c:
                continue
            if a+b > c and b+c > a and c+a > b:
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:

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

c = 0

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


print(c)

Submission status: Accepted

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

count = 0
i = 0
while i < N:
    a = L_list[i]
    j = 0
    while j < i:
        b = L_list[j]
        k = 0
        while k < j:
            c = L_list[k]
            k += 1
            if a == b or b == c or c == a:
                continue
            if a + b > c and b + c > a and c + a > b:
                count += 1
        j += 1
    i += 1
                
print(count)

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):
            x = max(L[i], L[j], L[k])
            y = L[i] + L[j] + L[k]
            if x < y - x and (L[i] != L[j] and L[i] != L[k] and L[j] != L[k]):
                count += 1

print(count)

Submission status: Accepted

Solution code:
import itertools

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

c = list(itertools.combinations(l, 3))
ans = 0
for i in c:
    j = sorted(i)
    if j[0] != j[1] != j[2] != j[0]:
        if j[2] < j[0]+j[1]:
            ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a = int(input())
p = list(map(int,input().split()))
count = 0

for i in range(a):
     for s in range(a):
         for t in range(a):
             if p[t]<p[s]<p[i] and p[t]+p[s]>p[i]:
                 count+=1
print(count)

Submission status: Accepted

Solution code:
cnt = 0
n = int(input())
l = list(map(int, input().split()))
if len(l) >= 3:
  for i in range(len(l)):
    for j in range(i, len(l)):
      for k in range(j, len(l)):
        if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]:
          continue
        elif l[i] + l[j] > l[k] and l[i] + l[k] > l[j] and l[j] + l[k] > l[i]:
          cnt += 1
        else:
          continue
print(cnt)

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]:
                if max(L[i],L[j],L[k])<L[i]+L[j]+L[k]-max(L[i],L[j],L[k]):
                    count += 1
                else:
                    pass

print(count)

Submission status: Accepted

Solution code:
import itertools

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

Acomb = list(itertools.combinations(A, 3))

ans = 0
for tri in Acomb: 
  if tri[0] < tri[1] and tri[1] < tri[2] and tri[0] + tri[1] > tri[2]:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
def solve(string):
    _, *l = map(int, string.split())
    l.sort()
    ans = 0
    for i, l0 in enumerate(l[:-2]):
        for j, l1 in enumerate(l[i + 1:-1]):
            if l0 == l1:
                continue
            for l2 in l[i + j + 2:]:
                if l1 == l2:
                    continue
                if l2 < l0 + l1:
                    ans += 1
                else:
                    break
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int,input().split()))
if len(l) < 3:
  print(0)
  exit()
count = 0
l = sorted(l)
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]:
        count += 1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
count = 0
L_sort = sorted(L)
length = len(L_sort)
# 最長辺以外の辺の長さの和 > 最長辺の辺の長さ のとき三角形が成り立つ

for i in range(0, length-2):
    for j in range(i+1, length-1):
        if L_sort[i] == L_sort[j]:
            continue
        for k in range(j+1, length):
            if L_sort[j] == L_sort[k]:
                continue
            if L_sort[i] + L_sort[j] > L_sort[k]:
                count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
T = 0
if N > 2:
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            for k in range(j + 1, N):
                a = L[i]
                b = L[j]
                c = L[k]
                abc = sorted(list({a, b, c}))
                if len(abc) == 3 and abc[0] + abc[1] > abc[2]:
                    T += 1
print(T)

Submission status: Accepted

Solution code:
def solve(n, arr):
    # Firstly sort the array to reduce amount of calculation
    arr.sort()

    ans = 0

    for (i, _) in enumerate(arr):
        for j in range(i + 1, len(arr)):
            for k in range(j + 1, len(arr)):
                if arr[i] != arr[j] and arr[i] != arr[k] and arr[j] != arr[k]:
                    if arr[i] + arr[j] > arr[k]:
                        ans += 1
    return ans


if __name__ == "__main__":
    n = int(input())
    arr = list(map(int, input().split(' ')))
    print(solve(n, arr))

Submission status: Accepted

Solution code:
# ABC172 Making Triangle
N = int(input())
L = list(map(int,input().split()))
d = {i:L.count(i) for i in L}

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

Submission status: Accepted

Solution code:
# ABC172 Making Triangle
N = int(input())
L = list(map(int,input().split()))
d = {i:L.count(i) for i in L}

L = sorted(list(set(L)))
num = len(L)
ans = 0

for i in range(num-2):
    for j in range(i+1,num-1):
        for k in range(j+1,num):
            if L[k] < L[i] + L[j]:
                ans += d[L[k]]*d[L[i]]*d[L[j]]
            else:
                break
print(ans)

Submission status: Accepted

Solution code:
# string
# a, b, c = input().split()
# str_list = list(input().split())

# number
# a, b, c = map(int, input().split())
# num_list = list(map(int, input().split()))

# lows
# str_list = [input() for _ in range(n)]

# many inputs
# num_list = []
# for i in range(n): num_list.append(list(map(int, input().split())))

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

l.sort(reverse = True)

ctr = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if l[i] == l[j]:
            continue
        for k in range(j+1, n):
            if l[j] == l[k]:
                continue
            if l[i] < l[j] + l[k]:
                ctr += 1

print(ctr)

Submission status: Accepted

Solution code:
N = int(input())
bar = list(map(int, input().split()))
triangles = []
for i in range(N-2):
    for j in range(i + 1, N - 1):
        if bar[i] == bar[j]:
            continue
        for k in range(j + 1, N):
            if bar[j] == bar[k] or bar[i] == bar[k]:
                continue
            if (bar[i] + bar[j] > bar[k]) and (bar[j] + bar[k] > bar[i]) and (bar[i] + bar[k] > bar[j]):# and (len(set([bar[i], bar[j], bar[k]])) == 3):
                triangles.append([bar[i], bar[j], bar[k]])
print(len(triangles))

Submission status: Accepted

Solution code:
N = int(input())
bar = list(map(int, input().split()))
triangles = []
for i in range(N-2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            if (bar[i] + bar[j] > bar[k]) and (bar[j] + bar[k] > bar[i]) and (bar[i] + bar[k] > bar[j]) and (len(set([bar[i], bar[j], bar[k]])) == 3):
                triangles.append([bar[i], bar[j], bar[k]])
print(len(triangles))

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):
    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)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import itertools

input()
rods = list(map(int, input().split(" ")))
sorted_rods = sorted(rods)

count = 0
for combination in itertools.combinations(sorted_rods, 3):
  a, b, c = combination
  if a != b and b != c:
    if a + b > c:
      count += 1
      
print(count)

Submission status: Accepted

Solution code:
n=int(input())
L=list(map(int,input().split()))
L.sort()#L[i]<=L[j]<=L[k]
ans=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if L[i] != L[j] != L[k]:
                if L[i] + L[j] >L[k]:#三角形を作る条件
                    ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
def backtrack(nums, step, result):
    if len(step) == 3:
        if len(set(step)) == 3:
            sorted_step = sorted(step)
            a,b,c = sorted_step
            if a+b > c:
                result.append(step[:])
    else:
        for i in range(len(nums)):
            step.append(nums[i])
            backtrack(nums[i+1:], step, result)
            step.pop()

def solve():
    N = int(input())
    L = [int(i) for i in input().split()]
    result = []
    backtrack(L, [], result)
    print(len(result))

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

n =0
#print(Llist)
for i in range(N-2):
  for j in range(N-1):
    for k in range(N):
      if i<j and j<k and Llist[i]!=Llist[j] and Llist[j]!=Llist[k] and Llist[i]!=Llist[k] and Llist[i]+Llist[j]>Llist[k] and Llist[j]+Llist[k]>Llist[i] and Llist[i]+Llist[k]>Llist[j]:
        #print ('{}{}{}'.format(Llist[i], Llist[j], Llist[k]))
        #print ('{}{}{}'.format(i, j, k))
        n+=1
print(n)

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
len_list = list(map(int, input().split()))
len_list = sorted(len_list)
#print(len_list)

per_len = list(combinations(len_list, 3))
#print(per_len)
count = 0

for i in range(len(per_len)):
    if per_len[i][2] == per_len[i][0] or per_len[i][1] == per_len[i][2] or per_len[i][0] == per_len[i][1]:
        pass
    
    else:
        if per_len[i][2] < per_len[i][0] + per_len[i][1] :
            count += 1
            #print(i)
            #print(count)

print(count)

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
l = list(map(int, input().split()))
comb = list(combinations(range(n), 3))
ans = 0
for i,j,k in comb:
    a = l[i]
    b = l[j]
    c = l[k]

    if a == b:
        continue
    if b == c:
        continue
    if c == a:
        continue
    if sum([a,b,c]) <= 2 * max(a,b,c):
        continue
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
tmp = input()
line = input().split(" ")
for i in range(len(line)):
  line[i] = int(line[i])
line.sort()
count = 0
for i in range(0, len(line) - 2):
  for j in range(1, len(line) - 1):
    if i > j or i == j:
      continue
    for k in range(2, len(line)):
      if j > k or j == k:
        continue
      if int(line[i]) != int(line[j]) and int(line[j]) != int(line[k]):
        if int(line[i]) + int(line[j]) > int(line[k]):
          count += 1
print(count)

Submission status: Accepted

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

def is_unique(a, b, c):
    return (a != b) and (a != c) and (b != c)

def is_triangle(a, b, c):
    return (a + b > c) and (b + c > a) and (c + a > b)

cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            a, b, c = l[i], l[j], l[k]
            if is_unique(a, b, c) and is_triangle(a, b, c):
                cnt += 1
print(cnt)

Submission status: Accepted

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

count = 0

# 組合せnCpの総当たりforループ（計算速度遅）
for i in range(0, n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if list_l[i] != list_l[j] != list_l[k] and list_l[i] != list_l[k]:
                if list_l[i] < list_l[j] + list_l[k] and list_l[j] < list_l[i] + list_l[k] and list_l[k] < list_l[i] + list_l[j]:
                    
                    count += 1
print(count)

Submission status: Accepted

Solution code:
N = int(input().rstrip())
l = list(map(int, input().rstrip().split()))
#l = list(set(l))
l.sort(reverse=True)
num = 0
for i in range(len(l) - 2):
	for j in range(i + 1, len(l) - 1):
		if l[i] == l[j]:
			continue

		for k in range(j + 1, len(l)):
			if l[j] == l[k]:
				continue

			if l[i] < (l[j] + l[k]):
				num += 1

print(num)

Submission status: Accepted

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

    for i in range(N-2):
        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]:
                    count += 1

    print(count)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(len(l)):
    for j in range(i + 1, len(l)):
        for k in range(j + 1, len(l)):
            sum = l[i] + l[j] + l[k]
            if sum - max(l[i], l[j], l[k]) > max(l[i], l[j], l[k]):
                if l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                    t += 1

print(t)

Submission status: Accepted

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

count=0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            li=l_list[i]
            lj=l_list[j]
            lk=l_list[k]
            if li!=lj and li!=lk and lj!=lk:
                if lk<li+lj:
                    count+=1
            
print(count)

Submission status: Accepted

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

res = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        if lens[i] == lens[j]:
            continue
        for k in range(j + 1, n):
            if lens[i] == lens[k] or lens[j] == lens[k]:
                continue
            if lens[i] < lens[j] + lens[k]:
                res += 1

print(res)

Submission status: Accepted

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

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[i] != L[k] and L[j] != L[k] and abs(L[j]-L[k]) < L[i] 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()))
 
ans = 0
if(N >= 3):
  t = []
  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[i] != L[k]) & (L[j] != L[k]) & (abs(L[j]-L[k]) < L[i]) & (L[i] < L[j]+L[k])): t.append((L[i], L[j], L[k]))
  ans = len(t)

print(ans)

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 L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
        if L[i] + L[j] + L[k] > 2 * max(L[i],L[j],L[k]):
          c +=1
 
print(c)

Submission status: Accepted

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

from itertools import combinations

cnt = 0
for i in combinations(L, 3):
    longest = max(i)
    rest = sum(i) - max(i)
    if longest < rest and i[0] != i[1] and i[0] != i[2] and i[1] != i[2] :
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import math

n = int(input())
s = list(map(int, input().split()))
s.sort()

cnt = 0
for i in range(n-2):
    for j in range(i, n-1):
        for k in range(j, n):
            if s[i] == s[j] or s[j] == s[k]:
                pass
            else:
                if s[i] + s[j] > s[k]:
                    cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int, input().split()))
num = 0
for i,h,j in itertools.combinations(l,3):
    if i+h>j and h+j>i and j+i>h and j!=i and i!=h and h!=j:
        num += 1
print(num)

Submission status: Accepted

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

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

print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
sides=[int(x) for x in input().split()]
counter=0
for i in range(N-2):
	for j in range(i+1,N-1):
		for k in range(j+1,N):
			A=sorted([sides[i],sides[j],sides[k]])
			if (A[0]+A[1]>A[2]) and A[0]!=A[1] and A[1]!=A[2] and A[0]!=A[2]:
				counter+=1
				
print(counter)

Submission status: Accepted

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

count=0

if len(L)<3:
    Lis=[]
else:
    Lis=list(itertools.combinations(L,3))
 
numb=len(Lis)

for i in range(numb):
    if len(L)<3:
        break
 
    if Lis[i][0]==Lis[i][1] or Lis[i][0]==Lis[i][2] or Lis[i][1]==Lis[i][2]:
        pass
    else:
        bpc=Lis[i][1]+Lis[i][2]
        bmc=abs(Lis[i][1]-Lis[i][2])
        if bmc<Lis[i][0] and Lis[i][0]<bpc:
            #if Lis[i][0]<bpc:
            count+=1
 
print(count)

Submission status: Accepted

Solution code:
import itertools
import sys

N = int(input())
s = input().rstrip().split(' ')
L = [int(j) for j in s]

if len(L) < 3:
    print(0)
    sys.exit()

ans = 0

for i,j,k in itertools.combinations(L,3):
    if (i == j) or (i == k) or (j == k): continue
    if (i < j+k) and (j < i+k) and (k < i+j):
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def check(a,b,c):
	if a==b or a==c or b==c:
		return False
	if a+b>c and b+c>a and c+a>b:
		
		return True
	return False

n=int(input())
c=list(map(int,input().split()))
count=0
for i in range(len(c)-2):
	for j in range(i+1,len(c)-1):
		for k in range(j+1,len(c)):
			if check(c[i],c[j],c[k]):
				count+=1
print(count)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(i) for i in input().split()]
cnt = 0
for i in range(n-2):
  l1 = l[i]
  for j in range(i+1, n-1):
    l2 = l[j]
    for g in range(j+1, n):
      l3 = l[g]
      l1_, l2_, l3_ = sorted([l1, l2, l3])
      if l1_ == l2_ or l2_ == l3_:
        continue
      if l3_ < l2_ + l1_:
        cnt += 1
        #print(i+1, j+1, g+1, l3_, l2_, l1_)
print(cnt)

Submission status: Accepted

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

print(a)

Submission status: Accepted

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