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()))
a = sorted(l)

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

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
count = 0
l.sort()

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

print(count)

Submission status: Accepted

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

counter = 0

import itertools
for v in itertools.combinations(l, 3):
  t = sorted(v, reverse=False)
  if (t[0]!=t[1])&(t[0]!=t[2])&(t[1]!=t[2])&((t[0]+t[1]) > t[2]):
    counter+=1

print(counter)

Submission status: Accepted

Solution code:
from itertools import combinations
N = int(input())
L = list(map(int, input().split()))
ans = 0
for l in combinations(L, 3):
    a = l[0]
    b = l[1]
    c = l[2]
    if a == b or b == c or c == a:
        continue
    if a + b > c and b + c > a and c + a > b:
        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-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]:
                    ans += 1

print(ans)

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key
from bisect import bisect_left


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


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

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

def bindex(a,x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return i
    return None

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    N = intinput()
    indatas = list(mulinputs())

    ans = set([])
    for i in range(0,N):
        for j in range(i+1,N):
            for k in range(j+1,N):
                l0 = indatas[i]
                l1 = indatas[j]
                l2 = indatas[k]
                if l0 == l1:
                    continue
                if l0 == l2:
                    continue
                if l1 == l2:
                    continue
                if l0 < l1 + l2 and l1 < l0 + l2 and l2 < l0 + l1:
                    ans.add(tuple(sorted([i,j,k])))

    # 出力
    print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

readline = sys.stdin.readline
read = sys.stdin.read


n = int(input())
l = np.array(readline().split(), dtype=np.int64)
l, c = np.unique(l, return_counts=True)
x = len(l)
ans = 0
for i in range(x-2):
    for j in range(i+1, x-1):
        for k in range(j+1, x):
            if l[i] + l[j] > l[k] :
                ans += c[i] * c[j] * c[k]
print(ans)

Submission status: Accepted

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

for i in range(n):
    if l[i] not in num_map:
        num_map[l[i]] = 1
    else:
        num_map[l[i]] += 1

num_list = sorted(list(num_map.keys()))
m = len(num_list)
res = 0
for i in range(m - 2):
    for j in range(i + 1, m - 1):
        for k in range(j + 1, m):
            if num_list[i] + num_list[j] > num_list[k]:
                res += num_map[num_list[i]] * num_map[num_list[j]] * num_map[num_list[k]]
print(res)

Submission status: Accepted

Solution code:
import sys
from itertools import combinations


def resolve(in_):
    N = int(next(in_))
    L = list(map(int, next(in_).split()))
    L.sort()

    ans = 0
    for i, j, k in combinations(L, 3):
        if not (i < j < k):
            continue
        if i + j > k and j + k > i and k + i > j:
            ans += 1
    return ans

def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

Solution code:


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

L.sort(reverse=True)

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

Submission status: Accepted

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

L.sort()

c = 0

for i in range(len(L)-2):
    for j in range(i+1,len(L)-1):
        for k in range(j+1,len(L)):
            if L[i]==L[j] or L[j]==L[k]:
                continue
            if L[i] + L[j] > L[k]:
                c +=1

print(c)

Submission status: Accepted

Solution code:
n = int(input())
an = 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):
      if an[i] == an[j] or an[j] == an[k] or an[i] == an[k]:
        continue
        
      sn = [an[i],an[j],an[k]]
      sn.sort()
      if sn[0] + sn[1] > sn[2]:
        count += 1
print(count)

Submission status: Accepted

Solution code:
n=int(input(''))
l=list(map(int,input('').split(' ')))
p=0
for a in range(0,n):
    for b in range(a,n):
        s0=l[a]+l[b]
        for c in range(b,n):
            s1=l[a]+l[c]
            s2=l[b]+l[c]

            if l[a]!=l[b] and l[b]!=l[c] and l[c]!=l[a]:
                if s1>l[b] and s2>l[a] and s0>l[c]:
                    p+=1

print(p)

Submission status: Accepted

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

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

ans = 0

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

Submission status: Accepted

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

if N <= 3:
    print(0)
    exit()

ans = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            ans += 1
            if L[i] == L[j]:
                ans -= 1
            elif L[j] == L[k]:
                ans -= 1
            elif L[i] + L[j] <= L[k]:
                ans -= 1

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
data = list(map(int, input().split()))
data.sort()
c = 0
for tri in combinations(data, 3):
  if tri[0] < tri[1] < tri[2] and tri[0] + tri[1] > tri[2] and tri[0] + tri[2] > tri[1] and tri[2] + tri[1] > tri[0]:
    c += 1
print(c)

Submission status: Accepted

