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

from collections import deque

H, W = map(int, input().split())
dist_matrix = [[-1] * W for i in range(H)]
#queue = []
queue = deque()
for i in range(H):
  line_list = list(input())
  #for j in range(W):
  for j,ch in enumerate(line_list):
    #if line_list[j] == "#":  
    if ch == "#":
      dist_matrix[i][j] = 0
      queue.append([i,j])

#cnt = 0
#print(queue)
max_value = 0
while(True):
  #print(len(queue))
  if len(queue) == 0:
    break
  
  #i,j = queue.pop(0)
  i,j = queue.popleft()
  max_value = dist_matrix[i][j]
  #cnt += 1
  if i > 0 and dist_matrix[i-1][j] == -1:
    dist_matrix[i-1][j] = max_value + 1
    queue.append([i-1,j])
  if i < H-1 and dist_matrix[i+1][j] == -1:
    dist_matrix[i+1][j] = max_value + 1
    queue.append([i+1,j])
  if j > 0 and dist_matrix[i][j-1] == -1:
    dist_matrix[i][j-1] = max_value + 1
    queue.append([i,j-1])
  if j < W-1 and dist_matrix[i][j+1] == -1:
    dist_matrix[i][j+1] = max_value + 1
    queue.append([i,j+1])

#print(cnt)
#print(dist_matrix)
print(max_value)

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
 
H, W = map(int, input().split())
mark_matrix = [[True]*(W+2)]
#mark_matrix.extend([[True]+[False]*(W)+[True] for _ in range(H)])
mark_matrix.extend([[True]+[x!='.' for x in input()] for _ in range(H)])
mark_matrix[H].append(True)
mark_matrix.append([True]*(W+2))
#queue = []
queue = deque()
for i in range(1,H+1):
  for j in range(1,W+1):
    if mark_matrix[i][j]:
      queue.append((i,j))
#  line = input()
#  for j,ch in enumerate(line):
#    if ch == "#":
#      mark_matrix[i+1][j+1] = True
#      queue.append((i+1,j+1))
#for i in range(1,H+1):
#  mark_matrix[i][0] = True
#  mark_matrix[i][W+1] = True
#for j in range(W+2):
#  mark_matrix[0][j] = True
#  mark_matrix[H+1][j] = True
#print(mark_matrix)
 
#cnt = 0
#print(queue)
max_value = 0
while(True):
  #print(len(queue))
  if len(queue) == 0:
    break
  
  new_queue = deque()
  for i,j in queue:
  
    if not mark_matrix[i-1][j]:
      mark_matrix[i-1][j] = True
      #queue.append((i-1,j))
      new_queue.append((i-1,j))
    if not mark_matrix[i+1][j]:
      mark_matrix[i+1][j] = True
      #queue.append((i+1,j))
      new_queue.append((i+1,j))
    if not mark_matrix[i][j-1]:
      mark_matrix[i][j-1] = True
      #queue.append((i,j-1))
      new_queue.append((i,j-1))
    if not mark_matrix[i][j+1]:
      mark_matrix[i][j+1] = True
      #queue.append((i,j+1))
      new_queue.append((i,j+1))
 
  if len(new_queue) == 0:
    break
  else:
    queue = new_queue
    max_value += 1
  
#print(cnt)
#print(dist_matrix)
print(max_value)
### BUGGY CODE ###

INFTY = 10**9+7
N = int(input())
A = list(map(int,input().split()))
if N%2==0:
    flag = 0
    for i in range(1,N,2):
        if A.count(i)==2:
            pass
        else:
            flag = 1
            break
else:
    flag = 0
    for i in range(2,N,2):
        if A.count(i)==2:
            pass
        else:
            flag = 1
            break
    if A.count(0)!=1:
        flag = 1
