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()
n=len(s)
dic={}
for i in range(n):
    if s[i] in dic:
        dic[s[i]].append(i)
    else:
        dic[s[i]]=[i]
for i in dic.values():
    if len(i)>1:
        for j in range(1,len(i)):
            if i[j]-i[j-1]<=2:
                print(i[j-1]+1,i[j]+1)
                exit()
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)
if n >= 3:
    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()
n = len(s)
for k in range(1,n):
    if s[k-1] == s[k]:
        print(k,k+1)
        exit(0)
if n >= 3:
    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()

flag = False
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        flag = True
        break

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

Solution (Python):

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

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


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

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

Solution (Python):
s = input()
for x in list(map(chr, range(ord('a'), ord('z')+1))):
    p = None
    for i, c in enumerate(s):
        if c!=x: continue
        if p is not None and i-p<=2:
            print(p+1, i+1)
            exit()
        p = i

print(-1, -1)

Solution (Python):
import sys
s=input()
if len(s)==1:
  print(-1,-1)
elif s[0]==s[1]:
  print(1,2)
else:
  a=s[0]
  b=s[1]
  for i in range(2,len(s)):
    if s[i]==a:
      print(i-1,i+1)
      sys.exit()
    elif s[i]==b:
      print(i,i+1)
      sys.exit()
    else:
      a=b
      b=s[i]
  print(-1,-1)

Solution (Python):
import sys
l= input()
a=len(l)
b=(-1,-1)
for i in range(a-1):
  if l[i]==l[i+1]:
    print(i+1,i+2)
    sys.exit()
for i in range(a-2):
  if l[i]==l[i+2]:
    print(i+1,i+3)
    sys.exit()
print(-1,-1)
sys.exit()

Solution (Python):
sl = list(input())

n = len(sl)

if n == 2:
   if sl[0] == sl[1]:
      print(1)
      print(2)
   else:
      print(-1)
      print(-1)
   import sys
   sys.exit()
else:
   for i in range(n-2):
      a = [sl[i], sl[i+1], sl[i+2]]
      if len(set(a)) <= 2:
         print(i+1)
         print(i+3)
         import sys
         sys.exit()
   print(-1)
   print(-1)

Solution (Python):
def solve(s: str) -> (int, int):
    for i in range(0, len(s) - 1):
        if s[i] == s[i + 1]:
            return (i + 1, i + 2)
    for i in range(0, len(s) - 2):
        if s[i] == s[i + 2]:
            return (i + 1, i + 3)
    return (-1, -1)

s = input()
print('{} {}'.format(*solve(s)))

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

max_num = min(len(s),5)

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

for k in range(3,max_num,2):
    l = [0]*26
    for kk in range(k):
        l[ord(s[kk])-97] += 1
    if max(l) == (k+1)//2:
        print(1,k)
        exit()

    for i in range(k,len(s)):
        l[ord(s[i-k])-97] -= 1
        l[ord(s[i])-97] += 1
        if max(l) == (k+1)//2:
            print(i-k+2,i+1)
            exit()

print(-1,-1)

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

max_num = min(len(s),100)

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

for k in range(3,max_num,2):
    l = [0]*26
    for kk in range(k):
        l[ord(s[kk])-97] += 1
    if max(l) == (k+1)//2:
        print(1,k)
        exit()

    for i in range(k,len(s)):
        l[ord(s[i-k])-97] -= 1
        l[ord(s[i])-97] += 1
        if max(l) == (k+1)//2:
            print(i-k+2,i+1)
            exit()

print(-1,-1)

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

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

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

Solution (Python):
s = input()


