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:
# 4?
x = int(input())
lis = list(map(int, input().split()))
count = 0

for i in range(x):
  mag=lis[i]
  for s in range(x):
    len=lis[s]
    for t in range(x):
        pas=lis[t]
        if pas == len or len == mag or mag == pas:
            count=count
        elif abs(pas-mag)<len<pas+mag:
            count = count+1
        else:
            count = count

#print(count)
ans = int(count/6)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
count = 0
def make_sankaku(san):
    if san[0] == san[1] or san[1] == san[2] or san[2] == san[0]:
        return False
    else:
        san.sort()
        if san[2] - san[0] >= san[1]:
            return False
    return True
All_a = []
if len(A) <3:
    count = 0
else:
    for i in range(len(A)):
        for k in range(i+1, len(A)):
            for l in range(k + 1 ,len(A)):
                if make_sankaku([A[i], A[k], A[l]]):
                    if [A[i], A[k], A[l]] not in All_a:
                        count += 1
print(count)

Submission status: Accepted

Solution code:
import itertools

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

def has_duplicates(seq):
    return len(seq) != len(set(seq))


for pair in itertools.combinations(L, 3):
    # print(list(pair))
    if has_duplicates(pair) == False:

        if (pair[0] + pair[1] > pair[2]) and (pair[1] + pair[2]) > pair[0] \
                and (pair[2] + pair[0] > pair[1]):
            count += 1





print(count)

Submission status: Accepted

Solution code:
import itertools
n=int(input())
seq=list(map(int,input().split()))
ans=0
for li in list(itertools.combinations(seq,3)):
  if(li[0]+li[1]>li[2] and li[1]+li[2]>li[0] and li[0]+li[2]>li[1]):
    if(li[0]!=li[1] and li[1]!=li[2] and li[0]!=li[2]):
      ans+=1

print(ans)

Submission status: Accepted

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

if n < 3:
  print(0)
else:
  cnt = 0
  for i in range(n-2):
    for s in range(i+1,n-1):
      for t in range(s+1,n):
        x = int(l[i])
        y = int(l[s])
        z = int(l[t])
        if x != y and x != z and y != z:
          #print(l[i],l[s],l[t])
          if x > y and x > z and x < (y+z):
            cnt += 1
          elif y > x and y > z and y < (x+z):
            cnt += 1
          elif z > x and z > y and z < (x+y):
            cnt += 1
  print(cnt)

Submission status: Accepted

Solution code:
from sys import stdin
import itertools

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

tmp = set()
cnt = 0
for s in itertools.combinations(L, 3):
    a = s[0]
    b = s[1]
    c = s[2]
    if a+b > c and b+c > a and c+a > b:
        if a != b and b != c and a != c:
            cnt = cnt + 1

print(cnt)

Submission status: Accepted

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

ans = 0
for i in range(0, len(ls)):
  for j in range(i+1, len(ls)):
    for k in range(j+1, len(ls)): 
      length = ls[i] + ls[j] + ls[k]
      if length - 2 * max(ls[i], ls[j], ls[k]) > 0:
        ans += l.count(ls[i]) * l.count(ls[j]) * l.count(ls[k])
        
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int, input().split()))
Ls = set(L)
Lslist = list(Ls)
LsSortlist = sorted(Lslist)
LSl = LsSortlist
tc = 0
for i in range(len(LSl)):
  L1 = LSl[i]
  for j in range(i + 1, len(LSl)):
    L2 = LSl[j]
    MinL = L2 - L1
    MaxL = L2 + L1
    for k in range(j + 1, len(LSl)):
      L3 = LSl[k]
      if MinL >= L3:
        continue
      elif L3 >= MaxL:
        break
      else:
        tc += L.count(L1) * L.count(L2) * L.count(L3)
if n < 3:
  print(0)
else:
  print(tc)

Submission status: Accepted

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

count = 0
for i in range(N):
  a1 = i+1
  if a1 > N:
    break
  for j in range(N):
    a2 = a1 + j + 1
    if a2 > N:
      break
    for k in range(N):
      a3 = a2 + k + 1
      if a3 > N:
        break
      a = [L[a1-1],L[a2-1],L[a3-1]]
      a.sort()
      if a[0] != a[1] and a[1] != a[2]:
        if a[0]+a[1] > a[2]:
          count = count + 1
        else:
          None
      else:
        None
print(count)

Submission status: Accepted

Solution code:
import numpy
import itertools

