peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
c = list(map(int, input().split()))
n, d = c[0], c[1]

xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

count = 0

for l in range(n):
    a = x[l]*x[l] + y[l]*y[l]
    if a <= d*d:
        count += 1
print(count)
# Judge status: Accepted
N, Q=map(int, input().split())
S=input()
count=0
ac=[0]
for i in range(N-1):
  if S[i]=="A" and S[i+1]=="C":
    count+=1
  ac.append(count)
for _ in range(Q):
  l, r=map(int, input().split())
  l-=1
  r-=1
  print(ac[r]-ac[l])
# Judge status: Accepted
i=input
p=print
l=len
person=[i(),i(),i()]
f=0
t="a"
try:
  while True:
    t=person[f][0]
    person[f]=person[f][1:]
    if t=='a':
      f=0
    elif t=='b':
      f=1
    elif t=='c':
      f=2
except IndexError:
  p(['A','B','C'][f])
# Judge status: Accepted
from collections import Counter
N = int(input())
a = list(map(int, input().split()))

c = dict(Counter(a))

cnt = 0

for i, j in c.items():
    if i > j: cnt += j
    else: cnt += j - i
print(cnt)
# Judge status: Accepted
n = int(input())
a_ = []
b_ = []
for i in range(n):
    a, b = list(map(int, input().split()))
    a_.append(a)
    b_.append(b)

to_added = 0
for i in reversed(range(n)):
    temp = a_[i] + to_added
    temp2 = temp % b_[i]
    if temp2 == 0:
        temp3 = 0
    else:
        temp3 = b_[i] - temp2

    to_added += temp3

print(to_added)
# Judge status: Wrong Answer
n,k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
count = 1
chk = []
p = 1
if n == 1:
  print(0)
  exit()
else:
  for i in range(n-1):
    if a[i] != a[i+1]:
      count += 1
      chk.append(p)
      p = 1
    else:
      p += 1
  if a[-1] == a[-2]:
    chk.append(p)
  else:
    chk.append(1)
  chk.sort()
  print(chk)
  print(count)
  if count <= k:
    print(0)
    exit()
  else:
    print(sum(chk[:count-k]))
    exit()
# Judge status: Wrong Answer
n = input()

if n[-1] in [2,4,5,7,9]:
  print('hon')
  
elif n[-1] in [0, 1, 6, 8]:
  print('pon')
  
else:
  print('bon')
# Judge status: Accepted
def main():
    X, N = list(map(int, input().split(' ')))
    if N == 0:
        P = input()
        print(X)
        return
    P = list(map(int, input().split(' ')))
    min_dist, ans = abs(X), 0
    for n in range(102):
        if n in P:
            continue
        if abs(X - n) < min_dist:
            min_dist = abs(X - n)
            ans = n
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
from bisect import bisect
N, *A = map(int, open(0).read().split())

mins = []
length = 0
for a in A:
    i = bisect(mins, -a)
    if i >= length:
        mins.append(-a)
        length += 1
    else:
        mins[i] = -a
print(length)
# Judge status: Wrong Answer
a,b=map(int,input().split())
ans=0
for i in range(a,b+1):
    if i%100==i//1000:ans+=1
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
for a in A:
    if a % 2 == 1:
        continue
    elif a % 3 == 0 or a % 5 == 0:
        continue
    else:
        print("DENIED")
        exit()

print("APPROVED")
# Judge status: Wrong Answer
def main():
    n, d = map(int, input().split())
    ps = [[*map(int, input().split())] for _ in range(n)]
    square = [i**2 for i in range(1, 20)]
    cnt = 0
    for i in range(n-1):
        for j in range(i+1, n):
            if sum([(ps[i][k] - ps[j][k]) ** 2 for k in range(d)]) in square:
                cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()
# Judge status: Accepted
N=int(input())
count=0
T,X,Y=0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    if abs(x-X)+abs(y-Y)<=abs(t-T) and t%2==(x+y)%2:count+=1
    T,X,Y=t,x,y
