Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, T = map(int, input().split())
ls = []
for i in range(N):
  a, b = map(int, input().split())
  ls += [(a,b)]
ls.sort(key=lambda x:x[0])

dp = [[0]*(T) for i in range(N+1)]

for i in range(N):
  a,b = ls[i]
  for j in range(T-1, a-1, -1):
    dp[i+1][j] = max(dp[i][j], dp[i][j-a]+b)

last = [0]*N
last[-1] = ls[-1][1]
for i in range(N-2, -1, -1):
  last[i] = max(last[i+1], ls[i][1])

ans = 0

for i in range(1,N+1):
  ans = max(ans, max(dp[i-1])+last[i-1])

print(ans)

Fixed submission:
N, T = map(int, input().split())
dp = [[0]*T for i in range(N+1)]

ls = []
for i in range(N):
  a, b = map(int, input().split())
  ls += [(a,b)]
ls.sort(key=lambda x:x[0])

for i in range(N):
  a, b = ls[i]
  for j in range(T-1, a-1, -1):
    dp[i+1][j] = max(dp[i][j], dp[i][j-a]+b)
    
pre = [0]*N
pre[-1] = ls[-1][1]
for i in range(N-2, -1, -1):
  pre[i] = max(pre[i+1], ls[i][1])
    
ans = 0
for i in range(N-1):
  ans = max(ans, max(dp[i+1])+pre[i+1])
ans = max(ans, max(dp[-1]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
from heapq import heappush, heappop
N, T = map(int, input().split())
dic = defaultdict(list)
ls = []
pre = []
log = [[1]*N]*T
dp = [0]*(T)
for i in range(N):
  a, b = map(int, input().split())
  ls += [(a,b)]
  if a<T:
    for j in range(T-1,a-1,-1):
      if dp[j-a]+b>dp[j]:
        dp[j] = dp[j-a]+b
        log[j] = log[j-a][:]
        log[j][i] = 0
  else:
    heappush(pre, -b)
m = 0
ind = -1
his = None
for j in range(T):
  if dp[j]>m:
    m = dp[j]
    ind = j
for c in range(N):
  if log[ind][c]:
    heappush(pre,-ls[c][1])

if pre:
  m -= heappop(pre)
print(m)

Fixed submission:
N, T = map(int, input().split())
dp = [[0]*T for i in range(N+1)]

ls = []
for i in range(N):
  a, b = map(int, input().split())
  ls += [(a,b)]
ls.sort(key=lambda x:x[0])

for i in range(N):
  a, b = ls[i]
  for j in range(T-1, a-1, -1):
    dp[i+1][j] = max(dp[i][j], dp[i][j-a]+b)
    
pre = [0]*N
pre[-1] = ls[-1][1]
for i in range(N-2, -1, -1):
  pre[i] = max(pre[i+1], ls[i][1])
    
ans = 0
for i in range(N-1):
  ans = max(ans, max(dp[i+1])+pre[i+1])
ans = max(ans, max(dp[-1]))
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input())
if 0<A<10 and 0<B<10:
  print(A*B)
else:
  print(-1)

Fixed submission:
A, B = map(int, input().split())
if 0<A<10 and 0<B<10:
  print(A*B)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
from math import atan, degrees
a, b, x = map(int, input().split())
if x<=a*a*b//2:
  tan = (2*x)/(a*b*b)
  print(90-degrees(atan(tan)))
else:
  m = a*b*a-x
  tan = a*a*a/(2*m)
  print(90-degrees(atan(tan)))

Fixed submission:
from math import atan, degrees
a, b, x = map(int, input().split())
if x<=a*a*b//2:
  tan = (2*x)/(a*b*b)
  print(90-degrees(atan(tan)))
else:
  m = a*b*a-x
  if m==0:
    print(0)
  else:
    tan = a*a*a/(2*m)
    print(90-degrees(atan(tan)))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [int(c) for c in input().split()]
F = [int(c) for c in input().split()]
A.sort()
F.sort(reverse=True)
M = 0
for i in range(N):
  if A[i]*F[i]>M:
    M = A[i]*F[i]

l = -1
r = M+1
while l+1<r:
  s = (l+r)//2
  cnt = 0
  for i in range(N):
    b = s//F[i]
    cnt += max(0, A[i]-b)
  if cnt>K:
    l = s
  else:
    r = s

print(r)

Fixed submission:
N, K = map(int, input().split())
a = [int(c) for c in input().split()]
f = [int(c) for c in input().split()]
a.sort()
f.sort(reverse=True)
def check(n):
  m = K
  for i in range(N):
    m -= max(0, a[i]-n//f[i])
    if m<0:
      return False
  return True
r = 0
l = a[-1]*f[0]
X = (l-r)//2+r
while not (check(X)^check(X+1)) :
  if check(X):
    l = l - (l-r)//2
  else:
    r = (l-r)//2 + r
  X = (l-r)//2+r
  if check(0):
    print(0)
    break
else:
  print(X+1)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left, bisect_right
N = int(input())
L = [int(c) for c in input().split()]
L.sort()
ans = 0
for i in range(N):
  for j in range(i+1, N):
    x = L[i]+L[j]
    ind = bisect_left(L, x)
    IND = bisect_right(L,x)
    ans += ind-j-1 if ind-j>0 else 0
#    print(x,ind)

print(ans)

Fixed submission:
from bisect import bisect_left
N = int(input())
L = [int(c) for c in input().split()]
L.sort()
ans = 0
for i in range(N):
  for j in range(i+1, N):
    x = L[i]+L[j]
    ind = bisect_left(L, x)
    ans += ind-j-1
#    print(x,ind)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,L,*X = map(int, open(0).read().split())
ls = X[:3*M]
INF = 10**9
Els = [[INF]*N for i in range(N)]
Q = X[3*M]
query = X[3*M+1:]
for a,b,c in zip(*[iter(ls)]*3):
  if c<=L:
    Els[a-1][b-1] = c
    Els[b-1][a-1] = c
for i in range(N):
  Els[i][i] = 0
for k in range(N):
  for i in range(N):
    for j in range(N):
      Els[i][j] = min(Els[i][j], Els[i][k]+Els[k][j])
      
dist = [[INF]*N for i in range(N)]
for i in range(N):
  for j in range(N):
    if Els[i][j]<=L:
      dist[i][j] = 1
for i in range(N):
  dist[i][i] = 0
for k in range(N):
  for i in range(N):
    for j in range(N):
      dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])