def unbalanced(st):
    for c in st:
        if st.count(c) > (len(st) // 2):
            return True
    return False


def test_str(st):
    r = (-1, -1)
    for j in range(1, 3):
        for i in range(len(s) - j):
            if unbalanced(s[i:i+j+1]):
                r = (i+1, i+j+1)
                return r
    return r


print(test_str(s)[0], test_str(s)[1])

Solution (Python):
s=input()
temp=0
tem=0
tot=0
flag=0
if s[-2]==s[-1]:
    print(len(s)-1,len(s))
else:
        
    if 1:
        for i in range(len(s)-2):
            if s[i]==s[i+1]:
                print(i+1,i+2)
                flag=1
                break
            elif s[i]==s[i+2]:
                print(i+1,i+3)
                flag=1
                break
        if flag==0:
            print("-1 -1")

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

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

Solution (Python):
s = input()

al = [chr(ord('a') + i) for i in range(26)]
c = dict()
for _al in al:
    c[_al] = [0]

for i in range(len(s)):
    for _al in al:
        if _al == s[i]:
            c[_al].append(c[_al][-1] + 1)
        else:
            c[_al].append(c[_al][-1])

f = False
for _al in al:
    tmp = []
    curmin = []
    for i in range(len(c[_al])):
        cur = c[_al][i] * 2 - i

        tmp.append(cur)
        if i == 0:
            curmin.append(cur)
        else:
            curmin.append(min(cur, curmin[-1]))

        if i >= 2 and tmp[-1] > curmin[-3]:
            y = i
            f = True
            break

    if f:
        break

if f:
    for j in range(len(tmp)):
        if tmp[j] == curmin[-3]:
            x = j + 1
            break
    print(' '.join([str(x), str(y)]))
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+1 + 1)
        exit()
    if s[i]==s[i+2]:
        print(i + 1,i+2 + 1)
        exit()

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

print(-1,-1)

Solution (Python):
import sys

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

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

    return -1, -1

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

Solution (Python):
s = input()

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

for start in range(len(s) - 2):
    a, b ,c = s[start:start + 3]
    if (a == b and b != c) or (a != b and b == c) or (a == c and a != b):
        print(start + 1, start + 3)
        break
else:
    print(-1, -1)

Solution (Python):
NO_SOL = (-1, -1)
 
 



def search_unbalanced_substr(s):
    n = len(s)
    
    for i in range(n - 1):
        if s[i] == s[i + 1]:
            return i, i + 1
    
    for i in range(n - 2):
        if s[i] == s[i + 2]:
            return i, i + 2
    
    return NO_SOL
 
 
def main():
    ans = search_unbalanced_substr(input())
    if ans == NO_SOL:
        print(*ans)
    else:
        print(*(i + 1 for i in ans))
 
 
if __name__ == '__main__':
    main()

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],s[i+1],s[i+2])))!=3:
      print(i+1,i+3)
      break
  else:
    print("-1 -1")

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

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

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

print(-1, -1)

Solution (Python):
import sys
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):
        
        
        
        t = s[i:i + 3]
        
        
        if t.count(t[0]) > 1 or t.count(t[1]) > 1:
            print(i + 1, i + 3)
            sys.exit()

    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):
        t = s[i:i + 3]
        if t.count(t[0]) > 1 or t.count(t[1]) > 1:
            print(i + 1, i + 3)
            exit()

    print("-1 -1")

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    before=""
    for i,s in enumerate(S,start=1):
        if before==s:
            print(i-1,i)
            exit()
        before = s
    substr = "   "
    for i,s in enumerate(S,start=1):
        substr = substr[1:]+s
        if substr[0]==substr[-1]:
            print(i-2,i)
            exit()        
    print(-1,-1)
if __name__ == '__main__':
    main()

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

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

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

print(-1, -1)

Solution (Python):
s = input()
ct = {i : 0 for i in set(s)}
ct[s[0]] += 1
ct[s[1]] += 1
if ct[s[1]] == 2:
    print(1, 2)
else:
    flg = False
    for i, _s in enumerate(s[2:], 2):
        ct[_s] += 1
        if ct[_s] > 1:
            flg = True
            break
        else:
            ct[s[i-2]] -= 1
    if flg:
        print(i-1, i+1)
    else:
        print("-1 -1")

