Harryxun/stf_run huggingface dataset:
n,m = list(map(int,input().split()))
ac = 0
wa = 0
y = [0] * n
z = [0] * n

for _ in range(m):
  p,s = input().split()
  p = int(p)
  if not y[p] and s == 'WA':
    z[p] += 1
  elif not y[p] and s == 'AC':
    ac += 1
    y[p] += 1

for i in range(m):
  if y[i]:
    wa += z[i]

print(ac,wa)

### FIXED CODE ###

n,m = list(map(int,input().split()))
ac = 0
wa = 0
y = {i:0 for i in range(1,n+1)}
z = {i:0 for i in range(1,n+1)}

for _ in range(m):
  p,s = input().split()
  p = int(p)
  if not y[p] and s == 'WA':
    z[p] += 1
  elif not y[p] and s == 'AC':
    ac += 1
    y[p] += 1

for i in range(1,n+1):
  if y[i]:
    wa += z[i]

print(ac,wa)
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]
#dp[i]はi番目までの文字で'AC'がいくつあるか
dp = [0] * (N+1)
for i in range(1, N+1):
    if S[i-1] == 'A' and S[i] == 'C':
        dp[i] = dp[i-1] + 1
    else:
        dp[i] = dp[i-1]

for l, r in LR:
    print(dp[r-1] - dp[l-1])

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]
#dp[i]はi番目までの文字で'AC'がいくつあるか
dp = [0] * (N+1)
for i in range(1, N):
    if S[i-1] == 'A' and S[i] == 'C':
        dp[i] = dp[i-1] + 1
    else:
        dp[i] = dp[i-1]

for l, r in LR:
    print(dp[r-1] - dp[l-1])
import math

A, B = map(int, input().split())
 
priceA1 = A / 0.08
priceA2 = (A+1) / 0.08
priceB1 = B / 0.10
priceB2 = (B+1) / 0.10

if priceA1 < math.ceil(priceB1) <= math.floor(priceA2):
    print(math.floor(priceB1,0))
elif priceB1 <= math.ceil(priceA1) <= math.floor(priceB2):
    print(int(priceA1))
else:
    print(-1)

### FIXED CODE ###

import math

A, B = map(int, input().split())

priceA1 = math.ceil(A / 0.08)
priceA2 = (A+1) / 0.08
priceB1 = math.ceil(B / 0.10)
priceB2 = (B+1) / 0.10

if math.floor(priceA2) < priceA2:
    priceA2 = math.floor(priceA2)
else:
    priceA2 = math.floor(priceA2) - 1


if math.floor(priceB2) < priceB2:
    priceB2 = math.floor(priceB2)
else:
    priceB2 = math.floor(priceB2) - 1

if priceA1 <= priceB1 <= priceA2:
    print(math.ceil(priceB1))
elif math.ceil(priceB1) < math.ceil(priceA1) < priceB2:
    print(math.ceil(priceA1))
elif math.ceil(priceA1) == math.ceil(priceB1):
    print(math.ceil(priceA1))
else:
    print(-1)
def partition(a, p, r):
    x = a[r]
    i = p - 1
    for j in range(p, r):
        if a[j] <= x:
            i = i + 1
            a[i], a[j] = a[j], a[i]
    a[i+1], a[r] = a[r], a[i+1]
    print(*a)
    return i+1

n = int(input())
a = list(map(int, input().split()))
partition(a, 0, n)

### FIXED CODE ###

def partition(a, p, r):
    x = a[r]
    i = p - 1
    for j in range(p, r):
        if a[j] <= x:
            i = i + 1
            a[i], a[j] = a[j], a[i]
    a[i+1], a[r] = a[r], a[i+1]
    return i+1

n = int(input())
a = list(map(int, input().split()))
m = partition(a, 0, n-1)
a = list(map(str, a))
a[m] = "[%s]"%(a[m])
print(" ".join(a))
a,b,c = map(int, input().split())

L = [a,b,c]
L.sorted()

print(abs(L[2]-L[0]))

### FIXED CODE ###

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

print(abs(max(a,b,c) - min(a,b,c)))
N=int(input())
A = []
for i in range(N):
  Ai=int(input())
  A.append(Ai)
on = 1
for i in range(N):
  on = A[on]
  if on == 2:
    print(i)
    break
