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):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    S = input()

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


if __name__ == '__main__':
    main()

Solution (Python):
import re
oRe = re.compile("(.)\\1|(.).\\2")
sS = input().rstrip()
oM = oRe.search(sS)
if oM :
    print(oM.start()+1,oM.end() )
else:
    print("-1 -1")

Solution (Python):
import re
oRe = re.compile("(.).\\1|(.)\\2")
sS = input().rstrip()
oM = oRe.search(sS)
if oM :
    print(oM.start()+1,oM.end() )
else:
    print("-1 -1")

Solution (Python):
sS = input().rstrip()
iL = len(sS)
for i in range(iL-1):
    if sS[i] == sS[i+1] :
        print(i+1,i+2)
        exit()
for i in range(iL-2):
    if sS[i] == sS[i+2] :
        print(i+1,i+3)
        exit()
print("-1 -1")

Solution (Python):
sS = input().rstrip()
iL = len(sS)
if iL == 2:
    if sS[0] == sS[1]:
        print ("1 2")
    else:
        print("-1 -1")
    exit()
for i in range(iL-2):
    if sS[i] == sS[i+1] or sS[i] == sS[i+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)
    exit(0)
  elif i+2 < len(S) and S[i] == S[i+2]:
    print(i+1, i+3)
    exit(0)
    
print(-1, -1)

Solution (Python):
S = list(input())
i = 0
while i <= len(S)-3:
    if S[i] == S[i+1]:
        print(i+1, i+2)
        break
    elif S[i] == S[i+2]:
        print(i+1, i+3)
        break
    i += 1
else:
    if S[i] == S[i+1]:
        print(i+1, i+2)
    else:
        print(-1, -1)

Solution (Python):
def search_unblanced_position(char_str):
    for i in range(len(char_str)-1):
        if s[i] == s[i+1]:
            return i+1,i+2
 
    for i in range(len(char_str)-2):
        if s[i] == s[i+2]:
            return i+1,i+3
 
    return -1,-1
 
s = input()
 
a,b = search_unblanced_position(s)
 
print (a,b)

Solution (Python):
s = '0' + input() + '1'


def f():
    for i, v in enumerate(s[:-2]):
        if s[i] == s[i + 1]:
            return (i, i + 1)
        elif s[i] == s[i + 2]:
            return (i, i + 2)
    return (-1, -1)


(a, b) = f()
print('{0} {1}'.format(a, b))

Solution (Python):



s = input()

if len(s) == 2:
    if s[0] == s[1]:
        print('1 2')
    else:
        print('-1 -1')
else:
    f = False
    for i in range(len(s) - 2):
        if len(set(s[i:i + 3])) < 3:
            f = True
            break
    if f:
        print('{0} {1}'.format(i + 1, i + 3))
    else:
        print('-1 -1')

Solution (Python):
def search_unblanced_position(char_str):
    for i in range(len(char_str)-1):
        if s[i] == s[i+1]:
            return i+1,i+2

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

    return -1,-1

s = input()

a,b = search_unblanced_position(s)

print (a,b)

Solution (Python):
def is_unbalance(lst):
    res = False
    for x in lst:
        if lst.count(x) >= 2:
            res = True
            break
    return res

s = input()
i = 0
a, b = -1, -1
for j in 2, 1:
    while i + j < len(s):
        if is_unbalance(s[i:i + j + 1]):
            a, b = i + 1, i + j + 1
            break
        i += 1
    if (a, b) != (-1, -1):
        break
print(a, b)

Solution (Python):
s = input()

if len(s) == 2:
    if len(set(list(s))) == 1:
        print("1 2")
        exit()

