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

import sys


def solve(s: str):
    N = len(s)
    
    for i in range(N-1):
        if(s[i] == s[i+1]):
            print(i+1, i+2)
            exit()
        else:
            if(i < N-2 and s[i] == s[i+2]):
                print(i+1, i+3)
                exit()
    
    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):
def main():
    s=input()
    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()
    if len(s)==2 and s[0]==s[1]:
        print(1,2)
        exit()
    print(-1,-1)
if __name__ == '__main__':
    main()

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

Solution (Python):
s = input()

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

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

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

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

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

        exit()
print(-1, -1)

Solution (Python):
s = list(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 d():
    s = input()

    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            print("{:g} {:g}".format(i+1, i+2))
            return

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

    print("-1 -1")

if __name__ == "__main__":
    d()

Solution (Python):

S = list(str(input()))
N = len(S)

ans = [-1,-1]
now = []
for i in range(N):
    if i == 0:
        now.append(S[0])
    elif i == 1:
        if now[0] == S[1]:
            ans[0] = 1
            ans[1] = 2
            break
        else:
            now.append(S[1])
    else:
        if S[i] in now:
            if now[0] == S[i]:
                ans[0] = i-1
            else:
                ans[0] = i
            ans[1] = i+1
            break
        else:
            del now[0]
            now.append(S[i])
            
print(*ans)

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

Solution (Python):
s = list(input())
ans = [-1, -1]

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

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

Solution (Python):
s=input()
a=-1
b=-1
from collections import defaultdict
count=defaultdict(lambda: [])
for i in range(len(s)):
    count[s[i]].append(i+1)
for i in count.keys():
    pla=count[i]
    for j in range(len(pla)-1):
        if pla[j+1]-pla[j]<=2:
            a=pla[j]
            b=pla[j+1]
print(a,b)

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

dic = {}
for i, s in enumerate(S):
    if not s in dic.keys():
        dic[s] = [i]
    else:
        dic[s].append(i)

ok = False
for v in dic.values():
    x = len(v)
    if x < 2:
        continue
    B = [None]*x
    for i in range(x):
        B[i] = v[i] - 2*i
    l = 0
    for r in range(1, x):
        if B[l] >= B[r]:
            ok = True
            L, R = v[l]+1, v[r]+1
            break
        else:
            l = r
    if ok:
        break

if not ok:
    print(-1, -1)
else:
    print(L, R)

Solution (Python):
s = input()
n = len(s)
s += "0"
def d():
    for i in range(n-1):
        if s[i] == s[i+1]:
            return str(i+1) + " " + str(i+2)
        elif s[i] == s[i+2]:
            return str(i+1) + " " + str(i+3)
    return "-1 -1"
print(d())

Solution (Python):
s = list(input())
len_str = len(s)
flag_check = 0
for start_i in range(len_str):
  if start_i < len_str - 1:
    if s[start_i] == s[start_i + 1]:
      flag_check = 1
      break
  if start_i < len_str - 2:
    if s[start_i] == s[start_i + 2]:
      flag_check = 2
      break
if flag_check == 0:
  print("-1 -1")
elif flag_check == 1:
  print("{} {}".format(start_i + 1, start_i + 2))
else:
  print("{} {}".format(start_i + 1, start_i + 3))

Solution (Python):
s = input()

flag = True
for i in range(len(s)):
    if i == 0:
        pass
    elif i == 1:
        if s[i] == s[i-1]:
            flag = False
            ans = str(i) + ' ' + str(i+1)
            break
    else:
        if s[i] == s[i-1]:
            flag = False
            ans = str(i) + ' ' + str(i+1)
            break
        elif s[i] == s[i-2]:
            flag = False
            ans = str(i-1) + ' ' + str(i+1)
            break

if flag:
    print('-1 -1')
else:
    print(ans)

Solution (Python):
s = input()

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

print(*ans)

Solution (Python):
S = input().strip()

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

Solution (Python):



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

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

    for j in range(n - 2):
        if len(set(list(s[j:j + 3]))) <= 2:
            print(j + 1, j + 3)
            exit()

    print(-1, -1)


if __name__ == '__main__':
    main()

Solution (Python):
S= input()
stack=0


if len(S)==2 and S[0]==S[1]:
  print("1 2")
  exit(0)

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

print("-1 -1")

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

Solution (Python):
S = list(input())
S.append("?")
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()

print("-1 -1")

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

print("-1 -1")

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

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

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

Solution (Python):
def main():
    s = list(input())
    s.append("0")
    s.append("0")

    now = s[0]
    for i in range(1,len(s)-2):
        if now == s[i]:
            print(i,end=" ")
            print(i+1)
            exit()
        elif now == s[i+1]:
            print(i, end=" ")
            print(i+2)
            exit()
        else:
            now = s[i]
    print(-1,end=" ")
    print(-1)
if __name__ == "__main__":
    main()

Solution (Python):
import collections

s = input()
n = len(s)

if n == 2:
    if s[0] == s[1]:
        print(1, 2)
    else:
        print(-1, -1)
else:
    for i in range(n - 2):
        if max(collections.Counter(s[i:i + 3]).values()) > 1:
            print(i + 1, i + 3)
            break
    else:
        print(-1, -1)

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

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

flag = True

res = -1

import sys

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

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

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

Solution (Python):
def main():

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

    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]:
            return i+1, i+3
    return -1, -1