print('Yes' if count==N else 'No')
# Judge status: Accepted
n,k=map(int,input().split())
A=list(map(int,input().split()))

ng=0
ok=max(A)


while abs(ok-ng)>1:
    mid=(ok+ng)//2
    
    now=0
    for i in A:
        now+= i//mid-1 if i%mid==0 else i//mid
    if now> k :
        ng=mid
    else:
        ok=mid

print(ok)
# Judge status: Accepted


def submit():
    h, w = map(int, input().split())

    if h == 1 or w == 1:
        print(1)
        return
    
    even_c = sum(divmod(w, 2))
    odd_c = w // 2
    even_row = sum(divmod(h, 2)) * even_c
    odd_row = (h // 2) * odd_c

    print(even_row + odd_row)


if __name__ == "__main__":
    submit()
# Judge status: Wrong Answer
N,K=map(int,input().split())
if N<=K:
    print(N)
else:
    A=N%K
    ans=min(A,K-A)
    print(ans)
# Judge status: Accepted
n = int(input())
As = list(map(int, input().split()))

four = sum([1 for a in As if a%4 == 0])
odd = sum([1 for a in As if a%2 == 1])
two = sum([1 for a in As if a%2 == 0 and a%4 != 0])
if four < two%2 + odd - 1:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
a, b, c, k = map(int, input().split())

if a >= k:
  a = k
  b = 0
  c = 0
if a < k and a+b >= k:
  c = 0
if a+b < k:
  c = k - a - b
  
sum_a = 1 * a
sum_c = -1 * c
  
print(sum_a + sum_c)
# Judge status: Accepted
N, M = map(int, input().split())
box = [1] * N
red = [1]
red.extend([0] * (N - 1))

for i in range(M):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    
    if red[x] == 1:
        if box[x] == 1:
            red[x] = 0
        red[y] = 1
    
    box[x] -= 1
    box[y] += 1


print(sum(red))
# Judge status: Accepted
a,b,c,d=map(int,input().split())

if abs(a-c)<=d:
    print("Yes")
elif abs(a-b)<=d and abs(b-c)<=d:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s, w = map(int, input().split())
if w  >= s//2:
    print('unsafe')
else:
    print('safe')
# Judge status: Accepted
#125_C
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))

L=[0 for _ in range(N+1)]
R=[0 for _ in range(N+1)]
for i in range(N):
    L[i+1]=gcd(L[i],A[i])
for i in range(N-1,-1,-1):
    R[i]=gcd(R[i+1],A[i])
    
ans=0
for i in range(N):
    M=gcd(L[i],R[i+1])
    ans=max(ans,M)

print(ans)
# Judge status: Accepted
def main():

    s, t = input().split()
    print(t + s)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a, b, c, d = map(int,input().split())

if abs(a-c) >= d or (abs(a-b) >= d and abs(b-c) >= d):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N,M=map(int, input().split())


print(N*(N-1)//2+M*(M-1)//2)
# Judge status: Wrong Answer
n, m, k = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
SA, SB = [0], [0]
for i in range(n):
    SA.append(SA[i] + A[i])
for j in range(m):
    SB.append(SB[j] + B[j])
ans, tmp = 0, m
for i in range(n + 1):
    if SA[i] > k:
        break
    for j in range(tmp, 0, -1):
        if SA[i] + SB[j] <= k:
            ans = max(ans, i + j)
            break
    tmp = j
print(ans)
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1, n + 1):
    t = n // i
    ans += t * (t + 1) // 2 * i
print(ans)
# Judge status: Accepted
k = int(input())

from collections import deque
queue = deque(range(1,10))
count = 0
while count < k:
  count += 1
  tmp = queue.popleft()
  tail = tmp%10
  if tail != 0:
    queue.append(10*tmp+tail-1)
  queue.append(10*tmp+tail)
  if tail != 9:
    queue.append(10*tmp+tail+1)

print(tmp)
# Judge status: Accepted
a, b = map(int, input().split())

