Harryxun/stf_run huggingface dataset:
n = int(input())
x = input()
COUNT = x.count('1')
mod1 = COUNT - 1
mod2 = COUNT + 1

# その桁に1が立っていた時の余り
mod = [[0, 0] for _ in range(n+1)]
mult = 1
mod[0][0] = 1 % mod1
mod[0][1] = 1 % mod2
for i in range(1, n+1):
    mod[i][0] = (mod[i-1][0] * (2 % mod1)) % mod1
    mod[i][1] = (mod[i-1][1] * (2 % mod2)) % mod2

all_mod1 = 0
all_mod2 = 0
for i in range(n):
    if x[i] == '1':
        all_mod1 = (all_mod1 + mod[n-1-i][0])
        all_mod2 = (all_mod2 + mod[n-1-i][1])
all_mod1 %= mod1
all_mod2 %= mod2

def popcount(idx):
    idx -= 1
    ret = 0
    if x[idx] == '1':
        ret = (all_mod1 - mod[n-1-idx][0]) % mod1
    else:
        ret = (all_mod2 + mod[n-1-idx][1]) % mod2
    return ret

bit_cnt_table = [0 for _ in range(n+1)]
bit_cnt_table[1] = 1
base = 0
i = 2
while i <= n:
    if i % (2 ** base) == 0:
        base += 1
    bit_cnt_table[i] = 1 + bit_cnt_table[i - 2**(base)]
    i += 1

def func(num):
    if bit_cnt_table[num] == 0:
        return 0
    return num % bit_cnt_table[num]

f = [-1 for _ in range(n+1)]
f[0] = 0
f[1] = 1
for i in range(2, n+1):
    tmp = func(i)
    f[i] = 1 + f[tmp]
# print("all_mod", all_mod1, all_mod2)
ans = []
for i in range(1, n+1):
    p = popcount(i)
    ans_i = 1 + f[p]
    # print(i, p, ans_i)
    ans.append(str(ans_i))
print("\n".join(ans))
# print(f)
# print(bit_cnt_table)

### FIXED CODE ###

n = int(input())
x = input()
COUNT = x.count('1')
mod1 = COUNT - 1
mod2 = COUNT + 1

# その桁に1が立っていた時の余り
mod = [[0, 0] for _ in range(n+1)]
mult = 1
if mod1 != 0:
    mod[0][0] = 1 % mod1
mod[0][1] = 1 % mod2
for i in range(1, n+1):
    if mod1 != 0:
        mod[i][0] = (mod[i-1][0] * (2 % mod1)) % mod1
    mod[i][1] = (mod[i-1][1] * (2 % mod2)) % mod2

all_mod1 = 0
all_mod2 = 0
for i in range(n):
    if x[i] == '1':
        if mod1 != 0:
            all_mod1 = (all_mod1 + mod[n-1-i][0])
        all_mod2 = (all_mod2 + mod[n-1-i][1])
if mod1 != 0:
    all_mod1 %= mod1
all_mod2 %= mod2

def popcount(idx):
    idx -= 1
    ret = 0
    if x[idx] == '1':
        if mod1 != 0:
            ret = (all_mod1 - mod[n-1-idx][0]) % mod1
        else:
            ret = -1
    else:
        ret = (all_mod2 + mod[n-1-idx][1]) % mod2
    return ret

bit_cnt_table = [0 for _ in range(n+1)]
bit_cnt_table[1] = 1
base = 0
i = 2
while i <= n:
    if i % (2 ** base) == 0:
        base += 1
    bit_cnt_table[i] = 1 + bit_cnt_table[i - 2**(base)]
    i += 1

def func(num):
    if bit_cnt_table[num] == 0:
        return 0
    return num % bit_cnt_table[num]

f = [-1 for _ in range(n+1)]
f[0] = 0
f[1] = 1
for i in range(2, n+1):
    tmp = func(i)
    f[i] = 1 + f[tmp]