if i != 2:
  print(-1)

### FIXED CODE ###

N=int(input())
A = []
for i in range(N):
  Ai=int(input())
  A.append(Ai)
on = 1 #現実世界での番号
for i in range(N):
  on = A[on-1] #次のボタンを知るために、配列を参照する
  if on == 2:
    print(i+1)
    break
if on != 2:
  print(-1)
#N,K入力
N,K= map(int,input().split())
#街の番号入力
A = [int(i) for i in input().split()]

# 重複した要素があるかどうかを判定
def has_duplicates(seq):
    return len(seq) == len(set(seq))

#移動経路
warp = [1]
a = 1

#同じ街にたどり着くまでループ
while has_duplicates(warp):
    a = A [a - 1]
    warp.append(a)
    #同じ街にたどり着かなかった場合はこっち
    if len(warp) == K +1:
        print(warp[K])
        break

l = [i for i, x in enumerate(warp) if x == a]

# 何回ワープしたらループする街に戻ってくるか
width = l[1] - l[0]

#　ループのどこに行くか
d = (K - l[0]) % (l[1]-l[0])

#結果の出力
print(d + l[0])

### FIXED CODE ###

#N,K入力
N,K= map(int,input().split())
#街のテレポート先入力
A = [int(i)-1 for i in input().split()]
judge = [-1] * N
judge[0] = 0
#初期位置
a = 0
#移動回数
step = 1

while step != K +1:
    #移動する街を決める
    a = A[a]
    if judge[a] > -1:
        break
    #何回目の移動なのか加える
    judge[a] = step
    step = step + 1

if step == K +1:
    print(a+1)
    # プログラム終了
else:
    width = step - judge[a]
    s =(K - judge[a]) % width
    print(judge.index(judge[a]+s)+1)
def edit_distance(s, t):
 s=raw_input()
 t=raw_input()
 dp = {}
 for i in range(len(s) + 1):
  dp[i] = {0: i}
 for j in range(len(t) + 1):
  dp[0][j] = j
 for i in range(1, len(s) + 1):
  for j in range(1, len(t) + 1):
   d = 0 if s[i-1] == t[j-1] else 1
   dp[i][j] = min(dp[i-1][j] + 1,
   dp[i][j-1] + 1,
   dp[i-1][j-1] + d)
 return dp[len(s)][len(t)]
n = input()
for p in range(n):
    print edit_distance()

### FIXED CODE ###

def edit_distance():
 s = raw_input()
 t = raw_input()
 a = len(s)
 b = len(t)
 x = [0 for i in range(b+1)]
 for i in range(a):
   q = s[i]
   x2 = x+[]
   for j in range(b):
    if (q ==t[j]):
     x[j+1] =x2[j]+1
    elif (x[j+1]<x[j]):
     x[j+1] =x[j]
 return x[-1]

n = input()
for i2 in range(n):
 print edit_distance()
N,M= list(map(int,input().split()))
end = []
start = []
for i in range(M):
    A,B = list(map(int,input().split()))
    end.append(B)
    start.append(A)
end_min = min(end)
start_max = max(start)
if start_max => end_min:
    print(0)
else:
    print(end_min-start_end+1)

### FIXED CODE ###

N,M= list(map(int,input().split()))
end = []
start = []
for i in range(M):
    A,B = list(map(int,input().split()))
    end.append(B)
    start.append(A)
end_min = min(end)
start_max = max(start)
if start_max > end_min:
    print(0)
else:
    print(end_min-start_max+1)
n = int(input())
review = []
for i in range(n):
    s, p = input().split()
    review.append([s, int(p), i + 1])
rev_sorted = sorted(review, key = lambda x: (x[0], x[1]), reverse = (False, True))
for i in rev_sorted:
    print(i[2])

### FIXED CODE ###

n = int(input())
review = []
for i in range(n):
    s, p = input().split()
    review.append([s, int(p), i + 1])
rev_sorted1 = sorted(review, key = lambda x: x[1] , reverse = True)
rev_sorted2 = sorted(rev_sorted1, key = lambda x: x[0], reverse = False)
for i in rev_sorted2:
    print(i[2])
X, Y = map(int, input().split())
ans = 'No'
for a in range(X + 1):
  b = X - a
  if 2 * a + 4 * b == Y:
  ans = 'Yes'
