Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
edge = [[] for i in range(N + 1)]
for i in range(N - 1):
    a, b, c = [int(t) for t in input().split()]
    edge[a].append((b, c))
    edge[b].append((a, c))

Q, K = [int(t) for t in input().split()]

def dfs(s):
    '''深さ優先探索でKからの距離を計算'''
    global dist
    for t, c in edge[s]:
        if dist[t] == None:
            dist[t] = dist[s] + c
            dfs(t)

dist = [None] * (N + 1)  # Kからの距離
dist[K] = 0
dfs(K)

for i in range(Q):
    x, y = [int(t) for t in input().split()]
    print(dist[x] + dist[y])

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
edge = [[] for i in range(N + 1)]
for i in range(N - 1):
    a, b, c = [int(t) for t in input().split()]
    edge[a].append((b, c))
    edge[b].append((a, c))

Q, K = [int(t) for t in input().split()]

def dfs(s):
    '''Kからの距離を計算'''
    global dist
    work = [s]
    while len(work) > 0:
        s = work.pop()
        for t, c in edge[s]:
            if dist[t] == None:
                dist[t] = dist[s] + c
                work.append(t)

dist = [None] * (N + 1)  # Kからの距離
dist[K] = 0
dfs(K)

for i in range(Q):
    x, y = [int(t) for t in input().split()]
    print(dist[x] + dist[y])
Buggy python submission (verdict: Runtime Error):
s = input()
ans = 'Yes'

if(s == 'AAA' || s == 'BBB'):
    ans = 'No'

print(ans)

Fixed submission:
s = input()
ans = 'Yes'

if(s == 'AAA' or s == 'BBB'):
    ans = 'No'

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = [int(input()) for i in range(n)]
a_max = max(a)
a2 = a[:]
a2.remove(a_max)
a_second_max = max(a2)

for i in range(n):
    if a[i] == a_max:
        print(a_second_max)
    else:
        print(a_max)

Fixed submission:
r = int(input())

print(3 * (r * r))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

a = [int(input()) for i in range(n)]

for i in range(n):
    a2 = a[:]
    a2.pop(i)
    print(max(a2))

Fixed submission:
n = int(input())

a = [int(input()) for i in range(n)]
a_max = max(a)
a2 = a[:]
a2.remove(a_max)
a_second_max = max(a2)

for i in range(n):
    if a[i] == a_max:
        print(a_second_max)
    else:
        print(a_max)

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

a = [int(input()) for i in range(n)]

for i in range(n):
    a2 = a[:]
    a2.pop(i)
    print(max(a2))

Fixed submission:
n = int(input())

a = [int(input()) for i in range(n)]
a_max = max(a)
a2 = a[:]
a2.remove(a_max)
a_second_max = max(a2)

for i in range(n):
    if a[i] == a_max:
        print(a_second_max)
    else:
        print(a_max)
Buggy python submission (verdict: Runtime Error):
a,b,c,k = map(int, input().split())

ans = a - b

if(k % 2 == 1):
    ans = abs(ans)

if(len(ans) >= 18):
    ans = 'Unfair'

print(ans)

Fixed submission:
a,b,c,k = map(int, input().split())

ans = a - b

if(k % 2 == 1):
    ans = b - a

print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = input().split(' ')

sunukekuns = [i for i in range(N)]

for k in range(K):
  _ = input()
  sunukekun = input().split(' ')
  for (kun in sunukekun):
    if kun in sunukekuns:
      sunukekuns.remove(kun)

print(len(sunukekuns))


Fixed submission:
lastWeek = input()

thisWeek = "ABC" if (lastWeek == "ARC") else "ARC"

print(thisWeek)
Buggy python submission (verdict: Runtime Error):
N, K = [int(ipt) for ipt in input().split(' ')]

sunukekuns = [str(i) for i in range(N)]

for k in range(K):
  _ = input()
  sunukekun = input().split(' ')
  for (kun in sunukekun):
    if kun in sunukekuns:
      sunukekuns.remove(kun)

print(len(sunukekuns))


Fixed submission:
N, K = [int(ipt) for ipt in input().split(' ')]

sunukekuns = [str(i+1) for i in range(N)]

for k in range(K):
  _ = input()
  sunukekun = input().split(' ')
  for kun in sunukekun:
    if kun in sunukekuns:
      sunukekuns.remove(kun)

print(len(sunukekuns))

Buggy python submission (verdict: Runtime Error):
N, K = input().split(' ')

sunukekuns = [i for i in range(N)]

