Harryxun/stf_run huggingface dataset:
import sys
sys.setrecursionlimit(10**10)

class Node:
    def __init__(self):
        self.val = None
        self.a = []

n = int(input())
nodes = []

for i in range(n):
    nodes.append(Node())

for i in range(n-1):
    u, v, w = map(int, input().split())
    node1 = nodes[u-1]
    node2 = nodes[v-1]
    node1.a.append([node2, w])
    node2.a.append([node1, w])

root = nodes[0]
root.val = True
nodeSet = set()

def traverse(node):
    if node in nodeSet:
        return
    else:
        nodeSet.add(node)

    for pair in node.a:
        adjNode = pair[0]
        dis = pair[1]
        if dis % 2 == 0:
            adjNode.val = node.val
        else:
            adjNode.val = not node.val
        traverse(adjNode)

traverse(root)

for i in range(n):
    node = nodes[i]
    if node.val:
        print(1)
    else:
        print(0)




### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

class Node:
    # def __init__(self, val):
    def __init__(self):
        self.val = None
        self.color = None
        self.a = []

n = int(input())
nodes = []

for i in range(n):
    nodes.append(Node())
    # nodes.append(Node(i+1))

for i in range(n-1):
    u, v, w = map(int, input().split())
    node1 = nodes[u-1]
    node2 = nodes[v-1]
    node1.val = u
    node2.val = v
    node1.a.append([node2, w])
    node2.a.append([node1, w])

# for i in range(n):
#     node = nodes[i]
#     for pair in node.a:
#         print(pair[0])
#         print(pair[1])

root = nodes[0]
root.color = True
nodeSet = set()

def traverse(node, distance):
    if node in nodeSet:
        return
    else:
        nodeSet.add(node)
    # print('# traverse: ' + str(node.val))
    for pair in node.a:
        adjNode = pair[0]
        dis = pair[1]
        if (distance + dis) % 2 == 0:
            adjNode.color = root.color
        else:
            adjNode.color = not root.color
        traverse(adjNode, distance + dis)

traverse(root, 0)

for i in range(n):
    node = nodes[i]
    if node.color:
        print(1)
    else:
        print(0)
# -*- coding: utf-8 -*-
x,y,z,k = map(int,input().split())
a,b,c = [],[],[]
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ab = []

for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])

ab.sort()

abc = []

for i in range(min(len(ab),k)):
    for j in range(min(z,k)):
        abc.append(ab[-(i+1)] + c[j])

abc.sort()

for i in range(k):
    print(abc[-(i+1)])

### FIXED CODE ###

# -*- coding: utf-8 -*-
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if e - a <= k:
    print("Yay!")
else:
    print(":(")
import functools
import math
N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
xlist.sort()
xlist_2 = list(map(lambda x:x - xlist[0], xlist))

if len(xlist) == 1:
    ans = xlist[0] - X
elif len(xlist) >= 2:
    ans = functools.reduce(math.gcd,xlist_2)

print(abs(ans))


### FIXED CODE ###

def gcd(a,b):
    while b % a:
        a,b = b, a % b
    return a
#(a >= b )

N ,X = list(map(int,input().strip().split()))
xlist = list(map(int,input().strip().split()))
abs_xlist = list(map(lambda x:abs(X - x), xlist))
abs_xlist.sort()
ans = abs_xlist[0]

for i in range(N):
    if abs_xlist[i] % ans != 0:
        num = gcd(abs_xlist[i],ans)
        ans = min(num,ans)
print(ans)
import itertools
H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]
A = [[0 for _ in range(W)] for _ in range(H)]
count = {}


def dfs(x, y, p, q):
    if A[x][y] == 1:
        return
    else:
        A[x][y] = 1
        count[p * H + q] = count.get(p * H + q, {})
        count[p * H + q][S[x][y]] = count[p * H + q].get(S[x][y], 0) + 1
        dxy = [[-1, 0], [1, 0], [0, -1], [0, 1]]
        for dx, dy in dxy:
            nx, ny = x + dx, y + dy
            if 0 <= nx < H and 0 <= ny < W:
                if S[x][y] == S[nx][ny]:
                    dfs(nx, ny, nx, ny)
                else:
                    dfs(nx, ny, p, q)


dfs(0, 0, 0, 0)
ans = 0
for i in count:
    ans += count[i].get('#', 0) * count[i].get('.', 0)
print(ans)


### FIXED CODE ###

import itertools
H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]
A = [[0 for _ in range(W)] for _ in range(H)]


