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

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

a = 0
b = 0
ans = 0
for k in range(len(A)):
    a += A[k]
    A[k] = a
for k in range(len(B)):
    b += B[k]
    B[k] = b

AA = [0] + A

BB = [0] + B

for k in range(N+1):
    if AA[k] <= K:
        for j in range(M):
            if  AA[k] + BB[j+1]> K >= AA[k] + BB[j]:
                ans = max(k+j, ans)
                break
            else:
                continue
        if K >= AA[k] + BB[M]:
            ans = max(k+M, ans)
    else:
        break
print(ans)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  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)
### BUGGY CODE ###

def tak_and_cards(N: int, A: int, x: list) -> int:
    count = 0
    for b in range(1, 1 << N):
        n, s = 0, 0
        for i in range(N):
            if (b >> i) & 1 == 0:
                continue
            n += 1
            s += x[i]

        if s == n * A:
            count += 1
    return count


if __name__ == "__main__":
    N, A = map(int, input().split())
    x = [int(s) for s in input().split()]
    ans = tak_and_cards(N, A, x)
    print(ans)


### FIXED CODE ###

def tak_and_cards(N: int, A: int, X: list) -> int:
    #  部分点解法
    # :---------:
    # count = 0
    # for b in range(1, 1 << N):
    #     n, s = 0, 0
    #     for i in range(N):
    #         if (b >> i) & 1 == 0:
    #             continue
    #         n += 1
    #         s += X[i]

    #     if s == n * A:
    #         count += 1
    # return count
    max_X = max(X)
    dp = [[0] * (2 * max_X * N + 1) for _ in range(N + 1)]
    dp[0][max_X * N] = 1

    for k, x in enumerate(X):
        for t in range(2 * max_X * N + 1):
            y = x - A

            dp[k + 1][t] = dp[k][t]
            if 0 <= t - y and t - y <= 2 * max_X * N:
                dp[k + 1][t] += dp[k][t - y]

    return dp[N][max_X*N] - 1


if __name__ == "__main__":
    N, A = map(int, input().split())
    x = [int(s) for s in input().split()]
    ans = tak_and_cards(N, A, x)
    print(ans)
### BUGGY CODE ###

n=int(input())
s=list(map(int,input().split()))
ex=0
va=0
t=[]
for i in s:
    if i in t:
        ex=1-ex
    else:
        t.append(i)
        va+=1

print(va-ex)

### FIXED CODE ###

import collections
n=int(input())
s=list(map(int,input().split()))
k=len(collections.Counter(s))
if (n-k)%2==0:
    print(k)
else:
    print(k-1)
### BUGGY CODE ###

#create date: 2020-04-26 21:06

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    n = len(s)
    now = 0
    m = [0] * 2019
    for i, si in zip(range(n), s[::-1]):
        now = (now + int(si) * (10**i)) % 2019
        #print(now)
        m[now] += 1
    ans = m[0]
    for mi in m[1:]:
        ans += (mi-1) * mi //2
    print(ans)

    
if __name__ == "__main__":
    main()

### FIXED CODE ###

#create date: 2020-04-26 21:06

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    n = len(s)
    now = 0
    m = [0] * 2019
    for i in range(n):
        now = (now + int(s[n-i-1]) * pow(10, i, 2019)) % 2019
        #print(now)
        m[now] += 1
    m[0] += 1
    ans = 0
    for mi in m:
        ans += (mi-1) * mi //2
    print(ans)

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

import numpy as np
import sys
if __name__ == "__main__":
    X = int(input())
    # n = 1
    # while True:
    #     if n**5 - (n-1)**5 > X:
    #         print(n)
    #         break # x=10^9 で n=120
    #     n += 1
    
    n = 1
    while True:
        i = 0
        while True:
            #print("{} {}".format(int(n), int(i)))
            sign = np.sign(n**5 - i**5 - X)
            #print(sign)
            if sign == 0:
                print("{} {}".format(int(n), int(i)))
                sys.exit()
            elif sign < 0:
                i -= 1
            else:
                i += 1
            #print(i)
            if i <= -n or n-1 <= i:
                break
        n += 1

### FIXED CODE ###

import numpy as np
import sys

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

