Problem:
 Score : 400 points    Problem Statement Given a string t , we will call it unbalanced if and only if the length of t is at least 2 , and more than half of the letters in t are the same. For example, both voodoo and melee are unbalanced, while neither noon nor a is.  You are given a string s consisting of lowercase letters. Determine if there exists a (contiguous) substring of s that is unbalanced. If the answer is positive, show a position where such a substring occurs in s .      Constraints  2 ≦ |s| ≦ 10^5  s consists of lowercase letters.       Partial Score  200 points will be awarded for passing the test set satisfying 2 ≦ N ≦ 100 .         Input The input is given from Standard Input in the following format:  s       Output If there exists no unbalanced substring of s , print -1 -1 .  If there exists an unbalanced substring of s , let one such substring be s_a s_{a+1} ... s_{b}  (1 ≦ a < b ≦ |s|) , and print a  b . If there exists more than one such substring, any of them will be accepted.        Sample Input 1 needed      Sample Output 1 2 5  The string s_2 s_3 s_4 s_5  =  eede is unbalanced. There are also other unbalanced substrings. For example, the output 2 6 will also be accepted.       Sample Input 2 atcoder      Sample Output 2 -1 -1  The string atcoder contains no unbalanced substring.

Solution (Python):
s = list(input())
n = len(s)

start = -1
end = -1

if n == 2:
    if s[0] == s[-1]:
        start = 1
        end = 2
    
for i in range(n-2):
    a = [0]*26
    for j in range(3):
        a[ord(s[i+j])-ord("a")] += 1
    if max(a) >= 2:
        ans = 1
        start = i+1
        end = i+3
        break
        
print(start, end)

Solution (Python):
def main():
    s = input()
    last_s = s[1]
    second_last_s = s[0]
    if last_s == second_last_s:
        print(1,2)
        exit()
    l = len(s)
    for i in range(2,l):
        if second_last_s == s[i]:
            print(i-1,i+1)
            exit()
        elif last_s == s[i]:
            print(i,i+1)
            exit()
        last_s = s[i]
        second_last_s = s[i-1]

    print(-1,-1)





if __name__ == "__main__":
    main()

Solution (Python):
s=input()
if (len(s))==2:print(1,2)if s[1]==s[0]else print(-1,-1)
else:
    for i in range(2,len(s)):
        if s[i]==s[i-1]:print(i,i+1)
        elif s[i]==s[i-2]:print(i-1,i+1)
        else:continue
        break
    else:print(-1,-1)

Solution (Python):
s=input()
for i,c in enumerate(s):
    if i == 0:
        continue
    if i == 1:
        if s[i-1] == s[i]:
            print(i, i+1)
            break
        continue
    if s[i-1] == s[i]:
        print(i, i+1)
        break
    if s[i-2] == s[i]:
        print(i-1, i+1)
        break
else:
    print(-1, -1)

Solution (Python):
def main():
    S = input()

    for i, (a, b) in enumerate(zip(S, S[1:]), start=1):
        if a == b:
            print(i, i + 1)
            return

    for i, (a, b, c) in enumerate(zip(S, S[1:], S[2:]), start=1):
        if a == c:
            print(i, i + 2)
            return

    print(-1, -1)


if __name__ == '__main__':
    main()

Solution (Python):
s=input()
s_len=len(s)
for i in range(s_len-1):
  if s[i]==s[i+1]:
    print(i+1,i+2)
    exit()
  if i!=s_len-2 and s[i]==s[i+2]:
    print(i+1,i+3)
    exit()

print(-1,-1)

Solution (Python):
s=input()
N=len(s)
rl=[]
tmp=""
t=0
ans=[-1,-1]

for i in range(N):
    if tmp=="":
        tmp=s[i]
        t +=1
    else:
        if s[i]==tmp:
            t +=1
            ans = [i-t+2,i+1]
        else:
            rl.append([tmp,t,i])
            tmp=s[i]
            t=1
else:
    rl.append([tmp,t,N])
    

if ans!=[-1,-1]:
    print(*ans)
else:
    leng=len(rl)
    if leng>=3:
        for j in range(2,leng):
            if rl[j][0]==rl[j-2][0]:
                ans=[rl[j][2]-2,rl[j][2]]
                break
    print(*ans)

Solution (Python):
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  


