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

if s[0] == s[1]:
    print(1,2)
elif len(s) == 2:
    print(-1,-1)
else:
    x, y = s[0], s[1]
    UNBALANCE = False
    for i in range(2, len(s)):
        if x == s[i]:
            print(i-1, i+1)
            UNBALANCE = True
            break
        elif y == s[i]:
            print(i, i+1)
            UNBALANCE = True
            break
        else:
            x, y = y, s[i]
    if not UNBALANCE:
        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)
for i in range(len(s)-2):
  if s[i]==s[i+2]:
    print(i+1,i+3)
    exit(0)
print(-1,-1)

Solution (Python):
S=input();l=-1;r=-1
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        l=i+1;r=i+2
        break

if l<0 and len(S)>2:
    for i in range(len(S)-2):
        if S[i]==S[i+2]:
            l=i+1;r=i+3;
            break
print(l,r)

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

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
s=input()
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:
    if len(s)==2 and s[0]==s[1]:
        print(1,2)
    else:
        print("-1 -1")

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

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

    elif i != l - 2:
        if s[i] == s[i+2]:
            print(str(i+1) + " " + str(i+3))
            exit(0)


print("-1 -1")

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

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

if n>=3:
  for i in range(n-2):
    if s[i]==s[i+2]:
      ans[0],ans[1]=i+1,i+2+1

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

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 len(set(s[i:i+3])) != 3:
        print(i+1, i+3)
        exit()
print(-1, -1)

Solution (Python):
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline


S = list(input().strip())

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()
l=len(s)
s+="123"
for i in range(l):
    if s[i]==s[i+1]:
        print(i+1,i+2)
        exit()
    elif s[i]==s[i+2]:
        print(i+1,i+3)
        exit()
print(-1,-1)

Solution (Python):


s=list(input())
n=len(s)

if n<3:
    print(*[1,2] if len(set(s))<2 else [-1,-1])

    exit()

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

Solution (Python):
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def conb(n,r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

Solution (Python):

import sys


def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

s = IS()+"9"
n = len(s)
a, b = -1, -1

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

Solution (Python):


s=input()
N=len(s)
judge=True

if N<3:
    if s[0]==s[1]:
        print(1,2)
    else:
        print(-1,-1)
    
elif (s[0]==s[1] and s[0]!=s[2]) or (s[0]==s[2] and s[0]!=s[1]) or (s[1]==s[2] and s[1]!=s[0]):
    print(1,3)
    
elif (s[-3]==s[-2] and s[-3]!=s[-1])or (s[-3]==s[-1] and s[-3]!=s[-2])or (s[-2]==s[-1] and s[-2]!=s[-3]):
    print(N-2,N)
    
else:
    for i in range(2,N):
        if (s[i-2]==s[i-1] and s[i-2]!=s[i]) or (s[i-2]==s[i] and s[i-2]!=s[i-1]) or (s[i-1]==s[i] and s[i-1]!=s[i-2]):
            print(i-1,i+1)
            judge=False
            break
    
    if judge:
        print(-1,-1)

Solution (Python):
from collections import Counter
s = input()
n = len(s)
ans = True
if n > 2:
    for i in range(n - 2):
        if max(list(Counter(s[i:i+3]).values())) > 1:
            print(i + 1, i + 3)
            ans = False
            exit()
    if ans:
        print(-1, -1)
else:
    if max(list(Counter(s).values())) > 1:
        print(1, 2)
    else:
        print(-1, -1)

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

print(*solve())

Solution (Python):

S = input()
N = len(S)
for i in range(N-1):
    c2 = S[i:i+2]
    c3 = S[i:i+3]
    if len(set(c2)) == 1:
        print(i+1, i+2)
        exit()
    if  i != N-2 and len(set(c3)) == 2:
        print(i+1, i+3)
        exit()

print(-1, -1)

Solution (Python):

def main():
    
    S = input().rstrip()
    N = len(S)
    if N == 2:  
        ans = (1, 2) if S[0] == S[1] else (-1, -1)
        print(*ans)
        return
    for i in range(N - 2):
        if len(set(S[i : i + 3])) == 2:
            print(i + 1, i + 3)
            return
    print(-1, -1)


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    S = input().rstrip()
    N = len(S)
    if N == 2:
        flg = S[0] == S[1]
        print("1 2" if flg else "-1 -1")
        return
    for i in range(N - 2):
        if len({S[i], S[i + 1], S[i + 2]}) == 2:
            print(i + 1, i + 3)
            return
    print(-1, -1)


if __name__ == "__main__":
    main()

Solution (Python):
s = list(input())
inf = 10 ** 5 + 1
table = [[inf, 0] for _ in range(26)]
a = ord("a")
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]:
      table[ord(s[i]) - a][0] = i + 1
      table[ord(s[i]) - a][1] = i + 3
  for i in range(26):
    if table[i][1] != 0:
      print(table[i][0], table[i][1])
      exit(0)
  print(-1, -1)

