def main():
    H, W, D = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    Q = int(input())
    ans = []

    x = [0 for _ in range(90001)]
    y = [0 for _ in range(90001)]
    for i, row in enumerate(A):
        for j, a in enumerate(row):
            x[a] = j
            y[a] = i

    for _ in range(Q):
        L, R = map(int, input().split())
        if L == R:
            ans.append(0)
            continue
        m = 0
        while L != R:
            m += abs(x[L] - x[L + D]) + abs(y[L] - y[L + D])
            L += D
        ans.append(m)
    for a in ans:
        print(a)

main()

def main():
    H, W, D = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    Q = int(input())
    ans = []

    x = [0 for _ in range(90001)]
    y = [0 for _ in range(90001)]
    dp = [0 for _ in range(90001)]

    for i, row in enumerate(A):
        for j, a in enumerate(row):
            x[a] = j
            y[a] = i
    for i in range(D + 1, H * W + 1):
        dp[i] = dp[i - D] + abs(x[i] - x[i - D]) + abs(y[i] - y[i - D])

    for _ in range(Q):
        L, R = map(int, input().split())
        ans.append(dp[R] - dp[L])
    for a in ans:
        print(a)

main()


H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
d = dict()
for i in range(H):
    for j in range(W):
        d[A[i][j]] = (i, j)
Q = int(input())
LR = [tuple(map(int, input().split())) for _ in range(Q)]
for L, R in LR:
    pow = 0
    while L != R:
        i, j = d[L]
        L += D
        x, y = d[L]
        pow += abs(x - i) + abs(y - j)
    print(pow)

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

d = [None for _ in range(H * W + 1)]
for i in range(H):
    for j in range(W):
        d[A[i][j]] = (i, j)

cumsum = [0 for _ in range(H * W + 1)]
for m in range(1, D + 1):
    i = m
    while i <= H * W:
        if i - D <= 0:
            i += D
            continue
        x1, y1 = d[i - D]
        x2, y2 = d[i]
        dist = abs(x2 - x1) + abs(y2 - y1)
        cumsum[i] = cumsum[i - D] + dist
        i += D

Q = int(input())
LR = [tuple(map(int, input().split())) for _ in range(Q)]
for L, R in LR:
    print(cumsum[R] - cumsum[L])


h, w, d = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]

nc = dict()
for row in range(h):
    for col in range(w):
        v = A[row][col]
        nc[v] = (row, col)

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

for lr in lrs:
    l, r = lr
    ans = 0
    while l != r:
        i, j = nc[l]
        x, y = nc[l + d]
        ans += abs(x - i) + abs(y - j)
        l += d
    print(ans)

h, w, d = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(h)]

nc = dict()
for row in range(h):
    for col in range(w):
        v = A[row][col]
        nc[v] = (row, col)

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

c_sums = [[0] for _ in range(d)]
for r in range(d):
    k = 0
    if r == 0:
        k = 1
    while r + (k + 1) * d <= h * w:
        i, j = nc[r + k * d]
        x, y = nc[r + (k + 1) * d]
        t = c_sums[r][-1] + abs(x - i) + abs(y - j)
        c_sums[r].append(t)
        k += 1

for lr in lrs:
    l, r = lr
    ld, rest = divmod(l, d)
    rd = r // d
    if rest == 0:
        ld -= 1
        rd -= 1
    print(c_sums[rest][rd] - c_sums[rest][ld])


h, w, d = map(int, input().split())

p = [[] for _ in range(h * w)]

for i in range(h):
    temp = list(map(int, input().split()))
    for j in range(w):
        p[temp[j] - 1] = [i, j]

q = int(input())
a = [[int(x) - 1 for x in input().split()] for _ in range(q)]

for i in range(q):
    temp = 0
    j = a[i][1]
    while j > a[i][0]:
        temp += abs(p[j][0] - p[j - d][0]) + abs(p[j][1] - p[j - d][1])
        j -= d
    print(temp)

h, w, d = map(int, input().split())

p = [[] for _ in range(h * w)]

for i in range(h):
    temp = list(map(int, input().split()))
    for j in range(w):
        p[temp[j] - 1] = [i, j]

q = int(input())
a = [[int(x) - 1 for x in input().split()] for _ in range(q)]

s = [0 for _ in range(h * w)]
for i in range(d, h * w):
    s[i] = s[i - d] + abs(p[i][0] - p[i - d][0]) + abs(p[i][1] - p[i - d][1])

for i in range(q):
    print(s[a[i][1]] - s[a[i][0]])


import sys

import numba as nb
import numpy as np

input = sys.stdin.readline

@nb.njit("void(i8,i8,i8,i8[:,:],i8,i8[:,:],i8[:])", cache=True)
def dfs(H, W, D, A, Q, LR, ans):
    position = [(-1, -1)] * (H * W + 1)
    for h in range(H):
        for w in range(W):
            position[A[h][w]] = (h, w)

    mp = np.zeros(shape=(H * W + 1), dtype=np.int64)

    for i in range(1, H * W + 1 - D):
        h, w = position[i]
        y, x = position[i + D]
        mp[i] = abs(x - w) + abs(y - h)

    for i in range(Q):
        l, r = LR[i]
        ans[i] = mp[l:r:D].sum()

def main():
    H, W, D = map(int, input().split())
    A = np.zeros(shape=(H, W), dtype=np.int64)
    for i in range(H):
        A[i] = tuple(map(int, input().split()))
    Q = int(input())
    LR = np.zeros(shape=(Q, 2), dtype=np.int64)
    for i in range(Q):
        LR[i] = tuple(map(int, input().split()))

    ans = np.zeros(shape=Q, dtype=np.int64)
    dfs(H, W, D, A, Q, LR, ans)

    print("\\n".join(map(str, ans)))

if __name__ == "__main__":
    main()

import sys

import numba as nb
import numpy as np

input = sys.stdin.readline

@nb.njit("void(i8,i8,i8,i8[:,:],i8,i8[:,:],i8[:])", cache=True)
def dfs(H, W, D, A, Q, LR, ans):
    position = [(-1, -1)] * (H * W + 1)
    for h in range(H):
        for w in range(W):
            position[A[h][w]] = (h, w)

    mp = np.zeros(shape=(H * W + 1), dtype=np.int64)

    for i in range(1, H * W + 1 - D):
        h, w = position[i]
        y, x = position[i + D]
        mp[i + D] = abs(x - w) + abs(y - h)

    for d in range(1, D + 1):
        mp[d::D] = np.cumsum(mp[d::D])

    for i in range(Q):
        l, r = LR[i]
        ans[i] = mp[r] - mp[l]

def main():
    H, W, D = map(int, input().split())
    A = np.zeros(shape=(H, W), dtype=np.int64)
    for i in range(H):
        A[i] = tuple(map(int, input().split()))
    Q = int(input())
    LR = np.zeros(shape=(Q, 2), dtype=np.int64)
    for i in range(Q):
        LR[i] = tuple(map(int, input().split()))

    ans = np.zeros(shape=Q, dtype=np.int64)
    dfs(H, W, D, A, Q, LR, ans)

    print("\\n".join(map(str, ans)))

if __name__ == "__main__":
    main()


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

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

