Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = int(input())

words = list(map(lambda word: input(), range(N)))

letter_lists = []
for word in words:
  letters = list(map(lambda word: word, word))
  letters.sort()
  letter_lists.append(letters)

count = 0
for i in range(N-1):
  for j in range(i+1,N):
    if letter_lists[i] == letter_lists[j]:
      count+=1 

print(count)

### FIXED CODE ###

N = int(input())

d_word={}
count=0

for _ in range(N):
  word = "".join(sorted(input()))
  if word not in d_word:
    d_word[word]=0
  else:
    d_word[word]+=1
    count+=d_word[word]

print(count)
### BUGGY CODE ###

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

counts = [0] * 60
for a in A:
    for i in range(60):
        counts[i] += (a >> i) % 2

ans = sum(c * (N - c) * (2 ** i % MOD) % MOD for i, c in enumerate(counts))

print(ans % MOD)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

counts = [sum((a >> i) & 1 for a in A) for i in range(60)]

power2 = [1]
for _ in range(59):
    power2.append((power2[-1] * 2) % MOD)

ans = sum(c * (N - c) * power2[i] for i, c in enumerate(counts))

print(ans % MOD)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def pri(tbl, tbl2, tbl3, tbl4, n, m):
	for i in range(n):
		for j in range(m):
			print("{:2}".format(tbl[i][j]+tbl2[i][j]+tbl3[i][j]+tbl4[i][j]), end='')
		print('')
	print('')

def main():
	n, m = map(int, input().strip().split())
	v = []
	for i in range(n):
		v.append(input().strip())
	tbl = [[0] * m for _ in range(n)]
	tbl2 = [[0] * m for _ in range(n)]
	tbl3 = [[0] * m for _ in range(n)]
	tbl4 = [[0] * m for _ in range(n)]
	for i in range(n):
		for j in range(m):
			if v[i][j] == '#':
				tbl[i][j] = -1
			elif j == 0:
				continue
			else:
				tbl[i][j] = tbl[i][j-1] + 1
	# pri(tbl, tbl2, tbl3, tbl4, n, m)
	for i in range(n):
		for j in range(m-1, -1, -1):
			if v[i][j] == '#':
				tbl2[i][j] = -1
			elif j == m-1:
				continue
			else:
				tbl2[i][j] = tbl2[i][j+1] + 1
	# pri(tbl, tbl2, tbl3, tbl4, n, m)

	
	for j in range(m):
		for i in range(n):
			if v[i][j] == '#':
				tbl3[i][j] = -1
			elif i == 0:
				continue
			else:
				tbl3[i][j] = tbl3[i-1][j] + 1
	for j in range(m):
		for i in range(n-1, -1, -1):
			if v[i][j] == '#':
				tbl4[i][j] = -1
			elif i == n-1:
				continue
			else:
				tbl4[i][j] = tbl4[i+1][j] + 1
	# for i in range(n):
	# 	print(tbl[i])
	# pri(tbl, tbl2, tbl3, tbl4, n, m)
	ans = 0
	for i in range(n):
		for j in range(m):
			ans = max(ans, tbl[i][j]+tbl2[i][j]+tbl3[i][j]+tbl4[i][j])
	print(ans+1)

if __name__ == '__main__':
	main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def pri(tbl, tbl2, tbl3, tbl4, n, m):
	for i in range(n):
		for j in range(m):
			print("{:2}".format(tbl[i][j]+tbl2[i][j]+tbl3[i][j]+tbl4[i][j]), end='')
		print('')
	print('')

