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

import sys
import numpy as np

N = int(sys.stdin.readline())
L = np.array(list(map(int, sys.stdin.readline().split())))
L = np.sort(L)

count = 0

for i in range(N - 2):
    a = L[i]
    for j in range(i + 1, N - 1):
        b = L[j]
        c_cand = L[j + 1:]
        c_num = np.count_nonzero(c_cand < a + b)
        count += c_num
        
print(count)

### FIXED CODE ###

import sys
import bisect

N = int(sys.stdin.readline())
L = list(map(int, sys.stdin.readline().split()))
L.sort()

count = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        c = bisect.bisect_left(L, L[i]+L[j])
        if c > j:
            count += c - j - 1
        else:
            pass
        
print(count)
### BUGGY CODE ###

import sys

N=int(input())
st=0
en=N-1
print(st)
sys.stdout.flush()
s=input().split()
if s=="Vacant":
  sys.exit()
print(en)
sys.stdout.flush()
e=input().split()
if e=="Vacant":
  sys.exit()
a=st
b=en
c=s
d=e

for i in range(18):
  x=(a+b)/2
  print(x)
  sys.stdout.flush()
  f=input().split()

  if f=="Vacant":
    sys.exit()
  elif elif (x-a)%2==0 and c!=f and elif (x-a)%2==1 and c!=f:
    a=x
    c=f
  elif elif (x-a)%2==0 and c==f and elif (x-a)%2==1 and c==f:
    b=x
    d=f
  elif (x-a)%2==0 and c!=f:
    b=x
    d=f
  elif (x-a)%2==1 and c!=f:
    a=x
    c=f
  elif (x-a)%2==0 and c==f:
    a=x
    c=f
  elif (x-a)%2==1 and c==f:
    b=x
    d=f

### FIXED CODE ###

import sys

N=int(input())
st=0
en=N
print(st)
sys.stdout.flush()
s=input().split()
if s=="Vacant":
  sys.exit()
a=st
b=en
c=s
d=s

for i in range(19):
  x=(a+b)//2
  print(x)
  sys.stdout.flush()
  f=input().split()

  if f=="Vacant":
    sys.exit()
  elif (x-a)%2==0 and c!=f:
    b=x
    d=f
  elif (x-a)%2==0 and c==f:
    a=x
    c=f
  elif (x-a)%2==1 and c!=f:
    a=x
    c=f
  elif (x-a)%2==1 and c==f:
    b=x
    d=f
### BUGGY CODE ###

from functools import reduce
N,M=map(int,input().split())
x=set()
L,R=map(int,input().split())
x=set(range(L,R+1))
for i in range(M-1):
    L,R=map(int,input().split())
    x=x & set(range(L,R+1))
print(len(x))    

### FIXED CODE ###

import sys
N,M=map(int,input().split())
_min,_max=map(int,input().split())
for i in range(M-1):
   L,R=map(int,input().split())
   if R<_min or L>_max:
       print(0)
       sys.exit()
   _min,_max=max(_min,L),min(_max,R)
print(_max+1-_min)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    h, n = input_to_int_map()
    ab = [input_to_int_tuple() for i in range(n)]

    x = max(a for a, b in ab)

    dp = [0] * (h + x)
    for i in range(1, h + 1):

        min_val = 9999999999
        for a, b in ab:
                min_val = min(min_val, dp[i - a] + b)

        dp[i] = min_val

    return dp[h]


if __name__ == "__main__":
    print(main())


### FIXED CODE ###

# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    h, n = input_to_int_map()
    ab = [input_to_int_tuple() for i in range(n)]

    x = max(a for a, b in ab)

    dp = [0] * (h + x)
    for i in range(1, h + 1):

        dp[i] = min(dp[i - a] + b for a, b in ab)

    return dp[h]


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

from collections import deque
import heapq
import sys
input = sys.stdin.readline

f=lambda:map(int,input().split())
V,E,L=f()
G=[[] for _ in [0]*(V+1)]
# G=[]

for _ in range(E):
    s,t,d=f()
    if d<=L:
        G[s].append((t,d))
        G[t].append((s,d))

INF=V+5

res=[[(INF,0)]*(V+1) for _ in  [0]*(V+1)]

