Harryxun/stf_run huggingface dataset:
import heapq
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
x_range = []
cut = [0]
count = 0
for i in range(m-1):
    x_range.append(abs(x[i]-x[i+1]))
h = heapq.nlargest(n-1,x_range)


for i in h:
    cut.append(x_range.index(i)+1)
cut.append(len(x))

if n>=m:
    print(0)
else:
    for i in range(len(cut)-1):
        sum_range = x[cut[i]:cut[i+1]]
        count += abs(sum_range[0]-sum_range[len(sum_range)-1])
print(count)


### FIXED CODE ###

n,m = map(int,input().split())
x = list(map(int,input().split()))
dist = []
x.sort()
if n > m:
    print(0)
else:
    for i in range(m-1):
        dist.append(x[i+1] -x[i])
    dist.sort()
    print(sum(dist[:m-n]))
def intinput(): return map(int,input().split())

def ab(i):
    global c,l,x
    while len(l[i])>0:
        try:
            l[l[i][0]].remove(i)
        except:
            pass
        x[l[i][0]]=c.pop(0)
        ab(l[i][0])
        l[i].pop(0)
        
    return

n=int(input())
l = [[] for _ in range(n+1)]
for i in range(n-1):
    a,b=intinput()
    l[a].append(b)
    l[b].append(a)
c = list(intinput())
c.sort(reverse=1)
x = [0 for _ in range(n+1)]
x[1]=c.pop(0)
for i in range(1,n+1):
    ab(i)
print(sum(x[2:]))
f = ""
q= len(x[1:])
for i in range(q):
    if i != q-1:
        f += str(x[i+1])+" "
    else:
        f += str(x[i+1])
print(f)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000) 

def intinput(): return map(int,input().split())

def ab(i):
    global c,l,x
    while len(l[i])>0:
        x[l[i][0]] = c.pop(0)
        l[l[i][0]].remove(i)
        ab(l[i][0])
        l[i].pop(0)
    return

n=int(input())
l = [[] for _ in range(n+1)]
for i in range(n-1):
    a,b=intinput()
    l[a].append(b)
    l[b].append(a)
c = list(intinput())
c.sort(reverse=1)
x = [0 for _ in range(n+1)]
x[1]=c.pop(0)
for i in range(1,n+1):
    ab(i)
print(sum(x[2:]))
f = ""
q= len(x[1:])
for i in range(q):
    if i != q-1:
        f += str(x[i+1])+" "
    else:
        f += str(x[i+1])
print(f)
N,M=map(int,input().split())
poti=list(input().split())
poti= [ int(s) for s in poti ]
poti=sorted(poti)
sa=[]
for i in range(0,M-1):
    a=poti[i+1]-poti[i]
    sa.append(a)
#print(sa)
if len(sa)!=0:
    while len(sa)!=M-N:
        maxi=max(sa)
        sa.remove(maxi)

    print(sum(sa))

else:
    print(0)
#print(poti)

### FIXED CODE ###

N,M=map(int,input().split())
poti=list(input().split())
poti= [ int(s) for s in poti ]
poti=sorted(poti)
sa=[]
if N>=M:
    print(0)
else:
    for i in range(0,M-1):
        a=poti[i+1]-poti[i]
        sa.append(a)


    if len(sa)!=0:  
        sa=sorted(sa)
        sa=sa[0:(M-1)-(N-1)]
        print(sum(sa))
    else:
        print(0)
import math
from functools import reduce
def gcds(*numbers):
    return reduce(math.gcd, numbers)

def resolve():
    N = int(input())
    As = list(map(int, input().split(" ")))
    if N == 2:
        return max(As)

    gcdmax = 0
    for i in range(N):
        gcd = gcds(*As[:i], *As[i+1:])
        gcdmax = max(gcdmax, gcd)

    return gcdmax

if '__main__' == __name__:
    print(resolve())

### FIXED CODE ###

import math
from fractions import gcd
from functools import reduce
def gcds(*numbers):
    return reduce(gcd, numbers)

