Harryxun/stf_run huggingface dataset:
class unionfindtree:
    def __init__(self, n):
        self.root = [i for i in range(n + 1)]
        self.friendcount = [1] * (n + 1)

    def getroot(self, x):
        node = self.root[x]
        if node == x:
            return x
        self.root[x] = self.getroot(node)
        return self.root[x]

    def unite(self, x, y):
        xroot = self.getroot(x)
        yroot = self.getroot(y)
        if xroot == yroot:
            return
        self.root[xroot] = yroot
        self.friendcount[yroot] += self.friendcount[xroot]

    def getfriendcount(self, x):
        xroot = self.getroot(x)
        return self.friendcount[xroot]

    def same(self, x, y):
        if self.getroot(x) == self.getroot(y):
            return true
        return false


n, m, k = map(int, input().split())
a = [0] * m
b = [0] * m
c = [0] * k
d = [0] * k

for i in range(m):
    a[i], b[i] = map(int, input().split())
for i in range(k):
    c[i], d[i] = map(int, input().split())

tree = unionfindtree(n)
for i in range(m):
    tree.unite(a[i], b[i])

friendscount = [0] * (n + 1)
blockcount = [0] * (n + 1)
for i in range(m):
    friendscount[a[i]] += 1
    friendscount[b[i]] += 1
for i in range(k):
    if tree.same(c[i], d[i]):
        blockcount[c[i]] += 1
        blockcount[d[i]] += 1

# print(1, 4, tree.same(1, 4))
# print(1, tree.getfriendcount(1))
# print(4, tree.getfriendcount(4))

result = [str(tree.getfriendcount(i) - 1 - friendscount[i] - blockcount[i]) for i in range(1, n + 1)]
print(" ".join(result))



### FIXED CODE ###

class UnionFindTree:
    def __init__(self, N):
        self.root = [i for i in range(N)]
        self.friendcount = [1] * N

    def getroot(self, x):
        node = self.root[x]
        if node == x:
            return x
        self.root[x] = self.getroot(node)
        return self.root[x]

    def unite(self, x, y):
        xroot = self.getroot(x)
        yroot = self.getroot(y)
        if xroot == yroot:
            return
        if xroot > yroot:
            self.root[xroot] = yroot
            self.friendcount[yroot] += self.friendcount[xroot]
        else:
            self.root[yroot] = xroot
            self.friendcount[xroot] += self.friendcount[yroot]

    def getfriendcount(self, x):
        xroot = self.getroot(x)
        return self.friendcount[xroot]

    def same(self, x, y):
        if self.getroot(x) == self.getroot(y):
            return True
        return False


N, M, K = map(int, input().split())
A = [0] * M
B = [0] * M
C = [0] * K
D = [0] * K

for i in range(M):
    A[i], B[i] = map(int, input().split())
for i in range(K):
    C[i], D[i] = map(int, input().split())

tree = UnionFindTree(N + 1)
for i in range(M):
    tree.unite(A[i], B[i])

friendscount = [0] * (N + 1)
blockcount = [0] * (N + 1)
for i in range(M):
    friendscount[A[i]] += 1
    friendscount[B[i]] += 1
for i in range(K):
    if tree.same(C[i], D[i]):
        blockcount[C[i]] += 1
        blockcount[D[i]] += 1

result = [str(tree.getfriendcount(i) - 1 - friendscount[i] - blockcount[i]) for i in range(1, N + 1)]
print(" ".join(result))
arr = list(map(int,input().split()))
A=arr[0]
B=arr[1]
H=arr[3]
M=arr[4]

kakudo_H = H*30 +M*0.5
kakudo_M = M*6
if M==0:
    kakudo_M=360

kakudo_sa=abs(kakudo_H-kakudo_M)
# cはまずは2条している値としてセット
c=A**2 +B**2-2*A*B*(math.cos(math.radians(kakudo_sa)))
C=c**0.5
print(C)

### FIXED CODE ###

import math
A,B,H,M=input().split()

A=int(A)
B=int(B)
H=int(H)
M=int(M)