for start in range(1,V+1):
    q=[((0,0),start)]
    while q:
        c,town=heapq.heappop(q)
        if res[start][town]<c:
            continue
        h,cost=c
        for next_town,d in G[town]:
            D=cost+d
            if D<=L and (h,D)<res[start][next_town]:
                heapq.heappush(q,((h,D),next_town))
                res[start][next_town]=(h,D)
            elif D>L and (1+h,d)<res[start][next_town]:
                heapq.heappush(q,((1+h,d),next_town))
                res[start][next_town]=(1+h,d)

Q=int(input())
for _ in [0]*Q:
    s,t=f()
    r=res[s][t][0]
    print(r if r<INF else -1)

### FIXED CODE ###

import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

f=lambda:map(int,input().split())
N,M,L=f()
G=[[0]*N for _ in [0]*N]
for _ in [0]*M:
    a,b,c=f()
    G[a-1][b-1]=c
    G[b-1][a-1]=c
    
csr=csr_matrix(G)

D=floyd_warshall(csr)
INF=float('inf')
G=[[INF]*N for _ in [0]*N]
for i in range(N):
    for j in range(N):
        if i!=j and D[i][j]<=L:
            G[i][j]=1
            G[j][i]=1
csr=csr_matrix(G)
res=floyd_warshall(csr)
Q=int(input())
for _ in [0]*Q:
    s,t=f()
    r=res[s-1][t-1]
    print(int(r-1) if r<INF else -1)
### BUGGY CODE ###

an = int(input())

numbers = [an]
while True:
  if an%2 == 1:
    an = 3*an+1
  else:
    an = an*2
  if an in numbers:
    print(len(numbers)+1)
    break
  else:
    numbers.append(an)

### FIXED CODE ###

an = int(input())

numbers = [an]
while True:
  if an%2 == 1:
    an = 3*an+1
  else:
    an = an//2
  if an in numbers:
    print(len(numbers)+1)
    break
  else:
    numbers.append(an)
### BUGGY CODE ###

r1,c1,r2,c2=map(int,input().split())

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

p=10**9+7
N=2*10**6
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

print((cmb(r2+1+c2+1,c2+1,p)-cmb(r1+c2+1,c2+1,p)-cmb(r2+1+c1,c1,p)+cmb(r1+c1,c1,p))%p)

### FIXED CODE ###

r1,c1,r2,c2=map(int,input().split())

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

p=10**9+7
N=2*10**6+10
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

print((cmb(r2+1+c2+1,c2+1,p)-cmb(r1+c2+1,c2+1,p)-cmb(r2+1+c1,c1,p)+cmb(r1+c1,c1,p))%p)
### BUGGY CODE ###

n,q = [int(i) for i in input().split()]
s = input()
l = []
r = []
for i in range(q):
  l_tmp, r_tmp = [int(j) for j in input().split()]
  l.append(l_tmp-1)
  r.append(r_tmp-1)
  
ac_loc = []
flag = False
for i in range(n-1):
  if flag:
    flag = False
    continue
  if s[i:i+2] == 'AC':
    ac_loc.append(i)
    flag = True
ac_cnt = len(ac_loc)

up_cnt = []
down_cnt = []
for i in range(n):
  up_cnt.append(sum(i<=j for j in ac_loc))
  down_cnt.append(sum(j+1<=i for j in ac_loc))
  
for i in range(q):
  ans = up_cnt[l[i]] + down_cnt[r[i]] - ac_cnt
  print(ans)

### FIXED CODE ###

n,q = [int(i) for i in input().split()]
s = input()
l = []
r = []
for i in range(q):
  l_tmp, r_tmp = [int(j) for j in input().split()]
  l.append(l_tmp-1)
  r.append(r_tmp-1)
  
ac_cnt = s.count('AC')
r_cnt = [ac_cnt]
l_cnt = [0]
for i in range(1,n):
  if s[i-1:i+1] == 'AC':
    r_cnt.append(r_cnt[i-1]-1)
    l_cnt.append(l_cnt[i-1]+1)
  else:
    r_cnt.append(r_cnt[i-1])
    l_cnt.append(l_cnt[i-1])
    
