Harryxun/stf_run huggingface dataset:
def resolve():
    # 最短経路問題で使われるアルゴリズムの１つ。
    # グラフ上の全ての頂点間の最短経路を探す
    # 負の閉路（辺の重みの和が負になるような閉路）がない限り、負の辺があっても使える。

    # 負の閉路を持つ場合は'NEGATIVE CYCLE'を、そうでない場合には(i,j)成分に
    # 頂点iから頂点jへの最短経路の距離を格納するdist_listをprintする関数
    def warshall_floyd(v_num, e_num, dist_lst):

        # 負の閉路を持つか

        # 頂点iから頂点jへの経路と、頂点kを経由した場合の経路とを比較して
        # よりコストの合計が小さい方を配列に入れる動的計画法
        for k in range(v_num):
            for i in range(v_num):
                for j in range(v_num):
                    # i→k→jがつながっててしかもi→jルートよりもイケてるなら更新
                    if dist_lst[i][k] != INF and dist_lst[k][j] != INF:
                        if dist_lst[i][j] > dist_lst[i][k] + dist_lst[k][j]:
                            dist_lst[i][j] = dist_lst[i][k] + dist_lst[k][j]

        ans=[0]*N
        for lst in dist_lst:
            for i in range(len(lst)):
                ans[lst[i]]+=1

        for j in range(1,N):
            print(int(ans[j]))

    N,X,Y=map(int,input().split())
    # 頂点の数と辺の数
    v_num, e_num = N,N

    # 配列dist_lst[a][b]には頂点a,b間の辺のコストを入れておき、
    # a=bの時は0を、a,b間の辺が存在しないときはINFを入れておく。
    INF = 10 ** 20
    dist_lst = [[INF] * v_num for _ in range(v_num)]

    for i in range(v_num-1):
        dist_lst[i][i+1] = 1
    dist_lst[X-1][Y-1] = 1


    for v in range(v_num):
        dist_lst[v][v] = 0

    warshall_floyd(v_num, e_num, dist_lst)





resolve()

### FIXED CODE ###

# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np

def resolve():
    from heapq import heappush, heappop

    # 長点数V、直接移動先とコストを記したリストg、スタート地点rをとって、
    # rからiに行くまでの最低コストがdist[i]であることを意味するリストdistを返す関数
    def dijkstra(V, g, r):

        dist = [INF] * V
        queue = [(0, r)]  # queueの要素(c,v)は、コストcで直接vに行けることを意味する
        dist[r] = 0  # スタート地点rにはコスト0で行ける

        while queue:
            c, v = heappop(queue)
            if dist[v] < c:  # すでに記録されているコストの方が小さいので更新不要
                continue
            for cost, t in g[v]:
                if dist[v] + cost < dist[t]:
                    dist[t] = dist[v] + cost
                    heappush(queue, (dist[t], t))

        return dist

    N,X,Y=map(int,input().split())
    V, E= N,N
    g = [[] for i in range(V)]

    for i in range(N-1):
        g[i].append((1, i+1))
        g[i+1].append((1, i))  # g[s]の要素(cost,t)はsからコストcostでtに直接行けることを意味する
        # g[s]の要素(cost,t)はsからコストcostでtに直接行けることを意味する
    g[X-1].append((1, Y-1))
    g[Y-1].append((1, X-1))

    INF = 10 ** 10
    ans = [0] * N

    for r in range(N):
        for i in dijkstra(V, g, r):
            if i<INF:
                ans[i]+=1

    for j in range(1, N):
        print(ans[j] // 2)


resolve()
from collections import deque
n=int(input())
A=[]
for i in range(n):
    a=input()
    if a in A:
        A.append(a)
    else:
        A.remove(a)
print(len(A))

### FIXED CODE ###

n=int(input())
A=set()
for i in range(n):
    a=input()
    if a in A:
        A.remove(a)
    else:
        A.add(a)
print(len(A))
s,t = input().split()
a,b = map(int,input().split())
u = input()

if u = s:
    print(a-1,b)
else:
    print(a,b-1)


### FIXED CODE ###

s,t = input().split()
a,b = map(int,input().split())
u = input()

if u == s:
    print(a-1,b)
else:
    print(a,b-1)
N = int(input())
ex_t, ex_x, ex_y = 0, 0, 0
count = 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-ex_x) + abs(y-ex_y) <= abs(t-ex_t) and t%2 = (x+y)%2:
        count += 1
    ex_t, ex_x, ex_y = t, x, y