print("{}".format(a*b))
# Judge status: Wrong Answer
n = int(input())
p = list(map(int, input().split()))
s = sorted(p)
count = 0

for i, j in zip(p, s):
    if i != j:
        count += 1

if count > 2:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
S = input()
T = input()

if len(T) == 2 and S[0] == T[0]:
    print("Yes")
else:
    if S[0] == T[0]:
        T = T.replace(S,"")
        if len(T)==1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
# Judge status: Wrong Answer
x,y = map(int,input().split())
if x == y:
  print(-1)
else:
  for i in range(1,10000000):
    a = i * x
    if a % y != 0:
      print(a)
      exit()
# Judge status: Accepted
from collections import deque
n=int(input())
a=list(map(str,input().split()))
b=deque()
#print(b)
for i in range(n):
    if i%2==0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
b=list(b)
if n%2==1:
    b=b[::-1]
print(" ".join(b))
# Judge status: Accepted
n, x, t = map(int, input().split())

if n % x == 0:
  total = n // x * t 
else:
  total = (n// x + 1) * t
print(total)
# Judge status: Accepted
print("01"[eval(input().replace(" ","%"))!=0])
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
if n==1:
  print(a[0])
else:
  l=list(map(lambda z:z**2,a))
  x=sum(a)
  y=sum(l)
  t=(x-y)//2
  print(t)
# Judge status: Accepted
a = list(map(int, input().split()))
a.sort()
ans = 0
while a[0]+1<a[2]:
    a[0] += 2
    ans += 1
    a.sort()
if a[0]==a[1]==a[2]:
    print(ans)
elif a[0]==a[1]:
    print(ans+1)
else:
    print(ans+2)
# Judge status: Accepted
a, b, c, k = list(map(int, input().split()))

if k <= a+b:
    ans = min(a,k)
else:
    ans = 2*a+b-k
print(ans)
# Judge status: Wrong Answer
S = [i for i in input()]
S = set(S)
S = sorted(list(S))
for i in range(97, 122):
    if chr(i) not in S:
        print(chr(i))
        exit(0)
else:
    print('None')
# Judge status: Wrong Answer
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=sorted(a)
b=[0]*(m-1)
for i in range(m-1):
	b[i]=a[i+1]-a[i]
b=sorted(b)
b=b[:m-1-(n-1)]
print(sum(b))
# Judge status: Accepted
a, b = map(int, input().split())
count = 0
for i in range(a, b+1):
    if str(i) == str(i)[::-1]:
        count += 1
print(count)
# Judge status: Accepted
x, a, b = map(int, input().split())

if (-a + b) <= 0:
    print('delicious')
elif 0 < (-a + b) <= x:
    print('safe')
else:
    print('dangerous')
# Judge status: Accepted
N = int(input())
C = []
for i in range(N):
  A, B = map(int, input().split())
  C.append([B, A])
C.sort()
a = 0
ans = 'Yes'
for i in range(N):
  if a + C[i][1] <= C[i][0]:
    a += C[i][1]
  else:
    ans = 'No'
    break
print(ans)
# Judge status: Wrong Answer
list = list(map(int, input().split()))
for i in range(4):
  if list[i]==0:
    print(i+1)
# Judge status: Accepted
import sys
from collections import Counter

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N = int(input())
    S = input().rstrip()

    c = Counter(S)
    ans = 1
    for v in c.values():
        ans = (ans * (v + 1)) % P

    ans = (ans - 1) % P
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
leng = len(input())
ans = 'x' * leng
print(ans)
# Judge status: Accepted
s = sorted(list(map(int, input().split())))
print(sum(s[:2]))
# Judge status: Accepted
x = input()
s_cnt = 0
t_cnt = 0
ans = 0
tmp = 0
for s in x:
    if s == "T":
        if tmp == 0:
            ans += 2
        else:
            tmp -= 1
    else:
        tmp += 1
print(ans)
# Judge status: Accepted
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
mx = 1
L = [0] * (N + 2)
R = [0] * (N + 2)
for i in range(1, N + 1):
    L[i] = gcd(L[i - 1], A[i - 1])
for i in range(N, 0, -1):
    R[i] = gcd(R[i + 1], A[i - 1])
for i in range(1, N + 1):
    mx = max(mx, gcd(L[i - 1], R[i + 1]))
print(mx)
# Judge status: Wrong Answer
l = int(input())

max = 0.0

for x in range(l+1):
    for y in range(l+1-x):
        vol = x * y * (l-x-y)
        if vol > max:
            max = vol

print(max)
# Judge status: Accepted
n = int(input())
num = list(map(int,input().split()))
lis = [0]*(max(num)+4)
for i in num:
    if i == 0:
        lis[i] +=1
        lis[i+1] +=1
    else:
        lis[i-1] +=1
        lis[i] +=1
        lis[i+1] +=1
    
print(max(lis))
# Judge status: Wrong Answer
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if e-a>k:
    print(':(')
else:
    ('Yay!')
# Judge status: Accepted
s=input()
if ((s[0]==s[1] and s[2]==s[3]) or (s[0]==s[2]and s[1]==s[3]) or (s[0]==s[3]and s[1]==s[2])):
  if s[0]==s[1]==s[2]==s[3]:
    print("No")
  else:  
    print("Yes") 
else:
  print("No")
# Judge status: Accepted
a = input()
b = input()
count = 0
for i in range(len(a)):
    if a[i] != b[i]:
        count += 1
print(count)
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())
from fractions import gcd
cd_gcd = gcd(c,d)
lcm= c*d // cd_gcd


