Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03393 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[27]:


S = input()


# In[28]:


ZtoA = "zyxwvutsrqponmlkjihgfedcba"
diff = sorted(list(set(ZtoA)^set(S)))
if len(S) < 26:
    print(S+diff[0])
else:
    if S == ZtoA:
        print(-1)
    else:
        for i in range(25):
            if S[i] < S[i+1]:
                k = i
        a = "z"
        for i in range(k+1,26):
            if S[k] < S[i]:
                a = min(a, S[i])
        print(S[:k]+a)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[9]:


S = input()


# In[18]:


ZtoA = list(reversed("abcdefghijklmnopqrstuvwxyz"))
diff = sorted(list(set(ZtoA)^set(S)))
if len(S) < 26:
    print(S+diff[0])
else:
    if S == ZtoA:
        print(-1)
    else:
        for i in range(25):
            if S[i] < S[i+1]:
                k = i
        a = "z"
        for i in range(k+1,26):
            if S[k] < S[i]:
                a = min(a, S[i])
    print(S[:k]+a)


# In[ ]:
Problem p03559 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[8]:


from bisect import bisect_left,bisect


# In[6]:


N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))


# In[9]:


ans = 0
for b in B:
    i = bisect_left(A,b)
    j = bisect(C,b)
    ans += i*(N-j)
print(ans)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[4]:


N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))


# In[6]:


ans = 0
for b in B:
    while i<N and A[i]<b:
        i+=1
    while j<N and C[j]<=b:
        j+=1
    ans += i*(N-j)
print(ans)


# In[ ]:
Problem p03624 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[24]:


# S = input()


# In[25]:


# mylist = list(sorted(set(S)))
# abc = "abcdefghijklmnopqrstuvwxyz"
# for i in range(len(abc)):
#     if mylist[i] != abc[i]:
#         print(abc[i])
#         break
# else:
#     print("None")


# In[ ]:


s = input()
chars = set('abcdefghijklmnopqrstuvxwyz')
x = list(sorted(chars - set(s)))
if len(x):
    print(x[0])
else:
    print('None')

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[18]:


S = input()


# In[19]:


mylist = list(sorted(set(S)))
abc = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(abc)):
    if mylist[i] != abc[i]:
        print(abc[i])
        break
else:
    print("None")


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[18]:


S = input()


# In[19]:


mylist = list(sorted(set(S)))
abc = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(abc)):
    if mylist[i] != abc[i]:
        print(abc[i])
        break
else:
    print("None")


# In[ ]:
Problem p03627 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[38]:


import collections


# In[52]:


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


# In[54]:


a_cnt = collections.Counter(A)
p = sorted([i for i in a_cnt.items() if i[1] >= 2], reverse=True)
if len(p) > 0:
    if p[0][1]>=4:
        print(p[0][0]**2)
    elif len(p) > 1:
        print(p[0][0]*p[1][0])
    else:
        print(0)
else:
    print(0)


# In[ ]:

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[38]:


import collections


# In[43]:


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


# In[49]:


a_cnt = collections.Counter(A)
p = sorted([i for i in a_cnt.items() if i[1] >= 2], reverse=True)
if p[0][1]>=4:
    print(p[0][0]**2)
elif len(p) > 1:
    print(p[0][0]*p[1][0])
else:
    print(0)


# In[ ]:
Problem p03680 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[28]:


# N = int(input())
# a = []
# for i in range(N):
#     a.append(int(input()))


# In[30]:


# def func(x, a, history, cnt):
#     print(x, a[x-1], history)
#     if a[x-1] == 2:
#         print(cnt)
#     elif a[x-1] in history:
#         print(-1)
#     else:
#         history.append(a[x-1])
#         cnt += 1
#         func(a[x-1], a, history, cnt)
# func(1, a, [], 1)


# In[ ]:


n = int(input())
a = [int(input()) for _ in range(n)]
L = [0] * n
cnt = 0
i = 0
while True:
    if L[i] == 1:
        print(-1)
        break
    else:
        L[i] = 1
        i = a[i] - 1
        cnt += 1
        if i == 1:
            print(cnt)
            break

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[28]:


N = int(input())
a = []
for i in range(N):
    a.append(int(input()))


# In[29]:


def func(x, a, history, cnt):
#     print(x, a[x-1], history)
    if a[x-1] == 2:
        print(cnt)
    elif a[x-1] in history:
        print(-1)
    else:
        history.append(a[x-1])
        cnt += 1
        func(a[x-1], a, history, cnt)
func(1, a, [], 1)


# In[ ]:
Problem p03761 (python)

Fixed submission:
#!/usr/bin/env python
# coding: utf-8

# In[ ]:


MAX_N = 50
n = int(input())
C = [[0] * 26 for _ in range(n)]
for i in range(n):
    S = input()
    for s in S:
        C[i][ord(s) - ord('a')] += 1
res = ''
for i in range(26):
    t = MAX_N + 1
    for j in range(n):
        t = min(t, C[j][i])
    res += chr(i + ord('a')) * t
print(res)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[28]:


n = int(input())
S = []
for _ in range(n):
    S.append(input())


# In[29]:


myset = set(S[0])
mycnt = {}
for i in range(len(myset)):
    mylist = list(myset)
    tmp = mylist[i]
    mycnt[tmp] = S[0].count(tmp)
for i in range(1,n):
    myset = myset & set(S[i])
    for i in range(len(myset)):
        mylist = list(myset)
        tmp = mylist[i]
        mycnt[tmp] = min(mycnt[tmp], S[i].count(tmp))


# In[30]:


ans = ""
for x in myset:
    print(x)
    cnt = mycnt[x]
    ans += x*cnt
print("".join(sorted(ans)))


# In[ ]:
Problem p03831 (python)

Fixed submission:
def main():
    N, A, B = map(int, input().split())
    X = list(map(int, input().split()))
 
    cost = 0
    for i in range(N-1):
        distance = abs(X[i] - X[i+1])
        if distance * A < B:
            cost += distance * A
        else:
            cost += B
    print(cost)
 
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
a
Problem p02573 (python)

Fixed submission:
n, m = map(int, input().split())
f = [i for i in range(n + 1)]
def getF(u):
    i = u
    while f[i] != i:
        i = f[i]
    j = u
    while f[j] != j:
        oj = j
        j = f[j]
        f[oj] = i
    return i
def uniF(u, v):
    u = getF(u)
    v = getF(v)
    if u != v:
        f[u] = v
for i in range(m):
    u, v = map(int, input().split())
    uniF(u, v)
c = [0] * (n + 1)
for i in range(1, n + 1):
    c[getF(i)] += 1
print(max(c))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
f = [i for i in range(n + 1)]
def getF(u):
    if f[f[u]] == f[u]:
        return f[u]
    f[u] = getF(f[u])
    return f[u]
def uniF(u, v):
    u = getF(u)
    v = getF(v)
    if u != v:
        f[u] = v
for i in range(m):
    u, v = map(int, input().split())
    uniF(u, v)
c = [0] * (n + 1)
for i in range(1, n + 1):
    c[getF(i)] += 1
print(max(c))
Problem p02603 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
c = 1000
for i in range(1, n):
    if a[i] > a[i - 1]:
        c = c // a[i - 1] * a[i] + c % a[i - 1]
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
dp = [[[-1] * (5 * 10 ** 6) for _ in range(n)] for _ in range(2)]
dp[0][0][1000] = 0
dp[1][0][1000] = 0
for i in range(n):
    for j in range(5 * 10 ** 6):
        dp[0][i + 1][j], dp[1][i + 1][j] = dp[0][i][j], dp[1][i][j]
    for j in range(5 * 10 ** 6):
        u, v = dp[0][i][j], dp[1][i][j]
        if max(u, v) < 0:
            continue
        dp[0][i + 1][j] = u
        dp[1][i + 1][j] = v
        # print(i, j, u, v)
        dp[0][i + 1][j + max(u, v) * a[i]] = 0
        dp[1][i + 1][j % a[i]] = max(u, v) + j // a[i]