def main():
	n, m = map(int, input().strip().split())
	v = []
	for i in range(n):
		v.append(input().strip())
	tbl = [[0] * m for _ in range(n)]
	tbl2 = [[0] * m for _ in range(n)]
	tbl3 = [[0] * m for _ in range(n)]
	tbl4 = [[0] * m for _ in range(n)]
	for i in range(n):
		for j in range(m):
			if v[i][j] == '#':
				tbl[i][j] = -1
			elif j == 0:
				continue
			else:
				tbl[i][j] = tbl[i][j-1] + 1
	# pri(tbl, tbl2, tbl3, tbl4, n, m)
	for i in range(n):
		for j in range(m-1, -1, -1):
			if v[i][j] == '#':
				tbl2[i][j] = -1
			elif j == m-1:
				continue
			else:
				tbl2[i][j] = tbl2[i][j+1] + 1
	# pri(tbl, tbl2, tbl3, tbl4, n, m)

	
	for j in range(m):
		for i in range(n):
			if v[i][j] == '#':
				tbl3[i][j] = -1
			elif i == 0:
				continue
			else:
				tbl3[i][j] = tbl3[i-1][j] + 1
	for j in range(m):
		for i in range(n-1, -1, -1):
			if v[i][j] == '#':
				tbl4[i][j] = -1
			elif i == n-1:
				continue
			else:
				tbl4[i][j] = tbl4[i+1][j] + 1
	# for i in range(n):
	# 	print(tbl[i])
	# pri(tbl, tbl2, tbl3, tbl4, n, m)
	ans = 0
	for i in range(n):
		for j in range(m):
			ans = max(ans, tbl[i][j]+tbl2[i][j]+tbl3[i][j]+tbl4[i][j])
	print(ans+1)

if __name__ == '__main__':
	main()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
def main():
    S = list(input())
    check = 0
    cnt = 0
    i = 0
    while(check == 0) :
        check = 1
        for i in range(len(S)-1):
            if S[i] == 'B' and S[i+1] == 'W':
                S[i], S[i+1] = 'W', 'B'
                cnt += 1
                check = 0
                break
    print(cnt)
                
if __name__ == '__main__':
    main()

### FIXED CODE ###

# -*- coding: utf-8 -*-
def main():
    S = list(input())
    Bcnt = 0
    ans = 0
    for i in range(len(S)):
        if S[i] == 'B':
            Bcnt += 1
        else:
            ans += Bcnt
    print(ans)
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import math
import copy
import collections
def calc_combi2(n):
    if n<=1:
        return 0
    return math.factorial(n)/(math.factorial(n-2)*math.factorial(2))
n=int(input())
data=list(map(int,input().split()))
for i in range(n):
    count=0
    cp=copy.copy(data)
    cp.pop(i)
    cp_cnt=collections.Counter(cp)
    for j in cp_cnt.values():
        count+=int(calc_combi2(j))
    print(count)
    

### FIXED CODE ###

import math
import collections
def calc_combi2(n):
    if n<=1:
        return 0
    return math.factorial(n)/(math.factorial(n-2)*math.factorial(2))
n=int(input())
data=list(map(int,input().split()))
data_cnt=collections.Counter(data)
count=0
for i in data_cnt.values():
    count+=calc_combi2(i)
for i in data:
    ans=count-data_cnt[i]+1
    print(int(ans))
### BUGGY CODE ###

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

M = 10**9+7

