Problem:


Score : 200 points

Problem Statement

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

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

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

L_i, L_j, and L_k are all different.

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

Constraints

1 \leq N \leq 100

1 \leq L_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
L_1 L_2 \cdots L_N

Output

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

Sample Input 1

5
4 4 9 7 5

Sample Output 1

5

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

Sample Input 2

6
4 5 4 3 3 5

Sample Output 2

8

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

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

Sample Input 3

10
9 4 6 1 9 6 10 6 6 8

Sample Output 3

39

Sample Input 4

2
1 1

Sample Output 4

0

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



Sample input:
5
4 4 9 7 5


Sample output:
5

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

ans = 0
for i in range(len(ls)-2) :
  a = ls[i]
  for j in range(len(ls)-i-2) :
    b = ls[i+1+j]
    for k in range(len(ls)-i-j-1) :
      c = ls[i+j+k+1]
      if b-a < c < b+a and a!=b!=c!=a :
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

arr = list(map(int, input().split()))
arr.sort()

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input())
L = list(map(int,input().split()))
l=[]
A=[]
ans=0
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]
            if a!=b and b!=c and c!=a and a+b>c and b+c>a and c+a>b:
                #print(i+1,j+1,k+1)
                #print(a,b,c)
                ans += 1
#print(L)
#print()
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations as comb
N = int(input())
L = list(map(int,input().split()))
count = 0
for a, b, c in comb(L, 3):
  if a != b and b != c and c != a and a + b > c and b + c > a and c + a > b:
    count += 1
print(count)

Submission status: Accepted

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

def judge(l, i, j, k):
  a = l[i]
  b = l[j]
  c = l[k]
  if a != b and b != c and c != a:
    if a + b > c and b + c > a and c + a > b:
      return 1
    else:
      return 0
  else:
    return 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 += judge(l, i, j, k)
      
print(cnt)

Submission status: Accepted

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

import itertools
cnt = 0
for s, t, u in itertools.combinations(L, 3):
    if (s != t) and (t != u) and (u != s):
        if (s+t > u) and (t+u > s) and (s+u > t):
            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)-3+1):
    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] and L[j]<L[i]+L[k] and L[k]<L[i]+L[j]:
                count += 1

print(count)

Submission status: Accepted

Solution code:
def resolve():
    # 最長の辺の長さ < 他の辺の長さの合計 で三角形
    N = int(input())
    lines = map(int, input().split())
    #N = 100
    #from random import randint
    #lines = [randint(1, 10 ** 9) for x in range(N)]
    from itertools import combinations
    count = 0
    for c in combinations(lines, 3):
        if len(set(c)) != 3:
            continue
        if max(c) < sum(c)-max(c):
            count += 1
    print(count)
resolve()

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 max(max(l[i],l[j]) ,l[k]) < l[i]+l[j]+l[k] - max(max(l[i],l[j]) ,l[k]):
             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):
    for k in range(j):
      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]):
        cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
L_list = list(map(int,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 = L_list[i]
            b = L_list[j]
            c = L_list[k]
            if a==b or b==c or c==a or a+b<=c or b+c<=a or c+a<=b:
                continue
            counter += 1


print(counter)

Submission status: Accepted

Solution code:
n = int(input())
l = [int(v) for v in input().split()]
pairs = 0
for i in range(len(l)):
    for j in range(i + 1, len(l)):
        for k in range(j + 1, len(l)):
            a = l[i]
            b = l[j]
            c = l[k]
            if a == b or b == c or c == a:
                continue
            else:
                if a + b <= c or b + c <= a or c + a <= b:
                    continue
                else:
                    pairs += 1
print(pairs)

Submission status: Accepted

Solution code:
n = int(input())
lis = list(map(int,input().split()))
#print(n,lis)  

num = 0
for i in range(n):
  for j in range(n):
    for k in range(n):
      a = lis[i]
      b = lis[j]
      c = lis[k]
      if a == b or b ==c or c==a:
        continue
      else:
        if a >= b + c or b >= a + c or c >= b + a:
          continue
        else:
          num += 1
print(int(num/6))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int,input().split()))
print(sum([1 if not(L[i]==L[j] or L[i]==L[k] or L[j]==L[k]) and L[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[j]+L[k] > L[i] else 0 for i in range(0,n) for j in range(i+1,n) for k in range(j+1,n)]))

Submission status: Accepted

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

for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if (st[i] != st[j] != st[k]) and (st[i] < st[j] + st[k]):
        count += 1
        
print(count)

Submission status: Accepted

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

L.sort(reverse = True)
i = j = k = 0
cnt = 0

while i<len(L)-2:
    j = i + 1
    while j<len(L)-1:
        k = j + 1
        if L[i] != L[j]:
            while k<len(L):
                if L[j] != L[k] and L[i] < L[j] + L[k]:
                    cnt += 1
                k += 1
        j += 1
    i += 1

print(cnt)

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

Submission status: Accepted

Solution code:

def main():
    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):
                l1 = L[i]
                l2 = L[j]
                l3 = L[k]
                l_max = max(l1, l2, l3)
                if l1 == l2 or l2 == l3 or l3 == l1:
                    continue
                if (l1+l2+l3) - l_max <= l_max:
                    continue
                cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# B
