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:
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===

def main():
    n = ni()
    l = na()

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


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):
            len = l[i] + l[j] + l[k]
            ma = max(l[i],l[j],l[k])
            rest = len - ma
            if ma < rest 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(i + 1, n):
        for k in range(j + 1, n):
            if not l[i] == l[j] and not l[j] == l[k] and not 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:
from itertools import *
N = int(input())
L = list(map(int,input().split()))
ans = 0

for C in combinations(L,3):
  C = sorted(C)
  if len(set(C))==3 and C[2]<C[0]+C[1]:
    ans+=1

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

n=II()
ll=LI()
ll.sort()
ans=0
#print(ll)
for i in range(n):
    for j in range(i):
        if ll[i]==ll[j]:continue
        for k in range(j):
            if ll[i]==ll[k] or ll[j]==ll[k]:continue
            if ll[i]<ll[j]+ll[k]:
                #print(i,j,k)
                ans+=1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
ok=0
for i in range(n-2):
    for j in range(i,n-1):
        for k in range(j,n):
            p=l[i]
            q=l[j]
            r=l[k]
            if p!=q and q!=r and r!=p and p+q>r and r+q>p and p+r>q:
                ok+=1
print(ok)

Submission status: Accepted

Solution code:
import sys
import bisect
#t=int(input())
t=1
for _ in range(t):
    #r,g,b=map(int,input().split())
    #l=list(map(int,input().split()))
    #l2=list(map(int,input().split()))
    n=int(input())
    l=list(map(int,input().split()))
    d={}
    for i in l:
        d[i]=d.get(i,0)+1
    l=list(set(l))
    l.sort()
    ans=0
    #print(d,l)
    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]:
                    ans+=d[l[i]]*d[l[j]]*d[l[k]]
    print(ans)

Submission status: Accepted

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

if n <= 2:
  print(0)
  exit()
  
ans = 0

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

Submission status: Accepted

Solution code:
import sys
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    L = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                a, b, c = L[i], L[j], L[k]
                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)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal

INF = 1 << 50


def run():
    N, *L = map(int, read().split())
    ans = 0
    for i in range(N-2):
        x = L[i]
        for j in range(i+1, N-1):
            y = L[j]
            for k in range(j+1, N):
                z = L[k]
                if x != y and y != z and z != x and z < x+y and x < y+z and y < x+z:
                    ans += 1


    print(ans)

if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
import itertools
n=int(input())
l=map(int,input().split())
count=0
for a,b,c in itertools.combinations(l,3):
    if a!=b and b!=c and a!=c:
        if abs(b-c)<a and a<b+c:
            count+=1
print(count)

Submission status: Accepted

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

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

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

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

print(ans)

Submission status: Accepted

Solution code:
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
L = rl()

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[i] == L[k] or L[j] == L[k]: 
				continue
			ls = [L[i], L[j], L[k]]
			if ls[0]+ls[1] > ls[2] and ls[1]+ls[2] > ls[0] and ls[2]+ls[0] > ls[1]:
				ans += 1
print(ans)

Submission status: Accepted

Solution code:
# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


# region fastio

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

# endregion
class union_find:
    def __init__(self, n):
        self.n = n
        self.rank = [0]*n
        self.parent = [int(j) for j in range(n)]
    
    def union(self,i,j):
        i = self.find(i)
        j = self.find(j)
        if self.rank[i] == self.rank[j]:
            self.parent[i] = j
            self.rank[j] += 1

        elif self.rank[i] > self.rank[j]:
            self.parent[j] = i
        else:
            self.parent[i] = j

    def find(self, i):
        temp = i
        if self.parent[temp] != temp:
            self.parent[temp] = self.find(self.parent[temp])
        return self.parent[temp]
