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: Time Limit Exceeded

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

import sys
import argparse
import logging
#import math

logging.basicConfig(filename='logger.log', level=logging.DEBUG)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)


def f(n: int, l_list: list, i: int = None, j: int = None, k: int = None) -> int:
    '''
    >>> f(0, [])
    0
    >>> f(1, [1])
    0
    >>> f(2, [1, 1])
    0
    >>> f(3, [1, 1, 1])
    0
    >>> f(3, [1, 1, 2])
    0
    >>> f(3, [1, 2, 2])
    0
    >>> f(3, [1, 2, 3])
    0
    >>> f(3, [1, 2, 4])
    0
    >>> f(3, [1, 3, 4])
    0
    >>> f(3, [2, 3, 4])
    1
    >>> f(5, [4, 4, 9, 7, 5])
    5
    >>> f(6, [4, 5, 4, 3, 3, 5])
    8
    >>> f(10, [9, 4, 6, 1, 9, 6, 10, 6, 6, 8])
    39
    '''
    if n <= 2:
        return 0
    result = 0
    for i in range(0, n-2):
        for j in range(i+1, n-1):
            for k in range(j+1, n):
                logger.debug("(n, i,j,k)=(%d, %d,%d,%d)" % (n, i, j, k))
                li = l_list[i]
                lj = l_list[j]
                lk = l_list[k]
                l_ijk = sorted([l_list[i], l_list[j], l_list[k]])
                if l_ijk[0] + l_ijk[1] > l_ijk[2]:
                    if li != lj and lj != lk and lk != li:
                        logger.debug("yes")
                        result += 1
    return result


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument(
            '--doctest', action='store_true', default=False)
    args = parser.parse_args()
    if args.doctest:
        import doctest
        doctest.testmod(verbose=True)
        sys.exit()

    n = int(sys.stdin.readline().rstrip())
    l_list = list(map(lambda x: int(x), sys.stdin.readline().rstrip().split()))
    print(f(n, l_list))

Submission status: Time Limit Exceeded

Solution code:
def check_triangle(a, b, c):
	return (a+b>c and a+c>b and b+c>a) and (a!=b and a!=c and c!=b)

def count_triangle(arr, N):
	count=0
	seen = []
	for x in range(N):
		for y in range(x+1, N):
			for z in range(y+1, N):
				if(x==y or x==z or z==y):
					continue
				if(check_triangle(arr[x], arr[y], arr[z])):
					if([[arr[x], arr[y], arr[z]]] not in seen):
						seen.append([arr[x], arr[y], arr[z]])
						count+=1
						
	return count

N = int(input())
arr = list(map(int, input().split()))
print(count_triangle(arr, N))

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(1,2**N):
  bin_line = str(bin(i))
  bin_line = bin_line.replace('0b', '')

  count = 0
  line = []
  for j in range(len(bin_line)):
    if bin_line[j] == '1':
      count += 1
      line.append(L[N-len(bin_line)+j])
      if count > 4:
        break
  if count == 3 and len(set(line)) == 3:
    if line[0]+line[1] > line[2] and line[0]+line[2] > line[1] and line[1]+line[2]>line[0]:
      ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

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):
          n1 = sum([l == L1 for l in ls])
          n2 = sum([l == L2 for l in ls])
          n3 = sum([l == L3 for l in ls])
          ans += n1 * n2 * n3
      Ls1 = Ls1[1:]
    LsR = LsR[1:]
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
from pdb import set_trace

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

if N<3:
    print(0)
    exit()
LN = [i for i in range(N)]
cnt = []
for xa, a in enumerate(L[:-2]):
    for xb, b in enumerate(L[xa+1:-1]):
        for xc, c in enumerate(L[xa+2:]):
            if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
                li = sorted([xa, xb+xa+1, xc+xa+2])
                if li in cnt:
                    continue
                cnt.append(li)
print(len(cnt))

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(1,2**N):
  bin_line = str(bin(i))
  bin_line = bin_line.replace('0b', '')
  if len(bin_line) < N:
    zero = '0'*(N-len(bin_line))
    bin_line = zero + bin_line
  count = 0
  line = []
  for j in range(N):
    if bin_line[j] == '1':
      count += 1
      line.append(L[j])
  if count == 3 and len(set(line)) == 3:
    if line[0]+line[1] > line[2] and line[0]+line[2] > line[1] and line[1]+line[2]>line[0]:
      ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
