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

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

if a < k:
  a1 = k - a
  a2 = b - a1 if b > a1 else 0
  print('0 ' + str(a2))
        
else:
  print(str(a-k) + ' ' + str(b))

Buggy submission (verdict: Runtime Error):
a, b, k = [int(i) for i in input().split()]
maxs = (0, a - k)


print(str(maxs) + " " + str(b - maxs))
Problem p02843 (python)

Fixed submission:
x = int(input())

flag = False
for c in range(1,x+1):
  if c * 100 <= x and x <= c * 105:
    flag = True
    break
print(1 if flag else 0)

Buggy submission (verdict: Runtime Error):
n = int(input())
 
ans = 0
for i in range(1, n+1):
  if n in list(range(100 * i, 105 * i + 1))
    ans = 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())

ans = 0
for i in range(1, n+1):
  for x in range(100 * x, 105 * x + 1):
    if n == x:
      ans = 1
print(ans)
Problem p02924 (python)

Fixed submission:
n = int(input())
print((n-1)*n // 2)

Buggy submission (verdict: Runtime Error):
n = int(input())
print(sum(list(range(1, n))) if n != 0 else 0)
Problem p02953 (python)

Fixed submission:
def hoge(x, y):
    return y if x >= y else y - 1

N = int(input())
H = list(map(int, input().split()))
H = list(reversed(H))

flag = 0
for i in range(N - 1):
    H[i + 1] = hoge(H[i], H[i + 1])
    if H[i] < H[i + 1]:
        flag = 1
        print("No")
        break

if flag == 0:
    print("Yes")

Buggy submission (verdict: Runtime Error):
def hoge(x, y):
    return y if x >= y else y - 1

N = int(input())
H = list(map(int, input().split()))
H = list(reversed(H))

flag = 0
for i in range(N - 1):
    H[i + 1] = hoge(H[i], H[i + 1])
    print(H)
    if H[i] < H[i + 1]:
        print("No")
        flag = 1
        break

if flag == 0:
    print("Yes")
Problem p02981 (python)

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

tac = N * A
train = B

if tac < train:
    print(tac)

else:
    print(train)

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

L, R = list(map(int, input().split()))
data = np.array([x for x in range(L, R+1)]) % 2019

if np.where(data == 0):
    print(0)

else: 
    data = np.sort(data)
    min_mod = (data[0] * data[1]) % 2019
    print(min_mod)
Problem p02983 (python)

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

if r - l >= 2019:
  print(0)
  
else:
  ll = l % 2019
  rr = r % 2019
  if rr < ll:
    print(0)
    
  else:
    keep = 2020
    for i in range(ll, rr+1):
      for j in range(i+1, rr+1):
        keep = min((i*j)%2019, keep)
    print(keep)

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

L, R = list(map(int, input().split()))
data = np.array([x for x in range(L, R+1)]) % 2019
data = np.unique(data)
length = R - L

min_mod = 2018
for t in range(length):
    i = length - t
    for j in range(i):
        mod = data[i] * data[j] % 2019
        min_mod = mod if min_mod > mod else min_mod
        if min_mod == 0:
            break
        
print(min_mod)

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

L, R = list(map(int, input().split()))
data = np.array([x for x in range(L, R+1)]) % 2019
data = np.unique(data)
length = R - L

min_mod = 2018
for t in range(length):
    i = length - t
    for j in range(i):
        mod = data[i] * data[j] % 2019
        min_mod = mod if min_mod > mod else min_mod
        
print(min_mod)

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

L, R = list(map(int, input().split()))
data = np.array([x for x in range(L, R+1)]) % 2019
data = np.unique(data)
length = R - L

min_mod = 2018
for t in range(length):
    i = length - t
    for j in range(i):
        mod = data[i]* data[j]
        min_mod = mod if min_mod > mod else min_mod
        
print(min_mod)

Buggy submission (verdict: Runtime Error):
import math

L, R = list(map(int, input().split()))
data = [x % 2019 for x in range(L, R+1)]
len_data = [x for x in range(len(data))]
mod_min = math.inf

for i in reversed(len_data):
    for j in range(i):
        mod = data[i] * data[j]
        mod_min = mod if mod_min > mod else mod_min

print(mod_min)

Buggy submission (verdict: Runtime Error):
import math

L, R = list(map(int, input().split()))
data = [x for x in range(L, R+1)]
len_data = [x for x in range(len(data))]
mod_min = math.inf

for i in reversed(len_data):
    for j in range(i):
        mod = (data[i] * data[j]) % 2019
        mod_min = mod if mod_min > mod else mod_min

print(mod_min)

Buggy submission (verdict: Runtime Error):
import math

L, R = list(map(int, input().split()))
data = [x for x in range(L, R+1)]

mod_min = math.inf
for x in data:
    for y in data:
        if x == y:
            continue
            
        mod = (x * y) % 2019
        mod_min = mod if mod_min > mod else mod_min

print(mod_min)
Problem p02988 (python)

Fixed submission:
import numpy as np

N = int(input())
data = list(map(int, input().split()))
pn = [x for x in range(1, N-1)]

cnt = 0
for p in pn:
    p_t = np.sort([data[p - 1], data[p], data[p + 1]])
    cnt = cnt + 1 if p_t[1] == data[p] else cnt
    
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
data = list(map(int, input().split()))
pn = [x for x in range(1, N-1)]

cnt = 0
for p in pn:
    p_t = np.sort([data[p - 1], data[p], data[p + 1]])
    cnt = cnt + 1 if p_t[1] == data[p] else cnt
    
print(cnt)
Problem p03105 (python)

Fixed submission:
A, B, C = list(map(int, input().split()))
print(min(B//A, C))

Buggy submission (verdict: Runtime Error):
from collections import Counter
print(2*min(Counter(list(input()).values()))
Problem p03136 (python)

Fixed submission:
n = int(input())
x = [int(i) for i in input().split()]
x = sorted(x, reverse=True)
print("Yes" if x[0] < sum(x[1:]) else "No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [int(i) for i in intpu().split()]

s = sorted(s, reverse=True)
print("Yes" if s[0] < sum(s[1:]) else "No")
Problem p03238 (python)

Fixed submission:
N = int(input())

if N == 1:
  print('Hello World')

else:
  print(sum([int(input()) for i in range(2)]))

Buggy submission (verdict: Runtime Error):
N = int(intput())

if N == 1:
  print('Hello World')

else:
  print(sum([int(input()) for i in range(2)]))

Buggy submission (verdict: Runtime Error):
N, a, b = [int(input()) for i in range(3)]

print('Hello World' if N == 1 else str(a + b))

Buggy submission (verdict: Runtime Error):
N, a, b = [int(input()) for i in range(3)]

print('Hello World' if N == 1 else a + b)
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())

for i in range(len(s)):
    if s[i] != "1":
        print(s[i])
        break
        
    else:
        k -= 1
        if k == 0:
            print(1)
            break

Buggy submission (verdict: Runtime Error):
s = input()
n = int(input())

for i in range(len(s)):
    if s[i] != "1":
        print(s[i])
        break
        
    else:
        k -= 1
        if k == 0:
            print(1)
            break
Problem p03361 (python)

Fixed submission:
import numpy as np
h, w = list(map(int, input().split()))
s = np.array([list(input()) for i in range(h)])

infer = []
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      pts = set([
        (max(0, i-1), j), 
        (i, max(0, j-1)), 
        (min(h-1, i+1), j), 
        (i, min(w-1, j+1))
      ])
      check = np.array([ s[ix][iy] for ix, iy in list(pts - set([(i, j)])) ])
      infer.append((check == "#").sum())

print("No" if 0 in infer else "Yes")

Buggy submission (verdict: Runtime Error):
h, w = list(map(int, input().split()))
maps = [list(input()) for i in range(h)]

def search(i, j):
  for dh, dw in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
    x = max(0, min(i + dw, w-1))
    y = max(0, min(j + dh, h-1))
    if i == y and j == x: continue 
    if maps[x][y] == "#":
      return True
  return False

flag = True
for i in range(h):
  for j in range(w):
    if maps[i][j] == "#" and not search(i, j):
        flag = False
        break
        
print("Yes" if flag else "No")
Problem p03456 (python)

Fixed submission:
import math
a, b = input().split()
x = int(a) * 10 ** len(b) + int(b)

flag = False
for i in range(1,int(math.sqrt(x))+1):
    if i ** 2 == x:
        flag =True
        break

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

Buggy submission (verdict: Runtime Error):
import math
a, b = list(map(int, input().split()))
x = a * 100 + b

flag = False
for i in range(1,int(math.sqrt(x))+1):
    if i ** 2 == x:
        flag =True
        break:

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

Buggy submission (verdict: Runtime Error):
import math
a, b = list(map(int, input().split()))
x = a * 100 + b

flag = False
for i in range(1,int(math.sqrt(x))+1):
    if i ** 2 == x:
        flag =True
        break:

print("Yes" if flag 2 else "No")
Problem p03607 (python)

Fixed submission:
from collections import Counter
n = int(input())
a = Counter([int(input()) for i in range(n)])

cnt = 0
for k, v in a.items():
  if v % 2 == 1:
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
cnt = [0 for i in range(10**6)]

for i in range(n):
  cnt[int(input())-1] += 1
  
print( (np.array(cnt) % 2).sum())

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
cnt = [0 for i in range(10**6)]

for ai in a:
  cnt[int(input())-1] += 1
  
print( (np.array(cnt) % 2).sum())

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = [int(input()) for i in range(n)]
cnt = [0 for i in range(1000000)]

for ai in a:
  cnt[ai-1] += 1
  
print( (np.array(cnt) % 2).sum())

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
cnt = [0 for i in range(1000000)]

for i in range(n):
  cnt[int(input())-1] += 1
  
print( (np.array(cnt) % 2).sum())
Problem p03627 (python)

Fixed submission:
import collections

n = int(input())
p = list(map(int,input().split()))
cnt = collections.Counter(p)

maxs = []
for k, v in cnt.items():
  if v > 1:
    maxs.append(k)
    
if len(maxs) > 1:
  maxs.sort()
  if cnt[maxs[-1]] > 3:
    print(maxs[-1] ** 2)
  else:
    print(maxs[-1] * maxs[-2])

else:
  print(0)

Buggy submission (verdict: Runtime Error):
import collections

n = int(input())
p = list(map(int,input().split()))
cnt = collections.Counter(p)

maxs = []
for k, v in cnt.items():
  if v > 1:
    maxs.append(k)
    
if len(maxs) > 1:
  maxs.sort()
  if len(maxs[-1]) > 3:
    print(maxs[-1] ** 2)
  else:
    print(maxs[-1] * maxs[-2])

else:
  print(0)
Problem p03639 (python)

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

a4, a4n, a2 = 0, 0, 0
for ai in a:
  if ai % 4 == 0:
    a4 += 1
  elif ai % 2 == 0:
    a2 += 1
  else:
    a4n += 1

if a2 != 0:
  print("Yes" if a4 + 1 >= a4n+1 else "No")

else:
  print("Yes" if a4 + 1 >= a4n else "No")

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

a4 = len(a[a % 4 == 0])
a2 = len(a[a % 2 == 0 and a % 4 != 0])
a4n = len(a[a % 4 != 0]) - a2 

if a2 != 0:
  print("Yes" if a4 + 1 >= a4n+1 else "No")

else:
  print("Yes" if a4 + 1 >= a4n else "No")
Problem p04001 (python)

Fixed submission:
from itertools import product
s = list(input())
n = len(s)-1

ans = 0
for x in list(product(["", "+"], repeat=n)):
    x = list(x)
    x.append("")
    
    strs = [i+j for i, j in zip(s, x)]
    ans += eval("".join(strs))
print(ans)

Buggy submission (verdict: Runtime Error):
s = list(input())
n = len(s)-1

ans = 0
for x in list(product(["", "+"], repeat=n)):
    x = list(x)
    x.append("")
    
    strs = [i+j for i, j in zip(s, x)]
    ans += eval("".join(strs))
print(ans)
Problem p04030 (python)

Fixed submission:
s = list(input())

hoge = []
for si in s:
  if si != "B":
    hoge.append(si)
  elif si == "B" and len(hoge) > 0:
    hoge.pop()
    
print("".join(hoge))

Buggy submission (verdict: Runtime Error):
s = list(input())

hoge = []
for si in s:
  if si != "B":
    hoge.append(si)
  else:
    hoge.pop()
    
print("".join(hoge))
Problem p04034 (python)

Fixed submission:
n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
ans[0] = 1
ball = [False] * (n)
ball[0] = True
for i in range(m):
    x, y = xy[i]
    ans[y-1] += 1
    ans[x-1] -= 1
    if ball[x-1]:
      ball[y-1] = True
    if ans[x-1] == 0:
      ball[x-1] = False
      
cnt = 0
for i in ball:
  if i:
    cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
ans[0] = 1
ball = [0] * (n)
ball[0] = 1
for i in range(m):
    x, y = xy[i]
    ans[y-1] += 1
    ans[x-1] -= 1
    if ball[x-1]:
      ball[y-1] = 1
    if ans[x-1] == 0:
      ball[x-1] = 0
      
print(sum(cnt))
Problem p02841 (python)

Fixed submission:
m1,d1=map(int,input().split())
m2,d2=map(int,input().split())

if m1+1==m2:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
m1=int(input())
d1=int(input())
m2=int(input())
d2=int(input())
if m1+1==m2:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
m1=int(input())
d1=int(intput())
m2=int(input())
d2=int(intput())
if m1+1==m2:
  print(1)
else:
  print(0)
Problem p02658 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
limit = 10**18
for i in a:
    ans*=i
    if ans > limit:
        print(-1)
        exit()
print(ans)

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split()))
ans = 1
if 0 in a:
    print(0)
    exit()
limit = 10**18
for i in a:
    ans*=i
    if ans > lim:
        print(-1)
        exit()
print(ans)
Problem p02692 (python)

Fixed submission:
n, a, b, c = map(int, input().split())
d = {'A':a, 'B':b, 'C':c}
ans = []
def move(inc, dec):
    d[inc]+=1
    d[dec]-=1
    ans.append(inc)
q = []
for i in range(n):
    q.append(input())
for i in range(n):
    x = q[i][0]
    y = q[i][1]
    if d[x] == 0 and d[y] == 0:
        print("No")
        exit()
    if d[x] == 1 and d[y] == 1:
        if i == n-1:
            move(x, y)
            continue
        if x in q[i+1]:
            move(x, y)
        else:
            move(y, x)
    else:
        if d[x] >= d[y]:
            move(y, x)
        else:
            move(x, y)
print("Yes")
print(*ans, sep = '\n')

Buggy submission (verdict: Runtime Error):
n, a, b, c = map(int, input().split())
d = {'A':a, 'B':b, 'C':c}
ans = []
def move(inc, dec):
    d[inc]+=1
    d[dec]-=1
    ans.append(inc)
q = []
for i in range(n):
    q.append(input())
for i in range(n):
    x = q[i][0]
    y = q[i][1]
    if d[x] == 0 and d[y] == 0:
        print("No")
        exit()
    if d[x] == 1 and d[y] == 1:
        if i == n-1:
            move(x, y)
        if x in q[i+1]:
            move(x, y)
        else:
            move(y, x)
    else:
        if d[x] >= d[y]:
            move(y, x)
        else:
            move(x, y)
print("Yes")
print(*ans, sep = '\n')
Problem p02811 (python)

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

Buggy submission (verdict: Runtime Error):
import math 
n, m = map(int, input().split())
a = list(map(int, input().split()))
z = a[0]
for i in a:
    z = math.gcd(z, i)
for i in range(n):
    a[i]//=z
lcm = 1
a = set(a)
for i in a:
    lcm*=i
print(math.ceil((m//lcm)/2))
Problem p02817 (python)

Fixed submission:
s, t = input().split()
print(t+s)

Buggy submission (verdict: Runtime Error):
s, t = input().split()
print(t+c)
Problem p02630 (python)

Fixed submission:
from collections import Counter

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

cnt = Counter(a)

s = sum(a)

for i in range(q):
	b, c = map(int, input().split())
	s = s - b*cnt[b]
	s = s + c*cnt[b]
	cnt[c] += cnt[b]
	cnt[b] = 0
	print(s)

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

for i in range(q):
	B, C = map(int, input().split())
	b.append(B)
	c.append(C)

cnt = Counter(a)

s = sum(cnt)

for i in range(q):
	b, c = map(int, input().split())
	s = s - b*cnt[b]
	s = s + c*cnt[b]
	cnt[c] += cnt[b]
	cnt[b] = 0
	print(s)

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

b = []
c = []
for i in range(q):
	B, C = map(int, input().split())
	b.append(B)
	c.append(C)

cnt = Counter(a)

s = sum(arr)

for i in range(q):
	s -= b[i]*cnt[b[i]]
	s += c[i]*cnt[b[i]]
	cnt[c[i]] += cnt[b[i]]
	cnt[b[i]] = 0
	print(s)

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

b = []
c = []
for i in range(q):
	B, C = map(int, input().split())
	b.append(B)
	c.append(C)

arr = Counter(a)

s = sum(arr)

for i in range(q):
	s -= b[i]*arr[b[i]]
	s += c[i]*arr[c[i]]
	ans[c[i]] += ans[b[i]]
	ans[b[i]] = 0
	print(s)
Problem p02696 (python)

Fixed submission:
import math

a, b, n = map(int, input().split())
x = min(n, b-1)
print(math.floor(a*x/b)-a*math.floor(x/b))

Buggy submission (verdict: Runtime Error):
import math

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

if n>=b:
	n1 = n//b*b-1
	n2 = n//b*b-2
	ans = max(math.floor(a*n/b)-a*math.floor(n/b), max(math.floor(a*n1/b)-a*math.floor(n1/b)), math.floor(a*n2/b)-a*math.floor(n2/b))
else:
	ans = math.floor(a*n/b)-a*math.floor(n/b)

print(ans)
Problem p02756 (python)

Fixed submission:
from collections import deque

s = deque(input())
q = int(input())

query = []
rev=1

for i in range(q):
    query.append(input().split())

for i in range(q):
    if query[i][0]=="1":
        rev*=-1
    else:
        if rev==1:
            if query[i][1]=="1":
                s.appendleft(query[i][2])
            else:
                s.append(query[i][2])
        else:
            if query[i][1]=="2":
                s.appendleft(query[i][2])
            else:
                s.append(query[i][2])

result="".join(list(s))
if rev==-1:
    result = result[::-1]
print(result)

Buggy submission (verdict: Runtime Error):
from collections import deque

s = deque(input())
q = int(input())

query = []
rev=1

for i in range(q):
    query.append(input().split())

for i in range(q):
    if query[i][0]=="1":
        rev*=-1
    else:
        if rev==1:
            if query[i][1]=="1":
                s.appendleft(query[i][2])
            else:
                s.append(query[i][2])
        else:
            if query[i][1]=="2":
                s.appendleft(query[i][2])
            else:
                s.append(query[i][2])

if rev==-1:
    s = s[::-1]
print("".join(list(s)))

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())

query = []
rev=1

for i in range(q):
    query.append(input().split())

for i in range(q):
    if query[i][0]=="1":
        rev*=-1
    else:
        if rev==1:
            if query[i][1]=="1":
                s.appendleft(query[i][2])
            else:
                s.append(query[i][2])
        else:
            if query[i][1]=="2":
                s.appendleft(query[i][2])
            else:
                s.append(query[i][2])

if rev==-1:
    s = s[::-1]
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())

query = [""]*q

rev=1

for i in range(q):
    query[i] = input()
    if query[i]=="1":
        rev*=-1
    else:
        r = query[i].split()
        if rev=1:
            if r[1]=="1":
                s = r[2]+s
            else:
                s += r[2]
        else:
            if r[1]=="2":
                s = r[2]+s
            else:
                s += r[2]

if rev=-1:
    s = s[::-1]
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())

query = [""]*q

for i in range(q):
    query[i] = input()
    if query[i]=="1":
        s = list(reversed(s))
    else:
        r = query[i].split()
        if r[1]=="1":
            s = r[2]+s
        else:
            s += r[2]

print(s)

Buggy submission (verdict: Runtime Error):
s = input()
q = int(input())

query = []
t = []
f = []
c = []

for i in range(q):
    query[i] = input()
    if query[i]=="1":
        t.append(1)
    else:
        r = query[i].split()
        t.append(2)
        f.append(int(r[1]))
        c.append(r[2])

for i in range(q):
    if t[i]==1:
        s = s[::-1]
    elif t[i]==2:
        if f[i]==1:
            s = c[i]+s
        elif t[i]==2:
            s = s+c[i]
print(s)
Problem p02705 (python)

Fixed submission:
import math
r = int(input())
ans = 2 * r * math.pi
print(ans)

Buggy submission (verdict: Runtime Error):
nm = list(map(int,input().split()))
n,m = nm[0],nm[1]
a = list(map(int,input().split()))
sam = sum(a)
ans = n - sam
if ans >= 0:
    print(ans)
else:
    print(-1)
Problem p02817 (python)

Fixed submission:
a = input().split()
S = a[0]
T = a[1]

print(T,end="")
print(S)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

X = int(input())
done = False
while not done:
    a = make_divisors(X)
    if len(a) == 2:
        done = True
        c = X
    else:
        X += 1
       

print(c)
Problem p02818 (python)

Fixed submission:
a = list(map(int,input().split()))
A = a[0]
B = a[1]
K = a[2]
A1 = A - K
B1 = B
if A1 < 0:
    B1 = A1 + B
    A1 = 0
    if B1 < 0:
        B1 = 0

print(A1,end=" ")
print(B1)

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
A = a[0]
B = a[1]
K = a[2]
A1 = A - K
if A1 < 0:
    B1 = A1 + B
    A1 = 0
    if B1 < 0:
        B1 = 0

print(A1,end=" ")
print(B1)
Problem p03161 (python)

Fixed submission:
nk = list(map(int,input().split()))
n,k= nk[0],nk[1]
h = list(map(int,input().split()))
dp = [0] * (n)
if n >= k:
    for i in range(k):#初期条件の定義
        dp[i] = abs(h[i] - h[0])
    for l in range(n-k):#漸化式の定義
        lis = []
        for m in range(k):
            lis.append(dp[l+m] + abs(h[l+k]-h[l+m]))
        dp[l+k] = min(lis)
    print(dp[n-1])
else:#n < k
    print(abs(h[n-1]-h[0]))

Buggy submission (verdict: Runtime Error):
nk = list(map(int,input().split()))
n,k= nk[0],nk[1]
h = list(map(int,input().split()))
dp = [0] * (n)
for i in range(k):#初期条件の定義
    dp[i] = abs(h[i] - h[0])
for l in range(n-k):#漸化式の定義
    lis = []
    for m in range(k):
        lis.append(dp[l+m] + abs(h[l+k]-h[l+m]))
    dp[l+k] = min(lis)
print(dp[n-1])
Problem p03164 (python)

Fixed submission:
N,W = map(int,input().split())
wv = [map(int,input().split()) for _ in range(N)]
w,v = [list(i) for i in zip(*wv)]
max_v,max_w = 0,0
for i,j in zip(w,v):
    max_w += i
    max_v += j
dp = [[float("inf")]*(max_v+1) for _ in range(N+1)]
dp[0][0] = 0#初期値
for i in range(1,N+1):
    for j in range(max_v+1):
        if j - v[i-1] >= 0:
            dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1])
        else:
            dp[i][j] = dp[i-1][j]
