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

N = int(input())

answer = [i for i in range(1, N+1) if N % i ==0]
answer_r = sorted(answer, reverse=True)

s = [[A,B] for A, B in zip(answer, answer_r)]

for i in range(len(s)):
    if i == len(s)//2:
        ans = s[i]
        break

if len(str(ans[0])) > len(str(ans[1])):
    a = ans[0]
else:
    a = ans[1]

print(len(str(a)))

### FIXED CODE ###

import math
N = int(input())
q = int(math.sqrt(N))
a = 0
for i in range(1,q+1) :
    if N%i == 0 :
        a = i
        b = int(N/a)
print(len(str(b)))
### BUGGY CODE ###

n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]

BC.sort(reverse=True)
cnt = 0
L = []
for b, c in BC:
    if cnt == n:
        break
    if cnt + b > n:
        b = n-cnt
    for _ in range(b):
        A.append(c)

A.sort(reverse=True)

print(sum(A[:n]))

### FIXED CODE ###

from operator import itemgetter

n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]


BC.sort(reverse=True, key=itemgetter(1))
cnt = 0
for b, c in BC:
    if cnt + b > n:
        b = n-cnt
    for _ in range(b):
        A.append(c)
    cnt += b
    if cnt == n:
        break

A.sort(reverse=True)

print(sum(A[:n]))
### BUGGY CODE ###

N = int(input())
P = list(input())
X = []
for i in range(N):
    X.append(P[:i].count("W")+P[i+1:].count("E"))
print(min(X))

### FIXED CODE ###

N = int(input())
P = list(input())
X = P[1:].count("E")
a = [X]
for i in range(N-1):
    if P[i] == "W":
        X += 1
    if P[i+1] == "E":
        X -= 1
    a.append(X)

print(min(a))
### BUGGY CODE ###

import sys
import math
from itertools import permutations
from itertools import combinations

#input = sys.stdin.readline
sys.setrecursionlimit(10**7)
N = int(input())
A = list(map(int, input().split()))
mod = 10**9 + 7

A.sort()
sumv = 0
for i, vi in enumerate(A):
    for vj in A[i+1:]:
        sumv += vi^vj
        sumv %= mod
print(sumv)


### FIXED CODE ###

import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())
A = np.array(input().split(), np.int)
#print(A)

cnt = 0
for i in range(61):
    B = (A>>i)&1
    z = np.count_nonzero(B)
    cnt += z*(N-z)*(2**(i))
    cnt %= MOD

print(cnt)
### BUGGY CODE ###

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

N = int(input())
D = list(map(int,input().split()))
ans = 1
a = 0
if D[0] != 0 or D.count(0) > 1:
  print(0)
  exit()

prev = 1
for i in range (max(D)):
  if D.count(i+1) == 0:
    if a < N-1:
      print(0)
      exit()
    else:
      print(ans)
      exit()
  else:
    count = D.count(i+1)
    a += count
    ans = ( ans * pow_k(prev,count) ) %998244353 
    prev = count
print(ans)

### FIXED CODE ###

n = int(input())
d = list(map(int, input().split()))
b = 1
ans = 1
dd=[0]*10**5
for i in d:
    dd[i]+=1
max = max(d)
if d[0] == 0 and d.count(0) == 1:
    for i in range(1, max+1):
        if dd[i] == 0:
            print(0)
            exit()
        if dd[i] == 1:
            ans *= b
        else:
            if b != 1:
                ans *= pow(b, dd[i], 998244353)
        b = dd[i]
    print(ans % 998244353)
else:
    print(0)
### BUGGY CODE ###

a,b,k=map(int,input().split())
for i in range(k):
  if a > 0:
    a -= 1
  elif a == 0 and b > 0:
    b -= 1
  elif a == 0 and b == 0:
    continue;
print(a,b)

### FIXED CODE ###

a,b,k=map(int,input().split())
if a >= k:
  a -= k
elif a < k and a+b >= k:
  b -= (k-a)
  a = 0
elif a+b < k:
  a = 0
  b = 0
print(a,b)
### BUGGY CODE ###

import numpy as np
from collections import deque
from itertools import product

h, w = map(int, input().split())
c = tuple(map(lambda x: int(x)+1, input().split()))
d = tuple(map(lambda x: int(x)+1, input().split()))
s = np.zeros((h+4, w+4), dtype=np.int8)
for i in range(h):
    s[i+2, 2:-2] = [0 if k == '#' else 1 for k in input()]

