Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)
nox_S = S.replace('x','')
if nox_S == nox_S[::-1]:
  si, ei = 0, N-1
  ans = 0
  while si <= ei:
    cnt1 = 0
    for i in range(si,N):
      if S[i] == 'x':cnt1 += 1
      else:
        si = i+1
        break
    
    cnt2 = 0
    for i in range(ei,-1,-1):
      if S[i] == 'x':cnt2 += 1
      else:
        ei = i-1
        break
    ans += abs(cnt1-cnt2)
  print(ans)
else:
  print(-1)
  


Fixed submission:
S = input()
N = len(S)
si, ei = 0, N-1
cnt = 0
while si<ei:
  if S[si] != S[ei]:
    if S[si] == 'x':
      si += 1
      cnt+=1
    elif S[ei] == 'x':
      ei -= 1
      cnt+=1
    else:
      print(-1)
      exit()
  else:
    si += 1
    ei -= 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)
nox_S = S.replace('x','')
if nox_S == nox_S[::-1]:
  si, ei = 0, -1
  ans = 0
  while si <= N+ei:
    if (S[si] == 'x' and S[ei] != 'x'):
      ans += 1
      si += 1
      ei -= 1
      N += 1
      S = S + 'x'
    elif (S[si] != 'x' and S[ei] == 'x'):
      ans += 1
      si += 1
      ei -= 1
      N += 1
      S = 'x' + S
    else:
      si += 1
      ei -= 1
  print(ans)
else:
  print(-1)
  


Fixed submission:
S = input()
N = len(S)
si, ei = 0, N-1
cnt = 0
while si<ei:
  if S[si] != S[ei]:
    if S[si] == 'x':
      si += 1
      cnt+=1
    elif S[ei] == 'x':
      ei -= 1
      cnt+=1
    else:
      print(-1)
      exit()
  else:
    si += 1
    ei -= 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
inf = float('inf')

def solve(graph, n, start_node, end_node):
  if start_node == end_node:
    return 0

  global costs_dict
  key = str(start_node) + '-' + str(end_node)
  if key in costs_dict:
    return costs_dict[key][end_node]

  costs = [inf for _ in range(n)]
  costs[start_node] = 0
  flgs = [False for _ in range(n)]

  while not all(flgs):
    prv_node = _get_min_idx(flgs,costs)
    flgs[prv_node] = True

    for node, dis in graph[prv_node]:
      if costs[node] > costs[prv_node] + dis:
        costs[node] = costs[prv_node] + dis
  costs_dict[key] = costs  
  return costs[end_node]
    
    
def _get_min_idx(flgs, costs):
    min_cost = inf
    min_idx = None
    cnt = 0
    for cost, flg in zip(costs, flgs):
      if min_cost > cost and flg is False:
        min_cost = cost
        min_idx = cnt
      cnt += 1
    return min_idx
        

n =int(input())
graph = defaultdict(list)
costs_dict = {}

for _ in range(n-1):
  a,b,c = map(int, input().split())
  graph[a-1].append([b-1,c])
  graph[b-1].append([a-1,c])

q, k = map(int, input().split())
k -= 1
for _ in range(q):
  x, y = map(int, input().split())
  print( solve(graph, n, x-1, k) + solve(graph, n, k, y-1))

