input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
import bisect;N=int(eval(input()));A,B,C=[sorted(map(int,input().split())) for _ in "ABC"];print((sum([bisect.bisect_left(A,i)*(N-bisect.bisect_right(C,i)) for i in B])))
| from bisect import *;N=int(eval(input()));A,B,C=[sorted(map(int,input().split())) for _ in "ABC"];print((sum([bisect_left(A,i)*(N-bisect_right(C,i)) for i in B]))) | p03557 |
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
def b_search_l(B,key):
#key < B[s]を満たす最小のs
if key < B[0]:
return 0
elif key >= B[N-1]:
return N-1
else:
lef... | N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
def b_search_l(B,key):
#key < B[s]を満たすsの個数
if key < B[0]:
return N
elif key >= B[N-1]:
return 0
else:
left,... | p03557 |
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
def b_search_l(B,key):
#key < B[s]を満たすsの個数
if key < B[0]:
return N
elif key >= B[N-1]:
return 0
else:
left,... | from bisect import bisect_left,bisect_right
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
#bisect_left:keyを挿入できる最小のindex
#bisect_right:keyを挿入できる最大のindex
ans = 0
for i in range(N):
b_l,b_r =... | p03557 |
import bisect
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a, b, c = sorted(a), sorted(b), sorted(c)
ans = 0
for i in b:
up_index = bisect.bisect_left(a,i)
down_index = bisect.bisect_right(c,i)
ans += len(a[:up... | import bisect
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a, b, c = sorted(a), sorted(b), sorted(c)
ans = 0
for i in b:
up_index = bisect.bisect_left(a,i)
down_index = bisect.bisect_right(c,i)
ans += up_index ... | p03557 |
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
import bisect
A2 = []
B2 = []
C2 = []
for a,b,c in zip(A,B,C):
bisect.insort_left(A2, a)
# bise... | #!/mnt/c/Users/moiki/bash/env/bin/python
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
import bisect
A2 = []
B2 = []
C2 = []
# for a,b,c in zip(A,B,C):
# bisect.insort_left(A2, a)
# ... | p03557 |
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
c.sort()
### 二分探索
ans = 0
for i in range(n):
for j in range(n):
if a[i] < b[j]:
for k in range(len(c)):
low = 0
high ... | import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
ans = 0
for i in range(N):
a = bisect.bisect_left(A, B[i])
c = bisect.bisect_right(C, B[i])
ans += a*(N-c)
print(ans)
| p03557 |
#!/usr/bin/python3
from bisect import bisect_left
def main():
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
res = 0
for a in A:
t = bisect_left(B, a + 1)
... | #!/usr/bin/python3
from bisect import bisect_left, bisect_right
def main():
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
res = 0
for b in B:
res += bisect_left(A... | p03557 |
icase=0
if icase==0:
n=int(eval(input())) #数値入力 「N」だけの入力のとき
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
elif icase==1:
n=2
a=[1,5]
b=[2,4]
c=[3,6]
elif icase==2:
n=6
a=[3, 14, 159, 2, 6, 53]
b=[58, 9, 79... | from bisect import bisect_left,bisect
n=int(eval(input()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
lenc=len(c)
a.sort()
b.sort()
c.sort()
jsum=0
for j in b:
ai=bisect(a,j-1)
ci=lenc-bisect_left(c,j+1)
# print(j,ai,ci)
jsum+=a... | p03557 |
import bisect
def I(): return int(eval(input()))
def LI(): return list(map(int,input().split()))
N = I()
A = sorted(LI())
B = sorted(LI())
C = sorted(LI())
ans = 0
BC = []
for b in B:
C2 = C[:]
ok = bisect.bisect(C2,b)
if ok!=N:
bisect.insort(C2,b)
for _ in range(N-ok):
... | import bisect
def I(): return int(eval(input()))
def LI(): return list(map(int,input().split()))
N = I()
A = sorted(LI())
B = sorted(LI())
C = sorted(LI())
ans = 0
for b in B:
ok_a = bisect.bisect_left(A,b)
ok_c = bisect.bisect_right(C,b)
if ok_a!=0 and ok_c!=N:
ans += ok_a*(N-ok_c)
pri... | p03557 |
import bisect
def I(): return int(eval(input()))
def LI(): return list(map(int,input().split()))
N = I()
A = sorted(LI())
B = sorted(LI())
C = sorted(LI())
ans = 0
for b in B:
ok_a = bisect.bisect_left(A,b)
ok_c = bisect.bisect_right(C,b)
if ok_a!=0 and ok_c!=N:
ans += ok_a*(N-ok_c)
pri... | import bisect
def I(): return int(eval(input()))
def LI(): return list(map(int,input().split()))
N = I()
A = sorted(LI())
B = sorted(LI())
C = sorted(LI())
ans = 0
for b in B:
ok_a = bisect.bisect_left(A,b)
ok_c = bisect.bisect_right(C,b)
ans += ok_a*(N-ok_c)
print(ans) | p03557 |
import bisect
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in b:
x = bisect.bisect_left(a,i)
y = bisect.bisect_right(c, i)
#print(x, y)
ans = ans+x*(n-y)
print(ans) | import bisect
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in b:
x = bisect.bisect_left(a, i)
y = bisect.bisect_right(c, i)
ans = ans + (x * (n-y))
print(ans) | p03557 |
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, ... | #!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in... | p03557 |
n = int(eval(input()))
xs = sorted(map(int, input().split()))
ys = sorted(map(int, input().split()))
zs = sorted(map(int, input().split()))
bs = [0] * n
for i in range(n):
for j in range(n):
if xs[j] < ys[i]:
bs[i] += 1
else:
break
cs = [0] * n
for i in ra... |
n = int(eval(input()))
xs = sorted(map(int, input().split()))
ys = sorted(map(int, input().split()))
zs = sorted(map(int, input().split()))
bs = [0] * n
j = 0
for i in range(n):
while j < n and xs[j] < ys[i]:
j += 1
bs[i] = j
cs = [0] * n
j = 0
k = 0
for i in range(n):
while j ... | p03557 |
#関数リスト
import sys
from bisect import bisect
input = sys.stdin.readline
def RD(): return input().rstrip()
def I(): return int(input().rstrip())
def MI(): return list(map(int, input().split()))
def MF(): return list(map(float,input().split()))
def LI(): return list(map(int, input().split()))
def LF(): return lis... | #関数リスト
import sys
import bisect
input = sys.stdin.readline
def RD(): return input().rstrip()
def I(): return int(input().rstrip())
def MI(): return list(map(int, input().split()))
def MF(): return list(map(float,input().split()))
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,... | p03557 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/22
Solved on 2019/3/
@author: shinjisu
"""
# ABC 077 C Festival
import collections
#import numpy as np
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/22
Solved on 2019/3/
@author: shinjisu
"""
# ABC 077 C Festival
import collections
#import numpy as np
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array... | p03557 |
from bisect import bisect_right, bisect_left
n = int(eval(input()))
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
li_c = list(map(int, input().split()))
li_a.sort()
li_b.sort()
li_c.sort()
relation_bc = [] #relation_bc[i] : 大きい方からi番目のbより大きいcがいくつあるか
for i in range(n):
i += 1... | from bisect import bisect_right, bisect_left
from itertools import accumulate
n = int(eval(input()))
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
li_c = list(map(int, input().split()))
li_a.sort()
li_b.sort()
li_c.sort()
relation_bc = [] #relation_bc[i] : 大きい方からi番目のbより大きいcがいくつあ... | p03557 |
import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
#A.sort()
B.sort()
C.sort()
lenC = len(C)
anssum = 0
for i in A:
for l in B[bisect.bisect_right(B,i):]:
anssum += lenC - bisect.bisect_right(C,l)
prin... | import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
anssum = 0
for i in B:
moreB = N-bisect.bisect_right(C,i)
lessB = bisect.bisect_left(A,i)
anssum += moreB*lessB
print(anssu... | p03557 |
from collections import Counter
N=int(eval(input()))
A=Counter(input().split())
B=Counter(input().split())
C=Counter(input().split())
ans=0
for a_key,a_count in A.most_common():
for b_key,b_count in B.most_common():
for c_key,c_count in C.most_common():
a_key,b_key,c_key=int(a_key),int(... | import bisect
N=int(eval(input()))
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
print((sum(bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b)) for b in B))) | p03557 |
n = int(eval(input()))
abc = [tuple(map(int, input().split(" "))) for i in range(3)]
a, b, c = [sorted(abc_i) for abc_i in abc]
sum_num = 0
for b_i in b:
can_a_count = n
for i, a_i in enumerate(a):
if a_i >= b_i:
can_a_count = i
break
can_c_count = n
for i, c_i in enumerate(c[::-1]):
if ... | import bisect
n = int(eval(input()))
abc = [tuple(map(int, input().split(" "))) for i in range(3)]
# n = 100000
# abc = [tuple(range(n)) for i in range(3)]
a, b, c = [sorted(abc_i) for abc_i in abc]
print((sum(bisect.bisect_left(a, b_i) * (n-bisect.bisect(c, b_i)) for b_i in b))) | p03557 |
import bisect
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
answer = 0
for a in A:
bi = bisect.bisect_right(B, a)
for i in range(bi, N):
ci = bisect.bisect_right(C, B[i])
... | import bisect
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
answer = 0
for b in B:
ai = bisect.bisect_left(A, b)
ci = bisect.bisect_right(C, b)
answer += ai * (N - ci)
print(answer)
| p03557 |
from bisect import bisect_left, bisect_right
N = int(eval(input()))
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
answer = 0
for b in B:
ai = bisect_left(A, b)
ci = bisect_right(C, b)
answer += len(A[:ai]) * len(C[ci:])
print(... | from bisect import bisect_left, bisect_right
N = int(eval(input()))
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
answer = 0
CL = len(C)
for b in B:
ai = bisect_left(A, b)
ci = bisect_right(C, b)
answer += ai * (CL - ci)
prin... | p03557 |
N = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))
a_b = 0
b_c = 0
count = 0
for b_item in b:
while a_b < N and a[a_b] < b_item:
if a[a_b] >= b_item:
break
a_b += 1
while b_c... | N = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
a_b = 0
b_c = 0
count = 0
for b_item in b:
while a_b < N and a[a_b] < b_item:
a_b += 1
while b_c < N and c[b_c] <= b_item:
b_c +... | p03557 |
import math
import sys
import bisect
N = int(eval(input()))
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A = sorted(A)
B = sorted(B)
C = sorted(C)
BAcnt = [0] * N
for i in range(N):
BAcnt[i] = bisect.bisect_left(A, B[i])
r... | import math
import sys
import bisect
N = int(eval(input()))
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A = sorted(A)
B = sorted(B)
C = sorted(C)
BAcnt = [0] * N
for i in range(N):
BAcnt[i] = bisect.bisect_left(A, B[i])
... | p03557 |
n=int(eval(input()))
a=list(map(int,input().split(' ')))
b=list(map(int,input().split(' ')))
c=list(map(int,input().split(' ')))
a=[0]+sorted(a)+[float('inf')]
c=[0]+sorted(c)+[float('inf')]
def bin_search_a(a,b):
low=0
high=len(a)-1
while low<=high:
mid=(low+high)//2
if a[mid... | n=int(eval(input()))
a=list(map(int,input().split(' ')))
b=list(map(int,input().split(' ')))
c=list(map(int,input().split(' ')))
a=[0]+sorted(a)+[float('inf')]
c=[0]+sorted(c)+[float('inf')]
def meguru_a(bi):
ng=n+1 ; ok=0
while (abs(ok - ng) > 1):
mid = (ok + ng) // 2
if a[mid] <... | p03557 |
def nibu(list,item):
high=len(list)-1
low=0
while low <= high:
mid=(low+high)//2
guess=list[mid]
if guess==item:
return mid+1
break
elif guess < item:
low = mid +1
elif guess > item:
high = mid - 1
i... | N=list(map(int,input().split()))
A=sorted(list(map(int,input().split())))
B=list(map(int,input().split()))
C=sorted(list(map(int,input().split())))
def countA(target,L):
ok=-1
ng=len(L)
while abs(ok-ng)>1:
mid=(ok+ng)//2
if L[mid]<target:
ok=mid
else:
ng=mid
return (ok+1)... | p03557 |
import bisect
N=int(eval(input()))
As=list(map(int,input().split()))
Bs=list(map(int,input().split()))
Cs=list(map(int,input().split()))
As.sort()
Bs.sort()
Cs.sort()
pyout=0
for i in range(N):
num1=bisect.bisect_left(Bs,Cs[i])
for j in range(num1):
num2=bisect.bisect_left(As,Bs[j])
... | import bisect
N=int(eval(input()))
As=list(map(int,input().split()))
Bs=list(map(int,input().split()))
Cs=list(map(int,input().split()))
As.sort()
Cs.sort()
pyout=0
for i in range(N):
num1=bisect.bisect_left(As,Bs[i])
num2=N-bisect.bisect_right(Cs,Bs[i])
pyout+=num2*num1
print(pyout) | p03557 |
import bisect
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
BtoC = [0]*N
for i in range(N):
BtoC[i] = N - bisect.bisect_right(C,B[i])
s = [0]*N
for i in range(N):
i = N-1-i
if i == N-... | import bisect
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
BtoC = [0]*N
for i in range(N):
BtoC[i] = N - bisect.bisect_right(C,B[i])
s = [0]*N
for i in range(N):
i = N-1-i
if i == N-... | p03557 |
import bisect
N=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort();B.sort();C.sort()
AB=[0 for i in range(N)]
BC=[0 for i in range(N)]
def find_gt(a,x):
i = bisect.bisect_right(a,x)
if i != len(a):
return N-i
... | import bisect
N=int(eval(input()))
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
ans=0
for i in range(N):
a=bisect.bisect_left(A,B[i])
c=N-bisect.bisect_right(C,B[i])
ans+=a*c
print(ans) | p03557 |
import bisect
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in range(N):
i = bisect.bisect_left(A, B[j])
k = bisect.bisect_right(C, B[j])
cnt += i * (N - k)
print(cnt) | from bisect import bisect,bisect_left
N=int(eval(input()))
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
ans=0
for b in B:
i=bisect_left(A,b)
j=bisect(C,b)
ans+=i*(N-j)
print(ans) | p03557 |
from bisect import bisect_left, bisect_right
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
a_left = 0
c_left = 0
for i in range(N):
b = B[i]
a_left += bisect_left(A[a_left:]... | from bisect import bisect_left, bisect_right
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
cnt = 0
for b in B:
cnt += bisect_left(A, b) * (N - bisect_right(C, b))
print(cnt) | p03557 |
import sys
from bisect import bisect
def main():
input = sys.stdin.readline
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
Bn = [0] * N
for i in range(N):
b = B[i... | import sys
from bisect import bisect
from itertools import accumulate
def main():
input = sys.stdin.readline
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
Bn = [0] * N
f... | p03557 |
n=int(eval(input()))
s=[list(map(int,input().split()))for i in range(3)]
c=0
for i in range(n):
p=s[2][i]
q=[j for j in s[1] if j<p]
f=[j for j in s[0] if j<p]
for a in range(len(q)):
r=q[a]
t=[j for j in f if j<r]
c+=len(t)
print(c) | n=int(eval(input()))
s=[list(map(int,input().split()))for i in range(3)]
s[0].sort()
s[1].sort()
s[2].sort()
c,d,e=0,0,0
for i in range(n):
while d<n and s[0][d]<s[1][i]:
d+=1
while e<n and s[2][e]<=s[1][i]:
e+=1
c+=d*(n-e)
print(c) | p03557 |
import bisect
N=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
A.sort()
B.sort()
C.sort()
for i in range(len(B)):
ans+=bisect.bisect_left(A,B[i])*(len(C)-bisect.bisect_right(C,B[i]))
print(ans) | N=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
#print(A)
A.sort()
B.sort()
C.sort()
#print(A)
import bisect
ans=0
for i in range(N):
cnt=bisect.bisect_left(A,B[i])*(N-bisect.bisect_right(C,B[i]))
ans+=cnt
print(ans) | p03557 |
import bisect
n=int(eval(input()))
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
b.sort()
c=[int(i) for i in input().split()]
c.sort()
#print(n,a,b,c)
ans=0
for j in range(n):
aa=bisect.bisect_right(b, a[j])
if aa < n:
for i in range(aa,n):
ans+=n-b... | import bisect
n=int(eval(input()))
a=[int(i) for i in input().split()]
a.sort()
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
c.sort()
#print(n,a,b,c)
ans=0
for j in range(n):
aa=bisect.bisect_left(a, b[j])
bb=bisect.bisect_right(c, b[j])
ans+=aa*(n-bb)
print(ans... | p03557 |
N=eval(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
#print A
#print B
#print C
sum=0
for i in range(N):
j_start=0
for j in range(N):
if B[j]<=A[i]:
continue
for k in range(j_start,N):
#print "# l... | import bisect
N=eval(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
sum=0
for val_b in B:
sum+=bisect.bisect_left(A, val_b)*( N-bisect.bisect_right(C, val_b) )
print(sum) | p03557 |
N=int(eval(input()))
*A,=sorted(map(int,input().split()))
*B,=sorted(map(int,input().split()))
*C,=sorted(map(int,input().split()))
from bisect import *
cnt=0
for a in A:
in_b = bisect_right(B, a)
for b in B[in_b:]:
in_c = bisect_right(C, b)
for c in C[in_c:]:
cnt+=1
pr... | N=int(eval(input()))
*A,=sorted(map(int,input().split()))
*B,=sorted(map(int,input().split()))
*C,=sorted(map(int,input().split()))
lenc=len(C)
from bisect import *
cnt=0
for b in B:
in_a = bisect_left(A, b)
in_c = bisect_right(C, b)
cnt+= in_a*(lenc-in_c)
print(cnt) | p03557 |
N=int(eval(input()))
*A,=sorted(map(int,input().split()))
*B,=sorted(map(int,input().split()))
*C,=sorted(map(int,input().split()))
lenc=len(C)
from bisect import *
cnt=0
for b in B:
in_a = bisect_left(A, b)
in_c = bisect_right(C, b)
cnt+= in_a*(lenc-in_c)
print(cnt) | N=int(eval(input()))
f=lambda:sorted(map(int,input().split()))
*A,=f()
*B,=f()
*C,=f()
from bisect import *
print((sum([bisect_left(A, b)*(N-bisect_right(C, b)) for b in B]))) | p03557 |
import sys
input = sys.stdin.readline
import itertools
def is_saidan(parts):
tmp = 0
for j in parts:
if j > tmp:
tmp = j
else:
break
else:
return True
return False
def snuke_festival(a,b,c):
comb = list(itertools.product(a,b,c))
... | import sys
input = sys.stdin.readline
def snuke_festival(a,b,c):
count = 0
a_sorted = sorted(a)
c_sorted = sorted(c)
for n in b:
ab = 0
bc = 0
for i in a_sorted:
if n > i:
ab += 1
for i in c_sorted:
if n < i:
... | p03557 |
import sys
input = sys.stdin.readline
def binary_search(ys,target,low,high,reverse=True):
xs = sorted(ys)
maxlen = len(xs)
middle = 0
#print("array => %s, target => %d" %(xs,target))
while(low <= high):
middle = (low + high) // 2
#print("target %d, low %d, mid %d, high %... | import sys
input = sys.stdin.readline
import bisect
def snuke_festival(a,b,c):
count = 0
a_sorted = sorted(a)
b_sorted = sorted(b)
c_sorted = sorted(c)
maxlen=len(b)
for target in b_sorted:
#mid_a = binary_search_left(a_sorted,target)
#mid_c = binary_search_rig... | p03557 |
import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
lenC = len(C)
cnt = 0
for a in A:
for b in B:
if a >= b: continue
ii = bisect.bisect_right(C, b)
... | import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
lenC = len(C)
cnt = 0
for b in B:
ind_a = bisect.bisect_left(A, b)
ind_c = bisect.bisect_right(C, b)
cnt += ind_a... | p03557 |
import bisect
n=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=0
for a in A:
bidx=bisect.bisect_right(B,a)
if bidx==len(B): break
for b in B[bidx:]:
cidx=bisect.bisect_right(C,b)
if cidx==... | import bisect
n=int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
ans=0
for b in B:
aidx=bisect.bisect_left(A,b)
cidx=bisect.bisect_right(C,b)
ans+=aidx*(len(C)-cidx)
print(ans) | p03557 |
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
b_ptn = [0] * (N)
for idx, b in enumerate(B):
cnt = 0
for a in A:
if a < b:
cnt += 1
else:
break
b_ptn[idx] = cnt
ans ... | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
nums = []
for idx in range(N):
nums.append((1, A[idx]))
nums.append((2, B[idx]))
nums.append((3, C[idx]))
nums.sort(key=lambda x:(x[1], -x[0]))
sum_a = 0
sum_b = 0
sum_c... | p03557 |
import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
B.sort()
C.sort()
cnt = 0
for a in A:
pos_b = bisect.bisect_right(B, a)
for pb in range(pos_b, N):
pos_c = bisect.bisect_right(C, B[pb])
cnt += N-pos... | import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
cnt = 0
for b in B:
pos_a = bisect.bisect_left(A, b)
pos_c = bisect.bisect_right(C, b)
cnt += pos_a * (N-pos_c)
print(cnt) | p03557 |
n=int(eval(input()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
count=0
import bisect
for i in range(0,n):
tempb=bisect.bisect_right(b,a[i])
if tempb!=len(b):
for j in range(tempb,n):
tempc=bisect.bisect_right(... | import bisect
n=int(eval(input()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
temp1=bisect.bisect_left(a,b[i])
temp2=bisect.bisect(c,b[i])
ans=ans+temp1*(n-temp2)
print(ans) | p03557 |
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
B = sorted(B,reverse=True)
C = sorted(C,reverse=True)
b_list = {-1:0}
for i in range(N):
for j in range(N):
if B[i] >= C[j]:
b_list[i] = j + b_list[i-1]... | from bisect import bisect_right
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
B = sorted(B)
C = sorted(C)
b_list = {N:0}
for i in range(N-1,-1,-1):
j = bisect_right(C,B[i])
b_list[i] = N - j + b_list[i+1]
m = 0
fo... | p03557 |
from bisect import bisect_right
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N = int(readline())
A = [int(i) for i in readline().split()]
B = [int(i) for i in readline().split()]
C = [int(i) for i in readline().split()]
A.so... | from bisect import bisect_right, bisect_left
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N = int(readline())
A = [int(i) for i in readline().split()]
B = [int(i) for i in readline().split()]
C = [int(i) for i in readline().split()... | p03557 |
import bisect
N=int(eval(input()))
A=list(map(int,input().split()))
A=sorted(A)
B=list(map(int,input().split()))
B=sorted(B)
C=list(map(int,input().split()))
C=sorted(C)
count=0
for num in (A):
a=bisect.bisect_right(B,num)
for i in range(a,len(B)):
K=B[i]
l=bisect.bisect_right(C,K... | import bisect
N=int(eval(input()))
A=list(map(int,input().split()))
A=sorted(A)
B=list(map(int,input().split()))
B=sorted(B)
C=list(map(int,input().split()))
C=sorted(C)
count=0
for num in (B):
a=bisect.bisect_left(A,num)
b=bisect.bisect_right(C,num)
count+=a*(N-b)
print(count) | p03557 |
n = int(eval(input()))
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
cnt = 0
for i in range(n):
for j in range(n):
if C[i]>B[j]:
for k in range(n):
if B[j]>A[k]:
cnt+=1
print(cnt) | import bisect
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())))
cnt = 0
for i in range(n):
a = bisect.bisect_left(A, B[i])
c = bisect.bisect_right(C, B[i])
cnt += a * (n-c)
print(cnt)
| p03557 |
import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for i in C:
index = bisect.bisect_left(B,i)
for j in range(index):
index2 = bisect.bisect_left(A,B[j])
... | import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
mid_list = [0]*N
for i in range(N):
index = bisect.bisect_left(A,B[i])
if i == 0:
mid_list[i] = index
else:
... | p03557 |
import bisect
n = int(eval(input()))
bb = [0] * (n+1)
ans = 0
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()
for i in range(1,n+1):
bb[i] = bisect.bisect_left(a,b[i-1]) + bb[i-1]
for i in range(n):
ans... | import bisect
n = int(eval(input()))
ans = 0
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
for i in range(n):
ans += bisect.bisect_left(a,b[i]) * (n-bisect.bisect_right(c,b[i]))
print(ans) | p03557 |
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A = sorted(A,reverse=True)
B = sorted(B,reverse=True)
C = sorted(C,reverse=True)
count = 0
for i in range(N):
a = A[i]
for j in range(N):
b = B[j]
if ... | def bs_left(A, target):
low, high = 0, len(A)
while low<high:
mid = (low+high)//2
if A[mid]<target:
low = mid+1
else:
high = mid
return low
def bs_right(C, target):
low, high = 0, len(C)
while low<high:
mid = (low+high)//2
... | p03557 |
import sys
input = lambda: sys.stdin.readline().rstrip()
def resolve():
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
def binsearch_left(a, x):
l = -1... | import sys
input = lambda: sys.stdin.readline().rstrip()
import bisect
def resolve():
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
ans = 0
for b in B:
a_r = ... | p03557 |
import bisect
def solve(N,A,B,C):
# A=['3', '14', '159', '2', '6', '53']
# B=['58', '9', '79', '323', '84', '6']
# C=['2643', '383', '2', '79', '50', '288']
A,B,C=list(map(int, A)),list(map(int, B)),list(map(int, C))
A=sorted(A)
B=sorted(B)
C=sorted(C)
# print(A)
# pr... |
import bisect
def solve(N,A,B,C):
# A=['3', '14', '159', '2', '6', '53']
# B=['58', '9', '79', '323', '84', '6']
# C=['2643', '383', '2', '79', '50', '288']
A,B,C=list(map(int, A)),list(map(int, B)),list(map(int, C))
A=sorted(A)
B=sorted(B)
C=sorted(C)
# print(A)
# pr... | p03557 |
import bisect
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
b_num = [0 for _ in range(len(b))]
for b_i in range(len(b)):
c_i = bisect.bisect_right(c, b[b_i])
b_num[b_i] = len(b) - c_i
... | import bisect
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
b_num = [0 for _ in range(n)]
for b_i in range(n):
c_i = bisect.bisect_right(c, b[b_i])
b_num[b_i] = n - c_i
for i in range(... | p03557 |
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.rstrip()
# sys.setrecursionlimit(10**8)
# mod = 1... | 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... | p03557 |
from bisect import bisect_left, bisect_right
N = int(eval(input()))
A = sorted([int(x) for x in input().split()])
B = sorted([int(x) for x in input().split()])
C = sorted([int(x) for x in input().split()])
ans = 0
for b in B:
ans += len(A[:bisect_right(A, b - 1)]) * len(C[bisect_left(C, b + 1):])
print(... | from bisect import bisect_left, bisect_right
N = int(eval(input()))
A = sorted([int(x) for x in input().split()])
B = sorted([int(x) for x in input().split()])
C = sorted([int(x) for x in input().split()])
ans = 0
for b in B:
ans += bisect_right(A, b - 1) * (N - bisect_left(C, b + 1))
print(ans)
| p03557 |
N = int(eval(input()))
Alist = sorted(list(map(int, input().split())))
Blist = sorted(list(map(int, input().split())))
Clist = sorted(list(map(int, input().split())))
def binary_search(num_list, target):
ans_counter = 0
if target <= num_list[0]:
return -1
if num_list[-1] < target:
... | import bisect
N = int(eval(input()))
Alist = sorted(list(map(int, input().split())))
Blist = sorted(list(map(int, input().split())))
Clist = sorted(list(map(int, input().split())))
ans = 0
for B in Blist:
Aindex = bisect.bisect_left(Alist, B)
Cindex = bisect.bisect_right(Clist, B)
# print(B,... | p03557 |
def read_input():
n = int(eval(input()))
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))
return n, alist, blist, clist
def submit():
n, alist, blist, clist = read_input()
alist.sort(reverse=True)
b... |
def read_input():
n = int(eval(input()))
alist = list(map(int, input().split()))
blist = list(map(int, input().split()))
clist = list(map(int, input().split()))
return n, alist, blist, clist
def submit():
n, alist, blist, clist = read_input()
alist.sort(reverse=True)
b... | p03557 |
import bisect
import sys
input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int ,input().split()))
B = list(map(int ,input().split()))
C = list(map(int ,input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in B:
a_index = bisect.bisect_left(A, j)
c_index = bisect.bisect_right(... | import bisect
import sys
input = sys.stdin.readline
N = int(eval(input()))
A = list(map(int ,input().split()))
B = list(map(int ,input().split()))
C = list(map(int ,input().split()))
A.sort()
B.sort()
C.sort()
cnt = 0
for j in B:
a_index = bisect.bisect_left(A, j)
c_index = bisect.bisect_right(... | p03557 |
n = int(eval(input()))
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())), reverse=True)
c = sorted(list(map(int, input().split())), reverse=True)
ans = 0
for ai in a:
for bi in b:
if bi <= ai:
break
for ci in c:
if ... | import bisect
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for bi in b:
upper = bisect.bisect_left(a, bi)
lower = n - bisect.bisect_right(c, bi)
ans += upper * lower
print(ans)
| p03557 |
def binarySearchLeft(nums, target):
low = 0
high = len(nums) - 1
while low <= high:
mid = low + high >> 1
if target == nums[mid]:
if mid == 0 or target != nums[mid - 1]:
return mid
else:
high = mid - 1
elif target < nu... | def binarySearchLeft(nums, target):
low = 0
high = len(nums) - 1
while low <= high:
mid = low + high >> 1
if target == nums[mid]:
if mid == 0 or target != nums[mid - 1]:
return mid
else:
high = mid - 1
elif target < nu... | p03557 |
import bisect
n = int(eval(input()))
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a = sorted(a)
b = sorted(b)
c = sorted(c)
ans = 0
for x in b:
aa = bisect.bisect_left(a,x)
cc = len(c) - bisect.bisect_right(c,x)
ans += ... | import bisect
n = int(eval(input()))
lstA = sorted(list(map(int,input().split())))
lstB = sorted(list(map(int,input().split())))
lstC = sorted(list(map(int,input().split())))
ans = 0
for i in range(n):
num = lstB[i]
top = bisect.bisect_left(lstA, num)
btm = n - bisect.bisect_right(lstC, num)
... | p03557 |
import bisect
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
C.sort()
ans = 0
mem_idx_a = {}
for idx_b in range(N):
idx_c = bisect.bisect_right(C,B[idx_b])
idx_a = bisect.bisect_left(A,B[idx_b])
ans += (N-i... | import bisect
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for b in B:
idx_a = bisect.bisect_left(A, b)
idx_c = bisect.bisect(C, b)
ans += idx_a * (N - idx_c)
print(ans)
| p03557 |
n = int(eval(input()))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a_check = [n] * n
c_check = [0] * n
for i,j in enumerate(sorted(b)):
for k,l in enumerate(sorted(c)):
if l > j:
c_check[i] = n - k
break
... | n = int(eval(input()))
a = sorted([int(i) for i in input().split()])
b = sorted([int(i) for i in input().split()])
c = sorted([int(i) for i in input().split()], reverse=True)
a.append(10**9)
check_a = 0
check_c = n - 1
ans = 0
for i in b:
while a[check_a] < i and check_a < n :
check_a += 1
... | p03557 |
import bisect
ans = 0
N = int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
length = len(A)
#A<B<Cの組み合わせの数が答え
for i in range(length):
#Aを1つ決めた時、BがA以下の値
A_miman = bisect.bisect_right(B,A[i])
for j... | import bisect
ans = 0
N = int(eval(input()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
#A<B<Cの組み合わせの数が答え
for i in range(N):
#Bを1つ決めた時、AがB未満の場合の総数
B_miman = bisect.bisect_left(A,B[i])
#Bを1つ決めた時、CがB以上の場合の総... | p03557 |
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
ans = 0
for b in B:
ans += bisect_left(A,b) * (N - b... | N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
from bisect import *
ans = 0
for b in B:
a = bisect_left(A,b)
c = N-bisect_right(C,b)
ans += a*c
print(ans) | p03557 |
N = int(eval(input()))
ABC = [sorted(list(map(int,input().split()))) for i in range(3)]
ans = 0
for i in range(N):
for j in range(N):
if ABC[0][i]>=ABC[1][j]:
continue
else:
for k in range(N):
if ABC[1][j]>=ABC[2][k]:
continue
else:
ans += 1
... | import bisect
N = int(eval(input()))
ABC = [sorted(list(map(int,input().split()))) for i in range(3)]
ans = 0
for b in ABC[1]:
ans += bisect.bisect_left(ABC[0],b)*(N-bisect.bisect_right(ABC[2],b))
print(ans) | p03557 |
import bisect
n = int(eval(input()))
a,b,c = [list(sorted(map(int, input().split()))) for _ in range(3)]
ans = 0
for i in range(n):
x = bisect.bisect_left(a, b[i])
y = len(c) - bisect.bisect_right(c, b[i])
ans += x*y
print(ans) | import bisect
n = int(eval(input()))
a,b,c = [list(sorted(map(int, input().split()))) for _ in range(3)]
ans = 0
for i in b:
x = bisect.bisect_left(a, i)
y = len(c) - bisect.bisect_right(c, i)
ans += x*y
print(ans) | p03557 |
#!/usr/bin/env python3
from itertools import product, permutations, combinations
N=int(eval(input()))
A=sorted(list(map(int, input().split())), reverse=True)
B=sorted(list(map(int, input().split())), reverse=True)
C=sorted(list(map(int, input().split())), reverse=True)
ret = 0
for i in C:
small_b = [b for... | #!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
N=int(eval(input()))
A=sorted(list(map(int, input().split())))
B=sorted(list(map(int, input().split())))
C=sorted(list(map(int, input().split())))
ret = 0
for i in range(N):
# 中段... | p03557 |
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
#A.sort()
B.sort()
C.sort()
def is_ok(arg, target, abc):
if abc[arg] > target:
return True
else:
return False
def bict(left, right, target, abc):
... |
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
def is_ok(arg, target, abc):
if abc[arg] >= target:
return True
else:
return False
def is_ok2(arg, target, abc):
... | p03557 |
import sys
import bisect
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
cnt = 0
for i in range(n):
if a[i] > b[n - 1]:
break
insert_index_b = bisect... | import sys
import bisect
input = sys.stdin.readline
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
cnt = 0
ans = 0
memo = [0] * n
for i in range(n):
insert_index_c = bisect.bisect_right(c... | p03557 |
import bisect
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
#初めから、どこに挿入されるのかを考えておく
A = {}
B = {}
C = {}
for i in range(n):
B[c[i]] = min(bisect.bisect_left(b, c[i]), n)
A[b[i]] ... | import bisect
n = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
#初めから、どこに挿入されるのかを考えておく
Bcount = [0 for i in range(n+1)]
for i in range(1,n+1):
Bcount[i] = bisect.bisect_left(a, b[i-1]) + B... | p03557 |
N = int(eval(input()))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
c.sort(reverse=True)
p=0
q=0
i = 0
ans = 0
for bss in b:
p = 0
q = 0
for ass in a:
if ass < bss:
p += 1
for css in c:
if css > bss:
... | import bisect
N = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()
ans = 0
def find_lt(a, x):
'Find rightmost value less than x'
i = bisect.bisect_left(a, x)
if i:
return i
return 0
def ... | p03557 |
N=int(eval(input()))
A,B,C=[sorted(map(int,input().split())) for i in range(3)]
ans=a=c=0
for i in B:
for j in A[a:]:
if i>j:a+=1
else: break
for k in C[c:]:
if i<k:break
else: c+=1
if c==N:break
ans+=a*(N-c)
print(ans) | N=int(eval(input()))
A,B,C=[sorted(map(int,input().split())) for i in range(3)]
ans=a=c=0
for i in B:
while a<N and A[a]<i:
a+=1
while c<N and C[c]<=i:
c+=1
if c==N:break
ans+=a*(N-c)
print(ans) | p03557 |
import sys
import bisect
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
c = list(map(int, sys.stdin.readline().split()))
a.sort()
b.sort()
c.sort()
b_ans_list = [0 for _ in range(n)]
for i in range(n):
# b[i]における選択可能なc... | import sys
import bisect
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
c = list(map(int, sys.stdin.readline().split()))
a.sort()
b.sort()
c.sort()
b_ans_list = [0 for _ in range(n)]
for i in reversed(list(range(n))):
... | p03557 |
import bisect
N =int(eval(input()))
A =sorted(list(map(int,input().split())))
B =sorted(list(map(int,input().split())))
C =sorted(list(map(int,input().split())))
counter = 0
for i in range(len(A)):
b_index = bisect.bisect(B,A[i])
if b_index >= len(B):
break
b_diam = B[b_index]
for j i... | import bisect
N =int(eval(input()))
A =sorted(list(map(int,input().split())))
B =sorted(list(map(int,input().split())))
C =sorted(list(map(int,input().split())))
counter = 0
for i in range(len(B)):
#Bより小さいAの探索
Ind_A = bisect.bisect_left(A,B[i])
if A[Ind_A-1] == B[i]:
Ind_A -= 1
... | p03557 |
import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
count = 0
for i in range(N):
b_idx = bisect.bisect_right(B, A[i])
for j in range(b_idx, N):
c_idx = bisect.bisect_ri... | import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
BtoC = [0 for i in range(N+1)]
for i in range(N-1, -1, -1):
c_idx = bisect.bisect_right(C, B[i])
BtoC[i] = BtoC[i+1] + (N - c_i... | p03557 |
N = int(input().rstrip())
A = list(map(int, input().rstrip().split()))
B = list(map(int, input().rstrip().split()))
C = list(map(int, input().rstrip().split()))
A.sort()
B.sort()
C.sort()
def bin_search(vlist, targ):
lb = -1
ub = len(vlist)
while ub - lb > 1:
mid = (lb + ub) // 2
... | import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
lower_a = bisect.bisect_left(A, b)
upper_c = N - bisect.bisect_right(C, b)
ans += lower_a*upper_c
... | p03557 |
#https://atcoder.jp/contests/abc077/tasks/arc084_a
N = int(eval(input()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
a.sort()
b.sort()
c.sort()
for bi in b:
ai = 0
ci = N-1
while ai < N and a[ai] < bi:
ai += 1
wh... | #https://atcoder.jp/contests/abc077/tasks/arc084_a
N = int(eval(input()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
a.sort()
b.sort()
c.sort()
ai = 0
ci = 0
for bi in b:
while ai < N and a[ai] < bi:
ai += 1
while ci < N... | p03557 |
import bisect
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
cnt = 0
info = []
for i in range(n):
b_p = bisect.bisect_left(a, b[i])
info.append(b_p)
for k in range(n):
a_p = bisect.bi... | import bisect
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
cnt = 0
info1 = []
for i in range(n):
b_p = bisect.bisect_left(a, b[i])
info1.append(b_p) # bがそれぞれ何種類のaを載せれるか
info2 = [info1[... | p03557 |
from bisect import bisect_right
N = int(eval(input()))
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
ans = 0
y_low = {}
i = 0
for x in A:
y_low[i] = bisect_right(B, x)
i += 1
for y_lowi in list(y_low.values()):
for y in B[y_... | from bisect import bisect_left
from bisect import bisect_right
N = int(eval(input()))
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
ans = 0
y_low = {}
i = 0
for y in B:
x = bisect_left(A, y)
z = bisect_right(C, y)
ans += x... | p03557 |
def lowerBound(arr, n):
arr += [10e9+7]
low, high = 0, len(arr)
mid = (low+high)//2
while high-low>1:
if arr[mid]>=n: high = mid
else: low = mid
mid = (low+high)//2
return high
def upperBound(arr, n):
arr = [0] + arr
low, high = 0, len(arr)
mid = (lo... | def lowerBound(arr, n):
low, high = -1, len(arr)
while high-low>1:
mid = (low+high)//2
if arr[mid]>=n: high = mid
else: low = mid
return high
def upperBound(arr, n):
low, high = -1, len(arr)
while high-low>1:
mid = (low+high)//2
if arr[mid]>n: hig... | p03557 |
n = int(eval(input()))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()
c = c[::-1]
answer,x,y = 0,0,0
for j in b:
for k in range(x,n):
if a[k] >= j:
x = k
break
elif k == n-1:
x = n
for k2 in rang... | import bisect
n = int(eval(input()))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
c.sort()
answer = 0
for i in b:
x = bisect.bisect_right(c,i)
y = bisect.bisect_left(a,i)
answer += (n-x)*y
print(answer) | p03557 |
import bisect
n=int(eval(input()))
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
sm=0
for i in C:
b=bisect.bisect_left(B,i)
for j in B[:b]:
sm+=bisect.bisect_left(A,j)
print(sm)
| import bisect
n=int(eval(input()))
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
sm=0
for j in B:
sm+=bisect.bisect_left(A,j)*(n-bisect.bisect_right(C,j))
print(sm)
| p03557 |
import bisect
N = int(eval(input()))
A = list(map(int, input().split()))
B = sorted(list(map(int, input().split())))
l_b = len(B)
C = sorted(list(map(int, input().split())))
l_c = len(C)
ans = 0
for a in A:
i = bisect.bisect_right(B, a)
for j in range(i, l_b):
num = bisect.bisect_right(C, B[j... | import bisect
N = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
l_c = len(C)
ans = 0
for b in B:
n_a = bisect.bisect_left(A, b)
n_c = l_c - bisect.bisect_right(C, b)
ans += n_a*n_c
print(ans)
| p03557 |
N = int(eval(input()))
A = [int(a) for a in input().split(" ")]
B = [int(b) for b in input().split(" ")]
C = [int(c) for c in input().split(" ")]
A.sort()
B.sort()
C.sort()
combiBC = [0] * len(B)
# combiBC[i] : number of combination of B, C when B[i] is selected
ic = 0
lc = len(C)
for ib in range(len(B... | N = int(eval(input()))
A = [int(a) for a in input().split(" ")]
B = [int(b) for b in input().split(" ")]
C = [int(c) for c in input().split(" ")]
A.sort()
B.sort()
C.sort()
combiBC = [0] * len(B)
# combiBC[i] : number of combination of B, C when B[i] is selected
ic = 0
lc = len(C)
for ib in range(len(B... | p03557 |
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return list(map(int, sys.stdin.readline().split()))
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): ret... | import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return list(map(int, sys.stdin.readline().split()))
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): ret... | p03557 |
n = eval(input())
top = list(map(int, input().split()))
top.sort()
middle = list(map(int, input().split()))
middle.sort()
under = list(map(int, input().split()))
under.sort()
cnt = 0
for i in top[::-1]:
for j in middle[::-1]:
if j <= i: break
for k in under[::-1]:
if k <= j: ... | # coding:utf-8
INF = float('inf')
def inpl(): return list(map(int, input().split()))
N = int(eval(input()))
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl())
ans = 0
i_a = 0
i_c = 0
for i_b in range(N):
while i_a < N and A[i_a] < B[i_b]:
i_a += 1
while i_c < N and C[i_c] ... | p03557 |
import bisect
n = int(eval(input()))
*a, = sorted(map(int, input().split()))
*b, = sorted(map(int, input().split()))
*c, = sorted(map(int, input().split()))
ans = 0
for _c in c:
i = bisect.bisect_left(b, _c)
for j in range(i):
ans += bisect.bisect_left(a, b[j])
print(ans)
| import bisect
n = int(eval(input()))
*a, = sorted(map(int, input().split()))
*b, = sorted(map(int, input().split()))
*c, = sorted(map(int, input().split()))
ans = 0
for _b in b:
aNum = bisect.bisect_left(a, _b)
cNum = len(c) - bisect.bisect_right(c, _b)
ans += aNum*cNum
print(ans)
| p03557 |
import bisect
n = int(eval(input()))
*a, = sorted(map(int, input().split()))
*b, = sorted(map(int, input().split()))
*c, = sorted(map(int, input().split()))
ans = 0
for _b in b:
aNum = bisect.bisect_left(a, _b)
cNum = len(c) - bisect.bisect_right(c, _b)
ans += aNum*cNum
print(ans)
| import bisect
n = int(eval(input()))
*a, = list(map(int, input().split()))
*b, = list(map(int, input().split()))
*c, = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for _b in b:
ans += bisect.bisect_left(a, _b)*(n - bisect.bisect_right(c, _b))
print(ans)
| p03557 |
import bisect
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
a = A[i]
for b in B[bisect.bisect_right(B, a):]:
ans += len(C[bisect.bisect_right(C, b):])
pri... | import bisect, itertools
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
c_num = [0]*n
for i in range(n):
c_num[i] = n - bisect.bisect_right(C, B[i])
c_accum = [0] + list(itertools.accumulate(c_num... | p03557 |
def main():
N = int(eval(input()))
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))
C = list(map(int, input().split(" ")))
A.sort()
B.sort()
C.sort()
cnt = 0
for a in A:
for b in B:
if a >= b:
continue
... | #!/usr/bin/env python
import bisect
def main():
N = int(eval(input()))
A = list(map(int, input().split(" ")))
B = list(map(int, input().split(" ")))
C = list(map(int, input().split(" ")))
A.sort()
B.sort()
C.sort()
cnt = 0
for b in B:
a_index = bisect.bise... | p03557 |
# ABC_077_C_Sunuke_Festival.py
from bisect import bisect_left, bisect_right
N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
# B[j]を固定してA[i]<=B[j]<=C[k]を満たす(i,j)の個数を求める
# ソートして二分探索すれば間に合う
A.sort()
# B.sort()
C.sort()
# prin... | from bisect import bisect_right, bisect_left
N=int(eval(input()))
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
a.sort()
c.sort()
ans=0
for i in range(N):
s=b[i]
k=bisect_left(a,s)*(N-bisect_right(c,s))
ans+=k
print(ans) | p03557 |
import bisect
from itertools import accumulate
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
b_to_c = [0]*n
for i in range(n):
b_to_c[i] = n - bisect.bisect_right(C, B[i])
Q = list(accumulate... | import bisect
n = int(eval(input()))
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for i in B:
ans += bisect.bisect_left(A, i) * (n - bisect.bisect_right(C, i))
print(ans) | p03557 |
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
#A2 = sorted(A)
#B2 = sorted(B)
#C2 = sorted(C)
def numadd(up, down):
array = []
count = 0
last = 0
for i in range(0,N):
while down[i] > up[count]:
... | N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A2 = sorted(A)
B2 = sorted(B)
C2 = sorted(C)
A2.append(2000000000)
B2.append(2000000000)
def numadd(up, down):
array = []
count = 0
for i in range(0,N):
... | p03557 |
import bisect
n = int(eval(input()))
a,b,c = [sorted(map(int,input().split())) for _ in "abc"]
print((sum([bisect.bisect_left(a,x)*(n-bisect.bisect_right(c,x)) for x in b]))) | from bisect import *
N = int(eval(input()))
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
print((sum(bisect_left(A,b)*(N-bisect_right(C,b)) for b in B))) | p03557 |
#-*-coding:utf-8-*-
import bisect
def main():
n = int(eval(input()))
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
a_list.sort()
b_list.sort()
c_list.sort()
cnt = 0
for i in range(n)... | #-*-coding:utf-8-*-
import bisect
def main():
n = int(eval(input()))
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
a_list.sort()
b_list.sort()
c_list.sort()
cnt = 0
for b in b_list:
... | p03557 |
import bisect
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
C.sort()
ans = 0
for b in B:
ai = bisect.bisect_left(A,b)
ci = bisect.bisect(C,b)
ans += ai*(N-ci)
print(ans) | import bisect
N = int(eval(input()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
C.sort()
ans = 0
for b in B:
ai = bisect.bisect_left(A, b)
ci = bisect.bisect_right(C, b)
ans += ai * (N-ci)
print(ans) | p03557 |
import bisect
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
a_n = [0] * n
b_n = [0] * n
for i in range(n):
a_n[i] = bisect.bisect_right(b, a[i])
for i in range(n):
b_n[i] = n - bisect.bisect_... | import bisect
n = int(eval(input()))
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
a_n = [0] * n
b_n = [0] * n
for i in range(n):
a_n[i] = bisect.bisect_right(b, a[i])
for i in range(n):
b_n[i] = n - bisect.bisect_... | p03557 |
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc077/tasks/arc084_a
"""
import sys
from sys import stdin
from bisect import bisect_left, bisect_right
from functools import lru_cache
input = stdin.readline
@lru_cache(maxsize=None)
def calc(i):
ans = 0
for b in B[i:]:
j =... | # -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc077/tasks/arc084_a
"""
import sys
from sys import stdin
from bisect import bisect_left, bisect_right
input = stdin.readline
def main(args):
N = int(eval(input()))
A = [int(x) for x in input().split()]
B = [int(x) for x in input... | p03557 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.