if __name__ == "__main__":
  N = int(input())
  L = [int(a) for a in input().split()]
  cnt = 0
  L_comb = list(itertools.combinations(L, 3))
  for i in L_comb:
    if len(set(i)) <= 2:
      continue
    i = numpy.asarray(i)
    max_index = numpy.argmax(i)
    if i[max_index] < sum(i) - i[max_index]:
      cnt += 1
    else:
      pass   
  print(cnt)

Submission status: Accepted

Solution code:
import itertools
N=int(input())
l=list(map(int,input().split()))
ctn=0
for c  in itertools.combinations(l, 3):
    if len(c)==len(set(c)):
        if sorted(c)[0]+sorted(c)[1]-sorted(c)[2]>0:
            ctn+=1
print(ctn)

Submission status: Accepted

Solution code:
a = int(input())#整数
x = list(map(int, input().split()))#配列Int型

ans = 0

for i in range(a):
    for j in range(1, a):
        for k in range(2, a):
            if x[i] == x[j] or x[i] == x[k] or x[j] == x[k]:
                continue
            if i > j or i > k or j > k:
                continue
            res = x[i] - x[j]
            res *= -1 if res < 0 else 1
            if res < x[k] and x[k] < (x[i] + x[j]):
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
num_list =[]
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]:
        num_list.append(L[i])
        num_list.append(L[j])
        num_list.append(L[k])
        num_list.sort()
        if num_list[0]+num_list[1] > num_list[2]:
          ans += 1
          num_list.clear()
        else:
          num_list.clear()
print(int(ans/6))

Submission status: Accepted

Solution code:
N = int(input())
Lall = input()
L_l = Lall.split()
L_l_spl = [int(n) for n in L_l]
L = sorted(L_l_spl)
c=0
for x in range(N-2):
  for y in range(x+1,N-1):
    if L[x] == L[y]:
      pass
    else:
      for z in range(y+1,N):
        if L[z] == L[y]:
          pass
        else:
          xy = L[x] + L[y]
          zint = L[z]
          if zint < xy:
            c = c + 1
print(c)

Submission status: Accepted

Solution code:
#-------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# ------------------- fast io --------------------

from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[j - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] =  j
    return pi

def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)

def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else '0' * (length - len(y)) + y

def solve(N, A):
    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[i] != A[k] and A[j] != A[k] and A[i] + A[j] > A[k] and A[i] + A[k] > A[j] and A[k] + A[j] > A[i]:
                    #print(A[i], A[j], A[k])
                    ans += 1
    return ans

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

print(solve(N, A))

Submission status: Accepted

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

import collections
c = collections.Counter(ls)

Ls = list(set(ls))
Ls.sort()

if len(Ls) < 3:
  print(0)
else:
  ans = 0
  LsR = sorted(Ls)
  while len(LsR) >= 3:
    L1 = LsR[0]
    Ls1 = LsR[1:]
    while len(Ls1) >= 2:
      L2 = Ls1[0]
      Ls2 = Ls1[1:]
      for L3 in Ls2:
        if L3 < L1 + L2 and L3 > abs(L1-L2):
          ans += c[L1] * c[L2] * c[L3]
      Ls1 = Ls1[1:]
    LsR = LsR[1:]
  print(ans)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
l = sorted(map(int,input().split()))
ans = 0
li =  []
c = 0
for team in itertools.combinations(l, 3):
    li.append(list(team))
    c  += 1
sum = 0
for i in range(c):
    if li[i][0] != li[i][1] and li[i][1] != li[i][2] and li[i][2] != li[i][0]:
        if li[i][0] + li[i][1] > li[i][2]:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:

import itertools
N = int(input())
L = input().split()
L = [int(i) for i in L]
count = 0
if(len(L) > 2):
  for comb in itertools.combinations(L, 3):
    comb = list(comb)
    if(len(set(comb))==3):
      if(comb[0]+comb[1] > comb[2]):
        if(comb[1]+comb[2] > comb[0]):
          	if(comb[2]+comb[0] > comb[1]):
          		count += 1
print(count)

Submission status: Accepted

Solution code:

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

count = 0

for i  in range(0, N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            box = [A[i], A[j], A[k]]
            if len(box) == len(set(box)):
            	if (A[i] + A[j] > A[k]) and (A[j] + A[k] > A[i]) and (A[i] + A[k] > A[j]):
                	count += 1

print(count)

Submission status: Accepted

Solution code:
n=int(input())
l=[int(i) for i in input().split()]
cou=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]:
        a=max(l[i],l[j],l[k])
        if a<l[i]+l[j]+l[k]-a:
          cou+=1