if flag==0:
    cnt = 1
    for i in range(N//2):
        cnt = (cnt*2)%INFTY
else:
    cnt = 0
print(cnt)

### FIXED CODE ###

INFTY = 10**9+7
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    if A[i] not in C:
        C[A[i]] = 0
    C[A[i]] += 1
if N%2==0:
    flag = 0
    for i in range(1,N,2):
        if i in C and C[i]==2:
            pass
        else:
            flag = 1
            break
else:
    flag = 0
    for i in range(2,N,2):
        if i in C and C[i]==2:
            pass
        else:
            flag = 1
            break
    if 0 not in C or C[0]!=1:
        flag = 1
cnt = 0
if flag==0:
    cnt = 1
    for i in range(N//2):
        cnt = (cnt*2)%INFTY
print(cnt)
### BUGGY CODE ###

INF = 10 ** 12
BLACK = '#'
WHITE = '.'
H, W = [int(i) for i in input().split()]
M = []
D = [[INF] * W for _ in range(H)]

for i in range(H):
    M.append(list(input()))


for i in range(H):
    for j in range(W):
        if M[i][j] == BLACK:
            D[i][j] = 0


for i in range(H):
    for j in range(W):
        up = INF
        if i > 0:
            up = D[i-1][j]
        left = INF
        if j > 0:
            left = D[i][j-1]

        D[i][j] = min(D[i][j], up + 1, left + 1)

for i in range(H-1, -1, -1):
    for j in range(W-1, -1, -1):
        down = INF
        if i < H-1:
            down = D[i+1][j]
        right = INF
        if j < W-1:
            right = D[i][j+1]
        D[i][j] = min(D[i][j], down + 1, right + 1)

max_value = 0
for i in range(H):
    for j in range(W):
        if D[i][j] > max_value:
            max_value = D[i][j]
print(max_value)


### FIXED CODE ###

INF = 10 ** 11
BLACK = '#'
H, W = [int(i) for i in input().split()]
M = [None] * H
D = [[INF] * W for _ in range(H)]

for i in range(H):
    inputs = input()
    for idx, j in enumerate(inputs):
        if j == BLACK:
            D[i][idx] = 0


def forward_update(i, j):
    up = INF
    if i > 0:
        up = D[i-1][j]
    left = INF
    if j > 0:
        left = D[i][j-1]

    D[i][j] = min(D[i][j], up + 1, left + 1)


def backward_update(i, j):
    down = INF
    if i < H-1:
        down = D[i+1][j]
    right = INF
    if j < W-1:
        right = D[i][j+1]
    D[i][j] = min(D[i][j], down + 1, right + 1)


_ = [forward_update(i, j) for i in range(H) for j in range(W)]
_ = [backward_update(i, j) for i in range(H-1, -1, -1) for j in range(W-1, -1, -1)]

max_value = max([max(x) for x in D])
print(max_value)
### BUGGY CODE ###

n = int(input())
D ={}
for i in range(n):
    s = input()
    if s in D.keys(): #sが辞書Dにあるのかチェック(これはある場合)
        D[s] += 1 #D[s] += 1 ->{'s':今までに出てきた回数+1}となる
    else:  #sが辞書Dにない場合
        D[s] = 1 #D[s] = 1 ->{'s':1}となる
poll = [k for k,v in D.items() if v == max(D.values())]
poll.sort()
for j in range(len(poll)):
    print(poll[j])

### FIXED CODE ###

n = int(input())
D ={}
for i in range(n):
    s = input()
    if s in D.keys(): #sが辞書Dにあるのかチェック(これはある場合)
        D[s] += 1 #D[s] += 1 ->{'s':今までに出てきた回数+1}となる
    else:  #sが辞書Dにない場合
        D[s] = 1 #D[s] = 1 ->{'s':1}となる
maxD = max(D.values())
poll = [k for k,v in D.items() if v == maxD]
print('\n'.join(sorted(poll)))
### BUGGY CODE ###

def main():
    N = int(input())
    A = list(map(int,input().split()))
    C = 1
    for i in range(N):
        C *= A[i]
    if C > 10**18:
        C = '-1'
    print(C)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int,input().split()))
    C = 1
    if 0 in A:
        print(0)
    else:
        for i in range(N):
            C *= A[i]
            if C > 10**18:
                C = '-1'
                break
            
        print(C)
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

#C-write and erase
n=int(input())
a=[int(input()) for i in range(n)]
a.sort()

b=0
c=0
while b!=n:
    d=a.count(a[b]) 
    if d%2==0:
        c+=0
    else:
        c+=1
    b+=d
    
print(c)



### FIXED CODE ###

#073C write and erase

n=int(input())
s=set()
for i in range(n):
    a=int(input())
    if a in s:
        s.remove(a)
    else:
        s.add(a)

print(len(s))
### BUGGY CODE ###