for s,t in zip(*[iter(query)]*2):
  if dist[s-1][t-1]>=INF:
    print(-1)
    continue
  print(dist[s-1][t-1]-1)

Fixed submission:
N, M, L = map(int, input().split())
INF = 10**12
dp = [[INF]*N for i in range(N)]
fp = [[INF]*N for i in range(N)]
for i in range(N):
  dp[i][i]=0
  fp[i][i]=0
k = [[0]*N for i in range(N)]
for i in range(M):
  a, b, c = map(int, input().split())
  dp[a-1][b-1] = c
  dp[b-1][a-1] = c

for i in range(N):
  for j in range(N):
    for h in range(N):
      dp[j][h] = min(dp[j][h], dp[j][i]+dp[i][h])

for j in range(N):
  for h in range(N):
    if dp[j][h]<=L:
      fp[j][h] = 1
for i in range(N):
  for j in range(N):
    for h in range(N):
      fp[j][h] = min(fp[j][h], fp[j][i]+fp[i][h])
Q = int(input())
for i in range(Q):
  s, t = map(int, input().split())
  s = s-1
  t = t-1
  if fp[s][t]==INF:
    print(-1)
  else:
    print(fp[s][t]-1)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
ls = [0]*(max(int(A**0.5)+1, int(B**0.5)+1)+1)
ans = 0
for i in range(1, max(int(A**0.5)+1, int(B**0.5)+1)):
  if A%i==0 and B%i==0:
    if ls[i]==0:
      ls[i]=1
    else:
      continue
    for n in range(2,int(i**0.5)+1):
      if i%n==0:
        break
    else:
      ans += 1
    j = A//i
    if B%j!=0:
      continue
    if ls[j]==0:
      ls[j] = 1
    else:
      continue
    for n in range(2,int(j**0.5)+1):
      if j%n==0:
        break
    else:
      ans += 1
print(ans)

