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

# coding: utf-8

import sys
input = sys.stdin.readline

def f3(n, h, a):
    dp = [0] * (n + 1)
    for i in range(1, n + 1):
        hi = h[i]
        temp = dp[hi - 1] + a[i]
        dp[hi:] = [x if x > temp else temp for x in dp[hi:]]
    return(dp[-1])

n = int(input()) # 1 <= n <= 2 x 10^5
h = [0] + list(map(int, input().split()))
a = [0] + list(map(int, input().split()))

print(f3(n, h, a))


### FIXED CODE ###

# coding: utf-8

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

powof2 = lambda x: len("{:b}".format(x))

def f2(n, h, a):
    p = powof2(n)
    N = 2 ** p
    segt = [0] * (2 * N - 1)

    def getmax(a, b, i = 0, l = 0, r = N - 1):
        if r <= a or b <= l:
            return(0)
        if a <= l and r <= b:
            return(segt[i])
        i1 = 2 * i + 1
        i2 = i1 + 1
        lr = (l + r) // 2
        lmax = getmax(a, b, i1, l, lr)
        rmax = getmax(a, b, i2, lr, r)
        return(lmax if lmax > rmax else rmax)

    def setmax(i, v):
        si = i + N - 1
        segt[si] = v
        while si > 0:
            si = (si - 1) // 2
            si1 = 2 * si + 1
            si2 = si1 + 1
            segt[si] = segt[si1] if segt[si1] > segt[si2] else segt[si2]

    for i in range(1, n + 1):
        m = getmax(0, h[i])
        setmax(h[i], m + a[i])

    return(getmax(0, n))

n = int(input()) # 1 <= n <= 2 x 10^5
h = [0] + list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
print(f2(n, h, a))
### BUGGY CODE ###

def gcd(num1,num2):
    if num1 % num2 == 0:
        return num2
    return gcd(num2 , num1 % num2)

N = int(input())
total = 0
for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N+1):
            nums = 0
            nums = gcd(i,j)
            total += gcd(nums,k)

print(total)

### FIXED CODE ###

from math import gcd

K = int(input())

memo = []
memolist = []
for i in range(1,K+1):
    if i != 1:
        memo.append(memolist)
    memolist = []
    for j in range(1,K+1):
        memolist.append(gcd(i,j))
memo.append(memolist)

result = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            result += gcd(memo[i-1][j-1],k)

print(result)
### BUGGY CODE ###

n,m,k = map(int,input().split())
mod = 998244353
f = [m*pow(m-1,n-1,mod)]
for i in range(1,k+1):
    f.append((f[i-1]*pow(m-1,mod-2,mod))%mod)
p = [1]
buns = 1
bunb = 1
for i in range(k):
    buns *= (n-1-i)
    buns %= mod
    bunb *= pow(i+1,mod-2,mod)
    p.append((bunb*buns)%mod)
ans =0 
for i in range(k+1):
    ans += f[i]*p[i]
    ans %= mod
print(ans)

### FIXED CODE ###

def cmb(n, r, mod):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

n,m,k = map(int,input().split())

mod = 998244353
fact = [1, 1]
factinv = [1, 1]
inv = [0,1]
rui = [1,m-1]