def resolve():
    N = int(input())
    As = list(map(int, input().split(" ")))
    
    left = [0] * (N + 1)
    right = [0] * (N + 1)
    for i in range(N):
        left[i + 1] = (gcd(left[i],As[i]))
        right[N - 1 - i] = (gcd(right[(N - 1) - i + 1], As[(N - 1) - i]))

    gcdmax = 0
    for i in range(N):
        gcdmax = max(gcdmax, gcd(left[i], right[i+1]))
    return gcdmax

if '__main__' == __name__:
    print(resolve())
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, m = readmi()
a = deque([0] )* (n + 2)
for i in range(m):
    x,y = readmi()
    a[x] = 1
    a[y + 1] = -1
for i in range(n + 1):
    a[i + 1] += a[i]
print(a.count(max(a)))
    


### FIXED CODE ###

# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

n, m = map(int, input().split())
a = [0] * (n + 2)
r = defaultdict(int)
for i in range(m):
    x,y = map(int,input().split())
    a[x - 1] += 1
    a[y] += -1

for i in range(n + 1):
    a[i + 1] += a[i]
count = 0
flg = True
for i in range(n):
    if a[i] >= m:
        count += 1
print(count)
import sys
input = sys.stdin.readline

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

from collections import defaultdict
G = defaultdict(list)

for _ in range(n-1):
    u,v = map(int,input().split())
    G[u-1].append(v-1)
    G[v-1].append(u-1)

from bisect import bisect
ansl = [0 for i in range(n)]
dp = [float("inf") for _ in range(n+1)]
dp[0] = -1
used = [0 for i in range(n)]
used[0] = 1


stack = []
def dfs(pos, dp):
    idx = bisect(dp, al[pos] - 1)
    stack.append((idx, dp[idx]))
    dp[idx] = min(al[pos], dp[idx])
    ansl[pos] = bisect(dp,10**18) - 1
    for v in G[pos]:
        if used[v] == 0:
            used[v] = 1
            dfs(v, dp)
            idx, k = stack.pop()
            dp[idx] = k


dfs(0, dp)
flag = False
for i in range(n):
    print(ansl[i])




### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

import sys
input = sys.stdin.readline

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

from collections import defaultdict
G = defaultdict(list)

for _ in range(n-1):
    u,v = map(int,input().split())
    G[u-1].append(v-1)
    G[v-1].append(u-1)

from bisect import bisect
ansl = [0 for i in range(n)]
dp = [float("inf") for _ in range(n+1)]
dp[0] = -1
used = [0 for i in range(n)]
used[0] = 1


stack = []
def dfs(pos):
    idx = bisect(dp, al[pos] - 1)
    stack.append((idx, dp[idx]))
    dp[idx] = min(al[pos], dp[idx])
    ansl[pos] = bisect(dp, 10**18) - 1
    for v in G[pos]:
        if used[v] == 0:
            used[v] = 1
            dfs(v)
            idx, k = stack.pop()
            dp[idx] = k


dfs(0)
flag = False
for i in range(n):
    print(ansl[i])
from math import gcd

A, B, C, D = map(int, input().split())
lcm = C*D//gcd(C, D)


divC = B//C - (A-1)//C
divD = B//D - (A-1)//D
divL = B//lcm - (A-1)//lcm

print((B-A+1) - divC - divD + divL)


### FIXED CODE ###

from fractions import gcd

A, B, C, D = map(int, input().split())
lcm = C*D//gcd(C, D)


divC = B//C - (A-1)//C
divD = B//D - (A-1)//D
divL = B//lcm - (A-1)//lcm

print((B-A+1) - divC - divD + divL)
N, M = map(int, input().split())
l1 = []
l2 = []
ans = 0
rest = M
for i in N+1:
	l1[i],l2[i]  = map(int, input().split())

while true:
	min_index = l1.index(min(l1))
	ans += min(l1) * l2[min_index]
	rest -= l2[min_index]
	if rest == 0:
		break
	l1.pop(min_index)

