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

from bisect import bisect_left
 
def lis(A: list):
    L = [A[0]]
    for a in A[1:]:
        if a > L[-1]:
            # Lの末尾よりaが大きければ増加部分列を延長できる
            L.append(a)
        else:
            # そうでなければ、「aより小さい最大要素の次」をaにする
            # 該当位置は、二分探索で特定できる
            L[bisect_left(L, a)] = a
    return len(L)

# l = [7,5,3,1,8]
# n = int(input())
# l = list(map(int,input().split()))

def dp_bubunnwa(l):
    n = len(l)
    m = sum(l)
    dp = [[0]*(m+1) for _ in range(n+1)]

    dp[0][0] = 1
    for i in range(n):
        for j in range(m+1):
            if l[i] <= j:
                dp[i+1][j] = dp[i][j-l[i]]+dp[i][j]
            else:
                dp[i+1][j] = dp[i][j]
    return dp

def bfs(G,start):
    from collections import deque
    dist = [-1] * n
    dist[start] = 0
    q = deque([start])
    add,pop=q.append,q.popleft
    while q:
        v = pop()
        for nv in G[v]:
            if dist[nv] < 0:
                dist[nv] = dist[v]+1
                add(nv)
            # 2部グラフ判定
            # else:
            #     if dist[v]%2 == dist[nv]%2:
            #         is_bipartite = False
    return dist


def lcs(a,b):
    a_size = len(a)
    b_size = len(b)
    lcs = [[0 for _ in range(a_size+1)] for _ in range(b_size+1)]
    for i in range(1,b_size+1):
        for j in range(1,a_size+1):
            if a[j-1] == b[i-1]:
                match = 1
            else:
                match = 0
            lcs[i][j] = max(lcs[i-1][j-1]+match, lcs[i-1][j], lcs[i][j-1])
    return lcs

def make_lcs(a,b):
    a_size = len(a)
    b_size = len(b)
    lcs = [[0 for _ in range(a_size+1)] for _ in range(b_size+1)]
    for i in range(1,b_size+1):
        for j in range(1,a_size+1):
            if a[j-1] == b[i-1]:
                match = 1
            else:
                match = 0
            lcs[i][j] = max(lcs[i-1][j-1]+match, lcs[i-1][j], lcs[i][j-1])
    # ここまではlcs()と同じ

    # lcsを使用して復元
    res = ''
    i,j = b_size,a_size
    while((i>0) & (j>0)):
        if lcs[i][j] == lcs[i-1][j]:
            i -= 1
        elif lcs[i][j] == lcs[i][j-1]:
            j -= 1
        else:
            res = b[i-1] + res
            i -= 1
            j -= 1
    return res
a = list(input())
b = list(input())
print(make_lcs(a,b))

### FIXED CODE ###

def make_lcs(a,b):
    a_size = len(a)
    b_size = len(b)
    lcs = [[0 for _ in range(a_size+1)] for _ in range(b_size+1)]
    for i in range(1,b_size+1):
        for j in range(1,a_size+1):
            if a[j-1] == b[i-1]:
                match = 1
            else:
                match = 0
            lcs[i][j] = max(lcs[i-1][j-1]+match, lcs[i-1][j], lcs[i][j-1])
    # ここまではlcs()と同じ

    # lcsを使用して復元
    res = ''
    i,j = b_size,a_size
    while((i>0) & (j>0)):
        if lcs[i][j] == lcs[i-1][j]:
            i -= 1
        elif lcs[i][j] == lcs[i][j-1]:
            j -= 1
        else:
            res = b[i-1] + res
            i -= 1
            j -= 1
    return res

def main():
    a = list(input())
    b = list(input())
    print(make_lcs(a,b))

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

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

flag = False
for i in range(N + 1):
    for j in range(N + 1):
        for k in range(N + 1):
            if i + j + k != N:
                continue

            if flag:
                break

            if 10000 * i + 5000 * j + 1000 * k == Y:
                flag = True
                break

        if flag:
            break

    if flag:
        break

if flag != True:
    i = -1
    j = -1
    k = -1

print(i, j, k)

### FIXED CODE ###

