import sys
import functools

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

@functools.lru_cache(maxsize=None)
def solve(h):
    if h <= 0:
        return 0

    ret_val = float("inf")
    for a, b in AB:
        ret_val = min(ret_val, b + solve(h - a))
    return ret_val

sys.setrecursionlimit(100000)

H, N = inpl()
AB = [inpl() for i in range(N)]
AB.sort(key=lambda ab: (ab[0] / ab[1], -ab[0]), reverse=True)
# print(AB)
print(solve(H))

import sys
import functools

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

@functools.lru_cache(maxsize=None)
def solve(h):
    if h <= 0:
        return 0

    ret_val = float("inf")
    for a, b in AB:
        val = b + solve(h - a)
        if val < ret_val:
            ret_val = val
        else:
            break
    return ret_val

sys.setrecursionlimit(100000)

H, N = inpl()
AB = [inpl() for i in range(N)]
AB.sort(key=lambda ab: (ab[0] / ab[1], -ab[0]), reverse=True)
# print(AB)
print(solve(H))


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

XH.sort()
q = []
t = 0
result = 0
for x, h in XH:
    while q:
        if x <= q[0][0]:
            break
        t -= q[0][1]
        q.pop(0)
    h -= t
    if h <= 0:
        continue
    c = (h + A - 1) // A
    result += c
    t += c * A
    q.append((x + 2 * D, c * A))
print(result)

from collections import deque

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

XH.sort()
q = deque()
t = 0
result = 0
for x, h in XH:
    while q:
        if x <= q[0][0]:
            break
        t -= q[0][1]
        q.popleft()
    h -= t
    if h <= 0:
        continue
    c = (h + A - 1) // A
    result += c
    t += c * A
    q.append((x + 2 * D, c * A))
print(result)


def main():
    N, D, A = map(int, input().split())

    XHN = []
    for _ in range(N):
        X, H = map(int, input().split())
        XHN.append([X, H, X + 2 * D])

    XHN.sort()

    q = []
    acc_damege = 0
    ans = 0
    for i in range(N):
        if 0 < XHN[i][1]:
            X, H, bomb_p = XHN[i]

            while q:
                acc_x, acc_d = q[0]
                if acc_x < X:
                    acc_damege -= acc_d
                    del q[0]
                else:
                    break

            H -= acc_damege

            if 0 < H:
                attack_count = H // -A * -1
                damege = A * attack_count
                ans += attack_count
                XHN[i][1] -= damege

                acc_damege += damege
                q.append((bomb_p, damege))

    print(ans)

main()

from collections import deque

def main():
    N, D, A = map(int, input().split())

    XHN = []
    for _ in range(N):
        X, H = map(int, input().split())
        XHN.append([X, H, X + 2 * D])

    XHN.sort()

    q = deque()
    acc_damege = 0
    ans = 0
    for i in range(N):
        if 0 < XHN[i][1]:
            X, H, bomb_p = XHN[i]

            while q:
                acc_x, acc_d = q[0]
                if acc_x < X:
                    acc_damege -= acc_d
                    del q[0]
                else:
                    break

            H -= acc_damege

            if 0 < H:
                attack_count = H // -A * -1
                damege = A * attack_count
                ans += attack_count
                XHN[i][1] -= damege

                acc_damege += damege
                q.append((bomb_p, damege))

    print(ans)

main()


n, d, a = map(int, input().split())
m = [list(map(int, input().split())) for _ in range(n)]
m.sort()
if m[0][1] < m[-1][1]:
    for i in range(n):
        m[i][0] = m[i][0] * (-1)
    m.reverse()
bomb = [0 for _ in range(n)]
r = 1
d *= 2
for i in range(n):
    while r < n and m[i][0] + d >= m[r][0]:
        r += 1
    bomb[i] = r - 1
res = 0
for i in range(n):
    if m[i][1] > 0:
        tres = (m[i][1] + a - 1) // a
        res += tres
        dh = tres * a
        for j in range(i, bomb[i] + 1):
            m[j][1] -= dh
print(res)

from collections import deque

n, d, a = map(int, input().split())
m = [list(map(int, input().split())) for _ in range(n)]
m.sort()
r = 1
d *= 2
q = deque([])
for i in range(n):
    while r < n and m[i][0] + d >= m[r][0]:
        r += 1
    m[i].append(r)
    m[i][1] = (m[i][1] + a - 1) // a
res = 0
tdamage = 0
for i in range(n):
    while q and q[0][0] <= i:
        minus = q.popleft()
        tdamage -= minus[1]
    m[i][1] -= tdamage
    if m[i][1] > 0:
        res += m[i][1]
        tdamage += m[i][1]
        q.append([m[i][2], m[i][1]])
print(res)


from collections import deque
import sys

N, D, A = map(int, input().split())
M = [tuple(map(int, x.split())) for x in sys.stdin.readlines()]
M.sort()

q = deque()
qt = deque()

ans = 0
for x, h in M:
    if len(q) == 0:
        bomb = (h + A - 1) // A
        q.append((x + 2 * D, bomb))
        ans += bomb
    else:
        while h > 0:
            d, bomb = q.popleft()
            if x <= d:
                h -= bomb * A
                qt.append((d, bomb))
            if h > 0 and len(q) == 0:
                bomb = (h + A - 1) // A
                h -= bomb * A
                qt.append((x + 2 * D, bomb))
                ans += bomb
        while len(qt) > 0:
            q.appendleft(qt.pop())

print(ans)

from collections import deque
import sys

N, D, A = map(int, input().split())
M = [tuple(map(int, x.split())) for x in sys.stdin.readlines()]
M.sort()

q = deque()
qt = deque()

ans = 0
dmg = 0
for x, h in M:
    if len(q) == 0:
        bomb = (h + A - 1) // A
        q.append((x + 2 * D, bomb))
        dmg += bomb * A
        ans += bomb
    else:
        while len(q) > 0:
            d, bomb = q.popleft()
            if d < x:
                dmg -= bomb * A
            else:
                q.appendleft((d, bomb))
                break
        if h > dmg:
            bomb = ((h - dmg) + A - 1) // A
            q.append((x + 2 * D, bomb))
            dmg += bomb * A
            ans += bomb

print(ans)


from heapq import heapify, heappush, heappop

N, D, A = map(int, input().split())
XH = [tuple(map(int, input().split())) for _ in range(N)]

heap = [(x, h, True) for x, h in XH]
heapify(heap)