kakudo_H = H*30 +M*0.5
kakudo_M = M*6
if M==0:
    kakudo_M=360

kakudo_sa=abs(kakudo_H-kakudo_M)
# cはまずは2条している値としてセット
c=A**2 +B**2-2*A*B*(math.cos(math.radians(kakudo_sa)))
C=c**0.5
print(C)
import numpy as np

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

p = np.zeros(n,d)

for i in range(n):
  p[i] = np.array(list(map(int, input().split())))

cnt = 0
d = 0
for i in range(n):
  for j in range(i+1,n):
    d = np.sqrt((p[i] - p[j]) ** 2)
    if d % 1 == 0:
      cnt += 1

print(cnt)


### FIXED CODE ###

import numpy as np
 
n, d = map(int, input().split())
 
p = np.zeros((n,d))
 
for i in range(n):
  p[i] = np.array(list(map(int, input().split())))
cnt = 0
d = 0
for i in range(n):
  for j in range(i+1,n):
    d = np.sqrt(np.sum((p[i] - p[j]) ** 2))
    if d % 1 == 0:
      cnt += 1
print(cnt)
-*- coding: utf-8 -*-
 
import sys
import subprocess
import json
import time
import math
import re
import sqlite3
 
s = input()
print(s.rfind('Z') - s.find('A') + 1)

### FIXED CODE ###

s = input()
     
a = s.find("A")
b = s.rfind("Z")
     
print(b-a+1)
N = int(input())
# h,n,w
temp = int((3*N)/4)
hlist = [i+1 for i in range(temp)]
flag = False
for i in hlist:
    temp = 4/N - 1/i
    if(temp > 0):
        nlist = [i+1 for i in range(int(2/temp))]
        for j in nlist:
            beta = 4/N - 1/i - 1/j
            if (beta > 0):
                if(1/beta == int(1/beta)):
                    w = int(1/beta)
                    n = j
                    h = i
                    flag = True
                    break

    if flag:
        break

print(str(h)+ " " + str(n)+ " " +str(w))

### FIXED CODE ###

S = int(input())
ans = 0
for i in range(6):
    A = S%10
    B = int(S/10)
    S = B
    ans += A
print(int(ans))
import sys
#import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
#import heapq
#import math
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()

n = ri()
a = rl()
a=a+a
a.sort()

a.pop()
ans=0
for i in range(n-1):
    ans+=a[-i-1]
print(ans)

### FIXED CODE ###

import sys
#import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
#import heapq
#import math
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))


n = ri()
a = rl()
a=a+a
a.sort()

a.pop()
ans=0
for i in range(n-1):
    ans+=a[-i-1]
print(ans)
from math import pi
print(pi*int(input())**2,pi*int(input())*2)


### FIXED CODE ###