S = LS2()
N = len(S)

for i in range(N-1):
    if S[i] == S[i+1]:
        print(i+1,i+2)
        exit()
for i in range(N-2):
    if S[i] == S[i+2]:
        print(i+1,i+3)
        exit()
print(-1,-1)

Solution (Python):
import sys
S = input()
L = len(S)
if S[0] == S[1]:
    print(1, 2)
    sys.exit()
if L == 2:
    print(-1, -1)
    sys.exit()
ansL = -1
ansR = -1
for i in range(2, L):
    if S[i-1] == S[i]:
        ansL = i
        ansR = i+1
        break
    if S[i-2] == S[i]:
        ansL = i-1
        ansR = i+1
        break
print(ansL, ansR)

Solution (Python):
s=input()
n=len(s)

if s[0]==s[1]:
    print(1,2)
    exit(0)

a=-1
b=-1
for i in range(n-2):
    d={}

    for j in range(3):
        t=s[i+j]

        if t not in d:
            d[t]=1
        else:
            a=i+1
            b=i+j+1
            print(a,b)
            exit(0)

print(a,b)

Solution (Python):
s=list(input())
n=len(s)
if n==2:
    if s[0]==s[1]:
        print(1,2)
    else:
        print(-1,-1)
else:
    for i in range(n-2):
        if s[i]==s[i+1] or s[i]==s[i+2] or s[i+1]==s[i+2]:
            print(i+1,i+3)
            exit()
    print(-1,-1)

Solution (Python):
import sys

s = input()
n = len(s)



for i in range(n - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        sys.exit()

for i in range(n - 2):
    if s[i] == s[i + 2]:
        print(i + 1, i + 3)
        sys.exit()

print(-1, -1)

Solution (Python):
s=input()
n=len(s)
x=[ord(c)-ord('a') for c in s]

for i in range(1,n):
    if x[i]==x[i-1]:
        print('{} {}'.format(i,i+1))
        exit(0)
    if i>1 and x[i-2]==x[i]:
        print('{} {}'.format(i-1,i+1))
        exit(0)

print('-1 -1')

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


S = LS2()
N = len(S)

for i in range(N-1):
    if S[i] == S[i+1]:
        print(i+1,i+2)
        exit()
for i in range(N-2):
    if S[i] == S[i+2]:
        print(i+1,i+3)
        exit()
print(-1,-1)

Solution (Python):
s = input()
n = len(s)
for i in range(n - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        exit()
    if i + 2 < n and s[i] == s[i + 2]:
        print(i + 1, i + 3)
        exit()
print(-1, -1)

Solution (Python):
import collections
s = input()
ls = len(s)
if ls ==2 and s[0]!=s[1]:
    print(-1,-1)
    exit()
elif ls ==2 and s[0]==s[1]:
    print(1,2)
    exit()
for i in range(2,ls):
    tmp = collections.Counter(s[i-2:i+1])
    if len(tmp.keys())<=2:
        print(i-1,i+1)
        exit()
print(-1,-1)

Solution (Python):
s = input()
for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        print(i, i + 1)
        exit()
    if i > 1 and s[i] == s[i - 2]:
        print(i - 1, i + 1)
        exit()
print(-1, -1)

Solution (Python):
s = '
for i in range(2,len(s)):
    if s[i] == s[i-1]:
        print(i-1,i)
        exit()
    elif s[i] == s[i-2]:
        print(i-2,i)
        exit()
print('-1 -1')

Solution (Python):
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter



input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  
    fac = [0] * SIZE  
    finv = [0] * SIZE  
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    
    
    
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    
    return X.flatten().tolist()[0]

class TwoDimGrid:
    
    def __init__(self, h, w, wall="
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self, start, goal):
        grid = self.grid
        cy, cx = start
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        warp = []
        for i in range(-2, 3):
            for j in range(-2, 3):
                if (i, j) not in move and (i != 0 or j != 0):
                    warp.append((i, j))
        
        d = deque()
        wd = deque()
        self.set(start[1], start[0], 0)
        d.append((0, cx, cy))
        while (d or wd):
            
            if d:
                cc, cx, cy = d.popleft()
            else:
                cc, cx, cy = wd.popleft()
            
            if self.get(cx, cy) < cc:
                continue
            for dx, dy in move:

                nx, ny = dx + cx, dy + cy
                if self.getgrid(nx, ny) == "
                    continue
                if self.get(nx, ny) > cc:
                    self.set(nx, ny, cc)
                    d.append((cc, nx, ny))

            for dx, dy in warp:
                nx, ny = dx + cx, dy + cy
                if nx < 0 or nx > self.w + 1 or ny < 0 or ny > self.h + 1:
                    continue
                if self.getgrid(nx, ny) == "
                    continue
                if self.get(nx, ny) > cc + 1:
                    self.set(nx, ny, cc + 1)
                    wd.append((cc + 1, nx, ny))
        
        
        
        ans = self.get(goal[1], goal[0])
        if ans == INF:
            print(-1)
            return
        else:
            print(ans)
            return

def solve():
    s = getS()
    for i in range(26):
        tgt = chr(ord("a") + i)
        prev = -100
        for j, c in enumerate(s):
            if c == tgt:
                if j - prev < 3:
                    print(prev + 1, j + 1)
                    return
                else:
                    prev = j

    print(-1, -1)



def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    
    solve()

Solution (Python):
import sys
import math
import collections
import bisect
import itertools



sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))