for i in range(q):
  ans = r_cnt[l[i]] + l_cnt[r[i]] - ac_cnt
  print(ans)
### BUGGY CODE ###

n = int(input())
S = input()
cnt = 0
for i in range(1000):
  hy = i//100
  zyu = (i-hy*100)//10
  ichi = i%10
  cnt_hy = float('inf')
  cnt_zyu = float('inf')
  cnt_ichi = float('inf')
  t = 0
  for j in range(n):
    if t == 0:
      if int(S[j]) == hy:
        cnt_hy = j
        t += 1
    elif t == 1:
      if int(S[j]) == zyu:
        cnt_zyu = j
        t += 1
    elif t == 2:
      if int(S[j]) == ichi:
        cnt_ichi = j
        cnt += 1
        break
print(cnt)

### FIXED CODE ###

n = int(input())
S = input()
cnt = 0
for i in range(10):
  for j in range(10):
    for k in range(10):
      i_pos = S.find(str(i))
      if i_pos == -1:
        continue
      j_pos = S.find(str(j),i_pos+1)
      if j_pos == -1:
        continue
      k_pos = S.find(str(k),j_pos+1)
      if k_pos == -1:
        continue
      cnt += 1
print(cnt)
### BUGGY CODE ###

n = int(input())
ans = 0
for a in range (1,n):
    for b in range(1, n):
        temp = a * b
        if n <= temp:
            break
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for a in range (1,n):
    for b in range(a, n, a):
        ans += 1
print(ans)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
b = []
tmp = 0
while True:
    tmp = s.find("AC", tmp)
    if tmp == -1:
        break
    tmp += 1
    b.append(tmp)
ans = []
for i in range(q):
    l, r = map(int, input().split())
    ans.append(sum(l <= x < r for x in b))
print(*ans, sep="\n")


### FIXED CODE ###

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

N,M = map(int,input().split())
ALL = set([])
Graph = [[] for _ in range(N)]
#gyaku = [set([]) for _ in range(N)]
for i in range(N-1+M):
  a,b = map(int,input().split())
  a-=1;b-=1
  Graph[a].append(b)
  #gyaku[b].add(a)
  ALL.add(b)
#print(Graph,gyaku)
for i in range(N):
  if i not in ALL:
    root = i
    break

used = [0 for _ in range(N)]
used[root] +=1
ans = [0 for _ in range(N)]
Q = [root]
while Q:
  v = Q.pop()
  #print(v,Q,used[v])
  if used[v] > 1:
    used[v] -=1
    continue
  used[v] -=1
  #print(v,Q)
  for w in Graph[v]:
    ans[w] = v+1
    used[w] += 1
    Q.append(w)
for x in ans:
  print(x)
  


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
N,M = map(int,input().split())
ALL = [i for i in range(N)]
ALL = set(ALL)
Graph = [[] for _ in range(N)]
gyaku = [set([]) for _ in range(N)]
for i in range(N-1+M):
  a,b = map(int,input().split())
  a-=1;b-=1
  Graph[a].append(b)
  gyaku[b].add(a)
  ALL.discard(b)
#print(Graph,gyaku)
ALL = list(ALL);root = ALL[0]

used = set([])
TS = []
def dfs(v):
  if v in used:
    return
  used.add(v)
  for w in Graph[v]:
    if w in used:
      continue
    dfs(w)
    TS.append(w)
    
dfs(root)
TS.append(root)
TS.reverse()
#print(TS)
ans = [0 for _ in range(N)]
for i in range(N):
  now = TS[i]
  for nxt in Graph[now]:
    ans[nxt] = now+1
    
for x in ans:
  print(x)
### BUGGY CODE ###

from math import factorial
def ncr(n,r):
	if n<r:
		return 0
	else:
		return factorial(n)/(factorial(n-r)*factorial(r))

n = int(input())
arr = list(map(int,input().split()))
d = {}
for i in range(n):
	try:
		d[arr[i]].append(i)
	except KeyError:
		d[arr[i]] = [i]

done = {}
for i in range(n):
	try:
		if done[arr[i]] > -1:
			continue
	except KeyError:
		ans = 0
		for j in d.keys():
			if j == arr[i]:
				ans+= ncr(len(d[j])-1,2)
			else:
				ans+= ncr(len(d[j]),2)
		done[arr[i]] = int(ans)