for i in range(1,max_v+2):
    if W >= dp[N][-i]:
        print(max_v+1-i)
        break

Buggy submission (verdict: Runtime Error):
import numpy as np
N,W = map(int,input().split())
wv = [map(int,input().split()) for _ in range(N)]
w,v = [list(i) for i in zip(*wv)]
max_v,max_w = 0,0
for i,j in zip(w,v):
    max_w += i
    max_v += j
dp = [[float("inf")]*(max_v+1) for _ in range(N+1)]
dp[0][0] = 0#初期値
for i in range(1,N+1):
    for j in range(max_v+1):
        if j - v[i-1] >= 0:
            dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1])
        else:
            dp[i][j] = dp[i-1][j]
for i in range(1,max_v+2):
    if W >= dp[N][-i]:
        print(max_v+1-i)
        break

Buggy submission (verdict: Runtime Error):
import numpy as np
N,W = map(int,input().split())
wv = [map(int,input().split()) for _ in range(N)]
w,v = [list(i) for i in zip(*wv)]
max_v,max_w = 0,0
for i,j in zip(w,v):
    max_w += i
    max_v += j

dp = np.ones(max_v+1, dtype=int) * max_w
for i in range(max_v-1,-1,-1):
    for j in range(N):
        if i+v[j] <= max_v:
            dp[i] = min(dp[i+1],dp[i+v[j]]-w[j])
        else:
            dp[i] = dp[i+1]
l = []
for i in dp:
    if i <= W:
        l.append(i)
ans = len(l)-1
print(ans)