Solution (Python):
S = input()
if(len(S)==2):
    if(S[0]==S[1]):
        print(1,2)
    else:
        print(-1,-1)
else:
    ans = [-1,-1]
    for ind,s in enumerate(S[:-2]):
        if(s==S[ind+1]):
            ans = [ind+1,ind+2]
            break
        elif(s==S[ind+2]):
            ans = [ind+1,ind+3]
            break
    print(*ans)

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

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

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

Solution (Python):
import itertools
S = input()
l = len(S)

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


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

print(-1,-1)

Solution (Python):
from collections import Counter

s = input()
possible = 0
for i in range(len(s) - 2):
    if len(Counter(s[i:i+3])) < 3:
        print(i+1, i+3)
        possible = 1
        break
if len(s) == 2:
    if s[0] == s[1]:
        print(1, 2)
        possible = 1
if not possible:
    print(-1, -1)

Solution (Python):
s=input()

p1 = s[0]
p2 = s[1]

if p1==p2:
    print(1,2)
else:
    flag=True
    for i in range(2,len(s)):
        if p1==s[i]:
            print(i-1,i+1)
            flag=False
            break
        elif p2==s[i]:
            print(i,i+1)
            flag=False
            break
        p1=s[i-1]
        p2=s[i]

    if flag:
        print(-1,-1)

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

Solution (Python):
S=input()
bb=S[0]
b=S[1]
flag=False
if bb==b:
    flag=True
    print("1 2")
if len(S)>2:
    for i in range(2,len(S)):
        if flag:
            break
        if S[i]==b or S[i]==bb:
            flag=True
            print(str(i-1)+" "+str(i+1))
            break
        bb,b=b,S[i]
if not flag:
    print("-1 -1")

Solution (Python):
import sys
s = input()
al = 'abcdefghijklmnopqrstuvwxyz'
count = 0
start = -1
end = -1
for ai in al:
    for j in range(len(s)):
        if s[j]==ai:
            if count<0:
                count=1
                start = j+1
            else:
                count+=1
            
        else:
            count-=1
        if start>0and start-1<j and count>0:
            print(start, j+1)
            sys.exit()
print(-1, -1)

Solution (Python):
s=input()
a=-1
at=-1
b=-1
bt=-1
for i in range(len(s)):
    if a==s[i]:
        print(at+1,i+1)
        quit()
    if b==s[i]:
        print(bt+1,i+1)
        quit()
    a=b
    at=bt
    b=s[i]
    bt=i
print(-1,-1)

Solution (Python):
s=input()
a=-1
at=-1
b=-1
bt=-1
for i in range(len(s)):
    if a==s[i]:
        print(at+1,i+1)
        quit()
    if b==s[i]:
        print(bt+1,i+1)
        quit()
    a=b
    at=bt
    b=s[i]
    bt=i
print(-1,-1)

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def two_unb(s: str) -> bool:
    judge = False
    st, ed = -1, -1

    for i in range(len(s)-1):
        if len(set(s[i:i+2])) < 2:
            judge = True
            st, ed = i, i+1

            return judge, (st, ed)

    return judge, (st, ed)

def thr_unb(s: str) -> bool:
    judge = False
    st, ed = -1, -1

    for i in range(len(s)-2):
        if len(set(s[i:i+3])) < 3:
            judge = True
            st, ed = i, i+2

            return judge, (st, ed)

    return judge, (st, ed)


s = ns()

jdg2, (st2, ed2) = two_unb(s)
jdg3, (st3, ed3) = thr_unb(s)

if jdg2:
    print(st2+1, ed2+1)