for i in range(len(s)-2):
    if len(set(list(s[i:i+3]))) != 3:
        print(str(i+1)+ " "+ str(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)
        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()

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

print("%d %d" % solve(s))

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

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

Solution (Python):
f=s=input()
for i in range(len(s)-2):
	for j in (i+1,i+2):
		if s[i]==s[j]:
			print(i+1,j+1)
			exit()
if s[-1]!=s[-2]:f=''
l=len(f)
print(l-1,l if l else-1)

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

Solution (Python):
s = input()

ans = 0
front = -1
back = -1

for i in range(len(s) - 1):
    j = i + 1
    if s[i] == s[j]:
        ans = 1
        front = i + 1
        back = j + 1

for i in range(len(s) - 2):
    j = i + 2
    if s[i] == s[j]:
        ans = 1
        front = i + 1
        back = j + 1

if ans == 0:
    print("-1 -1")
else:
    print(front, back)

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):
from collections import defaultdict

s = input()

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

else:
    exist = False
    for start in range(len(s)-2):
        dic = defaultdict(int)
        for item in range(start, start+3):
            dic[s[item]] += 1
            
        if any([i > 1 for i in list(dic.values())]):
            print(start+1, start+3)
            exist = True
            break
        
    if not exist:
        print(-1, -1)

Solution (Python):
S = input()
ids = [[] for i in range(26)]

for i,c in enumerate(S):
    j = ord(c) - ord('a')
    ids[j].append(i)

for arr in ids:
    if len(arr) < 2: continue
    for i1,i2 in zip(arr,arr[1:]):
        if i2 - i1 <= 2:
            print(i1+1, i2+1)
            exit()
print(-1,-1)

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

S = input()
L = len(S)

a2 = S[0]
a3 = S[1]

if a2 == a3:
	print(1,2)
	sys.exit()

for i in range(0,L-2):
	a1 = a2
	a2 = a3
	a3 = S[i+2]
	if a1 == a2 or a1 == a3 or a2 == a3:
		print(i+1,i+3)
		sys.exit()

print(-1,-1)

Solution (Python):


import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


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


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    i = -1
    j = -1
    for k in range(len(S)-1):
        if S[k] == S[k+1]:
            i = k+1
            j = k+2
            break
        if k+2 < len(S) and S[k] == S[k+2]:
            i = k+1
            j = k+3
            break
    return '%d %d' % (i, j)


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

    print(slv(S))


if __name__ == '__main__':
    main()

Solution (Python):


import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


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


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    i = -1
    j = -1
    for k in range(len(S)-1):
        if S[k] == S[k+1]:
            i = k+1
            j = k+2
            break
        if k+2 < len(S) and S[k] == S[k+2]:
            i = k+1
            j = k+3
    return '%d %d' % (i, j)


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

    print(slv(S))


if __name__ == '__main__':
    main()

Solution (Python):
s = input()

def f():
    p0, p1 = ' ', s[0]
    for i, p2 in enumerate(s[1:] + '_'):
        if p1 == p2:
            print(i + 1, i + 2)
            return
        if p0 == p2:
            print(i, i + 2)
            return
        p0, p1 = p1, p2
    print(-1, -1)
    return
f()

Solution (Python):

def main():
    s = input()

    if len(s) ==2:
        if len(set(list(s))) != 2:
            print("1 2")
            exit()



    for i in range(len(s)-2):
        if len(set(list(s[i:i+3]))) != 3:
            print(str(i+1) + " " + str(i+3))
            exit()

    print("-1 -1")


if __name__ == "__main__":
        main()

Solution (Python):
s = input()

def f():
    m = dict([(x, 0) for x in 'abcdefghijklmnopqrstuvwxyz'])
    m[' '] = 1
    m[s[0]] = 1
    p0, p1 = ' ', s[0]
    for i, x in enumerate(s[1:]):
        m[x] += 1
        if m[x] > 1:
            print(max(1, i),i + 2)
            return
        m[p0] -= 1
        p0, p1 = p1, x
    print(-1, -1)
    return
f()

Solution (Python):
S = input()

ans = [-1, -1]
for i in range(len(S) - 1):
    if S[i] == S[i + 1]:
        ans = [i + 1, i + 2]
        break

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

print(ans[0], ans[1])

Solution (Python):
import sys
s = input()

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

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

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

