s = str(input())
k = int(input())
subs = set()
for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        subs.add(s[i:j])
print(sorted(list(subs))[k - 1])

s = str(input())
k = int(input())
subs = set()
for i in range(len(s)):
    for j in range(i + 1, i + k + 1):
        subs.add(s[i:j])
print(sorted(list(subs))[k - 1])


import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

S = sys.stdin.readline().rstrip()
K = int(sys.stdin.readline())

def prune(it):
    hist = set()
    ret = []
    for s, l in it:
        if s not in hist:
            hist.add(s)
        if len(hist) > K:
            break
        ret.append((s, l))
    return ret

collections = prune(sorted([(c, L) for L, c in enumerate(S)]))
for size in range(1, len(S)):
    threshold, _ = collections[-1]
    for s, left in collections:
        r = left + size + 1
        if len(s) == size and r <= len(S):
            t = S[left:r]
            if t <= threshold:
                collections.append((t, left))
    collections = prune(sorted(collections))

strings = list(set([s for s, _ in collections]))
strings.sort()
print(strings[K - 1])

import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

S = sys.stdin.readline().rstrip()
K = int(sys.stdin.readline())

s = set()
for k in range(1, K + 1):
    for i in range(len(S)):
        s.add(S[i : i + k])

s = list(sorted(list(s)))
print(s[K - 1])


# UnionFindで参考にしたページ
# http://www.geocities.jp/m_hiroi/light/pyalgo61.html

# 集合の代表を求める
def find(x):
    while link[x] >= 0:
        x = link[x]
    return x

# 併合
def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if link[s1] >= link[s2]:
            # 小さいほうが個数が多い
            link[s1] += link[s2]
            link[s2] = s1
        else:
            link[s2] += link[s1]
            link[s1] = s2
        return True
    return False

N, M = map(int, input().split())
p = list(map(int, input().split()))
link = [-1 for _ in range(N + 1)]

for _ in range(M):
    x, y = map(int, input().split())
    union(x, y)

cnt = 0
for i in range(1, N + 1):
    a = find(i)
    b = find(p[i - 1])
    if a == b:
        cnt += 1
print(cnt)

# UnionFindで参考にしたページ
# http://www.geocities.jp/m_hiroi/light/pyalgo61.html

# 集合の代表を求める
def find(x):
    if link[x] < 0:
        return x
    else:
        # 経路の圧縮
        link[x] = find(link[x])
        return link[x]

# 併合
def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if link[s1] >= link[s2]:
            # 小さいほうが個数が多い
            link[s1] += link[s2]
            link[s2] = s1
        else:
            link[s2] += link[s1]
            link[s1] = s2
        return True
    return False

N, M = map(int, input().split())
p = list(map(int, input().split()))
link = [-1 for _ in range(N + 1)]

for _ in range(M):
    x, y = map(int, input().split())
    union(x, y)

cnt = 0
for i in range(1, N + 1):
    if find(i) == find(p[i - 1]):
        cnt += 1
print(cnt)


n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]

def root(x):
    if x == par[x]:
        return x
    par[x] = root(par[x])  # 経路圧縮
    return par[x]

def is_same(x, y):
    return root(x) == root(y)

def unite(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1
    par[x] = y

for x, y in xy:
    unite(x - 1, y - 1)

count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i - 1) else 0
print(count)

n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]

def root(x):
    if x == par[x]:
        return x
    par[x] = root(par[x])  # 経路圧縮
    return par[x]

def is_same(x, y):
    return root(x) == root(y)

def unite(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

for x, y in xy:
    unite(x - 1, y - 1)

count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i - 1) else 0
print(count)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s246289030.py", line 40, in <module>
    count += 1 if is_same(i, p_i - 1) else 0
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s246289030.py", line 17, in is_same
    return root(x) == root(y)
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s246289030.py", line 12, in root
    par[x] = root(par[x])  # 経路圧縮
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s246289030.py", line 12, in root
    par[x] = root(par[x])  # 経路圧縮
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s246289030.py", line 12, in root
    par[x] = root(par[x])  # 経路圧縮
  [Previous line repeated 994 more times]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s246289030.py", line 10, in root
    if x == par[x]:
RecursionError: maximum recursion depth exceeded in comparison


n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]

def root(x):
    if par[x] == x:
        return x
    par[x] = root(x)
    return par[x]

def is_same(x, y):
    return par[x] == par[y]

def union(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[y] == rank[x]:
            rank[x] += 1

for x, y in xy:
    union(x, y)

count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i) else 0
print(count)

n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]

def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]

def is_same(x, y):
    return root(x) == root(y)

def union(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[y] == rank[x]:
            rank[x] += 1

for x, y in xy:
    union(x, y)

count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i) else 0
print(count)


n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(n)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]

def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]

def is_same(x, y):
    return root(x) == root(y)

def union(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

for x, y in xy:
    union(x, y)

count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i) else 0
print(count)

n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]

def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]

def is_same(x, y):
    return root(x) == root(y)

def union(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

for x, y in xy:
    union(x, y)

count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i) else 0
print(count)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s721322256.py", line 3, in <module>
    xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(n)]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s721322256.py", line 3, in <listcomp>
    xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(n)]
EOFError: EOF when reading a line


import sys

sys.setrecursionlimit(2 * 10**5)

N, M = map(int, input().split())
p = [0] + list(map(int, input().split()))
x, y = zip(*(map(int, input().split()) for _ in range(M)))
E = [[] for _ in range(N + 1)]
for a, b in zip(x, y):
    E[a].append(b)
    E[b].append(a)
v = [True for _ in range(N + 1)]

def f(i, P, Q):
    v[i] = False
    P.add(i)
    Q.add(p[i])
    for a in E[i]:
        if v[a]:
            f(a, P, Q)

ans = 0
for i in range(1, N + 1):
    if v[i]:
        P = set()
        Q = set()
        f(i, P, Q)
        ans += len(P & Q)
print(ans)


# ABC097D - Equals (ARC097D)
"""
Union-Find: O(α(N))

Verified:
    https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/1/DSL_1_A
    https://judge.yosupo.jp/problem/unionfind
"""

class UnionFind:
    __slots__ = ["_data_size", "_first_index", "_parents"]

    def __init__(self, data_size: int, is_zero_indexed: bool = True) -> None:
        self._data_size = data_size
        self._first_index = 0 if is_zero_indexed else 1
        self._parents = [-1] * (data_size + self._first_index)

    def find(self, x: int) -> int:
        """Find the group (root) of vertex x"""
        if self._parents[x] < 0:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]

    def is_same(self, x: int, y: int) -> bool:
        """Return whether two vertices x and y are in the same group or not."""
        return self.find(x) == self.find(y)

    def unite(self, x: int, y: int) -> None:
        """Unite two groups of vertices x and y."""
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x

def main():
    N, _, *PXY = open(0).read().split()
    P, XY = PXY[:N], PXY[N:]
    uf = UnionFind(N, is_zero_indexed=False)
    for x, y in zip(*[iter(XY)] * 2):
        uf.unite(x, y)
    ans = sum(uf.is_same(i, p) for i, p in enumerate(P, 1))
    print(ans)

if __name__ == "__main__":
    main()

# ABC097D - Equals (ARC097D)
class UnionFind:
    __slots__ = ["_data_size", "_first_index", "_parents"]

    def __init__(self, data_size: int, is_zero_indexed: bool = True) -> None:
        self._data_size = data_size
        self._first_index = 0 if is_zero_indexed else 1
        self._parents = [-1] * (data_size + self._first_index)

    def find(self, x: int) -> int:
        """Find the group (root) of vertex x"""
        if self._parents[x] < 0:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]

    def is_same(self, x: int, y: int) -> bool:
        """Return whether two vertices x and y are in the same group or not."""
        return self.find(x) == self.find(y)

    def unite(self, x: int, y: int) -> None:
        """Unite two groups of vertices x and y."""
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x

def main():
    N, _, *PXY = map(int, open(0).read().split())
    P, XY = PXY[:N], PXY[N:]
    uf = UnionFind(N, is_zero_indexed=False)
    for x, y in zip(*[iter(XY)] * 2):
        uf.unite(x, y)
    ans = sum(uf.is_same(i, p) for i, p in enumerate(P, 1))
    print(ans)

if __name__ == "__main__":
    main()

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s667971540.py", line 52, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03354/Python/s667971540.py", line 43, in main
    P, XY = PXY[:N], PXY[N:]
TypeError: slice indices must be integers or None or have an __index__ method


if __name__ == "__main__":
    s = input()
    subsrings = []
    K = int(input())
    for i in range(len(s)):
        subsrings.append(s[i:])
    subsrings.sort()

    first = set()

    for s in subsrings:
        for i in range(1, len(s) + 1):
            if s[:i] not in first:
                first.add(s[:i])
                if len(first) == K:
                    print(s[:i])
                    break

if __name__ == "__main__":
    s = input()

    K = int(input())

    subsrings = [s[i : i + K + 1] for i in range(len(s))]
    subsrings.sort()

    first = set()

    for s in subsrings:

        for i in range(1, len(s) + 1):
            if s[:i] not in first:
                first.add(s[:i])
                if len(first) == K:
                    print(s[:i])
                    break


S = input()
K = int(input())
n = len(S)

ans = []
st = set()

for i in range(n):
    for j in range(i + 1, n + 1):
        sub = S[i:j]
        # print(sub)
        if sub in st:
            continue
        st.add(sub)
        ans.append(sub)
        ans.sort()
        # print(ans)
        if len(ans) > K:
            ans = ans[:K]

print(ans[-1])

S = input()
K = int(input())
n = len(S)

ans = []
st = set()

for i in range(n):
    for j in range(i + 1, min(n + 1, i + 1 + K)):
        sub = S[i:j]
        # print(sub)
        if sub in st:
            continue
        st.add(sub)
        ans.append(sub)
        ans.sort()
        # print(ans)
        if len(ans) > K:
            ans = ans[:K]

print(ans[-1])


s = input()
K = int(input())
s_dic = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
for i, c in enumerate(s):
    s_dic[c].append(i)
substrings = set()
for lc in "abcdefghijklmnopqrstuvwxyz":
    for i in s_dic[lc]:
        for j in range(i + 1, len(s) + 1):
            substrings.add(s[i:j])
    if len(substrings) >= K:
        break
print(sorted(list(substrings))[K - 1])

s = input()
K = int(input())
s_dic = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
for i, c in enumerate(s):
    s_dic[c].append(i)
substrings = set()
for indices in s_dic.values():
    for i in indices:
        for j in range(i + 1, i + K + 1):
            substrings.add(s[i:j])
print(sorted(list(substrings))[K - 1])


S = input()
N = len(S)
K = int(input())
ans = set()
for c in "abcdefghijklmnopqrstuvwxyz":
    for i in range(N):
        if S[i] == c:
            for j in range(i + 1, N + 1):
                ans.add(S[i:j])
    if len(ans) >= K:
        break
print(sorted(list(ans))[K - 1])

S = input()
N = len(S)
K = int(input())
ans = set()
for c in "abcdefghijklmnopqrstuvwxyz":
    for i in range(N):
        if S[i] == c:
            for j in range(i + 1, i + K + 1):
                ans.add(S[i:j])
    if len(ans) >= K:
        break
print(sorted(list(ans))[K - 1])


s = input()
k = int(input())

array = set()
n = len(s)

for i in range(n):
    for j in range(i + 1, n + 1):
        ss = s[i:j]
        array.add(ss)
        if len(array) > k:
            array = sorted(array)
            array.pop()
            array = set(array)