Fixed submission:
from collections import defaultdict
A, B = map(int, input().split())
ls = defaultdict(int)
ans = 0
for i in range(1, max(int(A**0.5)+1, int(B**0.5)+1)):
  if A%i==0 and B%i==0:
    if ls[i]==0:
      ls[i]=1
      for n in range(2,int(i**0.5)+1):
        if i%n==0:
          break
      else:
        ans += 1
  if A%i==0:
    j = A//i
    if B%j!=0:
      continue
  elif B%i==0:
    j = B//i
    if A%j!=0:
      continue
  else:
    continue
  if ls[j]==0:
    ls[j] = 1
  else:
    continue
  for n in range(2,int(j**0.5)+1):
    if j%n==0:
      break
  else:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
N, K , *P = map(int, open('0').read().split())
mhq = []
Mhq = []
for c in P[:K]:
  heappush(mhq,c)
  heappush(Mhq,-c)

ans = 1
log = set()
for i,c in enumerate(P[K:]):
  while mhq[0] in log:
    heappop(mhq)
  while -Mhq[0] in log:
    heappop(Mhq)
  d = P[i]
  m = mhq[0]
  M = -Mhq[0]
  log.add(d)
  heappush(mhq,c)
  heappush(Mhq,-c)
  if not (m==d and M<c):
    ans += 1
p = P[0]
m = 1
x = 0
for c in P[1:]:
  if p<c:
    m += 1
  else:
    if m>=K:
      x += 1
    m = 1
  p = c
if m>=K:
  x += 1
if x!=0:
  ans -= x-1
print(ans)

Fixed submission:
from heapq import heappush, heappop
N, K , *P = map(int, open(0).read().split())
mhq = []
Mhq = []
for c in P[:K]:
  heappush(mhq,c)
  heappush(Mhq,-c)

ans = 1
log = set()
for i,c in enumerate(P[K:]):
  while mhq[0] in log:
    heappop(mhq)
  while -Mhq[0] in log:
    heappop(Mhq)
  d = P[i]
  m = mhq[0]
  M = -Mhq[0]
  log.add(d)
  heappush(mhq,c)
  heappush(Mhq,-c)
  if not (m==d and M<c):
    ans += 1
p = P[0]
m = 1
x = 0
for c in P[1:]:
  if p<c:
    m += 1
  else:
    if m>=K:
      x += 1
    m = 1
  p = c
if m>=K:
  x += 1
if x!=0:
  ans -= x-1
print(ans)

Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop
N, K , *P = map(int, open('0').read().split())
mhq = []
Mhq = []
for c in P[:K]:
  heappush(mhq,c)
  heappush(Mhq,-c)

ans = 1
log = set()
for i,c in enumerate(P[K:]):
  while mhq[0] in log:
    heappop(mhq)
  while -Mhq[0] in log:
    heappop(Mhq)
  d = P[i]
  m = mhq[0]
  M = -Mhq[0]
  log.add(d)
  heappush(mhq,c)
  heappush(Mhq,-c)
  if not (m==d and M<c):
    ans += 1
p = P[0]
m = 1
x = 0
for c in P[1:]:
  if p<c:
    m += 1
  else:
    if m>=K:
      x += 1
    m = 1
  p = c
if m>=K:
  x += 1
print(ans-x+1)

Fixed submission:
from heapq import heappush, heappop
N, K , *P = map(int, open(0).read().split())
mhq = []
Mhq = []
for c in P[:K]:
  heappush(mhq,c)
  heappush(Mhq,-c)

ans = 1
log = set()
for i,c in enumerate(P[K:]):
  while mhq[0] in log:
    heappop(mhq)
  while -Mhq[0] in log:
    heappop(Mhq)
  d = P[i]
  m = mhq[0]
  M = -Mhq[0]
  log.add(d)
  heappush(mhq,c)
  heappush(Mhq,-c)
  if not (m==d and M<c):
    ans += 1
p = P[0]
m = 1
x = 0
for c in P[1:]:
  if p<c:
    m += 1
  else:
    if m>=K:
      x += 1
    m = 1
  p = c
if m>=K:
  x += 1
if x!=0:
  ans -= x-1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
