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

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

print ' '.join(map(str, solve(s)))

Solution (Python):
s = raw_input()
if len(s) == 2:
    if s[0] == s[1]:
        print '1 2'
    else:
        print '-1 -1'
else:
    for i in xrange(len(s) - 2):
        if s[i] == s[i+1] or s[i] == s[i+2] or s[i+1] == s[i+2]:
            print str(i + 1) + ' ' + str(i + 3)
            break
    else:
        print '-1 -1'

Solution (Python):

from collections import Counter
s = input()
flag = True
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        flag = False
        break
    elif i <= len(s)-3 and s[i] == s[i+2]:
        print(i+1, i+3)
        flag = False
        break
if flag:
    print("-1 -1")

Solution (Python):

import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

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

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

Solution (Python):

s=raw_input()
l=list(s)
f=False
for i in range(len(l)):
    try:
        if l[i]==l[i+1]:
            print i+1,i+2
            f=True
            break
        if l[i]==l[i+2]:
            print i+1,i+3
            f=True
            break
    except:
        pass
if f==False:
    print -1,-1

Solution (Python):
class nUnbalanced:
	def searchStrings(self,s):
		if len(s)==2:
			x_f=s[0]; x_s=s[1]
			if x_f==x_s: print 1,2; return
			else: print -1,-1; return
		for base in range(len(s)-2):
			x_f=s[base]; x_s=s[base+1]; x_t=s[base+2]
			if x_f==x_s or x_s==x_t or x_f==x_t: print base+1,base+3; return
		print -1,-1

if __name__ == "__main__":
	s=raw_input()
	u=nUnbalanced()
	u.searchStrings(s)

Solution (Python):
s = raw_input().strip()
n = len(s)

def find_two(s):
	for i in range(1, n):
		if s[i] == s[i-1]:
			return i-1, i
	return -1, -1

def find_three(s):
	n = len(s)
	if n <= 2:
		return -1, -1

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

ans_two = find_two(s)
if ans_two != (-1, -1):
	print '{0} {1}'.format(ans_two[0]+1, ans_two[1]+1)
else:
	ans_three = find_three(s)
	if ans_three != (-1, -1):
		print '{0} {1}'.format(ans_three[0]+1, ans_three[1]+1)
	else:
		print '{0} {1}'.format(-1, -1)

Solution (Python):
def checker(s):
  for i in range(1, len(s)):
    if s[i] == s[i-1]:
      print "%d %d" % (i, i+1)
      return
    if i > 1 and s[i] == s[i-2]:
      print "%d %d" % (i-1, i+1)
      return
  print "-1 -1"

s = raw_input()
checker(s)

Solution (Python):
s = raw_input()
if len(s) == 2:
    if s[0] == s[1]:
        print "1 2"
        exit()

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

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

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

print("-1 -1")

Solution (Python):
charseq = raw_input()
start = -1
end = -1

for i in range(len(charseq)-1):
    if charseq[i] == charseq[i+1]:
        start = i+1 
        end = i+2 
        break
if start == -1: 
    for i in range(len(charseq)-2):
        if charseq[i] == charseq[i+2]:
            start = i+1 
            end = i+3 
            break

print start, end

Solution (Python):
s = input()

length = len(s)

res = -1
for i in range(length - 1):
    subs = s[i:i+2]
    if len(set(subs)) < 2:
        res = i
        break

if res == -1:
    for i in range(length - 2):
        subs = s[i:i+3]
        if len(set(subs)) < 3:
            res = i
            break
    if res == -1:
        print('-1 -1')
    else:
        print('%d %d' % (res + 1, res + 3))
else:
    print('%d %d' % (res + 1, res + 2))

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

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 s[-2] == s[-1]:
		print(len(s)-1, len(s))
	else:
		print(-1, -1)

Solution (Python):
s = raw_input()
letters = [3]*26
done = False
for i in range(97,123):
    c = str(unichr(i))
    dist = -1
    for j in xrange(len(s)):
        if (dist >= 0):
            dist += 1
        if (c==s[j]):
            if (dist <= 2 and dist >= 0):
                done = True
                print str(j+1-dist) + " " + str(j+1)
                break
            dist = 0
    if done:
        break
if not done:
    print "-1 -1"

Solution (Python):
s=str(input())
L=len(s)
if L==1:
    print('-1 -1')
    exit()
elif L==2 and s[0]==s[1]:
    print('1 2')
    exit()
elif L==2 and s[0]!=s[1]:
    print('-1 -1')
    exit()
    


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

Solution (Python):


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

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

    return '-1 -1'

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

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

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

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

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

print (-1, -1)

Solution (Python):
s = input()

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

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

Solution (Python):
s = raw_input()
if len(s) == 1:
    print -1, -1
    exit()
