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:
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
ALPHA='abcdefghijklmnopqrstuvwxyz'
M=10**9+7
EPS=1e-6
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]


#-------------------------code---------------------------#
#vsInput()

n=Int()
a=sorted(array())

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input().rstrip())
edgeList = [int(x) for x in input().rstrip().split(" ")]
cnt = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    if edgeList[i] != edgeList[j]:
      for k in range(j+1, n):
        cnt += (edgeList[i] != edgeList[k] and 
                edgeList[j] != edgeList[k] and 
                edgeList[i] + edgeList[j] > edgeList[k] and 
                edgeList[j] + edgeList[k] > edgeList[i] and 
                edgeList[k] + edgeList[i] > edgeList[j])
print(cnt)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = sorted(list((map(int, input().split()))))
res = 0
pos = list(itertools.combinations(l, 3))
for pos_i in pos:
    pos_i = sorted(list(pos_i))
    if len(set(pos_i)) < 3:
        continue
    if pos_i[-1] < pos_i[0] + pos_i[1]:
        res += 1
print(res)

Submission status: Accepted

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

c=list(itertools.combinations(list(range(1,n+1)),3))
ans=0
for i in c:
  if i[0]<i[1] and i[1]<i[2]:
    #print(i[0],i[1],i[2])
    s=sorted(set([l[i[0]-1], l[i[1]-1], l[i[2]-1]]))
    if len(s) == 3:
      if s[-1] < s[0]+s[1]:
        ans+=1
        #print([l[i[0]-1], l[i[1]-1], l[i[2]-1]])
      
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
b = [int(s) for s in input().split()]
a = int(0)

if N == 1 or N == 2:
  print("0")
else:
  for i in range(N-2):
    for k in range(int(i)+1, N-1):
      for h in range(int(k)+1, N):
        if b[i] != b[k] and b[i] != b[h] and b[k] != b[h]:
          if b[i] + b[k] + b[h] - max([b[i], b[k], b[h]]) > max([b[i], b[k], b[h]]):
            a = a+1
          else:
            pass
        else:
          pass
  print(a)

Submission status: Accepted

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

n = int(input())
*a, = map(int, input().split())
cnt = 0
for i in range(n):
	for j in range(i):
		for k in range(j):
			x, y, z = sorted([a[i], a[j], a[k]])
			if z < x + y and x != y and y != z:
				cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
##B - Making Triangle
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] > L[k]) and (L[j] + L[k] > L[i]) and (L[k] + L[i] > L[j]) and L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
                ans += 1

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
import os
import heapq
import sys,threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10**5)
from io import BytesIO, IOBase
def gcd(a,b):
    if b==0:

        return a
    else:
        return gcd(b,a%b)
def power(x, p,m):
    res = 1
    while p:
        if p & 1:
            res = (res * x) % m
        x = (x * x) % m
        p >>= 1
    return res
def inar():
    return [int(k) for k in input().split()]

def lcm(num1,num2):
    return (num1*num2)//gcd(num1,num2)

def main():
    #t=int(input())
    t=1
    for _ in range(t):

        n=int(input())
        #x,k,d=inar()
        arr=inar()
        arr.sort()
        ans=0
        for i in range(n):
            for j in range(i+1,n):
                for k in range(j+1,n):
                    if (arr[i]+arr[j])>arr[k] and arr[i]!=arr[j]!=arr[k]:
                        ans+=1

        print(ans)




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()
    #threadin.Thread(target=main).start()

Submission status: Accepted

Solution code:
# import copy

# N = list(map(int,input().split(' ')))
# X =[input() for i in range(N[0])] 

def p(X):
    print(X)
N = int(input())
S = list(map(int, input().split()))
count = 0
for i in range(len(S)-2):
    for j in range(i+1,len(S)-1):
        for k in range(j+1,len(S)):
            result = [S[i],S[j],S[k]]
            re = sorted(result,reverse=True)
            if (S[i] != S[j] and S[i] != S[k] and S[j] !=S[k]) and (re[0]< re[1]+re[2]):
                count +=1