print("Yes" if count == N else "No")

### FIXED CODE ###

N = int(input())
ex_t, ex_x, ex_y = 0, 0, 0
count = 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-ex_x) + abs(y-ex_y) <= abs(t-ex_t) and t%2 == (x+y)%2:
        count += 1
    ex_t, ex_x, ex_y = t, x, y
print("Yes" if count == N else "No")
n = int(input())
nlist = [input() for i in range(n)]
m = int(input())
mlist = [input() for i in range(m)]

for i in range mlist:
    if i in nlist:
        nlist.remove(i)

def maxCOUNT( lis ):
  '''
  与えられたリストの中に、最も多く存在する要素を返す
  (最大の数の要素が複数ある場合、pythonのsetで先頭により近い要素を返す)
  '''
  L = lis[:]#copy
  S = set(lis)
  S = list(S)
  MaxCount=0

  for elem in S:
    c=0
    while elem in L:
      ind = L.index(elem)
      foo = L.pop(ind)
      c+=1
    if c>MaxCount:
      MaxCount=c
  return MaxCount

print(maxCOUNT(nlist))
    


### FIXED CODE ###

n = int(input())
nlist = [input() for i in range(n)]
m = int(input())
mlist = [input() for i in range(m)]
 
for i in mlist:
    if i in nlist:
        nlist.remove(i)
 
def maxCOUNT( lis ):
  '''
  与えられたリストの中に、最も多く存在する要素を返す
  (最大の数の要素が複数ある場合、pythonのsetで先頭により近い要素を返す)
  '''
  L = lis[:]#copy
  S = set(lis)
  S = list(S)
  MaxCount=0
 
  for elem in S:
    c=0
    while elem in L:
      ind = L.index(elem)
      foo = L.pop(ind)
      c+=1
    if c>MaxCount:
      MaxCount=c
  return MaxCount
 
print(maxCOUNT(nlist))
import heapq

n, m = map(int, input().split())
al = map(int, input().split())
h = []

for a in al:
    heapq.heappush(h, a)

for i in range(m):
    b, c = map(int, input().split())
    for j in range(b):
        heapq.heappush(h, c)


[heapq.heappop(h) for i in range(n)]

sum = 0
for i in range(n):
    sum += heapq.heappop(h)

print(sum)

### FIXED CODE ###

import heapq


n, m = map(int, input().split())
al = map(int, input().split())
h = []
ad = {}
for a in al:
    if a not in ad:
        ad[a] = 1
    else:
        ad[a] += 1
    

for i in range(m):
    b, c = map(int, input().split())
    
    if c not in ad:
        ad[c] = b
    else:
        ad[c] += b


keys = list( ad.keys() )
keys.sort(reverse=True)



for k in keys:
    for i in range(ad[k]):
        heapq.heappush(h, k)

        if len(h) >= n:
            break


ans = sum( heapq.nlargest(n, h) )
print(ans)
A,B,C,D = map( int,input().split() )
while A > 0 and c > 0:
    C -= B
    if C <= 0:
        print( 'Yes' )
        exit()
    A -= D 
    if A <= 0:
        print( 'No' )
        exit()


### FIXED CODE ###

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

while A > 0 and C > 0:
    C -= B
    if C <= 0:
        print("Yes")
        exit()
    A -= D
    if A <= 0:
        print("No")
        exit()
from string import*
from itertools import*
b = ascii_lowercase
s = input()
l = len(s)
if l < 26:
    print(s + sorted(set(b) - set(s))[0])
else:
    d = [p,*len(list(k)) for p, k in groupby([i < j for i, j in zip(s[-1::-1], t[-2::-1])])][0] - 2
    print(-(d < -26) or s[:d] + sorted(set(s[d+1:]) - set(b[:ord(s[d]) - 97]))[0])

### FIXED CODE ###

#!/usr/bin/env python3
from string import*
from itertools import*
b = ascii_lowercase
s = input()
l = len(s)
if l < 26:
    print(s + sorted(set(b) - set(s))[0])
else:
    t = s[::-1]
    a = [(p, len(list(k))) for p, k in groupby([i < j for i, j in zip(t, t[1:])])][0]
    d = - a[0]*a[1] - 2
    print(-(d < -26) or s[:d] + sorted(set(s[d+1:]) - set(b[:ord(s[d]) - 97]))[0])
