Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

def main():
    n = int(input())
    la = list(map(int, input().split()))
    lb = list(map(int, input().split()))
    lc = list(map(int, input().split()))
    
    la.sort()
    lb.sort()
    lc.sort()

    ans = 0
    for a in la:
        if a < lb[-1]:
            idxb = bisect.bisect_right(lb, a)
            for b in lb[idxb:]:
                if b < lc[-1]:
                    idxc = bisect.bisect_right(lc, b)
                    ans += (n - idxc)
    print(ans) 

if __name__ == '__main__':
    main()

### FIXED CODE ###

s1 = input()
s2 = input()[::-1]
print("YES") if s1 == s2 else print("NO")
import sys
mod = 10 ** 9 + 7

n,m = map(int,input().split())
if n in [0,1]:
    print(1)
    sys.exit()
    
if not m == 0:
    lis = [int(input()) for x in range(m)]
else:
    lis = []
val1 = 1
if 1 in lis:
    val2 = 0
else:
    val2 = 1
nex = 0
flg = lis[0]
f = 0
for x in range(2,n):
    if x == flg:
        nex += 1
        flg = lis[nex]
        now = 0
    else:
        now = (val1 + val2) % mod
    val1,val2 = val2,now
    
print((val1 + val2) % mod)
    


### FIXED CODE ###

import sys
mod = 10 ** 9 + 7

n,m = map(int,input().split())
if n in [0,1]:
    print(1)
    sys.exit()
    
if not m == 0: lis = [int(input()) for x in range(m)]
else: lis = [-1]
val1 = 1
if 1 in lis: val2 = 0
else: val2 = 1

if lis[0] == 1 and len(lis) >= 2:
    flg = lis[1]
    nex = 1
else:
    flg = lis[0]
    nex = 0
#print(lis)
for x in range(2,n):
    if x == flg: #x in lis
        #print(flg)
        nex += 1
        try: flg = lis[nex]
        except:flg = 0
        now = 0
    else:
        now = (val1 + val2) % mod
    val1,val2 = val2,now
    
print((val1 + val2) % mod)
s = input()

n = len(s)
ans = []
for i in range(n):
    if s[i] != '?':
        ans.append(s[i])
    else:
        if s[i-1] == 'P' and i > 0:
            ans.append('D')
        elif s[i-1] == '?'and i > 0:
            ans.append('D')
        elif s[i+1] == '?' and i < n:
            ans.append('P')
        elif s[i+1] == 'D' and i < n:
            ans.append('P')
        else:
            ans.append('D')
            
print(*ans,sep = '')
        


### FIXED CODE ###

s = input()

n = len(s)
ans = []
for i in range(n):
    if s[i] != '?':
        ans.append(s[i])
    else:
        ans.append('D')
            
print(*ans,sep = '')
(n, k) = [int(x) for x in input().split()]

s = set()

for i in range(k):
  input()
  s |= set(input().split)
    
print(n-len(s))


### FIXED CODE ###

(n, k) = [int(x) for x in input().split()]

s = set()

for i in range(k):
    input()
    s |= set(input().split())
    
print(n-len(s))
n,m = map(int,input().split())
graph = {i+1:[] for i in range(1,n+1)}

for _ in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)
  
bridge = set([])

ans = 0
while 1:
  count = 0
  for i in range(1,n+1):
    if len(graph[i]) == 1:
      count += 1
      a = graph[i]
      graph[a].remove(i)
      graph[i] = []
  ans += count
  if count == 0:
    break
  else:
    count = 0
print(ans)
  

### FIXED CODE ###

n,m = map(int,input().split())
graph = {i:[] for i in range(1,n+1)}

for _ in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)
  
bridge = set([])

ans = 0
while 1:
  count = 0
  for i in range(1,n+1):
    if len(graph[i]) == 1:
      count += 1
      a = graph[i][0]
      graph[a].remove(i)
      graph[i] = []
  ans += count
  if count == 0:
    break
  else:
    count = 0
print(ans)
tenki = input()

if tenki == Sunny:
  print("Cloudy")
