Harryxun/stf_run huggingface dataset:
import sys
import copy

N, M = map(int, input().split())

V = []
E = []

for i in range(N):
    V.append(set())

for i in range(M):
    *l,  = map(int, input().split())
    V[l[0]-1].add(l[1]-1)
    V[l[1]-1].add(l[0]-1)
    E.append([l[0], l[1]])

count = 0


E_copy = copy.deepcopy(E)
V_copy = copy.deepcopy(V)

for i in range(M):
    e = [E[i][0], E[i][1]]

	V[e[0]].remove(e[1])
    V[e[1]].remove(e[0])
    
    #辺が存在しないノードがあるかをチェックする。
    for v in V:
        if len(v)==0:
            count = count + 1
            break
    
    E = copy.deepcopy(E_copy)
    V = copy.deepcopy(V_copy)
   
print(count)


### FIXED CODE ###

import sys
import copy


N, M = map(int, input().split())

V = []
E = []

for i in range(N):
    V.append(set())

seen = []
seen = [False] * N

count = 0
def dfs(node):
    global V
    global seen

    #注目ノードは訪問済みか?
    if seen[node]==True:
        return
    
    seen[node]=True

    for next_node in V[node]:
        dfs(next_node)
    return

for i in range(M):
    *l,  = map(int, input().split())
    V[l[0]-1].add(l[1]-1)
    V[l[1]-1].add(l[0]-1)
    E.append([l[0]-1, l[1]-1])



E_copy = copy.deepcopy(E)
V_copy = copy.deepcopy(V)
seen_copy = copy.deepcopy(seen)


for i in range(M):
    e = [E[i][0], E[i][1]]
    
    V[e[0]].remove(e[1])
    V[e[1]].remove(e[0])
    
    dfs(0)
    if (False in seen):
        count = count + 1
    seen = [False] * N
    V = copy.deepcopy(V_copy)
   
print(count)
x=input()
if x == 7 or 5 or 3:
print("YES")
else:
print("NO")

### FIXED CODE ###

x=int(input())
if x == 7 or x == 5 or x == 3:
	print("YES")
else:
	print("NO")
a,b,c,d = map(int,input().split())
l = 0
if abs(a-c)=<d:
  print("Yes")
  l += 1
if abs(a-b)=<d:
  if abs(b-c)=<d:
    if l == 0:
      print("Yes")
  else:
    print("No")
else:
  print("No")

### FIXED CODE ###

a,b,c,d=map(int,input().split())
if abs(c-a)<=d:
  print("Yes")
elif abs(c-b)<=d and abs(b-a)<=d:
  print("Yes")
else:
  print("No")
#x,t=list(map(int,input().split()))
x = int(input())
if x <= 1200:
    print("ABC")
else:
    prit("ARC")
    


### FIXED CODE ###

#x,t=list(map(int,input().split()))
x = int(input())
if x < 1200:
    print("ABC")
else:
    print("ARC")
M, K = map(int, input().split())
if 2**M <= K:
    print(-1)
    exit(0)
if M == 1:
    if K == 1:
        print(-1)
    else:
        print("0 0 1 1")
else:
    *R, = [i for i in range(2**M) if i != K]
    print(K, *R, K, *reversed(R))

### FIXED CODE ###

M, K = map(int, input().split())
if 2**M <= K:
    print(-1)
    exit(0)
if M == 1:
    if K == 1:
        print(-1)
    else:
        print("0 0 1 1")
else:
    R = [i for i in range(2**M) if i != K]
    *S, = reversed(R)
    ans = [K] + R + [K] + S
    print(*ans)
a,b,c,k=map(int,input().split())
ai=0
bi=0
ci=0
if a >= k:
  ai=k
else:
  ai=a
  if b>= k-ai:
    bi=k-ai
    else:
      bi=b
      ci= k - ai - bi
print(ai-ci)
        


### FIXED CODE ###

a,b,c,k=map(int,input().split())
ai=0
bi=0
ci=0
if a >= k:
  ai=k
else:
  ai=a
  if b>= k-ai:
    bi=k-ai
  else:
    bi=b
    ci= k - ai - bi
