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:
#!/usr/bin/env python3

from itertools import combinations

def main():
  N = int(input())
  l = list(sorted(map(int,input().split())))
  combi = combinations(l,3)
  def judge(c):
    return c[0] < c[1] < c[2] and c[0] + c[1] > c[2]
  print(sum(judge(c) for c in combi))
  return

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import combinations 

N = int(input())
L_list = list(map(int, input().split()))
ans = 0

for x, y, z in combinations(L_list, 3):
  #print(x, y, z)
  if x == y or y == z or z == x:
    continue
  if x + y > z and y + z > x and z + x > y:
    ans += 1

print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations 

N = int(input())
L_list = sorted(list(map(int, input().split())))
ans = 0

for x, y, z in combinations(L_list, 3):
  #print(x, y, z)
  if x == y or y == z or z == x:
    continue
  if x + y > z and y + z > x and z + x > y:
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L = sorted(list(map(int,input().split())))
ans = 0
for k in range(2,len(L)):
    for j in range(1,k):
        for i in range(0,j):
            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()))


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

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 and b+c>a and c+a>b:
                ans += 1
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# a!=b b!=c c!=a
# a+b>c and b+c>a and c+a>b

N = int(input())
L_list = list(map(int, input().split()))
result = 0
setL = list(set(L_list))

countL = []  # setLの要素がL_listに何個ずつ含まれるかを記録。setLの要素の順番と同じ順番
def num_count(dum):
   return L_list.count(dum)
countL = list(map(num_count,setL))
#print(countL)
# print("setL",setL)

for i in range(len(setL)):
    a=setL[i]
    for j in range(i+1,len(setL)):
        b=setL[j]
        for k in range(j+1,len(setL)):
            # print("i=",i,"j=",j,"k=",k)
            c=setL[k]
            if(a+b > c and b+c > a and c+a > b):
                # print("a=",a,"b=",b,"c=",c)
                # print(countL[i]," ",countL[j]," ",countL[k])
                result += countL[i]*countL[j]*countL[k]
print(result)

Submission status: Accepted

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

cnt = 0
for i in range(n):
    for j in range(i,n):
        for k in range(j,n):
            q = [l[i],l[j],l[k]]
            q.sort()
            if (len(q) == len(set(q))) and (q[0] + q[1] > q[2]):
                cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
    # -*- coding: utf-8 -*-

def main():
    n = int(input())
    v = list(map(int, input().split()))

    counter = 0
    for ia in range(len(v) - 2):
        a = v[ia]
        for ib in range(ia + 1, len(v) - 1):
            b = v[ib]
            for ic in range(ib + 1, len(v)):
                c = v[ic]
                if (abs(a - b) < c) and (c < (a + b)):
                    if (a != b) and (b != c) and (c != a):
                        counter += 1
    print(counter)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools
import itertools

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

ans = 0
for l1, l2, l3 in itertools.combinations(L, 3):
    if l1 == l2 or l2 == l3:
        continue
    
    if l3 < l1 + l2:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
from itertools import combinations

N = int(input())
L = Counter(list(map(int, input().split())))
ans = 0
for a, b, c in combinations(L.keys(), 3):
    if a+b>c and b+c>a and c+a>b:
        ans += L[a]*L[b]*L[c]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
for a, b, c in itertools.combinations(l, 3):
    if a < b < c and a + b > c:
        ans +=1
print(ans)

Submission status: Accepted

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

res = 0
for t0 in range(0,len(l)-2):
    for t1 in range(t0+1,len(l)-1):
        for t2 in range(t1+1,len(l)):

             if (l[t0] + l[t1] > l[t2] and l[t0] + l[t2] > l[t1] and l[t1] + l[t2] > l[t0] and l[t0]!=l[t1] and l[t1]!=l[t2] and l[t0]!=l[t2]):
                 res += 1

