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

H, W, M = map(int, input().split())
P = []
X = [0 for i in range(H)]
Y = [0 for j in range(W)]
s = set([])
for i in range(M):
  h, w = map(int, input().split())
  X[h-1] += 1
  Y[w-1] += 1
  s.add((h-1, w-1)) #タプルを使う
I = [i for i in range(H) if X[i] == max(X)]
J = [j for j in range(W) if Y[j] == max(Y)]
flag = 0
for i in I:
  for j in J:
    if (i, j) not in s:
      flag = 1
      print(max(X)+max(Y))
      break
  if flag == 1:
    break
if flag == 0:
  print(max(X)+max(Y)-1)

### FIXED CODE ###

H, W, M = map(int, input().split())
X = [0 for i in range(H)]
Y = [0 for j in range(W)]
s = set([])
for i in range(M):
  h, w = map(int, input().split())
  X[h-1] += 1
  Y[w-1] += 1
  s.add((h-1, w-1)) #タプルを使う
mX = max(X)
mY = max(Y)
I = [i for i in range(H) if X[i] == mX]
J = [j for j in range(W) if Y[j] == mY]
flag = 0
for i in I:
  for j in J:
    if {(i, j)} <= s:
      continue
    flag = 1
    print(mX+mY)
    break
  if flag == 1:
    break
if flag == 0:
  print(mX+mY-1)
### BUGGY CODE ###

S = input()
Q = int(input())
flg = True
for _ in range(Q):
    query = input()
    if query[0] == "1":
        flg = not flg
    else:
        _,F,C = query.split()
        if (F == "1" and flg) or (F == "2" and not flg):
            S = C + S
        else:
            S = S + C
if not flg:
    S = S[::-1]
print(S)

### FIXED CODE ###

from collections import deque

S = deque(input())
Q = int(input())
flg = True
for _ in range(Q):
    query = input()
    if query[0] == "1":
        flg = not flg
    else:
        _,F,C = query.split()
        if (F == "1" and flg) or (F == "2" and not flg):
            S.appendleft(C)
        else:
            S.append(C)
if not flg:
    S.reverse()

print(''.join(S))
### BUGGY CODE ###

import copy
firstvar = input()
l = int(firstvar.split(" ")[0])
r = int(firstvar.split(" ")[1])
i = copy.deepcopy(l)
min = 2019
while i <= r:
    j = copy.deepcopy(i) + 1
    while j <= r:
        mod = (i*j)%2019
        if mod < min:
            min = copy.deepcopy(mod)
        j = j + 1
    i = i + 1
print(min)

### FIXED CODE ###

firstvar = input()
l = int(firstvar.split(" ")[0])
r = int(firstvar.split(" ")[1])
i = l
min = 2019
if (r/2019 - l/2019) >= 1:
    print(0)
else:
    for i in range(l,r + 1):
        for j in range(i + 1, r + 1):
            mod = (i*j)%2019
            if mod < min:
                min = mod
                if mod == 0:
                    break;
    print(min)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
n = len(a)
q = int(input())

for i in range(q):
  a.sort()
  b,c = map(int,input().split())
  for i in range(n):
    if a[i] == b:
      a[i] = c
    elif a[i] > b:
      break
  print(sum(a))
  

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=sum(a)
q=int(input())
dp=[0]*(10**5+1)
for i in a:
  dp[i]+=1

for j in range(q):
  b,c=map(int,input().split())
  ans+=(c-b)*dp[b]
  dp[c]+=dp[b]
  dp[b]=0
  print(ans)
### BUGGY CODE ###

N, A = map(int, input().split())
x = [int(i) for i in input().split()]
ans = 0

dp = [[[0]*(50*N+1) for j in range(N+1)] for k in range(N+1)]
dp[0][0][0] = 1 
for j in range(1,N+1):
  for k in range(N+1):
    for s in range(50*N+1):
      dp[j][k][s] = dp[j-1][k][s]
      if s>=x[j-1]:
        dp[j][k][s] += dp[j-1][k-1][s-x[j-1]]
for k in range(1,N+1):
  ans += dp[N][k][k*A]
print(ans)

### FIXED CODE ###

N, A = map(int, input().split())
x = [int(i) for i in input().split()]

