Harryxun/stf_run huggingface dataset:
N = int(input())
S = input()
Q = int(input())
set_dic = {}

for i, s in enumerate(S):
    if s not in set_dic.keys():
        set_dic[s] = {i+1}
    else:
        set_dic[s].add(i+1)

anslist = []

for _ in range(Q):
    query = input()
    if query[0] == "1":
        """
        i = int(query[2])
        c = query[4]
        for l in set_dic.values():
            l.discard(i)
        if c not in set_dic.keys():
            set_dic[c] = {i}
        else:
            set_dic[c].add(i)
            """
    else:
        l = int(query[2])
        r = int(query[4])
        ansset = set()
        for i in range(l, r + 1):
            for key, eachset in set_dic.items():
                if i in eachset:
                    ansset.add(key)
                    break
        ans = len(ansset)
        anslist.append(ans)

for i in anslist:
    print(i)

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline

def solve():
    N = int(input())
    S = list(input())
    Q = int(input())
    set_dic = {}

    for i, s in enumerate(S):
        if s not in set_dic:
            set_dic[s] = [i+1]
        else:
            bisect.insort_left(set_dic[s], i+1)

    anslist = []

    for _ in range(Q):
        query1, query2, query3 = input().split()
        if query1 == "1":
            i = int(query2)
            c = query3
            cap = S[i-1]
            if cap == c:
                continue
            set_dic[cap].remove(i)
            if c not in set_dic:
                set_dic[c] = [i]
            else:
                bisect.insort_left(set_dic[c], i)
            S[i-1] = c
        else:
            l = int(query2)
            r = int(query3)
            ansset = set()
            ans = 0
            for eachlist in set_dic.values():
                li = bisect.bisect_left(eachlist, l)
                ri = bisect.bisect_right(eachlist, r)
                if li != ri:
                    ans += 1
            anslist.append(ans)

    for i in anslist:
        print(i)

if __name__ == '__main__':
    solve()
X = int(input())

import numpy as np


def judge(X):
	maxrange = max(int(X/100)+1, 1000000)
	for a in range(maxrange):
		for b in range(maxrange):
			for c in range(maxrange):
				S = 100 * a + 101 * b + 102 * c
				d = np.arange(0, maxrange)
				e = np.arange(0, maxrange)
				f = np.arange(0, maxrange)
				DEF = np.meshgrid(d, e, f)
				Splus = 103 * DEF[0] + 104 * DEF[1] * 105 * DEF[2]
				if np.any(Splus == X - S) == True:
					return 1
				else:
					continue
	return 0

print(judge(X))

### FIXED CODE ###

X = int(input())

import numpy as np

J = np.zeros(X+1, dtype="bool")
# J[i] は、 i円の買い物ができるときにTrue, できないとFalse
J[0] = True
J[1:100] = False
J[100:106] = True
for i in range(106, X+1):
    if J[i - 100] or J[i - 101] or J[i - 102] or J[i - 103] or J[i - 104] or J[i - 105]:
        J[i] = True
    else:
        J[i] = False

if J[X] == True:
    print("1")
else:
    print("0")
A,B,C = int(input())
if A+B+C <= 21:
  print("win")
else:
  print("bust")

### FIXED CODE ###

A,B,C = map(int,input().split())
if A+B+C <= 21:
  print("win")
else:
  print("bust")
def parse(file):
    n = int(file.readline())
    nums = list(map(int, file.readline().split()))
    return n, nums


def main(n, nums):
    minimum_abs = abs(nums[0])
    negatives = 0
    ans = 0

    for num in nums:
        if num < 0:
            a = - num
            negatives += 1
        else:
            a = num

        if a < minimum_abs:
            minimum_abs = a
        ans += a

    if negatives % 2 == 1:
        ans -= minimum_abs * 2

    return ans


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

### FIXED CODE ###


import sys


def parse(file):
    n = int(file.readline().strip())
    nums = map(int, file.readline().split())
    return n, nums


def main(n, nums):
    minimum_abs = 1e20
    negatives = 0
    ans = 0

    for num in nums:
        if num < 0:
            a = - num
            negatives += 1
        else:
            a = num

        if a < minimum_abs:
            minimum_abs = a
        ans += a

    if negatives % 2 == 1:
        ans -= (minimum_abs * 2)

    return ans


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))
from collections import deque