ans = 0
for j in range(10 ** 4):
    if dp[0][n][j] != -1 or dp[1][n][j] != -1:
        ans = max(ans, j)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
dp = [[[-1] * (10 ** 4) for _ in range(n)] for _ in range(2)]
dp[0][0][1000] = 0
dp[1][0][1000] = 0
for i in range(n):
    for j in range(10 ** 4):
        dp[0][i + 1][j], dp[1][i + 1][j] = dp[0][i][j], dp[1][i][j]
    for j in range(10 ** 4):
        u, v = dp[0][i][j], dp[1][i][j]
        if max(u, v) < 0:
            continue
        dp[0][i + 1][j] = u
        dp[1][i + 1][j] = v
        # print(i, j, u, v)
        dp[0][i + 1][j + max(u, v) * a[i]] = 0
        dp[1][i + 1][j % a[i]] = max(u, v) + j // a[i]
ans = 0
for j in range(10 ** 4):
    if dp[0][n][j] != -1 or dp[1][n][j] != -1:
        ans = max(ans, j)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
dp = [[[-1] * (10 ** 4) for _ in range(80)] for _ in range(2)]
dp[0][0][1000] = 0
dp[1][0][1000] = 0
for i in range(n):
    for j in range(10 ** 4):
        dp[0][i + 1][j], dp[1][i + 1][j] = dp[0][i][j], dp[1][i][j]
    for j in range(10 ** 4):
        u, v = dp[0][i][j], dp[1][i][j]
        if max(u, v) < 0:
            continue
        dp[0][i + 1][j] = u
        dp[1][i + 1][j] = v
        # print(i, j, u, v)
        dp[0][i + 1][j + max(u, v) * a[i]] = 0
        dp[1][i + 1][j % a[i]] = max(u, v) + j // a[i]
ans = 0
for j in range(10 ** 4):
    if dp[0][n][j] != -1 or dp[1][n][j] != -1:
        ans = max(ans, j)
print(ans)
Problem p02742 (python)