move_a_area = [(0, -1), (-1, 0), (1, 0), (0, 1)]
move_b_area = [(i, j) for i, j in product(range(-2, 3), repeat=2) if (i, j) not in [(0, 0)] + move_a_area]

INF = 10 ** 12
cost = np.full_like(s, INF, dtype=np.int64)
cost[c[0], c[1]] = 0
que = deque([(c[0], c[1], 0)])

while que:
    y, x, m = que.popleft()
    # Move A
    for dx, dy in move_a_area:
        hh, ww = y + dy, x + dx
        if not s[hh, ww] or cost[hh, ww] <= m:
            continue
        cost[hh, ww] = m
        que.appendleft((hh, ww, m))
    # Move B
    for dx, dy in move_b_area:
        hh, ww = y + dy, x + dx
        if not s[hh, ww] or cost[hh, ww] <= m + 1:
            continue
        cost[hh, ww] = m + 1
        que.append((hh, ww, m + 1))

print(v if (v := cost[d[0], d[1]]) < INF else -1)


### FIXED CODE ###

from collections import deque
from itertools import product

h, w = map(int, input().split())
c = tuple(map(lambda x: int(x)-1, input().split()))
d = tuple(map(lambda x: int(x)-1, input().split()))
s = list(input() for _ in range(h))

move_a_area = [(0, -1), (-1, 0), (1, 0), (0, 1)]
move_b_area = [(i, j) for i, j in product(range(-2, 3), repeat=2) if (i, j) not in [(0, 0)] + move_a_area]

cost = [[float('inf')] * w for _ in range(h)]
cost[c[0]][c[1]] = 0
que = deque([(c[0], c[1], 0)])

while que:
    y, x, m = que.popleft()
    # Move A
    for dx, dy in move_a_area:
        hh, ww = y + dy, x + dx
        if hh < 0 or h <= hh or ww < 0 or w <= ww or s[hh][ww] == '#' or cost[hh][ww] <= m:
            continue
        cost[hh][ww] = m
        que.appendleft((hh, ww, m))
    # Move B
    for dx, dy in move_b_area:
        hh, ww = y + dy, x + dx
        if hh < 0 or h <= hh or ww < 0 or w <= ww or s[hh][ww] == '#' or cost[hh][ww] <= m + 1:
            continue
        cost[hh][ww] = m + 1
        que.append((hh, ww, m + 1))

print(cost[d[0]][d[1]] if cost[d[0]][d[1]] < float('inf') else -1)
### BUGGY CODE ###

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

d = dict()
key_all = []
for i in range(n):
    a = ab[i][0]
    b = ab[i][1]

    if a not in key_all:
        d[a] = [b]
        key_all.append(a)
    else:
        d[a].append(b)

key_all.sort()

ans = 0
l = []
import bisect

mm = key_all[-1]
for i in range(1, min(mm, m) + 1):
    if i == key_all[0]:
        for v in d[i]:
            bisect.insort(l, v)

        key_all.pop(0)

    if l != []:
        ans += l.pop()

if m > mm:
    for i in range(mm + 1, m + 1):
        if l != []:
            ans += l.pop()


print(ans)


### FIXED CODE ###

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

import heapq
import collections

a_all = []
for i in range(n):
    a_all.append(ab[i][0])

key_all = list(set(a_all))
key_all.sort()

d = dict()
for k in key_all:
    d[k] = []

for i in range(n):
    a = ab[i][0]
    b = ab[i][1]
    d[a].append(b)

ans = 0
l = []
for i in range(1, m+1):
    if key_all != []:
        if i == key_all[0]:
            for v in d[i]:
                heapq.heappush(l, -1 * v)

            heapq.heappop(key_all)

    if l != []:
        ans += heapq.heappop(l) * -1

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

s=input()
t=input()
l=list()
for _ in list(t):
  if [i for i,x in enumerate(list(s)) if x==_] != list():
    l.append([i for i,x in enumerate(list(s)) if x==_])
  else:
    print("-1")
    exit()
if len(t)==1:
  print(s.index(t)+1)
  exit()
ed=l[0][0]
cd=0
for i in range(len(t))[1:-1]:
  k=l[i]
  if max(k+[ed])==ed :
    cd+=1
    ed=k[0]
  else:
    ex=sorted(k+[ed])
    exex=ex.index(ed)
    ed=k[exex]