L=list(map(int,input().split(' ')))
l=0
T=[]
for i in range(N):
    for j in range(N):
        for k in range(N):
            if i!=k and i!=j and j!=k:
                u=[i,j,k]
                u.sort()
                if u not in T:
                    T.append(u)
                    if 2*max(L[i],L[j],L[k])<L[i]+L[j]+L[k] and L[i]!=L[k] and L[i]!=L[j] and L[j]!=L[k]:
                        l=l+1
print(l)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

L_uni = np.unique(L)

count=0
if len(L_uni) < 3:
    count=0
else:
    for i in range(len(L_uni)):
        for j in range(i+1, len(L_uni)):
            for k in range(j+1, len(L_uni)):
                L_tri = np.array([L_uni[i], L_uni[j], L_uni[k]])
                if L_uni[i] < L_uni[j] + L_uni[k] and L_uni[i] > abs(L_uni[j] - L_uni[k]):
                    count += np.sum(L == L_uni[i]) * np.sum(L==L_uni[j]) * np.sum(L==L_uni[k])
                
print(count)

Submission status: Time Limit Exceeded

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

    seen = []
    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
                if l[j] + l[k] > l[i] and [i, j, k] not in seen:
                    ans += 1
                    seen.append([i, j, k])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
from pdb import set_trace

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

if N<3:
    print(0)
    exit()
LN = [i for i in range(N)]
cnt = []
for xa, a in enumerate(L[:-2]):
    for xb, b in enumerate(L[xa+1:-1]):
        for xc, c in enumerate(L[xa+2:]):
            if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
                li = sorted([xa, xb+xa+1, xc+xa+2])
                flag = True
                for _cnt in cnt:
                    if _cnt==li:
                        flag = False
                if flag:
                    cnt.append(li)
print(len(cnt))

Submission status: Time Limit Exceeded

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

ans = 0
for b in range(0,2**n):
    cnt = 0
    for i in range(n):
        if (b >> i) % 2 == 1:
            cnt += 1
            if cnt >= 4:
                break    
    if cnt == 3:
        cnt = 0
        idx = []
        for i in range(n):
            if (b >> i) % 2 == 1:
                idx.append(i)
                cnt += 1
                if cnt == 3:
                    break
        A = L[idx[0]]     
        B = L[idx[1]]     
        C = L[idx[2]]
        if A+B>C and B+C>A and C+A>B and A is not B and B is not C and C is not A:
            ans += 1     

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(2**n):
    tmp = []
    for j in range(n):
        if ((i >> j) & 1):
            tmp .append(a[j])
    tmp.sort()
    if len(tmp) == 3 and abs(tmp[0]-tmp[1]) < tmp[2] and tmp[2] < tmp[0]+tmp[1] and tmp[0] != tmp[1] != tmp[2]:
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
for b in range(0,2**n):
    idx = []
    cnt = 0
    for i in range(n):
        if (b >> i) % 2 == 1:
            idx.append(i)
            cnt += 1
            if cnt >= 4:
                break
    if len(idx) == 3:
        A = L[idx[0]]     
        B = L[idx[1]]     
        C = L[idx[2]]
        if A+B>C and B+C>A and C+A>B and A is not B and B is not C and C is not A:
            ans += 1     

print(ans)

Submission status: Time Limit Exceeded

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

L = sorted(L)
res = []
cnt = 0
for i in range(len(L)):
  Li = L[i]
  for j in range(len(L)):
    Lj = L[j]
    for k in range(len(L)):
      Lk = L[k]
      if Li + Lj > Lk and Lj + Lk > Li and Lk + Li > Lj:
        if Li != Lj and  Lj!= Lk and Lk != Li:
          if sorted([i, j, k]) not in res:
            res.append(sorted([i, j, k]))
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

ans = 0
for b in range(0,2**n):
    idx = []
    for i in range(n):
        if (b >> i) % 2 == 1:
            idx.append(i)
    if len(idx) == 3:
        A = L[idx[0]]     
        B = L[idx[1]]     
        C = L[idx[2]]
        if A+B>C and B+C>A and C+A>B and A is not B and B is not C and C is not A:
            ans += 1     

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys,math
try:sys.stdin,sys.stdout=open('input.txt','r'),open('out.txt','w')
except:pass
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt,log
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
# print('{:.3f}'.format(1),round(1.123456789,4))
# sys.setrecursionlimit(500000)
def lcm(a,b): return (a*b)//gcd(a,b)
def setbits(n):return bin(n).count('1')
def resetbits(n):return bin(n).count('0')
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r):
    num,den=1,1;r=min(n,n-r)
    for i in range(r):num*=(n-i);den*=(i+1)
    return num//den