def dfs(p, q):
    if A[p][q] == 1:
        return 0
    count = {'#': 0, '.': 0}
    stack = [[p, q]]
    while stack:
        x, y = stack.pop()
        if A[x][y] != 1:
            count[S[x][y]] += 1
            A[x][y] = 1
            dxy = [[-1, 0], [1, 0], [0, -1], [0, 1]]
            for dx, dy in dxy:
                nx, ny = x + dx, y + dy
                if 0 <= nx < H and 0 <= ny < W and S[x][y] != S[nx][ny]:
                    stack += [[nx, ny]]
    return count['#'] * count['.']


print(sum([dfs(i, j) for i, j in itertools.product(range(H), range(W))]))
"""
KがAの最大公約数の倍数であれば実現可能。そうでなければ実現不可能。
"""
N,K = map(int,input().split())
A = list(map(int,input().split()))

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

g = gcd(A[0],A[1])
for i in range(2,N):
    g = gcd(g,A[2])

if K%g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

import sys
sys.setrecursionlimit(2000000)
N,K = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
if N ==1:
    g = A[0]
else:
    g = gcd(A[0],A[1])
    if N > 2:
        for i in range(2,N):
            g = gcd(g,A[i])
if K <= max(A) and K%g==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
t=input()
tl=list(t)
tln=len(t)
x=t.find("?")
while x != -1:
    if x == tln:
        tl[x]="D"
        break
    if tl[x+1]=="D":
        tl[x]="P"
    elif tl[x+1]=="?":
        tl[x]="P"
    else:
        tl[x]="D"
    t="".join(tl)
    x=t.find("?")
print(t)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
t=input()
tl=list(t)
tln=len(t)
x=0
for x in range(tln):
    if tl[x] == "?":
        if x == tln-1:
            tl[x]="D"
            break
        elif x==0:
            if tl[x+1]=="?":
                tl[x]="P"
                tl[x+1]="D"
            else:
                tl[x]="D"
        elif tl[x-1]=="P":
            tl[x]="D"
        elif tl[x+1]=="?":
            tl[x]="P"
            tl[x+1]="D"
        elif tl[x+1]=="D":
            tl[x]="P"
        else:
            tl[x]="D"
t="".join(tl)
print(t)
N,C=map(int,input().split())
imos=[0]*(2*10**5)
for i in range(N):
  s,t,c=map(int,input().split())
  imos[2*s-1]+=1
  imos[2*t]-=1
channels=[imos[0]]*(2*10**5)
for i in range(2*10**5-1):
  channels[i+1]=channels[i]+imos[i+1]
print(max(channels))

### FIXED CODE ###

N,C=map(int,input().split())
cha=[[0 for i in range(10**5+1)] for j in range(C)]
for i in range(N):
  s,t,c=map(int,input().split())
  cha[c-1][s-1:t]=[1]*(t-s+1)
channels=0
for i in range(10**5+1):
  chans=0
  for c in range(C):
    chans+=cha[c-1][i]
  channels=max(channels,chans)
print(channels)
nums = input()
S,T = nums.split(" ")

if len(S)+1 != len(T):
    print("No")

elif T[0:len(S)] == S:
    print("Yes")

else:
    print("No")

### FIXED CODE ###

S = input()
T = input()

if len(S)+1 != len(T):
    print("No")

elif T[0:len(S)] == S:
    print("Yes")

else:
    print("No")
n=int(input())
s=input()
t=input()
if s==t:
    print(n)
else:
    ans=2*n
    f=True
    for i in range(n):
        for j range(i+1):
            if t[j]==a[n-1-i+j]:
                f=False
        if not f:
            break
        ans-=1
    print(ans)

### FIXED CODE ###

n=int(input())
s=input()
t=input()
i=0
while n>i:
    if i==0 and s==t:
        break
    if t[:-i]==s[i:]:
        break
    i+=1
print(n+i)
# 各条件の入力
a, b, c = map(int, input().split())

# 答えの出力
import math

"""
素直にやると誤差で死ぬ
if math.sqrt(a) + math.sqrt(b) < math.sqrt(c):
    ans = 'Yes'
else:
    ans = 'No'
"""


# 整数でやる
left = a + b + (math.sqrt(a*b))*2
right = c

left2 = ((math.sqrt(a*b))*2) **2
right2 = (c - a - b) **2

left3 = 4*a*b
right3 = right2

if (c - a - b) < 0:
    ans = 'No'
elif left3 < right3:
    ans = 'Yes'