n = int(input())
l = list(map(int, input().split()))
l.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 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())
l = list(map(int, input().split()))
count = 0
c_list = list(itertools.combinations(l, 3))

for c in c_list:
    if (c[0]+c[1])>c[2] and (c[1]+c[2])>c[0] and (c[2]+c[0])>c[1]:
        if len(set(c)) == 3:
            count += 1

print(count)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int, input().split()))    
count = 0
ind_list = list(itertools.combinations(range(0,n), 3))

for ind in ind_list:
    if (l[ind[0]]+l[ind[1]])>l[ind[2]] and (l[ind[1]]+l[ind[2]])>l[ind[0]] and (l[ind[2]]+l[ind[0]])>l[ind[1]]:
        if l[ind[0]]!=l[ind[1]] and l[ind[0]]!=l[ind[2]] and l[ind[1]]!=l[ind[2]]:
            count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
L = sorted(map(int,input().split()))
ans = 0

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

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

Submission status: Accepted

Solution code:
def resolve():
    from itertools import combinations
    n = int(input())
    l = list(map(int, input().split()))
    ans = 0
    if n < 3:
        print(0)
        return

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

    print(ans)

resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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] != 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()))
count=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            L2=[L[i],L[j],L[k]]
            L2.sort()
            if L2[0]+L2[1]>L2[2] and L2[0] != L2[1] and L2[1] != L2[2] and L2[2] != L2[0]:
                count+=1
                
print(count)

Submission status: Accepted

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

ans = 0
for i1 in range(N):
    for i2 in range(i1, N):
        for i3 in range(i2, N):
            l1 = L[i1]
            l2 = L[i2]
            l3 = L[i3]
            if l1 != l2 and l2 != l3 and l3 != l1:
                if l1 < l2 + l3 and l2 < l3 + l1 and l3 < l1 + l2:
                    ans += 1

print(ans)

Submission status: Accepted

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

N = int(input().split()[0])
l_list = list(map(int, input().split()))

p_gen = itertools.combinations(range(len(l_list)), 3)
tri_list = []
for pattern in p_gen:
    i, j, k = sorted(list(pattern))
    w_list = sorted([l_list[i], l_list[j], l_list[k]])
    if len(set(w_list)) == 3:
        if w_list[2] < w_list[0] + w_list[1]:
            tri_list.append((i, j, k))
ans = len(tri_list)
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
count=0
for a in range(N):
    for b in range(N):
        for c in range(N):
            if L[a]<(L[b]+L[c]) and L[b]<(L[a]+L[c]) and L[c]<(L[b]+L[a]) and L[a]!=L[b] and L[a]!=L[c] and L[c]!=L[b] and a<b<c:
                count=count+1
            else:
                continue
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):
      sum_ = sum([l[i], l[j], l[k]])
      max_ = max([l[i], l[j], l[k]])
      if l[i] != l[j] and l[i] != l[k] and l[j] != l[k] and (sum_ - max_) > max_:
        cnt += 1
print(cnt)

Submission status: Accepted

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

c = 0
h = set([])

for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      t = [arr[i], arr[j],arr[k]]
      t.sort()
      if t[0] + t[1] > t[2]:
        if t[0]!=t[1]!=t[2]:#if (i,j,k) not in h:
          h.add((i,j,k))
          c+=1
        
print(c)

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 len(list(set([L[i], L[j], L[k]]))) < 3:
                continue
            if L[i] + L[j] <= L[k]:
                continue
            ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def solve(s, count, i, p):
    if count == 3:
        p = list(p.split(":"))
        if int(p[0]) + int(p[1]) > int(p[2]) and int(p[1]) + int(p[2]) > int(p[0]) and int(p[0]) + int(p[2]) > int(p[1]) :
            return 1
        else:
            return 0

    if i == len(s):
        return 0

    if s[i] in p:
        return solve(s, count, i + 1, p)
    else:
        return solve(s, count + 1, i + 1, p + s[i] + ":") + solve(s, count, i + 1, p)