print(ai-ci)
#Iroha Loves Strings (ABC Edition)
N, L = map(int, input().split())
S = []
for _ in range(N):
    S.append(input())
sort = sorted(S)
R = ""
for i in range(0,N):
    R = R + sort[i]
print(R)

### FIXED CODE ###

A,B,C = map(int,input().split())
S = A+B+C
if S == 17:
    S = S - max(A, B, C)
    if S == 10:
        S = S - min(A, B, C)
        if S == 5:
            print("YES")
        else:
            pass
    else:
        pass
else:
    print("NO")
def step_memo(H):
    N = len(H)
    memo = ["E"]*N
    n = N-1
    def step(n):
        if n == 0:
            memo[0] = 0
            return memo[0]
        elif n == 1:
            memo[1] = abs(H[1]-H[0])
            return memo[1]
        elif memo[n] != "E":
            return memo[n]
        else:
            memo[n]= min(step(n-2)+abs(H[n-2]-H[n]), step(n-1)+abs(H[n-1]-H[n]))
            return memo[n]
    return step(n)

N = int(input())
H = list(map(int, input().split()))
print(step_memo(H))

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
points = [0]*N
points[1] = abs(H[1]-H[0])
for i in range(2,N):
    points[i] = min(points[i-2]+abs(H[i-2]-H[i]), points[i-1]+abs(H[i-1]-H[i]))
print(points[-1])
n=int(input())
A=list(map(int,input().split()))
seq=0
B=[]
for i in range(n-1):
  if A[i]>=A[i+1]:
    seq+=1
  else:
    B.append(seq)
    seq=0
print(max(B))

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
seq=0
B=[]
for i in range(n-1):
  if A[i]>=A[i+1]:
    seq+=1
  else:
    B.append(seq)
    seq=0
B.append(seq)
print(max(B))
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
point = 0

for i in range(N):
  count+= B[A[i]]
  if i>0 and A[i] = A[i-1]:
    count += C[A[i-1]]
print(count)

### FIXED CODE ###

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

for i in range(N):
    point += B[A[i]-1]
    if i>0 and A[i]-1 == A[i-1]:
        point += C[A[i-1]-1]
print(point)
from functools import lru_cache

@lru_cache(maxsize=1000)
N = int(input())
S =input()
a = 0
for i in range(N-2):
  for j in range(i,N-1):
    for k in range(j,N):
      if S[i] != S[j] and S[i] != S[k] and S[k] != S[j] and j -i != k-j:
        a+= 1
        print(a)

### FIXED CODE ###

n = int(input())
s = input()

r = 0
g = 0
b = 0


for ss in s:
    if ss == "R":
        r += 1
    elif ss == "G":
        g += 1
    elif ss == "B":
        b += 1
ng = 0
i = 0
while i < n:
    j = 1
    while i+2*j < n:
        if s[i] != s[i+j] and s[i+j] != s[i+2*j] and s[i] != s[i+2*j]:
            ng += 1
        j += 1
    i += 1
print(r*g*b-ng)
#D
n = int(input())
A = list(map(int, input().split()))

sum_eve = sum(A[0::2])
sum_odd = sum(A[1::2])

x = [0] * n

x[0] = sum_eve - sum_odd

for num in range(1, n):
    x[num] = 2 * A[num-1] - x[num-1]
    
ans = " ".join(map(str,x))

pritn(ans)

### FIXED CODE ###

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

sum_eve = sum(A[0::2])
sum_odd = sum(A[1::2])

x = [0] * n

x[0] = sum_eve - sum_odd

for num in range(1, n):
    x[num] = 2 * A[num-1] - x[num-1]
    
ans = " ".join(map(str,x))
print(ans)
def mx(ls,i):
    if i == 0: return 0
    else     : return (i+1)*ls.pop()+ mx(i-1)

def cns(ls,m,sm):
    global n, s
    count = 0
    if m == n:
        if sm == s: return 1
        else      : return 0
    elif s-mx(ls,n-m+1) <= sm <= s:
        for i in range(9-m+1):
            rls = ls[:]
            k = rls.pop(i)
            count += cns(rls,m+1,sm+(m+1)*k)
        return count
    else: return 0

