Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        exit(0)
for sz in range(3, 102, 2):
    if sz > len(s):
        break
    for i in range(len(s) - sz + 1):
        curr = s[i:i + sz]
        for it in curr:
            if curr.count(it) > sz // 2:
                print(i + 1, i + sz)
                exit(0)
print("-1 -1")


Fixed submission:
s = input()
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        exit(0)
for sz in range(3, 4, 2):
    if sz > len(s):
        break
    for i in range(len(s) - sz + 1):
        curr = s[i:i + sz]
        for it in curr:
            if curr.count(it) > sz // 2:
                print(i + 1, i + sz)
                exit(0)
print("-1 -1")

Buggy python submission (verdict: Runtime Error):
s = input()
for sz in [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]
    if sz > len(s):
        break
    for i in range(len(s) - sz + 1):
        curr = s[i:i + sz]
        for it in curr:
            if curr.count(it) > sz // 2:
                print(i + 1, i + sz)
                exit(0)
print("-1 -1")


Fixed submission:
s = input()
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        exit(0)
for sz in range(3, 4, 2):
    if sz > len(s):
        break
    for i in range(len(s) - sz + 1):
        curr = s[i:i + sz]
        for it in curr:
            if curr.count(it) > sz // 2:
                print(i + 1, i + sz)
                exit(0)
print("-1 -1")

Buggy python submission (verdict: Runtime Error):
s = input()
for sz in [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]
    for i in range(len(s) - sz):
        curr = s[i:i + sz]
        if curr.count(curr[0]) > sz // 2 or curr.count(curr[1]) > sz // 2 or curr.count(curr[2]) > sz // 2:
            print(i + 1, i + sz)
            exit(0)
print("-1 -1")


Fixed submission:
s = input()
for i in range(len(s) - 1):
    if s[i] == s[i + 1]:
        print(i + 1, i + 2)
        exit(0)
for sz in range(3, 4, 2):
    if sz > len(s):
        break
    for i in range(len(s) - sz + 1):
        curr = s[i:i + sz]
        for it in curr:
            if curr.count(it) > sz // 2:
                print(i + 1, i + sz)
                exit(0)
print("-1 -1")
Buggy python submission (verdict: Time Limit Exceeded):
mod = 998244353

n = 0
x = []
d = []

def search(s):
    lo = 0
    hi = n - 1
    while lo <= hi:
        mid = (lo + hi) // 2
        if s > x[mid]:
            lo = mid + 1
        elif s < x[mid]:
            hi = mid - 1
        else:
            return mid
    return max(lo, hi)


if __name__ == "__main__":
    xd = []
    n = int(input())
    for i in range(n):
        xi, di = map(int, input().split())
        xd.append((xi, di))

    xd.sort()
    x = list(map(lambda x: x[0], xd))
    d = list(map(lambda x: x[1], xd))

    dp = [0] * (n+1)
    dp[-1] = 1
    next = [0] * n

    for i in range(n-1, -1, -1):
        currend = search(x[i] + d[i])
        j =  i+1
        while j < currend:
            currend = max(search(x[j] + d[j]), currend)
            j += 1
        next[i] = currend

    for i in range(n - 1, -1, -1):
        dp[i] = (dp[next[i]] + dp[i + 1]) % mod
    
    print(dp[0])
    
    # print(x, d)
    # print(dp)
    # print(next)



Fixed submission:
mod = 998244353

n = 0
x = []
d = []

def search(s):
    lo = 0
    hi = n - 1
    while lo <= hi:
        mid = (lo + hi) // 2
        if s > x[mid]:
            lo = mid + 1
        elif s < x[mid]:
            hi = mid - 1
        else:
            return mid
    return max(lo, hi)


if __name__ == "__main__":
    xd = []
    n = int(input())
    for i in range(n):
        xi, di = map(int, input().split())
        xd.append((xi, di))

    xd.sort()
    x = list(map(lambda x: x[0], xd))
    d = list(map(lambda x: x[1], xd))

    dp = [0] * (n+1)
    dp[-1] = 1
    next = [0] * n

    st = []
    st.append((n, 2e9))

    for i in range(n-1, -1, -1):

        while st[-1][1] < x[i] + d[i]:
            st.pop()
        next[i] = st[-1][0]
        st.append((i, x[i]))

    for i in range(n - 1, -1, -1):
        dp[i] = (dp[next[i]] + dp[i + 1]) % mod
    
    print(dp[0])