ans = []
for i in (a-1,b):
  ans.append(int(i/c) + int(i/d) - int(i/lcm))

print(b-a - (ans[1]-ans[0]))
# Judge status: Accepted
a, b = map(int, input().split())
if a == b:
    print('Draw')
    exit()
if a < b:
    if a == 1 and b == 13:
        print('Alice')
        exit()
    else:
        print('Bob')
        exit()
if b == 1 and a == 13:
    print('Bob')
    exit()
print('Alice')
# Judge status: Accepted
n = int(input()) - 1
ans = ""
for _ in range(13):
    ans += chr(ord("a") + (n%26))
    n //= 26
    if n == 0:
        break
    n -= 1
print(ans[::-1])
# Judge status: Accepted
a, b, k = [int(i) for i in input().split()]

if k < b-a+1:
    tmp1 = list(range(a, a+k))
    tmp2 = list(range(b-k+1, b+1))
    tmp1.extend(tmp2)
    tmp = sorted(list(set(tmp1)))
    
else:
    tmp = list(range(a, b+1))
    
for i in tmp:
    print(i)
# Judge status: Wrong Answer
s=input()
a=[]
for i in range(0,len(s),2):
  a.append(s[i:i+2])
a10=a.count('10')
a01=a.count('01')

if len(s)%2:
  s1=int(s[-1])
else:s1=-1

if a10>a01:
  if s1==0:
    cnt=len(a)-a10+a01+1
  else:
    cnt=len(a)-a10+a01
elif a01>a10:
  if s1==1:
    cnt=len(a)-a01+a10+1
  else:
    cnt=len(a)-a01+a10
else:
  cnt=len(a)
print(cnt)
# Judge status: Accepted
num_list = list(map(int,input().split()))

num_list = sorted(num_list)

print(int(num_list[2]*10 + num_list[0] + num_list[1]))
# Judge status: Accepted


def submit():
    n = int(input())
    s = input()

    cnt = 0
    op = 0
    for c in s:
        if c == "(":
            cnt += 1
        else:
            if cnt == 0:
                op += 1
            else:
                cnt -= 1

    print("(" * op + s + ")" * cnt)


submit()
# Judge status: Wrong Answer
s = input()

sc = 0
tc = 0
ans = len(s)
for si in s:
    if si == "S":
        sc += 1
    else:
        tc += 1
        if sc:
            ans -= min(sc,tc)*2
            sc -= min(sc,tc)
            tc -= min(sc,tc)
        #print(ans,sc,tc)