def ncr_p(n, r, p):
    num,den=1,1;r=min(r,n-r)
    for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
    return (num * modinv(den,p)) % p
def isPrime(num) :
    if num<=1:return False
    if num==2 or n==3:return True
    if (num % 2 == 0 or num % 3 == 0) :return False
    m = int(num**0.5)+1
    for i in range(5,m,6):
        if (num % i == 0 or num % (i + 2) == 0) :return False
    return True
def bin_search(arr, low, high, val):
    while low <= high:
        mid = low + (high - low) // 2;
        if arr[mid] == val:return mid
        elif arr[mid] < val:low = mid + 1
        else:high = mid - 1
    return -1
def sumofdigit(num):
    count=0;
    while num : count+=num % 10;num //= 10;
    return count;
def inputmatrix():
    r,c=iia();mat=[0]*r;
    for i in range(r):mat[i]=iia();
    return r,c,mat;
def prefix_sum(n,arr):
    for i in range(1,n):arr[i]+=arr[i-1]
    return arr;
def binomial(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0
def divisors(n):
    res = [];
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if i==n//i:res.append(i)
            else:res.append(i);res.append(n//i)
    return res;
# code start from here-

n= ii1()
arr = iia()
# arr= list(set(arr))
arr.sort()
count=0
lis=[]
n=len(arr)
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]:
                if arr[i]+arr[j]>arr[k] and arr[j]+arr[k]>arr[i] and arr[k]+arr[i]>arr[j]:
                    if (i,j,k) not in lis:
                        count+=1
                        lis.append((i,j,k))
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=list(map(int,input().split()))
s=0
for i in range(n-2):
    for j in range(i,n-1):
        k=j+1
        t=l[i]+l[j]
        while t>k:
            s+=1
print(s)

Submission status: Accepted

Solution code:
N = int(input())
hen = []

hen = list(int(x) for x in input().split())
hen.sort()
#print(hen)
#hen_u = set(hen)
#print(hen_u)
tri = 0

for a in hen:
    for b in hen:
        if(a == b)or (a > b):
            continue
        for c in hen:
            if(a == c)or(b == c) or (a > c) or (b > c):
                continue
            if(a+b >c)and(b+c >a)and(c+a >b):
                tri += 1

print(tri)

Submission status: Accepted

Solution code:
def A():
    s = input()
    if s == 'SSS': print(3)
    elif s=='RSS' or s=='SSR': print(2)
    elif s=='RRR': print(0)
    else: print(1)

def B():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    for i in range(n):
        for j in range(i+1, n):
            if a[i] == a[j]: continue
            for k in range(j+1, n):
                if a[i]==a[k] or a[j] == a[k]: continue
                s = a[i] + a[j] + a[k]
                if s > 2 * max(a[i], a[j], a[k]):
                    cnt += 1
    print(cnt)

def C():
    x, k, d = map(int, input().split())
    if abs(x) > k * d:
        print(abs(x) - k*d)
    else:
        tm = abs(x) // d
        x = abs(x) % d
        k -= tm
        if k % 2 == 0:
            print(x)
        else:
            print(d-x)
B()

Submission status: Accepted

Solution code:
#n = int(input()) #入力
#a, b = (int(x) for x in input().split())
#a, b = map(int, input().split())

#G = [input() for i in range(0, H)] #文字列を複数行に渡って

#a = [int(x) for x in input().split()]
#a = list(map(int, input().split()))
#a = [list(map(int,input().split(" "))) for i in range(N)]   #2次元


#a.sort() # C++ の sort(a.begin(), a.end());
#a.append(3) # C++ の a.push_back(3);


#exit(0) # return 0 的な。終了できる。
## 整数の切り捨て除算は // (ダブルスラッシュ)


#a[始まりの位置: 終わりの位置: スライスの増分] # (a は配列)


#import numpy as np  #importに100 ms 程度かかる。
import math
import copy
import string
#math.gcd(a, b) で、gcd 計算できる。
#math.pi は円周率。

INF = int(10**18) #べき乗 C++ の pow(10, 18) or 1e18;
pi = math.pi

MOD = 1000000007
#MOD = 1000000009
#MOD = 998244353




#繰り返し2乗法
#N^aの、Mで割った余りを求める。
def my_pow(N, a, M):
    if(a == 0):
        return 1
    else:
        if(a % 2 == 0):
            tempo = my_pow(N, a/2, M)
            return (tempo * tempo) % M
        else:
            tempo = my_pow(N, a - 1, M)
            return (tempo * N) % M




#N_C_a を M で割った余り
def my_combination(N, a, M):
    res = 1

    for i in range(0, a):
        res *= N - i
        res %= M

    for i in range(0, a):
        res *= my_pow(i + 1, M - 2, M)
        res %= M

    return res




#N_C_i を M で割った余りを、v[i] に代入する。
def my_combination_table(N, M, v):
    if(len(v) < N + 1):
        l = N + 1 - len(v)
        tempo = [1] * l
        v.extend(tempo)

    for i in range(1, N + 1):
        v[i] = v[i - 1] * (N - (i - 1))
        v[i] %= M

        v[i] *= my_pow(i, M - 2, M)
        v[i] %= M

    return




#math.factorial で階乗は計算できる。
#math.gcd で gcd は計算できる。
#np.gcd.reduce(A) #(Aは配列) で、Aの全ての要素の gcd が計算できる。


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

res = 0
for i in range(0, N):
    for j in range(i + 1, N):
        for k in range(j + 1, N):
            #print(L[i], L[j], L[k])
            tempo = [L[i], L[j], L[k]]
            tempo.sort()
            
            #print(tempo[0], tempo[1], tempo[2])
            if(tempo[0] + tempo[1] > tempo[2] and tempo[0] < tempo[1] and tempo[1] < tempo[2]): 
                res += 1
                #print(i, j, k)
print(res)

Submission status: Accepted

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

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]:
                continue
            if L[i] + L[j] > L[k]:
                cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