n = int(input())
l = list(input().strip().split(" "))
q = ""
print(solve(l, 0, 0, q))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
  for j in range(N):
    for k in range(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()))
w = list(set(l))
r = {w[i]:0 for i in range(len(w))}
for i in range(n):
    r[l[i]] += 1
t = list(r.items())
ans = 0
for i in range(len(t)-2):
    for j in range(i+1, len(t)-1):
        for k in range(j+1, len(t)):
            y = sum([t[i][0], t[j][0], t[k][0]])
            x = max([t[i][0], t[j][0], t[k][0]])
            if 2*x < y:
                ans += t[i][1] * t[j][1] * t[k][1]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
r = {l[i]:0 for i in range(n)}
for i in range(n):
    r[l[i]] += 1
t = list(r.items())
ans = 0
for i in range(len(t)-2):
    for j in range(i+1, len(t)-1):
        for k in range(j+1, len(t)):
            y = sum([t[i][0], t[j][0], t[k][0]])
            x = max([t[i][0], t[j][0], t[k][0]])
            if 2*x < y:
                ans += t[i][1] * t[j][1] * t[k][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] > A[k] and A[i] != A[j] and A[j] != A[k] and A[k] != A[i]:
                ans += 1
print(ans)

Submission status: Accepted

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

if N <= 2:
    print(0)
    exit()
    
count = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            rod = [L[i], L[j], L[k]]
            condition = set(rod)
            rod = sorted(rod)
            if rod[0] + rod[1] > rod[2] and len(condition) == 3:
                count += 1
                
print(count)

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):
      num=[l[i],l[j],l[k]]
      if len(set(num))!=3:continue
      num.sort()
      if num[2]<num[1]+num[0]: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(N):
    for k in range(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 // 6)

Submission status: Accepted

Solution code:
N, L = int(input()), [int(v) for v in input().split()]
L.sort()
ans = 0
for i in range(N):
    for j in range(i):
        for k in range(j):
            if L[k] != L[j] and L[j] != L[i] 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()]
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]:
            if L[a]+L[b] > L[c] and L[b]+L[c] > L[a] and L[c]+L[a] > L[b]:
              cnt += 1
print(cnt)

Submission status: Accepted

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

def judge_tri(a, b, c):
    if a+b>c and b+c>a and c+a>b:
        return True
    else:
        return False

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

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

print(cnt)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

n = readInt()
arr = readIntList()
if len(arr) < 3:
    print("0")
    exit()
arr.sort()
count = 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
            if arr[i] + arr[j] > arr[k]:
                count += 1
print(count)

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

print(ans)

Submission status: Accepted

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

cnt = 0
for a,b,c in itertools.combinations(l,3):
    if abs(a-b) < c < a+b and a != b and b != c and a != c:
        cnt += 1

print(cnt)

Submission status: Accepted

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

cnt = 0
for a,b,c in itertools.combinations(l,3):
    if abs(a-b) < c < a+b and len(set([a,b,c])) == 3:
        cnt += 1

print(cnt)

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:
k = int(input())

an = input().split()

for i in range(len(an)):
    an[i] = int(an[i])

ln = sorted(an)

ans = 0

for i in range(k):
    for j in range(i,k):    
        for l in range(j,k):
            a1 = int(ln[i])
            a2 = int(ln[j])
            a3 = int(ln[l])
            if a1!=a2 and a2 != a3:
                m = a1 + a2
                if a3 < m:
                    ans += 1

print(ans)

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 abs(a-b) < c < a+b and len(set([a,b,c])) == 3:
        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(len(L)):
    a=L[i]
    for j in range(i+1,len(L)):
        if L[j]!=a:
            b=L[j]
            for k in range(j+1,len(L)):
                if L[k]!=b:
                    if a+b>L[k]:
                        ans+=1
                    else:
                        break
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[j] == L[k] or L[k] == L[i]:
                    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,*l=map(int,open(0).read().split())
print(sum(i<j<k<i+j for i in l for j in l for k in l))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if n <= 2:
    print(0)
else:

    for i in range(0,n-2):
        for h in range(i+1,n-1):
            for j in range(h+1,n):
                if (abs(p[i]-p[h]) < p[j] < p[i]+p[h]) and (p[i] != p[h] and p[h] != p[j] and p[j] != p[i]):

                    count += 1

    print(count)

Submission status: Accepted

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

ans = 0
if N<=2:
  print(0)
  exit()