Solution (Python):
import sys

s = 'a' + input()

for i in range(3,len(s)):
  if s[i] != s[i-1] and s[i] != s[i-2]:
    continue
  elif s[i] == s[i-1]:
    print(i-1,i)
    sys.exit(0)
  elif s[i] == s[i-2]:
    print(i-2,i)
    sys.exit(0)

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

Solution (Python):
s = input()

a = -1
b = -1

for i in range(len(s) - 1):
  if a != -1:
    break
  if s[i] == s[i + 1]:
    a = i + 1
    b = i + 2

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

print(a, b)

Solution (Python):
a=input()

count=0
if len(a)==2:
    if a[0]==a[1]:
        print(1,2)
        count=1

for i in range(len(a)-2):
    if count==1:
        break
    x=a[i]
    y=a[i+1]
    z=a[i+2]
    if x==y:
        print(str(i),str(i+2))
        count=1
        break
    elif z==y:
        print(str(i+1),str(i+3))
        count=1
        break
    elif x==z:
        print(str(i+1),str(i+3))
        count=1
        break

if count==0:
    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):
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):
s = input().strip()
ans = [-1,-1]
if len(s)==2:
    if s[0]==s[1]:
        ans = [1,2]
else:
    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):
s = input().strip()
ans = [-1,-1]
for i in range(len(s)):
    if i<len(s)-1 and s[i]==s[i+1]:
        ans = [i+1,i+2]
        break
    if i<len(s)-2 and s[i]==s[i+2]:
        ans = [i+1,i+3]
        break
print(ans[0], ans[1])

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

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

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

Solution (Python):
s = input()
a1,a2 = s[0],s[1]
if a1 == a2:
  print(1,2)
  exit()
for k,v in enumerate(s[2:]):
  if v == a1:
    print(k+1,k+3)
    exit()
  elif v == a2:
    print(k+2,k+3)
    exit()
  a1 = a2
  a2 = v
print(-1,-1)

Solution (Python):
s = input()

N = len(s)
if N == 2:
    if s[0] == s[1]:
        ans = ["1", "2"]
    else:
        ans = ["-1", "-1"]
else:
    ans = ["-1", "-1"]
    for i in range(N-2):
        if s[i] != s[i+1] and s[i+1] != s[i+2] and s[i+2] != s[i]:
            continue
        else:
            ans = [str(i+1), str(i+3)]
            break
            
print(" ".join(ans))

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):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    S=input()
    n=len(S)

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

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

    
    print(-1,-1)
resolve()

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

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

Solution (Python):
s=input()
right=1

import collections
def isOK(target):
  counter=collections.Counter(list(target))
  if max(counter.values())>len(target)//2:
    return True
  return False
  
for left in range(len(s)-1):
  cur=s[left:right+1]
  while right+1<len(s) and s[right+1] in cur:
    cur+=s[right+1]
    right+=1
    if isOK(cur):
      break
    
  if isOK(cur):
    print(left+1,right+1)
    break
    
  if left+1==right:
    right+=1
else:
  print(-1,-1)

Solution (Python):
def main():
    s = input()
    b1,b2 = s[1],s[0]
    if len(s)==2:
        if b1 == b2:
            print("1 2")
            exit()
        else:
            print("-1 -1")
            exit()
    for i in range(2,len(s)):
        if s[i] == b1 or s[i] == b2:
            print("{} {}".format(i-1,i+1))
            exit()
        else:
            b1,b2 = s[i],s[i-1] 
    print("-1 -1")

if __name__=='__main__':
    main()

Solution (Python):
def main():
    s = input()
    ans1 = -1
    ans2 = -1

    for i in range(len(s)-1):
        if s[i]==s[i+1]:
            ans1 = i+1
            ans2 = i+2
            break
        elif i < len(s)-2 and s[i]==s[i+2]:
            ans1 = i+1
            ans2 = i+3
            break
        else:
            continue

    print(ans1, ans2)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