if __name__ == '__main__':
    output = main()
    print(" ".join(map(str, output)))

Solution (Python):
s = input()

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

Solution (Python):
def main():
    s=input()
    a,b=-1,-1
    if len(s)==2:
        if s[0]==s[1]:
            a,b=1,2
    else:
        for i in range(len(s)-2):
            if s[i]==s[i+1] or s[i]==s[i+2]:
                a,b=i+1,i+3
                break
    print(a,b,sep=' ')

if __name__=='__main__':
    main()

Solution (Python):
def main():
    s=input()
    a,b=-1,-1
    if len(s)==2:
        if s[0]==s[1]:
            a,b=1,2
    else:
        for i in range(len(s)-2):
            if s[i]==s[i+1] or s[i]==s[i+2]:
                a,b=i+1,i+3
                break
    print(a,b,sep=' ')

if __name__=='__main__':
    main()

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

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

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

Solution (Python):
s = input()
a = -1
b = -1

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

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

Solution (Python):
s=input()
flag=0
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+2] and s[i]!=s[i+1]:
            print(str(i+1)+' '+str(i+3))
            flag=1
            break
        elif s[i]==s[i+1] and s[i]!=s[i+2]:
            print(str(i+1)+' '+str(i+3))
            flag=1
            break
        elif s[i+1]==s[i+2] and s[i+1]!=s[i]:
            print(str(i+1)+' '+str(i+3))
            flag=1
            break
    if flag==0:
        print('-1 -1')

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

Solution (Python):
def IsUnbalanced(S):
  
  if S[0]==S[1] or S[0]==S[2] or S[2]==S[1]:
    return True
  return False


f = True

s = input()
N = len(s)
if N == 2:
  if s[0]==s[1]:
    print("1 2")
  else:
    print("-1 -1")