if len(s) == 2:
    if s[0] == s[1]:
        print 1, 2
    else:
        print -1, -1
    exit()
for i in xrange(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):
from collections import defaultdict


S = input()
d = defaultdict(list)
for i, s in enumerate(S):
    d[s].append(i + 1)
ret = False
for v in d.values():
    for i in range(len(v) - 1):
        if v[i + 1] - v[i] <= 2:
            ret = True
            print(v[i], v[i + 1])
            break
    if ret:
        break
if not ret:
    print(-1, -1)

Solution (Python):
import sys


in_stg = list(raw_input())

for x in range(len(in_stg) - 1):
	cand1, cand2 = min(x+1, len(in_stg)-1), min(x+2, len(in_stg)-1)
	if (in_stg[x] == in_stg[cand1]):
		print str(x + 1) + ' ' + str(cand1 + 1)
		sys.exit()
	elif (in_stg[x] == in_stg[cand2]):
		print  str(x + 1) + ' ' + str(cand2 + 1)
		sys.exit()
	else:
		pass

print '-1 -1'

Solution (Python):


import sys

s=raw_input()

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

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

Solution (Python):
s = input()
size = len(s)
flag = False

if size == 2:
    if s[0] == s[1]:
        print('1 2')
        flag = True
    else:
        print('-1 -1')
else:
    for i in range(size-2):
        if s[i] == s[i+1]:
            print(i+1, i+2)
            flag = True
            break
        elif s[i] == s[i+2]:
            print(i+1, i+3)
            flag = True
            break
        else:
            continue
    if flag == False:
        print('-1 -1')

Solution (Python):
def main():
    s = input()
    if s[0] == s[1]:
        print(1, 2)
        return
    for i in range(len(s)-2):
        if len(set(s[i: i+3])) < 3:
            print(i+1, i+3)
            return
    print(-1, -1)
if __name__ == '__main__':
    main()

Solution (Python):
import sys
s = list(raw_input())
if len(s) == 2:
    if s[0] == s[1]:
        print 1, 2
    else:
        print -1, -1
else:
    for n in [3]:
        for i in xrange(len(s) - n + 1):
            sub = s[i:i+n]
            for char in set(sub):
                if sub.count(char) >= n / 2 + n % 2:
                    print i + 1, i + n
                    sys.exit()
    print -1, -1

Solution (Python):
import math,sys
s = list(raw_input())
n = len(s)
s = s+["A","A"]
for i in range(n):
    if s[i] == s[i+1]:
        print i+1,i+2
        sys.exit()
    if s[i] == s[i+2]:
        print i+1,i+3
        sys.exit()
print -1,-1

Solution (Python):
y=raw_input()
f=0
if len(y)==1:
    print -1,-1
elif len(y)==2:
    if y[0]==y[1]:
        print 1,2
    else:
        print -1,-1
else:
    for i in range(len(y)-2):
        if y[i]==y[i+1] or y[i+1]==y[i+2] or y[i+2]==y[i]:
            print i+1,i+3
            f=1
            break
    if f!=1:
        print -1,-1

Solution (Python):


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

Solution (Python):
def solve(s):
  if len(s) == 2: return (1, 2) if s[0] == s[1] else (-1, -1)
  for i in range(len(s) - 2):
    for j in range(3):
      a = i+j
      b = i+(j + 1)%3
      if s[a] == s[b]: return (min(a,b) + 1, max(a,b) + 1)
  return (-1, -1)
  
print(*solve(input()))

Solution (Python):
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=raw_input()
tmp=[s[0], s[1]]
chk=len(s)
if tmp[0]==tmp[1]:
    print 1,2
elif chk==3 and len(set(list(s)))<3:
    print 1,3
elif chk<4:
    print -1,-1
else:
    for i in range(2,chk):
        if len(tmp)==3:
            tmp.pop(0)
        tmp.append(s[i])
        if len(set(tmp))<3:
            print i-1,i+1
            exit()
    else:
        print -1,-1

Solution (Python):
import collections
b = False
s = raw_input()
for i in range(len(s)-1):
    if not b and s[i] == s[i+1]:
        print i+1, i+2
        b = True
if not b:
    for i in range(len(s)-2):
        if not b and s[i] == s[i+2]:
            print i+1, i+3
            b = True
if not b:
    print "-1 -1"

Solution (Python):
s = raw_input()
noflag = True
for i in xrange(len(s)-2):
    w = s[i:i+3]
    d = {}
    for x in w:
        d.setdefault(x, 0)
        d[x] += 1

    if max(d.items(), key = lambda x:x[1])[1] == 2:
        print i+1, i+3
        noflag = False
        break

for i in xrange(len(s)-1):
    if noflag and s[i:i+2] == s[i]+s[i]:
        print i+1, i+2
        noflag = False
        break
if noflag:
    print "-1 -1"

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

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

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

print -1, -1