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()
s=s+'?'

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

print(-1,-1)

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

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):
def check(l, r):
    th = 1 + (r - l + 1) // 2 
    for i in range(26):
        if cnt[i] >= th:
            return True
    return False

s = input()
n = len(s)
si = [0] * n
for i in range(n):
    si[i] = ord(s[i]) - 97

l, r = 0, 1
cnt = [0]*26
for i in range(2):
    cnt[si[i]] += 1
while l < n-1 and r < n:
    if check(l, r):
        print(l+1, r+1)
        exit()
    elif max(cnt) == 1 + (r - l + 1) // 2 or r-l == 1:
        r += 1
        if r < n:
            cnt[si[r]] += 1
    else:
        cnt[si[l]] -= 1
        l += 1     
print(-1, -1)

Solution (Python):
def check(l, r):
    th = 1 + (r - l + 1) // 2 
    for i in range(26):
        if cnt[i] >= th:
            return True
    return False

s = input()
n = len(s)
si = [0] * n
for i in range(n):
    si[i] = ord(s[i]) - 97

l, r = 0, 1
cnt = [0]*26
for i in range(2):
    cnt[si[i]] += 1
while l < n-1 and r < n:
    if check(l, r):
        print(l+1, r+1)
        exit()
    elif max(cnt) == 1 + (r - l + 1) // 2 or r-l == 1:
        r += 1
        if r < n:
            cnt[si[r]] += 1
    else:
        cnt[si[l]] -= 1
        l += 1     
print(-1, -1)

Solution (Python):
s = str(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

def solve(s: str):
    """
    >>> solve("needed")
    (2, 3)
    >>> solve("ede")
    (1, 3)
    """
    for i, (c0, c1) in enumerate(zip(s, s[1:]), 1):
        if c0 == c1:
            return i, i+1
    for i, (c0, c2) in enumerate(zip(s, s[2:]), 1):
        if c0 == c2:
            return i, i+2
    return (-1, -1)


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

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

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

Solution (Python):
s = list(input())
def rle(lst):
    ans = []
    cnt = 1
    ini = lst[0]
    for i in range(1, len(lst)):
        if ini == lst[i]:
            cnt += 1
        else:
            ans.append((ini, cnt))
            cnt = 1
            ini = lst[i]
    ans.append((ini, cnt))
    return ans

sr = rle(s)
cnt = 0
for i in range(len(sr)):
    if sr[i][1] == 1:
        cnt += 1
    else:
        print(cnt+1, cnt+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
s = input()
N = len(s)

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def main():
    s = input()
    for i in range(26):
        a = chr(97 + i)
        cnt = 10**10
        for i, c in enumerate(s):
            if c == a and cnt <= 1:
                print("{} {}".format(i - cnt, i + 1))
                return
            if c == a:
                cnt = 0
            else:
                cnt += 1
    print("-1 -1")



if __name__ == "__main__":
    main()

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

def Judge(N, 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
    else:
        return -1, -1

S = list(input().strip())
N = len(S)
a, b = Judge(N, S)
print(a, b)

Solution (Python):
S = input()

from collections import defaultdict
def unbalance(S):
    D = defaultdict(lambda:0)
    for s in S:
        D[s] += 1
    if max(D.values()) > len(S)//2:
        return True
    else:
        return False

lenS =len(S)
for i in range(lenS-1):
    if unbalance(S[i:i+2]):
        print(f'{i+1} {i+2}'); break
    if i < lenS-2 and unbalance(S[i:i+3]):
        print(f'{i+1} {i+3}'); break
else:
    print('-1 -1')

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

Solution (Python):
from collections import Counter
s = input()
n = len(s)

for i in range(n):
    if n == 2:
        if s[0] == s[1]:
            print(1, 2)
            exit()
    if i == n - 2:
        break
    c = Counter(s[i:i + 3])
    v = c.most_common()
    if v[0][1] * 2 > len(s[i:i + 3]):
        print(i + 1, i + 3)
        exit()

print(-1, -1)

Solution (Python):
import sys

s = input()

if len(s) == 2 and s[0] == s[1]:
    print('1 2')
    sys.exit(0)
else:
    for i in range(0, len(s)-2):
        c1, c2, c3 = s[i], s[i+1], s[i+2]

        if len(set([c1,c2,c3])) <= 2:
                print('%s %s' % (i+1, i+3))
                sys.exit(0)

print('-1 -1')

Solution (Python):

import collections
found = (-1,-1)
s = raw_input()
if len(s) ==2:
	found = (1,2) if s[0] == s[1] else (-1,-1)

	print found[0], found[1]
	 
else:		
	for i in range(len(s)-2):
		cs = collections.Counter(s[i:i+3])
		if sorted(cs.values())[-1] >=2 and len(cs)>=2:
			found = (i+1,i+3)
			break

	print found[0], found[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):
        temp = {}
        for j in range(3):
            temp.setdefault(s[i + j], 0)
            temp[s[i + j]] += 1
        if max(temp.values()) >= 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)
    exit()
  if i!=N-2:
    if S[i]==S[i+2]:
      print(i+1,i+3)
      exit()
print(-1,-1)

Solution (Python):
S = input()+"_"
x = -2
y = -2

for n in range(len(S)-2):
  if S[n]==S[n+1]:
    x=n
    y=n+1
  if S[n]==S[n+2]:
    x=n
    y=n+2

print(x+1,y+1)

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

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

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

print(*[-1, -1])

Solution (Python):
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

s = input()
idxs = [[] for i in range(26)]
def wid(w):
    return ord(w)-ord("a")
for i in range(len(s)):
    w = s[i]
    idxs[wid(w)].append(i)
a=-1
b=-1
for i in range(26):
    if len(idxs[i])>=2:
        prev = idxs[i][0]
        for nex in idxs[i]:
            d = nex-prev
            if 1<=d<=2:
                a=prev+1
                b=nex+1
                break
            prev=nex
print(a,b)

Solution (Python):
s = input()

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

for i in range(len(s)):
    l[ord(s[i]) - 97].append(i)

for i in l:
    if len(i) < 2:
        continue

    j = 1
    while j < len(i):
        if i[j] - i[j-1] > 2:
            j += 1
            continue
        else:
            print(i[j-1] + 1, i[j] + 1)
            exit()

print(-1, -1)

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

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

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

print(a,b)

Solution (Python):
s = input()

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

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

Solution (Python):

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

S = readline().decode().rstrip()
N = len(S)
for i in range(N-1):
    if  S[i] == S[i+1]:
        print(i+1,i+2)
        sys.exit()
    if i+2 <= N-1:
        if S[i] == S[i+2]:
            print(i+1,i+3) 
            sys.exit()
print(-1,-1)

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

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

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

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

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


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

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

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

Solution (Python):
def main():
    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) - 2):
        if len(set(list(s[i:i + 3]))) < 3:
            print(i + 1, i + 3)
            exit()
    print(-1, -1)

