Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if a == 0:
        return b
    return gcd(b%a, a)

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

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    l = int(1)
    for e in a:
        l = lcm(l,e)
    s = int(0)
    for e in a:
        s += l//e
    mod = int(1000000007)
    print(int(s % mod))


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

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

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    l = int(1)
    for e in a:
        l = lcm(l,e)
    s = int(0)
    for e in a:
        s += l//e
    mod = int(1000000007)
    print(int(s % mod))

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if a == 0:
        return b
    return gcd(b%a, a)

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

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    l = int(1)
    for e in a:
        l = lcm(l,e)
    s = int(0)
    for e in a:
        s += l/e
    mod = int(1000000007)
    print(int(s % mod))


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

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

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    l = int(1)
    for e in a:
        l = lcm(l,e)
    s = int(0)
    for e in a:
        s += l//e
    mod = int(1000000007)
    print(int(s % mod))

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if a == 0:
        return b
    return gcd(b%a, a)

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

if __name__ == '__main__':
    n = input()
    a = list(map(int, input().split()))
    l = 1
    for e in a:
        l = lcm(l,e)
    s = 0
    for e in a:
        s += l/e
    mod = 1000000007
    print(int(s % mod))


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

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

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    l = int(1)
    for e in a:
        l = lcm(l,e)
    s = int(0)
    for e in a:
        s += l//e
    mod = int(1000000007)
    print(int(s % mod))
Buggy python submission (verdict: Runtime Error):
n = int(input());
point = [[0]*2 for i in range(n) ];
for i in range(n) :
	s = input().split(" ");
	point[i][0] = int(s[0]);
	point[i][1] = int(s[1]);

dict = {}
for i in range(n) :
	for j in range(n) :
		if i != j  :
			x = point[i][0] - point[j][0];
			y = point[i][1] - point[j][1];
			if (x,y) in dict:
				dict[(x,y)] += 1
			else:
				dict[(x,y)] = 1
print(n-max(dict.values()));

Fixed submission:
n = int(input());
if n==1:
	print(n)
	exit(0)
point = [[0]*2 for i in range(n) ];
for i in range(n) :
	s = input().split(" ");
	point[i][0] = int(s[0]);
	point[i][1] = int(s[1]);

dict = {}
for i in range(n) :
	for j in range(n) :
		if i != j  :
			x = point[i][0] - point[j][0];
			y = point[i][1] - point[j][1];
			if (x,y) in dict:
				dict[(x,y)] += 1
			else:
				dict[(x,y)] = 1
print(n-max(dict.values()));
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = map(int, input().split(' '))

ok = True

for i in range(N):
  if a[i] >= sum(a) - a[i]:
    ok = False

print("Yes" if ok else "No")

Fixed submission:
N = int(input())
a = list(map(int, input().split(' ')))
 
ok = True
 
for i in range(N):
  if a[i] >= sum(a) - a[i]:
    ok = False
 
print("Yes" if ok else "No")
Buggy python submission (verdict: Runtime Error):
N, M = stdin()
X = stdin()
X.sort()
dif = [0] * (len(X) - 1)
for i in range(len(X) - 1):
    dif[i] = X[i + 1] - X[i]

dif.sort()
ans = X[-1] - X[0] - sum(dif[-1:-N:-1])
print(0 if ans <= 0 else ans)


Fixed submission:
import math as mt
import itertools as it
import functools as ft
import random as rnd

stdin = lambda type_ = "int", sep = " ": list(map(eval(type_), input().split(sep)))
joint = lambda sep = " ", *args: sep.join(str(i) if type(i) != list else sep.join(map(str, i)) for i in args)

N, M = stdin()
X = stdin()
X.sort()
dif = [0] * (len(X) - 1)
for i in range(len(X) - 1):
    dif[i] = X[i + 1] - X[i]

dif.sort()
ans = X[-1] - X[0] - sum(dif[-1:-N:-1])
print(0 if ans <= 0 else ans)
Buggy python submission (verdict: Runtime Error):
R = lambda type_ = "int": list(map(eval(type_), input().split(' ')))