dp = [[0]*N for i in range(N)]
pm = 0
ans = 0
for i in range(N-1,0,-1):
  for j in range(i-1,-1,-1):
    if S[i]==S[j]:
      if i<N-1:
        dp[i][j] = min(dp[i+1][j+1]+1, i-j)
      else:
        dp[i][j] = 1
    else:
      dp[i][j] = 0
    if dp[i][j]>ans:
      ans = dp[i][j]
print(ans)

Fixed submission:
N = int(input())
S = input()
dp = [[0]*N for i in range(N)]
pm = 0
ans = 0
for i in range(N-1,0,-1):
  for j in range(i-1,-1,-1):
    if S[i]==S[j]:
      if i<N-1:
        dp[i][j] = min(dp[i+1][j+1]+1, i-j)
      else:
        dp[i][j] = 1
    else:
      dp[i][j] = 0
    if dp[i][j]>ans:
      ans = dp[i][j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
dp = [[0]*N for i in range(N)]
pm = 0
ans = 0
for i in range(N-1,0,-1):
  for j in range(i-1,-1,-1):
    if S[i]==S[j]:
      if i<N-1:
        dp[i][j] = min(dp[i+1][j+1]+1, i-j)
      else:
        dp[i][j] = 1
    else:
      if i<N-1:
        dp[i][j] = min(dp[i+1][j+1], i-j)
      else:
        dp[i][j] = 0
    if dp[i][j]>ans:
      ans = dp[i][j]
print(ans)

Fixed submission:
N = int(input())
S = input()
dp = [[0]*N for i in range(N)]
pm = 0
ans = 0
for i in range(N-1,0,-1):
  for j in range(i-1,-1,-1):
    if S[i]==S[j]:
      if i<N-1:
        dp[i][j] = min(dp[i+1][j+1]+1, i-j)
      else:
        dp[i][j] = 1
    else:
      dp[i][j] = 0
    if dp[i][j]>ans:
      ans = dp[i][j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
dp = [[0]*N for i in range(N)]
pm = 0
ans = 0
for i in range(N):
  for j in range(i+1,N):
    m = 0
    x = i + dp[i-1][j-1] if i>1 else i
    y = j + dp[i-1][j-1] if i>1 else j
    while x<j and y<N and S[x]==S[y]:
      x += 1
      y += 1
      m += 1
#    print(pm,i,j)
    if m>ans:
      ans = m
    dp[i][j] = m
print(ans)


Fixed submission:
N = int(input())
S = input()
dp = [[0]*N for i in range(N)]
pm = 0
ans = 0
for i in range(N-1,0,-1):
  for j in range(i-1,-1,-1):
    if S[i]==S[j]:
      if i<N-1:
        dp[i][j] = min(dp[i+1][j+1]+1, i-j)
      else:
        dp[i][j] = 1
    else:
      dp[i][j] = 0
    if dp[i][j]>ans:
      ans = dp[i][j]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
dp = [[0]*N for i in range(N)]
pm = 0
ans = 0
for i in range(N):
  for j in range(i+1,N):
    m = 0
    x = i + dp[i-1][j-1] if i>1 else i
    y = j + dp[i-1][j-1] if i>1 else j
    while x<j and y<N and S[x]==S[y]:
      x += 1
      y += 1
      m += 1
#    print(pm,i,j)
    if m>ans:
      ans = m
    dp[i][j] = m
print(ans)

Fixed submission:
N = int(input())
S = input()
dp = [[0]*N for i in range(N)]
pm = 0
ans = 0
for i in range(N-1,0,-1):
  for j in range(i-1,-1,-1):
    if S[i]==S[j]:
      if i<N-1:
        dp[i][j] = min(dp[i+1][j+1]+1, i-j)
      else:
        dp[i][j] = 1
    else:
      dp[i][j] = 0
    if dp[i][j]>ans:
      ans = dp[i][j]
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
from bisect import bisect_right
s = input()
t = input()
ss = set(s)
tt = set(t)
count = 0
for i in tt:
  if not i in ss:
    print(-1)
    break
else:
  dic = defaultdict(list)
  for i in range(len(s)):
    dic[s[i]] += [i+1]
  ans = 0
  for i in range(len(t)):
    x = ans%len(s)
    if dic[t[i]][-1]+1<=x:
      ans = ans - x + len(s) + dic[t[i]][0]
    else:
      ind = bisect_right(dic[t[i]], x)
      ans = ans - x + dic[t[i]][ind]
  print(ans)

Fixed submission:
from collections import defaultdict
from bisect import bisect_right
s = input()
t = input()
ss = set(s)
tt = set(t)
count = 0
for i in tt:
  if not i in ss:
    print(-1)
    break
else:
  dic = defaultdict(list)
  for i in range(len(s)):
    dic[s[i]] += [i+1]
  ans = 0
  for i in range(len(t)):
    x = ans%len(s)
    if dic[t[i]][-1]<=x:
      ans = ans - x + len(s) + dic[t[i]][0]
    else:
      ind = bisect_right(dic[t[i]], x)
      ans = ans - x + dic[t[i]][ind]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
s = input()
t = input()
ss = set(s)
tt = set(t)
count = 0
for i in tt:
  if not i in ss:
    print(-1)
    break
else:
  dic = defaultdict(list)
  for i in range(len(s)):
    dic[s[i]] += [i]
  ans = 0
  for i in range(len(t)):
    x = ans%len(s)
    for j in dic[t[i]]:
      count += 1
      if j+1>x:
        ans += j+1-x
        break
    else:
      ans += len(s) - x + dic[t[i]][0] + 1
  print(ans)

Fixed submission:
from collections import defaultdict
from bisect import bisect_right
s = input()
t = input()
ss = set(s)
tt = set(t)
count = 0
for i in tt:
  if not i in ss:
    print(-1)
    break
else:
  dic = defaultdict(list)
  for i in range(len(s)):
    dic[s[i]] += [i+1]
  ans = 0
  for i in range(len(t)):
    x = ans%len(s)
    if dic[t[i]][-1]<=x:
      ans = ans - x + len(s) + dic[t[i]][0]
    else:
      ind = bisect_right(dic[t[i]], x)
      ans = ans - x + dic[t[i]][ind]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
s = input()
t = input()
ss = set(s)
tt = set(t)
count = 0
for i in tt:
  if not i in ss:
    print(-1)
    break
else:
  dic = defaultdict(list)
  for i in range(len(s)):
    dic[s[i]] += [i]
  ans = 0
  for i in range(len(t)):
    x = ans%len(s)
    for j in dic[t[i]]:
      count += 1
      if j+1>x:
        ans += j+1-x
        break
    else:
      ans += len(s) - x + dic[t[i]][0] + 1
  print(ans)

Fixed submission:
from collections import defaultdict
from bisect import bisect_right
s = input()
t = input()
ss = set(s)
tt = set(t)
count = 0
for i in tt:
  if not i in ss:
    print(-1)
    break
else:
  dic = defaultdict(list)
  for i in range(len(s)):
    dic[s[i]] += [i+1]
  ans = 0
  for i in range(len(t)):
    x = ans%len(s)
    if dic[t[i]][-1]<=x:
      ans = ans - x + len(s) + dic[t[i]][0]
    else:
      ind = bisect_right(dic[t[i]], x)
      ans = ans - x + dic[t[i]][ind]
  print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
dic = {i:[] for i in range(1,M+1)}
for i in range(N):
  A, B = map(int, input().split())
  if A<=M:
    dic[A] += [B]
key = list(dic.keys())
key.sort()
ans = 0
ls = []
pm = 0
m = 0
for i in range(1,M+1):
  if dic[i]:
    x = max(dic[i])
    if m < x:
      ans += x
      dic[i].remove(x)
      ls += dic[i]
    else:
      ans += m
      ls.remove(m)
      ls += dic[i]
  else:
    ans += m
    ls.remove(m)
  m = max(ls)
  
  
print(ans)

Fixed submission:
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1):  # M - i 日後にするバイトを考える
    while (j < N) and (X[j][0] <= i):
        heappush(hq, -X[j][1])  # 候補の追加
        j += 1
    if len(hq):
        ans += -heappop(hq)  # 候補があるとき、候補から最大値を取り出す

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
dic = {i:[] for i in range(1,M+1)}
for i in range(N):
  A, B = map(int, input().split())
  if A<=M:
    dic[A] += [B]
key = list(dic.keys())
key.sort()
ans = 0
ls = []
m = 0
for i in range(1,M+1):
  ls += dic[i]
  if ls:
    ans += max(ls)
    ls.remove(max(ls))
  
print(ans)

Fixed submission:
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1):  # M - i 日後にするバイトを考える
    while (j < N) and (X[j][0] <= i):
        heappush(hq, -X[j][1])  # 候補の追加
        j += 1
    if len(hq):
        ans += -heappop(hq)  # 候補があるとき、候補から最大値を取り出す

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N, M = map(int, input().split())
dic = defaultdict(list)
for i in range(N):
  A, B = map(int, input().split())
  dic[A] += [B]
