Harryxun/stf_run huggingface dataset:
MOD = 10 ** 9 + 7
K = int(input())
M = len(input())
N = M + K

pow25 = [1] * (N + 1)
fac = [1] * (N + 1)
inv = [1] * (N + 1)
for x in range(1, N + 1):
    fac[x] = fac[x - 1] * x % MOD
    pow25[x] = pow25[x - 1] * 25 % MOD
inv[N] = pow(fac[N], MOD-2, MOD)
for x in range(N - 1, -1, -1):
    inv[x] = inv[x + 1] * (x + 1) % MOD

def binom(n, k):
    return fac[n] * inv[n - k] % MOD * inv[k] % MOD

pow25 = [1]

ans = 0
for k in range(M, N + 1):
    ans += binom(N, k) * pow25[N - k] % MOD
    ans %= MOD
print(ans)


### FIXED CODE ###

FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####

def solve(K, S):
    MOD = 10 ** 9 + 7
    N = len(S)
    N2 = N + K

    BIG =N2
    fac = [1, 1]
    for x in xrange(2, BIG+1):
        fac.append(fac[-1] * x  %MOD)
    inv = [1] * (BIG + 1)
    inv[BIG] = pow(fac[-1], MOD-2, MOD)
    for x in xrange(BIG-1, -1, -1):
        inv[x] = inv[x+1] * (x+1) % MOD

    def binom(n, k):
        ans = fac[n]
        ans *= inv[n-k]
        ans %= MOD
        
        ans *= inv[k]
        ans %= MOD
        return ans

    pow25 = [1]
    for x in xrange(1, BIG + 1):
        pow25.append(pow25[-1] * 25  %MOD)

    ans = 0
    for n in xrange(N, N2 + 1):
        ans += binom(N2, n)   * pow25[N2- n] % MOD
        ans %= MOD
    return ans

print solve(rri(), rr())
a,b = input().split()
dis = int(b) - int(a)
cnt = 0
for i in range(dis):
    nm = str(i + a)
    if nm[0] == nm[-1]:
        if nm[1] == nm[-2]:
            cnt += 1

print(cnt)

### FIXED CODE ###

n = input().split()
dis = int(n[1]) - int(n[0])
cnt = 0
for i in range(dis+1):
    nm = str(i + int(n[0]))
    if nm[0] == nm[-1]:
        if nm[1] == nm[-2]:
            cnt += 1

print(cnt)
import sys

input = sys.stdin.readline

N = input().split()

for i in range(3):
    if N[i] == '7':
        print('Yes')
        exit()
print('No')

### FIXED CODE ###

import sys

input = sys.stdin.readline

N = input().strip()

for i in range(3):
    if N[i] == '7':
        print('Yes')
        exit()
print('No')
a,b,x = map(int, input().split())

s = int(x/a)

for i in range(s,-1,-1):
  if a*i+b*len(str(i)) <= x:
    if i >= 10**9:
      print(10**9)
      exit()
    print(i)
    exit()
print(0)

### FIXED CODE ###

week = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1}
s = input()
print(week[s])
h,w,d = map(int, input().split())

