Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
X = list(map(int, input().split()))
a = sum(X)
b = sum(X[i]**2 for i in range(n))
m = np.floor(a/n)
if m + 1/2 <= a/n:
  m += 1
else:
  break
s = n*(m**2) - 2*a*m + b
print(int(s))


Fixed submission:
import numpy as np
n = int(input())
X = list(map(int, input().split()))
a = sum(X)
b = sum(X[i]**2 for i in range(n))
m = np.floor(a/n)
if m + 1/2 <= a/n:
  m += 1
s = n*(m**2) - 2*a*m + b
print(int(s))

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
X = list(map(int, input().split()))
a = sum(X)
b = sum(X[i]**2 for i in range(n))
m = math.floor(a/n)
if m + 1/2 <= a/n:
  m += 1
else:
  break
s = n*(m**2) - 2*a*m + b
print(s)

Fixed submission:
import numpy as np
n = int(input())
X = list(map(int, input().split()))
a = sum(X)
b = sum(X[i]**2 for i in range(n))
m = np.floor(a/n)
if m + 1/2 <= a/n:
  m += 1
s = n*(m**2) - 2*a*m + b
print(int(s))
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
p=10**9+7
k = 1
for i in range(n):
  k = 2*k % p
N = k - 1

fact = [1]
k = 1
for i in range(1, 10**5+1):
    k = k*i%p
    fact.append(k)
    
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def mod_e(n,p):
    res = 0
    while n >= p:
        res += n//p
        n = n//p
    return res

def mod_fact(n,p):
    if n==0:
        return 1
    res = mod_fact(n//p,p)
    
    if n//p %2 != 0:
        return res*(p-fact[n%p])%p
    return res*fact[n%p]%p

def mod_comb(n,k,p):
    a1 = mod_fact(n,p)
    a2 = mod_fact(k,p)
    a3 = mod_fact(n-k,p)
    return a1 * mod_inv(a2*a3%p,p) %p
  
A = mod_comb(n,a,p)
B = mod_comb(n,b,p)

if a == b:
  print((N-A) % p)
else:
  print((N-A-B) % p)

Fixed submission:
def ncr(n, r, p): 
    num = den = 1 
    for i in range(r): 
        num = (num * (n - i)) % p 
        den = (den * (i + 1)) % p 
    return (num * pow(den, p - 2, p)) % p
  
p = 10**9+7
n,a,b = map(int,(input().split()))

bb = ncr(n,a,p)+ncr(n,b,p)+1
print((pow(2,n,p)-(bb%p))%p)

Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
k = 1
for i in range(n):
  k = 2*k % (10**9 + 7)
N = k - 1
import math
def combinations_count(m, r):
  return math.factorial(m) // (math.factorial(m - r) * math.factorial(r))
A = combinations_count(n, a)
B = combinations_count(n, b)
if a == b:
  print((N-A) % (10**9 + 7))
else:
  print((N-A-B) % (10**9 + 7))

Fixed submission:
def ncr(n, r, p): 
    num = den = 1 
    for i in range(r): 
        num = (num * (n - i)) % p 
        den = (den * (i + 1)) % p 
    return (num * pow(den, p - 2, p)) % p
  
p = 10**9+7
n,a,b = map(int,(input().split()))

bb = ncr(n,a,p)+ncr(n,b,p)+1
print((pow(2,n,p)-(bb%p))%p)

Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())
N = 2**n - 1
import math
def combinations_count(m, r):
  return math.factorial(m) // (math.factorial(m - r) * math.factorial(r))
A = combinations_count(n, a)
B = combinations_count(n, b)
if a == b:
  print((N-A) % (10**9 + 7))
else:
  print((N-A-B) % (10**9 + 7))

Fixed submission:
def ncr(n, r, p): 
    num = den = 1 
    for i in range(r): 
        num = (num * (n - i)) % p 
        den = (den * (i + 1)) % p 
    return (num * pow(den, p - 2, p)) % p
  
p = 10**9+7
n,a,b = map(int,(input().split()))