for i in arr:
	print(done[i])
	



### FIXED CODE ###

from math import factorial
def nc2(n):
	if n<2:
		return 0
	else:
		return (n*(n-1))//2

n = int(input())
arr = list(map(int,input().split()))
d = {}
for i in range(n):
	try:
		d[arr[i]].append(i)
	except KeyError:
		d[arr[i]] = [i]

pick2 = {}
pick1 = {}
for i in d.keys():
	pick2[i] = nc2(len(d[i]))
	pick1[i] = nc2(len(d[i])-1)

sum_pick2 = sum(pick2.values())

done = {}

for i in d.keys():
	done[i] = (sum_pick2 - pick2[i] + pick1[i])

for i in arr:
	print(done[i])
### BUGGY CODE ###

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


while N!=0:
  if N>=abs(N-K):
    N = abs(N-K)
  elif N==0:
    break
  else:
    break
            
print(N)

### FIXED CODE ###

N, K = map(int, input().split())
if N>=K:
  N = N%K

while N!=0:
  if N>=abs(N-K):
    N = abs(N-K)
  elif N==0:
    break  
  else:
    break
print(N)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(int(1e6))

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

for _ in range(M):
    i = A.index(max(A))
    A[i] = A[i] // 2

print(sum(A))


### FIXED CODE ###

import sys
sys.setrecursionlimit(int(1e6))

import heapq

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
h_A = []
for a in A:
    heapq.heappush(h_A, -a)

