Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int,input().split())
A=list(map(int,input().split()))

A.sort(reverse=True)
#print(A)

B=A[0:min(N,M)]

for i in range(M):
    idx = B.index(max(B))

    B[idx] = int(B[idx] / 2.0)
#    A.sort(reverse=True)

ans = 0
for i in range(N):
    if i < len(B):
        ans+=B[i]
    else:
        ans += A[i]

print(ans)

Fixed submission:
import heapq

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

for i in range(N):
    A[i] = -A[i]

heapq.heapify(A)

for j in range(M):
    a = heapq.heappop(A)
    b = -1*((-a) // 2)
    heapq.heappush(A,b)

print(-sum(A))

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

A.sort(reverse=True)
#print(A)

B=A[0:min(N,M)]

for i in range(M):
    idx = B.index(max(B))

    B[idx] = int(B[idx] / 2.0)
#    A.sort(reverse=True)

ans = 0
for i in range(N):
    if i < len(B):
        ans+=B[i]
    else:
        ans += A[i]

print(ans)

Fixed submission:
import heapq

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

for i in range(N):
    A[i] = -A[i]

heapq.heapify(A)

for j in range(M):
    a = heapq.heappop(A)
    b = -1*((-a) // 2)
    heapq.heappush(A,b)

print(-sum(A))

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

A.sort(reverse=True)
#print(A)

B=A[0:max(N,M)]

for i in range(M):
    idx = B.index(max(B))

    B[idx] = int(B[idx] / 2.0)
#    A.sort(reverse=True)

ans = 0
for i in range(N):
    if i < len(B):
        ans+=B[i]
    else:
        ans += A[i]

print(ans)

Fixed submission:
import heapq

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

for i in range(N):
    A[i] = -A[i]

heapq.heapify(A)

for j in range(M):
    a = heapq.heappop(A)
    b = -1*((-a) // 2)
    heapq.heappush(A,b)

print(-sum(A))

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

A.sort(reverse=True)
#print(A)

for i in range(M):
    idx = A.index(max(A))

    A[idx] = int(A[idx] / 2.0)
#    A.sort(reverse=True)

ans = 0
for i in range(N):
    ans += A[i]

print(ans)

Fixed submission:
import heapq

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

for i in range(N):
    A[i] = -A[i]

heapq.heapify(A)

for j in range(M):
    a = heapq.heappop(A)
    b = -1*((-a) // 2)
    heapq.heappush(A,b)

print(-sum(A))

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

A.sort(reverse=True)
#print(A)

for i in range(M):
    A[0] = int(A[0] / 2.0)
    A.sort(reverse=True)

ans = 0
for i in range(N):
    ans += A[i]

print(ans)

Fixed submission:
import heapq

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

for i in range(N):
    A[i] = -A[i]

heapq.heapify(A)

for j in range(M):
    a = heapq.heappop(A)
    b = -1*((-a) // 2)
    heapq.heappush(A,b)

print(-sum(A))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

eachbit=[0]*30
for i in range(N):
    bin_str = format(A[i],'030b')
#    print(bin_str)
    for j in range(31):
        if bin_str[-j] == '1':
            eachbit[j] += 1

even = True
for e in eachbit:
    if e % 2 != 0:
        even = False

if even:
    print('Yes')
else:
    print('No')

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

eachbit=[0]*32
for i in range(N):
    bin_str = format(A[i],'032b')
#    print(bin_str)
    for j in range(1,33):
        if bin_str[-j] == '1':
            eachbit[j-1] += 1

#print(eachbit)
even = True
for e in eachbit:
    if e % 2 != 0:
        even = False

if even:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
L,R=map(int,input().split())

min=2019
for i in range(L,R):
    for j in range(i+1,R+1):
        mod = (i*j) % 2019
#        print(str(i)+' '+str(j)+' '+str(mod))
        if mod == 0:
            min = 0
            break
        if mod < min:
            min = mod
print(min)



Fixed submission:
L,R=map(int,input().split())

ans=2019
for i in range(L,min(R,L+2018)):
    for j in range(i+1,min(R+1,L+2019)):
        mod = (i*j) % 2019
#        print(str(i)+' '+str(j)+' '+str(mod))
        if mod == 0:
            ans = 0
            break
        if mod < ans:
            ans = mod
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D=map(int,input().split())

def lcm(x,y):
    return (x*y)//math.gcd(x,y)

BdivC=B//C
BdivD=B//D
BdivCD=B//(lcm(C,D))
AdivC=(A-1)//C
AdivD=(A-1)//D
AdivCD=(A-1)//(lcm(C,D))

"""
print(BdivC)
print(BdivD)
print(AdivC)
print(AdivD)
print(BdivCD)
print(AdivCD)
"""

ans=B-(A-1)-(BdivC-AdivC+BdivD-AdivD-BdivCD+AdivCD)

print(ans)

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

def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

BdivC=B//C
BdivD=B//D
BdivCD=B//(lcm(C,D))
AdivC=(A-1)//C
AdivD=(A-1)//D
AdivCD=(A-1)//(lcm(C,D))

ans=B-(A-1)-(BdivC-AdivC+BdivD-AdivD-BdivCD+AdivCD)

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

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:

Fixed submission:
input_angle = int(input())
input_length = input()

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
input_angle = int(input())
input_length = input()

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:

Fixed submission:
input_angle = int(input())
input_length = input()

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
input_angle = int(input())
input_length = input()

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-2):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:

Fixed submission:
input_angle = int(input())
input_length = input()

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
input_angle = int(input())
input_length = int(input())

length = input_length.split(' ')
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += length[i]
  
if sum > length[-1]:
  print('Yes')
else:
  print('No')

Fixed submission:
input_angle = int(input())
input_length = input()

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
passwd = set()
for i in range(1,n-1):
    pre = set(s[:i])
    post = set(s[i+1:])
    for c0 in pre:
        for c1 in post:
            passwd.add(c0+s[i]+c1)
print(len(passwd))

Fixed submission:
import collections as col
n = int(input())
s = list(input())
passwd = set()
pre = col.Counter({'0':0,'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,
                                '7':0,'8':0,'9':0})
post = col.Counter(s[1:])
for i in range(1,n-1):
    pre[s[i-1]] += 1
    post[s[i]] = max(0, post[s[i]]-1) 
    for c0 in pre:
        for c1 in post:
            if pre[c0] != 0 and post[c1] != 0:
                passwd.add(c0+s[i]+c1)
print(len(passwd))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
passwd = set()
for i in range(1,n-1):
    pre = set(s[:i])
    post = (s[i+1:])
    for c0 in pre:
        for c1 in post:
            passwd.add(c0+s[i]+c1)
print(len(passwd))

Fixed submission:
import collections as col
n = int(input())
s = list(input())
passwd = set()
pre = col.Counter({'0':0,'1':0,'2':0,'3':0,'4':0,'5':0,'6':0,
                                '7':0,'8':0,'9':0})
post = col.Counter(s[1:])
for i in range(1,n-1):
    pre[s[i-1]] += 1
    post[s[i]] = max(0, post[s[i]]-1) 
    for c0 in pre:
        for c1 in post:
            if pre[c0] != 0 and post[c1] != 0:
                passwd.add(c0+s[i]+c1)
print(len(passwd))
Buggy python submission (verdict: Runtime Error):
import numpy as np

a, b, x = list(map(int, input().split()))

xlim = a*b/2*a
if x<xlim:
    theta = np.arctan(a*b*b/2/x)/np.pi*180
else:
    theta = np.arctan(2*(a*a*b-x)/a**3)/np.pi*180

print(theta)


Fixed submission:
import numpy as np

a, b, x = list(map(int, input().split()))

xlim = a*b/2*a
if x<xlim:
    theta = np.arctan(a*b*b/2/x)/np.pi*180
else:
    theta = np.arctan(2*(a*a*b-x)/a**3)/np.pi*180

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

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
b = [0]
for _ in range(m):
    if a[-1] > b[-1]:
        am = a.pop()
        am = am // 2
        bisect.insort_left(b, am)
    else:
        bm = b.pop()
        bm = bm // 2
        bisect.insort_left(b, bm)
        
    
print(sum(a)+sum(b))

Fixed submission:
import heapq

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
b = []
heapq.heappush(b,0)
for _ in range(m):
    bm = -b[0]
    if len(a) != 0 and a[-1] > bm:
        am = a.pop()
        am = am // 2
        heapq.heappush(b,-am)
    else:
        bm = -heapq.heappop(b)
        bm = bm // 2
        heapq.heappush(b,-bm)
        
    
print(sum(a)-sum(b))

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

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
for _ in range(m):
    am = a.pop()
    am = am // 2
    bisect.insort_left(a, am)
    
print(sum(a))
    

Fixed submission:
import heapq

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
b = []
heapq.heappush(b,0)
for _ in range(m):
    bm = -b[0]
    if len(a) != 0 and a[-1] > bm:
        am = a.pop()
        am = am // 2
        heapq.heappush(b,-am)
    else:
        bm = -heapq.heappop(b)
        bm = bm // 2
        heapq.heappush(b,-bm)
        
    
print(sum(a)-sum(b))
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int, input().split()))

n2 = math.ceil(n/2)
cnt = 0
ans = 0
seq = []
for i in reversed(range(n2)):
    sumi = sum([a[j] for j in range(i,n,i+1)])
    if sumi%2 != a[i-1]:
        a[i*n//i-1] += 1
        seq.append(i*n//i)
        if a[i*n//i-1] > 1:
            ans = -1
            break
        else:
            cnt += 1
    
if ans == -1:
    print(-1)
else:
    print(cnt)
    print(' '.join(list(map(str, seq))))

Fixed submission:

n = int(input())
a = list(map(int, input().split()))
b = [0]*n
cnt = 0
ans = 0
seq = []
for i in reversed(range(1,n+1)):
    sumi = sum(b[i-1:n:i])
    if sumi % 2 == a[i-1]:
        continue
    else:
        b[i-1] = 1
        seq.append(i)
        cnt += 1
    
if ans == -1:
    print(-1)
else:
    print(cnt)
    print(' '.join(list(map(str, seq))))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 13 15:36:35 2019
ABC129D
@author: maezawa
"""

h, w = list(map(int, input().split()))
arr = [['*']*(w+2)]
for _ in range(h):
    arr.append(list('*' +input()+'*'))
arr.append(['*']*(w+2))

#result = arr[:]
#print(arr)

left = [[0]*(w+2) for _ in range(h+2)]
right = [[0]*(w+2) for _ in range(h+2)]
up = [[0]*(w+2) for _ in range(h+2)]
down = [[0]*(w+2) for _ in range(h+2)]

for i in range(1, h+1):
    for j in range(1, w+1):
        if arr[i][j] == '#':
            left[i][j] = 0
        else:
            left[i][j] = left[i][j-1] + 1
for i in range(1, h+1):
    for j in reversed(range(1, w+1)):
        if arr[i][j] == '#':
            right[i][j] = 0
        else:
            right[i][j] = right[i][j+1] + 1
            
#print(left,sep='\n')
#print(right,sep='\n')

for j in range(1, w+1):
    for i in range(1, h+1):
        if arr[i][j] == '#':
            down[i][j] = 0
        else:
            down[i][j] = down[i-1][j] + 1
for j in range(1, w+1):
    for i in reversed(range(1, h+1)):
        if arr[i][j] == '#':
            up[i][j] = 0
        else:
            up[i][j] = up[i+1][j] + 1
            
maxlight = 0
for i in range(1,h+1):
    for j in range(1,w+1):
        if arr[i][j] == '#':
            continue
        n = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3
        #result[i][j] = n
        if n > maxlight:
            maxlight = n
            
print(maxlight)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sat Jul 13 15:36:35 2019
ABC129D
@author: maezawa
"""

h, w = list(map(int, input().split()))
arr = [['*']*(w+2)]
for _ in range(h):
    arr.append(list('*' +input()+'*'))
arr.append(['*']*(w+2))

#result = arr[:]
#print(arr)

left = [[0]*(w+2) for _ in range(h+2)]
right = [[0]*(w+2) for _ in range(h+2)]
up = [[0]*(w+2) for _ in range(h+2)]
down = [[0]*(w+2) for _ in range(h+2)]

for i in range(1, h+1):
    for j in range(1, w+1):
        if arr[i][j] == '#':
            left[i][j] = 0
        else:
            left[i][j] = left[i][j-1] + 1
for i in range(1, h+1):
    for j in reversed(range(1, w+1)):
        if arr[i][j] == '#':
            right[i][j] = 0
        else:
            right[i][j] = right[i][j+1] + 1
            
#print(left,sep='\n')
#print(right,sep='\n')

for j in range(1, w+1):
    for i in range(1, h+1):
        if arr[i][j] == '#':
            down[i][j] = 0
        else:
            down[i][j] = down[i-1][j] + 1
for j in range(1, w+1):
    for i in reversed(range(1, h+1)):
        if arr[i][j] == '#':
            up[i][j] = 0
        else:
            up[i][j] = up[i+1][j] + 1
            
maxlight = 0
for i in range(1,h+1):
    for j in range(1,w+1):
        if arr[i][j] == '#':
            continue
        n = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3
        #result[i][j] = n
        if n > maxlight:
            maxlight = n
            
print(maxlight)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
maxxy = -10**9
for i in range(2**n):
    s = '0'*n + format(i, 'b')
    sl = list(s)
    #print(s)
    xy = 0
    for j in range(n):
        a = sl.pop(-1)
        if a == '1':
            xy += v[j]
            xy -= c[j]
    if xy > maxxy:
        maxxy = xy
        #print(s)
print(maxxy)

Fixed submission:
import itertools as itr 

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
maxxy = -10**9
for i2 in itr.product((0,1), repeat = n):
    xy = 0
    for j in range(n):
        if i2[j] == 1:
            xy += v[j]
            xy -= c[j]
    if xy > maxxy:
        maxxy = xy
        #print(s)
print(maxxy)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()

cnt = 0
i = 0
while True:
    if s[i] == '.':
        break
    i += 1

if i == n:
    pass
else:
    for j in range(i, n):
        if s[j] == '#':
            cnt += 1

print(cnt)

Fixed submission:
n = int(input())
s = str(input())
#n = len(s)

bl = s.count('#')
wh = s.count('.')
cnt = wh
mincnt = cnt
for i in range(n):
    if s[i] == '#':
        cnt += 1
    else:
        cnt -= 1
    mincnt = min(mincnt, cnt)

print(mincnt)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = list(map(int, input().split()))
s = input()

def f(i):
    cnt = 0
    for j in range(i-1):
        #print(s[j:j+2])
        if s[j:j+2] == 'AC':
            cnt += 1
    return cnt

for _ in range(q):
    l, r = list(map(int, input().split()))
    #print(s[l-1:r])
    print(f(r) - f(l))

Fixed submission:
n, q = list(map(int, input().split()))
s = input()

#def f(i):
#    cnt = 0
#    for j in range(i-1):
#        #print(s[j:j+2])
#        if s[j:j+2] == 'AC':
#            cnt += 1
#    return cnt

ftab = [0]*(n+1)
cnt = 0

for i in range(n-1):
    if s[i:i+2] == 'AC':
        cnt += 1
    ftab[i+2] = cnt

for _ in range(q):
    l, r = list(map(int, input().split()))
    #print(s[l-1:r])
    print(ftab[r] - ftab[l])

Buggy python submission (verdict: Runtime Error):
 n, q = list(map(int, input().split()))
s = input()

def f(i):
    cnt = 0
    for j in range(i-1):
        #print(s[j:j+2])
        if s[j:j+2] == 'AC':
            cnt += 1
    return cnt

for _ in range(q):
    l, r = list(map(int, input().split()))
    #print(s[l-1:r])
    print(f(r) - f(l))


Fixed submission:
n, q = list(map(int, input().split()))
s = input()

#def f(i):
#    cnt = 0
#    for j in range(i-1):
#        #print(s[j:j+2])
#        if s[j:j+2] == 'AC':
#            cnt += 1
#    return cnt

ftab = [0]*(n+1)
cnt = 0

for i in range(n-1):
    if s[i:i+2] == 'AC':
        cnt += 1
    ftab[i+2] = cnt

for _ in range(q):
    l, r = list(map(int, input().split()))
    #print(s[l-1:r])
    print(ftab[r] - ftab[l])
Buggy python submission (verdict: Runtime Error):
import numpy as np
a, b = list(map(int, input().split()))

n = int(np.ceil(np.log2(b)))+1
c = [0]*n
for i in range(n):
    ra = (a-1) % (2**(i+1))
    if ra < 2**i:
        ra1 = 0
    else:
        ra1 = 1
    rb = b % (2**(i+1))
    if rb < 2**i:
        rb1 = 0
    else:
        rb1 = 1    
    if ra1 == rb1:
        c[n-(i+1)] = '0'
    else:
        c[n-(i+1)] = '1'

s = ''.join(c)
ans = int(s, 2)
print(ans)    

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

a2 = True
b2 = False
if a % 2 != 0:
    a0 = a
    a += 1
    a2 = False
if b % 2 == 0:
    b0 = b
    b -= 1
    b2 = True

c = b-(a-1)
if c % 2 == 0:
    if (c // 2) % 2 == 0:
        ans = 0
    else:
        ans = 1 
elif ((c-1) // 2) % 2 == 0:
    ans = 0 ^ b
else:
    ans = 1 ^ b
    
if a2 == False:
    ans = ans ^ a0
if b2 == True:
    ans = ans ^ b0

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input()
b = input()
c = input()
cnt2 = 0
cnt3 = 0
for i in range(n):
  nsame = len(set([a[i], b[i], c[i]]))
    if nsame == 2:
      cnt2 += 1
    elif nsame == 1:
      cnt3 += 1
ans = 2*n - cnt2 - 2*cnt3
print(ans)
    

Fixed submission:
n = int(input())
a = input()
b = input()
c = input()
cnt2 = 0
cnt3 = 0
for i in range(n):
  nsame = len(set([a[i], b[i], c[i]]))
  if nsame == 2:
    cnt2 += 1
  elif nsame == 1:
    cnt3 += 1
ans = 2*n - cnt2 - 2*cnt3
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = input()
b = input()
c = input()
cnt2 = 0
cnt3 = 0
for i in range(n):
  nsame = len(set([a[i], b[i], c[i]])):
    if nsame == 2:
      cnt2 += 1
    elif nsame == 1:
      cnt3 += 1
ans = 2*n - cnt2 - 2*cnt3
print(ans)
    

Fixed submission:
n = int(input())
a = input()
b = input()
c = input()
cnt2 = 0
cnt3 = 0
for i in range(n):
  nsame = len(set([a[i], b[i], c[i]]))
  if nsame == 2:
    cnt2 += 1
  elif nsame == 1:
    cnt3 += 1
ans = 2*n - cnt2 - 2*cnt3
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
  ai, bi = list(map(int, input()))
  a.append((ai, bi, ai+bi))
a.sort(key = lambda x: x[2], reverse=True)
tak = 0
aok = 0
for i in range(n):
  if i%2 == 0:
    tak += a[i][0]
  else:
    aok += a[i][1]
print(tak - aok)
  

Fixed submission:
n = int(input())
a = []
for i in range(n):
  ai, bi = list(map(int, input().split()))
  a.append((ai, bi, ai+bi))
a.sort(key = lambda x: x[2], reverse=True)
tak = 0
aok = 0
for i in range(n):
  if i%2 == 0:
    tak += a[i][0]
  else:
    aok += a[i][1]
print(tak - aok)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a, b = list(map(int, input().split()))
p = list(map(int, input().split()))
cnta = 0
cntb = 0
cnt c = 0
for pi in p:
  if pi <= a:
    cnta += 1
  elif pi <= b:
    cntb += 1
  else:
    cntc += 1
ans = min(cnta, cntb, cntc)
print(ans)


Fixed submission:
n = int(input())
a, b = list(map(int, input().split()))
p = list(map(int, input().split()))
cnta = 0
cntb = 0
cntc = 0
for pi in p:
  if pi <= a:
    cnta += 1
  elif pi <= b:
    cntb += 1
  else:
    cntc += 1
ans = min([cnta, cntb, cntc])
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
dp = [0]*(n+1)
a = list(map(int, input().split()))
  
dp[1] = abs(a[1]-a[0])
for i in range(2,n+1):
  dp[i] =  min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]))
print(dp[n])
           

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

dp = [10**9+1]*n
dp[0] = 0
dp[1] = dp[0] + abs(a[1]-a[0])

for i in range(2, n):
    dp[i] = min([dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2])])

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n = int(input())
dp = [0]*(n+1)
a = []
for _ in range(n):
  a.append(int(input()))
  
dp[1] = abs(a[1]-a[0])
for i in range(2,n+1):
  dp[i] =  min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]))