def judge(S:str) -> tuple:
    
    left = 0
    right = 2
    
    
    for i in range(N-1):
        if S[left] == S[right-1]:
            return (left+1, right)

            
        left += 1
        right += 1
        
    
    left = 0
    right = 3
    for i in range(N-2):
        if S[left] == S[right-1]:
            return (left+1,right)
        
        left += 1
        right += 1
        
        
    return (-1,-1)


print(*judge(S))

Solution (Python):

"""
Created on Sat Aug  4 18:47:44 2018

@author: maezawa
"""

s = input()

a0 = ''
i0 = -1
a1 = ''
i1 = -1
flag = 0
for j, c in enumerate(s):
    if a1 == c:
        print('{} {}'.format(i1+1, j+1))
        flag = 1
        break
    elif a0 == c:
        print('{} {}'.format(i0+1, j+1))
        flag = 1
        break
    else:
        a0 = a1
        a1 = c
        i0 = i1
        i1 = j
if flag == 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)
    break
  elif i<n-2 and s[i]==s[i+2]:
    print(i+1,i+3)
    break
else:
  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)
    break
  elif i<n-2 and s[i]==s[i+2]:
    print(i+1,i+3)
    break
else:
  print(-1,-1)

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

Solution (Python):
s = input()
for i in range(len(s)-1):
    s1 = s[i]
    s2 = s[i+1]
    s3 = s[i+2] if i != len(s) - 2 else "?"
    if s1 == s2:
        print(i+1, i+2)
        exit()
    elif s2 == s3:
        print(i+2, i+3)
        exit()
    elif s1 == s3:
        print(i+1, i+3)
        exit()
    else:
        continue
print('-1 -1')

Solution (Python):
w=list(input())
l=len(w)
w.append(0) 
for i in range(l-1):
    if w[i]==w[i+2]:
        print("{} {}".format(i+1,i+3))
        break
    elif w[i]==w[i+1]:
        print("{} {}".format(i+1,i+2))
        break
else:
    print("{} {}".format(-1,-1))

Solution (Python):
s = input()

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

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

    print(-1, -1)

solve(s)

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

L = len(S)
chk = False
ans1,ans2 = 0,0



for i in range(1,L):
    if S[i]==S[i-1]:
        chk = True
        ans1,ans2 = i,i+1
        break



if not chk:
    for i in range(2,L):
        if S[i]==S[i-2]:
            chk = True
            ans1,ans2 = i-1,i+1
            break

if chk:
    print(ans1,ans2)
else:
    print(-1,-1)

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

Solution (Python):

def inpl(): return list(map(int, input().split()))

S = input()
L_ = [[] for _ in range(26)]

for i, s in enumerate(S):
    L_[ord(s)-97].append(i+1)

for L in L_:
    for i in range(len(L)-1):
        if L[i+1] - L[i] <= 2:
            print(*L[i:i+2])
            break
    else:
        continue
    break
else:
    print(-1, -1)

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

    left, right = -1, -1
    if len(s) == 2 and len(set(s)) == 1:
        left, right = 1, 2
    
    elif len(s) > 2:
        for i in range(len(s)-2):
            s_set = set(s[i:i+3])
            if len(s_set) < 3:
                left, right = i + 1, i + 3
                break

    print("{} {}".format(left, right))


if __name__ == '__main__':
    main()

Solution (Python):
s = list(input())
l, r = -1, -1

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

Solution (Python):
if __name__ == '__main__':
    s = input()
    for i in range(len(s) - 1):
        if s[i] == s[i + 1]:
            print("{} {}".format(i + 1, i + 2))
            exit(0)
    for i in range(len(s) - 2):
        if s[i] == s[i + 2]:
            print("{} {}".format(i + 1, i + 3))
            exit(0)
    print("-1 -1")

Solution (Python):
a=list(input().strip())
for i in range(len(a)):
  if i >=1:
    if a[i]==a[i-1]:
      print(i,i+1)
      break
  if i>=2:
    if a[i]==a[i-2]:
      print(i-1,i+1)
      break
else:
  print(-1,-1)

Solution (Python):
import numpy as np

s = [ord(a)-ord('a') for a in input()]
n = len(s)

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

cnt = np.array([0] * 26)
cum = [cnt.copy()]

