Harryxun/stf_run huggingface dataset:
s=list(str(input()))
n=int(input())
s_base = copy.deepcopy(s)
i0 = s[0]
count = 0
if len(s) == 1:
    ans = n//2
else:
    #r1 = n//2 + n%2
    #s

    for i, name in enumerate(s[1:]):
        if name == i0:
            i0 = -1
            count += 1
            s[i+1] = i0
        else:
            i0 = name
    if s[0] == s[-1]:
        al = n-1
        if s[1] == -1:
            s2 = copy.deepcopy(s)
            for i in s_base:
                s2.append(i)
            i0 = s2[0]
            count2 = copy.deepcopy(count)
            for i, name in enumerate(s2[1:]):
                if name == i0:
                    i0 = -1
                    count2 += 1
                    s2[i+1] = i0
                else:
                    i0 = name
            al = (count2 - count*2)*(n//2)
    else:
        al = 0
    ans = count*n + al
print(ans)

### FIXED CODE ###

import copy

s=list(str(input()))
n=int(input())
s_base = copy.deepcopy(s)
i0 = s[0]
count = 0
if len(s) == 1:
    ans = n//2
else:
    #r1 = n//2 + n%2
    #s

    for i, name in enumerate(s[1:]):
        if name == i0:
            i0 = -1
            count += 1
            s[i+1] = i0
        else:
            i0 = name
    if s[0] == s[-1]:
        al = n-1
        if s[1] == -1:
            s2 = copy.deepcopy(s)
            for i in s_base:
                s2.append(i)
            i0 = s2[0]
            count2 = copy.deepcopy(count)
            for i, name in enumerate(s2[1:]):
                if name == i0:
                    i0 = -1
                    count2 += 1
                    s2[i+1] = i0
                else:
                    i0 = name
            al = (count2 - count*2)*(n//2)
            if s2[0] == s2[-1]:
                al = (count2 - count * 2) * (n-1)
    else:
        al = 0
    ans = count*n + al
print(ans)
n = int(input())
a = list(map(int, input().split()))
p = 1
if 0 in n:
    print(0)
    exit()
for i in range(n):
    p = p * a[i]
if p > 10**18:
    print(-1)
else:
    print(p)

### FIXED CODE ###

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

def ans(a):
    if 0 in a:
        return 0
    n = 1
    for i in a:
        n *= i
        if n > 10**18:
            return -1
    return n

print(ans(a))
def pop_count(n):
    return bin(n).count("1")


N = int(input())
X = list(map(int, input()))
pop_X = X.count(1)
X_m = 0
X_p = 0
for i in range(N):
    if X[N - i - 1]:
        X_p += pow(2, i, pop_X + 1)
        X_p %= pop_X + 1
        X_m += pow(2, i, pop_X - 1)
        X_m %= pop_X - 1

for i in range(N):
    ans = 1
    n = 0
    if X[i]:
        n += X_m
        n -= pow(2, N - i - 1, pop_X - 1)
        n %= pop_X - 1
    else:
        n += X_p
        n += pow(2, N - i - 1, pop_X + 1)
        n %= pop_X + 1
    while n:
        n %= pop_count(n)
        ans += 1
    print(ans)


### FIXED CODE ###

def pop_count(n):
    return sum(n >> i & 1 for i in range(n.bit_length()))


def f(n):
    if n == 0:
        return 0
    return f(n % pop_count(n)) + 1


N = int(input())
X = input()
p = X.count("1")
rem_plus = 0
rem_minus = 0
for i in range(N):
    k = N - i - 1
    if X[i] == "0":
        continue
    elif p > 1:
        rem_minus = (rem_minus + pow(2, k, p - 1)) % (p - 1)
    rem_plus = (rem_plus + pow(2, k, p + 1)) % (p + 1)
for i in range(N):
    k = N - i - 1
    if X[i] == "0":
        print(f((rem_plus + pow(2, k, p + 1)) % (p + 1)) + 1)
    elif p > 1:
        print(f((rem_minus - pow(2, k, p - 1)) % (p - 1)) + 1)
    else:
        print(0)
# coding:utf-8
k, n = map(int, input().split())
a = list(map(int, input().split()))
a += k
l = 0
for i in range(n+1):
  l = max(l, a[i+1]-a[i])
 
print(k-l)

### FIXED CODE ###

# coding:utf-8
k, n = map(int, input().split())
a = list(map(int, input().split()))
distance = []
for i in range(len(a)):
  if i == len(a) - 1:
    distance.append(k+a[0] - a[i])
  else:
  	distance.append(a[i+1] - a[i])
distance.sort()
print(sum(distance[:-1]))
nn=[[1,2],[7,3],[4,4],[5,5],[3,5],[2,5],[9,6],[6,6],[8,7]]
n,m=map(int,input().split())
a=input().split()
for i in range(m):
  a[i]=int(a[i])
b=[]
for i in range(9):
  if nn[i][0] in a:
    b.append(nn[i])
  
c=[b[0]]
del b[0]
for i in range(len(b)):
  t=0
  for j in range(len(c)):
    if b[i][1] == c[j][1]:
      t=1
      break
  if t==1:
    continue
  c.append(b[i])
  
t=n//c[0][1]
n-=c[0][1]*t
a=c[0]
del c[0]
for i in range(len(c)):
  c[i][1]-=a[1]

ans=""
while c[0][1] <= n:
  for i in range(len(c)):
    i=len(c)-1-i
    if c[i][1]<=n:
      ans+=str(c[i][0])
      n-=c[i][1]
      t-=1
      break
      
ans+=str(a[0])*t
print(ans)

### FIXED CODE ###

nn=[2,5,5,4,5,6,3,7,6]
n,m=map(int,input().split())
a=input().split()
b=[]
for i in range(m):
  a[i]=int(a[i])
  
if 5 in a:
  if 2 in a:
    a.remove(2)
  if 3 in a:
    a.remove(3)
elif 3 in a:
  if 2 in a:
    a.remove(2)
if 9 in a:
  if 6 in a:
    a.remove(6)
    
a.sort(reverse=True)
for i in range(len(a)):
  b.append(nn[a[i]-1])
  
dp=[-10*18 for _ in range(n+1)]
dp[0]=0
for i in range(n):
  for j in range(len(b)):
    if i+b[j]>n:
      continue
    dp[i+b[j]]=max(dp[i+b[j]],dp[i]+1)
    
k=dp[n]
ans=""
for i in range(k):
  for j in range(len(b)):
    if n-b[j]<0:
      continue
    if dp[n-b[j]]==dp[n]-1:
      ans+=str(a[j])
      n-=b[j]
      break
      
print(ans)
import sys
sys.setrecursionlimit(10**8)
n, m = map(int, input().split())
g = [[] for i in range(n)]
for  i in range(n):
    a, b = map(int, input().split())
    a-=1; b-=1
    g[a].append(b)
    g[b].append(a)

used = [False] * n
ans = 0
def dfs(itr, n, cnt=0):
    ans = 0
    if len(itr)==n:
        return 1
    else:
        ans = cnt
        for e in g[itr[-1]]:
            if used[e]:
                continue
            used[e] = True
            ans+=dfs(itr+[e], n)
            used[e] = False
    return ans

used[0] = True
print(dfs([0], n, 0))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
n, m = map(int, input().split())
g = [[] for i in range(n)]
for  i in range(m):
    a, b = map(int, input().split())
    a-=1; b-=1
    g[a].append(b)
    g[b].append(a)

used = [False] * n
ans = 0
def dfs(itr, n, cnt=0):
    ans = 0
    if len(itr)==n:
        return 1
    else:
        ans = cnt
        for e in g[itr[-1]]:
            if used[e]:
                continue
            used[e] = True
            ans+=dfs(itr+[e], n)
            used[e] = False
    return ans

used[0] = True
print(dfs([0], n, 0))
n, m = map(int, input().split())

a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
for i in range(n):
    for j in range(n):
        if a[i][j] == b[0][0] and i + m <= n and j + m <= n:
            flag = 1
            for y in range(i, i + m):
                for x in range(j, j + m):
                    if a[i + y][j + x] != b[y][x]:
                        flag = 0
                        break
                
            if flag == 1:
                print("Yes")
                exit()

print("No")


### FIXED CODE ###

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

a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
for i in range(n):
    for j in range(n):
        if a[i][j] == b[0][0] and i + m - 1 < n and j + m - 1 < n:
            flag = 1
            for y in range(m):
                for x in range(m):
                    if a[i + y][j + x] != b[y][x]:
                        flag = 0
                        break
                
            if flag == 1:
                print("Yes")
                exit()

print("No")
a,b,c=sorted(map(int,input()))
print(10*c+b+a)
 

### FIXED CODE ###

a,b,c=sorted(map(int,input().split()))
print(10*c+b+a)
import math

def comb(n,r):
	return math.factorial(n)//math.factorial(n-r)//math.factorial(r)%1000000007

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

for i in range(1,K+1):
	print(comb(N-K+1,i)*comb(K-1,i-1)%1000000007)

### FIXED CODE ###

from math import factorial
N, K = map(int, input().split())
mod = 10**9 + 7
def combination(n, r):
	if n >= r:
		return int(factorial(n) // (factorial(r) * factorial(n - r)))
	else:
		return 0

for i in range(1, K+1):
	print(combination(N-K+1, i) * combination(K-1, i-1)%mod)
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True,key=lambda x:abs(x))
print(arr)
if k==n:
  ans=1
  for i in range(n):
    ans*=arr[i]
    ans%=mod
  print(ans)
else:
  if k%2==1 and max(arr)<0:
    ans=1
    for i in range(k):
      ans*=arr[n-1-i]
      ans%=mod
    print(ans)
  else:
    ans=1
    cnt=0
    for i in range(k):
      if arr[i]<0:
        cnt+=1
      ans*=arr[i]
      ans%=mod
    if cnt%2==0:
      print(ans)
    else:
      min_plus=0
      min_minus=0
      for i in range(k):
        if arr[i]>=0:
          min_plus=arr[i]
        else:
          min_minus=arr[i]
      max_plus=0
      max_minus=0
      for i in range(k,n):
        if arr[i]>=0 and max_plus==0:
          max_plus=arr[i]
        if arr[i]<0 and max_minus==0:
          max_minus=arr[i]
      print(min_plus,min_minus,max_plus,max_minus)
      if min_plus*max_plus>=min_minus*max_minus:
        arr.remove(min_minus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_plus
        ans%=mod
      else:
        arr.remove(min_plus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%-mod
        ans*=max_minus
        ans%=mod
      print(ans)

### FIXED CODE ###

import heapq
 
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
q=[]
cnt_plus=0
for i in range(n):
  if arr[i]>0:
    cnt_plus+=1
    heapq.heappush(q,(-arr[i],1))
  elif arr[i]<0:
    heapq.heappush(q,(arr[i],-1))
  else:
    heapq.heappush(q,(0,0))
pick=[]
prev_plus=0
prev_minus=0
cnt=0
for i in range(k):
  tmp,flag=heapq.heappop(q)
  tmp*=-1
  if flag==0:
    print(0)
    exit()
  if flag==1:
    pick.append(tmp)
    prev_plus=tmp
  if flag==-1:
    if cnt==0:
      prev_minus=tmp
      cnt+=1
    else:
      cnt=0
      pick.append(prev_minus)
      pick.append(tmp)
if cnt==0:
  ans=1
  for i in range(k):
    ans*=pick[i]
    ans%=mod
  print(ans%mod)
else:
  cand_plus=0
  cand_minus=0
  while len(q)!=0:
    tmp,flag=heapq.heappop(q)
    tmp*=-1
    if flag==1 and cand_plus==0:
      cand_plus=tmp
    if flag==-1 and cand_minus==0:
      cand_minus=tmp
  if (k%2==1 and cnt_plus==0) or (cand_plus==0 and cand_minus==0):
    if arr.count(0)!=0:
      print(0)
      exit()
    else:
      q=[]
      for i in range(n):
        heapq.heappush(q,abs(arr[i]))
      ans=1
      for _ in range(k):
        ans*=heapq.heappop(q)
        ans%=mod
      print((-ans)%mod)
  else:
    if prev_plus*cand_plus>=prev_minus*cand_minus:
      pick.append(cand_plus)
    else:
      if prev_plus!=0:
        pick.remove(prev_plus)
        pick.append(prev_minus)
        pick.append(cand_minus)
      else:
        pick.append(cand_plus)
    ans=1
    for i in range(k):
      ans*=pick[i]
      ans%=mod
    print(ans%mod)
n = int(input())
a = {i+1:int(input()) for i in range(n)}

def find(a, nexti, cnt, s):
    cnt += 1
    s.add(nexti)
    if a[nexti] == 2:
        return cnt
    elif a[nexti] in s:
        return -1
    else:
        return find(a, a[nexti], cnt, s)

print(find(a, 1, 0, set()))


### FIXED CODE ###

n = int(input())
a = {i+1:int(input()) for i in range(n)}
nexti = 1
for i in range(n):
    if a[nexti] == 2:
        print(i+1)
        exit()
    nexti = a[nexti]
print(-1)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A  = factorization(N) 

count = 0
for i in A:
  judge = 1
  temp = i[1]
  while temp >= judge:
    count += 1
    temp -=judge
    judge += 1

if N == 1:
  count = 0

print(count)

### FIXED CODE ###

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
A  = factorization(N) 

count = 0
for i in A:
  judge = 1
  temp = i[1]
  while temp >= judge:
    count += 1
    temp -=judge
    judge += 1

if N == 1:
  count = 0

print(count)
N,K,X,Y=[int(input()) i in range(4)]
print(X*K+Y*(N-K))

### FIXED CODE ###

N,K,X,Y=[int(input()) for i in range(4)]
print(N*X-(X-Y)*max(0,N-K))
X=int(input())
x=0
ans=[]

if X == 1:
  print(X)
else:
  # p
  for i in range(2, int(X**0.5)+1):
    n=1
    a=i
    # b
    while n < X : #超えたら中断
      n *= a
      ans.append(n)
    if n // a > x:
      x = (n//a)
      #print(ans)
print(max(i for i in ans if i <= X))

### FIXED CODE ###

X=int(input())
x=0
ans=[]

if X == 1:
  print(X)
  exit()
else:
  # p
  for i in range(2, int(X**0.5)+1):
    n=1
    a=i
    # b
    while n < X : #超えたら中断
      n *= a
      ans.append(n)
    if n // a > x:
      x = (n//a)
      #print(ans)
print(max(i for i in ans if i <= X))
import fractions
N = int(input())
l = list(map(int,input().split()))

if len(l) == 2:
    memo = max(l)
else:
    memo = 1
    for i in range(N):
        g = fractions.gcd(*(l[:i]+l[i+1:]))
        if g > memo:
            memo = g

print(memo)

### FIXED CODE ###

A,B,T = map(int,input().split())
print(int(((T+0.5)//A)*B))
a, b = map(int, raw_input().split())

if a>b:
  print "a > b"
if a<b:
  print "a < b"
if a==b:????
  print "a == b"

### FIXED CODE ###

a, b = map(int, raw_input().split())

if a>b:
  print "a > b"
if a<b:
  print "a < b"
if a==b:
  print "a == b"
N, M, P = map(int, input().split())
edge = []

for i in range(M):
    A, B, C = map(int, input().split())
    edge.append((A, B, P-C))

inf = float('inf')
cost = [inf] * (N+1)
cost[1] = 0
for i in range(N-1):
    for e in edge:
        a, b, c = e
        if cost[a] + c < cost[b]:
            cost[b] = cost[a] + c

for e in edge:
    a, b, c = e
    if cost[a] + c < cost[b]:
      if b == N:
      	print(-1)
        exit()
      cost[b] = cost[a] + c
        
print(max(-cost[N], 0))





### FIXED CODE ###

N, M, P = map(int, input().split())
edge = []

for i in range(M):
    A, B, C = map(int, input().split())
    edge.append((A, B, P-C))

inf = float('inf')
cost = [inf] * (N+1)
cost[1] = 0
for i in range(N-1):
    for e in edge:
        a, b, c = e
        if cost[a] + c < cost[b]:
            cost[b] = cost[a] + c

for i in range(N):
    for e in edge:
        a, b, c = e
        if cost[a] + c < cost[b]:
            if b == N:
                print(-1)
                exit()
            else:
                cost[b] = cost[a] + c
        
print(max(-cost[N], 0))
n = int(input())
import math
print(2*math.pi()*n)


### FIXED CODE ###

n = int(input())
import math
print(2*math.pi*n)
R = int(input())
G = int(nput())
print(2 * G - R)

### FIXED CODE ###

R = int(input())
G = int(input())
print(2 * G - R)
n = input()
inf = 1000000000
M = [[inf for i in range(n)] for i in range(n)]
for i in range(n):
  str = map(int, raw_input().split())
  u = str[0]
  k = str[1]
  for j in range(k):
    v = str[2+j]
    c = str[3+j]
    M[u][v] = c
d = [inf for i in range(n)]
color = [0 for i in range(n)]
 
d[0] = 0
color[0] = 1
 
while 1:
  minv = inf
  u = -1
  for i in range(n):
    if minv>d[i] and color[i]!=2:
      u = i
      minv = d[i]
    print minv
  if u == -1:
    break
  color[u] = 2
  for v in range(n):
    if color[v]!=2 and M[u][v]!=inf:
      if d[v]>d[u]+M[u][v]:
        d[v] = d[u] + M[u][v]
        color[v] = 1
for i in range(n):
  if d[i]==inf:
    print '%d -1' % i
  else:
    print '%d %d' % (i, d[i])

### FIXED CODE ###

n = input()
inf = 1000000000
M = [[inf for i in range(n)] for i in range(n)]
for i in range(n):
  str = map(int, raw_input().split())
  u = str[0]
  k = str[1]
  for j in range(k):
    v = str[2+2*j]
    c = str[3+2*j]
    M[u][v] = c
d = [inf for i in range(n)]
color = [0 for i in range(n)]
 
d[0] = 0
color[0] = 1
 
while 1:
  minv = inf
  u = -1
  for i in range(n):
    if minv>d[i] and color[i]!=2:
      u = i
      minv = d[i]
  if u == -1:
    break
  color[u] = 2
  for v in range(n):
    if color[v]!=2 and M[u][v]!=inf:
      if d[v]>d[u]+M[u][v]:
        d[v] = d[u] + M[u][v]
        color[v] = 1
for i in range(n):
  if d[i]==inf:
    print '%d -1' % i
  else:
    print '%d %d' % (i, d[i])
N, Q = map(int, input().split())
graph = [[] for _ in range(N)]
point = [0]*N
for i in range(N-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)
for i in range(Q):
    p, x = map(int, input().split())
    point[p-1] += x
def dfs(s,parent):
    for i in graph[s]:
        if i == parent:
            continue
        point[i] += point[s]
        dfs(i,s)
dfs(0,-1)
print(*point)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
N, Q = map(int, input().split())
graph = [[] for _ in range(N)]
point = [0]*N
for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)
for i in range(Q):
    p, x = map(int, input().split())
    point[p-1] += x
def dfs(s,parent):
    for i in graph[s]:
        if i == parent:
            continue
        point[i] += point[s]
        dfs(i,s)
dfs(0,-1)
print(*point)
mi=-(10**9+1)
n,k=[int(x) for x in input().split()]
p=[int(x) for x in input().split()]
c=[int(x) for x in input().split()]

#ループの最大値を求める
mxs=mi
otl=mi
lpc={}
for i in range(n):
    chkr={i:1}
    wks=0
    wks2=0
    nxt=i
    for _ in range(n):
        nxt=p[nxt]-1
        if chkr.get(nxt):
            wks+=c[nxt]
            break
        chkr[nxt]=1
        wks+=c[nxt]
        otl=max(otl,wks)
    if mxs<wks:
        mxs=wks
        lpc=chkr
dv=k//len(lpc)
rst=k%len(lpc)

mxr=0
for i in lpc.keys():
    wks=0
    nxt=i
    for _ in range(rst):
        nxt=p[nxt]-1
        wks+=c[nxt]
        mxr=max(mxr,wks)

ans=max(dv*mxs+mxr,otl)
print(ans)


### FIXED CODE ###

n,k=[int(x) for x in input().split()]
p=[int(x)-1 for x in input().split()]
c=[int(x) for x in input().split()]

ans=max(c)
if ans<0:
    print(ans)
    exit()

for i in range(n):
    #最後に自分という順番
    nxt=i
    lp=[]
    while 1:
        nxt=p[nxt]
        lp.append(nxt)
        if nxt==i:
            break
    lpc=sum(c[x] for x in lp)
    nxt=i
    lpl=len(lp)
    wks=0
    for j in range(lpl):
        nxt=p[nxt]
        wks+=c[nxt]
        ans=max(ans,(k-j-1)//lpl*max(0,lpc)+wks)
        if j==k-1:
            break
print(ans)
#!/usr/bin/env python3

from collections import defaultdict


class Graph(object):
    """ Graph data structure, undirected by default. """

    def __init__(self, connections, directed=False):
        self._graph = defaultdict(set)
        self._directed = directed
        self.add_connections(connections)

    def add_connections(self, connections):
        """ Add connections (list of tuple pairs) to graph """

        for u, v in connections:
            self.add(u, v)

    def add(self, u, v):
        """ Add connection between node u and node v """

        self._graph[u].add(v)
        if not self._directed:
            self._graph[v].add(u)

    def get_adj(self, v):
        """ Get adjacency list of node v """
        return self._graph[v]

    def __str__(self):
        return '{}({})'.format(self.__class__.__name__, dict(self._graph))


# -----
N, Q = map(int, input().split())
connections = []
for _ in range(N - 1):
    a, b = map(int, input().split())
    connections.append((a, b))
query = []
for _ in range(Q):
    p, x = map(int, input().split())
    query.append([p, x])
# print(N, Q)
# print(connections, query)

keys = [v for v in range(1, N + 1)]
values = [0 for _ in range(N)]
counter = dict(zip(keys, values))
# print(counter)
for p, x in query:
    counter[p] += x


def dfs(v, parent):
    if v != 1:
        counter[v] += counter.get(parent)
    for v_next in g.get_adj(v):
        dfs(v_next, v)


g = Graph(connections, directed=True)
# print(g)

keys = [v for v in range(1, N + 1)]
values = [False for _ in range(N)]
seen = dict(zip(keys, values))
root = 1
dfs(root, None)

for c in counter.values():
    print(c, end=" ")


### FIXED CODE ###

#!/usr/bin/env python3

import sys

input = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 6)

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

edges = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

query = []
for _ in range(Q):
    p, x = map(int, input().split())
    query.append([p, x])

counter = [0 for _ in range(N)]
for p, x in query:
    counter[p - 1] += x


def dfs(v, parent):
    for v_next in edges[v]:
        if v_next != parent:
            counter[v_next] += counter[v]
            dfs(v_next, v)


root = 0
dfs(root, None)

print(*counter)
n = int(input())
x_state = 0
y_state = 0
for i in range(n):
    t, x, y = map(int, input().split())
    if abs(x + y - x_state - y_state) != 1:
        print("No")
        exit()
    x_state = x.copy()
    y_state = y.copy()
print("Yes")
    

### FIXED CODE ###

n = int(input())
t_state, x_state, y_state = 0, 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    d = abs(x - x_state) + abs(y - y_state)
    td = t - t_state
    if  td < d or td%2 != d%2:
        print("No")
        exit()
    t_state, x_state, y_state = t, x, y
print("Yes")
n, m = map(int, input().split())
towns = [0] * n
cnt = 1

def rewr(x, y, z):
    if x == y:
        return z
    else:
        return x

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if towns[a] == 0 and towns[b] == 0:
        towns[a] = cnt
        towns[b] = cnt
        cnt += 1
    elif towns[a] > 0 and towns[b] == 0:
        towns[b] = towns[a]
    elif towns[b] > 0 and towns[a] == 0:
        towns[a] = towns[b]
    elif towns[a] > 0 and towns[b] > 0:
        if towns[a] != towns[b]:
            min_no = min(towns[a], towns[b])
            max_no = max(towns[a], towns[b])
            towns = [rewr(twn, max_no, min_no) for twn in towns]
    else:
        pass
        #print('pass')

rslt = 0
#print(towns)
rslt += max(towns) - 1
rslt += towns.count(0)
print(rslt)


### FIXED CODE ###

n = int(input())
s=''
for i in range(n):
    s = s + 'ACL'
print(s)
S = input()
S_list = list(set(S))
al = 'abcdefghijklmnopqrstucwxyz'
al_list = list(al)
S_list.sort()

for i in range(len(S)):
    if al_list[i] in S_list:
        pass
    else:
        print(al_list[i])
        break
    
if i == len(S) - 1:
    print('None')

### FIXED CODE ###

S = input()
S_list = list(set(S))
al = 'abcdefghijklmnopqrstucwxyz'
al_list = list(al)
S_list.sort()
flg = 1
for i in range(len(al_list)):
    if al_list[i] in S_list:
        pass
    else:
        print(al_list[i])
        flg = 0
        break
    
if flg == 1:
    print('None')
S = input().strip()
slen = len(S)
s = S + '##'

for i in range(slen):
  if s[i] == s[i+1]:
    print(i+1, i+2)
    exit()

  if s[i] == [i+2]:
    print(i+1, i+3)
  	exit()
    
print(-1, -1)

### FIXED CODE ###

def d_unbalanced(S):
    S_length = len(S)
    s = S + '##'  # 統一的に扱うため、アルファベットでない文字を番兵とする
    for i in range(S_length):
        # どちらかを満たす文字列をアンバランスなものとして出せばいい
        # 全部調べても成り立たなければ、アンバランスな文字列はない
        if s[i] == s[i + 1]:  # XXと文字が並んでいる
            return '{} {}'.format(i + 1, i + 2)
        elif s[i] == s[i + 2]:  # XYXと文字が並んでいる
            return '{} {}'.format(i + 1, i + 3)
    # アンバランスな文字列はなかった
    return '-1 -1'
 
S = input().strip()
print(d_unbalanced(S))