array = sorted(array)
print(array[k - 1])

s = input()
k = int(input())

n = len(s)
array = []

for i in range(n):
    for j in range(i + 1, i + 6):
        end = min(n, j)
        ss = s[i:end]
        array.append(ss)

array = set(array)
array = sorted(array)
print(array[k - 1])


#!/usr/bin/env python

class UnionFind:
    def __init__(self, size):
        self.table = list(range(size))

    def find(self, x):
        return self.table[x]

    def union(self, x, y):
        x1 = self.find(x)
        y1 = self.find(y)
        if x1 == y1:
            return False
        for i in range(len(self.table)):
            if self.table[i] == y1:
                self.table[i] = x1
        return True

n, m = map(int, input().split())
ps = list(map(int, input().split()))
uf = UnionFind(n)
for _ in range(m):
    x, y = map(int, input().split())
    uf.union(x - 1, y - 1)
print(sum([uf.find(i) == uf.find(p - 1) for i, p in enumerate(ps)]))

#!/usr/bin/env python

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

n, m = map(int, input().split())
ps = list(map(int, input().split()))
uf = UnionFind(n + 1)
for _ in range(m):
    x, y = map(int, input().split())
    uf.unite(x, y)
print(sum([uf.same(i + 1, p) for i, p in enumerate(ps)]))


a, b = int(input())

if b >= a:
    print(a)
else:
    print(a)

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

if b >= a:
    print(a)
else:
    print(a - 1)

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


a, b = int(input().split())
print(a if a <= b else a - 1)

a, b = map(int, input().split())
print(a if a <= b else a - 1)

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


def f(a, b, c, k):
    abc = sorted([a, b, c])
    abc[2] *= 2 * k
    print(sum(abc))

f(map(int, input().split()), int(input()))

def f(a, b, c, k):
    abc = sorted([a, b, c])
    if k != 0:
        abc[2] *= 2**k
    print(sum(abc))

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

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03360/Python/s048419312.py", line 7, in <module>
    f(map(int, input().split()), int(input()))
TypeError: f() missing 2 required positional arguments: 'c' and 'k'


A, B, C = map(int, input().split())
K = int(input())
result = sum(A, B, C)
t = max(A, B, C)
result += (t << K) - t
print(result)

A, B, C = map(int, input().split())
K = int(input())
result = sum([A, B, C])
t = max(A, B, C)
result += (t << K) - t
print(result)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03360/Python/s848836757.py", line 3, in <module>
    result = sum(A, B, C)
TypeError: sum() takes at most 2 arguments (3 given)


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

m = max(a, b, c)
ans = sum(a, b, c) - m + (2**k) * m

print(ans)

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

m = max(a, b, c)
ans = a + b + c - m + (2**k) * m

print(ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03360/Python/s177658372.py", line 5, in <module>
    ans = sum(a, b, c) - m + (2**k) * m
TypeError: sum() takes at most 2 arguments (3 given)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins

def solve(inputs):
    field = []
    for row in inputs:
        line = []
        for c in row:
            line.append(c)
        field.append(line)

    if len(field) == 1:
        if len(field[0]) == 1:
            return "No"

    for i, row in enumerate(field):
        for j, _ in enumerate(row):
            available = False
            if field[i][j] == ".":
                continue
            if i - 1 >= 0:
                available |= field[i - 1][j] == "#"

            if j - 1 >= 0:
                available |= field[i][j - 1] == "#"
            if j + 1 < len(row):
                available |= field[i][j + 1] == "#"

            if i + 1 < len(row):
                available |= field[i + 1][j] == "#"
            if not available:
                return "No"

    return "Yes"

if __name__ == "__main__":
    [N, _] = map(lambda x: int(x), input().split())
    ret = solve(inputs(N))
    print(ret)

def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins

def solve(inputs):
    field = []
    for row in inputs:
        line = []
        for c in row:
            line.append(c)
        field.append(line)

    if len(field) == 1:
        if len(field[0]) == 1:
            return "No"

    for i, row in enumerate(field):
        for j, _ in enumerate(row):
            available = False
            if field[i][j] == ".":
                continue
            if i - 1 >= 0:
                available |= field[i - 1][j] == "#"

            if j - 1 >= 0:
                available |= field[i][j - 1] == "#"
            if j + 1 < len(row):
                available |= field[i][j + 1] == "#"

            if i + 1 < len(field):
                available |= field[i + 1][j] == "#"
            if not available:
                return "No"

    return "Yes"

if __name__ == "__main__":
    [N, _] = map(lambda x: int(x), input().split())
    ret = solve(inputs(N))
    print(ret)


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

ds = [(1, 0), (-1, 0), (0, 1), (0, -1)]

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

        flag = False
        for dx, dy in ds:
            x, y = i + dx, j + dy
            if x < 0 or W <= x or y < 0 or H <= y:
                continue

            if S[x][y] == "#":
                flag = True
                break

        if not flag:
            print("No")
            exit()
print("Yes")

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

d = [(-1, 0), (1, 0), (0, -1), (0, 1)]

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

        flag = False
        for dx, dy in d:
            i2, j2 = i + dx, j + dy
            if not (0 <= i2 < H and 0 <= j2 < W):
                continue

            if S[i2][j2] == "#":
                flag = True

        if not flag:
            print("No")
            exit()
print("Yes")


N = int(input())

out = [i * 2 for i in range(1, N + 1)]

print(*out, " ")

N = int(input())

sosuu = []

def next_sosuu():
    if len(sosuu) == 0:
        sosuu.append(2)
        return 2
    if len(sosuu) == 1:
        sosuu.append(3)
        return 3
    curr = sosuu[-1] + 2

    while True:
        flag = True
        for s in sosuu:
            if curr % s == 0:
                flag = False
                break
        if flag:
            sosuu.append(curr)
            return curr
        curr += 2

results = []
while len(results) < N:
    n = next_sosuu()
    if n % 5 == 1:
        results.append(n)

txt = ""
for r in results:
    txt += str(r) + " "
txt = txt[0:-1]
print(txt)


from itertools import combinations

def is_prime(n):
    if n < 2:
        return False
    elif n == 2:
        return True
    else:
        for p in range(2, n):
            if n % p == 0:
                return False
        else:
            return True

# input
N = int(input())

# check
prime_nums = [n for n in range(2, 55555) if is_prime(n)]
for case in combinations(prime_nums, N):
    fl = True
    for check_case in combinations(case, 5):
        if is_prime(sum(check_case)):
            fl = False
            break
    if fl:
        res = " ".join([str(num) for num in case])
        print(res)
        exit(0)

def is_prime(n):
    if n < 2:
        return False
    else:
        for p in range(2, n):
            if n % p == 0:
                return False
        else:
            return True

# input
N = int(input())

# check
prime_nums = []
append = prime_nums.append
for n in range(2, 55555):
    if is_prime(n) and n % 5 == 1:
        append(n)
        if len(prime_nums) == N:
            break

res = " ".join([str(num) for num in prime_nums])
print(res)
exit(0)


N = int(input())

def is_prime(n):
    for i in range(1, n):
        if i != 1 and n % i == 0:
            return False
    return True

def prime_numbers():
    num = 2
    while True:
        is_num_prime = is_prime(num)
        if is_num_prime:
            yield num
        num += 1

prime_gene = prime_numbers()
ans = []

while len(ans) < 5:
    prime = next(prime_gene)
    if prime_gene % 5 == 1:
        ans.append(prime)
print(ans)

N = int(input())

def is_prime(n):
    for i in range(1, n):
        if i != 1 and n % i == 0:
            return False
    return True

def prime_numbers():
    num = 5
    while True:
        is_num_prime = is_prime(num)
        if is_num_prime and num % 5 == 1:
            yield num
        num += 1

prime_gene = prime_numbers()
ans = [next(prime_gene) for _ in range(N)]
print(*ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03362/Python/s462787302.py", line 25, in <module>
    if prime_gene % 5 == 1:
TypeError: unsupported operand type(s) for %: 'generator' and 'int'


N = int(input())
A = [int(_) for _ in input().split()]
cumsum = [0]
for a in A:
    cumsum += [cumsum[-1] + a]
ans = 0
for i in range(N):
    for j in range(i + 1, N + 1):
        ans += cumsum[j] - cumsum[i] == 0
print(ans)

import heapq

N = int(input())
A = [int(_) for _ in input().split()]
cumsum = [0]
for a in A:
    cumsum += [cumsum[-1] + a]
heapq.heapify(cumsum)
before = 10**10
count = 0
ans = 0
while cumsum:
    now = heapq.heappop(cumsum)
    count += before == now
    if not (before == now and cumsum):
        ans += count * (count + 1) // 2
        count = 0
    before = now
print(ans)


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

ans = 0

for i in range(N):
    total = 0
    for item in inputs[i:]:
        total += item
        if total == 0:
            ans += 1

print(ans)

from collections import Counter

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

ans = 0
ruisekiwa = [0] * (N + 1)

for i in range(N):
    ruisekiwa[i + 1] = ruisekiwa[i] + inputs[i]

ruisekiwa = ruisekiwa[1:]
ruisekiwa.sort()
counter_ruiseki = Counter(ruisekiwa)

for key, value in counter_ruiseki.items():
    if key == 0 and value == 1:
        ans += value
        continue
    elif key == 0 and value > 1:
        ans += value
    if value > 1:
        ans += sum(list(range(value)))

print(ans)


N = int(input())
num_list = list(map(int, input().split()))
cumulative_sum_list = [0]
c_s = 0
for i in num_list:
    c_s += i
    cumulative_sum_list.append(c_s)
cumulative_sum_list.sort()
cumulative_sum_set = set(cumulative_sum_list)
s = 0
for i in cumulative_sum_set:
    c = cumulative_sum_list.count(i)
    s += c * (c - 1) // 2
print(s)

from itertools import accumulate
from collections import Counter

N = int(input())
num_list = list(map(int, input().split()))
cumulative_sum_list = list(accumulate(num_list))
cumulative_sum_list.append(0)

c = Counter(cumulative_sum_list)
s = 0
for i in c.values():
    s += i * (i - 1) // 2
print(s)


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

cnt = 0

for i in range(0, N):
    for j in range(i + 1, N + 1):
        if sum(A[i:j]) == 0:
            cnt += 1

print(cnt)

from collections import Counter

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

S = [0]

for i, a in enumerate(A):
    S.append(S[i] + a)

S = sorted(S)
a = Counter(S).most_common()
cnt = 0

for i in range(len(a)):
    cnt += ((a[i][1] - 1) * a[i][1]) // 2

print(cnt)


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

a = int(input())
c = list(map(int, input().split()))
d = {0: 1}
e = 0
for i in range(len(c)):
    e += c[i]
    if e not in d:
        d[e] = 1
    else:
        d[e] += 1
ans = 0
for v in d.values():
    if v >= 2:
        ans += v * (v - 1) // 2
print(ans)

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


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

S = [0]

for a in A:
    S.append(S[len(S) - 1] + a)

S = sorted(S)

ret = 0
for s in set(S):
    cnt = S.count(s)
    ret += cnt * (cnt - 1) / 2
print(int(ret))

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

S = [0]

for a in A:
    S.append(S[len(S) - 1] + a)

S = sorted(S) + [None]
ret = 0
cnt = 1
for i in range(1, N + 2):
    if S[i] != S[i - 1]:
        ret += cnt * (cnt - 1) // 2
        cnt = 1
    else:
        cnt += 1

print(ret)


import bisect

n = int(input())
nums = list(map(int, input().split(" ")))
sigma = []
temp = 0
for num in nums:
    temp += num
    sigma.append(temp)

ans = 0
for i, s in enumerate(sigma):
    if s == 0:
        ans += 1
    beforeSums = sorted(sigma[:i])
    li = bisect.bisect_left(beforeSums, s)
    if li >= i:
        continue
    while beforeSums[li] == s:
        ans += 1
        li += 1
        if li >= i:
            break
print(ans)

from collections import Counter

N = int(input())
A = list(map(int, input().split(" ")))
S = [
    0,
]
now = 0
for n in A:
    now += n
    S.append(now)
Scounter = Counter(S)
ans = 0
for c, n in Scounter.most_common():
    if n >= 2:
        ans += n * (n - 1) // 2
    else:
        break
print(ans)


N = int(input())

cnt = 0
S_list = [input() for _ in range(N)]

def count_symmetry(S_symmetry):
    for i in range(N):
        for j in range(N):
            if S_symmetry[i][j] != S_symmetry[j][i]:
                return False
    return True

for k in range(N):
    S_symmetry = S_list[k:] + S_list[:k]
    if count_symmetry(S_symmetry):
        cnt += 1

print(cnt * N)

N = int(input())
S_list = [input() for _ in range(N)]
cnt = 0

def count_symmetry(S_symmetry):
    for i in range(N):
        for j in range(i + 1, N):
            if S_symmetry[i][j] != S_symmetry[j][i]:
                return False
    return True

for k in range(N):
    S_symmetry = S_list[k:] + S_list[:k]
    if count_symmetry(S_symmetry):
        cnt += 1

print(cnt * N)


N, X = map(int, input().split())
m = [int(i) for i in range(N)]
m.sort()
ans = 3

X -= sum(m)

while X >= m[0]:
    X -= m[0]
    ans += 1

print(ans)

N, X = map(int, input().split())
ans = N
m_list = []

for i in range(N):
    m = int(input())
    m_list.append(m)

m_list.sort()
X -= sum(m_list)

ans += X // m_list[0]

print(ans)


N, X = map(int, input().split())
M = [int(input()) for _ in range(N)]
ans = 0
for m in range(M):
    X -= m
    ans += 1
ans += X // min(M)
print(ans)

N, X = map(int, input().split())
M = [int(input()) for _ in range(N)]
ans = 0
for m in M:
    X -= m
    ans += 1
ans += X // min(M)
print(ans)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03370/Python/s961847795.py", line 4, in <module>
    for m in range(M):
TypeError: 'list' object cannot be interpreted as an integer


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

while X > 0 or Y > 0:
    if A + B > C:
        sum += C
        X -= 1
        Y -= 1
    else:
        sum += A + B
        X -= 1
        Y -= 1
    if X > 0 and Y > 0:
        continue
    if X > 0:
        if A > C:
            sum += C
            X -= 1
            Y -= 1
        else:
            sum += A
            X -= 1
    else:
        if B > C:
            sum += C
            X -= 1
            Y -= 1
        else:
            sum += B
            Y -= 1

print(sum)

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

while X > 0 or Y > 0:
    if X > 0 and Y > 0:
        if A + B > 2 * C:
            sum += 2 * C
            X -= 1
            Y -= 1
        else:
            sum += A + B
            X -= 1
            Y -= 1
    else:
        if X > 0:
            if A > 2 * C:
                sum += 2 * C
                X -= 1
                Y -= 1
            else:
                sum += A
                X -= 1
        else:
            if B > 2 * C:
                sum += 2 * C
                X -= 1
                Y -= 1
            else:
                sum += B
                Y -= 1

print(sum)

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


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

# A 1枚、B 1枚を2C円で買うと捉え直す。
# ピザは、最大でも10**5枚（A, Bそれぞれに対して）
# A, Bのセットを、1~10**セットまで動かして一番安い組を考える

cheapest = float("inf")

for i in range(max(X, Y) + 1):

    price = 2 * C * i + A * max(0, X - i) + B * max(Y - i)

    cheapest = min(cheapest, price)

print(cheapest)

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

# A 1枚、B 1枚を2C円で買うと捉え直す。
# ピザは、最大でも10**5枚（A, Bそれぞれに対して）
# A, Bのセットを、1~10**セットまで動かして一番安い組を考える

cheapest = float("inf")

for i in range(max(X, Y) + 1):

    price = 2 * C * i + A * max(0, X - i) + B * max(0, Y - i)

    cheapest = min(cheapest, price)

print(cheapest)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03371/Python/s831575287.py", line 11, in <module>
    price = 2 * C * i + A * max(0, X - i) + B * max(Y - i)
TypeError: 'int' object is not iterable


A, B, C, X, Y = map(int, input().split())
if A + B < 2 * C:
    ans = A * X + B * Y
elif A + B >= 2 * C:
    nokori = abs(X - Y)
    if X >= Y and A >= 2 * C:
        ans = C * 2 * X
    if Y >= X and B >= 2 * C:
        ans = C * 2 * Y
    if X > Y and A < 2 * C:
        ans = C * 2 * Y + nokori * A
    if Y > X and B < 2 * C:
        ans = C * 2 * X + nokori * B
print(ans)

A, B, C, X, Y = map(int, input().split())
if A + B <= 2 * C:
    ans = A * X + B * Y
elif A + B > 2 * C:
    nokori = abs(X - Y)
    if X >= Y and A >= 2 * C:
        ans = C * 2 * X
    if Y >= X and B >= 2 * C:
        ans = C * 2 * Y
    if X >= Y and A <= 2 * C:
        ans = C * 2 * Y + nokori * A
    if Y >= X and B <= 2 * C:
        ans = C * 2 * X + nokori * B
print(ans)


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

def main() -> None:
    """
    main function
    """
    (A, B, C, X, Y) = map(int, input().strip().split())

    if 2 * C <= B and 2 * C <= A:
        ans = (max(X, Y) * 2) * C
    elif 2 * C > A:
        ans = Y * 2 * C + max(X - Y, 0) * B
    elif 2 * C > B:
        ans = X * 2 * C + max(Y - X, 0) * A
    else:
        raise ValueError(f"{A}, {B}, {C}")

    print(ans)

if __name__ == "__main__":
    main()

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

def main() -> None:
    """
    main function
    """
    (A, B, C, X, Y) = map(int, input().split())

    if 2 * C <= A + B:
        ans = C * min(X, Y) * 2 + min(
            max((X - Y) * A, (Y - X) * B), max(X - Y, Y - X) * C * 2
        )
    else:
        ans = A * X + B * Y

    print(ans)

if __name__ == "__main__":
    main()


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

# x = 0 に v = 0 の寿司があると考える
X = [0]
V = [0]

for _ in range(N):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)
# print(X)
# print(V)

# 0, v_1, v_1+v_2, v_1+v_2+v_3, ...
cumsum1 = [0]
for i in range(1, N + 1):
    cumsum1.append(cumsum1[-1] + V[i])

# 0, v_N, v_N+v_N-1, v_N+v_N-1+v_N-2, ...
cumsum2 = [0]
for i in range(N, 0, -1):
    cumsum2.append(cumsum2[-1] + V[i])

# print(cumsum1)
# print(cumsum2)

# 歩く範囲を弧ABと考える(A<=B)
# x_A = 0, x_1, x_2, ..., x_N
# x_B = x_A, ..., x_N
ans = 0

for i in range(N + 1):
    for j in range(i + 1, N + 1):
        # print(i, j)
        a = X[i]
        b = X[j]
        if i == 0:
            # 反時計回り(反転しない)
            ans = max(ans, cumsum1[j] - b)
            # 時計回り(反転しない)
            ans = max(ans, cumsum2[N + 1 - j] - (C - b))
        else:
            # O -> A -> B(反転)
            ans = max(ans, cumsum1[i] + cumsum2[N + 1 - j] - 2 * a - (C - b))
            # O -> B -> A(反転)
            ans = max(ans, cumsum1[i] + cumsum2[N + 1 - j] - 2 * (C - b) - a)

print(ans)

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

# x = 0 に v = 0 の寿司があると考える
X = [0]
V = [0]

for _ in range(N):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)