s=input()
n=len(s)

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

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

print(-1,-1)

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

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

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

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

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

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

Solution (Python):
S = input()
prvs = ''
si = None
for i, s in enumerate(S):
  if prvs == s:
    if si is None: si = i
    print(i,i+1)
    exit()
  else:
    if si is not None:
      print(si, i)
  prvs = s

for i in range(len(S)-2):
  if len(set(S[i:i+3]))<=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()


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

Solution (Python):

from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

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

for i, (a1, a2, a3) in enumerate(zip(s, s[1:], s[2:])):
    if a1 == a2:
        print(i+1, i+2)
        exit()
    if a2 == a3:
        print(i+2, i+3)
        exit()
    if a1 == a3:
        print(i+1, i+3)
        exit()
print(-1, -1)

Solution (Python):
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    if len(s) > 3:
        for i in range(3, len(s)):
            t = s[i-3:i]
            t = collections.Counter(t)
            if len(t) == 1 or len(t) == 2:
                print(i-2, i)
                exit()
        print(-1, -1)
    elif len(s) == 3:
        s = collections.Counter(s)
        if len(s) == 1 or len(s) == 2:
            print(1, 3)
        else:
            print(-1, -1)
    elif len(s) == 2:
        s = collections.Counter(s)
        if len(s) == 1:
            print(1, 2)
        else:
            print(-1, -1)


if __name__ == '__main__':
    solve()

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

Solution (Python):
from itertools import groupby
s = input()
S = groupby(s)
table = []
for key,group in S:
  cnt = 0
  for id,_ in enumerate(group,1):
    cnt = id
  table.append([key,cnt])

if len(table) == 1:
  print(1,len(s))
  exit()
from collections import defaultdict
for i in range(len(table)-1):
  if table[i][1] != table[i+1][1]:
    print(i+1,i+1+table[i+1][1])
    exit()
  if i <= len(table)-3:
    if table[i][0] == table[i+2][0] and (table[i][1] + table[i+2][1])  > (table[i][1] + table[i+1][1] + table[i+2][1]) / 2:
      print(i+1,i+1+table[i+1][1] + table[i+2][1])
      exit()
print(-1,-1)

Solution (Python):
def examD():
    St = S()
    N = len(St)
    ans = [-1, -1]
    for lower in range(N - 1):
        if St[lower] == St[lower + 1]:
            ans = [lower+1, lower + 2]
            break
        elif lower < N - 2 and St[lower] == St[lower + 2]:
            ans = [lower+1, lower + 3]
            break

    print(" ".join(map(str, ans)))

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examD()

Solution (Python):

import sys
input = sys.stdin.readline


S = input()

N = len(S)
ans = [-1,-1]

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

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

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

Solution (Python):
arr = list(input())
tmp1 = arr[0]
tmp2 = arr[1]
 
i = 2
flg = True
if (tmp1 != tmp2):
    while i < len(arr):
        tmp3 = arr[i]
        if (tmp3 == tmp2):
            print(str(i) + " " + str(i + 1))
            flg = False
            break
        if (tmp3 == tmp1):
            print(str(i - 1) + " " + str(i + 1))
            flg = False
            break
 
        tmp1 = arr[i - 1]
        tmp2 = arr[i]
        i = i + 1
else:
    print("1 2")
    flg = False
 
if (flg):
    print("-1 -1")

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

Solution (Python):
arr = list(input())
tmp1 = arr[0]
tmp2 = arr[1]

i = 2
flg = True
if (tmp1 != tmp2):
    while i < len(arr):
        tmp3 = arr[i]
        if (tmp3 == tmp2):
            print(str(i) + " " + str(i + 1))
            flg = False
            break
        if (tmp3 == tmp1):
            print(str(i - 1) + " " + str(i + 1))
            flg = False
            break

        tmp1 = arr[i - 1]
        tmp2 = arr[i]
        i = i + 1