for k in range(K):
  _, sunukekun = input(), input().split(' ')
  for (kun in sunukekun):
    if kun in sunukekuns:
      sunukekuns.remove(kun)

print(len(sunukekuns))

Fixed submission:
N, K = [int(ipt) for ipt in input().split(' ')]

sunukekuns = [str(i+1) for i in range(N)]

for k in range(K):
  _ = input()
  sunukekun = input().split(' ')
  for kun in sunukekun:
    if kun in sunukekuns:
      sunukekuns.remove(kun)

print(len(sunukekuns))
Buggy python submission (verdict: Runtime Error):
text = input()

def checkHitachi(text):
  if (len(text)%2 != 0): # odd length
    return 'No'
  # even length
  for i in range(0, len(text), 2):
    if !((text[i]=='h') and (text[i+1]=='i')):
      return 'No'

  return 'Yes'
 
print(checkHitachi(text))


Fixed submission:
text = input()

def checkHitachi(text):
  # odd length
  if (len(text)%2 != 0): 
    return 'No'
  # even length
  for i in range(0, len(text)-1, 2):
    if (text[i:i+2]!='hi'):
      return 'No'

  return 'Yes'
 
print(checkHitachi(text))

Buggy python submission (verdict: Runtime Error):
text = input()

check_i = False

def checkHitachi(text):
  for i in range(len(text)):
    if check_i:
      if (text[i] != 'i'):
        return 'No'
      else:
        check_i = False
    else:
      if (text[i] != 'h'):
        return 'No'
      else:
        check_i = True
  return 'Yes'

print(checkHitachi(text))

Fixed submission:
text = input()

def checkHitachi(text):
  # odd length
  if (len(text)%2 != 0): 
    return 'No'
  # even length
  for i in range(0, len(text)-1, 2):
    if (text[i:i+2]!='hi'):
      return 'No'

  return 'Yes'
 
print(checkHitachi(text))
Buggy python submission (verdict: Runtime Error):
numA, numB, numCoupon = map(int, input().split(' '))
priceA = map(int, input().split(' '))
priceB = map(int, input().split(' '))

# initial best price
bestPrice = min(priceA) + min(priceB)

for n in range(numCoupon):
  # get coupon details
  typeA, typeB, discount = map(int, input().split(' '))
  # calculate price when this coupon is used
  currentPrice = priceA[typeA-1] + priceB[typeB-1] - discount
  # update best price
  if currentPrice < bestPrice:
    bestPrice = currentPrice

print(bestPrice)


Fixed submission:
numA, numB, numCoupon = map(int, input().split(' '))
priceA = list(map(int, input().split(' ')))
priceB = list(map(int, input().split(' ')))

# initial best price
bestPrice = min(priceA) + min(priceB)

for n in range(numCoupon):
  # get coupon details
  typeA, typeB, discount = map(int, input().split(' '))
  # calculate price when this coupon is used
  currentPrice = priceA[typeA-1] + priceB[typeB-1] - discount
  # update best price
  if currentPrice < bestPrice:
    bestPrice = currentPrice

print(bestPrice)

Buggy python submission (verdict: Runtime Error):
numA, numB, numCoupon = map(int, input().split(' '))
priceA = map(int, input().split(' '))
priceB = map(int, input().split(' '))

# initial best price
bestPrice = min(priceA) + min(priceB)

for n in range(numCoupon):
  # get coupon details
  typeA, typeB, discount = map(int, coupon.split(' '))
  # calculate price when this coupon is used
  currentPrice = priceA[typeA-1] + priceB[typeB-1] - discount
  # update best price
  if currentPrice < bestPrice:
    bestPrice = currentPrice

print(bestPrice)

Fixed submission:
numA, numB, numCoupon = map(int, input().split(' '))
priceA = list(map(int, input().split(' ')))
priceB = list(map(int, input().split(' ')))

# initial best price
bestPrice = min(priceA) + min(priceB)

for n in range(numCoupon):
  # get coupon details
  typeA, typeB, discount = map(int, input().split(' '))
  # calculate price when this coupon is used
  currentPrice = priceA[typeA-1] + priceB[typeB-1] - discount
  # update best price
  if currentPrice < bestPrice:
    bestPrice = currentPrice

print(bestPrice)
Buggy python submission (verdict: Time Limit Exceeded):
# N, A, B
num, greenNum, redNum = map(lambda x: int(x), input().split(' '))

# output
totalGreen = 0
while (num > 0):
  if (num <= greenNum):
    totalGreen += num
    num = 0
  else:
    totalGreen += greenNum
    num -= (greenNum + redNum)
    