N, Y = map(int, input().split())
ans = []
for i in range(N + 1):
    for j in range(N + 1):
        k = N - i - j
        if k < 0:
            break

        if 10000 * i + 5000 * j + 1000 * k == Y:
            ans = [i, j, k]

if ans == []:
    ans = [-1, -1, -1]

print(ans[0], ans[1], ans[2])
### BUGGY CODE ###

# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    digits = dict()
    for d in range(30):
        digits[d] = 0
        for a in As:
            digits[d] += a >> d & 1

    oore = dict()
    for k, v in digits.items():
        oore[k] = v % 2

    nums = [0] * N

    for i, a in enumerate(As):
        for d in range(30):
            nums[i] += ((a >> d & 1) ^ (oore[d])) << d

    return nums


def main():
    print(*solve())


if __name__ == "__main__":
    main()


### FIXED CODE ###

# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    digits = dict()
    for d in range(30):
        digits[d] = 0
        for a in As:
            digits[d] += a >> d & 1

    oore = 0
    for k, v in digits.items():
        oore += (v % 2) << k

    nums = [0] * N

    for i, a in enumerate(As):
        nums[i] = a ^ oore

    return nums


def main():
    print(*solve())


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



n = int(input())

# i = np.array([i+1 for i in range(n)])
#
# ps = [i+1 for i in range(1, n)] + [1]
#
# ps = np.array(ps)
#
# ms = i % ps

print(sum([i+1 for i in range(0, n-1)]))


### FIXED CODE ###

n = int(input())

if n == 1:
    print(0)
else:
    ans = n *(n-1) // 2
    print(ans)
### BUGGY CODE ###

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


def cmb(n, r):
    # combination
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    # print(n + r)
    return A[n] // (A[r] * A[n - r])


def g(x, y):
    return (cmb(x + y + 2, y + 1) - 1) % MOD


r1, c1, r2, c2 = inpl()

MOD = 10**9 + 7

A = [1]
for i in range(r2 + c2 + 2):
    A.append(A[-1] * (i + 1))
# print(A)
# print(g(r2, c2))
print((g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)) % MOD)


### FIXED CODE ###

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


def cmb(n, r):
    # combination
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    return (over[n] * under[r] * under[n - r]) % MOD


# 互いに素なx, yについて、a * x + b * y = 1の解の一つを求める。
def extGCD(x, y):
    r = [1, 0, x]
    w = [0, 1, y]
    # print(r, w)
    while w[2] != 1:
        # print(r, w)
        q = r[2] // w[2]
        w_tmp = [r[0] - q * w[0], r[1] - q * w[1], r[2] % w[2]]
        r, w = w, w_tmp

    return w[:2]


def mod_inv(a, m):
    _, x = extGCD(m, a)
    return (x + m) % m


def g(x, y):
    return (cmb(x + y + 2, x + 1) - 1 + MOD) % MOD


r1, c1, r2, c2 = inpl()

MOD = 10**9 + 7

over = [0 for i in range(r2 + c2 + 3)]
under = [0 for i in range(r2 + c2 + 3)]
over[0] = 1
for i in range(r2 + c2 + 2):
    over[i + 1] = over[i] * (i + 1) % MOD

under[r2 + c2 + 2] = mod_inv(over[r2 + c2 + 2], MOD)
for i in range(r2 + c2 + 1, 0, -1):
    under[i] = under[i + 1] * (i + 1) % MOD

print((g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)) % MOD)
### BUGGY CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[16]:


N = int(input())
A = [int(x) for x in input().split()]
MOD = 10 ** 9 + 7


# In[17]:


count = [0] * 60
for i in range(N):
    s = format(A[i], '060b')
    for d in range(60):
        count[d] += int(s[d])


# In[18]:


# print(count)


# In[19]:


ans = 0
for d in range(60):
    ans = (ans + 2 ** (59 - d) * count[d] * (N - count[d])) % MOD


# In[20]:


print(ans)


# In[ ]:






### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[1]:


N = int(input())
A = [int(x) for x in input().split()]
MOD = 10 ** 9 + 7


# In[2]:


count = [0] * 60
for i in range(N):
#     s = format(A[i], '060b')
#     for d in range(60):
#         count[d] += int(s[d])
    for j in range(60):
        count[j] += A[i] % 2
        A[i] //= 2