else:
    print("1 2")
    flg = False

if (flg):
    print("-1 -1")

Solution (Python):
S = input()

answer = ''

for i in range(len(S)):
    s = S[i]
    if i+1 <= len(S)-1 and S[i+1] == s:
        answer = str(i+1) + ' ' + str(i+2)
        break
    elif i+2 <= len(S)-2 and S[i+2] == s:
        answer = str(i+1) + ' ' + str(i+3)
        break
    else:
        answer = '-1 -1'

print(answer)

Solution (Python):
s=input()
if len(s)==2 or s[0]==s[1]:
    print("1 2" if s[0]==s[1] else "-1 -1")
else:
    for i in range(2,len(s)):
        if s[i-2]==s[i]:
            print(i-1,i+1)
            break
        elif s[i-1]==s[i]:
            print(i,i+1)
            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)
        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 = list(input())

is_done_2 = False
is_done_3 = False

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

if not is_done_2:
    for j in range(len(S)-2):
        if len(set(S[j:j+3])) < 3:
            is_done_3 = True
            break

if is_done_2:
    print(i+1, i+2)
elif is_done_3:
    print(j+1, j+3)
else:
    print(-1, -1)

Solution (Python):

import sys, math, fractions, itertools


def solve(s: str):
    N = len(s)
    for i in range(N-1):
        if s[i] == s[i+1]:
            print(i+1, i+2)
            return
    for i in range(N-2):
        if s[i] == s[i+2]:
            print(i+1, i+3)
            return
    print(-1, -1)
    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):
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 = 0
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        print('{} {}'.format(i+1, i+2))
        flag=1
        break
for i in range(len(s)-2):
    if flag==1:
        break
    if s[i]==s[i+2]:
        print('{} {}'.format(i+1, i+3))
        flag=1
        break
if flag == 0:
    print('-1 -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()

for i in range(len(s)-2):

    if s[i] == s[i+2]:
        print (i+1,i+3)
        sys.exit()

print (-1,-1)

Solution (Python):
def is_unbarance2(substring):
    return substring[0] == substring[1]


def is_unbarance3(substring):
    types = set(substring)
    return len(types) < 3


def main(string):
    if len(string) == 2:
        if is_unbarance2(string):
            return 1, 2
        else:
            return -1, -1
    else:
        for i in range(len(string) - 2):
            start = i
            stop = i + 3
            substring = string[start:stop]
            if is_unbarance3(substring):
                return start + 1, stop
        return -1, -1


if __name__ == '__main__':
    s = input()
    result = main(s)
    print(*result)

Solution (Python):
from collections import Counter 
def check(s): 
    c=Counter(s)
    if max(c.values())>len(s)/2:
        return 1 
    return 0 
s=input()
n=len(s)
for i in range(n):
    for j in range(i+1,min(n,i+15)):
        if check(s[i:j+1]):
            print(i+1,j+1)
            exit()
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):




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

Solution (Python):
s = input().rstrip()
n = len(s)
for i, c in enumerate(s):
    if i + 1 < n and c == s[i + 1]:
        print(i + 1, i + 2)
        break
    if i + 2 < n and c == s[i + 2]:
        print(i + 1, i + 3)
        break
else:
    print(-1, -1)

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

Solution (Python):
import string
from collections import defaultdict
S = input()
n = len(S)


s1 = S[::2]
s2 = S[1::2]

n1 = len(s1)
n2 = len(s2)

ans = 0
for i in range(1,n):
    if S[i] == S[i-1]:
       print("{} {}".format(i, i+1))
       exit()

ans = 0
for i in range(1,n1):
    if s1[i] == s1[i-1]:
       print("{} {}".format(2*i-1, 2*i+1))
       exit()

ans = 0
for i in range(1,n2):
    if s2[i] == s2[i-1]:
       print("{} {}".format(2*(i), 2*(i+1)))
       exit()

print("-1 -1")