for i, a in enumerate(s):
    cnt[a] += 1
    cum.append(cnt.copy())

def is_check(cum, n):
    i = 3
    d = 1
    for j in range(n-i+1):
        cum_ = cum[j+i] - cum[j]
        if cum_[cum_>1]:
            return j+1, j+i
    return -1, -1

print(' '.join(map(str, is_check(cum, len(s)))))

Solution (Python):
s = input()
flag = True
for i in range(1,len(s)):
	if s[i]==s[i-1]:
		flag = False
		print(i,i+1)
		break
if flag:
	for i in range(2,len(s)):
		if s[i]==s[i-2]:
			flag = False
			print(i-1,i+1)
			break
if flag: print(-1,-1)

Solution (Python):
def d_unbalanced(S):
    S_length = len(S)
    s = S + '
    for i in range(S_length):
        
        
        if s[i] == s[i + 1]:  
            return '{} {}'.format(i + 1, i + 2)
        elif s[i] == s[i + 2]:  
            return '{} {}'.format(i + 1, i + 3)
    
    return '-1 -1'

S = input().strip()
print(d_unbalanced(S))

Solution (Python):
def judge(s):
	if len(s) == 2:
		if s[0] == s[1]: return [1, 2]
		else: return [-1, -1]
	else:
		for i in range(0, len(s)-2):
			if s[i] == s[i+1] or s[i] == s[i+2] or s[i+1] == s[i+2]:
				return [i+1, i+3]
		return [-1, -1]

s = raw_input()
ans = judge(s)
print str(ans[0]) + " " + str(ans[1])

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

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

Solution (Python):
import sys

s_list = list(input())

a = 1

for _ in range(len(s_list) - 1):
    if s_list[a - 1] == s_list[a]:
        print(a, (a + 1))
        sys.exit()
    else:
        a += 1
        
a = 1
        
for _ in range(len(s_list) - 2):
    if s_list[a - 1] == s_list[a + 1]:
        print(a, (a + 2))
        sys.exit()
    else:
        a += 1
        
print('-1 -1')

Solution (Python):
s=list(input())
a,b=-1,-1
flag=False
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        a,b=i+1,i+2
        flag=True
        break
if not flag:
    for i in range(len(s)-2):
        if s[i]==s[i+2]:
            a,b=i+1,i+3
            break
print(a,b)

Solution (Python):
from collections import Counter
s=raw_input()
C=Counter(s)

for k in C.keys():
	pre=float("-inf")
	for idx,i in enumerate(s):
		if i==k:
			if idx-pre<=2:
				print pre+1,idx+1
				quit()
			pre=idx
else:
	print -1,-1

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

Solution (Python):
S = input()

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

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

Solution (Python):
s = input()
ans = ""
for i in range(len(s)-1):
	if s[i] == s[i+1]:
		ans = str(i+1) + " " + str(i+2)

if ans != "":
	print(ans)
	exit(0)

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

if ans == "":
	print("-1 -1")
else:
	print(ans)

Solution (Python):
s=input()
if len(s)==2:
  if s[0]==s[1]:
    print("1 2")
  else:
    print("-1 -1")
else:
  ans=True
  for i in range(2,len(s)):
    if s[i]==s[i-1] or s[i]==s[i-2] or s[i-1]==s[i-2]:
      print(i-1,i+1)
      ans=False
      break
  if ans:
    print("-1 -1")

Solution (Python):

"""
https://beta.atcoder.jp/contests/abc043/tasks/arc059_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s):
    ans = [-1, -1]
    if len(s) == 2:
        if s[0] == s[1]:
            return [1, 2]
        else:
            return ans

    for i, s0, s1, s2 in zip(range(1, 10**5+1), s, s[1:], s[2:]):
        if s0 == s1 or s0 == s2 or s1 == s2:
            ans = [i, i+2]
            break
    return ans


def main(args):
    s = input().strip()
    ans = solve(s)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):

"""
https://beta.atcoder.jp/contests/abc043/tasks/arc059_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s):
    ans = [-1, -1]
    if len(s) == 2:
        if s[0] == s[1]:
            return [1, 2]
        else:
            return ans

    for i, s0, s1, s2 in zip(range(1, 10**5+1), s, s[1:], s[2:]):
        if s0 == s1 or s0 == s2:
            ans = [i, i+2]
            break
    return ans