else:
    ans = 'No'

# 出力
print(ans)


### FIXED CODE ###

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
i = int(input())-1
print(l[i])
import numpy as np

N = int(input())
X = str(input())
num_one = X.count("1")
zero_ver = np.array([pow(2,  i, num_one + 1) for i in range(N)])
one_ver = np.array([pow(2,  i, num_one - 1) for i in range(N)])
bool_arr = np.array([True if X[N-i-1] == "1" else False for i in range(N)])


def func(x):
    if x == 0:
        return 0
    else:
        counter = 0
        x_tmp = x
        while x > 0:
            if x % 2 == 1:
                counter += 1
            x = x >> 1
        return func(x_tmp % counter) + 1

for i in range(1,N+1):
    tmp_bool = bool_arr.copy()
    start = 0
    if tmp_bool[N-i] == False:
        tmp_bool[N-i] = True
        start = sum(zero_ver[tmp_bool]) % (num_one + 1)
    else:
        tmp_bool[N-i] = False
        start = sum(one_ver[tmp_bool]) %  (num_one - 1)
    print(func(start)+1)

### FIXED CODE ###

import numpy as np

N = int(input())
X = str(input())
num_one = X.count("1")

dp = [-1] * N
dp[0] = 0
def dfs(n):
    if dp[n] == -1:
        dp[n] = 1 + dfs(n % bin(n).count('1'))
    return dp[n]

num_one = X.count("1")
bool_arr = np.array([True if X[N-i-1] == "1" else False for i in range(N)])
zero_ver = np.array([pow(2,  i, num_one + 1) for i in range(N)])
zero_ver_sum = sum(zero_ver[bool_arr])

one_ver = -1
one_ver_sum = 0
flag = False
if num_one != 1:
    one_ver = np.array([pow(2,  i, num_one - 1) for i in range(N)])
    one_ver_sum = sum(one_ver[bool_arr])
else:
    flag = True
for i in range(1,N+1):
    start = 0
    if bool_arr[N-i] == False:
        start = (zero_ver_sum + pow(2, N - i, num_one + 1)) % (num_one + 1)
        print(dfs(start)+1)
    else:
        if flag:
            print(0)
        else:
            start = (one_ver_sum - pow(2, N - i, num_one - 1))  %  (num_one - 1)
            print(dfs(start)+1)
from sys import exit

N = int(input())
a = [[int(e) - 1 for e in input().split()] for _ in range(N)]

id = [[0] * N for _ in range(N)]
def toId(i, j):
  if i > j:
    i, j = j, i
  return id[i][j]