a = [[0 for _ in range(w)] for _ in range(h)]
masu = {}
for i in range(h):
    a[i] = list(map(int, input().split())
    for j in range(w):
        masu[a[i][j]] = (i,j)
"""
masu = {}
for i in range(h):
    for j in range(w):
        masu[a[i][j]] = (i,j)
"""
point = [0] * (h*w)
for i in range(1,h*w-d+1):
    point[i] = abs(masu[i][0] - masu[i+d][0]) + abs(masu[i][1] - masu[i+d][1])


q = int(input())
ans = [0] * q
for i in range(q):
    l, r = map(int, input().split())
    if l == r:
        ans[i] = 0
    else:
        ans[i] = sum(point[l:r:d])
 
for i in range(q):
    print(ans[i])


### FIXED CODE ###

h,w,d = map(int, input().split())

a = [[0 for _ in range(w)] for _ in range(h)]
masu = {}
for i in range(h):
    a[i] = list(map(int, input().split()))
    for j in range(w):
        masu[a[i][j]] = (i,j)

point = [0] * (h*w+10)
for i in range(d+1,h*w+1):
    point[i] = point[i-d] + abs(masu[i][0] - masu[i-d][0]) + abs(masu[i][1] - masu[i-d][1])


q = int(input())
ans = [0] * q
for i in range(q):
    l, r = map(int, input().split())
    if l == r:
        ans[i] = 0
    else:
        ans[i] = point[r] - point[l]
 
for i in range(q):
    print(ans[i])
import math
import sys
input = sys.stdin.readline


N,Y = map(int, input().split())
flag=0
for i in range(0,N+1):
    for j in range(0,N-i):
        if(Y-10000*i-5000*j)/1000 == N-i-j :
            a = i
            b = j
            c = N-i-j
            flag =1
            break
        if flag==1:
            break
print(a,b,c)

if flag!=1:
    print("-1 -1 -1")


### FIXED CODE ###

import math
import sys
input = sys.stdin.readline


N,Y = map(int, input().split())
flag=0
for i in range(0,N+1):
    for j in range(0,N+1-i):
        if(Y-10000*i-5000*j)/1000 == N-i-j :
            a = i
            b = j
            c = N-i-j
            flag =1
            break
        if flag==1:
            break

if flag==1:
    print(a,b,c)

if flag!=1:
    print("-1 -1 -1")
a, b = input(), input()
S = a * b
R = 2 * (a+b)
print(S, R)

### FIXED CODE ###

a, b = map(int, raw_input().split())
print(str(a*b) + " " + str(2*(a+b)))
def main():
    n,k = map(int,input().split())
    hts = list(map(int,input().split()))
    
    dp = [float('inf')]*n
    dp[0] = 0
    dp[1] = abs(hts[1]-hts[0])

    for i in range(2,min(k,n)):
        ans = dp[i]
        for j in range(i,0,-1):
            ans = min(ans,dp[i-j]+abs(hts[i]-hts[i-j]))

        dp[i] = ans

    for i in range(k,n):
        ans = dp[i]
        for j in range(k,0,-1):
            ans = min(ans,dp[i-j]+abs(hts[i]-hts[i-j]))

        dp[i] = ans

    #print(dp)

    print(dp[-1])

main()


### FIXED CODE ###

def main():
    n = int(input())
    hts = list(map(int,input().split()))
    if n == 2:
        print(abs(hts[0]-hts[1]))
        return
    
    dp = [0]*n
    dp[0] = 0
    dp[1] = abs(hts[1]-hts[0])
    dp[2] = abs(hts[2]-hts[0])

    for i in range(3,n):
        dp[i] = min(dp[i-1]+abs(hts[i]-hts[i-1]),
                    dp[i-2]+abs(hts[i]-hts[i-2]))

    print(dp[-1])

main()
N = int(input())
A = list(map(int, input().split(' ')))
rect_long = 0
rect_small = 0
while A != []:
    long_max = max(A)
    if A.count(long_max) >= 2:
        rect_long += long_max
        A.remove(long_max)
        A.remove(long_max)
        break
	A.remove(long_max)

while A != []:
    small_max = max(A)
    if A.count(small_max) >= 2:
        rect_small += small_max
        break
    A.remove(small_max)

print(rect_long * rect_small)

### FIXED CODE ###

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

a = sorted(a, reverse=True)

count = 0
edge = []

i = 0
for _ in range(n-1):
    if a[i] == a[i+1]:
        count = count + 1
        edge.append(a[i])
        i = i + 1
        if count == 2:
            break
    i = i + 1

s = edge[0]*edge[1] if count == 2 else 0
print(s)
#!/usr/bin/env python3
import sys
from math import gcd


def solve(A: int, B: int):
    pa = []
    pb = []
    a = A
    b = B
    a = gcd(a,b)

    for x in range(2, int(pow(A, 0.5))+2):
        if a % x == 0:
            pa.append(x)
            while a % x == 0:
                a = a // x
    # print(pa)
    # for x in range(2, int(pow(B, 0.5))+2):
    #     if b % x == 0:
    #         pb.append(x)
    #         while b % x == 0:
    #             b = b // x
    # print(pb)


    print(len(set(pa))+1)
    # print(len(set(pa)&set(pb))+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
# from math import gcd

def gcd(a, b):
    while b: a, b = b, a % b
    return abs(a)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**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([n, 1])

    return arr

# print(factorization(14)) 

def solve(A: int, B: int):
    a = gcd(A,B)
    ap = a
    ct = 0
    x = 2
    if a % x == 0:
        ct+=1
        while a % x == 0:
            a = a // x
    x = 3
    while x*x < ap+1: 
        if a % x == 0:
            ct+=1
            while a % x == 0:
                a = a // x
        x+=2
    # print(pa)
    if a != 1:
        ct +=1
    print(ct+1)
    
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()
H,N = (int(x) for x in input().split())
a = list(map(int,input(),split()))

if sum(a) >= H:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

H,N = (int(x) for x in input().split())
a = list(map(int,input().split()))

if sum(a) >= H:
  print('Yes')
else:
  print('No')
n,k=int(input().split())
a=[]
def x(t,k):
  c=0
  while t<k:
    t*=2
    c+=1
  return c

for i in range(n):
  a.append(x(i+1),k)

ans=0
for i in range(k):
  ans=ans+1/6*(1/2)**k
print(ans)


### FIXED CODE ###

n,k=map(int,input().split())
a=[]
def x(t,k):
  c=0
  while t<k:
    t*=2
    c+=1
  return c

for i in range(n):
  a.append(x(i+1,k))

ans=0
for i in range(n):
  ans=ans+1/n*(1/2)**a[i]
print(ans)
a = input()
b = ""
if a == "SAT"
    b = 1
if a == "SUN"
    b = 7
if a == "MON"
    b = 6
if a == "TUE"
    b = 5
if a == "WED"
    b = 4
if a == "THU"
    b = 3
if a == "FRI"
    b = 2
return b

### FIXED CODE ###

a = input()
b = 0
if a == "SAT":
    b = 1
if a == "SUN":
    b = 7
if a == "MON":
    b = 6
if a == "TUE":
    b = 5
if a == "WED":
    b = 4
if a == "THU":
    b = 3
if a == "FRI":
    b = 2
print(b)
n=int(input())
a=[int(input()) for _ in range(n)]
print(a[0] if len(a)==1 else max(a)-min(a))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
print(max(a)-min(a))
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N = I()
T, A = LI()
H = LI()

new_H = sorted(H)
new_H = [T - i*0.006 for i in H]
#  print(new_H)
#  print(bisect.bisect_left(new_H, A))
idx = bisect.bisect_left(new_H, A)
if idx == len(new_H):
    print(len(H)-1)
    exit()
print(H.index(new_H[idx]))


### FIXED CODE ###

import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


N = I()
T, A = LI()
H = LI()

result = 10**18
result_idx = 0
for idx, h in enumerate(H):
    height = T - h * 0.006
    if abs(A - height) < result:
        result = abs(A - height)
        result_idx = idx + 1

print(result_idx)
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C, OrderedDict as od
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(" ".join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


@lru_cache(maxsize=None)
def recur(index=0):
    if index == n-1:
        return 0
    cost = inf
    cost = min(cost, recur(index+1) + abs(arr[index+1]-arr[index]))
    if index + 2 < n:
        cost = min(cost, recur(index+2) + abs(arr[index+2]-arr[index]))
    return cost


n = int(data())
arr = l()
out(recur())


### FIXED CODE ###

import sys
# from functools import lru_cache, cmp_to_key
# from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest
# from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
# from itertools import combinations as comb, permutations as perm
# from bisect import bisect_left as bl, bisect_right as br, bisect
# from time import perf_counter
# from fractions import Fraction
# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(" ".join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


n = int(data())
arr = l()
dp = dd(lambda: mod)
dp[n-1] = 0
for i in range(n-2, -1, -1):
    dp[i] = min(dp[i], dp[i+1] + abs(arr[i+1]-arr[i]))
    if i != n-2:
        dp[i] = min(dp[i], dp[i+2] + abs(arr[i+2]-arr[i]))
print(dp[0])
import numpy as np
w,h,n = map(int,input().split())
d = np.zeros(w-1,h-1)
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        d[:w] = 1
    elif a == 2:
        d[w:] = 1
    elif a ==3:
        d[:,:h] = 1
    else:
        d[:,h:] = 1
print(np.count_nonzero(d==0))

### FIXED CODE ###

w,h,n = map(int,input().split())
d = [0,w,0,h]
for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1 :
        d[0] = max(d[0],x)
    elif a == 2:
        d[1] = min(d[1],x)
    elif a == 3:
        d[2] = max(d[2],y)
    else:
        d[3] = min(d[3],y)
print(max(0,(d[1]-d[0]))*max(0,(d[3]-d[2])))
S = input()
num = [0]*len(S)
for i in range(len(S)):
  if S[i] == "R":
    for j in range(i+1,len(S)):
      if S[j] =="L":
        Lindex = j
        break
    if (Lindex-i)%2==1:
      num[Lindex-1] += 1
    else:
      num[Lindex] += 1
  else:
    for j in range(i-1,0,-1):
      if S[j] =="R":
        Rindex = j
        break
    if (Rindex-i)%2==1:
      num[Rindex+1] += 1
    else:
      num[Rindex] += 1

print(*num)

### FIXED CODE ###

S = input()

Lindex = S.index("L")
Rindex = 0

num = [0]*len(S)

for i in range(len(S)):
  if S[i] == "R":
    Rindex = i
    if Lindex < i: Lindex = i+ S[i:].index("L")
    if (Lindex-i)%2==1:
      num[Lindex-1] += 1
    else:
      num[Lindex] += 1
  else:
    if (Rindex-i)%2==1:
      num[Rindex+1] += 1
    else:
      num[Rindex] += 1
print(*num)
S, W = map(int, intput().split())

if S <= W:
  print('unsafe')
else:
  print('safe')

### FIXED CODE ###

S, W = map(int, input().split())
 
if S <= W:
  print('unsafe')
else:
  print('safe')
A, B, K = [int(i) for i in input().split()]
ra = list(range(A, B+1))
for i in ra:
    if i < A + K or B - K < i:
        print(i)



### FIXED CODE ###

A, B, K = map(int, input().split())
if B - A < 2 * K:
    print(*range(A, B + 1), sep="\n")
else:
    print(*range(A, A + K), sep="\n")
    print(*range(B - K + 1,  B + 1), sep="\n")
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = []
c = []
i = 0
while i < k*10:
    m = n - i
    for j in range(i+1):
        c = a[j:j + m]
        if sum(c) != 0:
            b.append(sum(c))
    i += 1
d = sorted(b, reverse=True)
for i in range(k):
    c.append(d[i])

ans = d[0]
for i in range(k):
    if i+1 == len(c):
        break
    ans = ans & c[i+1]
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ave = sum(a) / n
b = 10000000
c = 0
for i in range(n):
    if b > abs(ave - a[i]):
        b = abs(ave - a[i])
        c = i
print(c)
N=int(input())
T=int(input())
A=int(input())
"候補地の標高"
H=[]
for i in range(N):
    H.append(int(input()))


def abs_1(x):
    return abs(A-(T-x*0.006))

abslists=list(map(abs_1,H))
print(abslists.index(min(abslists))+1)

### FIXED CODE ###

n=int(input())
t,a=map(int,input().split())
lists=[abs(a-(t-x*0.006)) for x in map(int,input().split())]
print(lists.index(min(lists))+1)
r = input()
R = 2*3.1415*r
print(R)


### FIXED CODE ###

r = int(input())
R = 2*3.1415*r
print(R)
import sys

n = input()
n= int(n)
ls = input().split()
lsnum = list(map(int,ls))
ma = max(lsnum)

minvalue = 100000000
ans = -1
for num in lsnum:
    if num == ma:
        continue
    value = abs(ma/2-num)
    if minvalue >= value:
        minvalue = value
        ans = [ma, num]
print (ans[0], ans[1])


### FIXED CODE ###

import sys

n = input()
n= int(n)
ls = input().split()
lsnum = list(map(int,ls))
ma = max(lsnum)

minvalue = 10000000000
ans = -1
for num in lsnum:
    if num == ma:
        continue
    value = abs(ma-num*2)
    if minvalue >= value:
        minvalue = value
        ans = [ma, num]
print (ans[0], ans[1])
d=int(input())
if d == 22:
  print('Christmas Eve Eve Eve')
elif d == 23:
  print('Christmas Eve Eve')
elif d == 24:
  print('Christmas Eve')
eilf d == 25:
  print('Christmas')

### FIXED CODE ###

d=int(input())
if d == 22:
  print('Christmas Eve Eve Eve')
elif d == 23:
  print('Christmas Eve Eve')
elif d == 24:
  print('Christmas Eve')
elif d == 25:
  print('Christmas')
n = int(input())
a = list(map(int,input().split()))
a.sorted()

b = a[0]
for i in range(n - 1):
  b = (b + a[i + 1]) / 2

print(b)

### FIXED CODE ###

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

b = a[0]
for i in range(n - 1):
  b = (b + a[i + 1]) / 2

print(b)
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

manzoku=0;

for i in range(len(A)):
	manzoku+=B[A[i]-1]
	if i+1<n and A[i+1]-A[i]==1 :
		manzoku+=C[A[i]-1]
print(manzoku)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum =0;
for i in range(len(a)):
    sum += b[a[i]-1]
    if i +1 < n and a[i+1] - a[i] == 1:
        sum += c[a[i]-1]
print(sum)
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,k=MI()
    aa=LI()
    cs=[0]*(n+1)
    s=0
    for i,a in enumerate(aa,1):
        s+=a
        cs[i]=(s-i)%k
    #print(cs)
    cnt=[0]*k
    for a in cs[:k]:
        cnt[a]+=1
    ans=0
    for l,a in enumerate(cs):
        cnt[a]-=1
        ans+=cnt[a]
        if l+k<=n:cnt[cs[l+k]]+=1
    print(ans)

main()

### FIXED CODE ###

from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n,k=MI()
    aa=LI()
    cs=[0]*(n+1)
    s=0
    for i,a in enumerate(aa,1):
        cs[i]=(cs[i-1]+a-1)%k
    #print(cs)
    cnt=defaultdict(int)
    ans=0
    for i,c in enumerate(cs):
        if i-k>=0:cnt[cs[i-k]]-=1
        ans+=cnt[c]
        cnt[c]+=1
    print(ans)

main()
def main():
    n, m, k = list(map(int, input().split()))
    a_books = list(map(int, input().split()))
    b_books = list(map(int, input().split()))

    sumbooks = sum(a_books) + sum(b_books)
    count = len(a_books) + len(b_books)
    if a_books[0] > k and b_books[0] > k:
        print(0)
        exit()
    elif sumbooks <= k:
        print(len(a_books) + len(b_books))
        exit()

    while sumbooks > k:
        if len(a_books) and a_books[-1] >= b_books[-1]:
            sumbooks -= a_books.pop(-1)
        elif len(b_books) and b_books[-1] >= a_books[-1]:
            sumbooks -= b_books.pop(-1)

        if sumbooks <= k:
            break
        count -= 1
    print(count)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main2():
    n, m, k = list(map(int, input().split()))
    a_books = list(map(int, input().split()))
    b_books = list(map(int, input().split()))

    a, b = [0], [0]
    
    for i in range(len(a_books)):
        a.append(a[i] + a_books[i])

    for i in range(len(b_books)):
        b.append(b[i] + b_books[i])
    ans, j  = 0, len(b_books)
    
    for i in range(len(a)):
        if a[i] > k :
            break
        while b[j] > k - a[i]:
            j -= 1
        ans = max(ans, i+j)
    print(ans)


if __name__ == '__main__':
    main2()
N = int(input())
A = list(map(int,input().split()))
for i in A:
    anser *= i
if 0 in A:
    print(0)
if anser > 10 ** 18:
    print("-1")
else:
    print(anser)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
anser = 1
if 0 in A:
    print("0")
    exit()
for i in A:
    anser *= i
    if anser > 10 ** 18:
        print("-1")
        exit()
print(anser)
n=int(input())
s=[input() for i in range(n)]
d={}
for i in range(n):
  d[s[i]] = d.get(s[i],0) + 1

max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
max_k_list.sort()
print(*max_k_list)

### FIXED CODE ###

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

if a==b and b==c: print('No')
elif a==b or b==c or c==a: print('Yes')
else: print('No')
n = []
n[0] = int(input())
n[1] = int(input())
n[2] = int(input())
n[3] = int(input())
n[4] = int(input())

minNum = 10
array = 0
for i in range(len(n)):
	num = n[i] % 10
	if(num <= minNum):
		minNum = num
		array = i

arraySum = []
for j in n:
	k = ((j + 9) // 10) * 10
	arraySum.append(k)
	
print(sum(arraySum) + n[array])


### FIXED CODE ###

n =  [int(input()) for x in range(5)]
minNum = 10
array = 0
for i in range(len(n)):
    num = n[i] % 10
    if((num <= minNum) and (num != 0)):
        minNum = num
        array = i
        
numList = []
a = n[array]
n[array] = 0

for x in n:
    k = ((x + 9) // 10) * 10
    numList.append(k)  
print(sum(numList) + a)