k=l[len(t)-1]
if max(k+[ed])==ed :
  print((cd+1)*len(s)+min(k)+1)
else:
  ex=sorted(k+[ed])
  exex=ex.index(ed)
  ed=k[exex]
  print((cd)*len(s)+ed+1)

### FIXED CODE ###

def f():
    s,t=input(),input()
    n,m=len(s),len(t)
    table=[[]for i in  range(26)]
    d={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

    for j in range(n):
        table[d[s[j]]].append(j)
    now=0
    ind=0
    if set(list(t))-set(list(s)):print(-1);exit()
    from bisect import bisect_left as bl
    for p in t:
        if ind>table[d[p]][-1]:now+=1;ind=0
        ind=table[d[p]][bl(table[d[p]],ind)]+1

    print(now*n+ind)
if __name__ == "__main__":
    f()
### BUGGY CODE ###

N, M = map(int, input().split())
H_i = list(map(int, input().split()))
U = [list(map(int, input().split())) for i in range(M)]

high_max = []
ans = 0

for i in range(N):
    Highes = []
    for j in range(M):
        if U[j][0] == i + 1:
            Highes.append(H_i[U[j][1] - 1])
        if U[j][1] == i + 1:
            Highes.append(H_i[U[j][0] - 1])

    if Highes == []:
        high_max.append(0)
    else:
        high_max.append(max(Highes))

for i in range(N):
    if H_i[i] > high_max[i]:
        ans += 1

print(ans)


### FIXED CODE ###

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

good = [True] * N

for _ in range(M):
  A, B = map(int, input().split())
  A -= 1
  B -= 1
  if H[A] >= H[B]:
    good[B] = False
  if H[A] <= H[B]:
    good[A] = False
print(sum(good))
### BUGGY CODE ###

first_input = list(map(int, input().split()))
number = first_input[0]
steps = first_input[1]

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

start_cost = scaffolds[0]

costs = [start_cost for i in range(number)]

for i in range(number):
    next_step = i
    next_scaffold = scaffolds[next_step]
    target_cost = -1
    for j in range(steps):
        
        last_step = next_step - (j + 1)
        if -1 < last_step:
            cost = abs(scaffolds[next_step] - scaffolds[last_step]) + costs[last_step]
            if target_cost == -1 or cost < target_cost:
                target_cost = cost

    if 0 < target_cost:
        next_cost = target_cost
    else:
        next_cost = scaffolds[next_step]

    if -1 < next_cost:
        costs[i] = next_cost

print(costs[number - 1] - start_cost)

### FIXED CODE ###

first_input = list(map(int, input().split()))
number = first_input[0]
steps = first_input[1]

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

start_cost = scaffolds[0]

costs = []

for i in range(number):
    next_step = i
    next_scaffold = scaffolds[next_step]
    target_cost = -1
    for j in range(steps):
        
        last_step = next_step - (j + 1)
        if -1 < last_step:
            cost = abs(scaffolds[next_step] - scaffolds[last_step]) + costs[last_step]
            if target_cost == -1 or cost < target_cost:
                target_cost = cost

    if 0 < target_cost:
        next_cost = target_cost
    else:
        next_cost = scaffolds[next_step]

    
    costs.append(next_cost)

print(costs[number - 1] - start_cost)
### BUGGY CODE ###

def main():
  import sys
  input = sys.stdin.readline
  n = int(input())
  s = list(input())

  def segfunc(x,y):
      return x|y

  def init(init_val):
      #set_val
      for i in range(n):
          seg[i+num-1]=init_val[i]    
      #built
      for i in range(num-2,-1,-1) :
          seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
      
  def update(k,x):
      k += num-1
      seg[k] = x
      while k:
          k = (k-1)//2
          seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
      
  def query(p,q):
      if q<=p:
          return ide_ele
      p += num-1
      q += num-2
      res=ide_ele
      while q-p>1:
          if p&1 == 0:
              res = segfunc(res,seg[p])
          if q&1 == 1:
              res = segfunc(res,seg[q])
              q -= 1
          p = p//2
          q = (q-1)//2
      if p == q:
          res = segfunc(res,seg[p])
      else:
          res = segfunc(segfunc(res,seg[p]),seg[q])
      return res

  #####単位元######
  ide_ele = set()

  #num:n以上の最小の2のべき乗
  num =2**(n-1).bit_length()
  seg=[ide_ele]*2*num

  A = []
  for i in range(n):
    A.append(set(s[i]))
  init(A)
  q = int(input())
  for _ in range(q):
    p,a,b = input().split()
    if p == "1":
      update(int(a)-1,set(b))
    if p == "2":
      print(len(query(int(a)-1,int(b))))
main()
    

### FIXED CODE ###

def main():
  import sys
  input = sys.stdin.readline
  n = int(input())
  s = list(input())

  def segfunc(x,y):
      return x|y

  def init(init_val):
      #set_val
      for i in range(n):
          seg[i+num-1]=init_val[i]    
      #built
      for i in range(num-2,-1,-1) :
          seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
      
  def update(k,x):
      k += num-1
      seg[k] = x
      while k:
          k = (k-1)//2
          seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
      
  def query(p,q):
      if q<=p:
          return ide_ele
      p += num-1
      q += num-2
      res=ide_ele
      while q-p>1:
          if p&1 == 0:
              res = segfunc(res,seg[p])
          if q&1 == 1:
              res = segfunc(res,seg[q])
              q -= 1
          p = p//2
          q = (q-1)//2
      if p == q:
          res = segfunc(res,seg[p])
      else:
          res = segfunc(segfunc(res,seg[p]),seg[q])
      return res

  #####単位元######
  ide_ele = 0

  #num:n以上の最小の2のべき乗
  num =2**(n-1).bit_length()
  seg=[ide_ele]*2*num

  A = []
  for i in range(n):
    A.append(1<<(ord(s[i])-96))
  init(A)
  q = int(input())
  for _ in range(q):
    p,a,b = input().split()
    if p == "1":
      update(int(a)-1,1<<(ord(b)-96))
    if p == "2":
      print(bin(query(int(a)-1,int(b))).count("1"))
main()
### BUGGY CODE ###



def main():
    N = int(input())
    S = [i for i in input()]
    min_count = 30000
    for i in range(N):
        left = S[:i-1]
        right = S[i:]
        tmp_c = left.count("W")+right.count("E")
        if tmp_c < min_count:
            min_count = tmp_c
    print(min_count)

if __name__ == "__main__":
    main()

### FIXED CODE ###



def main():
    N = int(input())
    S = input()

    l = [0]*N
    r = [0]*N
    for i in range(1, N):
        l[i] = l[i-1] + (S[i-1]=="W")
    for i in range(N-1)[::-1]:
        r[i] = r[i+1] + (S[i+1]=="E")

    
    ans = 10**6
    for a, b, in zip(l, r):
        ans = min(a+b, ans)
    print(ans)
    

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

# 大きさがsum(a)のスライムが1匹いる
# dp[l][r]=min(区間[l,r]を分解するための最小コスト)
n=int(input())
a=list(map(int,input().split()))
INF=10**15
dp=[[0]*n for i in range(n)]
for i in range(n):
    dp[i][i]=a[i]
for i in range(n-1):
    for j in range(i+1,n):
        dp[i][j]=dp[i][j-1]+a[j]

for i in range(n-1):
    for j in range(i+1,n):
        ans=INF
        # print(j-i-1,j)
        for k in range(j-i-1,j):
            ans=min(ans,dp[j-i-1][k]+dp[k+1][j])
        if i<n-2:
            dp[j-i-1][j]+=ans
        else:
            print(ans)

### FIXED CODE ###

# 大きさがsum(a)のスライムが1匹いる
# dp[l][r]=min(区間[l,r]を分解するための最小コスト)
n=int(input())
a=list(map(int,input().split()))
INF=10**15
dp=[[0]*n for i in range(n)]
for i in range(n):
    dp[i][i]=a[i]
for i in range(n-1):
    for j in range(i+1,n):
        dp[i][j]=dp[i][j-1]+a[j]

for i in range(n-1):
    for j in range(i+1,n):
        ans=INF
        # print(j-i-1,j)
        for k in range(j-i-1,j):
            ans=min(ans,dp[j-i-1][k]+dp[k+1][j])
        if i<n-2:
            dp[j-i-1][j]+=ans
        else:
            print(ans)
### BUGGY CODE ###


def solve(i,m):
    if m == 0:
        return True
    if i >= n:
        return False
    res = solve(i+1,m) or solve(i+1,m-a[i])
    return res

n = input()
a = map(int,raw_input().split())
q = input()
p = map(int,raw_input().split())

for i in xrange(0,q):
    if solve(0,p[i]):
        print "yes"
    else:
        print "no"

### FIXED CODE ###


        
def solve(i,m):
    if dp[i][m] != -1:
        return dp[i][m]
    if m == 0:
        dp[i][m] = True
    elif i >= n:
        dp[i][m] = False
    elif solve(i+1, m):
        dp[i][m] = True
    elif solve(i+1, m-a[i]):
        dp[i][m] = True
    else:
        dp[i][m] = False
    return dp[i][m]

n = input()
a = map(int,raw_input().split())
q = input()
p = map(int,raw_input().split())
dp = [[-1 for i in xrange(2001)] for j in xrange(21)]
for i in xrange(q):
    if solve(0,p[i]):
        print "yes"
    else:
        print "no"
### BUGGY CODE ###

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

dp =[float('inf')] * N
dp[0] = 0
for i in range(N):
    if i + K + 1 >= N:
        t = N
    else:
        t = i + K + 1 
    for j in range(i, t):
        if j >= N:
            break
        dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))
