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

Fixed submission:
def fctr(n):
    f = []
    c = 0
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            c+=1
            n = n//i
        if c!=0:
            f.append([i,c])
            c = 0

    if n!=1:
        f.append([n,1])

    return f

def combination(n,r):
    r = min(r,n-r)
    result = 1
    for i in range(n-r+1,n+1):
        result *= i
    for i in range(1,r+1):
        result //= i
    return result

mod = 10**9 + 7
N,M = list(map(int,input().split()))
ans = 0
s = fctr(M)

for i in s:
    if ans == 0:
        ans = combination(N-1+i[1],i[1]) % mod
    else:
        ans = (ans*combination(N-1+i[1],i[1]))%mod

if M != 1:         
    print(ans)
else:
    print('1')

Buggy submission (verdict: Runtime Error):
#nの約数列挙
def devisor(n):
    ans = []
    if n == 1:return [1]
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            if i != n//i:
                ans.append(i)
                ans.append(n//i)
            else:
                ans.append(i)
            

    return ans       

#n個の正数の積でmになる場合の数
def cnt(n,m):
    ans = 0
    if n == 1:return 1
    s = devisor(m)
    for i in s:
        ans += cnt(n-1,m//i)
    return ans


N,M = list(map(int,input().split()))
print(cnt(N,M))
Problem p03307 (python)

Fixed submission:
N = int(input())
if N % 2 == 0:
  print(N)
else:
  print(N*2)

Buggy submission (verdict: Runtime Error):
import math

n=int(input())

#最小公倍数を定義
def lcm(x,y):
    return (x*y)//math.gcd(x,y)

print(lcm(n,2))

Buggy submission (verdict: Runtime Error):
import math

n=int(input())

#最小公倍数を定義
def lcm(x,y):
    return (x*y)//math.gcd(x,y)

print(lcm(n,2))
Problem p03804 (python)

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

pic1=[]
pic2=[]

for i in range(n):
    pic1.append(input())

for j in range(m):
    pic2.append(input())

#print(pic1)
#print(pic2)

ans="No"

for i in range(n-m+1):
    for j in range(n-m+1):
        flag=True
        for k in range(m):
            for l in range(m):
                if pic1[i+k][j+l]!=pic2[k][l]:
                    flag=False

            if not flag:
                break
        if flag:
            print("Yes")
            exit()

print("No")

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

pic1=[]
pic2=[]

for i in range(n):
    pic1.append(input())

for j in range(m):
    pic2.append(input())

#print(pic1)
#print(pic2)

ans="No"

for i in range(n-m+1):
    for j in range(n-m+1):
        flag=True
        for k in range(m):
            for l in range(m):
                if pic1[i+k][j+l]!=b[k][l]:
                    flag=False

            if not flag:
                break
        if flag:
            print("Yes")
            exit()

print("No")
Problem p03834 (python)

Fixed submission:
x = input()
x=x.replace(","," ")
print(x)

Buggy submission (verdict: Runtime Error):
k,s=map(int,input().split())

count=0

for i in range(k+1):
    for j in range(k+1):
        z=s-(i+j)
        
        if 0<=z<=s:
            count+=1
print(count)
Problem p03835 (python)

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

count=0

for i in range(k+1):
    for j in range(k+1):
        if s-k<=i+j<=s:
            count+=1
print(count)

Buggy submission (verdict: Runtime Error):
k,s=map(int,input().split())

count=0

for i in range(k+1):
    for j in range(k+1):
        z=s-(i+j)
        
        if nums.count(z):
            count+=1
print(count)
Problem p03835 (python)

Fixed submission:
k,s=map(int,input().split())
res=0
for x in range(k+1):
  for y in range(k+1):
    if s-x-y<=k and s-x-y>=0:
      res+=1
      #print(x,y,s-x-y)
print(res)

Buggy submission (verdict: Runtime Error):
k,s=map(int,input().split())
res=0
for x in range(k+1):
  for y in range(k+1):
    if s-x-y=>0:
      res+=1
print(res)
Problem p02984 (python)

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

X1by2 = 0
for i in range(N):
  if i%2 ==0:
    X1by2 += A[i]
  else:
    X1by2 -= A[i]

X = []

X.append(X1by2)
for i in range(len(A)-1):
  X.append((A[i]-X[i]/2)*2)

print(" ".join(repr(int(e)) for e in X))

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

X1by2 = 0
for i in range(N):
  if i%2 ==0:
    X1by2 += A[i]
  else:
    X1by2 -= A[i]

X = []

X.append(X1by2)
for i in range(len(A-1)):
  X.append((A[i]-X[i]/2)*2)

print(" ".join(repr(int(e)) for e in X))
Problem p02951 (python)

Fixed submission:
A_B_C = input().split()
A = int(A_B_C[0])
B = int(A_B_C[1])
C = int(A_B_C[2])

left = 0
if A >= (B+C):
  left = 0
else:
  left = C - (A-B)
print(left)

Buggy submission (verdict: Runtime Error):
A_B_C = input().split()
A = int(A_B_C[0])
B = int(A_B_C[1])
C = int(A_B_C[2])

left = 0
if A >= (B+C):
  left = 0
else:
  left = C - (A-B)
  
 print(left)

Buggy submission (verdict: Runtime Error):
A_B_C = input().split()
A = int(A_B_C[0])
B = int(A_B_C[1])
C = int(A_B_C[2])

left = 0
if A >= B + C:
  left = 0
else:
  left = C - (A-B)
  
 print(left)
Problem p02951 (python)

Fixed submission:
vals = [int(x) for x in input(). split()]
dif = vals[0] - vals[1]
 
if dif >= vals[2]:
  print(0)
else:
  print(vals[2] - dif)

Buggy submission (verdict: Runtime Error):
vals = input().split()
dif = vals[0] - vals[1]
 
if dif >= vals[3]:
  print(0)
else:
  print(vals[3] - dif)

Buggy submission (verdict: Runtime Error):
vals = input().split()
dif = vals[0] - vals[1]

if dif >= vals[3]:
  print 0
else:
  print vals[3] - dif

Buggy submission (verdict: Runtime Error):
import fileinput

for line in fileinput.input():
    vals = line.split()
    print min(vals[0] - vals[1], vals[2])
Problem p03011 (python)

Fixed submission:
inp=list(map(int,input().split(' ')))
print(min(inp)+sorted(inp)[1])

Buggy submission (verdict: Runtime Error):
N=int(input())
inp=list(map(int,input().split(' ')))
su=sum(inp)
ab=su
for i in range(N):
  s1=0
  for j in range(i):
    s1+=inp[j]
  if (ab>abs(2*s1-su)):
    ab=abs(2*s1-su)
print(ab)
Problem p02951 (python)

Fixed submission:
A, B, C = list(map(int, input().split()))
 
ABgap = A - B
remain = max(0, C - ABgap)
 
print(remain)

Buggy submission (verdict: Runtime Error):
N = int(input())
def count(start, end):
  return end - start + 1
keta = 1
while True:
  if 10**keta > N:
    break
  else:
    keta += 1
num = 0
for k in range(1, keta+1):
  if k % 2 == 1:
    num += count(10**(k-1), min(N, 10**k-1))
print(num)

Buggy submission (verdict: Runtime Error):
N = int(input())
def count(start, end_):
  return end_ - start + 1
keta = 1
while True:
  if 10**keta > N:
    break
  else:
    keta += 1  
num = 0
for k in range(1, keta+1):
  if k % 2 == 1:
    num += count(10**(k-1), min(N, 10**k-1))
print(num)

Buggy submission (verdict: Runtime Error):
N = int(input())
def count(start, end):
  return end - start + 1
keta = 1
while True:
  if 10**keta > N:
    break
  else:
    keta += 1  
num = 0
for k in range(1, keta+1):
  if k % 2 == 1:
    num += count(10**(k-1), min(N, 10**k-1))
print(num)

Buggy submission (verdict: Runtime Error):
N = int(input())
def count(start, end):
	return end - start + 1
keta = 1
while True:
	if 10**keta > N:
    	break
	else:
    	keta += 1
num = 0
for k in range(1, keta+1):
	if k % 2 == 1:
		num += count(10**(k-1), min(N, 10**k-1))

print(num)

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

def count(start, end):
  return end - start + 1

keta = 1
while True:
  if 10**keta > N:
    break
  else:
    keta += 1
      
num = 0
for k in range(1, keta+1):
  if k % 2 == 1:
    num += count(10**(k-1), min(N, 10**k-1))

print(num)

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

def count(start, end):
  return end - start + 1

keta = 1
while True:
  if 10**keta > N:
    break
  else:
  	keta += 1
      
num = 0
for k in range(1, keta+1):
  if k % 2 == 1:
    num += count(10**(k-1), min(N, 10**k-1))

print(num)

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

ABgap = A - B
remain = max(0, C - ABgap)

print(remain)
Problem p03803 (python)

Fixed submission:
a, b = (int(i) for i in input().split())

if a==1:
    a=14
if b==1:
    b=14

if a==b:
    print("Draw")
elif a>b:
    print("Alice")
else:
    print("Bob")

Buggy submission (verdict: Runtime Error):
N, M = (int(i) for i in input().split())
a = []
b = []
for i in range(N):
    data = list(input())
    a.append(data)
for i in range(M):
    data = list(input())
    b.append(data)

#N=4
#M=2
#a=[['a','s','a','s'],['a','a','s','s'],['s','a','a','s'],['s','a','a','a']]
#b=[['s','a'],['a','s']]

L = N-M

def check(i,j):
    ans=True
    for line in range(M):
        if (ans==False):
            break
        for row in range(M):
            if (a[i+line][j+row]!=b[line][row]):
                ans=False
                break
    return ans

ans=False
for i in range(L+1):
    if(ans==True):
        break
    for j in range(L+1):
        ansnow=check(i,j)
        print(ansnow,i,j)
        if(ansnow==True):
            ans=True
            break
if(ans==True):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N, M = (int(i) for i in input().split())
a = []
b = []
for i in range(N):
    data = list(input())
    a.append(data)
for i in range(M):
    data = list(input())
    b.append(data)
    
L = N-M

def check(i,j):
    ans=True
    for line in range(L+1):
        for row in range(L+1):
            if (a[i+line][j+row]!=b[line][row]):
                ans=False
                break
    return ans

ans=False
for i in range(L+1):
    for j in range(L+1):
        ansnow=check(i,j)
#        print(ansnow,i,j)
        if(ansnow==True):
            ans=True
            break
if(ans==True):
    print('Yes')
else:
    print('No')
Problem p02987 (python)

Fixed submission:
S=input()

if len(S)!=4:
  print('No')
else:  
  Sorted_S = sorted(S)
  
  L1=Sorted_S[0]
  L2=Sorted_S[1]
  L3=Sorted_S[2]
  L4=Sorted_S[3]

  if (L1==L2) and (L3==L4) and (L2!=L3):
    print("Yes")
  else:
    print("No")

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

c=0
for i in range(1,n-1):
  if (p[i-1]<p[i]<p[i+1]) or  (p[i-1]>p[i]>p[i+1]):
    c=c+1

print(c)
Problem p03011 (python)

Fixed submission:
p, q, r = map(int, input().split())
print(min([p+q, q+r, r+p]))

Buggy submission (verdict: Runtime Error):
p, q, r = map(int, input().split())
print(min([p+q, q+r, r+p])
Problem p03038 (python)

Fixed submission:
import sys  
input = sys.stdin.readline
 
N, M = list(map(int, input().split()))
 
A = list(map(int, input().split()))



BC = []
for i in range(M):
    b, c = list(map(int, input().split()))
    BC.append([b, c])

BC=sorted(BC, reverse=True, key=lambda x:x[1])

cnt = 0
com = []
for b, c in BC:
    cnt += b
    if cnt > N:
        add = N-cnt+b
        com.extend([c]*add)
        break
    else:
        x = [c]*b 
        com.extend(x)
A.sort()   
num = -1
for k in range(N):
    if k == len(com):
        num = k
        break
    if A[k] > com[k]:
        num = k
        break

if num == -1:
    print(sum(com))
else:
    print(sum(com[:num])+sum(A[num:]))

Buggy submission (verdict: Runtime Error):
import sys  
input = sys.stdin.readline
 
N, M = list(map(int, input().split()))
 
A = list(map(int, input().split()))



BC = []
for i in range(M):
    b, c = list(map(int, input().split()))
    BC.append([b, c])

BC=sorted(BC, reverse=True, key=lambda x:x[1])

cnt = 0
com = []
for b, c in BC:
    cnt += b
    if cnt > N:
        add = N-cnt+b
        com.extend([c]*add)
        break
    else:
        x = [c]*b 
        com.extend(x)

A.extend(com)
A = sorted(A, reverse=True)   

print(sum(A[:N])

Buggy submission (verdict: Runtime Error):
import sys  
input = sys.stdin.readline
 
N, M = list(map(int, input().split()))
 
A = list(map(int, input().split()))

def count_sort(arr):
    max_num = max(arr)
    min_num = min(arr)
    count = [0] * (max_num - min_num + 1)
    for ele in arr:
        count[ele - min_num] += 1

    return [ele for ele, cnt in enumerate(count, start=min_num) for __ in range(cnt)]


for i in range(M):
    b, c = list(map(int, input().split()))
    x = [c]*b
    A.extend(x)
 
A_ = count_sort(A)

    
 
print(sum(A_[-N:]))
Problem p03077 (python)

Fixed submission:
import math
N = int(input())
x = [int(input()) for i in range(5)]


y = min(x)
print(math.ceil(N/y)+4)

Buggy submission (verdict: Runtime Error):

N = int(input())
x = [int(input()) for i in range(5)]


for i in range(5):
    if x[i] == min(x):
        break
    
del x[i+1:]

lenx = len(x)
for k in range(4):
    for w in range(lenx-1):
        cnt=0
        if x[w] =< x[w+1] :
            del x[w+1]
            lenx -=1
        else:
            cnt+=1
            
ans=0
if lenx==0:
    print(5)
else:
    if N%x[0]==0:
        ans+=N/x[0]
    else:
        ans+=N//x[0]+1

    for p in range(1,lenx):
        d = N-(ans-p)*x[p]
        if d%x[p] == 0:
            ans+=d/x[p]
        else:
            ans+=d//x[p]+1

    print(ans+5-lenx)

Buggy submission (verdict: Runtime Error):

N = int(input())
x = [int(input()) for i in range(5)]
ans = [0]*5
if N%x[0]==0:
    ans[0] =  N//x[0]
else:
    ans[0] =  N//x[0] + 1

j = False
if x[0] == min(x):
    print(ans[0]+4)
else:

    for i in range(1,5):
        if j:
           break
        elif x[i] == min(x[i:]):
            j = True
            if (N-(x[i]*(ans[i-1]-1)))%x[i] == 0:
                ans[i] = (N-(x[i]*(ans[i-1]-1)))//x[i]
            else:
                ans[i] = (N-(x[i]*(ans[i-1]-1)))//x[i] + 1
        elif x[i] < x[i-1]:
            if (N-(x[i]*(ans[i-1]-1)))%x[i] == 0:
                ans[i] = (N-(x[i]*(ans[i-1]-1)))//x[i]
            else:
                ans[i] = (N-(x[i]*(ans[i-1]-1)))//x[i] + 1
        else
            if (N-(x[i]*(ans[i-1]-1)))%x[i] == 0:
                ans[i] = (N-(x[i-1]*(ans[i-1]-1)))//x[i]
            else:
                ans[i] = (N-(x[i-1]*(ans[i-1]-1)))//x[i] + 1


    for i in range(1, 5):
        if ans[i] == 0:
            ans[i] = 1
    
    print(sum(ans))
Problem p03803 (python)

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

if A==1:
    A = 14

if B==1:
    B = 14

if A > B:
    print("Alice")
elif B > A:
    print("Bob")
else :
    print("Draw")

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

if A==1 & B==!:
    print("Draw")
elif A==1 :
    print("Alice")
elif B==1 :
    print("Bob")
elif A > B:
    print("Alice")
elif B>A:
    print("Bob")
else :
    print("Draw")
Problem p03041 (python)

Fixed submission:
N, K = map(int, input().split())
S = input()
print(S[:K-1] + S[K-1].lower() + S[K:N])

Buggy submission (verdict: Runtime Error):
#A
N, K = map(int, input().split())
S = input()
print(S.replace(S[K],S[K].lower()))
Problem p03295 (python)

Fixed submission:
# https://atcoder.jp/contests/abc103/tasks/abc103_d
import sys

def solve():
    pairs.sort(key=lambda pair: pair[1])
    cnt = 0
    base = 0
    for (a, b) in pairs:
        if a >= base:
            cnt += 1
            base = b
    return cnt

n, m = map(int, input().split())
pairs = [tuple(int(c) for c in input().split()) for _ in range(m)]
print(n, pairs, file=sys.stderr)
print(solve())

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc103/tasks/abc103_d

def solve(n, pairs):
    pairs.sort(key=lambda pair: pair[1])
    cnt = 0
    while pairs:
        _, b0 = pairs[0]
        cnt += 1
        for (a, b) in pairs:
            if a < b0:
                pairs.remove((a, b))
    return cnt

n, m = map(int, input().split())
pairs = [[int(c) for c in input().split()] for _ in range(m)]
print(solve(n, pairs))
Problem p02984 (python)

Fixed submission:
import sys
import numpy as np
def input():
    return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    a = [int(e) for e in input().split()]

    x = [0 for _ in range(n)]
    x[0] = sum(a) - (sum(a[1:n:2]) * 2)
    for i in range(2, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    x[1] = sum(a) - (sum(a[2:n:2]) * 2)
    for i in range(3, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    print(*x)
main()

Buggy submission (verdict: Runtime Error):
N = int(input())
v = [int(_) for _ in input().split()]

import numpy as np

# v = [8, 3, 3, 4, 10]
# N = len(v)

A = np.zeros((N, N))
for i in range(N):
    A[(i - 1) % N][i] = 1 / 2
    A[i][i] = 1 / 2

ans = np.dot(np.linalg.inv(A), v)
ans = [int(x) for x in ans]
print(*ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
v = [int(_) for _ in input().split()]

import numpy as np

# v = [8, 3, 3, 4, 10]
# N = len(v)

A = np.zeros((N, N))
for i in range(N):
    A[(i - 1) % N][i] = 1 / 2
    A[i][i] = 1 / 2

ans = np.dot(np.linalg.inv(A), v)
ans = [int(x) for x in ans]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
v = [int(_) for _ in input().split()]

import numpy as np

# v = [2,2,4]
# N = len(v)

A = np.zeros((N, N))
for i in range(N):
    A[(i - 1) % N][i] = 1 / 2
    # A[i][(i - 1) % N] = 1 / 2
    A[i][i] = 1 / 2

# print(A)
# print(np.linalg.inv(A))
ans = np.dot(np.linalg.inv(A), v)
ans = [int(x) for x in ans]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
v = [int(_) for _ in input().split()]

import numpy as np

# v = [2, 2, 4]
# N = len(v)

A = np.zeros((N, N))
for i in range(N):
    # A[(i - 1) % N][i] = 1
    A[i][(i - 1) % N] = 1 / 2
    A[i][i] = 1 / 2

# print(A)
# print(np.linalg.inv(A))
ans = np.dot(np.linalg.inv(A), v)
ans = [int(x) for x in ans]
print(ans)
Problem p02987 (python)

Fixed submission:
S = input()
arr = []
for s in S:
    arr.append(s)
if (arr[0] == arr[1]):
    if (arr[0] != arr[2] and arr[2] == arr[3]):
        ans = "Yes"
    else:
        ans = "No"
else:
    if (arr.count(arr[0]) == 2 and arr.count(arr[1]) == 2):
        ans = "Yes"
    else:
        ans = "No"

print(ans)

Buggy submission (verdict: Runtime Error):
S = int(input())
# S = "SASA"
arr = []
for s in S:
    arr.append(s)
if (arr[0] == arr[1]):
    if (arr[2] == arr[3]):
        ans = "Yes"
    else:
        ans = "No"
else:
    if (arr.count(arr[0]) == 2 and arr.count(arr[1]) == 2):
        ans = "Yes"
    else:
        ans = "No"

print(ans)
Problem p03042 (python)

Fixed submission:
N = list(input())
m = list(map(int,N))
a = 10*m[0] + m[1]
b = 10*m[2] + m[3]
 
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12:
  print("MMYY")
elif 1<=b<=12:
  print("YYMM")
else:
  print("NA")

Buggy submission (verdict: Runtime Error):
N = list(input())
m = list(map(int,N))
a = 10*m[0] + m[1]
b = 10*m[2] + m[3]
 
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12:
  print("MMYY")
elif 1<=b<=12:
  print("YYMM")
else:
  print("NA")
N = list(input())
m = list(map(int,N))
a = 10*m[0] + m[1]
b = 10*m[2] + m[3]
 
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12:
  print("MMYY")
elif 1<=b<=12:
  print("YYMM")
else:
  print("NA")
Problem p02990 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())

mod = int(10 ** 9 + 7)


def comb(n, k):
    res = 1
    for i in range(k):
        res *= n - i
    for i in range(k):
        res //= k - i
    return res

for i in range(1, k + 1):
    if i > n - k + 1:
        print(0)
    else:
        print(comb(k - 1, i - 1) * comb(n - k + 1, i) % mod)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from scipy.misc import comb
import numpy as np

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

mod = int(10 ** 9 + 7)

for i in range(1, k + 1):
    if i > n - k + 1:
        print(0)
    else:
        print(int(np.ceil(comb(k - 1, i - 1))) * int(np.ceil(comb(n - k + 1, i))) % mod)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from scipy.misc import comb

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

mod = int(10 ** 9 + 7)

for i in range(1, k + 1):
    if i > n - k + 1:
        print(0)
    else:
        print(int(comb(k - 1, i - 1)) * int(comb(n - k + 1, i)) % mod)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from scipy.misc import comb

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

mod = int(10 ** 9 + 7)

for i in range(1, k + 1):
    if i > n - k + 1:
        print(0)
    else:
        print(comb(k - 1, i - 1) * comb(n - k + 1, i) % mod)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n, k = map(int, input().split())

divisor = int(10 ** 9 + 7)

max_degree = max(n - k + 1, k - 1)
fact = [1 for _ in range(max_degree + 1)]
for i in range(1, max_degree + 1):
    fact[i] = fact[i - 1] * i


def calc_combination(n, k):
    if k == 0:
        return 1
    div = fact[k] * fact[n - k]
    return fact[n] // div


for i in range(1, k + 1):
    red_patterns = calc_combination(n - k + 1, i)
    if red_patterns > divisor:
        red_patterns %= divisor
    blue_patterns = calc_combination(k - 1, i - 1)
    if blue_patterns > divisor:
        blue_patterns %= divisor

    ans = red_patterns * blue_patterns
    if ans > divisor:
        ans %= divisor

    print(ans)
Problem p03077 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
import numpy as np

def get_num():
    return int(input())


def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


def get_numbers():
    return map(int, input().split())


n = get_num()
costs = get_nums(5)

max_time = 0
for cost in costs:
    max_time = max(max_time, int(np.ceil(n / cost)))

print(max_time + 4)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
import numpy as np

def get_num():
    return int(input())


def get_nums(n):
    res = [0 for _ in range(n)]
    for i in range(n):
        res[i] = int(input())
    return res


def get_numbers():
    return map(int, input().split())


n = get_num()
costs = get_nums(5)

max_time = 0
for cost in costs:
    max_time = max(max_time, int(np.ceil(n / cost)))

print(max_time + 4)
Problem p03104 (python)

Fixed submission:
# -*- coding: utf-8 -*-
def get_numbers():
    return map(int, input().split())


def xor(n):
    if n % 4 == 3:
        return 0
    if n % 4 == 0:
        return n
    if n % 4 == 1:
        return 1
    if n % 4 == 2:
        return 1 ^ n


a, b = get_numbers()
print(xor(a - 1) ^ xor(b))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def get_numbers():
    return map(int, input().split())

a, b = get_numbers()
if a % 2 == 1:
    ans = a
    numbers = list(range(a + 1, b + 1))
else:
    ans = 0
    numbers = list(range(a, b + 1))

mod = len(numbers) % 4


if mod == 0:
    print(ans ^ 0)
elif mod == 1:
    print(ans ^ 0 ^ b)
elif mod == 2:
    print(ans ^ 1)
elif mod == 3:
    print(ans ^ 1 ^ b)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def get_numbers():
    return map(int, input().split())

a, b = get_numbers()
if a % 2 == 1:
    ans = a
    numbers = list(range(a + 1, b + 1))
else:
    ans = 0
    numbers = list(range(a, b + 1))

mod = len(numbers) % 4


if mod == 0:
    print(ans ^ 0)
elif mod == 1:
    print(ans ^ 0 ^ b)
elif mod == 2:
    print(ans ^ 1)
elif mod == 3:
    print(ans ^ 1 ^ b)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def get_numbers():
    return map(int, input().split())

a, b = get_numbers()
if a % 2 == 1:
    ans = a
    numbers = list(range(a + 1, b + 1))
else:
    ans = 0
    numbers = list(range(a, b + 1))

mod = len(numbers) % 4


if mod == 0:
    print(ans ^ 0)
elif mod == 1:
    print(ans ^ 0 ^ b)
elif mod == 2:
    print(ans ^ 1)
elif mod == 3:
    print(ans ^ 1 ^ b)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def get_numbers():
    return map(int, input().split())

a, b = get_numbers()
if a % 2 == 1:
    ans = a
    numbers = list(range(a + 1, b + 1))
else:
    ans = 0
    numbers = list(range(a, b + 1))

mod = len(numbers) % 4


if mod == 0:
    print(ans)
elif mod == 1:
    print(ans ^ b)
elif mod == 2:
    print(ans ^ 1)
elif mod == 3:
    print(ans ^ 1 ^ b)