bb = ncr(n,a,p)+ncr(n,b,p)+1
print((pow(2,n,p)-(bb%p))%p)
Buggy python submission (verdict: Runtime Error):
A = list(map(int, input().split()))
B = set(map(int, input().split()))
if len(B) == 2:
  print('Yes')
else:
  print('No')

Fixed submission:
A = list(map(int, input().split()))
B = set(A)
if len(B) == 2:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
  S.append(str(input()))
C = []
for i in range(N):
  C.append(S.count(S[i]))
S_new = sorted(set(S))
for s in S_new:
  if S.count(s) == max(C):
    print(s)


Fixed submission:
import collections
N = int(input())
S = []
for i in range(N):
  S.append(str(input()))
A = collections.Counter(S)
m = max(A.values())
for s in sorted(set(S)):
  if A[s] == m:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = []
for i in range(N):
  S.append(input())
C = []
for i in range(N):
  C.append(S.count(S[i]))
m = max(C)
S_new = sorted(set(S))
for s in S_new:
  if S.count(s) == m:
    print(s)

Fixed submission:
import collections
N = int(input())
S = []
for i in range(N):
  S.append(str(input()))
A = collections.Counter(S)
m = max(A.values())
for s in sorted(set(S)):
  if A[s] == m:
    print(s)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = []
for i in range(N):
  S.append(input())
m = max(S.count(S[i]), for i in range(N))
S_new = set(S)
for s in S_new:
  if m == S.count(s):
    print(s)
  

Fixed submission:
import collections
N = int(input())
S = []
for i in range(N):
  S.append(str(input()))
A = collections.Counter(S)
m = max(A.values())
for s in sorted(set(S)):
  if A[s] == m:
    print(s)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len("s")
X = x*n
print("X")

Fixed submission:
s = input()
n = len(s)
X = "x" *n
print(X)

Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
X = x*n
print("X")

Fixed submission:
s = input()
n = len(s)
X = "x" *n
print(X)

Buggy python submission (verdict: Runtime Error):
s = input()
n = int(len(s))
X = x*n
print(X)

Fixed submission:
s = input()
n = len(s)
X = "x" *n
print(X)

Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
X = x*n
print(X)

Fixed submission:
s = input()
n = len(s)
X = "x" *n
print(X)
Buggy python submission (verdict: Time Limit Exceeded):
n , k = map(int, input().split())
p = list(map(int, input().split()))

def sigma(a, b):
    s = 0
    for i in range(a, b+1):
        s += (1+p[i-1])/2
    return s
  
M = max(sigma(i, i+k-1) for i in range(1, n-k+2))
print(M)



Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
Q = [0]
for p in P:
    Q.append(Q[-1] + (p+1)/2)

print(max([Q[i+K]-Q[i] for i in range(N-K+1)]))

Buggy python submission (verdict: Runtime Error):
n , k = map(int, input().split())
p = list(map(int, input().split()))
for i in range(1,n+1):
  a_i = (1+p[i])/2
def sigma(a, b):
    s = 0
    for i in range(a, b+1):
        s += a_i
    return s
  
for i in range(n-k+1):
  r_i = sigma(i, i+k-1)
  
M = max(r_i for i in range(n-k+1))
print(M)



Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
Q = [0]
for p in P:
    Q.append(Q[-1] + (p+1)/2)

print(max([Q[i+K]-Q[i] for i in range(N-K+1)]))

Buggy python submission (verdict: Runtime Error):
n , k = map(int, input().split())
p = list(map(int, input().split()))
for i in range(n):
  a_i = (1+p[i])/2
def sigma(a, b):
    s = 0
    for i in range(a, b+1):
        s += a_i
    return s
  
for i in range(n-k+1):
  r_i = sigma(i, i+k-1)
  
M = max(r_i) for i in range(n-k+1)
print(M)



Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
Q = [0]
for p in P:
    Q.append(Q[-1] + (p+1)/2)

print(max([Q[i+K]-Q[i] for i in range(N-K+1)]))
Buggy python submission (verdict: Runtime Error):
H, A = int(input().split())
n = H+A-1//A
print(n)