print(dp[-1])

### FIXED CODE ###

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

dp = [0] * N
for i in range(1, N):
    dp[i] = min([dp[j] + abs(h[j]-h[i]) for j in range(max(0,i-K),i)])

print(dp[-1])
### BUGGY CODE ###


def main():
    n, m = map(int, input().split())
    l = []
    r = []
    ans = 0
    for i in range(m):
        a, b = map(int, input().split())
        l.append(a)
        r.append(b)
    for i in range(1, n+1):
        if i >= max(l) and i <= min(r):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, m = map(int, input().split())
    l = []
    r = []
    ans = 0
    for i in range(m):
        a, b = map(int, input().split())
        l.append(a)
        r.append(b)
    ml = max(l)
    mr = min(r)
    for i in range(1, n+1):
        if i >= ml and i <= mr:
            ans += 1
    print(ans)


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

def divisors(n):
    lst = []; i = 1
    while i ** 2 <= n:
        q, r = divmod(n, i)
        if r == 0:
            lst.append(i)
            if i != q: lst.append(q)
        i += 1
    return lst

N = int(input())
*A, = map(int, input().split())
A = sorted(A)
cnt = [0] * (10**6 + 1)
for a in A: cnt[a] += 1
ans = 0
for a in A:
    if cnt[a] > 1: continue
    for i in divisors(a):
        if i == a: continue
        if cnt[i] >= 1: break
    else:
        ans += 1