print(ans)

### FIXED CODE ###

X, Y = map(int, input().split())
ans = 'No'
for a in range(X + 1):
  b = X - a
  if 2 * a + 4 * b == Y:
    ans = 'Yes'
print(ans)
W,H,x,y = map(int, input().split())
if(x == 0 or x == W or y == 0 or Y == H):
	print(0, 0)
	exit(0)

if (W*y < H*x):
	if(W == y * 2):
		print(W*y, 1)
	else:
		print(W*y, 0)
elif (W*y > H*x):
	if(H == x * 2):
		print(H*x, 1)
	else:
		print(H*x, 0)
else:
	print(W*y, 1)

### FIXED CODE ###

W,H,x,y = map(int, input().split())
if(2*x == W and 2*y == H):
	print(W*H/2, 1)
else:
	print(W*H/2, 0)
a = input()
if a = SUN:
  print("7")
elif a = MON:
  print("6")
elif a = TUE:
  print("5")
elif a = WED:
  print("4")
elif a = THU:
  print("3")
elif a = FRI:
  print("2")
else:
  print("1")

### FIXED CODE ###

a = input()
if a == "SUN":
  print("7")
elif a == "MON":
  print("6")
elif a == "TUE":
  print("5")
elif a == "WED":
  print("4")
elif a == "THU":
  print("3")
elif a == "FRI":
  print("2")
else:
  print("1")
import fractions

n = int(input())
a = list(map(int, input().split()))
b = a[::-1]

left = [0, a[0]]
right = [0, b[0]]
l = a[0]
r = b[0]
for i in range(1, n):
    l = fractions.gcd(l, a[i])
    r = fractions.gcd(r, b[i])
    left.append(l)
    right.append(r)

gcd_max = 0
for i in range(n+1):
    gcd_tmp = gcd(left[i], right[n-i-1])
    if gcd_tmp > gcd_max:
        gcd_max = gcd_tmp

print(gcd_max)


### FIXED CODE ###

import fractions

n = int(input())
a = list(map(int, input().split()))
b = a[::-1]

left = [0, a[0]]
right = [0, b[0]]
l = a[0]
r = b[0]
for i in range(1, n):
    l = fractions.gcd(l, a[i])
    r = fractions.gcd(r, b[i])
    left.append(l)
    right.append(r)

gcd_max = 0
for i in range(n+1):
    gcd_tmp = fractions.gcd(left[i], right[n-i-1])
    if gcd_tmp > gcd_max:
        gcd_max = gcd_tmp

print(gcd_max)
import math as mt
import numpy as np

string = input()
use = string.split('x')
word =''
for x in use:
    word += x
i = 0
n = len(word) - 1
while i < n:
    if word[i] != word[n]:
        print(-1)
        exit()
    i += 1
    n -= 1

if len(word) % 2 == 0:
    fh = []
    i = 0
    mid = int(len(word)/2)
    count = 0
    n = len(string) - 1
    for x in string:
        if x == word[i]:
            i += 1
            fh.append(count)
            count = 0
            if i == mid:
                break
        else:
            count += 1
    i = len(word) - 1
    lh = []
    count = 0
    while i != mid - 1:
        if string[n] == word[i]:
            i -= 1
            lh.append(count)
            count = 0
        else:
            count += 1
        n -= 1
    print(np.sum(np.abs(np.array(fh)-np.array(lh))))

else:
    fh = []
    i = 0
    mid = int((len(word) - 1)/2)
    count = 0
    n = len(string) - 1
    for x in string:
        if x == word[i]:
            i += 1
            fh.append(count)
            count = 0
            if i > mid:
                break
        else:
            count += 1
    i = len(word) - 1
    lh = []
    count = 0
    while i != mid - 1:
        if string[n] == word[i]:
            i -= 1
            lh.append(count)
            count = 0
        else:
            count += 1
        n -= 1
    if len(fh) != len(lh):
        for x in 1000000000:
            y = 1+1
    print(np.sum(np.abs(np.array(fh)-np.array(lh))))


### FIXED CODE ###

import math as mt
import numpy as np

string = input()
collect = []
word = ''
count = 0
n = len(string)
i = 0
for x in string:
    if x != 'x':
        word += x
        collect.append(count)
        if i == n-1:
            collect.append(0)
        count = 0
    elif i == n-1:
        count += 1
        collect.append(count)
    else:
        count += 1
    i += 1

