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 = input()
answer = "-1 -1"

if s[-2] == s[-1]:
    answer = "{} {}".format(len(s) - 1, len(s))

for i in range(len(s) - 2):
    if s[i] == s[i + 1] or s[i] == s[i + 2] or s[i + 1] == s[i + 2]:
        answer = "{} {}".format(i + 1, i + 3)
        break

print(answer)

Solution (Python):
import sys
s = input()
for i, (x, y) in enumerate(zip(s, s[1:])):
    if x == y:
        print(i+1, i+2)
        sys.exit()
if len(s) <= 2:
    print(-1, -1)
    sys.exit()
for i, (x, y, z) in enumerate(zip(s, s[1:], s[2:])):
    if x == z:
        print(i+1, i+3)
        sys.exit()
print(-1, -1)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    pp = ""
    p = ""

    left = -1
    right = -1

    for i, char in enumerate(s, 1):
        if pp == char:
            left = i - 2
            right = i
            break
        if p == char:
            left = i - 1
            right = i
            break
        pp = p
        p = char

    print(left, right)


if __name__ == '__main__':
    main()

Solution (Python):
s = list(input())
ans = [-1,-1]
for i in range(len(s) -1):
    if s[i] == s[i + 1]:
        ans = [i+1,i+2]
for i in range(len(s) -2):
    if s[i] == s[i+2]:
        ans = [i+1,i+3]
print(" ".join(map(str,ans)))

Solution (Python):
import sys
s = input()
l = len(s)
if l == 2:
    if s[0] == s[1]:
        print(1, 2)
        sys.exit()
    else:
        print('-1 -1')
        sys.exit()
for i in range(l - 2):
    s1 = s[i]
    s2 = s[i + 1]
    s3 = s[i + 2]
    if s1 == s2 or s1 == s3 or s2 == s3:
        print(i + 1, i + 3)
        sys.exit()
print('-1 -1')

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache





MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


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


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum


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


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





S = S()
N = len(S)
for x in AZ:
  prev = -INF
  for i in range(N):
    if S[i] == x:
      if i-prev <= 2:
        print(prev+1,i+1)
        exit()
      prev = i
print(-1,-1)

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


if __name__ == '__main__':
    resolve()

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    s = input().strip()
    for i in range(1, len(s)):
        if s[i-1] == s[i]:
            return f'{i} {i+1}'
        if i > 1 and s[i-2] == s[i]:
            return f'{i-1} {i+1}'
    return '-1 -1'


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

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

Solution (Python):
txt = input()
L = len(txt)

def solve():
  for i in range(L-1):
    if txt[i] == txt[i+1]:
      return ' '.join([str(x) for x in [i+1,i+2]])
  for i in range(L-2):
    if txt[i] == txt[i+2]:
      return ' '.join([str(x) for x in [i+1,i+3]])
  return '-1 -1'

ans = solve()
print(ans)

Solution (Python):
def main():
    s = input()
    if len(s) == 2:
        if 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 + 2)
            break
        elif s[i] == s[i + 2]:
            print(i + 1, i + 3)
            break
    else:
        print(-1, -1)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	s_list = list(S())
	for t in range(2,min(len(s_list)+1,4)):
		for i in range(len(s_list)-t+1):
			c = Counter(s_list[i:i+t])
			if c.most_common()[0][1] / t  > 0.5:
				print(i+1, i+t)
				break
		else:
			continue
		break
	else:
		print(-1, -1)

if __name__ == '__main__':
    main()

Solution (Python):
S = list(input())
N = len(S)
flag = 0
for i in range(1,N):
    if i==1:
        if S[i]==S[i-1]:
            flag = 1
            print(i-1+1,i+1)
            break
    else:
        if S[i]==S[i-1]:
            flag = 1
            print(i-1+1,i+1)
            break
        if S[i]==S[i-2]:
            flag = 1
            print(i-2+1,i+1)
            break