print(totalGreen)


Fixed submission:
# N, A, B
num, greenNum, redNum = map(lambda x: int(x), input().split(' '))

numSet = num // (greenNum+redNum)
remain = num % (greenNum+redNum)
numRest = remain if (remain < greenNum) else greenNum

totalGreen = numSet * greenNum + numRest

print(totalGreen)

Buggy python submission (verdict: Runtime Error):
# N
num = int(input())
# A
greenNum = int(input())
# B
redNum = int(input())

# output
totalGreen = 0
while (num > 0):
  if (num <= greenNum):
    totalGreen += num
    num = 0
  else:
    totalGreen += greenNum
    num -= (greenNum + redNum)
    
print(totalGreen)

Fixed submission:
# N, A, B
num, greenNum, redNum = map(lambda x: int(x), input().split(' '))

numSet = num // (greenNum+redNum)
remain = num % (greenNum+redNum)
numRest = remain if (remain < greenNum) else greenNum

totalGreen = numSet * greenNum + numRest

print(totalGreen)
Buggy python submission (verdict: Runtime Error):
import numpy as np

# get input
eight, ten = map(lambda x: int(x), input().split(' '))

def oriPrice(a, b):
  """
  <int> a = round(0.08 * ori)
  <int> b = round(0.10 * ori)
  """
  # ori = b*10 ~ (b+1)*10 - 1
  for i in range(10, 0, -1):
    possibleOri = (b+1)/0.10-i
    if np.int(np.floor(possibleOri*0.08)) == a:
      return possibleOri[i]
    
  return -1

print(oriPrice(eight, ten))


Fixed submission:
import numpy as np

# get input
eight, ten = map(lambda x: int(x), input().split(' '))

def oriPrice(a, b):
  """
  <int> a = round(0.08 * ori)
  <int> b = round(0.10 * ori)
  """
  # ori = b * 10 ~ (b+1)*10 - 1
  possibleOri = [(b+1)/0.10-i for i in range(10, 0, -1)]
  
  for i in range(len(possibleOri)):
    if np.int(np.floor(possibleOri[i]*0.08)) == a:
      return np.int(possibleOri[i])
  
  return -1

print(oriPrice(eight, ten))
Buggy python submission (verdict: Runtime Error):
a, b, t = map(int, input().split(' '))
return (t+0.5)//a*b