from math import log2, ceil
from collections import deque, Counter as CC, defaultdict as dd
MOD = int(1e9+7)
def main():
# Enter your code here. Read input from STDIN. Print output to STDOUT
    # for t in range(int(input())):
        
        n = int(input())
        l = [int(j) for j in input().split()]
        ans =0 
        l.sort()
        for i in range(n):
            for j in range(i+1, n):
                for k in range(j+1, n):
                    s = [l[i], l[j], l[k]]
                    s.sort()
                    if((s.count(l[i])>1) or (s.count(l[j])>1) or (s.count(l[k])>1)):
                        continue
                    if(s[0]+s[1]>s[2]):
                        ans+=1
        print(ans)













        



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] and L[j]!=L[k] and L[k]!=L[i]:
                A=list((L[i],L[j],L[k]))
                if 2*max(A)<sum(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 - 2):
  for j in range(i + 1, n - 1):
    for k in range(j + 1, n):
      x, y, z = l[i], l[j], l[k]
      if x != y and y != z and z != x and x + y > z and x + z > y and y + z > x:
        ans += 1

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    ll = rli()
    ans = 0
    for i in range(n):
        li = ll[i]
        for j in range(i+1, n):
            lj = ll[j]
            for k in range(j+1, n):
                lk = ll[k]
                l = [li, lj, lk]
                l.sort()
                if l[0] == l[1] or l[1] == l[2]:
                    continue
                if l[0]+l[1] > l[2]:
                    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] 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:
# -*- coding: utf-8 -*-
# B

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
import itertools

input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

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