ls = [0,1,2,3,4,5,6,7,8,9]
while True:
    n, s = map(int, raw_input().split())
    if s > mx(ls,n): print 0
    else        : print cns(ls,0,0)

### FIXED CODE ###

def mxmn(ls,m):
	global n
	s1,s2 = 0, 0
	for i in range(m):
		s1 += (n-i)*ls[-i-1]
		s2 += (n-i)*ls[i]
	return s1,s2

def f(ls,m,s):
	global n
	count = 0
	if m > 0:
		mx,mn = mxmn(ls,m)
		if mx < s or mn > s: return 0
		elif mx == s or mn == s: return 1
		for i in range(len(ls)):
			lls = ls[:]
			a = (n-m+1)*lls.pop(i)
			if s-a < 0:	break
			else: count += f(lls,m-1,s-a)
		return count
	else:
		return 1 if s == 0 else 0
			
ls = [i for i in range(10)]
while True:
	try:
		n,s = map(int, raw_input().split())
		print f(ls,n,s)
	except:
		break
L,R = map(int,input().split())

# L <= i,j <== R の中で、i*j mod 2019の最小値を求めよ

# L,R は 0 ~ 2*10^9

# (i*j) mod 2019 = (i mod 2019) * (j mod 2019)

if(R <= 2019):
    ans = (R%2019)* ((R-1)%2019)

if(L >= 2019):
    if(L % 2019 < R % 2019):
        ans = (L % 2019)* ((L+1)%2019) % 2019
    else:
        ans = (R%2019)* ((R-1)%2019) % 2019
print(ans)

### FIXED CODE ###

L,R = map(int,input().split())

# L <= i,j <== R の中で、i*j mod 2019の最小値を求めよ

# L,R は 0 ~ 2*10^9

# (i*j) mod 2019 = (i mod 2019) * (j mod 2019) %2019

# =============================================================================
# for i in range(2019):
#     for j in range(i,2019):
#         a = (i*j) % 2019
#         b = (i % 2019)*(j % 2019) % 2019
#         if a != b:
#             print(i,a,b)
# =============================================================================

# 全探索: 2019*2019が最大

dist = (R - L)
if dist >= 2019:
    print("0")
else:
    ans = 999999
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans = min(ans,(i*j) % 2019)
    print(ans)
x, n = map(int, input().split())
if n > 0:
    ps = list(map(int, input().split()))
else:
    ps = []
nums = [n for n in range(1, 101) if n not in ps]

if x in nums:
    print(x)
else:
    abs_plus = sorted([n-x for n in nums if n-x >= 0])
    abs_minus = sorted([-(n-x) for n in nums if n-x < 0])
    if abs_plus == []:
        print(x-abs_minus[0])
    elif abs_minus == []:
        print(x+abs_plus[0])
    elif abs_plus[0] >= abs_minus[0]:
        print(x-abs_minus[0])
    else:
        print(x+abs_plus[0])

### FIXED CODE ###

x, n = map(int, input().split())
if n > 0:
    ps = list(map(int, input().split()))
else:
    print(x)
    exit()
nums = [n for n in range(-1, 102) if n not in ps]

abs_plus = sorted([n-x for n in nums if n-x >= 0])
abs_minus = sorted([-(n-x) for n in nums if n-x < 0])
if abs_plus == []:
    print(x-abs_minus[0])
elif abs_minus == []:
    print(x+abs_plus[0])
elif abs_plus[0] >= abs_minus[0]:
    print(x-abs_minus[0])
else:
    print(x+abs_plus[0])
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

print(lcm_list(T))

### FIXED CODE ###

import fractions

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

ans = T[0]
for i in range(1, N):
    ans = ans * T[i] // fractions.gcd(ans, T[i])
