Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = input().strip()
K = int(input())
if K>len(s)*26:
    d = (K-len(s)*26)//26
    K = K-26*d
x = ""
for i in range(len(s)):
    if i<len(s)-1 and (26-(ord(s[i])-ord("a")))%26 <= K:
        x += "a"
        K -= (26-(ord(s[i])-ord("a")))%26
    elif i<len(s)-1:
        x += s[i]
    elif i==len(s)-1:
        k = ord(s[i])+K%26
        if k<=122:
            x += chr(k)
        else:
            x += chr(k-26)
print(x)

Fixed submission:
s = input().strip()
K = int(input())
if K>len(s)*26:
    d = (K-len(s)*26)//26
    K = K-26*d
x = ""
for i in range(len(s)):
    if i<len(s)-1 and (26-(ord(s[i])-ord("a")))%26 <= K:
        x += "a"
        K -= (26-(ord(s[i])-ord("a")))%26
    elif i<len(s)-1:
        x += s[i]
    elif i==len(s)-1:
        k = ord(s[i])+K%26
        if k<=122:
            x += chr(k)
        else:
            x += chr(k-26)
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
s = input().strip()
K = int(input())
cnt = 0
x = ""
for i in range(len(s)):
    if i<len(s)-1 and (26-(ord(s[i])-ord("a")))%26 <= K-cnt:
        x += "a"
        cnt += (26-(ord(s[i])-ord("a")))%26
    elif i<len(s)-1:
        x += s[i]
    elif i==len(s)-1:
        k = ord(s[i])+(K-cnt)%26
        if k<=122:
            x += chr(k)
        else:
            x += chr(k-26)
print(x)

Fixed submission:
s = input().strip()
K = int(input())
if K>len(s)*26:
    d = (K-len(s)*26)//26
    K = K-26*d
x = ""
for i in range(len(s)):
    if i<len(s)-1 and (26-(ord(s[i])-ord("a")))%26 <= K:
        x += "a"
        K -= (26-(ord(s[i])-ord("a")))%26
    elif i<len(s)-1:
        x += s[i]
    elif i==len(s)-1:
        k = ord(s[i])+K%26
        if k<=122:
            x += chr(k)
        else:
            x += chr(k-26)
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
s = input().strip()
K = int(input())
cnt = 0
x = ""
for i in range(len(s)):
    if i<len(s)-1 and (26-(ord(s[i])-ord("a")))%26 <= K-cnt:
        x += "a"
        cnt += (26-(ord(s[i])-ord("a")))%26
    elif i<len(s)-1:
        x += s[i]
    else:
        k = ord(s[i])+(K-cnt)%26
        if k<=122:
            x += chr(k)
        else:
            x += chr(k-26)
print(x)

Fixed submission:
s = input().strip()
K = int(input())
if K>len(s)*26:
    d = (K-len(s)*26)//26
    K = K-26*d
x = ""
for i in range(len(s)):
    if i<len(s)-1 and (26-(ord(s[i])-ord("a")))%26 <= K:
        x += "a"
        K -= (26-(ord(s[i])-ord("a")))%26
    elif i<len(s)-1:
        x += s[i]
    elif i==len(s)-1:
        k = ord(s[i])+K%26
        if k<=122:
            x += chr(k)
        else:
            x += chr(k-26)
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C = map(int,input().split())
N = A*B*C
cmin = N
for a in range(1,A):
    cmin = min(cmin,abs(2*a*B*C-N))
for b in range(1,B):
    cmin = min(cmin,abs(2*b*C*A-N))
for c in range(1,C):
    cmin = min(cmin,abs(2*c*A*B-N))
print(cmin)