if flag==0:
    print(-1,-1)

Solution (Python):
'''     
        
        
        

import sys
import math


def get_ints(): return map(int, input().strip().split())
def get_list(): return list(get_ints())

def printspx(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end=" \ ")

MODPRIME = int(1e9+7); BABYMODPR = 998244353;

ONLINE_JUDGE = 1
if not ONLINE_JUDGE:
    sys.stdin  = open("input.txt","r")
    sys.stdout = open("output.txt","w")
    sys.stderr = open("output.txt","w")


s = input()
a = b = -1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        a, b = i+1, i+2
        break
    elif i != len(s) - 2 and s[i] == s[i+2]:
        a, b = i+1, i+3
        break
print(a, b)




'''
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
THE LOGIC AND APPROACH IS BY ME @luctivud ( UDIT GUPTA )
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
DO NOT PLAGIARISE.
TESTCASES:
>>> COMMENT THE STDIN!! CHANGE ONLINE JUDGE !!
'''

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7






def rand_letter(size):
    ascii_original='ABCD'
    digits_original='01'

    digits='0123456789'
    ascii_lowercase='abcdefghijklmnopqrstuvwxyz'
    ascii_uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'

    
    psuedo = ascii_original

    return ''.join([random.choice(psuedo) for i in range(size)])

S = input()
N = len(S)

ans = [-1, -1]
for i in range(1, N):
    if S[i] == S[i - 1]:
        ans = [i, i + 1]
        break
    if i > 1 and S[i] == S[i - 2]:
        ans = [i - 1, i + 1]
        break
print(*ans)

Solution (Python):
import os, sys, re, math, queue

S = input()

al = 'abcdefghijklmnopqrstuvwxyz'

def doit():
	for a in al:
		m = re.search(a+'{2,}', S)
		if m:
			return str(m.start()+1) + ' ' + str(m.end())
		m = re.search(a+'[^'+a+']'+a, S)
		if m:
			return str(m.start()+1) + ' ' + str(m.end())
	
	return '-1 -1'

print(doit())

Solution (Python):
s=input()
n=len(s)
n2a = lambda c: chr(c+64).lower()
d={}
d_={}
for i in range(1,27):
  d[n2a(i)]=[0]
  d_[n2a(i)]=0
for i in range(n):
  d_[s[i]]+=1
  for j in range(1,27):
    d[n2a(j)].append(2*d_[n2a(j)]-(i+1))
def func(l):
  mina=[0,0]
  for k in range(2,n+1):
    if mina[0]<l[k]:
      return [mina[1]+1,k]
    elif mina[0]>l[k-2]:
      mina=[l[k-2],k-2]
  return [-1,-1]
for i in range(1,27):
  tmp=func(d[n2a(i)])
  if tmp[0]>0:
    print(tmp[0],tmp[1])
    exit()
print(-1,-1)

Solution (Python):
s = list(input())
s.append("1")
s.append("2")
N = len(s)
for i in range(N-2):
    now = s[i]
    if s[i+1] == now:
        print(i+1,i+2)
        break
    if s[i+2] == now:
        print(i+1,i+3)
        break
else:
    print(-1,-1)

Solution (Python):
import re


def get_char_list():
    return [chr(ord('a') + i) for i in range(26)]


def main():
    S = input()
    N = len(S)
    char_list = get_char_list()
    for c in char_list:
        for pattern in ['{}.{}'.format(c, c), '{}{}'.format(c, c)]:
            m = re.search(pattern, S)
            if m is not None:
                sp = m.span()
                print('{} {}'.format(sp[0] + 1, sp[1]))
                return
    print('{} {}'.format(-1,-1))


if __name__ == '__main__':
    main()

Solution (Python):
S = input()
N = len(S)
S = "!" + S + "!"
if N == 2:
    if S[1] == S[2]:
        print("1 2")
    else:
        print("-1 -1")
    exit()
for i in range(1, N+1, 1):
    PrevAl = S[i-1]
    NowAl = S[i]
    NextAl = S[i+1]
    if PrevAl == NowAl or NowAl == NextAl or PrevAl == NextAl:
        AnsL = i-1
        AnsR = i+1
        if AnsL == 0:
            AnsL = 1
        print(AnsL, AnsR)
        exit()
print("-1 -1")

Solution (Python):
s = input()
l = len(s)
s += "!"*10
for i in range(l):
    for j in range(i+1,i+3):
        if s[i] == s[j]:
            print(i+1,j+1)
            exit()
print(-1,-1)

Solution (Python):
s = input()
l = len(s)
s += "!"*10
for i in range(l):
    tar = s[i]
    for j in range(i+1,i+3):
        if s[i] == s[j]:
            print(i+1,j+1)
            exit()
print(-1,-1)

Solution (Python):
import re

s = input()

set_s = set(s)
flag = 0

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


for x in set_s:
    regex1 = re.compile(x+x +r"\w")
    regex2 = re.compile(x +r"\w" + x)
    mo1 = regex1.search(s)
    mo2 = regex2.search(s)
    if mo1:
        
        print(mo1.start()+1,mo1.end())
        flag = 1
        break
    elif mo2:
        
        print(mo2.start()+1,mo2.end())
        flag = 1
        break

if not flag:
    print(-1,-1)

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

if N == 2 and S[0] == S[1]:
  print(1, 2)
  quit()

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

print(-1, -1)

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

def solve():
  for i in range(1,n):
    if s[i-1] == s[i]:
      print(i,i+1)
      return
  for i in range(2,n):
    if s[i-2] == s[i-1] or s[i-1] == s[i] or s[i-2] == s[i]:
      print(i-1,i+1)
      return
  print(-1,-1)

if n==2:
  if s[0]==s[1]:
    print(1,2)
  else:
    print(-1,-1)    
else:
  solve()

Solution (Python):
import sys
s = input()
z = True
for i in range(len(s)):
    if not z:
        break
    try:
        if s[i] == s[i + 1]:
            print(i + 1, i + 2)
            z = False
            sys.exit()
        if s[i] == s[i + 2]:
            print(i + 1, i + 3)
            z = False
            sys.exit()
    except:
        pass
if z:
    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()
for i in range(N-2):
    if S[i] == S[i + 2]:
        print(i + 1 ,i + 3)
        exit()
        
print(-1,-1)

Solution (Python):
from collections import Counter

def unbalanced(s):
    c = Counter(s)
    if max(c.values()) > len(s)/2:
        return True
    else:
        return False

s = input()
l = len(s)

balanced = False

for i in range(l-1):
    if unbalanced(s[i:i+2]):
        print(i+1,i+2)
        exit()

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

print(-1,-1)

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

if len(s) == 2:
    if s[0] == s[1]:
        print(1,2)
    else:
        print(-1,-1)
else:
    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=list(input())

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

Solution (Python):
s = input()
left = -1;right = -1
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        left = i+1;right=i+2
        break
    if not i == len(s)-2:
        if s[i]==s[i+2]:
            left = i+1;right=i+3
            break
print(left, right)

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()
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()
dict={}
check=False
for i, ele in enumerate(s):
    try:
      if i-dict[ele]<=2:
        print("{} {}".format(dict[ele]+1,i+1)) 
        check=True
        break
    except:pass
    dict[ele]=i
if (check==False):
  print("-1 -1")

Solution (Python):
import sys
import collections
input = sys.stdin.readline

def main():
    S = input().strip()

    a = [[] for _ in range(26)]

    for i, s in enumerate(S):
        a[ord(s) - ord('a')].append(i)

    ans = []
    f = False
    for i in range(26):
        for j in range(len(a[i]) - 1):
            if (a[i][j + 1] - a[i][j] + 1) < 4:
                ans.append(a[i][j])
                ans.append(a[i][j + 1])
                f = True
                break
        if f:
            break

    if f:
        print(ans[0] + 1, ans[1] + 1)
    else:
        print(-1, -1)







    

if __name__ == '__main__':
    main()

Solution (Python):

import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    a=ord('a')
    S=list(map(lambda s:ord(s)-a,input()))
    N=len(S)
    for k in range(26):
        SUM=[0]*(N+1)
        for i in range(N):
            SUM[i+1]=SUM[i]+(S[i]==k)
        T=[2*x-i for i,x in enumerate(SUM)]
        m=T[0]
        mi=0
        for i in range(2,N+1):
            if T[i]>m:
                print(mi+1,i)
                exit()
            if m>T[i-1]:
                m=T[i-1]
                mi=i-1
    print(-1,-1)
        
        

if __name__ == '__main__':
    main()

Solution (Python):
s=input()







if len(s)==2:
    if 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+1+1)
        exit()
    elif s[i]==s[i+2]:
        print(i+1,i+2+1)
        exit()

print(-1,-1)

Solution (Python):
s=input()
N=len(s)
res = (-1, -1)

for i in range(N-1):
    tgt = s[i:i+2]
    if tgt[0]==tgt[1]:
        res = (i+1,i+2)


for i in range(N-2):
    tgt = s[i:i+3]
    if tgt[0]==tgt[2]:
        res = (i+1,i+3)
print(*res)

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

Solution (Python):
s = input()
for i in range(len(s)):
    if s[i] == s[i-1] and i-1>=0:
        print(i-1+1, i+1)
        exit()
    elif (i+1)<=len(s)-1 and s[i+1] == s[i]:
        print(i+1, i+1+1)
        exit()
    elif (i-1)>=0 and (i+1)<= len(s)-1 and s[i-1]==s[i+1]:
        print(i-1+1,i+1+1)
        exit()
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])
        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()
flag = False
for i in range(1,len(s)):
    if s[i] == s[i-1]:
        flag = True
        j = i-1
        break
    if i > 2 and s[i] == s[i - 2]:
        flag = True
        j = i-2
        break
if flag:
    print(j+1, i+1)
else:
    print(-1, -1)

Solution (Python):


import sys






















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())


    def calc_consective(s):
        n = len(s)
        for i in range(n-1):
            if s[i] == s[i+1]:
                return [i+1, i+2]    
        return None
    
    def calc_skip(s):
        n = len(s)
        for i in range(n-2):
            if s[i] == s[i+2]:
                return [i+1, i+3]    
        return None


    def calc_ans(s):
        ans = calc_consective(s)
        if ans:
            return ans
        ans = calc_skip(s)
        if ans:
            return ans
        return (-1, -1)

    
    s = input()
    res = calc_ans(s)
    print("{} {}".format(res[0], res[1]))


if __name__ == "__main__":
    main()

Solution (Python):
from sys import exit

s = input()

n = len(s)
for i in range(n):
  if i+1 < n and 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 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 = list(input())
for i in range(len(s) - 1):
    v = s[i]
    if s[i + 1] == v:
        print(i + 1, i + 2)
        exit()
    if i + 2 < len(s) and s[i + 2] == v:
        print(i + 1, i + 3)
        exit()
print(-1, -1)

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

Solution (Python):
s = input()

old2 = s[0]
old1 = s[1]

if old2 == old1:
    print(1,2)
    exit()

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

print(-1,-1)

Solution (Python):
s=input()
n=len(s)
alp=[[] for _ in range(26)]

for i in range(n):
    alp[ord(s[i])-97].append(i)

flag=0
ans=[]
for i in range(26):
    for j in range(1,len(alp[i])):
        if (alp[i][j]-alp[i][j-1])<=2:
            flag=1
            ans=[alp[i][j-1],alp[i][j]]
            break
    if flag==1:
        break
if flag==0:
    print("-1 -1")
else:
    print(ans[0]+1,ans[1]+1)

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

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

for i in range(n-2):
  t=s[i:i+3]
  if t[0]==t[1] or t[1]==t[2] or t[0]==t[2]:
    print(i+1, i+3)
    exit()
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
 
    if i < len(s) - 2 and s[i] == s[i + 2]:
        print(i + 1, i + 3)
        break
else:
    print(-1, -1)

Solution (Python):
s = input()
for i in range(len(s)-1):
    if s[i:i+3].count(s[i]) >=2:
        print("{} {}".format(i+1, min(len(s), i+3)))
        break
else:
    print("-1 -1")

Solution (Python):
s = input()
d = dict()
ans = '-1 -1'
for i in range(len(s)):
    if d.get(s[i]) is None:
        d[s[i]] = i
    else:
        if i - d[s[i]] <= 2:
            ans = '{a} {b}'.format(b=i + 1, a=d[s[i]] + 1)
            break
        else:
            d[s[i]] = i
print(ans)

Solution (Python):
s = list(map(lambda x: ord(x) - ord('a'), list(input())))

ans = ["-1", "-1"]

if len(s) == 2:
    if len(set(s)) == 1:
        print(1, 2)
        exit()
    else:
        print(" ".join(ans))
        exit()

for i in range(len(s) - 2):
    
    if len(set(s[i:i+3])) <= 2:
        
        ans = [str(i+1), str(i+3)]
        break

print(" ".join(ans))

Solution (Python):
a=input()
t=-1
flag="False"
for i in range(len(a)-1):
  if a[i]==a[i+1]:
    flag="True1"
    t=i
    break
  if i!=len(a)-2:
    if a[i]==a[i+2]:
      flag="True2"
      t=i
      break
if flag=="False":
  print("{} {}".format(-1,-1))
elif flag=="True1":
  print("{} {}".format(t+1,t+2))
else:
  print("{} {}".format(t+1,t+3))

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

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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()
L = len(S)

def p():
    for j in range(L - 2):
        if S[j] == S[j + 1]:
            print(j + 1, j + 2)
            return
        if S[j] == S[j + 2]:
            print(j + 1, j + 3)
            return

    if S[-2] == S[-1]:
        print(L - 1, L)
    else:
        print(-1, -1)

p()

Solution (Python):
S = input()

a1, a2 = -1, -1
for i in range(26):
    t = chr(ord('a') + i)

    s0 = ''
    s1 = ''
    for j, s2 in enumerate(S):
        if s2 == t:
            if s2 == s1:
                a1, a2 = j, j + 1
                break
            elif s2 == s0:
                a1, a2 = j - 1, j + 1
                break
        s0, s1 = s1, s2
    else:
        continue
    break

print(a1, a2)

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()

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 = list(input())


for i in range(len(s)-1):
	if s[i] == s[i+1]:
		print('{} {}'.format(i+1, i+2))
		break
	if i + 2 != len(s):
		if s[i] == s[i+2]:
			print('{} {}'.format(i+1, i+3))
			break
else:
	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=list(input())

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    s = input().rstrip()
    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)

if __name__ == '__main__':
    main()

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()

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

print(-1, -1)

Solution (Python):
s = str(input())


if len(s) > 2:
    for i in range(len(s)-2):
        if s[i] == s[i+1] or s[i] == s[i+2]:
            res1 = str(i+1)
            res2 = str(i+3)
            print(res1 + " " + res2)
            quit()
        else:
            continue
else:
    if s[0] == s[1]:
        print("1 2")
        quit()

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()

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()
slist = list(s)

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

else:
    for i in range(1,len(slist)-1):
        if len(set(slist[i-1:i+2])) !=3:
            print(i,i+2)
            exit()
            
    print("-1 -1")

Solution (Python):


data=input()+"_";x=y=-2

for i in range(len(data)-2):
    if data[i]==data[i+1]:x=i;y=i+1
    if data[i]==data[i+2]:x=i;y=i+2
      
print(x+1,y+1)

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