print(ans)
s = list(map(int,list(input()))
a = s[0]*10+s[1]
b = s[2]*10+s[3]
lst = [1,2,3,4,5,6,7,8,9,10,11,12]
if a in lst:
    if b in lst:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if b in lst:
        print('YYMM')
    else:
        print('NA')

### FIXED CODE ###

s = list(map(int,list(input())))
a = s[0]*10+s[1]
b = s[2]*10+s[3]
lst = [1,2,3,4,5,6,7,8,9,10,11,12]
if a in lst:
    if b in lst:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if b in lst:
        print('YYMM')
    else:
        print('NA')
# -*- coding: utf-8 -*-
import math
import heapq
import sys

N, M = map(int, input().split())
MAX = math.inf

nodes = [[] for i in range(N+1)]

for i in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    nodes[u].append(v)

S, T = map(int, input().split())
S -= 1
T -= 1

# init
d = [
    [math.inf for i in range(N)],
    [math.inf for i in range(N)],
    [math.inf for i in range(N)],
]
d[0][S] = 0
queue = []
heapq.heappush(queue, [0, 0, S])

while queue:
    p, m, n = heapq.heappop(queue)
    if m == 0 and n == T:
        print(int(p/3))
        sys.exit(0)
    for to in nodes[n]:
        if d[(m+1) % 3][to] > d[m][n] + 1:
            d[(m+1) % 3][to] = d[m][n] + 1
            heapq.heappush(queue, [
                d[(m+1) % 3][to],
                (m+1) % 3,
                to
            ])

print(-1)
sys.exit(0)


### FIXED CODE ###

# -*- coding: utf-8 -*-
import heapq

N, M = map(int, input().split())
MAX = float("inf")

nodes = [[] for i in range(N+1)]

for i in range(M):
    u, v = map(int, input().split())
    u -= 1
    v -= 1
    nodes[u].append(v)

S, T = map(int, input().split())
S -= 1
T -= 1

# init
d = [
    [MAX for i in range(N)],
    [MAX for i in range(N)],
    [MAX for i in range(N)],
]
d[0][S] = 0
queue = []
heapq.heappush(queue, [0, 0, S])

while queue:
    p, m, n = heapq.heappop(queue)
    if m == 0 and n == T:
        print(int(p/3))
        quit()
    for to in nodes[n]:
        if d[(m+1) % 3][to] > d[m][n] + 1:
            d[(m+1) % 3][to] = d[m][n] + 1
            heapq.heappush(queue, [
                d[(m+1) % 3][to],
                (m+1) % 3,
                to
            ])

print(-1)
N,K = (int(x) for x in input().split())
s = input()
print ''.join(x for i,x in enumerate(s) if i != K-1 else x.lower())

### FIXED CODE ###

N,K = (int(x) for x in input().split())
s = input()
print(''.join([x if i != K-1 else x.lower() for i,x in enumerate(s) ]))
N = int(input())
a = list(map(int, input().strip().split()))
a.sort()

i = 0
j = 1
ans = 0

for i in range(N-1):
	if a[i] == a[i+1]:
		j += 1
	else:
		if j >= a[i]:
			ans += j - a[i]
		else:
			ans += j
if a[N-1] != A[N-2]:
	if a[N-1] != 1:
		ans += 1
else:
	if j >= a[i]:
		ans += j - a[i]
	else:
		ans += j


### FIXED CODE ###

N = int(input())
a = list(map(int, input().strip().split()))
a.sort()
i = 0
j = 1
ans = 0

for i in range(N-1):
	if a[i] == a[i+1]:
		j += 1
	else:
		if j >= a[i]:
			ans += j - a[i]
		else:
			ans += j
		j = 1
if a[N-1] != a[N-2]:
	if a[N-1] != 1:
		ans += 1
else:
	if j >= a[i]:
		ans += j - a[i]
	else:
		ans += j
print(ans)
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[]
D[0]=0
for i in range(1,N+1):
  t=D[i-1]+L[i-1]
  D.append(t)
s=0
for j in range(0,N+1):
  if D[j]<=X:
    s+=1
print(s)

### FIXED CODE ###

N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[]
D.append(0)
for i in range(1,N+1):
  D.append(D[i-1]+L[i-1])
s=0
for j in range(0,N+1):
  if D[j]<=X:
    s+=1
print(s)
def main(n,s):
    if n == 1:
        return 1
        
    count = 1
    for i in range(1,n):
        if s[i] != s[i-1]:
            count += 1
    return count

inp = input().split()
n = int(inp[0])
s = inp[1]


print(main(n,s))

### FIXED CODE ###

n = int(input())
s = input()

cnt = 1
for i in range(n-1):
    if s[i]!=s[i+1]:
        cnt+=1
print(cnt)
n = int(input())
ans=0
while(n%2==0):
  ans++
  n/=2
print(ans)

### FIXED CODE ###

n=int(input())
ans=1
while(2*ans<=n):
	ans*=2
print(ans)
import math
n=int(input())
t=[int(input()) for _ in [0]*n]

d=t[0]
for i in range(1,n):
    d=(t[i]*d)//math.gcd(t[i],d)
print(d)

### FIXED CODE ###

import fractions
n=int(input())
t=[int(input()) for _ in [0]*n]

d=t[0]
for i in range(1,n):
    d=(t[i]*d)//fractions.gcd(t[i],d)
print(d)
import numpy as np
S=np.array(list(input()))
T=np.array(list(input()))
if all(S==T[:-2]):
  print("Yes")
else:
  print('No')

### FIXED CODE ###

s = input()
t = input()
if s == t[:-1]:
  print('Yes')
else:
  print('No')
import output
N = int(input())
A = [int(n) for n in input().split()]
flg = 1
cnt = 0
while flg:
    flg = 0
    for i in range(N-1, 0, -1):
        if A[i] < A[i-1]:
            t = A[i]
            A[i] = A[i-1]
            A[i-1] = t
            flg = 1
            cnt += 1
output.print_1(A)
print(cnt)

### FIXED CODE ###

N = int(input())
A = [int(n) for n in input().split()]
flg = 1
cnt = 0
while flg:
    flg = 0
    for i in range(N-1, 0, -1):
        if A[i] < A[i-1]:
            t = A[i]
            A[i] = A[i-1]
            A[i-1] = t
            flg = 1
            cnt += 1
for i in range(N):
    if i == N - 1:
        print(A[i])
    else:
        print(A[i], end=" ")
print(cnt)
S = input()
N = len(S)

flag = True

for i in range(int(len(S)/2)):
  if S[i]!=S[-1-i]:
    flag = False
    breakat

if flag==True:
  right = int((N-1) / 2)
  subS = S[0:right]
  for i in range(int(len(subS)/2)):
    if subS[i]!=subS[-1-i]:
      flag = False
      break

if flag==True:
  left = int((N+3) / 2)
  subS = S[left-1:N]
  for i in range(int(len(subS)/2)):
    if subS[i]!=subS[-1-i]:
      flag = False

if flag:
  print("Yes")
else:
  print("No")



### FIXED CODE ###

S = input()
N = len(S)

flag = True

for i in range(int(len(S)/2)):
  if S[i]!=S[-1-i]:
    flag = False
    break

if flag==True:
  right = int((N-1) / 2)
  subS = S[0:right]
  for i in range(int(len(subS)/2)):
    if subS[i]!=subS[-1-i]:
      flag = False
      break

if flag==True:
  left = int((N+3) / 2)
  subS = S[left-1:N]
  for i in range(int(len(subS)/2)):
    if subS[i]!=subS[-1-i]:
      flag = False
      break

if flag:
  print("Yes")
else:
  print("No")
A,B,C = map(int, input().split())
if A=B or B=C or C=A:
  print('Yes')
print('No')

### FIXED CODE ###

A,B,C = map(int, input().split())
if A==B==C:
  print('No')
elif A==B or B==C or C==A:
  print('Yes')
else:
  print('No')
import numpy as np
N = input()
a = np.array(input().split()).astype(int)
flags = (np.diff(a) <= 0).astype(int)
result = 0
max_result = 0
for i, flag in enumerate(flags):
    if flag == 0:
        if result > max_result:
            max_result = result
        result = 0
    else:
        result += 1
    if i == len(flags) - 1:
        if result > max_result:
            max_result = result
print(max_result)

### FIXED CODE ###

import numpy as np
N = input()
a = np.array(input().split()).astype(int)
flags = (np.diff(a) <= 0).astype(int)
result = 0
max_result = 0
for i, flag in enumerate(flags):
    if flag == 0:
        if result > max_result:
            max_result = result
        result = 0
    else:
        result += 1
    if i == len(flags) - 1:
        if result > max_result:
            max_result = result
print(max_result)
A = int(input())
B = inT(input())

print(A*B)

### FIXED CODE ###

A,B = input().split()
A = int(A)
B = int(B)
print(A*B)
#coding: utf-8;
import itertools
import math

def hoge(i,flag):
  s = list(flag)
  s[i] = "B"
  return "".join(s)

N = int(input())
data = input()

R=[]
G=[]
B=[]
count = 0

for i,c in enumerate(data):
  if c=="R":
    R.append(i)
    continue
  if c=="G":
    G.append(i)
    continue
  if c=="B":
    B.append(i)
    continue

temp_max = 999999999999
min_list = []
#全探索(N!^2)でやってみようか
for num,x in enumerate(itertools.permutations(G)):
  for y in itertools.permutations(B):
      for i in range(N):
        ti = R[i]+G[i]+B[i]
        if ti==temp_max:
          min_list.append(R[i]+G[i]+B[i])
        elif ti<temp_max:
          temp_max = ti
          min_list = [R[i]+G[i]+B[i]]

print((len(min_list)*math.factorial(N))%998244353)

##TLE -> temp_maxより大きいのは登録しないようにしようか

### FIXED CODE ###

#coding: utf-8;

data = input()
#\nは？

K = 0
count = 0
prev = ""
now = ""
i = 0

if len(data)==1:
  print("1")
  exit()

while True:
  if count==len(data):
    if len(now)==0:
      break
    if now!=prev:
      K+=1
      break
    #こっからが問題
    break

  now += data[count]
  count += 1
  if now != prev:
    prev = now
    now = ""
    K += 1

print(K)
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

N = getN()
A = getList()
listnum = [0] * (N + 1)
for i in A:
    listnum[i] += 1
for i in range(N + 1):
    if listnum[i] >= 3:
        listnum[i] = (listnum[i] % 2) + 1
minus = listnum.count(2)
if minus % 2 == 0:
    print(sum(listnum) - minus)
else:
    print(sum(listnum) - minus - 1)

### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

N = getN()
nums = [int(e) for e in input().split()]
nums.sort()
checker = nums[0]
count = 1
for i in range(1,N):
    if(checker != nums[i]):
        count+=1
        checker = nums[i]
if(N - count)%2==0:
    print(count)
else:
    print(count-1)
X, Y = list(map(int, input().split()))

print(A + B // 2)


### FIXED CODE ###

X, Y = list(map(int, input().split()))

print(X + Y // 2)
import math

A, B, H, M = (int(x) for x in input().split())
 

hang = math.radians(30*H/12+6*M)
mang = math.radians(6*M)
hm = abs(haang-mang)
ans = math.sqrt(A**2+B**2-2*A*B*math.cos(hm))
print(ans)

### FIXED CODE ###

import math
a, b, h, m = map(int, input().split())
     
mr = 6*m
hr = 360*(h/12+m/720)
r = math.radians(abs(mr-hr))
ans = math.sqrt((a**2)+(b**2)-2*a*b*math.cos(r))
print(ans)
import numpy as np
n,d,a = map(int,input().split())
x = np.zeros(n)
h = x.copy()
for i in range(n):
    x[i],h[i] = map(int,input().split())
    
ind = np.argsort(x)
ind2 = np.arange(n)
x = np.sort(x)
h[ind2] = h[ind]

def calc(x,h):
    if 2*d >= x[-1]-x[0]:
        b = np.max(h)
        ans = b//a + min(1,b%a)
    else:
        ans1 = h[0]//a + min(1,h[0]%a)
        ans2 = h[-1]//a + min(1,h[-1]%a)
        ans = ans1 + ans2
        h[:np.searchsorted(x,x+2*d,side='right')] -= ans1*a
        h[np.searchsorted(x,x[-1]-2*d,side='left'):] -= ans2*a
        c = np.where(h > 0)[0]
        if len(c) > 0:
            x_ = x[c[0]:c[-1]+1]
            h_ = h[c[0]:c[-1]+1]
            ans += calc(x_,h_)
    
    return ans

print(int(calc(x,h)))

### FIXED CODE ###

from collections import deque
from math import ceil

n,d,a = map(int,input().split())
xh = sorted([list(map(int,input().split())) for _ in range(n)])

q = deque()
ans = 0
count = 0
total = 0
for x,h in xh:
    while q:
        if q[0][0] < x:
            total -= q.popleft()[1]
        else:
            break
    
    if total < ceil(h/a):
        count = ceil(h/a)-total
        ans += count
        total += count
        q.append((x+2*d,count))

print(ans)
input_val = []
for i in range(6) :
    input_val.append(int(input()))

input_size = len(input_val)
count = 0
for i in range(5) :
    stan_val = input_val[i]
    for j in range(i+1,5) :
        diff = abs(stan_val - input_val[j])
        if diff > input_val[5] :
            count += 1
            
        else : count = count

if count == 0 :
   print("Yay!")
else : print(":(")

### FIXED CODE ###

a,b = [int(i) for i in input().split()]

x = 0
for i in range(2) :
    c = max(a,b)
    if c == a :
        x += a 
        a = a - 1
    else : 
        x += b
        b = b -1

print(x)
s=int(input())
a=[s]
i=1
while len(a)==len(set(a)):
  if a[i-1]%2=0:
    a.append(a[i-1]//2)
  else:
    a.append(a[i-1]*3+1)
  i+=1
print(i)

### FIXED CODE ###

s=int(input())
a=[s]
i=1
while len(a)==len(set(a)):
  if a[i-1]%2==0:
    a.append(a[i-1]//2)
  else:
    a.append(a[i-1]*3+1)
  i+=1
print(i)
h,w,n = map(int,input().split())
r,c = map(int,input().split())
sd = {'L':0,'R':0,'U':0,'D':0}
td = {'L':0,'R':0,'U':0,'D':0}
s = input()
t = input()
ans = 'YES'
for i in range(n):
  sd[s[i]] += 1
  if max(1,r-td['U'])+sd['D'] > h or min(h,r+td['D'])-sd['U'] < 1 or max(1,c-td['L'])+sd['R'] > w or min(w,c+td['R'])-sd['L'] < 1:
    ans = 'NO'
    break
  if t[i] == 'L' and s[i] == 'R':
    sd['R'] -= 1
  if t[i] == 'R' and s[i] == 'L':
    sd['L'] -= 1
  if t[i] == 'D' and s[i] == 'U':
    sd['U'] -= 1
  if t[i] == 'U' and s[i] == 'D':
    sd['D'] -= 1
  else:
    td[t[i]] += 1
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

h,w = map(int,input().split())
c = []
for i in range(h):
  a = input()
  c.append(a)
  
from collections import deque

d = [[-1] * w for i in range(h)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

que = deque([])
for i in range(h):
  for j in range(w):
    if c[i][j] == '#':
      que.append((i,j,0))
      d[i][j] = 0

ans = 0
while que:
  p = que.popleft()
  for i in range(4):
      nw = p[1] + dx[i]
      nh = p[0] + dy[i]
      if 0 <= nw < w and 0 <= nh < h and d[nh][nw]==-1:
          que.append((nh,nw,p[2]+1))
          d[nh][nw] = p[2]+1
          ans = max(ans,p[2]+1)

print(ans)
a=map(int,input().split())
sum=0
for i in a:
  sum+=a
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
return ans%(10**9+7)

### FIXED CODE ###

n=input()
a=input().split()
sum=0
for i in range(len(a)):
  a[i]=(int)(a[i])
for i in a:
  sum+=i
ans=0
ans+=(sum**2)
for i in a:
  ans-=i*i
print((ans//2)%(10**9+7))
# -*- coding: utf-8 -*-
A = input()
B = input()
C = input()
D = input()
L = A + B
R = C + D
if L == R:
    print("Balanced")
elif L <= R:
    print("Right")
else :
    print("Left")

### FIXED CODE ###

# -*- coding: utf-8 -*-
A,B,C,D = map(int, input().split())
L = A + B
R = C + D
if L == R:
    print("Balanced")
elif L < R:
    print("Right")
else :
    print("Left")