nl = len(word) - 1
i = 0
while i < nl:
    if word[i] != word[nl]:
        print(-1)
        exit()
    i += 1
    nl -=  1
nl = len(collect) - 1
i = 0
out = 0
while i < nl:
    out += np.abs(collect[i] - collect[nl])
    i += 1
    nl -= 1
print(out)
t = s.find("C")
if s[t:].find("F") > 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = input()
t = s.find("C")
if s[t:].find("F") > 0:
    print("Yes")
else:
    print("No")
A, B = map(int, input().split())

t = A + B
x = A * B
m = A - B

a_flg = False
b_flg = False

if A >= 0:
  a_flg = True
if B >= 0:
  b_flg = True
  
if A == 0:
  if B < 0:
    print(m)
if B == 0:
  if A < 0:
    print(t)
if a_flg and b_flg:
  print(x)
elif a_flg == True and b_flg == False:
  print(m)
elif a_flg == False and b_flg == True:
  print(t)
elif a_flg == False and b-flg == False:
  print(x)

### FIXED CODE ###

A, B = map(int, input().split())
 
t = A + B
x = A * B
m = A - B
 
map = {'t': t, 'x': x, 'm': m}

sorted_map = sorted(map.items(), key=lambda x:x[1])

ans = sorted_map[-1]
print(ans[-1])
#タプルを深くしたまま進め、速度アップ？
#初期入力
import sys
input = sys.stdin.readline
S = input().split()
S=S[0]
Q = int(input())
FQ_dic =tuple()
rev =0
for i in range(Q):
    FQ_dic =tuple(input().split())

    if      FQ_dic[0] =="1": #逆転する
                rev +=1
    else:                   #逆転なし  
        if      FQ_dic[1]=="1":     #後ろにつける
            if rev %2 ==0:
                    S = FQ_dic[2] , S
            else:
                    S = S ,FQ_dic[2] 
        else: #                      #前につける
            if rev %2 ==0:
                    S = S , FQ_dic[2]
            else:        
                    S = FQ_dic[2] , S

#深いパックをアンパック
def flatten_list_tuple_range(l):
    for el in l:
        if isinstance(el, (list, tuple, range)):
            yield from flatten_list_tuple_range(el)
        else:
            yield el
S =flatten_list_tuple_range(S)
S=[i for i in S]

#逆転の回数で場合分け
if rev %2 ==0:
    print(*S,sep="")
else:
    print(*S[::-1],sep="")

### FIXED CODE ###

#前・左につける変数、後ろ・右につける変数を用意して最後に足す
#前・左は最後にひっくり返す（abc ⇒cba)

#初期入力
import sys
input = sys.stdin.readline
S = input()
S=S.strip("\n")
Q = int(input())
FQ_dic={}
for i in range(Q):
    FQ_dic[i] =input().split()

rev =0
front =""
back =""

for i in range(Q):
   # print(S) 

    if FQ_dic[i][0] =="1": #逆転する
                rev +=1
    else:                   #逆転なし  
        if FQ_dic[i][1]=="1":     #前=左につける 
            if rev %2 ==0:
                front += FQ_dic[i][2]
            else:
                back  += FQ_dic[i][2]  
        else: #                      #後ろ=右につける
            if rev %2 ==0:
                back  += FQ_dic[i][2]  
            else:        
                front += FQ_dic[i][2]
front =front[::-1]
S =front + S + back

if rev %2 ==0:
    print(*S,sep="")
else:
    print(*S[::-1],sep="")
N = input()
if int(x[2])=7:
    print("Yes")
elif int(x[1])=7:
    print("Yes")
elif int(x[0])=7:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N = input()
if int(N[2])==7:
    print("Yes")
elif int(N[1])==7:
    print("Yes")
elif int(N[0])==7:
    print("Yes")
else:
    print("No")
n, m = map(int,input().split())
q = [0 for i in range(n)]
alist = []
ac = 0
pe = 0
be = be
for i in range(m):
    a,b=input().split()
    alist.append((int(a), b))
for i in range(m):
    if q[alist[i][0]-1] == 0:
        if alist[i][1] == 'AC':
            ac += 1
            be = be + pe
            q[alist[i][0]-1] = 1
        else:
            pe += 1
    else:
        continue
