Harryxun/stf_run huggingface dataset:
N, H = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
A = [i[0] for i in AB].sort()
B = [i[1] for i in AB].sort()

count= 0
while len(B) > 0:
    damage = B.pop()
    H -= damage
    count += 1
    if H <= 0:
        print(count)
        return

count += round(H/A[-1])
print(count)


### FIXED CODE ###

from math import ceil
N, H = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
A = [i[0] for i in AB]
A.sort()
B = [i[1] for i in AB]
B.sort()

furudamage = A[-1]
count= 0
while len(B):
    nagedamage = B.pop()
    if nagedamage > furudamage:
        H -= nagedamage
        count += 1
        if H <= 0:
            print(count)
            break
    else:
        break
if H > 0:
    count += ceil(H/furudamage)
    print(count)
import math
print(math.ceil((int(input)+int(input))/2))

### FIXED CODE ###

a,b = map(int,input().split())
import math
print(math.ceil((a+b)/2))
S=input()
if S[1]==S[2] and S[2]==S[3]:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

S=input()
if S[0]==S[1] and S[1]==S[2]:
  print('No')
else:
  print('Yes')
in_list = input().split()
A, B, K = int(in_list[0]), int(in_list[1]), int(in_list[2])

for k in range(K):
  if A > 0:
    A -= 1
  elif B > 0:
    B -= 1
  elif:
	pass

print(A, B)


### FIXED CODE ###

import sys

def stdin_parse_int():
    a = list(map(int,input().split()))
    return a

list = stdin_parse_int()
A = list[0]
B = list[1]
K = list[2]

if A > K:
    print(str(A-K) + " " + str(B))
elif A+B > K:
    print(str(0) + " " + str(A+B-K))
else:
    print("0 0")
import numpy as np
import numpy

N,K = map(int, input().split())
P = list(map(int,input().split()))
M = 0

S = numpy.cumsum(P)
P.append(0)

for i in range(1,N):
    if P[i+K] == 0:
        break
    A = S[i+K] - S[i]
    M = max(M, A)

ans = 0.5 * (M + K)

print(ans)

### FIXED CODE ###

import numpy as np
import numpy

N,K = map(int, input().split())
P = list(map(int,input().split()))

S = numpy.cumsum(P)
P.append(0)
M = S[K-1]

for i in range(0,N):
    if P[i+K] == 0:
        break
    A = S[i+K] - S[i]
    M = max(M, A)

ans = 0.5 * (M + K)

print(ans)
# https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
    def __init__(self, N):
        self._root = [-1 for _ in range(N)]

    def find(self, x):
        if self._root[x] < 0: return x
        self._root[x] == self.find(self._root[x])
        return self._root[x]

    def unite(self, x, y):
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy:
            return False
        if self._root[gx] > self._root[gy]:
            gx, gy = gy, gx
        self._root[gx] += self._root[gy]
        self._root[gy] = gx
        return True

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

    def size(self, x):
        return -(self._root[self.find(x)])

    def roots(self):
        return [i for i in self._root if i < 0]


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

nodes = []
for _ in range(m):
    a, b = map(int, input().split())
    nodes.append((a,b))

cnt = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i != j:
           uf.unite(nodes[j][0]-1, nodes[j][1]-1)
    cnt += (len(uf.roots()) != 1)
print(cnt)

### FIXED CODE ###

# https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
    def __init__(self, N):
        self._root = [-1 for _ in range(N)]

    def find(self, x):
        if self._root[x] < 0: return x
        self._root[x] = self.find(self._root[x])
        return self._root[x]

    def unite(self, x, y):
        gx = self.find(x)
        gy = self.find(y)
        if gx == gy: return False
        if self._root[gx] > self._root[gy]:
            gx, gy = gy, gx
        self._root[gx] += self._root[gy]
        self._root[gy] = gx
        return True

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

    def size(self, x):
        return -(self._root[self.find(x)])

    def roots(self):
        return [i for i in self._root if i < 0]


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