if __name__ == "__main__":
    X = int(input())
    divs = make_divisors(X)
    #print(divs)
    a = 0
    while True:
        for d in divs:
            b_p = 0
            b_n = 0
            while True:
                b_p += d
                b_n -= d
                #print(b_p)
                if a**5 - b_p**5 == X:
                    #print(a)
                    #print(b_p)
                    print(a,b_p)
                    #print("{} {}".format(int(a), int(b_p)))
                    sys.exit()
                if a**5 - b_n**5 == X:
                    #print("{} {}".format(int(a), int(b_n)))
                    print(a,b_n)
                    sys.exit()
                if b_p > a:
                    #print('break')
                    break
        a += 1
### BUGGY CODE ###

n = int(input())
Data = list(map(int,input().split()))
Ans = []
for d in Data:
    Ans.append(d)
    Ans.reverse()
for a in Ans:
    print(a, end=' ')


### FIXED CODE ###

n = int(input())
m = n // 2
Data = list(map(int,input().split()))
Ans = []
if n % 2 == 0:
    for i in range(m):
        Ans.append(Data[n-1-i*2])
    for i in range(m):
        Ans.append(Data[2*i])
else:
    for i in range(m+1):
        Ans.append(Data[n-1-i*2])
    for i in range(m):
        Ans.append(Data[2*i+1])

for a in Ans:
    print(a,end=' ')
### BUGGY CODE ###

import copy

S = input()
nN = len(S)
nAns = [ 1 for i in range(nN)]
nAnsC = [ 0 for i in range(nN)]

for j in range(10**100):
  nAnsT = [ 0 for i in range(nN)]
  for i in range(nN):
    sTmp = S[i]
    
    if nAns[i]==0:
      continue
    nNum = nAns[i]
    nAns[i] = 0
    if sTmp =='R':
      nTmp = i + 1
    elif sTmp =='L':
      nTmp = i - 1
    nAnsT[nTmp] += nNum
  
  nAns = copy.deepcopy(nAnsT)
  if i==1:
    nAnsC = copy.deepcopy(nAnsT)
  else:
    nTmp2 = i
    nTmp2 &= 1
    if nTmp == 1:
      if nAns == nAnsC:
        break
      else:
        nAnsC = copy.deepcopy(nAns)
      
    print(*nAns)
  
print(*nAns)



### FIXED CODE ###

import sys
import copy

S = input()
nN = len(S)
nAns = [ 0 for i in range(nN)]
nAnsT = [ 0 for i in range(nN)]
nAnsR = [ 0 for i in range(nN)]

nCnt = S.count('RL')
nRLp = [ 0 for i in range(nCnt)]

nTmpP = 0
for i in range(nCnt):
  nTmp = S.find('RL',nTmpP)
  nRLp[i] = nTmp
  nTmpP = nTmp + 1

nCntE = S.count('LR')
nLRp = [ 0 for i in range(nCntE)]
nTmpP = 0
for i in range(nCntE):
  nTmp = S.find('LR',nTmpP)
  nLRp[i] = nTmp
  nTmpP = nTmp + 1
  
# print(nRLp)
# print(nLRp)

nTmpS = 0
for i in range(nCnt):
  nTmpR = nRLp[i]
  nTmpL = nTmpR + 1
  
  if i == nCnt - 1:
    nTmpE = nN - 1
  else:
    nTmpE = nLRp[i]
    
  nSize = nTmpE-nTmpS+1
  nB1 = nSize // 2
  nB2 = nSize // 2
  nChk = nSize % 2
  if nChk == 1:
    nB1 += 1
  
  nChk = nTmpR - nTmpS
  nChk %= 2
  if nChk == 0:
    nAns[nTmpR]=nB1
    nAns[nTmpL]=nB2
  else:
    nAns[nTmpR]=nB2
    nAns[nTmpL]=nB1
  
  nTmpS = nTmpE + 1

print(*nAns)
### BUGGY CODE ###

H, W, M = map(int, input().split())
Hsum = [0] * H
Wsum = [0] * W

hw = []
for m in range(M):
  h, w = map(int, input().split())
  Hsum[h-1] += 1
  Wsum[w-1] += 1
  hw.append(str(h-1)+"_"+str(w-1))