elif jdg3:
    print(st3+1, ed3+1)

else:
    print(-1, -1)

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

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

Solution (Python):
S=input()
bef0=(1,S[0])
bef1=(2,S[1])
if bef0[1]==bef1[1]:
    print("1 2")
    exit()
else:
    flag=True
    for i in range(2,len(S)):
        if bef0[1]==S[i] or bef1[1]==S[i]:
            print(" ".join([str(bef0[0]),str(i+1)]))
            flag=False
            break
        else:
            bef0=bef1
            bef1=(i+1,S[i])
    if flag:
        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
else:
  for i in range(len(s)-2):
    if 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
else:
    for i in range(N-2):
        if 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)-2):
    if s[i]==s[i+1] or s[i]==s[i+2]:
        print(i+1,end=' ')
        print(i+3)
        exit()
if s[-2]==s[-1]:
    print(len(s)-1,end=' ')
    print(len(s))
    exit()
print('-1 -1')

Solution (Python):
s = input()
n = len(s)
pre2, pre1 = 0, 0

if n == 2 and s[0] == s[1]:
    print(1, 2)
    exit()
for j in range(n):
    i = s[j]
    if i == pre2 or i == pre1:
        print(j-1, j+1)
        exit()
    else:
        pre2 = pre1
        pre1 = i
else:
    print("-1 -1")

Solution (Python):
s = input()

d = dict()
for i in range(len(s)):
    c = s[i]
    if d.__contains__(c):
        d[c].append(i)
    else:
        d[c]=[]
        d[c].append(i)
for c in d.keys():
    for i in range(len(d[c])-1):
        if d[c][i+1]-d[c][i]<3:
            print(d[c][i]+1,d[c][i+1]+1)
            exit(0)
print(-1,-1)

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

def read_input():
    s = input()
    return s

def submit():
    s = read_input()

    for i, (l, r) in enumerate(zip(s, s[1:])):
        if l == r:
            print('{} {}'.format(i + 1, i + 2))
            return

    for i, (l, r) in enumerate(zip(s, s[2:])):
        if l == r:
            print('{} {}'.format(i + 1, i + 3))
            return

    print('-1 -1')


if __name__ == '__main__':
    submit()

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

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


if __name__ == '__main__':
	main()

Solution (Python):


s = input()

ans = ''

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        ans = ' '.join([str(i+1), str(i+2)])
for j in range(len(s)-2):
    if s[j] == s[j+2]:
        ans = ' '.join([str(j+1), str(j+3)])

if ans:
    print(ans)
else:
    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):

import sys


def solve(s: str):
    n = len(s)
    for i, c in enumerate(s):
        if i == n-1:
            print('-1 -1')
            return
        if i <= n-3:
            if c == s[i+2]:
                print(i+1, i+3)
                return
        if c == s[i+1]:
            print(i+1, i+2)
            return
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  
    solve(s)

if __name__ == '__main__':
    main()

Solution (Python):
sn = input()
for i in range(len(sn)-1):
    if sn[i] == sn[i+1]:
        print(i+1, i+2)
        break
    if (i < (len(sn)-2)) and (sn[i] == sn[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] == 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):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    return


def B():
    return


def C():
    return


def D():
    s = S()
    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)

    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    D()

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    INF = float("inf")
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    s = list(_ for _ in input())
    left = -1
    right = -1
    for i in range(len(s)-1):
        if(s[i+1]==s[i]):
            left = i+1
            right = i+2
            break
        
    for i in range(len(s)-2):
        if(s[i+2]==s[i]):
            left = i+1
            right = i+3
            break
    print(left,right)
if __name__ == '__main__':
    main()

Solution (Python):
s=input()
a,b=-1,-1
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        a,b=i+1,i+2
        break
if a+b==-2:
    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):
s = input()
n = len(s)
for i in range(n-1):
    if i < n-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:
            continue
    else:
        if s[i] == s[i+1]:
            print(i+1,i+2)
        else:
            print(-1,-1)

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

Solution (Python):
s = input()
t = s[1:]+" "
r = s[2:]+"  "
for n,(i,j,k) in enumerate(zip(s,t,r)):
    if i == j :
        print(n+1,n+2)
        exit()
    elif i == k:
        print(n+1,n+3)
        exit()
print(-1,-1)