print(cou)

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
def findNumberOfTriangles(arr, n):
    count = 0
    ans = []
    for i in range(n):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                if (arr[i] + arr[j] > arr[k] and
                    arr[i] + arr[k] > arr[j] and
                    arr[k] + arr[j] > arr[i]):
                    if len(set([arr[i], arr[j], arr[k]]))==3:
                        count += 1


    return count

n = int(input())
arr = [int(x) for x in input().split()]
print(findNumberOfTriangles(arr, n))

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

Submission status: Accepted

Solution code:
n = int(input())
l = input()
a = l.split(' ')
new_l = []
countl = 0

for i in range(n):
    new_l.append(int(a[i]))

new_l.sort()

for i in range(n):
    for j in range(i+1,n-i):
        if(new_l[i]==new_l[j]):
            countl += 1

count = 0

for i in range(n): # i=0-5
    for j in range(i+1, n): # j=i+1 to 4-i
        for k in range(j+1, n): # k=i+j
            if(new_l[i] + new_l[j] > new_l[k]):
                if(new_l[i]!=new_l[j] and new_l[j]!=new_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(i + 1, N):
        for k in range(j + 1, N):
            if not (L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]):
                continue
            if not(L[i] != L[j] and L[j] != L[k] and L[k] != L[i]):
                continue
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
  
n = int(input())
l = list(map(int, input().split()))
index_list = [i for i in range(n)]

def is_triangle(a, b, c):
    if a + b <= c:
        return False
    if b + c <= a:
        return False
    if c + a <= b:
        return False
    if abs(a - b) >= c:
        return False
    if abs(b - c) >= a:
        return False
    if abs(c - a) >= b:
        return False
    return True

ans = 0
for i1, i2, i3 in itertools.permutations(index_list, 3):
#   print(f"{a} {b} {c}")
    if l[i1] != l[i2] and l[i2] != l[i3] and l[i1] != l[i3]:
    # if len(set(l[i1], l[i2], l[i3])) == 3:
        if i1 < i2 < i3:
            if is_triangle(l[i1], l[i2], l[i3]):
                # print(f"{i1 + 1} {i2 + 1} {i3 + 1}")
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools

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

unqL = list(set(L))
Lnums = {}
for l in unqL:
    Lnums[l] = L.count(l)

cnt = 0    
for cmb in itertools.combinations(unqL, 3):
    cmb = sorted(cmb)
    l1, l2, lmax = cmb    
    if l1 + l2 > lmax:
        cnt += Lnums[l1] * Lnums[l2] * Lnums[lmax]
    
print(cnt)

Submission status: Accepted

Solution code:
def second_smallest(numbers):
    m1, m2 = float('inf'), float('inf')
    for x in numbers:
        if x <= m1:
            m1, m2 = x, m1
        elif x < m2:
            m2 = x
    return m2

count=0
N = int(input())
L = list(map(int, input().split()))
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[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
                if max(L[i], L[j], L[k]) < second_smallest([L[i], L[j], L[k]])+min(L[i], L[j], L[k]):
                    count=count+1
                    
print(count)

Submission status: Accepted

Solution code:
import numpy as np
num = int(input())
data = list(map(int ,input().split()))
count =0
for i in range(num):
  for j in range(num-1):

    if (i>j):
      continue
    for k in range(num-2):
    
      if (j>k):
        continue
      datalist = [data[i],data[j+1],data[k+2]]
      max_i=np.argmax(datalist)
      
      if(datalist[max_i]<(datalist[(max_i+1)%3]+datalist[(max_i+2)%3])and not datalist[0]==datalist[1] and not datalist[1]==datalist[2] and not datalist[2]==datalist[0]):
        
        count +=1
      
      
print(count)

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    l = list(map(int, input().split()))
    ll = len(l)
    ans = 0

    for i in range(ll):
        for j in range(i+1, ll):
            for k in range(j+1, ll):
                if len(set([l[i], l[j], l[k]])) != 3:
                    continue
                item = [l[i], l[j], l[k]]
                if max(item) < sum(item) - max(item):
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import combinations as comb


def main():
    n = int(input())
    ls = list(map(int, input().split()))
    ls_count = Counter(ls)
    ls_keys = list(ls_count.keys())
    m = len(ls_keys)
    ans = 0
    for i in range(m-2):
        c = ls_keys[i]
        pairs = list(comb(ls_keys[(i+1):], 2))
        for a, b in pairs:
            if c + a > b and a + b > c and b + c > a:
                ans += ls_count[c] * ls_count[a] * ls_count[b]
    print(ans)


if __name__ == "__main__":
    main()

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

print(ans)

Submission status: Accepted

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

ans = 0
if len(L) <= 2 :
    print(ans)
else:
    for lists in itertools.combinations(L,3):
        if sum(lists) - max(lists) > max(lists):
            if len(lists) != len(set(lists)):
                continue
            else:
                ans += 1


        else:
            continue
    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):
        ##print(str(i)+" "+str(j)+" "+str(k))
        if (L[i]+L[j])>L[k] and abs(L[i]-L[j])<L[k] and L[i]!=L[j] and L[j]!=L[k] and L[i]!=L[k]:
          ##print(str(L[i])+" "+str(L[j])+" "+str(L[k]))
          count+=1

