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())
a = [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):
            m = max(a[i], a[j], a[k])
            if len(set([a[i], a[j], a[k]])) == 3 and m < (a[i] + a[j] + a[k] - m):
                ans+= 1
print(ans)

Submission status: Accepted

Solution code:
import copy
import math
import time
import statistics
import math
import itertools
import bisect
from decimal import *

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():

    start = time.time()

    #n, q = get_int_multi()
    n = get_int()

    a = get_int_list()
    a.sort()

    ans = 0
    for i in range(n):
        for ii in range(i+1,n):
            if a[i] == a[ii]:
                continue
            for iii in range(ii+1,n):
                if a[ii] == a[iii]:
                    continue
                if a[i] + a[ii] > a[iii]:
                    ans += 1

    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

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

ret = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            x,y,z = l[i],l[j],l[k]
            lis = [x,y,z]
            lis = sorted(lis)
            if len(set(lis)) == 3 and lis[-1] < lis[0] + lis[1]:
                #print(lis)
                ret+=1

print(ret)

Submission status: Accepted

Solution code:
from itertools import combinations

n = int(input())
l = sorted(map(int, input().split()))
c = 0
for i, j, k in combinations(range(n), 3):
    li, lj, lk = l[i], l[j], l[k]
    if li == lj or lj == lk or lk == li:
        continue
    if li + lj > lk:
        c += 1
print(c)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
a=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            b=[l[i],l[j],l[k]]
            p,q,r=min(b),sum(b)-min(b)-max(b),max(b)
            a+=(len(set(b))==3)and (p+q>r)
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()

    ans = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                    continue
                if L[i] + L[j] > L[k]:
                    ans += 1
    
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
L = list(map(int,input().split()))
for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if len(set((L[i], L[j] , L[k])))!= 3:
        continue
      A = L[i] + L[j] + L[k]
      if 2*max([L[i] , L[j] , L[k]])<A:
        count += 1
        # print(i,j,k)
print(count)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    cnt = 0
    for i in range(N):
        for j in range(i + 1, N):
            if L[i] == L[j]:
                continue
            for k in range(j + 1, N):
                if L[i] == L[k]:
                    continue
                if L[j] == L[k]:
                    continue
                if L[k] < L[i] + L[j]:
                    cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok

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):
            a=l[i]
            b=l[j]
            c=l[k]
                
            if(a!=b and b!=c and c!=a)and (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 = sorted(map(int, input().split()))
ans = 0
# print(l)
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            # print(i, j, k)
            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()))
ans = 0
l.sort()
if n <= 2:
    print(0)
    exit()
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] + l[j] > l[k] and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]: 
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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):
            # print(l[i],l[j],l[k])
            if l[i]==l[j] or l[j]==l[k] or l[i]==l[k]:
                continue
            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()))
cnt=0
l.sort()
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]:
                if l[k]<l[i]+l[j]:
                    cnt+=1
print(cnt)

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

Submission status: Accepted

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

ans = 0
for comb in combinations(L, 3):
    l1,l2,l3 = comb
    if l1 != l2 and l2 != l3 and l1 != l3:
        if sum(comb) - max(comb) > max(comb):
            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[i]!=l[k] and l[j]!=l[k]:
                if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[k]+l[i]>l[j]:
                    ans+=1
print(ans)

Submission status: Accepted

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

def solve(N: int, L: "List[int]"):
    a = 0
    L = sorted(L)
    for k in it.combinations(L,3):
        if (k[0] != k[1] != k[2]) and (k[0]+k[1]>k[2]):
            a+=1
    print(a)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

def main():
    import itertools
    input = sys.stdin.readline
    n = int(input())
    l = list(map(int, input().split()))
    ans = 0
    for i in itertools.combinations(l, 3):
        if len(set(i)) == 3 and abs(i[0] - i[1]) < i[2] < i[0] + i[1]:
            ans += 1
    print(ans)




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
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):
        if l[i] == l[j]:
            continue

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

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

N = int(input())
#N, M = map(int, input().split())
A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]
#S = input()
#S = [input() for _ in range(N)]

A.sort(reverse = True)
#print(A)

answer = 0
for i in range(N):
    ai = A[i]
    for j in range(i + 1, N):
        aj = A[j]
        for k in range(j + 1, N):
            ak = A[k]
            
            if ai < aj + ak and aj < ai + ak and ak < ai + aj and ai != aj and aj != ak and ak != ai:
                answer += 1

print(answer)

Submission status: Accepted

Solution code:
def main():
    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] or L[i] == L[k] or L[j] == L[k]:
                    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)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import itertools
def resolve():
    N = int(input())
    L = list(map(int,input().split()))
    count=0
    for i,j,k in itertools.combinations(L,3):
        if i+j > k and i+k > j and j+k > i and i!=j and j!=k and k!=i:
            count +=1 
    print(count)
resolve()

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

        for k in range(j):

            if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue

            if max(L[i],L[j],L[k]) < (L[i]+L[j]+L[k]) - max(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(N):
        for k in range(N):
            if i < j and j < k and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                edges = [L[i],L[j],L[k]]
                edges.sort()
                if edges[0]+edges[1] > edges[2]:
                    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):
            A,B,C = L[i],L[j],L[k]
            if A != B and B != C and C != A and A+B+C - max(A,B,C) > max(A,B,C):
                ans += 1

