input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
def s(generator, splitter, mapper):
return [ mapper(s) for s in generator().split(splitter) ]
# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
return [ int(s) for s in input().split(" ")]... |
import sys
def log(*args, **kwargs):
print(*args, file=sys.stderr)
log("hogehoge")
a,b = map(int, input().split())
print(max(a*b, a+b, a-b))
| p02945 |
a, b = list(map(int, input().split()))
x = a+b
y = a-b
v = a*b
print((max(x,y,v))) |
a, b = list(map(int, input().split()))
x = a+b
y = a-b
z = a*b
print((max(x,y,z))) | p02945 |
a,b=list(map(int, input().split()))
print((max(a+b,a-b,a*b))) | A,B=list(map(int,input().split()))
C=A+B
D=A-B
E=A*B
ans=max(C,D,E)
print(ans) | p02945 |
A, B = list(map(int, input().split()))
ans = max(A + B, A - B, A * B)
print(ans)
| A, B = list(map(int, input().split()))
x = A+B
y =A-B
z =A*B
if x > y:
if x>z:
ans = x
else:
ans = z
else:
if y>z:
ans = y
else:
ans = z
print(ans)
| p02945 |
A, B = list(map(int, input().split()))
if B > 0:
if A * B > (A + B):
val = A * B
else:
val = A + B
else:
if A * B > (A - B):
val = A * B
else:
val = A - B
print(("%d"%val))
| A, B = list(map(int, input().split()))
print(("%d"% max([A + B, A - B, A* B])))
| p02945 |
i = list(map(int, input().split()))
l = [i[0] + i[1], i[0] - i[1], i[0]*i[1]]
print((max(l, key=int))) | i = list(map(int, input().split()))
a = i[0]+i[1]
b = i[0]*i[1]
c = i[0]-i[1]
print((max(a,b,c)))
| p02945 |
a, b = list(map(int, input().split()))
print((max(a+b, a-b, a*b))) | a, b = list(map(int, input().split()))
print((max([a+b, a-b, a*b]))) | p02945 |
# A - +-x
def main():
a, b = list(map(int, input().split()))
print((max([a+b, a-b, a*b])))
if __name__ == '__main__':
main() | # A - +-x
def main():
a, b = list(map(int, input().split()))
print((max(a+b, a-b, a*b)))
if __name__ == '__main__':
main() | p02945 |
A,B=list(map(int,input().split()))
print((max(A*B,A+B,A-B))) | A,B = list(map(int,input().split()))
print((max(A+B,A-B,A*B))) | p02945 |
a, b = list(map(int, input().split()))
print((max(a-b, a+b, a*b))) | n, m = list(map(int, input().split()))
print((max(n+m, n-m, n*m))) | p02945 |
a,b = list(map(int,input().split()))
c = max(a+b, a-b, a*b)
print(c) | def resolve():
a, b = list(map(int, input().split()))
print((max(a+b, a-b, a*b)))
resolve() | p02945 |
a,b = list(map(int, input().split()))
li = [a+b, a-b,a*b]
print((max(li)))
| a,b=list(map(int,input().split()))
print((max(a+b,a-b,a*b))) | p02945 |
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
def getN():
return int(eval(input()))
def getList():
return list(map(int, input().split()))
import math
a, b = getList()
print((max([a+b, a-b, a*b])))
# print(ans) | import sys
# from collections import defaultdict, deque
# import math
# import copy
# from bisect import bisect_left, bisect_right
# import heapq
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(eval(input()))
getList = lambda... | p02945 |
A,B = list(map(int,input().split()))
print((max(A+B,A-B,A*B)))
| a , b = input().split()
a =int(a)
b =int(b)
print((max(a + b,a - b,a * b)))
| p02945 |
a,b = list(map(int,input().split()))
print((max(a+b,a-b,a*b))) | a,b = list(map(int,input().split()))
ans1 = a+b
ans2 = a-b
ans3 = a*b
ans = max(ans1,ans2,ans3)
print(ans) | p02945 |
# ABC143 D Triangles
n = int(eval(input()))
l_list = [int(x) for x in input().split()]
l_list.sort()
ans = 0
# (i < j < k) -> (_a < _b < _c)
for i in range(n-2):
_a = l_list[i]
for j in range(i+1,n-1):
_b = l_list[j]
_tmp = _a + _b
for k in range(j+1,n):
_c ... | # ABC143 D Triangles
import bisect
n = int(eval(input()))
l_list = [int(x) for x in input().split()]
l_list.sort()
ans = 0
for i in range(n-2):
_a = l_list[i]
for j in range(i+1,n-1):
_b = l_list[j]
_tmp = bisect.bisect_left(l_list, _a+_b)
if j < _tmp:
ans... | p02888 |
N = int(eval(input()))
L = list(map(int, input().split()))
from itertools import combinations
X = list(combinations(L, 3))
ans = 0
for a,b,c in X:
if a < b + c and b < c + a and c < a + b:
ans += 1
print(ans) | N = int(eval(input()))
L = list(map(int, input().split()))
SL = sorted(list(L))
A = [0] * (10 ** 3 + 10)
for i in SL:
A[i] = True
for i in range(len(A)):
if A[i] == True:
A[i] = A[i-1] + 1
else:
A[i] = A[i-1]
# print(A[4-1] - A[2])
ans = 0
for i in range(N-2):
for j i... | p02888 |
N = int(eval(input()))
L = list(map(int, input().split()))
SL = sorted(list(L))
A = [0] * (10 ** 3 + 10)
for i in SL:
A[i] = True
for i in range(len(A)):
if A[i] == True:
A[i] = A[i-1] + 1
else:
A[i] = A[i-1]
# print(A[4-1] - A[2])
ans = 0
for i in range(N-2):
for j i... | N = int(eval(input()))
L = list(map(int, input().split()))
SL = sorted(list(L))
# print('SL', SL)
import bisect
ans = 0
for i in range(N-2):
for j in range(i+1, N-1):
ab = SL[i] + SL[j]
# print(i, j)
# print(SL[i], SL[j])
r = bisect.bisect_left(SL, ab)
l = j + 1... | p02888 |
import bisect
n = int(eval(input()))
l = list(map(int,input().split()))
co = []
ol = sorted(l)
nl = sorted(l,reverse=True)
for i in range(1,n):
for j in range(1,n):
if i<j:
co.append(nl[i]+nl[j])
nco = list(reversed(co))
sk = 0
g = 0
for i in range(2,n):
a = ol[i]
x = nco[... | import bisect
n=int(eval(input()))
l=sorted(list(map(int,input().split())))
g=0
for ai in range(n-2):
for bi in range(ai+1,n-1):
g+=max(0,bisect.bisect_left(l,l[bi]+l[ai])-1-bi)
print(g)
| p02888 |
N=int(eval(input()))
L=list(map(int,input().split()))
L=sorted(L)
a=0
for i in range(N-1):
for k in range(1,N-i-1):
a=a+sum(x<L[i]+L[i+k] for x in L[i+k+1:N])
print(a) | import bisect
N=int(eval(input()))
L=list(map(int,input().split()))
L=sorted(L)
ans=0
for i in range(N-1):
for k in range(i+1,N-1):
a=L[i]+L[k]
b=bisect.bisect_left(L,a)
ans=ans+(b-k-1)
print(ans) | p02888 |
import itertools
n = int(eval(input()))
list_score = list(map(int, input().split()))
list_score.sort()
p_list = list(itertools.combinations(list_score, 3))
a = len(p_list)
ans = 0
for i in range(a):
if p_list[i][0] + p_list[i][1] > p_list[i][2]:
ans += 1
print(ans) | import itertools
n = int(eval(input()))
list_score = list(map(int, input().split()))
list_score.sort()
ans = 0
for i in range(0, n):
for j in range(i+1, n):
for k in range(i+1, j):
if list_score[k] + list_score[i] > list_score[j]:
ans += 1
print(ans) | p02888 |
N = int(eval(input()))
ll = list(map(int, input().split()))
def is_triangle(t):
a, b, c = t
if a < b + c and b < c + a and c < a + b:
return True
return False
import itertools
comb = list(itertools.combinations(ll ,3))
ans = len(list(filter(is_triangle, comb)))
print(ans) | eval(input())
ll = list(map(int, input().split()))
ll.sort()
def is_triangle(a, b, c):
if a < b + c and b < c + a and c < a + b:
return True
return False
ans = 0
for i, a in enumerate(ll):
for j, b in enumerate(ll[i+1:]):
climit = a + b
for k, c in enumerate(ll[i+j+2:]):
if c >= ... | p02888 |
n=int(eval(input()))
l=list(map(int,input().split()))
l.sort(reverse=True)
ans=0
for i in range(0,n-1):
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]:
ans+=1
#print(l[i],l[j],l[k])
print(ans)
| n=int(eval(input()))
l=list(map(int,input().split()))
l.sort(reverse=True)
ans=0
for i in range(0,n-2):
for j in range(i+1,n-1):
left = j
right = n
while right-left>1:
mid = (left + right)//2
if l[i]+l[j]>l[mid] and l[i]+l[mid]>l[j] and l[mid]+l[j]>l[i]:
left = m... | p02888 |
n = int(eval(input()))
L = list(map(int,input().split()))
def tri_judge(a,b,c):
if a<b+c and b<c+a and c<a+b:
return 1
else:
return 0
cnt = 0
for i in range(n-2):
for j in range(i+1,n-1):
check = L[i]+L[j]
for k in range(j+1,n):
if check>L[k]:
... | import bisect
N = int(eval(input()))
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N):
for j in range(i+1,N):
cnt += bisect.bisect_left(L,L[i]+L[j])-(j+1)
print(cnt) | p02888 |
from bisect import bisect_left
n = int(eval(input()))
a = sorted(map(int, input().split()))
print((sum(bisect_left(a, a[i] + a[j], i + 1) - i - 1
for i in range(1, n - 1) for j in range(i))))
| from bisect import bisect_right
n = int(eval(input()))
a = sorted(map(int, input().split()))
print((sum(j - bisect_right(a, a[i] - a[j], 0, j)
for i in range(2, n) for j in range(1, i)))) | p02888 |
import itertools
def d():
_ = int(eval(input()))
ls = list(map(int, input().split()))
combs = list(itertools.combinations(ls, 3))
count = 0
a = 0
b = 1
c = 2
for comb in combs:
if comb[a] < comb[b] + comb[c] and comb[b] < comb[c] + comb[a] and comb[c] < comb[a] + ... | import itertools
def d():
_ = int(eval(input()))
ls = list(map(int, input().split()))
combs = list(itertools.combinations(ls, 2))
count = 0
a = 0
b = 1
visited = set()
for comb in combs:
for l in ls:
if {comb[a], comb[b], l} not in visited:
... | p02888 |
import itertools
def d():
_ = int(eval(input()))
ls = list(map(int, input().split()))
combs = list(itertools.combinations(ls, 2))
count = 0
a = 0
b = 1
visited = set()
for comb in combs:
for l in ls:
if {comb[a], comb[b], l} not in visited:
... | def d():
n = int(eval(input()))
ls = list(map(int, input().split()))
ls.sort()
count = 0
for i in range(n-1):
k = i + 2
for j in range(i+1, n-1):
while k < n and ls[i] + ls[j] > ls[k]:
k += 1
count += k - j - 1
print(count)
... | p02888 |
import bisect
n = int(eval(input()))
l = sorted(list(map(int, input().split())))
ans = 0
for i in range(n-2):
a = l[i]
for j in range(i + 1, n-1):
ans += bisect.bisect_left(l, l[j]+a, lo = j + 1)-j-1
print(ans) | import bisect
n = int(eval(input()))
l = sorted(list(map(int, input().split())))
ans = 0
for i in range(n-2):
a = l[i]
for j in range(i + 1, n-1):
ans += bisect.bisect_left(l, l[j]+a)-j-1
print(ans) | p02888 |
import math
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
ans = 0
for a in range(N - 2):
b = a + 1
c = a + 2
while c < N and b < N - 1:
if L[c] >= L[a] + L[b]:
ans += c - 1 - b
b += 1
if b == c:
c += 1
... | import math
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
ans = 0
for a in range(N - 2):
b = a + 1
c = a + 2
while c < N and b < N - 1:
if L[c] >= L[a] + L[b]:
ans += c - 1 - b
b += 1
if b == c:
c += 1
... | p02888 |
import math
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
ans = 0
for a in range(N - 2):
b = a + 1
c = a + 2
while c < N and b < N - 1:
if L[c] >= L[a] + L[b]:
ans += c - 1 - b
b += 1
if b == c:
c += 1
... | N = int(eval(input()))
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(0, N - 2):
a = L[i]
for j in range(i + 1, N - 1):
b = L[j]
ok = j + 1
ng = N - 1
if L[ng] < a + b:
ans += ng - j
continue
if L[ok] >= a + b:
... | p02888 |
value = 0
N = int(eval(input()))
L = list(map(int,input().split()))
L = sorted(L)
for i in range(N-2):
for j in range(i+1,N-1):
x = L[i]+L[j]
B = N-1
A = j
max_c_index = j
# while True:
while A <= B: #A>Bとなったときに停めるようにすれば簡潔
# M = A + (B-A)//2
M = (A+B)//2 #こう書くほうがシンプル... | from bisect import bisect_left
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N): # 1番短い棒
for j in range(i + 1, N): # 真ん中の長さの棒
ans += bisect_left(L, L[i] + L[j]) - (j + 1)
print(ans) | p02888 |
from bisect import bisect_left
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N): # 1番短い棒
for j in range(i + 1, N): # 真ん中の長さの棒
ans += bisect_left(L, L[i] + L[j]) - (j + 1)
print(ans) | from bisect import bisect_left
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N-2): # 1番短い棒 #どうせ増えないからNでも多分大丈夫
for j in range(i + 1, N-1): # 真ん中の長さの棒
ans += bisect_left(L, L[i] + L[j]) - (j + 1)
print(ans) | p02888 |
import sys
import itertools
# import numpy as np
import time
import math
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
L = list(sorted(map(int, readline().... | import sys
import itertools
# import numpy as np
import time
import math
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
L = list(sorted(map(int, readline().... | p02888 |
from bisect import bisect_left
from bisect import bisect_right
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
"""
短いほうから2本固定して条件に合うものをさがす(長いほうから2本固定でもOK)
最長と最短を固定するとややこしくなるから、こういう場合は最長/最短どちらかから固定するほうがいいか
"""
ans = 0
for i in range(N-2):
for j in range(i+1, N-1):
# ... | from bisect import bisect_left
from bisect import bisect_right
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
"""
短いほうから2本固定して条件に合うものをさがす(長いほうから2本固定でもOK)
最長と最短を固定するとややこしくなるから、こういう場合は最長/最短どちらかから固定するほうがいいか
"""
ans = 0
for i in range(N-2):
a = L[i]
for j in range(i+1, N-1... | p02888 |
from bisect import bisect_left
from bisect import bisect_right
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
"""
短いほうから2本固定して条件に合うものをさがす(長いほうから2本固定でもOK)
最長と最短を固定するとややこしくなるから、こういう場合は最長/最短どちらかから固定するほうがいいか
"""
ans = 0
for i in range(N-2):
a = L[i]
for j in range(i+1, N-1... | from bisect import bisect_left
from bisect import bisect_right
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
"""
短いほうから2本固定して条件に合うものをさがす(長いほうから2本固定でもOK)
最長と最短を固定するとややこしくなるから、こういう場合は最長/最短どちらかから固定するほうがいいか
"""
ans = 0
for i in range(N-2):
a = L[i]
for j in range(i+1, N-1... | p02888 |
import bisect
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
for j in range(i+1, N-1):
index = bisect.bisect_right(L, L[i] + L[j]-1)
ans += index - j - 1
print(ans)
| from bisect import bisect_left
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
for j in range(i+1, N):
x = L[i] + L[j]
y = bisect_left(L, x)
ans += y - j - 1
print(ans) | p02888 |
from collections import deque
from bisect import bisect_left
n = int(eval(input()))
l = sorted(map(int, input().split()))
ld = deque(l)
cnt = 0
for a in range(n - 2):
l_a = ld.popleft()
for b in range(a + 1, n - 1):
cnt += bisect_left(l[b + 1 :], l_a + l[b])
print(cnt) | from collections import deque
from bisect import bisect_left
n = int(eval(input()))
l = sorted(map(int, input().split()))
ld = deque(l)
cnt = 0
for a in range(n - 2):
l_a = ld.popleft()
for b in range(a + 1, n - 1):
cnt += bisect_left(l, l_a + l[b]) - b - 1
print(cnt) | p02888 |
from collections import deque
from bisect import bisect_left
n = int(eval(input()))
l = sorted(map(int, input().split()))
ld = deque(l)
cnt = 0
for a in range(n - 2):
l_a = ld.popleft()
for b in range(a + 1, n - 1):
cnt += bisect_left(l, l_a + l[b]) - b - 1
print(cnt) | def main():
from collections import deque
from bisect import bisect_left
n = int(eval(input()))
l = sorted(map(int, input().split()))
ld = deque(l)
cnt = 0
for a in range(n - 2):
l_a = ld.popleft()
for b in range(a + 1, n - 1):
cnt += bisect_left(l, l_... | p02888 |
#coding:utf-8
import sys
import bisect
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
input = lambda : given().rstrip()
LMIIS = lambda : list(map(int,input().split()))
II = lambda... | #coding:utf-8
import sys
import bisect
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
input = lambda : given().rstrip()
LMIIS = lambda : list(map(int,input().split()))
II = lambda... | p02888 |
import itertools
N = int(eval(input()))
L = list(map(int, input().split()))
T = list(itertools.combinations(L,3))
ans = 0
for t in T:
if t[0] < t[1]+t[2] and t[1] < t[0]+t[2] and t[2] < t[0]+t[1]:
ans += 1
print(ans)
| N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for n1 in range(N):
for n2 in range(n1+1, N):
for n3 in range(n2+1, N):
if L[n1] + L[n2] > L[n3]:
ans += 1
print(ans)
| p02888 |
import math
N=int(eval(input()))
S=input().split()
list=[]
for i in range(0,N):
list.append(int(S[i]))
list.sort()
ans=0
for i in range(0,N-2):
a=list[i]
for j in range(i+1,N-1):
b=list[j]
L=j+1
R=N-1
while True:
if L==R or R==L+1:
break
if list[math.floor((L+R... | import bisect
n = int(eval(input()))
l = sorted(list(map(int,input().split())))
count = 0
for i in range(n):
for j in range(i+1,n):
index = bisect.bisect_left(l,l[i]+l[j])
count += index - j - 1
print(count) | p02888 |
import itertools
N = int(eval(input()))
L = [int(i) for i in input().split()]
l=list(itertools.combinations(L,3))
result = 0
for i in l:
isOk=True
a,b,c=i
if a+b>c and a+c>b and c+b>a:
result+=1
print(result) | N = int(eval(input()))
L = [int(i) for i in input().split()]
result = 0
for aIndex,a in enumerate(L):
for bIndex,b in enumerate(L[aIndex+1:]):
for c in L[aIndex+bIndex+2:]:
if a<b+c and b<a+c and c<a+b:
result+=1
print(result) | p02888 |
from bisect import bisect_left
N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()
result = 0
for aIndex,a in enumerate(L[:N-2]):
for bIndex,b in enumerate(L[aIndex+1:N-1]):
bIndex = aIndex + bIndex + 1
ab = a+b
n = bisect_left(L,ab) - bIndex - 1
resul... | from bisect import bisect_left
N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()
result = 0
for i,a in enumerate(L[:N-2]):
i += 1
for j,b in enumerate(L[i:N-1]):
j += i + 1
n = bisect_left(L,a+b) - j
result += n
print(result) | p02888 |
import bisect
n = int(eval(input()))
l = sorted([int(i) for i in input().split()])
ans = 0
for d in range(n):
for e in range(d+1, n):
a, b = l[d], l[e]
idx = bisect.bisect_right(l, a + b)
for c in l[e+1:idx]:
if not c < a + b:
break
ans +=... | import bisect
n = int(eval(input()))
l = sorted([int(i) for i in input().split()])
ans = 0
for d in range(n):
for e in range(d+1, n):
a, b = l[d], l[e]
idx = bisect.bisect_left(l, a + b)
ans += max(idx - e - 1, 0)
print(ans)
| p02888 |
from bisect import bisect_left
N = int(eval(input()))
L = [int(i) for i in input().split()]
L.sort()
num_triangles = 0
for i in range(N-2):
for j in range(i+1, N-1):
idx = bisect_left(a=L, x=L[i]+L[j], lo=j+1)
num_triangles += idx-(j+1)
print(num_triangles)
| from bisect import bisect_left
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
for j in range(i+1, n):
endpt = bisect_left(l, l[i] + l[j])
ans += endpt-j-1
print(ans) | p02888 |
from bisect import bisect_left
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
num_triangles = 0
for i in range(N-2):
for j in range(i+1, N-1):
idx = bisect_left(a=L, x=L[i]+L[j], lo=j+1)
num_triangles += idx-j-1
print(num_triangles)
| from bisect import bisect_left
N = int(eval(input()))
L = list(map(int, input().split(" ")))
L.sort()
num_triangles = 0
for i in range(N-2):
for j in range(i+1, N-1):
idx = bisect_left(L, L[i]+L[j], j+1)
num_triangles += idx-j-1
print(num_triangles)
| p02888 |
from collections import deque
from copy import copy
import bisect
n = int(eval(input()))
order = sorted(list(map(int, input().split())))
l = deque(order)
ans = 0
for _ in range(len(l)-2):
first = l.pop()
m = copy(l)
for _ in range(len(m)-1):
second = m.pop()
fix = first-sec... | from bisect import bisect_right
n = int(eval(input()))
order = sorted(list(map(int, input().split())))
ans = 0
for i in reversed(list(range(2, n))):
for j in reversed(list(range(1, i))):
ans += j - bisect_right(order[0:j], order[i]-order[j])
print(ans) | p02888 |
from bisect import bisect_right
n = int(eval(input()))
order = sorted(list(map(int, input().split())))
ans = 0
for i in reversed(list(range(2, n))):
for j in reversed(list(range(1, i))):
ans += j - bisect_right(order[0:j], order[i]-order[j])
print(ans) | from bisect import bisect_right
n = int(eval(input()))
order = sorted(list(map(int, input().split())))
ans = 0
for i in reversed(list(range(2, n))):
for j in reversed(list(range(1, i))):
fix = bisect_right(order, order[i]-order[j])
if j > fix:
ans += j - fix
print(ans) | p02888 |
from bisect import bisect_left, bisect_right
N, *X = list(map(int, open(0).read().split()))
X.sort()
ans = 0
for i in range(N - 2):
for j in range(i + 1, N - 1):
k1 = bisect_right(X, X[j] - X[i])
k2 = bisect_left(X, X[i] + X[j])
k1 = max(k1, j + 1)
ans += max(0, k2 - k1)... |
from bisect import bisect_left
N = int(eval(input()))
X = list(map(int, input().split()))
X.sort()
ans = 0
for i in range(N):
for j in range(i + 1, N):
k = bisect_left(X, X[i] + X[j])
ans += k - j - 1
print(ans)
| p02888 |
# encoding:utf-8
import copy
import random
import bisect #bisect_left これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect
import collections
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
def LI(): return list(map(int, sys.stdin.readline().split()))
"""
... | # encoding:utf-8
import copy
import random
import bisect #bisect_left これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect
import collections
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
def LI(): return list(map(int, sys.stdin.readline().split()))
"""
... | p02888 |
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort(reverse=True)
ans = 0
for i in range(N):
j = N-2
temp = 0
while j > i:
if temp > 0:
k = temp
else:
k = N - 1
while k > j:
if L[i]-L[j]-L[k] < 0:
ans += k-j
temp = k
break
... | N = int(eval(input()))
L = list(map(int, input().split()))
L.sort(reverse=True)
ck = [0]*(N-2)
ans = 0
for i in range(N-2):
j = i + 1
k = N - 1
while j < k:
if L[i]-L[j]-L[k] < 0:
ans += k-j
j += 1
else:
k -=1
print(ans) | p02888 |
from bisect import bisect
from bisect import bisect_right
from bisect import bisect_left
from bisect import insort
from bisect import insort_right
from bisect import insort_left
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
#print(L)
cnt = 0
for i in range(N):
for j in range(i+1,... | from bisect import bisect
from bisect import bisect_right
from bisect import bisect_left
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
#print(L)
cnt = 0
for i in range(N):
for j in range(i+1, N):
s = L[i] + L[j]
x = bisect_left(L, s)
#print((L[i], L[j]), s, x)
... | p02888 |
import itertools
N = int(eval(input()))
L = list(map(int, input().split(' ')))
count = 0
for l in list(itertools.combinations(L, 3)):
if l[0] < l[1] + l[2] and l[1] < l[0] + l[2] and l[2] < l[0] + l[1]:
count += 1
print(count) | import itertools
N = int(eval(input()))
L = list(map(int, input().split(' ')))
L = sorted(L)
count = 0
for i in range(N - 1):
for j in range(i + 1, N - 1):
x, y = L[i], L[j]
top = N
bottom = j + 1
tmp = (top + bottom) // 2
while(top - bottom > 1):... | p02888 |
import bisect
N=int(eval(input()))
L=sorted(list(map(int,input().split())))
ans=0
for i in range(N-2):
for j in range(i+1,N-1):
# ans+=bisect.bisect_left(L,L[i]+L[j])-j-1
ans+=bisect.bisect_left(L,L[i]+L[j],j)-j-1
print(ans) | import bisect
N=int(eval(input()))
L=sorted(list(map(int,input().split())))
ans=0
for i in range(N-2):
for j in range(i+1,N-1):
ans+=bisect.bisect_left(L,L[i]+L[j])-j-1 # Code 1
# ans+=bisect.bisect_left(L,L[i]+L[j],j)-j-1 # Code 2
print(ans) | p02888 |
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect
def solve():
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(n):
for j in range(i+1, n):
k = bisect.bisect_le... | import math
import collections
import fractions
import itertools
import functools
import operator
import bisect
def solve():
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(n):
k = i
for j in range(i+1, n):
while... | p02888 |
import sys
input = sys.stdin.readline
N = int(eval(input()))
L = [int(i) for i in input().split()]
total = 0
L = sorted(L, reverse=True)
for i in range(N-2):
if L[i+1] + L[i+2] <= L[i]:
continue
for j in range(i+1, N):
for k in range(j+1, N):
if L[i] < L[j]+L[k] and ... | import sys
input = sys.stdin.readline
N = int(eval(input()))
L = [int(i) for i in input().split()]
total = 0
L = sorted(L)
for i in range(N-2):
k = i + 2
for j in range(i+1, N):
while k < N and L[i] + L[j] > L[k]:
k+=1
if k > j:
total += k-j-1
print(t... | p02888 |
n = int(eval(input()))
ln = list(map(int, input().split()))
ln.sort()
def binary_search(x, r):
left = r + 1
right = n-1
while left < right:
mid = (left + right) // 2
if ln[mid] == x:
return mid
elif ln[mid] > x:
right = mid - 1
else:
... | n = int(eval(input()))
ln = list(map(int, input().split()))
ln.sort()
def binary_search(x, r):
left = r + 1
right = n - 1
while left <= right:
mid = (left + right) // 2
if ln[mid] >= x:
right = mid - 1
else:
left = mid + 1
if ln[mid] >= x:
... | p02888 |
#!/usr/bin/env python3
import sys
from bisect import bisect_left
def main():
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N-1):
for j in range(i+1,N):
index = bisect_left(L,L[i]+L[j])
ans += max(0,index-j-1)
... | from bisect import bisect_right
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
for j in range(i + 1, N):
b = L[i]
c = L[j]
M = L[i+1:j]
ans += bisect_right(M, b + c - 1) - bisect_right(M, c - b)
print(ans) | p02888 |
from bisect import bisect_left, bisect_right
n = int(eval(input()))
ls = sorted(list(map(int, input().split())))
total = 0
for i in range(n):
for j in range(i+1, n):
b, c = ls[i], ls[j]
lower = abs(b-c) + 0.5
upper = b+c - 0.5
ii = bisect_left(ls, lower)
jj = bisect... | from bisect import bisect_left, bisect_right
n = int(eval(input()))
ls = sorted(list(map(int, input().split())))
total = 0
for i in range(n):
for j in range(i+1, n):
b, c = ls[i], ls[j]
lower = abs(b-c) + 0.5
upper = b+c - 0.5
ii = bisect_left(ls, lower)
jj = bisect... | p02888 |
import sys
input = sys.stdin.readline
import collections
import bisect
def main():
n = int(eval(input()))
l = input_list()
l.sort()
ans = 0
for i in range(n-2):
for j in range(i+1, n-1):
ind = bisect.bisect_left(l, l[i]+l[j])
num = ind - 1 - j
... | import sys
input = sys.stdin.readline
import bisect
# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
n = int(eval(input()))
l = sorted(input_list())
ans = 0
for a in range(n):
for b in range(a+1, n):
ans += bisect.bisect_left(l, l[a]+l[b]) - (b... | p02888 |
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().dec... | # -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().dec... | p02888 |
import bisect
N=int(eval(input()))
L=list(map(int, input().split()))
L.sort()
ans=0
for i in range(N-2):
for j in range(i+1,N-1):
small = bisect.bisect_left(L, L[j]-L[i])
large = bisect.bisect_left(L, L[j]+L[i])
#print(i,j,L[i],L[j]," ",L[j]-L[i],L[j]+L[i],small,large)
ans += ma... | import bisect
N=int(eval(input()))
L=list(map(int, input().split()))
L.sort()
ans=0
for i in range(N-2):
for j in range(i+1,N-1):
#small = bisect.bisect_left(L, L[j]-L[i])
large = bisect.bisect_left(L, L[j]+L[i])
#print(i,j,L[i],L[j]," ",L[j]-L[i],L[j]+L[i],small,large)
ans += max(l... | p02888 |
eval(input())
a = input().split(' ')
b = []
for i in a:
b.append(int(i))
b.sort()
b.reverse()
out = 0
for i in range(len(b) - 2):
l = i + 1
r = len(b) - 1
while l < r:
if b[i] < b[l] + b[r]:
out += r - l
l += 1
else:
r -= 1
print(out... | n = int(eval(input()))
sticks = list (map (int, input().strip().split()))
sticks.sort()
ans = 0
for a_idx in range(n - 1, 0, -1):
b_idx = a_idx - 1
c_idx = 0
while c_idx < b_idx:
if sticks[a_idx] < sticks[b_idx] + sticks[c_idx]:
ans += b_idx - c_idx
b_idx -= 1
... | p02888 |
import sys
input = sys.stdin.readline
import itertools
import bisect
def main():
N = int(eval(input()))
L = [int(x) for x in input().split()]
ans = 0
L_sorted = sorted(L)
for i in range(N - 2):
for j in range(i + 1, N - 1):
a = L_sorted[i]
b = L_sorted[j... | import sys
input = sys.stdin.readline
import itertools
import bisect
def main():
N = int(eval(input()))
L = [int(x) for x in input().split()]
ans = 0
L_sorted = sorted(L)
for i in range(N - 2):
for j in range(i + 1, N - 1):
a = L_sorted[i]
b = L_sorted[j... | p02888 |
import sys
input = sys.stdin.readline
import itertools
import bisect
def main():
N = int(eval(input()))
L = [int(x) for x in input().split()]
ans = 0
L_sorted = sorted(L)
for i in range(N - 2):
for j in range(i + 1, N - 1):
a = L_sorted[i]
b = L_sorted[j... | import sys
input = sys.stdin.readline
import itertools
import bisect
def main():
N = int(eval(input()))
L = [int(x) for x in input().split()]
ans = 0
L_sorted = sorted(L)
for i in range(N - 2):
a = L_sorted[i]
for j in range(i + 1, N - 1):
b = L_sorted[j]
... | p02888 |
# coding: utf-8
import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : retu... | # coding: utf-8
import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def... | p02888 |
from sys import stdout
import bisect
printn = lambda x: stdout.write(x)
inn = lambda : int(eval(input()))
inl = lambda: list(map(int, input().split()))
inm = lambda: list(map(int, input().split()))
DBG = True and False
BIG = 999999999
R = 10**9 + 7
def ddprint(x):
if DBG:
print(x)
n = i... | from sys import stdout
import bisect
printn = lambda x: stdout.write(x)
inn = lambda : int(eval(input()))
inl = lambda: list(map(int, input().split()))
inm = lambda: list(map(int, input().split()))
DBG = True and False
BIG = 999999999
R = 10**9 + 7
def ddprint(x):
if DBG:
print(x)
n = i... | p02888 |
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
ans = 0
for r in range(n-1,-1,-1):
m = r
for l in range(n):
if l == m and m + 1 < r:
m += 1
while True:
if a[l] + a[m-1] > a[r] and l < m-1:
m -= 1
else:
break
if l < m < r:
ans += r... | n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
ans = 0
for r in range(n-1,-1,-1):
m = r
for l in range(n):
if l == m and m + 1 < r:
m += 1
else:
while True:
if a[l] + a[m-1] > a[r] and l < m-1:
m -= 1
else:
break
if l < m... | p02888 |
import itertools
n = int(eval(input()))
l = list(map(int,input().split()))
c = [i for i in itertools.combinations(l,3) if i[0]<i[1]+i[2] and i[1]<i[2]+i[0] and i[2]<i[0]+i[1]]
print((len(c))) | import bisect
n = int(eval(input()))
l = list(map(int,input().split()))
l.sort()
ans = 0
for b in range(n):
for a in range(b):
ans += bisect.bisect_left(l,l[a]+l[b])-(b+1)
print(ans) | p02888 |
import itertools
import bisect
n=int(eval(input()))
count = 0
a=sorted(list(map(int, input().split(" "))))
for i in range(2,n):
for j, k in itertools.combinations(a[:i], 2):
if j + k > a[i]:
count += 1
print(count) | n = int(eval(input()))
import bisect
a = sorted(list(map(int, input().split(" "))))
ans = 0
for i in range(1, n-1):
b = a[:i]
c = a[i + 1:]
#print(b, c)
for j in b:
ans += bisect.bisect(c, a[i]+j-0.1)
#print(bisect.bisect(c, a[i]+j-0.1))
print(ans) | p02888 |
import sys
N = int(eval(input()))
L = list(map(int, input().split()))
from itertools import permutations, combinations,combinations_with_replacement,product
nCr = list(combinations(list(range(N)), 3))
ret = 0
for i in nCr:
if L[i[0]]<L[i[1]]+L[i[2]] and L[i[1]]<L[i[2]]+L[i[0]] and L[i[2]]<L[i[0]]+L[i[1]]:
... | N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ret = 0
for i in range(0, N-2):
for j in range(i+1, N-1):
ret += len([k for k in L[j+1:] if L[i]+L[j]>k])
print(ret) | p02888 |
import bisect
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
# print(L)
ab =[L[0]+L[1]]
ans = 0
for i in range(2, N):
c = L[i]
j = bisect.bisect_right(ab, c)
# print(j)
# print(ab)
ans += len(ab) - j
... | import bisect
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
# print(L)
ans = 0
for i in range(N-2):
for j in range(i+2, N):
a = L[i]
c = L[j]
k = bisect.bisect_left(L, c-a+1)
if k <= i:
... | p02888 |
length = 2010
n = int(eval(input()))
L = list(map(int, input().split()))
ans = 0
L.sort()
sum_1 = [ 0 for _ in range(length)]
for i in range(n):
sum_1[L[i]]+=1
#棒の長さで累積和
for i in range(length-1):
sum_1[i+1] +=sum_1[i]
for i in range(n-1):
for j in range(i+1, n):
a = abs(L[i]-L[j])
... | length = 2010
n = int(eval(input()))
L = list(map(int, input().split()))
ans = 0
L.sort()
sum_1 = [0]*length
for i in range(n):
sum_1[L[i]]+=1
#棒の長さで累積和
for i in range(length-1):
sum_1[i+1] +=sum_1[i]
for i in range(n-1):
for j in range(i+1, n):
a = abs(L[i]-L[j])
b = L[i]+L[... | p02888 |
import bisect
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for k in range(N-2):
for j in range(k+1, N-1):
ans += bisect.bisect_left(L[j+1:], L[k]+L[j])
print(ans) | import bisect
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
from bisect import bisect_left
for k in range(N-2):
for j in range(k+1, N-1):
ans += bisect_left(L[j+1:], L[k]+L[j])
print(ans) | p02888 |
n = int(eval(input()))
l = list(map(int, input().split()))
s = 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]:
s += 1
print(s)
| n = int(eval(input()))
l = list(map(int, input().split()))
s = 0
l.sort()
for i in range(n-2):
j = n-2
k = n-1
while i < j:
if l[k] >= l[i] + l[j] and j < k:
#print(0, i, j, k)
k -= 1
else:
#print(1, i, j, k)
s += k - j
... | p02888 |
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort(reverse=... | import sys
import bisect
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce, reduce
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
def main():
N = int(eval(input()))
L = list(map(int, input().split()... | p02888 |
import bisect
n = int(eval(input()))
l = sorted([int(li) for li in input().split()])
sum = 0
for i in range(n)[::-1]:
for j in range(i)[::-1]:
k = bisect.bisect_right(l[:j],l[i]-l[j])
sum += j-k
print(sum)
| import bisect
n = int(eval(input()))
l = sorted([int(li) for li in input().split()])
sum = 0
for i in range(n-1,-1,-1):
for j in range(i-1,-1,-1):
k = bisect.bisect_right(l,l[i]-l[j])
sum += j-k if j>k else 0
print(sum)
| p02888 |
N=int(eval(input()))
L=[int(x) for x in input().split()]
L.sort()
count=0
for i,a in enumerate(L):
for j,b in enumerate(L[i+1:]):
for k,c in enumerate(L[i+j+2:]):
if c>=a+b:
break
count+=1
print(count) | def main():
N=int(eval(input()))
L=[int(x) for x in input().split()]
L.sort()
count=0
dic={}
for i in range(N):
for j in range(i+1,N):
if i:
try:
start=dic[j]
count+=dic[j]-j-1
except:
... | p02888 |
N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()
cnt = 0
for i in range(N-2):
for j in range(i+1,N-1):
for k in range(j+1,N):
if L[k] < L[i] + L[j]:
cnt += 1
print(cnt) | import bisect
N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()
cnt = 0
for i in range(N-2):
for j in range(i+1,N-1):
num = L[i] + L[j]
third = bisect.bisect_left(L,num)
if third > j:
cnt += third - j - 1
print(cnt) | p02888 |
import itertools
import sys
from collections import defaultdict
input = sys.stdin.readline
class AtCoder:
def main(self):
N = int(eval(input()))
L = list(map(int, input().split()))
ans = 0
for a,b,c in itertools.combinations(L,3):
if a < b + c and b < ... | import bisect
import itertools
import sys
input = sys.stdin.readline
class AtCoder:
def main(self):
N = int(eval(input()))
L = list(map(int, input().split()))
ans = 0
L.sort()
for i in range(N - 2):
for j in range(i + 1, N - 1):
... | p02888 |
n = int(eval(input()))
L = sorted(list(map(int, input().split())))
def isOK(target,a,b):
return target > abs(a-b) and target < a+b
def bin_search(a,b):
left = 1
right = n
while right-left>1:
mid = left+(right-left)//2
if isOK(L[mid],a,b):
left = mid
else:
right = mid
ret... | n = int(eval(input()))
L = sorted(list(map(int, input().split())))
def isOK(target,a,b):
return target < a+b
def bin_search(a,b):
left = 1
right = n
while abs(right-left)>1:
mid = (left+right)//2
if isOK(L[mid],a,b):
left = mid
else:
right = mid
return left
ans = 0
for... | p02888 |
import bisect
N= int(eval(input()))
L = list(map(int, input().split()))
L.sort(reverse=True)
#print(L)
for i in range(N):
L[i] *= -1
count = 0
for i in range(N-2):
#print(i)
for j in range(i+1, N-1):
if -L[i] >= -L[j] * 2:
break
data = L[i] - L[j]
#print... | import bisect
N= int(eval(input()))
L = list(map(int, input().split()))
L.sort(reverse=True)
#print(L)
for i in range(N):
L[i] *= -1
count = 0
for i in range(N-2):
#print(i)
for j in range(i+1, N-1):
if -L[i] >= -L[j] * 2:
break
data = L[i] - L[j]
#print... | p02888 |
import bisect
n = int(eval(input()))
L = sorted(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]
l = bisect.bisect(L[j+1:n], a+b-1)
ans += l
print(ans)
| import bisect
n = int(eval(input()))
L = sorted(map(int, input().split()))
ans = 0
for i in range(n):
a = L[i]
for j in range(i+1, n):
b = L[j]
k = bisect.bisect_left(L, a+b)
if k > j:
ans += k - j - 1
print(ans)
| p02888 |
import bisect
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
cnt = 0
for i in range(N):
for j in range(i + 1, N):
idx = bisect.bisect_left(L, L[i] + L[j], lo=j + 1)
cnt += max(0, idx - (j + 1))
print(cnt) | import bisect
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
cnt = 0
for i in range(N):
for j in range(i + 1, N):
idx = bisect.bisect_left(L, L[i] + L[j])
cnt += max(0, idx - (j + 1))
print(cnt) | p02888 |
import bisect
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
cnt = 0
for i in range(N - 2):
for j in range(i + 1, N - 1):
idx = bisect.bisect_left(L, L[i] + L[j], lo=j + 1)
cnt += max(0, idx - (j + 1))
print(cnt) | import bisect
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
ans = 0
for i in range(N - 2):
for j in range(i + 1, N - 1):
k = bisect.bisect_left(L, L[i] + L[j], j + 1) - 1
ans += k - j
print(ans)
| p02888 |
import sys
from bisect import bisect_left as bl
from bisect import bisect_right as br
input = sys.stdin.buffer.readline
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
dl = []
for i in range(N - 1):
for j in range(i + 1, N):
dl.append((L[i] + L[j], i, j, abs(L[i] - L[j])))
dl.sort()... | import sys
from bisect import bisect_left as bl
from bisect import bisect_right as br
input = sys.stdin.buffer.readline
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
dl = []
res = 0
for i in range(N - 1):
for j in range(i + 1, N):
d0 = L[i] + L[j]
d1 = i
d2 = j
d3 =... | p02888 |
import bisect
def main():
n = int(eval(input()))
L = list(int(x) for x in input().split())
ans = 0
c = 0
L.sort()
for i in range(n-2):
for j in range(i+1, n):
c = L[i]+L[j]
l = j
r = bisect.bisect_left(L, c, lo=l) -1
a... | import bisect
def main():
n = int(eval(input()))
L = list(int(x) for x in input().split())
ans = 0
c = 0
L.sort()
for i in range(n-2):
for j in range(i+1, n-1):
c = L[i]+L[j]
l = j
r = bisect.bisect_left(L, c, lo=l) -1
a... | p02888 |
from bisect import bisect_left
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(N):
for j in range(i+1, N):
max_len = L[i] + L[j]
count += bisect_left(L, max_len) - j - 1
print(count)
| from bisect import bisect_left
import sys
input = sys.stdin.readline
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-1):
for j in range(i+1, N):
l = L[i] + L[j]
k = bisect_left(L, l)
ans += max(0, k - j - 1)
print(ans) | p02888 |
import itertools
n = int(eval(input()))
l = list(map(int, input().split()))
counter = 0
for v in itertools.combinations(l, 3):
if 2 * max(v) < sum(v):
counter += 1
print(counter) | import bisect
n = int(eval(input()))
l = sorted(list(map(int, input().split())))
counter = 0
for i in range(n):
for j in range(i + 1, n):
counter += (bisect.bisect_left(l, l[i] + l[j]) - j - 1)
print(counter) | p02888 |
n = int(eval(input()))
l = sorted(list(map(int,input().split())))
ans = 0
import bisect
for i in range(n):
for j in range(i+1,n):
a1 = abs(l[i]-l[j])
a2 = l[i]+l[j]
x1 = bisect.bisect_right(l,a1)
x2 = bisect.bisect_left(l,a2)
buf = 0
if x1<=i<=x2:buf+=1
... | n = int(eval(input()))
l = sorted(list(map(int,input().split())))
ans = 0
import bisect
for i in range(n):
for j in range(i+1,n):
a = l[i]+l[j]
x = bisect.bisect_left(l,a)
if x>j:
ans += max(0,x-j-1)
print(ans)
| p02888 |
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline
def main():
n = int(eval(input()))
l = list(map(int, input().split()))
l = sorted(l)
result = 0
for i in range(n-2):
for j in range(i + 1, n - 1):
result += bisect.bisect_left(l[j+1:],... | # -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline
def main():
n = int(eval(input()))
l = list(map(int, input().split()))
l = sorted(l)
result = 0
for i in range(n-2):
for j in range(i + 1, n - 1):
result += bisect.bisect_left(l, l[i] ... | p02888 |
N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()
ans = 0
import bisect
for i in range(N-2):
for j in range(i,N-1):
if i==j:
continue
a = L[i]
b = L[j]
k = bisect.bisect_left(L[j+1:],a+b)
l = bisect.bisect_left(L[j+1:],abs(a-b))
... | N = int(eval(input()))
L = list(map(int,input().split()))
L.sort()
ans = 0
import bisect
for i in range(N-2):
a = L[i]
for j in range(i+1,N-1):
b = L[j]
k = bisect.bisect_left(L,a+b)
l = bisect.bisect_left(L,b-a)
ans += k-max(j+1,l)
print(ans) | p02888 |
from bisect import bisect_left
n = int(eval(input()))
length_list = list(map(int, input().split()))
count = 0
length_list.sort()
for a_idx in range(n - 2):
for b_idx in range(a_idx + 1, n - 1):
a = length_list[a_idx]
b = length_list[b_idx]
if b > a:
a, b = b, a
... | from bisect import bisect_left
n = int(eval(input()))
length_list = list(map(int, input().split()))
count = 0
length_list.sort()
for a_idx in range(n - 2):
for b_idx in range(a_idx + 1, n - 1):
a = length_list[a_idx]
b = length_list[b_idx]
left_count = bisect_left(length_lis... | p02888 |
### a<=b<=cととることとし、a,bを固定すると
### cは c<a+b
from bisect import bisect_left
N = int(eval(input()))
lst = list(map(int, input().split()))
sor = sorted(lst)
res = 0
for i in range(N):
for j in range(i+1, N):##ここでa<=bを満たしている
ab = sor[i] + sor[j]
highbound = bisect_left(sor, ab)
res += h... | ### a<=b<=cととることとし、a,bを固定すると
### cは c<a+b
from bisect import bisect_left
def main():
N = int(eval(input()))
lst = list(map(int, input().split()))
sor = sorted(lst)
res = 0
for i in range(N):
for j in range(i+1, N):##ここでa<=bを満たしている
ab = sor[i] + sor[j]
highb... | p02888 |
import bisect
N = int(eval(input()))
L = input().split()
for i in range(0, N):
L[i] = int(L[i])
L.sort()
ans = 0
for i in range(0, N-1):
for j in range(i+1, N):
a = L[j] - L[i]
b = L[j] + L[i]
c = bisect.bisect_right(L, a)
d = bisect.bisect_left(L, b)
if 2*L[i] > L[j]:
ans ... | import bisect
N = int(eval(input()))
L = input().split()
for i in range(0, N):
L[i] = int(L[i])
L.sort()
ans = 0
for i in range(0, N-1):
for j in range(i+1, N):
a = L[i] + L[j]
b = bisect.bisect_left(L, a)
ans += b-j-1
print(ans) | p02888 |
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
def check(x, a):
if a < x:
return True
else:
return False
def bin_search(x, ok, ng, l):
while ng - ok > 1:
mid = (ng + ok) // 2
if check(x, l[mid]):
ok = mid
else:
... | n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
def bin_search(x, ok, ng, l):
while ng - ok > 1:
mid = (ng + ok) // 2
if l[mid] < x:
ok = mid
else:
ng = mid
return ok + 1
ans = 0
for i in range(n - 2):
for j in range(i + 1,... | p02888 |
N = int(eval(input()))
L = list(map(int, input().split()))
from itertools import combinations
cb = list(combinations(L, 3))
def my_def(x):
if x[0] + x[1] > x[2]:
if x[1] + x[2] > x[0]:
if x[0] + x[2] > x[1]:
return(True)
return(False)
print((sum(list(map(my_... | N = int(eval(input()))
L = list(map(int, input().split()))
from itertools import combinations
cb = combinations(L, 3)
def my_def(x):
#cb.sort
if x[1] + x[2] > x[0]:
if x[0] + x[2] > x[1]:
if x[0] + x[1] > x[2]:
return(True)
return(False)
print((sum(list... | p02888 |
from bisect import bisect, bisect_left
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
cnt = 0
for i in range(N-1):
for j in range(i):
a, b = L[i], L[j]
k = i + 1
l = bisect_left(L[i+1:], a-b) + i+1
r = bisect_left(L, a+b)
cnt += max(r - l, 0... | from bisect import bisect, bisect_left
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
cnt = 0
for i in range(N-1):
for j in range(i):
a, b = L[i], L[j]
r = bisect_left(L[i+1:], a+b) + i+1
cnt += max(r - i - 1, 0)
print(cnt) | p02888 |
#!/usr/bin/env python3
import sys
# import numpy as np
import bisect
def solve(N: int, L: "List[int]"):
L = sorted(L)
ct = 0
for a in range(len(L)-2):
a_ = L[a]
# for b in range(a+1, len(L)-1):
# ct+= bisect.bisect_left(L[b+1:],a_+L[b])
# print("L :{} a+L... | #!/usr/bin/env python3
import sys
# import numpy as np
import bisect
def solve(N: int, L: "List[int]"):
L = sorted(L)
ct = 0
for a in range(len(L)-2):
a_ = L[a]
for b in range(a+1, len(L)-1):
b_in = bisect.bisect_left(L,a_+L[b]) - b -1
if b_in > 0:
... | p02888 |
N = int(eval(input()))
L = sorted(map(int, input().split()))
counter = 0
for i in range(N):
a = L[i]
for j in range(i+1, N):
b = L[j]
for k in range(j+1, N):
c = L[k]
if c >= a + b:
break
elif b < c + a and a < b + c:
... | import bisect
N = int(eval(input()))
L = sorted(map(int, input().split()))
counter = 0
for i in range(N):
a = L[i]
for j in range(i+1, N):
b = L[j]
k = bisect.bisect_left(L, a + b)
counter += max(0, k - (j + 1))
print(counter) | p02888 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.