p(count)

Submission status: Accepted

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

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

print(res)

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):
    i = sorted(i)
    if len(set(i))==3 and i[0]+i[1]>i[2]:
      count+=1
print(count)

Submission status: Accepted

Solution code:
import itertools

n = int(input())
L = list(map(int, input().split()))
cnt = 0
for i, j, k in itertools.combinations(list(range(n)), 3):
    if (L[i] != L[j]) and (L[j] != L[k])and (L[i] != L[k]):
        if (L[i] < L[j] + L[k]) and (L[j] < L[i] + L[k]) and (L[k] < L[i] + L[j]):
            cnt += 1
print(cnt)

Submission status: Accepted

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

ct=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]<L[j]+L[k] and L[j]<L[k]+L[i] and L[k]<L[i]+L[j] and \
               L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
                ct+=1
                # print(i,j,k)

print(ct)

Submission status: Accepted

Solution code:
n = int(input())
L=list(map(int,input().split()))
import itertools
p = list(itertools.combinations(L, 3))

cnt=0
for j in range(len(p)):
    m =p[j].index(max(p[j]))
    if len(list(set(p[j]))) ==3:
        if m==0:
            if abs(p[j][1]-p[j][2]) < p[j][m] < p[j][1]+p[j][2]:
                cnt+=1
        elif m==1:
            if abs(p[j][0]-p[j][2]) < p[j][m] < p[j][0]+p[j][2]:
                cnt+=1 
        elif m==2:
            if abs(p[j][0]-p[j][1]) < p[j][m] < p[j][0]+p[j][1]:
                cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
import itertools as it

N = int(input())
sides = [int(i) for i in input().split()]


combs = it.combinations(sides, 3)
combs = it.filterfalse(lambda x: not (x[0] != x[1] and x[1] != x[2] and x[0] != x[2]) ,combs)



def is_triangle(comb):
    if comb[0] + comb[1] > comb[2] and comb[1] + comb[2] > comb[0] and comb[0] + comb[2] > comb[1]:
        return True
    return False

count = 0
for comb in combs:
    if is_triangle(comb):
        count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
if a < 3:
    print(0)
    exit()
count = 0
for i in range(a-2):
    for j in range(i+1,a-1):
        for k in range(j+1,a):
            if ar[i] != ar[j] and ar[j] != ar[k] and ar[i] != ar[k]:
                br = [ar[i],ar[j],ar[k]]
                br.sort()
                if br[0] + br[1] > br[2]:
                    count += 1
print(count)

Submission status: Accepted

Solution code:
N = int(input())
line = (input())

strL = line.split()

lenL = len(strL)
ans = 0

#L = []
L = list(map(int, strL))

if lenL < 3:
    ans = 0
else:
    L.sort()
    for i in range(0, lenL-2):
        for j in range(i+1, lenL-1):
            if L[i] == L[j] :
                continue
            for k in range(j+1, lenL):
                #print(i, j, k)
                if L[j] == L[k] or L[k] == L[i]:
                    #print(L[i], L[j], L[k], "NG1")
                    continue
                if L[i] + L[j] <= L[k]:
                    #print(L[i], L[j], L[k], "NG2")
                    break
                else:
                    #print(L[i], L[j], L[k], "OK")
                    ans += 1
print(ans)

Submission status: Accepted

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

if __name__ == "__main__":
    main()

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

Submission status: Accepted

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


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

ans =0