# In[ ]:





# In[3]:


ans = 0
for d in range(60):
    ans = (ans + count[d] * (N - count[d]) * 2 ** (d)) % MOD


# In[4]:


print(ans)


# In[ ]:
### BUGGY CODE ###

def S(n):
    k=list(str(n))
    import functools
    return functools.reduce(lambda x,y:x+y,[int(i) for i in k])
k=int(input())
def T(n):
    return n/S(n)
A=list()
i=0
import functools
while len(A)<k:
    i=i+1
    if i<10:
        A.append(i)
    else:
        I=list(str(i))
        j=int(I[0])*10**(len(I)-1)+functools.reduce(lambda x,y:x+y,[9*10**i for i in range(len(I)-1)])
        if i>=j:
            if T(i)<=T(i+1):
                A.append(i)
for i in A:
    print(i)
    
            
    

### FIXED CODE ###

def S(n):
    k=list(str(n))
    import functools
    return functools.reduce(lambda x,y:x+y,[int(i) for i in k])
k=int(input())
def T(n):
    return n/S(n)
def f(N):
    len_N=len(str(N))
    A=[10**len_N+10**i-1 for i in range(len_N)]
    B=[T(i) for i in A]
    ans1=A[B.index(min(B))]
    i=0
    while True:
        I=10**(len_N-1)+10**i-1
        J=10**(len_N-1)+10**(i+1)-1
        if T(J)<T(I):
            i+=1
        else:
            break
    C=[((N+1)//(10**i))*10**i+j*10**i-1 for j in range(1,11)]
    D=[T(i) for i in C]
    ans2=C[D.index(min(D))]
    if T(ans1)<T(ans2):
        return(ans1)
    else:
        return(ans2)
K=[]
N=1
while len(K)<k:
    K.append(N)
    N=f(N)
for i in range(k):
    print(K[i])
### BUGGY CODE ###

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

n = 1
  
for i in range(a):
  n = n * b[i]

if n > 10**18:
  print('-1')
else:
  print(n)


### FIXED CODE ###

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

c = 0
d = 0

for i in b:
    if i == 0:
        c += 1
    elif i > 10**18:
        d += 1
        
if c > 0:
    print(0)
    exit()
if d > 1 and c == 0:
    print(-1)
    exit()

for i in b:
  n *= i
  if n > 10**18:
    print(-1)
    exit()
print(n)
### BUGGY CODE ###

N = int(input())
D = [list(map(int,input().split()))+[k] for k in range(N)]

T = sorted(D, key = lambda x: (-x[0],-x[1]))
A = sorted(D, key = lambda x: (-x[1],-x[0]))
U = [1 for k in range(N)]

ans = 0
l = 0
m = 0
for k in range(N):
    if k%2 == 0:
        while U[T[l][2]] == 0:
            l += 1
        ans += T[l][0]
        U[T[l][2]] = 0
    else:
        m = 0
        while U[A[m][2]] == 0:
            m += 1
        ans -= A[m][1]
        U[A[m][2]] = 0

print(ans)

### FIXED CODE ###

N = int(input())
D = [list(map(int,input().split()))+[k] for k in range(N)]

T = sorted(D, key = lambda x: x[0]+x[1], reverse = True)
A = sorted(D, key = lambda x: x[1]+x[0], reverse = True)
U = [1 for k in range(N)]

ans = 0
l = 0
m = 0
for k in range(N):
    if k%2 == 0:
        while U[T[l][2]] == 0:
            l += 1
        ans += T[l][0]
        U[T[l][2]] = 0
    else:
        while U[A[m][2]] == 0:
            m += 1
        ans -= A[m][1]
        U[A[m][2]] = 0

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

x, y, z, k = map(int, input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

ab=[]

for i in a:
    for j in b:
        ab.append(i+j)
ab.sort(reverse=True)

abc=[]
for i in ab[:k]:
    for j in c:
        abc.append(i+j)
abc.sort(reverse=True)

for i in abc[:k]:
    print(i)

### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ab = sorted(x+y for x in a for y in b)[:-k-1:-1]
abc = sorted(x+y for x in ab[:k] for y in c)[:-k-1:-1]
print(*abc, sep='\n')
### BUGGY CODE ###

#!/usr/bin/python3

class Node:
    pass

def kdtree(points, depth=0):
    if not points:
        return
    # dimension
    k = len(points[0][1])
    axis = depth % k

    points.sort(key=lambda x:x[1][axis])
    median = len(points)//2

    node = Node()
    node.location = points[median]
    node.left = kdtree(points[:median], depth + 1)
    node.right = kdtree(points[median + 1:], depth + 1)
    return node

def find(sx, tx, sy, ty, node, depth):
    if node == None:
        return []
    result = []
    x = node.location[1][0]
    y = node.location[1][1]
    if sx <= x <= tx and sy <= y <= ty:
        result.append(node.location[0])

    if depth % 2 == 0:
        if sx <= x:
            ret = find(sx, tx, sy, ty, node.left, depth + 1)
            result.extend(ret)
        if x <= tx:
            ret = find(sx, tx, sy, ty, node.right, depth + 1)
            result.extend(ret)
    else:
        if sy <= y:
            ret = find(sx, tx, sy, ty, node.left, depth + 1)
            result.extend(ret)
        if y <= ty:
            ret = find(sx, tx, sy, ty, node.right, depth + 1)
            result.extend(ret)
    return result

# main
n = int(input())
points = [(i, tuple(map(int, input().split()))) for i in range(n)]
tree = kdtree(points)
q = int(input())
for i in range(q):
    sx, tx, sy, ty = map(int, input().split())
    result = find(sx, tx, sy, ty, tree, 0)
    result.sort()
    for i in result:
        print(i)
    print()

### FIXED CODE ###

#!/usr/bin/python3
from sys import stdin
import math
from operator import itemgetter
from bisect import bisect_left, bisect_right
readline = stdin.readline

def main():
    n = int(readline())
    xy = [tuple(map(int, readline().split())) + (i,) for i in range(n)]
    # [..., (x_i, y_i, i), ...]
    # sort by x
    xy.sort()

    root = int(math.sqrt(len(xy)))

    low = [x for x, y, i in xy[::root]]
    high = [x for x, y, i in xy[root - 1::root]] + [float('inf')]

    xy = [sorted(xy[i:i + root], key=itemgetter(1)) for i in range(0, len(xy), root)]
    xy = [([y for x, y, i in xyi], xyi) for xyi in xy]
    for sx, tx, sy, ty in (map(int, readline().split()) for _ in range(int(readline()))):
        ret = []
        for i in range(bisect_left(high, sx), bisect_right(low, tx)):
            k, v = xy[i]
            for i in range(bisect_left(k, sy), bisect_right(k, ty)):
                if sx <= v[i][0] <=tx:
                    ret.append(v[i][2])
        if ret:
            ret.sort()
            print('\n'.join(map(str,ret)))
        print()

main()
### BUGGY CODE ###

N = int(input())
a = []
used = []
ans = 0
for i in range(N):
  b = input()
  a.append(b)
  for j in a:
    if not j in used:
      ans += 1
      used.append(j)
print(ans)

### FIXED CODE ###

N = int(input())
ans = set()
for i in range(N):
  ans.add(input())
print(len(ans))
### BUGGY CODE ###

n, m = map(int, input().split())
lis = list(map(lambda z: int(z) - 1, map(int, input().split())))

s = [0]
res = [0]

while lis[res[-1]] not in s:
    res.append(lis[res[-1]])
    s.append(res[-1])

x, y = res.index(lis[res[-1]]), len(res)

if m < y:
    print(res[m] + 1)
else:
    mm = (m - x) % (y - x)
    print(res[mm + x] + 1)


### FIXED CODE ###

n, m = map(int, input().split())
lis = list(map(lambda z: int(z) - 1, map(int, input().split())))

s = {0}
res = [0]

while lis[res[-1]] not in s:
    res.append(lis[res[-1]])
    s.add(res[-1])

x, y = res.index(lis[res[-1]]), len(res)

if m < y:
    print(res[m] + 1)
else:
    mm = (m - x) % (y - x)
    print(res[mm + x] + 1)
### BUGGY CODE ###

S = input()
Q = int(input())

for _ in range(Q):
  a = list(input().split())
  if a[0] == "1":
    S = S[::-1]
  else:
    if a[1] == "1":
      S = a[2] + S
    else:
      S = S + a[2]
      
print(S)

### FIXED CODE ###

S = input()
Q = int(input())
rev = 0
top = []
bot = []

for _ in range(Q):
  a = list(input().split())
  if a[0] == "1":
    rev += 1
  else:
    if rev%2 == 0:
      if a[1] == "1":
        top.append(a[2])
      else:
        bot.append(a[2])
    else:
      if a[1] == "2":
        top.append(a[2])
      else:
        bot.append(a[2])
      
t = "".join(top)[::-1]
b = "".join(bot)
S = "".join([t,S,b])
if rev%2 == 1:
  S = S[::-1]
print(S)
### BUGGY CODE ###

import itertools
import networkx as nx
H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]

source = 2 * H * W
sink = source + 1

INF = 10**12

graph = nx.DiGraph()


def add(start, end, cap):
    graph.add_edge(start, end, capacity=cap)


for x, y in itertools.product(range(H), range(W)):
    i = x * W + y
    if S[x][y] == '.':
        add(2 * i, 2 * i + 1, 1)
    else:
        add(source, 2 * i + 1, INF)
    for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        x1, y1 = x + dx, y + dy
        if 0 <= x1 < H and 0 <= y1 < W:
            j = x1 * W + y1
            add(2 * i + 1, 2 * j, 1)
        else:
            add(2 * i + 1, sink, INF)
ans = nx.minimum_cut_value(graph, source, sink)
ans = ans if ans < INF else -1
print(ans)


### FIXED CODE ###

import sys
import itertools
from scipy.sparse import csr_matrix, lil_matrix
from scipy.sparse.csgraph import maximum_flow

H, W = map(int, sys.stdin.buffer.readline().split())
S = b''.join(sys.stdin.buffer.read().split())

source = 2 * H * W
sink = source + 1

INF = source * 2

graph = lil_matrix((sink + 1, sink + 1), dtype=int)

for i in range(H * W):
    x, y = divmod(i, W)
    if S[i] == ord('.'):
        graph[2 * i, 2 * i + 1] = 1
    else:
        graph[source, 2 * i + 1] = INF
    for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        x1, y1 = x + dx, y + dy
        if 0 <= x1 < H and 0 <= y1 < W:
            j = x1 * W + y1
            graph[2 * i + 1, 2 * j] = 1
        else:
            graph[2 * i + 1, sink] = INF
graph = graph.tocsr()
ans = maximum_flow(graph, source, sink).flow_value
ans = ans if ans < INF else -1
print(ans)
### BUGGY CODE ###

import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

s = input()
q = int(input())
for i in range(q):
    query = input().split()
    t = int(query[0])
    if t == 1:
        s = s[::-1]
    elif t == 2:
        f = int(query[1])
        c = query[2]
        if f == 1:
            s = c + s
        elif f == 2:
            s += c
print(s)

### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

s = readline().decode().strip()
q = int(readline())
is_reversed = False
qs = read().decode().split("\n")
left = []
right = [] 
for i in range(q):
    query = qs[i].split()
    t = int(query[0])
    if t == 1:
        is_reversed = not is_reversed
    elif t == 2:
        f = int(query[1])
        c = query[2]
        if f == 1:
            if is_reversed:
                right.append(c)
            else:
                left.append(c)
        elif f == 2:
            if is_reversed:
                left.append(c)
            else:
                right.append(c)

s = "".join(reversed(left)) + s + "".join(right)
if is_reversed:
    print(s[::-1])
else:
    print(s)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(set(a))
l=[];m=[]
for i in range(len(b)):
  l.append([b[i],a.count(b[i])])
if len(l)>2:
  for j in range(len(b)-2):
    x=l[j][1]
    if l[j+1][0]-l[j][0]<=2:x+=l[j+1][1]
    if l[j+2][0]-l[j][0]<=2:x+=l[j+2][1]
    m.append(x)
elif len(l)>1:
  for j in range(len(b)-1):
    x=l[j][1]
    if l[j+1][0]-l[j][0]<=2:x+=l[j+1][1]
    m.append(x)
else:
  m.append(l[0][1])
print(max(m))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
l=[]
for i in range(max(a)+3):
  l.append(0)
for j in range(n):
  l[a[j]+1]+=1
m=[]
for i in range(1,max(a)+2):
  m.append(l[i-1]+l[i]+l[i+1])
print(max(m))
### BUGGY CODE ###

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

Y = X[::-1]
Y = tuple(Y)

for k in range(N):
    try:
        i = Y.index(k+1)
        Y = Y[:i]
    except:
        i = -1
        leng = k
        break
    leng = k + 1

if leng == 0:
    ans = -1
else:
    ans = N - leng
print(ans)

### FIXED CODE ###

N = int(input())
X = tuple(map(int, input().split()))

c = 0
for x in X:
    if x == c+1:
        c+=1
if c == 0:
    ans = -1
else:
    ans = N-c
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [1e9] * n
dp[0] = 0

for i in range(n):
    for j in range(i + 1, i + k + 1, 1):
        if j < n:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))