key = list(dic.keys())
key.sort()
ans = 0
for i in range(1,M+1):
  m = 0
  K = 0
  for k in key:
    if k>i:
      break
    if dic[k] and m<max(dic[k]):
      m = max(dic[k])
      K = k
      #print(m,K, i, k, ans)
  if m==0:
    continue
  ans += m
  dic[K].remove(m)
print(ans)

Fixed submission:
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1):  # M - i 日後にするバイトを考える
    while (j < N) and (X[j][0] <= i):
        heappush(hq, -X[j][1])  # 候補の追加
        j += 1
    if len(hq):
        ans += -heappop(hq)  # 候補があるとき、候補から最大値を取り出す

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
count = 0
dic = {}
ans = [0 for i in range(len(S))]
ind = []
for i in range(len(S)-1):
  if S[i]=='R' and S[i+1]=='L':
    ind += [i]
for i in range(len(S)):
  s = S[i]
  j = 0
  k = len(ind)-1
  if s=='R':
    while i>ind[j]:
      j+=1
    if (ind[j]-i)%2==0:
      ans[ind[j]]+=1
    else:
      ans[ind[j]+1]+=1
  if s=='L':
    while ind[k]>i:
      k -=1
    if (ind[k]-i)%2==0:
      ans[ind[k]]+=1
    else:
      ans[ind[k]+1]+=1