print(res)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import itertools
N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
c=0
for i in range(N):
    for j in range(i):
        for k in range(j):
            if L[j]-L[k]<L[i]<L[j]+L[k] and L[j]!=L[k]and L[j]!=L[i] and L[i]!=L[k]:
                c+=1
print(c)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

for i in itertools.combinations(l,3):
    a = i[0]
    b = i[1]
    c = i[2]
    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:
#!/usr/bin/env python3

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

print(ret)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

N = input()
L = input().split(' ')

l = len(L)
L = [int(s) for s in L]
L.sort()
  
a = 0
for i in range(l - 2):
    for j in range(i + 1, l - 1):
        for k in range(j + 1, l):
            if (L[i] + L[j]) > L[k]:
                if (L[i] != L[j]) and (L[k] != L[j]) and (L[i] != L[k]):
                    a += 1
print(int(a))

Submission status: Accepted

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

Submission status: Accepted

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

if len(l) < 3:
    print(0)
    exit()

cnt = 0

for i in range(len(l)):
    j = i + 1
    for j in range(len(l)):
        k = j + 1
        for k in range(len(l)):
            a = l[i]
            b = l[j]
            c = l[k]
            if (a < b < c) and (((a + b) > c) and ((b + c) > a) and ((c + a) > b)):
                cnt += 1

print(cnt)

Submission status: Accepted

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

l.sort()

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

print(cnt)

Submission status: Accepted

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

ans = 0
if N >= 3:
    for p in range(N):
        P = L[p]
        for q in range(p+1,N):
            Q = L[q]
            for r in range(q+1,N):
                R = L[r]
                if P!=Q and Q != R and R != P :
                    if P+Q>R and Q+R>P and R+P>Q:
                        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N,*L = map(int, open(0).read().split())
L.sort()
if N <= 2:
    print(0)
else:
    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
                else:
                    if L[i] + L[j] > L[k]:
                        ans += 1
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    from itertools import combinations
    import sys
    input = sys.stdin.readline

    n = int(input())
    l = list(map(int, input().split()))
    comb = list(combinations(range(n), 3))
    ans = 0

    for i, j, k in comb:
        a = l[i]
        b = l[j]
        c = l[k]

        # 3変数のうち、最大値が残りの2変数よりも大きいことを楽に実装する
        # See:
        # https://www.youtube.com/watch?v=auQRcs5JMwE&feature=youtu.be
        # a + b <= c (ただし、a < b < c)
        # 両辺にcを足す
        # a + b + c <= c + c
        if a == b:
            continue
        if b == c:
            continue
        if c == a:
            continue

        if sum([a, b, c]) <= 2 * max(a, b, c):
            continue

        ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    from itertools import combinations
    import sys
    input = sys.stdin.readline

    n = int(input())
    l = list(map(int, input().split()))
    comb = list(combinations(range(n), 3))
    ans = 0

    for i, j, k in comb:
        a = l[i]
        b = l[j]
        c = l[k]

        total = a + b + c
        max_value = max(a, b, c)
        diff = total - max_value

        if a == b:
            continue
        if b == c:
            continue
        if c == a:
            continue

        if diff <= max_value:
            continue

        ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
L = inpl()

cnt = 0
for i,j,k in itertools.combinations(L,3):
    if i != j and j != k and k != i and max(i,j,k) < (i+j+k) - max(i,j,k):
        cnt += 1

print(cnt)

Submission status: Accepted

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

cnt = 0

for i in range(0, n-2):
    t = l[i]
    for b in range(i+1, n-1):
        s = l[b]
        if (t != s):
            for k in range(b+1, n):
                a = s + l[k]
                if(a > t and s != l[k]):
                    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    N = Scanner.int()
    L = Scanner.map_int()
    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] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                    ans += 1
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    solve()


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-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if max(L[i],L[j],L[k]) < L[i]+L[j]+L[k]-max(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:
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):
            tmp = [L[i],L[j],L[k]]
            if len(set(tmp)) == 3 and max(tmp) < sum(tmp)/2:
                ans += 1