class RollingHash():
    def __init__(self, s, base1=1007, base2=2009, mod1=10**9+7, mod2=10**9+9):
        self.mod1 = mod1
        self.mod2 = mod2
        self.s = s
        n = len(s)
        self.hash1 = [0]*(n+1)
        self.pow1 = [1]*(n+1)
        self.hash2 = [0]*(n+1)
        self.pow2 = [1]*(n+1)
        for i in range(n):
            self.hash1[i+1] = (self.hash1[i]*base1 + ord(s[i])) % self.mod1
            self.pow1[i+1] = (self.pow1[i]*base1) % self.mod1
            self.hash2[i+1] = (self.hash2[i]*base2 + ord(s[i])) % self.mod2
            self.pow2[i+1] = (self.pow2[i]*base2) % self.mod2

    def get(self, l, r):
        h1 = (self.hash1[r] - self.hash1[l] * self.pow1[r-l]) % self.mod
        h2 = (self.hash2[r] - self.hash2[l] * self.pow2[r-l]) % self.mod2
        return (h1,h2)


n = int(input())
s = input()
rh = RollingHash(s, base1=1007, base2=1007, mod1=10**9+7, mod2=10**9+7)

for len_ in range(n//2,0,-1):
    ql = [(-1,-1)]*(len_-1)
    wait_q = deque(ql)
    hset = set()
    # print(len_)
    for i in range(n-len_+1):
        # print(s[i:i+len_])
        hs = rh.get(i,i+len_)
        if hs in hset:
            print(len_)
            exit()
        else:
            wait_q.append(hs)
            hset.add(wait_q.popleft())
        # print(wait_q)
        # print(hset)

else:
    print(0)

### FIXED CODE ###

from collections import deque

class RollingHash():
    def __init__(self, s, base1=19683,base2=6561,mod1=2^61-1,mod2=2^61-1):
        self.mod1 = mod1
        self.mod2 = mod2
        self.s = s
        n = len(s)
        self.hash1 = [0]*(n+1)
        self.pow1 = [1]*(n+1)
        self.hash2 = [0]*(n+1)
        self.pow2 = [1]*(n+1)
        for i in range(n):
            self.hash1[i+1] = (self.hash1[i]*base1 + ord(s[i])) % self.mod1
            self.pow1[i+1] = (self.pow1[i]*base1) % self.mod1
            self.hash2[i+1] = (self.hash2[i]*base2 + ord(s[i])) % self.mod2
            self.pow2[i+1] = (self.pow2[i]*base2) % self.mod2

    def get(self, l, r):
        h1 = (self.hash1[r] - self.hash1[l] * self.pow1[r-l]) % self.mod1
        h2 = (self.hash2[r] - self.hash2[l] * self.pow2[r-l]) % self.mod2
        return (h1,h2)


n = int(input())
s = input()
rh = RollingHash(s,base1=1007,base2=2009,mod1=10**9+7,mod2=10**9+9)

for len_ in range(n//2,0,-1):
    ql = [(-1,-1)]*(len_-1)
    wait_q = deque(ql)
    hset = set()
    # print(len_)
    for i in range(n-len_+1):
        # print(s[i:i+len_])
        hs = rh.get(i,i+len_)
        if hs in hset:
            print(len_)
            exit()
        else:
            wait_q.append(hs)
            hset.add(wait_q.popleft())
        # print(wait_q)
        # print(hset)

else:
    print(0)
N,T = map(int,input().split())
import copy
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
C = zip(B,A)
C = sorted(C)
B,A = zip(*C)
A = list(A)
B = list(B)
dp = [[0 for i in range(T)]for j in range(N+1)]
dp1 = [[[]for i in range(T)]for j in range(N+1)]
for i in range(1,N+1):
    a,b = A[i-1],B[i-1]
    for t in range(1,T):
        p = dp[i-1][t]
        if t >= a:
            q = dp[i-1][t-a] + b
            if p > q:
                dp[i][t] = p
                dp1[i][t] = copy.deepcopy(dp1[i-1][t])
            elif p < q:
                dp[i][t] = q
                dp1[i][t] = copy.deepcopy(dp1[i-1][t-a])
                dp1[i][t].append(b)
            else:
                dp[i][t] = p
                mp = max(dp1[i-1][t])
                mq = max(dp1[i-1][t-a])
                mq = max(mq,b)
                if mp >= mq:
                    dp1[i][t] = copy.deepcopy(dp1[i-1][t-a])
                    dp1[i][t].append(b)
                else:
                    dp1[i][t] = copy.deepcopy(dp1[i-1][t])
        else:
            dp[i][t] = p
            dp1[i][t] = copy.deepcopy(dp1[i-1][t])
M = 0
for i in range(N):
    b = B[N-1-i]
    if b not in dp1[N][T-1]:
        M = b
        break
print(dp[N][T-1]+M)

### FIXED CODE ###

N,T = map(int,input().split())
C = []
for i in range(N):
    a,b = map(int,input().split())
    C.append([a,b])
C.sort()
dp = [[0 for i in range(T)]for j in range(N+1)]
for i in range(1,N+1):
    a,b = C[i-1][0],C[i-1][1]
    for t in range(1,T):
        p = dp[i-1][t]
        if t >= a:
            q = dp[i-1][t-a] + b
            dp[i][t] = max(p,q)
        else:
            dp[i][t] = p
M = 0
for i in range(1,N+1):
    M = max(M,C[i-1][1]+dp[i-1][T-1])
print(M)
s = input()
t = input()

c=1
j=0
k=0

#t
for i in range(0,len(t)):
  while True:
    if t[i:i+1]==s[j:j+1]:
      J=J+1
      k=0
      break
    else:
      if j==len(s):
        j=0
      else:
        j=j+1
        k=k+1
        c=c+1
        if k+1==len(s):
          print("-1")
          exit()
        else:
          j=j+1
          k=k+1
          c=c+1
print(c)


### FIXED CODE ###

s = input()
t = input()

x = len(s)
y = len(t)

a = 0
b = x
c = 0
a0 = 0


for i in range(0,y):
  while True:
    #先頭からの位置
    a=s.find(t[i:i+1],a0)+1
    if a <= 0:
      a=s.find(t[i:i+1])+1
    if a <= 0:
      print("-1")
      exit()
    
    if a<=a0:
      c=c+a+b
    else:
      c=c+a-a0
    b=x-a
    a0=a
    break
    
print(c)
n = int(input())
x = input()
val = int(x, 2)

cnt1 = x.count("1")
p_cnt = cnt1 + 1
m_cnt = cnt1 - 1
p_amari = val % (cnt1 + 1)
m_amari = val % (cnt1 - 1)


#p_mod = [0] * (n + 1)
#for i in range(n + 1):
#    p_mod[i] = pow(2, i, p_cnt)

#m_mod = [0] * (n + 1)
#for i in range(n + 1):
#    m_mod[i] = pow(2, i, m_cnt)


for i in range(n):
    ans = 0
    if x[i] == "0":
        # pになる
        amari = p_amari + pow(2, n - i - 1, p_cnt)
        amari %= p_cnt
        ans += 1
    elif x[i] == "1":
        # mになる
        amari = m_amari - pow(2, n - i - 1, m_cnt)
        amari %= m_cnt
        ans += 1
    while amari != 0:
        amari %= bin(amari).count("1")
        ans += 1
    print(ans)

### FIXED CODE ###

n = int(input())
x = input()
val = int(x, 2)

cnt1 = x.count("1")
p_cnt = cnt1 + 1
m_cnt = cnt1 - 1
p_amari = val % (cnt1 + 1)
if cnt1 - 1 != 0:
    m_amari = val % (cnt1 - 1)
else:
    m_amari = 0


for i in range(n):
    ans = 0
    if x[i] == "0":
        # pになる
        amari = p_amari + pow(2, n - i - 1, p_cnt)
        amari %= p_cnt
        ans += 1
    elif x[i] == "1":
        # mになる
        if cnt1 - 1 == 0:
            print(0)
            continue
        amari = m_amari - pow(2, n - i - 1, m_cnt)
        amari %= m_cnt
        ans += 1
    while amari != 0:
        amari %= bin(amari).count("1")
        ans += 1
    print(ans)
N, M = map(int, input().split())
E = [[] for i in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    E[x-1].append(y-1)
dp = [-1] * N
def solve(n):
    if dp[n] != -1:
        return dp[n]
    res = 0
    for nn in E[n]:
        res = max(res, solve(nn)+1)
    dp[n] = res
    return dp[n]
ans = 0
for i in range(N):
    ans = max(ans, solve(i))
print(ans)

### FIXED CODE ###

from collections import deque
from collections import defaultdict
N, M = map(int, input().split())
d = [0]*N
G = defaultdict(list)
for i in range(M):
    s, t = map(int, input().split())
    d[t-1] += 1
    G[s-1].append(t-1)
q = deque([])
for i in range(N):
    if d[i] == 0:
        q.append(i)
ans = []
while q:
    s = q.popleft()
    ans.append(s)
    for t in G[s]:
        d[t] -= 1
        if d[t] == 0:
            q.append(t)
dp = [0] * (N+1)
num = 0
for i in range(0,N):
    for n in G[ans[i]]:
        dp[n] = max(dp[n], dp[ans[i]]+1)
print(dp[ans[-1]])
import math
n,p,q=[list(map(int, i.split())) for i in open(0)]
def ps(l):
    s=0
    t=list(range(1,n+1))
    for i in range(n):
        s+=t.index(l[i])*math.factorial(n-i-1)
        t.remove(l[i])
print(abs(ps(p)-ps(q)))

### FIXED CODE ###

import itertools
(n,),p,q=[tuple(map(int, i.split())) for i in open(0)]
j=list(itertools.permutations(range(1, -~n)))
print(abs(j.index(p) - j.index(q)))
li= list(map(int, input().split())
while True:
	li.sort()
	if li==[0,0]
		break
	print(*li)


### FIXED CODE ###

while True:
	x,y=sorted(map(int,input().split()))
	if x==0 and y==0:
		break
	print(x, y)
import math
A,B,K=map(int,input().split())
d=[]
if A==1 or B==1:
    d.append(1)
else:
    for i in range(2,math.gcd(A,B)+1):
        if A%i==0 and B%i==0:
            d.append(i)
print(d[len(d)-K])

### FIXED CODE ###

import math
A,B,K=map(int,input().split())
d=[]
for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        d.append(i)
print(d[len(d)-K])
import sys


def alg_combination_mod(n, r, mod):
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    x, y = list(map(int, readline().split()))
    if x / y == 2 or y / x == 2:
        print(1)
    else:
        cnt = min(x // 3, y // 3)
        x -= cnt * 3
        y -= cnt * 3
        if x == 0 and y == 0:
            xcnt = cnt
            ycnt = cnt
        elif x % 2 == 0 and y % 2 == 0:
            if x != 0 and y / x == 2:
                    xcnt = cnt + x
                    ycnt = cnt
            elif y != 0 and x / y == 2:
                    xcnt = cnt
                    ycnt = cnt + y
        else:
            print(0)
            exit()
        print(alg_combination_mod(xcnt + ycnt, xcnt, mod))


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys


def alg_combination_mod(n, r, mod):
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    x, y = list(map(int, readline().split()))
    if (x + y) % 3 == 0:
        t = (x + y) // 3
        for i in range(0, t + 1):
            tx = i * 2 + (t - i)
            ty = i + (t - i) * 2
            if tx == x and ty == y:
                print(alg_combination_mod(t, i, mod))
                exit()
        print(0)
    else:
        print(0)


if __name__ == '__main__':
    solve()
A=input()
B=input()
C=input()
D=input()
fee=0
if A<B:
    fee=fee+A
else:
    fee=fee+B
if C<D:
    fee=fee+C
else:
    fee=fee+D

print(fee)


### FIXED CODE ###

A=int(input())
B=int(input())
C=int(input())
D=int(input())
fee=0
if A<B:
    fee=fee+A
else:
    fee=fee+B
if C<D:
    fee=fee+C
else:
    fee=fee+D

print(fee)
# -*- coding: utf-8 -*-
X,Y= "int(input())","int(input())"
print("{}".format(X + 2 //Y))

### FIXED CODE ###

#!usr/bin/env python
# -*- coding: utf-8 -*-
X , Y= map(int,input().split())
print("{}".format(X + Y // 2))
A,B=int(input())
print(max(A+B,A-B,A*B))

### FIXED CODE ###

A,B=map(int,input().split())
print(max(A+B,A-B,A*B))
list=["ABC","ARC]
a=input()
if a==list[0]:
      print(list[1])
else:
      print(list[0])

### FIXED CODE ###

list=["ABC","ARC"]
a=input()
if a==list[0]:
      print(list[1])
else:
      print(list[0])
import sys
num = sys.stdin.readline()
print(num**3)

### FIXED CODE ###

num = int(input())
print(num**3)
x, y  = map(int, input().split())

def prime_factorize(a):
  ls = [1]
  if a == 1:
    return ls
  else:
  	while(i <= a):
      if(a % i == 0):
        ls.append(i)
      i += 1
    return ls
  
prime_x = prime_factorize(x)
prime_y = prime_factorize(y)

num_x = len(prime_x)
num_y = len(prime_y)

num = min(num_x, num_y)
co = list(set(num_x) & set(num_y))
ans = 0
for i in range(len(co)):
  if co == [1]:
    ans = 1
    break
  else:
    if len(prime_factorize(co[i])) == 1 or len(prime_factorize(co[i])) == 2:
      ans += 1
print(ans)



### FIXED CODE ###

x, y  = map(int, input().split())
 
def prime_factorize(n):
    a = [1]
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  
prime_x = prime_factorize(x)
prime_y = prime_factorize(y)
 
num_x = len(prime_x)
num_y = len(prime_y)
 
num = min(num_x, num_y)
co = list(set(prime_x) & set(prime_y))

ans = 0
for i in range(len(co)):
  if co == [1]:
    ans = 1
    break
  else:
    if len(prime_factorize(co[i])) == 1 or len(prime_factorize(co[i])) == 2:
      ans += 1
print(ans)
# -*- coding: utf-8 -*-
# 整数の入力
import math
 
a = int(input())
 
gusu = a // 2
ngusu = math.floor(gusu)
 
if gusu > ngusu:
  kisu = ngusu + 1
else:
  kisu = ngusu
kaku = kisu // a 
print(raund(kaku,6)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
import math
 
a = float(input())
 
gusu = a / 2
ngusu = math.floor(gusu)
 
if gusu > ngusu:
  kisu = ngusu + 1
else:
  kisu = ngusu
kaku = kisu / a 

print(kaku)
N, M = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))
X.sort1(key=lambda x: x[0])
i = 0
num = 0
ans = 0
while i <= N - 1:
    num += X[i][1]
    ans += X[i][0] * X[i][1]
    if num > M:
        ans -= X[i][0] * (num - M)
        break
    i += 1
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))
X.sort(key=lambda x: x[0])
i = 0
num = 0
ans = 0
while i <= N - 1:
    num += X[i][1]
    ans += X[i][0] * X[i][1]
    if num > M:
        ans -= X[i][0] * (num - M)
        break
    i += 1
print(ans)
n, m = map(int, input().split())
a = []
for i in range(m):
    a.append(int(input()))

flag = 0
for i in range(m-1):
    if a[i+1] - a[i] == 0:
        flag = 1
        print(0)
        break

if flag == 0:
    b = [1]
    if a[0] == 1:
        b.append(0)
        a.pop(0)
    else:
        b.append(1)
    for i in range(2, n+1):
        if len(a) != 0 and a[0] == i:
            b.append(0)
            a.pop(0)
        else:
            b.append((b[i-1]+b[i-2])%1000000007)

    print(b[-1])

### FIXED CODE ###

n, m = map(int, input().split())
a = []
for i in range(m):
    a.append(int(input()))

flag = 0
for i in range(m-1):
    if a[i+1] - a[i] == 0:
        flag = 1
        print(0)
        break

if flag == 0:
    b = [1]
    if len(a) != 0 and a[0] == 1:
        b.append(0)
        a.pop(0)
    else:
        b.append(1)
    for i in range(2, n+1):
        if len(a) != 0 and a[0] == i:
            b.append(0)
            a.pop(0)
        else:
            b.append((b[i-1]+b[i-2])%1000000007)

    print(b[-1])
S = input()
while len(S) > 0:
    if S[0] == 'd':
        if S[0:5] == 'dream':
            if S[5:7] == 'er':
                if S[7] == 'a':
                    S = S[5:]
                else:
                    S = S[7:]
            else:
                S = S[5:]
        else:
            print('NO')
            exit()
    elif S[0] == 'e':
        if S[0:5] == 'erase':
            if S[5] == 'r':
                S = S[6:]
            else:
                S = S[5:]
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)

S = input()[::-1]


while len(S) > 0:
    if S[0] == 'r':
        if S[0:6] == 'resare':
            S = S[6:]
        elif S[0:7] == 'remaerd':
            S = S[7:]
        else:
            print('NO')
            exit()
    elif S[0:5] == 'maerd':
        S = S[5:]
    elif S[0:5] == 'esare':
        S = S[5:]
    else:
        print('NO')
        exit()
print('YES')
import math
def f(k):
    aaa = 1/math.sqrt(5)*(((1+math.sqrt(5))/2)**k-((1-math.sqrt(5))/2)**k)%1000000007
    return aaa
    
n,m = map(int,input().split())
start = []
for i in range(m):
    start.append(int(input())
if start == []:
    print(f(n-1))
else:
    pstart = [-1]+start+[n+1] #スタートとゴールを追加
    newlist = [] #距離のリスト
    for j in range(n-1):
        newlist.append(pstart[j+1]-pstart[j]) #障害物同士の距離を測る
    if 1 in newlist[1:len(newlist)-1]:
                 print(0)
    else: #ちゃんと距離が出そうなとき
        for w in newlist:
            ans = 1
            ans = ans*f(w-1)%1000000007      
        print(ans)         

### FIXED CODE ###

def Fib(n):
    a,b = 1,1
    if n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        for i in range(n-2):
            a,b = b,a+b
        return b
    
n,m = map(int,input().split())
start = []
for i in range(m):
    start.append(int(input()))

if start == []:
    print(Fib(n+1)%1000000007)
else:
    pstart = [-1]+start+[n+1] #スタートとゴールを追加
    newlist = [] #距離のリスト
    for j in range(len(pstart)-1):
        newlist.append(pstart[j+1]-pstart[j]) #障害物同士の距離を測る
    if 1 in newlist[1:len(newlist)-1]:
                 print(0)
    else: #ちゃんと距離が出そうなとき
        ans = 1
        #print(newlist)
        for w in newlist:
            #print(Fib(w-1))
            #print(ans)
            ans = (ans*Fib(w-1))%1000000007
        print(ans)
##C problem
N = int(input())
v = list(map(float, input().split()))
##初期処理
a=min(v)
##最初に出てくる指定した要素を削除
v.remove(a)
b=min(v)
v.remove(b)
v.append( (a+b)/2 )

for i in range(N-2):
        a=v[-1]
        remove(a)
        b=min(v)
        v.remove(b)
        v.append((a+b)/2)

print(v[-1])

### FIXED CODE ###

##C problem
N = int(input())
v = list(map(float, input().split()))

vs = sorted(v)

for i in range(N-1):

    a=vs[0]

    b=vs[1]
    c=(a+b)/2
    vs.remove(b)
    vs.insert(0,c)
    vs.remove(a)
    #print(i)
    #print(vs)

print(vs[0])
# ==================================================-
# 二分探索
# functionを満たす,search_listの最大の要素を出力
# 【注意点】searchリストの初めの方はfunctionを満たし、後ろに行くにつれて満たさなくなるべき
import math
def binary_research(start,end,search_list,function):
    if start==end:
        return search_list[start]
    middle=math.ceil((start+end)/2)
    if function(search_list[middle],k,a_sum,b_sum):
        start=middle
    else:
        end=middle-1
    return binary_research(start, end, search_list, function)

# ==================================================-

n,m,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
a_sum=[0]
b_sum=[0]
for book in a:
    a_sum.append(a_sum[-1]+book)
for book in b:
    b_sum.append(b_sum[-1]+book)


def can_read(num,k,a_sum,b_sum):

    min_read_time=1000000000000000
    for i in range(max(0,num-m),n+1):
        a_num=i
        b_num=num-i
        min_read_time=min(min_read_time,a_sum[a_num]+b_sum[b_num])
    if min_read_time<=k:
        return True
    return False

search_list=list(range(n+m+1))
start=0
end=n+m

print(binary_research(start,end,search_list,can_read))


### FIXED CODE ###

n,m,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]

def make_sumlist(book_list):
    sumnum=0
    container=[0]
    for i in book_list:
        container.append(sumnum+i)
        sumnum+=i
    return container

total_a=make_sumlist(a)
total_b=make_sumlist(b)

# print(n,m,k)
# print(total_a)
# print(total_b)


#r個読めるか
def readable(r):
    #全部読んでも無理
    if r>n+m:
        return False
    if r==0:
        return True
    max_book=100000000000
    for a_n in range(max(0,r-m),min(n,r)+1):
        b_n=r-a_n
        # print(a_n,b_n)
        book_sum=total_a[a_n]+total_b[b_n]
        # print(book_sum)
        max_book=min(max_book,book_sum)
    if max_book<=k:
        return True
    return False

def nibuntansaku(start,end):
    if start==end:
        return start
    middle=(start+end)//2+1
    if readable(middle):
        start=middle
    else:
        end=middle-1
    return nibuntansaku(start,end)

print(nibuntansaku(0,k))