def main():
    s = list(input())

    for i in range(len(s)):
        if i - 1 >= 0:
            if s[i] == s[i - 1]:
                print(i, i + 1)
                exit()
        if i - 2 >= 0:
            if s[i] == s[i - 2]:
                print(i - 1, i + 1)
                exit()

    print(-1, -1)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	
	
	s = input()
	for i in range(ord('z')-ord('a')+1):
		cc = chr(ord('a')+i)
		pre=-100
		for ci, c in enumerate(s):
			if c != cc:
				pre -= 1
			elif pre >= -2:
				print(ci+pre+1, ci+1)
				return 
			else:
				pre = -1
			
	print(-1,-1)
	return 
	
		
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
s = input()
l = len(s)
for i in range(l-2):
  temp = s[i]
  if s[i+1]==temp:
    print(str(i+1)+" "+str(i+2))
    quit()
  if s[i+2]==temp:
    print(str(i+1)+" "+str(i+3))
    quit()
    
if s[-1]==s[-2]:
  print(str(l-1)+ " "+str(l))
  quit()
print("-1 -1")

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
n = len(s)
ans = None
for i in range(n-1):
    if s[i]==s[i+1]:
        ans = (i+1,i+2)
        
for i in range(n-2):
    if s[i]==s[i+2]:
        ans = (i+1,i+3)
if ans is not None:
    print(" ".join(map(str, ans)))
else:
    print("-1 -1")

Solution (Python):
s=input()
n=len(s)
e,p,r=exit,print,range
for i in r(n-1):
 if s[i]==s[i+1]:e(p(i+1,i+2))
for i in r(n-2):
 if s[i]==s[i+2]:e(p(i+1,i+3))
p(-1,-1)

Solution (Python):
s = input()
n = len(s)
for i in range(n - 1):
    if s[i] == s[i + 1]:
        exit(print(i + 1, i + 2))
for i in range(n - 2):
    if s[i] == s[i + 2]:
        exit(print(i + 1, i + 3))
print(-1, -1)

Solution (Python):
'''
研究室PCでの解答
'''
import math

import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    s = input()
    n = len(s)
    if s[0] == s[1]:
        print(1,2)
        exit()
    for i in range(2,n):
        if s[i] == s[i-1]:
            print(i,i+1)
            exit()
        elif s[i] == s[i-2]:
            print(i-1,i+1)
            exit()

    print(-1,-1)


    return None

if __name__ == '__main__':
    main()

Solution (Python):
s = input()
if len(s)==2 and s[0]==s[1]:
  print(1,2)
  exit()
for i in range(len(s)-2):
  if s[i]==s[i+1]:
    print(i+1,i+3)
    exit()
  elif s[i]==s[i+2]:
    print(i+1,i+3)
    exit()
else:
  print(-1,-1)

Solution (Python):
import sys
import re

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    S = in_s()

    orda = ord('a')
    for c in range(orda, orda + 26):

        c = chr(c)

        pattern = c + c
        m = re.search(pattern, S)
        if m:
            a, b = m.span()
            print(a + 1, b)
            exit()

        pattern = c + '[^' + c + ']' + c
        m = re.search(pattern, S)
        if m:
            a, b = m.span()
            print(a + 1, b)
            exit()
    else:
        print(-1, -1)