def pow(a,b,M):
    if b == 0:
        return 1
    elif b % 2 == 0:
        return pow((a**2)%M,b//2,M) % M
    else:
        return ((a % M) * pow((a**2)%M,b//2,M)) % M

def inv(a,p):
    return pow(a,p-2,p)

def comb(n,k,M):
    nume,deno = 1,1
    for i in range(1,k+1):
        nume = (nume * (n - i + 1)) % M
        deno = (deno * i) % M
    return (nume * inv(deno,M)) % M

ans = 0
for i in range(N-K+1):
    ans = (ans + comb(N-1-i,K-1,M)*((A[N-1-i]-A[i]) % M)) % M
print(ans)


### FIXED CODE ###

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

M = 10**9+7

def pow(a,b,M):
    if b == 0:
        return 1
    elif b % 2 == 0:
        return pow((a**2)%M,b//2,M) % M
    else:
        return ((a % M) * pow((a**2)%M,b//2,M)) % M

def inv(a,p):
    return pow(a,p-2,p)

ans,comb = 0,1
#i番目ではcomb = (K-1-i)_C_(K-1)
#max,min以外での選ぶ個数は常にK-1であることに注目すればcomb関数はいらなかった
for i in range(N-K+1):
    if i > 0:
        comb = (comb * (K-1+i) * inv(i,M)) % M
    ans = (ans + comb*((A[K-1+i]-A[N-K-i]) % M)) % M
print(ans)
### BUGGY CODE ###

import collections
import sys
input=sys.stdin.readline

class BIT:
  def __init__(self,n):
    self.n=n+1
    self.BIT=[0]*self.n
  def add(self,i,x):
    idx=i
    while idx<self.n:
      self.BIT[idx]+=x
      idx+=(idx&-idx)
  def _sum(self,i):
    ret=0
    idx=i
    while idx>0:
      ret+=self.BIT[idx]
      idx-=(idx&-idx)
    return ret
  def sum(self,l,r):
    return self._sum(r)-self._sum(l-1)
  def value(self,i):
    return self._sum(i)-self._sum(i-1)

n,q=map(int,input().split())
arr=list(map(int,input().split()))
query=[]
for i in range(q):
  l,r=map(int,input().split())
  query.append((l,r,i))
query=sorted(query,key=lambda x:x[0])
ans=[0]*q
bit=BIT(n)
pos_now=[-1]*(n+1)
pos_all=[[] for _ in range(n+1)]
for i in range(n):
  val=arr[i]
  if pos_now[val]==-1:
    bit.add(i+1,1)
    pos_now[val]=0
  pos_all[val].append(i+1)
for i in range(n+1):
  pos_all[i].append(-1)
cnt=collections.Counter(arr)
prev=1
for l,r,id in query:
  while prev<l:
    val=arr[prev-1]
    if pos_all[val][pos_now[val]+1]!=-1:
      pos_now[val]+=1
      bit.add(pos_all[val][pos_now[val]],1)
    prev+=1
  ans[id]=bit.sum(l,r)
for val in ans:
  print(val)

### FIXED CODE ###

import sys
input=sys.stdin.readline

class BIT:
  def __init__(self,n):
    self.n=n+1
    self.BIT=[0]*self.n
  def add(self,i,x):
    idx=i
    while idx<self.n:
      self.BIT[idx]+=x
      idx+=(idx&-idx)
  def _sum(self,i):
    ret=0
    idx=i
    while idx>0:
      ret+=self.BIT[idx]
      idx-=(idx&-idx)
    return ret
  def sum(self,l,r):
    return self._sum(r)-self._sum(l-1)
  def value(self,i):
    return self._sum(i)-self._sum(i-1)

n,q=map(int,input().split())
arr=list(map(int,input().split()))
query=[]
for i in range(q):
  l,r=map(int,input().split())
  query.append((l,r,i))
query=sorted(query,key=lambda x:x[0])
ans=[0]*q
bit=BIT(n)
pos_now=[-1]*(n+1)
pos_prev=[-1]*(n+1)
dic={}
for i in range(n):
  val=arr[i]
  dic[i+1]=-1
  if pos_now[val]==-1:
    bit.add(i+1,1)
    pos_now[val]=i+1
  if pos_prev[val]!=-1:
    dic[pos_prev[val]]=i+1
  pos_prev[val]=i+1
prev=1
for l,r,id in query:
  while prev<l:
    val=arr[prev-1]
    if dic[pos_now[val]]!=-1:
      pos_now[val]=dic[pos_now[val]]
      bit.add(pos_now[val],1)
    prev+=1
  ans[id]=bit.sum(l,r)
for val in ans:
  print(val)
### BUGGY CODE ###

from math import gcd
N=int(input())
A=list(map(int,input().split()))
l=[0]*1000001
pr=[]
for i in range(2,1000001):
    if l[i]:
        continue
    pr.append(i)
    for j in range(i**2,1000001,i):
        l[j]=1
lp=len(pr)
l=[0]*lp
g=gcd(A[0],A[1])
for i in A:
    g=gcd(g,i)
if g>1:
    print("not coprime")
    exit()
for i in A:
    t=i
    for j in range(lp):
        pj=pr[j]
        if pj>t:
            break
        if t%pj==0:
            if l[j]:
                print("setwise coprime")
                exit()
            l[j]=1
            while 1:
                t//=pj
                if t%pj:
                    break
print("pairwise coprime")

### FIXED CODE ###

from math import gcd
N=int(input())
A=list(map(int,input().split()))
g=gcd(A[0],A[1])
for i in A:
    g=gcd(g,i)
if g>1:
    print("not coprime")
    exit()
l=[0]*1000001
for i in A:
    l[i]+=1
for i in range(2,1000000):
    c=0
    for j in range(i,1000001,i):
        c+=l[j]
    if c>1:
        print("setwise coprime")
        break
else:
    print("pairwise coprime")
### BUGGY CODE ###

s = input()

count = 0

oi1000 = "0"*1000 + "1"*1000
io1000 = "1"*1000 + "0"*1000

while oi1000 in s or io1000 in s:
    while oi1000 in s:
        s = s.replace(oi1000, "", 1)
        count += 1000
    while io1000 in s:
        s = s.replace(io1000, "", 1)
        count += 1000

oi100 = "0"*100 + "1"*100
io100 = "1"*100 + "0"*100

while oi100 in s or io100 in s:
    while oi100 in s:
        s = s.replace(oi100, "", 1)
        count += 100
    while io100 in s:
        s = s.replace(io100, "", 1)
        count += 100

oi10 = "0"*10 + "1"*10
io10 = "1"*10 + "0"*10

while oi10 in s or io10 in s:
    while oi10 in s:
        s = s.replace(oi10, "", 1)
        count += 10
    while io10 in s:
        s = s.replace(io10, "", 1)
        count += 10

while "01" in s or "10" in s:
    while "01" in s:
        num = s.count("01")
        s = s.replace("01", "")
        count += num
    while "10" in s:
        num = s.count("10")
        s = s.replace("10", "")
        count += num

print(count * 2)


### FIXED CODE ###

s = input().rstrip()
a = s.count("0")
b = s.count("1")
print(min(a,b)*2)
### BUGGY CODE ###


N = int(input())
A = list(map(int, input().split()))
A = [[a,i] for a,i in zip(A,range(N))]
A = sorted(A,reverse=True)

dp = [[0]*(N+1) for _ in range(N+1)]
ans = 0

for n in range(0,N+1):
    for y in range(0,n+1):
        x = n-y
        a = A[n-1]
        ind = a[1]
        if x==0 and y==0:
            dp[x][y] = 0
        elif x==0:
            dp[x][y] = dp[x][y-1] + a[0]*abs(ind-((N-1)-(y-1)))
        elif y==0:
            dp[x][y] = dp[x-1][y]+a[0]*abs(ind-(x-1))
        else:
            dp[x][y] = max(dp[x-1][y]+a[0]*abs(ind-(x-1)),dp[x][y-1] + a[0]*abs(ind-((N-1)-(y-1))))
        ans = max(ans,dp[x][y])

print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A = [[a,i] for a,i in zip(A,range(N))]
A = sorted(A,reverse=True)

dp = [[0]*(N+1) for _ in range(N+1)]
ans = 0

for n in range(0,N+1):
    for y in range(0,n+1):
        x = n-y
        a = A[n-1]
        ind = a[1]
        if x==0 and y==0:
            dp[x][y] = 0
        elif x==0:
            dp[x][y] = dp[x][y-1] + a[0]*abs(ind-((N-1)-(y-1)))
        elif y==0:
            dp[x][y] = dp[x-1][y]+a[0]*abs(ind-(x-1))
        else:
            dp[x][y] = max(dp[x-1][y]+a[0]*abs(ind-(x-1)),dp[x][y-1] + a[0]*abs(ind-((N-1)-(y-1))))
        ans = max(ans,dp[x][y])

print(ans)
### BUGGY CODE ###

n=int(input())
ans=1
s=list(map(int,input().split()))
for i in range(1,n+1):
    print(s.index(i)+1,end=" ")

### FIXED CODE ###

import numpy as np
n=int(input())
s=list(map(int,input().split()))
x=np.argsort(s)
print(*x+1)
### BUGGY CODE ###

#coding: utf-8
import math
import heapq
import bisect
#from scipy.misc import comb

MOD = 10**9+7

H,W = map(int, input().split())

Map = []
for i in range(H):
    s = input()
    Map.append(s)

L = [[0]*W for _ in range(H)]
for i in range(H):
    cnt = 0
    for j in range(W):
        if Map[i][j]=="#":
           L[i][j] = -1
           cnt = 0
        else:
            L[i][j] = cnt
            cnt += 1

R = [[0]*W for _ in range(H)]
for i in range(H):
    cnt = 0
    for j in reversed(range(W)):
        if Map[i][j]=="#":
           R[i][j] = -1
           cnt = 0
        else:
            R[i][j] = cnt
            cnt += 1

U = [[0]*W for _ in range(H)]
for j in range(W):
    cnt = 0
    for i in range(H):
        if Map[i][j]=="#":
           U[i][j] = -1
           cnt = 0
        else:
            U[i][j] = cnt
            cnt += 1

D = [[0]*W for _ in range(H)]
for j in range(W):
    cnt = 0
    for i in reversed(range(H)):
        if Map[i][j]=="#":
           D[i][j] = -1
           cnt = 0
        else:
            D[i][j] = cnt
            cnt += 1

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]+1)

print(ans)

### FIXED CODE ###

#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

MOD = 10**9+7

H,W = map(int, input().split())
M = np.array([list(input().rstrip("\n")) for _ in range(H)]) == "."

D = np.zeros((H,W),dtype=int)
U = np.zeros((H,W),dtype=int)
L = np.zeros((H,W),dtype=int)
R = np.zeros((H,W),dtype=int)

for i in range(H):
    U[i] = (U[i-1] + 1) * M[i]
    D[-i-1] = (D[-i] + 1) * M[-i-1]

for i in range(W):
    L[:,i] = (L[:,i-1] + 1) * M[:,i]
    R[:,-i-1] = (R[:,-i] + 1) * M[:,-i-1]

print(np.max(U+D+L+R)-3)
### BUGGY CODE ###

s=input().split("01")
a=len(s)-1
t="".join(s)
while True:
  s=t.split("01")
  if len(s)==1:
    while True:
      s=t.split("10")
      if len(s)==1:
        break
      a+=len(s)-1
      t="".join(s)
    break
  a+=len(s)-1
  t="".join(s)
print(2*a)


### FIXED CODE ###

s=input()
a=s.count("0")
b=len(s)-a
if a>=b:
  print(2*b)
else:
  print(2*a)
### BUGGY CODE ###

import heapq
import math

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

for i in range(N):
    p = A[i]
    A[i] = [-p, i]

heapq.heapify(A)
C = [0]*N
for j in range(K):
    x, y = heapq.heappop(A)
    cnt = C[y]
    x = x * (cnt+1) / (cnt+2)
    C[y] += 1
    heapq.heappush(A, [x, y])

ans = heapq.heappop(A)[0]

ans = math.ceil(-ans)

print(ans)




### FIXED CODE ###

import heapq
import math
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    def C(m):
        cnt = 0
        for i in range(N):
            cnt += math.ceil(A[i]/m)-1
        return cnt

    l, r = 0, max(A)
    while r - l > 1:
        mid = (l+r)//2
        if C(mid) <= K:
            r = mid
        else:
            l = mid
    
    print(r)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

N,K = map(int,input().split())
X_all = list(map(int,input().split()))
m = float("inf")
for i in range(N-K+1):
    X = X_all[i:i+K]
    if X[0] > 0:
        d = X[-1]
    elif X[-1] < 0:
        d = -X[0]
    else:
        d = X[-1]-X[0]+min(-X[0],X[-1])
    m = min(m,d)
print(m)

### FIXED CODE ###

N,K = map(int,input().split())
X = list(map(int,input().split()))
m = 2*(abs(X[-1])+abs(X[0]))
for i in range(N-K+1):
    if X[i] > 0:
        d = X[i+K-1]
    elif X[i+K-1] < 0:
        d = -X[i]
    else:
        d = X[i+K-1]-X[i]+min(-X[i],X[i+K-1])
    m = min(m,d)
print(m)
### BUGGY CODE ###

(N, K) = map(lambda a: int(a), input().split())
A = list(map(lambda a: int(a), input().split()))

def proc():
    global A
    B = [0 for _ in range(N)]

    for i in range(0,N):
        f = max(0, i - A[i])
        t = min(N-1, i + A[i])
        #for j in range(max(0, f), min(N, t)+1):
        #    B[j] += 1
        B[f] += 1
        if t+1 < N:
            B[t+1] -= 1
    for i in range(1,N):
        B[i] += B[i-1]
    A = B

for _ in range(0, K):
    proc()

print(" ".join(map(lambda a: str(a), A)))

### FIXED CODE ###

import numpy as np
from numba import njit

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

@njit
def solve(N,K,A):
    for j in range(0, K):
        B = np.zeros(N, dtype=np.int64)

        for i in range(0,N):
            f = max(0, i - A[i])
            t = min(N-1, i + A[i])
            #for j in range(max(0, f), min(N, t)+1):
            #    B[j] += 1
            B[f] += 1
            if t+1 < N:
                B[t+1] -= 1
        A = np.cumsum(B)
        if np.all(A == N):
            return A
        i += 1
    return A
    

print(" ".join(map(str, solve(N,K,A))))
### BUGGY CODE ###


# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines

#n = int(input())
h,w = [int(i) for i in readline().split()]

a = [[int(i) for i in readline().split()] for _ in range(h)]
b = [[int(i) for i in readline().split()] for _ in range(h)]


dp = [set() for _ in range(w)]
dp[0] = set([0])

#print(dp)
for i in range(h):
    ndp = [set() for _ in range(w)]
    for j in range(w):
        v = a[i][j] - b[i][j]
        #print(v)
        for c in dp[j]: 
            ndp[j].add(c+v)
            ndp[j].add(c-v)
        if j:
            for c in ndp[j-1]:
                ndp[j].add(c+v)
                ndp[j].add(c-v)

    dp = ndp
    #print(dp)
    

print(min(map(abs, dp[j])))














### FIXED CODE ###


# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines

#n = int(input())
h,w = [int(i) for i in readline().split()]

a = [[int(i) for i in readline().split()] for _ in range(h)]
b = [[int(i) for i in readline().split()] for _ in range(h)]


dp = [[0] for _ in range(w)]
dp[0][0] = 1

#print(dp)
N = 6401
for i in range(h):
    ndp = [[0]*N for _ in range(w)]
    for j in range(w):
        v = abs(a[i][j] - b[i][j])
        #print(v)
        for ii,c in enumerate(dp[j]):
            if ii+v < N:
                ndp[j][abs(ii+v)] |= c
            ndp[j][abs(ii-v)] |= c
        if j:
            for ii,c in enumerate(ndp[j-1]):
                if ii+v < N:
                    ndp[j][abs(ii+v)] |= c
                ndp[j][abs(ii-v)] |= c

    dp = ndp
    #print(dp)
    
c = [i for i,c in enumerate(dp[j]) if c]

#print(c)
print(min(c))
### BUGGY CODE ###

import itertools
def s(): return input()
def I(): return map(int,input().split())

N,K = I()
S = list(s())
num = 0
cnt = 0
L = []
for i in range(N):
    if i == N-1:
        L.append(N-num)
    if i < num:
        continue
    s = S[i]
    if s == '0':
        cnt += 1
    for j in range(i,N):
        if S[j] != s:
            L.append(j-num)
            num = j
            break
ruiseki = [0]+list(itertools.accumulate(L))
l = len(ruiseki)
if cnt <= K:
    print(N)
    exit()
start = 0
ans = 0
if S[0] == '0':
    start = 1
for i in range(start,l,2):
    if i+K*2+1 > l-1:
        break
    ans = max(ans,ruiseki[i+K*2+1]-ruiseki[i])
if S[0] == '0':
    ans = max(ans,ruiseki[K*2])
if S[-1] == '0':
    ans = max(ans,ruiseki[-1]-ruiseki[l-K*2-1])
print(ans)

### FIXED CODE ###

import itertools
def s(): return input()
def I(): return map(int,input().split())

N,K = I()
S = list(s())
num = 1
cnt = 0
L = []
for i in range(N-1):
    if S[i] != S[i+1]:
        L.append(num)
        num = 0
        if S[i] == '0':
            cnt += 1
    num += 1
L.append(num)
if S[-1] == '0':
    cnt += 1
ruiseki = [0]+list(itertools.accumulate(L))
l = len(ruiseki)
if cnt <= K:
    print(N)
    exit()
start = 0
ans = 0
if S[0] == '0':
    start = 1
for i in range(start,l,2):
    if i+K*2+1 > l-1:
        break
    ans = max(ans,ruiseki[i+K*2+1]-ruiseki[i])
if S[0] == '0':
    ans = max(ans,ruiseki[K*2])
if S[-1] == '0':
    ans = max(ans,ruiseki[-1]-ruiseki[l-K*2-1])
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
h,w = map(int, input().split())
al = [list(input()) for _ in range(h)]
c = [[0]*w for _ in range(h)]

q = []
for hi in range(h):
    for wi in range(w):
        if al[hi][wi]=="#":
            q.append((hi,wi))

while len(q)>0:
    hi,wi = q.pop(0)
    for d in [[1,0],[0,1],[-1,0],[0,-1]]:
        if h>hi+d[0]>=0 and w>wi+d[1]>=0:
            if al[hi+d[0]][wi+d[1]]==".":
                c[hi+d[0]][wi+d[1]] = c[hi][wi]+1
                al[hi+d[0]][wi+d[1]] = "#"
                q.append((hi+d[0], wi+d[1]))

res = -1
for hi in range(h):
    for wi in range(w):
        res = max(res, c[hi][wi])
print(res)


### FIXED CODE ###

# -*- coding: utf-8 -*-
h,w = map(int, input().split())
al = [list(input()) for _ in range(h)]
cnt = 0

q = []
for hi in range(h):
    for wi in range(w):
        if al[hi][wi]=="#":
            q.append((hi,wi))

while len(q)>0:
    nq = []
    cnt += 1
    for hi,wi in q:
        for d in [[1,0],[0,1],[-1,0],[0,-1]]:
            if h>hi+d[0]>=0 and w>wi+d[1]>=0:
                if al[hi+d[0]][wi+d[1]]==".":
                    al[hi+d[0]][wi+d[1]] = "#"
                    nq.append((hi+d[0], wi+d[1]))
    q = nq

print(cnt-1)
### BUGGY CODE ###

from collections import Counter
n = int(input())
a = sorted(Counter(list(map(int, input().split()))).items(), reverse=True)
g = [0]*(n+1)
g[n] = 1
for _, x in a:
  if sum(g) < x:
    print('No')
    break
  t = [0]*(n+1)
  for i in range(n, -1, -1):
    if g[i] <= x:
      t[i-1] = t[i] + g[i]
      x -= g[i]
      g[i] = 0
    else:
      t[i-1] = t[i] + x
      g[i] -= x
      x = 0
  t[n] = 0
  g = [x+y for x,y in zip(g, t)]
else:
  print('Yes')

### FIXED CODE ###

from collections import Counter
n = int(input())
a = sorted(Counter(list(map(int, input().split()))).items(), reverse=True)
g = [0]*(n+1)
g[n] = 1
for _, x in a:
  if sum(g) < x:
    print('No')
    break
  t = [0]*(n+1)
  for i in range(n, -1, -1):
    if g[i] <= x:
      t[i-1] = t[i] + g[i]
      x -= g[i]
      g[i] = 0
    else:
      t[i-1] = t[i] + x
      g[i] -= x
      x = 0
  t[n] = 0
  g = [x+y for x,y in zip(g, t)]
else:
  print('Yes')
### BUGGY CODE ###

from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
m = int(data[0].split()[1])

k = int(data[0].split()[2])

a = [int(s) for s in data[1].split()]
b = [int(s) for s in data[2].split()]

c = [0]
time = 0
for i in range(1,n+m+1):
    for j in range(0,i+1):
        if j <= n and 0 <= i-j <= m:
            if sum(a[0:j])+sum(b[0:i-j]) <= k:
                c.append(i)
print(max(c))

### FIXED CODE ###

from sys import stdin
data = stdin.readlines()

n = int(data[0].split()[0])
m = int(data[0].split()[1])

k = int(data[0].split()[2])

A = [int(s) for s in data[1].split()]
B = [int(s) for s in data[2].split()]

a = [0]
b = [0]

for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    else:
        while a[i]+b[j] > k:
            j -= 1
        ans = max(ans, i+j)
print(ans)