print(ans)
# Judge status: Accepted
n = int(input())
a_list = []
for i in range(2):
  a_list.append(list(map(int,input().split())))
max_list = [[0 for i in range(n)] for i in range(2)]
max_list[0][0] = a_list[0][0]
max_list[1][0] = a_list[0][0] + a_list[1][0]
for i in range(1,n):
  max_list[0][i] = max_list[0][i-1] + a_list[0][i]
for j in range(1,n):
  max_list[1][j] = max(max_list[0][j],max_list[1][j-1]) + a_list[1][j]
  
print(max_list[1][n-1])
# Judge status: Accepted
o = input()
e = input()
ans = ""
for a,b in zip(o,e):
    ans += a + b

if len(o)-len(e) == 1:
    print(ans+o[-1])
else:
    print(ans)
# Judge status: Wrong Answer
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    S=input()
    W=["Sunny","Cloudy","Rainy"]
    if S==S[0]:print(W[1])
    elif S==S[1]:print(W[2])
    else: print(W[0])
    #%%submit!
resolve()
# Judge status: Accepted
# 147 A

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

if a + b + c >= 22 :
    print("bust")
else:
    print("win")
# Judge status: Accepted
n,m=map(int,input().split())
a=[1]*(n+1)
b=[0]*(n+1)
b[1]=1
for _ in range(m):
  x,y=map(int,input().split())
  a[x]-=1
  a[y]+=1
  if b[x]:b[y]=1
  if a[x]==0:b[x]=0
ans=0
for i,j in zip(a,b):
  ans+=(i!=0)*j
print(ans)
# Judge status: Accepted
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A = [0] * 5
for i in range(5):
    A[i] = ir()

K = ir()
bl = A[-1] - A[0] <= K
print('Yay!' if bl else ':(')
# Judge status: Accepted
import collections
n=int(input())
lst=[]
for i in range(n):
    lst.append(input())
cnt=collections.Counter(lst)
ma=0
for val in cnt.values():
    val=int(val)
    if(val>ma):
        ma=val
li=[]
for key,val in cnt.items():
    val=int(val)
    if(val==ma):
        li.append(key)
li.sort()
for i in li:
    print(i)
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a >= 9 or b >= 9:
    print(":(")
else:
    print("Yay")
# Judge status: Wrong Answer
S = input()

N = S[-1]

if N == 'e':
    print(S+'s')

else:
    print(S+'es')
# Judge status: Wrong Answer
a=list(map(int,input().split()))
for i in range(4):
    if a[i]==0:
        print(i+1)
# Judge status: Accepted
N = int(input())
ans = 0
prev = 0
for i in range(N):
  a = int(input())
  if prev == 1 and a >= 1:
    ans += 1
    a -= 1
  ans += a // 2
  prev = a % 2
print(ans)
# Judge status: Accepted
N = int(input())
X = int(N/1.08)

if int(X*1.08) == N:
    print(X)
elif int((X+1)*1.08) == N:
    print(X+1)
else:
    print(":(")
# Judge status: Wrong Answer
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(1000000)
from collections import deque

# スペース区切りの整数の入力
a, b, c, d = map(int, input().split())

if b <= 0 and d <= 0:
    print(a*c)
elif b < 0 and d > 0:
    print(b*c)
elif b >0 and d < 0:
    print(a*d)
else:
    print(b*d)
# Judge status: Wrong Answer
def main():
    n = int(input())
    S = input()
    ans = ''
    left, right = 0, 0
    for s in S:
        if s == '(':
            left += 1
            if right:
                m = max(left, right)
                ans += '(' *m + ')'*m 
                left, right = 1, 0
        else:
            right += 1
    if right or left:
        m = max(left, right)
        ans += '(' *m + ')'*m
    print(ans)
main()
# Judge status: Wrong Answer
N,K = map(int,input().split())
Count=0
while N > 0:
  N = int(N/K)
  print(N)
  Count=Count+1