nodes = []
for _ in range(m):
    a, b = map(int, input().split())
    nodes.append((a, b))

cnt = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i != j:
          uf.unite(nodes[j][0]-1, nodes[j][1]-1)
    cnt += (len(uf.roots()) != 1)
print(cnt)
S=input()
K=int(input())
L=len(S)
cnt=0
ren=1

if L==1:
  ans= K//2
elif L==2:
  if S[0]==S[1]:
    ans = K
  else:
    ans = 0
else:  #|S|>=3が保証
  if S[0]!=S[-1]:
    for i in range(1,L):  
      if S[i]==S[i-1]:
        ren +=1
        if i==L-1:
          cnt += ren//2  
      else:
        cnt += ren//2
        ren=1
    ans=cnt*K
  else:
    head=0
    tail=0
    i=0
    j=0
    while S[i]==S[0]:
      head += 1
      i +=1
    while S[-1-j]==S[-1]:
      tail += 1
      j += 1
    #print(head,tail)
    if L-head-tail==0:
      print(K*L//2)
    elif L-head-tail<0:
      ans=K*L//2
    else:  
      for k in range(head,L-tail):  
        #print("k=",k,"S[k]=",S[k])
        if S[k]==S[k-1]:
          ren +=1
          if k==L-tail-1:
            cnt += ren//2  
        else:
          cnt += ren//2
          ren=1
      #print("cnt",cnt)   
      
    ans=K*cnt + (K-1)*(head+tail)//2 + head//2 + tail//2
    
print(ans)


### FIXED CODE ###

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

if S.count(S[0])==N:
  ans= K*N//2
else:
  h=0
  for i in range(N):
    if S[i]==S[0]:
      h +=1
    else:
      break
  t=0
  for i in range(N-1,-1,-1):
    if S[i]==S[-1]:
      t +=1
    else:
      break
  ren=1
  cnt=0
  for i in range(h,N-t):
    if S[i]==S[i-1]:
      ren +=1
      if i==N-t-1:
        cnt += ren//2
    else:
      cnt += ren//2
      ren=1    
      
  if S[0]==S[-1]:
    #print(h//2, (K-1)*((h+t)//2), t//2 ,K*cnt)
    ans= h//2 + (K-1)*((h+t)//2) + t//2 + K*cnt
  else:
    #print(h//2,cnt,t//2)
    ans= (h//2 + cnt + t//2)*K
print(ans)
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
a = iarr()

cum = []; sum = 0
for num in a: sum += num; cum.append(sum)

ans = 1
now = 1
for i in range(n):
    next = min(2*(now - a[i]), cum[n]-cum[i])
    now = next
    if n==i and next<0 : ans = -1; break
    if n!=i and next<=0 : ans = -1; break
    ans += next

if a[n] > 2**n: ans = -1
if a[1] < 2: ans = -1
print(ans)



### FIXED CODE ###

import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
a = iarr()

cum = []; sum = 0
for num in a: sum += num; cum.append(sum)

ans = 1
now = 1
for i in range(n+1):
    next = min(2*(now - a[i]), cum[n]-cum[i])
    now = next
    if n==i and next<0 : ans = -1; break
    if n!=i and next<=0 : ans = -1; break
    ans += next

if a[n] > 2**n: ans = -1
print(ans)
S = input()
s_1 = S[:2]
s_2 = S[2:]

if 0 < s_1 < 13 and 0 < s_2 < 13:
  print("AMBIGUOUS")
elif 0 < s_1 < 13:
  print("MMYY")
elif 0 < s_2 < 13:
  print("YYMM")
else:
  print("NA")

### FIXED CODE ###

S = input()
s_1 = int(S[:2])
s_2 = int(S[2:])

if 0 < s_1 < 13 and 0 < s_2 < 13:
  print("AMBIGUOUS")
elif 0 < s_1 < 13:
  print("MMYY")
elif 0 < s_2 < 13:
  print("YYMM")
else:
  print("NA")
a,b=map(int,input().split())
c=list(map(int,input().split()))
required=sum(c)/(4*b)
count=0
for d in sorted(c,reverse=True):
  if d>=required:
      count+=1
  else:
      break
print("YNeos"[count<b::2])

### FIXED CODE ###

a,b,c=map(int,input().split())
print(c,a,b)
A, B = input().split()
print(format((A*B), '.0f'))

### FIXED CODE ###

def resolve():
    A, B = input().split()
    ans = int(A)*int(B[0])*100+int(A)*int(B[2:])
    print(str(ans)[:-2] if len(str(ans)) >= 3 else "0")
resolve()
a, b = map(int,input.split)
if a * b // 2 == 1:
  print(Odd)
else:
  print(Even)

### FIXED CODE ###

a,b = map(int,input().split())
 
print("Even" if (a * b) % 2 == 0 else "Odd" )
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
a = []
correct_num = 0
for i in range(N):
    a.append(map(int, input().split()))
    sum = 0
    for j in range(M):
        sum + =a[i][j] * B[j]
    if sum > 0:
        correct_num += 1
    else:
        pass
print(sum)

### FIXED CODE ###

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
a = []
correct_num = 0
for i in range(N):
    a.append(list(map(int, input().split())))
    sum = 0
    for j in range(M):
        sum += a[i][j] * B[j]
    if sum + C > 0:
        correct_num += 1
    else:
        pass
print(correct_num)
n = int(input())
ans = 0
li = []
for i in range(n):
    a, b = map(int, input().split())
    li.append([a+b, a, b])

li = sorted(li)
li = reversed(li)
for i in range(n):
    if i%2 == 0:
        ans += li[i][1]
    else:
        ans -= li[i][2]

print(ans)




### FIXED CODE ###

n = int(input())
ans = 0
li = []
for i in range(n):
    a, b = map(int, input().split())
    li.append([a+b, a, b])

li = sorted(li)
li.reverse()
for i in range(n):
    if i%2 == 0:
        ans += li[i][1]
    else:
        ans -= li[i][2]

print(ans)
N,D = map(int,input().split())
import numpy as np
xlist = [list(map(int,input().split())) for i in range(n)]
xarray = np.array(xlist)
ans = 0
for i in range(n):
  for j in range(i+1,n+1):
    if (xarray[i]-xarray[j])%1!=0:
      ans+=1
print(ans)

### FIXED CODE ###

n,d = map(int,input().split())
import numpy as np
xlist = [list(map(int,input().split())) for i in range(n)]
xarray = np.array(xlist)
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if np.linalg.norm(xarray[i]-xarray[j])==int(np.linalg.norm(xarray[i]-xarray[j])):
      ans+=1
print(ans)
A,B = map(int,input().split(' '))
result = int(A*B)
print(result)

### FIXED CODE ###

A, B = map(str, input().split()) # take the input in one line
A = int(A) # convert A into integer
C = B[0]+B[2]+B[3]
C = int(C)
print(A*C//100) # printing the output

# time complixity O(1)
n=input()
#print(n)
mynum=2**(len(n)-1)
#print(mynum)
data=['','+']
x=['0']*10000
#print(x)

for i in range(mynum):
  y=format(i, 'b')
  z=y.zfill(len(n)-1)
  x[i]=n[0]
  for j in range(len(z)):
    x[i]+=data[int(z[j])]+n[j+1]
#  print(x[i])           
x=[eval(i) for i in x]

print(sum(x))
#12656242944

### FIXED CODE ###

n=input()
size=len(n)
#print(n,size)

ans=0
for i in range(2**(size-1)):
    z=format(i,'b').zfill(size-1)
#    print(z)
    string=n[0]
    for j in range(size-1):
        if z[j]=='1':
            string+='0'+n[j+1]
        elif z[j]=='0':
            string+=n[j+1]
    string=string.replace('0','+')
    ans+=eval(string)

print(ans)

#12656242944
import  heapq

N, M = map(int, input().split())
data = [[int(x) for x in input().split()] for i in range(N)]

data.sort(reverse=True, key=lambda x: (-x[0], x[1]))

day = M
reward = 0

# d日前
q = []
i = 0
for d in range(1, M + 1):
    for t in range(i, N):
        if data[t][0] > d:
            break
        i += 1
        heapq.heappush(q, -1 * data[t][1])
    reward += heapq.heappop(q)

print(-1 * reward)





### FIXED CODE ###

import  heapq
 
N, M = map(int, input().split())
data = [[int(x) for x in input().split()] for i in range(N)]
data.sort(reverse=True, key=lambda x: (-x[0], x[1]))
 
day = M
reward = 0
 
# d日前
q = []
i = 0
for d in range(1, M + 1):
    for t in range(i, N):
        if data[t][0] > d:
            break
        i += 1
        heapq.heappush(q, -1 * data[t][1])
    if q:
        reward += heapq.heappop(q)
 
print(-1 * reward)
N,M= list(map(int, input().split()))
P = [list(map(int,input().split())) for i in range(M)]
Q = list(map(list, set(map(tuple, P))))
C = []
S = []
n = N -1
sum1 = 0

for s in range(len(Q)):
    C.append(Q[s][0])
for t in range(len(Q)):
    S.append(Q[t][1])
D = list(set(C))
if len(D) <len(S) :
    print("-1")
elif N < max(D):
    print("-1")
else:
    if N == 1 and M == 1 and Q[0][1] == 0:
        print("0")

    else:
        for u in range(len(Q)):
            sum1 = sum1 + Q[u][1]*(10 ** (N - Q[u][0]))
        if sum1 >= (10 ** n):
            print(sum1)
        else:
            if D.count(1) >= 1:
                unko = C.index(1)
                if Q[unko][1] == 0:
                    print("-1")
                else:
                    print(sum1 + 10 ** n)
            else:
                print(sum1 + 10 ** n)


### FIXED CODE ###

N,M= list(map(int, input().split()))
P = [list(map(int,input().split())) for i in range(M)]
Q = list(map(list, set(map(tuple, P))))
C = []
S = []
n = N -1
sum1 = 0
 
for s in range(len(Q)):
    C.append(Q[s][0])
for t in range(len(Q)):
    S.append(Q[t][1])
D = list(set(C))
if len(D) <len(S) :
    print("-1")
else:
    if N == 1 and M == 1 and Q[0][1] == 0:
        print("0")
    elif N == 1 and M == 0:
                print("0")
    else:
        for u in range(len(Q)):
            sum1 = sum1 + Q[u][1]*(10 ** (N - Q[u][0]))
        if sum1 >= (10 ** n):
            print(sum1)
        else:
            if D.count(1) >= 1:
                unko = C.index(1)
                if Q[unko][1] == 0:
                    print("-1")
                else:
                    print(sum1 + 10 ** n)
            else:
                print(sum1 + 10 ** n)
print(int(input(R))*6.3)


### FIXED CODE ###

import math

R = int(input())

print(R * 2 * math.pi)
import numpy as np
n,k,q=map(int,input().split())
a=[int(input()) for i in range(Q)]
li=np.array([0]*n)
d=np.array([k-q]*n)
for j in range(0,len(a)):
  li[a[j]-1]+=1

  
ans=np.array(li+d)


for m in range(0,n):
  if ans[m]>0:
    print("Yes")
  else:
    print("No")


### FIXED CODE ###

import numpy as np
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
li=np.array([0]*n)
d=np.array([k-q]*n)

for j in range(0,len(a)):
  li[a[j]-1]+=1

  
ans=np.array(li+d)


for m in range(0,n):
  if ans[m]>0:
    print("Yes")
  else:
    print("No")
S = list(map(int,input().split()))
len(S)=int(p)
t=0
for n in range(p):
  if S[n]=S[p-n-1]:
    continue
  else:
    t+=1
print(t)

### FIXED CODE ###

S = input()
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(int(t/2))
H=int(input())
import math
H=int(math.log2())
print(2**(H+1))

### FIXED CODE ###

H=int(input())
import math
H=int(math.log2(H))
print(2**(H+1)-1)
# -*- coding: utf-8 -*-

N = int(input())

dp = {b: 1 for b in "ACGT"}
for _ in range(N - 1):
    dp_new = {}
    for k in dp:
        for b in "ACGT"
           if k[-2:] + b in ("AGC", "ACG", "GAC") or k[-3:4] + b in ("ACGC", "AGGC", "ATGC", "AGCC", "AGGC", "AGTC"):
                continue
            else:
                dp_new[k[-3:] + b] += dp[k]
    dp = dp_new

mod = 10 ** 9 + 7
print(sum(dp.values()) % mod)


### FIXED CODE ###

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

import itertools
comb = list(map(''.join, itertools.product("ACGT", repeat=4)))

mod = int(1e9) + 7

N = int(input())

dp = {c: [0, 0] for c in comb}
dp["TTTT"] = [1, 0]

for _ in range(N):
    dp_new = {c: [0, 0] for c in comb}
    for k in dp:
        for b in "ACGT":
            if k[2:4] + b in ("AGC", "ACG", "GAC") or k[1:4] + b in ("ACGC", "AGGC", "ATGC", "AGCC", "AGGC", "AGTC"):
                dp_new[k[1:4] + b][1] += dp[k][0]
                dp_new[k[1:4] + b][1] += dp[k][1]
            else:
                dp_new[k[1:4] + b][0] += dp[k][0]
                dp_new[k[1:4] + b][1] += dp[k][1]
    dp = dp_new


print((4 ** N - sum([dp[k][1] for k in dp])) % mod)
a, b, c = map(int, input().split())
print(a + b + c - , max(a, b, c))

### FIXED CODE ###

a, b, c = map(int, input().split())
print(a + b + c - max(a, b, c))
n, m = map(int, input().split())
submits = []
for i in range(m):
  submit = input().split()
  submits.append(submit)
wa = 0
ac = 0
l = [submits[0]]
for i in range(1, m):
  if submits[i] == submits[i-1]:
    l.append(submits[i])
  else:
    l = []
    l.append(submits[i])
  if i != m-1 and submits[i] != submits[i+1]:
    for j in range(len(l)):
      if l[j][1] == "WA":
        wa += 1
      else:
        ac += 1
        break
  elif i == m-1:
    for j in range(len(l)):
      if l[j][1] == "WA":
        wa += 1
      else:
        ac += 1
        break
print(ac, wa)


### FIXED CODE ###

n, m = map(int, input().split())
acs = [0]*n
was = [0]*n
ac = 0
wa = 0
for i in range(m):
  p, s = input().split()
  p = int(p) - 1
  if s == "AC" and acs[p]==0:
    acs[p] += 1
    ac += 1
    wa += was[p]
  elif s == "WA":
    was[p] += 1
print(ac, wa)
class Dijkstra():
    """ ダイクストラ法
    重み付きグラフにおける単一始点最短路アルゴリズム

    * 使用条件
        - 負のコストがないこと
        - 有向グラフ、無向グラフともにOK

    * 計算量はO(E*log(V))

    * ベルマンフォード法より高速なので、負のコストがないならばこちらを使うとよい
    """
    class Edge():
        """ 重み付き有向辺 """
        def __init__(self, _to, _cost):
            self.to = _to
            self.cost = _cost

    def __init__(self, V):
        """ 重み付き有向辺
        無向辺を表現したいときは、_fromと_toを逆にした有向辺を加えればよい

        Args:
            V(int): 頂点の数
        """
        self.G = [[] for i in range(V)]  # 隣接リストG[u][i] := 頂点uのi個目の隣接辺
        self._E = 0  # 辺の数
        self._V = V  # 頂点の数

    @property
    def E(self):
        """ 辺数
        無向グラフのときは、辺数は有向グラフの倍になる
        """
        return self._E

    @property
    def V(self):
        """ 頂点数 """
        return self._V

    def add(self, _from, _to, _cost):
        """ 2頂点と、辺のコストを追加する """
        self.G[_from].append(self.Edge(_to, _cost))
        self._E += 1

    def shortest_path(self, s):
        """ 始点sから頂点iまでの最短路を格納したリストを返す
        Args:
            s(int): 始点s
        Returns:
            d(list): d[i] := 始点sから頂点iまでの最短コストを格納したリスト。
                     到達不可の場合、値はfloat("inf")
        """
        import heapq
        que = []  # プライオリティキュー（ヒープ木）
        d = [10**15] * self.V
        d[s] = 0
        heapq.heappush(que, (0, s))  # 始点の(最短距離, 頂点番号)をヒープに追加する

        while len(que) != 0:
            cost, v = heapq.heappop(que)
            # キューに格納されている最短経路の候補がdの距離よりも大きければ、他の経路で最短経路が存在するので、処理をスキップ
            if d[v] < cost: continue

            for i in range(len(self.G[v])):
                # 頂点vに隣接する各頂点に関して、頂点vを経由した場合の距離を計算し、今までの距離(d)よりも小さければ更新する
                e = self.G[v][i]  # vのi個目の隣接辺e
                if d[e.to] > d[v] + e.cost:
                    d[e.to] = d[v] + e.cost  # dの更新
                    heapq.heappush(que, (d[e.to], e.to))  # キューに新たな最短経路の候補(最短距離, 頂点番号)の情報をpush
        return d

def main():
    N,M=map(int,input().split())
    key=[]
    for i in range(0,M):
        a,b=map(int,input().split())
        c=list(map(int,input().split()))
        s=sum(2**(c[j]-1) for j in range(0,b))
        key.append(s*(10**6)+a)


    node=2**N
    djk=Dijkstra(node)
    for i in xrange(0,M):
        for j in xrange(0,node):
            s=key[i]//(10**6)
            a=key[i]%(10**6)
            djk.add(j,s|j,a)

    d=djk.shortest_path(0)
    if d[node-1]==10**15:
        print(-1)
    else:
        print(d[node-1])


if __name__=="__main__":
    main()

### FIXED CODE ###

N,M=map(int,input().split())
key=[]
cost=[]
for i in range(0,M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    s=sum(2**(c[j]-1) for j in range(0,b))
    key.append(s)
    cost.append(a)

node=2**N

dp=[[10**10 for i in range(0,node)] for j in range(0,M)]

for i in range(0,M):
    dp[i][node-1]=0
#i:何番までか j:手に入れた鍵
for i in range(0,M):
    for j in range(1,node):
        k=node-1-j
        if i==0:
            if k|key[0]==node-1:
                dp[0][k]=cost[0]
        else:
            dp[i][k]=min(dp[i-1][k],dp[i-1][k|key[i]]+cost[i])

if dp[M-1][0]>=10**10:
    print(-1)
else:
    print(dp[M-1][0])
MOD = 10**9 + 7
N = int(input())
C = []
last_idx = [None for i in range(N+1)]
bef = [None for i in range(N+1)]
for i in range(1,N+1):
	c = int(input())
	C.append(c)
	if last_idx[c] != None:
		bef[i] = last_idx[c]
	last_idx[c] = i
dp = [0 for i in range(N+1)]
dp[1] = 1
for i in range(2, N+1):
	if bef[i] != None and bef[i] < i-1:
		dp[i] = (dp[i-1] + dp[bef[i]]) % MOD
	else:
		dp[i] = dp[i-1]
print(dp[N])

### FIXED CODE ###

MOD = 10**9 + 7
N = int(input())
C = []
last_idx = [0 for i in range(200001)]
bef = [0 for i in range(N+1)]
for i in range(1,N+1):
	c = int(input())
	C.append(c)
	bef[i] = last_idx[c]
	last_idx[c] = i
dp = [0 for i in range(N+1)]
dp[1] = 1
if N == 1 or N == 2:
	print(1)
	exit()

for i in range(2, N+1):
	if bef[i] < i-1:
		dp[i] = (dp[i-1] + dp[bef[i]]) % MOD
	else:
		dp[i] = dp[i-1]
print(dp[N])
S = input()
T = input()
N = len(T)

flag = False
pos = 51
ans = ""
for i in range(len(S)-4):
    cnt = 0
    for j in range(N):
        if S[i+j] == "?" or S[i+j] == T[j]:
            cnt += 1
        else:
            break
    if cnt == N:
        pos = i
        flag = True
        break
if flag:
    for i in range(len(S)):
        if pos <= i and i < pos + N:
            ans += T[i-pos]
        elif S[i] == "?":
            ans += "a"
        else:
            ans += S[i]
else:
    ans = "UNRESTORABLE"
print(ans)

### FIXED CODE ###

S = input()
T = input()
N = len(T)

if len(S) < N:
    print("UNRESTORABLE")
    import sys
    sys.exit()

flag = False
pos = 51
ans = ""
for i in range(len(S)-N+1):
    cnt = 0
    for j in range(N):
        if S[i+j] == "?" or S[i+j] == T[j]:
            cnt += 1
        else:
            break
    if cnt == N:
        pos = i
        flag = True
if flag:
    for i in range(len(S)):
        if pos <= i and i < pos + N:
            ans += T[i-pos]
        elif S[i] == "?":
            ans += "a"
        else:
            ans += S[i]
else:
    ans = "UNRESTORABLE"
print(ans)
n=sys.argv
print(n*n*n)

### FIXED CODE ###

n=input()
num=int(n)
print(num*num*num)
import math
n = int(input())
a = list(map(int, input().split()))
a.sort()
max_gcd = 1
if len(a) == 2:
    max_gcd = max(a)
else:
    gcd1 = math.gcd(a[0], a[1],a[2])
    gcd2 = math.gcd(a[1], a[2],a[3])
    gcd3 = math.gcd(a[2], a[0],a[3])
    gcd4 = math.gcd(a[0],a[1],a[3])
    max_gcd = max(gcd1,gcd2, gcd3, gcd4)

print(max_gcd)

### FIXED CODE ###

def gcd(a,b):
    l = max(a,b)
    s = min(a,b)
    if s == 0:
        return l
    else:
        return gcd(s, l%s)

n = int(input())
a = [0] + list(map(int, input().split())) + [0]
max_gcd = 1
L = [0] * (n+2)
R = [0] * (n+2)

for i in range(1,n+2):
    L[i] = gcd(a[i],L[i-1])
    R[n+1-i] = gcd(a[n+1-i], R[n+2-i])
for i in range(1,n+1):
    max_gcd = max(max_gcd,gcd(L[i-1], R[i+1]))

print(max_gcd)
import math

def solve(n, x0, X):
    X = [x - x0 for x in X]
    g = X.pop()
    for x in X:
        g = math.gcd(g, x)
    return g

_n , _x0 = map(int, input().split())
_X = map(int, input().split())
print(solve(_n, _x0, _X))

### FIXED CODE ###

def solve(n, x0, X):

    def gcd(a, b):
        if a > b:
            a, b = b, a
        while a % b != 0:
            a, b = b, a % b
        return b

    X = [abs(x - x0) for x in X]
    g = X.pop()
    for x in X:
        g = gcd(g, x)
    return g

_n , _x0 = map(int, input().split())
_X = map(int, input().split())
print(solve(_n, _x0, _X))