def main(args):
    s = input().strip()
    ans = solve(s)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
def solve(s):
    d = {}
    for i, c in enumerate(s):
        d.setdefault(c, []).append(i)
    for k in d:
        d[k].sort()
        for i in range(len(d[k]) - 1):
            if d[k][i + 1] - d[k][i] <= 2:
                return (d[k][i] + 1, d[k][i + 1] + 1)
    return (-1, -1)


s = input()
print(*solve(s))

Solution (Python):
def d_Unbalanced(S):
    for i in range(0, len(S) - 2):
        cond1 = S[i] == S[i + 1]  
        cond2 = S[i] == S[i + 2]  
        
        
        if cond1:
            return '{} {}'.format(i + 1, i + 2)
        elif cond2:
            return '{} {}'.format(i + 1, i + 3)
        else:
            continue
    
    if S[-2] == S[-1]:
        return '{} {}'.format(len(S) - 1, len(S))
    
    return '-1 -1'

S = input().strip()
print(d_Unbalanced(S))

Solution (Python):
s = input()

if len(s) == 2:
    if s[0] == s[1]:
        print(1, 2)
    else:
        print(-1, -1)
else:
    for i in range(len(s)-2):
        tmp = s[i:i+3]
        if tmp.count(tmp[0]) >= 2:
            print(i+1, i+3)
            quit()
    
    print(-1, -1)

Solution (Python):



"""043-d"""


import sys


def main():
    """Main function."""
    s = input()
    len_ = len(s)

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

    if len_ >= 2 and s[-2] == s[-1]:
        print(len_ - 1, len_)
        sys.exit(0)

    print(-1, -1)


if __name__ == '__main__':
    sys.exit(main())

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

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

Solution (Python):
s = input()

if len(s) == 2 and s[0] == s[1]:
  print("1 2")
  import sys
  sys.exit()

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]:
    print("{} {}".format(i+1, i+3))
    import sys
    sys.exit()

print("-1 -1")

Solution (Python):
s = input()
tc = [ chr(i)*2 for i in range(ord('a'), ord('z')+1) ]  + [ chr(i)+chr(j)+chr(i) for i in range(ord('a'), ord('z')+1) for j in range(ord('a'), ord('z')+1)]
x=y=-1
t = "0"
for i in set(tc):
  if i in s:
    t = i
    break
for i in range(len(s)):
    if s[i:i+len(t)] == t:
      x = i+1
      y = i+len(t)
      break
print(x, y)

Solution (Python):
s = input()
tc = [ chr(i)*2 for i in range(ord('a'), ord('z')+1) ]  + [ chr(i)+chr(j)+chr(i) for i in range(ord('a'), ord('z')+1) for j in range(ord('a'), ord('z')+1)]
x=y=-1
t = "0"
for i in set(tc):
  if i in s:
    t = i
for i in range(len(s)):
    if s[i:i+len(t)] == t:
      x = i+1
      y = i+len(t)
print(x, y)

Solution (Python):
s = input()
tc = [ chr(i)*2 for i in range(ord('a'), ord('z')+1) ]  + [ chr(i)+chr(j)+chr(i) for i in range(ord('a'), ord('z')+1) for j in range(ord('a'), ord('z')+1)]
x=y=-1
t = "0"
for i in tc:
  if i in s:
    t = i
for i in range(len(s)-len(t)+1):
    if s[i:i+len(t)] == t:
      x = i+1
      y = i+len(t)
print(x, y)

Solution (Python):
import sys
s=str(input())
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    print(str(i+1)+" " +str(i+2))
    sys.exit()
for i in range(len(s)-2):
  if s[i]==s[i+2]:
    print(str(i+1)+" " +str(i+3))
    sys.exit()
print(str(-1)+" " +str(-1))