count = 0
L = list(map(int, input().split()))
for i,li in enumerate(L[:-2]):
  for j,lj in enumerate(L[i+1:-1]):
    for k,lk in enumerate(L[i+j+1:]):
      if (li != lj) and (lj != lk) and (li != lk):
#        la,lb,lc = sorted([li,lj,lk])
        if li + lj > lk and lj + lk > li and lk + li > lj:
#          print(i+1,i+j+1,i+j+k+1,li,lj,lk)
          count += 1
print(count)

Submission status: Accepted

Solution code:
n=int(input())
r=list(map(int,input().split()))
t=0
for i in range(n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			if r[i]==r[j] or r[j]==r[k] or r[i]==r[k]:continue
			s=[r[i],r[j],r[k]]
			s.sort()
			if s[0]+s[1]>s[2]:
				t+=1
print(t)

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):
      li = [l[i], l[j], l[k]]
      
      m = max(li)
      if 2*m < sum(li) and len(set(li)) == 3:
        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 h in range(j+1,n):
            if l[i] != l[j] and l[i] != l[h] and l[j] != l[h]:
                mnum = max(l[i],l[j],l[h])
                if mnum < l[i] + l[j] + l[h] - mnum:
                    ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations

N = int(input())
a = list(map(int, input().split()))
count = 0
for i in combinations(a,3):
    b = list(i)
    b.sort()
    if b[2] > b[1] and b[1] > b[0]:
        if b[2] < (b[1] + b[0]):
            count += 1

print(count)

Submission status: Accepted

Solution code:
import itertools
import sys
N = int(input())
if N < 3:
  print(0)
  sys.exit()
 
#辺を取得してint型に変換
hen_list = input().split()
for i in range(len(hen_list)):
    hen_list[i] = int(hen_list[i])
 
#組み合わせ
count = 0
for tri in itertools.combinations(hen_list, 3):
    sort_tri = sorted(tri)
    if sort_tri[0] + sort_tri[1] > sort_tri[2]:
        if tri[0] != tri[1] and tri[0] != tri[2] and tri[1] != tri[2]:
            #print(sort_tri)
            count += 1
print(count)

Submission status: Accepted

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

ans = 0

for a in range(n):
    for b in range(a+1,n):
        for c in range(b+1,n):
            if  l[a] != l[b] != l[c] and l[a]+l[b] > l[c]:
                ans += 1