print(ans//6)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def is_triangle(a, b, c):
    return len({a, b, c})==3 and a+b>c and b+c>a and c+a>b

n = int(input())
if n <= 2:
    print(0)
    exit()
*l, = 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 is_triangle(l[i], l[j], l[k]):
                ans += 1
print(ans)

Submission status: Accepted

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

def check_tri(x):#x==[a,b,c]
  x = sorted(x)
  #print("sort",x)
  if x[0]==x[1] or x[0]==x[2] or x[1]==x[2]:
    return 0
  elif x[2]<x[0]+x[1]:
    return 1
  else:
    return 0
s = 0
for i in range(0,n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      a,b,c = l[i],l[j],l[k]
      #print(i,j,k)
      x =check_tri([a,b,c])
      #print("ch",x)
      s+=x
print(s)

Submission status: Accepted

Solution code:
from collections import Counter
import itertools 

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

S = list(set(L))

ans = 0
for a, b, c in itertools.combinations(S, 3):
    if a + b > c and a + c > b and b + c > a:
        ans += (C[a]*C[b]*C[c])

print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


from itertools import combinations
from collections import Counter as cc
def main():
    def check(a, b, c):
        return a+b > c

    n = ii()
    l = li()
    l = cc(l)
    x = list(combinations(l.keys(), 3))

    cnt = 0
    for a, b, c in x:
        if check(a, b, c) and check(b, c, a) and check(c, a, b):
            cnt += l[a]*l[b]*l[c]
    print(cnt)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = list(map(int, input().split()))
ans = 0
comb = itertools.combinations(l, 3)
for i in comb:
    if len(set(i)) == 3:
        if (i[0] + i[1]) > i[2] and (i[1] + i[2]) > i[0] and (i[2] + i[0]) > i[1]:
            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]:
            continue
        for k in range(j+1, N):
            if L[k] >= L[i] + L[j]:
                break
            if L[j] == L[k]:
                continue
            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 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()))
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] 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_L = [int(x) for x in input().split()]

L_L.sort()
ans = 0

for i in range(N):
    _li = L_L[i]
    for j in range(i+1, N):
        _lj = L_L[j]
        if _li == _lj:
            continue
        for k in range(j+1, N):
            _lk = L_L[k]
            if _li == _lk or _lj == _lk:
                continue
            if _li + _lj > _lk:
                ans += 1


print(ans)

Submission status: Accepted

Solution code:

import sys
import math
# from collections import Counter
input = sys.stdin.readline
# import numpy as np

def inp():
    return(int(input()))

def inps():
    return str(input())
    
def inlt():
    return(list(map(int,input().split())))
    
def inlst():
    return(list(map(str,input().split())))
    
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split())) 

def tri(arr):
    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] or arr[i]==arr[k] or arr[k]==arr[j]:
                    continue
                if arr[i]+arr[j]>arr[k] and arr[i]+arr[k]>arr[j] and arr[k]+arr[j]>arr[i]:
                    cnt+=1
    return cnt
n = inp()
arr = inlt()
print(tri(arr))

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int,input().split()))
count = 0
for i in range(N):
	for j in range(N):
		for k in range(N):
			if a[i] + a[j] + a[k] - max(a[i], a[j],a[k]) > max(a[i], a[j],a[k]) and a[i] != a[j] and a[i] != a[k] and a[k] != a[j]:
				count += 1
count = count //6
print(count)

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

Submission status: Accepted

Solution code:
N=int(input())
S=list(map(int,input().split()))
s=list(set(S))
s.sort()
x=len(s)
Z=0
for i in range(x-1):
  a=s[i]
  A=S.count(a)
  for j in range(x-i-1):
    b=s[i+1+j]
    B=S.count(b)
    t=[i for i in S if i>b and i<a+b]
    T=len(t)
    Z+=A*B*T
print(Z)

Submission status: Accepted

