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

Fixed submission:
n, k = map(int, input().split())
hlis = list(map(int, input().split()))
hlis.sort(reverse=True)

del hlis[0:k]
print(sum(hlis))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
hlis = list(map(int, input().split()))
# hlis.sort(reverse=True)

for i in range(0, k):
  cache = max(hlis)
  hlis.remove(cache)
print(sum(hlis))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
hlis = list(map(int, input().split()))
# hlis.sort(reverse=True)

for i in range(0, k):
  cache = max(hlis)
  hlis.remove(cache)
print(sum(hlis))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
hlis = list(map(int, input().split()))
hlis.sort(reverse=True)
for i in range(0, k):
  del hlis[0]
print(sum(hlis))
Problem p02819 (python)

Fixed submission:
x = int(input())
while True:
  xs = [i for i in range(1, x + 1) if x % i == 0]
  if len(xs) == 2:
    break
  x += 1
print(x)

Buggy submission (verdict: Runtime Error):
x = int(input())
while True:
	xs = [n for i in range(x) if x % n == 0]
    if len(xs) > 2:
      break
	x += 1
print(x)

Buggy submission (verdict: Runtime Error):
x = int(input())
while True:
	xs = [n for i in range(x) if x % n == 0]
    if len(xs) > 2:
      break
	x += 1
print(x)
Problem p02835 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a + b + c > 21:
  print("bust")
else:
  print("win")

Buggy submission (verdict: Runtime Error):
a, b, c = ma@(int, input().split())
if a + b + c > 21:
  print("bust")
else:
  print("win")
Problem p02836 (python)

Fixed submission:
s = input()
l = len(s)
h = l // 2
lis1 = []
lis2 = []
for i in range(0, h):
  lis1.append(s[i])
  lis2.append(s[-(i + 1)])
count = 0
for a, b in zip(lis1, lis2):
  if a != b:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
s = input()
l = len(s)
h = l // 2
lis1 = []
lis2 = []
for i in range(0, l + 1):
  lis1.append(s[i])
  lis2.append(s[-(i + 1)])
count = 0
for a, b in zip(lis1, lis2):
  if a != b:
    count += 1
print(count)
Problem p02881 (python)

Fixed submission:
# C
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)

    divisors.sort()
    return divisors

N = int(input())
divisors = make_divisors(N)
memo = 0
maX = divisors[0] + divisors[len(divisors) - 1]
for (i, r) in zip(divisors, reversed(divisors)):
    maX = min(i + r, maX)
    memo = i
    if memo == r:
        break
print(maX - 2)

Buggy submission (verdict: Runtime Error):
# C
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)

    divisors.sort()
    return divisors

N = int(input())
divisors = make_divisors(N)
memo = 0
maX = divisors[0] + divisors[len(divisors) - 1]
for (i, r) in zip(make_divisors, reversed(make_divisors)):
    maX = min(i + r, maX)
    memo = i
    if memo == r:
        break
print(maX)
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
k1 = e - a
if k >= k1:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
import math
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
if a >= 100:
    a1 = a % 10
else:
    a2 = a - 100
    a1 = a2 % 10
if b >= 100:
    b1 = b % 10
else:
    b2 = b - 100
    b1 = b2 % 10
if c >= 100:
    c1 = c % 10
else:
    c2 = c - 100
    c1 = c2 % 10
if d >= 100:
    d1 = d % 10
else:
    d2 = d - 100
    d1 = d2 % 10
if e >= 100:
    e1 = e % 10
else:
    e2 = e - 100
    e1 = e2 % 10
if a1 == 0:
    a1 = 9
if b1 == 0:
    b1 = 9
if c1 == 0:
    c1 = 9
if d1 == 0:
    a1 = 9
if e1 == 0:
    e1 = 9