Fixed submission:
H, A = map(int, input().split())
n = (H+A-1)//A
print(n)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
P = list(map(int, input().split()))
t = 0
for i in range(n):
  if min(P[:i+1]) >= P[i]:
    t += 1
print(t)

Fixed submission:
n = int(input())
P = list(map(int, input().split()))
t = 1
m = P[0]
for i in range(1, n):
  if m > P[i]:
    m = P[i]
    t += 1
print(t)
Buggy python submission (verdict: Runtime Error):
N, K, M = map(int, input().split())
L = list(map(int, input().split()))
diff = N*M-sum(L)
if diff <= K:
  print(max(0, diff))
else:
  print(-1)

Fixed submission:
print(chr(ord(input())+1))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ac = [0]*n
wa = [0]*n
a = 0
w = 0
for i in range(m):
  p, s = input().split()
  p = int(p)-1
  if ac[p] == 0, s == "AC":
    ac[p] += 1
    a += 1
    w += wa[p] 
  elif ac[p] == 0, s == "WA":
    wa[p] += 1
print(a,w)

Fixed submission:
n, m = map(int, input().split())
ac = [0]*n
wa = [0]*n
a = 0
w = 0
for i in range(m):
  p, s = input().split()
  p = int(p)-1
  if ac[p] == 0 and s == "AC":
    ac[p] += 1
    a += 1
    w += wa[p] 
  elif ac[p] == 0 and s == "WA":
    wa[p] += 1
print(a,w)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ac = [0]*n
wa = [0]*n
a = 0
w = 0
for i in range(m):
  p, s = input().split()
  p = int(p)-1
  if ac[p] == 0, s == "AC":
    acs[p] += 1
    a += 1
    w += was[p] 
  elif ac[p] == 0, s == "WA":
    was[p] += 1
print(a,w)

Fixed submission:
n, m = map(int, input().split())
ac = [0]*n
wa = [0]*n
a = 0
w = 0
for i in range(m):
  p, s = input().split()
  p = int(p)-1
  if ac[p] == 0 and s == "AC":
    ac[p] += 1
    a += 1
    w += wa[p] 
  elif ac[p] == 0 and s == "WA":
    wa[p] += 1
print(a,w)
Buggy python submission (verdict: Runtime Error):
k, x = map(int, input().split())
print("Yes") if 500*k >= x, else print("No")

Fixed submission:
k, x = map(int, input().split())
print("Yes") if 500*k >= x else print("No")

Buggy python submission (verdict: Runtime Error):
k, x = map(int, input().split())
print("Yes" if 500*k >= x, else "No")

Fixed submission:
k, x = map(int, input().split())
print("Yes") if 500*k >= x else print("No")

Buggy python submission (verdict: Runtime Error):
k, x = map(int, input().split())
print("Yes" if 500*k >= x, else "No")

Fixed submission:
k, x = map(int, input().split())
print("Yes") if 500*k >= x else print("No")
Buggy python submission (verdict: Runtime Error):
import itertools 
n = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
l = list(itertools.permutation([i for i in range(1, n+1)]))
print(abs(l.index(P) - l.index(Q)))

Fixed submission:
import itertools 
n = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
l = list(itertools.permutations([i for i in range(1, n+1)]))
print(abs(l.index(P) - l.index(Q)))
Buggy python submission (verdict: Runtime Error):
n = map(int, raw_input())
a = []
for _ in range(3):
  a.append(raw_input())
ans = 0
for i in range(n):
  diff_chars = set()
  for j in range(3):
    diff_chars.add(a[j][i])
  ans += len(diff_chars) - 1
print ans

Fixed submission:
n = int(raw_input())
a = []
for _ in range(3):
  a.append(raw_input())
ans = 0
for i in range(n):
  diff_chars = set()
  for j in range(3):
    diff_chars.add(a[j][i])
  ans += len(diff_chars) - 1
print ans
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))



a,b,n = MI()
ans = 0
for i in range(1,n+1):
	tmp = floor((a*i)/b) - a*floor(i/b)
	ans=max(tmp,ans)
print(ans)
# n,m,q = MI()
# A =[]
# B = []
# C = []
# D = []