elif tenki == Rainy:
  print("Rainy")
else:
  print("Cloudy")

### FIXED CODE ###

tenki = input()

if tenki == "Sunny":
  print("Cloudy")
elif tenki == "Cloudy":
  print("Rainy")
else:
  print("Sunny")
S = raw_input()
answer = 0
model = "CODEFESTIVAL2016"
for x range(15):
    if S[x] != model[x]:
        answer += 1
print answer

### FIXED CODE ###

S = raw_input()
answer = 0
model = "CODEFESTIVAL2016"
for x in range(16):
    if S[x] != model[x]:
        answer += 1
print answer
c = 0
b = 0
for an in range(n):
    c+=1
    b+=ls[an]
    if b>x:
        break
print(c)

### FIXED CODE ###

n,x=map(int,input().split())
ls=list(map(int,input().split()))
c = 1
b = 0
for an in range(n):
    b+=ls[an]
    if b>x:
        break
    c+=1
print(c)
n=int(input())
x=input()
p=0
chk0=chk1=chk2=0
b=x.count("1")
for i,j in enumerate(x[::-1]):
    if j=="1":
        chk1+=pow(2,i,b+1)
        chk2+=pow(2,i,b-1)
l=[]
for i,j in enumerate(x[::-1]):
    a1=pow(2,i,b+1)
    a2=pow(2,i,b-1)
    if j=="0":
        t=chk1+a1
    else:
        t=chk2+b-1-a2
    ans=0
    f=1
    while t:
        if f:
            if j=="0": t%=(b+1)
            else: t%=(b-1)
            f=0
        else:
            t%=bin(t).count("1")
        ans+=1
    l.append(ans)
for i in l[::-1]:
    print(i)

### FIXED CODE ###

n=int(input())
x=input()
chk0=chk1=chk2=0
b=x.count("1")
if b==1 and x=="1":
    print(0)
    exit()
elif b==1:
    for i in range(n):
        if i==n-1: print(2)
        elif x[i]=="0": print(1)
        else: print(0)
    exit()
for i,j in enumerate(x[::-1]):
    if j=="1":
        chk1+=pow(2,i,b+1)
        if b>1: chk2+=pow(2,i,b-1)
        else: chk2=0
l=[]
for i,j in enumerate(x[::-1]):
    if b: a1=pow(2,i,b+1)
    else: a1=1
    if b>1: a2=pow(2,i,b-1)
    else: a2=1
    if j=="0":
        t=chk1+a1
    else:
        if b>1: t=chk2+b-1-a2
        else: t=0
    ans,f=0,1
    while t:
        if f:
            if j=="0": t%=(b+1)
            else: t%=(b-1)
            f=0
        else:
            t%=bin(t).count("1")
        ans+=1
    l.append(ans)
for i in l[::-1]:
    print(i)
N, K = map(int, input().split())
S = input()
if S[K-1] == "A":
  S[K-1] = "a"
elif S[K-1] == "B":
  S[K-1] = "b"
else:
  S[K-1] = "c"
print(S)


### FIXED CODE ###

N, K = map(int, input().split())
S = list(input())
if S[K-1] == "A":
  S[K-1] = "a"
elif S[K-1] == "B":
  S[K-1] = "b"
else:
  S[K-1] = "c"
ans = "".join(S)
print(ans)
l. r. d = map(int, input().split())
cnt = 0
for i in (l, r+1):
  if i % d == 0:
    cnt += 1
print(cnt)

### FIXED CODE ###

l, r, d = map(int, input().split())
cnt = 0
for i in range(l, r+1):
  if i % d == 0:
    cnt += 1