print(ans)

Submission status: Accepted

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

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
            if l[k]-l[j]-l[i]<0:
                cnt+=1

print(cnt)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations
def main():
    n, *a = map(int, read().split())
    coma = combinations(a, 3)
    r = 0
    for c in coma:
        if sum(c) > max(c)*2:
            if len(set(c)) > 2:
                r += 1
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

l=list(combinations(l_,3))
#print(l)
cnt=0
for i in range(len(l)):
  
  if len(list(set(l[i])))==len(l[i]):
    
    if max(l[i])<sum(l[i])-max(l[i]):
      cnt+=1
      
print(cnt)

Submission status: Accepted

Solution code:
import math
import collections
import itertools

def YesNo(Bool):
    if(Bool):
        print("Yes")
    else:
        print("No")
    return

def resolve():

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

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,N):
        for k in range(j,N):
            if l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                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()))
l.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
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[k] and L[k]+L[j] > L[i] and L[i]+L[k] > L[j]:
                if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                    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 or i == k or j == k: continue
  if i >= j+k or j >= i+k or k >= i+j: continue
  ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
ans=0
N=II()
L=LI()
c = itertools.combinations(L, 3)
for v in itertools.combinations(L, 3):
    v=list(v)
    v.sort()
    if v[0]==v[1] or v[1]==v[2]:
      continue
    if v[0]+v[1]>v[2]:
      ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from itertools import combinations


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


sys.setrecursionlimit(20000000)

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


def main():
    N = int(input())
    L = list(map(int, input().split()))
    count = Counter(L)
    key = count.keys()

    set_list = combinations(key, 3)
    answer = 0
    for s in set_list:
        a = s[0]
        b = s[1]
        c = s[2]
        if (a + b) > c and (b + c) > a and (c + a) > b:
            answer += count[a] * count[b] * count[c]
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0
if N > 2:
    for i in range(N - 2):
        for j in range(i + 1, N - 1):
            for k in range(j + 1, N):
                tmp = [L[i], L[j], L[k]]
                if (len(tmp) == len(set(tmp))) and (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 numpy as np
from numba import *


N = int(input())
length = np.array(input().split(), np.int64)


length = np.sort(length)


def calc(length):
    cnt = 0
    
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                l1, l2, l3 = length[i], length[j], length[k]
                if (l1 != l2 and l1 != l3 and l2 != l3):
                    if (l1 + l2 > l3):
                        cnt += 1
    
    return (cnt)

ans = calc(length)
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
from numba import *


N = int(input())
length = np.array(input().split(), np.int64)


length = np.sort(length)

@njit
def calc(length):
    cnt = 0
    
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                l1, l2, l3 = length[i], length[j], length[k]
                if (l1 != l2 and l1 != l3 and l2 != l3):
                    if (l1 + l2 > l3):
                        cnt += 1
    
    return (cnt)

ans = calc(length)
print(ans)

Submission status: Accepted

Solution code:

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

li.sort()

ans = 0

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

Submission status: Accepted

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

answer = 0
for idx1 in range(0, len(arr) - 2):
    for idx2 in range(idx1+1, len(arr) - 1):
        for idx3 in range(idx2+1, len(arr)):
            if arr[idx1] == arr[idx2] or arr[idx1] == arr[idx3] or arr[idx2] == arr[idx3]:
                continue
            if arr[idx1] + arr[idx2] > arr[idx3] and arr[idx1] + arr[idx3] > arr[idx2] and arr[idx2] + arr[idx3] > arr[idx1]:
                answer += 1

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools

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

combinations = list(itertools.combinations(range(N), 3))

count = 0
for cmb in combinations:
    flag = True
    for i in range(3):
        if L[cmb[i]] + L[cmb[(i + 1) % 3]] > L[cmb[(i + 2) % 3]] and L[cmb[i]] != L[cmb[(i + 1) % 3]]:
            continue
        else:
            flag = False
            break
    if flag:
        count += 1

print(count)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(300000)
from itertools import combinations

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()
L = LMI()

ans = 0
for a, b, c in combinations(L, 3):
    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(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] and 2 * max(l[i],l[j],l[k]) < l[i]+l[j]+l[k]:
                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(range(N),3):
  ell = sorted([L[i], L[j], L[k]])
  if ell[2] < ell[0] + ell[1] and len(set(ell)) == 3:
    ans += 1
print(ans)