table = [[[0]*(N*A+1) for i in range(N+1)] for j in range(N+1)]
table[0][0][0] = 1

for j in range(1,N+1):
  for k in range(N+1):
    for s in range(N*A+1):
      c = x[j-1]
      if s-c<0:
        table[j][k][s] = table[j-1][k][s]
      elif s-c>=0 and k>=1:
        table[j][k][s] = table[j-1][k][s] + table[j-1][k-1][s-c]
      
ans = 0
for i in range(1,N+1):
  ans += table[N][i][i*A]
print(ans)
### BUGGY CODE ###

s = input()
n = len(s)
slist = [int(i)for i in s]
q = True
ans = 0
while q:
  q = False
  kesu = []
  for i in range(1,len(slist)):
    if slist[i] != slist[i-1]:
      kesu.append(i)
      ans += 2
      q = True
      break
  if kesu:
    p = 0
    for i in kesu:
      del slist[i-1-p:i+1-p]
      p += 2

print(ans)

### FIXED CODE ###

s = input()
cnt1 = s.count('1')
cnt0 = s.count('0')
print(len(s)-abs(cnt1-cnt0))
### BUGGY CODE ###

'''input
100000 1
1 100000 100
'''
import sys
sys.setrecursionlimit(100100)
N, M = [int(x) for x in input().split()]

vien = [[] for _ in range(N)]

for _ in range(M):
	a, b, w = [int(x) for x in input().split()]
	a -= 1
	b -= 1
	w = w & 1
	vien[a].append(b)
	vien[b].append(a)

been = [False]*N
ats = 0
def dfs(x):
	been[x] = True
	for u in vien[x]:
		if not been[u]:
			dfs(u)


for i in range(N):
	if been[i]: continue

	ats += 1
	dfs(i)

print(ats)

### FIXED CODE ###

'''input
100000 1
1 100000 100
'''
import sys
sys.setrecursionlimit(100100)
N, M = [int(x) for x in input().split()]

vien = [[] for _ in range(N)]

for _ in range(M):
	a, b, w = [int(x) for x in input().split()]
	a -= 1
	b -= 1
	w = w & 1
	vien[a].append(b)
	vien[b].append(a)

been = [False]*N
ats = 0
def dfs(x):
	been[x] = True
	for u in vien[x]:
		if not been[u]:
			dfs(u)


for i in range(N):
	if been[i]: continue

	ats += 1
	dfs(i)

print(ats)
### BUGGY CODE ###

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

for t in T:
    if not D:
        break
    if t in D:
        D.remove(t)
    else:
        print("NO")
        break
else:
    print("YES")

### FIXED CODE ###

from collections import defaultdict

N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
Ddic = defaultdict(int)
Tdic = defaultdict(int)

for d in D:
    Ddic[d] += 1
for t in T:
    Tdic[t] += 1
for n, v in Tdic.items():
    Ddic[n] -= v
dv = Ddic.values()
if all(i >= 0 for i in dv):
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

from bisect import bisect_right as bisect
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = max(A)
a_to_i = [[] for _ in range(m+1)]
for i in range(N):
    a_to_i[A[i]].append(i)
now = 0
next_k_i = [[None]*N for _ in range(60)]
for now in range(N):
    h = 0
    i = bisect(a_to_i[A[now]], now)
    if i == len(a_to_i[A[now]]):
        i = 0
        h+=N
    i = a_to_i[A[now]][i]
    h+=(i-now+1)
    next_k_i[1][now] = ((i+1)%N, h)
for i in range(2, 60):
    for j in range(N):
        a, b = next_k_i[i-1][j]
        c, d = next_k_i[i-1][a]
        next_k_i[i][j] = (c, b+d)
now = 0
cnt = K*N
while cnt:
    flag = False
    for i in range(1, 60)[::-1]:
        a, b = next_k_i[i][now]
        if cnt>=b:
            cnt-=b
            now = a
            flag = True
            break
    if not flag:
        break
ans = []
while now<N:
    a = next_k_i[1][now][0]
    if next_k_i[1][now][0] == 0:
        a+=N
    if a>now+1:
        now = a
        continue
    ans.append(A[now])
    now+=1
print(*ans)

### FIXED CODE ###