Fixed submission:
a, b = map(int, input().split())
if min(a, b) > 1:
    print(b // 2 * a + ((a // 2 + a % 2) if b % 2 else 0))
else:
    print(1)

Buggy submission (verdict: Runtime Error):
if min(a, b) > 1:
    print(b // 2 * a + ((a // 2 + a % 2) if b % 2 else 0))
else:
    print(1)
Problem p02745 (python)

Fixed submission:
maxn = 2000 * 4 + 3
maxnh = maxn // 2
 
def check(s, t, d):
    for i in range(max(0, d), min(len(s), len(t) + d)):
        if s[i] != '?' and t[i - d] != '?' and s[i] != t[i - d]:
            return False
    return True
 
def ca(s, t):
    res = [True] * maxn
    for i in range(-len(t), len(s) + 1):
        res[i + maxnh] = check(s, t, i)
    return res
 
a, b, c = (input() for _ in range(3))
ans = sum(map(len, (a, b, c)))
ab, bc, ac = ca(a, b), ca(b, c), ca(a, c)
 
for i in range(maxn):
    if not ab[i]:
        continue
    for j in range(maxn):
        if not bc[j]:
            continue
        if (0 <= i + j - maxnh < maxn) and not ac[i + j - maxnh]:
            continue
        ans = min(ans, max(len(a), len(b) + i - maxnh, len(c) + i + j - maxnh * 2) - min(0, i - maxnh, i + j - maxnh * 2))
 
print(ans)

Buggy submission (verdict: Runtime Error):
maxn = 2000 * 3 + 3
maxnh = maxn // 2

def check(s, t, d):
    for i in range(max(0, d), min(len(s), len(t) + d)):
        if s[i] != '?' and t[i] != '?' and s[i] != t[i - d]:
            return False
    return True

def ca(s, t):
    res = [True] * maxn
    for i in range(-len(t), len(s) + 1):
        res[i + maxnh] = check(s, t, i)
    return res

a, b, c = (input() for _ in range(3))
ans = sum(map(len, (a, b, c)))
ab, bc, ac = ca(a, b), ca(b, c), ca(a, c)
for i in range(maxn):
    if not ab[i]:
        continue
    for j in range(maxn):
        if not bc[j]:
            continue
        if not (0 <= i + j - maxnh < maxn) or not ac[i + j - maxnh]:
            continue
        ans = min(ans, max(len(a), len(b) + i - maxnh, len(c) + i + j - maxnh * 2) - min(0, i - maxnh, i + j - maxnh * 2))
print(ans)
Problem p02746 (python)

Fixed submission:
def solve():
    a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    if a > c:
        a, b, c, d = c, d, a, b
    for k in range(30, -1, -1):
        def check(a, b, c, d):
            if a // 3 ** k == c // 3 ** k and a // 3 ** k % 3 == 1 \
                    and (min(b, d) // 3 ** k % 3 == 0 and max(b, d) // 3 ** k % 3 == 2
                            or max(b, d) // 3 ** k - min(b, d) // 3 ** k >= 3):
                print(min(a % 3 ** k + 1 + c % 3 ** k + 1 + abs(b - d),
                    3 ** k - a % 3 ** k + 3 ** k - c % 3 ** k + abs(b - d)))
                return True
        if check(a, b, c, d) or check(b, a, d, c):
            return
    print(abs(a - c) + abs(b - d))

q = int(input())
for _ in range(q):
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    if a > c:
        a, b, c, d = c, d, a, b
    for k in range(30, -1, -1):
        if a // 3 ** k == c // 3 ** k and a // 3 ** k % 3 == 1 \
                and min(b, d) // 3 ** k % 3 == 0 and max(b, d) // 3 ** k % 3 == 2:
            print(min(a % 3 ** k + 1 + c % 3 ** k + 1 + abs(b - d),
                3 ** k - a % 3 ** k + 3 ** k - c % 3 ** k + abs(b - d)))
            return
        if b // 3 ** k == d // 3 ** k and b // 3 ** k % 3 == 1:
                and min(a, c) // 3 ** k % 3 == 0 and max(a, c) // 3 ** k % 3 == 2:
            print(min(b % 3 ** k + 1 + d % 3 ** k + 1 + abs(a - c),
                3 ** k - b % 3 ** k + 3 ** k - d % 3 ** k + abs(a - c)))
            return
    print(abs(a - c) + abs(b - d))

q = int(input())
for _ in range(q):
    solve()
Problem p02840 (python)

Fixed submission:
import math

n, X, D = map(int, input().split())

if D == 0:
	if X == 0:
		print(1)
	else:
		print(n + 1)
	exit()

Y = dict()

for i in range(n + 1):
	b = -2 * i * X
	r = (n - 1 + n - i) * i // 2
	l = (0 + i - 1) * i // 2
	off = b % (-2 * D)
	l += (b - off) // (-2 * D)
	r += (b - off) // (-2 * D)
	if off in Y:
		Y[off].append((l, r))
	else:
		Y[off] = [(l, r)]

def calc(u):
	pt = dict()
	for l, r in u:
		if l in pt:
			pt[l] += 1
		else:
			pt[l] = 1
		if r + 1 in pt:
			pt[r + 1] -= 1
		else:
			pt[r + 1] = -1
	cur, v = -10 ** 100, 0
	ans = 0
	for k in sorted(pt.keys()):
		if v:
			ans += k - cur
		v += pt[k]
		cur = k
	return ans

print(sum(map(calc, Y.values())))

Buggy submission (verdict: Runtime Error):
import math

n, X, D = map(int, input().split())

if D == 0:
	if X == 0:
		print(1)
	else:
		print(N + 1)
	exit()

Y = dict()

for i in range(n + 1):
	b = -2 * i * X
	r = (n - 1 + n - i) * i // 2
	l = (0 + i - 1) * i // 2
	off = b % (-2 * D)
	l += (b - off) // (-2 * D)
	r += (b - off) // (-2 * D)
	if off in Y:
		Y[off].append((l, r))
	else:
		Y[off] = [(l, r)]

def calc(u):
	pt = dict()
	for l, r in u:
		if l in pt:
			pt[l] += 1
		else:
			pt[l] = 1
		if r + 1 in pt:
			pt[r + 1] -= 1
		else:
			pt[r + 1] = -1
	cur, v = -10 ** 100, 0
	ans = 0
	for k in sorted(pt.keys()):
		if v:
			ans += k - cur
		v += pt[k]
		cur = k
	return ans

print(sum(map(calc, Y.values())))

Buggy submission (verdict: Runtime Error):
import math
n, X, D = map(int, input().split())
Y = dict()
for i in range(n + 1):
	b = -2 * i * X
	r = (n - 1 + n - i) * i // 2
	l = (0 + i - 1) * i // 2
	off = b % (-2 * D)
	l += (b - off) // (-2 * D)
	r += (b - off) // (-2 * D)
	if off in Y:
		Y[off].append((l, r))
	else:
		Y[off] = [(l, r)]
def calc(u):
	pt = dict()
	for l, r in u:
		if l in pt:
			pt[l] += 1
		else:
			pt[l] = 1
		if r + 1 in pt:
			pt[r + 1] -= 1
		else:
			pt[r + 1] = -1
	cur, v = -10 ** 100, 0
	ans = 0
	for k in sorted(pt.keys()):
		if v:
			ans += k - cur
		v += pt[k]
		cur = k
	return ans
print(sum(map(calc, Y.values())))
Problem p02981 (python)

Fixed submission:
n, a, b = map(int, input().split())
print(min(n * a, b))

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input())
print(min(n * a, b))
Problem p03247 (python)

Fixed submission:
n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]

s = set(map(lambda x: sum(map(abs, x)) % 2, a))
if len(s) >= 2:
    print(-1)
    exit()

if next(iter(s)) == 0:
    m = 33
else:
    m = 32

d = [2 ** i for i in range(32)]
if m > len(d):
    d.append(1)

print(m)
print(*d)

def fetch(x, y, i=31):
    if i == 0:
        return {(1, 0): 'R', (-1, 0): 'L', (0, 1): 'U', (0, -1): 'D'}[(x, y)]
    if abs(x - d[i]) + abs(y) < d[i]:
        return fetch(x - d[i], y, i - 1) + 'R'
    if abs(x + d[i]) + abs(y) < d[i]:
        return fetch(x + d[i], y, i - 1) + 'L'
    if abs(y - d[i]) + abs(x) < d[i]:
        return fetch(x, y - d[i], i - 1) + 'U'
    if abs(y + d[i]) + abs(x) < d[i]:
        return fetch(x, y + d[i], i - 1) + 'D'

for x, y in a:
    if m == 33:
        print(fetch(x + 1, y) + 'L')
    else:
        print(fetch(x, y))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]