Solution (Python):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    S = input_raw[0]


    for k in range(2, 4):
        for i in range(len(S) - k + 1):
            dic = {}
            for j in range(k):
                if S[i + j] not in dic:
                    dic[S[i + j]] = 1
                else:
                    dic[S[i + j]] += 1
            for j in range(k):
                if dic[S[i + j]] >= k/2 + 1:
                    print i + 1, k + i
                    return
    print -1, -1


if __name__ == '__main__':
    main()

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

Solution (Python):
s = list(input())
N = len(s)
judge = "balanced"
for i in range(N - 1):
	if s[i] == s[i + 1]:
		print(i + 1, i + 2)
		judge = "unbalanced"
		break

if judge == "balanced":
	for i in range(N - 2):
		if s[i] == s[i + 2]:
			print(i + 1, i + 3)
			judge = "unbalanced"
			break
			
if judge == "balanced":
	print(-1, -1)

Solution (Python):

from itertools import accumulate
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
N = len(S)
ansL = -1
ansR = -1

if N == 2:
    if S[0] == S[1]:
        ansL = 1
        ansR = 2

else:
    for l in range(N-2):
        if S[l] == S[l+1]:
            ansL = l+1
            ansR = l+2
            break
        elif S[l] == S[l+2]:
            ansL = l+1
            ansR = l+3
            break
print(ansL, ansR)

Solution (Python):

S=input()
c={}
for i in [chr(ord('a') + i) for i in range(26)]:
	c[i]=0
for i in range(len(S)):
	if i<3:
		c[S[i]]+=1
		if c[S[i]]>=2:
			print(1,i+1)
			exit()
	else:
		c[S[i-3]]-=1
		c[S[i]]+=1
		if c[S[i]]>=2:
			print(i-1,i+1)
			exit()
print(-1,-1)

Solution (Python):
a=input()
flag = 0
for i in range(len(a)-1):
  if flag == 0:
    if a[i]==a[i+1]:
      print("{0} {1}".format(i+1,i+2))
      flag = 1
    elif i+2!=len(a) and a[i]==a[i+2]:
      print("{0} {1}".format(i+1,i+3))
      flag = 1
if flag == 0:
  print("-1 -1")

Solution (Python):
a=input()
flag = 0
for i in range(len(a)-1):
  if flag == 0:
    if a[i]==a[i+1]:
      print("{0} {1}".format(i+1,i+2))
      flag = 1
    elif i+2!=len(a) and a[i]==a[i+2]:
      print("{0} {1}".format(i+1,i+3))
      flag = 1
if flag == 0:
  print("-1 -1")

Solution (Python):
s=input()
if len(s)==2:
  if s[0]==s[1]:
    print(1,2)
  else:
    print(-1,-1)
  exit(0)
for i, (a,b,c) in enumerate(zip(s,s[1::],s[2::]),1):
  if a==b:
    print(i,i+1)
    exit(0)
  if a==c:
    print(i,i+2)
    exit(0)
print(-1,-1)

Solution (Python):
def main():
	s = input()
	for i in range(len(s)-1):
		if s[i] == s[i+1]:
			print("{} {}".format(i+1,i+2))
			return
		elif i+2<len(s) and s[i] == s[i+2]:
			print("{} {}".format(i+1, i+3))
			return
	print("-1 -1")
	return

main()

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

Solution (Python):
s = input() 
k = -1
l = -1
flag = False
for i in range(0,len(s)-1):
  if s[i] == s[i+1]:
    flag = True
    k = i+1
    l = i+2
    break
if not flag:
  if len(s) > 2:
    for j in range(0,len(s)-2):
      if s[j] == s[j+2]:
        flag = True
        k = j+1
        l = j+3
        break
  else:
    None
print(k,l)

Solution (Python):
S = list(input())
S.append("A")
for j in range(len(S) - 2):
    if (S[j] == S[j + 1]):
        print(j+1, j+2)
        exit()
    if (S[j] == S[j + 2]):
        print(j+1, j+3)
        exit()
else:
    print("-1 -1")

Solution (Python):
S = input()
one = S[0]
two = S[1]
ans = "-1 -1"
l = len(S)
for i in range(2,l):
    s = S[i]
    if s == one:
        ans = str(i-1) + " " + str(i+1)
        break
    elif s == two:
        ans = str(i) + " " + str(i+1)
        break
    one, two = two, s