if __name__ == '__main__':
    main()

Solution (Python):
import re
text = input()
for i in list('abcdefghijklmnopqrstuvwxyz'):
    match_object = re.search(r'{0}.?{0}'.format(i), text)
    if match_object:
        print(str(match_object.start() + 1) + ' ' + str(match_object.end()))
        exit()
print('-1 -1')

Solution (Python):
import re
text = input()
alphabet = list('abcdefghijklmnopqrstuvwxyz')
output = ['-1', '-1']
for i in range(len(alphabet)):
    pattern = alphabet[i] + '.?' + alphabet[i]
    match_object = re.search(r'%s.?%s' % (alphabet[i], alphabet[i]), text)
    if match_object:
        output[0] = str(match_object.start() + 1)
        output[1] = str(match_object.end())
        break

print(' '.join(output))

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

ans1,ans2 = -1,-1

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

    if s[i] == s[i+2]:
        ans1,ans2 = i+1,i+3
        break

print(ans1,ans2)

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()
n=len(s)
alp=[chr(i+ord('a')) for i in range(26)]
a=[[0]*n for _ in range(26)]
for i in alp:
  ans=-2
  for j in range(n):
    if s[j]==i:
      if ans<-1:
        ans=0
        l=j
      else:ans+=1
    else:ans-=1
    if ans>0 or (j>1 and s[j-2]==s[j]==i):
      print(l+1,j+1)
      exit()
print(-1,-1)

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

Solution (Python):
def abc043_d():
    s = str(input())
    n = len(s)
    ans = (-1, -1)
    if n == 2:
        if s[0] == s[1]:
            ans = (1, 2)
    else:
        for i in range(n-2):
            if len(set(s[i:i+3])) < 3:
                ans = (i+1, i+3)
                break
    print(*ans, sep=' ')

if __name__ == '__main__':
    abc043_d()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



s = input()

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 

from decimal import *



s = input()

dic = defaultdict(list)

for i, x in enumerate(s, 1):
	dic[x].append(i)

for lis in dic.values():
	for i in range(len(lis)-1):
		if lis[i+1] <= lis[i]+2:
			print(lis[i], lis[i+1])
			break
	else:
		continue
	break
else:
	print(-1, -1)

Solution (Python):
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

def check(n,l):
    s=0
    for i in range(len(l)):
        s+=(l[i]-n)*(l[i]-n)
    return s

def solve():
    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)
 

for _ in range(1):
    solve()

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

Solution (Python):
s = input()

if len(s) != 2:
    for i in range(len(s) - 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()

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


print(-1, -1)

Solution (Python):
def main():
    s = input()
    N = len(s)
    
    nums = [-1] * 26
    for i in range(N):
        x = ord(s[i]) - ord('a')
        if nums[x] == -1:
            nums[x] = i
        else:
            
            if i - nums[x] < 3:
                print(nums[x]+1, i+1)
                exit()
            else:
                nums[x] = i
    print(-1,-1) 

if __name__ == "__main__":
    main()

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

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


for i, (s1,s2,s3) in enumerate(zip(s[:-2], s[1:-1], s[2:])):
    same_cnt = 0
    if s1 == s2 or s2 == s3 or s3 == s1:
        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)
        exit()
for i in range(n-2):
    if s[i]==s[i+2]:
        print(i+1, i+3)
        exit()
print(-1, -1)