print(dp[n - 1])

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * n

for i in range(1, n):
    dp[i] = min(dp[j] + abs(a[i] - a[j])
                for j in range(i - 1, max(i - k - 1, -1), -1))

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

n=int(input())
f=[1]*(n+1)
s=1
for c in range(2,n+1):
    for d in range(1,n//c+1):
        f[c*d]+=1
    s+=c*f[c]
print(s)

### FIXED CODE ###

n=int(input())
f=[2-x%2 for x in range(n+1)]
s=5
for c in range(3,n+1):
    for d in range(1,n//c+1):
        f[c*d]+=1
    s+=c*f[c]
if n==1:
    print(1)
elif n==2:
    print(5)
else:
    print(s)
### BUGGY CODE ###

n, m = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]
ans = []
for i in range(m):
    res = []
    for j in range(lr[i][0], lr[i][1] + 1):
        res.append(j)
    if i == 0:
        ans = set(res)
    else:
        ans = set(ans) & set(res)
print(len(ans))


### FIXED CODE ###

n, m = map(int, input().split())
mi, ma = 1, n
for _ in range(m):
    l, r = map(int, input().split())
    mi = max(l, mi)
    ma = min(r, ma)
print(max(0, ma - mi + 1))
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline
n, k, q = map(int, input().split())
a = []

for i in range(n):
    a.append(k)

for i in range(q):
    b = int(input())
    for j in range(n):
        if j != (b - 1):
            a[j] -= 1

for i in range(n):
    if a[i] > 0:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline
n, k, q = map(int, input().split())
a = []

for i in range(n):
    a.append(k - q)

for i in range(q):
    b = int(input())
    a[b - 1] += 1

for i in range(n):
    if a[i] > 0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

H,W,D = map(int,input().split())
A = [list(map(int,input().split())) for i in range(H)]
Q = int(input())
LR = [list(map(int,input().split())) for i in range(Q)]

Point = {}
for y in range(H) :
    for x in range(W) :
        Point[A[y][x]] = (y, x)

def dist (y1,x1,y2,x2) :
    return abs(y1-y2) + abs(x1-x2)

for i in range(Q) :
    res = 0
    l,r = LR[i][0], LR[i][1]
    while l != r :
        l += D
        res += dist(Point[l][0], Point[l][1], Point[l-D][0], Point[l-D][1])
    print(res)


### FIXED CODE ###

H,W,D = map(int,input().split())
Point = {}
for y in range(H) :
    line = list(map(int,input().split()))
    for x,p in enumerate(line) :
        Point[p] = (y,x)

Q = int(input())

def dist(ny,nx,py,px) :
    return abs(ny-py) + abs(nx-px)

Cost = [0]*(H*W+1)
for i in range(D+1, H*W+1) :
    yi,xi = Point[i-D]
    yj,xj = Point[i]
    Cost[i] = Cost[i-D] + dist(yi,xi,yj,xj)


for i in range(Q) :
    l,r = map(int,input().split())
    print(Cost[r] - Cost[l])