Solution code:
#B
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse= True)
M = 0
for i in range(N):
    for j in range(i):
        for k in range(j):
            if (i != j) and (i != k) and (j != k):
                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[i]+L[k]) > L[j]) :
                        M += 1 
                        #print(L[i],L[j],L[k],M)       
# 出力
print(M)

Submission status: Accepted

Solution code:
import itertools
n = int(input())
l = [int(i) for i in input().split()]
ls = list(itertools.combinations(range(n),3))
ans = 0
if n < 3:
    print(0)
else:
    for i in range(len(ls)):
        index_ls = list(ls[i])
        tmp_ls = [l[index_ls[0]],l[index_ls[1]],l[index_ls[2]]]
        tmp_ls.sort()
        if tmp_ls[0] + tmp_ls[1] > tmp_ls[2]:
            if tmp_ls[0] == tmp_ls[1] or tmp_ls[1] == tmp_ls[2] or tmp_ls[0] == tmp_ls[2]:
                continue
            else:
                ans += 1
    print(ans)

Submission status: Accepted

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

for l in ls:
    for other_l1 in [i for i in ls if i != l]:
        for other_l2 in [i for i in ls if i not in [l, other_l1]]:
            new_l = [l, other_l1, other_l2]
            new_l.sort()
            if new_l[0] + new_l[1] > new_l[2]:
                c += 1

print(int(c / 6))

Submission status: Accepted

Solution code:
N=int(input())
L=[int(i) for i in input().split()]
cnt=0
if N<3:print(0)
else:
	for i in range(N):
		for j in range(i):
			for k in range(j):
				if (L[i]-L[j])*(L[j]-L[k])*(L[k]-L[i])!=0:
					if (L[i]+L[j]-L[k])>0 and  (L[j]+L[k]-L[i])>0 and  (L[i]+L[k]-L[j])>0:cnt+=1

	print(cnt)

Submission status: Accepted

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

L = sorted(L)

ln = len(L)

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
S=list(map(int,input().split()))
s=list(set(S))
s.sort()
x=len(s)
Z=0
for i in range(x-1):
  a=s[i]
  A=S.count(a)
  for j in range(x-i-1):
    b=s[i+1+j]
    B=S.count(b)
    t=[i for i in S if i>b and i<a+b]
    T=len(t)
    Z+=A*B*T
print(Z)

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):
            x=L[i]+L[j]-L[k]
            y=L[j]+L[k]-L[i]
            z=L[k]+L[i]-L[j]
            if min(x,y,z)>0 and len({L[i],L[j],L[k]})==3:
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 175
# B - Making Triangle

import bisect

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]:
            pass
        else:
            ab=L[i]+L[j]
            c=bisect.bisect_left(L,ab)
            bequalc=bisect.bisect_right(L,L[j])
            ans+=c-(bequalc)

print(ans)

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
L = LI()
c = itertools.combinations(L, 3)
ans = 0
for i, j, k in c:
    if i+j > k and j+k > i and i+k > j and i != j and j != k and k != i:
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ls_L = list(map(int,input().split()))
ls_L.sort()
  
ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            a = ls_L[i]
            b = ls_L[j]
            c = ls_L[k]
            if c < a + b:
                if (a - b) * (b - c) * (c - a) != 0:
                    ans += 1
                    
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

l = list(map(int,input().split()))
l.sort()
t = 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[i] == l[k]:
                continue
            else:
                if l[i] + l[j] > l[k]:
                    t += 1
print(t)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    L = LI()
    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 abs(L[i] - L[j]) < L[k] and L[k] < L[i] + L[j]:
                    cnt += 1
    print(cnt)

main()

Submission status: Accepted

Solution code:
import itertools

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

for a, b, c in itertools.combinations(l, 3):
    a, b, c = sorted([a, b, c])
    if a != b and b != c and c < a + b:
        cnt += 1
print(cnt)

Submission status: Accepted

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

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