Harryxun/stf_run huggingface dataset:
import math
import numpy as np


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    act = []
    for i in range(N):
        act.append(inputIntList())
    act.append([0, 0, 0])
    dp = [0 for _ in range(N + 1)]
    for i in range(N):
        dp[i + 1] = dp[i] + max(act[i])
        act[i + 1][np.argmax(act[i])] = 0
        # print(np.argmax(act[i]))

    return dp[-1]


if __name__ == "__main__":
    print(main())


### FIXED CODE ###

import math
import numpy as np


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N = inputInt()
    act = [inputIntList() for _ in range(N)]
    act.append([0, 0, 0])
    dp = [[0 for _ in range(3)] for _ in range(N + 1)]
    dp[0] = act[0]
    for i in range(1, N + 1):
        for j in range(3):
            dp[i][j] = max(dp[i - 1][j - 1], dp[i - 1][j - 2]) + act[i][j]
            # print(dp)

    return max(dp[-1])


if __name__ == "__main__":
    print(main())
A=int(input())
B=int(input())
C=int(input())
X=int(input())

num = 0
scoA = X//500


while scoA > 0:
    sco1 = X - (scoA*500)
    sco2 = sco1//100
    while sco2 > 0:
        sco2 -= 1
        num += 1
        
        if (sco1-(sco2*100))//50 < C:
            continue
        elif sco2 > B:
            continue


    num +=1
    scoA -= 1

    if scoA == 0:
        break


print(num)


### FIXED CODE ###

x = int(input())
A = int(input())
B = int(input())

x = (x-A)

y = x%B
print(y)
N = int(input())
a = list(map(int, input().split()))
ans = 0
import math
from functools import reduce
def lcm_base(x, y):
    return int((x * y) / math.gcd(x, y))
def lcm_list(numbers):
    ans = 0
    for i in range(1,len(numbers)):
        if(i == 1):
            ans = lcm_base(numbers[0], numbers[1])
        else:
            ans = lcm_base(ans, numbers[i])
    return ans

min_bin= lcm_list(a)

# ans = 0
for i in a:
    ans += (min_bin-1) % i
    # print(tmp)
print(ans)


### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
ans = 0

# import math
# from functools import reduce
# def lcm_base(x, y):
#     return int((x * y) / math.gcd(x, y))
# def lcm_list(numbers):
#     ans = 0
#     for i in range(1,len(numbers)):
#         if(i == 1):
#             ans = lcm_base(numbers[0], numbers[1])
#         else:
#             ans = lcm_base(ans, numbers[i])
#     return ans
# min_bin= lcm_list(a)
num = 1
for i in a:
    num = num * i
num = num - 1
for i in a:
    ans += num % i
# for i in range(5000000):
#     tmp = 0
#     for j in a:
#         # print(j)
#         tmp += i % j
#     if(tmp > ans):
#         ans = tmp
print(ans)
5
1 1 1 1 1n=int(input())
l=list(map(int,input().split()))
a=l[0]
b=0
c=[]
for i in range(1,n):
  if l[i]==a:
    b+=1
  else:
    c.append(b)
    b=0
  a=l[i]
c.append(b)
for i in range(len(c)):
  c[i]=(c[i]+1)//2
print(sum(c))

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
a=l[0]
b=0
c=[]
for i in range(1,n):
  if l[i]==a:
    b+=1
  else:
    c.append(b)
    b=0
  a=l[i]
c.append(b)
for i in range(len(c)):
  c[i]=(c[i]+1)//2
print(sum(c))
t,x=map(int,input().split(''))
print(t/x)

### FIXED CODE ###

t,x=map(int,input().split(' '))
print(t/x)
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, K = map(int, input().split())
mod = int(1e+9 + 7)
print(mod)
for i in range(1, K+1):
    print(int(combinations_count(N-K+1, i) * combinations_count(K-1, i-1) % mod))


### FIXED CODE ###

import math


def combinations_count(n, r):
    if n >= r:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    else:
        return 0


N, K = map(int, input().split())
mod = int(1e+9 + 7)
for i in range(1, K+1):
    print(int(combinations_count(N-K+1, i) * combinations_count(K-1, i-1) % mod))
D,N=map(int,input()split())

if N<100:
  print(100**D*N)
else:
  print(100**D*101)


### FIXED CODE ###

A,B=map(int,input().split())
if (A>8) or (B>8):
  print(":(")
else:
  print("Yay!")
x,a,b=[int(input) for i in range(3)]
ans=(x-a)%b
print(ans)