for _ in range(M):
    x = heapq.heappop(h_A)
    heapq.heappush(h_A, -(-x // 2))

prices = [- heapq.heappop(h_A) for _ in range(N)]
print(sum(prices))
### BUGGY CODE ###

N = int(input())
arr = []
product = 1
# while i < N:
arr = ((input().split(' ')))

for i in arr:
    product = product * int(i)

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

### FIXED CODE ###

def main ():
    N = int(input())
    A = list(map(int,input().split()))
    if 0 in A: 
        print (0)
        return
    prod = 1 
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod) 

main ()
### BUGGY CODE ###

S = input()
K = int(input())

S = list(set(S[i:j] for i in range(len(S)) for j in range(i + 1, len(S) + 1)))
S.sort()
print(S[K - 1])


### FIXED CODE ###

S = input()
K = int(input())
N = len(S)

C = list(set(S[i:i + j + 1] for i in range(N) for j in range(K) if i + j < N))
C.sort()
print(C[K - 1])
### BUGGY CODE ###

N = int(input())

divList = []

n = N

while n != 1:
    div = 1
    for i in range(2, n+1):
        if n % i == 0:
            div = i
            break
    divList.append(div)
    n = int(n / div)
    # print(divList)

# print(divList)

t = [([1], [1])]

for d in divList:
    newT = []
    for ab in t:
        a, b = ab[0], ab[1]
        a_add = a[:]
        a_add.append(d)
        b_add = b[:]
        b_add.append(d)

        newT.append((a, b_add))
        newT.append((a_add, b))
    t = newT

# print(t)

from functools import reduce

a1 = [(reduce(lambda a, b:a * b, ab[0]), reduce(lambda a, b:a * b, ab[1]))
      for ab in t]
# print(a1)


a2 = [(len(str(ab[0])), len(str(ab[1]))) for ab in a1]

# print(a2)

a3 = [max(ab[0], ab[1]) for ab in a2]

# print(a3)

print(min(a3))


### FIXED CODE ###

N = int(input())


def countDigits(n):
    return len(str(n))


ans = countDigits(N)
A = 1
while A * A <= N:
    if(N % A != 0):
        A += 1
        continue
    B = N // A

    cur = max(countDigits(A), countDigits(B))
    if (ans > cur):
        ans = cur
    A += 1
print(ans)
### BUGGY CODE ###

N,K=map(int,input().split())
h=[]
for i in range(N):
    h.append(int(input()))
h.sort()

mindiff=max(h)-min(h)
for i in range(N-K+1):
    maxmin=max(h[i:i+K])-min(h[i:i+K])
    mindiff=min(mindiff,maxmin)
print(mindiff)


### FIXED CODE ###

N,K=map(int,input().split())
h=[]
for i in range(N):
    h.append(int(input()))
h.sort()

d=max(h)-min(h)
for i in range(N-K+1):
    d=min(d,h[i+K-1]-h[i])
print(d)
### BUGGY CODE ###

import bisect


class SegmentTreeRMQ(object):  # 1-indexed
    def __init__(self, size, value):
        self.len = 1 << size.bit_length()
        # print(self.len)
        self.array = [value] * (2 * self.len)

    def update(self, i, x):
        i += self.len
        while i > 0:
            self.array[i] = max(self.array[i], x)
            i >>= 1
        # print(self.array)

    def get(self, i):
        return self.array[i + self.len]

    def query(self, l, r, i, a, b):
        if l == a and r == b:
            return self.array[i]
        center = (a + b) // 2
        if center >= r:
            return self.query(l, r, i * 2, a, center)
        elif center <= l:
            return self.query(l, r, i * 2 + 1, center, b)
        else:
            return max(
                self.query(l, center, i * 2, a, center),
                self.query(center, r, i * 2 + 1, center, b))

    def get_maximum(self, l, r):
        return self.query(l, r, 1, 0, self.len)


N = int(input())
xd_array = [list(map(int, input().split())) for _ in range(N)]

xd_array = sorted(xd_array, key=lambda x: x[0])
x_array = [i[0] for i in xd_array]
d_array = [i[1] for i in xd_array]

mod = 998244353

tree = SegmentTreeRMQ(N, -1)
index_array = [0] * N
for i in range(N-1, -1, -1):
    move = x_array[i] + d_array[i] - 0.1
    max_index = bisect.bisect_left(x_array, move)
    max_move = tree.get_maximum(i, max_index)
    tree.update(i, max(max_move, i))
    index_array[i] = max(max_move, i)

ans_array = [0] * (N+1)
ans_array[-1] = 1
for i in range(N-1, -1, -1):
    ans_array[i] = (ans_array[i+1] + ans_array[index_array[i] + 1]) % mod

print(ans_array[0])


### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline


class SegmentTreeRMQ(object):  # 1-indexed
    def __init__(self, size, value):
        self.len = 1 << size.bit_length()
        # print(self.len)
        self.array = [value] * (2 * self.len)

    def update(self, i, x):
        i += self.len
        while i > 0:
            self.array[i] = max(self.array[i], x)
            i >>= 1
        # print(self.array)

    def get(self, i):
        return self.array[i + self.len]

    def get_maximum(self, l, r):
        L = l+self.len
        R = r+self.len
        ANS = -1 << 30

        while L < R:
            if L & 1:
                ANS = max(ANS, self.array[L])
                L += 1

            if R & 1:
                R -= 1
                ANS = max(ANS, self.array[R])
            L >>= 1
            R >>= 1

        return ANS


N = int(input())
xd_array = [list(map(int, input().split())) for _ in range(N)]

xd_array = sorted(xd_array, key=lambda x: x[0])
x_array = [i[0] for i in xd_array]
d_array = [i[1] for i in xd_array]

mod = 998244353

tree = SegmentTreeRMQ(N, -1)
ans_array = [0] * (N+1)
ans_array[-1] = 1
for i in range(N-1, -1, -1):
    move = x_array[i] + d_array[i] - 0.1
    max_index = bisect.bisect_left(x_array, move)
    max_move = max(i, tree.get_maximum(i, max_index))
    tree.update(i, max_move)
    ans_array[i] = (ans_array[i+1] + ans_array[max_move + 1]) % mod

print(ans_array[0])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
S = input()
C = 10**9+7


def answer(a):
    if a == '0' or a == '':
        return 1
    if a == '1':
        return 3
    if a[0] == '0':
        return answer(a[1:])
    else:
        b = a[1:]
        return (pow(3, (len(a)-1), C)+2*answer(b)) % C


print(answer(S))


### FIXED CODE ###

S = input()
C = 10**9+7
T = S[::-1]
N = len(S)
dp = [0]*N
dp[0] = 1+2*(int(T[0]))

for i in range(1, N):
    if T[i] == '0':
        dp[i] = dp[i-1]
    else:
        dp[i] = (pow(3, i, C)+2*dp[i-1]) % C
print(dp[-1])
### BUGGY CODE ###

import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input
L = input()
N = len(L)
MOD = 10 ** 9 + 7
bits = [1, 2]
acc = [1, 3]
for _ in range(N):
    nex = bits[-1] * 3 % MOD
    bits.append(nex)
    acc.append((acc[-1] + nex) % MOD)
ans = acc[N-1]
cnt = 1
for i, b in enumerate(L):
    if i == 0:
        continue
    now = N-i-1
    if b == '1':
        ans += acc[now] * pow(2, cnt) % MOD
        cnt += 1
    ans %= MOD
ans += pow(2, cnt)
ans %= MOD
print(ans)


### FIXED CODE ###

import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input
L = input()
N = len(L)
MOD = 10 ** 9 + 7
bits = [1, 2]
acc = [1, 3]
for _ in range(N):
    nex = bits[-1] * 3 % MOD
    bits.append(nex)
    acc.append((acc[-1] + nex) % MOD)
ans = acc[N-1]
cnt = 1
for i, b in enumerate(L):
    if i == 0:
        continue
    now = N-i-1
    if b == '1':
        ans += acc[now] * pow(2, cnt, MOD) % MOD
        cnt += 1
    ans %= MOD
ans += pow(2, cnt, MOD)
ans %= MOD
print(ans)
### BUGGY CODE ###

def resolve():
    n=int(input())
    a=list(map(int,input().split()))
    for i in range(n):
        ans=0
        for j in range(n):
            if j==i:
                continue
            ans=ans^a[j]
        print(ans)

if __name__ == '__main__':
    resolve()

### FIXED CODE ###

def resolve():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    for i in range(n):
        ans=ans^a[i]
    for i in range(n):
        print(ans^a[i])

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

s=(input())
n=len(s)

print(sum([int(s[i:j+1])%2019==0 for i in range(n) for j in range(i+3,n)]))

### FIXED CODE ###

S=input()[::-1]
l=[0]*2019
a=1
d=0

for s in S:
  d=d+int(s)*a
  l[d%2019]+=1
  a*=10
  a%=2019
  
ans=l[0]
for i in l:
  if i>=2:
    ans+=i*(i-1)//2
    
print(ans)
### BUGGY CODE ###

import math
import numpy as np

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = []
for i in range(1, N+1):
  B.append(list(range(math.ceil(i - A[i-1] -0.5), math.ceil(i + A[i-1] + 0.5))))
A = [0] * N
for x in B:
  for n in range(0, N):
    if n + 1 in x:
      A[n] += 1
if K >= 2:
  for i in range(math.ceil(np.log(K))):
    for k in range(1, N+1):
      B[k-1] = list(range(math.ceil(k - A[k-1] -0.5), math.ceil(k + A[k-1] + 0.5)))
    A = [0] * N
    for x in B:
      for n in range(0, N):
        if n + 1 in x:
          A[n] += 1
print(*A) 

### FIXED CODE ###

import sys
 
import numba as nb
import numpy as np
 
input = sys.stdin.readline
 
 
@nb.njit("i8[:](i8,i8,i8[:])", cache=True)
def solve(N, K, A):
    for _ in range(min(41, K)):
        A_cumsum = np.zeros(shape=N, dtype=np.int64)
        for i in range(N):
            A_cumsum[max(0, i - A[i])] += 1
            b = i + A[i] + 1
            if N - 1 < b:
                pass
            else:
                A_cumsum[b] -= 1
        A = np.cumsum(A_cumsum)
    return A
 
 
def main():
    N, K = map(int, input().split())
    A = np.array(input().split(), dtype=np.int64)
 
    ans = solve(N, K, A)
 
    print(" ".join(map(str, ans)))
 
 
if __name__ == "__main__":
    main()
### BUGGY CODE ###

a,b,c,k=map(int,input().split())
data=[]
for i in range(a):
    data.append(1)
for i in range(b):
    data.append(0)
for i in range(c):
    data.append(-1)
s=0
for i in range(k):
    s += data[i]
print(s)

### FIXED CODE ###

a,b,c,k=map(int,input().split())
if k < a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(2*a+b-k)