Fixed submission:
import math
A,B,C = map(int,input().split())
a = (math.ceil(A/2)-A//2)*B*C
b = (math.ceil(B/2)-B//2)*C*A
c = (math.ceil(C/2)-C//2)*A*B
print(min(a,b,c))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
cnt = 0
for i in range(N):
    cnt += A[i]//2
    A[i] = A[i]%2
for i in range(1,N-1):
    if A[i-1]+A[i]==2:
        cnt += 1
        A[i]=0
print(cnt)

Fixed submission:
N = int(input())
A = []
a = []
for i in range(N):
    x = int(input())
    if x==0:
        b = a[:]
        A.append(b)
        a = []
    else:
        a.append(x)
A.append(a)
cnt = 0
for a in A:
    c = sum(a)
    cnt += c//2
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
print(N*(N+1))//2)

Fixed submission:
N = int(input())
print((N*(N+1))//2)
Buggy python submission (verdict: Runtime Error):
s = input().strip()
a = -1
b = -1
if s[0]==s[1]:
    a = 1
    b = 2
elif s[1]==s[2]:
    a = 2
    b = 3
elif s[0]==s[2]:
    a = 1
    b = 3
else:
    for i in range(3,len(s)):
        if s[i]==s[i-1]:
            a = i
            b = i+1
            break
        elif s[i]==s[i-2]:
            a = i-1
            b = i+1
            break
print(a,b)

Fixed submission:
s = input().strip()
a = -1
b = -1
if s[0]==s[1]:
    a = 1
    b = 2
elif len(s)>2 and s[1]==s[2]:
    a = 2
    b = 3
elif len(s)>2 and s[0]==s[2]:
    a = 1
    b = 3
else:
    for i in range(3,len(s)):
        if s[i]==s[i-1]:
            a = i
            b = i+1
            break
        elif s[i]==s[i-2]:
            a = i-1
            b = i+1
            break
print(a,b)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
D = list(map(int,input().split()))
E = []
for i in range(10):
    if i not in D:
        E.append(i)
E = sorted(E)
N = str(N)
ind = len(N)
for i in range(len(N)):
    if int(N[i]) not in E:
        ind = i
        break
if ind==len(N):
    print(N)
else:
    flag = 0
    x = ""
    for i in range(ind-1,-1,-1):
        n = int(N[i])
        if n==E[-1]:continue
        else:
            for e in E:
                if e>n:
                    x = N[:i]+str(e)+str(E[0])*(len(N)-i-1)
                    flag = 1
                    break
            if flag==1:break
    if flag==0:
        for e in E:
            if e>int(N[0]):
                a = e
                flag = 1
                break
        x = str(a)+str(E[0])*(len(N)-1)
        if flag==0:
            if E[0]>0:
                a = E[0]
            else:
                a = E[1]
            x = str(a)+str(E[0])*len(N)
    print(x)

Fixed submission:
import itertools
N,K = map(int,input().split())
D = list(map(int,input().split()))
A = []
for i in range(10):
    if i not in D:
        A.append(i)
cmin = 100000
k = len(str(N))
for i in range(k,6):
    for x in itertools.product(A,repeat=i):
        cnt = 0
        for j in range(i):
            cnt += x[j]*10**(i-1-j)
        if cnt>=N:
            cmin = min(cmin,cnt)
print(cmin)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

H, W, M = list(map(int, input().split()))
hw = [list(map(int, input().split())) for _ in range(M)]

d1 = defaultdict(int)
d2 = defaultdict(int)

b = [[False] * (W+1) for _ in range(H+1)]

for h, w in hw:
    d1[h] += 1
    d2[w] += 1
    b[h][w] = True

m1 = max(d1.values())
m2 = max(d2.values())

e1 = [k for k in d1.keys() if d1[k] == m1]
e2 = [k for k in d2.keys() if d2[k] == m2]

flag = True

for x in e1:
    for y in e2:
        if not b[x][y]:
            flag = False
            break
    if not flag:
        break

if flag:
    print(m1+m2-1)
else:
    print(m1+m2)

Fixed submission:
from collections import defaultdict

H, W, M = list(map(int, input().split()))
hw = [list(map(int, input().split())) for _ in range(M)]

d1 = defaultdict(int)
d2 = defaultdict(int)

b = defaultdict(int)

for h, w in hw:
    d1[h] += 1
    d2[w] += 1
    b[(h, w)] = 1

m1 = max(d1.values())
m2 = max(d2.values())

e1 = [k for k in d1.keys() if d1[k] == m1]
e2 = [k for k in d2.keys() if d2[k] == m2]

flag = True

for x in e1:
    for y in e2:
        if b[(x, y)] == 1:
            pass
        else:
            flag = False
            break
    if not flag:
        break

if flag:
    print(m1+m2-1)
else:
    print(m1+m2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

k = int(input())

n = 1

if k % 2  == 0:
    n = -1
else:
    r = 7 % k
    s = r

    while True:
        if r == 0:
            break
        else:
            r = (r * 10 + s) % k
            n += 1

print(n)

Fixed submission:
import sys
input = sys.stdin.readline

k = int(input())

n = 1

if k % 2  == 0:
    n = -1
else:
    r = 7 % k
    s = r

    while True:
        if r == 0:
            break
        elif n > 1000000:
            n = -1
            break
        else:
            r = (r * 10 + s) % k
            n += 1


print(n)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from fractions import Fraction
import math
import heapq
input = sys.stdin.readline

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

s = sum(a)

w = [(k * a[i]) // s for i in range(n)]
b = [Fraction((w[i] + 1), a[i]) for i in range(n)]

r = k - sum(w)

heapq.heapify(b)
#print(b)

for i in range(r):
    x = heapq.heappop(b)
    heapq.heappush(b, Fraction(x.numerator+1, x.denominator))

y = heapq.heappop(b)

print(math.ceil(Fraction(y.denominator, y.numerator)))

Fixed submission:
import sys
from fractions import Fraction
import math
import heapq
input = sys.stdin.readline

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

s = sum(a)

w = [(k * a[i]) // s for i in range(n)]
b = [Fraction((w[i] + 1), a[i]) for i in range(n)]

r = k - sum(w)

heapq.heapify(b)
#print(b)

for i in range(r):
    x = heapq.heappop(b)
    heapq.heappush(b, Fraction(x.numerator+1, x.denominator))

y = heapq.heappop(b)

print(math.ceil(Fraction(y.denominator, y.numerator)))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from fractions import Fraction
import math
input = sys.stdin.readline

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

s = sum(a)

w = [(k * a[i]) // s for i in range(n)]
b = [Fraction(a[i] / (w[i] + 1)) for i in range(n)]

r = k - sum(w)

for i in range(r):
    b.sort()
    b[-1] = Fraction(b[-1].numerator, b[-1].denominator + 1)

b.sort()

print(math.ceil(b[-1]))

Fixed submission:
import sys
from fractions import Fraction
import math
import heapq
input = sys.stdin.readline

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

s = sum(a)

w = [(k * a[i]) // s for i in range(n)]
b = [Fraction((w[i] + 1), a[i]) for i in range(n)]

r = k - sum(w)

heapq.heapify(b)
#print(b)

for i in range(r):
    x = heapq.heappop(b)
    heapq.heappush(b, Fraction(x.numerator+1, x.denominator))

y = heapq.heappop(b)

print(math.ceil(Fraction(y.denominator, y.numerator)))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

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


s = []
t = []


for i in range(n):
    #print(k + a[i])
    if len(s) > k:
        break
    elif len(s) < k < len(s) + a[i]:
        s += [i] * (k + 1 - len(s))
    else:
        s += [i] * a[i]

if len(s) <k:
    s += [n] * (k + 1 - len(s))

for i in range(m):
    if len(t) > k:
        break
    elif len(t) < k < len(t) + b[i]:
        t += [i] * (k + 1 - len(t))
    else:
        t += [i] * b[i]

if len(t) <k:
    t += [m] * (k + 1 - len(t))

m = 0

# print(s)
# print(t)

#print(s[-1], t[-1])

if len(s) + len(t) - 2 <= k:
    m = s[-1] + t[-1]
else:
    for i in range(k+1):
        m = max(m, s[i] + t[k-i])

print(m)

Fixed submission:
import sys
input = sys.stdin.readline

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


#Aだけのときのmax

s = 0
j = 0
for i in range(n):
    if s + a[i] > k:
        break
    else:
        s += a[i]
        j += 1


ans = [j]

for l in range(m):
    flag = True
    s += b[l]
    while s > k:
        s -= a[j-1]
        j -= 1
        if j < 0:
            flag = False
            break
    
    if not flag:
        break
    else:
        ans.append(l + 1 + j)
        #print(ans)

print(max(ans))
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque

input = sys.stdin.readline

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

a.sort()
tf = [True] * n

for j in range(n):
    if not tf[j]:
        pass
    else:
        for k in range(j+1, n):
            if tf[k] and a[k] % a[j] == 0:
                tf[k] = False
    #print(tf)

if a[0] % a[1] == 0:
    tf[0] = False

print(tf.count(True))






Fixed submission:
import sys
from collections import deque

input = sys.stdin.readline

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

a.sort()
tf = [True] * a[-1]
dup = [False] * a[-1]


for i in range(n):
    if tf[a[i]-1] == True:
        #print(a[i])
        if dup[a[i]-1] == True:
            tf[a[i]-1] = False
        else:
            dup[a[i]-1] = True
            for j in range(a[i]*2, a[-1]+1, a[i]):
                tf[j-1] = False
                

c = 0

#print(tf)

for x in a:
    if tf[x-1]:
        c += 1

print(c)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

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

a.sort()

s = 0

for i in range(n):
    j = 0
    while j < i:
        if a[i] % a[j] == 0:
            #print(0, a[i], a[j])
            break
        elif a[j] ** 2 > a[i]:
            s += 1
            #print(1, a[i], a[j])
            break
        j += 1

if a[0] != a[1]:
    s += 1

print(s)


Fixed submission:
import sys
from collections import deque

input = sys.stdin.readline

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

a.sort()
tf = [True] * a[-1]
dup = [False] * a[-1]


for i in range(n):
    if tf[a[i]-1] == True:
        #print(a[i])
        if dup[a[i]-1] == True:
            tf[a[i]-1] = False
        else:
            dup[a[i]-1] = True
            for j in range(a[i]*2, a[-1]+1, a[i]):
                tf[j-1] = False
                

c = 0

#print(tf)

for x in a:
    if tf[x-1]:
        c += 1

print(c)
Buggy python submission (verdict: Runtime Error):
import numpy as np
from numpy import array


n, m, x = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))

a = array(a)

c_min = 0
flag = False

for i in range(1, 2 ** n ):
    b = np.zeros(m+1)

    for k in range(n):
        if ((i >> k) & 1):
            b += a[k]
    
    if np.all(b[1:] >= x):
        if flag == False:
            c_min = b[0]
            flag = True
        else:
            c_min = min(c_min, b[0])
        

c_min = int(c_min)

if flag == False:
    c_min = -1

print(c_min)



Fixed submission:
import numpy as np
from numpy import array


n, m, x = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))

a = array(a)

c_min = 0
flag = False

for i in range(1, 2 ** n ):
    b = np.zeros(m+1)

    for k in range(n):
        if ((i >> k) & 1):
            b += a[k]
    
    if np.all(b[1:] >= x):
        if flag == False:
            c_min = b[0]
            flag = True
        else:
            c_min = min(c_min, b[0])
        

c_min = int(c_min)

if flag == False:
    c_min = -1

print(c_min)

Buggy python submission (verdict: Runtime Error):
import numpy as np
from numpy import array


n, m, x = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))

a = array(a)

c_min = 1e5 * n
flag = False

for i in range(1, n ** 2 + 1):
    j = str(bin(i))

    b = np.zeros(m+1)

    for k in range(n):
        if j[k] == 1:
            b += a[k]
    
    if np.all(b[1:] >= m):
        c_min = min(c_min, b[0])
        flag = True

if flag == False:
    c_min = -1

print(c_min)



Fixed submission:
import numpy as np
from numpy import array


n, m, x = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))

a = array(a)

c_min = 0
flag = False

for i in range(1, 2 ** n ):
    b = np.zeros(m+1)

    for k in range(n):
        if ((i >> k) & 1):
            b += a[k]
    
    if np.all(b[1:] >= x):
        if flag == False:
            c_min = b[0]
            flag = True
        else:
            c_min = min(c_min, b[0])
        

c_min = int(c_min)

if flag == False:
    c_min = -1

print(c_min)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())

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