### FIXED CODE ###

x,a,b=[int(input()) for i in range(3)]
ans=(x-a)%b
print(ans)
x, k, d = map(int, input().split())
if x >= 0:
    if x - k*d >= 0:
        ans = x - k*d
    else:
        pre = x//d
        x -= pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif pre%2 == 1:
            ans = min(abs(x-d), abs(x+d))
elif x <= 0:
    if x + k*d <= 0:
        ans = x + k*d
    else:
        pre = abs(x)//d
        x += pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif pre%2 == 1:
            ans = min(abs(x-d), abs(x+d))
print(ans)

### FIXED CODE ###

x, k, d = map(int, input().split())
if x >= 0:
    if x - k*d >= 0:
        ans = abs(x - k*d)
    else:
        pre = x//d
        x -= pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif k%2 == 1:
            ans = min(abs(x-d), abs(x+d))
elif x <= 0:
    if x + k*d <= 0:
        ans = abs(x + k*d)
    else:
        pre = abs(x)//d
        x += pre*d
        k -= pre
        if k%2 == 0:
            ans = abs(x)
        elif k%2 == 1:
            ans = min(abs(x-d), abs(x+d))
print(ans)
import collections

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

hantei = 0

for i in range(0,n):
    if u[0] != u[i]:
        hantei = 1
        break