for i in range(0,N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if (L[i]-L[j])*(L[j]-L[k])*(L[i]-L[k]) != 0 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:
n = int(input())
l = list(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] and l[i] + l[j] > l[k]:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N, *L = map(int,open(0).read().split())
def check_different_length(a,b,c):
    if a == b or a == c or b == c:
        return False
    else:
        return True

def check_can_make(a,b,c):
    if a >= b+c or b >= a+c or c >= a+b:
        return False
    else:
        return True

cnt = 0
for a in range(N-2):
    for b in range(a+1,N-1):
        for c in range(b+1,N):
            if check_different_length(L[a],L[b],L[c]):
                if check_can_make(L[a],L[b],L[c]):
                    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys

n=int(input())
l=[int(x) for x in input().rstrip().split()]
l.sort()


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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
a.sort()
res = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if a[i] != a[j] != a[k]:
                if a[i] + a[j] > a[k]:
                    res += 1
print(res)

Submission status: Accepted

Solution code:
def conbination(dct):
    for i in range(len(dct)-2):
        for j in range(i+1,len(dct)-1):
            for k in range(j+1,len(dct)):
                v_lst = list(dct.values())
                k_lst = list(dct.keys())
                l = [ int(k_lst[i]), int(k_lst[j]), int(k_lst[k]) ]
                l_sorted = sorted(l)
                if l_sorted[2] < l_sorted[0] + l_sorted[1]:
                    global cnt 
                    cnt += v_lst[i]*v_lst[j]*v_lst[k]
    return cnt

N = int(input())
L = input().split()
D = dict()
cnt = 0
for i in range(len(L)):
    if L[i] in D.keys():
        D[L[i]] += 1
    elif not L[i] in D.keys():
        D[L[i]] = 1
if len(D) < 3:
    print(0)
elif len(D) >= 3:
    print(conbination(D))

Submission status: Accepted

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

L.sort()
ans = 0

for i in range(N) :
  li = L[i]
  for j in range(i+1, N) :
    flag = False
    lj = L[j]
    if li == lj :
      continue
    for k in range(j+1, N) :
      lk = L[k]
      if lj == lk :
        continue
      if flag :
        continue
      if li + lj > lk :
        ans += 1
      else :
        flag = True
        
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
l = sorted(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 len(set([l[i], l[j], l[k]])) != 3:
                continue
            if l[k] < l[i] + l[j]:
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
def max(x):
    p = x[0]
    for i in range(0,len(x)):
        if p < x[i]:
            p = x[i]
        else:
            p = p
    return p
        
n = int(input())
s = list(map(int, input().split()))
q = 0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if s[i] == s[j] or s[i] == s[k] or s[j] == s[k]:
                q = q
            else:
                if s[i] + s[j] + s[k] - max([s[i],s[j],s[k]]) > max([s[i],s[j],s[k]]):
                    q = q + 1
                else:
                    q = q
print(q)

Submission status: Accepted

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

count = 0

for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue
            max_l = max(l[i],l[j],l[k])
            if 2*max_l < l[i]+l[j]+l[k]:
                count +=1
print(count)

Submission status: Accepted

Solution code:
read = lambda:list(map(int, input().split()))
n = int(input())
l = read()
l.sort()
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 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 - 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 and max(l[i], l[j], l[k]) < sum([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()))
print(sum(i<j<k<i+j for i in L for j in L for k in L))

Submission status: Accepted

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

ans = 0
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())
a=input().split()
count=0

for t in range(n):
  a[t]=int(a[t])
  
for i in range(n-2):
  for j in range(n-2):
    if j>=i:
      for k in range(n-2):
        if k>=j:
          if a[i]!=a[j+1] and a[j+1]!=a[k+2] and a[k+2]!=a[i]:
            if a[i]+a[j+1]>a[k+2] and a[j+1]+a[k+2]>a[i] and a[k+2]+a[i]>a[j+1]:
              count+=1
print(count)

Submission status: Accepted

Solution code:
from itertools import combinations
n = int(input())
L = sorted(map(int, input().split()))
ans = 0
for subset in combinations(L, 3):
    a, b, c = subset
    if len(set(subset)) != 3:
        continue
    if 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 L:
    for j in L:
        for k in L:
            if (not i==j and not j==k and not i==k):
                if ( i+j>k and  i+k>j and k+j>i):
                    ans+=1

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

Submission status: Accepted

Solution code:
import itertools
n=int(input())
l=list(map(int,input().split()))
c_list=list(itertools.combinations(l,3))
ans=0
for i in c_list:
    if(i[0]+i[1]>i[2] and i[1]+i[2]>i[0] and i[2]+i[0]>i[1] and i[0]!=i[1] and i[1]!=i[2] and i[2]!=i[0]):
        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(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] > L[k] and L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            a, b, c = sorted([L[i], L[j], L[k]])
            if a == b or b == c or c == a:
                continue
            if c < a+b:
                ans += 1
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
list.sort(L,reverse=True)
count=0
if N>2:
    for x in range(N):
        for y in range(x+1,N):
            for z in range(y+1,N):
                if L[x]==L[y]:
                    break
                elif (L[z]!=L[y])and(L[x]<(L[y]+L[z])):
                    count+=1
print(count)

Submission status: Accepted

Solution code:
n=input()
L=[int(x) for x in input().split()]

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

print(t)

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

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

N = I()
L = LI()

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

print(count)

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    if N < 3:
        print(0)
        return
    L = list(sorted([int(i) for i in input().split()]))
    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 L[i] + L[j] <= L[k]:
                    break
                ans += 1
    print(ans)

resolve()

Submission status: Accepted

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

def checkTri(a,b,c):
  if a == b or b == c or a == c:
    return False
  if abs(a-c) < b < a+c:
    return True
  else:
    return False

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter
from bisect import bisect_left
import sys
input = sys.stdin.readline


def main():
    _ = int(input())
    L = list(map(int, input().split()))
    counter = Counter(L)
    L = list(set(L))
    L.sort()
    n = len(L)
    
    cumsum = []
    total = 0
    for l in L:
        total += counter[l]
        cumsum.append(total)


    ans = 0
    for i in range(n-2):
        for j in range(i+1, n-1):
            a, b = L[i], L[j]
            limit = a + b
            k = bisect_left(L, limit, lo=j+1)
            pattern = counter[a] * counter[b] * (cumsum[k-1] - cumsum[j])
            ans += pattern

    print(ans)


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):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            tri = [l[i], l[j], l[k]]
            if len(set(tri)) != 3:
                continue
            if 2*max(tri) < sum(tri):
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.readline
import time
from heapq import heappush, heappop
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