Solution code:
#import numpy as np
#import math
#from decimal import *
#from numba import njit

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

    i1 = 0
    i2 = 1
    i3 = 2

    c = 0
    while i1 < N-2:
        if L[i1] != L[i2] and L[i2] != L[i3] and L[i3] != L[i1] and \
            L[i1]+L[i2] > L[i3] and \
            L[i2]+L[i3] > L[i1] and \
        L[i3]+L[i1] > L[i2]:
            c += 1
        if i3 < N-1:
            i3 += 1
        elif i2 < N-2:
            i2 += 1
            i3 = i2 + 1
        else:
            i1 += 1
            i2 = i1 + 1
            i3 = i2 + 1

    print(c)

main()

Submission status: Accepted

Solution code:
import itertools

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

for group in itertools.combinations(L, 3):
    if group[0] != group[1] and \
        group[1] != group[2] and \
        group[2] != group[0] and \
        group[0] + group[1] > group[2] and \
        group[1] + group[2] > group[0] and \
        group[2] + group[0] > group[1]:
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import collections
S = int(input().rstrip())
L = list(map(int,input().rstrip().split()))
c = collections.Counter(sorted(L))
key = list(c.keys())
ans = 0
num = len(c)
for i in range(num-2):
    for j in range(i+1,num-1):
        for k in range(j+1,num):
            if key[i]+key[j]>key[k]:
                ans += c[key[i]]*c[key[j]]*c[key[k]]
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,n):
        for k in range(j,n):
            if l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                if abs(l[i]-l[j]) < l[k] < l[i] + l[j]:
                    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in L:
  for j in L:
    for k in L:
      if i + j > k and j + k > i and k + i > j and i != j and j != k and k != i:
        ans += 1

ans = ans // 6
print(ans)

Submission status: Accepted

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

from itertools import combinations
c = combinations(L, 3)
count = 0
for cs in c:
    if len(set(cs)) < 3:
        continue
    cs = sorted(cs)

    if cs[0] + cs[1] <= cs[2]:
        continue

    count += 1
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import itertools

n = int(input())
ln = list(map(int, input().split()))
num = [i for i in range(n)]
combi_list = []
for i in itertools.combinations(num, 3):
    combi_list.append(i)
Ans = 0
for i in range(len(combi_list)):
    hen = sorted([ln[combi_list[i][0]],ln[combi_list[i][1]],ln[combi_list[i][2]]])
    if hen[2] < hen[0]+hen[1] and (hen[0]!=hen[1] and hen[1]!=hen[2] and hen[2] != hen[0]):
        Ans +=1
print(Ans)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
tr = set()
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] or l[j] == l[k] or l[k] == l[i]: continue
            a = l[i]
            b = l[j]
            c = l[k]
            if a < b+c and b < c+a and c < a+b:
                ans +=1
            # if l[i] < l[j]+l[k]: ans += 1
print(ans)


# tr = set()
# 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] or l[j] == l[k]: continue
#             a = l[i]
#             b = l[j]
#             c = l[k]
#             t = [a,b,c]
#             t.sort()
#             t = tuple(t)
#             if a < b+c:
#                 if t in tr:continue
#                 ans +=1
#                 tr.add(t)
#             # if l[i] < l[j]+l[k]: ans += 1
# print(ans)





# for a in l:
#     for b in l:
#         for c in l:
#             if a == b or b == c: continue
#             if a<b+c or b < c+a or c < a+b:
#                 ans += 1
# print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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):
        if l[i] == l[j]:
            continue

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

            c = sorted([l[i], l[j], l[k]])
            if c[0] + c[1] > c[2]:
                count += 1

print(count)

Submission status: Accepted

Solution code:
N = int(input())
Ls = list(map(lambda x: int(x), input().split(" ")))

Ls.sort()

result = 0
for i in range(len(Ls)-2):
    for j in range(i+1, len(Ls)-1):
        if Ls[i] == Ls[j]:
            continue
        for k in range(j+1, len(Ls)):
            if Ls[j] == Ls[k]:
                continue
            if Ls[i] + Ls[j] > Ls[k]:
                result += 1


print(result)

Submission status: Accepted

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

list1 = list(itertools.combinations(L, 3))
count=0
for i in list1:
    if i[0] != i[1] and i[1] != i[2] and i[2] != i[0]:
        if i[0] + i[1] <= i[2]:
            continue
        
        if i[0] + i[2] <= i[1]:
            continue
        
        if i[2] + i[1] <= i[0]:
            continue
    
        count+=1
    else:
        continue
print(count)

Submission status: Accepted

