Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n, k = map(int,input().split())
from math import factorial
ans = []
if n == k:
    ans.append(1)
else:
    for i in range(1, k+1):
        if i >= n-k+1:
            c = 1
        else:
            c = factorial(n-k+1) // (factorial(n-k+1 - i) * factorial(i))
        if i > k-i:
            c2 = int(factorial(i) / (factorial(i-(k-i)) * factorial(k-i)))
        else:
            c2 = 1
        if c > 0:
            ans.append(c*c2)

mod = 10**9 + 7
for j in ans:
    print(j%mod)

Fixed submission:
import math
def C(n,r):
  if n<0 or r<0 or n-r<0:
    return 0
  else:
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))
 
n,k=map(int,input().split())
for i in range(1,k+1):
  print(C(n-k+1,i)*C(k-1,i-1)%(10**9+7))

Buggy python submission (verdict: Runtime Error):
n, k = map(int,input().split())
from math import factorial
ans = []
if n == k:
    ans.append(1)
else:
    for i in range(1, k+1):
        c = int(factorial(n-k+1) / (factorial(n-k+1 - i) * factorial(i)))
        if i > k-i:
            c2 = int(factorial(i) / (factorial(i-(k-i)) * factorial(k-i)))
        else:
            c2 = 1
        if c > 0:
            ans.append(c*c2)

mod = 10**9 + 7
for j in ans:
    print(j%mod)

Fixed submission:
import math
def C(n,r):
  if n<0 or r<0 or n-r<0:
    return 0
  else:
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))
 
n,k=map(int,input().split())
for i in range(1,k+1):
  print(C(n-k+1,i)*C(k-1,i-1)%(10**9+7))

Buggy python submission (verdict: Runtime Error):
n, k = map(int,input().split())
from math import factorial
ans = []
for i in range(1, k+1):
    c = factorial(n-k+1) // (factorial(n-k+1 - i) * factorial(i))
    if i > k-i:
        c2 = factorial(i) // (factorial(i-(k-i)) * factorial(k-i))
    else:
        c2 = 1
    if c == 0:
        break
    ans.append(c*c2)

mod = 10**9 + 7
for j in ans:
    print(j%mod)

Fixed submission:
import math
def C(n,r):
  if n<0 or r<0 or n-r<0:
    return 0
  else:
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))
 
n,k=map(int,input().split())
for i in range(1,k+1):
  print(C(n-k+1,i)*C(k-1,i-1)%(10**9+7))

Buggy python submission (verdict: Runtime Error):
n, k = map(int,input().split())
from math import factorial
ans = []
for i in range(1, k+1):
    c = factorial(n-k+1) // (factorial(n-k+1 - i) * factorial(i))
    if c == 0:
        break
    ans.append(c)

mod = 10**9 + 7
for j in ans:
    print(j%mod)

Fixed submission:
import math
def C(n,r):
  if n<0 or r<0 or n-r<0:
    return 0
  else:
    return math.factorial(n)//(math.factorial(r)*math.factorial(n-r))
 