for i in range(2,n+1):
    fact.append((fact[-1] * i) % mod)
    inv.append((inv[mod % i] * (mod - (mod // i))) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)
    rui.append(rui[-1]*(m-1) % mod)

ans = 0
for i in range(k+1):
    ans += cmb(n-1,i,mod)*m*rui[n-1-i]
    ans %= mod
print(ans)
### BUGGY CODE ###

n=int(input())
a=[int(i)for i in input().split()]
res=0
for i in range(n-1):
    res+=sum(map(lambda x:x*a[i]%(1000000000+7),a[i+1:]))

print(res%(1000000000+7))

### FIXED CODE ###

n=int(input())
a=[int(i) for i in input().split()]
s=sum(a)
mod=10**9+7
res=0
for i in a:
    s-=i
    res+=i*s%mod
print(res%mod)
### BUGGY CODE ###

I=lambda:map(int,input().split());n,q=I();s=input();a=0,
for i in range(n):a+=a[i]+(s[i-1:i+1]=='AC'),
while q:l,r=I();print(a[r]-a[l]);q-=1

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
a=[0]*n
for i in range(n):
    if i:
        a[i]=a[i-1]+(s[i-1:i+1]=='AC')
for _ in range(q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])
### BUGGY CODE ###

l,r=map(int,input().split())
if r-l+1>=2019:
  print(0)
else:
  l=l%2019
  r=r%2019
  
  if l>=r:
    print(0)
    exit()
ans=10000000
for i in range(l,r+1):
  for j in range(i+1,r+1):
    ans=min(ans,(i*j)%2019)
print(ans)

### FIXED CODE ###

l,r=map(int,input().split())
if r-l+1>=2019:
  print(0)
  exit()
else:
  l=l%2019
  r=r%2019
  
  if l>=r:
    r+=2019
ans=10000000
for i in range(l,r+1):
  for j in range(i+1,r+1):
    ans=min(ans,(i*j)%2019)
print(ans)
### BUGGY CODE ###

from itertools import permutations


N, M, R = map(int, input().split())
r = list(map(int, input().split()))
INF = float('inf')

graph = [[INF for _ in range(N)] for _ in range(N)]

for _ in range(M):
    a, b, c = map(int, input().split())
    graph[a-1][b-1] = c
    graph[b-1][a-1] = c

distance = [[float('inf') for _ in range(N)] for _ in range(N)]

for k in range(N):
    for i in range(N):
        for j in range(N):
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

total_min = INF
for i in permutations(r, len(r)):
    total = 0
    for j in range(len(r)-1):
        total += graph[i[j]-1][i[j-1]-1]
    if total < total_min:
        total_min = total

print(total_min)



### FIXED CODE ###

from itertools import permutations


N, M, R = map(int, input().split())
r = list(map(int, input().split()))
INF = float('inf')

graph = [[INF for _ in range(N)] for _ in range(N)]

for _ in range(M):
    a, b, c = map(int, input().split())
    graph[a-1][b-1] = c
    graph[b-1][a-1] = c

distance = [[float('inf') for _ in range(N)] for _ in range(N)]

for k in range(N):
    for i in range(N):
        for j in range(N):
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

total_min = INF
for i in permutations(r, len(r)):
    total = 0
    for j in range(len(r)-1):
        total += graph[i[j]-1][i[j-1]-1]
    if total < total_min:
        total_min = total

print(total_min)
### BUGGY CODE ###

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

def calc_n_combinations(l):
  ball_unique = set(l)
  sum = 0
  for b in ball_unique:
    n = l.count(b)
    sum += n * (n-1) // 2
  return sum
 
results = []
c_all = calc_n_combinations(balls)
for b in balls:
  c_tmp = balls.count(b) - 1
  result = c_all - c_tmp
  print(result)

### FIXED CODE ###

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

counter = {}
for b in balls:
  counter[b] = counter.get(b, 0) + 1

sum = 0
for v in counter.values():
  sum += v * (v-1) // 2
  
for b in balls:
  n_old = counter[b]
  c_old = n_old * (n_old - 1) // 2
  c_new = (n_old - 1) * (n_old - 2) // 2
  
  result = sum - c_old + c_new
  print(result)
### BUGGY CODE ###

N = int(input())
a_list = list(map(int, input().split()))
a_list.sort()
cnt = 0
for i in range(N):
    if a_list[i] > N:
        cnt += 1
for i in range(1, N+1):
    if a_list.count(i) > i:
        cnt += a_list.count(i) - i
    elif a_list.count(i) < i:
        cnt += a_list.count(i)
    else:
        pass
print(cnt)

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import Counter


N = int(input())
a_list = list(map(int, input().split()))
a_list_unique = list(set(a_list))
a_cnt = Counter(a_list)
cnt = 0
for i in a_list_unique:
    a_dict = a_cnt[i]
    if i <= a_dict:
        cnt +=  a_dict - i
    else:
        cnt += a_dict
print(cnt)
### BUGGY CODE ###

s=input()
k=int(input())
l=set()
for i in  range(len(s)):
    for j in range(len(s)):
        l.add(s[i:i+j+1])
ll=list(l)
ll.sort()

print(ll[k-1])


### FIXED CODE ###

s=input()
k=int(input())
l=set()
for i in  range(len(s)):
    for j in range(1,k+1):
        l.add(s[i:i+j])
ll=list(l)
ll.sort()

print(ll[k-1])
### BUGGY CODE ###

def main():

    import sys
    import heapq

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

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

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

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

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

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

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

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

        i += 1


if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():

    import sys
    import heapq

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

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

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

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

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

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

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

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

        i += 1


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

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

last_ans = 0

for i in range(2 ** N):
    hako = [0]*N
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            hako[j] = 1

    #print(hako)
    ans = 0
    for kijun in range(1,N+1):
        baisuu = 1
        total = 0
        while kijun*baisuu <= N:
            if hako[kijun*baisuu-1] == 1:
                total += 1
            baisuu += 1

        total %= 2
        if a[kijun-1] != total:
            ans = 1
            break

    if ans == 0:
        last_ans = 1
        break

if last_ans == 1:
    print(hako.count(1))
    if hako.count(1) != 0:
        buf = [i+1 for i, x in enumerate(hako) if x == 1]
        print(' '.join(map(str, buf)))
else:
    print(-1)

### FIXED CODE ###

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

hako = [0]*N
last_ans = 1

for i in range(N-1, -1, -1):
    #print(i)
    check = 0
    kijun = i+1
    baisuu = 1
    total = 0
    while kijun*baisuu <= N:
        if hako[kijun*baisuu-1] == 1:
            total += 1
        baisuu += 1
    total %= 2
    if total != a[i]:
        hako[i] = 1

if last_ans == 1:
    print(hako.count(1))
    if hako.count(1) != 0:
        buf = [i+1 for i, x in enumerate(hako) if x == 1]
        print(' '.join(map(str, buf)))
else:
    print(-1)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
import functools
INF = float("inf")

MOD = 1000000007  # type: int


@functools.lru_cache(maxsize=None)
def cmb(n, r):
    r = min(r, n-r)
    if r == 0:
        return 1
    if r == 1:
        return n

    numer = [n - r + k + 1 for k in range(r)]
    denom = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denom[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numer[k - offset] /= pivot
                denom[k] /= pivot

    result = 1
    for k in range(r):
        if numer[k] > 1:
            result *= int(numer[k])

    return result


def solve(N: int, K: int, A: "List[int]"):

    A.sort()

    ans = 0
    for i in range(N):
        # A[i]が最大として選ばれるケース
        if i >= K-1:
            ans += cmb(i, K-1)*A[i]
            ans %= MOD

        # A[i]が最小として選ばれるケース
        if N-i-1 >= K-1:
            ans -= cmb(N-i-1, K-1)*A[i]
            ans %= MOD
    print(ans)

    return


def main():

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


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import functools
INF = float("inf")

MOD = 1000000007  # type: int


class Combination(object):
    """
    組み合わせを求める。
    cmbで使いうる最大のNまでを前処理で準備。
    """

    def __init__(self, N, mod=10**9+7):
        fac, finv, inv = [0]*(N+1), [0]*(N+1), [0]*(N+1)
        fac[:2] = 1, 1
        finv[:2] = 1, 1
        inv[1] = 1
        for i in range(2, N+1):
            fac[i] = fac[i-1]*i % mod
            inv[i] = -inv[mod % i]*(mod//i) % mod
            finv[i] = finv[i-1]*inv[i] % mod
        self.N = N
        self.MOD = mod
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def __call__(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n] * (self.finv[k]*self.finv[n-k] % self.MOD) % self.MOD


def solve(N: int, K: int, A: "List[int]"):

    cmb = Combination(N, mod=MOD)

    A.sort()

    ans = 0
    for i in range(N):
        # A[i]が最大として選ばれるケース
        if i >= K-1:
            ans += cmb(i, K-1)*A[i]
            ans %= MOD

        # A[i]が最小として選ばれるケース
        if N-i-1 >= K-1:
            ans -= cmb(N-i-1, K-1)*A[i]
            ans %= MOD
    print(ans)

    return


def main():

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


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

import queue

N, Q = map(int, input().split())
#AB = [list(map(int, input().split())) for _ in range(N-1)]
#PX = [list(map(int, input().split())) for _ in range(Q)]

node = [0] * (N+1)
nxt = [[] for _ in range(N+1)]

#for ab in AB:
    #a, b = ab[0], ab[1]
for _ in range(N-1):
    a,b = map(int, input().split())
    nxt[a].append(b)
    nxt[b].append(a)

#for px in PX:
    #p,x = px[0], px[1]
for _ in range(Q):
    p,x = map(int, input().split())
    node[p] += x

visited = [False] * (N+1)
q = queue.Queue()
q.put(1)
while not q.empty():
    v = q.get()
    visited[v] = True
    for nv in nxt[v]:
        if not visited[nv]:
            node[nv] += node[v]
            q.put(nv)

for i in range(1, N+1):
    print(node[i], end=' ')
print()


### FIXED CODE ###

import sys
import queue

input = sys.stdin.readline

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

node = [0] * (N+1)
nxt = [[] for _ in range(N+1)]

for _ in range(N-1):
    a,b = map(int, input().split())
    nxt[a].append(b)
    nxt[b].append(a)

for _ in range(Q):
    p,x = map(int, input().split())
    node[p] += x

visited = [False] * (N+1)
q = queue.Queue()
q.put(1)
while not q.empty():
    v = q.get()
    visited[v] = True
    for nv in nxt[v]:
        if not visited[nv]:
            node[nv] += node[v]
            q.put(nv)

for i in range(1, N+1):
    print(node[i], end=' ')
print()
### BUGGY CODE ###

N=int(input())
X=list(map(int, input().split()))
ans=1
for i in range(N):
    ans *= X[i]

print(ans if ans<=10**18 else -1)    

### FIXED CODE ###

N=int(input())
X=list(map(int, input().split()))
ans=1
if 0 in X:
    print(0)
else:
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)
### BUGGY CODE ###

n = int(raw_input())
travel = [map(int, raw_input().split()) for i in range(n)]

accessible_now = [(0,0)]
limit = 1e5 + 1

stroke = 0
for target in travel:
  t, x, y = target
  while (stroke<t):
    stroke += 1
    accessible_next = [] 
    for loc in accessible_now:
      for step in [(1,0),(0,1),(-1,0),(0,-1)]:
        loc_next = (loc[0]+step[0],loc[1]+step[1])
        if ((-1 in loc_next) or (limit in loc_next)):
          continue
        if (loc_next in accessible_next):
          continue
        accessible_next.append(loc_next)
    accessible_now = accessible_next
    #print stroke, t, accessible_now
    if (stroke == t):
      if ((x,y) in accessible_now):
        accessible_now = [(x,y)]
        continue
      else:
        print 'No'
        exit(0) 
res = 'Yes' if (stroke==t) else 'No'
print res


### FIXED CODE ###

n = int(raw_input())
travel = [map(int, raw_input().split()) for i in range(n)]

loc = (0,0)
now = 0
res = 'Yes'

for dest in travel:
  t, x, y = dest
  minpath = abs(x-loc[0]) + abs(y-loc[1])
  tmp = (t-now)-minpath
  if (tmp%2==0 and tmp>=0 ):
    loc = (x,y)
    now = t
    continue
  else:
    res = 'No'
    break
print res
### BUGGY CODE ###

N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]
point = [K]*N
for i in range(Q):
  a = A[i]
  for p in range(N):
    if p+1 != a:
      point[p] -= 1
for p in range(N):
  if point[p] <= 0:
    print("No")
  else:
    print("Yes")

### FIXED CODE ###

N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]
point = [0]*N
for i in range(Q):
  a = A[i]
  point[a-1] += 1
for i in range(N):
  point[i] -= (Q-K)
for p in range(N):
  if point[p] <= 0:
    print("No")
  else:
    print("Yes")
### BUGGY CODE ###

n, q = map(int, (input().split()))
s = input()
lst = [list(map(int, input().split())) for i in range(q)]

for i in range(q):
    print(s[lst[i][0] - 1:lst[i][1]].count('AC'))


### FIXED CODE ###

n, q = map(int, (input().split()))
s = input()

tbl = [0] * n
cnt = 0
for i in range(1, n):
    if s[i - 1] == 'A' and s[i] == 'C':
        cnt += 1
    tbl[i] = cnt

for i in range(q):
    l, r = map(int, input().split())
    print(tbl[r - 1] - tbl[l - 1])
### BUGGY CODE ###

n = int(input())
s = input()
ans = 0
count = 0
maximum = 0

for i in range(n):
	for j in range(i+1,n):
		if s[i] == s[j]:
			i_dash = i
			j_dash = j
			while True:
				if i_dash == j or j_dash == n:
					break
				elif j_dash - i_dash < maximum:
					break

				if s[i_dash] == s[j_dash]:
					count+=1
				else:
					break
				i_dash += 1
				j_dash += 1
			if ans < count:
				ans = count
			count = 0
			maximum = ans

print(ans)


### FIXED CODE ###

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

def z_algo(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
        	j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A
ans = 0
for i in range(n-1):
	tmp = z_algo(s[i:])
	for j,zj in enumerate(tmp):
		if j+1 > zj:
			ans = max(ans,zj)

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

x = int(input())
a = 0
b = 0
while a ** 5 - b ** 5 != x and a ** 5 + b ** 5 != x:
    for b in range (a+1):
        if a ** 5 - b ** 5 == x or a ** 5 + b ** 5 == x:
            break
    
    a += 1

if a ** 5 - b ** 5 == x:
    print(a, b)
else:
    print(a, -1 * b)

### FIXED CODE ###

x = int(input())
a = 0
b = 0
while a ** 5 - b ** 5 != x and a ** 5 + b ** 5 != x:
    B = a ** 5 - x
    b = int(abs(B ** (1/5)))
    if a ** 5 - b ** 5 == x or a ** 5 + b ** 5 == x:
        break

    a += 1

if a ** 5 - b ** 5 == x:
    print(a, b)
else:
    print(a, -1 * b)
### BUGGY CODE ###

n,m=map(int,input().split())
lst=[int(input()) for i in range(m)]
DP=[0]*(n+1)
temp=0
DP[0]=1
for i in range(1, n+1):
  if i==1 and i not in lst:
    DP[i]=1
  elif i==1 and i in lst:
    DP[i]=1
    temp=i+1
  elif i!=temp and i in lst:
    DP[i]=DP[i-1]
    temp=i+1
  elif i==temp and i in lst:
    break;
  elif i==temp and i not in lst:
    DP[i]=DP[i-1]
  elif i-2 in lst:
    DP[i]=DP[i-1]
  else:
    DP[i]=DP[i-1]+DP[i-2]
print(DP[n]%1000000007)

### FIXED CODE ###

N,M=map(int,input().split())
br=set([int(input()) for _ in range(M)])
dp=[0]*(N+1)
dp[0]=1
if not 1 in br:
    dp[1]=1
for i in range(2,N+1):
    if not i in br:
        dp[i]+=(dp[i-1]+dp[i-2])%1000000007
print(dp[-1])
### BUGGY CODE ###

H=int(input())-1
K = [list(map(int, input().split())) for i in range(H)]
total_total=[]
for j in range(H):
    total=K[j][0]+K[j][1]
    for i in range(j,H-1):
        c1=K[i][0]
        s1=K[i][1]
        f1=K[i][2]
        c2=K[i+1][0]
        s2=K[i+1][1]
        f2=K[i+1][2]
        if total>s2:
            count=s2
            while total>count:
                count=count+f2
            total=count+c2
        else:
            total=s2+c2
    print(total)
print(0)

### FIXED CODE ###

H=int(input())-1
K = [list(map(int, input().split())) for i in range(H)]
total_total=[]
for j in range(H):
    total=K[j][0]+K[j][1]
    for i in range(j,H-1):
        c1=K[i][0]
        s1=K[i][1]
        f1=K[i][2]
        c2=K[i+1][0]
        s2=K[i+1][1]
        f2=K[i+1][2]
        if total>s2:
            if (total-s2)%f2==0:
                total=total+c2
            else:
                total=((total-s2)//f2+1)*f2+s2+c2
        else:
            total=s2+c2
    print(total)
print(0)
### BUGGY CODE ###

N, K, Q = input().split()
N = int(N)
K = int(K)
Q = int(Q)

A = []
for i in range(Q):
    A.append(int(input()))

people = []
for i in range(N):
    people.append(K)

for index in A:
    for i, p in enumerate(people):
        if i != index - 1:
            people[i] -= 1

for i in people:
    if i <= 0:
        print("No")
    else:
        print("Yes")


### FIXED CODE ###

N, K, Q = input().split()
N = int(N)
K = int(K)
Q = int(Q)

A = []
for i in range(Q):
    A.append(int(input()))

people = []
for i in range(N):
    people.append(K - Q)

for i in A:
    people[i-1] += 1

for i in people:
    if i <= 0:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

# 1からNまでの数字それぞれの約数を求める
# Nから(大きい値から)見ていき、1であれば入れる
# 数字iを入れた場合、iの約数の数を+1
# それぞれの数はdictで保持する

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

ans = [0 for _ in range(N)]

ans_num = 0
ans_list = ""
for i in range(N):
    tmp = N - i
    s = 0
    for j in range(tmp, N):
        if (j + 1) % tmp == 0:
            s += ans[j]

    if s % 2 != A[tmp - 1]:
        ans[tmp - 1] = 1
        ans_num += 1
        ans_list += str(tmp)
        ans_list += " "


print(ans_num)
print(ans_list[:-1])

### FIXED CODE ###

# 1からNまでの数字それぞれの約数を求める
# Nから(大きい値から)見ていき、1であれば入れる
# 数字iを入れた場合、iの約数の数を+1
# それぞれの数はdictで保持する

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

ans = [0 for _ in range(N)]

ans_num = 0
ans_list = ""
for i in range(N):
    tmp = N - i
    s = 0
    for j in range(tmp, N+1, tmp):
        s += ans[j-1]

    if s % 2 != A[tmp - 1]:
        ans[tmp - 1] = 1
        ans_num += 1
        ans_list += str(tmp)
        ans_list += " "


print(ans_num)
print(ans_list[:-1])
### BUGGY CODE ###

from bisect import bisect_left, bisect_right

n = int(input())
l = sorted(map(int, input().split()))
ans = 0
for i1 in range(n - 2):
    for i2 in range(i1 + 1, n - 1):
        a = l[i1]
        b = l[i2]
        i3s = bisect_right(l, b - a, i2 + 1)
        i3e = bisect_left(l, a + b, i3s)
        ans += i3e - i3s
print(ans)


### FIXED CODE ###

from bisect import bisect_left, bisect_right

n = int(input())
l = sorted(map(int, input().split()))
ans = 0
for i1 in range(n - 2):
    for i2 in range(i1 + 1, n - 1):
        a = l[i1]
        b = l[i2]
        i3s = max(bisect_right(l, b - a), i2 + 1)
        i3e = bisect_left(l, a + b)
        ans += i3e - i3s
print(ans)