Solution code:
#b
n = int(input())
l = list(map(int, input().split()))
l_set = set(l)
import itertools
if len(l_set) < 3:
    print("0")
    
else:
    
    ans = 0
    for b in itertools.combinations(l, 3):
        if (b[0] != b[1]) and (b[1] != b[2]) and  (b[2] != b[0]):
            if (b[0] + b[1] > b[2]) and (b[1]+b[2] > b[0]) and (b[2] + b[0] > b[1]):
                ans += 1
    print(ans)

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+1, n-1):
        for k in range(j+1, n):
            s = []
            s.append(l[i])
            s.append(l[j])
            s.append(l[k])
            s.sort()
            if s[0]+s[1] > s[2]:
                if len(set(s)) == 3:
                    c += 1

print(c)

Submission status: Accepted

Solution code:
n, *l = map(int, open(0).read().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]): continue
            if(l[i]+l[j]<=l[k] or l[j]+l[k]<=l[i] or l[k]+l[i]<=l[j]): continue
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

ans = 0
c = 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[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                c += 1
                #print("aa",l[i],l[j],l[k])
                if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                    c += 1
                else:
                    #print(l[i],l[j],l[k])
                    ans += 1
                    c += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
N = int(input())
L = inputlist()
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] and L[i] != L[j] and L[j] != L[k]:
                ans +=1
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
l = np.array(list(map(int,input().split())))

counter = 0
lenl = len(l)
for i in range(lenl):
  for j in range(i+1,lenl):
    for k in range(j+1,lenl):
      if l[i] == l[j] or l[j] == l[k] or l[i] == l[k]:
        continue
      if max([l[i],l[k],l[j]]) >= l[i]+l[k]+l[j]-max([l[i],l[k],l[j]]):
        continue
      else:
        counter += 1
print(counter)

Submission status: Accepted

Solution code:
import math

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

# l_list = set(l_list)

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

# print(combinations_count(len(l_list), 3))

l_list = sorted(l_list)

# print(l_list)

ans = 0

for a in range(len(l_list)):
    
    for b in range(a + 1, len(l_list)):

        for c in range(b + 1,len(l_list)):

           if l_list[a] != l_list[b] and l_list[b] != l_list[c] and l_list[c] != l_list[a] and abs(l_list[b] - l_list[c]) < l_list[a] < l_list[b] + l_list[c] :
               ans += 1

print(ans)

Submission status: Accepted

Solution code:

import datetime
from decimal import Decimal, ROUND_DOWN
import heapq
from fractions import gcd
from functools import reduce
from collections import deque
# from math import factorial
import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)
# import statistics
# import numpy as np
# n = int(input())
# n, m, p = list(map(int, input().split()))
# a = list(map(int, input().split()))
#
#  abc = [int(input()) for i in range(5)]
n = int(input())
#n, m = list(map(int, input().split()))
# a, b = list(map(int, input().split()))
l = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# n = int(input())
# a = list(map(int, input().split()))
# b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# data = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
# for i in range(1, int(n**0.5)+1):
count = 0
data = []
for a, b, c in itertools.combinations(l, 3):
    if a+b > c and b+c > a and c+a > b:
        data.append([a, b, c])

#data = list(map(list, set(map(tuple, data))))
for i in range(len(data)):
    if data[i][0] != data[i][1] and data[i][0] != data[i][2] and data[i][1] != data[i][2]:
        count += 1

# print(data)
# print(len(data))
print(count)

Submission status: Accepted

Solution code:
import itertools

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

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

ans = 0
for a, b, c in C:
    if a < b + c and b < a + c and c < b + a and a != b and b != c and a != c:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools

n = int(input())

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

combi = list(itertools.combinations(l, 3))
cnt = 0

for i in range(len(combi)):
  if combi[i][0] != combi[i][1] != combi[i][2] != combi[i][0] and max(combi[i])*2 < sum(combi[i]):
    cnt +=1

print(cnt)

Submission status: Accepted

Solution code:
import collections

N=int(input())
l=list(map(int,input().split()))
c=collections.Counter(l)

c=sorted(c.items(),key=lambda x:x[0])

item=[]
num=[]

for i,n in c:
    item.append(i)
    num.append(n)
    
count=0

if N<3:
    print(0)
else:
    for i in range(len(item)-2):
        for j in range(i+1,len(item)-1):
            k=j+1
            sumij=item[i]+item[j]
            mulij=num[i]*num[j]
            while k<len(item) and item[k]<sumij:
                count+=mulij*num[k]
                k+=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):
      if l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]:
        if ((l[i]) + (l[j])) > (l[k]) and ((l[k]) + (l[j])) > (l[i]) and ((l[i]) + (l[k])) > (l[j]):
          count += 1