print(ans)

Submission status: Accepted

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

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    L=list(mi())

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

    print(ans)




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
l = nl()

cnt=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] or l[j]==l[k] or l[i]==l[k]):
          ll = sorted([l[i],l[k],l[j]])
          if ll[0]+ll[1]>ll[2]:
            cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
import itertools

N = int(input())
L_list = [int(e) for e in input().split()]

ans = 0

for Li,Lj,Lk in itertools.combinations(L_list, 3):
    if Li != Lj != Lk != Li:
        comb_L = [Li,Lj,Lk]
        comb_L.sort(reverse=False)
        longest = comb_L.pop(-1)
        if longest < sum(comb_L):
            ans += 1
            
print(ans)

Submission status: Accepted

Solution code:
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

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

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N = In.int()
L = In.ints()
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[i]!=L[k] and L[j]!=L[k]:
                if L[k]<L[i]+L[j] and L[j]<L[k]+L[i] and L[i]<L[k]+L[j]:
                    ans+=1

Out.int(ans)


######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Submission status: Accepted

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

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

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):
            for k in range(j):
                lv = [L[i], L[j], L[k]]
                lv.sort()
                # print(lv)
                if len(set(lv)) == 3 and lv[2] < lv[1] + lv[0]:
                    ans += 1
    return ans



if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    l = sorted(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]:
                    if l[k]<l[i]+l[j]:
                        ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
arr = [int(j) for j in input().split()]
ans = 0
arr.sort()
for i in range(len(arr)):
	for j in range(i+1, len(arr)):
		for k in range(j+1, len(arr)):
			if arr[i] + arr[j] > arr[k] and arr[i] != arr[j] and arr[j] != arr[k] and arr[k] != arr[i]:
				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] or L[j] == L[k]:
                continue
            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
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            #print(l[i],l[j],l[k])
            if l[i]+l[j]>l[k] and l[i]!=l[j] and l[i]!=l[k] and l[k]!=l[j]:
                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, *l = map(int, read().split())
    if n < 3:
        print(0)
        sys.exit()
    com = tuple(combinations(l, 3))
    r = 0
    for c in com:
        c1 = c[0]
        c2 = c[1]
        c3 = c[2]
        if c1 == c2 or c2 == c3 or c1 == c3:
            continue
        else:
            cs = sum(c) - max(c)
            r += cs > max(c)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in combinations(l, 3):
    i = list(i)
    i.sort()
    if i[0]==i[1] or i[1]==i[2]:
        continue
    if i[0]+i[1]>i[2]:
        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 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 statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
L = sorted(readInts())
ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        if L[i] == L[j]:
            continue
        for k in range(j+1,n):
            if L[j] == L[k]:
                continue
            if abs(L[i]-L[j]) < L[k] < L[i] + L[j]:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
l = LIST()
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[k] != l[i]:
                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:
def main():
    N = int(input())
    L = [int(_x) for _x in input().split()]
    length = len(L)
    LL = list(sorted(L))
    cnt = 0
    for i in range(0, length):
        for j in range(i+1, length):
            for k in range(j+1, length):
                if LL[i] + LL[j] > LL[k] and LL[i] != LL[j] and LL[i] != LL[k] and LL[j] != LL[k]:
                    cnt += 1
    print(cnt)


main()

Submission status: Accepted

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

if N < 2:
    print(0)
    exit()

cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        if L[i] == L[j]:
            continue

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

if N<=2:
    print(0)
    exit()
count=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            a=L[i]
            b=L[j]
            c=L[k]
            if a!=b and b!=c and c!=a:
                if a+b>c and b+c>a and c+a>b:
                    count+=1

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
from collections import defaultdict,deque
from itertools import permutations
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

t=1
#t=ii()
for _ in range(t):
    n=ii()
    ans=0
    a=ll()
    #a.sort()
    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):
                if((a[i]+a[j])>a[k] and (a[i]+a[k])>a[j] and (a[j]+a[k])>a[i] and a[i]!=a[j] and a[j]!=a[k] and a[i]!=a[k]) :
                    ans+=1
    print(ans)

Submission status: Accepted

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

ans = 0
for a in range(N):
    la = L[a]
    for b in range(a+1,N):
        lb = L[b]
        if la==lb: continue
        for c in range(b+1,N):
            lc = L[c]
            if la==lc or lb==lc: continue
            if (lc < lb + la) and (lb < la + lc) and (la < lb + lc):
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, L):
    L.sort()
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            if L[i] == L[j]: continue
            for k in range(j + 1, N):
                if L[i] == L[k] or L[j] == L[k]: continue
                if L[i] + L[j] > L[k]:
                    ans += 1
    print(ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *L, = map(int, input().split())
    main(N, L)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import combinations
N = int(input())
L = list(map(int,input().split()))

ans = 0
for a,b,c in combinations(L,3):
    if c<a+b and a<b+c and b<a+c:
        if a != b and b != c and c != a:
            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):
            a,b,c=sorted([L[i],L[j],L[k]])
            if a!=b!=c:
                if c<a+b:
                    ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys, math
from functools import lru_cache
from collections import defaultdict
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    L = list(mi())
    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] \
                    and abs(L[j]-L[k]) < L[i] < L[j]+L[k]:
                    cnt += 1

    print(cnt)

if __name__ == '__main__':
    main()