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

Fixed submission:
N = int(input())
if N % 2 == 1:
    print(0)
else:
    ans = 0
    for i in range(1, 30):
        ans += (N // 2) // (5 ** i)
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 2 == 1:
    print(0)
else:
    ans = 0
    for i in range(1, 30):
        ans += (N // 2) // (5 ** i)

print(ans)
Problem p02862 (python)

Fixed submission:
MOD = 10 ** 9 + 7


def modpow(a, b, mod):
    ret = 1
    while b > 0:
        if b % 2 == 1:
            ret = ret * a % mod
        a = a * a % mod
        b //= 2
    return ret


X, Y = map(int, input().split())
if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
    print(0)
elif (2 * X - Y) // 3 < 0 or (2 * Y - X) // 3 < 0:
    print(0)
else:
    A, B = (2 * X - Y) // 3, (2 * Y - X) // 3
    ans = 1
    for n in range(A + B, A, -1):
        ans = ans * n % MOD
    for n in range(1, B + 1):
        ans = ans * modpow(n, MOD - 2, MOD) % MOD
    print(ans % MOD)

Buggy submission (verdict: Runtime Error):
def modpow(a, b, mod=1):
    ret = 1
    while b > 0:
        if b % 2 == 1:
            ret = ret * a % mod
        a, b = a * a % mod, b // 2
    return ret


MOD = 10 ** 9 + 7
X, Y = map(int, input().split())
A, B = (2 * X - Y) // 3, (2 * Y - X) // 3
if (X + Y) % 3 != 0 or A < 0 or B < 0:
    print(0)
else:
    ans = 1
    for n in range(A + B, A, -1):
        ans = ans * n % MOD
    for n in range(1, B + 1):
        ans = ans * modpow(n, MOD - 2, MOD) % MOD

print(ans)
Problem p02948 (python)

Fixed submission:
import heapq
maxB = 10 ** 1

N, M = map(int, input().split())
AB = []
for _ in range(N):
    A, B = map(int, input().split())
    AB.append((maxB - B, A))

AB.sort(key=lambda x: x[1])

ans, heap, idx, lAB = 0, [], 0, len(AB)
for i in range(M):
    while idx < lAB and AB[idx][1] <= i + 1:
        heapq.heappush(heap, AB[idx])
        idx += 1
    if len(heap) > 0:
        ans += maxB - heapq.heappop(heap)[0]

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
AB, mx = [], [0] * (10 ** 1 + 1)
for i in range(N):
    A, B = map(int, input().split())
    AB.append((A, B))
    mx[A] = max(mx[A], B)

AB.sort(key=lambda x: x[1], reverse=True)
AB.sort(key=lambda x: x[0])

ans, idx, lAB = 0, 0, len(AB)
for i in range(1, M + 1):
    if AB[idx][0] <= i:
        while AB[idx][1] < mx[AB[idx][0] + 1]:
            tmp = AB[idx][0] + 1
            while not AB[idx][0] == tmp:
                idx += 1
        ans, idx = ans + AB[idx][1], idx + 1

print(ans)
Problem p02990 (python)

Fixed submission:
import math
MOD = 10 ** 9 + 7

N, K = map(int, input().split())


def f(n):
    return math.factorial(n)


for i in range(K):
    if N - K - i >= 0:
        print(f(N - K + 1) // f(N - K - i) // f(i + 1)
              * (f(K - 1) // f(K - i - 1) // f(i)) % MOD)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
import math
MOD = 10 ** 9 + 7

N, K = map(int, input().split())
B, R = K, N - K


def f(n):
    return math.factorial(n)


for i in range(K):
    print(f(R + 1) // f(R - i) // f(i + 1)
          * (f(B - 1) // f(B - i - 1) // f(i)) % MOD)
Problem p03634 (python)

Fixed submission:
N = int(input())
neig = [[] for _ in range(N)]

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    neig[a - 1].append((b - 1, c))
    neig[b - 1].append((a - 1, c))

Q, K = map(int, input().split())

S, D = [(K - 1, K - 1)], [0] * N
while len(S) > 0:
    p, pp = S.pop()
    for c, d in neig[p]:
        if not c == pp:
            D[c] = D[p] + d
            S.append((c, p))

for _ in range(Q):
    x, y = map(int, input().split())
    print(D[x - 1] + D[y - 1])

Buggy submission (verdict: Runtime Error):
N = int(input())
T, D = {i: [] for i in range(N)}, [-1] * N
for _ in range(N - 1):
    a, b, c = map(int, input().split())
    T[a - 1].append((b - 1, c))
    T[b - 1].append((a - 1, c))


def dfs(p, c, d):
    D[c] = d
    for c2, d2 in T[c]:
        if c2 != p:
            dfs(c, c2, d + d2)


Q, K = map(int, input().split())
dfs(-1, K - 1, 0)
for _ in range(Q):
    x, y = map(int, input().split())
    print(D[x - 1] + D[y - 1])
Problem p03774 (python)

Fixed submission:
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
CD = [tuple(map(int, input().split())) for _ in range(M)]

for a, b in AB:
    ans, maxD = 0, 10 ** 10
    for i, (c, d) in enumerate(CD):
        if abs(a - c) + abs(b - d) < maxD:
            ans, maxD = i + 1, abs(a - c) + abs(b - d)
    print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
CD = [tuple(map(int, input().split())) for _ in range(N)]

for a, b in AB:
    ans, maxD = 0, 10 ** 10
    for i, (c, d) in enumerate(CD):
        if abs(a - c) + abs(b - d) < maxD:
            ans, maxD = i + 1, abs(a - c) + abs(b - d)
    print(ans)
Problem p03776 (python)

Fixed submission:
from math import factorial

N, A, B = map(int, input().split())
V = sorted(list(map(int, input().split())), reverse=True)

print(sum(V[:A]) / A)
if V[0] == V[A - 1]:
    n = sum([1 for v in V if v == V[0]])
    print(sum([factorial(n) // factorial(r) // factorial(n - r)
               for r in range(A, min(n, B) + 1)]))
else:
    n = sum([1 for v in V if v == V[A - 1]])
    r = sum([1 for v in V[:A] if v == V[A - 1]])
    print(factorial(n) // factorial(r) // factorial(n - r))

Buggy submission (verdict: Runtime Error):
from math import factorial

N, A, B = map(int, input().split())
V = sorted(list(map(int, input().split())), reverse=True)

print(sum(V[:A]) / A)
if V[0] == V[A - 1]:
    n = sum([1 for v in V if v == V[0]])
    print(sum([factorial(n) // factorial(r) // factorial(n - r)
               for r in range(A, B + 1)]))
else:
    n = sum([1 for v in V if v == V[A - 1]])
    r = sum([1 for v in V[:A] if v == V[A - 1]])
    print(factorial(n) // factorial(r) // factorial(n - r))
Problem p02723 (python)

Fixed submission:
s = input()
if s[2] == s[3] and s[4] == s[5]:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
cnt = (n // 1000) * 2000
n -= (n // 1000) * 1000
cnt += (n // 5) * 5
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
cnt = (n // 1000) * 2000
n -= (n // 1000) * 1000
cnt += (n // 5) * 5
print(cnt)
Problem p02771 (python)

Fixed submission:
s = set(map(int, input().split()))
if len(s) == 2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a=set(map(int,input().split()))
if len(set)==2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
lst=set(map(int,input().split(" ")))
if len(set)==2:
  print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
n=int(input())
lst=list(map(int,input().split()))

for i in range(0,n):
    if lst[i]%2==0:
        if lst[i]%3==0 or lst[i]%5==0:
            x=1
            
        else: x=0
if x==1:print("APPROVED")
else: print("DENIED")

Buggy submission (verdict: Runtime Error):
ans=[]
for i in range(0,3):
    ele=int(input())
    ans.append(ele)
    
anns=set(ans)
if len(anns)==2:
    print("Yes")
else: print("No")
Problem p02777 (python)

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()
if u == s:
    a-= 1
else: b -= 1
print(a, b)

Buggy submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a-=1
else:  b-=1
print(a, b)

Buggy submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a-=1
else:
    b-=1
print(a, b)

Buggy submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a-=1
elif:b-=1
print(a, b)

Buggy submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a-=
elif:b-=
print(a, b)

Buggy submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a--
elif u==t:
    b--
print("{} {}".format(a,b))

Buggy submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input()split())
u=input()
if u==s:
    a--
elif u==t:
    b--
print({} {},format(a,b))
Problem p02779 (python)

Fixed submission:
n=input()
lst=input().split()
if len(lst)==len(set(lst)):
    print("YES")
else: print("NO")

Buggy submission (verdict: Runtime Error):
n=map(int,input())
lst=len(set(map(int,input(split))))
if n==lst:
    print("YES")
else:  print("NO")
Problem p02578 (python)

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

stack = [a[0]]
s = 0
for i in range(1,n):
    if a[i]<stack[-1]:
        s = s + abs(a[i] - stack[-1])
    else:
        stack.append(a[i])
print(s)

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

stack = [a[0]]
s = 0
for i in range(1,n):
    if a[i]<stack[-1]:
        s = s + abs(a[i] - stack[-1])
    else:
        stack.append(a[i])
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
for i in range(n-1,-1,-1):
    if a[i]<a[i-1]:
        s = s + abs(a[i] - a[i-1])
print(s)
Problem p02595 (python)

Fixed submission:
n, d = map(int, input().split())
s = 0
for i in range(n):
	x, y = map(int, input().split())
	if x**2+y**2 <= d**2:
		s += 1
print(s)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
s = 0
for i in range(n+1):
	x, y = map(int, input().split())
	if x**2+y**2 <= d**2:
		s = s+1
print(s)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
s == 0
for i in range(n+1):
	x, y = map(int, input().split())
	if x**2+y**2 <= d**2:
		s = s+1
print(s)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
s == 0
for i in range(n+1):
	x, y = map(int,input().split())
	if x**2+y**2 <= d**2:
		s = s+1
print(s)

Buggy submission (verdict: Runtime Error):
n, d = map(int,input().split())
s == 0
for i in range(n):
	x, y = map(int,input().split())
	if x**2+y**2 <= d**2:
		s = s+1
	else:
			s = s
print(s)

Buggy submission (verdict: Runtime Error):
n, d = map(int,input().split())
s == 0
for i in range(n):
	x, y = map(int,input().split())
	if x**2+y**2 <= d**2:
		s = s+1
		else:
			s = s
print(s)

Buggy submission (verdict: Runtime Error):
n, d = map(int,input().split())
s == 0
for i in range(n):
	x, y = map(int,input().split())
	if x**2 + y**2 <= d**2:
		s = s + 1
		else:
			s = s
print(s)
Problem p02596 (python)

Fixed submission:
import sys

k = int(input())

a = 0

for i in range(1, k+1):
	a = (a*10+7)%k
	if a == 0:
		print(i)
		sys.exit()
print(-1)

Buggy submission (verdict: Runtime Error):
k = int(input())
s = 7
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	while s%k != 0:
		s = 10*s+7
		s = str(s)
	print(len(s))

Buggy submission (verdict: Runtime Error):
k = int(input())
s = 7
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	while s%k != 0:
		s = 10*s+7
	print(len(s))

Buggy submission (verdict: Runtime Error):
k = int(input())
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	s = 7
	while s%k != 0:
		s = 10*s+7
	print(len(s))

Buggy submission (verdict: Runtime Error):
k = int(input())
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	s = 7
	while s%k != 0:
		s = 10*s+7
	print(len(s))

Buggy submission (verdict: Runtime Error):
k = int(input())
if k%2 = 0:
	print(-1)
elif k%5 = 0:
	print(-1)
else:
	s = 7
	while s%k != 0:
		s = 10*s+7
	print(len(s))
Problem p03834 (python)

Fixed submission:
x, y, z = input().split(",")
print(x, y, z)

Buggy submission (verdict: Runtime Error):
x, y, z = map(input().split(,))
print(x y z)
Problem p03104 (python)

Fixed submission:
def to_bin(number):

    return bin(number)[2:].zfill(45)


def xor(num1, num2):

    num1_str = to_bin(num1)
    num2_str = to_bin(num2)

    result_list = [0] * 45

    for digit in range(0, 45):
        result_list[digit] += int(num1_str[digit])
        result_list[digit] += int(num2_str[digit])

    result_str = ''

    for digit in result_list:

        if digit % 2 == 0:
            result_str += '0'
        else:
            result_str += '1'
    return int(result_str, 2)


def f(a, b):
    if a > 0:
        a -= 1

    return xor(g(a), g(b))


def g(num):

    others = 0

    if num % 2 == 0:
        if (num // 2) % 2 != 0:
            others = 1

        return xor(num, others)
    else:
        if ((num - 1) // 2) % 2 != 0:
            others = 1

        return xor(xor(num, others), num - 1)


A, B = map(int, input().split())

result = f(A, B)

print(result)

Buggy submission (verdict: Runtime Error):
def to_bin(number):
    return bin(number)[2:].zfill(45)


def xor(num1, num2):

    num1_str = to_bin(num1)
    num2_str = to_bin(num2)

    result = [0] * 45

    for digit in range(0, 45):
        result[digit] += int(num1_str[digit])
        result[digit] += int(num2_str[digit])

    result_str = ''

    for digit in result:

        if digit % 2 == 0:
            result_str += '0'
        else:
            result_str += '1'
    return int(result_str,2)


def f(a, b):
    return xor(g(a - 1), g(b))


def g(num):

    others = 0

    if num % 2 == 0:
        if (num // 2) % 2 != 0:
            others = 1

        return xor(num, others)
    else:
        if ((num - 1) // 2) % 2 != 0:
            others = 1

        return xor(xor(num, others), num - 1)


A, B = map(int, input().split())

result = f(A, B)

print(result)
Problem p02597 (python)

Fixed submission:
N=int(input())
C=list(input())

white=[0]*(N+1)
red=[0]*(N+1)

for i in range(N):
    if C[i]=="W":
        white[i+1]=white[i]+1
        red[i+1]=red[i]
    else:
        white[i+1]=white[i]
        red[i+1]=red[i]+1

if white[-1]==N or red[-1]==N:
    print(0)
    exit()

ans=float("inf")
for i in range(1,N):
    wcnt=white[i]
    rcnt=red[-1]-red[i]
    m=max(wcnt,rcnt)
    ans=min(m,ans)

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
N=int(input())
C=list(input())

qw=deque(list())
qr=deque(list())

ans=0
for i in range(N//2):
    if C[i]=='W':
        qw.append(i)
    if C[-(i+1)]=='R':
        qr.append(-(i+1))
    if len(qw)>0 and len(qr)>0:
        ans+=1
        l=qw.popleft()
        r=qr.popleft()
        C[l],C[r]=C[r],C[l]

if len(qw)>0:
    l=qw.popleft()
    if C[l+1]=='R':
        C[l+1]='W'
        ans+=1
elif len(qr)>0:
    r=qr.popleft()
    if C[r-1]=='W':
        C[r-1]='R'
        ans+=1

if (C[N//2-1]==C[N//2]==C[N//2+1]) or (C[N//2]=='R' and C[N//2-1]=='R' and C[N//2+1]=='W') or (C[N//2]=='W' and C[N//2-1]=='R' and C[N//2+1]=='R'):
    print(ans)
else:
    print(ans+1)
Problem p02831 (python)

Fixed submission:
a,b=map(int,input().split())
def gcd(x,y):
    while y!=0:
        x,y=y,x%y
    return x
print(int((a*b)/gcd(a,b)))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
x=math.gcd(a,b)
print(int((a*b)/x))
Problem p02571 (python)

Fixed submission:
s = input()
t = input()
lists = list()

for i in range(len(s)-len(t)+1):
  ans = 0
  for j in range(len(t)):
    if s[i+j] == t[j]:
      ans += 1
    lists.append(ans)

print(len(t)-max(lists))

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

for i in range(len(s)-len(t)):
  ans = 0
  for j in range(len(t)-1):
    if s[i+j] == t[j]:
      ans = ans + 1
    lists.append(ans)

print(len(t)-max(lists))
Problem p02659 (python)

Fixed submission:
from decimal import Decimal 
a,b = input().split()
c = Decimal(b)
print(int(int(a)*c))

Buggy submission (verdict: Runtime Error):
ab = list(input().split())

a = int(ab[0])
b = float(ab[1]*100)

print(a*b//100)
Problem p02832 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
brick = 0
for i in range (n) :
    if a[i] == brick + 1 :
        brick += 1
if (brick == 0) :
    print(-1)
else :
    print(n - brick)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split())
s = 0
for i in range (n) :
    if a[i] = s + 1 :
        s += 1
print(n - s)
Problem p02984 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
p = All-sum(a2[1::2])
a3 = [p]
for i in range(n-1) :
    p = a[i]*2 - p
    a3.append(p)
mountain = ""
for j in range(n) :
    mountain += str(a3[j])
    if j == n-1 :
        print(mountain)
        exit()
    mountain += " "

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a2 = list(map(lambda x:x*2,a))
All = sum(a)
t = 0
while True :
    t += 1
    if t > n :
        exit()
    print(All-a2[1::2])
    a2.append(a2[0])
    del a2[0]

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a2 = list(map(int,lambda x:x*2,a))
All = sum(a)
t = 0
while True :
    t += 1
    if t > n :
        exit()
    print(All-a2[1::2])
    a2.append(a2[0])
    del a2[0]
Problem p02711 (python)

Fixed submission:
n = int(input())
if (n%100)%10==7 or (n//10)%10==7 or n//100==7:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
if n%100 == 7:
  print(‘Yes’)
elif (n//10)%10 == 7:
  print(‘Yes’)
elif n//100 == 7:
  print(‘Yes’)
else:
  print(‘No’)
Problem p02723 (python)

Fixed submission:
s = input()

if s[2]==s[3] and s[4]==s[5]:
  print('Yes')
else:
  print('No')

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

if s[2]==s[3] and s[4]==s[5]:
  print('Yes')
else:
  print('No')
Problem p02725 (python)

Fixed submission:
k,n = map(int, input().split())
A = input().split()
A = [int(a) for a in A]
for i in range(n):
  A.append(A[i])

min = k
for i in range(n):
  if A[i+n-1]>=A[i]: 
    d = A[i+n-1]-A[i]
  else:
    d = A[i+n-1]+k-A[i]
  if d<min: min = d
    
print(min)

Buggy submission (verdict: Runtime Error):
k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = k
for i in range(-1,n-1):
  ans = min(ans, k-(n[i+1]-n[i]))
print(ans)
Problem p02729 (python)

Fixed submission:
n,m = map(int, input().split())
 
print(int(n*(n-1)/2+m*(m-1)/2))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input())
print(int(n*(n-1)/2)+int(m*(m-1)/2))
Problem p02759 (python)

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

print(math.ceil(n/2))

Buggy submission (verdict: Runtime Error):
card = [list(map(int, input().split())) for i in range(3)]
N = int(input())
 
bingo = [[0 for i in range(3)] for j in range(3)]
 
for i in range(N):
  	key = int(input())
    for j in range(3):
        for k in range(3):
            if card[j][k] == key:
                bingo[j][k] += 1
 
for i in range(3):
    if bingo[0][i] * bingo[1][i] * bingo[2][i] > 0:
        print('Yes')
        exit()
for i in range(3):
    if bingo[i][0] * bingo[i][1] * bingo[i][2] > 0:
        print('Yes')
        exit()
if bingo[0][0] * bingo[1][1] * bingo[2][2] > 0:
    print('Yes')
    exit()
if bingo[0][2] * bingo[1][1] * bingo[2][0] > 0:
    print('Yes')
    exit()
print('No')
Problem p02773 (python)

Fixed submission:
n = int(input())

dic = {}

for i in range(n):
  word = input()
  if word not in dic:
    dic[word] = 1
  else:
    dic[word] += 1
    
max_num = max(dic[word] for word in dic)
l = []
for word in dic:
  if dic[word]==max_num:
    l.append(word)
    
l = sorted(l)
for i in range(len(l)):
  print(l[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
dic = {}
for i in range(n):
  s = input()
  if s not in dic: dic[s] = 1
  else: dic[s] += 1
v = dic.values()
v = sorted(v)
max_num = v[n-1]
ans = []
for s in dic:
  if dic[s]==max_num:
    ans.append(s)
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])
Problem p02819 (python)

Fixed submission:
n = int(input())

import math
def prime(n):
  a = math.ceil(math.sqrt(n))
  for i in range(2,a):
    if n%i==0: return 1
  return 0

while (1):
  if prime(n)==0: 
    print(n)
    exit()
  n+=1

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

def prime(n):
  a = int(n**(1/2))
  for i in range(2,a+1):
    if n%i==0: return False
  return true

while (1):
  if prime(x)==False: x += 1
  else: break
  x += 1
print(x)

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

import math
def prime(n):
  a = math.ceil(sqrt(n))
  for i in range(2,a):
    if n%i==0: return 1
  return 0

while (1):
  n += 1
  if prime(n)==1: 
    print(n)
    exit()
Problem p02831 (python)

Fixed submission:
num1, num2 = map(int, input().split())

import math
def gcd(num1, num2):
  for i in range(min(num1, num2),0,-1):
    if num1%i==0 and num2%i==0:
      return i
    
print(int(num1*num2/gcd(num1,num2)))

Buggy submission (verdict: Runtime Error):
num1, num2 = map(int, input().split())

import math
def factor(num):
  l = []
  a = math.ceil(math.sqrt(num))
  for i in range(2,a):
    if num%i==0:
      l.append(i)
  return l

l1 = factor(num1)
l2 = factor(num2)
l = set(l1,l2)

ans = 1
for _ in l:
  ans = ans * _
  
print(ans)

Buggy submission (verdict: Runtime Error):
n1, n2 = map(int, input().split())
import math
print(math.gcd(n1,n2))
Problem p02847 (python)

Fixed submission:
s = input()

dic = {'SUN':7,'MON':1,'TUE':2,'WED':3,'THU':4,'FRI':5,'SAT':6}

if s == 'SUN':
  print(7)
else:
  print(dic['SUN']-dic[s])

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

import math
def digit(n):
  return math.floor(math.log(n,10))+1
  
n_max = 10**9
n_min = 0

while((n_max-n_min)>1):
  key = (n_max+n_min)//2
  if a*key + b*digit(key) < x:
    n_min = key
  elif a*key + b*digit(key) > x:
    n_max = key

if n_max*a + b*digit(n_max) < x:
  print(n_max)
else:
  print(n_min)

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

dic = {'SUN':7,'MON':1,'TUE':2,'WED':3,'THU':4'FRI':5,'SAT':6}

if s == 'SUN':
  print(7)
else:
  print(dic['SUN']-dic[s])
Problem p02859 (python)

Fixed submission:
print(int(pow(int(input()),2)))

Buggy submission (verdict: Runtime Error):
print(int(pow(input(),2)))
Problem p02880 (python)

Fixed submission:
n = int(input())

for i in range(1,10):
  if n%i == 0:
    if int(n/i) <= 9:
      print('Yes')
      exit()
      
print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(1,10):
  for i in range(1,10):
    if i*j == n:
      print('Yes')
      exit()
print('No')
Problem p02959 (python)

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

c = [0]*(n+1)
ans = 0
for i in range(n):
  if b[i]+c[i] > a[i]:
    if c[i]>=a[i]:
      ans = ans + a[i]
      c[i+1] = b[i]
    else:
      ans = ans + a[i]
      c[i+1] = b[i]+c[i]-a[i]
  else:
    ans = ans + b[i] + c[i]
if c[n]>a[n]:
  ans = ans + a[n]
else:
  ans = ans + c[n]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
begin = sum(a)
c = 0
for i in range(n):
  a[i] = a[i]-c[i] if a[i]>c[i] else 0
  c = 0
  a[i] = a[i]-b[i] if a[i]>b[i] else 0
  c = b[i] - a[i] if b[i]>a[i] else 0
a[n] = a[n]-c if a[n]>c else 0
after = sum(a)
print(begin-after)
Problem p02989 (python)

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

diff = sorted(diff)
l = diff[int(n/2)-1]
r = diff[int(n/2)]
print(r-l)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
d = sorted(d)
l = d[n/2-1]
r = d[n/2]
print(r-l)
Problem p03013 (python)

Fixed submission:
n,m = map(int, input().split())
num = list(int(input()) for _ in range(m))

count = [-1]*(n+1)
for stair in num:
  count[stair] = 0
  
count[0] = 1
count[1] = 1 if 1 not in num else 0

for i in range(2,n+1):
  if count[i] != 0:
  	count[i] = (count[i-1]+count[i-2]) % (10**9+7)
  
print(count[n])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
flag = [0]*(n+1)
for i in range(m):
  a = int(input())
  flag[a] = 1
num = 10**9+7
count = [0]*(n+1)
count[0] = 1
count[1] = 1 if 1 not in a else 0
for i in range(2,n+1):
  if flag[i]==0: count[i] = count[i-1] + count[i-2]
  count[i] = count[i]%num
print(count[n])