# print("all_mod", all_mod1, all_mod2)
ans = []
for i in range(1, n+1):
    p = popcount(i)
    if p == -1:
        ans_i = 0
    else:
        ans_i = 1 + f[p]
    # print(i, p, ans_i)
    ans.append(str(ans_i))
print("\n".join(ans))
# print(f)
# print(bit_cnt_table)
from fractions import gcd
A, B, C, D = map(int, input().split())
sc = B//C - (A-1)//C
sd = B//D - (A-1)//D
scd = B//gcd(C, D) - (A-1)//math.gcd(C, D)
print(sc, sd, scd, B-A+1)
print(B-A+1 - sc - sd + scd)


### FIXED CODE ###

from fractions import gcd


def lcm(a, b):
    return (a*b)//gcd(a, b)


A, B, C, D = map(int, input().split())
sc = B//C - (A-1)//C
sd = B//D - (A-1)//D
scd = B//lcm(C, D) - (A-1)//lcm(C, D)
#print(B//lcm(C, D), (A-1)//lcm(C, D))
#print(sc, sd, scd, B-A+1)
print(B-A+1 - sc - sd + scd)
N=int(input())
T,A=map(int,input().split())
mylist=list(map(int,input().split()))
min=T
index=0

for i in range(N):
  if(min>abs(T-0.006*mylist[i])):
    min=mylist
    index=i
print(index)


### FIXED CODE ###

N=int(input())
T,A=map(int,input().split())
mylist=list(map(int,input().split()))
mymin=10**6
index=0

for i in range(N):
  if(mymin>abs(A-(T-0.006*mylist[i]))):
    mymin=abs(A-(T-0.006*mylist[i]))
    index=i
print(index+1)
N, K = map(int, input().split())
MOD = 10**9+7

paskal3 = [[1]]
for i in range(1, N+5):
    l = [1]
    for j in range(1, i):
        l.append((paskal3[i-1][j-1]+paskal3[i-1][j]) % MOD)
    l.append(1)
    paskal3.append(l)


def comb(n, r):
    return paskal3[n][r]


if N == K:
    for i in range(1, K+1):
        if i == 1:
            print(1)
        else:
            print(0)
    exit()

for i in range(1, K+1):
    print((comb(N-K+1, i) * comb(K-1, i-1)) % MOD)


### FIXED CODE ###

N, B = map(int, input().split())
R = N-B
MOD = 10**9+7

paskal3 = [[1]]
for i in range(1, N+5):
    l = [1]
    for j in range(1, i):
        l.append((paskal3[i-1][j-1]+paskal3[i-1][j]) % MOD)
    l.append(1)
    paskal3.append(l)


def comb(n, r):
    try:
        return paskal3[n][r]
    except:
        return 0


for i in range(1, B+1):
    print((comb(R+1, i) * comb(B-1, i-1)) % MOD)
A, B = map(int, input().split())

if A = 1:
    A += 12
if B = 1:
    B += 12

if A < B:
    print('Alice')
if A > B:
    print('Bob')
else:
    print('Draw')

### FIXED CODE ###

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

if A == 1:
    A += 13
if B == 1:
    B += 13

if A > B:
    print('Alice')
elif A < B:
    print('Bob')
else:
    print('Draw')
def LCS():
  x = ' ' + raw_input()
  y = ' ' + raw_input()
  X = len(x)
  Y = len(y)
  maxl = 0
  for i in range(1,X+1):
    c[i][0] = 0
  for j in range(1,Y+1):
    c[0][j] = 0
 
  for i in range(1,X+1):
    for j in range(1,Y+1):
      if X[i] == Y[i]: 
        c[i][j] = c[i - 1][j - 1] + 1
 
      else:
        c[i][j] = max(c[i - 1][j], c[i][j - 1])

    maxl = (c[i][j], maxl)     
 return maxl
 
q = input()
 
for i in xrange(q):
  print LCS

### FIXED CODE ###