print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
*A, = map(int, input().split())
A = sorted(A)
max_A = A[-1]
cnt = Counter(A)
admissible = [True] * (max_A + 1)
checked = [False] * (max_A + 1)
ans = 0
for a in A:
    if not admissible[a] or checked[a]: continue
    ans += 1
    i = 2
    while a * i <= max_A:
        admissible[a * i] = False
        i += 1
    checked[a] = True
    if cnt[a] > 1: ans -= 1
print(ans)
### BUGGY CODE ###

from collections import deque
h,w = map(int,input().split())
a = [list(input()) for i in range(h)]
visit = [[-1 for i in range(w)] for j in range(h)]
d = deque()

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            visit[i][j] = 0
            d.append((i,j))

p = [(1,0),(-1,0),(0,1),(0,-1)]
ans = 0
while d:
    x,y = d.popleft()
    for s,t in p:
        if 0 <= x+s <= h-1 and 0 <= y+t <= w-1:
            if visit[x+s][y+t] == -1:
                visit[x+s][y+t] = visit[x][y] + 1
                ans = max(ans,visit[x][y]+1)
                d.append((x+s,y+t))
        
print(ans)

### FIXED CODE ###

from collections import deque
h,w = map(int,input().split())
a = [list(input()) for i in range(h)]
visit = [[-1 for i in range(w)] for j in range(h)]
d = deque()

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            visit[i][j] = 0
            d.append((i,j))

p = [(1,0),(-1,0),(0,1),(0,-1)]
ans = 0
while d:
    x,y = d.popleft()
    for s,t in p:
        if 0 <= x+s <= h-1 and 0 <= y+t <= w-1:
            if visit[x+s][y+t] == -1:
                visit[x+s][y+t] = visit[x][y] + 1
                ans = max(ans,visit[x][y]+1)
                d.append((x+s,y+t))
        
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
    for j in range(i+A[i],N):
        if j-i == A[i]+A[j]:
            ans += 1
