Harryxun/stf_run huggingface dataset:
import collections

graph = collections.defaultdict(list)

N = int(input())
for i in range(N-1):
    # print(i)
    a, b, c = map(int, input().split(' '))
    a -= 1
    b -= 1
    graph[a].append([b, c])
    graph[b].append([a, c])


Q, K = map(int, input().split(' '))

dist = [-1 for _ in range(N)]
dist[K-1] = 0

def dfs(a):
    for b, c in graph[a]:
        if dist[b] == -1:
            dist[b] = dist[a] + c
            dfs(b)
dfs(K-1)
# print(dist)


for _ in range(Q):
    x, y = map(int, input().split(' '))
    x -= 1
    y -= 1
    print(dist[x] + dist[y])

### FIXED CODE ###

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

import collections


N = int(input())
graph = [[] for _ in range(N)]
# graph = collections.defaultdict(list)

for i in range(N-1):
    # print(i)
    a, b, c = map(int, input().split(' '))
    a -= 1
    b -= 1
    graph[a].append([b, c])
    graph[b].append([a, c])


Q, K = map(int, input().split(' '))

dist = [-1 for _ in range(N)]
dist[K-1] = 0
stack = [K-1]
while len(stack) != 0:
    a = stack.pop()
    for b, c in graph[a]:
        if dist[b] == -1:
            dist[b] = dist[a] + c
            stack.append(b)


# def dfs(a):
#     for b, c in graph[a]:
#         if dist[b] == -1:
#             dist[b] = dist[a] + c
#             dfs(b)
# dfs(K-1)
# print(dist)


for _ in range(Q):
    x, y = map(int, input().split(' '))
    x -= 1
    y -= 1
    print(dist[x] + dist[y])
import itertools

N, M = map(int, input().split())
E = [[0] * N for i in range(N)]
for i in range(N):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    E[a].append(b)
    E[b].append(a)

count = 0
for V in itertools.permutations(range(1, N)):
    if V[0] in E[0] and all(V[i] in E[V[i-1]] for i in range(1, N-1)):
        count += 1
print(count)        


### FIXED CODE ###

import itertools

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

count = 0
for V in itertools.permutations(range(1, N)):
    if V[0] in E[0] and all(V[i] in E[V[i-1]] for i in range(1, N-1)):
        count += 1
print(count)
N = int(input())
A = [int(k) for k in input().split(' ')]

from collections import Counter 
import math 

# res = [] # solution for each key in A
res_list = {} # solution for each value in A

# counter ver
A_c = Counter(A)
l = len(A_c)

def ncr(j):
  return math.factorial(j) // math.factorial(2) // math.factorial(j - 2) if j >= 2 else 0

# store ncr for each value 
combs = {k: ncr(v) for k, v in A_c.items()}

s = sum(combs.values())
  
for m in A_c.keys():
  cnt = combs[m]

  n = s
  n -= cnt # the only inaccurate entry
  n += ncr(A_c[m] - 1)
  res_list[m] = n

res = ''
for k in range(N):
  res += '\n' + str(res_list[A[k]])
print(res[1:])
# print('\n'.join([str(s) for s in res]))

### FIXED CODE ###

M, N = [int(k) for k in input().split(' ')]
import math 
res = 0