from math import pi
k = float(input())
print(pi*k**2,pi*k*2)
import copy
import sys
sys.setrecursionlimit(10**7)

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 = [int(x) for x in input().split()]
    # A_s = set(A)
    # 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)
    # mがlcmの半分よりも小さかったら0
    if (a_lcm / 2) > m:
    # if a_lcm > m * 2:
        print(0)
        exit()
    for a in A:
        # # これなら72は通る
        # print(0)
        # exit()
        if a_lcm // 2 % a == 0:
        # if (a_lcm // a) % 2 == 0: 
            print(0)
            exit()
    # # あとは定数倍の数調べて終わり
    ans = int((m - (a_lcm / 2)) // a_lcm) + 1
    print(ans)

if __name__ == '__main__':
    main()

### 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 math

# input
s = input()

ans = ''

for i in range(math.ceil(len(s) // 2):
    ans = ans + s[2 * i]

print(ans)

### FIXED CODE ###

import math

# input
s = input()

ans = ''

for i in range(math.ceil(len(s) / 2)):
    ans = ans + s[2 * i]

print(ans)
s = [1, 2, 3]
a = int(input())
b = int(input())

_ = s.pop(a-1)
_ = s.pop(b-1)

print(s[0])

### FIXED CODE ###

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

for i in range(3):
  if i+1 != a and i+1 != b:
    print(i+1)
N=int(input())
d=map(int,input().split())
s=list(d)
l=[]
for i in range(N-1):
  for j in range(i+1,N):
  l.append(i*j)
print(sum(l))
   
  



### FIXED CODE ###

N=int(input())
d=list(map(int,input().split()))
s=0
for i in range(0,N-1):
  s+=d[i]*sum(d[i+1:N])
print(s)
s,t = input().split()
if s in t and len(t) == len(s) + 1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = input()
t = input()
if s == t[:-1]:
    print('Yes')
else:
    print('No')
a = input()
b = input()
c = input()
d = input()
e = input()
k = input()
if e - a > k:
  	print(':(')
else:
  	print('Yay!')


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e - a > k:
  	print(':(')
else:
  	print('Yay!')
from sys import stdin
input = stdin.readline
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()) for _ in range(X))
q = list(map(int, input().split()) for _ in range(Y))
r = list(map(int, input().split()))
new = p + q + r
new = sorted(new, reverse = True)
print(sum(new[0:X+Y]))

### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
p.reverse()
q.sort()
q.reverse()
new = p[0:X] + q[0:Y] + r
new.sort()
new.reverse()
print(sum(new[0:X+Y]))
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
p = 10**9+7
Aplus = []
Nplus = 0
Aminus = []
Nminus = 0
Aabs = []
for i in range(N):
    if A[i]>=0:
        Aplus.append(A[i])
        Nplus += 1
    else:
        Aminus.append(A[i])
        Nminus += 1
Aplus.sort(reverse=True)
Aminus.sort(reverse=False)

if Nplus==0:
    if K%2==0:
        t=0
        out = 1
        while t<=K-1:
            out = out*Aminus[t]%p
            t+=1
    else:
        t=0
        out = 1
        while t<=K-1:
            out = out*Aminus[N-1-t]%p
            t+=1
    print(out)
else:
    Aminus2 = []
    for i in range(Nminus//2):
        Aminus2.append(Aminus[2*i]*Aminus[2*i+1])

    out = 1
    l = 0
    r = 0
    while K>0:
        cand = [0,0]
        flag = 0
        if r<=Nminus-1 and K>=2 and Aminus2[r]>0:
            cand[0] = Aminus2[r]
            flag=1
        if l+1<=Nplus-1:
            cand[1] = Aplus[l]*Aplus[l+1]
            flag=1
        if flag==1:
            if cand[0]>cand[1]:
                r+=2
                K+=-2
                out = out*cand[0]%p
            elif cand[0]<=cand[1]:
                l+=1
                K+=-1
                out = out*cand[1]%p
        else:
            if l==Nplus-1 and r==Nminus-1 and K==2:
                out = out*Aplus[l]*Aminus2[r]%p
            elif l==Nplus-1 and r==Nminus-1 and K==1:
                out = out*Aplus[l]%p
            elif K==2:
                out = out*Aplus[l]*Aplus[l+1]%p
            else:
                out = out*Aplus[l]%p
            break
    print(out)

### FIXED CODE ###

N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
p = 10**9+7
Aplus = []
Nplus = 0
Aminus = []
Nminus = 0
Aabs = []
for i in range(N):
    if A[i]>=0:
        Aplus.append(A[i])
        Nplus += 1
    else:
        Aminus.append(A[i])
        Nminus += 1
Aplus.sort(reverse=True)
Aminus.sort(reverse=False)

if K==N:
    out=1
    for i in range(K):
        out = out*A[i]%p
    print(out)
elif Nminus==N and K%2==1:
    out=1
    for i in range(K):
        out = out*Aminus[N-i-1]%p
    print(out)
else:
    l=0
    r=0
    out=1
    inf = float('inf')
    while K>0:
        if l+1<=Nplus-1:
            cand1 = Aplus[l]*Aplus[l+1]
        elif l==Nplus-1:
            cand1 = Aplus[l]
        else:
            cand1 = -1*inf

        if r+1<=Nminus-1:
            cand2 = Aminus[r]*Aminus[r+1]
        elif r==Nminus-1:
            cand2 = Aminus[r]
        else:
            cand2 = -1*inf

        if cand1>cand2 or K==1:
            out=out*Aplus[l]%p
            K += -1
            l += 1
        else:
            out=out*Aminus[r]*Aminus[r+1]%p
            K += -2
            r += 2
    print(out)
num=input()
a=0

if int(num[0])==1:
  a++
  
if int(num[1])==1:
  a++
  
if int(num[2])==1:
  a++
  
print(a)

### FIXED CODE ###

num=input()
a=0
 
if int(num[0])==1:
  a+=1
  
if int(num[1])==1:
  a+=1
  
if int(num[2])==1:
  a+=1
  
print(a)
class UnionFind:
  
    def __init__(self,n):
        #par[x]==xならxというノードが根。xに親がいない
        self.par = [i for i in range(n+1)]
        self.rank = [0]*(n+1) 
    
    def find(self,x): #xの根を検索
        #xが根なら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 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 #rankが同じ木を繋げたとき根のランクを一つ上げる
    
    def same_check(self,x,y): #xとyが同じ集合に属しているか
        return self.find(x) == self.find(y)

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

A=[list(map(int,input().split())) for i in range(m)]
ans = 0
for i in range(m):
    uf = UnionFind(n) #
    for j in range(m):
        if i != j: #
            uf.unite(A[j][0],A[j][1])
    f = 1
    g = uf.find(1) #
    for j in range(1,n+1):
        if g != uf.find(j): #1~n(iを除く)がすべて同じ集合に属しているか
            f = 0
            break
    if not f:
        ans += 1
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
graph = [[False for i in range(60)] for _ in range(60)]
A, B = [], []
ans = 0

def dfs(v):
    if vis[v]:
        return
    vis[v] = True
    for i in range(n):
        if graph[v][i]:
            dfs(i)

for i in range(m):
    a, b = map(lambda x: int(x)-1, input().split())
    A.append(a)
    B.append(b)
    graph[a][b] = graph[b][a] = True

for i in range(m): #どれが橋か
    graph[A[i]][B[i]] = graph[B[i]][A[i]] = False
    vis = [False] * n
    
    dfs(0)

    f = 0
    for j in range(n):
        if not vis[j]: f = 1
    if f: ans += 1
    
    graph[A[i]][B[i]] = graph[B[i]][A[i]] = True

print(ans)
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = dict(Counter(a))
dp_on = {}
dp_off = {}
for k, v in c.items():
if v < 2:
        dp_on[k] = 0
        dp_off[k] = 0
elif v < 3:
        dp_on[k] = 1
        dp_off[k] = 0
else:
        dp_on[k] = int(v*(v-1)/2)
        dp_off[k] = int((v-1)*(v-2)/2)
comb_sum = sum([v for v in dp_on.values()])
for i in range(n):
print(comb_sum - dp_on[a[i]] + dp_off[a[i]])

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = dict(Counter(a))
dp_on = {}
dp_off = {}
for k, v in c.items():
    if v == 1:
        dp_on[k] = 0
        dp_off[k] = 0
    elif v == 2:
        dp_on[k] = 1
        dp_off[k] = 0
    else:
        dp_on[k] = int(v*(v-1)/2)
        dp_off[k] = int((v-1)*(v-2)/2)
comb_sum = sum([v for v in dp_on.values()])
for i in range(n):
    print(comb_sum - dp_on[a[i]] + dp_off[a[i]])
a, b = map(int, raw_input().split())
p = map(int, raw_input().split())
q = map(int, raw_input().split())
ans = 0
for i in range(a):
    if b - i <= ans: break
    j = 0; k = i
    cnt = 0
    while 1:
        if p[j] == q[k]:
            cnt += 1; j += 1; k += 1
        else: j += 1
        if j == a: break
    ans = max(ans, cnt)
print ans

### FIXED CODE ###

l = map(int, raw_input().split())
if len(l) == 2:
    a = l[0]; b = l[1]
else:
    a = l[0]; b = input()
p = map(int, raw_input().split())
q = map(int, raw_input().split())
ans = 0
for i in range(a):
    if b - i <= ans or a - i <= ans: break
    j = 0; k = i
    cnt = 0
    while 1:
        if p[j] == q[k]:
            cnt += 1; j += 1; k += 1
        else: j += 1
        if j == a: break
    ans = max(ans, cnt)
print ans
N = input()
str_list = [input() for _ in range(N)]

print(len(set(str_list)))

### FIXED CODE ###

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

print(len(set(str_list)))
n,m=map(int,input())

if m>=n:

    print('unsafe')

else:
    print('safe')


### FIXED CODE ###

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

if m>=n:

    print('unsafe')

else:
    print('safe')
n,m=map(int,input().split())
st=[]
ch=[]
def mht(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

for i in range(n):
  st.append(list(map(int,input().split())))
for i in range(m):
  ch.append(list(map(int,input().split())))
  
for i in st:
  mn=100000000
  for (j,k) in zip(ch,range(1,m+1)):
    mh=mht(i,j)
    if mh<mn:
      mn=mh
      nm=k
  print(nm)


### FIXED CODE ###

n,m=map(int,input().split())
st=[]
ch=[]
def mht(ax,ay,bx,by):
  return abs(ax-bx)+abs(ay-by)

for i in range(n):
  st.append(list(map(int,input().split())))
for i in range(m):
  ch.append(list(map(int,input().split())))
  
for i in st:
  ax=i[0]
  ay=i[1]
  mn=1000000000
  for (j,k) in zip(ch,range(len(ch))):
    bx=j[0]
    by=j[1]
    mh=mht(ax,ay,bx,by)
    if mh<mn:
      mn=mh
      nm=k
  print(nm+1)
import sys
import  math
from heapq import *
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

    
N,M=nm()
INF=10**18
def bfs(start,edge):
    d=[INF]*(M+1)
    ans=[0]*(M+1)
    d[start]=0
    q=[(0,start)]
    while(len(q)!=0):
        ci,i=heappop(q)
        for j in edge[i]:
            if(d[j]>d[i]+1):
                d[j]=d[i]+1
                heappush(q,(d[j],j))
                ans[j]=i

    return ans




edge=[[]for _ in range(M+1)]
for i in range(M):
    A,B=nm()
    edge[A].append(B)
    edge[B].append(A)

ans=bfs(1,edge)

for i in range(2,M+1):
    if(ans[i]==0):
        print('No')
        sys.exit(0)

print('Yes')
for i in range(2,M+1):
    print(ans[i])


### FIXED CODE ###

import sys
import  math
from heapq import *
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

    
N,M=nm()
INF=10**18
def bfs(start,edge):
    d=[INF]*(N+1)
    ans=[0]*(N+1)
    d[start]=0
    q=[(0,start)]
    while(len(q)!=0):
        ci,i=heappop(q)
        for j in edge[i]:
            if(d[j]>d[i]+1):
                d[j]=d[i]+1
                heappush(q,(d[j],j))
                ans[j]=i

    return ans




edge=[[]for _ in range(N+1)]
for i in range(M):
    A,B=nm()
    edge[A].append(B)
    edge[B].append(A)

ans=bfs(1,edge)


for i in range(2,N+1):
    if(ans[i]==0):
        print('No')
        sys.exit(0)

print('Yes')
for i in range(2,N+1):
    print(ans[i])
N = int(input())
a = [int(i) for i in input().split()]
list = {}


for i in a:
    if 1 <= i <= 399:
        list[0] = 1
    elif 400 <= i <= 799:
        list[1] = 1
    elif 800 <= i <= 1199:
        list[2] = 1
    elif 1200 <= i <= 1599:
        list[3] = 1
    elif 1600 <= i <= 1999:
        list[4] = 1
    elif 2000 <= i <= 2399:
        list[5] = 1
    elif 2400 <= i <= 2799:
        list[6] = 1
    elif 2800 <= i <= 3199:
        list[7] = 1
    else:
        list[8] += 1

min = len(list)


if list[8] > 0:
    max = len(list) + chin
else:
    max = len(list)

print(min,max)


### FIXED CODE ###

N = int(input())
a = [int(i) for i in input().split()]
list = {}
list[8] = 0

for i in a:
    if 1 <= i <= 399:
        list[0] = 1
    elif 400 <= i <= 799:
        list[1] = 1
    elif 800 <= i <= 1199:
        list[2] = 1
    elif 1200 <= i <= 1599:
        list[3] = 1
    elif 1600 <= i <= 1999:
        list[4] = 1
    elif 2000 <= i <= 2399:
        list[5] = 1
    elif 2400 <= i <= 2799:
        list[6] = 1
    elif 2800 <= i <= 3199:
        list[7] = 1
    else:
        list[8] += 1

if len(list) == 1:
    min = 1
else:
    min = len(list) - 1

if list[8] > 0:
    max = len(list) + list[8] - 1
else:
    max = len(list) - 1

print(min,max)
from bisect import bisect, bisect_left
from itertools import accumulate
from math import ceil


def solve(h, aa, bb):
    max_a = max(aa)
    bf = list(filter(lambda x: x > max_a, bb))
    bf.sort(reverse=True)
    bba = list(accumulate(bf))
    remain = h - bba[-1]
    slash_cnt = max(0, ceil(remain / max_a))
    slash_dmg = slash_cnt * max_a
    throw_dmg = h - slash_dmg
    for i, dmg in enumerate(bba):
        if dmg >= throw_dmg:
            break
    return slash_cnt + i + 1


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

print(solve(h, aa, bb))


### FIXED CODE ###

from bisect import bisect, bisect_left
from itertools import accumulate
from math import ceil


def solve(h, aa, bb):
    max_a = max(aa)
    bf = list(filter(lambda x: x > max_a, bb))
    if not bf:
        return ceil(h / max_a)
    bf.sort(reverse=True)
    bba = list(accumulate(bf))
    remain = h - bba[-1]
    slash_cnt = max(0, ceil(remain / max_a))
    slash_dmg = slash_cnt * max_a
    throw_dmg = h - slash_dmg
    for i, dmg in enumerate(bba):
        if dmg >= throw_dmg:
            break
    return slash_cnt + i + 1


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

print(solve(h, aa, bb))
import sys
def inpl(): return list(map(int, sys.stdin.readline().split()))
N, K = map(int, sys.stdin.readline().split())
A = inpl()
dic = {}
for i in range(N):
    dic[i+1] = A[i]
i = 1
visit = []
visit_set = set()
while i not in visit:
    visit.append(i)
    i = dic[i]
find = visit.index(i)
if K < find:
    print(visit[K])
else:
    visit = visit[find:]
    length = len(visit) - find
    K = (K-find) % length
    print(visit[K])

### FIXED CODE ###

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
i = 0
visit = []
visit_set = set()
while i not in visit_set:
    visit.append(i)
    visit_set.add(i)
    i = A[i] - 1
find = visit.index(i)
if K < find:
    print(visit[K] + 1)
else:
    root = visit[find:]
    K = (K-find) % len(root)
    print(root[K] + 1)
s = input()
if s[0] != s[1] and s[1] != s[2] and s[1] != s[3]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = input()
if s[0] != s[1] and s[1] != s[2] and s[2] != s[0]:
  print("Yes")
else:
  print("No")
from math import ceil
d, t, s = map(int, input().split())
u, l = ceil(d/t), d//t
if u == l:
	if u <= s: print("Yes")
    else: print("No")
else:
    if d/t <= s: print("Yes")
    else:print("No")

### FIXED CODE ###

import sys; input = sys.stdin.readline
from math import ceil
d, t, s = map(int, input().split())
u, l = ceil(d/t), d//t
if u == l:
    if u <= s: print("Yes")
    else: print("No")
else:
    if d/t <= s: print("Yes")
    else:print("No")
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

ans = sum(b)
for i in range(1, n):
  if a[i] == a[i - 1] + 1 and i != n:
    ans += c[a[i] - 1]

print(ans)

### FIXED CODE ###

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

ans = sum(b)
for i in range(1, n):
  if a[i] == a[i - 1] + 1:
    ans += c[a[i - 1] - 1]

print(ans)