print(str(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):
        if L[i] != L[j]:
            for k in range(j + 1, n):
                if not(L[i] == L[k] or L[j] == L[k]):
                    a, b, c = sorted([L[i], L[j], L[k]])
                    if c < a + b:
                        ans += 1
print(ans)

Submission status: Accepted

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

nums = set([])
for i in range(n):
    for j in range(n):
        for k in range(n):
            if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]:
                continue
            else:
                ver = [l[i],l[j],l[k]]
                num = [i,j,k]
                ver.sort()
                num.sort()
                if ver[0] + ver[1] > ver[2]:
                    nums.add(tuple(num))

print(len(nums))

Submission status: Accepted

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

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

L.sort()

cnt = 0
comb = []
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(i+2,N):
      if L[i] < L[j] < L[k] :
        comb.append([L[i],L[j],L[k]])
        
for i in range(len(comb)):
  X = comb[i][0] + comb[i][1]
  if X > comb[i][2]:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
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-1):
    for k in range(j+1,n):
      if l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[j]+l[k]>l[i]:
        if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
   	      count += 1
print(count)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]


N = int(input())
L = [int(i) for i in input().split()]
L.sort()
SL = set(L)
ans = 0

if(len(SL)<3):
    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]):
                    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()))
if n <= 2:
    print(0)
    quit()
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            a = sorted([l[i],l[j],l[k]])
            if len(set(a)) != 3:
                continue
            if a[0]+a[1] > a[2]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i,j,k in combinations(l, 3):
  if i != j and j != k and i != k and i+j > k and i+k > j and j+k > i: ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

def judge(arg1,arg2,arg3):
    if arg1 == arg2 or arg1 == arg3 or arg3 == arg2:
        return 0
    elif arg1 + arg2 > arg3 and arg2 + arg3 > arg1 and arg1 + arg3 > arg2:
        return 1
    else:
        return 0
# for i in range(N):
#     for j in range(N):
#         for k in range(N):
#             if i == j or j == k or i == k:
#                 pass
#             elif L[i] + L[j] >= L[k] or L[j] + L[k] >= L[i] or L[i] + L[k] >= L[j]:
#                 cnt += 1

for pairs in itertools.combinations(L,3):
    if judge(*pairs):
        cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# input here
_INPUT = """\
5
4 4 9 7 5
"""

def main():
    N = int(input())
    sido = list(map(int, input().split()))
    triangle = list(itertools.combinations(sido, 3))
    #print(triangle)

    # 三角形の成立条件
    j = 0
    for i in range(len(triangle)):
        if len(triangle[i]) != len(set(triangle[i])):
            continue

        if ((triangle[i][0] + triangle[i][1] > triangle[i][2])
           & (triangle[i][1] + triangle[i][2] > triangle[i][0])
           & (triangle[i][0] + triangle[i][2] > triangle[i][1])):
           j += 1
           #print(triangle[i])
    print(j)


if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools

    # sys.stdin = io.StringIO(_INPUT)
    main()

Submission status: Accepted

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

i = 0
while i < n - 2:
  j = i + 1
  while j < n - 1:
    k = j + 1
    while k < n:
      d = ls[i] + ls[j] + ls[k]
      mx = max(ls[i], max(ls[j], ls[k]))
      if ls[i] == ls[j] or ls[j] == ls[k] or ls[k] == ls[i]:
        k += 1
        continue
      if mx < d - mx:
        ans += 1
        # print(ls[i], ls[j], ls[k])
      k += 1
    j += 1
  i += 1

print(ans)

Submission status: Accepted

Solution code:
import itertools
import math
n=int(input())
l=list(map(int,input().split()))
if len(l)<=2:
    print('0')