# 0, v_1, v_1+v_2, v_1+v_2+v_3, ...
cumsum1 = [0]
for i in range(1, N + 1):
    cumsum1.append(cumsum1[-1] + V[i])

# 0, v_N, v_N+v_N-1, v_N+v_N-1+v_N-2, ...
cumsum2 = [0]
for i in range(N, 0, -1):
    cumsum2.append(cumsum2[-1] + V[i])

# 歩く範囲を弧ABと考える(A<=B)
# x_A = 0, x_1, x_2, ..., x_N
# x_B = x_A, ..., x_N

# 0, v_1-x_1, v_1+v_2-x_2, v_1+v_2+v_3-x_3, ...
f1 = [0]
# 0, v_1-2*x_1, v_1+v_2-2*x_2, v_1+v_2+v_3-2*x_3, ...
f2 = [0]
for i in range(1, N + 1):
    f1.append(cumsum1[i] - X[i])
    f2.append(cumsum1[i] - 2 * X[i])

f1_max = [0]
for i in range(1, N + 1):
    f1_max.append(max(f1_max[-1], f1[i]))
f2_max = [0]
for i in range(1, N + 1):
    f2_max.append(max(f2_max[-1], f2[i]))

ans = 0
# Bを全探索（固定する）
for i in range(N + 1):
    if i == 0:
        continue
    else:
        # 0 -> B(反時計回り、反転なし)
        ans = max(ans, cumsum1[i] - X[i])
        # 0 -> B(時計回り、反転なし)
        ans = max(ans, cumsum2[N + 1 - i] - (C - X[i]))
        # 0 -> A -> B(反転)
        ans = max(ans, f2_max[i - 1] + cumsum2[N + 1 - i] - (C - X[i]))
        # 0 -> B -> A(反転)
        ans = max(ans, f1_max[i - 1] + cumsum2[N + 1 - i] - 2 * (C - X[i]))

print(ans)


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

ans = A * X + B * Y
if X >= 1 and Y >= 1:

    z = min(X, Y)
    ans = min(ans, A * (X - z) + B * (Y - z) + C * (z * 2))

    z = max(X, Y)
    ans = min(ans, A * max(0, (X - z)) + B * max(0, (Y - z)) + C * (z * 2))

print(ans)


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

if a <= x <= a + b:
    print("YES")
else:
    print("NO")

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

if a <= x <= a + b:
    print("YES")
else:
    print("NO")

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


import numpy as np

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

for i in range(N):
    B = X.copy()
    B.pop(i)
    print(int(np.median(B)))

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

Y = sorted(X)

