Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n, m = map(int, input().split())
a = map(int, input().split())
a = sorted(a)
for i in range(m):
  a[-1] = int(a[-1] / 2)
  tmp = a[:-1]
  p = bisect.bisect_left(tmp, a[-1])
  a = tmp[:p] + [a[-1]] + tmp[p:]
print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)

for i in range(m):
  tmp = int(heapq.heappop(a) / 2)
  heapq.heappush(a, tmp)
print(-1 * sum(a))

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

n, m = map(int, input().split())
a = map(int, input().split())
a = sorted(a)
for i in range(m):
  a[-1] = int(a[-1] / 2)
  tmp = a[:-1]
  p = bisect.bisect_left(tmp, a[-1])
  a = tmp[:p] + [a[-1]] + tmp[p:]
print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)

for i in range(m):
  tmp = int(heapq.heappop(a) / 2)
  heapq.heappush(a, tmp)
print(-1 * sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = map(int, input().split())
a = sorted(a)[::-1]
for i in range(m):
  a[0] = int(a[0] / 2)
  a = sorted(a)[::-1]
print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)

for i in range(m):
  tmp = int(heapq.heappop(a) / 2)
  heapq.heappush(a, tmp)
print(-1 * sum(a))
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = list(map(int,iput().split()))
cnt = 1
dis = 0
for i in range(n):
  dis += l[i]
  if dis > x:
    break
  cnt += 1
print(cnt)

Fixed submission:
n, x = map(int, input().split())
l = list(map(int,input().split()))
cnt = 1
dis = 0
for i in range(n):
  dis += l[i]
  if dis > x:
    break
  cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
if 1 in a and 2 in a:
    print(0)
    exit()
ans = 1
k = 0
if a[-1]!=n:
    a.append(n)

mod = 10**9+7
max = 10**5+1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, max + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