print(ac,be)

### FIXED CODE ###

n, m = map(int,input().split())
q = [0 for i in range(n)]
alist = []
ac = 0
pe = [0 for i in range(n)]
be = 0
for i in range(m):
    a,b=input().split()
    alist.append((int(a), b))
for i in range(m):
    if q[alist[i][0]-1] == 0:
        if alist[i][1] == 'AC':
            ac += 1
            be = be + pe[alist[i][0]-1]
            q[alist[i][0]-1] = 1
        else:
            pe[alist[i][0]-1] +=  1
    else:
        continue
print(ac,be)
N, K = map(int, input().split)
h = list(map(int, input().split()))
for hantei in h:
    if K > hantei:
        N -= 1
    else:
        pass
print(N)
        

### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
for hantei in h:
    if K > hantei:
        N -= 1
    else:
        pass
print(N)
import copy
import math

n=int(input())
a=list(map(int,input().split()))
ans=0
r=[]
if n==2:
    print(max(a[0],a[1]))
else:
    
    for i in range(n):
      l=copy.copy(a)
      del l[i]
      r.clear()
      for j in range(n-2):
        r.append(math.gcd(l[j],l[j+1]))
      g=r[-1]
      if ans<g:
        ans=g
    print(ans)


### FIXED CODE ###

import fractions
n=int(input())
a=list(map(int,input().split()))
l=[a[0]]
r=[a[-1]]
for i in range(n-1):
  l.append(fractions.gcd(l[i],a[i+1])) #l[i] は最初i個
for i in range(n-1):
  r.append(fractions.gcd(r[i],a[-2-i])) #r[i]は右i r[n-1]=全部 l[0]and r[n-3]
m=[l[n-2],r[n-2]]
for i in range(n-2):
  m.append(fractions.gcd(l[i],r[n-i-3]))
print(max(m))
n = int(input())
A = list(map(int, input().split()))

ANS = []
for i in range(len(A)):
  for j in range(i,len(A)+1):
    ANS.append(abs(A[i] - A[j]))
    
print(max(ANS))

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))

ANS = []
for i in range(len(A)):
  for j in range(i,len(A)):
    ANS.append(abs(A[i] - A[j]))
    
print(max(ANS))
import sys

line = sys.stdin.readline():
     x, y = line.split(" ")

x = int(x)
y = int(y)

divide = 1

if x > y:
    x, y = y, x

for i in range(2, x + 1):
    if x % i == 0 and y % i == 0:
        divide *= i
        x = x / i
        y = y / i
        i -= 1

print divide

### FIXED CODE ###

import sys

def div(x, y):
    if x % y == 0:
        print y
    else:
        div(y, x%y)


line = sys.stdin.readline()
x, y = line.split(" ")

x = int(x)
y = int(y)

if x < y:
    x, y = y, x

if x == y:
    print x

else:
    div(x, y)
a,b = int(input().split())
print((b-a)*(b-a-1)/2 - a)

### FIXED CODE ###