# for _ in rage(q):
# 	a,b,c,d = MI()
# 	A.append(a)
# 	B.append(b)
# 	C.append(c)
# 	D.append(d)

# for i in range(n):



Fixed submission:
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


# l = ['a', 'a', 'a', 'a', 'b', 'c', 'c']
# c = Counter(l)

# d = defaultdict(int)

sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI(): return list(map(lambda x:int(x), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))



a,b,n = MI()
i = min(n,b-1)
tmp = floor((a*i)/b) - a*floor(i/b)
print(tmp)

# n,m,q = MI()
# A =[]
# B = []
# C = []
# D = []

# for _ in rage(q):
# 	a,b,c,d = MI()
# 	A.append(a)
# 	B.append(b)
# 	C.append(c)
# 	D.append(d)

# for i in range(n):
Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
S = input()

ans = 0
k = set('RGB')
for i in range(N):
	for j in range(i+1,N):
		ii = S[i]
		jj = S[j]
		if not ii==jj:
			tmp=list(k-set(ii+jj))[0]
			ans += S[j+1:].count(tmp)
			if 2*j-i<N and S[2*j-i]==tmp:
				ans -= 1
print(ans)

Fixed submission:
import sys
from collections import defaultdict
d = defaultdict(str)
N = int(sys.stdin.readline())
S = sys.stdin.readline()

ans = 0
k = 'RGB'
for i in range(N):
	for j in range(i+1,N):
		if not S[i]==S[j]:
			tmp =k.replace(S[i],'')
			tmp = tmp.replace(S[j],'')
			if d[str(j+1)+tmp]=='':
				p = S[j+1:].count(tmp)
				d[str(j+1)+tmp] = p
				ans += p
				if 2*j-i<N and S[2*j-i]==tmp:
					ans-= 1
					
			else:
				ans +=d[str(j+1)+tmp]
				if 2*j-i<N and S[2*j-i]==tmp:
					ans -=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
S = input()

ans = 0
k = 'RGB'
for i in range(N):
	for j in range(i+1,N):
		if not S[i]==S[j]:
			tmp =k.replace(S[i],'')
			tmp = tmp.replace(S[j],'')
			ans += S[j+1:].count(tmp)
			if 2*j-i<N and S[2*j-i]==tmp:
				ans -= 1
print(ans)


Fixed submission:
import sys
from collections import defaultdict
d = defaultdict(str)
N = int(sys.stdin.readline())
S = sys.stdin.readline()

ans = 0
k = 'RGB'
for i in range(N):
	for j in range(i+1,N):
		if not S[i]==S[j]:
			tmp =k.replace(S[i],'')
			tmp = tmp.replace(S[j],'')
			if d[str(j+1)+tmp]=='':
				p = S[j+1:].count(tmp)
				d[str(j+1)+tmp] = p
				ans += p
				if 2*j-i<N and S[2*j-i]==tmp:
					ans-= 1
					
			else:
				ans +=d[str(j+1)+tmp]
				if 2*j-i<N and S[2*j-i]==tmp:
					ans -=1
print(ans)

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

ans = 0
k = 'RGB'
for i in range(N):
	for j in range(i+1,N):
		if not S[i]==S[j]:
			tmp =k.replace(S[i],'')
			tmp = tmp.replace(S[j],'')
			ans += S[j+1:].count(tmp)
			if 2*j-i<N and S[2*j-i]==tmp:
				ans -= 1
print(ans)


Fixed submission:
import sys
from collections import defaultdict
d = defaultdict(str)
N = int(sys.stdin.readline())
S = sys.stdin.readline()

ans = 0
k = 'RGB'
for i in range(N):
	for j in range(i+1,N):
		if not S[i]==S[j]:
			tmp =k.replace(S[i],'')
			tmp = tmp.replace(S[j],'')
			if d[str(j+1)+tmp]=='':
				p = S[j+1:].count(tmp)
				d[str(j+1)+tmp] = p
				ans += p
				if 2*j-i<N and S[2*j-i]==tmp:
					ans-= 1
					
			else:
				ans +=d[str(j+1)+tmp]
				if 2*j-i<N and S[2*j-i]==tmp:
					ans -=1