def LCS():
    X = raw_input()
    Y = raw_input()
 
    a, b = len(X), len(Y)
    c1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = X[i]
        c2 = c1+[]
        for j in range(b):
            if e1 == Y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
 
n = input()
for i in range(n):
    print LCS()
n, r = map(int, input().split())

if n >= 10:
    print(r)
else:
    print(r + 100*(10-n)))

### FIXED CODE ###

n, r = map(int, input().split())

if n >= 10:
    print(r)
else:
    print(r + 100*(10-n))
array = list(map(int, input().split())).sort()
print(array[0]+array[1])

### FIXED CODE ###

array = sorted(list(map(int, input().split())))
print(array[0]+array[1])
import numpy as np
s = list(input())
x, y = map(int, input().split())

X = [0]
Y = [0]

flag = True
tmp = 0
for i in s:
    if i == 'F':
        tmp += 1
    else:
        if flag:
            X.append(tmp)
        else:
            Y.append(tmp)
        tmp = 0
        flag = not flag

if flag:
    X.append(tmp)
else:
    Y.append(tmp)

# print (X)
# print (Y)

x -= X[1]
X[1] = 0

x = abs(x)
y = abs(y)

total_X = sum(X)
total_Y = sum(Y)

lst_X = np.zeros(total_X + 1)
lst_X[0] = 1
for i in X:
    if i == 0:
        continue
    lst_X[i:] = max(lst_X[i:], lst_X[:-i])

# print (lst_X)

lst_Y = [0] * (total_Y + 1)
lst_Y[0] = 1
for i in Y:
    if i == 0:
        continue
    for j in range(total_Y - i, -1, -1):
        if lst_Y[j] == 1:
            lst_Y[j + i] = 1

# print (lst_Y)
if x > total_X or y > total_Y:
    print ('No')
    exit()