print(ans)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int,input().split()))
B = Counter(list(i+1+A[i] for i in range(N)))
#print(B,B[3])
C = Counter((i+1-A[i] for i in range(N)))
ans = 0
#print(C)
for j in range(N):
    ans += B[j]*C[j]
print(ans)
### BUGGY CODE ###

#B
N, K = map(int, input().split())
h = [int(x) for x in input().split()]
c = [float('inf')] * N

for i in range(N):
    if i == 0:
        c[i] = 0
    elif i == 1:
        c[i] = abs(h[1]-h[0])
    else:
        j = 1
        while j <= K and i-j >= 0:
            now = abs(h[i]-h[i-j])+c[i-j]
            c[i] = min(c[i], now)
            j += 1
print(int(c[N-1]))

### FIXED CODE ###

#B
N, K = map(int, input().split())
h = [int(x) for x in input().split()]
c = [float('inf')] * N

for i in range(N):
    if i == 0:
        c[i] = 0
    elif i == 1:
        c[i] = abs(h[1]-h[0])
    else:
        j = 1
        while j <= K and i-j >= 0:
            now = abs(h[i]-h[i-j])+c[i-j]
            c[i] = min(c[i], now)
            j += 1
print(int(c[N-1]))
### BUGGY CODE ###

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

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(n)]
for i in range(n):
    b[a[i] - 1] = i + 1
for i in b:
    print(i,end=" ")
### BUGGY CODE ###

import sys
from math import sqrt
input = sys.stdin.readline
from heapq import heappop, heappush
xs, ys, xt, yt = map(int, input().split())
N = int(input())
INF = float('inf')
cost = [[INF] * (N + 2) for i in range(N + 2)]
D = []
D.append((xs, ys, 0))
for i in range(N):
    x, y, r = map(int, input().split())
    D.append((x, y, r))
D.append((xt, yt, 0))

for i in range(N + 2):
    for j in range(i + 1, N + 2):
        k = max(0, sqrt((D[i][0] - D[j][0]) ** 2 + (D[i][1] - D[j][1]) ** 2) - D[i][2] - D[j][2])
        cost[i][j] = k
        cost[j][i] = k

d = [INF] * (N + 2)
d[0] = 0
que = [(0, 0.0)]
while que:
    v, dist = heappop(que)
    if d[v] < dist:
        continue
    if v == N + 1:
        print(d[v])
        exit()
    for w in range(N + 2):
        if w != v and d[w] > d[v] + cost[v][w]:
            d[w] = d[v] + cost[v][w]
            heappush(que, (w, d[w]))



### FIXED CODE ###

import sys
from math import sqrt
input = sys.stdin.readline
from heapq import heappop, heappush
xs, ys, xt, yt = map(int, input().split())
N = int(input())
INF = float('inf')
cost = [[INF] * (N + 2) for i in range(N + 2)]
D = [(xs, ys, 0)]
for i in range(N):
    x, y, r = map(int, input().split())
    D.append((x, y, r))
D.append((xt, yt, 0))

for i in range(N + 2):
    for j in range(i + 1, N + 2):
        k = max(0, sqrt((D[i][0] - D[j][0]) ** 2 + (D[i][1] - D[j][1]) ** 2) - D[i][2] - D[j][2])
        cost[i][j] = k
        cost[j][i] = k

visit = [0] * (N + 2)
visit[0] = 1
d = [INF] * (N + 2)
d[0] = 0
que = [(0, 0)]
while que:
    dist, v = heappop(que)
    if d[v] < dist:
        continue
    if v == N + 1:
        print(d[v])
        exit()
    visit[v] = 1
    for w in range(N + 2):
        if visit[w] == 0 and w != v and d[w] > d[v] + cost[v][w]:
            d[w] = d[v] + cost[v][w]
            heappush(que, (d[w], w))
### BUGGY CODE ###

from itertools import accumulate as ac
n,a=map(int,input().split())
o=[0]+list(map(int,input().split()))
m=list(ac(o))

q=sum(1 for l in range(1,n+1) for r in range(l,n+1) if (m[r]-m[l-1])%a==0)
print(q)

### FIXED CODE ###

from itertools import accumulate as ac
from math import factorial as fc
from collections import Counter

f=lambda a,b:fc(a)//(fc(a-b)*fc(b)) if a>=b>=0 else 0

n,m=map(int,input().split())
*a,=map(int,input().split())
*aa,=map(lambda x:x%m,ac([0]+a))
d=Counter(aa)

v=sum(f(i,2) for i in d.values())
print(v)