print(dp[n])
           

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

dp = [10**9+1]*n
dp[0] = 0
dp[1] = dp[0] + abs(a[1]-a[0])

for i in range(2, n):
    dp[i] = min([dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2])])

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
import itertools as itr

n, wmax = list(map(int, input().split()))
w = [0]*(n+1)
v = [0]*(n+1)

for i in range(1, n+1):
    wi, vi = list(map(int, input().split()))
    w[i] = wi
    v[i] = vi
vmax = sum(v)
    
dp = [[10**9+7]*(vmax+1) for _ in range(n+1)]
for i in range(n+1):
    dp[i][0]=0

for i, j in itr.product(range(1, n+1), range(1, vmax+1)):
    if j-v[i] >= 0:
        dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]]+w[i])
        #print((i,j), dp[i][j])
    else:
        dp[i][j] = dp[i-1][j]

ans = [j for j in range(vmax+1) if dp[n][j] <= wmax]       
print(ans[-1])

Fixed submission:
import itertools as itr

n, wmax = list(map(int, input().split()))
w = [0]*(n+1)
v = [0]*(n+1)

for i in range(1, n+1):
    wi, vi = list(map(int, input().split()))
    w[i] = wi
    v[i] = vi
vmax = sum(v)
    
dp = [[10**9+7]*(vmax+1) for _ in range(n+1)]
for i in range(n+1):
    dp[i][0]=0

for i, j in itr.product(range(1, n+1), range(1, vmax+1)):
    if j-v[i] >= 0:
        dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]]+w[i])
        #print((i,j), dp[i][j])
    else:
        dp[i][j] = dp[i-1][j]

ans = [j for j in range(vmax+1) if dp[n][j] <= wmax]       
print(ans[-1])