print(ans)
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
 
def common(s1, s2):
	l1 = len(s1)
	l2 = len(s2)
	memo = [[0 for i in range(l1+2)] for j in range(l2+2)]
 
	for idx1,w1 in enumerate(s1):
		for idx2,w2 in enumerate(s2):
			if w1==w2 or w1=='?'or w2=='?':
				memo[idx2+1][idx1+1] = memo[idx2][idx1] + 1
 
	return memo
m1 = 0
m2 = 0
m3 = 0
for l in common(a,b):
	if max(l)>m1:
		m1 = max(l)
for l in common(a,c):
	if max(l)>m2:
		m2 = max(l)
for l in common(b,c):
	if max(l)>m3:
		m3 = max(l)
ans=len(a)+len(b)+len(c)-m1-m2-m3+min([m1,m2,m3])
 
print(ans)

Fixed submission:
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
N = int(input())
print(l[N-1])
Buggy python submission (verdict: Runtime Error):
a,b,c,k = (map(int, input().split()))

if abs(a-b)>10**18:
  print("Unfair")
elif k%2==0-:
  
  print(a-b)
else:
  print(b-a)

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

if a-b>10**18:
  print("Unfair")
elif k%2==0:
  print(a-b)
else:
  print(b-a)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k = (map(int, input().split()))
for _ in range(k):
  tmpa = b+c
  tmpb = c+a
  tmpc = a+b
  a = tmpa
  b=tmpb
  c=tmpc
thre = 18
if str(a-b).startswith('-'):
  thre+=1
if len(str(a-b))>thre:
	print("Unfair")
else:
  print(a-b)

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

if a-b>10**18:
  print("Unfair")
elif k%2==0:
  print(a-b)
else:
  print(b-a)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k = (map(int, input().split()))
for _ in range(k):
  tmpa = b+c
  tmpb = c+a
  tmpc = a+b
  a = tmpa
  b=tmpb
  c=tmpc
if a-b>10**18:
  print("Unfair")
else:
  print(a-b)

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

if a-b>10**18:
  print("Unfair")
elif k%2==0:
  print(a-b)
else:
  print(b-a)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
d = dict()
for _ in range(n):
    a, b = map(int, input().split())
    d.setdefault(a, [])
    d[a].append(b)

l = []
ans = 0
for i in range(1, m + 1):
    if i in d:
        l += d[i]
        l.sort()
    if len(l) > 0:
        m = l.pop()
        ans += m
print(ans)


Fixed submission:
from heapq import heappush, heappop

n, m = map(int, input().split())
d = dict()
for _ in range(n):
    a, b = map(int, input().split())
    d.setdefault(a, [])
    d[a].append(-b)

h = []
ans = 0
for i in range(1, m + 1):
    for b in d.get(i, []):
        heappush(h, b)
    if len(h) > 0:
        m = heappop(h)
        ans -= m
print(ans)

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

n, m = map(int, input().split())
ab_list = [list(map(int, input().split())) for _ in range(n)]
ab_list.sort(key=lambda i: (i[0]))

l = []
ans = 0
d = {key: list(val) for key, val in itertools.groupby(ab_list, key=lambda i: i[0])}
for i in range(1, m + 1):
    if i in d:
        l += [b for _, b in d[i]]
        l.sort()
    if len(l) > 0:
        m = l.pop()
        ans += m
print(ans)


Fixed submission:
from heapq import heappush, heappop

n, m = map(int, input().split())
d = dict()
for _ in range(n):
    a, b = map(int, input().split())
    d.setdefault(a, [])
    d[a].append(-b)

h = []
ans = 0
for i in range(1, m + 1):
    for b in d.get(i, []):
        heappush(h, b)
    if len(h) > 0:
        m = heappop(h)
        ans -= m
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())
ran = b - a + 1
if a % c == 0:
    count1 = math.ceil(ran / c)
else:
    count1 = math.ceil((ran - (c - a % c)) / c)
if a % d == 0:
    count2 = math.ceil(ran / d)
else:
    count2 = math.ceil((ran - (d - a % d)) / d)