n,k=map(int,input().split())
for i in range(1,k+1):
  print(C(n-k+1,i)*C(k-1,i-1)%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a_l = [ int(input()) for _ in range(m) ]

dp = [0] * (n+1)
dp[0] = 1
if 1 not in a_l:
    dp[1] = 1
else:
    dp[1] = 0
if n > 1:
    if 2 not in a_l:
        dp[2] = dp[0] + dp[1]
    else:
        dp[2] = 0
    for i in range(2,n+1):
        if i not in a_l:
            dp[i] = (dp[i-1] + dp[i-2])%1000000007
        else:
            dp[i] = 0
print(dp[-1])

Fixed submission:
n, m = map(int, input().split())
a_l = [ int(input()) for _ in range(m) ]

dp = [1] * (n+1)
dp[0] = 1
if 1 not in a_l:
    dp[1] = 1
else:
    dp[1] = 0
if n > 1:
    for i in a_l:
        dp[i] = 0
    if 2 not in a_l:
        dp[2] = dp[0] + dp[1]
    else:
        dp[2] = 0
    for i in range(2,n+1):
        if dp[i] != 0:
            dp[i] = (dp[i-1] + dp[i-2])%1000000007
print(dp[-1])

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a_l = [ int(input()) for _ in range(m) ]

dp = [0] * (n+1)
dp[0] = 1
if 1 not in a_l:
    dp[1] = 1
else:
    dp[1] = 0
if 2 not in a_l:
    dp[2] = dp[0] + dp[1]
else:
    dp[2] = 0
for i in range(2,n+1):
    if i not in a_l:
        dp[i] = dp[i-1] + dp[i-2]
    else:
        dp[i] = 0
print(dp[-1]%1000000007)

Fixed submission:
n, m = map(int, input().split())
a_l = [ int(input()) for _ in range(m) ]

dp = [1] * (n+1)
dp[0] = 1
if 1 not in a_l:
    dp[1] = 1
else:
    dp[1] = 0
if n > 1:
    for i in a_l:
        dp[i] = 0
    if 2 not in a_l:
        dp[2] = dp[0] + dp[1]
    else:
        dp[2] = 0
    for i in range(2,n+1):
        if dp[i] != 0:
            dp[i] = (dp[i-1] + dp[i-2])%1000000007
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
l_r = [ list(map(int, input().split())) for _ in range(q) ]

for l,r in l_r:
    sub_s = s[l-1:r]
    print(len(sub_s.split('AC'))-1)

Fixed submission:
n, q = map(int, input().split())
s = input()
l_r = [ list(map(int, input().split())) for _ in range(q) ]

memo = [0] * (n+1)


for i in range(n):
    if s[i:i+2] == 'AC':
         memo[i+1] = memo[i] + 1
    else:
         memo[i+1] = memo[i]

for l,r in l_r:
    print(memo[r-1]-memo[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h_l = list(map(int, input().split()))

dp = [0] * n
for i in range(n-1):
    dp[i+1] = min(dp[i+1-j]+abs(h_l[i+1]-h_l[i+1-j]) for j in range(1, min(i+1,k)+1))
print(dp[-1])

Fixed submission:
n, k = map(int, input().split())
h_l = list(map(int, input().split()))

dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    from_jump = max(0,i-k)
    dp[i] = min(dp[j]+abs(h_l[i]-h_l[j]) for j in range(from_jump,i))
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
size = len(S)
ans = 0

while True:
    i = 0
    fg = False
    while i < size -1:
        if S[i] == 'B' and S[i+1] == 'W':
            ans += 1
            S[i] = 'W'
            S[i+1] = 'B'
            fg = True
        i += 1
    if fg == False:
        break
print(ans)

Fixed submission:
import sys
import math
S = list(input())
size = len(S)

B_size = sum([ 1 for i in S if i == 'B' ])
if B_size == 0:
    print(0)
    sys.exit()

B_size2 = sum([ i for i,j in enumerate(S) if j == 'B' ])
ans= sum(range(0, size)[-B_size:]) - B_size2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
size = len(S)
ans = 0

while True:
    i = 0
    fg = False
    while i < size -1:
        if S[i] == 'B' and S[i+1] == 'W':
            ans += 1
            S[i] = 'W'
            S[i+1] = 'B'
            fg = True
            break
        i += 1
    if fg == False:
        break
print(ans)

Fixed submission:
import sys
import math
S = list(input())
size = len(S)

B_size = sum([ 1 for i in S if i == 'B' ])
if B_size == 0:
    print(0)
    sys.exit()

B_size2 = sum([ i for i,j in enumerate(S) if j == 'B' ])
ans= sum(range(0, size)[-B_size:]) - B_size2
print(ans)
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
i = 0
min_cost = 1000
fg = False
while i < N:
    i += 1
    c, t = map(int, input().split())
    if t <= T:
        if c <= min_cost:
            fg = True
            min_cost = c

if fg:
    print(min_cost)
else:
    print('TLE')

Fixed submission:
N = int(input())
if N == 1:
    print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A + B)

Buggy python submission (verdict: Runtime Error):
N = input()
if N == 1:
    print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A + B)

Fixed submission:
N = int(input())
if N == 1:
    print('Hello World')
else:
    A = int(input())
    B = int(input())
    print(A + B)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def calc(n_list):
    return reduce(math.gcd, n_list)

N, X = map(int, input().split())
c = list(map(int, input().split()))
c = [ abs(x-X) for x in c ]

print(calc(c))

Fixed submission:
from functools import reduce

N, X = map(int, input().split())

def _calc(a,b):
    while b:
        a, b = b, a % b
    return a

def calc(n_list):
    return reduce(_calc, n_list)

c = list(map(int, input().split()))
c = [ abs(x-X) for x in c ]

print(calc(c))
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

if k == 1 or len(s) == 1:
    ans = list(s)[0]
else:
    for i, j in enumerate(list(s)):
        if j != '1' and i < k:
            ans = j
            break
        elif i >=k :
            ans = '1'
            break
        else:
            continue
print(ans)

Fixed submission:
s = input()
k = int(input())

if k == 1 or len(s) == 1:
    ans = list(s)[0]
else:
    ans = None
    for i, j in enumerate(list(s)):
        if i < k-1:
            if j != '1':
                ans = j
                break
        elif i == k-1:
            ans = j           
            break
        else:
            continue
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

if k == 1:
    ans = list(s)[0]
else:
    for i, j in enumerate(list(s)):
        if j != '1' and i < k:
            ans = j
            break
        elif i >=k :
            ans = '1'
            break
        else:
            continue
print(ans)

Fixed submission:
s = input()
k = int(input())

if k == 1 or len(s) == 1:
    ans = list(s)[0]
else:
    ans = None
    for i, j in enumerate(list(s)):
        if i < k-1:
            if j != '1':
                ans = j
                break
        elif i == k-1:
            ans = j           
            break
        else:
            continue
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
S = S.replace('W', '1')
S = S.replace('E', '0')
S = list(map(int, list(S)))
ans = min([ sum(S[:i]) + len(S[i+1:]) - sum(S[i+1:]) for i in range(N) ])
print(ans)

Fixed submission:
N = int(input())
S = input()

ans = S.count('E')
w = 0
e = S.count('E')
for i in range(N):
    if S[i-1] == 'W' and i != 0:
        w += 1
    if S[i] == 'E':
        e -= 1
    if w + e < ans:
        ans = w + e
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
ans = min([ S[:i].count('W') + S[i+1:].count('E')  for i in range(N) ])
print(ans)

Fixed submission:
N = int(input())
S = input()

ans = S.count('E')
w = 0
e = S.count('E')
for i in range(N):
    if S[i-1] == 'W' and i != 0:
        w += 1
    if S[i] == 'E':
        e -= 1
    if w + e < ans:
        ans = w + e
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
ans = []
for i in range(N):
    S_s = sum([ 1 for x in S[:i] if x == 'W' ])
    S_e = sum([ 1 for x in S[i+1:] if x == 'E']) 
    ans.append(S_s+S_e)
print(min(ans))

Fixed submission:
N = int(input())
S = input()

ans = S.count('E')
w = 0
e = S.count('E')
for i in range(N):
    if S[i-1] == 'W' and i != 0:
        w += 1
    if S[i] == 'E':
        e -= 1
    if w + e < ans:
        ans = w + e
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

ans = []
for i in range(N):
    count = 0
    for j in range(N):
        if i > j:
            if S[j] == 'W':
                count += 1
        elif i < j: 
            if S[j] == 'E':
                count +=1
        else:
            pass
    ans.append(count)
print(min(ans))

Fixed submission:
N = int(input())
S = input()

ans = S.count('E')
w = 0
e = S.count('E')
for i in range(N):
    if S[i-1] == 'W' and i != 0:
        w += 1
    if S[i] == 'E':
        e -= 1
    if w + e < ans:
        ans = w + e
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
ans = set()
r = len(s)
if r <= 50:
    for i in range(r):
        for j in range(r):
            ans.add(s[i:r-j])
    print(sorted(list(ans))[k])
else:
    print('Pass')

Fixed submission:
s = input()
k = int(input())
ans = set()
r = len(s)

if r == 1:
    print(s)
else:
    for i in range(r):
        for j in range(k):
            ans.add(s[i:i+j+1])
    print(sorted(list(ans))[k-1])

Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
ans = set()
r = len(s)
for i in range(r):
    for j in range(r):
        ans.add(s[i:r-j+1])
print(sorted(list(ans))[k])

Fixed submission:
s = input()
k = int(input())
ans = set()
r = len(s)

if r == 1:
    print(s)
else:
    for i in range(r):
        for j in range(k):
            ans.add(s[i:i+j+1])
    print(sorted(list(ans))[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())

sub_list = []
for i in range(0, len(s)):
    for j in range(1, len(s)-i+1):
        sub_list.append(s[i:j+i])
print(sorted(list(set(sub_list)))[k-1])

Fixed submission:
s = input()
k = int(input())
ans = set()
r = len(s)

if r == 1:
    print(s)
else:
    for i in range(r):
        for j in range(k):
            ans.add(s[i:i+j+1])
    print(sorted(list(ans))[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x_l = list(map(int,input().split()))
s_x_l = [ (i, j) for i,j in enumerate(x_l) ]
s_x_l = sorted(s_x_l, key=lambda x: x[1])
size = len(s_x_l)
med_idx = int((size-1+1)/2)-1

ans = []
for i in range(n):
    left = s_x_l[:i]
    right = s_x_l[i+1:]
    idx = s_x_l[i][0]
    merge = left+right
    med = merge[med_idx][1]
    ans.append([idx, med])

ans = sorted(ans, key=lambda x:x[0])
for i in ans:
    print(i[1])

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
idx = range(N)
Y = [ [ idx[i], X[i]] for i in range(N) ]
Z = sorted(Y , key=lambda x: x[1])
ans = []
for i,j in enumerate(Z):
    idx_tmp = Z[i][0]
    if i < int(N/2):
        median = Z[int(N/2)][1]
    else:
        median = Z[int(N/2)-1][1]
    ans.append([idx_tmp,median])
ans = sorted(ans, key=lambda x:x[0])
for i in ans:
    print(i[1])
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int,input().split())

for i in range(a, b+1):
    if  i <= a+k-1 or b+1-k <= i:
        print(i)

Fixed submission:
a, b, k = map(int,input().split())
if a+k+1 <= b:
    for i in range(a, k+a):
        print(i)
    if a+k+1 <= b+1-k:
        for i in range(b+1-k, b+1):
            print(i)
    else:
        for i in range(a+k, b+1):
            print(i)
else:
    for i in range(a, b+1):
        print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a_l = list(map(int, input().split()))
base = set(a_l)
num = len(base)-k
ans = []

if num <= 0:
    print(0)
else:
    for idx, v in enumerate(base):
        ans.append(a_l.count(v))
    print(sum(sorted(ans)[:num]))

Fixed submission:
n, k = map(int, input().split())
a_l = sorted(list(map(int, input().split())))
base = list(set(a_l))
num = len(base)-k
ans = []

if num <= 0:
    print(0)
else:
    c_idx = 1
    c_num = a_l[0]
    for idx, v in enumerate(a_l[1:]):
        if c_num == v:
            c_idx += 1
            continue
        else:
            ans.append(c_idx)
            c_idx = 1
            c_num = v
    ans.append(c_idx)

    print(sum(sorted(ans)[:num]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a_l = list(map(int, input().split()))
base = set(a_l)
num = len(base)-k
ans = []

if num <= 0:
    print(0)
else:
    for idx, v in enumerate(base):
        ans.append(a_l.count(v))
    print(sum(sorted(ans)[:num]))

Fixed submission:
n, k = map(int, input().split())
a_l = sorted(list(map(int, input().split())))
base = list(set(a_l))
num = len(base)-k
ans = []

if num <= 0:
    print(0)
else:
    c_idx = 1
    c_num = a_l[0]
    for idx, v in enumerate(a_l[1:]):
        if c_num == v:
            c_idx += 1
            continue
        else:
            ans.append(c_idx)
            c_idx = 1
            c_num = v
    ans.append(c_idx)

    print(sum(sorted(ans)[:num]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a_l = list(map(int, input().split()))
base = list(set(a_l))
num = len(base)-k
ans = [n] * len(base)

if num <= 0:
    print(0)
else:
    for idx, v in enumerate(base):
        ans[idx] = a_l.count(v)
    print(sum(sorted(ans)[:num]))

Fixed submission:
n, k = map(int, input().split())
a_l = sorted(list(map(int, input().split())))
base = list(set(a_l))
num = len(base)-k
ans = []

if num <= 0:
    print(0)
else:
    c_idx = 1
    c_num = a_l[0]
    for idx, v in enumerate(a_l[1:]):
        if c_num == v:
            c_idx += 1
            continue
        else:
            ans.append(c_idx)
            c_idx = 1
            c_num = v
    ans.append(c_idx)

    print(sum(sorted(ans)[:num]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
import math
print(int(math.sqrt(n))

Fixed submission:
n = int(input())
import math
print(int(math.sqrt(n))**2)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a > b:
    print('GREATER')
elif a < n:
    print('LESS')
else:
    print('EQUAL')

Fixed submission:
a = int(input())
b = int(input())
if a > b:
    print('GREATER')
elif a < b:
    print('LESS')
else:
    print('EQUAL')
Buggy python submission (verdict: Time Limit Exceeded):
a, b ,x = map(int, input().split())
ans = 0
for i in range(a, b+1):
    if i%x == 0:
        ans+=1
print(ans)

Fixed submission:
a, b ,x = map(int, input().split())
ans = 0
n_a = a//x
n_b = b//x
if a%x == 0:
    ans+=1
ans += n_b - n_a
print(ans)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
mat_a = [ list(input()) for _ in range(h) ]


ans = 'Possible'
ans = 'Impossible'

def check(i,j):
    if mat_a[i][j] == '.':
        return True

    count = 0
    try:
        if mat_a[i][j-1] == '#':
            count += 1
    except:
        pass

    try:
        if mat_a[i-1][j] == '#':
            count += 1
    except:
        pass

    try:
        if mat_a[i][j+1] == '#':
            count += 1
    except:
        pass

    try:
        if mat_a[i+1][j] == '#':
            count += 1
    except:
        pass

    if count == 2 or count ==4:
        return True
    else:
        return False    


ans = True
for i in range(h):
    for j in range(w):
        if not check(i,j):
            if i+1 == h and j+1 == w:
                continue
            if i == 0 and j == 0:
                continue
            ans = False
            break

if ans:
    print('Possible')
else:
    print('Impossible')
(env3) (kentaro:~/git/2020/atcode/20200717/3 2020-07-17T17:09:31)$ vi main.py 
(env3) (kentaro:~/git/2020/atcode/20200717/3 2020-07-17T17:10:52)$ cat main.py 
h, w = map(int, input().split())
mat_a = [ list(input()) for _ in range(h) ]

def check(i,j):
    if mat_a[i][j] == '.':
        return True

    count = 0
    try:
        if mat_a[i][j-1] == '#':
            count += 1
    except:
        pass

    try:
        if mat_a[i-1][j] == '#':
            count += 1
    except:
        pass

    try:
        if mat_a[i][j+1] == '#':
            count += 1
    except:
        pass

    try:
        if mat_a[i+1][j] == '#':
            count += 1
    except:
        pass

    if count == 2 or count == 4:
        return True
    else:
        return False    


ans = True
for i in range(h):
    for j in range(w):
        if not check(i,j):
            if i+1 == h and j+1 == w:
                continue
            if i == 0 and j == 0:
                continue
            ans = False
            break

if ans:
    print('Possible')
else:
    print('Impossible')

Fixed submission:
h, w = map(int, input().split())
mat_a = [ list(input()) for _ in range(h) ]

count = 0

ans = True
for i in range(h):
    for j in range(w):
        if mat_a[i][j] == '#':
            count+= 1

if count == h+w-1:
    print('Possible')
else:
    print('Impossible')
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
  
for i,c in enumerate(S):
    if len(S[i:]) > 3:
        subset = S[i:i+3]
        if subset[0] == subset[2] or subset[1] == subset[2]:
            print("%d %d" % (i+1, i+3))
            break
        continue
    elif len(S[i:]) == 2:
        subset = S[i:i+2]
        if subset[0] == subset[1]:
            print("%d %d" % (i+1, i+2))
            break
        continue
    else:
        print("-1 -1")
        break

Fixed submission:
import sys
S = list(input())
if len(S) == 2 and S[0] == S[1]:
    print("%d %d" % (1, 2))
    sys.exit()

for i in range(len(S) - 2):
    subset = S[i:i+3]
    if subset[0] == subset[2] or subset[1] == subset[2]:
        print("%d %d" % (i+1, i+3))    
        sys.exit()

print("-1 -1")

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())

for i,c in enumerate(S):
    if len(S[i:]) == 2:
        subset = S[i:i+2]
        if subset[0] == subset[1]:
            print("%d %d" % (i+1, i+2))
            break   
        continue    
        
    elif len(S[i:]) > 2:
        subset = S[i:i+3]
        if subset[0] == subset[2] or subset[1] == subset[2]:
            print("%d %d" % (i+1, i+3))    
            break
        continue   

    else:
        print("-1 -1")

Fixed submission:
import sys
S = list(input())
if len(S) == 2 and S[0] == S[1]:
    print("%d %d" % (1, 2))
    sys.exit()

for i in range(len(S) - 2):
    subset = S[i:i+3]
    if subset[0] == subset[2] or subset[1] == subset[2]:
        print("%d %d" % (i+1, i+3))    
        sys.exit()

print("-1 -1")

Buggy python submission (verdict: Runtime Error):
S = list(input())

for i,c in enumerate(S):
    if len(S[i:]) == 2:
        subset = S[i:i+1]
        if subset[0] == subset[1]:
            print("%d %d" % (i+1, i+2))
            break   
        continue    
        
    elif len(S[i:]) > 2:
        subset = S[i:i+3]
        if subset[0] in subset[1:] or subset[1] == subset[2]:
            print("%d %d" % (i+1, i+3))    
            break
        continue   

    else:
        print("-1 -1")

Fixed submission:
import sys
S = list(input())
if len(S) == 2 and S[0] == S[1]:
    print("%d %d" % (1, 2))
    sys.exit()

for i in range(len(S) - 2):
    subset = S[i:i+3]
    if subset[0] == subset[2] or subset[1] == subset[2]:
        print("%d %d" % (i+1, i+3))    
        sys.exit()

print("-1 -1")
Buggy python submission (verdict: Runtime Error):
#coding: utf-8
from collections import defaultdict

N, M = [int(x) for x in input().split()]

G = defaultdict(set)
for i in range(M):
    a, b = [int(x) - 1 for x in input().split()]
    G[a].add(b)
    G[b].add(a)

grp = [-1] * N

def dfs(node, color):
    if grp[node] != -1:
        return 
    grp[node] = color
    for n in G[node]:
        if grp[n] == -1:
            dfs(n, color)

for i in range(N):
    dfs(i, i)

n = defaultdict(int)
for i in range(N):
    n[grp[i]] += 1

ret = 0
for r in n:
    ret = max(ret, n[r])
print(ret)


Fixed submission:
#coding: utf-8
from collections import defaultdict, deque

N, M = [int(x) for x in input().split()]

G = defaultdict(set)
for i in range(M):
    a, b = [int(x) - 1 for x in input().split()]
    G[a].add(b)
    G[b].add(a)

grp = [-1] * N

for i in range(N):
    q = deque()
    q.append((i,i))

    while(len(q) != 0):
        node, color = q.popleft()
        if grp[node] != -1:
            continue
        grp[node] = color
        for n in G[node]:
            if grp[n] == -1:
                q.append((n, color))

n = defaultdict(int)
for i in range(N):
    n[grp[i]] += 1

ret = 0
for r in n:
    ret = max(ret, n[r])
print(ret)