Solution (Python):
from collections import defaultdict


def main():
    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__':
    main()

Solution (Python):
s = input()

a = -1
b = -1

for i in range(len(s)-2):
    if s[i]==s[i+1]:
        a = i+1
        b = i+2
        break
    elif s[i]==s[i+2]:
        a = i+1
        b = i+3
        break
if s[-2]==s[-1]:
    a = len(s)-1
    b = len(s)
        
print(str(a)+" "+str(b))

Solution (Python):
s = raw_input()

def find_unbalance():
    for i in range(ord('a'),ord('z')+1):
        for j in range(len(s)-1):
            if s[j] == chr(i) and s[j+1] == chr(i):
                return (j+1, j+2)
            if j < len(s)-2 and s[j] == chr(i) and s[j+2] == chr(i):
                return (j+1, j+3)
    return (-1, -1)
ans = find_unbalance()
print ans[0], ans[1]

Solution (Python):
s = raw_input()
N = len(s)
def run():
    for i in range(N):
        if (i+1 < N) and (s[i] == s[i+1]):
            return (i+1, i+2)
        elif (i+2 < N) and (s[i] == s[i+2]):
            return (i+1, i+3)
    return (-1, -1)
print "%d %d" % run()

Solution (Python):
s = input()

for i in range(len(s)-2):
    c1, c2, c3 = s[i], s[i + 1], s[i + 2]
    if c1 == c2 or c1 == c3 or c2 == c3:
        print(i+1, i+3)
        break
else:
    if len(s) == 2 and s[0] == s[1]:
        print(1, 2)
    else:
        print(-1, -1)

Solution (Python):
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

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

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

        return

    for i in range(n - 2):
        if s[i] == s[i + 1]:
            print(i + 1, i + 2)
            return
        elif s[i + 1] == s[i + 2]:
            print(i + 2, i + 3)
            return
        elif s[i] == s[i + 2]:
            print(i + 1, i + 3)
            return
        else:
            pass

    print(-1, -1)


if __name__ == '__main__':
    solve()

Solution (Python):

INF=10**10

def main():
    
    str=input()
    n=len(str)
    if n==2:
        if str[0]==str[1]:
            print("1 2")
            return 0
        else:
            print("-1 -1")
            return 0
        
    
    for i in range(n-2):
        temp=str[i:i+3]
        for j in range(2):
            for k in range(j+1,3): 
                if temp[j]==temp[k]:
                    print("{0} {1}".format(i+1,i+3))
                    return 0
    print("-1 -1")
    
if __name__=="__main__":
    main()

Solution (Python):



s = input()


def search(s):
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            return i+1, i+2
        if len(s) > i+2 and s[i] == s[i+2]:
            return i+1, i+3
    return -1, -1


if __name__ == "__main__":
    a, b = search(s)
    if a == -1:
        print("-1 -1")
    else:
        print(a, end="")
        print(' ', end="")
        print(b, end="")

Solution (Python):
s = input()
import re
r = re.search(r"(.)\1", s) or re.search(r"(.).\1", s)
print(r and "%d %d" %(lambda x, y: (x + 1, y))(*r.span()) or "-1 -1")

Solution (Python):
s = input()
letter = set(s)

for x in letter:
    tmp1 = ''
    tmp2 = ''
    for i in range(len(s)):
        if s[i] == tmp1:
            print(i, i+1)
            exit()
        elif s[i] == tmp2:
            print(i-1, i+1)
            exit()
        else:
            tmp2 = tmp1
            tmp1 = s[i]
else:
    print(-1, -1)

Solution (Python):


def main():
    s = input()
    unbalance = True

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

    if unbalance: print(-1, -1)

if __name__ == '__main__':
    main()

Solution (Python):


def main():
    s = input()
    unbalance = True

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

    if unbalance: print(-1, -1)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
s = input()

if len(s) == 2 and s[0:1] == s[1:2]:
    print(1, 2)
    sys.exit()

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

print(-1, -1)

Solution (Python):


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

    print("{0} {0}".format(-1))


if __name__ == '__main__':
    main()