ans = 0
bomb_effect = 0
while heap:
    x, h, monster_flg = heappop(heap)
    if monster_flg:
        tairyoku = h - bomb_effect
        if tairyoku > 0:
            new_bomb = -((-tairyoku) // A)
            ans += new_bomb
            heappush(heap, (x + 2 * D + 0.5, new_bomb, False))
            bomb_effect += new_bomb * A
    else:
        bomb_effect -= h * A

print(ans)

N, D, A = map(int, input().split())
XH = [tuple(map(int, input().split())) for _ in range(N)]
XH.sort()

ans = 0
bomb_effect = 0
bomb_i = 0
bombs = []
for x, h in XH:
    while (bomb_i < len(bombs)) and (x > bombs[bomb_i][0]):
        bomb_effect -= bombs[bomb_i][1] * A
        bomb_i += 1

    tairyoku = h - bomb_effect
    if tairyoku > 0:
        new_bomb = -((-tairyoku) // A)
        ans += new_bomb
        bombs.append((x + 2 * D + 0.5, new_bomb))
        bomb_effect += new_bomb * A

print(ans)


from heapq import heapify, heappop, heappush
from math import ceil
import sys

input = sys.stdin.readline

def main():
    n, d, a = map(int, input().split())
    hp = [list(map(int, input().split())) for _ in range(n)]
    heapify(hp)

    ans = 0

    while hp:
        left = heappop(hp)
        cnt = ceil(left[1] / a)
        li = []
        while hp and hp[0][0] <= left[0] + 2 * d:
            nxt = heappop(hp)
            if nxt[1] - a * cnt > 0:
                li.append([nxt[0], nxt[1] - a * cnt])

        for e in li:
            heappush(hp, e)

        ans += cnt

    print(ans)

if __name__ == "__main__":
    main()

from heapq import heapify, heappush, heappop
from math import ceil

REAL = 0
UNREAL = 1

n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]

hp = []
for x, h in xh:
    heappush(hp, [x, REAL, h])

bomb_acm = 0
ans = 0
while hp:
    x, r, h = heappop(hp)
    if r == REAL:
        if h > bomb_acm:
            left = h - bomb_acm
            bomb_cnt = ceil(left / a)
            hp_dis = a * bomb_cnt
            bomb_acm += hp_dis
            heappush(hp, [x + 2 * d, UNREAL, hp_dis])
            ans += bomb_cnt

    else:  # r == UNREAL
        bomb_acm -= h

print(ans)


from sys import stdin

n, d, a = (int(v) for v in stdin.readline().split())
monsters = [(int(v) for v in stdin.readline().split()) for i in range(n)]

monsters = [[x, (h // a + 1) if h % a > 0 else (h // a)] for x, h in monsters]
monsters = sorted(monsters)
bomb_size = 2 * d + 1
num_bombs = 0

ptr = 0
while ptr < len(monsters):
    while ptr < len(monsters) and monsters[ptr][1] <= 0:
        ptr += 1
    if ptr < len(monsters):
        position = monsters[ptr][0]
        bombs_now = monsters[ptr][1]
        i = ptr
        while i < len(monsters) and monsters[i][0] - position < bomb_size:
            monsters[i][1] -= bombs_now
            i += 1
        num_bombs += bombs_now

print(num_bombs)

from sys import stdin
from collections import deque

n, d, a = (int(v) for v in stdin.readline().split())
monsters = [(int(v) for v in line.split()) for line in stdin.readlines()]

monsters = [[x, (h // a + 1) if h % a > 0 else (h // a)] for x, h in monsters]
monsters = sorted(monsters)
bomb_size = 2 * d + 1
num_bombs = 0

current_bombs = 0
bomb_endpoints = deque()
bomb_endnumbers = deque()

for i in range(len(monsters)):
    while len(bomb_endpoints) > 0 and bomb_endpoints[0] <= monsters[i][0]:
        current_bombs -= bomb_endnumbers[0]
        bomb_endpoints.popleft()
        bomb_endnumbers.popleft()
    monsters[i][1] -= current_bombs
    if monsters[i][1] > 0:
        bombs_now = monsters[i][1]
        monsters[i][1] = 0
        num_bombs += bombs_now
        current_bombs += bombs_now
        bomb_endpoints.append(monsters[i][0] + bomb_size)
        bomb_endnumbers.append(bombs_now)

print(num_bombs)


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

if n / m == 1:
    print("Yes")
else:
    print("No")

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

if n == m:
    print("Yes")
else:
    print("No")


data = input().split()

a = data[0]
b = data[1]

ans = min(a, b) * max(a, b)

print(ans)

data = input().split()

a = data[0]
b = data[1]

ans = min(a, b) * int(max(a, b))

print(ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02790/Python/s088084103.py", line 6, in <module>
    ans = min(a, b) * max(a, b)
TypeError: can't multiply sequence by non-int of type 'str'


N = int(input())
P = list(map(int, input().split()))
ans = 1

for i in range(1, N):
    if P[i] <= min(P[:i]):
        ans += 1

print(ans)

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

"""
参考
https://cocoinit23.com/abc152/
すべての(i, j)を調べていると制限時間を超過してしまう。
listの2つ目の要素(index=1)から順に見ていって、最小値が更新されたら解をカウントアップする。
ただし、解の最小値は常に1となるので、解の初期値は1にしておくこと。
"""
ans = 1
min_p = P[0]

for i in range(1, N):
    if P[i] <= min_p:
        min_p = P[i]
        ans += 1

print(ans)


n = int(input())
p = list(map(int, input().split()))
t = []
c = 0
for i in p:
    t += [i]
    if i <= min(t):
        c += 1
print(c)

n = int(input())
p = list(map(int, input().split()))
t = n
c = 0
for i in range(n):
    t = min(t, p[i])
    if p[i] <= t:
        c += 1
print(c)


n = int(input())
p_list = list(map(int, input().split()))
ans = 1
for i in range(1, n):
    if all([p_list[i] <= p_list[j] for j in range(i)]):
        ans += 1
print(ans)

n = int(input())
p_list = list(map(int, input().split()))
ans = 1
min = p_list[0]
for i in range(1, n):
    if min >= p_list[i]:
        ans += 1
        min = p_list[i]
print(ans)


n = int(input())
p = map(int, input().split())
m = 1

if n > 1:
    for i, pi in enumerate(p):
        if pi <= i:
            continue
        elif all([pj >= pi for pj in p[:i]]):
            m += 1
        else:
            continue

print(m)

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

q = p[0]
p = p[1:]

m = 1

if n > 1:
    for pi in p:
        if q > pi:
            m += 1
            q = pi

print(m)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02791/Python/s560223723.py", line 9, in <module>
    elif all([pj >= pi for pj in p[:i]]):
TypeError: 'map' object is not subscriptable


import numpy as np

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

value = np.array(P)

ac = [v for i, v in enumerate(P) if v == np.minimum.accumulate(P)[i]]

print(len(ac))

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

value = 10**9
ans = 0
for v in P:
    if v < value:
        ans += 1
        value = v
print(ans)


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

max0, max1, count = [], 0, 0
for i in p:
    max0.append(i)
    max1 = i
    if max1 == 1:
        count += 1
        break
    elif min(max0) >= max1:
        count += 1
print(count)

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

max0, max1, count = p[0], 0, 0
for i in p:
    max0 = min(max0, i)
    max1 = i
    if max1 == 1:
        count += 1
        break
    elif max0 >= max1:
        count += 1
print(count)


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

c = 0
try:
    while P:
        p_i = P.pop()
        if p_i <= min(P):
            c += 1
except ValueError:
    print(c + 1)

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

m = next(P)
c = 1
for p in P:
    if p <= m:
        m = p
        c += 1
print(c)


n = int(input())
p = list(map(int, input().split()))
# result_list = [0]*n
result_count = 0

for i in range(n):
    for j in range(i):
        if p[i] > p[j]:
            # result_list[i] = 1
            result_count += 1
            break

# print(result_list.count(0))
print(n - result_count)

n = int(input())
p = list(map(int, input().split()))
# result_list = [0]*n
result = 1
com_val = p[0]

for i in range(1, n):
    if com_val < p[i]:
        continue
    else:
        result += 1
        com_val = p[i]

print(result)


N = int(input())
P = list(map(int, input().split()))
print(1 + sum([int(P[i] <= min(P[:i])) for i in range(1, N)]))

N = int(input())
P = list(map(int, input().split()))
Q = []
m = 10**17
for p in P:
    m = min(m, p)
    Q.append(m)
c = 0
for x, y in zip(P, Q):
    if x <= y:
        c += 1
print(c)


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

cnt = 0
tmp = []
for i in range(len(lst)):
    num = lst[i]
    tmp.append(num)
    if num == min(tmp):
        cnt += 1

print(cnt)

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

cnt = 0
tmp_min = max(lst)
for i in range(len(lst)):
    num = lst[i]
    if num <= tmp_min:
        cnt += 1
        tmp_min = num

print(cnt)


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

def main():
    n = int(input())
    p = list(map(int, input().split()))

    count = 0
    for i in range(0, n):
        for j in range(0, i + 1):
            if p[i] > p[j]:
                break
            elif j == i:
                count += 1
    print(count)

if __name__ == "__main__":
    main()

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

def main():
    n = int(input())
    p = list(map(int, input().split()))

    count = 0
    n_min = 0
    for i in range(0, n):
        if i == 0:
            count += 1
            n_min = p[i]
            continue
        if p[i] <= n_min:
            count += 1
            n_min = p[i]
    print(count)

if __name__ == "__main__":
    main()


N = int(input())
P = [int(x) for x in input().split()]
count = 0
check = 0
for i in range(N):
    check = 0
    for j in range(i):
        if P[i] > P[j]:
            check = 1
            break
    if check == 0:
        count += 1

print(count)

N = int(input())
P = [int(x) for x in input().split()]
count = 0
check = 0
min = 10**9
for i in P:
    check = 0
    if min > i:
        min = i
    if i <= min:
        count += 1

print(count)


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

ans = 0
for i in range(N):
    if i == 0:
        ans += 1
        continue

    if P[i] <= min(P[:i]):
        ans += 1

print(ans)

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

ans = 0
n_p = 0
for i in range(N):
    if i == 0:
        ans += 1
        n_p = P[0]
        continue

    if P[i] <= n_p:
        ans += 1

    if n_p > P[i]:
        n_p = P[i]

print(ans)


import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()])
end_set = set()
count = 0

for a in A:
    if not end_set:
        count += 1
    elif a == min(min(end_set), a):
        count += 1
    end_set.add(a)

print(count)

N = int(input())
A = list([int(x) for x in input().split()])
count = 0

min_a = N + 1

for a in A:
    if a == min(min_a, a):
        count += 1
        min_a = a

print(count)


n = int(input())
p_n = list(map(int, input().split()))
ans = 1
p_i_1 = [p_n[0]]
for i in range(1, n):
    if min(p_i_1) > p_n[i]:
        ans += 1
    p_i_1.append(p_n[i])
print(ans)

n = int(input())
p_n = list(map(int, input().split()))
ans = 1
p_i_1 = [p_n[0]]
m = p_n[0]
for i in range(1, n):
    if m > p_n[i]:
        ans += 1
    m = min(m, p_n[i])
    p_i_1.append(p_n[i])
    if m == 1:
        break
print(ans)


N = int(input())
P = [int(x) for x in input().split()]
ans = 0
m = 0
for i in range(N):
    for j in range(m, i):
        if P[i] > P[j]:
            m = j
            break
    else:
        ans += 1
print(ans)

N = int(input())
P = [int(x) for x in input().split()]
mins = [0] * N
mins[0] = P[0]
for n in range(1, N):
    mins[n] = min(P[n], mins[n - 1])
ans = 0
for i in range(N):
    if P[i] == mins[i]:
        ans += 1
print(ans)


# -*- 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():
    n = input_int()
    p = input_to_int_tuple()

    cnt = 0
    for i in range(n):

        if i == 0 or p[i] <= min(p[:i]):
            cnt += 1

        # temp = True
        # for j in range(i):
        #     if p[i] > p[j]:
        #         temp = False
        #         break
        # if temp:
        #     cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()

# -*- 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():
    n = input_int()
    p = input_to_int_tuple()

    cnt = 0
    pre_min = 10**6
    for i in range(n):

        if i == 0 or p[i] <= pre_min:
            cnt += 1

        pre_min = min(pre_min, p[i])

        # temp = True
        # for j in range(i):
        #     if p[i] > p[j]:
        #         temp = False
        #         break
        # if temp:
        #     cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()


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

count = 1
for i in range(1, N):
    if P[i] <= min(P[:i]):
        count += 1
print(count)

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

count = 1
mini = P[0]
for i in range(1, N):
    if mini >= P[i]:
        count += 1
        mini = P[i]

print(count)


N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
    for j in range(0, i):
        if P[j] < P[i]:
            break
    else:
        ans += 1
print(ans)

N = int(input())
P = list(map(int, input().split()))
ans = 1
dp = [0 for i in range(N + 1)]
dp[0] = P[0]  # min
for i in range(N - 1):
    if P[i + 1] <= dp[i]:
        ans += 1
        dp[i + 1] = P[i + 1]
    else:
        dp[i + 1] = dp[i]

print(ans)


n = int(input())
p = [int(x) for x in input().split()]

ans = 0

for i in range(n):
    baes = p[i]
    flag = True
    for j in range(i):
        if p[i] > p[j]:
            flag = False
            break

    if flag:
        ans += 1

print(ans)

n = int(input())
p = [int(x) for x in input().split()]

ans = 1
base = p[0]

for i in range(1, n):
    if p[i] < base:
        ans += 1
        base = p[i]

print(ans)


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

cnt = 1

for i in reversed(range(1, N)):
    if P[i] < min(P[:i]):
        cnt += 1

print(cnt)

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

cnt = 1
p_min = P[0]

for i in range(1, N):
    if P[i] < p_min:
        cnt += 1
        p_min = P[i]

print(cnt)


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

ret = 0
currmin = P[0]
for i in range(N):
    if P[i] <= currmin:
        currmin = P[i]
        ret += 1

print(ret)

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

ret = 0
currmin = P[0]
for i in range(N):
    if P[i] <= currmin:
        currmin = P[i]
        ret += 1

print(ret)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02791/Python/s629344950.py", line 5, in <module>
    currmin = P[0]
TypeError: 'map' object is not subscriptable


N = int(input())
P = list(map(int, input().split()))
cnt = 0
for n in range(N):
    if n == 0:
        cnt += 1
    else:
        L = P[:n]
        L.sort()
        if P[n] <= L[0]:
            cnt += 1
print(cnt)

N = int(input())
P = list(map(int, input().split()))
cnt = 0
res = float("Inf")
for n in range(N):
    if P[n] < res:
        res = P[n]
        cnt += 1
print(cnt)


N = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(N):
    for n in range(i + 1):
        if P[n] < P[i]:
            break
        if i == n:
            count += 1
print(count)

N = int(input())
P = list(map(int, input().split()))
MIN = list()
count = 0
MIN.append(P[0])
for i in range(1, N):
    MIN.append(min(MIN[i - 1], P[i]))
for i in range(0, N):
    if P[i] <= MIN[i]:
        count += 1
print(count)


n = int(input())
p_list = list(map(int, input().split()))
min_list = []
min_list.append(p_list[0])
ans = 1

for i in range(1, n):
    if p_list[i] <= min(min_list):
        ans += 1
    min_list.append(p_list[i])

print(ans)

n = int(input())
p_list = list(map(int, input().split()))
min_num = p_list[0]
ans = 1

for i in range(1, n):
    if p_list[i] <= min_num:
        ans += 1
    min_num = min(min_num, p_list[i])

print(ans)


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

answer = 0
for i in range(len(p_li)):
    count_flag = True
    for j in range(i):
        if p_li[i] <= p_li[j]:
            continue
        else:
            count_flag = False
            break
    if count_flag:
        answer += 1

print(answer)

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

answer = 0
now_min = 999999
for i in range(len(p_li)):
    if now_min > p_li[i]:
        now_min = p_li[i]
        answer += 1

print(answer)


def main():
    N = int(input())
    P = list(map(int, input().split()))

    ans = 1

    for i in range(1, N):
        tmp = min(P[:i])
        if P[i] <= tmp:
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()

def main():
    N = int(input())
    P = list(map(int, input().split()))

    ans = 1
    tmp = P[0]
    for i in range(1, N):
        if P[i] == 1:
            print(ans + 1)
            return

        tmp = min(tmp, P[i])
        if P[i] <= tmp:
            ans += 1

    print(ans)

if __name__ == "__main__":
    main()


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

ans = 1
for i in range(1, n):
    if p[i] <= min(p[:i]):
        ans += 1

print(ans)

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

ans = 1
min = p[0]
for i in range(1, n):
    if min > p[i]:
        min = p[i]
    if p[i] <= min:
        ans += 1

print(ans)


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

ans = 1
for i in range(1, N):
    if min(P[:i]) >= P[i]:
        ans += 1
print(ans)

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

# N = 5
# P = [4, 2, 5, 1, 3]

ans = 0
min = 2 * 10**5
for i in range(0, N):
    # i = 1
    if min > P[i]:
        min = P[i]
    if P[i] <= min:
        ans += 1

print(ans)


import fractions

N = int(input())
A = list(map(int, input().split()))
L = A[0]
for i in range(1, N):
    L = L * A[i] // fractions.gcd(L, A[i])

ans = 0
for i in range(N):
    ans = (ans + L // A[i]) % 1000000007

print(ans)

import fractions

N = int(input())
A = list(map(int, input().split()))
L = A[0]
for i in range(1, N):
    L = L * A[i] // fractions.gcd(L, A[i])

ans = 0
for i in range(N):
    ans = ans + L // A[i]  #% 1000000007

print(ans % 1000000007)


from collections import defaultdict

def factorize(n: int) -> dict:
    f = defaultdict(int)
    while n % 2 == 0:
        f[2] += 1
        n //= 2
    p = 3
    while p * p <= n:
        while n % p == 0:
            f[p] += 1
            n //= p
        p += 2
    if n != 1:
        f[n] += 1
    return f

def _pow(b, p, mod):
    ret = 1
    while p:
        if p % 2 == 1:
            ret *= b
            ret %= mod
        b **= 2
        p //= 2
    return ret

MOD = 10**9 + 7
n = int(input())
a = tuple(map(int, input().split()))

a_fac = []
lcm_fac = defaultdict(int)
for a_i in a:
    a_fac_i = factorize(a_i)
    a_fac.append(a_fac_i)
    for k, v in a_fac_i.items():
        lcm_fac[k] = max(lcm_fac[k], v)

# print(lcm_fac)
ans = 0
for a_fac_i in a_fac:
    b_i = 1
    for k, v in lcm_fac.items():
        b_i *= _pow(k, v - a_fac_i[k], MOD)
        b_i %= MOD
    # print(i, a[i], b_i)
    ans += b_i
    ans %= MOD

print(ans)

from collections import defaultdict

def factorize(n: int) -> dict:
    f = defaultdict(int)
    while n % 2 == 0:
        f[2] += 1
        n //= 2
    p = 3
    while p * p <= n:
        while n % p == 0:
            f[p] += 1
            n //= p
        p += 2
    if n != 1:
        f[n] += 1
    return f

MOD = 10**9 + 7
n = int(input())
a = tuple(map(int, input().split()))

MAX_a = max(a)
iinv = [1] * (MAX_a + 1)
for i in range(2, MAX_a + 1):
    iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD

a_fac = []
lcm_fac = defaultdict(int)
for a_i in a:
    a_fac_i = factorize(a_i)
    a_fac.append(a_fac_i)
    for k, v in a_fac_i.items():
        lcm_fac[k] = max(lcm_fac[k], v)

lcm = 1
for k, v in lcm_fac.items():
    lcm *= pow(k, v, MOD)
    lcm %= MOD

ans = 0
for i in range(n):
    ans += lcm * iinv[a[i]]
    ans %= MOD

print(ans)


import fractions
import functools

MOD = 10**9 + 7

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

def lcm(a, b):
    gcd = fractions.gcd(a, b)
    return (a * b) // gcd

LCM = functools.reduce(lcm, A)
ans = sum([(LCM // a) % MOD for a in A]) % MOD

print(ans)

import functools
import fractions

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

L = functools.reduce(lambda a, b: a // fractions.gcd(a, b) * b, A) % MOD
ans = 0

for a in A:
    ans += L * pow(a, MOD - 2, MOD)
    ans %= MOD

print(ans)


def lcm(a, b):
    from math import gcd

    return a // gcd(a, b) * b

def main():
    _ = int(input())
    a = list(map(int, input().split()))
    x = 1

    for e in a:
        x = lcm(x, e)

    ans = 0
    for e in a:
        ans += x // e

    print(ans % int(1e9 + 7))

main()

def lcm(a, b):
    from fractions import gcd

    return a // gcd(a, b) * b

def main():
    _ = int(input())
    a = list(map(int, input().split()))
    x = 1

    for e in a:
        x = lcm(x, e)

    ans = 0
    for e in a:
        ans += x // e

    print(ans % int(1e9 + 7))

main()


from itertools import combinations
import sys

input = sys.stdin.buffer.readline

n = int(input())
graph = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)
# LCAが必要そう
# 慣れないけどdoublingしてみる？
# 実行時間に余裕があるし、毎回DFSしていい気がしてきた。
# 通った辺を(a,b)の形でsetに打ち込んで全部白になる場合の数を調べる方針

def dfs(s, g):
    kouho = set()
    par = [-1] * (n + 1)
    depth = [0] * (n + 1)
    stack = []
    stack.append(s)
    while stack:
        v = stack.pop()
        if v == g:
            break
        d = depth[v]
        for u in graph[v]:
            if u == par[v]:
                continue
            par[u] = v
            depth[u] = d + 1
            stack.append(u)
    # 経路復元
    p = g
    q = par[g]
    while q > 0:
        kouho.add((min(p, q), max(p, q)))
        p = q
        q = par[q]
    return kouho

m = int(input())
sets = [[] for _ in range(m)]
for i in range(m):
    u, v = map(int, input().split())
    sets[i] = dfs(u, v)
ans = 0
for i in range(1, m + 1):
    kumiawase = list(combinations(range(m), i))
    for kumi in kumiawase:
        temp = set()
        for j in range(i):
            temp |= sets[kumi[j]]
        num = len(list(temp))
        ans += (-1) ** (i + 1) * (pow(2, n - 1) - pow(2, n - 1 - num))

print(ans)

from itertools import combinations
import sys

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

n = int(readline())
AB = list(list(map(int, readline().split())) for _ in range(n - 1))
m = int(readline())
UV = list(list(map(int, readline().split())) for _ in range(m))

graph = [[] for _ in range(n + 1)]
for i, (a, b) in enumerate(AB):
    graph[a].append((b, i))
    graph[b].append((a, i))

def dfs(s, g):
    kouho = 0
    par = [(0, 0)] * (n + 1)
    stack = []
    stack.append(s)
    while stack:
        v = stack.pop()
        if v == g:
            break
        for u, i in graph[v]:
            if u == par[v][0]:
                continue
            par[u] = (v, i)
            stack.append(u)
    # 経路復元
    p = g
    q, i = par[p]
    while q > 0:
        kouho |= 1 << i
        p = q
        q, i = par[q]
    return kouho

def popcnt(n):
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
    c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F)
    c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF)
    c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF)
    c = (c & 0x00000000FFFFFFFF) + ((c >> 32) & 0x00000000FFFFFFFF)
    return c

sets = [0 for _ in range(m)]

for idx, (u, v) in enumerate(UV):
    sets[idx] = dfs(u, v)
ans = 0
for i in range(1, m + 1):
    kumiawase = list(combinations(range(m), i))
    for kumi in kumiawase:
        temp = 0
        for j in range(i):
            temp |= sets[kumi[j]]
        num = popcnt(temp)
        ans += (-1) ** (i + 1) * (pow(2, n - 1) - pow(2, n - 1 - num))

print(ans)


import heapq

n = int(input())
XL = [tuple(map(int, input().split())) for _ in range(n)]

blocked = [0] * n
total = 0
for i in range(n):
    ax, al = XL[i]
    for j in range(i + 1, n):
        bx, bl = XL[j]
        if ax - al < bx - bl < ax + al or ax - al < bx + bl < ax + al:
            blocked[i] -= 1
            blocked[j] -= 1
            total += 1
count = 0
heapq.heapify(blocked)
while total > 0:
    total += heapq.heappop(blocked)
    count += 1

print(n - count)

n = int(input())
LR = [None] * n
for i in range(n):
    x, l = map(int, input().split())
    LR[i] = (x - l, x + l)
LR.sort(key=lambda lr: lr[1])
count = 1
cur = LR[0][1]
for l, r in LR[1:]:
    if cur <= l:
        count += 1
        cur = r
print(count)


N = int(input())
R = sorted([list(map(int, input().split())) for i in range(N)])
T = []
for i in range(N):
    T.append([R[i][0] + R[i][1], R[i][0] - R[i][1]])
T.sort()
while len(T) - 1 > 0:
    t = T.pop(0)
    i = 1
    while len(T) and t[0] > T[0][1]:
        N -= 1
        i += 1
        T.pop(0)
print(N)

N = int(input())
X = [list(map(int, input().split())) for i in range(N)]
LR = [[x[0] - x[1], x[0] + x[1]] for x in X]
LR.sort(key=lambda x: x[1])

A = 1
right = LR[0][1]
for i in range(1, N):
    if right <= LR[i][0]:
        A += 1
        right = LR[i][1]
print(A)


N = int(input())
R = [list(map(int, input().split())) for i in range(N)]
T = [[R[i][0] + R[i][1], R[i][0] - R[i][1]] for i in range(N)]
T.sort()
while len(T) - 1 > 0:
    t = T.pop(0)
    i = 1
    while len(T) and t[0] > T[0][1]:
        N -= 1
        i += 1
        T.pop(0)
print(N)

N = int(input())
R = sorted([list(map(int, input().split())) for i in range(N)])
T = []
for i in range(N):
    T.append([R[i][0] + R[i][1], R[i][0] - R[i][1]])
T.sort(reverse=True)
while len(T) - 1 > 0:
    t = T.pop()
    i = 1
    while len(T) and t[0] > T[-1][1]:
        N -= 1
        i += 1
        T.pop()
print(N)


from sys import stdin

N, K, S = [int(x) for x in stdin.readline().rstrip().split()]

ans = [S] * K
n = (N - K) // (S - 1)
ans.extend([S + 1] * (N - K))

print(*ans)

from sys import stdin

N, K, S = [int(x) for x in stdin.readline().rstrip().split()]

ans = [S] * K
if S == 10**9:
    ans.extend([1] * (N - K))
else:
    ans.extend([S + 1] * (N - K))

print(*ans)


from itertools import repeat

n, k, s = map(int, input().split())
print(*repeat(s, k), *repeat((s + 1) % 10**9, n - k))


def iter_bit(k, LIMIT):
    v = (1 << k) - 1

    while v < LIMIT:
        yield v
        x = v & -v
        y = v + x
        v = (v & ~y) // x >> 1 | y

def solve(n, cards):
    dp = [{} for _ in range(1 << n)]
    dp[-1][0] = 0
    LIMIT = 1 << n

    for d in range(n):
        for state in iter_bit(n - d, LIMIT):
            scores = dp[state]
            k = state
            curr = 0
            while k:
                b = k & -k
                i = b.bit_length() - 1
                num = cards[i][(d - i) % 2]
                next_dp = dp[state ^ b]
                for score, left_num in scores.items():
                    if left_num > num:
                        continue
                    ns = score + curr
                    if ns not in next_dp or next_dp[ns] > num:
                        next_dp[ns] = num
                k ^= b
                curr += 1

    if len(dp[0]) > 0:
        return min(dp[0].keys())
    else:
        return -1

n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
cards = list(zip(aaa, bbb))
print(solve(n, cards))

def iter_bit(k, LIMIT):
    v = (1 << k) - 1

    while v < LIMIT:
        yield v
        x = v & -v
        y = v + x
        v = (v & ~y) // x >> 1 | y

def solve(n, cards):
    dp = [{} for _ in range(1 << n)]
    dp[-1][0] = 0
    LIMIT = 1 << n

    for d in range(n):
        for state in iter_bit(n - d, LIMIT):
            scores = dp[state]
            k = state
            curr = 0
            while k:
                b = k & -k
                i = b.bit_length() - 1
                num = cards[i][(d - i) % 2]
                next_dp = dp[state ^ b]
                for left_num, score in scores.items():
                    if left_num > num:
                        continue
                    ns = score + curr
                    if num not in next_dp or next_dp[num] > ns:
                        next_dp[num] = ns
                k ^= b
                curr += 1

    if len(dp[0]) > 0:
        return min(dp[0].values())
    else:
        return -1

n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))
cards = list(zip(aaa, bbb))
print(solve(n, cards))


import sys

args = sys.argv

a = "abcdefghijklmnopqrstuvwxyz"

c = args[1]
idx = a.index(c)
print(a[idx + 1])

import sys

args = sys.argv

a = "abcdefghijklmnopqrstuvwxyz"

c = input()
idx = a.index(c)
print(a[idx + 1])

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02801/Python/s556171083.py", line 7, in <module>
    c = args[1]
IndexError: list index out of range


import string

AL = string.lowercase

C = input()
idx = AL.find(C)
idy = (idx + 1) % 26
print(AL[idy])

import string

AL = string.ascii_lowercase

C = input()
idx = AL.find(C)
idy = (idx + 1) % 26
print(AL[idy])

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02801/Python/s068085135.py", line 3, in <module>
    AL = string.lowercase
AttributeError: module 'string' has no attribute 'lowercase'


c = input()
s = "abcdefghijklmnopqrstuvwxyz"
flg = True
for i in range(len(s) + 1):
    if c == s[i] and c != "z":
        print(s[i + 1])
        flg = False
    elif c == "z":
        print("a")
        flg = False

c = input()
s = "abcdefghijklmnopqrstuvwxyz"
flg = True
for i in range(len(s) + 1):
    if c == s[i] and c != "z":
        print(s[i + 1])
        break
    elif c == "z":
        print("a")
        break

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02801/Python/s621913033.py", line 5, in <module>
    if c == s[i] and c != "z":
IndexError: string index out of range


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

def resolve():
    n, m = map(int, input().split())

    if n == m:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    resolve()

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

def resolve():
    c = input()

    print(chr(ord(c) + 1))

if __name__ == "__main__":
    resolve()

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02801/Python/s953923794.py", line 15, in <module>
    resolve()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02801/Python/s953923794.py", line 6, in resolve
    n, m = map(int, input().split())
ValueError: invalid literal for int() with base 10: 'a'


N, M = map(int, input().split())
correct = []
missed = [0 for _ in range(N)]
penalty = 0

for _ in range(M):
    p, s = input().split()
    p = int(p)

    if s == "AC" and p not in correct:
        correct.append(p)
        penalty += missed[p - 1]
    elif s == "WA" and p not in correct:
        missed[p - 1] += 1

print(len(correct), penalty)

N, M = map(int, input().split())
correct = [0 for _ in range(N)]
missed = [0 for _ in range(N)]
penalty = 0
ans = 0
for _ in range(M):
    p, s = input().split()
    p = int(p)

    if s == "AC" and correct[p - 1] == 0:
        correct[p - 1] = 1
        penalty += missed[p - 1]
    elif s == "WA" and correct[p - 1] == 0:
        missed[p - 1] += 1

print(sum(correct), penalty)


n, m = map(int, input().split())
table = {}
ac = 0
pena_arr = [0 for _ in range(m + 1)]
for _ in range(n):
    a, b = input().split()
    a = int(a)
    if a not in table and b == "AC":
        ac += 1
        table[a] = True
    elif a not in table and b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, m + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)

n, m = map(int, input().split())
table = {}
ac = 0
pena = 0
pena_arr = [0 for _ in range(n + 1)]
for _ in range(m):
    a, b = input().split()
    a = int(a)
    if a in table:
        continue
    if b == "AC":
        ac += 1
        table[a] = True
    elif b == "WA":
        pena_arr[a] += 1
pena = 0
for i in range(1, n + 1):
    if pena_arr[i] > 0 and i in table:
        pena += pena_arr[i]
print(ac, pena)


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

scores = [[0, False] for _ in range(n)]

for _ in range(m):
    p, S = input().split()
    p = int(p)

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)

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

scores = [[0, False] for _ in range(n + 1)]

for _ in range(m):
    p, S = input().split()
    p = int(p)

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02802/Python/s650750562.py", line 9, in <module>
    if scores[p][1]:
IndexError: list index out of range


N, M = map(int, input().split())
accepted = [0] * N
penalties = [0] * N
for _ in range(M):
    p, ac = input().split()
    p, ac = int(p), ac == "AC"
    accepted[p] |= ac
    penalties[p] += not accepted[p]
print(sum(accepted), sum(p for ac, p in zip(accepted, penalties) if ac))

N, M = map(int, input().split())
accepted = [0] * N
penalties = [0] * N
for _ in range(M):
    p, ac = input().split()
    p, ac = int(p) - 1, ac == "AC"
    accepted[p] |= ac
    penalties[p] += not accepted[p]
print(sum(accepted), sum(p for ac, p in zip(accepted, penalties) if ac))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02802/Python/s182965476.py", line 7, in <module>
    accepted[p] |= ac
IndexError: list index out of range


import numpy as np

n, m = map(int, input().split())
is_ac = np.zeros(n, dtype=int)
wc_count = np.zeros(n, dtype=int)

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if is_ac[p - 1] == 0:
        if s == "WA":
            wc_count[p - 1] += 1
        else:
            is_ac[p - 1] = 1
print(is_ac.sum(), wc_count[is_ac].sum())

import numpy as np

n, m = map(int, input().split())
is_ac = np.zeros(n, dtype=bool)
wc_count = np.zeros(n, dtype=int)

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if not is_ac[p - 1]:
        if s == "WA":
            wc_count[p - 1] += 1
        else:
            is_ac[p - 1] = True
print(is_ac.sum(), wc_count[is_ac].sum())


def main(n, m, p_s):
    st = [False for _ in range(n)]
    ac, wa = 0, 0

    for p, s in p_s:
        if st[p - 1]:
            continue

        if s == "AC":
            ac += 1
            st[p - 1] = True
        if s == "WA":
            wa += 1

    print(ac, wa)

if __name__ == "__main__":
    n, m = map(int, input().split())
    p_s = [list(map(int, input().split())) for _ in range(m)]

    main(n, m, p_s)

def main(n: int, m: int, p_s: list):
    bool_ac = [False for _ in range(n)]
    count_wa = [0 for _ in range(n)]
    ac, wa = 0, 0

    for p, s in p_s:
        p = int(p)

        if bool_ac[p - 1]:
            continue

        if s == "AC":
            bool_ac[p - 1] = True
            wa += count_wa[p - 1]
            ac += 1
        elif s == "WA":
            count_wa[p - 1] += 1

    print(ac, wa)

if __name__ == "__main__":
    n, m = map(int, input().split())
    p_s = [input().split() for _ in range(m)]

    main(n, m, p_s)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02802/Python/s345841239.py", line 20, in <module>
    p_s = [list(map(int, input().split())) for _ in range(m)]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02802/Python/s345841239.py", line 20, in <listcomp>
    p_s = [list(map(int, input().split())) for _ in range(m)]
ValueError: invalid literal for int() with base 10: 'WA'


from collections import deque

H, W = map(int, input().split())

H += 2
W += 2

grid = "#" * W
for _ in range(H - 2):
    grid += "#" + input().split()
grid += "#" * W

def bfs(start):
    INF = 10 * 9
    dist = [INF] * (H * W)
    dist[start] = 0
    q = deque([start])
    while q:
        v = q.popleft()
        dv = dist[v]
        for move in (-1, 1, W, -W):
            # next place
            w = v + move
            # wall or not
            if grid[w] == "#":
                continue

            dw = dv + 1
            if dw >= dist[w]:
                continue
            dist[w] = dw
            q.append(w)

    return max(x for x in dist if x < INF)

answer = max(bfs(v) for v in range(H * W) if grid[v] != "#")
print(answer)

from collections import deque

H, W = map(int, input().split())

H += 2
W += 2

grid = "#" * W
for _ in range(H - 2):
    grid += "#" + input() + "#"
grid += "#" * W

def bfs(start):
    INF = 10**9
    dist = [INF] * (H * W)
    dist[start] = 0
    q = deque([start])
    while q:
        v = q.popleft()
        dv = dist[v]
        for move in (-1, 1, W, -W):
            # next place
            w = v + move
            # wall or not
            if grid[w] == "#":
                continue

            dw = dv + 1
            if dw >= dist[w]:
                continue
            dist[w] = dw
            q.append(w)

    return max(x for x in dist if x < INF)

answer = max(bfs(v) for v in range(H * W) if grid[v] != "#")
print(answer)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02803/Python/s560031032.py", line 10, in <module>
    grid += "#" + input().split()
TypeError: can only concatenate str (not "list") to str


from collections import deque
import itertools
import copy

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

def bfs(maze, s, g):
    q = deque()
    q.append((s, 0))

    maze[s[0]][s[1]] = "#"

    while len(q) > 0:
        p, depth = q.popleft()

        if p == g:
            return depth

        # ikerutoko
        next_pos = []
        if 0 <= p[0] - 1 < H and maze[p[0] - 1][p[1]] != "#":
            next_pos.append((p[0] - 1, p[1]))
        if 0 <= p[0] + 1 < H and maze[p[0] + 1][p[1]] != "#":
            next_pos.append((p[0] + 1, p[1]))
        if 0 <= p[1] - 1 < W and maze[p[0]][p[1] - 1] != "#":
            next_pos.append((p[0], p[1] - 1))
        if 0 <= p[1] + 1 < W and maze[p[0]][p[1] + 1] != "#":
            next_pos.append((p[0], p[1] + 1))

        # print(next_pos, q)

        for pos in next_pos:
            maze[pos[0]][pos[1]] = "#"
            q.append((pos, depth + 1))

    return -1

kaisuu = 0
for s in itertools.product(range(H), range(W)):
    for g in itertools.product(range(H), range(W)):
        if s == g or S[s[0]][s[1]] == "#" or S[g[0]][g[1]] == "#":
            continue

        maze = copy.deepcopy(S)
        k = bfs(maze, s, g)
        kaisuu = max(kaisuu, k)

print(kaisuu)

from collections import deque
import copy

H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

def bfs(maze, start):
    q = deque()
    q.append((start, 0))

    max_depth = 0

    while len(q) > 0:
        p, depth = q.popleft()

        if p[0] < 0 or H <= p[0]:
            continue
        if p[1] < 0 or W <= p[1]:
            continue
        if maze[p[0]][p[1]] == "#":
            continue

        maze[p[0]][p[1]] = "#"
        max_depth = depth

        next_pos = [
            (p[0] - 1, p[1]),
            (p[0] + 1, p[1]),
            (p[0], p[1] - 1),
            (p[0], p[1] + 1),
        ]

        for pos in next_pos:
            q.append((pos, depth + 1))

    return max_depth

depth = 0
for h in range(H):
    for w in range(W):
        maze = copy.deepcopy(S)
        depth = max(depth, bfs(maze, (h, w)))

print(depth)


from scipy.sparse.csgraph import dijkstra, csgraph_from_dense
import numpy as np

H, W = map(int, input().split())
S = [input() for _ in range(H)]

v_id_dict = {}
dista = np.ones((20, 20)) * np.inf

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            v_id_dict[i, j] = len(v_id_dict)

            if (i > 0) and (S[i - 1][j] == "."):
                dista[v_id_dict[(i, j)], v_id_dict[(i - 1, j)]] = 1

            if (j > 0) and (S[i][j - 1] == "."):
                dista[v_id_dict[(i, j)], v_id_dict[(i, j - 1)]] = 1

dist_mat = dijkstra(
    csgraph_from_dense(dista[: len(v_id_dict), : len(v_id_dict)]),
    directed=False,
    unweighted=False,
)

print(int(dist_mat.max()))

from scipy.sparse.csgraph import dijkstra, csgraph_from_dense
import numpy as np

H, W = map(int, input().split())
S = [input() for _ in range(H)]

v_id_dict = {}
dista = np.ones((400, 400)) * np.inf

for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            v_id_dict[i, j] = len(v_id_dict)

            if (i > 0) and (S[i - 1][j] == "."):
                dista[v_id_dict[(i, j)], v_id_dict[(i - 1, j)]] = 1

            if (j > 0) and (S[i][j - 1] == "."):
                dista[v_id_dict[(i, j)], v_id_dict[(i, j - 1)]] = 1

dist_mat = dijkstra(
    csgraph_from_dense(dista[: len(v_id_dict), : len(v_id_dict)]),
    directed=False,
    unweighted=False,
)

print(int(dist_mat.max()))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02803/Python/s307435936.py", line 1, in <module>
    from scipy.sparse.csgraph import dijkstra, csgraph_from_dense
ModuleNotFoundError: No module named 'scipy'


from copy import deepcopy
from collections import deque

# 最短にする
# 0回以上でたどり着けるのでスタート=ゴールのことがある ふざけんな
h, w = map(int, input().split())
table = [[] for _ in range(h)]
for i in range(h):
    table[i] = list(input())

def bfs(y, x, t):
    steps = [0, 1, 0, -1, 0]
    queue = deque([[y, x]])
    arr = []
    while len(queue) > 0:
        cur_y, cur_x = queue.popleft()
        for i in range(4):
            next_y, next_x = cur_y + steps[i], cur_x + steps[i + 1]
            if 0 <= next_y < h and 0 <= next_x < w:
                if t[next_y][next_x] == "G":
                    arr.append(t[cur_y][cur_x])
                    continue
                if t[next_y][next_x] == ".":
                    t[next_y][next_x] = t[cur_y][cur_x] + 1
                    queue.append([next_y, next_x])

    return 0 if len(arr) == 0 else min(arr) + 1

ans = 0
for sy in range(h):
    for sx in range(w):
        # table[sy][sx]をスタート地点とする
        if table[sy][sx] != ".":
            continue
        for gy in range(h):
            for gx in range(w):
                if sy == gy and sx == gx:
                    continue
                if table[gy][gx] == ".":
                    mytable = deepcopy(table)
                    mytable[sy][sx] = 0
                    mytable[gy][gx] = "G"
                    # ans = min(ans, bfs(sy, sx, mytable))
                    ret = bfs(sy, sx, mytable)
                    ans = max(ans, ret)

print(ans)

from copy import deepcopy
from collections import deque

# 最短にする
# 0回以上でたどり着けるのでスタート=ゴールのことがある ふざけんな
h, w = map(int, input().split())
table = [[] for _ in range(h)]
for i in range(h):
    table[i] = list(input())

def bfs(y, x, t):
    steps = [0, 1, 0, -1, 0]
    queue = deque([[y, x]])
    ret = 0
    while len(queue) > 0:
        cur_y, cur_x = queue.popleft()
        for i in range(4):
            next_y, next_x = cur_y + steps[i], cur_x + steps[i + 1]
            if 0 <= next_y < h and 0 <= next_x < w:
                if t[next_y][next_x] == ".":
                    t[next_y][next_x] = t[cur_y][cur_x] + 1
                    ret = max(ret, t[next_y][next_x])
                    queue.append([next_y, next_x])

    return ret

ans = 0
for sy in range(h):
    for sx in range(w):
        # table[sy][sx]をスタート地点とする
        if table[sy][sx] != ".":
            continue
        mytable = deepcopy(table)
        mytable[sy][sx] = 0
        ret = bfs(sy, sx, mytable)
        ans = max(ans, ret)

print(ans)


MOD = 10**9 + 7

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
A_r = list(reversed(A))
factorial = {0: 1, 1: 1}
for i in range(2, N + 1):
    factorial[i] = factorial[i - 1] * i

ans = 0
for i, j in zip(A, A_r):
    if N < K:
        break
    C = (factorial[N - 1] / factorial[K - 1]) / factorial[N - K]
    ans += (j - i) * C
    ans %= MOD
    N -= 1
ans = int(ans % MOD)
print(ans)

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort()
MOD = 10**9 + 7

def combination(mod=MOD):
    fact = [1] * (N + 1)
    inv_fact = [1] * (N + 1)
    r = 1
    for i in range(1, N + 1):
        fact[i] = r = r * i % mod
    inv_fact[N] = r = pow(fact[N], mod - 2, mod)
    for i in range(N, 0, -1):
        inv_fact[i - 1] = r = r * i % mod

    def _wrapper(n, k):
        nonlocal fact, inv_fact, mod
        if n == 0 or k == 0:
            return 1
        return fact[n] * inv_fact[k] * inv_fact[n - k] % mod

    return _wrapper

def main():
    if K == 1:
        print(0)
        exit()
    comb = combination()
    sum_max = 0
    sum_min = 0
    for i, A_i in enumerate(A):
        if i >= K - 1:
            sum_max += comb(i, K - 1) * A_i % MOD
        if N - i >= K:
            sum_min += comb(N - i - 1, K - 1) * A_i % MOD
    ans = (sum_max - sum_min) % MOD
    print(ans)

if __name__ == "__main__":
    main()


n = int(input())
x = list(map(int, input().split()))
mod = 10**9 + 7
X = []
for i in range(n - 1):
    X.append(x[i + 1] - x[i])
l, left = 1, [1]
for i in range(1, n - 1):
    l *= i
    l %= mod
    left.append(l)
r, right = 1, [1]
for i in range(n - 1, 1, -1):
    r *= i % mod
    right.append(r)
right.reverse()
f, flst = 0, []

for i, j in zip(left, right):
    f += i * j % mod
    f %= mod
    flst.append(f)
s = 0
for i, j in zip(X, flst):
    s += i * j % mod
print(s % mod)

# https://atcoder.jp/contests/dwacon6th-prelims/submissions/9426910

def solve():
    MOD = 10**9 + 7

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

    ds = []
    for i in range(N - 1):
        d = xs[i + 1] - xs[i]
        ds.append(d)

    nums = [1, 1]
    num = 1
    for i in range(2, N - 1):
        num *= i
        num %= MOD
        nums.append(num)

    ms = [N - 1]
    m = N - 1
    for i in reversed(range(2, N - 1)):
        m *= i
        m %= MOD
        ms.append(m)
    ms.reverse()
    ms.append(1)

    ks = []
    k = 0
    for num, m in zip(nums, ms):
        k += num * m % MOD
        k %= MOD
        ks.append(k)

    ans = 0
    for d, k in zip(ds, ks):
        ans += d * k % MOD
        ans %= MOD

    print(ans)

solve()


import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
permutation = list(itertools.permutations([x for x in range(1, N + 1)]))

a = permutation.index(P) + 1
b = permutation.index(Q) + 1
print(abs(a - b))

K, X = map(int, input().split())
print("Yes" if K * 500 >= X else "No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02811/Python/s360744826.py", line 3, in <module>
    N = int(input())
ValueError: invalid literal for int() with base 10: '2 900'


K = int(input("Enter k: "))
X = int(input("Enter x: "))

if K * 500 >= X:
    print("Yes")
else:
    print("No")

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

if K * 500 >= X:
    print("Yes")
else:
    print("No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02811/Python/s761507450.py", line 1, in <module>
    K = int(input("Enter k: "))
ValueError: invalid literal for int() with base 10: '2 900'


if __name__ == "__main__":
    x = int(input())
    m, n = map(int, input().split())
    if m * 500 >= n:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    m, n = map(int, input().split())
    if m * 500 >= n:
        print("Yes")
    else:
        print("No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02811/Python/s384378340.py", line 2, in <module>
    x = int(input())
ValueError: invalid literal for int() with base 10: '2 900'


n = int(input())
s = input()
ans = 0
for i in range(n):
    if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":
        ans += 1
print(ans)

n = int(input())
s = input()
ans = 0
for i in range(n):
    if s[i : i + 3] == "ABC":
        ans += 1
print(ans)


N = int(input())
S = input()

ans = 0
i = 0
while i < N:
    if S[i] == "A":
        i += 1
        if S[i] == "B":
            i += 1
            if S[i] == "C":
                ans += 1
            else:
                i += 1
        else:
            i += 1
    else:
        i += 1

print(ans)

N = int(input())
S = input()

ans = 0
for i in range(N):
    if S[i : i + 3] == "ABC":
        ans += 1

print(ans)


N = int(input())
S = input()
count = 0
for i in range(N):
    if S[i] == "A" and S[i + 1] == "B" and S[i + 2] == "C":
        count += 1
print(count)

N = int(input())
S = input()
count = 0
for i in range(N):
    try:
        if S[i] == "A" and S[i + 1] == "B" and S[i + 2] == "C":
            count += 1
    except IndexError:
        break
print(count)


# ABC150C - Count Order
from itertools import permutations

def main():
    N, *PQ = map(int, open(0).read().split())
    P, Q = PQ[:N], PQ[N:]
    perms = list(permutations(range(1, N + 1), N))
    ans = abs(perms.index(P) - perms.index(Q))
    print(ans)

if __name__ == "__main__":
    main()

# ABC150C - Count Order
from itertools import permutations

def main():
    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))
    perms = list(permutations(range(1, N + 1)))
    ans = abs(perms.index(P) - perms.index(Q))
    print(ans)

if __name__ == "__main__":
    main()

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02813/Python/s593478625.py", line 14, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02813/Python/s593478625.py", line 9, in main
    ans = abs(perms.index(P) - perms.index(Q))
ValueError: [1, 3, 2] is not in list


from scipy.special import perm

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
per = perm(n - 1, n - 1, exact=True)
r = 0
r2 = 0
for k in range(1, n)[::-1]:
    t = p[0]
    c = sum([t > x for x in p])
    r += per * c
    p.remove(t)
    t = q[0]
    c = sum([t > x for x in q])
    r2 += per * c
    q.remove(t)
    per = int(per / k)

print(int(abs(r - r2)))

import math

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
per = math.factorial(n - 1)
r = 0
r2 = 0
for k in range(1, n)[::-1]:
    t = p[0]
    c = sum([t > x for x in p])
    r += per * c
    p.remove(t)
    t = q[0]
    c = sum([t > x for x in q])
    r2 += per * c
    q.remove(t)
    per = int(per / k)

print(int(abs(r - r2)))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02813/Python/s340291207.py", line 1, in <module>
    from scipy.special import perm
ModuleNotFoundError: No module named 'scipy'


# ABC150C - Count Order
from itertools import permutations

def main():
    N, *PQ = map(int, open(0).read().split())
    P, Q = PQ[:N], PQ[N:]
    perms = list(permutations(range(1, N + 1)))
    ans = abs(perms.index(P) - perms.index(Q))
    print(ans)

if __name__ == "__main__":
    main()

# ABC150C - Count Order
from itertools import permutations

def main():
    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))
    perms = tuple(permutations(range(1, N + 1)))
    ans = abs(perms.index(P) - perms.index(Q))
    print(ans)

if __name__ == "__main__":
    main()

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02813/Python/s713702771.py", line 14, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02813/Python/s713702771.py", line 9, in main
    ans = abs(perms.index(P) - perms.index(Q))
ValueError: [1, 3, 2] is not in list


def GCD(a: int, b: int) -> int:
    return a if b == 0 else GCD(b, a % b)

def LCM(a: int, b: int) -> int:
    return a * b // GCD(a, b)

n, m = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))