t = [[0] * ((H * W + D - 1) // D) for _ in range(D)]
for i in range(D):
    ti = t[i]
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        ti[j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(len(ti) - 1):
        ti[j + 1] += ti[j]

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    print(t[i][(R - i) // D] - t[i][(L - i) // D])

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

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

t = [[0] * ((H * W + D - 1) // D + 1) for _ in range(D)]
for i in range(D):
    ti = t[i]
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        ti[j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(len(ti) - 1):
        ti[j + 1] += ti[j]

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    print(t[i][(R - i) // D] - t[i][(L - i) // D])


H, W, D = map(int, input().split())
X, Y = [-1] * H * W, [-1] * H * W

for h in range(H):
    A = list(map(int, input().split()))
    for w in range(W):
        X[A[w] - 1], Y[A[w] - 1] = h, w

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    ans = 0
    while L != R:
        ans += abs(X[L - 1] - X[L + D - 1]) + abs(Y[L - 1] - Y[L + D - 1])
        L += D
    print(ans)

H, W, D = map(int, input().split())
X, Y, ans = [-1] * H * W, [-1] * H * W, [0] * H * W

for h in range(H):
    A = list(map(int, input().split()))
    for w in range(W):
        X[A[w] - 1], Y[A[w] - 1] = h, w

for d in range(D):
    while d + D < H * W:
        ans[d + D] = ans[d] + abs(X[d] - X[d + D]) + abs(Y[d] - Y[d + D])
        d += D

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print(ans[R - 1] - ans[L - 1])


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

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

t = [[0] * (H * W // D + 1) for _ in range(D)]
for i in range(D):
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        t[i][j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(len(H * W // D + 1) - 1):
        t[i][j + 1] += t[i][j]

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    print(t[i][(R - i) // D] - t[i][(L - i) // D])

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

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

t = [[0] * (H * W // D + 1) for _ in range(D)]
for i in range(D):
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        t[i][j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(H * W // D):
        t[i][j + 1] += t[i][j]

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    print(t[i][(R - i) // D] - t[i][(L - i) // D])

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03426/Python/s565873746.py", line 19, in <module>
    for j in range(len(H * W // D + 1) - 1):
TypeError: object of type 'int' has no len()


n = input()

lst = list(map(int, list(n)))
print(sum(lst[0], lst[0] - 1 + 9 * (len(lst) - 1)))

n = input()

lst = list(map(int, list(n)))
print(max(sum(lst), lst[0] - 1 + 9 * (len(lst) - 1)))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03427/Python/s873894440.py", line 4, in <module>
    print(sum(lst[0], lst[0] - 1 + 9 * (len(lst) - 1)))
TypeError: 'int' object is not iterable


N = list(input())
if len(N) == 1:
    print(int(N))
else:
    print((len(N) - 1) * 9 + (int(N[0]) - 1))

def main():
    from itertools import dropwhile

    S = input()
    it = dropwhile(lambda char: char == "9", reversed(S))
    # 末尾から見て9以外の数字が現れたら、以降をiterate

    len_ = len(list(it))
    if len_ <= 1:
        print(sum(map(int, S)))
    else:
        head = S[0]
        body = str(int(head) - 1)
        body += "9" * (len(S) - 1)

        print(sum(map(int, body)))

if __name__ == "__main__":
    main()


s = input()

if s < 10:
    print(s)
else:
    print(int(s[0]) - 1 + 9 * (len(s) - 1))

s = input()

if int(s) < 10:
    print(int(s))
elif all([x == "9" for x in s[1:]]):
    print(int(s[0]) + 9 * (len(s) - 1))
else:
    print(int(s[0]) - 1 + 9 * (len(s) - 1))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03427/Python/s576472986.py", line 3, in <module>
    if s < 10:
TypeError: '<' not supported between instances of 'str' and 'int'


def solve(n, k):
    MOD = 998244353

    if n > k:
        return 0

    invs = [1] * (k + 1)
    pf, kf = 1, 1
    for m in range(2, k + 1):
        pf = kf
        kf *= m
        kf %= MOD
        invs[m] = pow(kf, MOD - 2, MOD)

    ans = 0
    if k & 1 == 0:
        if n == 1:
            ans = 1
        else:
            r = k >> 1
            t = r - n + 1
            ans = pf * (invs[r] * invs[r - 1] - invs[r + t] * invs[k - r - t - 1]) % MOD

    for r in range(k // 2 + 1, k + 1):
        if r * 2 >= n + k:
            ans += kf * invs[r] * invs[k - r]
        else:
            t = r - n + 1
            ans += kf * (invs[r] * invs[k - r] - invs[r + t] * invs[k - r - t])
        ans %= MOD
    return ans

print(solve(*map(int, input().split())))

def solve(n, k):
    MOD = 998244353

    if n > k:
        return 0
    if n == 1:
        return pow(2, k - 1, MOD)

    invs = [1] * (k + 1)
    pf, kf = 1, 1
    for m in range(2, k + 1):
        pf = kf
        kf *= m
        kf %= MOD
        invs[m] = pow(kf, MOD - 2, MOD)

    ans = 0
    if k & 1 == 0:
        r = k >> 1
        s = k - n + 1
        ans = pf * (invs[r] * invs[r - 1] - invs[s] * invs[k - s - 1]) % MOD

    for r in range(k // 2 + 1, k + 1):
        if r * 2 >= n + k:
            ans += kf * invs[r] * invs[k - r]
        else:
            s = r * 2 - n + 1
            ans += kf * (invs[r] * invs[k - r] - invs[s] * invs[k - s])
        ans %= MOD
    return ans

print(solve(*map(int, input().split())))


N = int(input())
A = int(input())

ans = N % A

if A == 0:
    print("No")
    exit()
print("Yes" if ans <= A else "No")

N = int(input())
A = int(input())

print("Yes" if N % 500 <= A else "No")


N = input()
A = input()

if N % 500 <= A:
    print("Yes")
else:
    print("No")

n = int(input())
a = int(input())

if n % 500 <= a:
    print("Yes")
else:
    print("No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03433/Python/s013245589.py", line 4, in <module>
    if N % 500 <= A:
TypeError: not all arguments converted during string formatting


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

n = input()
a = input()

if n % 500 <= a:
    print("Yes")
else:
    print("No")

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

n = int(input())
a = int(input())

if n % 500 <= a:
    print("Yes")
else:
    print("No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03433/Python/s074980758.py", line 6, in <module>
    if n % 500 <= a:
TypeError: not all arguments converted during string formatting


_, *a = map(int, open(0).read().split())
a.sorted()
print(sum(a[-1::2]) - sum(a[-2::2]))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03434/Python/s513111966.py", line 2, in <module>
    a.sorted()
AttributeError: 'list' object has no attribute 'sorted'. Did you mean: 'sort'?


N = int(input())
a = list(map(int, input().split()))
a.soat(reverse=True)
A = sum([i for i in a[::2]])
B = sum([j for j in a[1::2]])
print(A - B)

N = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
A = sum([i for i in a[::2]])
B = sum([j for j in a[1::2]])
print(A - B)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03434/Python/s555410226.py", line 3, in <module>
    a.soat(reverse=True)
AttributeError: 'list' object has no attribute 'soat'. Did you mean: 'sort'?


# https://atcoder.jp/contests/abc088/tasks/abc088_b?lang=ja

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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

for i in range(len(a)):
    if i % 2 == 0:
        alice_score += a[i]
    else:
        bob_score += a[i]

print(alice_score - bob_score)
# https://atcoder.jp/contests/abc088/tasks/abc088_b?lang=ja

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

a.sort(reverse=True)

alice_score = 0
bob_score = 0

for i in range(len(a)):
    if i % 2 == 0:
        alice_score += a[i]
    else:
        bob_score += a[i]

print(alice_score - bob_score)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03434/Python/s375721705.py", line 20, in <module>
    N = int(input())
EOFError: EOF when reading a line


n = int(input())
s = list(map(int, input().split()))
s.sort(reverse=True)
print(s[::2] - s[1::2])

n = int(input())
s = list(map(int, input().split()))
s.sort(reverse=True)
print(sum(s[::2]) - sum(s[1::2]))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03434/Python/s552917295.py", line 4, in <module>
    print(s[::2] - s[1::2])
TypeError: unsupported operand type(s) for -: 'list' and 'list'


N = int(input())
a = sorted(list(map((int, input().split())), reverse=True))
A = 0
B = 0
for i in range(N):
    if i % 2 == 0:
        A += a[i]
    else:
        B += a[i]

print(A - B)

N = int(input())
a = list(map(int, input().split()))
asort = sorted(a, reverse=True)
A = 0
B = 0
for i in range(N):
    if i % 2 == 0:
        A += asort[i]
    else:
        B += asort[i]

print(A - B)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03434/Python/s148944674.py", line 2, in <module>
    a = sorted(list(map((int, input().split())), reverse=True))
TypeError: map() must have at least two arguments.


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

nums.sort_values(reverse=True)
print(sum(nums[0::2]) - sum(nums[1::2]))

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

nums.sort(reverse=True)
print(sum(nums[0::2]) - sum(nums[1::2]))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03434/Python/s337319572.py", line 4, in <module>
    nums.sort_values(reverse=True)
AttributeError: 'list' object has no attribute 'sort_values'


C1 = list(map(int, input().split()))
C2 = list(map(int, input().split()))
C3 = list(map(int, input().split()))

C = [C1, C2, C3]
A = [0] * 3
B = [0] * 3

B = C1
A[1] = C2[0] - B[0]
A[2] = C3[0] - B[0]

flg = True
for a in range(A[1], A[2]):
    for b in range(B[1], B[2]):
        if C[a][b] != a + b:
            flg = False

if flg is True:
    print("Yes")
else:
    print("No")

C1 = list(map(int, input().split()))
C2 = list(map(int, input().split()))
C3 = list(map(int, input().split()))

C = [C1, C2, C3]
A = [0] * 3
B = [0] * 3

B = C1
A[1] = C2[0] - B[0]
A[2] = C3[0] - B[0]
flg = True
for i, a in enumerate(A):
    for j, b in enumerate(B):
        if C[i][j] != a + b:
            flg = False

if flg is True:
    print("Yes")
else:
    print("No")


c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

bs = []
for a1 in range(0, 100):
    for b1 in range(0, 100):
        if a1 + b1 == c11:
            f1 = True
            break
    for b2 in range(0, 100):
        if a1 + b2 == c12:
            f2 = True
            break
    for b3 in range(0, 100):
        if a1 + b3 == c13:
            f3 = True
            break
    if f1 and f2 and f3:
        bs.append((b1, b2, b3))

bss = []
for a2 in range(0, 100):
    for b1, b2, b3 in bs:
        if a2 + b1 == c21 and a2 + b2 == c22 and a2 + b3 == c23:
            bss.append((b1, b2, b3))

for a3 in range(0, 100):
    for b1, b2, b3 in bss:
        if a3 + b1 == c31 and a3 + b2 == c32 and a3 + b3 == c33:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")

c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

bs = []
for a1 in range(0, 101):
    for b1 in range(0, 101):
        if a1 + b1 == c11:
            f1 = True
            break
    for b2 in range(0, 101):
        if a1 + b2 == c12:
            f2 = True
            break
    for b3 in range(0, 101):
        if a1 + b3 == c13:
            f3 = True
            break
    if f1 and f2 and f3:
        bs.append((b1, b2, b3))

bss = []
for a2 in range(0, 101):
    for b1, b2, b3 in bs:
        if a2 + b1 == c21 and a2 + b2 == c22 and a2 + b3 == c23:
            bss.append((b1, b2, b3))

for a3 in range(0, 101):
    for b1, b2, b3 in bss:
        if a3 + b1 == c31 and a3 + b2 == c32 and a3 + b3 == c33:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")


c = [list(map(int, input().split())) for _ in range(3)]
try:
    assert (sum(c[2]) - sum(c[1])) % 3 == 0
    assert (sum(c[1]) - sum(c[0])) % 3 == 0
    assert (sum([c[2] for line in c]) - sum([c[1] for line in c])) % 3 == 0
    assert (sum([c[1] for line in c]) - sum([c[0] for line in c])) % 3 == 0
    print("Yes")
except AssertionError:
    print("No")

c = [list(map(int, input().split())) for _ in range(3)]
try:
    assert (sum(c[2]) - sum(c[1])) % 3 == 0
    assert (sum(c[1]) - sum(c[0])) % 3 == 0
    assert (sum([line[2] for line in c]) - sum([line[1] for line in c])) % 3 == 0
    assert (sum([line[1] for line in c]) - sum([line[0] for line in c])) % 3 == 0
    print("Yes")
except AssertionError:
    print("No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03435/Python/s748241963.py", line 5, in <module>
    assert (sum([c[2] for line in c]) - sum([c[1] for line in c])) % 3 == 0
TypeError: unsupported operand type(s) for +: 'int' and 'list'


# 最短でゴールして残った黒をぜんぶ白に変えれば最大のポイントをもらえそう
# ってなふうに雑に考えてたけど、探索・最短経路復元・解答それぞれで1度ずつBFSをしなきゃならんのか？？？？

h, w = map(int, input().split())
table = [[] for _ in range(h)]
for y in range(h):
    table[y] = list(input())
# ステップ更新用
my_table = [[-1 for _ in range(w)] for _ in range(h)]
my_table[0][0] = 0
yo = [(0, 0)]
steps = [0, -1, 0, 1, 0]
while len(yo) > 0:
    p = yo[0]
    yo = yo[1:]
    for i in range(4):
        next_x, next_y = steps[i + 1] + p[1], steps[i] + p[0]
        if next_x < 0 or w <= next_x or next_y < 0 or h <= next_y:
            continue
        if table[next_y][next_x] == "#":
            continue
        if my_table[next_y][next_x] >= 0:
            continue
        my_table[next_y][next_x] = my_table[p[0]][p[1]] + 1
        yo.append((next_y, next_x))

# 経路を逆からたどって最短経路復元
restore_table = [["o" for _ in range(w)] for _ in range(h)]
restore_table[h - 1][w - 1] = "x"
now = my_table[h - 1][w - 1]
cur = (h - 1, w - 1)
while now != 0:
    for i in range(4):
        next_y, next_x = steps[i] + cur[0], steps[i + 1] + cur[1]
        if next_x < 0 or w <= next_x or next_y < 0 or h < next_y:
            continue
        if my_table[next_y][next_x] == now - 1:
            restore_table[next_y][next_x] = "x"
            cur = (next_y, next_x)
            now -= 1
            break

# やっと答え
ans = 0
for y in range(h):
    for x in range(w):
        if restore_table[y][x] == "o" and table[y][x] == ".":
            ans += 1
print(ans)

# 最短でゴールして残った黒をぜんぶ白に変えれば最大のポイントをもらえそう
# ってなふうに雑に考えてたけど、探索・最短経路復元・解答それぞれで1度ずつBFSをしなきゃならんのか？？？？

h, w = map(int, input().split())
table = [[] for _ in range(h)]
for y in range(h):
    table[y] = list(input())
# ステップ更新用
my_table = [[-1 for _ in range(w)] for _ in range(h)]
my_table[0][0] = 0
yo = [(0, 0)]
steps = [0, -1, 0, 1, 0]
while len(yo) > 0:
    p = yo[0]
    yo = yo[1:]
    for i in range(4):
        next_x, next_y = steps[i + 1] + p[1], steps[i] + p[0]
        if next_x < 0 or w <= next_x or next_y < 0 or h <= next_y:
            continue
        if table[next_y][next_x] == "#":
            continue
        if my_table[next_y][next_x] >= 0:
            continue
        my_table[next_y][next_x] = my_table[p[0]][p[1]] + 1
        yo.append((next_y, next_x))
if my_table[h - 1][w - 1] == -1:
    print(-1)
    exit()

# 経路を逆からたどって最短経路復元
restore_table = [["o" for _ in range(w)] for _ in range(h)]
restore_table[h - 1][w - 1] = "x"
now = my_table[h - 1][w - 1]
cur = (h - 1, w - 1)
while now != 0:
    for i in range(4):
        next_y, next_x = steps[i] + cur[0], steps[i + 1] + cur[1]
        if next_x < 0 or w <= next_x or next_y < 0 or h < next_y:
            continue
        if my_table[next_y][next_x] == now - 1:
            restore_table[next_y][next_x] = "x"
            cur = (next_y, next_x)
            now -= 1
            break

# やっと答え
ans = 0
for y in range(h):
    for x in range(w):
        if restore_table[y][x] == "o" and table[y][x] == ".":
            ans += 1
print(ans)


from collections import deque

def bfs(start):
    q = deque([[start]])
    visited = set()
    while q:
        path = q.popleft()
        i, j = path[-1]
        if (i, j) == (H - 1, W - 1):
            return path
        for di, dj in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            ni, nj = i + di, j + dj
            if (
                0 <= ni < H
                and 0 <= nj < W
                and field[ni][nj] != "#"
                and (ni, nj) not in visited
            ):
                new_path = list(path) + [(ni, nj)]
                q.append(new_path)
                visited.add((i, j))

H, W = map(int, input().split())
field = [input() for _ in range(H)]
shortest_path = bfs((0, 0))
if shortest_path is None:
    print(-1)
    exit()
ans = 0
for i in range(H):
    for j in range(W):
        if field[i][j] == "." and (i, j) not in shortest_path:
            ans += 1
print(ans)

from collections import deque

def bfs(start):
    q = deque([[start]])
    visited = set()
    while q:
        path = q.popleft()
        i, j = path[-1]
        if (i, j) == (H - 1, W - 1):
            return path
        for di, dj in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
            ni, nj = i + di, j + dj
            if (
                0 <= ni < H
                and 0 <= nj < W
                and field[ni][nj] != "#"
                and (ni, nj) not in visited
            ):
                q.append(path + [(ni, nj)])
                visited.add((ni, nj))

H, W = map(int, input().split())
field = [input() for _ in range(H)]
shortest_path = bfs((0, 0))
if shortest_path is None:
    print(-1)
    exit()
ans = 0
for i in range(H):
    for j in range(W):
        if field[i][j] == "." and (i, j) not in shortest_path:
            ans += 1
print(ans)


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

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

max_num = 10**18 // X

for i in range(max_num + 1):
    if i == 0:
        continue
    else:
        if (i * X) % Y != 0:
            print(i * X)
            break
        else:
            if i == (max_num + 1):
                print(-1)
            else:
                continue

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

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

max_num = 10**18 // X

if X % Y == 0:
    print(-1)
else:
    for i in range(max_num + 1):
        if i == 0:
            continue
        else:
            if (i * X) % Y != 0:
                print(i * X)
                break
            else:
                continue


from functools import reduce

from math import gcd

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

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

    return reduce(lcm, numbers, 1)

a = lcm(x, y) - x

print(-1 if a == 0 else a)

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

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

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

a = lcm(x, y) - x

print(-1 if a == 0 else a)


# 8 = 2 * 2 * 2
# 6 = 2 * 3
x = int(input())
y = int(input())
result = 0

if x % y == 0:
    result = -1
else:
    result = x * 2

print(result)

# 8 = 2 * 2 * 2
# 6 = 2 * 3
x, y = map(int, (input().split()))

result = 0

if x % y == 0:
    result = -1
else:
    result = x

print(result)

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


X, Y = map(int, input().split())
i = 1
if X % Y == 0:
    print(-1)
else:
    while True:
        if i % X == 0 and i % Y != 0:
            print(i)
            break
        else:
            i += 1

X, Y = map(int, input().split())
i = 1
if X % Y == 0:
    print(-1)
else:
    print(X)


x, y = [int(i) for i in input().split()]
if x % y == 0:
    print(-1)
else:
    i = 2
    while True:
        if i * x % y != 0:
            print(i * x)
            break
        i += 1


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

if X == Y:
    print(-1)
    exit()
x = 2
while True:
    if X * x % Y != 0:
        print(X * x)
        exit()
    x += 1

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

if X % Y == 0:
    print(-1)
else:
    print(X)


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

cnt_a, cnt_b = sum(a), sum(b)
ans = "No"
i = 0
cnt = 0
while cnt < cnt_b - cnt_a:
    if a[i] < b[i]:
        cnt += int((b[i] - a[i]) / 2 + 0.5)
    else:
        cnt += a[i] - b[i]
    i += 1
    if i == n:
        ans = "Yes"

print(ans)

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

x, y = 0, 0
for i in range(n):
    dif = b[i] - a[i]
    if dif > 0:
        x += dif // 2
    else:
        y += -dif

print("Yes" if x >= y else "No")


from queue import PriorityQueue

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

A_sum = sum(A)
B_sum = sum(B)
diff = B_sum - A_sum
if diff < 0:
    print("No")
    exit()

Aq = PriorityQueue()
Bq = PriorityQueue()
for a in A:
    Aq.put((a, a))
for b in B:
    Bq.put((b, b))

cnt = 0

while cnt <= diff and (not Aq.empty()) and (not Bq.empty()):
    _, a = Aq.get()
    _, b = Bq.get()
    if a < b:
        ne_a = a + 2
        ne_b = b + 1
        Aq.put((ne_a, ne_a))
        Bq.put((ne_b, ne_b))
        cnt += 1

if Aq.empty() and Bq.empty():
    print("Yes")
else:
    print("No")

import math
from queue import PriorityQueue

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

A_sum = sum(A)
B_sum = sum(B)
diff = B_sum - A_sum
if diff < 0:
    print("No")
    exit()

cnt = 0
for a, b in zip(A, B):
    if a < b:
        cnt += math.ceil((b - a) / 2)

if cnt > diff:
    print("No")
else:
    print("Yes")


a, b, c, x = [int(input()) for i in range(4)]
counter = 0

for rep1 in range(a + 1):
    for rep2 in range(b + 1):
        for rep3 in range(c + 1):
            if rep1 * 500 + rep2 * 100 + rep3 * 50 == x:
                counter += 1

print(counter)

x, a, b = [int(input()) for i in range(3)]

print((x - a) % b)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03447/Python/s994669644.py", line 1, in <module>
    a, b, c, x = [int(input()) for i in range(4)]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03447/Python/s994669644.py", line 1, in <listcomp>
    a, b, c, x = [int(input()) for i in range(4)]
EOFError: EOF when reading a line


x500 = int(input())
x100 = int(input())
x50 = int(input())
xxx = int(input())

i = 0
j = 0
k = 0

def judge(sum, xxx):
    sum = 500 * i + 100 * j + 50 * k
    return sum == xxx and sum <= 2000

count = 0
for i in range(x500):
    if judge(i, j, k):
        count += 1
    for j in range(x100):
        if judge(i, j, k):
            count += 1
        for k in range(x50):
            if judge(i, j, k):
                count += 1
print(count)

A, B, C, x = [int(input()) for i in range(4)]
print(
    sum(
        500 * a + 100 * b + 50 * c == x
        for a in range(A + 1)
        for b in range(B + 1)
        for c in range(C + 1)
    )
)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03448/Python/s426003175.py", line 18, in <module>
    if judge(i, j, k):
TypeError: judge() takes 2 positional arguments but 3 were given


a = input()
b = input()
c = input()
x = input()
count = 0
for i in range(min(x // 500, a) + 1):
    for j in range(min((x - i * 500) // 100, b) + 1):
        if (x - i * 500 - j * 100) // 50 <= c:
            count += 1
print(count)

a, b, c, x = map(int, [input() for i in range(4)])
count = 0
for i in range(min(x // 500, a) + 1):
    for j in range(min((x - i * 500) // 100, b) + 1):
        if x - i * 500 - j * 100 <= c * 50:
            count += 1
print(count)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03448/Python/s960607681.py", line 6, in <module>
    for i in range(min(x // 500, a) + 1):
TypeError: unsupported operand type(s) for //: 'str' and 'int'


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

price = 0
count = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            price = i * 500 + j * 100 + k * 50
            if price == X:
                count += 1
            price = 0

print(count)

A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if i * 500 + j * 100 + k * 50 == X:
                count += 1

print(count)

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


s = input().split()
a = s[0]
b = s[1]

if a % 2 == 0 or b % 2 == 0:
    print("Even")
else:
    print("Odd")

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

if a % 2 == 0 or b % 2 == 0:
    print("Even")
else:
    print("Odd")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03455/Python/s883692144.py", line 5, in <module>
    if a % 2 == 0 or b % 2 == 0:
TypeError: not all arguments converted during string formatting


# Product
# シカのAtCoDeerくんは二つの正整数a,bを見つけました。aとbの席が偶数か奇数か判定してください。
# 1<a,b<10000
# a.bは整数

a = int(input())
b = int(input())

# print(a,b,x)

# 積が奇数なら"Odd"、偶数なら"Even"と
if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")

# Product
# シカのAtCoDeerくんは二つの正整数a,bを見つけました。aとbの席が偶数か奇数か判定してください。
# 1<a,b<10000
# a.bは整数

a, b = map(int, input().split())
x = int(a * b)
# print(a,b,x)

# 積が奇数なら"Odd"、偶数なら"Even"と表示
if x % 2 == 0:
    print("Even")
else:
    print("Odd")

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


n1 = int(input())
n2 = int(input())

s = n1 * n2

if s % 2 == 0:
    print("Even")
else:
    print("Odd")

a, b = map(int, input().split())
if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")

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


a = int(input())
b = int(input())

c = a * b

if c % 2 == 0:
    print("Even")
else:
    print("Odd")

t = input().split()
for i in range(len(t)):
    t[i] = int(t[i])

a = t[0]
b = t[1]

if (a * b) % 2 == 0:
    print("Even")
else:
    print("Odd")

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


a, b = map(int, input().split())
ans = [0, 1]
print(ans[(a + b) / 2])

a, b = map(int, input().split())
ans = ["Even", "Odd"]
print(ans[(a * b) % 2])

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03455/Python/s996994010.py", line 3, in <module>
    print(ans[(a + b) / 2])
TypeError: list indices must be integers or slices, not float


class Solution:
    def isEven(self, a, b):
        if (a * b) % 2 == 0:
            print("Even")
        else:
            print("Odd")

if __name__ == "__main__":
    a, b = input(), input()
    solution = Solution()
    solution.isEven(a, b)

class Solution:
    def isEven(self, a: int, b: int):
        if (a * b) % 2 == 0:
            print("Even")
        else:
            print("Odd")

if __name__ == "__main__":
    a, b = map(int, input().split())
    solution = Solution()
    solution.isEven(a, b)

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


i = input()
sp = i.spint()

multid = sp[0] * sp[1]

if multid % 2 == 0:
    print("Even")
else:
    print("Odd")

i = input()
sp = i.split()

multid = int(sp[0]) * int(sp[1])

if multid % 2 == 0:
    print("Even")
else:
    print("Odd")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03455/Python/s527332902.py", line 2, in <module>
    sp = i.spint()
AttributeError: 'str' object has no attribute 'spint'. Did you mean: 'split'?


# 入力
a = int(input())
b = int(input())

# 処理
if a * b % 2 == 0:
    answer = "Even"
else:
    answer = "Odd"

print(answer)

# 086A
# 入力値の積が偶数か奇数か

# 入力
a, b = map(int, input().split())

# 処理
x = a * b % 2

if x == 0:
    print("Even")
else:
    print("Odd")

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


from sys import stdin

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

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

if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")

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

if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")

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


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

if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")

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

if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03455/Python/s771135942.py", line 1, in <module>
    a, b = list(map(int, input()).split())
AttributeError: 'map' object has no attribute 'split'


num1 = int(input())
num2 = int(input())

sum = num1 * num2

if sum % 2 == 0:
    print("Even")
else:
    print("Odd")

num = input().split(" ")

sum = int(num[0]) * int(num[1])

if sum % 2 == 0:
    print("Even")
else:
    print("Odd")

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


a = int(input())
b = int(input())

mul = a * b

if mul % 2 == 0:
    print("Even")
else:
    print("Odd")

# coding: utf-8

# １行の入力データを分割
data = input().split(" ")

a = int(data[0])
b = int(data[1])

mul = int(a * b)

if mul % 2 == 0:
    print("Even")
else:
    print("Odd")

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


N = int(input())
txy = [tuple() for _ in range(N)]
for i in range(N - 1):
    now = txy[i]
    next = txy[i + 1]
    root = abs(next[1] - now[1]) + abs(next[2] - now[2])
    time = next[0] - now[0]
    if time < root:
        print("No")
        break
    else:
        if time == root:
            pass
        else:
            if (time - root) % 2 != 0:
                print("No")
                break
else:
    print("Yes")

N = int(input())
txy = [(0, 0, 0)] + [tuple(map(int, input().split())) for _ in range(N)]

for i in range(N):
    now = txy[i]
    next = txy[i + 1]
    root = abs(next[1] - now[1]) + abs(next[2] - now[2])
    time = next[0] - now[0]
    if time < root:
        print("No")
        break
    else:
        if time == root:
            pass
        else:
            if (time - root) % 2 != 0:
                print("No")
                break
else:
    if N == 1:
        root = txy[1][1] + txy[1][2]
        time = txy[1][0]
        if time < root:
            print("No")
        else:
            if (time - root) % 2 == 0:
                print("Yes")
            else:
                print("No")
    else:
        print("Yes")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03457/Python/s888307883.py", line 6, in <module>
    root = abs(next[1] - now[1]) + abs(next[2] - now[2])
IndexError: tuple index out of range


from bisect import bisect_left
from collections import defaultdict
from itertools import accumulate

n = int(input())
arr = list(map(int, input().split()))
arr.sort()
sa = sum(arr)
lim = sa // 2
dp = defaultdict(int)
dp[0] = 1

for a in arr:
    # print(a, dp)
    ndp = dp.copy()
    for i, v in dp.items():
        if i + a <= lim:
            ndp[i + a] += v
    dp = ndp
    # print(a, dp)

dpk = list(dp.keys())
dpk.sort()
dpv = [dp[k] for k in dpk]
adp = list(accumulate(dpv))
k = 2 ** (n - 1)
j = bisect_left(adp, k)

# print(adp)
# print(k)

print(sa - dpk[j])

n, arr, dp = int(input()), list(map(int, input().split())), 1
for a in arr:
    dp |= dp << a
ofs = (sum(arr) + 1) // 2
dp >>= ofs
print((dp & -dp).bit_length() + ofs - 1)


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s849843365.py", line 2, in <module>
    s[3] = "7"
TypeError: 'str' object does not support item assignment


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s767798189.py", line 2, in <module>
    s[:4] = "2018"
TypeError: 'str' object does not support item assignment


S = input()

S = S.replace("7", "8", 1)
print(S)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s675103813.py", line 3, in <module>
    S[3] = 8
TypeError: 'str' object does not support item assignment


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s998798459.py", line 2, in <module>
    S[:4] = "2018"
TypeError: 'str' object does not support item assignment


S = str(input())
S = S.replace(2017, 2018, 1)
print(S)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s315077891.py", line 2, in <module>
    S = S.replace(2017, 2018, 1)
TypeError: replace() argument 1 must be str, not int


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s679354678.py", line 3, in <module>
    print(S.join("/"))
AttributeError: 'list' object has no attribute 'join'


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s780711657.py", line 2, in <module>
    S[3] = 8
TypeError: 'str' object does not support item assignment


S = input()

print(S.replace(2017, 2018))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s380335764.py", line 3, in <module>
    print(S.replace(2017, 2018))
TypeError: replace() argument 1 must be str, not int


S = list(input())
S[3] = 8
print("".join(S))

S = list(input())
S[3] = "8"
a = "".join(S)
print(a)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s280675216.py", line 3, in <module>
    print("".join(S))
TypeError: sequence item 3: expected str instance, int found


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

a = 0
b = 0
c = n
ans = c * 1000

while ans < y:
    if y - ans >= 9000:
        tmp = (y - ans) // 9000
        a += tmp
        c -= tmp
    elif y - ans >= 4000:
        tmp = (y - ans) // 4000
        b += tmp
        c -= tmp
    ans = a * 10000 + b * 5000 + c * 1000

if ans != y:
    a = b = c = -1

print(a, b, c)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s711679119.py", line 1, in <module>
    n, y = map(int, input().split())
ValueError: invalid literal for int() with base 10: '2017/01/07'


s = input().rstrip()

s1 = "2018" + s[4:] if s.startwith("2017") else s

s = input().rstrip()

s1 = "2018" + s[4:] if s.startswith("2017") else s
print(s1)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03469/Python/s739767122.py", line 3, in <module>
    s1 = "2018" + s[4:] if s.startwith("2017") else s
AttributeError: 'str' object has no attribute 'startwith'. Did you mean: 'startswith'?


n = input()
ls = [int(input()) for i in range(n)]
ls = list(set(ls))
print(len(ls))

n = int(input())
ls = [int(input()) for i in range(n)]
ls = set(ls)
print(len(ls))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s164646605.py", line 2, in <module>
    ls = [int(input()) for i in range(n)]
TypeError: 'str' object cannot be interpreted as an integer


N = int(input())

List = sorted(list(set(list(int(input()) for i in range(N)))))

print(len(List()))

N = int(input())

List = sorted(list(set(list(int(input()) for i in range(N)))))

print(len(List))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s093646747.py", line 5, in <module>
    print(len(List()))
TypeError: 'list' object is not callable


N = int(input())
d = [int(input()) for i in range(N)]

print(list(set(d)))
e = list(set(d))
print(len(e))
N = int(input())
d = [int(input()) for i in range(N)]

# print(list(set(d)))
e = list(set(d))
print(len(e))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s146380919.py", line 7, in <module>
    N = int(input())
EOFError: EOF when reading a line


n = int(input())
list = [int(input()) for i in range(n)]
check = 101
count = 0

list.sorted(reverse=True)

for k in list:
    if k < check:
        count += 1
        check = k

print(count)

n = int(input())
list = [int(input()) for i in range(n)]
check = 101
count = 0

list.sort(reverse=True)

for k in list:
    if k < check:
        count += 1
        check = k

print(count)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s066996346.py", line 6, in <module>
    list.sorted(reverse=True)
AttributeError: 'list' object has no attribute 'sorted'. Did you mean: 'sort'?


n = int(input())
nums = [int(input()) for _ in range(int(input()))]
print(len(set(nums)))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s066397851.py", line 2, in <module>
    nums = [int(input()) for _ in range(int(input()))]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s066397851.py", line 2, in <listcomp>
    nums = [int(input()) for _ in range(int(input()))]
EOFError: EOF when reading a line


n = int(input())
d = sorted([int(input()) for _ in range(n)])
cnt = 1
for a, b in zip(cnt[1:], cnt):
    if a > b:
        cnt += 1
print(cnt)

n = int(input())
d = sorted([int(input()) for _ in range(n)])
cnt = 1
for a, b in zip(d[1:], d):
    if a > b:
        cnt += 1
print(cnt)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03470/Python/s632286045.py", line 4, in <module>
    for a, b in zip(cnt[1:], cnt):
TypeError: 'int' object is not subscriptable


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

a, b, c = (-1, -1, -1)
for i in range(n + 1):
    for j in range(n + 1 - i):
        k = n - (i + j)
        if 10000 * i + 5000 * j + 1000 * k == y:
            a, b, c = (i, j, k)
            break
print(a, b, c)


N, Y = map(int, input().split())
for y in range(9):
    for x in range(N + 1):
        for z in range(N + 1):
            if Y == (10000 * x) + (5000 * y) + (1000 * z) and x + y + z == N:
                print(x, y, z)
                break
        else:
            continue
        break
    else:
        if y == 8:
            print(-1, -1, -1)
        continue
    break

N, Y = map(int, input().split())
for y in range(9):
    for x in range(N + 1):
        if Y == (10000 * x) + (5000 * y) + (1000 * (N - x - y)) and N >= x + y:
            print(x, y, N - x - y)
            break
        else:
            continue
        break
    else:
        if y == 8:
            print(-1, -1, -1)
        continue
    break


n, y = map(int, input().split())
max_x = y // 10000
max_y = y // 5000
max_z = y // 1000

for i in range(max_x + 1):
    for j in range(max_y + 1):
        remain = y - 10000 * i - 5000 * j
        if remain < 0:
            continue
        if remain // 1000 == n - (i + j):
            print(i, j, (n - i - j))
            exit()
print(-1, -1, -1)

N, Y = list(map(int, input().split()))
ans = [-1, -1, -1]
flag = False
for x in range(N, -1, -1):
    for y in range(N - x, -1, -1):
        if 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            ans = [x, y, N - x - y]
            flag = True
            break
        if flag == True:
            break
    if flag == True:
        break
print(ans[0], ans[1], ans[2])


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

flag = False

for z in range(n + 1)[::-1]:
    rem1 = n - z + 1
    for y in range(rem1)[::-1]:
        x = n - z - y
        val = 10000 * x + 5000 * y + 1000 * z
        if val == y:
            flag = True
            break
    if flag:
        break

if not flag:
    x, y, z = -1

print(x, y, z)

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

flag = False

for z in range(N + 1)[::-1]:
    rem1 = N - z + 1
    for y in range(rem1)[::-1]:
        x = N - z - y
        val = 10000 * x + 5000 * y + 1000 * z
        if val == Y:
            flag = True
            break
    if flag:
        break

if not flag:
    x = -1
    y = -1
    z = -1

print(x, y, z)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03471/Python/s426671470.py", line 17, in <module>
    x, y, z = -1
TypeError: cannot unpack non-iterable int object


def judge(z):
    if z >= 0:
        remain = n - z
        pay = [[i, remain - i] for i in range(remain + 1)]

        for i in range(remain + 1):
            if 10 * pay[i][0] + 5 * pay[i][1] + z == m:
                print(pay[i][0], pay[i][1], z)
                exit()

        judge(z - 1)

    else:
        print(-1, -1, -1)

n, M = list(map(int, input().split(" ")))
m = int(M / 1000)

judge(n)

def pay(i: int, remain: int, z: int):
    for i in range(0, (n - z) + 1):
        if 10 * i + 5 * (remain - i) + z == m:
            print(i, remain - i, z)
            exit()

    return

n, M = list(map(int, input().split(" ")))
m = int(M / 1000)

for z in range(n, -1, -1):
    pay(0, n - z, z)

print(-1, -1, -1)


N, Y = map(int, input().split())
ans = 0
found = False
for i in range(N + 1):
    for j in range(0, N - i + 1):
        k = N - i - j
        is_sum = i * 10_000 + j * 5_000 + k * 1_000 == Y
        if is_sum:
            print(i, j, k)
            found = True
            break
    if found:
        break
        # for k in range(N):
        #     if i * 10_000 + j * 5_000 + k * 1_000 == Y and i + j + k == N:
        #         print(i, j, k)
        #         found = True
if not found:
    print("-1 -1 -1")

N, Y = map(int, input().split())
ans = 0
found = False

Y //= 1000

T = 0
for i in range(Y // 10 + 1):
    for j in range((Y - i * 10) // 5 + 1):
        T += 1
        x = Y - i * 10 - j * 5
        if x < 0:
            break
        if i + j + x == N:
            print(i, j, x)
            found = True
            break
    if found:
        break
if not found:
    print("-1 -1 -1")


N, Y = input().split()

for x in range(1, N):
    for y in range(1, N):
        if (N - x - y < 0) and (10000 * x + 5000 * y + 1000(N - x - y)) == Y:
            print(x, y, N - x - y)

N, Y = map(int, input().split())
for x in range(N + 1):
    for y in range(N + 1):
        if (N - x - y >= 0) and (10000 * x + 5000 * y + 1000 * (N - x - y) == Y):
            print(x, y, N - x - y)
            break
    else:
        if x == N and y == N:
            print(-1, -1, -1)
        continue
    break

/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03471/Python/s576925636.py:5: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
  if (N - x - y < 0) and (10000 * x + 5000 * y + 1000(N - x - y)) == Y:
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03471/Python/s576925636.py", line 3, in <module>
    for x in range(1, N):
TypeError: 'str' object cannot be interpreted as an integer


N, Y = list(map(int, input().split()))
ans = []
for i_yukichi in range(N + 1):
    for j_higuchi in range(N + 1 - i_yukichi):
        k_noguchi = N - i_yukichi - j_higuchi
        if 10000 * i_yukichi + 5000 * j_higuchi + 1000 * k_noguchi == Y:
            ans.append(i_yukichi)
            ans.append(j_higuchi)
            ans.append(k_noguchi)
            break
if len(ans) != 0:
    print(ans[0], ans[1], ans[3])
else:
    print("-1 -1 -1")

N, Y = list(map(int, input().split()))
ans = []
for i_yukichi in range(N + 1):
    for j_higuchi in range(N + 1 - i_yukichi):
        k_noguchi = N - i_yukichi - j_higuchi
        if 10000 * i_yukichi + 5000 * j_higuchi + 1000 * k_noguchi == Y:
            ans.append(i_yukichi)
            ans.append(j_higuchi)
            ans.append(k_noguchi)
            break
if len(ans) != 0:
    print(ans[0], ans[1], ans[2])
else:
    print("-1 -1 -1")


#!/usr/bin/env python3

def main():
    args = input().split()
    N = int(args[0])
    Y = int(args[1])

    for num10000 in range(0, N + 1):
        for num5000 in range(0, N + 1 - num10000):
            for num1000 in range(0, N + 1 - num10000 - num5000):
                if num10000 + num5000 + num1000 != N:
                    continue
                value = 10000 * num10000 + 5000 * num5000 + 1000 * num1000
                if value == Y:
                    print(num10000, num5000, num1000)
                    return

    print(-1, -1, -1)

if __name__ == "__main__":
    main()

#!/usr/bin/env python3

def main():
    args = input().split()
    N = int(args[0])
    Y = int(args[1])

    for num10000 in range(0, N + 1):
        for num5000 in range(0, N + 1 - num10000):
            num1000 = N - num10000 - num5000
            value = 10000 * num10000 + 5000 * num5000 + 1000 * num1000
            if value == Y:
                print(num10000, num5000, num1000)
                return

    print(-1, -1, -1)

if __name__ == "__main__":
    main()


N, H = map(int, input().split())
a, b = [0] * N, [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())
a.sort(reverse=True)
b.sort(reverse=True)
ans = 0
while len(b) > 0 and b[0] > a[0]:
    H -= b[0]
    b = b[1:]
    ans += 1
ans += (H + a[0] - 1) // a[0]
print(ans)

N, H = map(int, input().split())
a, b = [0] * N, [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())
ma = max(a)
b.sort(reverse=True)
ans = 0
index = 0
while H > 0 and len(b) > index and b[index] > ma:
    H -= b[index]
    index += 1
    ans += 1
if H > 0:
    ans += (H + ma - 1) // ma
print(ans)


def main():
    N, Y = [int(i) for i in input().split()]

    A = []
    B = []

    for i in range(N):
        a, b = [int(i) for i in input().split()]
        A.append(a)
        B.append(b)

    B.sort()
    B.reverse()
    A.sort()
    A.reverse()

    for i in range(1000000000):
        if Y <= 0:
            print(i)
            return

        b_m = max(B, default=0)
        a_m = max(A)
        if b_m > a_m:
            Y = Y - b_m
            B.remove(b_m)
        else:
            Y = Y - a_m

main()

def answer():
    import sys

    input = sys.stdin.readline
    wield = 0
    l = []
    N, H = map(int, input().split())
    for i in range(N):
        a, b = map(int, input().split())
        l.append(b)
        wield = max(a, wield)
    l.sort(reverse=True)
    ret = 0
    for a in l:
        if H <= 0:
            break
        if a > wield:
            ret += 1
            H -= a
        else:
            break
    if H > 0:
        ret += (H + wield - 1) // wield
    print(ret)

answer()


n, h = [int(t) for t in input().split()]
aa = []
bb = []
for _ in range(n):
    a, b = [int(t) for t in input().split()]
    aa.append(a)
    if b > a:
        bb.append(b)
aa.sort()
bb.sort()

cnt = 0
while h > 0:
    if not bb:
        cnt += (h - 1) // aa[-1] + 1
        break
    elif bb[-1] > aa[-1]:
        h -= bb.pop()
    else:
        h -= aa[-1]
    cnt += 1
print(cnt)

n, h = [int(t) for t in input().split()]
aa = []
bb = []
for _ in range(n):
    a, b = [int(t) for t in input().split()]
    aa.append(a)
    if b > a:
        bb.append(b)
aa.sort()
bb.sort()

cnt = 0
while h > 0:
    if not bb or aa[-1] >= bb[-1]:
        cnt += (h - 1) // aa[-1] + 1
        break
    else:
        h -= bb.pop()
    cnt += 1
print(cnt)


n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai), b.append(bi)
a.sort(), b.sort()

ans, amax = 0, a[-1]
for bi in b[::-1]:
    if bi <= amax or h <= 0:
        mod = (h + amax - 1) // amax
        break
    h -= bi
    ans += 1
print(ans + mod if h > 0 else ans)

n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai), b.append(bi)
a.sort(), b.sort()

ans, amax = 0, a[-1]
for bi in b[::-1]:
    if bi <= amax or h <= 0:
        break
    h -= bi
    ans += 1
mod = (h + amax - 1) // amax
print(ans + mod if h > 0 else ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03472/Python/s359965169.py", line 15, in <module>
    print(ans + mod if h > 0 else ans)
NameError: name 'mod' is not defined


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03473/Python/s581215127.py", line 2, in <module>
    n = 48 - m
TypeError: unsupported operand type(s) for -: 'int' and 'str'


A, B = input().split()
S1, S2 = input().split("-")
print("Yes" if len(S1) == A and len(S2) == B else "No")

A, B = map(int, input().split())
S = input().split("-")
print("Yes" if len(S) == 2 and len(S[0]) == A and len(S[1]) == B else "No")


a, b = map(int, input().split())
s = input()
first, second = s.split("-")
if len(first) == a and len(second) == b:
    print("Yes")
else:
    print("No")

a, b = map(int, input().split())
s = input()
try:
    first, second = s.split("-")
    if len(first) == a and len(second) == b:
        print("Yes")
    else:
        print("No")
except:
    print("No")


N = int(input())
C, S, F = [0] * (N - 1), [0] * (N - 1), [0] * (N - 1)
for i in range(N - 1):
    C[i], S[i], F[i] = map(int, input().split())

def get_t(x, i):
    t = S[i]
    while x > t:
        t += F[i]
    return t

for i in range(N - 1):
    x = S[i] + C[i]
    for j in range(i + 1, N - 1):
        t = get_t(x, j)
        x = t + C[j]
    print(x)
print(0)

N = int(input())
C, S, F = [0] * (N - 1), [0] * (N - 1), [0] * (N - 1)
for i in range(N - 1):
    C[i], S[i], F[i] = map(int, input().split())

for i in range(N):
    t = 0
    for j in range(i, N - 1):
        if t < S[j]:
            t = S[j]
        elif t % F[j] == 0:
            pass
        else:
            t += F[j] - t % F[j]
        t += C[j]
    print(t)


n = int(input())
train_info = []
for _ in range(1, n):
    train_info.append(list(map(int, input().split())))

# print(train_info)

for i in range(1, n + 1):
    # print("i = {}".format(i))
    t = 0

    if i == n:
        print(0)
    else:
        for j in range(i, n):
            C_j, S_j, F_j = train_info[j - 1]
            while True:
                if (t >= S_j) & (t % F_j == 0):
                    t += C_j
                    break
                else:
                    t += 1

        print(t)

n = int(input())
train_info = []
for _ in range(1, n):
    train_info.append(list(map(int, input().split())))

# print(train_info)

for i in range(1, n + 1):
    # print("i = {}".format(i))
    t = 0

    if i == n:
        print(0)
    else:
        for j in range(i, n):
            # print("t = {}".format(t))
            C_j, S_j, F_j = train_info[j - 1]
            if t <= S_j:
                t = S_j + C_j
            elif t % F_j == 0:
                t += C_j
            else:
                t += F_j - t % F_j
                t += C_j

        print(t)


n = int(input())

_list = []
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    _list.append([a, b, c])

for i in range(n - 1):
    num = i
    time = 0

    while num < n - 1:
        c, s, f = _list[num]

        if num == i:
            time += s + c
            num += 1
            continue

        while True:
            wait = s - time
            if wait >= 0:
                time += wait + c
                break

            s += f

        num += 1

    print(time)

print(0)

n = int(input())

_list = []
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    _list.append([a, b, c])

for i in range(n - 1):
    num = i
    time = 0

    while num < n - 1:
        c, s, f = _list[num]

        if num == i:
            time += s + c
            num += 1
            continue

        while True:
            wait = s - time

            if wait >= 0:
                time += wait + c
                break

            test = (wait * -1) // f
            s += int(f * test)

            if s - time < 0:
                s += f

        num += 1

    print(time)

print(0)


N = int(input())
C, S, F = [], [], []
for _ in range(N - 1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

def next_time(i, t):
    a = S[i]
    while a < t:
        a += F[i]
    return a

for i in range(N):
    time = 0
    for j in range(i, N - 1):
        time = next_time(j, time)
        time += C[j]

    print(time)

N = int(input())
C, S, F = [], [], []
for _ in range(N - 1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

def next_time(i, t):
    a = S[i]
    if t - a < 0:
        return a
    if t % F[i] == 0:
        return t
    b = (t - a + F[i] - 1) // F[i]
    # print(i, t, a, b, t + b * F[i])
    assert (a + b * F[i]) % F[i] == 0
    return a + b * F[i]

for i in range(N):
    time = 0
    for j in range(i, N - 1):
        time = next_time(j, time)
        time += C[j]

    print(time)


from math import ceil, sqrt

Q = int(input())
querys = [tuple(map(int, input().split())) for i in range(Q)]

N = max(map(max, querys))

Primes = [False] * 2 + [True] * (N - 1)
for i in range(3, N + 1):
    for j in range(2, ceil(sqrt(i)) + 1):
        if i % j == 0:
            Primes[i] = False

s2017s = [False] * (N + 1)
for i in range(1, N + 1, 2):
    if Primes[i] and Primes[(i + 1) // 2]:
        s2017s[i] = True

nums = [0] * (N + 1)
for i in range(1, N + 1, 2):
    nums[i] = nums[i - 2]
    if s2017s[i]:
        nums[i] += 1

for li, ri in querys:
    print(nums[ri] - nums[max(0, li - 2)])

from math import ceil, sqrt

Q = int(input())
querys = [tuple(map(int, input().split())) for i in range(Q)]

N = max(map(max, querys))

Primes = [False] * 2 + [True] * (N - 1)
for i in range(3, N + 1):
    for j in range(2, ceil(sqrt(i)) + 1):
        if i % j == 0:
            Primes[i] = False
            break

s2017s = [False] * (N + 1)
for i in range(1, N + 1, 2):
    if Primes[i] and Primes[(i + 1) // 2]:
        s2017s[i] = True

nums = [0] * (N + 1)
for i in range(1, N + 1, 2):
    nums[i] = nums[i - 2]
    if s2017s[i]:
        nums[i] += 1

for li, ri in querys:
    print(nums[ri] - nums[max(0, li - 2)])


def primes(n):
    primes = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            primes.append(i)
    return is_prime

Q = int(input())

ps = primes(10000)
like_numbers = [False] * 10001
for i in range(3, 10001, 2):
    if ps[i] and ps[(i + 1) // 2]:
        like_numbers[i] = True

like_numbers_cnt = [0] * 10001

for i in range(1, 10001):
    if like_numbers[i]:
        like_numbers_cnt[i] = like_numbers_cnt[i - 1] + 1
    else:
        like_numbers_cnt[i] = like_numbers_cnt[i - 1]

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

def primes(n):
    primes = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            primes.append(i)
    return is_prime

Q = int(input())

ps = primes(100000)
like_numbers = [False] * 100001
for i in range(3, 100001, 2):
    if ps[i] and ps[(i + 1) // 2]:
        like_numbers[i] = True

like_numbers_cnt = [0] * 100001

for i in range(1, 100001):
    if like_numbers[i]:
        like_numbers_cnt[i] = like_numbers_cnt[i - 1] + 1
    else:
        like_numbers_cnt[i] = like_numbers_cnt[i - 1]

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


n, a, b = map(int, input().split())
counter = 0

for i in range(1, n):
    str_i = str(i)
    sum_i = sum(map(int, str_i))
    if a <= sum_i <= b:
        counter += i

print(counter)

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

print("Left" if a + b > c + d else "Balanced" if a + b == c + d else "Right")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03477/Python/s233397764.py", line 1, in <module>
    n, a, b = map(int, input().split())
ValueError: too many values to unpack (expected 3)


A, B, C, D = map(input().split())

if A + B > C + D:
    print("Left")
elif A + B == C + D:
    print("Balanced")
else:
    print("Right")

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

if A + B > C + D:
    print("Left")
elif A + B == C + D:
    print("Balanced")
else:
    print("Right")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03477/Python/s591114327.py", line 1, in <module>
    A, B, C, D = map(input().split())
TypeError: map() must have at least two arguments.


# -*- coding: utf-8 -*-
# Input
list = []
for _ in range(3):
    list += [int(input())]

total = 0
for ii in range(1, list[0] + 1):
    sum = 0
    tmp = ii
    while tmp > 0:
        sum += tmp % 10
        tmp = tmp // 10

    if sum >= list[1] and sum <= list[2]:
        total += ii
print(total)

# -*- coding: utf-8 -*-
# Input
list = []
n, a, b = map(int, input().split())

total = 0
for ii in range(1, n + 1):
    sum = 0
    tmp = ii
    while tmp > 0:
        sum += tmp % 10
        tmp = tmp // 10

    if sum >= a and sum <= b:
        total += ii
print(total)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03478/Python/s606181373.py", line 5, in <module>
    list += [int(input())]
ValueError: invalid literal for int() with base 10: '20 2 5'


n, b, c = map(int, input().split(""))
ans = 0
for i in range(n + 1):
    if b <= sum(list(map(int, list(str(i))))) <= c:
        ans += i
print(ans)

n, b, c = map(int, input().split())
ans = 0
for i in range(n + 1):
    if b <= sum(list(map(int, list(str(i))))) <= c:
        ans += i
print(ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03478/Python/s330413525.py", line 1, in <module>
    n, b, c = map(int, input().split(""))
ValueError: empty separator


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

ans = 0
for i in range(N + 1):
    if A <= sum(map(int, list(str(i)))) <= B:
        ans += 1
print(ans)

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

ans = 0
for i in range(N + 1):
    if A <= sum(list(map(int, list(str(i))))) <= B:
        map(int, list(str(i)))
        ans += i
print(ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03478/Python/s203322622.py", line 1, in <module>
    N, A, B = map(input, input().split())
EOFError: EOF when reading a line


import sys

S = input()
center = len(S) // 2
b = S[center]

if len(S) % 2 == 1:
    for i in range(1, center + 1):
        if S[center + i] != b or S[center - i] != b:
            print(center + i)
            sys.exit()
else:
    for i in range(center + 1):
        if S[center - i] != b or S[center + 1 + i] != b:
            print(center)
            sys.exit()

import sys

S = input()
center = len(S) // 2

if len(S) % 2 == 1:
    b = S[center]
    for i in range(1, center + 1):
        if S[center + i] != b or S[center - i] != b:
            print(center + i)
            sys.exit()
else:
    b = S[center - 1]
    for i in range(center):
        if S[center - 1 - i] != b or S[center + i] != b:
            print(center + i)
            sys.exit()
print(len(S))


# coding=utf-8
S = int(input())

# 0と1の個数のうち、大きい方
cnt = 0
for i in range(len(S)):
    if S[i] == "0":
        cnt += 1
cnt = max(cnt, len(S) - cnt)
print(cnt)

S = input()

ans = len(S)
for i in range(1, len(S)):
    if S[i - 1] != S[i]:
        ans = min(ans, max(i, len(S) - i))

print(ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03480/Python/s330718076.py", line 6, in <module>
    for i in range(len(S)):
TypeError: object of type 'int' has no len()


a, b = map(float, input().split())
print(int(round((a + b) / 2), 0))

a, b = map(float, input().split())
if int((a + b) / 2) < ((a + b) / 2):
    print(int((a + b) / 2) + 1)
else:
    print(int((a + b) / 2))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03485/Python/s451038837.py", line 2, in <module>
    print(int(round((a + b) / 2), 0))
TypeError: int() can't convert non-string with explicit base


s = [*input()]
t = [*input()]
s.sort()
t.sort()
t.reverse()
print("Yes" if s < t else "No")

S = input()
T = input()
s = list(S)
t = list(T)
s.sort()
t.sort()
t.reverse()
print("Yes" if s < t else "No")


s = list(input())
t = list(input())
a = 0

s.sort()
t.sort()
t = t[::-1]

if len(s) < len(t):
    for i in range(len(s)):
        if s[i] < t[i]:
            print("Yes")
            break
        elif s[i] == t[i]:
            a += 1
            continue
        else:
            print("No")
            break
    if a == len(s):
        print("Yes")

else:
    for i in range(len(s)):
        if s[i] < t[i]:
            print("Yes")
            break
        elif s[i] == t[i]:
            a += 1
            continue
        else:
            print("No")
            break
    if a == len(s):
        print("No")

s = list(input())
t = list(input())
a = 0

s.sort()
t.sort()
t = t[::-1]

if len(s) < len(t):
    for i in range(len(s)):
        if s[i] < t[i]:
            print("Yes")
            break
        elif s[i] == t[i]:
            a += 1
            continue
        else:
            print("No")
            break
    if a == len(s):
        print("Yes")

else:
    for i in range(len(t)):
        if s[i] < t[i]:
            print("Yes")
            break
        elif s[i] == t[i]:
            a += 1
            continue
        else:
            print("No")
            break
    if a == len(t):
        print("No")


s = sorted(input())
t = sorted(input()).reverse()
print("Yes" if s < t else "No")

s = sorted(input())
t = sorted(input())[::-1]
print("Yes" if s < t else "No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03486/Python/s804213311.py", line 3, in <module>
    print("Yes" if s < t else "No")
TypeError: '<' not supported between instances of 'list' and 'NoneType'


print("Yes" if sorted(input()) < sorted(input())[::-1] else "No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03486/Python/s649784028.py", line 1, in <module>
    print("Yes" if print(sorted(input())) < print(sorted(input())[::-1]) else "No")
TypeError: '<' not supported between instances of 'NoneType' and 'NoneType'


n = int(input())
a = list(map(int, input().split()))
max = max(a) + 1
num = [0] * max
for i in a:
    num[i] += 1
ans = 0
for i in range(max):
    if i > num[i]:
        ans += num[i]
    else:
        ans += num[i] - i
print(ans)

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

a.sort()
cnt = 1
ans = 0
for i in range(len(a) - 1):
    if a[i] == a[i + 1]:
        cnt += 1
        continue

    if cnt >= a[i]:
        ans += cnt - a[i]
    else:
        ans += cnt
    cnt = 1
if cnt >= a[-1]:
    ans += cnt - a[-1]
else:
    ans += cnt
print(ans)


n = input()
arr = list(map(int, input().split()))
ar = [0 for i in range(max(arr))]
for i in arr:
    ar[i - 1] += 1
res = 0
for i in range(len(ar)):
    if ar[i] > i + 1:
        res += ar[i] - i - 1
    if ar[i] < i + 1:
        res += ar[i]
print(res)

n = input()
arr = list(map(int, input().split()))
ar = [0 for i in range(100001)]
res = 0
for i in arr:
    if i > 100000:
        res += 1
    else:
        ar[i] += 1
for i in range(len(ar)):
    if ar[i] > i:
        res += ar[i] - i
    if ar[i] < i:
        res += ar[i]
print(res)


# Good Sequence
n = int(input())
a = list(map(int, input().split()))
a_ = set(a)
p = 0
for i in a_:
    if a.count(i) < i:
        p += a.count(i)
    elif a.count(i) > i:
        p += a.count(i) - i
print(p)

# Good Sequence
n = int(input())
a = list(map(int, input().split()))
count = {}
ans = 0
for i in a:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1
for i, c in count.items():
    if i > c:
        ans += c
    elif i < c:
        ans += c - i
print(ans)


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

for i in list(set(a)):
    count_of_i = a.count(i)
    if count_of_i < i:
        ans += count_of_i
    else:
        ans += count_of_i - i
print(ans)

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
ans = 0
counter = Counter(a)
for i in set(a):
    if counter[i] < i:
        ans += counter[i]
    else:
        ans += counter[i] - i
print(ans)


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

list_a = list(set(a))

result = 0
for i in list_a:
    cnt = a.count(i)
    if cnt != i:
        result = result + cnt if cnt < i else result + cnt - i

print(result)

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

count_a = {}
for n in range(N):
    if a[n] in count_a.keys():
        count_a[a[n]] += 1
    else:
        count_a[a[n]] = 1

result = 0
for n in list(count_a.keys()):
    if count_a[n] != n:
        result = result + count_a[n] if count_a[n] < n else result + count_a[n] - n

print(result)


N = int(input())
a_list = list(map(int, sorted(input().split())))

sum = 0

for a in set(a_list):
    cnt = a_list.count(a)
    if a > cnt:
        sum += cnt
    else:
        sum += cnt - a

print(sum)

from collections import Counter

N = int(input())
counter = Counter(map(int, input().split()))

sum = 0

for a, cnt in counter.most_common():
    if a > cnt:
        sum += cnt
    else:
        sum += cnt - a

print(sum)


N = int(input())
A_LI = sorted(map(int, input().split()))
A_SET = set(A_LI)
ans = 0
for a in A_SET:
    cnt = A_LI.count(a)
    if cnt < a:
        ans += cnt
    else:
        ans += cnt - a
print(ans)

N = int(input())
A_LI = sorted(map(int, input().split()))
a_dict = {}
ans = 0
pre = None
for a in A_LI:
    if a not in a_dict:
        if pre in a_dict:
            # 出揃った値について取り除く個数を求める
            if a_dict[pre] < pre:
                ans += a_dict[pre]
            else:
                ans += a_dict[pre] - pre
        pre = a
        a_dict[a] = 1
    else:
        a_dict[a] += 1
# 最後の値について取り除く個数を求める
if a_dict[pre] < pre:
    ans += a_dict[pre]
else:
    ans += a_dict[pre] - pre
print(ans)


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

ans = 0
for s in sorted(set(a))[::-1]:
    cnt = a.count(s)
    tmp = cnt - s
    ans += (tmp > 0) * tmp + (tmp < 0) * cnt
print(ans)

from collections import Counter

N = int(input())
a = list(map(int, input().split()))
cnt = Counter(a)
ans = 0
for k, v in cnt.items():
    if k > v:
        ans += v
    elif k < v:
        ans += v - k
print(ans)


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

s = set(a)

ans = 0

for x in s:
    c = a.count(x)
    if c > x:
        ans += c - x
    if c < x:
        ans += c

print(ans)

import collections

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

c = collections.Counter(a)
ans = 0

for k, v in c.items():
    if k > v:
        ans += v
    if k < v:
        ans += v - k

print(ans)


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

n = int(input())

alist = list(map(int, input().split()))
result = 0

for i in set(alist):
    if alist.count(i) > i:
        result += alist.count(i) - i
    elif alist.count(i) < i:
        result += alist.count(i)
print(result)

from collections import Counter

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

count = 0
for key, value in B.items():
    count += value - key if value >= key else value

print(count)


n = int(input())
a = list(map(int, input().split()))
ans = 0
_a = set(a)
for x in _a:
    y = a.count(x)
    if y < x:
        ans += y
    elif y > x:
        ans += y - x
print(ans)

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
ans = 0
c = Counter(a)
for key in c:
    if c[key] < key:
        ans += c[key]
    elif c[key] > key:
        ans += c[key] - key
print(ans)


N = int(input())
A = list(map(int, input().split()))
A = {a: A.count(a) for a in set(A)}
ans = 0
for k, v in A.items():
    if k > v:
        ans += v
    elif k < v:
        ans += v - k
print(ans)

N = int(input())
A = list(map(int, input().split()))
S = {}
for a in A:
    if a in S:
        S[a] += 1
    else:
        S[a] = 1
ans = 0
for k, v in S.items():
    if k > v:
        ans += v
    elif k < v:
        ans += v - k
print(ans)


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

A_set = set(A)
ans = 0

for a in A_set:
    count = A.count(a)
    if count >= a:
        ans += count - a
    else:
        ans += count

print(ans)

import collections

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

B = collections.Counter(A)
ans = 0

for key, val in B.items():
    if val > key:
        ans += val - key
    elif val < key:
        ans += val

print(ans)


n = int(input())
aList = list(map(int, input().split()))
aSet = list(set(aList))
aSum = 0
for a in aSet:
    aCount = aList.count(a)
    if aCount > a:
        aSum += aCount - a
        continue
    if aCount == a:
        continue
    if aCount < a:
        aSum += aCount
        continue
print(aSum)

n = int(input())
aList = list(map(int, input().split()))
aLen = len(aList)
aSet = sorted(list(set(aList)))
aSum = 0
for a in aSet:
    aCount = aList.count(a)
    if aCount > a:
        aSum += aCount - a
    if aCount < a:
        aSum += aCount
    aLen -= aCount
    if a > aLen:
        aSum += aLen
        break

print(aSum)


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

check = []

ans = 0
for i in a:
    if i not in check:
        check.append(i)
        tmp = a.count(i)
        if tmp < i:
            ans += tmp
        else:
            ans += tmp - i

print(ans)

from collections import Counter as ct

N = int(input())
a = [int(i) for i in input().split()]
c = ct(a)

ans = 0
for i, j in c.items():
    if i <= j:
        ans += j - i
    else:
        ans += j

print(ans)


n = int(input())
li_a = input().split()

result = 0
for i in set(li_a):
    cnt = li_a.count(i)
    if cnt > int(i):
        result += cnt - int(i)
    elif cnt < int(i):
        result += cnt

print(result)

from collections import defaultdict

n = int(input())
li_a = input().split()

ndict = defaultdict(int)

for i in li_a:
    ndict[i] += 1

result = 0
for k in ndict.keys():
    if ndict[k] > int(k):
        result += ndict[k] - int(k)
    elif ndict[k] < int(k):
        result += ndict[k]

print(result)


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

counter_remove = 0
counter = dict()
counter_keys = []
for i in range(n):
    if a[i] not in counter_keys:
        counter_keys.append(a[i])
        counter[str(a[i])] = 1
    else:
        if counter[str(a[i])] < a[i]:
            counter[str(a[i])] += 1
        else:
            counter_remove += 1

# remove small
for key in counter_keys:
    if counter[str(key)] < int(key):
        counter_remove += int(counter[str(key)])

print(counter_remove)

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

from collections import Counter

b = Counter(a)

counter = 0
for key in b.keys():
    if b[key] < key:
        counter += b[key]
    elif b[key] > key:
        counter += b[key] - key
print(counter)


N = int(input())
A = [int(zz) for zz in input().split()]
B = set(A)

ans = 0
for i in B:
    p = A.count(i)
    if i > p:
        ans += p
    elif i < p:
        ans += p - i

print(ans)

import bisect

N = int(input())
A = [int(zz) for zz in input().split()]
B = set(A)
A.sort()
ans = 0
for i in B:
    p = bisect.bisect_right(A, i) - bisect.bisect_left(A, i)
    if i > p:
        ans += p
    elif i < p:
        ans += p - i

print(ans)


S = input()
X, Y = map(int, input().split())

if S.find("F") < 0:
    if X != 0 or Y != 0:
        print("No")
        exit()

n = len(S)
d = list(map(len, S.split("T")))
xs = d[::2]
ys = d[1::2]

dpx = [[False] * (2 * n + 1) for _ in range(len(xs))]
for i in range(len(xs)):
    if i == 0:
        d = (-1) ** S.find("F")
        dpx[i][d * xs[i] + n] = True
        continue

    for j in range(2 * n + 1):
        if j + xs[i] <= 2 * n:
            dpx[i][j] |= dpx[i - 1][j + xs[i]]
        if 0 <= j - xs[i] <= 2 * n:
            dpx[i][j] |= dpx[i - 1][j - xs[i]]

dpy = [[False] * (2 * n + 1) for _ in range(len(ys) + 1)]
dpy[0][n] = True
for i in range(len(ys)):
    for j in range(2 * n + 1):
        if j + ys[i] <= 2 * n:
            dpy[i + 1][j] |= dpy[i][j + ys[i]]
        if 0 <= j - ys[i] <= 2 * n:
            dpy[i + 1][j] |= dpy[i][j - ys[i]]

ans = dpx[-1][X + n] & dpy[-1][Y + n]
print("Yes" if ans else "No")

S = input()
X, Y = map(int, input().split())

if S.find("F") < 0:
    if X != 0 or Y != 0:
        print("No")
    else:
        print("Yes")
    exit()

n = len(S)
d = list(map(len, S.split("T")))
xs = d[::2]
ys = d[1::2]

dpx = [set() for _ in range(len(xs))]
for i in range(len(xs)):
    if i == 0:
        d = (-1) ** S.find("F")
        dpx[i].add(d * xs[i] + n)
        continue

    for j in dpx[i - 1]:
        dpx[i].add(j + xs[i])
        dpx[i].add(j - xs[i])

dpy = [set() for _ in range(len(ys) + 1)]
dpy[0].add(n)
for i in range(len(ys)):
    for j in dpy[i]:
        dpy[i + 1].add(j + ys[i])
        dpy[i + 1].add(j - ys[i])

ans = (X + n in dpx[-1]) & (Y + n in dpy[-1])
print("Yes" if ans else "No")


s = input()
x, y = map(int, input().split())

# Tで区切り、各Tの前にFが何文字あるか数える
steps = []
cnt = 0
for i in range(len(s)):
    if s[i] == "F":
        cnt += 1
    elif s[i] == "T":
        steps.append(cnt)
        cnt = 0
# 最後のブロックについて
if cnt > 0:
    steps.append(cnt)
AX = steps[0::2]
AY = steps[1::2]

# dpX[i][j] = X軸方向の移動をi回行って、jに到達できるか
# j = 0, 1, ..., 16000 だが、実際のX座標は -8000, ..., 0, ..., 8000
# 原点(x=0)は、j = 8000に相当する
dpX = [[0 for _ in range(2 * 8000 + 1)] for _ in range(len(AX) + 1)]
dpX[0][8000] = 1
# 最初に右へ移動する場合
if s[0] == "F":
    dpX[1][8000 + AX[0]] = 1
    for i in range(1, len(AX)):
        for j in range(2 * 8000 + 1):
            if dpX[i][j] == 1:
                # +X方向に移動
                if j + AX[i] <= 2 * 8000:
                    dpX[i + 1][j + AX[i]] = 1
                # -X方向に移動
                if 0 <= j - AX[i]:
                    dpX[i + 1][j - AX[i]] = 1
# 最初に回転する場合
else:
    for i in range(len(AX)):
        for j in range(2 * 8000 + 1):
            if dpX[i][j] == 1:
                # +X方向に移動
                if j + AX[i] <= 2 * 8000:
                    dpX[i + 1][j + AX[i]] = 1
                # -X方向に移動
                if 0 <= j - AX[i]:
                    dpX[i + 1][j - AX[i]] = 1

# dpY[i][j] = Y軸方向の移動をi回行って、jに到達できるか
# j = 0, 1, ..., 16000 だが、実際のY座標は -8000, ..., 0, ..., 8000
# 原点(y=0)は、j = 8000に相当する
dpY = [[0 for _ in range(2 * 8000 + 1)] for _ in range(len(AY) + 1)]
dpY[0][8000] = 1
for i in range(len(AY)):
    for j in range(2 * 8000 + 1):
        if dpY[i][j] == 1:
            # +Y方向に移動
            if j + AY[i] <= 2 * 8000:
                dpY[i + 1][j + AY[i]] = 1
            # -Y方向に移動
            if 0 <= j - AY[i]:
                dpY[i + 1][j - AY[i]] = 1

if dpX[-1][x + 8000] == 1 and dpY[-1][y + 8000] == 1:
    print("Yes")
else:
    print("No")

s = input()
x, y = map(int, input().split())

# Tで区切り、各Tの前にFが何文字あるか数える
steps = []
cnt = 0
for i in range(len(s)):
    if s[i] == "F":
        cnt += 1
    elif s[i] == "T":
        steps.append(cnt)
        cnt = 0
# 最後のブロックについて
if cnt > 0:
    steps.append(cnt)
AX = steps[0::2]
AY = steps[1::2]

# X軸方向の最大値
max_X = sum(AX)
# dpX[i][j] = X軸方向の移動をi回行って、jに到達できるか
# j = 0, 1, ..., 2*max_X だが、実際のX座標は -max_X, ..., 0, ..., max_X
# 原点(x=0)は、j = max_Xに相当する
dpX = [[0 for _ in range(2 * max_X + 1)] for _ in range(len(AX) + 1)]
dpX[0][max_X] = 1
# 最初に右へ移動する場合
if s[0] == "F":
    dpX[1][max_X + AX[0]] = 1
    for i in range(1, len(AX)):
        for j in range(2 * max_X + 1):
            if dpX[i][j] == 1:
                # +X方向に移動
                if j + AX[i] <= 2 * max_X:
                    dpX[i + 1][j + AX[i]] = 1
                # -X方向に移動
                if 0 <= j - AX[i]:
                    dpX[i + 1][j - AX[i]] = 1
# 最初に回転する場合
else:
    for i in range(len(AX)):
        for j in range(2 * max_X + 1):
            if dpX[i][j] == 1:
                # +X方向に移動
                if j + AX[i] <= 2 * max_X:
                    dpX[i + 1][j + AX[i]] = 1
                # -X方向に移動
                if 0 <= j - AX[i]:
                    dpX[i + 1][j - AX[i]] = 1
# Y軸方向の最大値
max_Y = sum(AY)
# dpY[i][j] = Y軸方向の移動をi回行って、jに到達できるか
# j = 0, 1, ..., 2*max_Y だが、実際のY座標は -max_Y, ..., 0, ..., max_Y
# 原点(y=0)は、j = max_Yに相当する
dpY = [[0 for _ in range(2 * max_Y + 1)] for _ in range(len(AY) + 1)]
dpY[0][max_Y] = 1
for i in range(len(AY)):
    for j in range(2 * max_Y + 1):
        if dpY[i][j] == 1:
            # +Y方向に移動
            if j + AY[i] <= 2 * max_Y:
                dpY[i + 1][j + AY[i]] = 1
            # -Y方向に移動
            if 0 <= j - AY[i]:
                dpY[i + 1][j - AY[i]] = 1

if -max_X <= x <= max_X and -max_Y <= y <= max_Y:
    if dpX[-1][x + max_X] == 1 and dpY[-1][y + max_Y] == 1:
        print("Yes")
        exit()
print("No")


s = input()
x, y = map(int, input().split())
command = s.split("T")

command_length = len(command)
x_command = command_length // 2
y_command = command_length // 2
if command_length % 2 != 0:
    x_command += 1

dpx = [[False for _ in range(8000 + 1)] for _ in range(x_command + 1)]
dpx[0][4000] = True
dpy = [[False for _ in range(8000 + 1)] for _ in range(y_command + 1)]
dpy[0][4000] = True

for i in range(1, x_command + 1):
    f = len(command[2 * (i - 1)])
    for j in range(f, 8000 + 1 - f):
        if dpx[i - 1][j - f] or dpx[i - 1][j + f]:
            dpx[i][j] = True

for i in range(1, y_command + 1):
    f = len(command[2 * (i - 1) + 1])
    for j in range(f, 8000 + 1 - f):
        if dpy[i - 1][j - f] or dpy[i - 1][j + f]:
            dpy[i][j] = True

if dpx[x_command][4000 + x] and dpy[y_command][4000 + y]:
    print("Yes")
else:
    print("No")

s = input()
x, y = map(int, input().split())
command = s.split("T")

command_length = len(command)

x_command = []
y_command = []
for i in range(command_length):
    c = len(command[i])
    if i % 2 == 0:
        x_command.append(c)

    else:
        y_command.append(c)
x -= x_command.pop(0)
x_command.sort(reverse=True)
y_command.sort(reverse=True)

c_x = 0
c_y = 0
for c in x_command:
    if x - c_x >= 0:
        c_x += c
    else:
        c_x -= c

for c in y_command:
    if y - c_y > 0:
        c_y += c
    else:
        c_y -= c
if c_x == x and c_y == y:
    print("Yes")
else:
    print("No")


s = list(input().split("T"))
x, y = map(int, input().split())
s2 = [len(x) for x in s]
pos = [0, 0]
LR = [s2[i] for i in range(len(s2)) if i % 2 == 0]
UD = [s2[i] for i in range(len(s2)) if i % 2 == 1]

flag = False
tmp = 1
tmp = tmp << sum(LR)
for d in LR:
    tmp = tmp << d | tmp >> d

if x >= 0:
    tmp = tmp >> sum(LR)
    if (tmp >> x) % 2 == 1:
        flag = True
else:
    if (tmp >> (sum(LR) + x)) % 2 == 1:
        flag = True
if flag:

    tmp = 1
    tmp = tmp << sum(UD)
    flag = False
    for d in UD:
        tmp = tmp << d | tmp >> d
    if y >= 0:
        tmp = tmp >> sum(UD)
        if (tmp >> y) % 2 == 1:
            flag = True
    else:
        if (tmp >> (sum(UD) + y)) % 2 == 1:
            flag = True

if flag:
    print("Yes")
else:
    print("No")

s = list(input().split("T"))
x, y = map(int, input().split())
s2 = [len(x) for x in s]
LR = [s2[i] for i in range(len(s2)) if i % 2 == 0]
UD = [s2[i] for i in range(len(s2)) if i % 2 == 1]

flag = False
tmp = 1
tmp = tmp << sum(LR)
for i, d in enumerate(LR):
    if i != 0:
        tmp = tmp << d | tmp >> d
    else:
        tmp = tmp << d

if x >= 0:
    tmp = tmp >> sum(LR)
    if (tmp >> x) % 2 == 1:
        flag = True
else:
    if sum(LR) + x >= 0:
        if (tmp >> (sum(LR) + x)) % 2 == 1:
            flag = True
if flag:

    tmp = 1
    tmp = tmp << sum(UD)
    flag = False
    for d in UD:
        tmp = tmp << d | tmp >> d
    if y >= 0:
        tmp = tmp >> sum(UD)
        if (tmp >> y) % 2 == 1:
            flag = True
    else:
        if sum(UD) + y >= 0:
            if (tmp >> (sum(UD) + y)) % 2 == 1:
                flag = True

if flag:
    print("Yes")
else:
    print("No")


N = int(input())
a = list(map(int, input().split()))
cnt = 0
S = 0
for i in range(100000):
    tmp = a.count(i + 1)
    S += tmp
    if tmp > i + 1:
        cnt += tmp - i - 1
    elif tmp < i + 1:
        cnt += tmp
cnt += N - S
print(cnt)

N = int(input())
a = list(map(int, input().split()))
tmp = 1
cnt = 0
S = 0
a.sort()
a.append(0)
for i in range(N):
    if a[i] == a[i + 1]:
        tmp += 1
    else:
        if tmp > a[i]:
            cnt += tmp - a[i]
        elif tmp < a[i]:
            cnt += tmp
        tmp = 1
print(cnt)


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

a.sort()

count = 0

while a:
    k = a.pop(0)
    k_count = 1
    while (len(a) > 0) and (a[0] == k):
        a.pop(0)
        k_count += 1
    if k_count < k:
        count += k_count
    else:
        count += k_count - k
print(count)

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

a.sort()

count = 0

while a:
    k = a.pop(-1)
    k_count = 1
    while (len(a) > 0) and (a[-1] == k):
        a.pop(-1)
        k_count += 1
    if k_count < k:
        count += k_count
    else:
        count += k_count - k
print(count)


print(sum([int(x) for x in input().split()]))


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s523943434.py", line 1, in <module>
    print(input().cont("1"))
AttributeError: 'str' object has no attribute 'cont'. Did you mean: 'count'?


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s893573368.py", line 1, in <module>
    print(input.count("1"))
AttributeError: 'builtin_function_or_method' object has no attribute 'count'


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s568979144.py", line 1, in <module>
    print(input().count(1))
TypeError: must be str, not int


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s769249601.py", line 2, in <module>
    print(sss.count(1))
TypeError: must be str, not int


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s417747495.py", line 2, in <module>
    print(s.count(1))
TypeError: must be str, not int


a = int(input())
b = a.count(int(1))
print(b)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s056240522.py", line 2, in <module>
    b = a.count(int(1))
AttributeError: 'int' object has no attribute 'count'


s = list(map(int, input().split()))
ans = 0
for i in range(3):
    if s[i] == 1:
        ans += 1

print(ans)

s = list(input())
ans = 0
for i in range(3):
    if s[i] == "1":
        ans += 1

print(ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s116744075.py", line 4, in <module>
    if s[i] == 1:
IndexError: list index out of range


a = list(str(int(input)))
print(a.count("1"))

a = list(str(int(input())))
print(a.count("1"))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s840199366.py", line 1, in <module>
    a = list(str(int(input)))
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'builtin_function_or_method'


a = map(int, input().split())
print(a.count(1))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s330524274.py", line 2, in <module>
    print(a.count(1))
AttributeError: 'map' object has no attribute 'count'


# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
print(sum(list(map(int, list(a)))))

# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
s = str(a)
print(sum(list(map(int, list(s)))))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s452121313.py", line 4, in <module>
    print(sum(list(map(int, list(a)))))
TypeError: 'int' object is not iterable


Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s325538655.py", line 1, in <module>
    print(input().count(1))
TypeError: must be str, not int


marbles = input()
num = marbles.count(1)
print(num)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s142159490.py", line 2, in <module>
    num = marbles.count(1)
TypeError: must be str, not int


a, b, c = map(int, input().split())
print(a + b + c)

a, b, c = map(int, input())
print(a + b + c)

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


s = list(input())

for i in s:
    sum += int(i)

print(sum)

s = list(input())
ball = 0
for i in s:
    ball = ball + int(i)

print(ball)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s247381986.py", line 4, in <module>
    sum += int(i)
TypeError: unsupported operand type(s) for +=: 'builtin_function_or_method' and 'int'


# -*- coding: utf-8 -*-
# 入力
a = list(str(input))
# String to Int
num = [int(s) for s in a]
# Output
print(sum(num))

# -*- coding: utf-8 -*-
a = list(str(input()))
num = [int(s) for s in a]
print(sum(num))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s488211323.py", line 5, in <module>
    num = [int(s) for s in a]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03493/Python/s488211323.py", line 5, in <listcomp>
    num = [int(s) for s in a]
ValueError: invalid literal for int() with base 10: '<'


N = int(input())
As = [int(input()) for _ in range(N)]

sunuke = 0
while all([a % 2 == 0 for a in As]):
    sunuke += 1
    As = [a / 2 for a in As]
print(sunuke)

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

sunuke = 0
while all([a % 2 == 0 for a in As]):
    sunuke += 1
    As = [a // 2 for a in As]
print(sunuke)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03494/Python/s383170291.py", line 2, in <module>
    As = [int(input()) for _ in range(N)]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03494/Python/s383170291.py", line 2, in <listcomp>
    As = [int(input()) for _ in range(N)]
ValueError: invalid literal for int() with base 10: '8 12 40'


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

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

ans = 0
while 1:
    new_a = [a // 2 if a % 2 == 0 else -1 for a in A]
    if -1 in new_a:
        break
    ans += 1

print(ans)

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

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

ans = 0
new_a = A.copy()
while 1:
    new_a = [a // 2 if a % 2 == 0 else -1 for a in new_a]
    if -1 in new_a:
        print(ans)
        exit()
    ans += 1

print(ans)


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

DA = []
for v in A:
    d = 0
    while v & 1 == 0:
        v = v << 2
        d += 1
    DA.append(d)

print(min(DA))

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

DA = []
for v in A:
    d = 0
    while v & 1 == 0:
        v = v >> 1
        d += 1
    DA.append(d)

print(min(DA))


kazu = int(input())
numbers_list = list(map(int, input().split()))
count = 0
seisu = 0
while True:
    for index in range(kazu):
        if numbers_list[index] % 2 != 0:
            seisu = 1
            break
        else:
            numbers_list[index] = numbers_list / 2
    if seisu == 1:
        break
    count += 1
print(count)

kazu = int(input())
numbers_list = list(map(int, input().split()))
count = 0
seisu = 0
while True:
    for index in range(kazu):
        if numbers_list[index] % 2 != 0:
            seisu = 1
            break
        else:
            numbers_list[index] = numbers_list[index] / 2
    if seisu == 1:
        break
    count += 1
print(count)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03494/Python/s612541287.py", line 11, in <module>
    numbers_list[index] = numbers_list / 2
TypeError: unsupported operand type(s) for /: 'list' and 'int'


n = int(input())
a = list(map(int, input().split()))
ans = 0
while all(A % 2 == 0 for A in a):
    A = [i / 2 for i in a]
    ans += 1
print(ans)

n = int(input())
a = list(map(int, input().split()))
ans = 0
while all(A % 2 == 0 for A in a):
    a = [i / 2 for i in a]
    ans += 1
print(ans)