if N >= 2:
  res += (math.factorial(N) // math.factorial(2) // math.factorial(N - 2))

if M >= 2:
  res += (math.factorial(M) // math.factorial(2) // math.factorial(M - 2))

print(res)
i=int(input())
j,k=int(input()),int(input())
l=0
while True:
    if j<=l*i<=k:
        print("OK")
        break
    elif l*i>k:
        print("NG")
        break
    l+=1

### FIXED CODE ###

i=int(input())
j,k=(int(x) for x in input().split())
l=0
while True:
    if j<=l*i<=k:
        print("OK")
        break
    elif l*i>k:
        print("NG")
        break
    l+=1
def main():
    A,B,C = map(int, input().split())
    if A>B:
        D=A
    else:
        D=B

    list =[]
    for i in range(D):
        if i!=0:
            if (A%i == 0) & (B%i == 0) :
                list.append(i)
    print(list[(len(list)-C)])

main()

### FIXED CODE ###

def main():
    A,B,C = map(int, input().split())
    if A>B:
        D=A
    else:
        D=B

    list =[]
    for i in range(D+1):
        if i!=0:
            if (A%i == 0) & (B%i == 0) :
                list.append(i)
    print(list[(len(list)-C)])
    


main()
1000000000000000000 1

### FIXED CODE ###

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

N = N % K

if K - N > N:
  print(N)
  exit()
print(K - N)
x = int(input())
arr = []
for i in range(2,32):
    multi = 2
    while i**multi <= x:
        arr.append(i**multi)
        multi += 1
print(max(arr))

### FIXED CODE ###

x = int(input())
arr = [1]
for i in range(2,32):
    multi = 2
    while i**multi <= x:
        arr.append(i**multi)
        multi += 1
print(max(arr))
from collections import deque

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

tree=[[0] for _ in range(N)]

for _ in range(M):
    A,B=map(int,input().split())
    tree[A-1].append(B-1)
    tree[B-1].append(A-1)

dist = [-1]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in tree[v]:
        if dist[w]!=-1:
            continue
        dist[w] = v
        que.append(w)

print("Yes")
for j in range(1,N):
    print(ans[j])

### FIXED CODE ###

from collections import deque

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

tree=[[0] for _ in range(N)]

for _ in range(M):
    A,B=map(int,input().split())
    tree[A-1].append(B-1)
    tree[B-1].append(A-1)

dist = [-1]*N
que = deque([0])
dist[0] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in tree[v]:
        if dist[w] > -1:
            continue
        dist[w] = d + 1
        que.append(w)
ans=[0 for _ in range(N)]
for i in range(1,N):
    for t in tree[i]:
        if dist[t]==dist[i]-1:
            ans[i]=t+1
            break

print("Yes")
for j in range(1,N):
    print(ans[j])
import numpy as np
n = int(input())
if n == 1:
    print(1)

points = np.zeros((n, 2), dtype=np.int)
for i in range(n):
    x, y = [int(x) for x in input().split()]
    points[i, 0] = x
    points[i, 1] = y

diffs = {}
for i in range(n):
    for j in range(n):
        if i != j:
            diff = (points[i, 0] - points[j, 0], points[i, 1] - points[j, 1])
            if diff in diffs:
                diffs[diff] += 1
            else:
                diffs[diff] = 1

count = sorted(diffs.items(), key=lambda kv: kv[1])[-1][1]
print(n-count)

### FIXED CODE ###

import numpy as np
n = int(input())
if n == 1:
    print(1)
else:
    points = np.zeros((n, 2), dtype=np.int)
    for i in range(n):
        x, y = [int(x) for x in input().split()]
        points[i, 0] = x
        points[i, 1] = y

    diffs = {}
    for i in range(n):
        for j in range(n):
            if i != j:
                diff = (points[i, 0] - points[j, 0], points[i, 1] - points[j, 1])
                if diff in diffs:
                    diffs[diff] += 1
                else:
                    diffs[diff] = 1

    count = sorted(diffs.items(), key=lambda kv: kv[1])[-1][1]
    print(n-count)
from math import gcd
k=int(input())
ans=0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans+=gcd(a,b,c)
print(ans)

### FIXED CODE ###

from math import gcd
k=int(input())
ans=0
for a in range(1,k+1):
  for b in range(1,k+1):
    d=gcd(a,b)
    for c in range(1,k+1):
      ans+=gcd(d,c)
print(ans)
a = int(input())
b=int(input())
if a <b:
  print(a)
else:
  print(a-b)

### FIXED CODE ###

A,B = map(int,input().split())
curtain = int(B*2)
if A > curtain:
    ans = A - curtain
else:
    ans = 0
print(ans)
n, k = map(int, input().split())
P = list(map(int, input().split()))


E = [0] * 1001

total = 0
for i in range(1, 1001):
    total += i
    e = total / i
    E[i] = e

P_to_E = [E[p] for p in P]

candidates = []
candidate = sum(P_to_E[:k])

for i in range(n-k):
    drop = P_to_E[i]
    add = P_to_E[i+k]
    candidate += add - drop
    candidates.append(candidate)

print(max(candidates))

### FIXED CODE ###

n, k = map(int, input().split())
P = list(map(int, input().split()))


E = [0] * 1001

total = 0
for i in range(1, 1001):
    total += i
    e = total / i
    E[i] = e

P_to_E = [E[p] for p in P]


candidate = sum(P_to_E[:k])
candidates = [candidate]

for i in range(n-k):
    drop = P_to_E[i]
    add = P_to_E[i+k]
    candidate += add - drop
    candidates.append(candidate)

print(max(candidates))
N, K =map(int, input().split())
A = list(map(int, input().split()))
for i in range(K, N):
  if A[K+i] ＞ A[i]:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

N, K =map(int, input().split())
A = list(map(int, input().split()))
for i in range(N-K):
    if A[K+i] > A[i]:
        print('Yes')
    else:
        print('No')
n = int(input())
a = [0]*n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        tmp1,tmp2 = list(map(int,input().split()))
        x[i].append(tmp1-1)
        y[i].append(tmp2)

ans = 0
honest = [0]*n
cnt=0
for i in range(2**n): #bit全探索
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
            cnt+=1
        else:
            honest[j] = 0
            
        f = True
        for k in range(n):
          	if honest[k]!=1:
                f = False
                break
            for l in range(a[k]):
                if( and y[k][l]!=honest[x[k][l]]):
                    f = False
                    break
        	if f:
            	ans = max(ans,cnt)
        cnt=0

print(ans)

### FIXED CODE ###

n = int(input())
a = [0]*n
x = [[] for i in range(n)]
y = [[] for i in range(n)]
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        tmp1,tmp2 = list(map(int,input().split()))
        x[i].append(tmp1-1)
        y[i].append(tmp2)

ans = 0
honest = [0]*n
for i in range(2**n): #bit全探索
    for j in range(n):
        if((i>>j)&1):
            honest[j] = 1
        else:
            honest[j] = 0
            
        f = True
        for k in range(n):
            for l in range(a[k]):
                if(honest[k]==1 and y[k][l]!=honest[x[k][l]]):
                    f = False
                    break
        if f:
            ans = max(ans,honest.count(1))

print(ans)
S,T = input().split(' ')
A,B = list(map(int,input().split(' ')))
U = input()

if U == S:
    A = A-1
else:
    B=B-1

print(f'{A} {B}')

### FIXED CODE ###

S,T = input().split(' ')
A,B = list(map(int,input().split(' ')))
U = input()

if U == S:
    A = A-1
else:
    B=B-1

print(str(A)+' '+str(B))
#coding:utf-8

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

print(min(a,c)- max(b,d))


### FIXED CODE ###

#coding:utf-8

n = list(input())

if n[0] == n[2]:
  print('Yes')
else:
  print('No')
n,m=map(int,input().split())
for ai in range(m):
    ai=list(map(int,input().split())
    k=sum(ai)
if k<=n:
    print(m-k)
else:
    print("-1")

### FIXED CODE ###

n,m=map(int,input().split())
ai=list(map(int,input().split()))
k=sum(ai)
if k<=n:
    print(n-k)
else:
    print("-1")
a,b = input().split()
c = 0
n = 0
flag = False
c = a*(1**len(b))+b
for i in range(100000):
  n += 1
  if int(n*n) == int(c):
    flag = True
    break
if flag == True:
  pritn("Yes")
else:
  print("No")

### FIXED CODE ###

a,b = input().split()
c = 0
n = 0
flag = False
c = a*(1**len(b))+b
for i in range(100000):
  n += 1
  if int(n*n) == int(c):
    flag = True
    break
if flag == True:
  print("Yes")
else:
  print("No")
v = list(map(int, input().split()))
if sum(v) >= 22:
  print("bust")
else
  print("win")

### FIXED CODE ###

v = list(map(int, input().split()))
if sum(v) >= 22:
  print("bust")
else:
  print("win")
r, g, b = map(int,input())

if (100*r + 10*g + b) % 4 == 0:
    print(f'YES')
else:
    print(f'NO')

### FIXED CODE ###

r, g, b = map(int,input().split())

if (100*r + 10*g + b) % 4 == 0:
    print('YES')
else:
    print('NO')
a, b = map(int, input().split())
print(a * a - b)


### FIXED CODE ###

a = int(input())
b = int(input())
print(a * a - b)
# coding: utf-8
# Your code here!
import itertools
import math
from scipy.special import comb

N,K = map(int,input().split())
INF = 10**9 + 7
for i in range(1,K+1):
    print(comb(K-1, i-1, True) * comb(N-K+1, i, True) % INF)

### FIXED CODE ###

# coding: utf-8
# Your code here!
from operator import mul
from functools import reduce

def cmb(n, r):
	if n < r:
		return 0
	r = min(n - r, r)
	if r == 0:
		return 1
	numer = reduce(mul, range(n, n - r, -1))
	denom = reduce(mul, range(1, r + 1))
	return numer // denom % INF

N,K = map(int,input().split())
INF = 10**9 + 7
for i in range(1,K+1):
    print(cmb(K-1, i-1) * cmb(N-K+1, i) % INF)
if input().count("5")==2,input().count("7")==1:
              print("YES")
else:
              print("NO")

### FIXED CODE ###

a=input().split()
if a.count("5")==2 and a.count("7")==1:
   print("YES")
else:
   print("NO")
DEBUG = False

N, M, X = map(int, input().split())
A = []
C = []
for _ in range(N):
    CA = list(map(int, input().split()))
    C.append(CA[0])
    A.append(CA[1::])

if DEBUG:
    print(A)
    print(C)

ans_money = float('inf')
# ans_algorythm = None
for i in range(2**N):
    bit = bin(i)[2::]
    bit = bit.zfill(M)
    if DEBUG:
        print("i: {}, bit: {}".format(i, bit))
    tmp_money = 0
    tmp_algorythm = [0] * M
    for j, b in enumerate(bit):
        if b == '1':
            tmp_money += C[j]
            for k, c in enumerate(A[j]):
                tmp_algorythm[k] += c
    if DEBUG:
        print("tmp_money: {}, tmp_algorythm: {}".format(tmp_money, tmp_algorythm))
    if len(list(filter(lambda x: x < X, tmp_algorythm))) == 0:
        ans_money = min(tmp_money, ans_money)
        if DEBUG:
            print("ans_money: {}".format(ans_money))
        # break

if ans_money == float('inf'):
    print(-1)
else:
    print(ans_money)


### FIXED CODE ###

DEBUG = False

N, M, X = map(int, input().split())
A = []
C = []
for _ in range(N):
    CA = list(map(int, input().split()))
    C.append(CA[0])
    A.append(CA[1::])

if DEBUG:
    print(A)
    print(C)

max_money = 10**5 * N + 1
ans_money = max_money
# ans_algorythm = None
for i in range(2**N):
    bit = bin(i)[2::]
    bit = bit.zfill(N)
    if DEBUG:
        print("i: {}, bit: {}".format(i, bit))
    tmp_money = 0
    tmp_algorythm = [0] * M
    for j, b in enumerate(bit):
        if b == '1':
            tmp_money += C[j]
            for k, c in enumerate(A[j]):
                tmp_algorythm[k] += c
    if DEBUG:
        print("tmp_money: {}, tmp_algorythm: {}".format(tmp_money, tmp_algorythm))
    if len(list(filter(lambda x: x < X, tmp_algorythm))) == 0:
        ans_money = min(tmp_money, ans_money)
        if DEBUG:
            print("ans_money: {}".format(ans_money))
        # break

if ans_money == max_money:
    print(-1)
else:
    print(ans_money)
n=list(map(int,input().split()));print(min([i+j for i in n for j in n if i!=j]))

### FIXED CODE ###

P, Q, R = map(int, input().split())
time = [P, Q, R]
result = []
for i in range(len(time)):
  for j in range(i+1, len(time)):
    result.append(time[i]+time[j])
print(min(result))
num = [x for x in input().split() ]
count5 = num.count5("5")
count7 = num.count7("7")
if count5 == 2 and count7 == 1:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

num = list(map(int,input().split()))
if num.count(5) == 2 and num.count(7) == 1:
  print("YES")
else:
  print("NO")
x=int(input())
for i in range(1,x+1):
  if (i**2)>x:
    ans=(i-1)**2
    break
print(ans)    



### FIXED CODE ###

x=int(input())
li=[]
for i in range(1,34):
  for j in range(2,11):
    if (i**j)<=x:
      li.append(i**j)
print(max(li))
def rally():
    N=int(input())
    X=list(map(int,input().split()))
    dispersion=[]
    cnt=0
    for i in range(min(X),max(X)):
        for j in range(N):
            cnt+=abs(X[j]-i)**2
        dispersion.append(cnt)
        cnt=0
    print(min(dispersion))
    return 0
rally()


### FIXED CODE ###

N=int(input())
X=list(map(int,input().split()))
dispersion=[]
cnt=0
for i in range(100):
    for j in range(N):
        cnt+=abs(X[j]-i)**2
    dispersion.append(cnt)
    cnt=0
print(min(dispersion))
import sys,math
def sieves(m):
    global S
    S = range(1,m+1,2)
    r = int(m**.5)
    h = len(S)
    S[0] = 0
    for i in range(h):
        x = S[i]
        if x>r: break
        if x and i+x<h: S[i+x:h:x] = [0]*((h-1-i-x)/x+1)
    S[0] = 2
    return
m = 50100
sieves(m)
for s in sys.stdin:
    n = int(s)
    for p1 in range(n/2-1,0,-1):
        if S[p1]: break
    for p2 in range((n+1)/2,m/2+1):
        if S[p2]: break
    print S[p1],S[p2]

### FIXED CODE ###

import sys
def primes(m):
    N = range(1,m+1,2)
    r = int(m**.5)
    h = len(N)
    N[0] = 0
    i=0
    while N[i]<=r:
        x = N[i]
        if x and i+x<h: N[i+x:h:x] = [0]*((h-1-i-x)/x+1)
        i += 1
    x = [2] + filter(None,N)
    return x

PRIMES = primes(50030)
for s in sys.stdin:
    n = int(s)
    for a in PRIMES:
        if a>n: break
        elif a<n: b = a
    print b,a
import math

# nの約数を全て求める
lim = 10 ** 9 + 7

n = int(input())
if (n <= 2):
    ans = n
else:
    fact = math.factorial(n)

    ans = 1
    loop = int(fact/2)
    for i in range(1, loop + 1):
        if (fact % i == 0):
            #check[i] = 1
            ans += 1


#ans = sum(check)
ans %= lim
print(ans)


### FIXED CODE ###

#import math
#from decimal import Decimal
import numpy as np
# nの約数を全て求める
# n!が大きすぎ＞　解説をみると。。
# ex; 24 = 2^3 * 3
#       (1,2,3,4,6,8,12,24) > 8個

# approach, 1~Nごとに、素因数分解をして、カウントする。
# 最後に掛け合わせる。
lim = 10 ** 9 + 7
n = int(input())
# https://note.nkmk.me/python-prime-factorization/

num = [0] * (n + 1)
#num[1] = 1

for i in range(2, n + 1):
    temp = i
    # even number
    while (temp % 2 == 0):
        if (num[2] == 0):
            num[2] = 1
        num[2] += 1
        # print('2A')
        temp //= 2

    f = 3
    # odd number
    while (f * f <= temp):
        if (temp % f == 0):
            if (num[f] == 0):
                num[f] = 1
            num[f] += 1
            #print('B', f)
            temp //= f
        else:
            f += 2
    # prime number
    if (temp != 1):
        if (num[temp] == 0):
            num[temp] += 1
        num[temp] += 1
        #print('C', temp)

numA = np.array(num)
numAA = np.argwhere(numA != 0)
numAAA = numAA.tolist()
# print(numA)

ans = 1
for i in numAAA:
    tar = i[0]
    ans *= num[tar]

#ans = sum(num)
ans %= lim

print(ans)
a,b,c=map(input().split())
s=list[b]
print("A"+b[0]+"C")


### FIXED CODE ###

a,b,c = map(str,input().split())
B = list(b)
print("A"+B[0]+"C")
A, B, C, D = map(int, input().split())
while (A>0 and C > 0):
    C = C - B
    if C <= 0:
        break
    A = A - D
print("Yes" if C<=0 else "No")

### FIXED CODE ###

s, w = map(int, input().split())
if ( w >= s ):
    print("unsafe")
else:
    print("safe")
x,a,b = map(int, input().split())
if b <=a:
    print("delicious")
elif b <= a+x:
    print("safe")
else:
    print("dangerous")
afaafafd

### FIXED CODE ###

x,a,b = map(int, input().split())
if b <=a:
    print("delicious")
elif b <= a+x:
    print("safe")
else:
    print("dangerous")
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import deque
n=int(input())
a=[]
for i in range(0,n):
  a.append(int(input()))
a.sort()

d = [a[0]]
a=a[1:]
b = deque(d)

f=True
while len(a)>0:
  la=len(a)-1
  lb=len(b)-1
  ln = abs(b[0]-a[0])
  lx = abs(b[0]-a[la])
  rn = abs(b[lb]-a[0])
  rx = abs(b[lb]-a[la])

  x = max(ln, max(lx, max(rn, rx)))

  if x == ln:
    b.insert(0,a[0])
    a=a[1:]
  elif x == lx:
    b.insert(0,a.pop())
  elif x == rn:
    b.append(a[0])
    a=a[1:]
  else:
    b.append(a.pop())
#print(b)

res=0
for i in range(0,len(b)-1):
  res=res+abs(b[i]-b[i+1])
print(res)


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
s=input()
if len(s)==2:
  print(s)
else:
  print(s[2]+s[1]+s[0])
#! usr/bin/env python3
#B:

N = int(input())

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

count = 1

for i in A:
	if A % 2 == 0:
		count *= 2
	else:
		pass

ans = (3 ** len(A)) - count

print(ans)

### FIXED CODE ###

#! usr/bin/env python3
#B:

N = int(input())

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

count = 1

for i in A:
	if i % 2 == 0:
		count *= 2
	else:
		pass

ans = (3 ** len(A)) - count

print(ans)
a,b=map(int,input().split())

if (a*b)%2=0:
    print('Even')
else:
    print('Odd')

### FIXED CODE ###

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

if (a*b)%2==1:
    print('Odd')
else:
    print('Even')
import sys
from collections import defaultdict

def main():
    input = sys.stdin.readline
    S = str(input().strip())
    T = str(input().strip())

    if not set(T) <= set(S):
        return -1

    n = len(S)
    d = defaultdict(list)
    for i, s in enumerate(S, start=1):
        d[s].append(i)

    cnt = 0
    pos = 0
    for t in T:
        if pos > max(d[t]):
            cnt += 1
            pos = d[t][0]
        else:
            left = 0
            right = len(d[t])
            while left != right:
                mid = (left + right) // 2
                np = d[t][mid]
                if np <= pos:
                    left = mid + 1
                else:
                    right = mid
            pos = d[t][left]

    return n * cnt + pos


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys
from collections import defaultdict

def main():
    input = sys.stdin.readline
    S = str(input().strip())
    T = str(input().strip())

    if not set(T) <= set(S):
        return -1

    n = len(S)
    d = defaultdict(list)
    for i, s in enumerate(S, start=1):
        d[s].append(i)

    cnt = 0
    pos = 0
    for t in T:
        if pos >= d[t][-1]:
            cnt += 1
            pos = d[t][0]
        else:
            left = 0
            right = len(d[t])
            while left < right:
                mid = (left + right) // 2
                np = d[t][mid]
                if np <= pos:
                    left = mid + 1
                else:
                    right = mid
            pos = d[t][left]

    return n * cnt + pos


if __name__ == '__main__':
    print(main())
def solve(s):
  for i, j in zip(range(0, len(s)-1), range(1, len(s))):
    if s[i] == s[j]:
      return '{0} {1}'.format(i+1,j+1)
  for i, j in zip(range(0, len(s)-2), range(2, len(s))):
    if s[i] == s[j]:
      return '{0} {1}'.format(i+1, j+1)
  return '{0} {1}'.format(-1 -1)

print(solve(input()))


### FIXED CODE ###

def solve(s):
  for i in range(len(s)-1):
    if s[i] == s[i+1]:
      return '{0} {1}'.format(i+1, i+2)
  for i in range(len(s)-2):
    if s[i] == s[i+2]:
      return '{0} {1}'.format(i+1, i+3)
  return '{0} {1}'.format(-1, -1)

print(solve(input()))
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
a = []
b = []
for i in range(0,n,2):
    a.append(v[i])
    b.append(v[i+1])
a = Counter(a)
b = Counter(b)
p = a.most_common()[0][1]
q = b.most_common()[0][1]

if a.most_common()[0][0] == b.most_common()[0][0]:
    if p == n//2:
        if q == n//2:
            print(n-p-q+n//2)
        else:
            print(n-p-q+(n//2-b.most_common[1][1]))
    else:
        if q != n//2:
            print(n-p-q+n-a.most_common[1][1]-b.most_common[1][1])
        else:
            print(n-p-q+(n//2-a.most_common[1][1]))
            
    
        
            
        

else:
    print(n-p-q)



### FIXED CODE ###

from collections import Counter
n = int(input())
v = list(map(int,input().split()))
a = []
b = []
for i in range(0,n,2):
    a.append(v[i])
    b.append(v[i+1])
a = Counter(a)
b = Counter(b)
p = a.most_common()[0][1]
q = b.most_common()[0][1]

if a.most_common()[0][0] == b.most_common()[0][0]:
    if p == n//2:
        if q == n//2:
            print(n-p-q+n//2)
        else:
            print(n-q-b.most_common()[1][1])
    else:
        if q != n//2:
            
            print(min(n-p-b.most_common()[1][1],n-q-a.most_common()[1][1]))
        else:
            print(n-q-a.most_common()[1][1])
            
    
        
            
        

else:
    print(n-p-q)
N=int(input())
dp=[[0]*3 for i  in range(n+1)]
for i in range(n):
  a,b,c=map(int,input())
  dp[i+1][0]=max(dp[i][1],dp[i][2])+a
  dp[i+1][1]=max(dp[i][0],dp[i][2])+b
  dp[i+1][2]=max(dp[i][0],dp[i][1])+c
print(max(dp[-1]))

### FIXED CODE ###

n=int(input())
dp=[[0]*3 for i  in range(n+1)]
for i in range(n):
  a,b,c=map(int,input().split())
  dp[i+1][0]=max(dp[i][1],dp[i][2])+a
  dp[i+1][1]=max(dp[i][0],dp[i][2])+b
  dp[i+1][2]=max(dp[i][0],dp[i][1])+c
print(max(dp[-1]))