if __name__ == '__main__':
    main()

Solution (Python):
r="-1 -1"
s=input()
for i in range(len(s)-2):
  if len(set(s[i:i+3]))<=2:
    r=str(i+1)+" "+str(i+3)
    break
if len(s)==2 and len(set(list(s)))==1:
  r="1 2"
print(r)

Solution (Python):
from collections import defaultdict
s = input()
dd = defaultdict(list)
for i, c in enumerate(s):
    dd[c].append(i)


def solve(ls):
    for x, y in zip(ls, ls[1:]):
        if y-x <= 2:
            return True, (x+1, y+1)
    return False, None


for k, v in dd.items():
    is_yes, ans = solve(v)
    if is_yes:
        print(*ans)
        break
else:
    print(-1, -1)

Solution (Python):
s = input()

"""
ある文字が一つ飛ばし以内で存在すれば、その2文字を含めて3文字の答えを作れる
これ以上離れていてもアンバランスにするには、どこかで上記の条件を満たす必要があるため
十分条件でもある。
これをaからzまで試す
"""

for i in range(26):
    tgt = chr(ord('a')+i)
    idx = -10**7
    for j in range(len(s)):
        if s[j]==tgt:
            if j-idx<=2:
                print('{} {}'.format(idx+1, j+1))
                exit()
            else:
                idx = j
print('-1 -1')

Solution (Python):
from collections import Counter

s = input()

flg = False
lst = []

for i in range(len(s)-2):
    if(s[i] == s[i+1]):
        flg = True
        lst.append(i+1)
        lst.append(i+2)
        break
    elif(s[i] == s[i+2]):
        flg = True
        lst.append(i+1)
        lst.append(i+3)
        break

if not(lst):     
    if(s[len(s)-1] == s[len(s)-2]):
        lst.append(len(s)-1)
        lst.append(len(s))
        flg = True

if(flg):
    print(*lst)
else:
    print(-1, -1)

Solution (Python):
s = input()
n = len(s)

for i in range(n-1):
    if(s[i]==s[i+1]):
        print('{} {}'.format(i+1,i+2))
        exit()

for i in range(n-2):
    if(s[i]==s[i+2]):
        print('{} {}'.format(i+1,i+3))
        exit()

print('{} {}'.format(-1,-1))

Solution (Python):
s = input()

if s[-1] == s[-2]:
    print(len(s)-1, len(s))
    exit()

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

print(-1, -1)

Solution (Python):
s = input()
n = len(s)
alp = [0 for i in range(26)]
lef = 0
rig = 0
alp[ord(s[0]) - ord("a")] += 1
for i in range(n-1):
    rig += 1
    now = ord(s[rig]) - ord("a")
    alp[now] += 1
    if alp[now] == 2:
        while True:
            if alp[now] == 1:
                break
            if 2<= rig-lef+1 <= 3:
                print(str(lef+1) + " " + str(rig+1))
                exit()
            alp[ord(s[lef]) - ord("a")] -= 1
            lef += 1
                
print("-1 -1")

Solution (Python):
from collections import Counter

s = input()

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

Solution (Python):
s = input()

if s[0] == s[1]:
    print(1, 2)
    exit()

for i in range(len(s)-2):
    if s[i] == s[i+1] or s[i] == s[i+2]: 
        print(i+1, i+3)
        exit()

print(-1, -1)

Solution (Python):
s = input()

bb = ""
b = ""
ans = -1
end = -1
for i in range(len(s)):
    if s[i] == b:
        ans = i
        end = i+1
        break
    elif s[i] == bb:
        ans = i-1
        end = i+1
        break
    else:
        bb = b
        b = s[i]


print(ans,end)

Solution (Python):




import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    s=str(input())
    ls=len(s)
    if ls==2: print("-1 -1" if s[0]!=s[1] else "1 2")
    else:
        for i in range(ls-2):
            if len(set(s[i:i+3]))!=3:
                print(i+1,i+3)
                break
        else: print('-1 -1')
            

    
resolve()

Solution (Python):


import sys
read = sys.stdin.read
readline = sys.stdin.readline



s = input()
l = len(s)

if l==2:
    if s[0]==s[1]: print(1,2)
    else: print(-1,-1)
    exit()