print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))
X.sort(key=lambda x: x[0])
i = 0
num = 0
ans = 0
while i <= N - 1:
    num += X[i][1]
    ans += X[i][0] * X[i][1]
    if num > M:
        ans -= X[i][0] * (num - M)
        break
    i += 1
print(ans)
#import sys
#input = sys.stdin.readline
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
x,y = zip(*xy)

#import random
#N = 20000
#x = [random.randint(0,0) for i in range(N)]
#y = [random.randint(0,0) for i in range(N)]

class UnionFind:
    def __init__(self,nodes):
        self.parents = {node : node for node in nodes}
    def root(self,x):
        if x == self.parents[x]:
            return x
        else:
            rt = self.root(self.parents[x])
            self.parents[x] = rt
            return rt
    def find(self,x,y):
        return self.root(x) == self.root(y)
    def union(self,x,y):
        self.parents[self.root(x)] = self.root(y)

xi = [(x,i+1) for i,x in enumerate(x)]
yi = [(y,i+1) for i,y in enumerate(y)]

xi.sort()
yi.sort()

diffx = [(x1-x0,i0,i1) for (x0,i0),(x1,i1) in zip(xi,xi[1:])]
diffy = [(y1-y0,i0,i1) for (y0,i0),(y1,i1) in zip(yi,yi[1:])]

diffx.extend(diffy)
diffx.sort()

uf = UnionFind(list(range(1,N+1)))
ans = 0
for d,i0,i1 in diffx:
    if not uf.find(i0,i1):
        ans += d
        uf.union(i0,i1)
print(ans)




### FIXED CODE ###

from collections import defaultdict
import sys
from heapq import heappush, heappop
input = sys.stdin.readline
N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
x,y = zip(*xy)

#import random
#N = 200000
#x = [random.randint(0,10**9) for i in range(N)]
#y = [random.randint(0,10**9) for i in range(N)]

def Prim(g,cost):
    h = []
    N = len(g.keys())
    visited = [False]*(N+1)
    visited[1] = True
    v = 1
    for nv in g[v]:
        heappush(h, (cost[(v,nv)], (v,nv)))
    res = []
    d = 0
    while True:
        c, (v,nv) = heappop(h)
        if visited[nv]:
            continue
        res.append((v,nv))
        d += c
        if len(res) == N-1:
            break
        visited[nv] = True
        for nnv in g[nv]:
            if not visited[nnv]:
                heappush(h, (cost[(nv,nnv)], (nv,nnv)))
    return res, d

xi = [(x,i+1) for i,x in enumerate(x)]
yi = [(y,i+1) for i,y in enumerate(y)]

xi.sort()
yi.sort()

diffx = [(x1-x0,i0,i1) for (x0,i0),(x1,i1) in zip(xi,xi[1:])]
diffy = [(y1-y0,i0,i1) for (y0,i0),(y1,i1) in zip(yi,yi[1:])]

g = defaultdict(set)
cost = defaultdict(lambda : 10**10)
for d,i0,i1 in diffx:
    g[i0].add(i1)
    g[i1].add(i0)
    cost[(i0,i1)] = min(cost[(i0,i1)],d)
    cost[(i1,i0)] = min(cost[(i0,i1)],d)
for d,i0,i1 in diffy:
    g[i0].add(i1)
    g[i1].add(i0)
    cost[(i0,i1)] = min(cost[(i0,i1)],d)
    cost[(i1,i0)] = min(cost[(i0,i1)],d)

res,ans = Prim(g,cost)
print(ans)
n = int(input())
m = 0
for i in range(n):
  a, b = input().split(' ')
  a = int(a)
  if b == 'BTC':
    a = 380000*a
  m += a
print(m)

### FIXED CODE ###

n = int(input().rstrip())
m = 0
for i in range(n):
  a, b = input().rstrip().split(' ')
  a = float(a)
  if b == 'BTC':
    a = 380000*a
  m += a