A = [str(i) for i in  ans]
print(' '.join(A))


Fixed submission:
S = input()
count = 0
dic = {}
ans = [0 for i in range(len(S))]
ind = []
for i in range(len(S)-1):
  if S[i]=='R' and S[i+1]=='L':
    ind += [i]
j = 0
k = 0
for i in range(len(S)):
  s = S[i]
  if s=='R':
    while i>ind[j]:
      j+=1
    if (ind[j]-i)%2==0:
      ans[ind[j]]+=1
    else:
      ans[ind[j]+1]+=1
  if s=='L':
    while ind[k]<i:
      k +=1
      if k==len(ind):
        break
    k -= 1
    if (ind[k]-i)%2==0:
      ans[ind[k]]+=1
    else:
      ans[ind[k]+1]+=1
A = [str(i) for i in  ans]
print(' '.join(A))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
count = 0
dic = {}
ans = [0 for i in range(len(S))]
for i in range(len(S)):
  pi= -1
  ppi = -1
  ori = i
  while not ppi==i:
    ppi = pi
    pi = i
    if S[i] == 'R':
      i +=1
    else:
      i -=1
  if (ppi-ori)%2==0:
    dic[ori]=ppi
  else:
    dic[ori]=pi
for k in dic.keys():
  ind = dic[k]
  ans[ind]+=1
A = [str(i) for i in ans]
print(' '.join(A))

Fixed submission:
S = input()
count = 0
dic = {}
ans = [0 for i in range(len(S))]
ind = []
for i in range(len(S)-1):
  if S[i]=='R' and S[i+1]=='L':
    ind += [i]
j = 0
k = 0
for i in range(len(S)):
  s = S[i]
  if s=='R':
    while i>ind[j]:
      j+=1
    if (ind[j]-i)%2==0:
      ans[ind[j]]+=1
    else:
      ans[ind[j]+1]+=1
  if s=='L':
    while ind[k]<i:
      k +=1
      if k==len(ind):
        break
    k -= 1
    if (ind[k]-i)%2==0:
      ans[ind[k]]+=1
    else:
      ans[ind[k]+1]+=1
A = [str(i) for i in  ans]
print(' '.join(A))
Buggy python submission (verdict: Runtime Error):
N = int(input())
inf = input().split()
if inf[0]==1:
  print(-1)
