Harryxun/stf_run huggingface dataset:
while 1:
  W, H = map(int, raw_input().split())
  if W = H = 0:
    break
  for i in range(H):
    if i = 0 or i = H-1:
      print "#"
    else
      print "#" + "" * (W-2) + "H"

### FIXED CODE ###

while 1:
   H, W = map(int, raw_input().split())
   if H == 0 and W == 0:
      break
   print "#"*W
   for i in range(1, H-1):
      print ("#"+"."*(W-2)+"#")
   print "#"*W
   print ""
N = input()
if N[-3] == '0':
  print(0)
else:
  print((10 - int(N[-3]))*100)

### FIXED CODE ###

N = input()
if N[-3:] == '000':
  print(0)
else:
  print(1000 - int(N[-3:]))
a,b = input()
ai = int(a)
bi = int(b)

if ai < 10 and bi < 10:
  print(ai * bi)
else:
  print(-1)

### FIXED CODE ###

a,b =map(int,input().split())
ai = int(a)
bi = int(b)
 
if ai < 10 and bi < 10:
  print(ai * bi)
else:
  print(-1)
a, b, c = list(map(int, input().split(' ')))
N = int(input())
max_ = max([a, b, c]
print(a+b+c+max_**N-max_)


### FIXED CODE ###

a, b, c = list(map(int, input().split(' ')))
N = int(input())
max_ = max([a, b, c])
print(a+b+c+max_*(2**N)-max_)
n=int(input())
t = list(map(int,input().split()))
m = int(input())
l = [list(map(int,input().split())) for i in range(m)]
print(sum(t)-t[l[0][0]-1]+l[0][1])
print(sum(t)-t[l[1][0]-1]+l[1][1])
print(sum(t)-t[l[2][0]-1]+l[2][1])

### FIXED CODE ###

n=int(input())
t = list(map(int,input().split()))
m = int(input())
l = [list(map(int, input().split())) for i in range(m)]
for j in range(m):
    print(sum(t)-t[l[j][0]-1]+l[j][1])
num = map(int, raw_input().split())

num.sort()

printf(num[0], num[1], num[2])

### FIXED CODE ###

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

num.sort()

print(num[0], num[1], num[2])
import numpy as np

N, W = [int(x) for x in input().split()]
weight = np.zeros((N,2))
for x in range(N):
    weight[x] = [int(y) for y in input().split()]
#topdown
memo = np.zeros((N+1,W+1))
for x in range(N+1):
    memo[x] = [-1]*(W+1)

def dp(n,w):
    if w < 0:
        return -float('inf')
    elif n == 0 or w == 0:
        return 0
    elif memo[n][w] != -1:
        return memo[n][w]
    else:
        memo[n][w] = max(dp(n-1,w), dp(n-1,w - int(weight[n-1][0])) + weight[n-1][1])
        return memo[n][w]

print(int(dp(N,W)))


### FIXED CODE ###

import numpy as np

N = int(input())
a = np.zeros((N,3))
for i in range(N):
    a[i][0],a[i][1],a[i][2] = map(int,input().split())

memo = np.zeros((N,3))

memo[0][0], memo[0][1], memo[0][2] = a[0][0],a[0][1],a[0][2]
day = 1

while (day < N):
    memo[day] = [max(memo[day-1][(x+1)%3],memo[day-1][(x+2)%3]) + a[day][x] \
                   for x in [0,1,2]]
    day += 1

print(int(max(memo[day - 1])))
import ita
import numpy as np
val1=input()
s=input()
n=int(val1)

data=ita.array.make1d(1000)

for i in range(0,n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            data[int(s[i]+s[j]+s[k])]+=1
1000-data.count(0)

### FIXED CODE ###

val1=input()
s=input()
n=int(val1)
count=0
for i in range(0,1000):
    a=str(i).zfill(3) #ゼロうめ
    p=0
    for j in range(0,n):
        if a[p]==s[j]:
            p+=1
            if p==3:
                count+=1
                break
print(count)
N, A, B, C = map(int, input().split(" "))
commands = []
data = {
    'A': A,
    'B': B,
    'C': C
}
ans = [] 

if A >=1 and B >= 1 and C >= 1 :
    print("Yes")
    for _ in range(N) :
        command = input()
        if data[command[0]] > data[command[1]] :
            data[command[0]] -= 1
            data[command[1]] += 1
            print(command[1])
        else :
            data[command[0]] += 1
            data[command[1]] -= 1
            print(command[0]) 
else :
    safe = []
    commands = []
    for _ in range(N) :
        commands.append(input())

    fail = False
    i = 0 
    ans = []
    
    while i < N : 
        if data[commands[i][0]] == 0 and data[commands[i][1]] == 0 :
            if safe == [] :
                fail = True
                break
            else : 
                data, i, _ans = safe.pop()
                ans = ans[:i+1]
                ans.append(_ans)
                
        elif data[commands[i][0]] == 1 and data[commands[i][1]] == 1 :
            _data = { 'A' :data['A'], 'B' :data['B'], 'C' :data['C'] }
            _i = i
            
            _data[commands[i][1]] += 1
            _data[commands[i][0]] -= 1
            _ans = commands[i][1] 
            safe.append( [_data, _i, _ans] )  

            data[commands[i][0]] += 1
            data[commands[i][1]] -= 1
            ans.append( commands[i][0] )
        else :
            if data[commands[i][0]] > data[commands[i][1]] :
                x = commands[i][0] 
                y = commands[i][1] 
            else :
                x = commands[i][1] 
                y = commands[i][0]

            data[x] -= 1 
            data[y] += 1
            ans.append(y)

        i += 1

    if fail :
        print("No")
    else :
        print("Yes")
        for c in ans :
            print(c)

### FIXED CODE ###

s = input()
if s == "ABC" :
    print("ARC")
else :
    print("ABC")
N = int(input())
for i in range(N//4 + 1):
  for j in range(N//7 + 1):
	if 4*i + 7*j == N:
	  print("Yes")
	  break
else:
  print("No")

### FIXED CODE ###

N = int(input())
fmax = int(N/4)+1
smax = int(N/7)+1
for i in range(fmax+1):
  for j in range(smax+1):
    if (4*i+7*j) == N:
      print('Yes')
      exit()
print('No')
s = {input() for i in range(3)}
N = len(s)
print(N)

### FIXED CODE ###

s = set(input().split())
N = len(s)
print(N)
n=int(input()

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

min=P[0]
count=0
for i in P:
    if min>=i:
        count+=1
        min=i
print(count)
        

### FIXED CODE ###

n=int(input())
 
P=list(map(int,input().split()))
 
min=P[0]
count=0
for i in P:
    if min>=i:
        count+=1
        min=i
print(count)
N = int(input())
X = list(map(int, input().split()))
for P in range(1, max(X)):
    Distance = list(map(lambda x: (x-P)**2), X)
    Total_Distance = sum(Distance)
Total_Distance_List = list(Total_Distance)
print(min(Total_Distance_List))

### FIXED CODE ###

N = int(input())
X = list(map(int, input().split()))
ans = float("inf")
for p in range(1, max(X)+1):
    x_sum=0
    for x in X:
        x_sum+=(x-p)**2
    ans = min(ans, x_sum)
print(ans)
import math
#最大公約数
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
#因数分解
def factorize(x):
    ans=1#約数１
    div=2
    while div**2<=x:
        while x%div==0:
            x=x//div
            flag=1
        if flag==1:
            ans+=1
        div+=1
        flag=0
    if x>1:
        ans+=1
    return ans

a,b=map(int,input().split())
g=gcd(a,b)
f=factorize(g)
print(f)


### FIXED CODE ###

import math
#最大公約数
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
#因数分解
def factorize(x):
    f=[]
    div=2
    while div**2<=x:
        while x%div==0:
            f.append(div)
            x=x//div
        div+=1
    if x>1:
        f.append(x)
    return f

"""def factorize(x):
    ans=1#約数１
    div=2
    while div**2<=x:
        while x%div==0:
            x=x//div
            flag=1
        if flag==1:
            ans+=1
        div+=1
        flag=0
    if x>1:
        ans+=1
    return ans"""

a,b=map(int,input().split())
g=gcd(a,b)
f=factorize(g)
print(len(set(f))+1)
n, q = map(int, input().split())
*C, = map(int, input().split())
k = 2**16
S = [set()] * (2 * k - 1)
for i in range(n):
    S[k - 1 + i] = {C[i]}
for i in range(k - 1)[::-1]:
    S[i] = S[2 * i + 1] | S[2 * i + 2]


def ans(a=0, b=k, p=0):
    if b <= x or y <= a:
        return set()
    if x <= a and b <= y:
        return S[p]
    left = ans(a, (a + b) // 2, 2 * p + 1)
    right = ans((a + b) // 2, b, 2 * p + 2)
    return left | right


for _ in range(q):
    x, y = map(int, input().split())
    x -= 1
    print(len(ans()))


### FIXED CODE ###

import sys
input = sys.stdin.readline


class BIT:
    def __init__(self, n):
        self.array = [0] * (n + 1)
        self.size = n

    def sum(self, i):
        s = 0
        tmp = i
        while tmp > 0:
            s += self.array[tmp]
            tmp -= tmp & -tmp
        return s

    def add(self, i, x):
        tmp = i + 1
        while tmp <= self.size:
            self.array[tmp] += x
            tmp += tmp & -tmp


def main():
    n, q = map(int, input().split())
    *C, = map(lambda x: int(x) - 1, input().split())
    P = [0] * n
    N = [None] * n
    for i in range(n)[::-1]:
        if P[C[i]]:
            N[i] = P[C[i]]
        P[C[i]] = i
    F = [0] * n
    B = BIT(n)
    for i in range(n):
        if F[C[i]] == 0:
            B.add(i, 1)
            F[C[i]] = 1
    XY = [tuple(map(int, input().split())) for j in range(q)]
    ids = list(range(q))
    ids.sort(key=lambda j: XY[j][0])
    a = 0
    lst = [0] * q
    for j in ids:
        x, y = XY[j]
        for i in range(a, x - 1):
            if N[i]:
                B.add(N[i], 1)
        a = x - 1
        lst[j] = B.sum(y) - B.sum(x - 1)
    print(*lst, sep="\n")


main()
# -*- coding: utf-8 -*-

# input
S = input()
# S = "abcdefghijklmnopqrstuvwzyx"
# S = "atcoder"

s = list(S)
a = []
for i in range(len(s)):
    a.append(ord(s[i]))

t = [chr(i) for i in range(97, 97+26)]
b = [i for i in range(97, 97+26)]


def func(s_):
    ss_ = []
    for i in range(len(s_)):
        ss_.append(chr(s_[i]))
    ss_ = ''.join(ss_)
    return ss_


# solve
if (len(s) < 26):
    for i in range(len(s)):
        b.remove(a[i])
    a.append(min(b))
    print(func(a))

if (len(s) == 26):
    print(a)
    for i in reversed(range(len(s))):
        if (a[i] < a[i-1]):
            if (i == 1):
                print(-1)
            else:
                continue
        else:
            a = a[0:i]
            # ここから26文字未満の場合とほとんど同じ
            for i in range(len(a)):
                b.remove(a[i])
            a.pop()
            a.append(min(b))
            print(func(a))
            break


### FIXED CODE ###

# -*- coding: utf-8 -*-
import bisect

# input
S = input()
# S = "abcdefghijklmnopqrstuvwzyx"
# S = "atcoder"
# S = "qpwoeirutyalskdjfhgzmxnvcb"

s = list(S)
a = []
for i in range(len(s)):
    a.append(ord(s[i]))

t = [chr(i) for i in range(97, 97+26)]
b = [i for i in range(97, 97+26)]


# function
def func(s_):
    ss_ = []
    for i in range(len(s_)):
        ss_.append(chr(s_[i]))
    ss_ = ''.join(ss_)
    return ss_


# solve
if (len(s) < 26):
    for i in range(len(s)):
        b.remove(a[i])
    a.append(min(b))
    print(func(a))

if (len(s) == 26):
    for i in reversed(range(len(s))):
        if (a[i] < a[i-1]):
            if (i == 1):
                print(-1)
                break
            else:
                continue
        else:
            c = a[0:i]
            d = a[i:len(a)]
            d = sorted(d)
            # a[i-1]よりも大きくて最も小さいものを探す
            num = c.pop()
            ind = bisect.bisect_left(d, num)
            c.append(d[ind])
            print(func(c))
            break
n=int(input())
a=list(map(int,input().split()))
ans="APPROVED"
for i in range n:
  if a[i]%2==0:
    if a[i]%15!=0:
      ans="DENIED"
    
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans="APPROVED"
for i in range (n):
  if a[i]%2==0:
    if a[i]%3!=0 and a[i]%5!=0:
      ans="DENIED"
    
    
print(ans)
import sys
readline = sys.stdin.readline
from fractions import gcd

class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = I
        self.seg = [I for i in range(self.sz * 2)]
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k //= 2
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
 
    def query(self, a, b):
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a % 2 == 1:
                R = self.func(R, self.seg[a])
                a += 1
            if b % 2 == 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a //= 2
            b //= 2
        return R

def main():
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()


### FIXED CODE ###

from fractions import gcd
import copy

class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = 2 ** (N-1).bit_length()
        self.func = copy.deepcopy(func)
        self.I = copy.deepcopy(I)
        self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]

    def assign(self, k, x):
        self.seg[k + self.sz] = copy.deepcopy(x)

    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = copy.deepcopy(x)
        while k > 1:
            k //= 2
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = copy.deepcopy(self.I)
        R = copy.deepcopy(self.I)
        a += self.sz
        b += self.sz
        while a < b:
            if a % 2 == 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b % 2 == 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a //= 2
            b //= 2
        return self.func(L, R)

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

def f(x,y):
    if x * y == 0:
        return x + y
    else:
        return gcd(x,y)

seg = SegmentTree(N + 1, f, 0)
for i in range(N):
    seg.assign(i , A[i])
seg.build()

ans = 1
for i in range(N):
    ans = max(ans , f(seg.query(0 , i) , seg.query(i + 1 , N)))
print(ans)
DATA=list(map(int, input().split(" ")))
DATA=sorted(DATA)
if DATA[0] == DATA[-1]:
    print("Yes")
else;
    print("No")

### FIXED CODE ###

DATA=list(map(int, input().split(" ")))
DATA=sorted(DATA)
if DATA[0] == DATA[-1]:
    print("Yes")
else:
    print("No")
a, b, c = map(list, input().split(' '))
if a[-1] = b[-1] and b[-1] = c[-1]:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a, b, c = list(input().split(' '))
if a[-1] == b[0] and b[-1] == c[0]:
    print('YES')
else:
    print('NO')
N, K = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(N+1)]

indexs = []
for i in range(len(L)):
    if i%2 != 0:
        indexs.append(L[i])

uniq_list = []
for li in indexs:
    for e in li:
        if e not in uniq_list:
            uniq_list.append(e)

print(N - len(uniq_list))

### FIXED CODE ###

N, K = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(K*2)]

indexs = []
for i in range(len(L)):
    if i%2 != 0:
        indexs.append(L[i])

uniq_list = []
for li in indexs:
    for e in li:
        if e not in uniq_list:
            uniq_list.append(e)

print(N - len(uniq_list))
ANS='No'
S=input()
T=input()
N=len(S)
for i in range(S):
  if S[i:N] + S[:i] == T:
    ANS='Yes'
    break
print(ANS)

### FIXED CODE ###

ANS='No'
S=input()
T=input()
N=len(S)
for i in range(N):
  if S[i:N] + S[:i] == T:
    ANS='Yes'
    break
print(ANS)
S = input()
T = input()

def match_num_character(x, y):
  count = 0
  for a, b in zip(x, y):
    if a == b:
      count += 1
      
  return count

length = len(T)
max_count = max([match_num_character(S[i:i+length], T) for i in range(len(S) - length)])

print(length - max_count)



### FIXED CODE ###

S = input()
T = input()
 
def match_num_character(x, y):
  count = 0
  for a, b in zip(x, y):
    if a == b:
      count += 1
      
  return count
 
length = len(T)
max_count = max([match_num_character(S[i:i+length], T) for i in range(1+len(S) - length)])
 
print(length - max_count)
a, b = map(int, input().split())


while b:
    a, b = b, a % b

# aが最大公約数になっている

if a == 1 :
    print(1)
    exit

def factorization(a):
    arr = []
    temp = a
    for i in range(2, int(-(-a**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([a, 1])

    return arr

print(len(factorization(a) + 1))

### FIXED CODE ###

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


while b:
    a, b = b, a % b

# aが最大公約数になっている

if a == 1 :
    print(1)
else :
    def factorization(a):
        arr = []
        temp = a
        for i in range(2, int(-(-a**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])

        if temp!=1:
            arr.append([temp, 1])

        if arr==[]:
            arr.append([a, 1])

        return arr

    print(int(len(factorization(a)) + 1))
def sakujo():
 moji1 = raw_input()
 moji2 = raw_input()
  
 a, b = len(moji1), len(moji2)
 x1 = [0 for i in range(b+1)]
 for i in range(a):
  e1 = seq1[i]
  x2 = x1+[]
  for j in range(b):
   if e1 == moji2[j]:
    x1[j+1] = x2[j] + 1
   elif x1[j+1] < x1[j]:
    x1[j+1] = x1[j]
 return x1[-1]

 
n=input()
for ix in range(n):
 def sakujo

### FIXED CODE ###

def longest():
    alps1 = raw_input()
    alps2 = raw_input()
    
    x, y = len(alps1), len(alps2)
    k = [0 for i in range(y+1)]
    for i in range(x):
        e1 = alps1[i]
        l = k+[]
        for j in range(y):
            if e1 == alps2[j]:
                k[j+1] = l[j] + 1
            elif k[j+1] < k[j]:
                k[j+1] = k[j]
 
    return k[-1]
    
n = input()
for i in range(n):
    print longest()
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()

ans = 1
cnt = [0, 0, 0]
for i in range(N):
	ans = ans * cnt.count(A[i]) % mod
	cnt[cnt.index(A[i])] += 1

print(ans)

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()

ans = 1
cnt = [0, 0, 0]
for i in range(N):
	ans = ans * cnt.count(A[i]) % mod
	if A[i] in cnt:
		cnt[cnt.index(A[i])] += 1
	else:
		print(0)
		exit()

print(ans)
N = int(input())
L = [False for i in range(100001)]
A = [int(input()) for n in range(N)]


for a in A:
    L[a] = not L[a]

print(sum(L))


### FIXED CODE ###

N = int(input())
A = [int(input()) for n in range(N)]
A = sorted(A)

res = []
tmp = A[0]
count = 1
for i in range(1,N):
    if A[i] == tmp:
        count += 1
    else:
        res.append(count%2 != 0)
        count = 1
    tmp = A[i]
res.append(count%2 != 0)

print(sum(res))
n = int(input())
s = []
for i in range(0, n):
    s.append(input())

c = 0
a = 0
b = 0
ab = 0

for i in range(0, n):
    for j in range(1, len(s[i])):
        if s[i][j-1:j+1] == "AB":
            c += 1
    if s[i][-1] == "A" and s[i][0] == "B":
        ab += 1
    else: 
        if s[i][0] == "B":
            b += 1
        if s[i][-1] == "A":
            a += 1

s = c
s += min(a, b)
a -= min(a, b)
b -= min(a, b)

if(ab > 0):
    s += ab - 1
    if(a > 0):
        s += 1
    if(b > 0):
        s += 1

print(s)

### FIXED CODE ###

n, k = [int(i) for i in input().split(" ")]
print(n - k + 1)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
index_a=0
index_b=0
tot=0
count=0
while index_a<len(a) or index_b<len(b):
	if index_a<len(a) and index_b<len(b):
		if a[index_a]<=b[index_b]:
			tot+=a[index_b]
			if tot>k:
				break
			count+=1
			index_a+=1
		else:
			tot+=b[index_b]
			if tot>k:
				break
			count+=1
			index_b+=1
	elif index_a>=len(a) and index_b<len(b):
		tot+=b[index_b]
		if tot>k:
			break
		count+=1
		index_b+=1
		
	elif index_a<len(a) and index_b>=len(b):
		tot+=a[index_a]
		if tot>k:
			break
		count+=1
		index_b+=1
	else:
		break
		
print(count)



### FIXED CODE ###

n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a=[0]
b=[0]
for i in range(len(A)):
	a.append(a[i]+A[i])

for i in range(len(B)):
	b.append(b[i]+B[i])


ans,j=0,m
for i in range(n+1):
	if a[i]>k:
		break
	while b[j]>k-a[i]:
		j-=1
	ans=max(ans,i+j)
print(ans)
import sys
n = int (sys.stdin.readline())
a = map (int, sys.stdin.readline().split())
res = 0
for i in range (n):
  if a[i] == i+1:
    if i+1 < n:
      a[i], a[i+1] = a[i+1], a[i]
    res += 1
print (res)


### FIXED CODE ###

import sys
n = int (sys.stdin.readline())
a = map (int, sys.stdin.readline().split())
res = 0
for i in range (n):
  if a[i] == i+1:
    if i+1 < n:
      a[i], a[i+1] = a[i+1], a[i]
    res += 1
print (res)
import math
a,b=[int(i)for i in input().split()]
print(int(a*b/math.gcd(a,b)))

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
a,b=[int(i)for i in input().split()]
print(a*b//gcd(a,b))
n = int(input())
schd = []

for _ in range(n):
    schd.append(list(map(int, input().split())))

def travel(t, x, y, k):
    t1, x1, y1 = schd[k][0], schd[k][1], schd[k][2]
    dist = abs(x1-x) + abs(y1-y)
    time_dist = t1-t
    
    if dist <= time_dist and dist%2 == time_dist%2:
        if k+1 == n:
            return "Yes"
        else:
            return travel(t1, x1, y1, k+1)
    else:
        return "No"

print(travel(0, 0, 0, 0))


### FIXED CODE ###

n = int(input())
x, y, t = 0, 0, 0
schd = []

for _ in range(n):
    schd.append(list(map(int, input().split())))

for k in range(n):
    t1, x1, y1 = schd[k][0], schd[k][1], schd[k][2]
    dist = abs(x1-x) + abs(y1-y)
    if dist <= t1-t and (t1-t-dist)%2 == 0:
        t, x, y = t1, x1, y1
    else:
        print("No")
        exit()
else:
    print("Yes")