a_lcm = a[0]
for i in range(1, n):
    a_lcm = LCM(a_lcm, a[i])

flag = True
for i in range(n):
    if (a_lcm // a[i]) % 2 == 0:
        flag = False
        break

if flag:
    ans = ((m // a_lcm) + 1) // 2
else:
    ans = 0
print(ans)

def GCD(a: int, b: int) -> int:
    return a if b == 0 else GCD(b, a % b)

def LCM(a: int, b: int) -> int:
    return a * b // GCD(a, b)

n, m = map(int, input().split())
a = list(map(lambda x: int(x) // 2, input().split()))

a_lcm = a[0]
for i in range(1, n):
    a_lcm = LCM(a_lcm, a[i])
    if a_lcm > m:
        break

if a_lcm <= m:
    flag = True
    for i in range(n):
        if (a_lcm // a[i]) % 2 == 0:
            flag = False
            break

    if flag:
        ans = ((m // a_lcm) + 1) // 2
    else:
        ans = 0
else:
    ans = 0
print(ans)


import sys
import math

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

cur = a[0]
for x in a[1:]:
    g = math.gcd(cur, x)
    if (cur // 2) % g != (x // 2) % g:
        print(0)
        sys.exit(0)
    else:
        cur = cur // g * x
    if cur > m * 2:
        print(0)
        sys.exit(0)

print((m + cur // 2) // cur)

import sys

def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y)

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

cur = a[0]
for x in a[1:]:
    g = gcd(cur, x)
    if (cur // 2) % g != (x // 2) % g:
        print(0)
        sys.exit(0)
    else:
        cur = cur // g * x
    if cur > m * 2:
        print(0)
        sys.exit(0)

print((m + cur // 2) // cur)


from fractions import gcd
from functools import reduce
import sys

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

max_value = 2 * m

if len(A) > 1:
    lcm = lcm_list(A)
else:
    lcm = A[0]

if any((lcm / a) % 2 != 1 for a in A):
    print("0")
    sys.exit(0)

max_product = max_value // lcm
print((max_product + 1) // 2)

from fractions import gcd
from functools import reduce
import sys

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers, maxvalue):
    first = 1
    second = 1
    for i in numbers:
        second = i
        lcm_result = lcm_base(first, second)
        if lcm_result > max_value:
            return -1
        first = lcm_result
    return lcm_result

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

max_value = 2 * m

lcm = lcm_list(A, 2 * m)
if lcm == -1:
    print("0")
    sys.exit(0)

if any((lcm / a) % 2 != 1 for a in A):
    print("0")
    sys.exit(0)

max_product = max_value // lcm
print((max_product + 1) // 2)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02814/Python/s018417487.py", line 1, in <module>
    from fractions import gcd
ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib/python3.10/fractions.py)


from sys import stdin
import fractions

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) // 2 for x in stdin.readline().rstrip().split()]
ans = 0
g = 1

for i in range(len(A)):
    g = g * A[i] // fractions.gcd(g % A[i], A[i])

for i in range(len(A)):
    if (g // A[i]) % 2 == 0:
        print(0)
        exit()

ans = M // g
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + 1) // 2)

from sys import stdin
import fractions

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) // 2 for x in stdin.readline().rstrip().split()]
ans = 0
g = 1

for i in range(len(A)):
    g = g * A[i] // fractions.gcd(g % A[i], A[i])
    if g > M:
        print(0)
        exit()

for i in range(len(A)):
    if (g // A[i]) % 2 == 0:
        print(0)
        exit()

ans = M // g
if ans % 2 == 0:
    print(ans // 2)
else:
    print((ans + 1) // 2)


import math

def f(x):
    res = 0
    while x % 2 == 0:
        x /= 2
        res += 1
    return res

def lcm(a, b):
    return a * b // math.gcd(a, b)

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

# a -> a'
for i in range(N):
    A[i] = A[i] // 2

# a' -> a''
t = f(A[0])
for i in range(N):
    if f(A[i]) != t:
        print(0)
        exit()
    A[i] >>= t  # A[i] /= 2^t
M >>= t

L = 1
for i in range(N):
    L = lcm(L, A[i])
    if L > M:
        print(0)
        exit()

M /= L
ans = math.ceil(M / 2)
print(ans)

from fractions import gcd
from functools import reduce

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

A = [i >> 1 for i in A]

def applied_lcm(x, y):
    g = gcd(x, y)
    x //= g
    y //= g
    if x % 2 == 0 or y % 2 == 0:
        return 0
    n = x * y * g
    if n >> 10**9:
        return 0

    return n

p = reduce(applied_lcm, A)
if p == 0:
    ans = 0
else:
    ans = (M // p) - (M // (p + p))
print(ans)


from fractions import gcd
from functools import reduce

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

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def count2(i, t=0):
    if i % 2 == 0:
        return count2(i // 2, t + 1)
    else:
        return t

N, M = inpl()
A = inpl()
A = [a // 2 for a in A]

all_lcm = lcm_list(A)
c_2 = count2(A[0])
for a in A:
    if c_2 != count2(a):
        print(0)
        exit()

print(((M // all_lcm) + 1) // 2)

from fractions import gcd
from functools import reduce

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

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def count2(i):
    t = 2
    ret = 1
    while i % t == 0:
        t *= 2
        ret += 1
    return ret - 1

N, M = inpl()
A = inpl()
A = [a // 2 for a in A]

all_lcm = 1
c2 = count2(A[0])
for a in A:
    all_lcm = lcm(all_lcm, a)
    if count2(a) != c2:
        print(0)
        exit()

print(((M // all_lcm) + 1) // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
d = [0] * (2 * n - 1)
for i in range(n - 1):
    c[i] = b[i] ^ b[i + 1]
    d[i] = a[i] ^ a[i + 1]
c[n - 1] = b[0] ^ b[-1]
d[n - 1] = a[0] ^ a[-1]
for i in range(n - 1):
    d[n + i] = d[i]
t = [0] * (n + 1)
t[0] = -1
j = -1
for i in range(n):
    while j >= 0 and c[i] != c[j]:
        j = t[j]
    j += 1
    t[i + 1] = j
m = 0
ans = []
while m < n:
    for i in range(n):
        if c[i] != d[m + i]:
            m += i - t[i]
            if i > 0:
                i = t[i]
            break
    else:
        ans.append(m)
        m = m + n - t[n]
        i = t[n]
for k in ans:
    print(k, a[k] ^ b[0])

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * n
d = [0] * (2 * n - 1)
for i in range(n - 1):
    c[i] = b[i] ^ b[i + 1]
    d[i] = a[i] ^ a[i + 1]
c[n - 1] = b[0] ^ b[-1]
d[n - 1] = a[0] ^ a[-1]
for i in range(n - 1):
    d[n + i] = d[i]
t = [0] * (n + 1)
t[0] = -1
j = -1
for i in range(n):
    while j >= 0 and c[i] != c[j]:
        j = t[j]
    j += 1
    t[i + 1] = j
m = 0
i = 0
ans = []
while m < n:
    if c[i] == d[m + i]:
        i += 1
        if i == n:
            ans.append(m)
            m += i - t[i]
            i = t[i]
    else:
        m += i - t[i]
        if i > 0:
            i = t[i]
for k in ans:
    print(k, a[k] ^ b[0])


In = list(map(int, input().split()))
sin = set(In)
print("Yes" if len(sin) == 2 else "No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02817/Python/s961214447.py", line 1, in <module>
    In = list(map(int, input().split()))
ValueError: invalid literal for int() with base 10: 'oder'


s, t = map(int, input().split())
print(s + t)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02817/Python/s795282831.py", line 1, in <module>
    s, t = map(int, input().split())
ValueError: invalid literal for int() with base 10: 'oder'


s, t = list(input().split().rstrip())
print(t + s)

s, t = input().rstrip().split()
print(t + s)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02817/Python/s248204703.py", line 1, in <module>
    s, t = list(input().split().rstrip())
AttributeError: 'list' object has no attribute 'rstrip'


s, t = input().split()
ans = t + s
print(ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02817/Python/s790047642.py", line 2, in <module>
    T = input()
EOFError: EOF when reading a line


s, t = map(str, input().split())
print(t + s)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02817/Python/s530679524.py", line 1, in <module>
    s, t = input()
ValueError: too many values to unpack (expected 2)


A, B, K = map(int, input().split())

for _ in range(K):
    if A > 0:
        A -= 1
    elif B > 0:
        B -= 1
    else:
        continue
print(A, B)

A, B, K = map(int, input().split())

C = max(0, A - K)
K -= A - C
print(C, max(0, B - K))


a, b, k = (int(i) for i in input().split())
takahashi = a - k
aoki = b + takahashi if takahashi < 0 else b
print(f"{max(takahashi, 0)} {max(aoki, 0)}")

a, b, k = (int(i) for i in input().split())
takahashi = a - k
aoki = b + takahashi if takahashi < 0 else b
print("{} {}".format(max(takahashi, 0), max(aoki, 0)))


a, b, k = map(int, input().split())
for _ in range(k):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1
print(a, b)

a, b, k = map(int, input().split())
if k >= a:
    b -= k - a
    a = 0
else:
    a -= k
print(max(a, 0), max(b, 0))


import sys

A, B, K = [int(num) for num in input().split()]

if A + B == K:
    print(0, 0)
    sys.exit(0)

if K > A:
    K = K - A
    A = 0

while K:
    if A > 0:
        A -= 1
        K -= 1
        continue
    if B > 0:
        B -= 1
        K -= 1
        continue
print(A, B)

import sys

A, B, K = [int(num) for num in input().split()]

if A + B <= K:
    A = 0
    B = 0
    print(A, B)
    sys.exit(0)

if A > K:
    A = A - K
    print(A, B)
    sys.exit(0)
else:
    K = K - A
    A = 0

if B > K:
    B = B - K
    print(A, B)
    sys.exit(0)
else:
    B = 0
    print(A, B)


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

for _ in range(k):
    if a >= 1:
        a -= 1
    elif b >= 1:
        b -= 1

print(a, b, sep=" ")

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

# TEだった
# for _ in range(k):
#     if a >= 1:
#         a -= 1
#     elif b >= 1:
#         b -= 1

ans_a = 0
ans_b = 0

if a >= k:
    ans_a = a - k
    ans_b = b
else:
    ans_a = 0
    if b >= (k - a):
        ans_b = b - (k - a)
    else:
        ans_b = 0

print(ans_a, ans_b, sep=" ")


A, B, K = map(int, input().split())
a = max(0, A - K)
if K - A > 0:
    b = max(0, B - K + A)
print(a, b)

A, B, K = map(int, input().split())
a = max(0, A - K)
b = B
if K - A > 0:
    b = max(0, B - K + A)
print(a, b)


a, b, k = input().split()
print(max(a - k, 0), b - max(k - a, 0))

a, b, k = map(int, input().split())
print(max(a - k, 0), max(b - max(k - a, 0), 0))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02818/Python/s417489568.py", line 2, in <module>
    print(max(a - k, 0), b - max(k - a, 0))
TypeError: unsupported operand type(s) for -: 'str' and 'str'


x = int(input())

while True:
    if x % 2 == 0:
        x += 1
        continue
    i = 1
    while i * i <= x:
        if x % i == 0:
            break
        i += 1
    else:
        print(x)
        exit()
    x += 1

x = int(input())
while True:
    i = 2
    while i * i <= x:
        if x % i == 0:
            break
        i += 1
    else:
        print(x)
        exit()
    x += 1


from sympy import sieve

x = int(input())

while True:
    if x in sieve:
        print(x)
        break
    x += 1

import math

x = int(input())

def is_prime(x):
    if x < 2:
        return False  # 2未満に素数はない
    if x == 2 or x == 3 or x == 5:
        return True  # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:
        return False  # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0:
            return False

        prime += step
        step = 6 - step

    return True

while True:
    if is_prime(x):
        print(x)
        break
    x += 1


import sympy

n = int(input())

if sympy.isprime(n):
    print(n)
else:
    res = sympy.nextprime(n, 1)
    print(res)

import math

n = int(input())

def prime_checker(n):
    dest = int(math.sqrt(n))
    for i in range(2, dest):
        if n % i == 0:
            return False
    return True

while True:
    if prime_checker(n):
        print(n)
        break
    n += 1


x = int(input())
nums = [i for i in range(2, 100004)]
while nums:
    primal = nums.pop(0)
    if primal >= x:
        print(primal)
        break
    nums = [num for num in nums if num % primal != 0]

import sys

x = int(input())
nums = [i for i in range(1, 100004, 2)]
del nums[0]
if x == 2:
    print(2)
    sys.exit()
while nums:
    primal = nums.pop(0)
    if primal >= x:
        print(primal)
        break
    nums = [num for num in nums if num % primal != 0]


import math

x = int(input())

primes = []

for n in range(2, 10000000000, 2):
    f = True
    mp = math.ceil(math.sqrt(n))
    for p in primes:
        if p > mp:
            break
        if n % p == 0:
            f = False
            break
    if f:
        primes.append(n)
        if n >= x:
            print(n)
            exit(0)

import math

x = int(input())

primes = []

if x == 2:
    print(2)
    exit(0)

for n in range(3, 10000000000, 2):
    f = True
    mp = math.ceil(math.sqrt(n))
    for p in primes:
        if p > mp:
            break
        if n % p == 0:
            f = False
            break
    if f:
        primes.append(n)
        if n >= x:
            print(n)
            exit(0)


import sys

x = int(input())
nums = [i for i in range(1, 100004, 2)]
del nums[0]
if x == 2:
    print(2)
    sys.exit()
while nums:
    primal = nums.pop(0)
    if primal >= x:
        print(primal)
        break
    nums = [num for num in nums if num % primal != 0]

def check_primal(num):
    """素数だったら0を、違ったら1を返す"""
    for mod in range(2, int(num**0.5 + 1)):
        if num % mod == 0:
            return 1
    return 0

x = int(input())

for i in range(x, 100004):
    if check_primal(i) == 0:
        print(i)
        break


# import math
import fractions

n = int(input())

def prime(n):
    if n == 1:
        n += 1
    while True:
        flag = 0
        for k in range(2, int(fractions.sqrt(n)) + 1):
            if n % k == 0:
                flag = 1
                break
        if flag == 0:
            return n
        n += 1

ans = prime(n)
print(ans)

n = int(input())

def prime(n):
    if n == 1:
        n += 1
    while True:
        flag = 0
        for k in range(2, int(n**0.5) + 1):
            if n % k == 0:
                flag = 1
                break
        if flag == 0:
            return n
        n += 1

ans = prime(n)
print(ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02819/Python/s955323601.py", line 21, in <module>
    ans = prime(n)
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02819/Python/s955323601.py", line 12, in prime
    for k in range(2, int(fractions.sqrt(n)) + 1):
AttributeError: module 'fractions' has no attribute 'sqrt'


def factors(n):
    return [i for i in range(2, n) if n % i == 0]

X = int(input())

prime_l = factors(X)
while True:
    for i in prime_l:
        if X % i == 0:
            break
    prime_l.append(X)
    X += 1
print(X)

import random

def is_prime3(q, k=50):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True

X = int(input())

while not is_prime3(X):
    X += 1

print(X)


import sympy

pg = sympy.primerange(2, 100001)

x = int(input())

for p in pg:
    if p >= x:
        print(p)
        break

import math

x = int(input())

def is_prime(n):
    if n < 2:
        return False
    if n % 2 == 0 and n > 2:
        return False
    return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))

for n in range(100005):
    if n >= x and is_prime(n):
        print(n)
        break


from itertools import accumulate

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

A.sort(reverse=True)
d = [0] * (A[0] * 2 + 1)
for i in range(N):
    d[A[i]] += 1
d = list(accumulate(d[::-1]))[::-1]
b = list(accumulate(A))

left = 0
right = A[0] * 2 + 1
while right - left > 1:
    mid = (left + right) // 2
    m = 0
    for i in range(N):
        m += d[max(0, mid - A[i])]
    if m >= M:
        left = mid
    else:
        right = mid

ans = 0
m = 0
for i in range(N):
    t = min(d[max(0, left - A[i])], M - m)
    ans += b[t] + A[i] * t
    m += t
print(ans)

from itertools import accumulate

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

A.sort(reverse=True)
d = [0] * (A[0] * 2 + 1)
for i in range(N):
    d[A[i]] += 1
d = list(accumulate(d[::-1]))[::-1]
S = list(accumulate([0] + A))

left = 0
right = A[0] * 2 + 1
while right - left > 1:
    mid = (left + right) // 2
    m = 0
    for i in range(N):
        m += d[max(0, mid - A[i])]
    if m >= M:
        left = mid
    else:
        right = mid

ans = 0
m = 0
for i in range(N):
    t = min(d[max(0, right - A[i])], M - m)
    ans += S[t] + A[i] * t
    m += t
ans += left * (M - m)
print(ans)


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

c = [ai + aj for ai in A for aj in A]
c.sort()

ans = sum(c[-M:])
print(ans)

from numpy.fft import rfft, irfft
import numpy as np
from bisect import bisect_left, bisect_right

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

a = np.zeros(2**18)
for Ai in A:
    a[Ai] += 1

fa = rfft(a)
a2 = irfft(fa**2)
a2 = np.round(a2).astype(np.int)

cum_a2 = np.cumsum(a2)

index = bisect_left(cum_a2, N**2 - M)
eli = cum_a2[index] - (N**2 - M)

a2[index] -= eli

ans = sum(A) * 2 * N - (a2[: index + 1] * np.arange(index + 1)).sum()
print(ans)


n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
s = a[0]
t = 0
j = 1
ret = 0
for i in range(n):
    s -= a[i]
    ret += a[i] * 2
    m -= 1
    while j < n and (i >= n - 1 or a[i + 1] + a[i + 1] <= a[i] + a[j]):
        if m < i * 2:
            for k in range(i):
                if m > 0:
                    ret += a[j] + a[k]
                    m -= 1
                if m > 0:
                    ret += a[j] + a[k]
                    m -= 1
        else:
            ret += a[j] * i * 2 + t * 2
            m -= i * 2
        s += a[j]
        j += 1
    num = (j - i - 1) * 2
    if m <= num:
        for k in range(i + 1, j):
            if m > 0:
                ret += a[i] + a[k]
                m -= 1
            if m > 0:
                ret += a[i] + a[k]
                m -= 1
        break
    m -= num
    ret += s * 2 + a[i] * num
    t += a[i]
    print(a, m, num, s, i, j, ret)
print(ret)

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
s = [0]
for ai in a:
    s.append(ai + s[-1])

def count(x, accum=False):
    ret = 0
    for ai in a:
        lo, hi = -1, n
        while hi - lo > 1:
            mid = (lo + hi) // 2
            if ai + a[mid] >= x:
                lo = mid
            else:
                hi = mid
        ret += ai * hi + s[hi] if accum else hi
    return ret

lo, hi = 0, 1000000000
while hi - lo > 1:
    mid = (lo + hi) // 2
    if count(mid) >= m:
        lo = mid
    else:
        hi = mid

print(count(lo, accum=True) - (count(lo) - m) * lo)


import numpy as np

N, A, B = map(int, input().split())
ab_max = np.amax(np.array([A, B]))
ab_min = np.amin(np.array([A, B]))

if (A - B) % 2 == 0:
    print(int((ab_max - ab_min) / 2))
else:
    print(int(np.amin([(ab_max - 1), (N - ab_min)])))

import numpy as np
from decimal import Decimal

N, A, B = map(Decimal, input().split())
ab_max = np.amax(np.array([A, B]))
ab_min = np.amin(np.array([A, B]))

if (A - B) % 2 == 0:
    print(int((ab_max - ab_min) / 2))
else:
    print(int(np.amin([ab_min - 1, N - ab_max]) + (ab_max - ab_min + 1) / 2))


n, m, v, p = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

def check(x):
    if x > n - p:
        return True

    for i in range(x + 1, n - p + 1):
        if a[x] + m < a[i]:
            return False

    if v - x - p > 0:
        cnt = 0
        for i in range(x + 1, n - p + 1):
            cnt += min((a[x] + m) - a[i], m)

        if (cnt // (v - x - p)) >= m:
            return True
        else:
            return False
    else:
        return True

lb = -1  # False
ub = n - 1  # True
while ub - lb > 1:
    mid = (ub + lb) // 2
    if check(mid):
        ub = mid
    else:
        lb = mid

# print(a)
# print(lb, ub)
ans = n - ub
print(ans)

n = int(input())

def make3board(x):
    # 3x3のクォリティー2の敷き詰め方
    # aab
    # d.b
    # dcc
    m = x // 3
    base = ["aab", "d.b", "dcc"]
    board = []
    for i in range(m):
        sl = "..." * i
        sr = "..." * (m - 1 - i)
        for bj in base:
            board.append(sl + bj + sr)
    return board

def make4board(x):
    # 4x4のクォリティー3の敷き詰め方
    # aagh
    # bbgh
    # cdee
    # cdff
    m = x // 4
    base = ["aagh", "bbgh", "cdee", "cdff"]
    board = []
    for i in range(m):
        sl = "...." * i
        sr = "...." * (m - 1 - i)
        for bj in base:
            board.append(sl + bj + sr)
    return board

def make5board(x):
    # 5x5のクォリティー3の敷き詰め方
    # aadde
    # bbg.e
    # ccgff
    # ..abc
    # ..abc
    m = x // 5
    base = ["aadde", "bbg.e", "ccgff", "..abc", "..abc"]
    board = []
    for i in range(m):
        sl = "....." * i
        sr = "....." * (m - 1 - i)
        for bj in base:
            board.append(sl + bj + sr)
    return board

def make7board(x):
    # 7x7のクォリティー3の敷き詰め方
    # aabbcc.
    # dd.dd.c
    # ..d..dc
    # ..d..db
    # dd.dd.b
    # ..d..da
    # ..d..da
    m = x // 7
    base = ["aabbcc.", "dd.dd.c", "..d..dc", "..d..db", "dd.dd.b", "..d..da", "..d..da"]
    return board

def concat_board(board1, board2):
    # クォリティーが同じ２つのboardを対角線上に配置して繋ぐ
    # A..
    # .BB
    # .BB
    x, y = len(board1), len(board2)
    board = []
    sr = "." * y
    board += [board1[i] + sr for i in range(x)]
    sl = "." * x
    board += [sl + board2[i] for i in range(y)]
    return board

board = []
if n % 3 == 0:
    board = make3board(n)
elif n % 4 == 0:
    board = make4board(n)
elif n % 5 == 0:
    board = make5board(n)
elif n == 7 or n == 11:
    board7 = [
        "aabbcc.",
        "dd.dd.c",
        "..d..dc",
        "..d..db",
        "dd.dd.b",
        "..d..da",
        "..d..da",
    ]
    board = concat_board(board7, make4board(n - 7))
else:
    for x in range(4, n, 4):
        y = n - x
        if y % 5 == 0:
            board = concat_board(make4board(x), make5board(y))
            break

if len(board) != 0:
    print(*board, sep="\\n")
else:
    print(-1)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02825/Python/s793394062.py", line 1, in <module>
    n, m, v, p = map(int, input().split())
ValueError: not enough values to unpack (expected 4, got 1)


a, b = map(int, input().split())
ans = 6 - (a + b)
print(ans)

a = int(input())
b = int(input())
print(6 - a - b)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02829/Python/s996128891.py", line 1, in <module>
    a, b = map(int, input().split())
ValueError: not enough values to unpack (expected 2, got 1)


def main():
    A = input()
    B = input()

    if A == "1" and B == "2":
        ans = 3
    elif A == "2" and B == "3":
        ans = 1
    elif A == "3" and B == "1":
        ans = 2

    print(ans)

if __name__ == "__main__":
    main()

def main():
    A = int(input())
    B = int(input())

    ans = 6 - A - B

    print(ans)

if __name__ == "__main__":
    main()


a, b = map(int, input().split())
print(6 - a - b)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02829/Python/s060375473.py", line 1, in <module>
    a, b = map(int, input().split())
ValueError: not enough values to unpack (expected 2, got 1)


n = int(input())
s, t = [int(input()) for i in range(2)]
out = ""
for i in range(n):
    out += s[i] + t[i]
print(out)

n = int(input())
s, t = input().split()
out = ""
for i in range(n):
    out += s[i] + t[i]
print(out)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02830/Python/s669050732.py", line 2, in <module>
    s, t = [int(input()) for i in range(2)]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02830/Python/s669050732.py", line 2, in <listcomp>
    s, t = [int(input()) for i in range(2)]
ValueError: invalid literal for int() with base 10: 'ip cc'


import math

def main():
    A, B = map(int, input().split())

    print(A * B // math.gcd(A, B))

if __name__ == "__main__":
    main()

import fractions

def main():
    A, B = map(int, input().split())

    print(A * B // fractions.gcd(A, B))

if __name__ == "__main__":
    main()


import numpy as np

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

print(np.lcm(a, b))

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

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(a, b))


# C - Snack

from math import gcd

A, B = map(int, input().split())
print(A * B // gcd(A, B))

# C - Snack

from fractions import gcd

A, B = map(int, input().split())
print(A * B // gcd(A, B))


import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

ab = input()
a = int(ab.split(" ")[0])
b = int(ab.split(" ")[1])

print(lcm(a, b))

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

ab = input()
a = int(ab.split(" ")[0])
b = int(ab.split(" ")[1])

print(lcm(a, b))


import math

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

print((a * b) // math.gcd(a, b))

import fractions

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

print((a * b) // fractions.gcd(a, b))


import math

A, B = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

from fractions import gcd

A, B = map(int, input().split())

def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(A, B))


import numpy as np

A, B = [int(i) for i in input().split()]

print(np.lcm(A, B))

import fractions

A, B = [int(i) for i in input().split()]

print(int(A * B / fractions.gcd(A, B)))


import math

a, b = map(int, input().split())
print(a / math.gcd(a, b) * b)

import fractions

a, b = map(int, input().split())
print(a // fractions.gcd(a, b) * b)


from math import gcd

a, b = tuple(map(int, input().split()))
print(int(a * b / gcd(a, b)))

from fractions import gcd

a, b = tuple(map(int, input().split()))
print(int(a * b / gcd(a, b)))


import math

A, B = map(int, input().split())
print(A * B // math.gcd(A, B))

import fractions

A, B = map(int, input().split())
print(A * B // fractions.gcd(A, B))


import math

A, B = map(int, input().split())

print(int(A * B / math.gcd(A, B)))

import fractions

A, B = map(int, input().split())

print(int(A * B / fractions.gcd(A, B)))


import math

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

ans = int(a * b / math.gcd(a, b))

print(ans)

def calc_gcd(a, b):
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b

    return b

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

if a < b:
    tmp = a
    a = b
    b = tmp

gcd = calc_gcd(a, b)
ans = int(a * b / gcd)

print(ans)


import math

data = input().split()
val = [int(n) for n in data]

res = val[0] * val[1] / math.gcd(val[0], val[1])

print(res)

import fractions

data = input().split()
val = [int(n) for n in data]

res = val[0] * val[1] / fractions.gcd(val[0], val[1])

print(int(res))


num_list = [int(i) for i in input().split()]

result = 0

max = num_list[0] * num_list[1]
for i in range(1, max + 1):
    amari_1 = i % num_list[0]
    amari_2 = i % num_list[1]
    if amari_1 == 0 and amari_2 == 0:
        result = i
        break

print(result)

num_list = [int(i) for i in input().split()]

result = 0

if num_list[0] < num_list[1]:
    A = num_list[0]
    B = num_list[1]
else:
    A = num_list[1]
    B = num_list[0]

while True:
    amari = A % B
    if amari == 0:
        break
    A = B
    B = amari

# 最大公約数 B

# 最小公倍数
result = num_list[0] * num_list[1] // B

print(result)


import math

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

k = math.gcd(a, b)

ans = (a * b) // k

print(ans)

import fractions

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

k = fractions.gcd(a, b)

ans = (a * b) // k

print(ans)


import math

if __name__ == "__main__":
    A, B = input().split()
    A = int(A)
    B = int(B)
    ret = (A * B) // math.gcd(A, B)
    print(ret)

import fractions

if __name__ == "__main__":
    A, B = input().split()
    A = int(A)
    B = int(B)
    ret = (A * B) // fractions.gcd(A, B)
    print(ret)


from sys import stdin
import fractions

a = int(stdin.readline().rstrip())
b = int(stdin.readline().rstrip())

print(a * b // fractions.gcd(a, b))

import fractions

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

print(a * b // fractions.gcd(a, b))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02831/Python/s722500141.py", line 4, in <module>
    a = int(stdin.readline().rstrip())
ValueError: invalid literal for int() with base 10: '2 3'


import numpy as np

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

print(int((a * b) / np.gcd(a, b)))

import fractions

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

print(int((a * b) / fractions.gcd(a, b)))


from sys import stdin
import math

# A = int(stdin.readline().rstrip())
A, B = [int(x) for x in stdin.readline().rstrip().split()]
# print(A, B)

if A < B:
    A, B = B, A

print((A * B) // math.gcd(A, B))

from sys import stdin
import fractions

A, B = [int(x) for x in stdin.readline().rstrip().split()]

print((A * B) // fractions.gcd(A, B))


import math

a, b = map(int, input().split())
t = math.gcd(a, b)
print(a // t * b)

from fractions import gcd

a, b = map(int, input().split())
t = gcd(a, b)
print(a // t * b)


import math

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

ans = a * b // math.gcd(a, b)
print(ans)

import fractions

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

ans = a * b // fractions.gcd(a, b)
print(ans)


import math

a, b = [int(x.strip()) for x in input().split()]
print((a * b) // math.gcd(a, b))

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

def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def lcm(x, y):
    return (x * y) // gcd(x, y)

def sol(a, b):
    return (a * b) // gcd(a, b)

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


import fraction

A, B = map(int, input().split())

print(A * B // fraction.gcd(A, B))

import fractions

A, B = map(int, input().split())

print(A * B // fractions.gcd(A, B))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02831/Python/s216243162.py", line 1, in <module>
    import fraction
ModuleNotFoundError: No module named 'fraction'


import math

x, y = map(int, input().split())
print((x * y) // math.gcd(x, y))

import fractions

x, y = map(int, input().split())
print((x * y) // fractions.gcd(x, y))


import math

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

print((a * b) // math.gcd(a, b))

# import math
import fractions

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

print((a * b) // fractions.gcd(a, b))


# from fractions import gcd
from math import gcd

a, b = map(int, input().split())
print(a * b // gcd(a, b))
exit(0)

from fractions import gcd

# from math import gcd

a, b = map(int, input().split())
print(a * b // gcd(a, b))
exit(0)


import math

A, B = map(int, input().split())

def get_lcm(a, b):
    return (a * b) // math.gcd(a, b)

print(get_lcm(A, B))

import fractions

A, B = map(int, input().split())

def get_lcm(a, b):
    return (a * b) // fractions.gcd(a, b)

print(get_lcm(A, B))


import math

# 最小公倍数lcm（ least common multiple）を返す関数は用意されていない
# が、lcm(a, b) = a * b / gcd(a, b)で求められる

A, B = map(int, input().split())
ans = A * B // math.gcd(A, B)
print(ans)

import fractions

# 最小公倍数lcm（ least common multiple）を返す関数は用意されていない
# が、lcm(a, b) = a * b / gcd(a, b)で求められる

A, B = map(int, input().split())
ans = A * B // fractions.gcd(A, B)
print(ans)


import math

A, B = [int(n) for n in input().split()]

print(int((A * B) / math.gcd(A, B)))

import fractions

A, B = [int(n) for n in input().split()]

print(A * B // fractions.gcd(A, B))


import math

N = input().split()

A = int(N[0])
B = int(N[1])

lcm = int(A * B / math.gcd(A, B))

print(lcm)

from fractions import gcd

N = input().split()

A = int(N[0])
B = int(N[1])

lcm = int(A * B / gcd(A, B))

print(lcm)


import fractions

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

print(int(a * b / fractions.gcd(a * b)))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02831/Python/s463768606.py", line 5, in <module>
    print(int(a * b / fractions.gcd(a * b)))
AttributeError: module 'fractions' has no attribute 'gcd'


import functions

X = [int(x) for x in input().split()]

v = functions.gcd(X[0], X[1])
j = X[0] / v
p = int(X[1] * j)

print(p)

import fractions

X = [int(x) for x in input().split()]

v = fractions.gcd(X[0], X[1])
j = X[0] / v
p = int(X[1] * j)

print(p)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02831/Python/s715572091.py", line 1, in <module>
    import functions
ModuleNotFoundError: No module named 'functions'


import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

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

print(lcm(a, b))

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

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

print(lcm(a, b))


import math as ma

def lcm(x, y):
    return (x * y) // ma.gcd(x, y)

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

print(lcm(a, b))


import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A, B = map(int, input().split())

print(lcm(A, B))

import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

A, B = map(int, input().split())

print(lcm(A, B))


import math

A, B = map(int, input().split())

print(A * B // math.gcd(A, B))

A, B = map(int, input().split())

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

print(A * B // gcd(A, B))


import fractions as f

A, B = map(int, input().split())

print(A * B // f.gcd(A, B))


import math

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

print(a * b // math.gcd(a, b))

# import math

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

# print(a * b // math.gcd(a, b))

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

print(lcm(a, b))


#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-Snack.py
#
import math

a, b = map(int, input().split())
ans = int(a * b / math.gcd(a, b))
print(ans)

#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-Snack.py
#
from fractions import gcd

a, b = map(int, input().split())
ans = int(a * b // gcd(a, b))
print(ans)


# 最小公倍数
import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

# 最小公倍数
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(a, b))


import fractions

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

print(a * b // fractions.gcd(a, b))


import math

A, B = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

import math

A, B = map(int, input().split())

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

# a,bの最小公倍数

def lcm(a, b):
    return a * b // gcd(a, b)

print(lcm(A, B))


N = int(input())
a = list(map(int, input().split()))
nm = 1
ans = 0
while a:
    x = a.pop(0)
    if x == nm:
        nm += 1
    else:
        ans += 1

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

N = int(input())
a = list(map(int, input().split()))
nm = 1
ans = 0
for i in range(N):
    x = a[i]
    if x == nm:
        nm += 1
    else:
        ans += 1

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


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

length = len(A)
head = 0
i = 1

while True:
    if i in A:
        head = A.index(i)
        A = A[head:]
        i += 1
    else:
        break

if i == 1:
    print(-1)
else:
    print(length - i + 1)

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

length = len(A)
find_next = 1

for i in range(N):
    if A[i] == find_next:
        find_next += 1

if find_next == 1:
    print(-1)
else:
    print(length - find_next + 1)


def main(n: int, a: list):
    ans = 0

    i = 1

    if 1 not in a:
        print(-1)
        return

    while len(a) > 0:
        if a[0] != i:
            a.pop(0)
            ans += 1
            continue
        i += 1
        a.pop(0)

    print(ans)

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)

def main(n: int, a: list):
    ans = 0

    i = 1

    if 1 not in set(a):
        print(-1)
        return

    for _a in a:
        if _a != i:
            ans += 1
        else:
            i += 1

    print(ans)

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)


N = int(input())
a = list(map(int, input().split()))
remain = 1  # 残す整数
index = 0

if remain not in a:
    print(-1)
    exit()

while remain in a[index:]:
    index = a[index:].index(remain)
    remain += 1

print(N - remain + 1)

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

now = 1
for ai in a:
    if ai == now:
        now += 1

if now == 1:
    print(-1)
else:
    print(N - now + 1)


n = int(input())
lst = list(map(int, input().split()))
i, j = 0, 1
while i < len(lst):
    if lst[i] != j:
        lst.pop(i)
    else:
        i += 1
        j += 1

if not lst:
    print(-1)
else:
    print(n - len(lst))

n = int(input())
lst = list(map(int, input().split()))
i = 1
for j in lst:
    if i == j:
        i += 1

print(-1 if i == 1 else n - i + 1)


N = int(input())
alist = list(map(int, input().split()))
left = 0
for i in range(1, N + 1):
    try:
        old_left = left
        left = alist[left:].index(i)
        p = left + old_left
    except ValueError:
        print(i, p)
        if i == 1:
            print(-1)
        else:
            print(N - i + (N - p))
        break
else:
    print(0)

N = int(input())
alist = list(map(int, input().split()))
now = 1
for a in alist:
    if a == now:
        now += 1
if now == 1:
    print(-1)
else:
    print(N - now + 1)


n = int(input())
a = tuple(map(int, input().split()))
pos = 0
j = 1

while True:
    for i, data in enumerate(a[pos:]):
        if data == j:
            pos += i + 1
            j += 1
            break
    else:
        print((-1, n - j + 1)[j != 1])
        break

n = int(input())
j = 1

for i in map(int, input().split()):
    if i == j:
        j += 1

print((-1, n - j + 1)[j != 1])