def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    OPT[i][j] - number of pairs for first i man, with mask j=0011..01

    OPT[i+1][j|k] += OPT[i][j] k has exactly one bit set j|k != j and i+1 is compatible with k-th woman

    """
    N = read_int()
    modulo = 10**9+7
    A = []
    for _ in range(N):
        A.append(read_ints())
    OPT = [
        [0]*(2**N) for _ in range(1+N)
    ]
    OPT[0][0] = 1
    S = set([0])
    for i in range(N):
        #new_S = set()
        for j in range(2**N):
            for k in range(N):
                if j & (1 << k) == 0 and A[i][k] == 1:
                    OPT[i+1][j|(1 << k)] = (OPT[i+1][j|(1 << k)]+OPT[i][j])%modulo
                    #new_S.add(j|(1 << k))
        #S = new_S
    return OPT[-1][-1]


if __name__ == '__main__':
    print(solve())


### FIXED CODE ###



def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def count_bits(N):
    T = 0
    while N != 0:
        T += N & 1
        N >>= 1
    return T


def solve():
    """
    OPT[i][j] - number of pairs for first i man, with mask j=0011..01

    OPT[i+1][j|k] += OPT[i][j] k has exactly one bit set j|k != j and i+1 is compatible with k-th woman

    """
    N = read_int()
    modulo = 10**9+7
    A = []
    for _ in range(N):
        A.append(read_ints())
    dp = [0]*(2**N)
    dp[0] = 1
    for mask in range(2**N-1):
        a = count_bits(mask)
        for b in range(N):
            if A[a][b] and mask&(1<<b) == 0:
                dp[mask|(1<<b)] = (dp[mask|(1<<b)]+dp[mask])%modulo
    return dp[-1]


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

from bisect import bisect_left as bisect
import sys
sys.setrecursionlimit(10**9)

N = int(input())
a = list(map(int,input().split()))
g = [[] for _ in range(N)]
for i in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)

ans = [0]*N
def dfs(t,f,l):
    res = 0
    i = bisect(l,a[t])
    if len(l)==i:
        l.append(a[t])
    else:
        res = [i,l[i]]
        l[i]=a[t]
    ans[t] = len(l)
    for v in g[t]:
        if v != f:
            back = dfs(v,t,l)
            if back:
                l[back[0]] = back[1]
            else:
                l.pop()
    return res
dfs(0,0,[])
for i in range(N):
    print(ans[i])

### FIXED CODE ###

from bisect import bisect_left as bisect
import sys
sys.setrecursionlimit(10**9)

N = int(input())
a = list(map(int,input().split()))
g = [[] for _ in range(N)]
for i in range(N-1):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    g[u].append(v)
    g[v].append(u)

ans = [0]*N
def dfs(t,f,l):
    res = 0
    i = bisect(l,a[t])
    if len(l)==i:
        l.append(a[t])
    else:
        res = [i,l[i]]
        l[i]=a[t]
    ans[t] = len(l)
    for v in g[t]:
        if v != f:
            back = dfs(v,t,l)
            if back:
                l[back[0]] = back[1]
            else:
                l.pop()
    return res
dfs(0,0,[])
for i in range(N):
    print(ans[i])
### BUGGY CODE ###

N = int(input())
A = [int(input()) for c in range(N)]
ans = []

for i in A:
    if i in ans:
        ans.remove(i)
    else:
        ans.append(i)
print(len(ans))

### FIXED CODE ###

N = int(input())
A = [int(input()) for c in range(N)]
A = sorted(A)

tmp = 1
cnt = 0
for i in range(N):    
    if i+1<N:
        if A[i] == A[i+1]:
            tmp += 1
        else:
            cnt += tmp%2
            tmp = 1
    else:
        cnt += tmp%2

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

n,m=map(int,input().split())
a=list(map(int,input().split()))
def factorization(n):
    arr={}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i]=cnt
    if temp!=1:
        arr[temp]=1
    if arr==[]:
        arr[n]=1
    return arr
b=factorization(a[0])[2]
for i in range(1,n):
  if b==factorization(a[i])[2]:
    continue
  else:
    print(0)
    exit(0)
from fractions import gcd
lcmn=a[0]//2
for i in range(1,n):
    lcmn=(lcmn*a[i]//2)//gcd(lcmn,a[i]//2)
print((1+m//lcmn)//2)


### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
def func(n):
  ret=0
  n=n/2
  while n.is_integer():
    ret+=1
    n=n/2
  return ret
b=func(a[0])
for i in range(1,n):
  if b==func(a[i]):
    continue
  else:
    print(0)
    exit(0)
from fractions import gcd
lcmn=a[0]//2
for i in range(1,n):
    lcmn=(lcmn*a[i]//2)//gcd(lcmn,a[i]//2)
print((1+m//lcmn)//2)
### BUGGY CODE ###

n=int(input())
A=list(map(int,input().split()))
q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    for j in range(len(A)):
        if A[j]==b:
            A[j]=c
    #print(A)
    print(sum(A))
    

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
q=int(input())
B=[0 for i in range(10**5)]
for a in A:
    B[a-1]+=1
suma=sum(A)
for i in range(q):
    b,c=map(int,input().split())
    print(B[b-1]*(c-b)+suma)
    suma+=B[b-1]*(c-b)
    B[c-1]+=B[b-1]
    B[b-1]=0
### BUGGY CODE ###

MOD = 1000000007
n = int(raw_input())
d = {}
for i, ai in enumerate(int(_) for _ in raw_input().split()):
    if ai in d:
        stt = d[ai]
        end = i
        break
    d[ai] = i
del d, i, ai


def ncr(n, r):
    if r * 2 > n:
        return ncr(n, n - r)
    p = q = 1
    for i in xrange(n - r + 1, n + 1):
        p = p * i % MOD
    for i in xrange(1, r + 1):
        q = q * i % MOD
    return (p * pow(q, MOD - 2, MOD)) % MOD


l = stt
r = n - end

for k in xrange(1, n + 2):
    a = ncr(n + 1, k) % MOD
    if l + r >= k - 1:
        a -= ncr(l + r, k - 1) % MOD
    print a % MOD


### FIXED CODE ###

MOD = 1000000007
n = int(raw_input())
d = {}
for i, ai in enumerate(int(_) for _ in raw_input().split()):
    if ai in d:
        stt = d[ai]
        end = i
        break
    d[ai] = i
del d, i, ai

fac = {0: 1}
facinv = {}
for i in xrange(1, n + 2):
    fac[i] = fac[i - 1] * i % MOD
facinv[n + 1] = pow(fac[n + 1], MOD - 2, MOD)
for j in xrange(n, -1, -1):
    facinv[j] = facinv[j + 1] * (j + 1) % MOD


def ncr(n, r):
    return (fac[n] * facinv[n - r] * facinv[r]) % MOD


l = stt
r = n - end

for k in xrange(1, n + 2):
    a = ncr(n + 1, k) % MOD
    if l + r >= k - 1:
        a -= ncr(l + r, k - 1) % MOD
    print a % MOD
### BUGGY CODE ###

import sys

Num = int(sys.stdin.readline().rstrip())
list_stu_Num = list(sys.stdin.readline().rstrip().split())
list_attend_stu = []
list_stu_Serial_Num = list(range(1, Num + 1))
for i in list_stu_Serial_Num:
    i = str(i)
    l = list_stu_Num.index(i)
    list_attend_stu.append(l)
print(*list(map(lambda x: x + 1, list_attend_stu)))


### FIXED CODE ###

import sys
import numpy as np

Num = int(sys.stdin.readline().rstrip())
list_stu_Num = list(sys.stdin.readline().rstrip().split())
list_stu_Num_int = [int(s) for s in list_stu_Num]
print(*np.argsort(list_stu_Num_int) + 1)
### BUGGY CODE ###

import numpy as np

N = int(input())
C_arr = np.zeros(N)
B_arr = np.zeros(N)
for i in range(N):
    A, B = map(int, input().split())
    C_arr[i], B_arr[i] = (B-A)%B, B
count = 0
for i in range(N-1, -1, -1):
    count += C_arr[i]
    C_arr[:i] = (C_arr[:i] - C_arr[i]) % B_arr[:i]
print(int(count))


### FIXED CODE ###

N = int(input())

B_list = []
C_list = []
for i in range(N):
    A, B = map(int, input().split())
    B_list.append(B)
    C_list.append((B-A) % B)

count = 0
for i in range(N-1, -1, -1):
    count += (C_list[i] - count) % B_list[i]
print(count)
### BUGGY CODE ###

import sys
import bisect
input = sys.stdin.readline

def main():
    N = int(input())
    S = [int(s) for s in input().split()]
    S.sort()

    cur = []
    cur.append(S.pop(-1))

    for i in range(N):
        nxt = [j for j in cur]
        for x in cur:
            bl = bisect.bisect_left(S,x)
            if bl==0:
                return("No")
            else:
                nxt.append(S.pop(bl-1))
        cur = [j for j in nxt]
    return("Yes")

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

### FIXED CODE ###

import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])


def main():
    N = I()
    S = sorted(LI(),reverse=True)

    flag = [True]*len(S)

    cur = []
    cur.append(S[0])
    flag[0] = False

    for i in range(N):
        nxt = [x for x in cur]
        j = 0

        for k in range(len(S)):
            if j >= len(cur):
                break
            elif flag[k] and S[k]<cur[j]:
                nxt.append(S[k])
                j+=1
                flag[k] = False
        if len(cur) != j:
            return("No")
        cur = sorted(nxt,reverse=True)
    return("Yes")

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

import sys
input=sys.stdin.readline

n,m=map(int,input().split())
inf=10**9+7
dp=[inf]*(2**n)
dp[0]=0

for i in range(m):
    a,b=map(int,input().split())
    C=list(map(int,input().split()))
    bit=0
    for i in C:
        bit|=(1<<(i-1))
    for j in range(2**n):
        dp[j|bit]=min(dp[j|bit],dp[j]+a)

if dp[-1]>=inf:
    print(-1)
else:
    print(dp[-1])

### FIXED CODE ###

import sys
input=sys.stdin.readline

n,m=map(int,input().split())
inf=10**9+7
dp=[inf]*(2**n)
dp[0]=0

for i in range(m):
    a,b=map(int,input().split())
    C=list(map(int,input().split()))
    bit=0
    for i in C:
        bit|=(1<<(i-1))
    for j in range(2**n):
        dp[j|bit]=min(dp[j|bit],dp[j]+a)

if dp[-1]>=inf:
    print(-1)
else:
    print(dp[-1])
### BUGGY CODE ###

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    for _ in range(M):
        B, C = map(int, input().split())
        A += [C] * B

    A.sort(reverse=True)
    ans = 0
    for i in range(N):
        ans += A[i]

    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import defaultdict

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    d = defaultdict(int)
    for a in A:
        d[a] += 1
    for _ in range(M):
        B, C = map(int, input().split())
        d[C] += B

    sort_d = sorted(d.items(),reverse = True)

    cnt = 0
    ans = 0
    for i,j in sort_d:
        if cnt + j < N:
            ans += i * j
            cnt += j
        elif cnt + j >= N:
            if cnt == N:
                break
            ans += i * (N - cnt)
            break 

    print(ans)



main()
### BUGGY CODE ###

n = int(input())
ans = 0
aaa = 2
maxi = 2
def prime(aaa):
    if n != 1:
        i = 2
        while i*i <= aaa:
            if aaa % i == 0:
                return False
            i += 1
        return True
    else:
        return False
def make_divisors(n):
    if prime(n):
        return True
    a = 0
    i = 2
    while i <= n:
        if n % i == 0:
            if a == 0:
                a = i
                n /= i
                i -= 1
                if n == 1:
                    return True
            elif a == i:
                n /= i
                i -= 1
                if n == 1:
                    return True
                pass
            else:
                return False
        i += 1
    return True
def divisors(a, i):
    global ans, aaa, maxi
    while i <= n and i <= a:
        if prime(a) and i * i <= a:
            ans += 1
            break
        if a % i == 0:
            if make_divisors(i):
                ans += 1
                num = a / i
                aaa = num
                if maxi <= i:
                    maxi = i
                divisors(num, i+1)
                break
        i += 1
if n == 1:
    print(0)
else:
    if prime(n):
        print(1)
    else:
        divisors(n, 2)
        print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
aaa = 2
maxi = 2
def prime(aaa):
    global primemode
    if n != 1:
        i = 2
        while i*i <= aaa:
            if aaa % i == 0:
                primemode = False
                return False
            i += 1
        return True
    else:
        return False
def make_divisors(n):
    if prime(n):
        return True
    a = 0
    i = 2
    while i <= n:
        if n % i == 0:
            if a == 0:
                a = i
                n /= i
                i -= 1
                if n == 1:
                    return True
            elif a == i:
                n /= i
                i -= 1
                if n == 1:
                    return True
                pass
            else:
                return False
        i += 1
    return True
def divisors(a, i):
    global ans, aaa, maxi, primemode
    while i <= n and i <= a:
        if i * i <= a and primemode:
            if prime(a):
                ans += 1
                break
        if a % i == 0:
            if make_divisors(i):
                primemode = True
                ans += 1
                num = a / i
                aaa = num
                if maxi <= i:
                    maxi = i
                divisors(num, i+1)
                break
        i += 1
if n == 1:
    print(0)
else:
    if prime(n):
        print(1)
    else:
        divisors(n, 2)
        print(ans)
### BUGGY CODE ###

s=input()
t=[]
ans=0
for c in s:
    l=len(t)
    for i in range(l):
        t[i]*=10
        t[i]+=int(c)
        t[i]%=2019
        if t[i]==0:
            ans+=1
    t.append(int(c))
    t=list(set(t))
print(ans)

### FIXED CODE ###

S=input()
MOD=2019
dp=[0]*MOD
dp[0]=1
r=0
t=1
for c in reversed(S):
    r+=int(c)*t
    r%=MOD
    t*=10
    t%=MOD
    dp[r]+=1
print(sum(i*(i-1)//2 for i in dp))
### BUGGY CODE ###

n,k = map(int,input().split())
ans = 0
for i in range(n):
    if i >= k:
      ans += float(1/n)
    else:
      c = i
      d=0
      while c<k:
        c = c*2
        d+=1
      ans +=float(1/(n*(2**d)))
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
ans = 1
for i in range(1,n+1):
    if i < k:
      c = i
      d=0
      while c<k:
        c = c*2
        d+=1
      ans -=float((2**d-1)/(n*(2**d)))
print(ans)
### BUGGY CODE ###

A,B,C,D = map(int,input().split())
result = [i for i in range(A,B+1) if i%C!=0 and i%D!=0]
ans = len(result)
print(ans)


### FIXED CODE ###

import fractions as f
a,b,c,d = map(int,input().split())
i = abs((a-1)//c-b//c)
j = abs((a-1)//d-b//d)
 
def lcm(x,y):
  return (x*y)//f.gcd(x,y)
l = lcm(c,d)
k = abs((a-1)//l-b//l)
print(b-a+1-(i+j-k))
### BUGGY CODE ###

import bisect

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

construction = [list(map(int, input().rstrip().split(' '))) for _ in range(N)]
D = [int(input()) for _ in range(Q)]
construction = sorted(construction, key=lambda x: x[2])

dist = [-1] * Q
indices = list(range(Q))
for c in construction:
    i1 = bisect.bisect_left(D, c[0] - c[2])
    i2 = bisect.bisect_left(D, c[1] - c[2])
    for i in list(range(i1, i2))[::-1]:
        D.pop(i)
        dist[indices[i]] = c[2]
        indices.pop(i)
    
for d in dist:
    print(d)

### FIXED CODE ###

import sys
import bisect
input=sys.stdin.readline

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

construction = [list(map(int, input().split(' '))) for _ in range(N)]
D = [int(input()) for _ in range(Q)]
construction = sorted(construction, key=lambda x: x[2])

dist = [-1] * Q
jump = [-1] * Q
indices = list(range(Q))
for s, t, x in construction:
    i1 = bisect.bisect_left(D, s-x)
    i2 = bisect.bisect_left(D, t-x)
    i = i1
    while i < i2:
        k = jump[i]
        if k != -1:
            i = k
        else:
            jump[i] = i2
            dist[i] = x
            i += 1
    
for d in dist:
    print(d)
### BUGGY CODE ###

S = input()
N = len(S)
mod_list = [0]*2020
mod_list[0] = 1

mod = 2019

for i in range(N):
    num = int(S[N-i-1:N])
    mod_list[num%mod] += 1
    
ans = 0

for i in mod_list:
    ans += i*(i-1)//2
        
print(ans)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import Counter

S = input()

P = 2019
N = len(S)

def solve_2(S):
    ind = (i for i, x in enumerate(S, 1) if x % 2 == 0)
    return sum(ind)

def solve_5(S):
    ind = (i for i, x in enumerate(S, 1) if x % 5 == 0)
    return sum(ind)

def solve(S,P):
    if P == 2:
        return solve_2(S)
    if P == 5:
        return solve_5(S)
    S = S[::-1]
    T = [0] * len(S)
    T[0] = int(S[0]) % P
    power = 1
    for i in range(1, len(S)):
        power *= 10
        power %= P
        T[i] = T[i-1] + power * int(S[i])
        T[i] %= P
    counter = Counter(T)
    return sum(x * (x - 1) // 2 for x in counter.values()) + counter[0]


print(solve(S,P))
### BUGGY CODE ###

from collections import deque

n = int(input())
D = deque()
for i in range(n):
    x = int(input())
    if x in D:
        D.remove(x)
    else:
        D.append(x)
print(len(D))

### FIXED CODE ###

from collections import Counter
n = int(input())
A = Counter([int(input()) for i in range(n)]).most_common()
B = []

for i in range(len(A)):
    if A[i][1] % 2 == 1:
        B.append(A[i][1])
        
print(len(B))