else:
    c = list(itertools.combinations(l, 3))
    count=0
    r=math.factorial(len(l)) // (math.factorial(len(l) - 3) * 6)
    for i in range(r):
        if c[i][0]==c[i][1] or c[i][1]==c[i][2] or c[i][2]==c[i][0]:
            pass
        else:
            if c[i][0]+c[i][1]>c[i][2] and c[i][1]+c[i][2]>c[i][0] and c[i][2]+c[i][0]>c[i][1]:
                count+=1
            else:
                pass
    print(count)

Submission status: Accepted

Solution code:
import itertools
N = int(input())
N_List =list(map(int,input().split()))
cnt = 0
for pairs in itertools.permutations(N_List, 3):
    if len(set(pairs)) == 3:
        if list(pairs) == sorted(list(pairs)):
            a = list(pairs)
            if a[0] + a[1] > a[2]:
                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):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue
            hens = []
            hens.append(l[i])
            hens.append(l[j])
            hens.append(l[k])
            hens.sort()
            if hens[0] + hens[1] > hens[2]:
                cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
s=int(input())
a=list(map(int, input().split()))
count=0
a.sort()
#print(a)
for i in range(s):
  for j in range(i+1,s):
    for k in range(j+1,s):
      #print('tttt',i,j,k,a[i],a[j],a[k])
      if a[i]==a[j]: continue
      if a[j]==a[k]: continue
      if a[k]==a[i]: continue

     
      ij = a[i]+a[j]
      jk = a[j]+a[k]
      ki = a[k]+a[i]
      #print(ij,jk,ki)
      #print(a[i b],a[j],a[k])
      if (ij > a[k]) and (jk > a[i])and (ki > a[j]):
        #print(i,j,k,a[i],a[j],a[k])
        count +=1
print(count)

Submission status: Accepted

Solution code:
import itertools

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

#l = list(set(L))

cnt = 0

for x in itertools.combinations(L, 3):
    if x[0]==x[1] or x[1]==x[2] or x[0]==x[2]:
        continue

    if x[0]+x[1] < x[2]:
        continue
    if x[1]+x[2] < x[0]:
        continue
    if x[0]+x[2] < x[1]:
        continue

    if x[0] > x[1]:
        if x[0]-x[1] >= x[2]:
            continue
    else:
        if x[1]-x[0] >= x[2]:
            continue
        
    if x[1] > x[2]:
        if x[1]-x[2] >= x[0]:
            continue
    else:
        if x[2]-x[1] >= x[0]:
            continue

    if x[0] > x[2]:
        if x[0]-x[2] >= x[1]:
            continue
    else:
        if x[2]-x[0] >= x[1]:
            continue
    
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import itertools

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

L = []

for i in itertools.combinations(l, 3):
    if len(set(i)) == 3 and (i[0]+i[1] > i[2]) and (i[1]+i[2] > i[0]) and (i[2]+i[0] > i[1]):
        L.append(i)

print(len(L))

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = [0 for _ in range(n)]
l = [int(s) for s in input().split()]




def solve(l_list):
    l_list = list(l_list)
    l_list.sort()
    #print(l_list)
    l1 = l_list[0]
    l2 = l_list[1]
    l3 = l_list[2]
    if(l1 + l2 <=l3 or l1 == l2 or l1 == l3 or l3 == l2):
        #print(l_list)
        return 0
    else:
        return 1
if(n < 3):
    print(0)
else:
    l_koho = list(itertools.combinations(l,3))
    #print(l_koho)
    cnt = 0
    for x in l_koho:
        #print(x)
        cnt += solve(x)

    print(cnt)

Submission status: Accepted

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

counter = 0
L = sorted(L,reverse=True)
#print(L)

first = 0

while first < len(L) - 2:
  second = first + 1
  while second < len(L) - 1:
    third = second + 1
    while third < len(L):
      if first != second and first != third and second != third:
        if L[first] != L[second] and L[second] != L[third] and L[first] < L[second]+L[third]:
          counter += 1
          #print(L[first],L[second],L[third])
      third += 1
    second += 1
  first += 1

print(counter)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L_list = list(map(int, input().split()))
c = 0
if len(L_list) < 3:
    print(c)
else:
    for i in range(N):
        for j in range(i,N):
            for k in range(j,N):
                if L_list[i] == L_list[j] or L_list[i] == L_list[k] or L_list[j] == L_list[k]:
                    continue
                else:
                    n1 = L_list[i]
                    n2 = L_list[j]
                    n3 = L_list[k]                   
                    if n1 + n2 > n3 and n1 + n3 > n2 and n3 + n2 > n1:
                        c += 1
    print(c)