if (total_X - x) % 2 == (total_Y - y) % 2 == 0 and lst_X[(total_X - x) // 2] == 1 and lst_Y[(total_Y - y) // 2]:
    print ('Yes')
else:
    print ('No')

### FIXED CODE ###

s = list(input())
x, y = map(int, input().split())

X = [0]
Y = [0]

flag = True
tmp = 0
for i in s:
    if i == 'F':
        tmp += 1
    else:
        if flag:
            X.append(tmp)
        else:
            Y.append(tmp)
        tmp = 0
        flag = not flag

if flag:
    X.append(tmp)
else:
    Y.append(tmp)

# print (X)
# print (Y)

x -= X[1]
X[1] = 0

x = abs(x)
y = abs(y)

total_X = sum(X)
total_Y = sum(Y)

lst_X = [0] * (total_X + 1)
lst_X[0] = 1
for i in X:
    if i == 0:
        continue
    for j in range(total_X - i, -1, -1):
        if lst_X[j] == 1:
            lst_X[j + i] = 1

# print (lst_X)

lst_Y = [0] * (total_Y + 1)
lst_Y[0] = 1
for i in Y:
    if i == 0:
        continue
    for j in range(total_Y - i, -1, -1):
        if lst_Y[j] == 1:
            lst_Y[j + i] = 1

# print (lst_Y)
if x > total_X or y > total_Y:
    print ('No')
    exit()

if (total_X - x) % 2 == (total_Y - y) % 2 == 0 and lst_X[(total_X - x) // 2] == 1 and lst_Y[(total_Y - y) // 2]:
    print ('Yes')
else:
    print ('No')
N = int(input())
mojiretu = [input() for _ in range(N)]
dict = {}
answer = 0

for n in mojiretu:
  a = ''.join(sorted(list(n)))
  if a in dict.keys():
    dict[a]+=1
  else:
    dict[a]= 1
 

def fact(n):
  if n == 0 or n == 1:
    return 1
  else:
    return n * fact(n-1)

  
for value in dict.values():
	if value > 1:
		answer += fact(value-1)

print(answer)

### FIXED CODE ###

#!/usr/bin/env python3
import sys
import collections
from itertools import groupby

def solve(N: int, s: "List[str]"):
    s = [sorted(s[i]) for i in range(N)]
    s.sort()
    group = groupby(s)
    answer = 0
    for key, group in group:
        a = len(list(group))
        answer += int(a*(a-1)/2) if a > 1 else 0
    print(answer)
   


    # for i in range(N):
    #     a = 1
    #     pop_index = []
    #     for j in range(i+1,len(ss)):
    #         if ss[i] == ss[j]:
    #             a += 1
    #             pop_index.append(j)
        
    #     ss = [ss[i] for i in range(len(ss)) if i not in pop_index]
    #     answer += int(a*(a-1)/2) if a > 1 else 0
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, s)

if __name__ == '__main__':
    main()
n,m,a,b=[int(i) for i in input().split()]
l=[[0 for i in range(m)] for j in range(n)]
t1=[0 for i in range(n)]
t2=[0 for i in range(m)]

for i in range(n):
    for j in range(m):
        if t1[i]!=a and t2[j]!=b:
            t1[i]+=1
            t2[i]+=1
            l[i][j] = 0
        else:l[i][j]=1

countmin = 1000000000000
for i in range(n):
    countmin = min(countmin,l[i].count(0),l[i].count(1))
if countmin<a:
    print(-1)
    exit()
countmin = 1000000000000
for j in range(m):
    a1,a2=0,0
    for i in range(n):
        if l[i][j] == 0:a1+=1
        else:a2+=1
    countmin = min(countmin,a1,a2)
if countmin<b:
    print(-1)
    exit()
for i in range(n):
    for j in range(m):
        print(l[i][j],end="")
    print()

### FIXED CODE ###

n,m,a,b=[int(i) for i in input().split()]
l=[[0 for i in range(m)] for j in range(n)]

for i in range(n):
    for j in range(m):
        if i<b:
            if j<a:
                l[i][j] = 0
            else:
                l[i][j] = 1
        else:
            if j<a:
                l[i][j] = 1
            else:
                l[i][j] = 0
for i in range(n):
    print("".join(str(e) for e in l[i]))
n = int(input())
a = list(map(int,input().split()))
pos = []
neg = []
cnt = 0
for i in a:
    if i > 0:
        pos.append(i)
    elif i < 0:
        neg.append(i)
    else:
        cnt += 1
if cnt != 0 or len(neg) % 2 == 0:
    print(sum(pos) - sum(neg))
else:
    pos = sorted(pos)
    neg = sorted(neg)
    b = min(pos)
    c = -max(neg)
    pos = pos[1:]
    neg = neg[:-1]
    r = sum(pos) - sum(neg)
    m = max(b - c, c - b)
    print(r + m)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
pos = []
neg = []
cnt = 0
for i in a:
    if i > 0:
        pos.append(i)
    elif i < 0:
        neg.append(i)
    else:
        cnt += 1
if cnt != 0 or len(neg) % 2 == 0:
    print(sum(pos) - sum(neg))
else:
    pos = sorted(pos)
    neg = sorted(neg)
    if pos == []:
      print(-sum(neg[:-1])+neg[-1])
      exit()
    else:
      b = min(pos)
    c = -max(neg)
    pos = pos[1:]
    neg = neg[:-1]
    r = sum(pos) - sum(neg)
    m = max(b - c, c - b)
    print(r + m)
n,m = list(map(int, input().split()))
counter = [0 for _ in range(m)]
#min = m

for i in range(n):
  k,*b = input().split()
  b = [int(j) for j in b]
  for l in b:
    counter[l] +=1
    
print(counter.count(n))

### FIXED CODE ###

n,m = list(map(int, input().split()))
counter = [0]*m
#min = m

for i in range(n):
  k,*b = input().split()
  b = [int(j) for j in b]
  for l in b:
    counter[l-1] +=1
    
print(counter.count(n))
from scipy.special import comb
from collections import deque

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

li = list(np.mod(A, 2))
zero = li.count(0)
one = li.count(1)

if P == 0:
    combi = [0] + [2 * x for x in range(1, (one + 2) // 2)]
if P == 1:
    combi = [1] + [2 * x + 1 for x in range(1, (one + 1) // 2)]

q = deque(combi)

right = 0
while q:
    c = q.popleft()
    tmp = comb(one, c, exact=True)
    right += tmp

print(2**zero * right)

### FIXED CODE ###

from collections import deque
import numpy as np
from functools import lru_cache

nCr = {}


@lru_cache(maxsize=None)
def cmb(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
    return nCr[(n, r)]


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

li = list(np.mod(A, 2))
zero = li.count(0)
one = li.count(1)

if P == 0:
    combi = [0] + [2 * x for x in range(1, (one + 2) // 2)]
if P == 1:
    combi = [1] + [2 * x + 1 for x in range(1, (one + 1) // 2)]

q = deque(combi)

right = 0
while q:
    c = q.popleft()
    tmp = cmb(one, c)
    right += tmp

print(2**zero * right)
n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in range(n):
    ans[a[i]-1]=i+1
print(*ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n):
    ans[a[i]-1]=i+1
print(*ans)
a = list(map(int,input().split())

if sum(a) =>22:
    print(bust)
else:
    print(win)

### FIXED CODE ###

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

if sum(a) >= 22:
    print("bust")
else:
    print("win")
for line in sys.stdin:
    a, b = map(int, line.split())
    print(len(str(a + b)))

### FIXED CODE ###

import sys

for line in sys.stdin:
    a, b = map(int, line.split())
    print(len(str(a + b)))
n = int(input())
s = input()

ans = 0

for i in range(1, n):
    h = s[:i]
    t = s[i:]
    cnt = 0
    for j in range(26):
        c = chr(ord('a') + j)
        if c in head and c in tail:
            cnt += 1

    ans = max(ans, cnt)

print(ans)


### FIXED CODE ###

n = int(input())
s = input()

ans = 0
for i in range(1, n):
    head = s[:i]
    tail = s[i:]
    cnt = 0
    for i in range(26):
        c = chr(ord('a') + i)
        if c in head and c in tail:
            cnt += 1

    ans = max(ans, cnt)

print(ans)
d, t, s = map(int, input().split())
if d > t * s:
　print('no')
if d <= t * s:
　print('yes')

### FIXED CODE ###

d, t, s = map(int, input().split())

if d > t * s:
		print('No')
if d <= t * s:
		print('Yes')
N,K=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(N-K+1):
    b.append(min(abs(a[i])+abs(a[i+K-1]-a[i]),abs(a[i+K-1])+abs(a[i]-a[i+K-1]))
print(min(b))


### FIXED CODE ###

N,K=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(N-K+1):
    b.append(min(abs(a[i])+abs(a[i+K-1]-a[i]),abs(a[i+K-1])+abs(a[i]-a[i+K-1])))
print(min(b))
import sys

args = sys.argv

a = args[0]
b = args[1]

sum = a + b
minus = a - b
sub = a * b

if sum - minus < 0:
  if sum - sub < 0:
    return sum
  return sub

if minus - sub < 0:
  return sub

return minus

### FIXED CODE ###

import sys

a, b = map(int, input().split())
 
sum = a + b
minus = a - b
sub = a * b
 
if (sum - minus) > 0:
  if (sum - sub) > 0:
    print(sum)
  else:
    print(sub)
else:
  if (minus - sub) > 0:
    print(minus)
  else:
    print(sub)
N, M = map(int, input().split())

S = [0] * M
C = [0] * M

for i in range(M):
    S[i], C[i] = input().split()

ans = -1
for i in range(10 * (N - 1) + 1, 10 * N):
    for s, c in zip(S, C):
        if not str(i)[int(s) - 1] == c:
            break
    else:
        ans = i
        break
    if not ans == -1:
        break


### FIXED CODE ###

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

K = [0, -1, -1, -1]
ans = -1
for i in range(M):
    s, c = map(int, input().split())
    if not N == 1 and s == 1 and c == 0:
        break
    if K[s] >= 0 and not K[s] == c:
        break
    K[s] = c
else:
    if K[1] == -1 and N >= 2:
        K[1] = 1
    if K[1] == -1 and N == 1:
        K[1] = 0
    if K[2] == -1:
        K[2] = 0
    if K[3] == -1:
        K[3] = 0

    ans = ''.join(map(str, K[1:N + 1]))

print(ans)
N, Q = map(int, input().split())
works = []
for i in range(N):
    s, t, x = map(int, input().split())
    if x < s:
        works.append([s - x, t - x - 1, x])

    elif s <= x <= t:
        works.append([0, t - x - 1, x])

    else:
        continue


works.sort(key=lambda w: w[1])
works.append([float('inf'), float('inf'), -1])
i = 0

for q in range(Q):
    d = int(input())
    while i < N:
        s, t, x = works[i]
        if s <= d <= t:
            print(x)
            break

        i += 1
        if d < works[i][0]:
            print(-1)
            break





### FIXED CODE ###

def main():

    import sys
    import heapq

    N, Q = map(int, sys.stdin.readline().split())
    events = []

    for i in range(N):
        s, t, x = map(int, sys.stdin.readline().split())
        events.append((s - x, 1, x))  # 通行止め追加
        events.append((t - x, -1, x))  # 通行止め削除

    for i in range(Q):
        d = int(input())
        events.append((d, 2, 0))

    events.sort()
    events.append([float('inf'), 'guard', None])

    i = 0
    closing = set()
    hq = []  # 最小値を高速に入手するため
    while d >= events[i][0]:
        time, event, x = events[i]
        if event == 1:
            closing.add(x)
            heapq.heappush(hq, x)

        elif event == -1:
            closing.remove(x)

        else:
            while hq and (hq[0] not in closing):
                heapq.heappop(hq)

            if hq:
                print(hq[0])
            else:
                print(-1)

        i += 1


if __name__ == '__main__':
    main()
import math
def lcm(a, b):
    return a // math.gcd(a, b) * b
n = int(input())
ans = 1
for i in range(n):
    ans = lcm(ans, int(input()))
print(ans)


### FIXED CODE ###

def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a // gcd(a, b) * b

n = int(input())
ans = 1
for i in range(n):
    ans = lcm(ans, int(input()))
print(ans)
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import collections
N,M = [int(x) for x in input().split()]
idls =[]
for i in range(N):
    idls.append(i+1)
ans =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    iidls = idls[L-1:R]
    ans+=iidls
c= collections.Counter(ans)

a = c.most_common()

counter = 0
count = 0
while True:
    if a[counter][1] == M:
        count+=1
        counter +=1
        if counter == N:
            break
    else:
        break

print(count)







### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
Llist =[]
Rlist =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    Llist.append(L)
    Rlist.append(R)
 
lmax = max(Llist)
Rmax = min(Rlist)

if lmax > Rmax:
    print(0)
else:
    print(Rmax-lmax+1)
X, Y = map(int, input().split())

add = 0
flug =0

for i in range(X):
    add = i*4 + (X-i)*2
    if add == Y:
        print('Yes')
        flag = 1
        break

if flag == 0:
    print('No')

### FIXED CODE ###

X, Y = map(int, input().split())

add = 0
flag =0

for i in range(X+1):
    add = i*4 + (X-i)*2
    if add == Y:
        print('Yes')
        flag = 1
        break

if flag == 0:
    print('No')
a=input().strip().splt(" ")

b=[int(i) for i in a]

if(b[1]-b[0]==b[2]-b[1]):
    print("YES")
else:
    print("NO")


### FIXED CODE ###

a=input().strip().split(" ")

b=[int(i) for i in a]

if(b[1]-b[0]==b[2]-b[1]):
    print("YES")
else:
    print("NO")
N, M, K = map(int, input().split())
a_books = list(map(int, input().split()))
b_books = list(map(int, input().split()))
a_time = 0
b_time = 0
a_times = [0 for _ in range(N+1)]
b_times = [0 for _ in range(M+1)]
for i, a in enumerate(a_books):
  a_time += a
  a_times[i+1] = a_time
  
for i, b in enumerate(b_books):
  b_time += b
  b_times[i+1] = b_time
  
result = 0
l = 0
for i in range(N+1):
  if l == M:
    break
  while(True):
    if a_times[N-i] + b_times[l] <= K:
      result = max(result, N-i+l)
      l += 1
    else:
      break
print(result)

### FIXED CODE ###

N, M, K = map(int, input().split())
a_books = list(map(int, input().split()))
b_books = list(map(int, input().split()))
a_time = 0
b_time = 0
a_times = [0 for _ in range(N+1)]
b_times = [0 for _ in range(M+1)]
for i, a in enumerate(a_books):
  a_time += a
  a_times[i+1] = a_time
  
for i, b in enumerate(b_books):
  b_time += b
  b_times[i+1] = b_time
  
result = 0
l = 0
for i in range(N+1):
  if l == M:
    break
  while(l <= M):
    if a_times[N-i] + b_times[l] <= K:
      result = max(result, N-i+l)
      l += 1
    else:
      break
print(result)
N,M=map(int,input().split())
d=[[] for i in range(N)]
for i in range(M):
    x,y=map(int,input().split())
    d[x-1].append(y-1)
scores=[]
def depth(now,score):
    global scores
    if d[now]:
        for i in d[now]:
            depth(i,score+1)
    else:
        scores.append(score)
Max=0
for i in range(N):
    depth(i,0)
    if scores and max(scores)>Max:
        Max=max(scores)
    scores.clear()
print(Max)

### FIXED CODE ###

S=input()
T=input()
dp=[[0 for j in range(len(T)+1)] for i in range(len(S)+1)]
for i in range(len(S)):
    for j in range(len(T)):
        if S[i]==T[j]:
            dp[i+1][j+1]=dp[i][j]+1
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j])
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1])
i=len(S)
j=len(T)
ans=""
while i>0 and j>0:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ans=S[i-1]+ans
        i-=1
        j-=1
print(ans)
n = input()
change = n[1:]
change = int(change)
print(change)

### FIXED CODE ###

n = int(input())
for i in range(10):
  pay = 1000 * (i+1)
  change = 0
  if pay >= n:
    change = pay - n
    break
print(change)
from sys import stdin
import fractions

n, m = [int(x) for x in stdin.readline().rstrip().split()]
a_list = [int(x) for x in stdin.readline().rstrip().split()]

pick = [ x for x in a_list if x >= sum(a_list) * fractions.Fraction(1, 4 * m )]

print("Yes" if len(pick) > m else "No")

### FIXED CODE ###

from sys import stdin

a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

print('{} {} {}'.format(c, a, b))
# SUN MON TUE WED THU FRI SAT

A = input()

if A == "SUN":
  print(7)
elif A == "MON":
  print(6)
elif A == "TUE":
  prnt(5)
elif A == "WED":
  print(4)
elif A == "THU":
  print(3)
elif A == "FRI":
  print(2)
elif A == "SAT":
  print(1)

### FIXED CODE ###

# SUN MON TUE WED THU FRI SAT

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)
elif A == "SAT":
  print(1)
n=int(input())
a = [0]*(10000)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            if i**2+j**2+k**2 >= n:
                break
            a[i**2+j**2+k**2+i*j+j*k+i*k]+=1
for i in range(1,n+1):
    print(a[i])



### FIXED CODE ###

n=int(input())
a = [0]*(20000)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            if i**2+j**2+k**2 >= n:
                break
            a[i**2+j**2+k**2+i*j+j*k+i*k]+=1
for i in range(1,n+1):
    print(a[i])