print(m)
#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(H: int, W: int, s: "List[str]"):
    count = 0
    numofshirp = 0
    for s_ in s:
        numofshirp += s_.count("#")

    #padding
    edge = ["".join(["."] * (W + 2))]
    for i, si in enumerate(s):
        s[i] = "".join("."+si+".")
    s.extend(edge)
    edge.extend(s)

    for i, ei in enumerate(edge):
        for j, eij in enumerate(ei):
            if eij == "#" and i > 0 and j > 0:
                if "#" in (edge[i - 1][j], edge[i + 1][j], edge[i][j - 1], edge[i][j + 1]):
                    count += 1

    if count == numofshirp:
        print(YES)
    else:
        print(NO)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(W)]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, W: int, s: "List[str]"):
    ans = YES
    for i in range(1, H-1):
        for j in range(1, W-1):
            if s[i][j] == "#" and s[i-1][j] == s[i+1][j] == s[i][j-1] == s[i][j+1] == ".":
                ans = NO
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    H, W = map(int,input().split())  # type: int
    s = [input() for _ in range(H)]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()
import numpy as np
N = int(input())

c = np.zeros((10,10),dtype = int)

for k in range(1,N+1):
	c[int(str(k)[0])][int(str(k)[-1])] += 1

ans = 0
for i in range(10):
	for j in range(10):
		ans += c[i][j]*c[j][i]
print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())

c = np.zeros((10,10),dtype = int)

for k in range(1,N+1):
	c[int(str(k)[0])][int(str(k)[-1])] += 1

ans = 0
for i in range(10):
	for j in range(10):
		ans += c[i][j]*c[j][i]
print(ans)
a = int(input())

for i in range(a - 1):
  result = result + i + 1

print(result)

### FIXED CODE ###