if l == 2:
    if one == two:
        ans = "1 2"
print( ans)

Solution (Python):


def main():
    s = input().strip()
    if len(s) == 2:
        return ("1 2" if s[0] == s[1] else "-1 -1")
    for i in range(len(s) - 2):
        if len(set(s[i:i + 3])) <= 2:
            return "{} {}".format(i + 1, i + 3)
    return "-1 -1"


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

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

sys.setrecursionlimit(10000)

S = input()

for i in range(len(S)):
    if i <= len(S) -2:
        if S[i] == S[i+1]:
            print("{} {}".format(i+1,i+2))
            break
    if i <= len(S) -3:
        if S[i] == S[i+2]:
            print("{} {}".format(i+1, i+3))
            break
else:
    print("-1 -1")

Solution (Python):
a = input()
count = 0
if len(a) > 3:
    for i in range(len(a)-2):
        if a[i] == a[i+1] or a[i] == a[i+2] or a[i+1] == a[i+2]:
            print(i+1,i+3)
            count += 1
            break
else:
    if a[0] == a[1]:
        print(1,2)
        count += 1
if count == 0:
    print(-1,-1)

Solution (Python):
S = input()

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

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

print(-1, -1)

Solution (Python):
import collections
S = input()

if len(S) == 1:
    print(-1,-1)
    exit()

tmp_s1 = '1'
tmp_s2 = '2'
tmp_s3 = '3'

for i,s in enumerate(S):
    if i == 0:
        tmp_s1 = s
    elif i == 1:
        tmp_s2 = s
    elif i == 3:
        tmp_s3 = s

    else:
        tmp_s1 = tmp_s2
        tmp_s2 = tmp_s3
        tmp_s3 = s

    if tmp_s1 == tmp_s2:
        print(i-1 + 1,i + 1)
        exit()
    elif tmp_s2 == tmp_s3:
        print(i, i+1)
        exit()
    elif tmp_s1 == tmp_s3:
        print(i-2 + 1,i + 1)
        exit()
print(-1,-1)

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

Solution (Python):
s = input()
b = ''
ans = [-1,-1]
for i in range(len(s)):
    a = s[i]
    if a == b:
        ans = [i,i+1]
    b = s[i]
b = ''
for i in range(0,len(s),2):
    a = s[i]
    if a == b:
        ans = [i-1,i+1]
    b = s[i]
b = ''
for i in range(1,len(s),2):
    a = s[i]
    if a == b:
        ans = [i-1,i+1]
    b = s[i]

print(*ans)

Solution (Python):

flag=True
s = input()
if len(s)!=0:
    for i in range(1,len(s)):
        if s[i-1]==s[i]:
            print(str(i)+" "+str(i+1))
            flag=False
            break
        if i>1:
            if s[i-2]==s[i]:
                print(str(i-1)+" "+str(i+1))
                flag=False
                break
    if flag:
        print("-1 -1")            
else:
    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()

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

print("-1 -1")

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

check = False
for i in range(n-2):
    temp = s[i:i+3]
    temp.sort()
    if temp[1] == temp[0] or temp[1] == temp[2]:
        check = True
        print(i+1,i+1+2)
        break
if n == 2 and s[0] == s[1]:
    check = True
    print("1 2")
if check == False:
    print('-1 -1')

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

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

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

    print(-1, -1)
ARC059D()

Solution (Python):
from string import ascii_lowercase
s = input()
for x in ascii_lowercase:
    cnt = 0
    l = 0
    for r, y in enumerate(s):
        if y == x:
            cnt += 1
        else:
            cnt -= 1
        if r - l > 0 and cnt > 0:
            print(l + 1, r + 1)
            exit()
        if y == x:
            l = r
            cnt = 1

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

print(-1,-1)

Solution (Python):


def main():
    s = input()
    n = len(s)
    for i in range(n - 1):
        if is_unstable(s[i:i + 2]):
            print(i + 1, i + 2)
            return
    for i in range(n - 2):
        if is_unstable(s[i:i + 3]):
            print(i + 1, i + 3)
            return
    print("-1 -1")

def is_unstable(s):
    assert len(s) in [2, 3]
    return s[0] == s[-1]

main()