for i in range(l-2):
    t = s[i:i+3]
    
    if t[0]==t[1] or t[1]==t[2] or t[2]==t[0]:
        print(i+1,i+3)
        break

else:
    print(-1,-1)

Solution (Python):
S = input()

for i in range(len(S)-1):
    if S[i] == S[i+1]:
        print(i+1, i+2)
        break
    elif i < len(S)-2:
        if S[i] == S[i+2]:
            print(i+1, i+3)
            break
else:
    print(-1, -1)

Solution (Python):
import sys
s=input()
n=len(s)
for i in range(1,n):
  if s[i]==s[i-1]:
    print(i)
    print(i+1)
    sys.exit()
  if i>1 and s[i]==s[i-2]:
    print(i-1)
    print(i+1)
    sys.exit()
print(-1)
print(-1)

Solution (Python):
s = input()
length = len(s)
ans = '-1 -1'
for i in range(length - 1):
  if s[i] == s[i + 1]:
    ans = '{} {}'.format(i + 1, i + 2)
    break
  if i < length - 2 and s[i] == s[i + 2]:
    ans = '{} {}'.format(i + 1, i + 3)
    break
print(ans)

Solution (Python):
s=input()
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    print(i+1,i+2)
    quit()
for i in range(len(s)-2):
  if s[i]==s[i+2]:
    print(i+1,i+3)
    quit()  
print(-1,-1)

Solution (Python):
s = input()
if s[-2] == s[-1]:
    print(len(s)-1, len(s))
    exit()

for i in range(len(s) - 2):
    if s[i] == s[i+1] or s[i] == s[i+2]:
        print(i+1, i+3)
        exit()
print(-1, -1)

Solution (Python):

import sys
readline = sys.stdin.readline

S = readline().rstrip()
if len(S) == 2:
  if S[0] == S[1]:
    print(1,2)
  else:
    print(-1,-1)
  exit(0)

for i in range(len(S) - 3):
  if len(set(S[i:i + 3])) < 3:
    print(i + 1, i + 3)
    exit(0)
else:
  print(-1,-1)

Solution (Python):
s = input()

for i in range(len(s) - 2):
    temp = s[i]
    if temp == s[i + 1] or temp == s[i + 2]:
        print(i + 1, i + 3)
        exit()
if len(s) == 2 and len(set(s)) == 1:
    print(1, 2)
else:
    print(-1, -1)

Solution (Python):
s = input()
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        break
    try:
        if s[i] == s[i+2] or s[i+1] == s[i+2]:
            print(i+1, i+3)
            break
    except :
        pass
else:
    print(-1, -1)

Solution (Python):
def main():
    from itertools import tee
    S = input()

    it1, it2 = tee(iter(S), 2)
    next(it2)
    for i, (c1, c2) in enumerate(zip(it1, it2), start=1):
        if c1 == c2:
            print(i, i + 1)
            return

    it1, it2, it3 = tee(iter(S), 3)
    next(it2)
    next(it3)
    next(it3)
    for i, (c1, c2, c3) in enumerate(zip(it1, it2, it3), start=1):
        if c1 == c3:
            print(i, i + 2)
            return

    print(-1, -1)


if __name__ == '__main__':
    main()

Solution (Python):


S = input()
N = len(S)
for i in range(N):
    if i < N-1:
        if len(set(S[i:i+2])) == 1:
            print(i+1, i+2)
            exit()

    if i < N-2:
        if len(set(S[i:i+3])) <= 2:
            print(i+1, i+3)
            exit()

print(-1,-1)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    S = input()
    N = len(S)
    for i in range(N - 2):
        if S[i] == S[i + 1]:
            print(i + 1, i + 2)
            return

        if S[i] == S[i + 2]:
            print(i + 1, i + 3)
            return

    if S[N - 2] == S[N - 1]:
        print(N - 1, N)
        return

    print(-1, -1)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    S = readline().strip()
    N = len(S)

    for i in range(N-1):
        if S[i+1] == S[i]:
            print(i + 1, i + 2)
            exit()

    for i in range(N-2):
        if S[i+2] == S[i]:
            print(i + 1, i + 3)
            exit()
    
    print(-1, -1)


if __name__ == "__main__":
    main()

Solution (Python):
s=input()
s_l=len(s)