visited = [False] * (N * (N - 1) // 2)
calculated = [False] * (N * (N - 1) // 2)
dp = [0] * (N * (N - 1) // 2)
to = [[] for _ in range(N * (N - 1) // 2)]

def dfs(v):
  if visited[v]:
    if not calculated[v]:
      return -1
    return dp[v]
  visited[v] = True
  dp[v] = 1
  for u in to[v]:
    res = dfs(u)
    if res == -1:
      return -1
    dp[v] = max(dp[v], res + 1)
  calculated[v] = True
  return dp[v]

v = 0
for i in range(N):
  for j in range(N):
    if i >= j:
      continue
    id[i][j] = v
    v += 1

for i in range(N):
  for j in range(N - 1):
    a[i][j] = toId(i, a[i][j])
  for j in range(N - 2):
    to[a[i][j + 1]].append(a[i][j])

ans = 0
for i in range(N * (N - 1) // 2):
  res = dfs(i)
  if res == -1:
    print('-1')
    exit()
  ans = max(ans, res)
print(ans)


### FIXED CODE ###

from sys import exit, setrecursionlimit
setrecursionlimit(1000000)

def dfs(v, dp, to):
  t = dp[v]
  if t >= 0:
    return t
  dp[v] = 0
  t = 0
  for u in to[v]:
    res = dfs(u, dp, to)
    if res == 0:
      print('-1')
      exit()
    if res > t:
      t = res
  t += 1
  dp[v] = t
  return t

def toId(i, j, id_db):
  if i < j:
    return id_db[i][j]
  else:
    return id_db[j][i]

def main():
  N = int(input())
  a = [[int(e) - 1 for e in input().split()] for _ in range(N)]

  id_db = [[0] * N for _ in range(N)]

  dp = [-1] * (N * (N - 1) // 2)
  to = [[] for _ in range(N * (N - 1) // 2)]

  v = 0
  for i in range(N):
    for j in range(i + 1, N):
      id_db[i][j] = v
      v += 1

  for i in range(N):
    for j in range(N - 1):
      a[i][j] = toId(i, a[i][j], id_db)
    for j in range(N - 2):
      to[a[i][j + 1]].append(a[i][j])

  print(max(dfs(i, dp, to) for i in range(N * (N - 1) // 2)))

main()
a,b,k=map(int,input().split())
if a>=k: print(a-k,b)
elif a+b>=k: print(0,a+b-k)
else: print(0,0)


### FIXED CODE ###

s,t=input().split()
print(t+s)
import collections
n = int(input())
*pr, = map(int,input().split())
#print(pr)
d = collections.Counter(pr)
#print(d)
mod = 10**9+7
if n % 2 != 0:
  if d[0] != 1:
    print(0)
    exit()
  else:
    for k, v in d.items():
      if k != 0 and v != 2:
        print(0)
        exit()
      elif k%2 != 0:
        print(0)
        exit()
    print(((len(d)-1)**2)%mod)
else:
  for ky,vl in d.items():
    if ky == 0:
      print(0)
      exit()
    elif ky%2 == 0:
      print(0)
      exit()
    elif vl != 2:
      print(0)
      exit()
  print((len(d)**2)%mod)


### FIXED CODE ###

a, p, b = map(str,input().split())
print(int(a)+int(b) if p == '+' else int(a)-int(b))
INF = 10**11
from bisect import bisect

A, B, Q = map(int, input().split())
s_array = [int(input()) if i != 0 else -INF for i in range(A + 1)]
s_array.append(INF)
t_array = [int(input()) if i != 0 else -INF for i in range(B + 1)]
t_array.append(INF)
q_array = [int(input()) for i in range(Q)]

# print(s_array, t_array, q_array)

ans_array = []
for q in q_array:
    s_index = bisect(s_array, q)
    t_index = bisect(t_array, q)
    method_a = q - min(s_array[s_index], t_array[t_index])
    method_b = max(s_array[s_index + 1], t_array[t_index + 1]) - q
    method_c = (q - s_array[s_index]) + (t_array[t_index + 1] - q) + min(
        (q - s_array[s_index]), (t_array[t_index + 1] - q))
    method_d = (q - t_array[t_index]) + (s_array[s_index + 1] - q) + min(
        (q - t_array[t_index]), (s_array[s_index + 1] - q))
    ans_array.append(min(method_a, method_b, method_c, method_d))

for ans in ans_array:
    print(ans)

### FIXED CODE ###

INF = 10**11


def binary_search(array, value):
    start = 0
    end = len(array) - 1
    while end - start >= 2:
        tmp = (start + end) // 2
        # print(start, end, tmp)
        if array[tmp] <= value:
            start = tmp
        else:
            end = tmp
        # print(start, end, tmp)
    return start


A, B, Q = map(int, input().split())
s_array = [int(input()) if i != 0 else -INF for i in range(A + 1)]
s_array.append(INF)
t_array = [int(input()) if i != 0 else -INF for i in range(B + 1)]
t_array.append(INF)
q_array = [int(input()) for i in range(Q)]

# print(s_array, t_array, q_array)

ans_array = []
for q in q_array:
    s_index = binary_search(s_array, q)
    t_index = binary_search(t_array, q)
    method_a = q - min(s_array[s_index], t_array[t_index])
    method_b = max(s_array[s_index + 1], t_array[t_index + 1]) - q
    method_c = (q - s_array[s_index]) + (t_array[t_index + 1] - q) + min(
        (q - s_array[s_index]), (t_array[t_index + 1] - q))
    method_d = (q - t_array[t_index]) + (s_array[s_index + 1] - q) + min(
        (q - t_array[t_index]), (s_array[s_index + 1] - q))
    ans_array.append(min(method_a, method_b, method_c, method_d))

for ans in ans_array:
    print(ans)
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
V = []
W = []
for _ in range(n):
    v, w = LI()
    V.append(v)
    W.append(w)

q = I()
vl = []
maxL = 0
for _ in range(q):
    v, l = LI()
    maxL = max(maxL, l)
    vl.append([v,l])

m = min(n, 1 << 10)
dp = [[0]*(maxL + 1) for _ in range(m + 1)]

for i in range(1, m+1):
    v, w = V[i-1], W[i-1]
    for j in range(maxL+1):
        if j < w:
            dp[i][j] = dp[i>>1][j]
        else:
            dp[i][j] = max(dp[i>>1][j], dp[i>>1][j - w] + v)


for i in range(q):
    v, L = vl[i]
    if v <= m:
        print(dp[v][L])
        continue
    cnt = 0
    tmp = v
    v_ = []
    w_ = []
    while tmp > m:
        v_.append(v[tmp-1])
        w_.append(w[tmp-1])
        tmp >>= 1
        cnt += 1
    ret = 0
    for j in range(1 << cnt):
        weight_sum = 0
        value_sum = 0
        for v, w in zip(v_, w_):
            if j & 1:
                weight_sum += w
                value_sum += v
                if weight_sum > L:
                    break
            j >>= 1
        else:
            value_sum += dp[tmp][L - weight_sum]
            ret = max(ret, value_sum)
    print(ret)


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    import sys
    def I(): return int(sys.stdin.readline())
    def LI(): return list(map(int,sys.stdin.readline().split()))

    n = I()
    V = []
    W = []

    maxL = 10**5
    m = min(n, 1 << 10)
    dp = [[0]*(maxL + 1)]
    
    for i in range(n):
        v, w = LI()
        if i <= m:
            d_ = dp[(i+1)>>1][:]
            for j in range(w, maxL+1)[::-1]:
                d_[j] = max(d_[j], d_[j - w] + v)
            dp.append(d_)
        V.append(v)
        W.append(w)
    
    q = I()
    for i in range(q):
        v, L = LI()
        if v <= m:
            print(dp[v][L])
            continue
        cnt = 0
        v_ = []
        w_ = []
        while v > m:
            v_.append(V[v-1])
            w_.append(W[v-1])
            v >>= 1
            cnt += 1
        ret = dp[v][L]
        v_tmp = [0] * (1 << cnt)
        w_tmp = [0] * (1 << cnt)
        for b in range(1, 1 << cnt):
            lsb = b & -b
            l = lsb.bit_length()
            w_t = w_tmp[b - lsb] + w_[l-1]
            w_tmp[b] = w_t
            if w_t <= L:
                v_t = v_tmp[b - lsb] + v_[l-1]
                v_tmp[b] = v_t
                ret = max(ret, v_t + dp[v][L - w_t])
        print(ret)
    return

if __name__ == "__main__":
    main()
import math

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

AL=[0]*N
AR=[0]*N
for i in range(N):
    if i == 0:
        AL[0] = A[0]
    else:
        AL[i] = math.gcd(AL[i-1],A[i])
for i in range(N):
    if i == 0:
        AR[0] = A[N-1]
    else:
        AR[i] = math.gcd(AR[i-1],A[N-i-1])

max=0
for i in range(N):
    if i == 0:
        n_ex_gcd =  AR[N-2]
    elif i == N-1:
        n_ex_gcd = AL[N-2]
    else:
        n_ex_gcd = math.gcd(AL[i-1],AR[N-i-2])
    if n_ex_gcd > max:
        max = n_ex_gcd
print(max)

### FIXED CODE ###

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

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

AL=[0]*N
AR=[0]*N
for i in range(N):
    if i == 0:
        AL[0] = A[0]
        AR[0] = A[N-1]
    else:
        AL[i] = gcd(AL[i-1],A[i])
        AR[i] = gcd(AR[i-1],A[N-i-1])

max=0
for i in range(N):
    if i == 0:
        n_ex_gcd =  AR[N-2]
    elif i == N-1:
        n_ex_gcd = AL[N-2]
    else:
        n_ex_gcd = gcd(AL[i-1],AR[N-i-2])
    if n_ex_gcd > max:
        max = n_ex_gcd
print(max)
from decimal import *
a, b, c = map(int, input().split())

print("Yes" if Decimal(a)) + sqrt(Decimal(b)) < sqrt(Decimal(c)) else "No")

### FIXED CODE ###

from decimal import *
a, b, c = map(int, input().split())

print("Yes" if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt() else "No")
a, b, c, x = map(int, [input() fot z in range(4)])
 
ans = 0
 
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if i*500 + j*100 + k*50 == x:
        ans += 1

print(ans)

### FIXED CODE ###

a, b, c, x = map(int, [input() for z in range(4)])
 
ans = 0
 
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if i*500 + j*100 + k*50 == x:
        ans += 1
print(ans)
s=input()
def solve(decided, left, idx):
    if idx==len(s):
        return decided+left
    # 手前に+を入れる
    ret1 = solve(decided+left,int(s[idx]),idx+1)
    # 入れない
    ret2 = solve(decided, left*10int(s[idx]), idx+1)
    return ret1+ret2
print(solve(0,int(s[0]),1))

### FIXED CODE ###

s=input()
def solve(decided, left, idx):
    if idx==len(s):
        return decided+left
    # 手前に+を入れる
    ret1 = solve(decided+left,int(s[idx]),idx+1)
    # 入れない
    ret2 = solve(decided, left*10+int(s[idx]), idx+1)
    return ret1+ret2
# 最初の文字の左側には+は入れる必要が無いので1から
print(solve(0,int(s[0]),1))
a,t = map(string, input().split())
if a == t:
  print("H")
elif a != t :
  print("D")

### FIXED CODE ###

a, t = input().split()
if a == t:
  print("H")
else:
  print("D")
class Robot:
    def __init__(self, left, right):
        self.left = left
        self.right = right
    
    def __lt__(self, other):
        return self.right < other.right

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]) - int(line[1]), int(line[0]) + int(line[1])

robos.sort()

cur = -1000000000
ans = 0
for i in range(n):
    if cur <= robos[i].left:
        ans += 1
        cur = robos[i].right

print(ans)

### FIXED CODE ###

class Robot:
    def __init__(self, left, right):
        self.left = left
        self.right = right
    
    def __lt__(self, other):
        return self.right < other.right

n = int(input().rstrip())
robos = [None] * n

for i in range(n):
    line = input().rstrip().split(' ')
    robos[i] = Robot(int(line[0]) - int(line[1]), int(line[0]) + int(line[1]))

robos.sort()

cur = -1000000000
ans = 0
for i in range(n):
    if cur <= robos[i].left:
        ans += 1
        cur = robos[i].right

print(ans)
N,K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
for i,v in enumerate(p):
    ans += v
    if i == 2:
        print(ans)
        exit()
print(ans)

### FIXED CODE ###

N,K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
ans = 0
for i,v in enumerate(p):
    ans += v
    if i == K - 1:
        print(ans)
        exit()
print(ans)
h, w = map(int, input().split())
ss = [list(input()) for i in range(h)]
s = list(map(lambda x: list(map(lambda y: 1 if y == '#' else 0, x)), ss))

def calc(x, y):
    if (x+1) == 1 and (y+1) == 1:
        return s[x+1][y] + s[x][y+1] + s[x+1][y+1]
    elif (x+1) == h and (y+1) == 1:
        return s[x-1][y] + s[x][y+1] + s[x-1][y+1]
    elif (x+1) == 1 and (y+1) == w:
        return s[x+1][y] + s[x][y-1] + s[x+1][y-1]
    elif (x+1) == h and (y+1) == w:
        return s[x-1][y] + s[x][y-1] + s[x-1][y-1]
    elif (x+1) == 1:
        return s[x+1][y] + s[x][y-1] + s[x][y+1] + s[x+1][y+1] + s[x+1][y-1]
    elif (x+1) == h:
        return s[x-1][y] + s[1][y-1] + s[x][y+1] + s[x-1][y+1] + s[x-1][y-1]
    elif (y+1) == 1:
        return s[x+1][y] + s[x-1][y] + s[x][y+1] + s[x-1][y+1] + s[x+1][y+1]
    elif (y+1) == w:
        return s[x+1][y] + s[x-1][y] + s[x][y-1] + s[x-1][y-1] + s[x+1][y-1]
    else:
        return s[x-1][y] + s[x+1][y] + s[x][y-1] + s[x][y+1] + s[x+1][y+1] + s[x+1][y-1] + s[x-1][y+1] + s[x-1][y-1]

a = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if ss[i][j] == '#': a[i][j] = '#'
        else: a[i][j] = calc(i, j)

for i in range(h):
    for j in range(w):
        print(a[i][j], end='')
    print('')


### FIXED CODE ###

h, w = map(int, input().split())
s = [input() for _ in range(h)]
for i in range(h):
    l = ''
    for j in range(w):
        if s[i][j] == '#': l += '#'
        else:
            l += str(sum([ss[max(0, j-1):min(w, j+2)].count('#') for ss in s[max(0, i-1):min(h, i+2)]]))
    print(l)
p = 0
for i in range(len(S)):
    if S[i] != 'S':
        p =+ 1
print(p)


### FIXED CODE ###

S = input()
p = 0
q = 0
for i in range(len(S)):
    if S[i] != 'S':
        p += 1
        if p > q:
            q = p
    else:
      	p = 0
print(q)