else:
  A = {i+1:int(inf[i]) for i in range(N)}
  ans = [0 for i in range(N+1)]
  keys = list(A.keys())
  keys.sort(reverse=True)
  for k in keys[::-1]:
    count = 0
    for j in range(2*k, N, k)[::-1]:
      count += ans[j]
      ans[k] = (A[k]-(count%2))%2
      value = sum(ans)
  print(value)
  tag = []
  for i in range(N+1):
    if ans[i]:
      tag += [str(i)]
      print(' '.join(tag))

Fixed submission:
N = int(input())
inf = input().split()
A = {i+1:int(inf[i]) for i in range(N)}
ans = [0 for i in range(N+1)]
keys = list(A.keys())
keys.sort(reverse=True)
for k in keys:
  count = 0
  for j in range(2*k, N+1, k)[::-1]:
    count += ans[j]
  ans[k] = (A[k]-(count%2))%2
value = sum(ans)
print(value)
if value>0:
  tag = []
  for i in range(N+1):
    if ans[i]:
      tag += [str(i)]
  print(' '.join(tag))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict, deque
N, M = map(int, input().split())
dic = defaultdict(list)
for i in range(M):
  u, v = map(int, input().split())
  dic[u-1] += [v-1]
S, T = map(int, input().split())
S -= 1
T -= 1
dist = [[float('inf')]*3 for i in range(N)]
dist[S][0] = 0
q = deque([(S,0)])
flag = False
cnt = 0
while q:
  cnt += 1
  e, m = q.pop()
  n = (m+1)%3
  for p in dic[e]:
    if p==T:
      flag = True
    if dist[p][n]>dist[e][m]+1:
      dist[p][n] = dist[e][m]+1
      q += [(p,n)]
if flag:
  ans = dist[T][0] if dist[T][0]!=float('inf') else -1
  print(ans//3)
else:
  print(-1)


Fixed submission:
from collections import defaultdict, deque
N, M = map(int, input().split())
dic = defaultdict(list)
for i in range(M):
  u, v = map(int, input().split())
  dic[u-1] += [v-1]
S, T = map(int, input().split())
S -= 1
T -= 1
dist = [[float('inf')]*3 for i in range(N)]
dist[S][0] = 0
q = deque([(S,0)])
flag = False
cnt = 0
while q:
  cnt += 1
  e, m = q.popleft()
  n = (m+1)%3
  for p in dic[e]:
    if p==T:
      flag = True
    if dist[p][n]>dist[e][m]+1:
      dist[p][n] = dist[e][m]+1
      q += [(p,n)]
if flag:
  ans = dist[T][0] if dist[T][0]!=float('inf') else -1
  print(ans//3)
else:
  print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N, M = map(int, input().split())
dic = defaultdict(list)
for i in range(M):
  u, v = map(int, input().split())
  dic[u-1] += [v-1]
S, T = map(int, input().split())
S -= 1
T -= 1
dist = [[float('inf')]*3 for i in range(N)]
ls = [float('inf')]*3
dist[S][0] = 0
q = [(S,0)]
flag = False
while q:
  e, m = q.pop()
  n = (m+1)%3
  for p in dic[e]:
    if p==T:
      flag = True
    if dist[p][n]>dist[e][m]+1:
      dist[p][n] = dist[e][m]+1
      q += [(p,n)]
if flag:
  ans = dist[T][0] if dist[T][0]!=float('inf') else -1
  print(ans//3)
else:
  print(-1)
      

Fixed submission:
from collections import defaultdict, deque
N, M = map(int, input().split())
dic = defaultdict(list)
for i in range(M):
  u, v = map(int, input().split())
  dic[u-1] += [v-1]
S, T = map(int, input().split())
S -= 1
T -= 1
dist = [[float('inf')]*3 for i in range(N)]
dist[S][0] = 0
q = deque([(S,0)])
flag = False
cnt = 0
while q:
  cnt += 1
  e, m = q.popleft()
  n = (m+1)%3
  for p in dic[e]:
    if p==T:
      flag = True
    if dist[p][n]>dist[e][m]+1:
      dist[p][n] = dist[e][m]+1
      q += [(p,n)]
if flag:
  ans = dist[T][0] if dist[T][0]!=float('inf') else -1
  print(ans//3)
else:
  print(-1)