lis = [a1,b1,c1,d1,e1]
if a1 == min(lis) :
    answer = math.ceil(b / 10) * 10 + math.ceil(c/ 10) * 10 + math.ceil(e/ 10* 10+ math.ceil(d/ 10 * 10 + a
if b1 == min(lis):
    answer = math.ceil(a/ 10)* 10 + math.ceil(c/ 10)* 10 + math.ceil(e/ 10)* 10 + math.ceil(d/ 10)* 10 + b
if c1 == min(lis):
    answer = math.ceil(b/ 10)* 10 + math.ceil(a/ 10)* 10 + math.ceil(e/ 10)* 10 + math.ceil(d/ 10)* 10 + c
if d1 == min(lis):
    answer = math.ceil(b/ 10)* 10 + math.ceil(c/ 10)* 10 + math.ceil(e/ 10)* 10 + math.ceil(a/ 10)* 10 + d
if e1 == min(lis):
    answer = math.ceil(b/ 10)* 10 + math.ceil(c/ 10)* 10 + math.ceil(e/ 10)* 10 + math.ceil(a/ 10)* 10 + e
print(answer)
Problem p02891 (python)

Fixed submission:
s = input()
k = int(input())
ans = 0
cnt = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        cnt += 1
    else:
        ans += (cnt//2)*k
        cnt = 1
ans += ((cnt)//2)*k
if cnt == len(s):
    ans = len(s)*k//2
elif s[0] == s[-1]:
    l = 1
    r = 1
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            l += 1
        else:
            break
    for i in range(len(s)-1,0,-1):
        if s[i] == s[i-1]:
            r += 1
        else:
            break
    ans -= (l//2 + r//2 - ((l+r)//2))*(k-1)
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
ans = 0
cnt = 0
if len(s) == 1:
    ans = k//2
else:
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            cnt += 1
        else:
            ans += ((cnt+1)//2)*k
            cnt = 0
    ans += ((cnt+1)//2)*k
    if s[0] == s[-1]:
        if s[0] != s[1] and s[-1] != s[-2]:
            ans += k - 1
        if len(s) > 2 and s[0] == s[1] == s[2] or s[-1] == s[-2] == s[-3]:
            ans += 1
print(ans)
Problem p03013 (python)

Fixed submission:
def fibcmb(start,end):
    start += 1
    end -= 1
    up = end - start
    a1 = 1
    a2 = 2
    if up < 0:
        return 0
    elif up == 0:
        return 1
    elif up == 1:
        return a1
    elif up == 2:
        return a2
    else:
        for _ in range(up-2):
            an = a1 + a2
            a1 = a2
            a2 = an
        return an

n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
ans = 1
cmb = [0]*(m+1)
if m == 0:
    ans = fibcmb(-1,n+1)
else:
    cmb[0] = fibcmb(-1,a[0])
    for i in range(1,m):
        cmb[i] = fibcmb(a[i-1],a[i])
    cmb[-1] = fibcmb(a[-1],n+1)
    for i in range(m+1):
        ans *= cmb[i]
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
def fibcmb(start,end):
    start += 1
    end -= 1
    up = end - start
    a1 = 1
    a2 = 2
    if up < 0:
        return 0
    elif up == 0:
        return 1
    elif up == 1:
        return a1
    elif up == 2:
        return a2
    else:
        for _ in range(up-2):
            an = a1 + a2
            a1 = a2
            a2 = an
        return an

n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
ans = 1
cmb = [0]*(m+1)
cmb[0] = fibcmb(-1,a[0])
for i in range(1,m):
    cmb[i] = fibcmb(a[i-1],a[i])
cmb[-1] = fibcmb(a[-1],n+1)
for i in range(m+1):
    ans *= cmb[i]
print(ans%1000000007)
Problem p03053 (python)

Fixed submission:
from collections import deque

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

def bfs():
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    que = deque()
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                que.append((i, j))
                a[i][j] = 0

    while que:
        p = que.popleft()
        for i in range(4):
            ny = p[0] + dy[i]
            nx = p[1] + dx[i]

            if 0 <= nx < w and 0 <= ny < h and a[ny][nx] == '.':
                que.append((ny,nx))
                a[ny][nx] = a[p[0]][p[1]] + 1
    ans = 0
    for i in range(h):
        ans = max(ans, *a[i])
    return ans

print(bfs())

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

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

def bfs():
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    que = deque([])
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                que.append((i, j))
                a[i][j] = 0

    while que:
        p = que.popleft()
        for i in range(4):
            ny = p[0] + dy[i]
            nx = p[1] + dx[i]

            if 0 <= nx < w and 0 <= ny < h and a[ny][nx] == '.':
                que.append((nx,ny))
                a[ny][nx] = a[p[0]][p[1]] + 1
    ans = 0
    for i in range(h):
        ans = max(ans, *a[i])
    return ans

print(bfs())
Problem p03774 (python)

Fixed submission:
n, m = map(int, input().split())
stu = []
check = []
for i in range(n):
    stu.append(list(map(int, input().split())))
for i in range(m):
    check.append(list(map(int, input().split())))
for i in stu:
    min_dis = 4 * 10 ** 8 + 1
    for j, k in enumerate(check):
        dis = abs(i[0] - k[0]) + abs(i[1] - k[1])
        if dis < min_dis:
            ans = j + 1
            min_dis = dis
    print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
stu = []
check = []
for i in range(n):
    stu.append(list(map(int, input().split())))
for i in range(m):
    check.append(list(map(int, input().split())))
for i in stu:
    min_dis = 2 * 10 ** 8 + 1
    for j, k in enumerate(check):
        dis = abs(i[0] - k[0]) + abs(i[1] - k[1])
        if dis < min_dis:
            ans = j + 1
            min_dis = dis
    print(ans)
Problem p03803 (python)

Fixed submission:
a,b = map(int,input().split())
if a == 1:
  if b == 1:
    print('Draw')
  else:
    print('Alice')
elif b == 1:
  print('Bob')
else:
  if a == b:
    print('Draw')
  elif a > b:
    print('Alice')
  else:
    print('Bob')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a == 1:
  if b == 1:
    print(Draw)
  else:
    print(Alice)
elif b == 1:
  print(Bob)
else:
  if a == b:
    print(Draw)
  elif a < b:
    print(Alice)
  else:
    print(Bob)
Problem p02685 (python)

Fixed submission:
n,m,k = map(int, input().split())
#ncr
mod = 998244353
class Combination:
    def __init__(self, N):
        self.fac = [1] * (N + 1)
        for i in range(1, N + 1):
            self.fac[i] = (self.fac[i - 1] * i) % mod
        self.invmod = [1] * (N + 1)
        self.invmod[N] = pow(self.fac[N], mod - 2, mod)
        for i in range(N, 0, -1):
            self.invmod[i - 1] = (self.invmod[i] * i) % mod 
    def ncr(self, n, k):  # nCk
        return self.fac[n] * self.invmod[k] % mod * self.invmod[n - k] % mod 
cmb = Combination(n)
ans = 0
for i in range(k+1):
  a = m*pow(m-1,n-i-1,mod)%mod
  a *= cmb.ncr(n-1,i)
  ans += a%mod
print(ans%mod)

Buggy submission (verdict: Runtime Error):
n,m,k = map(int, input().split())
#ncr
mod = 998244353
class Combination:
    def __init__(self, N):
        self.fac = [1] * (N + 1)
        for i in range(1, N + 1):
            self.fac[i] = (self.fac[i - 1] * i) % mod
        self.invmod = [1] * (N + 1)
        self.invmod[N] = pow(self.fac[N], mod - 2, mod)
        for i in range(N, 0, -1):
            self.invmod[i - 1] = (self.invmod[i] * i) % mod 
    def ncr(self, n, k):  # nCk
        return self.fac[n] * self.invmod[k] % mod * self.invmod[n - k] % mod 
cmb = Combination(n)
ans = 0
for i in range(k+1):
  a = m*(m-1)**(n-i-1)%p
  a *= cmb.ncr(n,i)
  ans += a%p
print(ans%p)
Problem p02701 (python)

Fixed submission:
n = int(input())
a = []
for i in range(n):
  a.append(str(input()))
print(len(set(a)))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
  a.apped(str(input()))
print(len(set(a)))
Problem p02912 (python)

Fixed submission:
import math
import heapq

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

hq = []
for i in range(n):
  heapq.heappush(hq, a[i]*(-1))

for i in range(m):
  b = heapq.heappop(hq)
  b = ((-1)*b)//2
  heapq.heappush(hq, b*(-1))

ans = 0
for i in hq:
  ans += i *(-1)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import heapq

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

hq = []
for i in range(n):
  heapq.heappush(hp, a[i]*(-1))

for i in range(m):
  b = heapq.heappop(hq)
  b = b//2
  heapq.heappush(hp, b)

ans = 0
for i in hq:
  ans += i *(-1)
print(ans)
Problem p02954 (python)

Fixed submission:
s = list(str(input()))

len_s = len(s)
key = "L"
num = 0
ans = []
for i in range(len_s):
  if s[i] != key:
    num += 1
  else:
    ans.append(num)
    num = 1
    if key == "R":
      key = "L"
    else:
      key = "R"
ans.append(num)

len_ans = len(ans)
for i in range(len_ans):
  if i % 2 == 0:
    for j in range(ans[i]-1):
      print(0, end=" ")
    print((ans[i]+1)//2+(ans[i+1])//2, end=" ")
  else:
    print((ans[i-1])//2 + (ans[i]+1)//2, end=" ")
    for j in range(ans[i]-1):
      print(0, end=" ")

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

len_s = len(s)
key = "L"
num = 0
ans = []
for i in range(len_s):
  if s[i] != key:
    num += 1
  else:
    ans.append(num)
    if key == "R":
      key = "L"
    else:
      key = "R"
len_ans = len(ans)
for i in range(len_ans):
  if i % 2 == 0:
    for j in range(ans[i]-1):
      print(0, end=" ")
  	print((ans[i]+1)//2 + (ans[i+1]-1)//2, end=" ")
  else:
    print((ans[i-1]-1)//2 + (ans[i]+1)//2, end=" ")
    for j in range(ans[i]-1):
      print(0, end=" ")
Problem p02989 (python)

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

ans = p[int(n/2)] - p[int(n/2)-1]
print(ans)

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


ans = p[int(n/2)] - [int(n/2)-1]
print(ans)
Problem p03012 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = 0
for i in range(n):
  s += a[i]

b = []
t = s
for i in range(n-1):
  s -= a[i]
  b.append(abs(t-s*2))
print(min(b))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(range(n))
s = 0
for i in range(n):
  a[i] = int(input())
  s += a[i]

t = s  
for i in range(n):
  t_ = t
  t -= a[i]
  if abs(t) >= abs(t_):
    break
print(abs(t_))
Problem p03041 (python)

Fixed submission:
n, k = list(map(int, input().split()))
s = list(str(input()))

if s[k-1] == "A":
    s[k-1] = "a"
if s[k-1] == "B":
    s[k-1] = "b"
if s[k-1] == "C":
    s[k-1] = "c"
print("".join([str(i) for i in s]))

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

z = x.extend(y)
N = range(n)
for i in range(n):
    N[i] = z.count(i+1)

ans = 0
for i in range(n):
    ans = ans + N.count(i)/(2**i)
print(ans)
Problem p03072 (python)

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

ans = 0
mx = h[0]
for i in range(n):
    if h[i] >= mx:
        ans = ans + 1
        mx = h[i]
print(ans)

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

for i in range(2,n+1):
    if h[n-i] < h[n-i+1]:
        ans = i - 1
        break
print("\n")
print(ans)

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

for i in range(2,n+1):
    if h[n-i] < h[n-i+1]:
        ans = i - 1
        break
print(ans)

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

for i in range(1,n):
    if h[n-i] < h[n-i+1]:
        ans = i
        break
print(ans)

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

for i in range(1,N):
    if h[N-i] < h[N-i+1]:
        ans = i
        break
print(ans)
Problem p02779 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
cnt = 0
from collections import Counter
B=Counter(A)
C=B.most_common()
if C[0][1] <= 1:
	print('YES')
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
from collections import Counter
B=A.Counter
if B.most_common[0][1] <= 1:
	print('YES')
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
from collections import Counter

if A.most_common[0][1] <= 1:
	print('YES')
else:
	print('NO')
Problem p02831 (python)

Fixed submission:
a, b = map(int, input().split())
#greatest commmon divisor(gdc)を定義する
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
#least common multiple (lcm)を定義する
def lcm(a,b):
    return (a*b)// gcd(a, b)

print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math    
A, B = map(int, input().split())
#最小公倍数least common multiple (lcm)を定義する
def lcm(A,B):
    return (A*B)// math.gcd(A, B)

print(lcm(A,B))
Problem p02835 (python)

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

if A + B + C>=22:
	print("bust")
else:
	print("win")

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())

if sum(A, B, C)<=22:
	print("bust")
else:
	print("win")
Problem p03250 (python)

Fixed submission:
a, b, c = (int(x) for x in input().split())
print(a + b + c + max(a, b, c)*9)

Buggy submission (verdict: Runtime Error):
N, M, X, Y = map(int, input().split())
 
x = list(map(int, input().split()))
y = list(map(int, input().split()))    
 
for z in range(-100, 101):
    if (X < z) and (max(x) < z) and (z <= min(y)) and (z <= Y):
        print("No War")
    else:
        print("War")

Buggy submission (verdict: Runtime Error):
N, M, X, Y = map(int, input().split())

x = list(map(int, input().split()))
y = list(map(int, input().split()))    
for z in range(X+1, Y+1):
    if (max(x) < z) and (z <= min(y)):
        print("No War")
        break
    else:
        print("War")

Buggy submission (verdict: Runtime Error):
N, M, X, Y = map(int, input().split())

x = list(map(int, input().split()))
y = list(map(int, input().split()))    

for z in range(-100, 101):
    if (X < z) and (max(x) < z) and (z <= min(y) and (z <= Y):
        print("No War")
    else:
        print("War")

Buggy submission (verdict: Runtime Error):
N, M, X, Y = map(int, input().split())

x = list(map(int, input().split()))
y = list(map(int, input().split()))    

for z in range(-100, 101):
    if (X < z) and (max(x) < z) and (min(y) >= z) and (Y >= z):
        print("No War")
    else:
        print("War")

Buggy submission (verdict: Runtime Error):
A = int(input("A =",))
B = int(input("B =",))
C = int(input("C =",))

if A == max(A, B, C):
    x = 10*A + B + C
    print("お小遣いは", x)
elif B == max(A, B, C):
    x = A + 10*B + C
    print("お小遣いは", x)
elif C == max(A, B, C):
    x = A + B + 10*C
    print("お小遣いは", x)
Problem p02819 (python)

Fixed submission:
import math
x = int(input())

def is_prime(x):
  for i in range(2, int(math.sqrt(x))+1):
    if x%i==0:
      return False
  return True

while not is_prime(x):
  x+=1
print(x)

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

def get_numprime(n):
  nums = [i + 1 for i in range(2, n, 2)]
  prime = [2]
  while True:
    p = nums[0]
    if  p>=x:
      return p
    prime.append(p)
    nums = [e for e in nums if e%p !=0]

if x==2:
  print(x)
else:
  print(get_numprime(x+20))
Problem p02832 (python)

Fixed submission:
from collections import deque
n = int(input())
r = deque(map(int, input().split()))
i=0
while True:
    if max(len(r),i)==i:
        break
    if r[i]!=i+1:
        r.popleft()
    else:
        i+=1
print('-1' if len(r)==0 else n-len(r))

Buggy submission (verdict: Runtime Error):
n = int(input())
R = list(map(int, input().split()))
c, i = 0, 1
for r in R:
  if r==i: i+=1
  else: c+=1
print(c if c<N else '-1')
Problem p02891 (python)

Fixed submission:
def cal(S):
    tmp, a, cnt = S[0], 1, 0
    flag = True
    for s in S[1:]:
        if S[0]!=s: flag=False
        if flag: a+=1
        if tmp[-1]==s:
            s = '*'
            cnt += 1
        tmp += s
    return a, cnt


S = input().replace('\n', '')
k = int(input())
ans = 0
if len(list(set(S)))==1:
    ans = len(S)*k//2
else:
    a, cnt = cal(S)
    b, _ = cal(S[::-1])
    ans = cnt*k
    if S[0]==S[-1]:
        ans -= ((a//2)+(b//2)-((a+b)//2))*(k-1)
print(ans)

Buggy submission (verdict: Runtime Error):
def cal(S):
    tmp, a, cnt = S[0], 1, 0
    flag = True
    for s in S[1:]:
        if S[0]!=s: flag=False
        if flag: a+=1
        if tmp[-1]==s:
            s = '*'
            ans += 1
        tmp += s
    return a, cnt


S = input().replace('\n', '')
k = int(input())
ans = 0
if len(list(set(S)))==1:
    ans = len(S)*k//2
else:
    a, cnt = cal(S)
    b, _ = cal(S[::-1])
    ans = cnt*k
    if S[0]==S[-1]:
        ans -= ((a//2)+(b//2)-((a+b)//2))*(k-1)
print(ans)
Problem p03013 (python)

Fixed submission:
n, m = map(int,input().split())
broken = [0]*(n+1)
for _ in range(m):
  a = int(input())
  broken[a]=1

dp = [0]*(n+2)
mod = int(1e9+7)
dp[n] = 1
for i in range(n-1, -1 , -1):
  if broken[i]:
    dp[i] = 0
  else:
    dp[i] = (dp[i+1] + dp[i+2]) % mod

print(dp[0])

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
a = [int(input()) for _ in range(m)]
dp = [0]*(n+2)
mod = int(1e9+7)
for i in range(n, -1, -1):
  if i==n and a[-1]!=i:
    dp[i] = 1
  elif i!=n:
    if i in a:
      dp[i] = 0
    else:
      dp[i] = dp[i+1] + dp[i+2]
  else:
    break

print(dp[0]%mod)
Problem p03127 (python)

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

n = int(input())
monster = sorted(list(map(int,input().split())))
ans = []
for i in range(n-1):
  g = gcd(monster[i], monster[i+1])
  ans.append(g)
print(min(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
monster = sorted(list(map(int,input().split())))
min_HP = min(monster)
cnt=0
while True:
  tmp = int(monster[-1]/monster[-2])
  monster[-1]-=monster[-2]*tmp
  if monster[-1]<=0:
    monster.pop(-1)
  monster = sorted(monster)
  if min_HP==monster[0]:
    cnt+=1
    if cnt>=2:
      print(min_HP)
      exit()
  else:
    min_HP = monster[0]
    cnt=0

Buggy submission (verdict: Runtime Error):
n = int(input())
monster = sorted(list(map(int,input().split())))
min_HP = min(monster)
cnt=0
while True:
  tmp = int(monster[-1]/monster[-2])
  monster[-1]-=monster[-2]*tmp
  if monster[-1]<=0:
    monster.pop(-1)
  monster = sorted(monster)
  if min_HP==monster[0]:
    cnt+=1
    if cnt>=2:
      print(min_HP)
      exit()
  else:
    min_HP = monster[0]
    cnt=0
  print(monster)
Problem p03208 (python)

Fixed submission:
n,k =map(int,input().split())
trees = sorted([int(input()) for _ in range(n)])
ans = float('inf')
for i in range(n):
  if i+k>n:
    print(ans)
    exit()
  else:
    ans = min(trees[i+k-1]-trees[i], ans)
    if ans==0:
      print(ans)
      exit()

Buggy submission (verdict: Runtime Error):
n,k =map(int,input().split())
trees = sorted([int(input()) for _ in range(n)])
ans = float('inf')
for i in range(n):
  if i+2==n:
    break
  else:
    temp = abs(trees[i]-trees[i+k-1])
    if temp<ans:
      ans = temp
      if ans==0:
        break

print(ans)
Problem p02695 (python)

Fixed submission:
n,m,q=map(int,input().split())
lis=[]
for i in range(q):
    a,b,c,d=map(int,input().split())
    lis.append((a,b,c,d))
    
from itertools import combinations_with_replacement

co=list(combinations_with_replacement(range(1,m+1),n))

ans=0
for status in co:
    tmp_score=0
    for a,b,c,d in lis:
        if status[b-1]-status[a-1]==c:
            tmp_score+=d
    ans=max(ans,tmp_score)
print(ans)

Buggy submission (verdict: Runtime Error):
vn,m,q=map(int,input().split())
lis=[]
for i in range(q):
    a,b,c,d=map(int,input().split())
    lis.append((a,b,c,d))
    
from itertools import combinations_with_replacement

co=list(combinations_with_replacement(range(1,m+1),n))

ans=0
for status in co:
    tmp_score=0
    for a,b,c,d in lis:
        if status[b-1]-status[a-1]==c:
            tmp_score+=d
    ans=max(ans,tmp_score)
print(ans)