Fixed submission:
N = input()
print('Yes' if N == ''.join([n for n in N[::-1]]) else 'No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0 for _ in range(9)]
for a in map(int,input().split()):
  A[a//400]+=1
rate_num = 8-A[:-1].count(0)
print(rate_num, min(8,rate_num+A[-1]))

Fixed submission:
N = int(input())
A = [0 for _ in range(9)]
for a in map(int,input().split()):
  A[min(a//400,8)]+=1
rate_num = 8-A[:-1].count(0)
print(max(1,rate_num), rate_num+A[-1])
Buggy python submission (verdict: Time Limit Exceeded):
def is_rect_in_HW(H, W, s1, s2, mem):
  s2_factors = factorize(s2, H, W, mem)
  
  res = []
  for  s2_factor in s2_factors:
    if s1[0] == s2_factor[0]: res.append([s1[0], s1_factor[1] + s1[1]])
    elif s1[0] != s1[1] and s1[1] == s2_factor[1]: res.append([s1[0] + s2_factor[0], s1[1]])
  return res

def factorize(num, H, W, mem):
  if num in mem:
    return mem[num]

  factors = set([])
  for i in range(1, min(num+1, max(H+1,W+1))):
    i2 = num//i
    if min(i,i2) > min(H,W) or max(i,i2) > max(H,W): continue
    if num % i == 0: factors.add(tuple(sorted([i,i2])))
  mem[num] = factors
  return factors


H, W = map(int, input().split())
S = int(H*W)
mem = {}
for del_s in range(S-2):
  for s1 in range(1,S-1):
    s3 = s1 + del_s
    s2 = S - s1 - s3
    if not (s1 <= s2 and s2<= s3): continue
    
    for s1_factor in factorize(s1, H, W, mem):
      res = is_rect_in_HW(H, W, s1_factor, s2, mem)
      if len(res) == 0: continue
      for tmp_s in res:
        res = is_rect_in_HW(H, W, sorted(tmp_s), s3, mem)
        #print(del_s, tmp_s, s1, s2, s3, res)
        if len(res) == 0: continue
        else:
          print(del_s)
          exit()

Fixed submission:
from math import floor, ceil

H,W = map(int,input().split())
ans = float('inf')

if H%3==0 or W%3==0:
  print(0)
  exit()

for x in range(1,H):
  S = [W*x, (H-x)*floor(W/2), (H-x)*ceil(W/2)]
  ans = min(ans, max(S)-min(S))

for x in range(1,W):
  S = [H*x, (W-x)*floor(H/2), (W-x)*ceil(H/2)]
  ans = min(ans, max(S)-min(S))

print(min(ans,H,W))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N,K=map(int,input().split())
nums = []
for _ in range(N):
  a,b = map(int,sys.stdin.readline().split())
  nums += [a for _ in range(b)]
nums.sort()
print(nums[K-1])

Fixed submission:
import sys
N,K=map(int,input().split())
nums = {}
for _ in range(N):
  a,b = map(int,sys.stdin.readline().split())
  if a in nums:
    nums[a] += b
  else:
    nums[a] = b

cnt = 0
for key in sorted(nums.keys()):
  cnt += nums[key]
  if cnt >= K:
    print(key)
    exit()
Buggy python submission (verdict: Runtime Error):
N,W = map(int,input().split())
w1,v1 = map(int,input().split())
items = {w: [] for w in range(w1,w1+3)}
items[w1].append(v1)
for _ in range(N-1):
  w,v = map(int,input().split())
  items[w].append(v)

lens = {}
for key in sorted(items.keys()):
  items[key].sort(reverse=True)
  lens[key] = len(items[key])

ans = -float('inf')
for i1 in range(lens[w1]+1):
  for i2 in range(lens[w1+1]+1):
    if W-i1*w1-i2*(w1+1) < 0: continue
    i3 = (W-i1*w1-i2*(w1+1))//(w1+2)
    ans = max(ans, sum(items[w1][:i1])+sum(items[w1+1][:i2])+sum(items[w1+2][:i3]))
print(ans)

Fixed submission:
N,W = map(int,input().split())
w1,v1 = map(int,input().split())
items = {w: [] for w in range(w1,w1+4)}
items[w1].append(v1)

if N==1:
  print(v1)
  exit()

for _ in range(N-1):
  w,v = map(int,input().split())
  items[w].append(v)

lens = {}
for key in sorted(items.keys()):
  items[key].sort(reverse=True)
  lens[key] = len(items[key])

ans = -float('inf')
for i1 in range(lens[w1]+1):
  for i2 in range(lens[w1+1]+1):
    for i3 in range(lens[w1+2]+1):
      if W-i1*w1-i2*(w1+1)-i3*(w1+2) < 0: continue
      i4 = (W-i1*w1-i2*(w1+1)-i3*(w1+2))//(w1+3)
      ans = max(ans, sum(items[w1][:i1])+sum(items[w1+1][:i2])+sum(items[w1+2][:i3])+sum(items[w1+3][:i4]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
prv_total =0
cnt = 0
for i in range(n-1):
  total = prv_total + a[i]
  nxt_total = total+a[i+1]
  while total*nxt_total >= 0:
    if total == nxt_total:
      if total > 0:
        a[i+1] -= 1
        nxt_total -=1
      else:
        a[i+1] += 1
        nxt_total +=1        
    elif total-nxt_total == 1:
      a[i+1] -= 1
      nxt_total -=1
    elif nxt_total-total == 1:
      a[i+1] += 1
      nxt_total += 1
    elif (total<nxt_total and total >= 0) or (nxt_total<total and nxt_total >= 0):
      total -= 1
      nxt_total -= 1
    elif (total<nxt_total and nxt_total <= 0) or (nxt_total<total and total <= 0):
      total += 1
      nxt_total += 1
    cnt += 1
  prv_total = total

total = prv_total + a[-1]
if total == 0:
  cnt += 1
  
print(cnt)

Fixed submission:
from itertools import accumulate
import copy

def sol(acmA, sign=1):    
  add = 0
  ans = 0
  if sign==1:
    if acmA[0] <= 0:
      add = -acmA[0]+1
      ans = abs(-acmA[0]+1)
      acmA[0] = 1
  else:  
    if acmA[0] >= 0:
      add = -acmA[0]-1
      ans = abs(-acmA[0]-1)
      acmA[0] = -1      
      
  for i in range(1,N):
    acmA[i] += add
    tmp_add = 0
    if sign == 1:
      if i%2==0:
        if acmA[i] <=0:
          tmp_add = -acmA[i]+1
      else:
        if acmA[i] >=0:
          tmp_add = -acmA[i]-1
    else:
      if i%2==1:
        if acmA[i] <=0:
          tmp_add = -acmA[i]+1
      else:
        if acmA[i] >=0:
          tmp_add = -acmA[i]-1     
   
    #print(i, tmp_add, acmA[i])
    acmA[i] += tmp_add
    add +=  tmp_add
    ans +=abs(tmp_add)
  if acmA[-1] == 0: return ans +1
  else: return ans

N = int(input())
A = list(map(int,input().split()))
acmA = list(accumulate(A))
acmA2 = copy.deepcopy(acmA)
print(min(sol(acmA, 1), sol(acmA2, -1)))
Buggy python submission (verdict: Time Limit Exceeded):
def F(a,b):
  return max(len(str(a)), len(str(b)))

N = int(input())
ans = float('inf')
for a in range(1,N+1):
  if N % a != 0: continue
  ans = min(ans,F(a,int(N/a)))
print(ans)

Fixed submission:
def sol(n):
  ans = float('inf')
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      ans = min(ans, max(len(str(i)),len(str(n//i))))
            
  return ans

print(sol(int(input())))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
MOD_NUM = 10**9 + 7
ans = 1
for i in range(1,N+1):
  ans *= i
print(ans%MOD_NUM)

Fixed submission:
import math
print(math.factorial(int(input()))%(10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
ans = 0
for i in range(0,M+1,2):
  ans = max(ans, min((M-i)//2,N+i//2))
print(ans)

Fixed submission:
N,M = map(int,input().split())

if 2*N >= M:
  print(M//2)
  exit()
else:
  cnum = M-2*N
  print(N+cnum//4)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
def factorial(N): return reduce(lambda x,y: x*y, [i for i in range(1,N+1)])

def is_prime(N):
  if N == 1: return False
  for i in range(2,int(N**0.5)+1):
    if N%i == 0: return False
  return True

def trial_division(N, factors):
  val = N
  cnt = 0
  
  if is_prime(N) is True:
    i = N
    if i not in factors: factors[i] = 1
    else: factors[i] += 1
  else:
    for i in range(2,N):
      while val % i == 0:
        val //= i
        if i not in factors: factors[i] = 1
        else: factors[i] += 1
        cnt += 1

      if cnt == 0:
        if i not in factors: factors[i] = 1
        else: factors[i] += 1


N = int(input())
factors = {}

for i in range(2,N+1):
  trial_division(i,factors)
print(reduce(lambda x,y: x*y,[factor+1 for factor in factors.values()])%(10**9+7))

Fixed submission:
from math import factorial
from functools import reduce
from operator import mul

N = factorial(int(input()))
if N == 1:
  print(1)
  exit()

M = 10**9 + 7
ans = 1

div = 2
while N != 1:
  cnt = 0
  while N%div == 0:
    N //= div
    cnt += 1
  if cnt != 0:
    ans *= (cnt+1)
    ans = ans%M
  div += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int,input().split())
ans = 0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if int(i + j + k) == S: ans += 1
print(ans)

Fixed submission:
K, S = map(int,input().split())
ans = 0
for x in range(K+1):
  for y in range(K+1):
    z = S - x - y
    if 0 <= z and z <= K: ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict, deque

def solve(graph, edges, n, start_idx):
  flg = [False for _ in range(n)] #未検索のノードはFlase
  flg[start_idx] = True
  
  cost = [float('inf') for _ in range(n)]
  cost[start_idx] = 0
  
  prv_edges = [None for _ in range(n)]
  
  prv_node = start_idx  
  while not all(flg):
    for node, dis in graph[prv_node]:
      if cost[node] > dis:
        cost[node] = dis
        
        tmp_edge = sorted([prv_node, node])
        if tmp_edge in edges:
          edges.remove(tmp_edge)
        if prv_edges[node] is not None and prv_edges[node] not in edges:
          edges.append(prv_edges[node])
        prv_edges[node] = tmp_edge
    
    min_cost = float('inf')
    tmp_idx = -1
    for i in range(n):
      if flg[i] is False and min_cost > cost[i]:
        min_cost = cost[i]
        tmp_idx = i
    prv_node = tmp_idx
    flg[prv_node] = True
    #print(start_idx, prv_node, cost, edges, prv_edges)
  return edges

n, m = map(int, input().split())
graph = defaultdict(list)
edges = []

for i in range(m):
  a,b,c = map(int, input().split())
  graph[a-1].append([b-1,c])
  graph[b-1].append([c-1,c])
  edges.append(sorted([a-1,b-1]))

for i in range(n):
  edges = solve(graph, edges, n, i)
print(len(edges))

Fixed submission:
INF = float('inf')

def dijkstra(s,N,M,cost,ans):
  d = [INF] * N
  used = [False] * N
  d[s] = 0
  prvv = [[] for _ in range(N)]
  while True:
    v = -1
    for i in range(N):
      if (not used[i]) and (v == -1): v = i
      elif (not used[i] and d[i] < d[v]): v = i
    if v == -1: break
    used[v] = True
  
    for j in range(N):
      if d[j] > d[v]+cost[v][j]:
        d[j] = d[v]+cost[v][j]
        prvv[j] = [v]
      elif d[j] == d[v]+cost[v][j]:
        d[j] = d[v]+cost[v][j]
        prvv[j].append(v)
  
  for i, vs in enumerate(prvv):
    for v in vs:
      ans.add(tuple(sorted([v,i])))

  return prvv

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

cost = [[INF for _ in range(N)] for _ in range(N)]
for i in range(M):
  a,b,c = map(int,input().split())
  cost[a-1][b-1] = c
  cost[b-1][a-1] = c


ans =set([])
for i in range(N):
  dijkstra(i,N,M,cost,ans)
print(M-len(ans))
#print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

sys.setrecursionlimit(10 ** 5)
def dfs(si, t):
    for subs in ['dream', 'dreamer', 'erase', 'eraser']:
        if si + len(subs) <= N and S[si:si + len(subs)] == subs:
            if si + len(subs) == N:
                print('YES')
                exit()
            else:
                dfs(si + len(subs), t + subs)


S = input()
N = len(S)
dfs(0, '')
print('NO')


Fixed submission:
S = input()
lenS = len(S)

i=0
while i < lenS:
  if S[i:i+5] =='dream':
    i+=5
    if S[i:i+2] == 'er' and S[i:i+5] != 'erase':i+=2
  elif S[i:i+6] == 'eraser': i+=6
  elif S[i:i+5] == 'erase': i+=5
  else:
    print('NO')
    exit()
print('YES')

Buggy python submission (verdict: Runtime Error):
def dfs(si, t):
    for subs in ['dream', 'dreamer', 'erase', 'eraser']:
        if si + len(subs) <= N and S[si:si + len(subs)] == subs:
            if si + len(subs) == N:
                print('Yes')
                exit()
            else:
                dfs(si + len(subs), t + subs)


S = input()
N = len(S)
dfs(0, '')
print('No')


Fixed submission:
S = input()
lenS = len(S)

i=0
while i < lenS:
  if S[i:i+5] =='dream':
    i+=5
    if S[i:i+2] == 'er' and S[i:i+5] != 'erase':i+=2
  elif S[i:i+6] == 'eraser': i+=6
  elif S[i:i+5] == 'erase': i+=5
  else:
    print('NO')
    exit()
print('YES')
Buggy python submission (verdict: Runtime Error):
ans = 0
S = input()
for i in range(1,len(S)): if S[i-1] != S[i]: ans += 1
print(ans) 

Fixed submission:
ans = 0
S = input()
for i in range(1,len(S)):
  if S[i-1] != S[i]: ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil

N = int(input())
prv_t, prv_a = map(int,input().split())
ans = prv_t + prv_a
for _ in range(N-1):
  t,a = map(int,input().split())
  
  x = ceil(ans/(t+a))
  while prv_t > t*x or prv_a > a*x:
    x+=1
  ans = (t+a)*x
  prv_t, prv_a = t*x, a*x
print(ans)

Fixed submission:
from math import ceil

N = int(input())
prv_t, prv_a = 1, 1
for _ in range(N):
  t,a = map(int,input().split())
  x = max(-(-prv_t//t), -(-prv_a//a))
  prv_t, prv_a = t*x, a*x
print(prv_t+prv_a)
Buggy python submission (verdict: Runtime Error):
def sol():
  ti = 0
  ans = lenX
  for i in range(lenX//2):
    while S[i]>=T[ti]:
      ti += 1
      if ti>=lenX//2:
        return ans
    ans -= 2    
    ti += 1
  return ans

X = input()
lenX = len(X)
S = []
T = []
for i,x in enumerate(X):
  if x == 'S':S.append(i)
  else:T.append(i)

print(sol())

Fixed submission:
def sol():
  ti = 0
  ans = lenX
  for i in range(lenX//2):
    while S[i]>=T[ti]:
      ti += 1
      if ti>=lenX//2:return ans
    ans -= 2    
    ti += 1
    if ti>=lenX//2:return ans
  return ans

X = input()
lenX = len(X)
S = []
T = []
for i,x in enumerate(X):
  if x == 'S':S.append(i)
  else:T.append(i)

print(sol())

Buggy python submission (verdict: Time Limit Exceeded):
X = input()
lenX = len(X)
si = 0
ei = 0
ans = lenX
for _ in range(lenX//2):
  try:
    si = X[si:].index('S') + si
    ei = X[max(si,ei):].index('T') + max(si,ei)
    if si<ei:ans-=2
    si += 1
    ei += 1
  except:
    break
print(ans)

Fixed submission:
def sol():
  ti = 0
  ans = lenX
  for i in range(lenX//2):
    while S[i]>=T[ti]:
      ti += 1
      if ti>=lenX//2:return ans
    ans -= 2    
    ti += 1
    if ti>=lenX//2:return ans
  return ans

X = input()
lenX = len(X)
S = []
T = []
for i,x in enumerate(X):
  if x == 'S':S.append(i)
  else:T.append(i)

print(sol())
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
alp = 'abcdefghijklmnopqrstuvwxyz'
alp_dict = {s:i for i, s in enumerate('abcdefghijklmnopqrstuvwxyz')}
N = len(alp)
S = input()
K = int(input())
ans = ''
for s in S:
  i = alp_dict[s]
  if K>=N-i:
    ans += 'a'
    K -= N-i
  else:
    ans += s
if K == 0:
  print(ans)
else:
  K = K%N
  last_s = alp[(alp_dict[ans[-1]]+K)%N]
  print(ans[:-1] + last_s)


Fixed submission:
S = input()
K = int(input())
alp = '0bcdefghijklmnopqrstuvwxyza'
alp_dict = {s:i for i,s in enumerate(alp)}


cnt = 0
ans = ''
for i,s in enumerate(S):
  if cnt + (26-alp_dict[s]) <= K:
    cnt += (26-alp_dict[s])
    ans += 'a'
  else:
    ans += s

if (K-cnt)%26==0:
  print(ans)
else:
  rest = (K-cnt)%26
  print(ans[:-1]+alp[(alp_dict[ans[-1]]+rest)%26])

Buggy python submission (verdict: Runtime Error):
import bisect

alp = {s:i for i, s in enumerate('abcdefghijklmnopqrstuvwxyz')}
N = len(alp)
S = input()
K = int(input())
ans = ''
for s in S:
  i = alp[s]
  if K>=N-i:
    ans += 'a'
    K -= N-i
  else:
    ans += s
if K == 0:
  print(ans)
else:
  K = K%N
  last_s = alp[(S.find(ans[-1])+K)%N]
  print(ans[:-1] + last_s)


Fixed submission:
S = input()
K = int(input())
alp = '0bcdefghijklmnopqrstuvwxyza'
alp_dict = {s:i for i,s in enumerate(alp)}


cnt = 0
ans = ''
for i,s in enumerate(S):
  if cnt + (26-alp_dict[s]) <= K:
    cnt += (26-alp_dict[s])
    ans += 'a'
  else:
    ans += s

if (K-cnt)%26==0:
  print(ans)
else:
  rest = (K-cnt)%26
  print(ans[:-1]+alp[(alp_dict[ans[-1]]+rest)%26])
Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S)
ans = 0
for i in range(2 ** (N - 1)):
    signs = bin(i)[2:].zfill(N - 1).replace('0', '+').replace('1', ' ')

    tmp_s = S[0]
    for j, sign in enumerate(signs):
        tmp_s += sign + S[j + 1]

    ans += eval(tmp_s.replace(' ', ''))

print(ans)


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

if N == 1:
    print(S)
    exit()

ans = 0
for i in range(2 ** (N - 1)):
    signs = bin(i)[2:].zfill(N - 1).replace('0', '+').replace('1', ' ')

    tmp_s = S[0]
    for j, sign in enumerate(signs):
        tmp_s += sign + S[j + 1]

    ans += eval(tmp_s.replace(' ', ''))

print(ans)
Buggy python submission (verdict: Runtime Error):
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 set(S[i:i+3])>=3:
    print(i+1, i+4)
    exit()
  
print(-1, -1)
  

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

Buggy python submission (verdict: Runtime Error):
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 range(len(S)-2):
  if set(S[i:i+3])>=3:
    print(i+1, i+4)
    exit()
  
print(-1, -1)
  

Fixed submission:
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)
Buggy python submission (verdict: Runtime Error):
alpha = input()
if alpha.isupper():
  output = A
else:
  output = a

print(output)


Fixed submission:
alpha = input()
if alpha.isupper():
  output = 'A'
else:
  output = 'a'

print(output)

Buggy python submission (verdict: Runtime Error):
alpha = input()
if alpha.isupper():
  output = A
else:
  ourput = a

print(output)


Fixed submission:
alpha = input()
if alpha.isupper():
  output = 'A'
else:
  output = 'a'

print(output)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

dic = {a+1:0 for a in range(10**5)}
for a in A:
  dic[a] += 1

for i in range(Q):
  B, C = list(map(int, input().split()))
  dic[C] += dic[B]
  dic[B] = 0
  
  ans = 0
  for k, v in dic.items():
    ans += k*v
  
  print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

ans = sum(A)
dic = {a+1:0 for a in range(10**5)}
for a in A:
  dic[a] += 1

for i in range(Q):
  B, C = list(map(int, input().split()))
  ans += dic[B]*(C-B)
  dic[C] += dic[B]
  dic[B] = 0
    
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

dic = {a:0 for a in A}
for a in A:
  dic[a] += 1

for i in range(Q):
  B, C = list(map(int, input().split()))
  if C not in dic.keys():
    dic[C] = 0
  if B in dic.keys():
    dic[C] += dic[B]
    dic[B] = 0
  
  ans = 0
  for k, v in dic.items():
    ans += k*v
  
  print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

ans = sum(A)
dic = {a+1:0 for a in range(10**5)}
for a in A:
  dic[a] += 1

for i in range(Q):
  B, C = list(map(int, input().split()))
  ans += dic[B]*(C-B)
  dic[C] += dic[B]
  dic[B] = 0
    
  print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = tuple(int(x) for x in input().split())
B = tuple(int(x) for x in input().split())
C = tuple(int(x) for x in input().split())

satisfy = sum(B)

for i in range(len(A)-1):
  if A[i+1]-A[i] is 1:
    satisfy += C[A[i]]

print(satisfy)

Fixed submission:
N = int(input())
A = tuple(int(x) for x in input().split())
B = tuple(int(x) for x in input().split())
C = tuple(int(x) for x in input().split())

satisfy = sum(B)

for i in range(N-1):
  if A[i+1]-A[i] is 1:
    satisfy += C[A[i]-1]

print(satisfy)
Buggy python submission (verdict: Time Limit Exceeded):
print(sum(x for x in range(int(input()))))

Fixed submission:
N = int(input())
print(N*(N-1)//2)