l = [a[i] +i+1 for i in range(n)]
r = [i+1 -a[i] for i in range(n)]

L = collections.Counter(l)
R = collections.Counter(r)

c = 0

for i in range(max(max(l),max(r))+1):
    c += L.get(i, 0) * R.get(i, 0)

print(c)

Fixed submission:
import collections

n = int(input())

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


l = [a[i] +i+1 for i in range(n)]
r = [i+1 -a[i] for i in range(n)]

L = collections.Counter(l)
R = collections.Counter(r)

c = 0

for i in L.keys():
    c += L.get(i, 0) * R.get(i, 0)

print(c)

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

n = int(input())

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


listi = [a[i] +i+1 for i in range(n)]
listj = [i+1 -a[i] for i in range(n)]

c = 0
for i in range(n):
    for j in range(i+1,n):
        if listi[i] == listj[j]:
            c += 1
print(c)

Fixed submission:
import collections

n = int(input())

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


l = [a[i] +i+1 for i in range(n)]
r = [i+1 -a[i] for i in range(n)]

L = collections.Counter(l)
R = collections.Counter(r)

c = 0

for i in L.keys():
    c += L.get(i, 0) * R.get(i, 0)

print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import numpy as np

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

a=[]
b=[]
c=[]
d=[]

for i in range(q):
    ai, bi, ci, di = list(map(int, input().split()))
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