for i in range(s_l-1):
  if s[i]==s[i+1]:
    i+=1
    print(i,i+1)
    exit()
  elif i!=s_l-2 and s[i]==s[i+2]:
    i+=1
    print(i,i+2)
    exit()

print(-1,-1)

Solution (Python):
def solve():
    S = input()
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            print(i+1,i+2)
            return
    
    for i in range(len(S)-2):
        if S[i] == S[i+2]:
            print(i+1,i+3)
            return

    print(-1,-1)
    
if __name__ == '__main__':
    solve()

Solution (Python):
s=input()
n=len(s)

for i in range(n-1):
  t=s[i:i+2]
  if t[0]==t[-1]:
    print(i+1,i+2)
    exit(0)

for i in range(n-2):
  t=s[i:i+3]
  if t[0]==t[-1] and t[0]!=t[1]:
    print(i+1,i+3)
    exit(0)
print(-1,-1)

Solution (Python):
s = input()

if len(s) == 2:
    if len(set(s)) == 1:
        print(1, 2)
        exit()
    else:
        print(-1, -1)
        exit()

for i in range(len(s)-2):
    if len(set(s[i:i+3])) < 3:
        print(i+1, i+3)
        exit()
else:
    print(-1, -1)

Solution (Python):
s = input().strip()
C = {chr(i):[] for i in range(97,123)}
for j in range(len(s)):
    C[s[j]].append(j)
flag = 0
for i in range(97,123):
    a = chr(i)
    n = len(C[a])
    if n>1:
        for j in range(1,n):
            if C[a][j]-C[a][j-1]<=2:
                flag = 1
                x = C[a][j-1]
                y = C[a][j]
                break
    if flag==1:
        break
if flag==0:
    print(-1,-1)
else:
    print(x+1,y+1)

Solution (Python):
S=input()
if S[0]==S[1]:
    print(1,2)
    exit()
L=[S[0],S[1]]

for i in range(2,len(S)):
    s=S[i]
    if s in L:
        print(i+1-(2-L.index(s)), i+1)
        exit()
    else:
        L.pop(0)
        L.append(s)
    
print(-1, -1)

Solution (Python):
S = input()
N = len(S)

def sol():
    for i in range(N - 1):
        T = list(S[i: i + 2])
        if len(set(T)) == 1:
            return (i + 1, i + 2)
    for i in range(N - 2):
        T = list(S[i: i + 3])
        if len(set(T)) <= 2:
            return (i + 1, i + 3)
    return (-1, -1)

print(*sol())

Solution (Python):
import sys

import math
from fractions import Fraction
import itertools


s=input()
n=len(s)
ans1=ans2=-1
for i in range(n-2):
    if s[i]==s[i+2]:
        ans1=i
        ans2=i+2
        break
else:
    for i in range(n-1):
        if s[i]==s[i+1]:
            ans1=i
            ans2=i+1
            break
    else:
        print(-1,-1)
        exit()

print(ans1+1,ans2+1)

Solution (Python):
s = input()
N = len(s)

res = ""
ind = -1
eind = -1
c = 0
for i in range(N):
  if c == 0:
    if s[i] != res:
      res = s[i]
      ind = i
    else:
      c = 1
  elif c == 1:
    if s[i] != res:
      eind = i
      break
if eind == -1:
  if ind == N-1:
    ind = -1
  else:
    eind = N-1

if ind == -1 and eind == -1:
  ind = -1
  eind = -1
  for i in range(N):
    if i+2 < N:
      if s[i] == s[i+2]:
        ind = i
        eind = i+2
        break  
if ind != -1 and eind != -1:           
  ind += 1
  eind += 1
print(ind,eind)

Solution (Python):
def main():
    s = input() + "
    group = [[s[0], 1, 1, 0]]
    for i in range(1, len(s)):
        if s[i] == group[-1][0]:
            group[-1][1] += 1
        else:
            group[-1][3] = i
            group.append([s[i], 1, i + 1, -1])
    group.sort(key=lambda x: x[1], reverse=True)
    if group[0][1] > 1:
        print(group[0][2], group[0][3])
    else:
        for i in range(len(s) - 4):
            if s[i] == s[i + 2] and s[i] != s[i + 1]:
                print(i + 1, i + 3)
                break
        else:
            print(-1, -1)


