Harryxun/stf_run huggingface dataset:
import math

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

lcm_CD = (C*D)//math.gcd(C, D)

C_bot = C * -(-A//C) 
C_top = C * (B//C) 
D_bot = D * -(-A//D)
D_top = D * (B//D)
CD_bot = lcm_CD * -(-A//(lcm_CD ))
CD_top = lcm_CD  * (B//(lcm_CD ))

num_A_B = B - A + 1
num_divC = (C_top - C_bot)//C + 1
num_divD = (D_top - D_bot)//D + 1
num_divCD = (CD_top - CD_bot)//(lcm_CD ) + 1
ans = num_A_B - num_divC - num_divD + num_divCD


print(int(ans))

### FIXED CODE ###

import fractions

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

lcm_CD = (C*D)//fractions.gcd(C, D)

C_bot = C * -(-A//C) 
C_top = C * (B//C) 
D_bot = D * -(-A//D)
D_top = D * (B//D)
CD_bot = lcm_CD * -(-A//(lcm_CD ))
CD_top = lcm_CD  * (B//(lcm_CD ))

num_A_B = B - A + 1
num_divC = (C_top - C_bot)//C + 1
num_divD = (D_top - D_bot)//D + 1
num_divCD = (CD_top - CD_bot)//(lcm_CD ) + 1
ans = num_A_B - num_divC - num_divD + num_divCD


print(int(ans))
import numpy as np
from numba import njit

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

h = np.zeros(H + 1, np.int64)
w = np.zeros(W + 1, np.int64)
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x] += 1
    w[y] += 1
    boms.add((x, y))

h_max = h.max()
w_max = w.max()

h_idx = np.where(h == h_max)[0]
w_idx = np.where(w == w_max)[0]


@njit
def solve(h_max, w_max, boms):
    minus = -1
    for x in h_idx:
        for y in w_idx:
            if (x, y) in boms:
                minus = 0
                break
    return h_max + w_max + max(minus)


print(solve(h_max, w_max, boms))

### FIXED CODE ###

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

h = [0] * H
w = [0] * W
boms = set()

for _ in range(M):
    x, y = map(int, input().split())
    h[x - 1] += 1
    w[y - 1] += 1
    boms.add((x, y))

h_max = max(h)
w_max = max(w)

h_idx = [x + 1 for x, y in enumerate(h) if y == h_max]
w_idx = [x + 1 for x, y in enumerate(w) if y == w_max]

minus = -1
for x in h_idx:
    for y in w_idx:
        if not (x, y) in boms:
            minus = 0
            break

print(h_max + w_max + minus)
N,M = input().split()
s,c,a = [],[],[]
number = []
for i in range(int(M)):
    a_i = input().split()
    a.append(a_i)
    s.append(int(a_i[0]))
    c.append(int(a_i[1]))
ans = True
for i in range(int(N)):
    number.append('')
for i in range(int(M)):
    if (s[i]==1 and c[i]==0 and int(N)>1) or s[i] > N:
        if ans:
            print('-1')
            ans = False
    elif number[s[i]-1] == '' or number[s[i]-1] == c[i]:
        number[s[i]-1] = c[i]
    else:
        if ans:
            print('-1')
            ans = False
for i,elem in enumerate(number):
    if number[i] == '' and i == 0:
        number[i] = 1
    elif elem == '':
        number[i] = 0
if ans:
    strs = '' 
    for i in number:
        strs += str(i)
    print(int(strs))


### FIXED CODE ###

N,M = input().split()
s,c,a = [],[],[]
number = []
for i in range(int(M)):
    a_i = input().split()
    a.append(a_i)
    s.append(int(a_i[0]))
    c.append(int(a_i[1]))
ans = True
for i in range(int(N)):
    number.append('')
for i in range(int(M)):
    if s[i]==1 and c[i]==0 and int(N)>1:
        if ans:
            print('-1')
            ans = False
    elif s[i] > int(N):
        if ans:
            print('-1')
            ans = False
    elif number[s[i]-1] == '' or number[s[i]-1] == c[i]:
        number[s[i]-1] = c[i]
    else:
        if ans:
            print('-1')
            ans = False
for i,elem in enumerate(number):
    if number[i] == '' and i == 0 and int(N) >1:
        number[i] = 1
    elif elem == '':
        number[i] = 0
if ans:
    strs = '' 
    for i in number:
        strs += str(i)
    print(int(strs))
N = int(input())

for i in range(N):
    if i**2 > N:
        print(i-1)**2
        exit()

### FIXED CODE ###

n = int(input())

ans = 0

for a in range(10**5 + 1):
    if a**2 <= n:
        ans = max(ans, a**2)

print(ans)
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

typedef struct {
    int ipt; int num;
} tpl;

int asc(const void *a, const void *b) {
    return ((*(tpl *)a)).ipt - ((*(tpl *)b)).ipt;
}

int main(void){
    int N;
    scanf("%d", &N);
    int a[100000 + 10];
    tpl array[100000 + 10];
    for (int i = 0; i < N; i++) {
        scanf("%d", &array[i].ipt);
        array[i].num = i + 1;
    }
    qsort(array,N,sizeof (tpl), asc);
    for (int i = 0; i < N; i++) {
        printf("%d ",array[i].num);
    }

}


### FIXED CODE ###

N = int(input())
L = list(map(int,input().split()))
a = []
for i in range(len(L)):
    t = (L[i],i)
    a.append(t)
a = sorted(a)
for i in a:
    print(i[1]+1,end = ' ')
A,B,C=list(map(int, input().split()))

if A==B and B==C or A!=B and B!=C and C!=A:
    print('No')
else
    print('Yes')


### FIXED CODE ###

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

if A==B and B==C or A!=B and B!=C and C!=A:
    print('No')
else:
    print('Yes')
def func(N):
    return N%bin(N).count("1")

N = int(input())
X = input()

popcount = X.count("1")
X_num = int(X,2)
bi = 2**(N-1)


for i in range(N):
    if(X[i] == "0"):
        hoge = X_num+bi
        I_count = popcount + 1
    else:
        hoge = X_num-bi
        I_count = popcount - 1
    count = 1
    hoge = hoge%I_count
    while hoge != 0:
        hoge = func(hoge)
        count += 1
    print(count)
    bi >>= 1

### FIXED CODE ###

def func(N):
    return N%bin(N).count("1")

N = int(input())
X = input()

popcount = X.count("1")
X_num = int(X,2)

O = X_num%(popcount+1)
if popcount==1:
    I = 0
else:
    I = X_num%(popcount-1)

bO = 1
bI = 1

ans= []
for i in range(N):
    if X[-1-i]=="0":
        hoge = (O + bO)%(popcount+1)
    else:
        if popcount==1:
            ans.append(0)
            continue
        hoge = (I - bI)%(popcount-1)
    count = 1
    while hoge:
        hoge = func(hoge)
        count += 1
    ans.append(count)
    bO = (bO*2)%(popcount+1)
    if popcount != 1:
        bI = (bI*2)%(popcount-1)

for i in range(N):
    print(ans[-1-i])
a, b = map(int,input().split())
d = (int)a/b
r = a%b
f = a/b
print("%s %s %f" %(d,r,f))

 

### FIXED CODE ###

a, b = map(int,input().split())
d = a // b 
r = a % b
f = a / b
print("%d %d %f" %(d,r,f))
n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)
x_sub = []

if len(x_sort) == 1:
    print(0)
else:
    for i in range(m-1):
        x_sub.append(x_sort[i+1]-x_sort[i])
    
    x_sub = sorted(x_sub)
    
    for i in range(n-1):
        x_sub.remove(x_sub[-1])
    
    print(sum(x_sub))

### FIXED CODE ###

n, m = [int(i) for i in input().split()]
x_arr = [int(i) for i in input().split()]

x_sort = sorted(x_arr)

if n >= m or m==1:
    print(0)
else:
    x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1)]
    x_sub = sorted(x_sub)
    print(sum(x_sub[:(m-1)-(n-1)]))
X=int(input())
i=2
L=[]
import math
while math.floor(X**(1/i))!=1:
    L.append(math.floor(X**(1/i))**i)
    i+=1
print(max(L))

### FIXED CODE ###

X=int(input())
L=[1]
for i in range(2,X+1):
  j=2
  while i**j<=X:
    L.append(i**j)
    j+=1
print(max(L))
n = list(map(int, input().split())
count = 0
         
while count == n[2]:
	if n[0] > 0:
    	n[0]-=1   
        count+=1
    elif n[1] > 0:
        n[1]-=1
        count+=1
 
print(n[0] n[1])

### FIXED CODE ###

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

if A > K:
  print(A - K, B)
elif B - (K - A) > 0:
  print(0, B - (K - A))
else:
  print(0,0)
H, W, M = map(int, input().split())
hws = [list(map(lambda x :int(x)-1, input().split())) for _ in range(M)]

booms = [set() for _ in range(H)]

yoko = [0 for _ in range(W)]
tate = [0 for _ in range(H)]

for hw in hws:
    tate[hw[0]] += 1
    yoko[hw[1]] += 1
    booms[hw[0]].add(hw[1])
    
max_tate = max(tate)
max_yoko = max(yoko)


tate_candidates = []
yoko_candidates = []

for i in range(H):
    if tate[i] == max_tate:
        tate_candidates.append(i)
        
for i in range(W):
    if yoko[i] == max_yoko:
        yoko_candidates.append(i)

exist = 0
for tate_candidate in tate_candidates:
    for yoko_candidate in yoko_candidates:
        if yoko_candidate not in booms[tate_candidate]:
            exist = 1
			break
    else:
      continue
    break
print(max_tate + max_yoko + (exist-1))


### FIXED CODE ###

H, W, M = map(int, input().split())
hws = [list(map(lambda x :int(x)-1, input().split())) for _ in range(M)]

booms = [set() for _ in range(H)]

yoko = [0 for _ in range(W)]
tate = [0 for _ in range(H)]

for hw in hws:
    tate[hw[0]] += 1
    yoko[hw[1]] += 1
    booms[hw[0]].add(hw[1])
    
max_tate = max(tate)
max_yoko = max(yoko)


tate_candidates = []
yoko_candidates = []

for i in range(H):
    if tate[i] == max_tate:
        tate_candidates.append(i)
        
for i in range(W):
    if yoko[i] == max_yoko:
        yoko_candidates.append(i)

exist = 0
for tate_candidate in tate_candidates:
    for yoko_candidate in yoko_candidates:
        if yoko_candidate not in booms[tate_candidate]:
            exist = 1
            break
    else:
        continue
    break
print(max_tate + max_yoko + (exist-1))
import sys
n=int(input())
w=[].append(input())

check=True
for i in range (1,n-1,1):
    x = input()
    print(w)
    if x in w or x[0]!=w[i-1][len(w[i-1])-1]:
        check=False
        w.append("0")
    else:
        w.append(x)
if check:
    print('YES')
else:
    print('NO')



### FIXED CODE ###

a=int(input())
x=[]
flag=0
for i in range(a):
    s=input()
    if i==0:
        x.append(s)
        continue
    #print(s,x[i-1])
    if s in x or x[i-1][len(x[i-1])-1]!=s[0] :
        x.append("1")
        flag=1
    else:
        x.append(s)
if flag == 0:
    print("Yes")
else:
    print("No")
import copy

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

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

def main():
    n, m = map(int, input().split())
    # これだと72がREになる
    A = set([int(x) for x in input().split()])
    # これだと74も78もREになる
    # A = [int(x) for x in input().split()]
    # A_ = copy.deepcopy(A)
    # a_lcm = A.pop()
    a_lcm = 1
    # Aの要素が複数ならlcmを計算する
    #if len(A) >= 1:
    for a in A:
        a_lcm = lcm(a_lcm, a)
    #else:
    #    a_lcm = a_lcm
    # 元のAの値とlcmの半分の値を割り切れるものがあったら0
    #for i in A_:
    for i in A:
        if (a_lcm / 2) % i == 0:
        # if (a_lcm / i) % 2 == 0: 
            print(0)
            exit()
        # else:
        #     continue
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
    # if a_lcm > m * 2:
        print(0)
        exit()
    else:
        # # あとは定数倍の数調べて終わり
        # ans = int((m - (a_lcm / 2))) // a_lcm + 1
        ans = int((m - (a_lcm / 2)) // a_lcm) + 1
        print(ans)
    
        # a_lcm = a_lcm // 2
        # q = m // a_lcm
        # if q % 2 == 0:
        #     ans = q // 2
        # else:
        #     ans = q // 2 + 1
        # print(ans)

if __name__ == '__main__':
    main()

# https://atcoder.jp/contests/abc150/submissions/15070410　参考

### FIXED CODE ###

import copy
# from math import gcd


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

def lcm(a, b):
    return (a // gcd(a, b)) * b
def main():
    n, m = map(int, input().split())
    A = set([int(x) for x in input().split()])
    a_lcm = 1
    for a in A:
        a_lcm = lcm(a_lcm, a)
        # mがlcmの半分よりも小さかったら0
        if (a_lcm / 2) > m:
            print(0)
            exit()
    for a in A:
        if (a_lcm / 2) % a == 0:
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()
import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    N, M, X = il()
    CA = [il() for _ in range(N)]

    ret = MAX
    for n in range(1 << N):
        k = 0
        A = [0] * M
        for m in range(M):
            c, *a = CA[m]

            if n >> m & 1:
                k += c
                for i in range(len(a)):
                    A[i] += a[i]

                if all([aa >= X for aa in A]):
                    break
        else:
            continue

        ret = min(ret, k)

    print(ret)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import os
import math
import bisect
import collections
import itertools
import heapq

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    N, M, X = il()
    CA = [il() for _ in range(N)]

    ret = MAX
    for n in range(1 << N):
        k = 0
        A = [0] * M
        for j in range(N):
            c, *alist = CA[j]
            if n >> j & 1:
                k += c
                for i in range(len(alist)):
                    A[i] += alist[i]
            if all([a >= X for a in A]):
                ret = min(ret, k)
                break
        else:
            continue

    print(-1 if ret == MAX else ret)


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

stdin = np.fromstring(open(0).read(), np.int64, sep=' ')
N = stdin[0]
XL = stdin[1:].reshape(-1, 2).T
x = XL[0]
l = XL[1]
arg = np.argsort(x)
x = x[arg]
l = l[arg]
xleft = x - l
xright = x + l

count = 0
i = 0
while i < N - 1:
    for j in range(i + 1, N):
        if xright[i] > xright[j]:
            count += 1
            i += 1
            break    
        elif xright[i] > xleft[j]:
            count += 1
            j = j + 1
        else:
            i = j
            break
    else:
        i = N - 1

print(N - count)

### FIXED CODE ###

N, K, S = map(int, input().split())
a = [S] * K
if S < 1000000000:
    b = [S + 1] * (N - K)
else:
    b = [S - 1] * (N - K)
print(' '.join(map(str, a + b)))
n, c = map(int, input().split())
X = [0 for _ in range(n)]
V = [0 for _ in range(n)]
right = [0 for _ in range(n)]
left = [0 for _ in range(n)]
rl = [0 for _ in range(n)]
lr = [0 for _ in range(n)]
rlm = [0 for _ in range(n)]
lrm = [0 for _ in range(n)]

calsum = 0
for i in range(n):
    x, v = map(int, input().split())
    X[i] = x
    V[i] = v
    calsum += v
    right[i] = calsum-x
    rl[i] = calsum-2*x

calsum = 0
for i in range(n):
    calsum += V[n-i-1]
    left[i] = calsum - (c-X[n-i-1])
    lr[i] = calsum - 2*(c-X[n-i-1])


m = 0
for i in range(0, n-1):
    m = max(m, left[i])
    rlm[i] = m + rl[n-i-2]

m = 0
for i in range(0, n-1):
    m = max(m, right[i])
    lrm[i] = m + lr[n-i-2]

print(max(0, max(right), max(left), max(rlm), max(lrm))


### FIXED CODE ###

n, c = map(int, input().split())
X = []
V = []
right = []
rightleft = []
calsum = 0
for i in range(n):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)
    calsum += v
    right.append(calsum-x)
    rightleft.append(calsum-2*x)

left = []
leftright = []
calsum = 0
for i in range(n):
    calsum += V[n-i-1]
    left.append(calsum - (c-X[n-i-1]))
    leftright.append(calsum - 2*(c-X[n-i-1]))

m = 0
M = 0
for i in range(0, n-1):
    m = max(m, left[i])
    M = max(M, m + rightleft[n-i-2])

mm = 0
MM = 0
for i in range(0, n-1):
    mm = max(mm, right[i])
    MM = max(MM, mm + leftright[n-i-2])

print(max(max(right), max(left), M, MM, 0))
a,b,c,d=map(int,input().split())

while True:
    c=c-b
    if c<=0:
  		print("Yes")
  		break
	a=a-d
  	if a<=0:
  		print("No")
  		break

### FIXED CODE ###


a, b, c, d = map( int, input().split() )
#print( a, b, c, d )
 
for i in range( 200 ):
    c = c - b
    if c <= 0:
        print( "Yes" )
        exit()
 
    a = a - d
    if a <= 0:
        print( "No" )
        exit()
N = int(input())
A = list(map(int, input(), split()))
ans = 0
while all(a % 2 == 0 for a in A):
    A = [a / 2 for a in A]
    ans += 1
print(ans)


### FIXED CODE ###

input()
A=list(map(int,input().split()))
ans=0
while all(a%2==0 for a in A):
    A=[a/2 for a in A]
    ans+=1
print(ans)
import sys
import numpy as np


def solve(N):
    p, q = 0, 1
    for x in N:
        p, q = min(p + x, q + 10 - x), min(p + x + 1, q + 9 - x)
    print(p)


try:
    sys.winver
    N = np.array([int(_) for _ in input()])
    from numba import jit
    solve = jit(solve, '(i8[:])')
    solve(N)
except:
    if sys.argv[-1] != 'ONLINE_JUDGE':
        import numba
        from numba.pycc import CC
        cc = CC('my_module')
        cc.export('solve', '(i8[:])')(solve)
        # b1: bool, i4: int32, i8: int64, double: f8, [:], [:, :]
        cc.compile()
    else:
        #from my_module import solve
        #N = np.array([int(_) for _ in input()])
        solve(N)


### FIXED CODE ###

N = [int(_) for _ in input()]
dp = [[0, 0] for _ in range(len(N))]
dp[0][0] = min(N[0], 11 - N[0])
dp[0][1] = min(N[0] + 1, 10 - N[0])
for i in range(1, len(N)):
    dp[i][0] = min(dp[i - 1][0] + N[i], dp[i - 1][1] + 10 - N[i])
    dp[i][1] = min(dp[i - 1][0] + N[i] + 1, dp[i - 1][1] + 9 - N[i])
print(dp[-1][0])
import sys

sys.setrecursionlimit(10**20)


class Dp:

    def __init__(self, size):
        self.size = size
        self.array = [0] * (size+1)

    def calc(self, n):
        if n == 1:
            return 1
        if self.array[n] != 0:
            return self.array[n]
        self.array[n] = self.calc(n//2) * 2 + 1
        return self.array[n]


def main():
    h = int(input())
    dp = Dp(h)
    result = dp.calc(h)
    print(result)


if __name__ == "__main__":
    main()

    

### FIXED CODE ###

import sys
from functools import lru_cache
sys.setrecursionlimit(20000)


class Dp:

    def __init__(self, size):
        self.size = size

    @lru_cache(maxsize=None)
    def calc(self, n):
        if n == 1:
            return 1
        return self.calc(n//2) * 2 + 1


def main():
    h = int(input())
    dp = Dp(h)
    result = dp.calc(h)
    print(result)


if __name__ == "__main__":
    main()
n,q=map(int,input().split())
graph=[[] for _ in range(n+1)]
ab=[list(map(int,input().split())) for _ in range(n-1)]
for a,b in ab:
    graph[a].append(b)
    graph[b].append(a)
px=[list(map(int,input().split())) for _ in range(q)]
ans=[0]*(n+1)
for p,x in px:
    ans[p]+=x
seen=[0]*(n+1)
def dfs(i):
    seen[i]=1
    for li in graph[i]:
        if seen[li]==0:
            ans[li]+=ans[i]
            dfs(li)
dfs(1)
print(' '.join(map(str,ans[1:])))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
def main():
    n,q=map(int,input().split())
    graph=[[] for _ in range(n+1)]
    ab=[list(map(int,input().split())) for _ in range(n-1)]
    for a,b in ab:
        graph[a].append(b)
        graph[b].append(a)
    px=[list(map(int,input().split())) for _ in range(q)]
    seen=[0]*(n+1)
    ans=[0]*(n+1)
    for p,x in px:
        ans[p]+=x
    def dfs(i):
        seen[i]=1
        for li in graph[i]:
            if seen[li]==0:
                ans[li]+=ans[i]
                dfs(li)
    dfs(1)
    print(' '.join(map(str,ans[1:])))
if __name__ == '__main__':
    main()
import sys
import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

B = 0
s = 1
for i, a in enumerate(A):
    if i < K:
        s *= a
        B = s
    elif:
        s /= A[i-K]
        s *= a
        if B != 0 and B < s:
            print('Yes')
        elif B != 0 and B >= s:
            print('No')
        B = s

### FIXED CODE ###

import sys
import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))

B = 0
s = 1
for i, a in enumerate(A):
    if i >= K:
        B = A[i-K]
        s = a
        if B != 0 and B < s:
            print('Yes')
        elif B != 0 and B >= s:
            print('No')
N, *D = map(int, open(0).read().split())

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ans += D[i] * D[j]

print(ans)


### FIXED CODE ###

from itertools import groupby

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

G = [len(tuple(v)) for k, v in groupby(S)]
print(len(G))
import math

N, x, y = list(map(int, input().split()))
INF = math.inf
adj_mtx = [ [INF] * (N+1) for _ in range(N+1) ]

for i in range(1, N+1):
  if i != N:
    adj_mtx[i][i] = 0
    adj_mtx[i][i+1] = 1
    adj_mtx[i+1][i] = 1
adj_mtx[x][y] = 1
adj_mtx[y][x] = 1

for k in range(1, N+1):
  for i in range(1, N+1):
    for j in range(1, N+1):
      adj_mtx[i][j] = min(adj_mtx[i][j], adj_mtx[i][k] + adj_mtx[k][j])

for i in range(1, N):
  # print("i", i)
  print(sum([ r.count(i) for r in adj_mtx ]) // 2)

### FIXED CODE ###

N, X, Y = list(map(int, input().split()))
result = [0] * N


for i in range(1, N):
  for j in range(i+1, N+1):
    step = min( j-i, abs(i-X)+1+abs(j-Y), abs(i-Y)+1+abs(j-X))
    result[step] += 1

for e in result[1:]: print(e)
N = int(input())
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
C = [int(i) for i in input().split()]
C.sort()
# 根から始め、巡回した葉にCの大きなものから順に書き込んで行く。
# int_list = list(sorted(C))
graph = [[] for _ in range(N)]
for u, v in Nodes:  # 0-basedとする
    graph[u - 1].append(v - 1)
    graph[v - 1].append(u - 1)
# print(Nodes)
# print(graph)

# 各頂点にCの値が大きなもの順に書き込んでいく
ret = [0] * N
def dfs(p, c):
    # ret[c] = int_list.pop()
    ret[c] = C.pop()
    for next_edge in graph[c]:
        if next_edge != p and ret[next_edge] == 0:  # 木を「逆戻り」しない頂点だけ調べる
            dfs(c, next_edge)
dfs(p=-1, c=0)

print(sum(ret[1:]))
print(" ".join(map(str, ret)))


### FIXED CODE ###

def d_maximum_sum_of_minimum(N, Nodes, C):
    # 根から始め、巡回した葉にCの大きなものから順に書き込んで行く。
    import sys
    sys.setrecursionlimit(10**6)

    int_list = list(sorted(C))
    graph = [[] for _ in range(N)]
    for u, v in Nodes:  # 0-basedとする
        graph[u - 1].append(v - 1)
        graph[v - 1].append(u - 1)

    def traverse_tree(parent, current, ret=[0] * N):
        """各頂点にCの値が大きなもの順に書き込んでいく"""
        def dfs(p, c):
            ret[c] = int_list.pop()
            for next_edge in graph[c]:
                if next_edge != p:  # 木を「逆戻り」しない頂点だけ調べる
                    dfs(c, next_edge)
        dfs(parent, current)
        return ret
    tmp = traverse_tree(-1, 0)
    return str(sum(tmp[1:])) + '\n' + ' '.join(map(str, tmp))

N = int(input())
Nodes = [[int(i) for i in input().split()] for j in range(N - 1)]
C = [int(i) for i in input().split()]
print(d_maximum_sum_of_minimum(N, Nodes, C))
a=int(input('a'))
b=int(input('b'))
if (a*b)%2 ==1:
	print('Odd')
else:
	print('Even')

### FIXED CODE ###

a,b=map(int,input().split())
if (a*b)%2 ==0:
  print('Even')
else:
  print('Odd')
from heapq import*
N,M,*t=map(int,open(0).read().split())
v=[[]for _ in'_'*M]
for i in range(N):M<t[2*i]or v[t[2*i]-1].append(t[2*i+1])
z=0
q=[]
for i in v:
	for j in i:heappush(q,-j)
	z-=q[0]and heappop(q)
print(z)

### FIXED CODE ###

from heapq import*
(N,M),*t=[map(int,s.split())for s in open(0)]
v=[[]for _ in'_'*M]
z=0
for a,b in t:
	if a<=M:v[a-1]+=[b]
q=[0]*M
for i in v:
	for j in i:heappush(q,-j)
	z-=heappop(q)
print(z)
n,m = map(int, input().split())
Li = [[] for y in range(m)]
Li2 = []
a = 0
for x in range(n):
    Li[x] += list(map(int, input().split()))
for x in range(m):
    Li2.append(int(input()))
for x in range(n):
    for y in range(m):
        a += Li[x][y]*Li2[y]
    print(a)
    a = 0



### FIXED CODE ###

n,m = map(int, input().split())
Li = [[] for y in range(n)]
Li2 = []
a = 0
for x in range(n):
    Li[x] += list(map(int, input().split()))
for x in range(m):
    Li2.append(int(input()))
for x in range(n):
    for y in range(m):
        a += Li[x][y]*Li2[y]
    print(a)
    a = 0