print(cnt)
a, b = map(int, input().split())
print("{} {}".format(a*b, 2*(a+b))


### FIXED CODE ###

a, b = map(int, input().split())
print("{} {}".format(a*b, 2*(a+b)))
S = input()
list_num = S.split(' ')
list_num = map(int, list_num)
N, A, B = list_num

if A+B>N:
  print(N-A-B)
elif A+B=N:
  print(A)

### FIXED CODE ###

l = input().split()

[n,a,b] = [int(x) for x in l]

if a==b and a==0:
    print(0)
else:
    x = a+b
    y = n//x

    if a == 0:
        print(0)
    else:
        if b == 0:
            print(n)
        else:
            t = n - y*x
            if t > a:
                print(y*a+a)
            else:
                print(y*a+t)
N=int(input())
lst=input().split()
lst_i=[int(i) for i in lst]
a=max(lst_i)
b=min(lst_i)
print(abs(a-b))

### FIXED CODE ###

N=int(input())

if N%2==0:
  print(N)
else:
  print(N*2)
inputlines = list(map(int, input().split()))
li = inputlines.sort()
print(' '.join(map(str, li)))

### FIXED CODE ###

inputlines = list(map(int, input().split()))
li = sorted(inputlines)
print(' '.join(map(str, li)))
a,b=map(int,input().split())
print(str(int(a*b)))

### FIXED CODE ###

a,b=map(float,input().split())
a=int(a)
b=int((b+10**-8)*100)
print(a*b//100)
N, K = map(int, input().split())

array = input().split()
for i in range(len(array)):
    array[i] = int(array[i])

now = 1

history = set()
start_number = -1

for i in range(K):
    history.add(now)
    now = array[now - 1]
    if(now in history):
        start_number = now
        break

if not(start_number == -1):
    start_ind = history.index(start_number)
    length = len(history) - start_ind
    mod = (K - start_ind) % length
    now = history[start_ind + mod]

print(now)


### FIXED CODE ###

N, K = map(int, input().split())

array = input().split()
for i in range(len(array)):
    array[i] = int(array[i])

now = 1

history = []
sethistory = set()
start_number = -1

for i in range(K):
    history.append(now)
    sethistory.add(now)
    now = array[now - 1]
    if(now in sethistory):
        start_number = now
        break

if not(start_number == -1):
    start_ind = history.index(start_number)
    length = len(history) - start_ind
    mod = (K - start_ind) % length
    now = history[start_ind + mod]

print(now)
import sys

for line in sys.stdin:
    a,b,c,d,e,f= map(int,line.split(" "))
    z=a*e-b*d
    if(z!=0):
        x=(c*e-b*f)/z
        y=(a*f-c*d)/z
    print("{0:.3f} {1:.3f)".format(x+0,y+0))

### FIXED CODE ###

while(True):
        try:
            a,b,c,d,e,f=map(float,input().split(" "))
            z=a*e-b*d
            if(z!=0):
                x=(c*e-b*f)/z
                y=(a*f-c*d)/z
            print("{:.3f} {:.3f}".format(x+0,y+0))
        except:
            break
import numpy as np
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
ll = np.ones(1)
for i in range(99):
    ll = np.append(ll,int(i+1))
    
for j in p:
    ll= ll[~(ll == j)]

# print(ll)

a = np.zeros(len(ll))
for i in range(len(ll)):
    a[i]=abs(x-ll[i])
# print(ll)
print(int(ll[np.argmin(a)]))


### FIXED CODE ###

import numpy as np
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
ll = np.ones(1)*(-1)
for i in range(102):
    ll = np.append(ll,int(i))
    
for j in p:
    ll= ll[~(ll == j)]

if len(ll) == 0:
    print(x)
    exit()
# print(ll)

a = np.zeros(len(ll))
for i in range(len(ll)):
    a[i]=abs(x-ll[i])
# print(ll)
print(int(ll[np.argmin(a)]))
import math
import fractions
from functools import reduce

n, m = map(int,input().split())
a = list(map(int,input().split()))
a = [x // 2 for x in a]#リストの要素すべてを2で割る

def lcm_base(x, y):
    return (math.gcd(x, y))

def lcm_list(numbers): #最小公倍数を求める
    return reduce(lcm_base, numbers, 1)

def num_dev2(x):
    return bin(x)[::-1].find("1") #２で割り切れる回数を確認

lcm = lcm_list(a)
q = m #lcm,mは最小公倍数で何回割れるか

count = 0
dev2 = num_dev2(a[0])
for i in range(1,n):
    if dev2 != num_dev2(a[i]):#リストのすべての要素の２で割れる回数は等しいか
        count += 1
        break
if count != 0:
    print(0)
else:
    print(math.ceil(q/2))

### FIXED CODE ###

import math
import fractions
from functools import reduce
 
n, m = map(int, input().split())
a = list(map(int, input().split()))
a=[t//2 for t in a] # リストの要素を全て2で割る
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
def lcm_list(numbers): # 最小公倍数を求める
    return reduce(lcm_base, numbers, 1)
 
def num_dev2(x): # 2で割り切れる回数をカウント
    return format(x, 'b')[::-1].find('1')
 
lcm = lcm_list(a)
q = m // lcm # mは最小公倍数で何回割れるか
 
count = 0
dev2 = num_dev2(a[0])
for i in range(1, n):
    if dev2 != num_dev2(a[i]): # リストの全ての要素の、2で割れる回数は等しいか？
        count += 1
        break
if count != 0:
    print(0)
else:
    print(math.ceil(q/2))
import math

N,M = map(int, input().split())
S = input()
T = input()

if S[0] != T[0]:
    print(-1)
    exit()

gcd = math.gcd(len(S), len(T))
lcm = len(S)*len(T) // gcd

if len(S) == len(T):
    if S == T:
        print(len(S))
    else:
        print(-1)
    exit()


ans = ['' for _ in range(lcm+1)]
#ans[1] = S[0]

#S
for i in range(0,N):
    L_N = lcm//N
    ind = i * L_N + 1

    if ans[ind] == '':
        ans[ind] = S[i:i+1]

for i in range(0,M):
    L_M = lcm//M
    ind = i * L_M + 1

    if ans[ind] == '':
        ans[ind] = T[i:i+1]
    elif ans[ind] != T[i:i+1]:
        print(-1)
        exit()

print(lcm)


### FIXED CODE ###

import bisect

def gcd(a,b):
    if b == 0:
        return abs(a)
    else:
        return gcd(b, a%b)

N,M = map(int, input().split())
S = input()
T = input()


if S[0] != T[0]:
    print(-1)
    exit()

if len(S) == len(T):
    if S == T:
        print(len(S))
    else:
        print(-1)
    exit()

gcd1 = gcd(len(S), len(T))
lcm = len(S)*len(T) // gcd1

SS = []
TT = []
i = 0
j = 0
while i < N:
    SS.append(i*lcm//N + 1)
    i += 1
while j < M:
    TT.append(j*lcm//M + 1)
    j += 1

ind = 0
ind_max = j-1

for i,v in enumerate(SS):
    ind = bisect.bisect_left(TT, v,ind, j)
    if ind == j:
        break
#    print(ind)
    if TT[ind] == v:
        if S[i] == T[ind]:
            continue
        else:
            print(-1)
            exit()
print(lcm)
import math

a,b=map(int,input().split())
c=math.floor((a+b)//2)
print(c)

import math

a,b=map(int,input().split())
c=math.floor((a+b)//2)
print(c)

### FIXED CODE ###

a,b=map(int,input().split())

if (a+b)%2==0:
    print((a+b)//2)    
else:
    print((a+b)//2+1)
print((int(input())//11)*2+(x%11-1)//6+1)

### FIXED CODE ###

import math
x = int(input())

if x<=6:
    print(1)
elif 7<=x<=11:
    print(2)
else:
    if x%11 ==1 or x%11 ==2 or x%11 ==3 or x%11 ==4 or x%11 ==5 or x%11 ==6:
        print((x//11)*2+1)
    elif x%11 ==7 or x%11 ==8 or x%11 ==9 or x%11 ==10:
        print((x // 11) * 2 + 2)
    else:
        print((x//11)*2)
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

N=int(input())
if N/9==0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import math

N=int(input())
if N%9==0:
    print('Yes')
else:
    print('No')
[a, b] = input().split()
if a+b == 15:
  print("+")
  return
if a*b == 15:
  print("*")
  return
print("x")
return

### FIXED CODE ###

[a, b] = map(int, input().split())
if a+b == 15:
  print("+")
elif a*b == 15:
  print("*")
else:
    print("x")
a = list(map(int, input().split()))

a.sort()
ans = 0:
for i in range(1, 3):
    ans += abs(a[i] - a[i - 1])

print(ans)

### FIXED CODE ###

a = list(map(int, input().split()))

a.sort()
ans = 0
for i in range(1, 3):
    ans += abs(a[i] - a[i - 1])

print(ans)
N,M=map(int,input().split())
ans=['A']*(N+1)
for i in range(M):
    s,c=map(str,input().split())
    s=int(s)
    if ans[s]=='A' or ans[s]==c :
        ans[s]=c
    else:
        print('-1')
        exit()
FA=ans[1:]
FA=''.join(FA)
if FA.count('A')>0:
    print(FA.replace('A','0'))
print(int(FA))


### FIXED CODE ###

N,M=map(int,input().split())
ans=[-1]*(N+1)
for i in range(M):
    s,c=map(int,input().split())
    if ans[s]==-1 :
        ans[s]=c
    elif ans[s]==c :
        pass
    else:
        print('-1')
        exit()

if N>=2 and ans[1]==0:
    print('-1')
    exit()
elif N>=2 and ans[1]==-1: #ここが間違ってた。
    ans[1]=1
else:
    pass

for j in range(len(ans)):
    if ans[j] == -1:
        ans[j] = 0

if N==1:
    FA=ans[-1]
elif N==2:
    FA=10*ans[-2]+ans[-1]
else:
    FA=100*ans[-3]+10*ans[-2]+ans[-1]
print(FA)
K = int(input())
A, B = map(int,input().spilt())
if(A<=B/K*K){
  print("OK")
}
else{
  print("NG")
}


### FIXED CODE ###

N = int(input())
A, B = map(int, input().split())
for i in range(A, B+1):
  if i % N == 0:
    print('OK')
    break
else:
  print('NG')
#C

K=int(input())
if K==1:
    ans=1
elif K==2 or K==5 or K==10:
    ans=-1
else:
    p=0
    for i in range(1,K+1):
        p = (p*10+7)%K 
        #print(i,p)
        if p==0:
            ans=i
            break

print(ans)

### FIXED CODE ###

#C

K=int(input())
ans=-1
if K==1:
    ans=1
elif K==2 or K==5 or K==10:
    ans=-1
else:
    p=0
    for i in range(1,K+1):
        p = (p*10+7)%K 
        #print(i,p)
        if p==0:
            ans=i
            break

print(ans)
N,L=map(int,input())
S=[input() for _ in range(N)]
S.sort()
print("".join(S))

### FIXED CODE ###

N,L=map(int,input().split())
S=[input() for _ in range(N)]
S.sort()
print("".join(S))
N=input()
count=0
for i in range(N):
    count+=int(input())%2
if count>0:
    print("first")
else:
    print("second")

### FIXED CODE ###

# Enter your code here. Read input from STDIN. Print output to STDOUT

def find(x):
    dic={}
    
    def fact(t):
        T=int(t**0.5)+1
        for i in range(2,T):
            if t%i==0:
                if i in dic:
                    dic[i]+=1
                else:
                    dic[i]=1
                return i
        if t in dic:
            dic[t]+=1
        else:
            dic[t]=1            
        return t

    while x>1:
        #print(x)
        x=int(x/fact(x))
        #print(x)
    return dic

def find_ans(N,P):
    dic=find(P)
    ans=1
    for x in dic:
        ans*=pow(x,dic[x]//N)
    return ans    

N,P=list(map(int,input().split(" ")))
print(find_ans(N,P))
import math
a, b, c=input().split(" ")
 
if float(a) + 2*math.sqrt(float(a)) * math.sqrt(float(b)) + float(b) < c:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import math
a, b, c=input().split(" ")
a = int(a) 
b = int(b)
c = int(c) 

if  4*a*b < (c-a-b)*(c-a-b) and (c-a-b)>0:
  print("Yes")
else:
  print("No")
tmp = input().rstrip().split()
N = int(tmp[0])

list = [[] for x in range(100000)]
count = [0]*100000

for  i in range(N):
    work = input().rstrip().split()
    for i in range(int(work[0]),int(work[1])+1):
        if int(work[2]) not in list[i]:
            list[i].append(int(work[2]))
            count[i] += 1
            
print(max(count))

### FIXED CODE ###

N,C = map(int,input().split())
tvs = [list(map(int,input().split())) for _ in range(N)]
chans = [[] for _ in range(C+1)]
tvs.sort(key=lambda x:x[0])
targets = []
times = [0]*(pow(10,5)+2)

for tv in tvs:
  chans[tv[2]].append([tv[0],tv[1]])

for chan in chans:
  tmp = []
  if len(chan) == 1:
    targets.append(chan[0])
    continue
  for x in range(len(chan)):
    if len(tmp) == 0:
      tmp = chan[x]
      continue
    if chan[x][0] <= tmp[1] + 1:
      tmp[1] = chan[x][1]
      if x == len(chan)-1:
        targets.append(tmp)
    else:
      targets.append(tmp)
      tmp = chan[x]

for target in targets:
  times[target[0]] += 1
  times[target[1]+1] += -1

for j in range(1,pow(10,5)+2):
  times[j] += times[j-1]

print(max(times))
n, k = map(int, input().split())
lst = [int(x) for x in input().split()]
newLst = []

for i in range(n-1):
    for j in range(i+1, n):
        newLst.append(lst[i]*lst[j])

newLst = sorted(newLst)
print(newLst[k-1])

### FIXED CODE ###

a,b,c = input().split()

if a == b == c:
  print('No')
elif a != b and b != c and a != c:
  print('No')
elif a == b and a != c:
  print('Yes')
elif a == c and a != b:
  print('Yes')
elif b == c and a != b:
  print('Yes')
else:
  print('No')
x = int(input())
 
for val in range(x+1, x**100) :
	if x ==2 :
		print(x)
		break
	elif ((2** val) % val) == 2 :
		print (val)
		break
	else :
		continue

### FIXED CODE ###

S, T = (str(i) for i in input().split())

U = T + S
print(U)
s=input()
s.split()
if (int(s[0])+int(s[1]))>=int(s[3]):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s=input().split()
if (int(s[0])+int(s[1]))>=int(s[2]):
  print('Yes')
else:
  print('No')
N,K = map(int,input().split())
S = input()
print(S[:k-1]+S[k-1].lower()+S[k:])

### FIXED CODE ###

n, k = map(int,input().split())
s = input().split()

li = []

for i in range(n):
    if k-1 == i:
        li.append(s[0][i].lower())
    else:
        li.append(s[0][i])

print(''.join(li))
import numpy as np


def check(x, al, bl):
    rcost = np.inf
    for a in al:
        tmp_c = abs(a - x)
        for b in bl:
            t = abs(b - a)
            rcost = min(rcost, tmp_c + t, abs(b - x) + t)

    print(int(rcost))


n = [int(each) for each in input().split()]
a, b, q = n[0], n[1], n[2]

sl = np.zeros(a)
tl = np.zeros(b)
xl = np.zeros(q)

for i in range(a):
    sl[i] = int(input())
for i in range(b):
    tl[i] = int(input())
for i in range(q):
    xl[i] = int(input())

result = []
for x in xl:
    check(x, sl, tl)


### FIXED CODE ###

a = input()
a = a.replace('/', '')


if int(a) > 20190430:
    print('TBD')
else:
    print('Heisei')
n = input()
a = len(n)  # 桁数
if a % 2 == 0:  # 桁数が偶数
  ans = "90" * (a // 2)
  ans = int(ans[:-1])
else:
  ans = "90" * ((a - 1) // 2)
  ans = int(ans[:-1])
  ans += int(n) - 10 ** (a - 1) + 1
print(ans)

### FIXED CODE ###

n = input()
a = len(n)  # 桁数
if a % 2 == 0:  # 桁数が偶数
  ans = "90" * (a // 2)
  ans = int(ans[:-1])
else:
  if a == 1:
    ans = int(n)
  else:
    ans = "90" * ((a - 1) // 2)
    ans = int(ans[:-1])
    ans += int(n) - 10 ** (a - 1) + 1
print(ans)
n = int(input())
p = [float(x) for x in input().split()]

dp_list = [[0]*(n+1) for i in range(n)]

def dp(i, j):
  if dp_list[i][j] == 0:
    if i == 0:
      if j == 0:
        dp_list[i][j] = 1-p[i]
      if j == 1:
        dp_list[i][j] = p[i]
    elif j-i == 1:
      dp_list[i][j] = dp(i-1, j-1)*p[i]
    elif j == 0:
       dp_list[i][j] = dp(i-1, j)*(1-p[i])
    else:
      dp_list[i][j] = dp(i-1, j)*(1-p[i]) + dp(i-1, j-1)*p[i]
  return dp_list[i][j]

ans = 0
for i in range(n//2+1, n+1):
  ans += dp(n-1, i)
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(4000)

n = int(input())
p = [float(x) for x in input().split()]

dp = [[0]*(n+1) for i in range(n)]

dp[0][0] = 1-p[0]
dp[0][1] = p[0]

for i in range(n-1):
  for j in range(i+2):
    dp[i+1][j] += dp[i][j]*(1-p[i+1])
    dp[i+1][j+1] += dp[i][j]*p[i+1]

ans = 0
for i in range(n//2+1, n+1):
  ans += dp[n-1][i]
print(ans)
# -*- coding: utf-8 -*-

from sys import stdin
from functools import reduce

def load():
    n = int(stdin.readline())
    s = stdin.readline()
    q = int(stdin.readline())
    k = [int(x) for x in stdin.readline().split()]
    
    return (s, k)

def calc(s, ks):
    dmcmap = dmc(s, max(ks))
    for k in ks:
        print(sum(dmcmap[:k]))

def dmc(src, kmax):
    ret = [0 for _ in range(kmax)]

    for ind in range(len(src)):
        if src[ind] == 'D':
            for inm in range(ind+1, len(src)):
                if src[inm] == 'M':
                    for inc in range(inm+1, len(src)):
                        if src[inc] == 'C':
                            ret[inc-ind] += 1
    return ret

s, ks = load()
calc(s,ks)

### FIXED CODE ###

# -*- coding: utf-8 -*-

import numpy as np
from sys import stdin

def load():
    n = stdin.readline()
    data = [int(x) for x in stdin.readline().split()]
    return (n,data)

def calc(n, data):
    d = np.asarray(data)
    m = d.mean()
    diff = np.abs(d - m)
    return diff.argmin()

n, data = load()
print(calc(n, data))
A,B = map(int,input().split())
if A-2B>=0:
  print(A-2B)
else:
  print(0)

### FIXED CODE ###

A,B = map(int,input().split())
if A-2*B>=0:
  print(A-2*B)
else:
  print(0)
s = input()
a = 700
for i in s:
    if i == o:
        a += 100
    if i == x:
        continue
print(a)


### FIXED CODE ###

s = input()
a = 700
for i in s:
    if i == "o":
        a += 100
    if i == "x":
        continue
print(a)
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    ans = 1
 
    for i in a:
        ans *= i
      	if ans > int(1e18): return -1
    
    
    return ans
    

print(solve())


### FIXED CODE ###

from collections import Counter
def solve():
    n = int(input())
    a = list(map(int, input().split()))

    if 0 in a: return 0
    l = Counter(a)
    ans = 1
    for i,j in l.items():
        ans *= i**j
        if ans > int(1e18):
            return -1

    return ans
    

print(solve())
c1 = input()
c2 = input()

print("YES" if c1 = c2[::-1] else "NO")

### FIXED CODE ###

c1 = input()
c2 = input()

print("YES" if c1 == c2[::-1] else "NO")