s = set(map(lambda x: sum(map(abs, x)) % 2, a))
if len(s) >= 2:
    print(-1)
    exit()

if next(iter(s)) == 1:
    m = 39
else:
    m = 40
d = [1] * m

print(m)
print(*d)

for x, y in a:
    c = []
    if x < 0:
        c.extend(['L'] * -x)
    elif x > 0:
        c.extend(['R'] * x)
    if y < 0:
        c.extend(['D'] * -y)
    elif y > 0:
        c.extend(['U'] * y)
    print(''.join(c + ['LR'] * m)[:m])
Problem p02576 (python)

Fixed submission:
n,x,t = map(int,input().split())
import math
if n%x == 0:
  print(math.floor((n/x)*t))
else:
  print(math.floor(((n+x)//x)*t))

Buggy submission (verdict: Runtime Error):
n,x,t = map(int,input().split())
if n%x == 0:
  print(n*y/x)
else:
  print(((n//x)+1)*t)
Problem p02583 (python)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
l.sort
ans = 0
for i in range(n):
  for j in range(n):
    if i ==	j:
      continue
    for k in range(n):
      if j == k:
        continue
      elif i == k:
        continue
      if l[i] < l[j] < l[k]:
        if l[i] + l[j] > l[k]:
          ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = input()
ans = 
for i in l:
  for j in l:
    if i<j:
      for k in l:
        if j<k and i+j>k:
          ans+=1

print(ans)
Problem p02630 (python)

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

ls = sorted(ls)
ans = sum(ls)
newls = [0]*(100000+1+1)
for p in ls:
  newls[p] += 1
ls = newls

q=int(input())
for _ in range(q):
  b,c = map(int,input().split())
  
  tmp = ls[b]
  ans = ans + tmp*c - tmp*b
  ls[b] = 0
  ls[c] += tmp
  
  print(ans)

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

ls = sorted(ls)
ans = sum(ls)
newls = [0]*(n+1)
for p in ls:
  newls[p] += 1
ls = newls

q=int(input())
for _ in range(q):
  b,c = map(int,input().split())
  
  tmp = ls[b]
  ans = ans + tmp*c - tmp*b
  ls[b] = 0
  ls[c] = tmp
  
  print(ans)
Problem p02641 (python)

Fixed submission:
x,n = map(int,input().split())
if n==0:
  print(x)
  exit()
ls = list(map(int,input().split()))

ls = sorted(ls)
d = 10**3
ans = 0
for i in range(ls[0]-1,ls[-1]+2):
  if i in ls:
    continue
  if d>abs(i-x):
    d = abs(i-x)
    ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
x,n = map(int,input().split())
ls = list(map(int,input().split()))

ls = sorted(ls)
d = 10**3
ans = 0
for i in range(ls[0]-1,ls[-1]+2):
  if i in ls:
    continue
  if d>abs(i-x):
    d = abs(i-x)
    ans = i
print(ans)
Problem p02646 (python)

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

if w>=v:
  print("NO")
  exit()

print("YES" if max(a-b,b-a)/(v-w)<=t else "NO")

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

print("YES" if max(a-b,b-a)/(w-v)<=t else "NO")
Problem p02706 (python)

Fixed submission:
n,m = map(int,input().split())
ls = list(map(int,input().split()))
for a in ls:
  n -= a
print(max(-1,n))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
ls = list(map(int,input().split()))
for a in range(ls):
  n -= a
print(max(-1,n))
Problem p02742 (python)

Fixed submission:
h,w = map(int,input().split())

if h==1 or w==1:
  print(1)
  exit()

print((w+1)//2*(h%2) + w*(h//2))

Buggy submission (verdict: Runtime Error):
import ceil from math
h,w = map(int,input().split())

print(ceil(w/2)*(h%2) + w*(h//2))
Problem p02760 (python)

Fixed submission:
mat = [list(map(int,input().split())) for i in range(3)]
mat = mat[0]+mat[1]+mat[2]

n = int(input())
for _ in range(n):
  m = int(input())
  for i in range(9):
    if mat[i] == m:
      mat[i] = 1000

if sum(mat[:3])>=3000:
  print("Yes")
elif sum(mat[3:6])>=3000:
  print("Yes")
elif sum(mat[6:])>=3000:
  print("Yes")
elif sum(mat[::3])>=3000:
  print("Yes")
elif sum(mat[1::3])>=3000:
  print("Yes")
elif sum(mat[2::3])>=3000:
  print("Yes")
elif sum(mat[::4])>=3000:
  print("Yes")
elif sum(mat[2:7:2])>=3000:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
mat = [[map(int,input().split())] for i in range(3)]
mat = mat[0]+mat[1]+mat[2]

n = int(input())
for _ in range(n):
  m = int(input())
  for i in range(9):
    if mat[i] == m:
      mat[i] = 1000

if sum(mat[:3])>=3000:
  print("Yes")
elif sum(mat[3:6])>=3000:
  print("Yes")
elif sum(mat[6:])>=3000:
  print("Yes")
elif sum(mat[::3])>=3000:
  print("Yes")
elif sum(mat[1::3])>=3000:
  print("Yes")
elif sum(mat[2::3])>=3000:
  print("Yes")
elif sum(mat[::4])>=3000:
  print("Yes")
elif sum(mat[2:7:2])>=3000:
  print("Yes")
else:
  print("No")
Problem p02765 (python)

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

if n >=10:
  print(r)
else:
  print(r+100*(10-n))

Buggy submission (verdict: Runtime Error):
n,r = map(int,input().split())

if n >=10:
  print(r)
else:
  print(r+100*(10−n))

Buggy submission (verdict: Runtime Error):

n,r = map(int,input().split())

if n >=10:
  print(r)
else:
  print(r+100×(10−n))
Problem p02768 (python)

Fixed submission:
def comb_mod(n,m,mod):
  p = q = 1
  for i in range(m):
    p = p*(n-i) % mod
    q = q*(i+1) % mod
  return p* pow(q,mod-2,mod) % mod

n,a,b = map(int,input().split())
mod = 10**9 +7
print( (pow(2,n,mod)-1 -comb_mod(n,a,mod) -comb_mod(n,b,mod) ) % mod )

Buggy submission (verdict: Runtime Error):
def comb_mod(n,m,mod):
  p = q = 1
  for i in range(m):
    p = p*(n-i) % mod
    q = q*(i+1) % mod
  return p* pow(q,mod-2,mod) % mod

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

print( (pow(2,n,mod)-1 -comb_mod(n,a,mod) -comb_mod(n,b,mod) ) % mod )
Problem p02783 (python)

Fixed submission:
import math

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

print(math.ceil(a/b))

Buggy submission (verdict: Runtime Error):
h,n = map(int,input().split())

ls = [list(map(int,input().split())) for _ in range(n)]

amax = max(a for a,b in ls)

dp = [0]*(h+amax)

for i in range(1,h+amax):
  dp[i] = min(dp[max(0,i-a)]+b for a,b in ls)

print(min(dp[h:]))
Problem p02787 (python)

Fixed submission:
n,m=map(int, input().split())
s=[list(map(int, input().split())) for i in range(m)]
x=max(a for a,b in s)
dp=[0]*(n+x)
for i in range(0,n+x):
  if i>0:
    dp[i]=min(dp[i-a]+b for a,b in s)
print(min(dp[n:]))

Buggy submission (verdict: Runtime Error):
from operator import itemgetter, attrgetter

h,n = map(int,input().split())
ls = []

for _ in range(n):
  a,b =  map(int,input().split())
  ls.append(a,b)

ls = sorted(ls,key = lambda x: min(x[0],h)/x[1], reverse = True)
ans = 0

t = ls[0]
ans += h//t
h %= t

while h>0:
  ls = sorted(ls,key = lambda x: min(x[0],h)/x[1], reverse = True)
  t = ls[0]
  ans += h//t
  h %= t
print(ans)
Problem p02797 (python)

Fixed submission:
import math

def f(n,k,s):
  if s== 10**9:
    return [s if i<k else s-1 for i in range(n)]
  return [s if i<k else s+1 for i in range(n)]
  
    

n,k,s= map(int,input().split())

ans = f(n,k,s)

s= ""

for a in ans:
  s += str(a)+" "
  
print(s)

Buggy submission (verdict: Runtime Error):
import math

def f(n,k,s):
  if n==k:
    return [s]*n
  u = math.ceil(s/2)-1
  v = s-u
  ls = [(u if i%2==0 else v) for i in range(n)]
  for i in range(n-k-1):
    ls[i] = s+1


n,k,s= map(int,input().split())

ans = f(n,k,s)

s= ""

for a in ans:
  s += str(a)+" "
  
print(s)