Buggy python submission (verdict: Runtime Error):
N = int(input())
pritn((N+1)//2)

Fixed submission:
N = int(input())
print((N+1)//2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
a.sort()
ans = a[-1] - a[0]
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = a[-1] - a[0]
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
a = a.sort()
ans = a[-1] - a[0]
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = a[-1] - a[0]
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
price = 700 + 100*s.count('o')
print(price)

Fixed submission:
S = input()
price = 700 + 100*S.count('o')
print(price)
Buggy python submission (verdict: Runtime Error):
r, g, b = map(int, input().split())
num = 10*y + z
if num % 4 == 0:
  print("YES")
else:
  print("NO")


Fixed submission:
r, g, b = map(int, input().split())
num = 10*g + b
if num % 4 == 0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [i for i in range(1,n+1)]
counter = 0
while(True):
    if len([i for i in s if i % 2 == 0])==1:
        s = [i for i in s if i % 2 == 0]
        print(int(s[-1] * (2 ** counter)))
        break
    else:
        s = [i/2 for i in s]
        counter += 1


Fixed submission:
n = int(input())
s = [i for i in range(1,n+1)]
counter = 0
while(True):
    if len(s)==1:
        print(1)
        break
    if len([i for i in s if i % 2 == 0])==1:
        s = [i for i in s if i % 2 == 0]
        print(int(s[0]) * (2 ** counter))
        break
    else:
        s = [i/2 for i in s]
        counter += 1
Buggy python submission (verdict: Runtime Error):
x,a = map(int,input())

print('0') if x<a else print('10')

Fixed submission:
x,a = map(int,input().split())

print('0') if x<a else print('10')
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

S = [a, b, c, d, e]
R = [a%10, b%10, c%10, d%10, e%10]
C = []
for i in R:
  if i > 0:
    C.append(i)
    
min = S[R.index(min(C))]

sum = 0
for i in S:
  sum += -(-i//10)*10
  
print(sum - (-(-min//10)*10) + min)

Fixed submission:
A = [int(input()) for _ in[0]*5]
B = [-(-a//10)*10-a for a in A]

print(sum(A)+sum(B)-max(B))
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N ==1:
  print('Hello World')
else:
  print(int(input())+int(print()))

Fixed submission:
N = int(input())

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

if R < 1200:
  print(ABC)
elif 1200 <= R and R < 2800:
  print(ARC)
else:
  print(AGC)

Fixed submission:
R = int(input())

if R < 1200:
  print('ABC')
elif 1200 <= R and R < 2800:
  print('ARC')
else:
  print('AGC')
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())

print(max(abs(a-b), abs(b-c), abs(c-a))

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

print(c - a)
Buggy python submission (verdict: Runtime Error):
A,B=input().split()

mydict = {"A":11, "B":12, "C":14, "D":13, "E":14, "F":15}

print('>') if mydict(A) > mydict(B) else print('<') if mydict(A) < mydict(B) else print('=')


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

mydict = {"A":10, "B":11, "C":12, "D":13, "E":14, "F":15}

print('>') if mydict[A] > mydict[B] else print('<') if mydict[A] < mydict[B] else print('=')

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

mydict = {"A":11, "B":12, "C":14, , "D":13, "E":14, "F":15}

print('>') if mydict(A) > mydict(B) else print('<') if mydict(A) < mydict(B) else print('=')

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

mydict = {"A":10, "B":11, "C":12, "D":13, "E":14, "F":15}

print('>') if mydict[A] > mydict[B] else print('<') if mydict[A] < mydict[B] else print('=')
Buggy python submission (verdict: Runtime Error):
r = int(input())
g = int(input())

print(2g-r)

Fixed submission:
r = int(input())
g = int(input())

print(2*g-r)
Buggy python submission (verdict: Runtime Error):
x,t = map(int,input())

print(x-t) if x > t else print('0')


Fixed submission:
x, t = map(int, (input().split()))
print(x-t if x-t > 0 else 0)

Buggy python submission (verdict: Runtime Error):
x,t = map(int,input())

print(x-t) if x > t else print(0)

Fixed submission:
x, t = map(int, (input().split()))
print(x-t if x-t > 0 else 0)
Buggy python submission (verdict: Runtime Error):
n, m = = map(int, input().split())
print((n-1)*(m-1))

Fixed submission:
n, m = map(int, input().split())
print((n-1)*(m-1))

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input())
print((n-1)*(m-1))

Fixed submission:
n, m = map(int, input().split())
print((n-1)*(m-1))
Buggy python submission (verdict: Runtime Error):
n = int(input())

for i in range(7):
  if n > 2**i:
    ans = 2**i
print(ans)

Fixed submission:
n = int(input())

for i in range(7):
  if n >= 2**i:
    ans = 2**i
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(n*(n-1)//2)

Fixed submission:
s = input()
t = input()
r = 0
if s[0] == t[0]:
    r += 1
if s[1] == t[1]:
    r += 1
if s[2] == t[2]:
    r += 1
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
r = 0
for i in range(n):
    r += i
print(r)


Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())
r = 0
bc = b // c
bd = b // d
bcd = b // ((c * d) // math.gcd(c, d))
ac = -(-a // c)
ad = -(-a // d)
acd = -(-a // ((c * d) // math.gcd(c, d)))
print(b - a + 1 - bc + ac - 1 - bd + ad - 1 + bcd - acd + 1)


Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

a, b, c, d = map(int, input().split())
r = 0
bc = b // c
bd = b // d
bcd = b // lcm(c, d)
ac = -(-a // c)
ad = -(-a // d)
acd = -(-a // lcm(c, d))
print(b - a + 1 - bc + ac - 1 - bd + ad - 1 + bcd - acd + 1)
Buggy python submission (verdict: Time Limit Exceeded):
n, x = map(int, input().split())
li = list(map(int, input().split()))
t = []
for i in li:
    t.append(abs(i - x))
for j in range(min(t)):
    if all(k % (min(t) - j) == 0 for k in t):
        print(min(t) - j)
        exit()


Fixed submission:
n, x = map(int, input().split())
li = list(map(int, input().split()))
t = []
for i in li:
    t.append(abs(i - x))
divisors = []
for i in range(1, int(min(t) ** 0.5) + 1):
    if min(t) % i == 0:
        divisors.append(i)
        if i != min(t) // i:
            divisors.append(min(t) // i)
divisors.sort()
divisors = divisors[::-1]
for j in divisors:
    if all(k % j == 0 for k in t):
        print(j)
        exit()
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 or i > b - k:
        print(i)


Fixed submission:
a, b, k = map(int, input().split())
for i in range(a, min(a + k, b + 1)):
    print(i)
for i in range(max(a + k, b - k + 1), b + 1):
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nlist = [int(input()) for i in range(n)]
xlist = []
c = 0
x = 1
while x != 2 and x not in xlist and c < n:
    xlist.append(x)
    x = nlist[x - 1]
    c += 1
if x == 2:
    print(c)
else:
    print(-1)


Fixed submission:
n = int(input())
nlist = [int(input()) for i in range(n)]
c = 0
x = 1
while x != 2 and c < n:
    x = nlist[x - 1]
    c += 1
if x == 2:
    print(c)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nlist = [int(input()) for i in range(n)]
xlist = []
c = 0
x = 1
while x != 2 and x not in xlist and c < n:
    xlist.append(x)
    x = nlist[x - 1]
    c += 1
if x == 2:
    print(c)
else:
    print(-1)


Fixed submission:
n = int(input())
nlist = [int(input()) for i in range(n)]
c = 0
x = 1
while x != 2 and c < n:
    x = nlist[x - 1]
    c += 1
if x == 2:
    print(c)
else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
nlist = [int(input()) for i in range(n)]
xlist = []
c = 0
x = 1
while x != 2 and x not in xlist:
    xlist.append(x)
    x = nlist[x - 1]
    c += 1
if x == 2:
    print(c)
else:
    print(-1)


Fixed submission:
n = int(input())
nlist = [int(input()) for i in range(n)]
c = 0
x = 1
while x != 2 and c < n:
    x = nlist[x - 1]
    c += 1
if x == 2:
    print(c)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
h1 = int(input())
m = 1
for i in range(h1):
    m = m * (i + 1)
print(m % (10 ** 9 + 7))


Fixed submission:
h1 = int(input())
m = 1
for i in range(h1):
    m = (m * (i + 1)) % (10 ** 9 + 7)
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
h1 = int(input())
m = 1
for i in range(h1):
    m = m * (i + 1)
print(m % (10 ** 9 + 7))


Fixed submission:
h1 = int(input())
m = 1
for i in range(h1):
    m = (m * (i + 1)) % (10 ** 9 + 7)
print(m)
Buggy python submission (verdict: Runtime Error):

A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b=[]
for i in range(N):
    b.append(int(input()))


for i in range(3):
    for j in range(3):
        for x in range(N):
            if A[i][j]==b[x]:
                A[i][j]=0

for i in range(3):
    if A[i][0]==0 and A[i][1]==0 and A[i][2]==0:
        print("Yes")
        break
for i in range(3):
    if A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
        print("Yes")
        break
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    print("Yes")
    break
if A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
    print("Yes")
    break
print("No")


Fixed submission:
dic = {}
for i in range(3):
  arr = input().split()
  for j in range(3):
    dic[arr[j]] = (i,j)
    
n = int(input())
appear=[[False for _ in range(3)] for __ in range(3)]

for _ in range(n):
  b = input()
  if b in dic:
    i, j = dic[b]
    appear[i][j] = True

ans = 'No'
for i in range(3):
  if appear[i][0] and appear[i][1] and appear[i][2]:
    ans = 'Yes'
    break
  if appear[0][i] and appear[1][i] and appear[2][i]:
    ans = 'Yes'
    break
if appear[0][0] and appear[1][1] and appear[2][2]:
  ans = 'Yes'
if appear[0][2] and appear[1][1] and appear[2][0]:
  ans = 'Yes'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=list(map(int,input().split()))
ans=0
for i,p in enumerate(P,1):
    if min(P[:i])==p:
        ans+=1
print(ans)

Fixed submission:
N=int(input())
P=map(int, input().split())
ans=0
mv=N
for p in P:
    if p<=mv:
        ans+=1
        mv=p
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())
print(A*B//math.gcd(A,B))

Fixed submission:
from fractions import gcd
A,B=map(int,input().split())
print(A*B//gcd(A,B))
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=[int(input()) for _ in range(M)]
n1,n2=0,1
for i in range(1,N+1):
    if i in A:
        n1=n2
        n2=0
    else:
        tmp=n2
        n2=(n1+n2)%1000000007
        n1=tmp
print(n2)

Fixed submission:
N,M=map(int,input().split())
A=[int(input()) for _ in range(M)]
ai=0
n1,n2=0,1
for i in range(1,N+1):
    if ai<M and i==A[ai]:
        ai+=1
        n1=n2
        n2=0
    else:
        tmp=n2
        n2=(n1+n2)%1000000007
        n1=tmp
print(n2)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
x={i for i in range(10**5+1)}
for _ in range(M):
    L,R=map(int,input().split())
    tmp={i for i in range(L,R+1)}
    x=x&tmp
print(len(x))

Fixed submission:
N,M=map(int,input().split())
L,R=[],[]
for _ in range(M):
    l,r=map(int,input().split())
    L.append(l)
    R.append(r)
Lm=max(L)
Rm=min(R)
print(Rm-Lm+1 if Rm-Lm>=0 else 0)
Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=input()
ans=[]
for _ in range(Q):
    l,r=map(int,input().split())
    print(S[l-1:r].count('AC'))

Fixed submission:
N,Q=map(int,input().split())
S=input()
t=[0,0]
for i in range(2,N+1):
    t.append(t[-1]+(S[i-2:i]=='AC'))
for _ in range(Q):
    l,r=map(int,input().split())
    print(t[r]-t[l])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=input()
ans=[]
for _ in range(Q):
    l,r=map(int,input().split())
    ans.append(S[l-1:r].count('AC'))
for i in ans:
    print(i)

Fixed submission:
N,Q=map(int,input().split())
S=input()
t=[0,0]
for i in range(2,N+1):
    t.append(t[-1]+(S[i-2:i]=='AC'))
for _ in range(Q):
    l,r=map(int,input().split())
    print(t[r]-t[l])
Buggy python submission (verdict: Time Limit Exceeded):
A,B=map(int,input().split())
res=A
for a in range(A+1,B+1):
    res=res^a
print(res)

Fixed submission:
A,B=map(int,input().split())
A-=1
if A%4==1:
    A=1
elif A%4==2:
    A+=1
elif A%4==3:
    A=0
if B%4==1:
    B=1
elif B%4==2:
    B+=1
elif B%4==3:
    B=0
print(A^B)

Buggy python submission (verdict: Time Limit Exceeded):
A,B=map(int,input().split())
res=A
for a in range(A+1,B+1):
    res=res^a
print(res)

Fixed submission:
A,B=map(int,input().split())
A-=1
if A%4==1:
    A=1
elif A%4==2:
    A+=1
elif A%4==3:
    A=0
if B%4==1:
    B=1
elif B%4==2:
    B+=1
elif B%4==3:
    B=0
print(A^B)

Buggy python submission (verdict: Time Limit Exceeded):
A,B=map(int,input().split())
n=0
tmp=B
while tmp>0:
    tmp=tmp//2
    n+=1
L=[]
for a in range(A,B+1):
    l=[]
    for i in range(n):
        if a%2==0:
            l.append(0)
        else:
            l.append(1)
        a=a//2
    L.append(l)
rv=[1 if sum(k)%2==1 else 0 for k in zip(*L)]
v=0
for i,b in enumerate(rv):
    v+=b*(2**i)
print(v)

Fixed submission:
A,B=map(int,input().split())
A-=1
if A%4==1:
    A=1
elif A%4==2:
    A+=1
elif A%4==3:
    A=0
if B%4==1:
    B=1
elif B%4==2:
    B+=1
elif B%4==3:
    B=0
print(A^B)
Buggy python submission (verdict: Runtime Error):
N=int(input())
print('ABC' if N<1000 else 'A

Fixed submission:
N=int(input())
print('ABC' if N<1000 else 'ABD')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
dp=[100000]*(N+1)
dp[0]=0
que=[(0,0)]
while len(que)!=0:
    que.sort(key=lambda x:x[0])
    c=que[0][0]
    v=que[0][1]
    que=que[1:]
    if c>dp[v]:
        continue
    pow6=1
    while v+pow6<=N:
        if dp[v]+1<dp[v+pow6]:
            dp[v+pow6]=dp[v]+1
            que.append((dp[v+pow6],v+pow6))
        pow6*=6
    pow9=1
    while v+pow9<=N:
        if dp[v]+1<dp[v+pow9]:
            dp[v+pow9]=dp[v]+1
            que.append((dp[v+pow9],v+pow9))
        pow9*=9
print(dp[N])

Fixed submission:
N=int(input())
dp=[N]*(N+1)
dp[0]=0
for i in range(1,N+1):
    dp[i]=min(dp[i],dp[i-1]+1)
    pow6 = 1
    while i>=pow6:
        dp[i]=min(dp[i],dp[i-pow6]+1)
        pow6*=6
    pow9 = 1
    while i>=pow9:
        dp[i]=min(dp[i],dp[i-pow9]+1)
        pow9*=9
print(dp[N])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
dp=[-1]*(N+1)
dp[0]=0
que=[0]
while len(que)!=0:
    v=que[0]
    que=que[1:]
    pow6=1
    while v+pow6<=N:
        if dp[v+pow6]==-1:
            dp[v+pow6]=dp[v]+1
            que.append(v+pow6)
        pow6*=6
    pow9=1
    while v+pow9<=N:
        if dp[v+pow9]==-1:
            dp[v+pow9]=dp[v]+1
            que.append(v+pow9)
        pow9*=9
print(dp[N])

Fixed submission:
N=int(input())
dp=[N]*(N+1)
dp[0]=0
for i in range(1,N+1):
    dp[i]=min(dp[i],dp[i-1]+1)
    pow6 = 1
    while i>=pow6:
        dp[i]=min(dp[i],dp[i-pow6]+1)
        pow6*=6
    pow9 = 1
    while i>=pow9:
        dp[i]=min(dp[i],dp[i-pow9]+1)
        pow9*=9
print(dp[N])

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

N=int(input())

memo=[-1]*(N+1)
memo[0]=0

def f(n):
    global memo
    if memo[n]!=-1:
        return memo[n]
    cnt=n
    pow6=1
    while pow6<=n:
        cnt=min(cnt,f(n-pow6)+1)
        pow6*=6
    pow9=1
    while pow9<=n:
        cnt=min(cnt,f(n-pow9)+1)
        pow9*=9
    memo[n]=cnt
    return cnt

print(f(N))

Fixed submission:
N=int(input())
dp=[N]*(N+1)
dp[0]=0
for i in range(1,N+1):
    dp[i]=min(dp[i],dp[i-1]+1)
    pow6 = 1
    while i>=pow6:
        dp[i]=min(dp[i],dp[i-pow6]+1)
        pow6*=6
    pow9 = 1
    while i>=pow9:
        dp[i]=min(dp[i],dp[i-pow9]+1)
        pow9*=9
print(dp[N])
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = [(int(i)+1.0)/2.0 for i in input().split()]
ans = 0
tmp = p[:k]
for i in range(k,n):
    tmp += p[i]-p[i-k]
    ans = max(ans, tmp)
print('{:.12f}'.format(ans))


Fixed submission:
n, k = map(int, input().split())
p = [(int(i)+1.0)/2.0 for i in input().split()]
ans = 0
for i in range(k):
    ans += p[i]
tmp1 = ans
for i in range(k, n):
    tmp2 = (tmp1 - p[i-k])+p[i]
    ans = max(ans, tmp2)
    tmp1 = tmp2
print('{:.12f}'.format(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int, input().split())
p=[int(i) for i in input().split()]

ans=0
for i in range(n-k+1):
  tmp=0
  for j in range(k):
    tmp+=(p[i+j]+1.0)/2.0
  ans = max(ans, tmp)
print('{:.12f}'.format(ans))


Fixed submission:
n, k = map(int, input().split())
p = [(int(i)+1.0)/2.0 for i in input().split()]
ans = 0
for i in range(k):
    ans += p[i]
tmp1 = ans
for i in range(k, n):
    tmp2 = (tmp1 - p[i-k])+p[i]
    ans = max(ans, tmp2)
    tmp1 = tmp2
print('{:.12f}'.format(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int, input().split())
p=[int(i) for i in input().split()]

ans=0
for i in range(n-k+1):
  tmp=0
  for j in range(k):
    tmp+=(p[i+j]+1.0)/2.0
  ans = max(ans, tmp)
print('{:.12f}'.format(ans))

Fixed submission:
n, k = map(int, input().split())
p = [(int(i)+1.0)/2.0 for i in input().split()]
ans = 0
for i in range(k):
    ans += p[i]
tmp1 = ans
for i in range(k, n):
    tmp2 = (tmp1 - p[i-k])+p[i]
    ans = max(ans, tmp2)
    tmp1 = tmp2
print('{:.12f}'.format(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = [int(i) for i in input().split()]

cnt = 0
for i in range(n):
    min_val = min(p[:i+1])
    if min_val >= p[i]:
        cnt += 1

print(cnt)

Fixed submission:
n = int(input())
p = [int(i) for i in input().split()]

cnt = 0
min_val = p[0]
for i in range(n):
    min_val = min(min_val, p[i])
    if min_val >= p[i]:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

result = [[0] * 2 for i in range(n)]

for _ in range(m):
    tmp_i, s = input().split()
    i = int(tmp_i)
    if result[i][0] == 1:
        continue
    if s == 'AC':
        result[i][0] += 1
    else:
        result[i][1] += 1

print(sum([result[i][0] for i in range(n)]),
      sum([result[i][1] for i in range(n)]))


Fixed submission:
n, m = map(int, input().split())

ac = [0] * n
wa = [0] * n
wa_total = 0
for _ in range(m):
    tmp_i, s = input().split()
    i = int(tmp_i) - 1
    if ac[i] == 1:
        continue
    if s == 'AC':
        ac[i] = 1
        wa_total += wa[i]
    else:
        wa[i] += 1

print(sum(ac), wa_total)