n = inp()
l = inpl()

l.sort()

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


# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = sorted(map(int,input().split()))
count = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i] !=  l[j] != l[k]:
                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()))

ans = 0
for i in range(N):
    for j in range(N):
        for k in range(N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i] and abs(L[i] - L[j]) < L[k] < L[i] + L[j]:
                ans += 1
print(ans // 6)

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

print(cnt)

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    L = sorted(map(int, input().split()))
    N = len(L)
    if N < 3:
        print(0)
        return
    ans = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            a = L[i]
            b = L[j]
            if a == b:
                continue
            for k in range(j+1, N):
                c = L[k]
                if a == c or b == c:
                    continue
                if a + b <= c:
                    break
                ans += 1
    print(ans)

solve()

Submission status: Accepted

Solution code:
N = int(input())
ls = 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 ls[i] + ls[j] > ls[k]:
        if ls[i] != ls[j] and ls[j] != ls[k]:
          ans += 1
      else:
        break
        
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！

n = I()
l = LI()
c = itertools.combinations(l, 3)
ans = 0
def check(i,j,k):
    if abs(i-j) < k < i+j and abs(i-k) < j < i+k and abs(k-j) < i < k+j:
        return True
    else:
        return False
for k in c:
    if check(k[0],k[1],k[2]):
        if k[0] != k[1] and k[1] != k[2] and k[2] !=  k[0]:
            ans += 1
print(ans)