print(Count)
# Judge status: Accepted
a, b = map(int, input().split())

if a <= 0 and b >= 0:
    print('Zero')
elif a > 0:
    print('Positive')
else:
    if (b - a) % 2 == 0:
        print('Negative')
    else:
        print('Positive')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

aPlus=0
bPlus=0

for i in range(n):
    if a[i]>b[i]:
        aPlus+=(a[i]-b[i])
    elif a[i]<b[i]:
        if (b[i]-a[i])%2==0:
            bPlus+=(b[i]-a[i])//2
        else:
            aPlus+=1
            bPlus+=(b[i]+1-a[i])//2

if aPlus<=bPlus:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
h = int(input())
w = int(input())
n = int(input())
if n % max(h, w) == 0:
    print(int(n / max(h, w)))
else:
    print(int(n // max(h, w) + 1))
# Judge status: Accepted
import math
A,B,X = map(int,input().split())
if(X >= A*A*B/2):
    arctan = (2*(A*A*B-X))/(A**3)
else:
    arctan = A*B*B/(2*X)
ans = math.degrees(math.atan(arctan))
print(ans)
# Judge status: Accepted
n,h = map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i], b[i] = map(int,input().split())
a = sorted(a, reverse=True)
b = sorted(b, reverse=True)
c = 0
j = 0
while j<n:
    if b[j] > a[0]:
        c += b[j]
    else:
        break
    j += 1
    if c >= h:
        break

if c < h:
    j += -(-(h-c)//a[0])
print(j)
# Judge status: Accepted
N, M = map(int, input().split())

n = 2*M+1
# Mが奇数の場合
if M%2==1:
    for i in range(1, M//2+1):
        print('{} {}'.format(i,M+1-i))
    for i in range(1, (M+1)//2+1):
        print('{} {}'.format(M+i,2*M+2-i))
# Mが偶数の場合
else:
    for i in range(1, M//2+1):
        print('{} {}'.format(i,M+2-i))
    for i in range(1, M//2+1):
        print('{} {}'.format(M+i+1,2*M+2-i))
# Judge status: Accepted
N = int(input())
abcde = [int(input()) for _ in range(5)]
m = min(abcde)

ans = (N + m - 1) // m
ans += 4

print(ans)
# Judge status: Accepted
N = int(input())
S = list()
for i in range(N):
  S.append(input())
M = int(input())
T = list()
for i in range(M):
  T.append(input())
count = 0
maxcount = 0
for i in range(N):
  count = 0
  for j in range(N):
    if S[i] == S[j]:
      count += 1
  for j in range(M):
    if S[i] == T[j]:
      count -= 1
  if count > maxcount:
    maxcount = count
print(maxcount)
# Judge status: Accepted
l, r, d = map(int, input().split())
print(len([i for i in range(l, r+1) if i % d == 0]))
# Judge status: Wrong Answer
def check(s, t, k):
	for i in range(len(t)):
		if s[i+k] != t[i] and s[i+k] != '?':
			return False
	return True

def construct(s, t, k):
	for i in range(len(t)):
		s[i+k] = t[i]
	for i in range(len(s)):
		if s[i] == '?':
			s[i] = 'a'
	return "".join(s)

def resolve():
	s = list(input())
	t = list(input())
	if len(s) < len(t):
		print('UNRESTORABLE')
		return
	for i in range(len(s) - len(t) + 1):
		if check(s, t, i):
			print(construct(s, t, i))
			return
	print('UNRESTORABLE')
resolve()
# Judge status: Accepted
n = input()
w = ["Sunny", "Cloudy", "Rainy"]
for i in range(3):
    if w[i]==n:
        break
print(w[(i+1)%3])
# Judge status: Wrong Answer
a,b = map(int,input().split())
s = input()
ans = ["0","1","2","3","4","5","6","7","8","9"]
ch1 = list(map(str,s[:a]))
ch2 = list(map(str,s[b:]))
count = 0
for i in range(len(ch1)):
    if ch1[i] not in ans:
        count +=1
for j in range(len(ch2)):
    if ch2[i] not in ans:
        count += 1
if count == 0 and s[a] == "-":
    print("Yes")
else:
    
    print("No")
# Judge status: Accepted
import fractions
from functools import reduce

def lcm(x, y):
  return (x * y) // fractions.gcd(x, y)

def lcm_for_lst(lst):
  return reduce(lcm, lst)

n = int(input())
lst = []
for i in range(n):
  t = int(input())
  lst.append(t)
print(lcm_for_lst(lst))
# Judge status: Wrong Answer
from itertools import permutations
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
l=[]
for i in range(n):
    l.append(i+1)
dic= sorted(list(permutations(l,n)))
r=len(dic)
dicp=0
dicq=0
for x in range(r):
    dic[x]=list(dic[x])
    if dic[x]==p:
        dicp=x+1
    elif dic[x]==q:
        dicq=x+1
print(max(dicp-dicq,dicq-dicp))
# Judge status: Accepted
A, B, X=map(int, input().split())
print('YES') if A<=X and A+B>=X else print('NO')
# Judge status: Wrong Answer
N = int(input())
cnt = 0
tmp = 0
for i in range(N):
    a = int(input())
    if tmp ==0:
        cnt += a//2
        tmp = a%2
    elif tmp ==1 and a>0:
        cnt += (a+tmp)//2
        tmp == (a+tmp)%2
    elif a==0:
        tmp = 0

print(cnt)
# Judge status: Accepted
H1,M1,H2,M2,K= list(map(int, input().split()))

a1 = H1*60+M1
a2 = H2*60+M2

print(a2-a1-K)
# Judge status: Accepted
a, b, k = map(int,input().split())
if a+k+1 <= b:
    for i in range(a, k+a):
        print(i)
    if a+k+1 <= b+1-k:
        for i in range(b+1-k, b+1):
            print(i)
    else:
        for i in range(a+k, b+1):
            print(i)
else:
    for i in range(a, b+1):
        print(i)
# Judge status: Accepted
#B
k,x = map(int,input().split())

min_k = x - k + 1
max_k = x + k - 1

ans = []
for i in range(min_k,max_k+1):
    ans.append(i)

print(*ans)
# Judge status: Accepted
N, M = map(int, input().split())
d = (N-1)//2
ans = [(1, 1+d)]

while True:
    a, b = ans[-1][0]+1, ans[-1][1]-1
    
    if a<b:
        ans.append((a, b))
    else:
        break

ans.append((2+d, 1+2*d))

while True:
    a, b = ans[-1][0]+1, ans[-1][1]-1
    
    if a<b:
        ans.append((a, b))
    else:
        break

for a, b in ans[:M]:
    print(a, b)
# Judge status: Accepted
a,b,c = sorted(map(int, input().split()))

print(a*b//2)
# Judge status: Accepted
if __name__ == '__main__':
    s = input()
    if (s[0] == s[1]) and (s[1] == s[2]):
        print("No")
    else:
        print("Yes")
# Judge status: Accepted
def main():
    sx, sy, tx, ty = map(int, input().split())
    ans = solve(sx, sy, tx, ty)
    print(ans)


def solve(sx, sy, tx, ty):
    dx = tx - sx
    dy = ty - sy
    st = 'U' * dy + 'R' * dx
    ts = 'D' * dy + 'L' * dx
    rt1 = st + ts
    rt2 = 'L' + 'U' + st + 'R' + 'D' + 'R' + 'D' + ts + 'L' + 'U'
    ans = rt1 + rt2
    return ans


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
state = 100
count = 1
tmp = a[0]
for i in a:
  if i == tmp:
    pass
  elif i > tmp:
    if state == 1:
      pass
    elif state == 0:
      count += 1
      state = 100
    else:
      state = 1
  else:
    if state == 0:
      pass
    elif state == 1:
      count += 1
      state = 100
    else:
      state = 0
  tmp = i
print(count)