if __name__ == '__main__':
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    n = len(s)

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

    for j in range(2, n):
        if s[j - 2] == s[j]:
            print(j - 1, j + 1)
            exit()

    print(-1, -1)


if __name__ == '__main__':
    resolve()

Solution (Python):
s = list(input())
ls = len(s)
for i in range(1, ls):
    if s[i] == s[i-1]:
        print(i, i+1)
        break
    if i == 1:
        continue
    if s[i] == s[i-2]:
        print(i-1, i+1)
        break
else:
    print(-1, -1)

Solution (Python):
def solve():
    S = input()
    n = len(S)
    if S[0]==S[1]:
        return [1,2]
    for i in range(1,n):
        if S[i]==S[i-1]:
            return [i,i+1]
        if i>=2 and S[i]==S[i-2]:
            return [i-1,i+1]
    return [-1,-1]
print(*solve())

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

S = list(input())
N = len(S)

for i in range(1, N):
    if S[i - 1] == S[i]:
        print (i, i + 1)
        exit()

for i in range(2, N):
    if S[i - 2] == S[i]:
        print (i - 1, i + 1)
        exit()

print (-1, -1)

Solution (Python):
s=input()
n=len(s)
for i in range(1,n):
  if s[i-1]==s[i]:
    print(i,i+1)
    exit()
for i in range(2,n):
  if s[i-2]==s[i]:
    print(i-1,i+1)
    exit()
print(-1,-1)

Solution (Python):
s=input()
n=len(s)
for x in range(n-1):
    if s[x]==s[x+1]:print(x+1,x+2,sep=" ");exit()
for i in range(n-2):
    if s[i]==s[i+2]:
        print(i+1,i+3,sep=" ");exit()

print("-1 -1")

Solution (Python):
s = list(input())
for i in range(26):
    x = chr(i + ord('a'))
    cnt = 0
    m = (0,-1)
    for j,t in enumerate(s):
        cnt -= 1
        if t == x:cnt += 2
        if m[0] < cnt and m[1]+1 != j:
            print(m[1]+2,j+1)
            exit(0)
        elif m[0] > cnt:
            m = (cnt,j)
print(-1,-1)

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()

if len(s) == 2:
    if s[0] == s[1]:
        print(1,2)
        exit()
    print(-1,-1)
    exit()

for i in range(len(s)-2):
    a,b,c = s[i],s[i+1],s[i+2]
    if a == b or b == c or c == a:
        print(i+1,i+3)
        exit()

print(-1,-1)

Solution (Python):
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    s = sys.stdin.readline().rstrip()
    s0 = s[0]
    s1 = s[1]
    if len(s) == 2 and s0 == s1:
        print(1,2)
        exit(0)

    for i in range(2,len(s)):
        x = s[i]
        if x == s0 or x == s1:
            print(i-1,i+1)
            exit(0)
        s0 = s1
        s1 = x

    print(-1,-1)


if __name__ == '__main__':
    main()

Solution (Python):


"""
アンバランス
・長さが2以上
→そのまま
・過半数の文字が同じ
→abcaa　とか aabacda　aa とか 

ある2文字や3文字の区間を見た時に
・2文字：両方一致
・3文字：3つ中二つが一致
ならアンバランス
"""

S = input()
N = len(S)

for i in range(N-1):
  if len(set(S[i:i+2])) == 1:
    print(i+1, i+2)
    exit()

for i in range(N-2):
  if len(set(S[i:i+3])) <= 2:
    print(i+1, i+3)
    exit()

print(-1, -1)

Solution (Python):
def is_umbalance(s):
    if len(s) == 2:
        return s[0] == s[1]
    if s[0] == s[1] or s[1] == s[2] or s[2] == s[0]:
        return True
    else:
        return False


def main(s):
    for i in range(len(s) - 1):
        if is_umbalance(s[i:i+2]):
            print(i + 1, i + 2)
            return
        if i + 2 < len(s) and is_umbalance(s[i:i+3]):
            print(i + 1, i + 3)
            return
    print(-1, -1)


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

Solution (Python):
import sys

s = sys.stdin.readline().rstrip()

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        sys.exit()

for i in range(len(s)-2):
    if s[i] == s[i+2]:
        print(i+1, i+3)
        sys.exit()

print(-1, -1)