h = []
A_list = np.array(list(itertools.combinations_with_replacement(range(1, m+1), n)))


for A in A_list:
    s = 0
    for i in range(q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            s += d[i]
    h.append(s)

print(max(h))
 



Fixed submission:
import itertools

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

a=[]
b=[]
c=[]
d=[]

for i in range(q):
    x = list(map(int, input().split()))
    a.append(x[0])
    b.append(x[1])
    c.append(x[2])
    d.append(x[3])

h = []
A_list = list(itertools.combinations_with_replacement(range(1, m+1), n))


for A in A_list:
    s = 0
    for i in range(q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            s += d[i]
    h.append(s)

print(max(h))

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

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

a=[]
b=[]
c=[]
d=[]

for i in range(q):
    ai, bi, ci, di = list(map(int, input().split()))
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

h = 0
it = itertools.combinations_with_replacement(range(1, m+1), n)
A_list = np.array(list(it))


for A in A_list:
    s = 0
    for i in range(q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            s += d[i]
    h = max(h, s)

print(h)
 



Fixed submission:
import itertools

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

a=[]
b=[]
c=[]
d=[]

for i in range(q):
    x = list(map(int, input().split()))
    a.append(x[0])
    b.append(x[1])
    c.append(x[2])
    d.append(x[3])

h = []
A_list = list(itertools.combinations_with_replacement(range(1, m+1), n))


for A in A_list:
    s = 0
    for i in range(q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            s += d[i]
    h.append(s)

print(max(h))

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

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

a=[]
b=[]
c=[]
d=[]

for i in range(q):
    ai, bi, ci, di = list(map(int, input().split()))
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)

def score(A, a, b, c, d):
    s = 0
    for i in range(len(a)):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            s += d[i]
    return s

h = 0
it = itertools.combinations_with_replacement(range(1, m+1), n)
A_list = np.array(list(it))


for A in A_list:
    h = max(h, score(A,a,b,c,d))

print(h)
 



Fixed submission:
import itertools

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

a=[]
b=[]
c=[]
d=[]

for i in range(q):
    x = list(map(int, input().split()))
    a.append(x[0])
    b.append(x[1])
    c.append(x[2])
    d.append(x[3])

h = []
A_list = list(itertools.combinations_with_replacement(range(1, m+1), n))


for A in A_list:
    s = 0
    for i in range(q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            s += d[i]
    h.append(s)

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

m = 0

for x in reversed(range(max(1,n-b),n+1)):
    if m > (a*x) // b:
        break
    else:
        y = (a*x)//b - a * (x//b)
        if m < y:
            m = y

print(m)

Fixed submission:
import math

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

m = 0
x = n

while x >= n-b:
    if m > (a*x) // b:
        break
    else:
        y =  math.floor((a * (x / b - math.floor(x / b))))
        if m < y:
            m = y
            x = b * math.floor(x / b) - 1
        else:
            x-=1  

print(m)

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

m = 0

for x in reversed(range(max(1, n-b),n+1)):
    y = (a*x)//b - a * (x//b)
    if m < y:
        m = y

print(m)

Fixed submission:
import math

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

m = 0
x = n

while x >= n-b:
    if m > (a*x) // b:
        break
    else:
        y =  math.floor((a * (x / b - math.floor(x / b))))
        if m < y:
            m = y
            x = b * math.floor(x / b) - 1
        else:
            x-=1  

print(m)

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

m = 0

for x in reversed(range(1,n+1)):
    if m > (a*x) // b:
        break
    else:
        y = (a*x)//b - a * (x//b)
        if m < y:
            m = y

print(m)

Fixed submission:
import math

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

m = 0
x = n

while x >= n-b:
    if m > (a*x) // b:
        break
    else:
        y =  math.floor((a * (x / b - math.floor(x / b))))
        if m < y:
            m = y
            x = b * math.floor(x / b) - 1
        else:
            x-=1  

print(m)

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

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

m = 0

for x in reversed(range(1,n+1)):
    if m > a*x/b:
        break
    else:
        y = math.floor(a*x/b) - a * math.floor(x/b)
        if m < y:
            m = y

print(m)

Fixed submission:
import math

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

m = 0
x = n

while x >= n-b:
    if m > (a*x) // b:
        break
    else:
        y =  math.floor((a * (x / b - math.floor(x / b))))
        if m < y:
            m = y
            x = b * math.floor(x / b) - 1
        else:
            x-=1  

print(m)

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

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

m = 0

for x in range(1,n+1):
    y = math.floor(a*x/b) - a * math.floor(x/b)
    if m < y:
        m = y

print(m)

Fixed submission:
import math

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

m = 0
x = n

while x >= n-b:
    if m > (a*x) // b:
        break
    else:
        y =  math.floor((a * (x / b - math.floor(x / b))))
        if m < y:
            m = y
            x = b * math.floor(x / b) - 1
        else:
            x-=1  

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

print(max(n - sum(a), -1)

Fixed submission:
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
 
print(max(n - sum(a), -1))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(1,n+1):
	print(a.count(i))

Fixed submission:
import collections

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

c = collections.Counter(a)

for i in range(n):
  print(c.get(i+1, "0"))