if hantei == 0:
    print(n // 2)
else:
   u1 = [] 
   u2 = [] 
   ans = 0
   for j in range(n):
       if j % 2 == 0:
           u2.append(u[j])
       else:
           u1.append(u[j])
   u1_list =collections.Counter(u1)
   u2_list =collections.Counter(u2)
   values1, counts1 = u1_list.most_common()[0]
   values2, counts2 = u2_list.most_common()[0]
   if values1 != values2:
       ans += n // 2 - counts1
       ans += n // 2 - counts2
   else:
       if len(u1_list) > 1 and len(u2_list) > 1:
           values3, counts3 = u1_list.most_common()[0]
           values4, counts4 = u2_list.most_common()[0]
           ans1 = n - count1 - count4
           ans2 = n - count2 - count3
           ans = min(ans1,ans2)
       elif len(u1_list) > 1 and len(u2_list) < 2:
           values3, counts3 = u1_list.most_common()[0]
           ans = n - count2 - count3
       elif len(u1_list) < 2 and len(u2_list) > 1:
           values3, counts3 = u2_list.most_common()[0]
           ans = n - count1 - count3

       ans = min(ans1,ans2)
   print(ans)

### FIXED CODE ###

import collections

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

hantei = 0

for i in range(0,n):
    if u[0] != u[i]:
        hantei = 1
        break

if hantei == 0:
    print(n // 2)
else:
   u1 = [] 
   u2 = [] 
   ans = 0
   for j in range(n):
       if j % 2 == 0:
           u2.append(u[j])
       else:
           u1.append(u[j])
   u1_list =collections.Counter(u1)
   u2_list =collections.Counter(u2)
   values1, counts1 = u1_list.most_common()[0]
   values2, counts2 = u2_list.most_common()[0]
   if values1 != values2:
       ans += n // 2 - counts1
       ans += n // 2 - counts2
   else:
       if len(u1_list) > 1 and len(u2_list) > 1:
           values3, counts3 = u1_list.most_common()[1]
           values4, counts4 = u2_list.most_common()[1]
           ans1 = n - counts1 - counts4
           ans2 = n - counts2 - counts3
           ans = max(ans1,ans2)
       elif len(u1_list) > 1 and len(u2_list) < 2:
           values3, counts3 = u1_list.most_common()[1]
           ans = n - counts2 - counts3
       elif len(u1_list) < 2 and len(u2_list) > 1:
           values3, counts3 = u2_list.most_common()[1]
           ans = n - counts1 - counts3

       ans = min(ans1,ans2)
   print(ans)
ans = ""
while True:
    try:
        memo = input()
    except:
        break
    for m in memo:
        ans = ans+m if m.isdigit() else ans+"@"
print(sum(ans.replace("@", " ").split()))

### FIXED CODE ###

import re
ans = 0
while True:
    try:
        line = input()
    except:
        print(ans)
        break
    ans += sum(map(int, re.findall("[0-9]+", line)))
if S == "ABC" :
  print("ARC")
else:
  print("ABC")
  


### FIXED CODE ###

S = input()
if S == "ABC" : 
  print("ARC")
else :
  print("ABC")
h = int(input())
def Count(a):
  if a==1:
    return 1
  return 1+2*Count(a//2)
print(Count(a))

### FIXED CODE ###

h = int(input())
def Count(a):
  if a==1:
    return 1
  return 1+2*Count(a//2)
print(Count(h))
s = input()
q = int(input())
flg = False

for i in range(q):
    x = input()
    if int(len(x)) == 1:
        a = int(x)
        if flg == False:
            flg = True
        else:
            flg = False
        print("G:",s)
    else:
        a, b, c = map(str, x.split()) 
        if flg == False and int(b) == 1:
            s = c + s
        elif flg == False and int(b) == 2:
            s = s + c
        elif flg == True and int(b) == 1:
            s = s + c
        else:
            s = c + s

if flg == True:
    s = s[::-1]
print(s)

### FIXED CODE ###

from collections import deque

s = input()
q = int(input())

t = deque(s)
flg = False
for _ in range(q):
    query = input()
    if query[0] == "1":
        flg = not flg
    elif query[0] == "2":
        _, f, c = query.split()
        if f == "1":
            if flg:
                t.append(c)
            else:
                t.appendleft(c)
        elif f == "2":
            if flg:
                t.appendleft(c)
            else:
                t.append(c)
result = "".join(t)
if flg:
    result = result[::-1]
print(result)
n = int(input())
a = sorted([int(input()) for i in range(n)])
l = n//2

if n % 2 == 0:
    small = a[:l]
    big = a[l:]
    ans = sum(big) * 2 - sum(small) * 2  - big[0] + small[-1]
    print(ans)

else:
    small = a[:l]
    big = a[l+1:]
    ans = sum(big) * 2 - sum(small) * 2 - min(n[l] - small[-1], big[0] - n[l])
    print(ans)

### FIXED CODE ###

n = int(input())
a = sorted([int(input()) for i in range(n)])

if n % 2 == 0:
    small = a[:(n//2)]
    big = a[(n//2):]
    ans = sum(big) * 2 - sum(small) * 2  - big[0] + small[-1]
    print(ans)

else:
    small = a[:(n//2)]
    big = a[(n//2):]
    ans = sum(big) * 2 - sum(small) * 2  - big[0] -big[1]

    small = a[:(n//2)+1]
    big = a[(n//2)+1:]
    ans = max(ans, sum(big) * 2 - sum(small) * 2 + small[-1] + small[-2])
    print(ans)
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if count == 3:
    break
  elif d1 == d2:
    count += 1
  else:
    count == 0
if count == 3:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = input()
if s[-1] == "s":
  print(s+"es")
else:
  print(s+"s")
N = list(map(int,input()))
bool = 0
for i in range(len(N) - 1):
    if N[i] != N[i+1]:
        bool = 1
if bool = 1:
    print("Good")
else:
    print("Bad")


### FIXED CODE ###

N = list(map(int,input()))
bool = 0
for i in range(len(N) - 1):
    if N[i] != N[i+1]:
        bool = 1
    else:
        print("Bad")
        exit()
if bool == 1:
    print("Good")
n=int(input())
p=input().rstrip()
if a<3200:
    print("red")
else:
    print(p)


### FIXED CODE ###

n=int(input())
p=input().rstrip()
if n<3200:
    print("red")
else:
    print(p)
from math import ceil
h,w =map(int,input(),split())
ss = (h*(w+1)//2)
if h>1 and w>1:
	print(ss)
else:
  print(1)


### FIXED CODE ###

a,b =map(int,input().split())
ss = a*b
hf =ss//2
if a>1 and b>1:
	print(ss-hf)
else:
  print(1)
S = input('天気が雨である日が連続していた最大の日数を出力せよ。')
if S == 'SSS':
	print(0)
else if S == 'SSR':
	print(1)
else if S == 'SRR':
	print(2)
else if S == 'SRS':
	print(1)
else if S == 'RSS':
	print(1)
else if S == 'RRS':
	print(2)
else if S == 'RRR':
	print(3)
else if S == 'RRS':
	print(2)

### FIXED CODE ###

S = input()
if S == 'SSS':
  print(0)
elif S == 'SRR':
  print(2)
elif S == 'RRS':
  print(2)
elif S == 'RRR':
  print(3)
else:
  print(1)
n = str(input())
a = string.ascii_lowercase.index(n) 
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
print (n,'is followed by',letters[a+1])

### FIXED CODE ###

x = input().lower()
print(chr(ord(x) + 1))
#..........
n=int(input())
s=input()
k=0
for i in range(n):
    if s[i]=="I":
        x+=1
        if x>k:
            k=x
    else:
        x+=-1
print(k)

### FIXED CODE ###

n=int(input())
s=input()
k=0
x=0
for i in range(n):
    if s[i]=="I":
        x+=1
        if x>k:
            k=x
    else:
        x+=-1
print(k)
N,D=map(int,input().split())
d2 = D**2
rt = 0
for i in range(n):
  x,y = map(int,input().split())
  
  if x**2 + y**2 < d2:
    rt+=1
print(rt)

### FIXED CODE ###

N,D=map(int,input().split())
d2 = D**2
rt = 0
for i in range(N):
  x,y = map(int,input().split())
  
  if x**2 + y**2 <= d2:
    rt+=1
print(rt)
r = input()

print(r*r)

### FIXED CODE ###

r = int(input())

print(r*r)
N, Q = list(map(int, input().split()))
nodes = [[] for i in range(N)]
for i in range(N-1):
  r, e = list(map(int, input().split()))
  r, e = r - 1, e - 1
  nodes[r].append(e)
  nodes[e].append(r)
#print(nodes)

result = [0] * N
for i in range(Q):
  r, s = list(map(int, input().split()))
  result[r-1] += s

def dfs(r, prev=-1):
  for i in nodes[r]:
    if i == prev:
      continue
    result[i] += result[r]
    dfs(i, r)

dfs(0)
print(*result)


### FIXED CODE ###

#人の（ほぼ同じなのにうまくいかないので）
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
lines = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    lines[a-1].append(b-1)
    lines[b-1].append(a-1)
ans = [0]*N
for _ in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

def dfs(v, parent):
    for u in lines[v]:
        if u != parent:
            ans[u] += ans[v]
            dfs(u, v)

dfs(0, -1)
print (*ans)
import sys
sys.setrecursionlimit(10000)

N = int(input())
color = [-1] * N
G = [[] for _ in range(N)]
W = [[] for _ in range(N)]
for i in range(N-1):
  u, v, w = map(int, input().split())
  G[u-1].append(v-1)
  G[v-1].append(u-1)
  W[u-1].append(w)
  W[v-1].append(w)

def dfs(v, cur):
  color[v] = cur
  for next_v, w in zip(G[v], W[v]):
    if color[next_v] != -1:
      continue
    if w % 2 == 0:
      dfs(next_v, cur)
    else:
      dfs(next_v, 1 - cur)
      
for i in range(N):
  if color[i] != -1:
    continue
  dfs(i, 0)
for i in range(N):
  print(color[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

N = int(input())
color = [-1] * N
G = [[] for _ in range(N)]
W = [[] for _ in range(N)]
for i in range(N-1):
  u, v, w = map(int, input().split())
  G[u-1].append(v-1)
  G[v-1].append(u-1)
  W[u-1].append(w)
  W[v-1].append(w)

def dfs(v, cur):
  color[v] = cur
  for next_v, w in zip(G[v], W[v]):
    if color[next_v] != -1:
      continue
    if w % 2 == 0:
      dfs(next_v, cur)
    else:
      dfs(next_v, 1 - cur)
      
for i in range(N):
  if color[i] != -1:
    continue
  dfs(i, 0)
for i in range(N):
  print(color[i])
def main():
    N = input()
    print((10 ** N - 9 ** N - 9 ** N + 8 ** N)%(10**9 + 7))

main()

### FIXED CODE ###

def main():
    N = int(input())
    print((10**N - 9**N - 9**N + 8**N)%(10**9 + 7))

main()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


A B = input().split()

if A < B:
    print('<')
elif A > B:
    print('>')
elif A == B:
    print('0')


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


A, B = input().split()

if A < B:
    print('<')
elif A > B:
    print('>')
elif A == B:
    print('=')
import sys 
a = list(map(int,input().split()))

N = a[0]
M = a[1]

b = ['0']*N

for i in range(0,M):
    x = list(map(str,input().split()))
    if b[int(x[0])-1] != '0' and b[int(x[0])-1] != x[1]:
        print('-1')
        sys.exit()
    elif x[0] == '1' and x[1] == '0':
        print('-1')
        sys.exit()
    else:
        b[int(x[0])-1] = x[1]

if b[0] == '0' and not b[1] == '0':
    b[0] = '1'

ans = ''.join(b)
print(ans)


### FIXED CODE ###

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

N = a[0]
M = a[1]

b = ['0']*N

for i in range(0,M):
    x = list(map(str,input().split()))
    if b[int(x[0])-1] != '0' and b[int(x[0])-1] != x[1]: #既に与えられたところに違う値
        print('-1')
        sys.exit()
    elif N >= 2 and x[0] == '1' and x[1] == '0': #the first digit is  "0"
        print('-1')
        sys.exit()
    else:
        b[int(x[0])-1] = x[1]

if N != 1 and b[0] == '0':
    b[0] = '1'

ans = ''.join(b)
print(ans)
import sys
input = sys.stdin.readline
 
n, k = map(int, input().split())
prob = 0
for i in range(1, n+1):
  count = 0
  total = i
  while total < k:
    total *= 2
    count += 1
  prob += 1/2**p
print(prob/n)


### FIXED CODE ###

import sys
input = sys.stdin.readline
 
n, k = map(int, input().split())
prob = 0
for i in range(1, n+1):
  count = 0
  total = i
  while total < k:
    total *= 2
    count += 1
  prob += 1/2**count
print(prob/n)
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]
booli = [False]*(N)
for i in a:
    booli[i-1] = True
mod = 1000000007
INF = -1
dp = [INF]*(N+1)
dp[0] = 1
if booli[1]:
    dp[1] = 0
else:
    dp[1] = 1
def solve():
    for i in range(2,N+1):
        if booli[i-1]:
            dp[i] = 0
        else:
            dp[i] = dp[i-1]+dp[i-2]
    return dp[N]%mod
print(solve())

### FIXED CODE ###

N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]
booli = [False]*(N+1)
for i in a:
    booli[i] = True
mod = 1000000007
INF = -1
dp = [INF]*(N+1)
dp[0] = 1
if booli[1]:
    dp[1] = 0
else:
    dp[1] = 1
def solve():
    for i in range(2,N+1):
        if booli[i]:
            dp[i] = 0
        else:
            dp[i] = dp[i-1]+dp[i-2]
    return dp[N]%mod
print(solve())
pi = math.pi
r = float(input())
print("{:.010f}{:.010f}".format(r*r*pi,2*r*pi))



### FIXED CODE ###

from math import pi
r = float(input())
print("{:.010f} {:.010f}".format(r * r * pi, 2 * pi * r))
a = input()
b =a[0]+a[1]+a[2]+a[3]+a[5]+a[6]+a[8]+a[9]
c =int(a)
if c <= 20190430:
  print('Heisei')
else:
  print('TBD')

### FIXED CODE ###

a = input()
b =a[0]+a[1]+a[2]+a[3]+a[5]+a[6]+a[8]+a[9]
c =int(b)
if c <= 20190430:
  print('Heisei')
else:
  print('TBD')
import sys
input = sys.stdin.readline
A,B,K=map(int,input().rstrip().split())

def resolve():
    
    if(A>K):
        ansA=int(A)-int(K)
        ansB=int(B)
    else:
        ansA=0
        ansB=int(B)-(int(K)-int(A))
        if(ansB<0):
            ansB=0
    print((int(ansA))+" "+(int(ansB)))

import sys
from io import StringIO
import unittest
#1000000000000 1000000000000 1000000000001
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 3 3"""
        output = """0 2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """500000000000 500000000000 1000000000000"""
        output = """0 0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

### FIXED CODE ###

import sys
input = sys.stdin.readline
A,B,K=map(int,input().rstrip().split())

def resolve():
    
    if(A>K):
        ansA=int(A)-int(K)
        ansB=int(B)
    else:
        ansA=0
        ansB=int(B)-(int(K)-int(A))
        if(ansB<0):
            ansB=0
    print(str(int(ansA))+" "+str(int(ansB)))

import sys
from io import StringIO
import unittest
#1000000000000 1000000000000 1000000000001
class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 3 3"""
        output = """0 2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """500000000000 500000000000 1000000000000"""
        output = """0 0"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()
s = input()
ans = []
dp = [-1]*(len(s))
if s[0] != "B":
    dp[0] = s[0]
else:
    dp[0] = [-1]

#print(dp)
for i in range(len(s)-1):
    if s[i+1] != "B":
        if dp[i] != -1:
            dp[i+1] = dp[i] + s[i+1]
        else:
            dp[i+1] = s[i+1]
    else:
        if dp[i] != -1 and i-1 >= 0:
            dp[i+1] = dp[i-1]
        else:
            dp[i+1] = -1
print(dp[len(s)-1])

### FIXED CODE ###

s = input()
ans = []
dp = [""]*(len(s))
if s[0] != "B":
    dp[0] = s[0]
else:
    dp[0] = ""

for i in range(len(s)-1):
    if s[i+1] != "B":
        dp[i+1] = dp[i] + s[i+1]
    else:
        dp[i+1] = dp[i][:len(dp[i])-1]
print(dp[len(s)-1])
N, Q = list(map(int, input().split()))
# 双方向に張る
tree = [[] for _ in range(N)]
for i in range(N-1):
    a, b = list(map(int, input().split()))
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)

# queryのスコア表を作る
total = [0 for _ in range(N)]
for i in range(Q):
    p, x = list(map(int, input().split()))
    total[p - 1] += x

# dfs
ans = [0 for _ in range(N)]
def dfs(v, p, value):
    value += total[v]
    ans[v] = value
    for c in tree[v]:
        if c == p: continue
        dfs(c, v, value)

dfs(0, -1, 0)
print(" ".join(list(map(str, ans))))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

readline = sys.stdin.readline
n, q = list(map(int, readline().split()))
# 双方向に張る
tree = [[] for _ in range(n)]
for i in range(n-1):
    a, b = list(map(int, readline().split()))
    a -= 1
    b -= 1
    tree[a].append(b)
    tree[b].append(a)

# queryのスコア表を作る
total = [0 for _ in range(n)]
for i in range(q):
    p, x = list(map(int, readline().split()))
    total[p - 1] += x

# dfs
ans = [0 for _ in range(n)]
def dfs(v, p, value):
    value += total[v]
    ans[v] = value
    for c in tree[v]:
        if c == p: continue
        dfs(c, v, value)

dfs(0, -1, 0)
print(*ans)
N = int(input())
*V, = map(int, input().split())
V.sort()
ans = V[0]
for i in range(1, N):
    ans = mix(ans,V[i])
print(ans)

### FIXED CODE ###

def mix(x, y):
    return (x + y) / 2
    
N = int(input())
*V, = map(int, input().split())
V.sort()
ans = V[0]
for i in range(1, N):
    ans = mix(ans,V[i])
print(ans)
n=input().split()
a=int(n[0][0])
b=int(n[0][1])
c=int(n[0][2])
d=int(n[0][3])
if a+b+c+d==7:
  print(a+b+c+d=7)
if a+b+c-d==7:
  print(a+b+c-d=7)
if a+b-c+d==7:
  print(a+b-c+d=7)
if a-b+c+d==7:
  print(a-b+c+d=7)
if a+b-c-d==7:
  print(a+b-c-d=7)
if a-b+c-d==7:
  print(a-b+c-d=7)
if a-b-c+d==7:
  print(a-b-c+d=7)
if a-b-c-d==7:
  print(a-b-c-d=7)


### FIXED CODE ###

import sys
S=input()
a,b,c,d=S[0],S[1],S[2],S[3]
lst=['+','-']
for i in lst:
  for j in lst:
    for k in lst:
      if eval(a+i+b+j+c+k+d+'==7'):
        print(a+i+b+j+c+k+d+'=7')
        sys.exit()
A,B = map(int,input().split())
print(max(A+B,A-B,A*B)

### FIXED CODE ###

A,B = map(int,input().split())
print(max(A+B,A-B,A*B))
N,M,K=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
while True:
    if A[0]<=B[0] or B==[]:
        count+=1
        K-=A.pop(0)
    else:
        count+=1
        K-=B.pop(0)

    if K<0:
        count-=1
        break

    if A==[] and B==[]:
        break
print(count)

### FIXED CODE ###

N,M,K=list(map(int,input().split()))
A=list(map(int,input().split()))
B=list(map(int,input().split()))
AA=[0]*(N+1)
BB=[0]*(M+1)
A3=0
B3=0
high=0
for i in range(0,N):
    A3+=A[i]
    AA[i+1]=A3
for j in range(0,M):
    B3+=B[j]
    BB[j+1]=B3
for i in range(0,N+1):
    if AA[i]>K:
        break
    while True:
        if BB==[]:
            break
        elif BB==[0]:
            BB=[]
            break
        elif AA[i]+BB[-1]>K:
            BB.pop(-1)
        else:
            break
    if BB!=[]:
        time=AA[i]+BB[-1]
        judge=1
    else:
        time=AA[i]
        judge=0
    if time<=K:
        if judge==0:
            if high<i:
                high=i
        else:
            if high<i+len(BB)-1:
                high=i+len(BB)-1
print(high)