for i in a:
    if i+1 in a:
        print(0)
        exit()
    else:
        if i-k<=2:
            m = 1
        elif i-k==3:
            m = 2
        else:
            m = 0
            f = i-k-1
            for j in range(f//2,-1,-1):
                m += cmb(f-j,j,mod)
        ans *= m
        ans %= mod
        k = i
print(ans%mod)

Fixed submission:
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
a = set(a)
mod = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
for i in range(2,n+1):
    if i not in a:
        dp[i] = dp[i-1]+dp[i-2]
print(dp[-1]%mod)
Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
s = [input() for _ in range(h)]
yoko = []
tate = []
for i in range(h):
    l = []
    k = s[i][0]
    m = 1
    for j in range(1,w):
        if s[i][j]!=k:
            if k=='.':
                l += [m]*m
            else:
                l += [0]*m
            m = 1
            k = s[i][j]
        else:
            m += 1
    if k=='.':
        l += [m]*m
    else:
        l += [0]*m
    yoko.append(l)

for i in range(w):
    l = []
    k = s[0][i]
    m = 1
    for j in range(1,h):
        if s[j][i]!=k:
            if k=='.':
                l += [m]*m
            else:
                l += [0]*m
            m = 1
            k = s[j][i]
        else:
            m += 1
    if k=='.':
        l += [m]*m
    else:
        l += [0]*m
    tate.append(l)
ans = 0
for i in range(h):
    for j in range(w):
        if yoko[i][j] and tate[j][i]:
            ans = max(ans,yoko[i][j]+tate[j][i]-1)
print(ans)

Fixed submission:
h,w = map(int,input().split())
s = [input() for _ in range(h)]
yoko = []
tate = []
for i in range(h):
    l = []
    k = s[i][0]
    m = 1
    for j in range(1,w):
        if s[i][j]!=k:
            if k=='.':
                l += [m]*m
            else:
                l += [0]*m
            m = 1
            k = s[i][j]
        else:
            m += 1
    if k=='.':
        l += [m]*m
    else:
        l += [0]*m
    yoko.append(l)

for i in range(w):
    l = []
    k = s[0][i]
    m = 1
    for j in range(1,h):
        if s[j][i]!=k:
            if k=='.':
                l += [m]*m
            else:
                l += [0]*m
            m = 1
            k = s[j][i]
        else:
            m += 1
    if k=='.':
        l += [m]*m
    else:
        l += [0]*m
    tate.append(l)
ans = 0
for i in range(h):
    for j in range(w):
        if yoko[i][j] and tate[j][i]:
            ans = max(ans,yoko[i][j]+tate[j][i]-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
q = int(input())
ans = []
for _ in range(q):
    x,d,n = map(int,input().split())
    a = np.arange(x,x+n*d,d)
    ans.append(np.prod(a)%1000003)
for i in ans:
    print(i)

Fixed submission:
mod = 10**6+3
max = 10**6+2
g1 = [1, 1]
for i in range( 2, max + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
def rev(a):
    return pow(a,mod-2,mod)
def f(x,d,n):
    if d==0:
        return pow(x,n,mod)
    else:
        d_r = rev(d)
        xdr = d_r * x % mod
        if xdr==0:
            return 0
        elif (xdr+n-1)>=mod:
            return 0
        else:
            return (g1[xdr+n-1]*rev(g1[xdr-1]%mod)*pow(d,n,mod))%mod
ans = []
q = int(input())
for _ in range(q):
    x,d,n = map(int,input().split())
    ans.append(f(x,d,n))
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
ans = 0
MOD = 10**9+7
for i in range(1,n):
    ans += i*(n-i)*(m**2)
for i in range(1,m):
    ans += i*(m-i)*(n**2)
from scipy.misc import comb
print((ans*comb(m*n-2,k-2,exact=True))%MOD)

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
dict = {}
for i in range(n):
    if a[i] not in dict:
        dict[a[i]] = 0
    dict[a[i]] += 1
for _ in range(m):
    b,c = map(int,input().split())
    if c not in dict:
        dict[c] = 0
    dict[c] += b
keys = list(dict.keys())
keys = sorted(keys)[::-1]
ans = 0
cnt = 0
for i in range(len(keys)):
    if n-cnt<=dict[keys[i]]:
        ans += keys[i] * (n-cnt)
        break
    else:
        ans += keys[i] * dict[keys[i]]
        cnt += dict[keys[i]]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int,input().split())
R,G,B,ans = 0,0,0,0
for i in range(n//r+1):
    for j in range((n-i*r)//g+1):
        for k in range((n-i*r-j*g)//b+1):
            if r*i+j*g+k*b==n:
                ans +=1
print(ans)

Fixed submission:
r,g,b,n = map(int,input().split())
ans = 0
for i in range(n//r+1):
    for j in range((n-i*r)//g+1):
        num = n-i*r-j*g
        if num%b==0:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(int(n**0.5)-1,n):
    if n%i==n//i:
        ans +=1

print(ans)

Fixed submission:
n = int(input())
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
div = make_divisors(n)
for i in div[1:]:
    if n//(i-1)==n%(i-1):
        ans += i-1

print(ans)
Buggy python submission (verdict: Runtime Error):
h,w,n = map(int,input().split())
sr,sc = map(int,input().split())
s = input()
t = input()
def taka(k,pos):
    if k=='U' and pos[0]-1<=h-pos[0]+1:
        pos[0] -= 1
    if k=='D' and h-pos[0]<=pos[0]:
        pos[0] += 1
    if k=='R' and w-pos[1]<=pos[1]:
        pos[1] += 1
    if k=='L' and pos[1]-1<=w-pos[1]+1:
        pos[1] -= 1
    return pos
def ao(k,pos):
    if k=='U' and pos[0]-1>=h-pos[0]+1:
        pos[0] -= 1
    if k=='D' and h-pos[0]>=pos[0]:
        pos[0] += 1
    if k=='R' and w-pos[1]>=pos[1]:
        pos[1] += 1
    if k=='L' and pos[1]-1>=w-pos[1]+1:
        pos[1] -= 1
    return pos
pos = [sr,sc]
for i in range(n):
    pos = taka(s[i],pos)
    if pos[0]<=0 or pos[1]=0 or pos[0]>h or pos[1]>w:
        print('NO')
        exit()
    pos = ao(t[i],pos)
print('YES')

Fixed submission:
h,w,n = map(int,input().split())
sr,sc = map(int,input().split())
s = input()
t = input()
wr = sc
wl = sc
hu = sr
hd = sr
def taka(k,wr,wl,hu,hd):
    if k=='U':
        hu -= 1
    if k=='D':
        hd += 1
    if k=='R':
        wr += 1
    if k=='L':
        wl -= 1
    return wr,wl,hu,hd
def ao(k,wr,wl,hu,hd):
    if k=='U':
        hd = max(1,hd-1)
    if k=='D':
        hu = min(h,hu+1)
    if k=='R':
        wl = min(w,wl+1)
    if k=='L':
        wr = max(1,wr-1)
    return wr,wl,hu,hd
for i in range(n):
    wr,wl,hu,hd = taka(s[i],wr,wl,hu,hd)
    if wl==0 or hu==0 or hd==h+1 or wr==w+1:
        print('NO')
        exit()
    wr,wl,hu,hd = ao(t[i],wr,wl,hu,hd)
print('YES')
Buggy python submission (verdict: Runtime Error):
n = int(input())
c = [0] + [int(input()) for _ in range(200001)]
dp = [0] * (n+1)
num = 1
for i in range(n):
    if c[i]!=c[i+1]:
        num += dp[c[i+1]]
        dp[c[i+1]] = num
print(num%(10**9+7))

Fixed submission:
n = int(input())
c = [0] + [int(input()) for _ in range(n)]
dp = [0] * (200001)
num = 1
for i in range(n):
    if c[i]!=c[i+1]:
        num += dp[c[i+1]]
        dp[c[i+1]] = num
print(num%(10**9+7))

Buggy python submission (verdict: Runtime Error):
n = int(input())
c = [0] + [int(input()) for _ in range(n)]
dp = [0] * (n+1)
num = 1
for i in range(n):
    if c[i]!=c[i+1]:
        num += dp[c[i+1]]
        dp[c[i+1]] = num
print(num)

Fixed submission:
n = int(input())
c = [0] + [int(input()) for _ in range(n)]
dp = [0] * (200001)
num = 1
for i in range(n):
    if c[i]!=c[i+1]:
        num += dp[c[i+1]]
        dp[c[i+1]] = num
print(num%(10**9+7))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

def f(x):
    if x==0:
        return [0]
    k=2
    l = []
    while True:
        mul = k>>1
        if mul>x:
            fin = mul>>1
            l[-1]=x-fin+1
            break
        fin = mul>>1
        l.append(x//k*mul+max(x%k+1-k//2,0))
        k = k<<1
    l = l[::-1]
    return l
l1 = f(b)
l2 = f(a-1)
k=1
ans=0
while not l1==[]:
    if l2==[]:
        t = l1.pop()
        if t%2==1:
            ans+=k
    else:
        t = l1.pop()-l2.pop()
        if t%2==1:
            ans+=k
    k = k<<1
print(ans)

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

def f(x):
    if x<=0:
        return [0]
    k=2
    l = []
    while True:
        mul = k>>1
        if mul>x:
            fin = mul>>1
            l[-1]=x-fin+1
            break
        fin = mul>>1
        l.append(x//k*mul+max(x%k+1-k//2,0))
        k = k<<1
    l = l[::-1]
    return l
l1 = f(b)
l2 = f(a-1)
k=1
ans=0
while not l1==[]:
    if l2==[]:
        t = l1.pop()
        if t%2==1:
            ans+=k
    else:
        t = l1.pop()-l2.pop()
        if t%2==1:
            ans+=k
    k = k<<1
print(ans)

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

def f(x):
    k=2
    l = []
    while True:
        mul = k>>1
        if mul>x:
            fin = mul>>1
            l[-1]=x-fin+1
            break
        fin = mul>>1
        l.append(x//k*mul+max(x%k+1-k//2,0))
        k = k<<1
    l = l[::-1]
    return l
l1 = f(b)
l2 = f(a-1)
k=1
ans=0
while not l1==[]:
    if l2==[]:
        t = l1.pop()
        if t%2==1:
            ans+=k
    else:
        t = l1.pop()-l2.pop()
        if t%2==1:
            ans+=k
    k = k<<1
print(ans)


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

def f(x):
    if x<=0:
        return [0]
    k=2
    l = []
    while True:
        mul = k>>1
        if mul>x:
            fin = mul>>1
            l[-1]=x-fin+1
            break
        fin = mul>>1
        l.append(x//k*mul+max(x%k+1-k//2,0))
        k = k<<1
    l = l[::-1]
    return l
l1 = f(b)
l2 = f(a-1)
k=1
ans=0
while not l1==[]:
    if l2==[]:
        t = l1.pop()
        if t%2==1:
            ans+=k
    else:
        t = l1.pop()-l2.pop()
        if t%2==1:
            ans+=k
    k = k<<1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
while True:
    pos_0 = s.find('01')
    pos_1 = s.find('10')
    if pos_0==-1 and pos_1==-1:
        break
    pos = max(pos_0,pos_1)
    s = s[:pos]+s[pos+2:]
    ans+=2
print(ans)


Fixed submission:
s = input()
print(min(s.count('0')*2,s.count('1')*2))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
while True:
    pos_0 = s.find('01')
    pos_1 = s.find('10')
    if pos_0==-1 and pos_1==-1:
        break
    pos = max(pos_0,pos_1)
    s = s.replace(s[pos:pos+2],'',1)
    ans+=2
print(ans)

Fixed submission:
s = input()
print(min(s.count('0')*2,s.count('1')*2))
Buggy python submission (verdict: Runtime Error):
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(n)]
INF = 10**9
def dfs(cur,a,b,c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret2 = dfs(cur+1,a+l[cur],b,c)+10
    ret3 = dfs(cur+1,a,b+l[cur],c)+10
    ret4 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)
print(dfs(0,0,0,0))

Fixed submission:
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
INF = 10**9
def dfs(cur,a,b,c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c) > 0 else INF
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c)+10
    ret2 = dfs(cur+1,a,b+l[cur],c)+10
    ret3 = dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
def f(a,b):
    if b==0:
        return a
    else:
        return f(b,a%b)
a = sorted(a)
ans = float('inf')
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        ans = min(ans,f(a[i],a[j]))
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
memo = {}
def f(a,b):
    if b==0:
        return a
    else:
        return f(b,a%b)
a = sorted(a)
ans = float('inf')
for i in range(len(a)-1):
    ans = min(ans,f(a[i],a[i+1]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
d = []
for i in range(len(x)-1):
    d.append(x[i+1]-x[i])
if n==1:
    print(x[-1]-x[0])
elif n>=len(x):
    print(0)
else:
    for i in range(n-1):
        d.remove(max(d))
    print(sum(d))

Fixed submission:
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
d = []
for i in range(len(x)-1):
    d.append(x[i+1]-x[i])
d = sorted(d)
if n==1:
    print(x[-1]-x[0])
elif n>=len(x):
    print(0)
else:
    dis = 0
    for i in range(n-1):
        dis+=d[-i-1]
    print(sum(d)-dis)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
d = []
for i in range(len(x)-1):
    d.append(x[i+1]-x[i])
if n==1:
    print(x[-1]-x[0])
else:
    for i in range(n-1):
        d.remove(max(d))
    print(sum(d))

Fixed submission:
n,m = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
d = []
for i in range(len(x)-1):
    d.append(x[i+1]-x[i])
d = sorted(d)
if n==1:
    print(x[-1]-x[0])
elif n>=len(x):
    print(0)
else:
    dis = 0
    for i in range(n-1):
        dis+=d[-i-1]
    print(sum(d)-dis)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort()
k = 1
twos = []
while k<2*10**5+1:
    twos += [k]
    k = k<<1
l = []
key = a[-1]
a.pop()
ans = 0
while True:
    for k in range(len(twos)-1):
        if twos[k]<key and key<twos[k+1]:
            two = twos[k+1]
            break
    for j in range(len(a)):
        if a[j]==two-key:
            a.remove(a[j])
            ans +=1
            break
    if not a==[]:
        key = a[-1]
        a.pop()
    else:
        break
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
from collections import Counter
dic = Counter(a)
ans = 0
for k in range(len(a)-1,-1,-1):
    if dic[a[k]]==0:
        continue
    dic[a[k]] -= 1
    t = 2**a[k].bit_length()-a[k]
    if dic[t]:
        dic[t] -= 1
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,x = map(int, input().split())
def burger(x):
    if x==0:
        return 'P'
    else:
        return 'B'+burger(x-1)+'P'+burger(x-1)+'B'
burger = burger(n)
print(burger[:x].count('P'))

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

a,p = [1], [1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(N,X):
    if N==0:
        return 0 if X<=0 else 1
    elif X<=1+a[N-1]:
        return f(N-1,X-1)
    else:
        return p[N-1]+1+f(N-1,X-2-a[N-1])

print(f(n,x))
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        H = l[0][2]+abs(i-l[0][0])+abs(j-l[0][1])
        for k in range(1,n):
            if not h==max(H-abs(i-l[k][0])-abs(j-l[k][1]), 0):
                break
            if k==n-1 and h>0:
                print(i,j,h)
                import sys
                sys.exit()

Fixed submission:
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh = sorted(xyh, key = lambda x: -x[2])
tx, ty, th = xyh[0]
for Cx in range(101):
  for Cy in range(101):
    H = th + abs(tx - Cx) + abs(ty - Cy)
    if(all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x,y,h in xyh)):
      print(Cx, Cy, H)
      exit()
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int,input().split()))
l1 = []
l2 = []
for i,v_ in enumerate(v):
    if i%2==0:
        l1.append(v_)
    else:
        l2.append(v_)

from collections import Counter
if set(l1)==set(l2):
    print(n//2)
else:
    c1 = Counter(l1).most_common(2)
    c2 = Counter(l2).most_common(2)
    if c1[0][0]==c2[0][0]:
        print(n-max(c1[0][1]+c2[1][1], c1[1][1]+c2[0][1]))
    else:
        print(n-c1[0][1]-c2[0][1])


Fixed submission:
n = input()
for n_ in n:
    if n_=='1':
        print('9',end='')
    else:
        print('1',end='')
print()
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int,input().split()))
l1 = []
l2 = []
for i,v_ in enumerate(v):
    if i%2==0:
        l1.append(v_)
    else:
        l2.append(v_)

from collections import Counter
if set(l1)==set(l2):
    print(n//2)
else:
    c1 = Counter(l1).most_common(2)
    c2 = Counter(l2).most_common(2)
    if c1[0][0]==c2[0][0]:
        print(n-max(v[0][1]+v[1][1], v[1][1]+v[0][1]))
    else:
        print(n-v[0][1]-v[0][1])


Fixed submission:
n = int(input())
v = list(map(int,input().split()))
l1 = []
l2 = []
for i,v_ in enumerate(v):
    if i%2==0:
        l1.append(v_)
    else:
        l2.append(v_)

from collections import Counter
if len(set(v))==1:
    print(n//2)
else:
    c1 = Counter(l1).most_common(2)
    c2 = Counter(l2).most_common(2)
    if c1[0][0]==c2[0][0]:
        print(n-max(c1[0][1]+c2[1][1], c1[1][1]+c2[0][1]))
    else:
        print(n-c1[0][1]-c2[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(m)]
a = sorted(a,key=lambda x:x[1])
ans = [0]
for a_ in a:
    for i,k in enumerate(ans):
        if a_[0]<k and a_[1]>=k:
            break
        elif i==len(ans)-1:
            ans.append(a_[1])
            break
print(len(ans)-1)

Fixed submission:
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(m)]
a = sorted(a,key=lambda x:x[1])
ans = [0]
for a_ in a:
    for i,k in enumerate(ans):
        if a_[0]<k and a_[1]>=k:
            break
        elif i==len(ans)-1:
            ans.append(a_[1])
            break
print(len(ans)-1)
Buggy python submission (verdict: Runtime Error):
n = str(input())
sum = 0
for i in range(len(n)):
    sum += int(n[i])
if n%sum==0:
    print('Yes')
else:
    print('No')

Fixed submission:
n = str(input())
sum = 0
for i in range(len(n)):
    sum += int(n[i])
if int(n)%sum==0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n = str(input())
sum = 0
for i in range(len(n)):
    sum += int(n[i])
if n%sum=0:
    print('Yes')
else:
    print('No')

Fixed submission:
n = str(input())
sum = 0
for i in range(len(n)):
    sum += int(n[i])
if int(n)%sum==0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n = str(input())
sum = 0
for i in n:
    sum += int(i)
if n%sum=0:
    print('Yes')
else:
    print('No')

Fixed submission:
n = str(input())
sum = 0
for i in range(len(n)):
    sum += int(n[i])
if int(n)%sum==0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
memo = [0 for i in range(1000001)]
def f(i):
    if memo[i]:
        return memo[i]
    if i==0 or i%2==1:
        return 0
    else:
        memo[i] = 1+f(i//2)
        return memo[i]
ans = 0
for a_ in a:
    ans += f(a_)
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
memo = {}
def f(i):
    if i in memo.keys():
        return memo[i]
    if i==0 or i%2==1:
        return 0
    else:
        memo[i] = 1+f(i//2)
        return memo[i]
ans = 0
for a_ in a:
    ans += f(a_)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
c = [6**i for i in range(1,7)]
c.extend([9**i for i in range(1, 6)])
c = sorted(c)[::-1]
dp = [0]*100000
for i in range(1,n+1):
    dp[i]=dp[i-1]+1
    for c_ in c:
        if i>=c_:
            dp[i]=min(dp[i],dp[i-c_]+1)
print(dp[n])

Fixed submission:
n = int(input())
c = [6**i for i in range(1,7)]
c.extend([9**i for i in range(1, 6)])
c = sorted(c)[::-1]
dp = [0]*1000000
for i in range(1,n+1):
    dp[i]=dp[i-1]+1
    for c_ in c:
        if i>=c_:
            dp[i]=min(dp[i],dp[i-c_]+1)
print(dp[n])