a = int(input())
print(int(a * (a - 1) // 2))
N = int(input())
v_l = [int(input()) for i in range(N)]
c_l = [int(input()) for i in range(N)]
net = [v_l[i] - c_l[i] for i in range(N)]
max = 0
for i in range(N):
  if net[i] > 0:
    max = max + net[i]
  else:
    max = max
print(max)

### FIXED CODE ###

N = int(input())
v_l = list(map(int, input().split()))
c_l = list(map(int, input().split()))
net = [v_l[i] - c_l[i] for i in range(N)]
max = 0
for i in range(N):
  if net[i] > 0:
    max = max + net[i]
  else:
    max = max
print(max)
"""

https://atcoder.jp/contests/agc034/tasks/agc034_c

cをどうやって決めるか考える
差分で考えることとする
負けることにする場合、cが大きいほど負けがかさむので l
そうでない場合、重要度を uにするべき

勝ちを増やす or 負けを減らすの、どっちの方が良い…？

bが小さいほうを勝ち、大きいほうを負けにした方がいい説
bが小さいほうで負け、大きいほうで勝つ場合を考えてみる
a1 < b1 < b2 < a2 とする。
この時、寄与は (a2-b2)*u2-(b1-a1)*l1 = X
aの値を交換してみると、寄与は
(a2-b1)*u1 - (b2-a1) * l2 = Y
となる。
Y-X = 
となり改善するので示された

bが小さいほうからi個を勝ちにする場合の最小を考えればいい
→あとは全探索すれば終わり

うわー luは固定じゃないんかい
とりあえず勝ち負けを決めた場合のスコア計算を考えてみる
最初全部負けで考え、損失の和Pを計算しておく→Σbi*li
N個のコインタワーがあり、上からbi個の価値はli、残りはuiである
Pを超える価値を取るための最小の枚数を求めよ
上を取っておいて下を取らない意味がないので、取ると決めたら山全部取るのが最適
→山の総和が大きい順にソート
→最大の山を全部取っても足りない場合、取りつくす
→最後の1山は残りから全探索する

"""

from sys import stdin

N,X = map(int,stdin.readline().split())

P = 0
sblu = [] #山の総和s,b,l,u

for i in range(N):
    b,l,u = map(int,stdin.readline().split())
    s = b * l + (X-b) * u
    P += b * l
    sblu.append((s,b,l,u))

sblu.sort()

ans = 0
while P >= sblu[-1][0]:
    P -= sblu[-1][0]
    ans += X
    del sblu[-1]

#print (P,sblu)

if P > 0:
    ansplus = float("inf")
    for s,b,l,u in sblu:
        np = 0
        if b * l >= P:
            np = (P+l-1)//l
        else:
            tmpP = P - b * l
            np = (tmpP+u-1)//u + b
        #print (np)
        ansplus = min(ansplus , np)
else:
    ansplus = 0

print (ans + ansplus)


### FIXED CODE ###


"""

https://atcoder.jp/contests/agc034/tasks/agc034_c

cをどうやって決めるか考える
差分で考えることとする
負けることにする場合、cが大きいほど負けがかさむので l
そうでない場合、重要度を uにするべき

勝ちを増やす or 負けを減らすの、どっちの方が良い…？

bが小さいほうを勝ち、大きいほうを負けにした方がいい説
bが小さいほうで負け、大きいほうで勝つ場合を考えてみる
a1 < b1 < b2 < a2 とする。
この時、寄与は (a2-b2)*u2-(b1-a1)*l1 = X
aの値を交換してみると、寄与は
(a2-b1)*u1 - (b2-a1) * l2 = Y
となる。
Y-X = 
となり改善するので示された

bが小さいほうからi個を勝ちにする場合の最小を考えればいい
→あとは全探索すれば終わり

うわー luは固定じゃないんかい
とりあえず勝ち負けを決めた場合のスコア計算を考えてみる
最初全部負けで考え、損失の和Pを計算しておく→Σbi*li
N個のコインタワーがあり、上からbi個の価値はli、残りはuiである
Pを超える価値を取るための最小の枚数を求めよ
上を取っておいて下を取らない意味がないので、取ると決めたら山全部取るのが最適
→山の総和が大きい順にソート
→最大の山を全部取っても足りない場合、取りつくす
→最後の1山は残りから全探索する

なぜWA?
分からん…
山を上からとらない理由がない

4,4,93 →和101
2,2,96 →和100
104
→大きいほうからとっていいなんてことはなかった
→総和が大きい山を必ずすべて使うという未証明命題を使おうとしたのが敗因

"""

from sys import stdin

N,X = map(int,stdin.readline().split())

P = 0
sblu = [] #山の総和s,b,l,u

for i in range(N):
    b,l,u = map(int,stdin.readline().split())
    s = b * l + (X-b) * u
    P += b * l
    sblu.append((s,b,l,u))

sblu.sort()
sblu.reverse()

ans = float("inf")
slis = []
for i in range(N):
    if i == 0:
        slis.append(sblu[i][0])
    else:
        slis.append(slis[-1] + sblu[i][0])

for i in range(N): #iは中途半端に取る場所

    #iも含めた和がPを超える最小のindexを求める
    L = -1
    R = N-1
    while R-L != 1:
        
        M = (R+L)//2
        if M < i:
            if slis[M] + sblu[i][0] >= P:
                R = M
            else:
                L = M
        else:
            if slis[M] >= P:
                R = M
            else:
                L = M

    if R < i:
        rem = P - slis[R]
        nans = X * (R+1)
    else:
        rem = P - (slis[R]-sblu[i][0])
        nans = X * R

    if rem < 0 or sblu[i][0] < rem:
        continue

    s,b,l,u = sblu[i]
    if rem <= b*l:
        nans += (rem+l-1) // l
    else:
        rem = rem - b * l
        nans += b + (rem+u-1)//u

    ans = min(ans,nans)

print (ans)
line=list(map(int,input().split()))

for i in range(3):
    if line(i)==line(i+1):
        print('Bad')
        break
    if i==2:
        print('Good')


### FIXED CODE ###

line=list(input())

for i in range(3):
    if line[i]==line[i+1]:
        print('Bad')
        break
    if i==2:
        print('Good')
N = int(input())
if N ＝＝ 3：
	print(1, 2, 3)
  	exit()
a = []
i = 2
while len(a) < N-N%2-2 and i + 2 <= 30000:
	a.append(i)
    a.append(i+2)
    i += 6
b = []
i = 3
while len(a) + len(b) < N-N%2 and i + 6 <= 30000:
  	b.append(i)
    b.append(i+6)
    i += 12
c = []
i = 6
while len(a) + len(b) + len(c) < N:
  	c.append(i)
    i += 6
print(' '.join(map(str, a+b+c)))

### FIXED CODE ###

N = int(input())
if N == 3:
    print(2, 5, 63)
    exit()
a = []
i = 2
while len(a) < N-N%2-2 and i + 2 <= 30000:
    a.append(i)
    a.append(i+2)
    i += 6
b = []
i = 3
while len(a) + len(b) < N-N%2 and i + 6 <= 30000:
    b.append(i)
    b.append(i+6)
    i += 12
c = []
i = 6
while len(a) + len(b) + len(c) < N:
    c.append(i)
    i += 6
print(' '.join(map(str, a+b+c)))
k, s = [int(x) for x in ks.split(" ")]
comb = []
for x in range(min(k,s) + 1)[::-1]:
    print(x)
    for y in range(min(x + 1, s - x + 1))[::-1]:
        z = s - x - y
        if (x <= k and y <= k and z <= k and y <= x and z <= y):
            comb.append([x,y,z])
count = 0
for c in comb:
    l = len(set(c))
    if l == 1:
        count += 1
    elif l == 2:
        count += 3
    else:
        count += 6
print(count)

### FIXED CODE ###

ks = input()
k, s = [int(x) for x in ks.split(" ")]
comb = []
for x in range(min(k,s) + 1)[::-1]:
    for y in range(min(x + 1, s - x + 1))[::-1]:
        z = s - x - y
        if (x <= k and y <= k and z <= k and y <= x and z <= y):
            comb.append([x,y,z])
count = 0
for c in comb:
    l = len(set(c))
    if l == 1:
        count += 1
    elif l == 2:
        count += 3
    else:
        count += 6
print(count)
from sys import stdin


class DFS():
    def __init__(self,A_B_arr,N,M):
        self.N = N
        self.M = M
        self.route = {i:[] for i in range(N+1)}
        for A, B in A_B_arr:
            self.route[A].append(B)
            self.route[B].append(A)

        self.dp = [[None,N] for i in range(N+1)]
        self.dp[1] = [1,0]
        self.finished = [False for i in range(N+1)]

    def dfs(self,i,rank):
        for r in self.route[i]:
            if rank<self.dp[r][1]:
                self.dp[r] = [i,rank]
                self.dfs(r,rank+1)
        self.route[i] = []
        return


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  # type:list(int)
    A_B_arr = []
    for i in range(M):
        _ = list(map(int,_in[i+1].split(' ')))  # type:list(int)
        A_B_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    dfs = DFS(A_B_arr,N,M)
    dfs.dfs(1,1)

    ans = []
    TF = 'Yes'
    for (i,_) in enumerate(dfs.dp):
        if i>1:
            if _[0] == None:
                TF = 'No'
                break
            else:
                ans.append(_[0])
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    if TF == 'Yes':
        print(TF)
        for _ in ans:
            print(_)
    else:
        print(TF)


### FIXED CODE ###

from sys import stdin
from collections import deque


class BFS():
    def __init__(self, con, val=None):
        # 隣接リスト表現
        self.con = con
        self.val = val
        self.N = len(self.con)
        # 1つ前の部屋(1-indexed)
        self.dist = [-1]*self.N
        self.que = deque()

        # 初期条件(0-indexed)
        self.dist[0] = 0
        self.que.append(0)

    def bfs(self):
        while self.que:
            v = self.que.popleft()
            for next_v in self.con[v]:
                if self.dist[next_v] != -1:
                    continue
                self.dist[next_v] = v+1
                self.que.append(next_v)


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, M = list(map(int,_in[0].split(' ')))  # type:list(int)
    A_B_arr = []
    for i in range(M):
        _ = list(map(int,_in[i+1].split(' ')))  # type:list(int)
        A_B_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    con = [[] for i in range(N)]
    for A,B in A_B_arr:
        A -= 1
        B -= 1
        con[A].append(B)
        con[B].append(A)

    bfs = BFS(con)
    bfs.bfs()
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    if -1 in bfs.dist[1:]:
        print('No')
    else:
        print('Yes')
        for _ in bfs.dist[1:]:
            print(_)
a,b = input().split()
print("<" a<b else ">")

### FIXED CODE ###

a,b = input().split()
print("<" if a<b else ">" if a>b else "=")
import math
# from collections import defaultdict
import time
def steps(n,p):
  c = 0
  while n:
    c += 1
    n = n%p
    p = bin(n).count('1')
  return c

# n = 200000
# x = "1"*n
n = int(input())
x = input()
incs = [1]
decs = [1]
p = x.count('1')
for i in range(1,n):
  incs.append((incs[-1]*2)%(p+1))
  decs.append((decs[-1]*2)%(p-1))
num = int(x,2)
inc = num%(p+1)
dec = num%(p-1)
start = time.time()
k = -1
for i in range(n):
  cp = p
  if x[i] == '0':
    cp += 1
    new = (inc+incs[k])%cp
  else:
    cp -= 1
    new = (dec-decs[k])%cp
  k -= 1
  ans = steps(new,cp)
  if ans==0:
    ans=1
  print(ans)
  # steps(new,cp)
# print(time.time()-start)

### FIXED CODE ###

import math
# from collections import defaultdict
import time
def steps(n,p):
  c = 0
  while n:
    c += 1
    n = n%p
    p = bin(n).count('1')
  return c

# n = 200000
# x = "1"*n
n = int(input())
x = input()
p = x.count('1')
ans = []
num = int(x,2)
if p==1:
  for i in range(n-1,-1,-1):
    if x[i]=='1':
      ans.append(0)
    else:
      if i==n-1 or x[n-1]=='1':
        ans.append(2)
      else:
        ans.append(1)
else:
  incs = 1
  decs = 1
  inc = num%(p+1)
  dec = num%(p-1)
  start = time.time()
  k = -1
  for i in range(n-1,-1,-1):
    cp = p
    if x[i] == '0':
      cp += 1
      new = (inc+incs)%cp
    else:
      cp -= 1
      new = (dec-decs)%cp
    k -= 1
    incs = (incs*2)%(p+1)
    decs = (decs*2)%(p-1)
    sol = steps(new,cp)
    if sol==0:
      sol=1
    ans.append(sol)
    # steps(new,cp)
  # print(time.time()-start)
ans = ans[::-1]
for x in ans:
  print(x)
def solve(i,sum):
    if i==n:
        ans[sum] = 1
        ans[sum+A[i]] = 1
    solve(i+1,sum)
    if sum+A[i] <= 2000:
        solve(i+1,sum+A[i])

n=int(input())
A=[]*n
A=list(input().split())
for i in range(n):
    A[i]=int(A[i])
ans=[0]*2001    
solve(0,0)   

m=int(input())
B=list(input().split())
for i in range(m):
    B[i]=int(B[i])
for i in range(m):
    if ans[B[i]]==1:
        print("yes")
    else:
        print("no")



### FIXED CODE ###

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

T = [[0]*2001 for i in range(n)]

T[0][0] = 1
T[0][A[0]] = 1
for i in range(1,n):
    for j in range(2001):
        T[i][j] = T[i-1][j]
        if (j - A[i] >=0) and (T[i-1][j-A[i]] == 1):
            T[i][j] = 1
    
for i in range(m):
    if T[n-1][B[i]] == 1: print("yes")
    else: print("no")