from bisect import bisect_right
import sys
N, K = map(int, input().split())
A = list(map(int, input().split()))
a_to_i = [[] for _ in range(max(A)+1)]
for i in range(N):
    a_to_i[A[i]].append(i)
next_index = [-1]*N
for i in range(N):
    a = A[i]
    j = bisect_right(a_to_i[a], i)
    if j == len(a_to_i[a]):
        next_index[i] = a_to_i[a][0]+N
    else: next_index[i] = a_to_i[a][j]
now = 0
cnt = 0
while True:
    i = next_index[now]
    if i>=N:
        i%=N
        cnt+=1
    else: now = i
    i+=1
    if i>=N:
        cnt+=1
        i%=N
    now = i
    if now == 0:
        break
K%=cnt
if K==0:
    print()
    sys.exit()
ans = [A[0]]
K*=N
K-=1
now = 0
while now<K:
    ni = next_index[now%N]+1
    if(now//N)*N+ni-1 == K:
        ans.pop()
        break
    if (now//N)*N+ni>K:
        now+=1
        ans.append(A[now%N])
    else:
        now = (now//N)*N+ni
        ans[-1] = A[now%N]




print(*ans, sep = ' ')
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    dp = [[float('inf') for _ in range(10**5+1)] for _ in range(N)]
    dp[0][0] = 0
    dp[0][v[0]] = w[0]

    js = [0,v[0]]

    for i in range(1,N):
        for j in js[:]:
            js.append(j+v[i])
        js = list(set(js))

        for j in js:
            if j - v[i] >= 0:
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i])
            else:
                dp[i][j] = dp[i-1][j]

    res = 0
    for i,j in enumerate(dp[-1]):
        if j != float("inf") and j <= W:
            res = i
    print(res)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    dp = [[float('inf') for _ in range(10**5+1)] for _ in range(N)]
    dp[0][0] = 0
    dp[0][v[0]] = w[0]

    js = [0,v[0]]

    for i in range(1,N):
        for j in js[:]:
            js.append(j+v[i])
        js = list(set(js))

        for j in js:
            if j - v[i] >= 0:
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i])
            else:
                dp[i][j] = dp[i-1][j]

    res = 0
    for i,j in enumerate(dp[-1]):
        if j != float("inf") and j <= W:
            res = i
    print(res)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

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

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

l = list(range(1, 200001))
count = 0
for i in range(n):
    if a[i] == l[0]:
        l.remove(l[0])
        count += 1

if count == 0:
    print(-1)
else:
    print(n - count)


### FIXED CODE ###

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

cnt = 0
for a in A:
	if a == cnt + 1:
		cnt += 1

if cnt == 0:
	print(-1)
else:
	print(n - cnt)
### BUGGY CODE ###

a = int(input())
b = list(map(int,input().split()))
num = 0
while True:
  for i in range(a):
    if b[i] % 2 == 0:
      c = b[i] / 2
      b[i] = c
      num += 1
    else:
      break

  

### FIXED CODE ###

import math
n = input()
a = list(map(int,input().split()))
ans = float("inf")
for i in a:
  ans = min(ans, len(bin(i))-bin(i).rfind("1") -1)
print(round(ans))
### BUGGY CODE ###

def distanced_nodes(neighbor, start_node, depth_limit):
    visited = [start_node]
    next_nodes = neighbor[start_node]
    depth = 1
    while len(next_nodes) > 0 and depth < depth_limit:
        depth += 1
        queue = next_nodes[:]
        visited += next_nodes
        next_nodes = []
        for q in queue:
            for node in neighbor[q]:
                if node in visited:
                    continue
                else:
                    next_nodes.append(node)
        next_nodes = list(set(next_nodes))
    return next_nodes

N, X, Y = list(map(int, input().split()))
neighbor = { i+1: [] for i in range(N) }
for i in range(1,N):
    neighbor[i].append(i+1)
    neighbor[N-i+1].append(N-i)
neighbor[X].append(Y)
neighbor[Y].append(X)

for i in range(1,N):
    pairs = set()
    for j in range(1,N+1):
        for node in distanced_nodes(neighbor, j, i):
            if node > j:
                pairs.add((j, node))
            else:
                pairs.add((node, j))
    print(len(pairs))