e = c * d / math.gcd(c, d)
if a % e == 0:
    count3 = math.ceil(ran / e)
else:
    count3 = math.ceil((ran - (e - a % e)) / e)
print(ran - (count1 + count2 - count3))


Fixed submission:
import math

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

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

a, b, c, d = map(int, input().split())
ran = b - a + 1

def count(x):
    r = ran if a % x == 0 else ran - (x - a % x)
    return r // x if r % x == 0 else r // x + 1

count1 = count(c)
count2 = count(d)
e = lcm(c, d)
count3 = count(e)
print(ran - (count1 + count2 - count3))
Buggy python submission (verdict: Runtime Error):
import itertools

n = int(input())
xy_list = [list(map(int, input().split())) for _ in range(n)]
counts = dict()
for (x1, y1), (x2, y2) in itertools.combinations(xy_list, 2):
    for pq in ((x2 - x1, y2 - y1), (x1 - x2, y1 - y2)):
        counts.setdefault(pq, 0)
        counts[pq] += 1
max_count = max(counts.values())
print(n - max_count)


Fixed submission:
import sys
import itertools

n = int(input())
xy_list = [list(map(int, input().split())) for _ in range(n)]
if n == 1:
    print(1)
    sys.exit()

counts = dict()
for (x1, y1), (x2, y2) in itertools.combinations(xy_list, 2):
    for pq in ((x2 - x1, y2 - y1), (x1 - x2, y1 - y2)):
        counts.setdefault(pq, 0)
        counts[pq] += 1
max_count = max(counts.values())
print(n - max_count)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
bc_list = [list(map(int, input().split())) for _ in range(m)]
a_list.sort()
bc_list.sort(key=lambda i: -i[1])

a_idx = 0
bc_idx = 0
while bc_idx < len(bc_list):
    b, c = bc_list[bc_idx]
    finish = False
    for _ in range(b):
        if c > a_list[a_idx]:
            a_list[a_idx] = c
            a_idx += 1
        else:
            finish = True
            break
    if finish:
        break
    bc_idx += 1

print(sum(a_list))


Fixed submission:
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
bc_list = [list(map(int, input().split())) for _ in range(m)]
a_list.sort()
bc_list.sort(key=lambda i: -i[1])

a_idx = 0
bc_idx = 0
while bc_idx < len(bc_list):
    b, c = bc_list[bc_idx]
    finish = False
    for _ in range(b):
        if a_idx >= len(a_list):
            finish = True
            break
        if c > a_list[a_idx]:
            a_list[a_idx] = c
            a_idx += 1
        else:
            finish = True
            break
    if finish:
        break
    bc_idx += 1

print(sum(a_list))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
pys = [list(map(int, input().split())) for _ in range(m)]
map_ = {}
for i, (p, y) in enumerate(pys):
    map_.setdefault(p, [])
    for j in range(len(map_[p])):
        if y < pys[map_[p][j]][1]:
            map_[p].insert(j, i)
            break
    else:
        map_[p].append(i)
ans = [None] * m
for key, val in map_.items():
    for num, i in enumerate(val):
        ans[i] = '{:06d}'.format(key) + '{:06d}'.format(num + 1)
for a in ans:
    print(a)


Fixed submission:
n, m = map(int, input().split())
pys = [list(map(int, input().split())) for _ in range(m)]
map_ = {}
for i, (p, y) in enumerate(pys):
    map_.setdefault(p, [])
    map_[p].append(i)

for val in map_.values():
    val.sort(key=lambda i: pys[i][1])

ans = [None] * m
for key, val in map_.items():
    for num, i in enumerate(val):
        ans[i] = '{:06d}'.format(key) + '{:06d}'.format(num + 1)
for a in ans:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
max_i = m // n
for i in range(max_i, 0, -1):
    if m % i == 0:
        print(i)
        break


Fixed submission:
import math

n, m = map(int, input().split())
max_i = 1
for i in range(1, int(math.sqrt(m)) + 1):
    if m % i != 0:
        continue
    j = m // i
    if i * n <= m and i > max_i:
        max_i = i
    if j * n <= m and j > max_i:
        max_i = j
print(max_i)