print(count)

Submission status: Accepted

Solution code:
import itertools

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

def valid(a, b, c):
    x = max(a, b, c)
    return x < a+b+c-x and len({a, b, c}) == 3

ways = 0
for i, j, k in itertools.combinations(range(N), 3):
    if valid(L[i], L[j], L[k]):
        ways += 1

print(ways)

Submission status: Accepted

Solution code:
import itertools 
N=int(input())
L=list(map(int,input().split()))
result=[]
for pair in itertools.combinations(L, 3):
	result.append(list(pair))
count=0
for i in range(len(result)):
	result[i].sort()
	if result[i][0]!=result[i][1] and result[i][0]!=result[i][2] and result[i][1]!=result[i][2] and (result[i][0]+result[i][1])>result[i][2]:
		count+=1
print(count)

Submission status: Accepted

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

import sys


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


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


def main():
    n = int(std_in())
    l = list(get_ints())
    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]:
                    s = {l[i], l[j], l[k]}
                    L = [l[i], l[j], l[k]]
                    L.sort()
                    if len(s) == 3:
                        if L[-1] < L[0] + L[1]:
                            c += 1
    print(c)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
li=sorted(list(map(int, input().split())),reverse=1)
res=0
for x in range(n):
    for y in range(x+1,n):
        for z in range(y+1,n):
            a=li[x]
            b=li[y]
            c=li[z]
            if (a<b+c) and a!=b and b!=c:
                res+=1
print(res)

Submission status: Accepted

Solution code:
def main():
    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 0<= i < j < k <= n-1 \
                    and 2 * max([l[i], l[j], l[k]]) < sum([l[i], l[j], l[k]]) \
                    and len(set([l[i], l[j], l[k]]))==3:
                    ans += 1
    print(ans)

    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
l = list(map(int, input().split()))
for i in range(0, n-2):
    for j in range(i+1, n-1):
        for z in range(j+1, n):
            ma = max(l[i], l[j], l[z])
            mi = min(l[i], l[j], l[z])
            mm = (l[i] + l[j] + l[z])-ma-mi
            if mm-mi < ma and ma < mi+mm and l[i] != l[j] and l[j] != l[z] and l[i] != l[z]:
                ans += 1
                # print(i, j, z)

print(ans)

Submission status: Accepted

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

N=int(input().rstrip('\n'))
if N<3:
  print(0)
else:
  ls = [int(x) for x in input().rstrip('\n').split()]
  ls = sorted(ls,reverse = True)
  res = 0
  for x in range(N-2):
    X=ls[x]
    for y in range(x+1,N-1):
      Y=ls[y]
      if X>Y:
        a = X-Y
        for z in range(y+1,N):
          Z=ls[z]
          if Y>Z and Z>a:
            res += 1
          elif Z<=a:
            break
  print(res)

Submission status: Accepted

Solution code:
import os

from itertools import combinations
n=int(input())
ls=list(map(int,input().split()))

cnt = 0
for a,b,c in combinations(ls, 3):
    if a == b or b == c or c == a:
        continue
    if a+b > c and b+c > a and c+a>b:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    L = [int(x) for x in input().split()]

    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                tmp = []
                tmp.append(L[i])
                tmp.append(L[j])
                tmp.append(L[k])
                x = set(tmp)
                if len(x) != 3:
                    continue
                tmp.sort()
                if tmp[2] < tmp[1] + tmp[0]:
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
L=[int(i) for i in input().split()]
cnt = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            #print('{}:{}:{}'.format(i,j,k))
            if not ((L[i] == L[j]) or (L[j]==L[k]) or (L[i]==L[k])):
                mx = max(L[i],L[j],L[k])
                s = L[i]+L[j]+L[k]-mx-mx
                if s > 0:
                    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3

def main():
    N = int(input())
    L = list(map(int, input().split()))
    count = 0
    for i in range(0, N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                if L[i] == L[j] or L[j] == L[k] or L[i] == L[k]:
                    continue
                if abs(L[j] - L[k]) < L[i] and L[i] < L[j] + L[k]:
                    count = count + 1
    print(count)


main()

Submission status: Accepted

Solution code:
n = int(input())

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

con = 0

for p in range(n):
    for q in range(p+1,n):
        for r in range(q+1,n):
            if x[p] != x[q] and x[q] != x[r] and x[r] < (x[p] + x[q]) and x[q] < (x[p] + x[r]) and (x[r]-x[p]) < x[q] and (x[r]-x[q]) < x[p] and (x[q]-x[p]) < x[r]:
                con += 1
                
print(con);