a,b = map(int, input().split())
print((b-a)*(b-a-1)//2 - a)
a = int(input())
b = int(input())
strip = b // a
emp = b % a
ans = strip + (strip // emp)
print(ans)

### FIXED CODE ###

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

ans = (a + b - 3) // (a - 1)
print(ans)
N=input()
A=list(map(int,input().split()))
count=0
while all([a%2==0 for a in A]):
    A = [a/2 for a in A]
    count+=1
print(count)

### FIXED CODE ###

print(input().count('1'))
def main():
    A, B = [int(x) for x in input().split()]
    count = 1
    B -= A
    while B > 0:
        B -= (A - 1)
        count += 1
    print (count)

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    A, B = [int(x) for x in input().split()]
    if B == 1:
        print(0)
        return
    count = 1
    B -= A
    while B > 0:
        B -= (A - 1)
        count += 1
    print (count)

if __name__ == "__main__":
    main()
N = input()
L = []
for i in range(0,N):
	L.append(input())
    
def mostFrequent(L):
  return max(set(A), key = A.count)

print(mostFrequent(L))

### FIXED CODE ###

from collections import defaultdict
from collections import OrderedDict
N = int(input())
ans = dict()
for _ in range(N):
    k = str(input())
    if k in ans:
        ans[k]+=1
    else:
        ans.update({k:1})
groupedByValue = defaultdict(list)
for key, value in sorted(ans.items()):
    groupedByValue[value].append(key)
l = groupedByValue[max(groupedByValue)]
for i in l:
    print(i)
#D
from sys import stdin
def main():
    readline=stdin.readline
    n = int(readline())
    a = list(map(int,readline().split()))
    count=0
    for i in a:
        num_div=0
        for j in a:
            if i%j==0:
                num_div+=1
        if num_div==1:
            count+=1
    print(count)
main()

### FIXED CODE ###

#A
x=list(map(int,input().split()))
for i in range(len(x)):
    if x[i] ==0:
        print(i+1)
N = int(input())
arr = [int(input()) for i in range(N)]

swap_cnt = 0
i = 0
while True:
    swap_flg = False
    for j in range(N - 1, i + 1, -1):
        if (arr[j] < arr[j - 1]):
            arr[j], arr[j - 1] = arr[j - 1], arr[j]
            swap_cnt += 1
            swap_flg = True
    if (!swap_flg):
        break



### FIXED CODE ###

N = int(input())
arr = [int(n) for n in input().split()]

swap_cnt = 0
swap_flg = True
i = 0
while swap_flg:
    swap_flg = False
    for j in range(N - 1, i, -1):
        if (arr[j] < arr[j - 1]):
            arr[j], arr[j - 1] = arr[j - 1], arr[j]
            swap_cnt += 1
            swap_flg = True
    i += 1

print(' '.join(map(str, arr)))
print(swap_cnt)
from math import sqrt, ceil
from collections import Counter
from scipy.special import comb

m = 10**9+7
def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    for i in range(2, ceil(sqrt(n))+1):
        if not is_prime(i): continue
        q,r = divmod(n, i)
        if r == 0:
            n = q
            factor.append(i)
            q,r = divmod(n, i)
            while r == 0:
                n = q
                factor.append(i)
                q,r = divmod(n, i)
    return factor

N, M = map(int, input().split())
p = prime_factorization(M)
c = Counter(p)
print(c)
ans = 1
for v in c.values():
    ans *= comb(v + N - 1, v, exact=True) % m
print(ans)


### FIXED CODE ###

from math import sqrt, ceil, factorial
from collections import Counter

m = 10**9+7
def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

def comb(n, r):
    a = 1
    for i in range(n-r+1, n+1):
        a *= i
    return a//factorial(r)

N, M = map(int, input().split())
p = prime_factorization(M)
c = Counter(p)
ans = 1
for v in c.values():
    ans *= (comb(v + N - 1, v) % m)
print(ans%m)
from math import log2

n,k = (int(num) for num in input().split())
p = 1/n
ans = 0.0

if n >= k:
    ans += p * (n-k+1)
    for i in range(1,k):
        ans += p*(1/2)**(int(log2(k/i))+1)
        
else:
    for i in range(1,n+1):
        ans += p*(1/2)**(int(log2(k/i))+1)
        
print(ans)

### FIXED CODE ###

from math import log

n,k = (int(num) for num in input().split())
p = 1/n
ans = 0.0

for i in range(1,n+1):
    j = i
    t = p
    while j < k:
        t *= 1/2
        j *= 2
    ans += t
    
print(ans)
n,m,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))

from collections import deque
a = deque([x for x in a])
b = deque([x for x in b])
a.append(10**9+1)
b.append(10**9+1)
ans = 0
def cnt(a,b,time):
  global ans
  #print(ans, time,a,b)
  if (time <= k) & ( (len(a) > 1) | (len(b) > 1)):
    if a[0] < b[0]:
      #time += a[0]
      a.popleft()
    else:
      #time += b[0]
      b.popleft()
    if time <= k:
      ans += 1
      cnt(a,b,time)

cnt(a,b,0)
print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0] * (n + 1)
sb = [0] * (m + 1)
for i in range(n):
  sa[i + 1] = sa[i] + a[i]
for i in range(m):
  sb[i + 1] = sb[i] + b[i]
r = m
ans = 0
for i in range(n + 1):
  if sa[i] > k:
    break
  while sa[i] + sb[r] > k:
    r -= 1
  ans = max(ans, i + r)
print(ans)