W, H, x, y, r = map(int, raw_input().split))
 
if 0 <= x-r and x+r <= W:
 if 0 <= y-r and y+r <= H:
  print "Yes"
else:
 print "No"

### FIXED CODE ###

W, H, x, y, r = map(int, raw_input().split())
 
if r <= x and x + r <= W and r <= y and y + r <= H:
 print 'Yes'
else:
 print 'No'
import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    a * (-e*y+f) / d + b * y = c
    -x = (e*y-f) / d
    print (round(x, 3)+' '+round(y, 3))


### FIXED CODE ###

import sys
for e in sys.stdin:
    a, b, c, d, e, f = map(int, e.split())
    y=(c*d-a*f)/(b*d-a*e)
    x = (c-b*y)/a
    #print (str(round(x, 3))+' '+str(round(y, 3)))#dont int+str
    print("%.3f %.3f"%(x,y))
[H, N] = [int(x) for x in input().split()]
A = list(map(int, input().split()))
count = 0

arr = sorted(A, reverse=True)
while N > 0:
    arr.pop(0)
    N -= 1
for x in arr:
    count += x

print(count)

### FIXED CODE ###

N, K = map(int, input().split())
H = map(int,input().split())
print(sum(sorted(H, reverse=True)[K::]))
from fractions import gcd
from functools import reduce