hmax = []
wmax = []
for i, h in enumerate(Hsum):
  if h == max(Hsum):
  	hmax.append(i)
for i, w in enumerate(Wsum):
  if w == max(Wsum):
  	wmax.append(i)
res = []
for h in hmax:
  for w in wmax:
    if str(h)+"_"+str(w) in hw:
      res.append(Hsum[h] + Wsum[w] - 1)
    else:
      res.append(Hsum[h] + Wsum[w])
print(max(res))

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
H, W, M = map(int, input().split())
Hsum = [0] * H
Wsum = [0] * W
hw = set()
for m in range(M):
  h, w = map(lambda x: int(x) - 1, input().split())
  Hsum[h] += 1
  Wsum[w] += 1
  hw.add((h, w))

mh = max(Hsum)
mw = max(Wsum)
hidx = [i for i, _ in enumerate(Hsum) if _ == mh]
widx = [i for i, _ in enumerate(Wsum) if _ == mw]
 
if len(hidx) * len(widx) > M:
  print(mh + mw)
else:
  fi_flg = False
  for h in hidx:
    for w in widx:
      if (h, w) not in hw:
        print(mh + mw)
        fi_flg = True
        break
    if fi_flg:
      break
  if fi_flg is False:
    print(mh + mw - 1)
### BUGGY CODE ###

import itertools
import bisect

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

Ac = list(itertools.accumulate(A))
Bc = list(itertools.accumulate(B))

iA = bisect.bisect_right(Ac,K)

A_ok = [0]+Ac[:iA]

ans = 0
for i in range(len(A_ok)):
    K2 = K - A_ok[i]
    iB = bisect.bisect_right(Bc,K2)
    Bc = Bc[:iB]
    ans = max(ans,i+iB)

print(ans)

### FIXED CODE ###

import itertools
import bisect

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
B = B + [10**10]

Ac = list(itertools.accumulate(A))

iA = bisect.bisect_right(Ac,K)

A_ok = Ac[:iA][::-1]+[0]
Alen = len(A_ok)

ans = 0
SUM = 0
cnt = 0
for i in range(Alen):
    K2 = K - A_ok[i]
    k = cnt
    for j in range(M-k):
        if SUM + B[j+k] <= K2:
            cnt += 1
            SUM += B[j+k]
        else:
            break
    ans = max(ans,(Alen-i-1+cnt))

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

k,s = map(int,input().split())
cnt = 0
 
for x in range(k+1):
  for y in range(k+1):
    for z in range(k+1):
      if x + y + z == s:
        cnt += 1
print(cnt)

### FIXED CODE ###

k,s = map(int,input().split())
cnt = 0
 
for x in range(k+1):
  for y in range(k+1):
      if x + y <= s and x + y >= s - k:
        cnt += 1
print(cnt)
### BUGGY CODE ###

s = input()
K = int(input())
dict = []

for i in range(len(s)):
    for k in range(len(s)-i+1):
        if s[i:(k+i)] not in dict:
            dict.append(s[i:(k+i)])
dict.sort()
print(dict[K])


### FIXED CODE ###

s = input()
K = int(input())
dict = []

for i in range(len(s)):
    for k in range(6):
        if s[i:min(i+k,len(s))] not in dict:
            dict.append(s[i:min(i+k,len(s))])
dict.sort()
print(dict[K])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10000000)
import math
import bisect
def input():
    return sys.stdin.readline()[:-1]