### FIXED CODE ###

def min_dist(i, j, X, Y):
    return min(abs(j-i), abs(X-1-i)+1+abs(Y-1-j), abs(Y-1-i)+1+abs(X-1-j))

N, X, Y = list(map(int, input().split()))
dists = [min_dist(i, j, X, Y) for i in range(N-1) for j in range(i+1, N)]
dist_dic = { i: 0 for i in range(1,N)}
for dist in dists:
    dist_dic[dist] += 1
for K in range(1,N):
    print(dist_dic[K])
### BUGGY CODE ###

N = int(input())
s = [''.join(sorted(input())) for _ in range(N)]

count = 0
for j in range(N):
    # print(j, s.count(s[j])-1)
    count += (s.count(s[j])-1)
print(count//2)


### FIXED CODE ###

N = int(input())
s = [''.join(sorted(input())) for _ in range(N)]

from collections import Counter
counter = Counter(s)
ans = sum(n*(n-1)//2 for n in counter.values())
print(ans)
### BUGGY CODE ###

n,m=(int(i) for i in input().split())
l=[[] for i in range(n+1)]
for i in range(m):
  a,b=(int(i) for i in input().split())
  l[a].append(b)
  l[b].append(a)
queue = []
visited = [] 
visited = [0 for i in range(n+1)]
ans=[None for i in range(n+1)]
queue.append([1,0])
visited[1]=1
while len(queue)>0:
  now=queue.pop(0)
  for i in l[now[0]]:
    if visited[i]==0:
      visited[i]=1
      queue.append([i,now[0]])
  ans[now[0]]=now[1]
print('Yes')
for i in range(n-1):
  print(ans[i+2])

### FIXED CODE ###

n,m=(int(i) for i in input().split())
l=[[] for i in range(n+1)]
for i in range(m):
  a,b=(int(i) for i in input().split())
  l[a].append(b)
  l[b].append(a)
queue = []
visited = [] 
visited = [0 for i in range(n+1)]
ans=[None for i in range(n+1)]
queue.append([1,0])
visited[1]=1
while len(queue)>0:
  now=queue.pop(0)
  for i in l[now[0]]:
    if visited[i]==0:
      visited[i]=1
      queue.append([i,now[0]])
  ans[now[0]]=now[1]
print('Yes')
for i in range(n-1):
  print(ans[i+2])
### BUGGY CODE ###

import itertools

N = int(input())
nums = list(map(int, input().split()))
box = []
memo = []

tmp = [0,1]
for balls in itertools.product(tmp, repeat=N):
    box.append(list(balls))

for x in range(len(box)):
    for i in range(1, N+1):
        total = 0
        for j in range(1, N+1):
            if j % i == 0:
                total += box[x][i-1]
        if nums[i-1] != total % 2:
            break
    else:
        memo = box[x]
        break
ans = []
count = 0
for i in range(len(memo)):
    if memo[i] == 1:
        count += 1
        ans.append(i+1)

print(count)
ans = [str(n) for n in ans]
ans = " ".join(ans)
print(ans)

### FIXED CODE ###

N = int(input())
nums = list(map(int, input().split()))
ans = [0] * N

for i in reversed(range(1,N+1)):
    count = 0
    total = 0
    # 倍数
    for j in range(i, N+1, i):
        count += 1
        total += ans[j-1]
    # 倍数が一つのとき
    if count == 1:
        if nums[i-1] == 0:
            ans[i-1] = 0
        else:
            ans[i-1] = 1
    # 倍数が複数ある
    else:
        # 指定が偶数
        if nums[i-1] == 0:
            if total % 2 != 0:
                ans[i-1] = 1
        else:
            if total % 2 == 0:
                ans[i-1] = 1


# 出力フォーマット処理
result = [i+1 for i in range(len(ans)) if ans[i] == 1]
result = [str(i) for i in result]
print(len(result))
print(" ".join(result))
### BUGGY CODE ###

L,R = map(int,input().split())
mn = 10**10
cal = 0
for i in range(L,R+1):
    for j in range(i+1,R+1):
        
        cal = (i%2019*j%2019)%2019
        if cal < mn:
            mn = cal
        if cal == 0:
            break
            
print(mn)
        

### FIXED CODE ###

L,R = map(int,input().split())
mn = 10**10
cal = 0
for i in range(L,R+1):
    for j in range(i+1,R+1):
        
        cal = ((i%2019)*(j%2019))%2019
        if cal < mn:
            mn = cal
        if cal == 0:
            break
    else:
        continue
    break
print(mn)
### BUGGY CODE ###

S = input()
Q = int(input())
turnover = False

for i in range(Q):
  TFC = input().split()
  T = int(TFC[0])
  if T == 1:
    # turn over
    turnover = not turnover
  elif T == 2:
    F = int(TFC[1])
    C = TFC[2]
    if turnover:
      if F == 1:
        F = 2
      else:
        F = 1
    if F == 1:
      S = C + S
      # put C before S
    elif F == 2:
      S = S + C
      # put C after S
if turnover:
  S = S[-1::-1]

print(S)

### FIXED CODE ###

S = input()
Q = int(input())
turnover = False
suffix = ""
prefix = ""

for i in range(Q):
  TFC = input().split()
  T = int(TFC[0])
  if T == 1:
    # turn over
    turnover = not turnover
  elif T == 2:
    F = int(TFC[1])
    C = TFC[2]
    if turnover:
      if F == 1:
        F = 2
      else:
        F = 1
    if F == 1:
      prefix = prefix + C
      # put C before S
    elif F == 2:
      suffix = suffix + C
      # put C after S
S = prefix[-1::-1]+S+suffix
if turnover:
  S = S[-1::-1]

print(S)
### BUGGY CODE ###

n = int(input())
sl = []
for _ in range(n):
    sl.append(input())
rl=[[0 for _ in range(26)] for _ in range(n)]
for i in range(n):
    for c in sl[i]:
        a=ord(c)-ord('a')
        rl[i][a]+=1
rslt=0
for i in range(n-1):
    for j in range(i+1,n):
        if rl[i] == rl[j]: rslt+=1
print(rslt)


### FIXED CODE ###

n = int(input())
S=[input() for _ in range(n)]
S=[''.join(sorted(i)) for i in S]
d={}
rslt=0
for s in S:
    if s in d:
        rslt+=d[s]
        d[s]+=1
    else:
        d[s]=1
print(rslt)
### BUGGY CODE ###

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

for a in range(0, n+1):
    for b in range(0, n-a+1):
        for c in range(n-(a+b)+1):

            if (10000*a + 5000*b + 1000*(n-(a+b))) == y:
                print(a, b, (n-(a+b)))
                exit()


print(-1, -1, -1)
               

### FIXED CODE ###

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

for a in range(0, n+1):
    for b in range(0, n-a+1):
        c = n-(a+b)
        if (10000*a + 5000*b + 1000*c) == y:
            print(a, b, c)
            exit()

print(-1, -1, -1)
### BUGGY CODE ###

a,b,k = map(int, input().split())
ans = []
for i in range(a,b+1):
  if i < a+k or i > b-k:
    ans.append(i)
  if i==b: ans.sort()
for i in range(len(ans)):
  print(ans[i])

### FIXED CODE ###

a, b, k = map(int, input().split())
for i in range(k):
    if a+i <= b:
        print(a+i)
for i in range(k-1,-1,-1):
    if b-i > a+k-1:
        print(b-i)
### BUGGY CODE ###

import numpy as np

N = int(input())
A = np.array([int(input()) for i in range(N)])

for i in range(N):
  print(np.max(np.delete(A,i)))

### FIXED CODE ###

import sys
input = sys.stdin.readline

import numpy as np

N = int(input())
A = np.array([int(input()) for _ in range(N)])

from_left = np.maximum.accumulate(A)
from_right = np.maximum.accumulate(A[::-1])[::-1]

from_left, from_right

from_left = [0] + from_left.tolist()[:-1]
from_right = from_right[1:].tolist() + [0]

for x,y in zip(from_left, from_right):
    print(x if x > y else y)
### BUGGY CODE ###

def main():
    N, C = map(int, input().split())
    stc = [list(map(int, input().split())) for _ in range(N)]
    st = []
    mxt = 0
    mnt = 0
    while len(stc) > 0:
        s, t, c = stc.pop()
        for i, (ss, tt, cc) in enumerate(stc):
            if c == cc:
                if s == tt:
                    stc.pop(i)
                    stc.append((ss, t, c))
                    break
                elif ss == t:
                    stc.pop(i)
                    stc.append((s, tt, c))
                    break
        else:
            mnt = min(mnt, s - 1)
            mxt = max(mxt, t)
            st.append((s - 1, t))
    cs = [0] * (mxt + 1)
    for s, t in st:
        cs[s] += 1
        cs[t] += -1
    ans = 0
    cc = 0
    for c in cs:
        cc += c
        ans = max(ans, cc)
    print(ans)


main()


### FIXED CODE ###

def main():
    N, C = map(int, input().split())
    stc = [[0] * (10 ** 5) for _ in range(C)]
    for _ in range(N):
        s, t, c = map(int, input().split())
        stc[c - 1][s - 1:t] = [1] * (t - s + 1)
    print(max(map(sum, zip(*stc))))


main()
### BUGGY CODE ###

X = int(input())
for i in range(-2000, 2000):
  for j in range(-2000, 2000):
    if i**5 - j**5 == X:
      print(i, j)
      exit()

### FIXED CODE ###

X = int(input())
for i in range(-200, 200):
  for j in range(-200, 200):
    if i**5 - j**5 == X:
      print(i, j)
      exit()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = max(max(a),max(b)).bit_length()+1
ans = 0
for i in range(1,x+1):
  c = sorted([a[j]&((1<<i)-1) for j in range(n)])
  d = sorted([b[j]&((1<<i)-1) for j in range(n)])
  t = 1<<(i-1)
  anstmp = 0
  for j in range(n):
    t1 = bisect.bisect_left(d,t-c[j])
    t2 = bisect.bisect_left(d,2*t-c[j])
    t3 = bisect.bisect_left(d,3*t-c[j])
    t4 = bisect.bisect_left(d,4*t-c[j])
    anstmp += (t2-t1)+(t4-t3)
  if anstmp%2:
    ans += t
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
x = max(max(a),max(b)).bit_length()+1
a = np.array(a,dtype=np.int32)
b = np.array(b,dtype=np.int32)
ans = 0
for i in range(1,x+1):
  c = a&(1<<i)-1
  d = b&(1<<i)-1
  d.sort()
  t = 1<<(i-1)
  anstmp = 0
  t1 = np.searchsorted(d,t-c).sum()
  t2 = np.searchsorted(d,2*t-c).sum()
  t3 = np.searchsorted(d,3*t-c).sum()
  anstmp += (t2-t1)+(n-t3)
  if anstmp%2:
    ans += t
print(ans)
### BUGGY CODE ###

import math

def readInt():
	return int(input())

def readInts():
	return list(map(int, input().split()))

def readChars():
	return input().split()

s = input()

ai = [0]*len(s)
si = [0]*len(s)

p = 2019

for i in range(len(s)):
	ai[i] = (int(s[-1*i-1])*pow(10,i))%p
	si[i] = sum(ai[:i+1])%p
countarr = [0]*2019
for i in si:
	countarr[i]+=1

res = countarr[0]
for i in range(p):
	c = countarr[i]
	res += c*(c-1)//2

print(res)

### FIXED CODE ###

import math

def readInt():
	return int(input())

def readInts():
	return list(map(int, input().split()))

def readChars():
	return input().split()

s = reversed(input())

ai = 0
si = 0

p = 2019
countarr = [0]*2019

for i, j in enumerate(s):
	ai = (int(j)*pow(10,i,p))%p
	si = (si+ai)%p
	countarr[si]+=1

res = countarr[0]
for i in range(p):
	c = countarr[i]
	res += c*(c-1)//2

print(res)
### BUGGY CODE ###

S = list(input())
ans = 0
while True:
    flg = False
    for i in range(len(S)-1):
        if S[i] == "B" and S[i+1] == "W":
            S[i] = "W"
            S[i+1] = "B"
            ans += 1
            break
    else:
        break
print(ans)


### FIXED CODE ###

S = list(input())
black = 0
ans = 0
for c in S:
    if c == "B":
        black += 1
    else:
        ans += black
print(ans)