for i1 in range(N-2):
  l1 = L[i1]
  for i2 in range(i1+1,N-1):
    l2 = L[i2]
    for i3 in range(i2+1,N):
      l3 = L[i3]
      if l1==l2 or l2==l3 or l3==l1: continue
      tmp = sorted([l1,l2,l3])
      if tmp[0]+tmp[1]>tmp[2]:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = 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 A[i] != A[j] and A[j] != A[k] and A[k] != A[i] and (A[i] + A[j]>A[k]) and (A[j] + A[k]>A[i]) and (A[k] + A[i]>A[j]):
        count = count + 1

print(count)

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] and l[j] + l[i] > l[k]:
         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)):
	for j in range(len(l)):
		for k in range(len(l)):
			if i < j and j < k \
			and l[i] != l[j] \
			and l[j] != l[k] \
			and l[i] != l[k] \
			and l[i]+l[j]+l[k] > 2*max(l[i], l[j], l[k]):
				count += 1
print(count)

Submission status: Accepted

Solution code:
from itertools import combinations

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

ans = 0

for a,b,c in combinations(L, 3):
    ans += a < b < c < a+b

print(ans)

Submission status: Accepted

Solution code:
import itertools

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

L.sort(reverse = True)
li = list(itertools.combinations(L, 3))

ans = 0
for v in li:
    if v[0] != v[1] and v[1] != v[2] and v[0] - v[1] < v[2]:
        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(i+1,n):
    for k in range(j+1,n):
      if L[i]!=L[j]!=L[k]:
        if L[j]+L[i]>L[k]:
         ans+=1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
arr = list(map(int, input().split()))
res = 0
for ii, i in enumerate(arr):
    for jj, j in enumerate(arr):
        for kk, k in enumerate(arr):
            if ii < jj < kk and i != j and j != k and k != i:
                if i + j > k and j + k > i and k + i > j:
                    res += 1
print(res)

Submission status: Accepted

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

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

print(N_tri)

Submission status: Accepted

Solution code:
def triangle(N, Ls):
  result = 0
  res = []
  numbers = {}
  edgeLength = list(set(Ls))
  for i in edgeLength:
    numbers[i] = Ls.count(i)
  for i in range(len(edgeLength)):
    a = edgeLength[i]   
    copy1 = edgeLength[i+1:]
    for j in range(len(copy1)):
      b = copy1[j]
      copy2 = copy1[j+1:]
      for k in range(len(copy2)):
        c = copy2[k]
        if a + b > c and b + c > a and c + a > b:
          res.append([a, b, c])
  for val in res:
    result += numbers[val[0]] * numbers[val[1]] * numbers[val[2]]
  return result




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

Submission status: Accepted

Solution code:
def ifTriangle(v):
    largest = max(v)
    smallers_sum = 0
    for x in v:
        if not x == largest:
            smallers_sum += x
    if smallers_sum > largest:
        return True
    return False


N = int(input())
L = [int(x) for x in input().split()]
L.sort()
L.reverse()

count = 0
before_i = -1
before_j = -1
before_k = -1
for i in range(N-2):
    for j in range(i+1, N-1):
        if L[j] == L[i]:
            continue
        if L[i]/2 >= L[j]:
            break
        for k in range(j+1, N):
            if L[k] == L[j]:
                continue
            if ifTriangle([L[i], L[j], L[k]]):
                count += 1
print(count)

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
n=int(input())
l=[int(i) for i in input().split()]
 
l.sort()
 
def func(one,two,three):
  if len({one,two,three})==3 and one+two>three:
    return True
  return False
 
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      one=l[i]
      two=l[j]
      three=l[k]
      if func(one,two,three):
        ans+=1
        
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
L = sorted(list(map(int,input().split())),reverse = True)
ans = 0
for i in L:
    for j in L:
        for k in L:
            if i<j<k:
                if i + j>k:
                    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
from sys import stdin


N = int(stdin.readline().rstrip())

L = [ int(x) for x in stdin.readline().rstrip().split()]

count = 0

for i in range(N):
    A = L.pop()
    Ln = copy.copy(L)
    for j in range(len(Ln)):
          B = Ln.pop()
          Lm = copy.copy(Ln)
          for k in Lm:
              C = k
              if ( A != B ) and ( B != C ) and ( C != A ) and ( A + B > C ) and ( B + C > A ) and ( C + A > B ):
                    count+=1
              
          

print(count)

Submission status: Accepted

Solution code:
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0
for i in L:
    for j in L:
        for k in L:
            if i < j < k:
                if i + j + k > max(i,j,k) * 2:
                    ans += 1
else:
    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(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)