def find_lcm(denominators):
    return reduce(lambda a,b: a*b // gcd(a,b), denominators)

def solve(nums):
    modula = 10**9 + 7
    lcm = find_lcm(nums)

    bs = []
    for n in nums:
        bs.append((lcm // n) % modula)

    print(sum(bs) % modula)

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


N = iin()
nums = iln()
solve(nums)


### FIXED CODE ###

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


def solve(N, M):
  print("Yes" if N == M else "No")
  
  
N, M = iln()
solve(N, M)
N, x, y = [int(i) for i in input().split()]

cnt = [0] * N
for i in range(1, N+1):
  for j in range(i+1, N+1):
    temp = min(abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x))
    cnt[temp] += 1

for i in range(1, N):
  print(cnt[i])

### FIXED CODE ###

s = input()
print("Yes" if s[2] == s[3] and s[4] == s[5] else "No")
x = int(input())

print(x)

print("Hello World!")

### FIXED CODE ###

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

if x[0]<9 and x[1]<9:
	print("Yay!")
else:
	print(":(")
import sys, io, os, re
import bisect
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque, defaultdict
from fractions import gcd
from functools import reduce

def array1(n): return [0] * n
def array2(n, m): return [[0] * m for x in range(n)]
def array3(n, m, l): return [[[0] * l for y in xrange(m)] for x in xrange(n)]

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

mod = 1000000007

N = n1()
(A, B) = ([], [])
for i in range(N):
    a, b = nn()
    if a < 0: a *= -1; b *= -1
    g = gcd(a, b)
    if g < 0: g *= -1
    A.append(a // g)
    B.append(b // g)

d = defaultdict(int)
for i in range(N):
    d[(A[i], B[i])] += 1

ans = 1
while len(d) > 0:
    #print(d, ans)
    (x, y), n1 = list(d.items())[0]
    d.pop((x, y))
    if y < 0: x *= -1; y *= -1
    if (y, -x) in d:
        n2 = d.pop((y, -x))
        ans = (ans * ((2**n1 -1 + 2**n2 - 1) % mod + 1)) % mod
    else:
        ans = (ans * (2**n1 % mod)) % mod

print(ans-1)


### FIXED CODE ###


import sys, io, os, re
import bisect
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque, defaultdict
from fractions import gcd
from functools import reduce

def array1(n): return [0] * n
def array2(n, m): return [[0] * m for x in range(n)]
def array3(n, m, l): return [[[0] * l for y in xrange(m)] for x in xrange(n)]

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

mod = 1000000007

N = n1()
(A, B) = ([], [])
for i in range(N):
    a, b = nn()
    g = gcd(a, b)
    if g != 0: a //= g; b //=g
    A.append(a)
    B.append(b)

d = defaultdict(int)
for i in range(N):
    d[(A[i], B[i])] += 1

ans = 1
n = 0
if (0, 0) in d:
    n = d.pop((0, 0))

while len(d) > 0:
    #print(d, ans)
    (x, y), n1 = d.popitem()
    if y < 0: x *= -1; y *= -1

    n2 = 0
    if (y, -x) in d: n2 += d.pop((y, -x))
    if (-y, x) in d: n2 += d.pop((-y, x))

    ans = (ans * ((pow(2,n1,mod) -1 + pow(2,n2,mod) - 1) % mod + 1)) % mod

print((ans-1+n)%mod)
import bisect
import time
import heapq


# N: バイトの種類
# M: 日数の最大
N,M = map(int,input().split(" "))

# A 日数
# b バイト代
A = []
B = []
for _ in range(N):
    a,b = map(int,input().split(" "))
    A.append(a)
    B.append(-b)

# 日数でソート
ind_sorted = sorted(range(N), key = lambda x:A[x])
tmp_a = 0
tmp_b_ls = [0]
money = 0
tmp_ind = 0
for i in range(N):
    if A[ind_sorted[i]] > M:
        break
    if tmp_a != A[ind_sorted[i]]:
        # 空いている日数
        print(d)
        print(tmp_b_ls)
        d = A[ind_sorted[i]]-tmp_a
        for _ in range(d):
            if tmp_b_ls == []:
                break
            money -= heapq.heappop(tmp_b_ls)
        tmp_a = A[ind_sorted[i]]
    heapq.heappush(tmp_b_ls,B[ind_sorted[i]])

d = M+1-tmp_a
print(d)
print(tmp_b_ls)

for _ in range(d):
    if tmp_b_ls == []:
        break
    money -= heapq.heappop(tmp_b_ls)
print(money)

### FIXED CODE ###

import bisect
import time
import heapq


# N: バイトの種類
# M: 日数の最大
N,M = map(int,input().split(" "))

# A 日数
# b バイト代
A = []
B = []
for _ in range(N):
    a,b = map(int,input().split(" "))
    A.append(a)
    B.append(-b)

# 日数でソート
ind_sorted = sorted(range(N), key = lambda x:A[x])
tmp_a = 0
tmp_b_ls = [0]
money = 0
tmp_ind = 0
for i in range(N):
    if A[ind_sorted[i]] > M:
        break
    if tmp_a != A[ind_sorted[i]]:
        # 空いている日数
        # print(d)
        # print(tmp_b_ls)
        d = A[ind_sorted[i]]-tmp_a
        for _ in range(d):
            if tmp_b_ls == []:
                break
            money -= heapq.heappop(tmp_b_ls)
        tmp_a = A[ind_sorted[i]]
    heapq.heappush(tmp_b_ls,B[ind_sorted[i]])

d = M+1-tmp_a
# print(d)
# print(tmp_b_ls)

for _ in range(d):
    if tmp_b_ls == []:
        break
    money -= heapq.heappop(tmp_b_ls)
print(money)
N, Q = map(int, input().split())
ki = [[[],0] for i in range(N)]
result = [0]*N

def dfs(i, num, parent):
    num_tmp = num+ki[i][1]
    result[i] = num_tmp
    if not ki[i][0]:
        return
    for j in ki[i][0]:
        if j == parent:
            continue
        dfs(j, num_tmp, i)
    return

for i in range(N-1):
    a, b = map(int, input().split())
    ki[a-1][0].append(b-1)
    ki[b-1][0].append(a-1)

for i in range(Q):
    p, x = map(int, input().split())
    ki[p-1][1] += x

dfs(0, 0, -1)
print(*result)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
n,q=[int(_) for _ in input().split()]
ki=[[] for _ in range(n)]
ans=[0]*n
 
def dfs(numQ,parent):
    for child in ki[numQ]:
        if child==parent:
            continue
        ans[child]+=ans[numQ]
        dfs(child,numQ)
 
for i in range(n-1):
    a,b=[int(_) for _ in input().split()]
    ki[a-1].append(b-1)
    ki[b-1].append(a-1)
 
for i in range(q):
    p,x=[int(_) for _ in input().split()]
    ans[p-1]+=x
 
dfs(0,-1)
print(*ans)
#!/usr/bin/env python3
import sys

def dfs(idx, con, visited):
    visited[idx] = True
    max_depth = 0
    max_len = 0
    depths = []
    if idx > len(con):
        return max_depth, max_len
    for v in con[idx]:
        if v < len(visited) and not visited[v]:
            max_d, max_l = dfs(v, con, visited)
            max_len = max(max_len, max_l)
            depths.append(max_d + 1)
    if len(depths) > 0:
        depths.sort(reverse=True)
        max_depth = depths[0]
        if len(depths) > 1:
            max_len = max(max_len, depths[0] + depths[1])
        else:
            max_len = max(max_len, depths[0])
    visited[idx] = False
    return max_depth, max_len


def solve(N: int, A: "List[int]", B: "List[int]"):
    con = [[] for _ in range(N)]
    for i in range(len(A)):
        a = A[i] - 1
        b = B[i] - 1
        con[a].append(b)
        con[b].append(a)
    #print(con)
    visited = [False] * N
    max_depth, max_len = dfs(0, con, visited)
    #print(max_len)
    if (max_len + 1) % 3 == 2:
        ret = 'Second'
    else:
        ret = 'First'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)

def dfs(idx, con, visited):
    visited[idx] = True
    max_depth = 0
    max_len = 0
    depths = []
    if idx >= len(con):
        return max_depth, max_len
    for v in con[idx]:
        if v < len(visited) and not visited[v]:
            max_d, max_l = dfs(v, con, visited)
            max_len = max(max_len, max_l)
            depths.append(max_d + 1)
    if len(depths) > 0:
        depths.sort(reverse=True)
        max_depth = depths[0]
        if len(depths) > 1:
            max_len = max(max_len, depths[0] + depths[1])
        else:
            max_len = max(max_len, depths[0])
    visited[idx] = False
    return max_depth, max_len


def solve(N: int, A: "List[int]", B: "List[int]"):
    con = [[] for _ in range(N)]
    for i in range(len(A)):
        a = A[i] - 1
        b = B[i] - 1
        con[a].append(b)
        con[b].append(a)
    #print(con)
    visited = [False] * N
    max_depth, max_len = dfs(0, con, visited)
    #print(max_len)
    if (max_len + 1) % 3 == 2:
        ret = 'Second'
    else:
        ret = 'First'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)

if __name__ == '__main__':
    main()
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

Alice = a[0::2]
Bob = a[1::2]

print(Alice - Bob)

### FIXED CODE ###

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

Alice = sum(a[::2])
Bob = sum(a[1::2])

print(Alice - Bob)
X,Y = map(str.input().split())
XY = ["A","B","C","D","E","F"]
for i in range(5):
    if X == XY[i]:
        XX = i
    if Y == XY[i]:
        YY = i
if XX == YY:
    print("=")
elif XX > YY:
    print(">")
else:
    print("<")
    

### FIXED CODE ###

X,Y = map(str,input().split())
XY = ["A","B","C","D","E","F"]
for i in range(6):
    if X == XY[i]:
        XX = i
    if Y == XY[i]:
        YY = i
if XX == YY:
    print("=")
elif XX > YY:
    print(">")
else:
    print("<")
def main():
    A, B = map(int, input().split())

    price = (int)(
        B   if A >= 13 else
        B/2 if A >= 6 else
        0)

    return price 


if __name__ == '__main__'
    print(main())

### FIXED CODE ###

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

price = (int)(
    B   if A >= 13 else
    B/2 if A >= 6 else
    0)

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

x=str(a).count("1")
print(x)






### FIXED CODE ###

from sys import stdin
a=stdin.readline().rstrip()
x=a.count("1")
print(x)
S = input()
YMD = S/split('/')
MD = int(''.join(YMD[1:]))

ans = 'Heisei' if MD <= 430 else 'TBD'
print(ans)

### FIXED CODE ###

S = input()
YMD = S.split('/')
MD = int(''.join(YMD[1:]))

ans = 'Heisei' if MD <= 430 else 'TBD'
print(ans)
data = input().split()
a = data[0]
b = data[1]
print (int(a) * int(b), 2 * (int(a) + int (b))

### FIXED CODE ###

data = input().split()
a = data[0]
b = data[1]
print(int(a) * int(b), 2 * (int(a) + int(b)))
# -*- coding: utf-8 -*-
import math

N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

divorces = make_divisors(math.factorial(N))
print(len(divorces)%(10**9 + 7))

### FIXED CODE ###

# -*- coding: utf-8 -*-
import math

import math
#試し割法
def trial_division(n):
    #素因数を格納するリスト
    factor = [0]
    #2から√n以下の数字で割っていく
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            if(num != 1):
                factor.append(num)
    #リストが空ならそれは素数
    if not factor:
        return n
    else:
        factor.append(n)
        return factor

def main():
    N = int(input())
    result = 1
    divisor = []

    for i in range(1, N+1):
        divisor.extend(trial_division(i))

    for i in range(2,N+1):
        result = result*(divisor.count(i)+1)

    print(result % (10 ** 9 + 7))


if __name__ == "__main__":
    main()
def stdinput():
    from sys import stdin
    return stdin.readline().strip()

def main():
    n = int(stdinput())
    A = list(sorted(map(int, stdinput().split(' '))))
    q = int(stdinput())
    M = list(map(int, stdinput().split(' ')))

    for m in M:
        if check(m, A):
            print('yes')
        else:
            print('no')

def check(m, A):
    # print(f'{m}:{A}')
    if m == 0:
        return True
    elif len(A) == 0:
        return False
    elif m > 0:
        for i, a in enumerate(A):
            if check(m-a, A[:i] + A[i+1:]):
                return True
    return False

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')


### FIXED CODE ###

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

def main():
    from itertools import combinations
    n = int(stdinput())
    *A, = map(int, stdinput().split(' '))
    q = int(stdinput())
    *M, = map(int, stdinput().split(' '))

    all_canditee = set([sum(c) for i in range(1, n+1) for c in combinations(A, i)])

    # print(A)
    # print(all_canditee)

    for m in M:
        if m in all_canditee:
            print('yes')
        else:
            print('no')

# can not pass 9/10
def check(m, a, A):
    for i, next_a in enumerate(A):
        this_a = a + next_a
        if this_a == m:
            return True
        elif this_a < m:
            if check(m, this_a, A[i+1:]):
                return True
    return False

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')
K = int(input("multiple of: "))
A = int(input("From A: "))
B = int(input("To B: "))
word = "NG"
for i in range(A, B+1):
    if i % K == 0:
        word = "OK"
print(word)


### FIXED CODE ###

K = int(input())
A, B = map(int, input().split())
word = "NG"
for i in range(A, B+1):
    if i % K == 0:
        word = "OK"
print(word)
import math
S = int(input())
X1 = 0
Y1 = 0
X2 = 0
Y2 = 0
X3 = 0
Y3 = 0
if  S <= 10 ** 9:
    X2 = S
    Y3 = 1
else:
    X2 = math.sqrt(S)//1
    Y3 = X2
    s = X2 ** 2  - S #残りの面積
    for i in range(1, int(math.sqrt(s) + 1)):
        if s%i == 0 and s%i <= 10 ** 9 and i <= 10 ** 9:
                X3 = i
                Y2 = s
                break


print (X1, Y1, X2, Y2, X3, Y3)


### FIXED CODE ###

import math
S = int(input())
X1 = 0
Y1 = 0
X2 = 0
Y2 = 0
X3 = 0
Y3 = 0
if  S <= 10 ** 9:
    X2 = S
    Y3 = 1
elif S == 1000000000000000000:
    X2 = int(math.sqrt(S))
    Y3 = X2
else:
    X2 = int(math.sqrt(S) + 1)
    Y3 = X2
    s = X2 ** 2  - S #残りの面積
    for i in range(1, int(math.sqrt(s) + 1)):
        if s%i == 0 and s//i <= 10 ** 9 and i <= 10 ** 9:
            X3 = i
            Y2 = s//i
            break

print (X1, Y1, X2, Y2, X3, Y3)
num, jet = (input().split())

height = list(map(int, input().split()))
ans = 0

for n in height:
    if n >= int(jet):
        ans += 1
    else:
        continue

print(ans)



### FIXED CODE ###

n = int(input())


if n % 2 == 0:
    print(0.5)
else:
    print((n//2 + 1)/n)
ab = [int(n) for n in input().split()]

S = ab[0]*ab[1]
L = 2*ab[0] + 2*ab[1]

print(" ".join(str,map([S,L])))



### FIXED CODE ###

ab = [int(n) for n in input().split()]
 
S = ab[0]*ab[1]
L = 2*ab[0] + 2*ab[1]
 
print(" ".join(map(str,[S,L])))