else:
  for i in range(N-2):
    if IsUnbalanced(s[i:i+3]):
      f = False
      print(i+1, i+3)
      break
  if f:
    print("-1 -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 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()
L = len(S)

if L == 2:
    print('1 2' if S[0] == S[1] else '-1 -1')
else:
    result = False
    for i in range(L - 2):
        s = S[i:i + 3]
        if s[0] == s[1] or s[1] == s[2] or s[2] == s[0]:
            print(str(i + 1) + ' ' + str(i + 3))
            result = True
            break

    result or print('-1 -1')

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

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush, heapify
import math
import itertools
import random
 




 
INF = float('inf')
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    s = input()
    
    for i,vol in enumerate(s):
        if i == 0:
            continue
        if vol == s[i-1]:
            print("{} {}".format(i, i+1))
            sys.exit()
            
    for i,vol in enumerate(s):
        if i + 2 >= len(s):
            break
        if vol == s[i+2]:
            print("{} {}".format(i+1, i+3))
            sys.exit()
            
    print("-1 -1")
    
if __name__ == "__main__":
	main()

Solution (Python):
s=input()
n=len(s)
if n==2:
  if s[0]==s[1]:
    print('1 2')
  else:
    print('-1 -1')
else:
  for i in range(n-1):
    if s[i]==s[i+1]:
      print('{} {}'.format(i+1,i+2))
      exit()
  for j in range(n-2):
    if s[j]==s[j+2]:
      print('{} {}'.format(j+1,j+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):
import sys
from math import factorial, ceil, floor
from bisect import bisect_right as bsr
from operator import itemgetter as ig
from collections import defaultdict as dd
from collections import deque


args = None
INF = float("inf")
MOD = int(1e9 + 7)
def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]
def nlist(n, v):
    if not n: return v
    return [nlist(n[1:], v) for _ in range(n[0])]


def main():
    S = input(str)

    if len(S) == 2 and S[0] == S[1]:
        print("1 2")
        return
    for n in range(2, len(S)):
        if S[n - 2] == S[n - 1] or S[n - 2] == S[n] or S[n - 1] == S[n]:
            print(n - 1, n + 1)
            break
    else:
        print(-1, -1)
    return

if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

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

    if N == 2:
        if S[0] == S[1]:
            print(1, 2)
            return
        else:
            print(-1, -1)
            return

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

    print(-1, -1)
    return


sol()

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

Solution (Python):
def D_Unbalanced():
    from collections import Counter
    s = list(input())
    xx = []
    xyx = []
    ans = [-1, -1]
    if s[0] == s[1]:
        ans = [1, 2]
    for x in range(len(s)-2):
        if s[x] == s[x+1]:
            xx.append(s[x])
            ans = [x+1, x+2]
            break
        if s[x] == s[x+2]:
            xyx.append(s[x])
            ans = [x+1, x+3]
            break

    print(*ans)
    
if __name__ == "__main__":
    D_Unbalanced()

Solution (Python):
s = input()
answer_1 = answer_2 = -1

for i in range(len(s) - 1):
  if s[i] == s[i+1]:
    answer_1 = i + 1
    answer_2 = i + 2
    break
  
  elif i != len(s) - 2 and s[i] == s[i+2]:
    answer_1 = i + 1
    answer_2 = i + 3
    break

print(str(answer_1) + " " + str(answer_2))

Solution (Python):

s = input()

judge = 0
for i in range(len(s)):
	try:
		if s[i] == s[i + 1]:
			print("{0} {1}".format(i + 1, i + 2))
			judge = 1
		if s[i] == s[i + 2]:
			print("{0} {1}".format(i + 1, i + 3))
			judge = 1
	except:
		pass
	if judge == 1:
		exit()

print(-1, -1)

Solution (Python):
s = input()
s_start = -1
s_end = -1

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

Solution (Python):

import sys

def is_unbalanced(n, li_part):
    li_uniq = set(li_part)

    for c in li_uniq:
        if li_part.count(c) > n/2. :
            return 1

    return 0

li_c = list(input())
N = len(li_c)

for size_frame in range(2, 4):
    i = 0

    while(i + size_frame <= N):
        if(is_unbalanced(size_frame, li_c[i:i+size_frame]) == 1):
            print( i+1, i+1 + size_frame -1) 
            sys.exit()

        i = i + 1

print(-1, -1)

Solution (Python):
S = input()

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

Solution (Python):
a= input()
n = len(a)
if n>1:
    for i in range(n-1):
        if a[i]==a[i+1]:
            print(i+1,i+2)
            exit()
if n>2:
    check = [0 for _ in range(26)]
    check[ord(a[0])-ord('a')]+=1
    check[ord(a[1])-ord('a')] += 1
    check[ord(a[2]) - ord('a')] += 1
    if check[ord(a[2]) - ord('a')] >=2:
        print(1,3)
        exit()
    for i in range(3,n):
        check[ord(a[i-3]) - ord('a')] -= 1
        next = ord(a[i]) - ord('a')
        check[next] += 1
        if check[next]>=2:
            print(i-1,i+1)
            exit()
print(-1,-1)

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

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

s_strat = -1
s_end = -1
for i in range(len(s_list)):
    if i==len(s_list)-1:
        break
    elif i==len(s_list)-2:
        if s_list[i]==s_list[i+1]:
            s_strat = i+1
            s_end = i+2
            break
    elif s_list[i]==s_list[i+1]:
        s_strat = i+1
        s_end = i+2
        break
    elif s_list[i]==s_list[i+2]:
        s_strat = i+1
        s_end = i+3
        break
print(s_strat,s_end)

Solution (Python):
input_s = input()
lengthOfInputS =len(input_s)

listOfLower_abc = list( map(chr, range(97,97+26)) ) 





for lower_abc in listOfLower_abc:
	double_abc = lower_abc*2
	if double_abc in input_s:
		indexOfCh = input_s.index( double_abc )
		print( indexOfCh+1, indexOfCh+2 )
		exit()


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

print( "-1 -1" )

Solution (Python):
s=input()
n=len(s)
abc=list(map(chr,range(97,123)))

for x in abc:
    if x*2 in s:
        d=s.index(x*2)
        print(d+1,d+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
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
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)
        break
    if i < n-2:
        if s[i] != s[i+1] and s[i] == s[i+2]:
            print(i+1,i+3)
            break
else:
    print(-1,-1)

Solution (Python):
from collections import Counter
s=input()
l=len(s)-2
if l==0:
    if s[0]==s[1]:
        print(1,2)
    else:
        print(-1,-1)
else:
    for i in range(l):
        c=Counter(s[i:i+3]).values()
        if 2 in c or 3 in c:
            print(i+1,i+3)
            break
    else:
        print(-1,-1)

Solution (Python):

import sys
sys.setrecursionlimit(300000)


def solve(s: str):
    ret = (-1, -1)
    def is_unbalance(t):
        if t[0] == t[1] or t[0] == t[2] or t[1] == t[2]:
            return True
        return False
    for i in range(len(s) - 2):
        if is_unbalance(s[i:i + 3]):
            ret = (i + 1, i + 3)
            break
    if len(s) == 2 and s[0] == s[1]:
        ret = (1, 2)
    print(ret[0], ret[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):
def main():
    s = str(input())
    sLen = len(s)
    for i in range(sLen - 2):
        if s[i] == s[i + 1]:
            print(i + 1, i + 2)
            return
        elif s[i] == s[i + 2]:
            print(i + 1, i + 3)
            return
    if s[sLen - 2] == s[sLen - 1]:
        print(sLen - 1, sLen)
        return

    print("-1 -1")


if __name__ == "__main__":
    main()

Solution (Python):

from collections import Counter
import sys


def main():
    data = list(input())
    

    for haba in range(2, 6):
        for i in range(len(data) - haba + 1):
            now_list = data[i:i+haba]
            count_list = Counter(now_list).values()
            if max(count_list) > haba // 2:
                print(i + 1, i + haba)
                sys.exit()

    print(-1, -1)


if __name__ == '__main__':
    main()

Solution (Python):
def find(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)
find(input())

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

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

Solution (Python):
S = input()
counters = []
for i in range(0, 26):
	counters.append(0)
ans = '-1 -1'
for i in range(0, len(S)-2):
	lst = [S[i], S[i+1], S[i+2]]
	lst.sort()
	if lst[0] == lst[1] or lst[1] == lst[2]:
		ans = str(i+1) + ' ' + str(i+3)
		break
if len(S) == 2:
	if S[0] == S[1]:
		ans = '1 2'
print(ans)

Solution (Python):
s = str(input())
a = ['a', 'b', 'c', 'd', 'e','f','g','h','i','j','k','l','m','n',
     'o','p','q','r','s','t','u','v','w','x','y','z']
I = -2
J = -2
for letter in a:
  if s[-1] == letter and s[-2] == letter:
    I = len(s)-2
    J = len(s)-1
    break
  for i in range(0, len(s)-2):
    if s[i] == letter and s[i+1] == letter:
      I = i
      J = i + 1
      break
    elif s[i] == letter and s[i+2] == letter:
      I = i
      J = i + 2
      break
print(I + 1, J + 1)

Solution (Python):
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations

from itertools import accumulate
from bisect import bisect_left, bisect_right

import re




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


dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e18)
MOD = int(1e9)+7 



s = input()

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

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

print(-1,-1)

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


len_s = len(s)
start = -1
end = -1
for i in range(len_s):
    i_1 = i + 1
    i_2 = i + 2
    if i_1 < len_s:
        if s[i] == s[i_1]:
            start = i + 1
            end = i_1 + 1
            break
    if i_2 < len_s:
        if s[i] == s[i_2]:
            start = i + 1
            end = i_2 + 1
            break

print(start, end)

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 sz in range(3, 4, 2):
    if sz > len(s):
        break
    for i in range(len(s) - sz + 1):
        curr = s[i:i + sz]
        for it in curr:
            if curr.count(it) > sz // 2:
                print(i + 1, i + sz)
                exit(0)
print("-1 -1")

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

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

Solution (Python):
s = input()
se = s[::2]
so = s[1::2]
ans = "-1 -1"
for i in range(len(s)-1) :
    if s[i] == s[i+1] :
        ans = str(i+1)+" "+str(i+2)
for i in range(len(se)-1) :
    if se[i] == se[i+1] :
        ans = str(2*i+1)+" "+str(2*i+3)
for i in range(len(so)-1) :
    if so[i] == so[i+1] :
        ans = str(2*i+2)+" "+str(2*i+4)
print(ans)

Solution (Python):



s = input()
if len(s) == 2 and s[0]==s[1]: print(1,2); exit()
for n,(i,j,k) in enumerate(zip(s,s[1:],s[2:])):
    if i==j or j==k or k==i:
        print(n+1,n+3)
        break
else: print(-1,-1)

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S = sys.stdin.readline().rstrip()
S = np.array(list(S))

ans = None
for c in string.ascii_lowercase:
    cnt = 0
    start = None
    for i, s in enumerate(S):
        if s == c:
            cnt += 1
            if start is not None:
                ans = start + 1, i + 1
                break
            start = i
        else:
            cnt -= 1
            if cnt < 0:
                start = None
                cnt = 0
    if ans:
        break
if ans:
    print(*ans)
else:
    print(-1, -1)

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

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

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