n,u,v = map(int,input().split())
u-=1
v-=1
g = [[]for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
seen = [-1 for i in range(n)]
taka = []
aok = []
def dfs(s,lis):
    nec = g[s]
    if len(nec)==1:
        lis.append(s)
    for i in nec:
        if seen[i]!=-1:
            continue
        seen[i] = seen[s]+1
        dfs(i,lis)

seen[u]=0
dfs(u,taka)
takadist = [i for i in seen]
seen = [-1 for i in range(n)]
seen[v]=0
dfs(v,aok)
ans = 0
for i in aok:
    if takadist[i]<seen[i]:
        ans = max(ans,seen[i])
if g[u]==[v]:
    print(0)
else:
    print(ans-1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
import math
import bisect
def input():
    return sys.stdin.readline()[:-1]

n,u,v = map(int,input().split())
u-=1
v-=1
g = [[]for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    g[a].append(b)
    g[b].append(a)
seen = [-1 for i in range(n)]
taka = []
aok = []
def dfs(s,lis):
    nec = g[s]
    if len(nec)==1:
        lis.append(s)
    for i in nec:
        if seen[i]!=-1:
            continue
        seen[i] = seen[s]+1
        dfs(i,lis)

seen[u]=0
dfs(u,taka)
takadist = [i for i in seen]
seen = [-1 for i in range(n)]
seen[v]=0
dfs(v,aok)
ans = 0
for i in aok:
    if takadist[i]<seen[i]:
        ans = max(ans,seen[i])
if g[u]==[v]:
    print(0)
else:
    print(ans-1)
### BUGGY CODE ###

# ?´???°?????°?????¨?????????????????°??????

import sys
import math

prim_no = {}                    # ????????°????´???°??§??????????????????????????????

def is_prime(no):
    if no == 2:
        return True
    
    if no % 2 == 0:
        return False

    if prim_no.get(no) is not None:
        return prim_no.get(no)

    max_check = int(math.sqrt(no))
    for i in range(3, max_check+1, 2):
        if no % i == 0:
            prim_no[no] = False
            return False

    prim_no[no] = True
    return True

def main():
    while True:
        num = sys.stdin.readline()
        if num is None or num.strip() == '':
            break

        num = int(num.strip())
        cnt = 0
        for i in range(2, num + 1):
            if is_prime(i):
                cnt += 1

        print(cnt)

if __name__ == '__main__':
    main()
    

### FIXED CODE ###

# ?´???°?????°?????¨?????????????????°??????

import sys
import math

prim_no = {2: True}                    # ????????°????´???°??§??????????????????????????????

def is_prime(no):
    if no == 2 or no == 1:
        return True
    
    if no % 2 == 0:
        return False

    if prim_no.get(no) is not None:
        return prim_no.get(no)

    max_check = int(math.sqrt(no))
    for i in range(3, max_check+1, 2):
        if no % i == 0:
            prim_no[no] = False
            return False

    prim_no[no] = True
    return True

def main():
    prim_vals = {}                         # ????????°?????§????´???°????????°
    num_data = []                          # ?????????????????????
    
    while True:
        num = sys.stdin.readline()
        if num is None or num.strip() == '':
            break

        num = int(num.strip())
        num_data.append(num)

    sorted_num_data = sorted(num_data)
    prim_num = {}
    
    for num in sorted_num_data:
        if prim_vals.get(num) is not None:
            cnt = prim_vals.get(num)
        else:
            if num == 1:
                cnt = 0
            else:
                cnt = 0

                if num % 2 == 0:
                    start_num = num -1
                else:
                    start_num = num
                    
                for i in range(start_num, 0, -2):
                    if prim_vals.get(i) is not None:
                        cnt += prim_vals.get(i)
                        break
                    
                    if is_prime(i):
                        cnt += 1
                        
                prim_vals[num] = cnt # ????????°?????§????´???°????????°????????????
        prim_num[num] = cnt

    for num in num_data:
        print(prim_num[num])

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

X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
A = A[:K]
B = B[:K]
AB = []
for a in A:
    for b in B:
        AB.append(a+b)
AB.sort(reverse=True)

AB = AB[:K]
C.sort(reverse=True)
C = C[:K]
ABC = []
i = 0
for c in C:
    # if i >= K: break
    for ab in AB:
        ABC.append(ab+c)
        i += 1

ABC.sort(reverse=True)

for i in range(K): print(ABC[i])

### FIXED CODE ###

X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ans = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K: ans.append(A[i]+B[j]+C[k])
            else: break
ans.sort(reverse=True)
for i in range(K): print(ans[i])
### BUGGY CODE ###



def main():
    import math
    import collections
    # import numpy as np

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

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

    # As = np.tile(A, (N, 1))
    # As = [A]*N
    # print(As)
    for i in range(N):
        x = A[i]
        A[i] = 0
        tmp_A = collections.Counter(A)
        su = 0
        for pairs in sorted(tmp_A.values(), reverse=True):
            if pairs >= 2:
                # su += combinations_count(pairs, 2)
                su += pairs*(pairs-1)//2
            else:
                break
        A[i] = x
        print(su)


if __name__ == '__main__':
    main()


### FIXED CODE ###



def main():
    import collections

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

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


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

a, b, x = map(int, input().split())
ans = 0
for i in range(a, b+1):
  if i%x == 0:
    ans += 1
print(ans)

### FIXED CODE ###

a, b, x = map(int, input().split())
if a%x == 0 and b%x == 0:
  ans = b//x -a//x +1
elif a%x != 0 and b%x == 0:
  ans = b//x -a//x
elif a%x == 0 and b%x != 0:
  ans = b//x -a//x +1
else:
  ans = b//x -a//x
print(ans)
### BUGGY CODE ###

h,w,m = map(int,input().split())
hw = [list(map(int,input().split()))for _ in range(m)]

tate = [0]*(h+1)
yoko = [0]*(w+1)

for x,y in hw:
    tate[x] += 1
    yoko[y] += 1

ans_x = []
ans_y = []
x_max = max(tate)
y_max = max(yoko)
for i in range(len(tate)):
    if tate[i] == x_max:
        ans_x.append(i)
for i in range(len(yoko)):
    if yoko[i] == y_max:
        ans_y.append(i)

ans = x_max + y_max
kaburi = True
for x in ans_x:
    if kaburi == False:
        break
    for y in ans_y:
        if [x,y] in hw:
            continue
        else:
            kaburi = False
            break
print(ans - int(kaburi))

### FIXED CODE ###

import sys
input = sys.stdin.readline
h,w,m = map(int,input().rstrip().split())
hw = [list(map(int,input().rstrip().split()))for _ in range(m)]

tate = [0]*(h+1)
yoko = [0]*(w+1)
bombpoint = set()

for x,y in hw:
    tate[x] += 1
    yoko[y] += 1
    bombpoint.add((x,y))

ans_x = []
ans_y = []
x_max = max(tate)
y_max = max(yoko)
for i in range(len(tate)):
    if tate[i] == x_max:
        ans_x.append(i)
for i in range(len(yoko)):
    if yoko[i] == y_max:
        ans_y.append(i)

ans = x_max + y_max
for x in ans_x:
    for y in ans_y:
        if (x,y) not in bombpoint:
            print(ans)
            exit()
print(ans - 1)
### BUGGY CODE ###

from collections import deque
n,m = map(int,input().split())
g = [[] for i in range(n)]
for i in range(m):
  x,y = map(int,input().split())
  x-=1;y-=1
  g[x].append(y)
dp = [0] * n
que = deque([])
for i in range(n):
  que.append(i)
han = set()
for i in range(n):
  han.add(i)
while que:
  i = que.popleft()
  han.remove(i)
  for j in g[i]:
    if dp[j] < dp[i]+1:
      dp[j] = dp[i]+1
      if j not in han:
        que.append(j)
        han.add(j)
print(max(dp))

### FIXED CODE ###

from collections import deque
n,m = map(int,input().split())
g = [[] for i in range(n)]
h = [[] for i in range(n)]
for i in range(m):
  x,y = map(int,input().split())
  x-=1;y-=1
  g[x].append(y)
  h[y].append(x)
topo = []
hukasa = [0] * n
hairu = [0]*n
que = deque([])
for i in range(n):
  hairu[i] = len(h[i])
  if hairu[i] == 0:
    topo.append(i)
    que.append(i)
def dfs(x):
  for i in g[x]:
    hairu[i]-=1
    if hairu[i] == 0:
      topo.append(i)
      que.append(i)
while que:
  x = que.popleft()
  dfs(x)
def dfs2(x):
  for i in g[x]:
    hukasa[i] = max(hukasa[i],hukasa[x]+1)
for i in topo:
  dfs2(i)
print(max(hukasa))
### BUGGY CODE ###


def Cf(n):
    if n == 1 or n ==0:
        return 0
    else:
        return n*(n-1)//2



N, P = map(int, input().split())
S = list(map(int, input()))
ans = 0
if P == 2:
    for i in range(N):
        if S[i]%2 == 0:
            ans +=i+1
    print(ans)

elif P ==5:
    for i in range(N):
        if S[i]%5 == 0:
            ans +=i+1
    print(ans)
else:
    data =[0]*P
    S[-1] = S[-1]%P
    data[S[-1]] +=1
    for i in range(N-2,-1,-1):
        k = (S[i+1] + S[i]*(10**(N-i-1))) %P
        S[i] =k
        data[k] += 1
    for i in data:
        ans += Cf(i)
    ans +=data[0]
    print(ans)

### FIXED CODE ###

N, P = map(int, input().split())
S = list(map(int, input()))
ans = 0
if P == 2:
    for i in range(N):
        if S[i]%2 == 0:
            ans +=i+1
    print(ans)

elif P ==5:
    for i in range(N):
        if S[i]%5 == 0:
            ans +=i+1
    print(ans)
else:
    data =[0]*P
    tens = 1
    k = 0
    for i in range(N-1,-1,-1):
        k += S[i] *tens %P
        k = k%P
        data[k] += 1
        tens *=10
        tens %=P

    for i in data:
        ans += i*(i-1)/2
    ans +=data[0]
    print(int(ans))
### BUGGY CODE ###

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

import numpy as np
A = np.array(A,dtype='int64')

def count_A(N,M,A):
  count=0
  for i in range(N+1):
    for t in range(N+1):
      count+=1 if i<t and np.sum(A[i:t])%M==0 else 0
  return print(count)
count_A(N,M,A)

### FIXED CODE ###

import collections
import numpy as np

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

A = np.array(A,dtype='int64')
C = np.append([0],np.cumsum(A))
L = [i%M for i in C]
L_c = collections.Counter(L)

ans = 0
for i in L_c.values():
    S = i * (i-1) / 2
    ans+=S
    
print(int(ans))
### BUGGY CODE ###

def comb(n):
    return n*(n-1) // 2
n = int(input())
num_list =  list(map(int,input().split()))
num_list2 = [0]*n
num_list3 = [0]*n
for i in num_list:
    num_list2[i-1] += 1
for i in range(n):
    ans = comb(num_list2[i-1])
    num_list3[i-1] = ans

for i in num_list:
    ans = comb(num_list2[i-1]-1)
    print(ans-num_list3[i-1]+sum(num_list3))
  #  elif size == 1:
        #ans = 0
   # else :
    #    ans = 0 
    #num_list5[num_list2[i]-1] = ans


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
cnt = [0] * n
for i in a:
    cnt[i-1] += 1
total = [0] * n
for i in range(n):
    total[i] = cnt[i] * (cnt[i] - 1) // 2
total_sum = sum(total)
for i in a:
    ans = total_sum
    ans -= total[i-1]
    ans += (cnt[i-1] - 1) * (cnt[i-1] - 2) // 2
    print(ans)
### BUGGY CODE ###

import heapq
n,k=map(int,input().split())
can=[]
for i in range(k):
    l,r=map(int,input().split())
    for j in range(l,r+1):
        can.append(j)
table=[0]*n
table[0]=1
que=[0]
heapq.heapify(que)
can.sort()
while que:
    now=heapq.heappop(que)
    for j in can:
        if now+j>=n:
            break
        table[now+j]=(table[now+j]+table[now])%998244353
        if not now+j in set(que):
            heapq.heappush(que,now+j)
print(table[-1]%998244353)

### FIXED CODE ###

p=998244353
n,k=map(int,input().split())
kukan=[]
for i in range(k):
    l,r=map(int,input().split())
    kukan.append((l,r))
dp=[0]*n
sdp=[0]*(n+1)
dp[0]=1
sdp[1]=1
for i in range(1,n):
    for l,r in kukan:
        left=max(0,i-r)
        right=max(0,i-l+1)
        dp[i]=(dp[i]+sdp[right]-sdp[left])%p
    sdp[i+1]=(sdp[i]+dp[i])%p
print(dp[-1])
### BUGGY CODE ###

#!/usr/bin/evn python3

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

for i in range(1, N+1):
    print(A.count(i))

### FIXED CODE ###

#!/usr/bin/env python3

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

lis = [0] * N
for i in A:
    lis[i-1] += 1

for i in range(len(lis)):
    print(lis[i])