l = Y[N // 2 - 1]
r = Y[N // 2]

for x in X:
    if l >= x:
        print(r)
    else:
        print(l)


import statistics
import copy

n = int(input())
a = list(map(int, input().split()))
ao = copy.copy(a)
for i in range(n):
    a.pop(i)
    print(statistics.median(a))
    a = copy.copy(ao)

import statistics

n = int(input())
x = list(map(int, input().split()))
xmd = statistics.median(x)
xs = sorted(x)
for i in x:
    if i < xmd:
        print(xs[n // 2])
    else:
        print(xs[n // 2 - 1])


from statistics import median

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

for i in range(N):
    Xx = [X[k] for k in range(N) if k != i]
    print(median(Xx))

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

Xs = sorted(X)
median1 = Xs[int(N / 2) - 1]
median2 = Xs[int(N / 2)]

for i in range(N):
    if X[i] >= median2:
        print(median1)
    else:
        print(median2)


from copy import copy

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

for xi in X:
    Y = copy(X)
    Y.remove(xi)
    print(sorted(Y)[N // 2 - 1])

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

M_small = sorted(X)[N // 2 - 1]
M_large = sorted(X)[N // 2]

for xi in X:
    if xi <= M_small:
        print(M_large)
    else:
        print(M_small)


import copy

input = open(0).read

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

def main():
    a = copy.copy(X)
    a.sort()

    for i in range(N):
        print(a[N // 2] if a.index(X[i]) < N // 2 else a[N // 2 - 1])

    return

main()

import copy

input = open(0).read

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

def main():
    a = copy.copy(X)
    l, r = sorted(a)[N // 2 - 1 : N // 2 + 1]

    print("\\n".join([str(r) if x < r else str(l) for x in X]))
    return

main()


n = int(input())
x = list(map(int, input().split()))
x1 = []
for i, xi in enumerate(x):
    x1.append([i, xi])

x_sort = sorted(x1, key=lambda x: x[1])
t = int(n / 2)
lxt = []
for i in range(n):
    if i < t:
        lxt.append(x_sort[i][0])
    else:
        break

for i in range(n):
    if i in lxt:
        print(x_sort[t][1])
    else:
        print(x_sort[t - 1][1])

n = int(input())
x = list(map(int, input().split()))
x1 = []
for i, xi in enumerate(x):
    x1.append([i, xi])

x_sort = sorted(x1, key=lambda x: x[1])
t = int(n / 2)
lxt = []
for i in range(n):
    if i < t:
        x[x_sort[i][0]] = x_sort[t][1]
    else:
        x[x_sort[i][0]] = x_sort[t - 1][1]

for i in range(n):
    print(x[i])


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

argsort = [[x, i] for i, x in enumerate(X)]
argsort.sort()
argsort = [[i, j] for j, [_, i], in enumerate(argsort)]
argsort.sort()
ranks = [j + 1 for _, j in argsort]

indices = [[x, i] for i, x in enumerate(X)]
indices.sort()
indices = {(i + 1): x for i, (x, _) in enumerate(indices)}

median = N // 2
for i in range(0, N):
    r = ranks[i]
    if r <= median:
        print(indices[median + 1])
    else:
        print(indices[median])

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

argsort = [[x, i] for i, x in enumerate(X)]
argsort.sort()

indices = {(i + 1): x for i, (x, _) in enumerate(argsort)}

argsort = [[i, j] for j, [_, i], in enumerate(argsort)]
argsort.sort()

ranks = [j + 1 for _, j in argsort]

median = N // 2
for i in range(0, N):
    r = ranks[i]
    if r <= median:
        print(indices[median + 1])
    else:
        print(indices[median])


N = int(input())
array = list(map(int, input().split()))
for i in range(0, N):
    konichiwa = list(array)
    konichiwa.pop(i)
    konichiwa.sort()
    print(konichiwa[int(N / 2) - 1])

N = int(input())
array = list(map(int, input().split()))
test = list(array)
test.sort()
wow = test[int(N / 2) - 1 : int(N / 2) + 1]
for i in range(0, N):
    if array[i] > wow[0]:
        print(wow[0])
    else:
        print(wow[1])


N = int(input())
X = [int(i) for i in input().split()]
for i in range(N):
    x = [int(X[j]) for j in range(N) if i != j]
    x.sort()
    print(x[(N - 1) // 2])

N = int(input())
X = [int(i) for i in input().split()]
x = sorted(X)
n = N // 2
for i in range(N):
    if X[i] < x[n]:
        print(x[n])
    else:
        print(x[n - 1])


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

for i in range(N):
    tmp = x.pop(i)
    tmplst = sorted(x)
    print(tmplst[(N - 1) // 2])
    x.insert(i, tmp)

import statistics

N = int(input())
x = list(map(int, input().split()))
sx = sorted(x)
tmp = statistics.median(sx)

for i in range(N):
    if x[i] <= tmp:
        print(sx[((N - 1) // 2) + 1])
    else:
        print(sx[(N - 1) // 2])


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

c = (n - 1) // 2

for i in range(len(x)):
    x2 = x.copy()
    x2.pop(i)
    x2.sort()
    print(x2[c])

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

x2 = x.copy()
x2.sort()
c1 = x2[n // 2 - 1]
c2 = x2[n // 2]
for i in x:
    if c1 >= i:
        print(c2)
    else:
        print(c1)


import numpy as np

n = int(input())
x = np.array(list(map(int, input().split(" "))))

sorted_x = sorted(x)
sorted_ind = list(np.argsort(x))
half_n = int(n / 2)

# print(x)
# print(half_n)
# print(sorted_ind)
# print(sorted_x)

for i in range(n):
    # print("==========")
    ind = sorted_ind.index(i)
    # print("ind: {}".format(ind))
    if ind <= half_n - 1:
        print(sorted_x[half_n - 1 + 1])
    else:
        print(sorted_x[half_n - 1])

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

sorted_x = sorted(x)

median_1 = sorted_x[n // 2 - 1]
median_2 = sorted_x[n // 2]

for i in range(n):
    if x[i] <= median_1:
        print(median_2)
    else:
        print(median_1)


import scipy.misc as scm

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

a = sorted(a, reverse=True)

comb = -1
a_i = a[0]
comb = 0
for i in range(1, n):
    c = scm.comb(a_i, a[i])
    if comb > c:
        comb = c
        a_j = a[i]
    else:
        break
print(a_i, a_j)

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

a = sorted(a, reverse=True)

comb = -1
a_i = a[0]
if a_i % 2 == 0:
    mid = int(a_i / 2)
    dif = 10**9
    for i in range(1, n):
        if dif > abs(a[i] - mid):
            dif = abs(a[i] - mid)
            a_j = a[i]
else:
    mid = int(a_i / 2)
    dif = 10**9
    for i in range(1, n):
        if a[i] > mid:
            if dif > abs(a[i] - mid - 1):
                dif = abs(a[i] - mid - 1)
                a_j = a[i]
        else:
            if dif > abs(a[i] - mid):
                dif = abs(a[i] - mid)
                a_j = a[i]

print(a_i, a_j)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03380/Python/s898511833.py", line 1, in <module>
    import scipy.misc as scm
ModuleNotFoundError: No module named 'scipy'


import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

ans = 0
a_i = a[0]
a_j = a[1]
for idx in range(1, n):
    if ans < combinations_count(a_i, a[idx]):
        ans = combinations_count(a_i, a[idx])
        a_j = a[idx]

print("%d %d" % (a_i, a_j))

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

max_a = max(a)
a.remove(max_a)
da = [abs(ai - max_a / 2) for ai in a]
med_i = da.index(min(da))

print("%d %d" % (max_a, a[med_i]))


def main():
    n = int(input())
    a = list(map(int, input().split()))
    if n == 2:
        print(a[0], a[1])
    ma = max(a)
    for i in range(n):
        if ma // 2 - i in a:
            print(ma, ma // 2 - i)
            exit()
        if ma // 2 - i + 1 in a:
            print(ma, ma // 2 - i + 1)
            exit()

main()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    if n == 2:
        print(max(a), min(a))
    else:
        ma = max(a)
        sa = sorted([(i, abs(ma // 2 - a[i])) for i in range(n)], key=lambda x: x[1])
        print(ma, a[sa[0][0]])

main()


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

ans1 = max(a)

flag = True
if ans1 % 2 == 1:
    s1 = ans1 // 2
    s2 = ans1 // 2 + 1
else:
    if ans1 // 2 in a:
        flag = False
        ans2 = ans1 // 2
    else:
        s1 = ans1 // 2 - 1
        s2 = ans1 // 2 + 1

while flag:
    if s1 in a:
        ans2 = s1
        break
    elif s2 in a:
        ans2 = s2
        break
    s1 -= 1
    s2 += 1

print(ans1, ans2)

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

ans1 = max(a)
sa = sorted(a)

if n == 2:
    ans1 = a[0]
    ans2 = a[1]
else:
    idx = n // 2
    flag = True
    if sa[idx] == ans1 // 2:
        ans2 = ans1 // 2
    elif sa[idx] < ans1 // 2:
        while True:
            idx += 1
            if ans1 // 2 <= sa[idx]:
                if abs(sa[idx] - ans1 / 2) < abs(sa[idx - 1] - ans1 / 2):
                    ans2 = sa[idx]
                else:
                    ans2 = sa[idx - 1]
                break
    else:
        while True:
            idx -= 1
            if sa[idx] <= ans1 // 2:
                if abs(sa[idx] - ans1 / 2) < abs(sa[idx + 1] - ans1 / 2):
                    ans2 = sa[idx]
                else:
                    ans2 = sa[idx + 1]
                break

print(ans1, ans2)


from math import factorial

def perm(n, r):
    return factorial(n) // factorial(n - r)

def comb(n, r):
    return perm(n, r) // factorial(r)

n = int(input())
A = list(map(int, input().split()))
A.sort()
m = A.pop()
biggest = 0
biggest_r = 0
for r in A:
    var = comb(m, r)
    if var > biggest:
        biggest = var
        biggest_r = r
print(m, biggest_r)

from bisect import bisect

n = int(input())
A = list(map(int, input().split()))
A.sort()
b = A.pop()
m = b / 2
i = bisect(A, m)
A.insert(i, m)

if i == 0:
    print(b, A[1])
elif i == len(A) - 1:
    print(b, A[-2])
elif A[i] - A[i - 1] < A[i + 1] - A[i]:
    print(b, A[i - 1])
else:
    print(b, A[i + 1])


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

X2 = sorted(X)

for i in range(0, N):
    idx = X2.index(X[i])
    if idx < N // 2:
        print(X2[N // 2])
    else:
        print(X2[N // 2 - 1])

import bisect

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

X2 = sorted(X)

for i in range(0, N):
    # idx = X2.index(X[i])
    idx = bisect.bisect_left(X2, X[i])
    if idx < N // 2:
        print(X2[N // 2])
    else:
        print(X2[N // 2 - 1])


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

def comb(n, r):
    res = 1
    for i in range(n - r + 1, n + 1):
        res *= i
    for i in range(1, r):
        res //= i
    return res

x = A.pop()
N -= 1
for i in range(N):
    if A[i] > x // 2:
        break
if comb(x, A[i]) > comb(x, A[i - 1]):
    y = A[i]
else:
    y = A[i - 1]
print(x, y)

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

def comb(n, r):
    res = 1
    for i in range(n - r + 1, n + 1):
        res *= i
    for i in range(1, r):
        res //= i
    return res

x = A.pop()
N -= 1
for i in range(N):
    if A[i] > x // 2:
        break
if abs(A[i] - x / 2) < abs(A[i - 1] - x / 2):
    print(x, A[i])
else:
    print(x, A[i - 1])


S = str(input())
ans = {}
ans.add(S[0])
ans.add(S[1])
ans.add(S[2])
if len(ans) == 3:
    print("Yes")
else:
    print("No")

S = str(input())
if not (S[0] == S[1]) and not (S[1] == S[2]) and not (S[0] == S[2]):
    print("Yes")
else:
    print("No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03385/Python/s103059776.py", line 3, in <module>
    ans.add(S[0])
AttributeError: 'dict' object has no attribute 'add'


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

def main():
    """Function."""
    s = str(input())
    if len(set(s[0], s[1], s[2])) == 3:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

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

def main():
    """Function."""
    s = str(input())
    if len(set([s[0], s[1], s[2]])) == 3:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03385/Python/s179544392.py", line 14, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03385/Python/s179544392.py", line 7, in main
    if len(set(s[0], s[1], s[2])) == 3:
TypeError: set expected at most 1 argument, got 3


s = input()
L = [s[0], s[1], s[2]].sort().join()
print("Yes") if L == "abc" else print("No")

s = input()
L = [s[0], s[1], s[2]]
L.sort()
S = "".join(L)
print("Yes") if S == "abc" else print("No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03385/Python/s660041027.py", line 2, in <module>
    L = [s[0], s[1], s[2]].sort().join()
AttributeError: 'NoneType' object has no attribute 'join'


# https://atcoder.jp/contests/abc093/tasks/abc093_b
a, b, k = [int(x) for x in input().split()]
r = list(range(a, b + 1))
for v in sorted(set(r[:k] + r[-k:])):
    print(v)

# https://atcoder.jp/contests/abc093/tasks/abc093_b
a, b, k = [int(x) for x in input().split()]
s = list(range(a, b + 1)[:k])
t = list(range(a, b + 1)[-k:])
for v in sorted(set(s + t)):
    print(v)


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

a, b, k = map(int, input().split())
for i in range(a, min(a + k, b + 1)):
    print(i)
for i in range(max(a + k, b - k + 1), b + 1):
    print(i)


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

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

    for i in list(range(A, B + 1)):
        if A <= i <= A + K - 1 or B + 1 >= i >= B - K + 1:
            print(i)

if __name__ == "__main__":
    main()

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

def main():
    A, B, K = map(int, input().split())
    AK = [i for i in range(A, min(B + 1, A + K))]
    BK = [i for i in range(max(A, B - K + 1), B + 1)]

    result = list(set(AK) | set(BK))
    result.sort()

    for i in result:
        print(i)

if __name__ == "__main__":
    main()


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

for i in range(a, b + 1):
    if i < a + k or i > b - k:
        print(i)

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

if b - a + 1 <= k * 2:
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(a, a + k):
        print(i)
    for i in range(b - k + 1, b + 1):
        print(i)


import copy

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

num = copy.deepcopy(list(range(a, b + 1)))

a_k = num[:k]
k_e = num[-k:]

# print(a_k, k_e)
ans_set = set(a_k + k_e)
ans_list = copy.deepcopy(list(ans_set))
ans_list.sort()
for i in ans_list:
    print(i)

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

num = range(a, b + 1)

a_k = num[:k]
k_e = num[-k:]

# print(a_k, k_e)
ans_set = set(a_k) | set(k_e)
ans_list = sorted(ans_set)
for i in ans_list:
    print(i)


def resolve():
    a, b, k = list(map(int, input().split()))
    small = list(range(a, b))[:k]
    large = list(range(a, b + 1))[::-1][:k]
    ans = sorted(set(small + large))
    for i in ans:
        print(i)

if __name__ == "__main__":
    resolve()

def resolve():
    a, b, k = list(map(int, input().split()))
    s = set()
    for i in range(a, min(a + k, b + 1)):
        s.add(i)
    for i in range(max(a, b - k + 1), b + 1):
        s.add(i)
    for i in sorted(s):
        print(i)

if __name__ == "__main__":
    resolve()


def resolve():
    A, B, K = [int(i) for i in input().split()]
    numbers = [i for i in range(A, B + 1)]
    ans = numbers[:K]
    ans.extend(numbers[-K:])
    print(*sorted(set(ans)), sep="\\n")

resolve()

def resolve():
    A, B, K = [int(i) for i in input().split()]
    offset = 0
    while offset < K and A + offset <= B:
        print(A + offset)
        offset += 1
    begin = A + offset
    r = max(B - K + 1, begin)
    while r <= B:
        print(r)
        r += 1

resolve()


A, B, K = map(int, input().split())
for i in range(A, B + 1):
    if i - A < K or B - i < K:
        print(i)

A, B, K = map(int, input().split())
ret = range(A, B + 1)
for i in sorted(set(ret[:K]) | set(ret[-K:])):
    print(i)


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

ans = []

for i in range(b - a + 1):
    n = a + i
    if n <= a + k - 1 or n >= b - k + 1:
        ans.append(n)

ans.sort()
for i in range(len(ans)):
    print(ans[i])

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

ans = []

for i in range(k):
    if a + i <= b and a <= b - i:
        ans.append(a + i)
        ans.append(b - i)

# ans.sort()
ans = set(ans)

for i in sorted(ans):
    print(i)


A, B, K = map(int, input().split())
for n in sorted({*range(A, A + K), *range(B - K + 1, B + 1)}):
    print(n)

A, B, K = map(int, input().split())
for n in sorted(
    filter(lambda n: A <= n <= B, set(range(A, A + K)) | set(range(B - K + 1, B + 1)))
):
    print(n)


a, b, k = map(int, input().split())
ls = list(range(a, b + 1))
lsRe = ls[::-1]
s = set()

if len(ls) > k:
    for i in range(k):
        s.add(ls[i])
        s.add(lsRe[i])
else:
    print(*ls, sep="\\n")
    quit()

s = sorted(s)
print(*s, sep="\\n")

a, b, k = map(int, input().split())
s = set()
if b - a == 0:
    print(a)
elif b - a + 1 <= k:
    print(*range(a, b + 1), sep="\\n")
else:
    for i in range(k):
        s.add(a + i)
        s.add(b - i)
    s = sorted(s)
    print(*s, sep="\\n")


A, B, K = map(int, input().split())
for i in range(A, B + 1):
    if abs(A - i) < K or abs(B - i) < K:
        print(i)

A, B, K = map(int, input().split())
if B - A <= 2 * K - 1:
    for i in range(A, B + 1):
        print(i)
else:
    for i in range(A, A + K):
        print(i)
    for i in range(B - K + 1, B + 1):
        print(i)


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

z = list(range(a, b + 1))
ans = sorted(list(set(z[:k]) | set(z[-k:])))
for x in ans:
    print(x)

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

for i in range(a, min(a + k, b - k + 1)):
    print(i)
for i in range(max(a, b - k + 1), b + 1):
    print(i)


a, b, k = map(int, input().split())
lst = [x for x in range(a, b + 1)]
lst_small = lst[:k]
lst_large = lst[-k:]
ans = list(set(lst_small) | set(lst_large))
ans = sorted(ans)
for i in range(len(ans)):
    print(ans[i])

a, b, k = map(int, input().split())
if b - a > k:
    lst_small = [x for x in range(a, a + k)]
    lst_large = [x for x in range(b - k + 1, b + 1)]
    ans = list(set(lst_small) | set(lst_large))
    ans = sorted(ans)
else:
    ans = [x for x in range(a, b + 1)]

for i in range(len(ans)):
    print(ans[i])


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

a, b, k = map(int, input().split())
for i in range(a, min(b, a + k - 1) + 1):
    print(i)
for i in range(max(b - k + 1, a + k), b + 1):
    print(i)


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

a, b, k = map(int, input().split())
ans = []
for i in range(a, min(a + k, b + 1)):
    ans.append(i)
for i in range(b, max(b - k, a - 1), -1):
    if i not in ans:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)


A, B, K = map(int, input().split())
N = B - A + 1
nums = list(range(A, B + 1))
ans = set()

for i in range(min(K, N)):
    ans.add(nums[i])

nums.reverse()
for i in range(min(K, N)):
    ans.add(nums[i])

ans = list(ans)
ans.sort()
for i in ans:
    print(i)

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

ans = set()
for i in range(A, min(B + 1, A + K)):
    ans.add(i)

for i in range(max(A, B - K + 1), B + 1):
    ans.add(i)
ans = sorted(list(ans))
for i in ans:
    print(i)


A, B, K = map(int, input().split())
if B - A < 2 * K:
    ans = [*range(A, B + 1)]
else:
    ans = [*range(A, A + K), *range(B - K + 1, B + 1)]
for v in ans:
    print(v)

A, B, K = map(int, input().split())
if B - A < 2 * K:
    # ans = [*range(A, B + 1)]
    ans = list(range(A, B + 1))
else:
    # ans = [*range(A, A + K), *range(B - K + 1, B + 1)]
    ans = list(range(A, A + K)) + list(range(B - K + 1, B + 1))
for v in ans:
    print(v)


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

num = list(range(a, b + 1))

a_k = num[:k]
k_e = num[-k:]

# print(a_k, k_e)
ans_set = set(a_k + k_e)
ans_list = list(ans_set)
ans_list.sort()
for i in ans_list:
    print(i)

a, b, k = map(int, input().split())
r = range(a, b + 1)
for i in sorted(set(r[:k]) | set(r[-k:])):
    print(i)


A, B, K = map(int, input().split())
print(
    *sorted(
        list(set(range(A, min(B + 1, A + K))) | set(range(max(A, B - K) + 1, B + 1)))
    ),
    sep="\\n",
)

A, B, K = map(int, input().split())
R = range(A, min(B + 1, A + K))
S = range(max(A, B - K + 1), B + 1)
L = list(set(R) | set(S))
L.sort()
print(*L, sep="\\n")


a, b, k = map(int, input().split())
r = [x for x in range(a, b + 1)]
for x in sorted(set(r[:k]) | set(r[-k:])):
    print(x)

a, b, k = map(int, input().split())
r = range(a, b + 1)
for x in sorted(set(r[:k]) | set(r[-k:])):
    print(x)


A, B, K = map(int, input().split())
arr = range(A, B + 1)
ans = []
for i in range(K):
    ans[i] = arr[A + i]
for j in range(K):
    ans[j + K + 2] = arr[B + 1 - K + j]
print(set(ans))

A, B, K = map(int, input().split())
arr = range(A, B + 1)
ans = []
for i in range(K):
    ans.append(A + i)
for j in range(K):
    ans.append(B + 1 - K + j)

anset = list(set(ans))
anset.sort()
if A + K <= B + 1:
    for ele in range(len(anset)):
        print(anset[ele])
else:
    for ele in range(A, B + 1):
        print(ele)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03386/Python/s604685648.py", line 5, in <module>
    ans[i] = arr[A + i]
IndexError: list assignment index out of range


A, B, K = map(int, input().split())
for i in range(A, B + 1):
    if (i <= A + K - 1) or (i >= B - K + 1):
        print(i)
        continue

A, B, K = map(int, input().split())
if B - A + 1 <= 2 * K:
    for i in range(A, B + 1):
        print(i)
    exit()
for i in range(A, A + K):
    print(i)
for i in range(B - K + 1, B + 1):
    print(i)


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

for i in range(a, b + 1):
    if i < a + k or i > b - k:
        print(i)

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

if b - a + 1 <= k * 2:
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(a, a + k):
        print(i)
    for i in range((b - k + 1), (b + 1)):
        print(i)


def abc():
    a, b, c = map(int, input().split())
    n = list(range(a, b + 1))
    for s in sorted(set(n[:c]) | set(n[-c:])):
        print(s)

abc()

def abc():
    a, b, c = map(int, input().split())
    n = range(a, b + 1)
    for s in sorted(set(n[:c]) | set(n[-c:])):
        print(s)

abc()


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

s = set()

for i in range(A, B + 1):
    if i <= A + K - 1:
        s.add(i)
    elif B - K + 1 <= i:
        s.add(i)

s = sorted(s)

for i in s:
    print(i)

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

s = set()

for i in range(A, min(A + K, B + 1)):
    s.add(i)

for i in range(B, max(A - 1, B - K), -1):
    s.add(i)

s = sorted(s)

for i in s:
    print(i)


A, B, K = map(int, input().split())
S = list(range(A, B + 1))

ans = sorted(set(S[:K] + S[-K:]))
for a in ans:
    print(a)

A, B, K = map(int, input().split())
SA = list(range(A, min(B, A + K)))
SB = list(range(max(A, B - K + 1), B + 1))

ans = sorted(set(SA + SB))
for a in ans:
    print(a)


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

for i in range(A, B + 1):
    if i < A + K or i > B - K:
        print(i)

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

for i in range(A, min(B + 1, A + K)):
    if i < A + K:
        print(i)

for i in range(max(B - K, A + K), B + 1):
    if i > B - K:
        print(i)


#!/usr/bin/env python3
A, B, K = map(int, input().split())
for i in range(A, B + 1):
    if i < A + K or B - K < i:
        print(i)

#!/usr/bin/env python3
A, B, K = map(int, input().split())
for i in range(A, min(B + 1, A + K)):
    print(i)
for i in range(max(0, B - K + 1), B + 1):
    if i < A + K:
        continue
    print(i)


A, B, K = map(int, input().split())
for num in range(A, B + 1):
    if num < A + K or num > B - K:
        print(num)

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

x = b - a
if x < 2 * k:
    for i in range(a, b + 1):
        print(i)
else:
    for i in range(a, a + k):
        print(i)

    for i in range(b - k + 1, b + 1):
        print(i)


a, b, k = [int(x) for x in input().split()]
lst = list(range(a, b + 1))
res = []
res.extend(lst[:k])
res.extend(lst[-k:])
res = sorted(set(res))
for i in res:
    print(i)

a, b, k = [int(x) for x in input().split()]
r = range(a, b + 1)
for i in sorted(set(r[:k]) | set(r[-k:])):
    print(i)


A, B, C = sorted([int(x) for x in input().split()])
if A == B and B == C:
    print(0)
    exit()

ret = 0
while True:
    if A < B and B < C:
        A += 1
        B += 1
    elif A < B and B == C:
        A += 2
    elif A > B and B == C:
        B += 1
        C += 1
    else:
        # 想定外
        exit(1)

    ret += 1
    if A == B and B == C:
        print(ret)
        exit()

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

ret = 0
while True:
    if A == B and B == C:
        print(ret)
        exit()

    ret += 1
    A, B, C = sorted([A, B, C])
    if B < C:
        A += 1
        B += 1
    elif B == C:
        A += 2


A, B, C = map(int, input().split())
diff = max(A, B, C) * 3 - sum(A, B, C)
if diff % 2 == 0:
    print(diff // 2)
else:
    print(diff // 2 + 2)

A, B, C = map(int, input().split())
diff = max(A, B, C) * 3 - (A + B + C)
if diff % 2 == 0:
    print(diff // 2)
else:
    print(diff // 2 + 2)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03387/Python/s401385664.py", line 2, in <module>
    diff = max(A, B, C) * 3 - sum(A, B, C)
TypeError: sum() takes at most 2 arguments (3 given)


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

combi = [A, B, C]
max_ABC = max([A, B, C])
other = [c for c in combi if c != max_ABC]
max_other = max(other)
min_other = min(other)

# Operation (1st method)
n_operation = max_ABC - max_other
max_other += n_operation
min_other += n_operation

if max_other == min_other:
    print(n_operation)
    exit()

# Operation (2nd method)
if (max_ABC - min_other) % 2:
    n_add = (max_ABC - min_other) // 2 + 1
else:
    n_add = (max_ABC - min_other) // 2
n_operation += n_add

print(n_operation)

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

combi = [A, B, C]
set_abc = set(combi)

len_set_abc = len(set_abc)
max_set = max(set_abc)
min_set = min(set_abc)
if len_set_abc == 1:
    print(0)
elif len_set_abc == 2:
    max_freq = combi.count(max_set)
    diff = max_set - min_set
    if max_freq == 2 and diff % 2:
        print((diff + 1) // 2 + 1)
    elif max_freq == 2:
        print(diff // 2)
    else:
        print(diff)
else:
    other = [c for c in combi if c != max_set]
    max_other = max(other)
    min_other = min(other)

    n_operation = max_set - max_other
    max_other += n_operation
    min_other += n_operation

    diff = max_set - min_other
    if diff % 2 and diff == 1:
        n_add = (max_set - min_other) // 2 + 2
    elif diff % 2:
        n_add = (max_set - min_other) // 2 + 2
    else:
        n_add = (max_set - min_other) // 2
    n_operation += n_add

    print(n_operation)


def solve(A, B):
    M = A * B
    cnt = 0

    x, y = A, B
    while y - x >= 1:
        x += 1
        y = M // x if M % x else M // x - 1
        cnt += 1
    cnt += y - 1

    x, y = B, A
    while y - x >= 1:
        x += 1
        y = M // x if M % x else M // x - 1
        cnt += 1
    cnt += y - 1

    return cnt

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

for A, B in Query:
    print(solve(A, B))

def solve(A, B):
    from math import sqrt

    M = A * B
    cnt = 0

    x, y = A, B
    if y - x >= 1:
        z = int(sqrt(M))
        x = z
        y = M // x if M % x else M // x - 1
        cnt += z - A
    cnt += y - 1

    x, y = B, A
    if y - x >= 1:
        z = int(sqrt(M))
        x = z
        y = M // x if M % x else M // x - 1
        cnt += z - B
    cnt += y - 1

    return cnt

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

for A, B in Query:
    print(solve(A, B))


N = int(input())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())

c = 0

if A == B:
    print(c)
    exit()

# A[i] < B[i]のところはA[i] == 0になるまで追いつけない
for i in range(N):
    if A[i] < B[i]:
        c += A[i]
        B[i] -= A[i]
        A[i] = 0

while A != B:
    x = 0
    for i in range(N):
        if A[i] == 0:
            continue
        x = i
        if A[i] < B[i]:
            break
    A[x] -= 1
    y = 0
    for i in range(N):
        if A[i] == B[i]:
            continue
        y = i
        if A[i] < B[i]:
            break
    B[y] -= 1
    c += 1

print(c)

N = int(input())

same = True
sum_a = 0
min_b = None

for _ in range(N):
    a, b = map(int, input().split())
    # Aの総和を求める
    sum_a += a
    # AとBが等しいどうかを調べる
    if a != b:
        same = False
    # Ai > Biの中で最小のbを求める
    if a > b and (min_b is None or b < min_b):
        min_b = b

# 初めから同じなら手数なし
if same:
    print(0)
    exit()

# Ai > Biの中で最小のbを求める
if min_b is None:
    min_b = 0

print(sum_a - min_b)


s = s0 = input()
d = {chr(c) for c in range(97, 123)}
for c in s:
    d.remove(c)
if d:
    s += min(d)
else:
    for c in reversed(s):
        s = s[:-1]
        if d and c < min(d):
            s += min(d)
            break
        d.add(c)
print(s if s else -1)
assert s0 < s

s = s0 = input()
d = {chr(c) for c in range(97, 123)}
for c in s:
    d.remove(c)
if d:
    s += min(d)
else:
    for c in reversed(s):
        s = s[:-1]
        if d and any(c < e for e in d):
            s += min(e for e in d if c < e)
            break
        d.add(c)
print(s if s else -1)
if s:
    assert s0 < s


S = input()
S_set = set(list(S))
C_set = set([chr(ord("a") + i) for i in range(26)])

if len(S_set) == len(C_set):
    S = list(S)
    p = None
    for i in range(len(S) - 2, -1, -1):
        if S[i] < S[i + 1]:
            p = i
            break
    else:
        print(-1)
    ans = S[:p].copy()
    rest = C_set - set(S[: p + 1])
    rest = sorted(rest)
    for r in rest:
        if S[p] < r:
            ans.append(r)
            break
    print(*ans, sep="")
else:
    diff = C_set - S_set
    diff = sorted(diff)
    print(S + diff[0])

def main():
    S = input()
    S_set = set(list(S))
    C_set = set([chr(ord("a") + i) for i in range(26)])

    if len(S_set) == len(C_set):
        S = list(S)
        p = None
        for i in range(len(S) - 2, -1, -1):
            if S[i] < S[i + 1]:
                p = i
                break
        else:
            print(-1)
            return

        ans = S[:p].copy()
        rest = C_set - set(S[: p + 1])
        rest = sorted(rest)
        for r in rest:
            if S[p] < r:
                ans.append(r)
                break
        print(*ans, sep="")
    else:
        diff = C_set - S_set
        diff = sorted(diff)
        print(S + diff[0])
        return

main()


from scipy.sparse.csgraph import floyd_warshall
import numpy as np

def make_graph(m):
    matrix = np.zeros([m + 1, m + 1, m + 1])
    for k in range(1, m + 1):
        for s in range(k, m + 1):
            matrix[k, s, s % k] = 1
    return matrix

def is_disable(matrix, subset, aaa, bbb):
    sub_matrix = matrix[list(subset)].max(axis=0)
    sp = floyd_warshall(sub_matrix)
    return any(sp[a, b] > 50 for a, b in zip(aaa, bbb))

def solve(aaa, bbb):
    for a, b in zip(aaa, bbb):
        if a < b:
            return -1
    m = max(aaa)
    matrix = make_graph(m)
    subset = set(range(1, m + 1))
    if is_disable(matrix, subset, aaa, bbb):
        return -1

    for k in range(m, 0, -1):
        subset.remove(k)
        if is_disable(matrix, subset, aaa, bbb):
            subset.add(k)
    return sum(1 << k for k in subset)

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

from scipy.sparse.csgraph import floyd_warshall
import numpy as np

def make_graph(m):
    matrix = np.zeros([m + 1, m + 1, m + 1])
    for k in range(1, m + 1):
        for s in range(k, m + 1):
            matrix[k, s, s % k] = 1
    return matrix

def is_disable(matrix, subset, aaa, bbb):
    if subset:
        sub_matrix = matrix[list(subset)].max(axis=0)
    else:
        sub_matrix = matrix[0]
    sp = floyd_warshall(sub_matrix)
    return any(sp[a, b] > 50 for a, b in zip(aaa, bbb))

def solve(aaa, bbb):
    for a, b in zip(aaa, bbb):
        if a < b:
            return -1
    m = max(aaa)
    matrix = make_graph(m)
    subset = set(range(1, m + 1))
    if is_disable(matrix, subset, aaa, bbb):
        return -1

    for k in range(m, 0, -1):
        subset.remove(k)
        if is_disable(matrix, subset, aaa, bbb):
            subset.add(k)
    return sum(1 << k for k in subset)

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

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


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

A, B, C, D = [int(input()) for _ in range(4)]
print(min(A, B) + min(C, D))

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


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

ab = [a, b]
cd = [c, d]

print(min(ab) + min(cd))

a, b, c, d = [int(input()) for _ in range(4)]

print(min(a, b) + min(c, d))

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


def main():
    A, B, C, D = map(int, input().split())
    print(min(A, B) + min(C, D))

if __name__ == "__main__":
    main()

def main():
    A, B, C, D = [int(input()) for _ in range(4)]
    print(min(A, B) + min(C, D))

if __name__ == "__main__":
    main()

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


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

print(min(a, b) + min(c, d))

a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(min(a, b) + min(c, d))

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


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


N = int(input())
D, X = map(int, input().split())
A = list(input() for i in range(N))
sum = 0
for i in range(N):
    B = 0
    while B * A[i] + 1 <= D:
        B += 1
        sum += 1
print(X + sum)

N = int(input())
D, X = map(int, input().split())
A = list(int(input()) for i in range(N))
sum = 0
for i in range(N):
    B = 0
    while B * A[i] + 1 <= D:
        B += 1
        sum += 1
print(X + sum)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03400/Python/s335777592.py", line 7, in <module>
    while B * A[i] + 1 <= D:
TypeError: can only concatenate str (not "int") to str


n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    b = 0
    bud = 0
    for ai in a:
        if a[i] != ai:
            bud += abs(ai - b)
            b = ai
    bud += abs(b)
    print(bud)

n = int(input())
a = list(map(int, input().split()))
a.append(0)
a.insert(0, 0)
costs = []
for i in range(n + 1):
    costs.append(abs(a[i + 1] - a[i]))

s = sum(costs)
for i in range(n):
    print(s - costs[i] - costs[i + 1] + abs(a[i] - a[i + 2]))


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

for skip_num in range(N):
    sum = 0
    pos = 0
    for i in range(N):
        if i == skip_num:
            continue
        sum += abs(pos - As[i])
        pos = As[i]
    sum += abs(pos)
    print(sum)

N = int(input())
As = [0]
As.extend(map(int, input().split()))
As.append(0)

sum = 0
pos = 0
for i in range(1, N + 2):
    sum += abs(pos - As[i])
    pos = As[i]

for i in range(1, N + 1):
    skip_pos = As[i]
    pre_pos = As[i - 1]
    post_pos = As[i + 1]

    if (pre_pos - skip_pos) * (post_pos - skip_pos) <= 0:
        print(sum)
    else:
        print(
            sum
            - abs(pre_pos - skip_pos)
            - abs(post_pos - skip_pos)
            + abs(pre_pos - post_pos)
        )


n = int(input())
a = list(map(int, input().split()))
Sum = 0
a.insert(0, 0)
a.append(0)
s = []
b = []
for i in range(len(a) - 1):
    b.append(abs(a[i] - a[i + 1]))
for i in range(len(b) - 1):
    ans = sum(b) - (b[i] + b[i + 1]) + abs(a[i] - a[i + 2])
    print(ans)

n = int(input())
a = list(map(int, input().split()))
Sum = 0
a.insert(0, 0)
a.append(0)
s = []
b = []
for i in range(len(a) - 1):
    b.append(abs(a[i] - a[i + 1]))
Sum_b = sum(b)
for i in range(len(b) - 1):
    ans = Sum_b - (b[i] + b[i + 1]) + abs(a[i] - a[i + 2])
    print(ans)


from collections import deque

n = int(input())
a = deque(map(int, input().split()))
a.appendleft(0)
a.append(0)
a = list(a)
kaisa = deque()
ans = list()

for i in range(len(a)):
    if i == 0:
        continue
    diff = a[i] - a[i - 1]
    kaisa.append(diff)

for i in range(n):
    ans = list(kaisa).copy()
    new_num = kaisa[i] + kaisa[i + 1]
    ans.remove(kaisa[i])
    ans.remove(kaisa[i + 1])
    ans.insert(i, new_num)
    print(sum([abs(n) for n in ans]))

from collections import deque

n = int(input())
a = deque(map(int, input().split()))
a.appendleft(0)
a.append(0)

sum = sum([abs(a[i + 1] - a[i]) for i in range(len(a) - 1)])
ans = 0

for i in range(n):
    ans = sum
    ans = ans - abs(a[i + 1] - a[i]) - abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i])
    print(ans)


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

A.append(0)
for i in range(N):
    b, s = 0, 0
    for j, a in enumerate(A):
        if i != j:
            s += abs(b - a)
            b = a
    print(s)

from collections import deque

N = int(input())
A = [0] + list(map(int, input().split())) + [0]

total = 0
for i in range(1, N + 2):
    total += abs(A[i - 1] - A[i])

visited = []
for i in range(1, N + 1):
    a = abs(A[i - 1] - A[i + 1])
    b = abs(A[i] - A[i - 1]) + abs(A[i] - A[i + 1])
    visited.append(total + (a - b))

for v in visited:
    print(v)


n = int(input())
a = list(map(int, input().split()))
m = []
for i in range(n - 2):
    if a[i] < a[i + 1] < a[i + 2] or a[i + 2] < a[i + 1] < a[i]:
        m.append(0)
    if a[i + 1] < a[i] < a[i + 2] or a[i + 1] < a[i + 2] < a[i]:
        m.append(1)
    if a[i] < a[i + 2] < a[i + 1] or a[i + 2] < a[i] < a[i + 1]:
        m.append(-1)

s = sum(abs(a[i] - a[i + 1]) for i in range(n - 1))

print(s - abs(a[0] - a[1]))
for i, m0 in enumerate(m):
    if m0 == 0:
        print(s)
    elif m0 > 0:
        print(s - 2 * abs(a[i + 1] - a[i + 2]))
    elif m0 < 0:
        print(s - 2 * abs(a[i + 2] - a[i + 3]))
print(s - abs(a[n - 1] - a[n]))

n = int(input())
a = [0] + list(map(int, input().split())) + [0]
m = []
for i in range(n):
    if a[i] <= a[i + 1] <= a[i + 2] or a[i + 2] <= a[i + 1] <= a[i]:
        m.append(0)
    elif a[i] <= a[i + 2] <= a[i + 1] or a[i + 1] <= a[i + 2] <= a[i]:
        m.append(1)
    elif a[i + 1] <= a[i] <= a[i + 2] or a[i + 2] <= a[i] <= a[i + 1]:
        m.append(-1)

s = sum(abs(a[i] - a[i + 1]) for i in range(n + 1))

for i, m0 in enumerate(m):
    if m0 == 0:
        print(s)
    elif m0 == 1:
        print(s - 2 * abs(a[i + 1] - a[i + 2]))
    elif m0 == -1:
        print(s - 2 * abs(a[i] - a[i + 1]))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03401/Python/s825783315.py", line 21, in <module>
    print(s - 2 * abs(a[i + 2] - a[i + 3]))
IndexError: list index out of range


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

total = sum(abs(a[i] - a[i + 1]) for i in range(0, n + 1))
for i in range(1, n + 1):
    print(total - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]))

n = int(input())
a = [0] + list(map(int, input().split())) + [0]

total = sum(abs(a[i] - a[i + 1]) for i in range(0, n + 1))
for i in range(1, n + 1):
    print(total - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1]))


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

for i in range(N):
    s = 0
    a = 0
    for j, b in enumerate(A):
        if i == j:
            continue
        s += abs(a - b)
        a = b
    s += abs(a)
    print(s)

N = int(input())
A = [0] + list(map(int, input().split())) + [0]

s = 0
for i in range(1, N + 2):
    x = abs(A[i - 1] - A[i])
    s += x

for i in range(1, N + 1):
    x = abs(A[i - 1] - A[i])
    y = abs(A[i] - A[i + 1])
    z = abs(A[i - 1] - A[i + 1])
    print(s - x - y + z)


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

for i in range(n):
    ans = 0
    tmp = 0
    for j in range(n):
        if j != i:
            ans += abs(tmp - a[j])
            tmp = a[j]

    ans += abs(tmp - 0)
    print(ans)

n = int(input())
a = list(map(int, input().split()))
s = abs(a[0])

for i in range(n - 1):
    s += abs(a[i] - a[i + 1])
s += abs(a[n - 1])

for i in range(n):
    if i == 0:
        print(s + abs(0 - a[i + 1]) - (abs(0 - a[i]) + abs(a[i] - a[i + 1])))
    elif i == n - 1:
        print(s + abs(a[i - 1] - 0) - (abs(a[i - 1] - a[i]) + abs(a[i])))
    else:
        print(
            s + abs(a[i - 1] - a[i + 1]) - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1]))
        )


x = input().split
if x[2] <= x[0] + x[1]:
    print("Yes")
else:
    print("No")

x = raw_input().split()
if int(x[2]) <= int(x[0]) + int(x[1]):
    print("Yes")

else:
    print("No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03407/Python/s586216421.py", line 2, in <module>
    if x[2] <= x[0] + x[1]:
TypeError: 'builtin_function_or_method' object is not subscriptable


A, B, C = map(int, input())
print("Yes" if A + B >= C else "No")

A, B, C = map(int, input().split())
print("Yes" if A + B >= C else "No")

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03407/Python/s505965538.py", line 1, in <module>
    A, B, C = map(int, input())
ValueError: invalid literal for int() with base 10: ' '


N = int(input())

s = []
t = []
for _ in range(N):
    s.append(input())

for _ in range(N):
    t.append(input())

sets = set(s)

ans = []
for word in sets:
    tmp = 0
    tmp += s.count(word)
    tmp -= t.count(word)
    ans.append(tmp)

print(max(ans))

N = int(input())
s = []
for _ in range(N):
    s.append(input())

M = int(input())
t = []
for _ in range(M):
    t.append(input())

sets = set(s)

ans = [0]
for word in sets:
    tmp = 0
    tmp += s.count(word)
    tmp -= t.count(word)
    ans.append(tmp)

print(max(ans))

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03408/Python/s032947728.py", line 9, in <module>
    t.append(input())
EOFError: EOF when reading a line


# ABC091B

n = int(input)
s = [0] * n
for i in range(n):
    s[i] = input()
m = int(input)
t = [0] * m
for i in range(m):
    t[i] = input()

blue = {}
for c in s:
    if c in blue.keys():
        blue[c] += 1
    else:
        blue.setdefault(c, 1)
red = {}
for c in t:
    if c in red.keys():
        red[c] += 1
    else:
        red.setdefault(c, 1)

Max = 0
for blue_key, blue_value in blue.items():
    get = blue_value
    if blue_key in red.keys():
        for red_key, red_value in red.items():
            if blue_key == red_key:
                get -= red_value
                break
    Max = max(Max, get)
print(Max)

# ABC091B

n = int(input())
s = [0] * n
for i in range(n):
    s[i] = input()
m = int(input())
t = [0] * m
for i in range(m):
    t[i] = input()

blue = {}
for c in s:
    if c in blue.keys():
        blue[c] += 1
    else:
        blue.setdefault(c, 1)
red = {}
for c in t:
    if c in red.keys():
        red[c] += 1
    else:
        red.setdefault(c, 1)

Max = 0
for blue_key, blue_value in blue.items():
    get = blue_value
    if blue_key in red.keys():
        for red_key, red_value in red.items():
            if blue_key == red_key:
                get -= red_value
                break
    Max = max(Max, get)
print(Max)

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


import sys

sys.setrecursionlimit(4100000)

def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins

def solve(blues, reds):
    blue_counts = {}
    red_counts = {}

    for b in blues:
        if b not in blue_counts:
            blue_counts[b] = 1
        else:
            blue_counts[b] += 1

    for r in reds:
        if r not in red_counts:
            red_counts[r] = 1
        else:
            red_counts[r] += 1

    max_count = 0
    for name, c in blue_counts.items():
        if name in red_counts:
            max_count = max(max_count, c - red_counts[name])
        else:
            max_count = max(max_count, c)
    return max_count

def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))

if __name__ == "__main__":
    [N] = string_to_int(inputs())
    blues = inputs(N)
    [M] = string_to_int(inputs())
    reds = inputs(M)
    ret = solve(blues, reds)
    print(ret)

import sys

sys.setrecursionlimit(4100000)

def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins

def solve(blues, reds):
    blue_counts = {}
    red_counts = {}

    for b in blues:
        if b not in blue_counts:
            blue_counts[b] = 1
        else:
            blue_counts[b] += 1

    for r in reds:
        if r not in red_counts:
            red_counts[r] = 1
        else:
            red_counts[r] += 1

    max_count = 0
    for name, c in blue_counts.items():
        if name in red_counts:
            max_count = max(max_count, c - red_counts[name])
        else:
            max_count = max(max_count, c)
    return max_count

def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))

if __name__ == "__main__":
    [N] = string_to_int(input())
    blues = inputs(N)
    [M] = string_to_int(input())
    reds = inputs(M)
    ret = solve(blues, reds)
    print(ret)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03408/Python/s858924667.py", line 41, in <module>
    [N] = string_to_int(inputs())
TypeError: inputs() missing 1 required positional argument: 'num_of_input'


from collections import Counter

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

M = int(input())
T = [input() for _ in range(M)]

s_counter = Counter(S)
t_counter = Counter(T)

result = 0

for k, v in s_counter:
    result = max(result, v - (t_counter[k] if t_counter[k] else 0))

print(result)

from collections import Counter

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

M = int(input())
T = [input() for _ in range(M)]

s_counter = Counter(S)
t_counter = Counter(T)

result = 0

for k, v in s_counter.items():
    result = max(result, v - (t_counter[k] if t_counter[k] else 0))

print(result if result > 0 else 0)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03408/Python/s472001842.py", line 14, in <module>
    for k, v in s_counter:
ValueError: too many values to unpack (expected 2)


from collections import defaultdict

n = int(input())
d = defaultdict()
for _ in range(n):
    s = input()
    d[s] += 1
m = int(input())
for _ in range(m):
    s = input()
    d[s] -= 1

answer = sorted([d[k] for k in d.keys()])[-1]
if answer < 0:
    answer = 0
print(answer)

from collections import defaultdict

n = int(input())
d = defaultdict(int)
for _ in range(n):
    s = input()
    d[s] += 1
m = int(input())
for _ in range(m):
    s = input()
    d[s] -= 1

answer = sorted([d[k] for k in d.keys()])[-1]
if answer < 0:
    answer = 0
print(answer)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03408/Python/s279183282.py", line 7, in <module>
    d[s] += 1
KeyError: 'apple'


def main(n, s: list, m, t: list):
    choices = set(s + t)

    ans = [0]

    for choice in choices:
        ans_t = 0
        for _s in s:
            if choice == _s:
                ans_t += 1
        for _t in t:
            if choice == _t:
                ans_t -= 1

        ans.append(ans_t)

    print(max(ans))

if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]
    m = int(input())
    t = [input() for _ in range(n)]

    main(n, s, m, t)

def main(n, s: list, m, t: list):
    choices = set(s + t)

    ans = [0]

    for choice in choices:
        ans_t = 0
        for _s in s:
            if choice == _s:
                ans_t += 1
        for _t in t:
            if choice == _t:
                ans_t -= 1

        ans.append(ans_t)

    print(max(ans))

if __name__ == "__main__":
    n = int(input())
    s = [input() for _ in range(n)]
    m = int(input())
    t = [input() for _ in range(m)]

    main(n, s, m, t)

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


def f(blue, red, ans):
    c = 0
    for i, b in enumerate(blue):
        for j, r in enumerate(red):
            if b[0] >= r[0] and b[1] >= r[1]:
                blue.pop(i)
                red.pop(j)
                c = max(c, f(blue, red, ans + 1))
                blue.insert(i, b)
                red.insert(j, r)
    return max(c, ans)

def main():
    N = int(input())
    red = [list(map(int, input().split())) for _ in range(N)]
    blue = [list(map(int, input().split())) for _ in range(N)]
    print(f(blue, red, 0))

main()

def main():
    N = int(input())
    red = sorted(
        [list(map(int, input().split())) for _ in range(N)],
        key=lambda x: x[1],
        reverse=True,
    )
    blue = sorted(
        [list(map(int, input().split())) for _ in range(N)], key=lambda x: x[0]
    )
    ans = 0
    for b in blue:
        for i, r in enumerate(red):
            if b[0] > r[0] and b[1] > r[1]:
                ans += 1
                red.pop(i)
                break
    print(ans)

main()


N = int(input())

red_points = [[int(i) for i in input().split()] for j in range(N)]

blue_points = [[int(i) for i in input().split()] for j in range(N)]

red_points.sort()
blue_points.sort()
count = 0
distance = 9999
for blue_point in blue_points:
    for red_point in red_points:
        if (blue_point[0] > red_point[0]) and (blue_point[1] > red_point[1]):
            if blue_point[1] - red_point[1] < distance:
                distance = blue_point[1] - red_point[1]
                tmp = red_point
    if tmp in red_points:
        red_points.remove(tmp)
        tmp.clear()
        count = count + 1
    distance = 9999
print(count)

N = int(input())

red_points = [[int(i) for i in input().split()] for j in range(N)]

blue_points = [[int(i) for i in input().split()] for j in range(N)]

red_points.sort()
blue_points.sort()
count = 0
distance = 9999
for blue_point in blue_points:
    tmp = [i for i in red_points if blue_point[0] > i[0] and blue_point[1] > i[1]]
    if tmp:
        for j in tmp:
            if (blue_point[1] - j[1]) < distance:
                distance = blue_point[1] - j[1]
                min_red = j
        count = count + 1
        red_points.remove(min_red)
        distance = 9999

print(count)

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03409/Python/s895373765.py", line 17, in <module>
    if tmp in red_points:
NameError: name 'tmp' is not defined


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

res = 0
for i in range(a, b + 1):
    i_str = str(i)
    if i_str == i_str[::-1]:
        res += 1
print(res)

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

res = 0
for i in range(a, b + 1):
    i_str = str(i)
    if i_str == i_str[::-1]:
        res += 1
print(res)

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


N, M = list(map(int, input().split()))
result = 0
pos = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)]
for i in range(N):
    for j in range(M):
        num = 0
        for p in pos:
            i_dest = i + p[0]
            j_dest = j + p[1]
            if 0 <= i_dest < N and 0 <= j_dest < M:
                num += 1
        if num % 2 != 0:
            result += 1
print(result)

N, M = list(map(int, input().split()))
result = 0
if N == 1 and M == 1:
    result = 1
elif N == 1:
    result = M - 2
elif M == 1:
    result = N - 2
else:
    result = (N - 2) * (M - 2)
print(result)


import numpy as np

n, k = map(int, input().split())
ans = 0
for m in range(k, n):
    nm = n - m
    sb = m + 1
    s = nm // sb
    ds = [nm // d + 1 for d in range(s, 0, -1)]
    ds = [sb] + ds + [n + 1]
    # print(m, nm, sb, s, ds)
    dd = np.diff(ds)
    pd = np.arange(s + 1, 0, -1) if m else np.arange(s, -1, -1)
    # print(dd, pd, dd * pd, sum(dd * pd))
    ans += sum(dd * pd)
print(ans)

import numpy as np

n, k = map(int, input().split())
ans = 0
for m in range(k, n):
    nm = n - m
    sb = m + 1
    s = nm // sb
    p = s + 1 if m else s
    ps = sb
    for d in range(s, 0, -1):
        ds = nm // d + 1
        co = ds - ps
        ans += co * p
        ps = ds
        p -= 1
    ans += n + 1 - ps

    # ds = [nm // d + 1 for d in range(s, 0, -1)]
    # ds = [sb] + ds + [n + 1]
    # # print(m, nm, sb, s, ds)
    # dd = np.diff(ds)
    # pd = np.arange(s + 1, 0, -1) if m else np.arange(s, -1, -1)
    # # print(dd, pd, dd * pd, sum(dd * pd))
    # ans += sum(dd * pd)
print(ans)


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

if "Y" in S:
    print("Four")
else:
    print("Three")

N = int(input())
S = list(map(str, input().split()))

if "Y" in S:
    print("Four")
else:
    print("Three")

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


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

print("Four" if "Y" in s else "Three")

n = int(input())
s = list(input().split())

print("Four" if "Y" in s else "Three")

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


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

def main():
    """Function."""
    n = int(input())
    s = list(map(str, input().split()))

    check = set()
    for i in range(n):
        check.append(s[i])

    if len(check) == 3:
        print("Three")
    else:
        print("Four")

if __name__ == "__main__":
    main()

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

def main():
    """Function."""
    n = int(input())
    s = list(map(str, input().split()))

    check = set()
    for i in range(n):
        check.add(s[i])

    if len(check) == 3:
        print("Three")
    else:
        print("Four")

if __name__ == "__main__":
    main()

Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03424/Python/s300014166.py", line 20, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03424/Python/s300014166.py", line 11, in main
    check.append(s[i])
AttributeError: 'set' object has no attribute 'append'


N = int(input())
s = list(map(input().split()))
print(len(set(s)))

N = int(input())
s = list(map(str, input().split()))
print(["Four", "Three"][len(set(s)) == 3])

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


import itertools

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

cnt = [0 for _ in range(5)]
for s in S:
    if s[0] == "M":
        cnt[0] += 1
    elif s[1] == "A":
        cnt[1] += 1
    elif s[2] == "R":
        cnt[2] += 1
    elif s[3] == "C":
        cnt[3] += 1
    elif s[4] == "H":
        cnt[4] += 1

ans = 0
for i, j, k in itertools.permutations(cnt, r=3):
    ans += i * j * k

print(ans)

import itertools

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

cnt = [0 for _ in range(5)]
for s in S:
    if s[0] == "M":
        cnt[0] += 1
    elif s[0] == "A":
        cnt[1] += 1
    elif s[0] == "R":
        cnt[2] += 1
    elif s[0] == "C":
        cnt[3] += 1
    elif s[0] == "H":
        cnt[4] += 1

ans = 0
for i, j, k in itertools.combinations(cnt, r=3):
    ans += i * j * k

print(ans)


from itertools import combinations

N = int(input())
s_li = []
for _ in range(N):
    s = input()
    if s[0] in "MARCH":
        s_li.append(s)
s_set = set(s_li)
# print(len(list(combinations(s_set, 3))))
ans = 0
for c in combinations(s_set, 3):
    initial = []
    for name in c:
        if name[0] in initial:
            break
        initial.append(name[0])
    else:
        ans += 1
print(ans)


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

import itertools

def main():
    N = int(input())
    S = [input() for _ in range(N)]

    march = []
    for s in S:
        if s[0] in ["M", "A", "R", "C", "H"]:
            march.append(s[0])

    result = []
    for comb in list(itertools.combinations(march, 3)):
        if comb[0] != comb[1] and comb[0] != comb[2] and comb[1] != comb[2]:
            result.append(comb)

    print(len(result))

if __name__ == "__main__":
    main()

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

from itertools import combinations

def main():

    N = int(input())

    count = {x: 0 for x in "MARCH"}

    for _ in range(N):
        s = input()[0]
        if s in count:
            count[s] += 1

    result = 0
    for a, b, c in combinations("MARCH", 3):
        result += count[a] * count[b] * count[c]

    print(result)

if __name__ == "__main__":
    main()


import re
import itertools

n = int(input())
ls = [input() for _ in range(n)]
new_ls = []
ans = 0

for name in ls:
    if re.match(r"[MARCH]", name):
        new_ls.append(name[:1])

comb_ls = list(itertools.combinations(new_ls, 3))

if new_ls:
    for comb in comb_ls:
        s = set(comb)
        if len(s) == 3:
            ans += 1
    print(ans)
else:
    print(0)
    quit()

import itertools

n = int(input())
ls = [input()[:1] for _ in range(n)]
ans = 0
cmb = list(itertools.combinations(list("MARCH"), 3))

for c in cmb:
    ans += ls.count(c[0]) * ls.count(c[1]) * ls.count(c[2])

print(ans)