Fixed submission:
a, b, t = map(int, input().split(' '))
print(int((t+0.5)//a*b))

Buggy python submission (verdict: Runtime Error):
A, B, T = input().split()
return int((int(T)+0.5)//int(A)*int(B))


Fixed submission:
a, b, t = map(int, input().split(' '))
print(int((t+0.5)//a*b))

Buggy python submission (verdict: Runtime Error):
A, B, T = input().split()
return int((T+0.5)//A*B)

Fixed submission:
a, b, t = map(int, input().split(' '))
print(int((t+0.5)//a*b))
Buggy python submission (verdict: Runtime Error):
def countInn(n, L):
  numInn = 1
  mainHurdle = L[0]
  hurdle = L[1]
  for i in range(1, n):
    currentH = L[i]
    if currentH < mainHurdle or currentH < hurdle:
      continue
    numInn += 1
    hurdle = currentH
  print(numInn)
  
n = int(input())
a = list(map(int, input().split()))
countInn(n, a)


Fixed submission:
def countInn(n, L):
  numInn = 1
  mainHurdle = L[0]
  hurdle = mainHurdle
  for i in range(1, n):
    currentH = L[i]
    if currentH < mainHurdle or currentH < hurdle:
      continue
    numInn += 1
    hurdle = currentH
  print(numInn)
  
n = int(input())
a = list(map(int, input().split()))
countInn(n, a)

Buggy python submission (verdict: Runtime Error):
def countInn(n, L):
  numInn = 1
  mainHurdle = L[0]
  hurdle = L[1]
  for i in range(1, n):
    currentH = L[i]
    if currentH < mainHurdle or currentH < hurdle:
      continue
    numInn += 1
    hurdle = currentH
  print(numInn)
  
n = int(input())
a = list(map(int, input().split()))
countInn(n, a)

Fixed submission:
def countInn(n, L):
  numInn = 1
  mainHurdle = L[0]
  hurdle = mainHurdle
  for i in range(1, n):
    currentH = L[i]
    if currentH < mainHurdle or currentH < hurdle:
      continue
    numInn += 1
    hurdle = currentH
  print(numInn)
  
n = int(input())
a = list(map(int, input().split()))
countInn(n, a)
Buggy python submission (verdict: Runtime Error):
S = input()
first = S[0]
inverse = str(1-int(first))
unit = first+inverse
if len(S) % 2 == 0:
  sample = unit*len(S)//2
else:
  sample = unit*len(S)//2+first

count = 0
for k in range(len(S)):
  if S[k] != sample[k]:
    count += 1

print(count)


Fixed submission:
S = input()
first = S[0]
inverse = str(1-int(first))
unit = first+inverse
if len(S) % 2 == 0:
  sample = unit*(len(S)//2)
else:
  sample = unit*(len(S)//2)+first

count = 0
for k in range(len(S)):
  if S[k] != sample[k]:
    count += 1

print(count)

Buggy python submission (verdict: Runtime Error):
if len(S) % 2 == 0:
  whiteS = '01'*len(S)//2
  blackS = '10'*len(S)//2
else:
  whiteS = '01'*len(S)//2 + '0'
  blackS = '10'*len(S)//2 + '1'
  
S = input()
first = S[0]
inverse = str(1-int(first))
unit = first+inverse
if len(S) % 2 == 0:
  sample = unit*len(S)//2
else:
  sample = unit*len(S)//2+first

count = 0
for k in range(len(S)):
  if S[k] != sample[k]:
    count += 1

print(count)

Fixed submission:
S = input()
first = S[0]
inverse = str(1-int(first))
unit = first+inverse
if len(S) % 2 == 0:
  sample = unit*(len(S)//2)
else:
  sample = unit*(len(S)//2)+first

count = 0
for k in range(len(S)):
  if S[k] != sample[k]:
    count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
A, B, C = (int, input().split())

if A == B == C:
    print("Yes")
else:
    print("No")

Fixed submission:
A, B, C = map(int, input().split())

if A == B == C:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
A, B, C = (int, input().split())

if A == B == C :
    print("Yes")
else :
    print("No")

Fixed submission:
A, B, C = map(int, input().split())

if A == B == C:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())

meal_price = n * 15
meal_discount_count = n // 15

return meal_price - (meal_discount_count * 200)

Fixed submission:
n = int(input())
  
meal_price = n * 800
meal_discount_count = n // 15
  
print (meal_price - (meal_discount_count * 200))
Buggy python submission (verdict: Time Limit Exceeded):
number = int(input())

result = 1
for index in range(1, number + 1):
  result = result * index


dividor = 10 ** 9 + 7
print (result % dividor)

Fixed submission:
import math
  
n = int(input())
result = math.factorial(n)
  
  
dividor = 10 ** 9 + 7
print (result % dividor)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

sumpro = 0
for i in range(N):
	sumpro += sum(A[i+1:]) * A[i]

print(sumpro % 1000000007)


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

s = sum(A)
sumpro = 0

for a in A[:-1]:
	s -= a
	sumpro += a * s

print(sumpro % (10 ** 9 + 7))

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

sumpro = 0
for i in range(N):
	for j in range(i + 1, N):
		sumpro += A[i] * A[j]

print(sumpro % 1000000007)


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

s = sum(A)
sumpro = 0

for a in A[:-1]:
	s -= a
	sumpro += a * s

print(sumpro % (10 ** 9 + 7))
Buggy python submission (verdict: Runtime Error):
N = input()
check = 0
for i in N:
  check += i
if check % 9 == 0:
  print("Yes")
else:
  print("No")


Fixed submission:
N = input()
check = 0

for i in N:
    check += int(i)

if check % 9 == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
a,b,c=map(int, input().split())
msg= "Yes" if math.sqrt(a)+math.sqrt(b)<math.sqrt(c) else "No"
print(msg)

Fixed submission:
import sys

lst=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
pos = input()
print(lst[int(pos)-1])

Buggy python submission (verdict: Runtime Error):
import sys
lst=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(lst[int(sys.argv[1])-1])

Fixed submission:
import sys

lst=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
pos = input()
print(lst[int(pos)-1])

Buggy python submission (verdict: Runtime Error):
import sys
lst=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(lst[sys.argv[1]-1])

Fixed submission:
import sys

lst=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
pos = input()
print(lst[int(pos)-1])

Buggy python submission (verdict: Runtime Error):
import sys
lst=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(lst[sys.args[1]-1])

Fixed submission:
import sys

lst=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
pos = input()
print(lst[int(pos)-1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

ans=mx=0
for x in a:
    mx=max(mx,x)
    ans+=mx-x

print(ans)


Fixed submission:
N,X,T=map(int,input().split())
print((N//X+(N%X!=0))*T)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from pprint import pprint

R,C,K=map(int,input().split())

grid=[[0]*C for _ in range(R+1)]
for _ in range(K):
    r,c,v=map(int,input().split())
    grid[r][c-1]=v

for i in range(1,R+1):
    cell=[0]*4
    for j in range(C):
        cell[0]=max(cell[0],grid[i-1][j])
        for k in range(2,-1,-1):
            cell[k+1]=max(cell[k+1],cell[k]+grid[i][j])
        grid[i][j]=max(cell)

print(grid[-1][-1])


Fixed submission:
import sys
from pprint import pprint

R,C,K=map(int,input().split())

grid=[[0]*C for _ in range(R+1)]
for _ in range(K):
    r,c,v=map(int,input().split())
    grid[r][c-1]=v

for i in range(1,R+1):
    cell=[0]*4
    for j in range(C):
        cell[0]=max(cell[0],grid[i-1][j])
        for k in range(2,-1,-1):
            cell[k+1]=max(cell[k+1],cell[k]+grid[i][j])
        grid[i][j]=max(cell)

print(grid[-1][-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys

R,C,K=map(int,input().split())

grid=[[0]*C for _ in range(R)]
for _ in range(K):
    r,c,v=map(int,next(sys.stdin).split())
    grid[r-1][c-1]=v

ans=0
stk=[(0,0,0,3)]
while stk:
    i,j,tt,k=stk.pop()
    ntt,nk=tt,k
    if k>0:
        ntt+=grid[i][j]
        nk=k-1
    if i+1==R and j+1==C:
        ans=max(ans,ntt)
        continue
    for ni,nj in (i,j+1),(i+1,j):
        if not (ni<R and nj<C):
            continue
        if ni!=i:
            k=nk=3
        stk.append((ni,nj,tt,k))
        if tt!=ntt:
            stk.append((ni,nj,ntt,nk))


print(ans)








Fixed submission:
import sys
from pprint import pprint

R,C,K=map(int,input().split())

grid=[[0]*C for _ in range(R+1)]
for _ in range(K):
    r,c,v=map(int,input().split())
    grid[r][c-1]=v

for i in range(1,R+1):
    cell=[0]*4
    for j in range(C):
        cell[0]=max(cell[0],grid[i-1][j])
        for k in range(2,-1,-1):
            cell[k+1]=max(cell[k+1],cell[k]+grid[i][j])
        grid[i][j]=max(cell)

print(grid[-1][-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys

R,C,K=map(int,input().split())

grid=[[0]*C for _ in range(R)]
for _ in range(K):
    r,c,v=map(int,next(sys.stdin).split())
    grid[r-1][c-1]=v

ans=0
stk=[(0,0,0,3)]
while stk:
    i,j,tt,k=stk.pop()
    ntt,nk=tt,k
    if k>0:
        ntt+=grid[i][j]
        nk=k-1
    if i+1==R and j+1==C:
        ans=max(ans,ntt)
        continue
    for ni,nj in (i,j+1),(i+1,j):
        if not (ni<R and nj<C):
            continue
        if ni!=i:
            k=nk=3
        stk.append((ni,nj,tt,k))
        if tt!=ntt:
            stk.append((ni,nj,ntt,nk))


print(ans)








Fixed submission:
import sys
from pprint import pprint

R,C,K=map(int,input().split())

grid=[[0]*C for _ in range(R+1)]
for _ in range(K):
    r,c,v=map(int,input().split())
    grid[r][c-1]=v

for i in range(1,R+1):
    cell=[0]*4
    for j in range(C):
        cell[0]=max(cell[0],grid[i-1][j])
        for k in range(2,-1,-1):
            cell[k+1]=max(cell[k+1],cell[k]+grid[i][j])
        grid[i][j]=max(cell)

print(grid[-1][-1])
Buggy python submission (verdict: Runtime Error):
N=int(input())
s=input()

ans=0
i,j=0,N-2
while i<j:
    if s[i]=='R':
        i+=1
    elif s[j]=='W':
        j-=1
    else:
        k+=1
        i+=1
        j-=1

print(k)


Fixed submission:
import sys

N=int(input())
s=list(input().strip())

#print(s)

k=0
i,j=0,N-1
while i<j:
    if s[i]=='R':
        i+=1
    elif s[j]=='W':
        j-=1
    else:
        s[i]='W'
        s[j]='R'
        k+=1
        i+=1
        j-=1

print(k)
Buggy python submission (verdict: Runtime Error):
import sys
input()
d=dict.fromkeys('AC WA TLE RE'.split(),0)
for ln in sys.stdin:
    d[ln.strip()]+=1
for k,v in ct.items():
    print(k,'x',v)


Fixed submission:
import sys

next(sys.stdin)

ct=dict(zip('AC WA TLE RE'.split(),[0]*4))
for s in map(str.strip,sys.stdin):
    ct[s]+=1

for k,v in ct.items():
    print(k,'x',v)
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
print(sum(x!=y for x,y in zip(S,T))


Fixed submission:
S=input()
T=input()
print(sum(x!=y for x,y in zip(S,T)))
Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int,input().split())
A,B=[0],[0]
A+=map(int,input().split())
B+=map(int,input().split())

for i in range(1,N+1):
    A[i]+=A[i-1]
for i in range(1,M+1):
    B[i]+=B[i-1]

ans=0
for i in range(N+1):
    if A[i]>K:
        break
    for j in range(M+1):
        if A[i]+B[j]>K:
            break
        ans=max(ans,i+j)

print(ans)


Fixed submission:
N,M,K=map(int,input().split())
A,B=[0],[0]
A+=map(int,input().split())
B+=map(int,input().split())

for i in range(1,N+1):
    A[i]+=A[i-1]
for i in range(1,M+1):
    B[i]+=B[i-1]

ans,j=0,M
for i in range(N+1):
    if A[i]>K:
        break
    while j>0 and A[i]+B[j]>K:
        j-=1
    ans=max(ans,i+j)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int,input().split())
A,B=[0],[0]
A+=map(int,input().split())
B+=map(int,input().split())

for i in range(1,N+1):
    A[i]+=A[i-1]
for i in range(1,M+1):
    B[i]+=B[i-1]

ans=0
for i in range(N+1):
    for j in range(M+1):
        x=A[i]+B[j]
        if x>K:
            break
        ans=max(ans,i+j)

print(ans)


Fixed submission:
N,M,K=map(int,input().split())
A,B=[0],[0]
A+=map(int,input().split())
B+=map(int,input().split())

for i in range(1,N+1):
    A[i]+=A[i-1]
for i in range(1,M+1):
    B[i]+=B[i-1]

ans,j=0,M
for i in range(N+1):
    if A[i]>K:
        break
    while j>0 and A[i]+B[j]>K:
        j-=1
    ans=max(ans,i+j)

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

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

x=[-1]*N
valid=True
for _ in range(M):
    s,c=map(int,input().split())
    if x[s-1]!=-1 and x[s-1]!=c:
        print(-1)
        sys.exit(1)
    x[s-1]=c

if N>1 and x[0]==0:
    print(-1)
else:
    ans=0
    for i in range(N):
        if x[i]==-1:
            if i>0 or N==1:
                x[i]=0
            else:
                x[i]=1
        ans=ans*10+x[i]
    print(ans)


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

x=[-1]*N
ok=True
for _ in range(M):
    s,c=map(int,input().split())
    s-=1
    if (s==0 and c==0 and N>1) or x[s]!=-1 and x[s]!=c:
        ok=False
        break
    x[s]=c

if ok:
    ans=0
    for i in range(N):
        if x[i]==-1:
            x[i]=0 if (i>0 or N==1) else 1
        ans=ans*10+x[i]
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
S=input()
print('YNEOS'[sum(map(int,S))%int(s)==0::2])

Fixed submission:
S=input()
print('YNeos'[int(S)%sum(map(int,S))!=0::2])

Buggy python submission (verdict: Runtime Error):
S=input()
print(sum(map(int,S))%int(s)==0

Fixed submission:
S=input()
print('YNeos'[int(S)%sum(map(int,S))!=0::2])
Buggy python submission (verdict: Runtime Error):
import sys
input()
d={k:0 for k in 'AC WA TLE RE'.split()}
for ln in sys.stdin:
    d[ln.strip()]+=1
for k,v in d.items():
    print(k,'x',v)


Fixed submission:
N=int(input())
S=input()
l,r=[0]*N,[0]*N
for i in range(N-1):
    l[i+1]+=l[i]+(S[i]=='W')
for i in range(N-1,0,-1):
    r[i-1]+=r[i]+(S[i]=='E')
ans=3*10**5
for i in range(N):
    ans=min(ans,l[i]+r[i])
print(ans)