N, H = R()
a, b = 0, []
while N:
    a_, b_ = R()
    b.append(b_)
    a = max(a, a_)
    N -= 1

b.sort()
i = len(b) - 1
while i >= 0 and H > 0 and b[i] >= a:
    H -= b[i]
    i -= 1
    
if i < 0 and H > 0:
    print(len(b) + (H - 1) // a + 1)
elif H <= 0:
    print(len(b) - i - 1)
elif a > b[i]:
    print(len(b) - i - 1 + (H - 1) // a + 1)


Fixed submission:
s = input()
print(s[:3] + '8' + s[4:])
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
typedef long long int ll;
 
int dh[4] = {1,0,-1,0};
int dw[4] = {0,1,0,-1};
int ddx[20] = {1,1,-1,-1,2,2,2,2,2,1,1,0,0,-1,-1,-2,-2,-2,-2,-2};
int ddy[20] = {1,-1,1,-1,2,1,0,-1,-2,2,-2,2,-2,2,-2,2,1,0,-1,-2};
 
int main()
{
    int dh[4] = {1,0,-1,0};
    int dw[4] = {0,1,0,-1};
  	int ddx[20] = {1,1,-1,-1,2,2,2,2,2,1,1,0,0,-1,-1,-2,-2,-2,-2,-2};
  	int ddy[20] = {1,-1,1,-1,2,1,0,-1,-2,2,-2,2,-2,2,-2,2,1,0,-1,-2};
  	
    int r,c;
    cin >> r >> c;
    int sy,sx,gy,gx;
    cin >> sy >> sx;
  	cin >> gy >> gx;
    sy--,sx--,gy--,gx--;
    vector<vector<char>>v(r,vector<char>(c,'.'));
    for(int i = 0; i < r; i++) for(int j = 0; j < c; j++) cin >> v[i][j];
    vector<vector<int>>dist(r,vector<int>(c,10000000));
    dist[sy][sx] = 0;
    queue<pair<int,int>>que;
    que.push(pair(sy,sx));
  
    while(!que.empty())
    {
        pair<int,int>p;
        p = que.front();
        que.pop();
        int y = p.first;
        int x = p.second;
        for(int i = 0; i < 4; i++)
        {
            int ny = y + dh[i];
            int nx = x + dw[i];
            if(ny >= r || ny < 0 || nx >= c || nx < 0) continue;
            if(dist[ny][nx] <= dist[y][x]) continue;
            if(v[ny][nx] == '#') continue;
            dist[ny][nx] = dist[y][x];
            que.push(pair(ny,nx));
        }
      
      	for(int i = 0; i < 20; i++)
        {
            int ny = y + ddy[i];
            int nx = x + ddx[i];
            if(ny >= r || ny < 0 || nx >= c || nx < 0) continue;
            if(dist[ny][nx] <= dist[y][x]+1) continue;
            if(v[ny][nx] == '#') continue;
            dist[ny][nx] = dist[y][x] + 1;
            que.push(pair(ny,nx));
        }
      	
      
    }
  	if (dist[gy][gx] == 10000000)
    {
      printf("-1");
    }
  	else
    {
    	cout << dist[gy][gx] << endl;
    }
}

Fixed submission:
import math

n,x,t = map(int,input().split())

print(math.ceil(n/x) * t)
Buggy python submission (verdict: Runtime Error):
import math

n,k = map(int,input().split())
a = list(map(int,input().split()))

def cal(lis,x):
    an = 0
    for i in range(len(lis)):
        an += (math.ceil(lis[i] / x) - 1)
        
    return an

left = 0
right = 10**9

for i in range(100):
    m = (left + right) // 2
    
    b = cal(a,m)
    
    if b > k:
        left = m
    else:
        right = m
        
print(m+1)

Fixed submission:
import math

n,k = map(int,input().split())
a = list(map(int,input().split()))

def cal(lis,x):
    an = 0
    for i in range(len(lis)):
        an += (math.ceil(lis[i] / x) - 1)
        
    return an

left = 0
right = 10**9

for i in range(100):
    m = (left + right) / 2
    
    b = cal(a,m)
    
    if b > k:
        left = m
    else:
        right = m
        
print(math.ceil(m))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

MAX = 10**18
ans = 1

for i in a:
    ans *= i
    
if ans > MAX:
    print(-1)
else:
    print(ans)

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

MAX = 10**18
ans = 1

for i in a:
    ans *= i
    if ans > MAX:
        print(-1)
        sys.exit()

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

ans = 0
for i in range(n):
    for j in range(i+1,n):
        if a[i]+a[j] == j-i:
            ans += 1
            
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
sa = [0]*n
wa = [0]*n

ans = 0
for i in range(n):
    sa[i] = a[i]-i
    wa[i] = a[i]+i
b = Counter(wa)
c = Counter(sa)
    
for i in b:
    ans += b[i]*c[-i]
            
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = list(map(int,input().split()))
fl = "Yes"

a.sort(reverse = True)
s = sum(a)

for i in range(m):
    if a[m] < s * (1 / (4*m)):
        fl = "No"
        
print(fl)

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
fl = "Yes"

a.sort(reverse = True)
s = sum(a)

for i in range(m):
    if a[i] < s * (1 / (4*m)):
        fl = "No"
        
print(fl)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p = list(map(int, input().split()))
kt = [0]*n
ans = 0

for i in range(n):
    kt[i] = (p[i]+1) / 2
    
for i in range(k-1,n):
    ans = max(ans , sum(kt[i+1-k:i+1]))
    
print(ans)

Fixed submission:
n,k = map(int,input().split())
p = list(map(int, input().split()))
kt = [0]*n
ans = sum(p[0:k])
prev = sum(p[0:k])

for i in range(k,n):
    prev = prev - p[i-k] + p[i]
    ans = max(ans , prev)
      
print((ans+k)/2)
Buggy python submission (verdict: Time Limit Exceeded):
import math

n,d,a = map(int,input().split())
x = [0]*n
h = [0]*n
for i in range(n):
    x[i] , h[i] = map(int, input().split())
    
itv = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
    itv[i][0] = x[i]
    itv[i][1] = h[i]
itv.sort()
ans = 0
    
for i in range(n):
    atk = 0
    if itv[i][1] > 0:
        atk = math.ceil(itv[i][1]/a)
        itv[i][1] = 0
        for j in range(i+1,n):
            if itv[j][0] <= itv[i][0] + (2*d):
                if itv[j][1] > 0:
                    itv[j][1] -= atk * a
            else:
                break
    ans += atk
    
print(ans)

Fixed submission:
import math
import bisect
 
n,d,a = map(int,input().split())
x = [0]*n
h = [0]*n
for i in range(n):
    x[i] , h[i] = map(int, input().split())
    
itv = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
    itv[i][0] = x[i]
    itv[i][1] = h[i]
itv.sort()
ans = 0

x.sort()
x.append(1145141919810)
h.append(0)

imos = [0]*(n+1)

atk = math.ceil(itv[0][1]/a)
imos[0] += atk * a
b = bisect.bisect(x,itv[0][0] + (2*d))
imos[b] -= atk * a
ans += atk
    
for i in range(1,n):
    atk = 0
    imos[i] += imos[i-1]
    if itv[i][1] > imos[i]:
        atk = math.ceil((itv[i][1]-imos[i])/a)
        imos[i] += atk * a
        b = bisect.bisect(x,itv[i][0] + (2*d))
        imos[b] -= atk * a
    ans += atk

print(ans)

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

n,d,a = map(int,input().split())
x = [0]*n
h = [0]*n
for i in range(n):
    x[i] , h[i] = map(int, input().split())
    
itv = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
    itv[i][0] = x[i]
    itv[i][1] = h[i]
itv.sort()
ans = 0
    
for i in range(n):
    atk = 0
    if itv[i][1] > 0:
        atk = math.ceil(itv[i][1]/a)
        itv[i][1] = 0
        for j in range(i+1,n):
            if itv[j][0] <= itv[i][0] + (2*d):
                itv[j][1] -= atk * a
            else:
                break
    ans += atk
    
print(ans)

Fixed submission:
import math
import bisect
 
n,d,a = map(int,input().split())
x = [0]*n
h = [0]*n
for i in range(n):
    x[i] , h[i] = map(int, input().split())
    
itv = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
    itv[i][0] = x[i]
    itv[i][1] = h[i]
itv.sort()
ans = 0

x.sort()
x.append(1145141919810)
h.append(0)

imos = [0]*(n+1)

atk = math.ceil(itv[0][1]/a)
imos[0] += atk * a
b = bisect.bisect(x,itv[0][0] + (2*d))
imos[b] -= atk * a
ans += atk
    
for i in range(1,n):
    atk = 0
    imos[i] += imos[i-1]
    if itv[i][1] > imos[i]:
        atk = math.ceil((itv[i][1]-imos[i])/a)
        imos[i] += atk * a
        b = bisect.bisect(x,itv[i][0] + (2*d))
        imos[b] -= atk * a
    ans += atk

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

INF = 114514191981036436433-4
h,w = map(int,input().split())

c = [[] for _ in range(h)]
for i in range(h):
    c[i] = input()
            
dx = [1,0,-1,0]
dy = [0,1,0,-1]

ans = 0
for i in range(h):
    for j in range(w):
        for l in range(h):
            for m in range(w):
                if c[i][j] == "#" or c[l][m] == "#":
                    continue
                if i == l and j == m:
                    continue
                    
                d = [[INF for i in range(w)] for j in range(h)]
                
                sx,sy = j,i
                gx,gy = m,l
                
                d[sy][sx] = 0
                que = deque([[sy,sx]])

                while que:
                    y,x = que.popleft()

                    for k in range(4):
                        nx = x + dx[k]
                        ny = y + dy[k]

                        if 0<=nx and nx<w and 0<=ny and ny<h and c[y][x] != '#':
                            if d[ny][nx] > d[y][x] + 1:
                                d[ny][nx]=d[y][x] + 1
                                que.append([ny,nx])
                                
                if d[gy][gx] != INF:         
                    ans = max(d[gy][gx],ans)

print(ans)

Fixed submission:
from collections import deque

h,w = map(int,input().split())
INF = 114514191981036436433-4

c = [None]*h
for i in range(h):
    c[i] = input()
            
dx = [1,0,-1,0]
dy = [0,1,0,-1]

ans = 0
for i in range(h):
    for j in range(w):
        if c[i][j] == "#":
            continue
        
        d = [[INF for i in range(w)] for j in range(h)]
        e = [[0 for i in range(w)] for j in range(h)]

        dx = [1,0,-1,0]
        dy = [0,1,0,-1]

        d[i][j] = 0
        que = deque([[i,j]])

        while que:
            y,x = que.popleft()

            for k in range(4):
                nx = x + dx[k]
                ny = y + dy[k]

                if 0<=nx and nx<w and 0<=ny and ny<h and c[ny][nx] != '#':
                    if d[ny][nx] > d[y][x]+1:
                        d[ny][nx]=d[y][x]+1
                        e[ny][nx] = d[ny][nx]
                        que.append([ny,nx])
                        
        tmax = 0
        for l in range(h):
            tmax = max(tmax,max(e[l]))
        ans = max(ans,tmax)
        
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

n,m = map(int,input().split())
a = set(map(int,input().split()))
a = list(a)
nn = len(a)

g = a[0]
for i in range(nn):
    t = math.gcd(g,a[i])
    
x = a[0]
for i in range(1,nn):
    x *= a[i]
    x //= t
    
fl = 1
ff = x//2
for i in range(nn):
    if ff % a[i] != a[i] // 2:
        fl = 0
        
if fl == 1:
    xx = (m-ff) // x + 1
else:
    xx = 0
    
print(xx)

Fixed submission:
from fractions import gcd

n,m = map(int,input().split())
a = set(map(int,input().split()))
a = list(a)
nn = len(a)

g = a[0]
    
x = a[0]
for i in range(1,nn):
    t = gcd(x,a[i])
    x *= a[i]
    x //= t
    
fl = 1
ff = x//2
for i in range(nn):
    if ff % a[i] != a[i] // 2:
        fl = 0
        
if fl == 1:
    xx = (m-ff) // x + 1
else:
    xx = 0
    
print(xx)
Buggy python submission (verdict: Runtime Error):
import math

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

c = math.gcd(a,b)
print(int(a*b/c))

Fixed submission:
aa,bb = map(int,input().split())
a = aa
b = bb
if aa>bb:
    a = bb
    b = aa
rx = a
ry = b

while 1:
    if rx == 0:
        break
    rx2 = ry%rx
    ry = rx
    rx = rx2

print(int(a*b/ry))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a=list(map(int, input().split()))
b = len(a)
c = 0

for i in range(n-1):
    for j in range(i,n):
        c = c + (a[i] ^ a[j])
        if c>=(10**9+7):
            c = c % (10**9+7)
        
print(c)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
MOD = 10**9 + 7

from collections import Counter
s = []

for i in range(n):
    b = bin(a[i])[2:]
    c = len(b)
    s.append("0"*(60-c) + b)
    
ans = 0
for i in range(60):
    zero = 0
    one = 0
    for j in range(n):
        if s[j][i] == "0":
            zero += 1
        else:
            one += 1
            
    temp = zero * one * (2 ** (59-i)) % MOD
    
    ans = (ans + temp) % MOD
    
print(ans)
Buggy python submission (verdict: Runtime Error):
#ABC145D

MOD = 10 ** 9 + 7
import math
x,y = map(int,input().split())
a,b = -1,-1

for i in range(x+1):
    m = 0
    if (x-i) % 2 == 0:
        m = (x-i) // 2
        if 2*i + m == y:
            if i >= 0 and m >= 0:
                a = i
                b = m
                break
    else:
        continue
        
MAX_N = 10**6

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%MOD)

fact_inv[-1] = pow(fact[-1],mod-2,MOD)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%MOD

def com(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod  
        
        
if a == -1 and b == -1:
    print(0)
else:
    print(com(a+b,a,MOD))

Fixed submission:
#ABC145D

MOD = 10 ** 9 + 7
import math
x,y = map(int,input().split())
a,b = -1,-1

for i in range(x+1):
    m = 0
    if (x-i) % 2 == 0:
        m = (x-i) // 2
        if 2*i + m == y:
            if i >= 0 and m >= 0:
                a = i
                b = m
                break
    else:
        continue
        
MAX_N = 10**6

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%MOD)

fact_inv[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%MOD

def com(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod  
        
        
if a == -1 and b == -1:
    print(0)
else:
    print(com(a+b,a,MOD))

Buggy python submission (verdict: Runtime Error):
#ABC145D

MOD = 10 ** 9 + 7
import math
x,y = map(int,input().split())
a,b = -1,-1

for i in range(x):
    m = 0
    if (x-i) % 2 == 0:
        m = (x-i) // 2
        if 2*i + m == y:
            if i >= 0 and m >= 0:
                a = i
                b = m
                break
    else:
        continue
MAX_N = 10**6

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%MOD)

fact_inv[-1] = pow(fact[-1],mod-2,MOD)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%MOD

def com(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod  
        
        
if a == -1 and b == -1:
    print(0)
else:
    print(com(a+b,a,MOD))

Fixed submission:
#ABC145D

MOD = 10 ** 9 + 7
import math
x,y = map(int,input().split())
a,b = -1,-1

for i in range(x+1):
    m = 0
    if (x-i) % 2 == 0:
        m = (x-i) // 2
        if 2*i + m == y:
            if i >= 0 and m >= 0:
                a = i
                b = m
                break
    else:
        continue
        
MAX_N = 10**6

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%MOD)

fact_inv[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%MOD

def com(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod  
        
        
if a == -1 and b == -1:
    print(0)
else:
    print(com(a+b,a,MOD))
Buggy python submission (verdict: Runtime Error):
h,w,a,b = map(int,input().split())
ans = [[0]*w for i in range(h)]
fl = True

if h == 1:
    for i in range(a):
        ans[0][i] = 1
elif w == 1:
    for i in range(b):
        ans[i][0] = 1
else:
    if h % b == 0 and w % a == 0 and h // b == w // a:
        al = h // b
        for i in range(al):
            for j in range(b):
                for k in range(a):
                    ans[b*i+j][a*i+k] = 1
                    
    else:
        fl = False
        
if fl:
    for i in range(h):
        print(*ans[i],sep = "")
else:
    print("No")

Fixed submission:
h,w,a,b = map(int,input().split())
ans = [[0]*w for i in range(h)]
fl = True

for i in range(a):
    for j in range(b):
        ans[j][i] = 1
        
for i in range(w-a):
    for j in range(h-b):
        ans[b+j][a+i] = 1
        
for i in range(h):
    print(*ans[i],sep = "")
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import copy

n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

for _ in range(m):
    a[n-1] //= 2
    if a[n-1] < a[n-2]:
        b = a[:n-1]
        bisect.insort(b,a[n-1])
        a = copy.deepcopy(b)
    
print(sum(a))

Fixed submission:
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i] *= (-1)
heapq.heapify(a)

for i in range(m):
    b = heapq.heappop(a)
    b = - (b * (-1) // 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)

for _ in range(m):
    a[0] //= 2
    a.sort(reverse = True)
    
print(sum(a))

Fixed submission:
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i] *= (-1)
heapq.heapify(a)

for i in range(m):
    b = heapq.heappop(a)
    b = - (b * (-1) // 2)
    heapq.heappush(a, b)
    
print(-sum(a))
Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
r = [[] for _ in range(n+1)]
bonus = [0] * (n+1)
score = [0] * (n+1)

for i in range(n-1):
    a,b = map(int,input().split())
    r[a].append(b)
for i in range(q):
    p,x = map(int,input().split())
    bonus[p] += x 

def dfs(d,u):
    s[u] = True
    score[u] += bonus[d]
    
    for v in r[u]:
        if not s[v]:
            dfs(d,v)
    
for i in range(1,n+1):
    s = [False] * (n+1)
    dfs(i,i)
        
print(*score[1:])

Fixed submission:
from collections import deque

n,q = map(int,input().split())
r = [[] for _ in range(n)]
bonus = [0] * n
score = [0] * n

for i in range(n-1):
    a,b = map(int,input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)
for i in range(q):
    p,x = map(int,input().split())
    bonus[p-1] += x
q = deque()
q.append(0)
used = [False]*n
used[0] = True
score[0] = bonus[0]

while q:
    p = q.popleft()
    for i in r[p]:
        if not used[i]:
            used[i] = True
            score[i] += score[p] + bonus[i]
            q.append(i)
        
print(*score)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9 + 7

s = input()
n = len(s)

dp = [[0]* 13 for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    if s[i] != '?':
        for j in range(13):
            a = s[i]
            a = int(a)
            keta = (j*10 + a) % 13
            dp[i+1][keta] += dp[i][j]
            dp[i+1][keta] % MOD
    else:
        for j in range(13):
            for k in range(10):
                keta = (j*10 + k) % 13
                dp[i+1][keta] += dp[i][j]
                dp[i+1][keta] % MOD
                
print(dp[n][5] % MOD)

Fixed submission:
MOD = 10**9 + 7

s = input()
n = len(s)

dp = [[0]* 13 for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    if s[i] != '?':
        for j in range(13):
            a = s[i]
            a = int(a)
            keta = (j*10 + a) % 13
            dp[i+1][keta] += dp[i][j]
            dp[i+1][keta] %= MOD
    else:
        for j in range(13):
            for k in range(10):
                keta = (j*10 + k) % 13
                dp[i+1][keta] += dp[i][j]
                dp[i+1][keta] %= MOD
                
print(dp[n][5] % MOD)