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

Fixed submission:
a = int(input())
if a % 2 == 0:
  print(str(int(a//2)))
else:
  print(str(int(a//2)+1))

Buggy submission (verdict: Runtime Error):
a = int(input())
if a % 2 = 0:
  print(str(int(a//2)))
else:
  print(str(int(a//2)+1.0))

Buggy submission (verdict: Runtime Error):
a = int(input())
if a % 2 = 0:
  print(str(int(a//2)))
else:
  print(str(int(a//2)+1))

Buggy submission (verdict: Runtime Error):
a = int(input())
if a % 2 = 0:
  print(str(a//2))
else:
  print(str((a//2)+1))

Buggy submission (verdict: Runtime Error):
a = int(input())
if a % 2 = 0:
  print(str(a/2))
else:
  print(str((a/2)+1))
Problem p02771 (python)

Fixed submission:
i = list(map(int,input().split()))
if (i[0] == i[1] and i[0] != i[2]) or (i[0] == i[2] and i[0] != i[1])  or (i[1] == i[2] and i[1] != i[0]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
i = map(int,input().split())
if (i[0] == i[1] and i[0] != i[2]) or (i[0] == i[2] and i[0] != i[1])  or (i[1] == i[2] and i[1] != i[0]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
i = map(int,input(),split())
if (i[0] == i[1] and i[0] != i[2]) or (i[0] == i[2] and i[0] != i[1])  or (i[1] == i[2] and i[1] != i[0]):
  print("Yes")
else:
  print("No")
Problem p02951 (python)

Fixed submission:
a,b,c = map(int,input().split())
 
if (a-b) <= c:
  print(str(c - (a - b)))
else:
  print("0")

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

if (a-b) <= c:
  print(str(c - (a - b)))
else:
  print("0")
Problem p02572 (python)

Fixed submission:
import math

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

for i in range(N-1):
    tmp+=A[i]
    ans+=tmp*A[i+1]
print(ans%((10**9)+7))

Buggy submission (verdict: Runtime Error):
for i in range(N-1):
    tmp+=A[i]
    ans+=tmp*A[i+1]
print(ans%((10**9)+7))
Problem p02729 (python)

Fixed submission:
from math import factorial
def ncr(n,r):
	if n<r:
		return 0
	else:
		return factorial(n)/(factorial(n-r)*factorial(r))
n,m = map(int,input().split())
print(int(ncr(n,2)+ncr(m,2)))

Buggy submission (verdict: Runtime Error):
from math import factorial
def nc2(n):
	if n<r:
		return 0
	else:
		return (n*(n-1))//2

n = int(input())
arr = list(map(int,input().split()))
d = {}
for i in range(n):
	try:
		d[arr[i]].append(i)
	except KeyError:
		d[arr[i]] = [i]

done = {}
for i in range(n):
	try:
		if done[arr[i]] > -1:
			continue
	except KeyError:
		ans = 0
		for j in d.keys():
			if j == arr[i]:
				ans+= ncr(len(d[j])-1,2)
			else:
				ans+= ncr(len(d[j]),2)
		done[arr[i]] = int(ans)

for i in arr:
	print(done[i])
Problem p02596 (python)

Fixed submission:
K = int(input())

def calculate(k):

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == 0:
        print(-1)
        return

    res = 1

    m = (((10 ** res) - 1) // 9) * 7


    while m % k > 0:
        res += 1
        m = m % k
        m = m * 10 + 7

    print(res)


calculate(K)

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

def calculate(k):

    res = 1

    n = 7

    if k % 2 == 0:
        print(-1)
        return

    if k % 5 == 0:
        print(-1)
        return

    while n % k > 0:
        n = n % k
        n = n * 10 + 7
        res += 1

    print(res)

calculate(K)


K = int(input())
Problem p02597 (python)

Fixed submission:
# N = 8
# S = "WRWWRWRR"
#
# N = 2
# S = "RR"
#
# N = 3
# S = "WWW"

N = int(input())
S = input()

def calculate(n, s):
    arr = list(s)

    wNum = arr.count("W")
    RNum = arr.count("R")

    if wNum == 0 or RNum == 0:
        print(0)
        return

    leftW = 0
    rightR = RNum



    result = []
    for i in range(n):
        if arr[i] == "R":
            rightR -= 1
        if arr[i] == "W":
            leftW += 1

        result.append(max(leftW, rightR))

    print(min(result))


calculate(N, S)

Buggy submission (verdict: Runtime Error):
def calculate(n, s):
    arr = list(S)

    RNum = arr.count("R")

    leftW = 0
    rightR = RNum

    result = []
    for i in range(n):
        if arr[i] == "R":
            rightR -= 1
        if arr[i] == "W":
            leftW += 1

        result.append(max(leftW, rightR))

    print(min(result))


calculate(N, S)
Problem p02623 (python)

Fixed submission:
from collections import deque

N, M, K = 3, 4, 240
ARR = [60, 90, 120]
BRR = [80, 150, 80, 150]
#
# N, M, K = 3, 4, 730
# ARR = [60, 90, 120]
# BRR = [80, 150, 80, 150]

N, M, K = 5, 4, 1
ARR = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]
BRR = [1000000000, 1000000000, 1000000000, 1000000000]

N, M, K = 7, 4, 14
ARR = [1, 6, 1, 1, 1, 7, 2]
BRR = [5, 1, 5, 6, 7]


N,M,K = map(int,input().split())
ARR = list(map(int,input().split()))
BRR = list(map(int,input().split()))


def calculate(n, m, k, arr, brr):
    q = deque()

    result = []
    total = 0

    for i in range(n):
        if (total + arr[i]) > k:
            break
        total += arr[i]
        q.append(arr[i])

    result.append(len(q))

    remain = k - total

    q2 = deque(brr)
    sss = 0

    while (len(q2) > 0) and ((sss + q2[0]) <= remain):
        v = q2.popleft()
        sss += v

    result.append(len(q) + (m - len(q2)))

    while len(q) > 0:
        right = q.pop()
        remain += right

        while (len(q2) > 0) and ((sss + q2[0]) <= remain):
            v = q2.popleft()
            sss += v

        result.append(len(q) + (m - len(q2)))

    print(max(result))


calculate(N, M, K, ARR, BRR)

Buggy submission (verdict: Runtime Error):
N, M, K = 3, 4, 240
ARR = [60, 90, 120]
BRR = [80, 150, 80, 150]


N,M,K = 3, 4, 730
ARR = [60, 90, 120]
BRR = [80, 150, 80, 150]


N,M,K = 5, 4, 1
ARR = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]
BRR = [1000000000, 1000000000, 1000000000, 1000000000]

N,M,K = map(int,input().split())
ARR = list(map(int,input().split()))
BRR = list(map(int,input().split()))


def calculate(n,m,k,arr,brr):
    arrIndex = 0
    brrIndex = 0

    total = 0
    result = 0

    while True:
        if (brrIndex >= m) and (arrIndex >= n):
            break

        if arrIndex >= n:
            if (total + brr[brrIndex]) <=k:
                total += brr[brrIndex]
                result += 1
                brrIndex += 1
                continue
            else:
                break

        if brrIndex >= m:
            if (total + brr[brrIndex]) <=k:
                total += brr[brrIndex]
                result += 1
                brrIndex += 1
                continue
            else:
                break

        if arr[arrIndex] < brr[brrIndex]:
            if (total + arr[arrIndex]) <= k:
                total += arr[arrIndex]
                result += 1
                arrIndex += 1
            else:
                break
        else:
            if (total + brr[brrIndex]) <=k:
                total += brr[brrIndex]
                result += 1
                brrIndex += 1
            else:
                break

    print(result)

calculate(N,M,K,ARR,BRR)
Problem p02659 (python)

Fixed submission:
from decimal import *

a, b = input().split()
x = Decimal(a)
y = Decimal(b)

print(int(x*y))

Buggy submission (verdict: Runtime Error):
S = input().split()
A = int(S[0])
B = float(S[1])

from mpmath import mp
mp.dps = 50

res = mp.mpf(B*A)
print(int(res))
Problem p02759 (python)

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

print(math.ceil(N/2))

Buggy submission (verdict: Runtime Error):
N, X = 6, 1
ARR = [1, 6, 1, 2, 0, 4]

N, X = 3, 3
ARR = [2, 2, 2]

N, X = 5, 9
ARR = [3, 1, 4, 1, 5]

N, X = 2, 0
ARR = [5, 5]

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

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


def calculate(n, x, arr):
    result = 0
    for i in range(1, n):
        sSum = arr[i - 1] + arr[i]
        if sSum <= x:
            continue

        diff = sSum - x

        if diff <= arr[i]:
            arr[i] -= diff
            result += diff
        else:
            result += diff
            arr[i] = 0

    print(result)


calculate(N, X, ARR)
Problem p02831 (python)

Fixed submission:
import fractions

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

res = fractions.gcd(A, B)

print(int(A*B / res))

Buggy submission (verdict: Runtime Error):
import math

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

res = math.gcd(A, B)

print(int(A*B / res))
Problem p02912 (python)

Fixed submission:
import heapq

S = input().split(" ")
N = int(S[0])
M = int(S[1])
S = input()

arr = [-int(s) for s in S.split(" ")]

heapq.heapify(arr)

for i in range(M):
    maxValue = -heapq.heappop(arr)
    heapq.heappush(arr,-(maxValue//2))

print(-sum(arr))

Buggy submission (verdict: Runtime Error):


S = input().split(" ")
N = int(S[0])
M = int(S[1])

S = input().split(" ")

arr =  [int(s) for s in S]
arr2 = arr.copy()
brr =  [0 for s in S]

def calculate(m,arr,brr):


    for i in range(m):
        maxValue = max(arr)
        maxIndex = arr.index(maxValue)
        arr[maxIndex] = arr[maxIndex]//2
        brr[maxIndex] = brr[maxIndex] + 1

    return brr

result = calculate(M,arr,brr)


for index,br in enumerate(brr):
    arr2[index] = arr2[index]//(2**br)

print(sum(arr2))

Buggy submission (verdict: Runtime Error):
import math

def getMax(arr):
    maxValue = max(list(arr))
    maxIndex = list(arr).index(maxValue)

    return maxIndex,maxValue


def getSum(arr):
    return sum(list(arr))

def calculate(arr,n):
    if n == 0:
        return getSum(arr)
    else:
        index,value = getMax(arr)
        if value == 0:
            return value
        n -= 1
        arr[index] = math.floor(value/2)
        return calculate(arr,n)

S = input().split(' ')
m = int(S[0])
n = int(S[1])

T = input().split(' ')
arr = list(map(int, list(T)))


result = calculate(arr,n)
print(result)
Problem p02990 (python)

Fixed submission:
from scipy import misc

def cnk(n,k):
    return misc.comb(n,k,exact=True)


# import scipy.special
# def cnk(n,k):
#     return int(scipy.special.comb(n,k))

def calculate(n,k):
    # 1. 在n+1个缝隙上，选择i个地方 Cn+1,i

    # 2. 在i个地方，放入k个球 C(k-1),(i-1)

    for i in range(1,k+1):

        a1 = cnk(n-k+1,i)
        a2 = cnk(k-1,i-1)
        print((a1 * a2) % (1000000000+7))


S = input().split(" ")

N = int(S[0])
K = int(S[1])

calculate(N,K)

Buggy submission (verdict: Runtime Error):
from scipy import misc

def cnk(n,k):
    return int(misc.comb(n,k))


# import scipy.special
# def cnk(n,k):
#     return int(scipy.special.comb(n,k))

def calculate(n,k):
    # 1. 在n+1个缝隙上，选择i个地方 Cn+1,i

    # 2. 在i个地方，放入k个球 C(k-1),(i-1)

    for i in range(1,k+1):

        a1 = cnk(n-k+1,i)
        a2 = cnk(k-1,i-1)
        print((a1 * a2) % (1000000000+7))


S = input().split(" ")

N = int(S[0])
K = int(S[1])

calculate(N,K)
Problem p03221 (python)

Fixed submission:
import sys
sys.setrecursionlimit(20000000)
S = input().split(" ")
n = int(S[0])
m = int(S[1])

py = []

for i in range(m):
    py.append([int(s) for s in input().split(" ")])

def prepare(n, data):
    result = [0 for i in range(n)]
    dict = {}
    data = sorted(data,key=lambda x:x[1])
    for d in data:
        i = d[0] - 1
        result[i] = result[i] + 1
        dict.__setitem__(generateID(d[0], d[1]), str(d[0]).zfill(6) + str(result[i]).zfill(6))

    return dict


def generateID(start, to):
    if start < to:
        start, to = to, start

    return start * 100000 + to

dict = prepare(n, py)

for p in py:
    print(dict[generateID(p[0],p[1])])

Buggy submission (verdict: Runtime Error):
S = input().split(" ")
n = int(S[0])
m = int(S[1])

py = []

for i in range(n+1):
    py.append([int(s) for s in input().split(" ")])

def prepare(n, data):
    result = [0 for i in range(n)]
    dict = {}
    data = sorted(data,key=lambda x:x[1])
    for d in data:
        i = d[0] - 1
        result[i] = result[i] + 1
        dict.__setitem__(generateID(d[0], d[1]), str(d[0]).zfill(6) + str(result[i]).zfill(6))

    return dict


def generateID(start, to):
    if start < to:
        start, to = to, start

    return start * 100000 + to

dict = prepare(n, py)

for p in py:
    print(dict[generateID(p[0],p[1])])
Problem p02707 (python)

Fixed submission:
N = int(input())
A =[int(n) for n in input().split()]
b = [0]*N
for i in A:
  b[i-1]+=1
for i in range(N):
  print(b[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
A =[int(i) for i in input().split()]
b = [0]*N
for i in A:
  result[i-1]+=1
for i in range(N):
    print(b[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = input().split()
A = [int(n) for n in A]
for i in range(N):
  count = 0
  for j in range(len(A)):
	if i+1 == A[j]:
	  count += 1
  A.pop(i+1)
  print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = input().split()
for i in range(N):
  count = 0
  for j in range(N-1):
	if i+1 == int(A[j]):
	  count += 1
  print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = input().split()
for i in range(N):
  count=0
  for j in range(N-1):
	if i+1==int(A[j]):
	  count+=1
  print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = input().split()
A = [int(n) for n in A]
for i in range(N):
  count = 0
  for j in range(N-1):
	if i+1 == A[j]:
	  count += 1
  print(count)

Buggy submission (verdict: Runtime Error):
A = input().split()
A = [int(n) for n in A]
for i in range(N):
  count = 0
  for j in range(N-1):
	if i+1 == A[j]:
	  count += 1
  print(count)
Problem p02689 (python)

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

G = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
#print(G)
ans = 0
for i in range(n):
    maxh = 0
    for gi in G[i]:
        maxh = max(h[gi], maxh)
    if maxh < h[i]:
        ans += 1
    #print(maxh, h[i])

print(ans)

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

G = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
#print(G)
ans = 0
for i in range(n):
    maxh = 0
    for gi in G[i]:
        maxh = max(h[gi], maxh)
    if maxh < h[i]:
        ans += 1
    #print(maxh, h[i])

print(ans)
Problem p02935 (python)

Fixed submission:
n = int(input())
v = list(map(int, input().split()))
#n = 3
#v = list(map(int, "500 300 200".split()))
v.sort()
ans = v[0]
for i in range(1,n):
    ans = (v[i] + ans)/2
print(ans)

Buggy submission (verdict: Runtime Error):
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
print(1.0/sum(list(map(lambda x: 1.0 / x, a))))

Buggy submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
v.sort()
ans = v[0]
for i in v[1:]:
    ans = (v[i] + ans)/2
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
v = list(map(int, input().split()))
#n = 3
#v = list(map(int, "500 300 200".split()))
v.sort()
ans = v[0]
for i in range(1,3):
    ans = (v[i] + ans)/2
print(ans)
Problem p03013 (python)

Fixed submission:
import sys 
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [int(input()) - 1 for _ in range(m)]
a.append(n)

dp = [-1] * max(3, n + 1)
dp[0] = 1
dp[1] = 1
dp[2] = 2
def stepsum(n):
    if dp[n] != -1:
        return dp[n]
    dp[n] = stepsum(n-1) + stepsum(n-2)
    return dp[n]
prev = 0
ans = 1
for ai in a:
    if prev != 0 and ai - prev < 0:
        ans = 0
        break
    ans *= stepsum(ai - prev)
    prev = ai + 2

print(ans % ( 10 ** 9 + 7 ))

Buggy submission (verdict: Runtime Error):
import sys 
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [int(input()) - 1 for _ in range(m)]
a.append(n)

dp = [-1] * max(3, n)
dp[0] = 1
dp[1] = 1
dp[2] = 2
def stepsum(n):
    if dp[n] != -1:
        return dp[n]
    dp[n] = stepsum(n-1) + stepsum(n-2)
    return dp[n]
prev = 0
ans = 1
for ai in a:
    if prev != 0 and ai - prev < 0:
        ans = 0
        break
    ans *= stepsum(ai - prev)
    prev = ai + 2

print(ans % ( 10 ** 9 + 7 ))

Buggy submission (verdict: Runtime Error):
import sys 
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [int(input()) - 1 for _ in range(m)]
a.append(n)

dp = [-1] * n
dp[0] = 1
dp[1] = 1
dp[2] = 2
def stepsum(n):
    if dp[n] != -1:
        return dp[n]
    dp[n] = stepsum(n-1) + stepsum(n-2)
    return dp[n]
prev = 0
ans = 1
for ai in a:
    if prev != 0 and ai - prev < 0:
        ans = 0
        break
    ans *= stepsum(ai - prev)
    prev = ai + 2

print(ans % ( 10 ** 9 + 7 ))
Problem p03053 (python)

Fixed submission:
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)] # #.のグリッドの場合
#print(a)

from collections import deque
step = [(0,1), (0,-1), (1,0), (-1,0)]
que = deque()

seen = [[-1] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            que.append((i, j))
            seen[i][j] = 0
ans = 0
#import numpy as np
#print(np.array(seen))
while len(que) > 0:
    x, y = que.popleft()
    for tx, ty in step:
        xi, yi = x + tx, y + ty
        if xi < 0 or yi < 0 or xi >= h or yi >= w:
            continue
        if a[xi][yi] == '#':
            continue
        if a[xi][yi] == '.':
            seen[xi][yi] = seen[x][y] + 1
            ans = max(ans, seen[xi][yi])
            a[xi][yi] = '#'
            que.append((xi, yi))
    #print(np.array(seen))
print(ans)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)] # #.のグリッドの場合
#print(a)

from collections import deque
step = [(0,1), (0,-1), (1,0), (-1,0)]
que = deque()

seen = [[-1] * w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            que.append((i, j))
            seen[i][j] = 0
ans = 0
import numpy as np
#print(np.array(seen))
while len(que) > 0:
    x, y = que.popleft()
    for tx, ty in step:
        xi, yi = x + tx, y + ty
        if xi < 0 or yi < 0 or xi >= h or yi >= w:
            continue
        if a[xi][yi] == '#':
            continue
        if a[xi][yi] == '.':
            seen[xi][yi] = seen[x][y] + 1
            ans = max(ans, seen[xi][yi])
            a[xi][yi] = '#'
            que.append((xi, yi))
    #print(np.array(seen))
print(ans)
Problem p02623 (python)

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

    ans = 10 ** 10
    t = 0

    for i in range(M):
        t += B[i]
    j = M
    ans = 0
    for i in range(N+1):
        while j > 0 and t > K:
            j -= 1
            t -= B[j]
        
        if t > K:
            break
        
        ans = max(ans, i+j)
        
        if i == N:
            break
        t += A[i]
    
    print(ans)

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N, M, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    read = deque()

    while sum(read) <= K:
        if len(A) == 0 and len(B) == 0:
            break

        if len(A) == 0:
            if sum(read) + B[0] <= K:
                read.append(B[0])
            B.pop(0)
            continue

        if len(B) == 0:
            if sum(read) + A[0] <= K:
                read.append(A[0])
            A.pop(0)
            continue

        if A[0] < B[0]:
            if sum(read) + A[0] <= K:
                read.append(A[0])
            A.pop(0)
        else:
            if sum(read) + B[0] <= K:
                read.append(B[0])

            B.pop(0)

    print(len(read))


resolve()
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
A, B = input().split()
A = Decimal(A)
B = Decimal(B)
print(int(A * B))

Buggy submission (verdict: Runtime Error):
A, B = int(input()), float(input())
print(int(A * B))

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))
print(int(A * B))
Problem p02754 (python)

Fixed submission:
def resolve():
    N, A, B = list(map(int, input().split()))
    ans = 0
    ans += N // (A + B) * A
    ans += min(N % (A+B), A)

    print(ans)

    return


resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N, A, B = list(map(int, input().split()))
    line = ''
    for i in range(10 ** 100):
        if len(line) > N:
            break
        if i % 2 == 0:
            line += 'b' * A
        else:
            line += 'r' * B

    print(line[:N].count('b'))

    return


resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    N, A, B = list(map(int, input().split()))
    line = ''
    for i in range(10 ** 100):
        if i > N:
            break
        if i % 2 == 0:
            line += 'b' * A
        else:
            line += 'r' * B

    print(line[:N].count('b'))

    return

resolve()
Problem p02819 (python)

Fixed submission:
import math
def resolve():
    def is_prime(n):
        if n == 1:
            return False
 
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
 
        return True
    X = int(input())
 
    while True:
        if is_prime(X):
            print(X)
            return
        else:
            X += 1
 
    return
 
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    def is_prime(n):
      	import math
        if n == 1:
            return False
 
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
 
        return True
    X = int(input())
 
    while True:
        if is_prime(X):
            print(X)
            return
        else:
            X += 1
 
    return
 
resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    def is_prime(n):
        if n == 1:
            return False

        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False

        return True
    X = int(input())

    while True:
        if is_prime(X):
            print(X)
            return
        else:
            X += 1

    return

resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    def is_prime(n):
        if n == 1:
            return False

        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False

        return True
    X = int(input())

    while True:
        if is_prime(X):
            print(X)
            return
        else:
            X += 1

    return
  
  
resolve()
Problem p03631 (python)

Fixed submission:
N = str(input())

A = N[::-1]
if N == A:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for i in range(N)]

import fractions
def lcm(a, b):
    if gcd != 0:
        return (a * b) // gcd
    else:
        return 0

gcd = 1
x = 0

for i in range(N):
    for j in range(N):
        gcd = int(fractions.gcd(T[i] , T[j]))
        x = max(lcm(T[i], T[j]), x)

print(x)
Problem p03805 (python)

Fixed submission:
from itertools import permutations
import copy

def resolve():
    N, M = list(map(int, input().split()))
    G = [[0] * N for _ in range(N)]
    for i in range(M):
        a, b = list(map(int, input().split()))
        G[a-1][b-1] = 1
        G[b-1][a-1] = 1

    ls = list(permutations(range(1, N)))
    ans = 0
    for l in ls:
        h = copy.deepcopy(G)
        cnt = 1
        p = 0 
        for k in l:
            if h[p][k] == 0:
                break
            else:
                cnt += 1
                p = k
        if cnt == N:
            ans += 1
    print(ans)
    return

resolve()

Buggy submission (verdict: Runtime Error):
from itertools import permutations
import copy
def resolve():
    N, M = list(map(int, input().split()))
    G = [[0]*N for _ in range(M)]
    for i in range(M):
        a, b = list(map(int, input().split()))
        G[a-1][b-1] = 1
        G[b-1][a-1] = 1

    ls = list(permutations(range(1, N)))
    ans = 0
    for l in ls:
        h = copy.deepcopy(G)
        cnt = 1
        p = 0 
        for k in l:
            if h[p][k] == 0:
                break
            else:
                cnt += 1
                p = k
        if cnt == N:
            ans += 1
    print(ans)
    return
resolve()