ans = 0
for a in list(itertools.combinations(L, 3)):
    a1, a2, a3 = a
    if a1 == a2 or a2==a3 or a3 == a1:
        continue
    a = list(a)
    a.sort()
    if a[2] < a[0] + a[1]:
        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):
            a,b,c=L[i],L[j],L[k]
            if i<j<k and a!=b and b!=c and c!=a:
                if a+b>c and b+c>a and c+a>b:
                    ans+=1
                    #print(a,b,c)

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
L = tuple(map(int, 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[i] == L[k] or L[j] == L[k]:
                continue
            ls = sorted((L[i], L[j], L[k]))
            if ls[0] + ls[1] <= ls[2]:
                continue
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    L = nl()
    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[i] + L[k] > L[j] and L[i] != L[j] and L[j] != L[k] and L[i] != L[k]:
                    ans += 1
    print(ans)


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] 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:
import itertools
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
C=itertools.combinations(range(n),3)
for a,b,c in C:
    if l[a]+l[b]>l[c] and l[a]!=l[b] and l[b]!=l[c] and l[a]!=l[c]:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = rl()
cnt = 0
for lis in list(itertools.combinations(li, 3)):
    a, b, c = sorted(lis)
    if a+b > c and a!=b!=c and c!=a:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ls = list(mapint())
Ls.sort()
ans = 0
for i in range(N-2):
    a = Ls[i]
    for j in range(i+1, N-1):
        b = Ls[j]
        for k in range(j+1, N):
            c = Ls[k]
            if a==b or b==c or c==a:
                continue
            if a+b>c and a+c>b and b+c>a:
                ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    L = list(map(int, input().split()))
    r = set()
    for i in range(N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                    if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                        r.add((i,j,k))
    return len(r)
    #S = input()
    #a,b,c = map(int, input().split())

print(main())

Submission status: Accepted

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

for i in range(n-2):
  for j in range(i+1,n-1):
    for k in range(j+1,n):
      if l[i] != l[j] and  l[j] != l[k] and  l[k] != l[i]:
        if abs(l[i] - l[j]) < l[k] and l[k] < l[i] + l[j]:
          cnt += 1        
    
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
li = list(map(int, input().split()))
li.sort()
c = 0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if li[i] == li[j] or li[j] == li[k] or li[k] == li[i]:
                continue
            else:
                if li[i]+li[j] > li[k] and li[k]+li[j] > li[i] and li[i]+li[k] > li[j]:
                    c += 1
print(c//6)

Submission status: Accepted

Solution code:
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10
    N = II()
    L = LMIIS()
    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 L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                    ans += 1
    print(ans)


    
main()

Submission status: Accepted

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

cnt = 0

for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      a, b, c = L[i], L[j], L[k]
      if a != b and b != c and c != a:
        if max(a, b, c) < a + b + c - max(a, b, c):
          cnt += 1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

def foo(i, j, k):
  if L[i] == L[j] or L[i] == L[k] or L[j] == L[k]:
    return 0
  if L[i] + L[j] - L[k] > 0 and L[i] + L[k] - L[j] > 0 and L[j] + L[k] - L[i] > 0:
    return 1
  else:
    return 0

ans = 0
for i in range(N):
  for j in range(i+1, N):
    for k in range(j+1,N):
      if foo(i, j, k):
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = onem()

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

Submission status: Accepted

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

from itertools import product,permutations as p, combinations as c

n = inp()
#x = list(set(ip()))
x = ip()
ct = 0
for i in c(x,3):
    #print(i)
    a,b,c = list(sorted(i))
    if len(set(i)) == 3 and a+b > c:
        ct += 1
print(ct)

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()
    L = sorted(in_nl())

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


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


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    target = LI()

    target.sort()

    ans = 0

    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                if target[i] != target[j] != target[k]:
                    if target[k] < target[i] + target[j]:
                        ans += 1

    print(ans)


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] > 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(ans)

Submission status: Accepted

Solution code:
# Date [ 2020-08-15 21:04:37 ]
# Problem [ b.py ]
# Author Koki_tkg

import sys;      from decimal import Decimal
import math;     from itertools import combinations, product
import bisect;   from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 6 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def lcm(a: int, b: int) -> int: return (a * b) // math.gcd(a, b)

def Main():
    n = read_int()
    l = read_int_list()
    cnt = 0

    for i in combinations(l, r=3):
        a, b, c = i
        if a != b and b != c and c != a:
            if a + b > c and b + c > a and c + a > b:
                cnt += 1
    print(cnt)

if __name__ ==  '__main__':
    Main()

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
l = na()
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] 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:
# = map(int, input().split())
N = int(input())
L = list(map(int, input().split()))
ans = 0
for k in range(N-2):
  for j in range(k+1, N-1):
    for l in range(j+1, N):
      li = [L[k], L[j], L[l]]
      li.sort()
      if li[0] < li[1] < li[2]:
        if li[2] < li[0] + li[1]:
          ans += 1
print(ans)

Submission status: Accepted

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

c = 0

for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            node = [l[i], l[j], l[k]]
            node.sort()
            if node[0] != node[1] and node[1] != node[2] and node[2] < node[1] + node[0]:
                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):
            x, y, z = sorted([l[i], l[j], l[k]])[::-1]
            if x != y and y != z and z != x and y + z > x:
                ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
b = list(map(int,input().split()))
ret = 0
from itertools import combinations
for x,y,z in list(combinations(range(n),3)):
    x,y,z=b[x],b[y],b[z]
    if x == y or x == z or y == z:
        continue
    else:
        if x+y>z and y+z>x and z+x>y:
            ret += 1

print(ret)

Submission status: Accepted

Solution code:
N=int(input())
*L,=map(int,input().split())
i=0
ans=0
while i<N:
    j=i+1
    while j<N:
        k=j+1
        while k<N:
            a,b,c=sorted([L[i],L[j],L[k]])
            if c<a+b and len(set([a,b,c]))==3:
                ans+=1
            k+=1
        j+=1
    i+=1
print(ans)

Submission status: Accepted

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

arr.sort()
length = len(arr)

ans = 0
for x in range(length):
    for y in range(x + 1, length):
        for z in range(y + 1, length):
            if arr[x] != arr[y] and arr[y] != arr[z] and arr[z] != arr[x]:
                if arr[x] + arr[y] > arr[z]:
                    ans += 1

print(ans)

Submission status: Accepted

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