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

Fixed submission:

n = int(input())
index = 2
result = 10**13
while index * index <= n:
    if n % index == 0:
        curr = (n // index) - 1
        curr += (index - 1)
        result = min(curr, result)
    index += 1
if result == 10**13:
    result = n - 1
print(result)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
index = 2
result = math.inf
while index * index <= n:
    if n % index == 0:
        curr = (n // index) - 1
        curr += (index - 1)
        result = min(curr, result)
    index += 1
if result == math.inf:
    result = n - 1
print(result)
Problem p03038 (python)

Fixed submission:
from heapq import *
n,m=map(int,input().split())
l=list(map(int,input().split()))
arr=[list(map(int,input().split())) for i in range(m)]
arr.sort(key=lambda x:x[1],reverse=True)
l.sort()
i=0
j=0
while(i<n):
    if(l[i]>=arr[j][1]):
        break
    l[i]=arr[j][1]
    arr[j][0]-=1
    if(arr[j][0]==0):
        j+=1
    if(j>=m):
        break
    i+=1
    #print(j,l)
#print(l)
print(sum(l))

Buggy submission (verdict: Runtime Error):
from heapq import *
n,m=map(int,input().split())
l=list(map(int,input().split()))
arr=[list(map(int,input().split())) for i in range(m)]
arr.sort(key=lambda x:x[1],reverse=True)
l.sort()
i=0
j=0
while(i<n):
    flag=False
    x=arr[j][0]
    k=0
    while(i<n and x>0 and arr[j][1]>l[i]):
        if(not flag):
            k=j+1
        l[i]=arr[j][1]
        x-=1
        i+=1
        flag=True
    j=k
    if(flag):
        continue
    else:
        i+=1
print(sum(l))
Problem p03041 (python)

Fixed submission:
n,k=map(int,input().split())
s=input()
k-=1
print(s[:k]+s[k:k+1].lower()+s[k+1:])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
k-=1
print(s[:k]+s[k:k+1].lower()+s[k+1])
Problem p03042 (python)

Fixed submission:
s = input()
first = int(s[0:2])
second = int(s[2:4])
if 1 <= first <= 12 and 1 <= second <= 12:
    print('AMBIGUOUS')
elif 1 <= first <= 12:
    print('MMYY')
elif 1 <= second <= 12:
    print('YYMM')
else:
    print('NA')

Buggy submission (verdict: Runtime Error):
l=input()
if((int(l[:2])>0 or int(l[2:])>0) and int(l[:2])<=12 and int(l[2:])<=12):
    print('AMBIGUOUS')
elif((int(l[:2])>0 or int(l[2:])>0) and int(l[2:])<=12 and int(l[:2])>=13):
    print("YYMM")
elif((int(l[:2])>0 or int(l[2:])>0) and int(l[2:]>=13) and int(l[:2])<=12):
    print("MMYY")
else:
    print('NA')

Buggy submission (verdict: Runtime Error):
l=input()
if(int(l[:2])>0 and int(l[2:])>0 and int(l[:2])<=12 and int(l[2:])<=12):
    print('AMBIGUOUS')
elif(int(l[:2])>0 and int(l[2:])>0 and int(l[2:])<=12 and int(l[:2])>=13):
    print("YYMM")
elif(int(l[:2])>0 and int(l[2:])>0 and int(l[2:]>=13) and int(l[:2])<=12):
    print("MMYY")
else:
    print('NA')

Buggy submission (verdict: Runtime Error):
l=input()
if(int(l[:2])>0 and int(l[2:])>0 and int(l[:2])<=12 and int(l[2:])<=12):
    print('AMBIGUOUS')
elif(int(l[:2])>0 and int(l[2:])>0 and int(l[:2])<=12 and int(l[2:])>=13):
    print("YYMM")
elif(int(l[:2])>0 and int(l[2:])>0 and int(l[:2>=13]) and int(l[2:])<=12):
    print("MMYY")
else:
    print('NA')
Problem p03221 (python)

Fixed submission:
import bisect
n,p=map(int,input().split())
arr=[]
arr1=[[] for i in range(100001)]
for i in range(p):
    arr.append(list(map(int,input().split())))
    arr1[arr[i][0]].append(arr[i][1])
for i in range(100001):
    if(len(arr1[i])>1):
        arr1[i].sort()
for i in range(p):
    print("%06d%06d"%(arr[i][0],bisect.bisect_right(arr1[arr[i][0]],arr[i][1])))
    #print("%06d%06d"%(arr[i][0],arr1[arr[i][0]].index(arr[i][1])+1))

Buggy submission (verdict: Runtime Error):
n,p=map(int,input().split())
arr=[]
arr1=[[] for i in range(10000)]
for i in range(p):
    arr.append(list(map(int,input().split())))
    arr1[arr[i][0]].append(arr[i][1])
for i in range(10000):
    arr1[i].sort()
for i in range(p):
    print("%06d%06d"%(arr[i][0],arr1[arr[i][0]].index(arr[i][1])+1))
Problem p02661 (python)

Fixed submission:
n = int(input())
A = []
B = []
for i in range(n):
  a,b = list(map(int, input().split()))
  A.append(a)
  B.append(b)
A.sort()
B.sort()
j = n//2
if n%2 == 0:
  print((B[j]+B[j-1])-(A[j]+A[j-1])+1)
else:
  print(B[j]-A[j]+1)

Buggy submission (verdict: Runtime Error):
n = input()
A = []
B = []
for i in range(n):
  a,b = map(int, input().split())
  A.append(a)
  B.append(b)
A.sort()
B.sort()
j = n//2
if n%2 == 0:
  print((B[j]+B[j+1])-(A[j]+A[j+1])+1)
else:
  print(B[j]-A[j]+1)
Problem p02970 (python)

Fixed submission:
import math

n, d = list(map(int, input().split()))

print(math.ceil(n / (1+2*d)))

Buggy submission (verdict: Runtime Error):
import math

n,d=list(map(int(input().split()))
         
print (math.ceil(n/1+2*d))
Problem p02948 (python)

Fixed submission:
from heapq import *
n, m = map(int, input().split())
pay = []
for _ in range(n):
    a, b = map(int, input().split())
    pay.append((a, b))
pay = sorted(pay, reverse=True)
q = []
ans = 0
for i in range(1, m+1):
    while pay and pay[-1][0] <= i:
        a, b = pay.pop()
        heappush(q, -b)
    if q:
        b = -heappop(q)
        ans += b
print(ans)

Buggy submission (verdict: Runtime Error):
from heapq import *
n, m = map(int, input().split())
pay = []
for _ in range(n):
    a, b = map(int, input().split())
    pay.append((a, b))
pay = sorted(pay, reverse=True)
print(pay)
q = []
ans = 0
for i in range(1, m+1):
    while pay and pay[-1][0] <= i:
        a, b = pay.pop()
        heappush(q, -b)
    print(q)
    if q:
        b = -heappop(q)
        ans += b
print(ans)
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())

if S <= W:
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
S, W = int(inpit())

if S <= W:
    print('unsafe')
else S > W:
    print('safe')

Buggy submission (verdict: Runtime Error):
S, W = int(input())

if S <= W:
    print('unsafe')
    elif S > W
    print('safe')

Buggy submission (verdict: Runtime Error):
S, W = int(inpit())

if S <= W:
    print('unsafe')
    elif S > W
    print('safe')
Problem p02682 (python)

Fixed submission:
a, b, c, k=input().split()
a=int(a)
b=int(b)
c=int(c)
k=int(k)
ans=0

if a>0 and k>0 and a<=k:
  k=k-a
  ans=ans+a
elif a>0 and k>0 and a>k:
  ans=ans+k
  k=0

if b>0 and k>0 and b<=k:
  k=k-b
elif b>0 and k>0 and b>k:
  k=0
  
if c>0 and k>0 and c<=k:
  k=k-c
  ans=ans-c
elif c>0 and c>0 and c>k:
  ans=ans-k
  k=0

  
print(ans)

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

if a>0 and k>0 and a<=k:
  k=k-a
  ans=ans+a
elif a>0 and k>0 and a>k:
  ans=ans+k
   k=0

while b>0 and k>0:
  b+=-1
  k+=-1

while c>0 and k>0:
  ans+=-1
  c+=-1
  k+=-1
  
print(ans)
Problem p02682 (python)

Fixed submission:
#ABC167
A,B,C,K=map(int,input().split())
#----------以上入力----------
if A > K:
    print(K)
elif  A+B >= K:
    print(A)
else:
    print(A-(K-A-B))

Buggy submission (verdict: Runtime Error):
A = int(input('A = '))
B = int(input('B = '))
C = int(input('C = '))
K = int(input('Selected number = '))
#----------以上入力----------
if A+B >= K:
    print(A)
else:
    print(A-(K-A-B))
Problem p02689 (python)

Fixed submission:
#ABC166
N,M=map(int,input().split())
H =list(map(int,input().split()))  #展望台の標高
A = list(range(1,N+1))
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        A[b-1] = 0
    elif H[a-1] < H[b-1]:
        A[a-1] = 0
    else:
        A[a-1] = 0
        A[b-1] = 0
print(N-A.count(0))

Buggy submission (verdict: Runtime Error):
#ABC166
N,M=map(int,input().split())
H =list(map(int,input().split()))  #展望台の標高
A = list(range(1,N+1))
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        A[b] = 0
    elif H[a-1] < H[b-1]:
        A[a] = 0
    else:
        A[a] = 0
        A[b] = 0
print(N-A.count(0))

Buggy submission (verdict: Runtime Error):
#ABC166
N,M=map(int,input().split())
H =list(map(int,input().split()))  #展望台の標高
A = list(range(N))
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1] > H[b-1]:
        A[b-1] = 0
    elif H[a-1] < H[b-1]:
        A[a-1] = 0
    else:
        A[a-1] = 0 and A[b-1] = 0

print(N-A.count(0))

Buggy submission (verdict: Runtime Error):
#ABC166
N,M=map(int,input().split())
H =list(map(int,input().split()))  #展望台の標高
A = list(range(M))
for i in range(M):
    a, b = map(int, input().split())
    if H[a-1]>H[b-1]:
        A[b-1] = 0
    elif H[a-1]<H[b-1]:
        A[a-1] = 0
    else:
        A[a-1] = 0
        A[b-1] = 0

print(N-A.count(0))
Problem p02759 (python)

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

Buggy submission (verdict: Runtime Error):
n = input()
if n % 2 == 0:
  print(n / 2)
else:
  print((n + 1) / 2)
Problem p02754 (python)

Fixed submission:
n, a, b = list(map(int, input().split(' ')))
blueBall = 0
answer = []

if a == 0:
    print(a)
else:
    if n / (a + b):
        answer = divmod(n, (a + b))
        blueBall = answer[0] * a
        if answer[1] > a:
            blueBall = blueBall + a
        else:
            blueBall = blueBall + answer[1]

        print(blueBall)
    else:
        if n <= a:
            print(n)
        elif n <= b:
            print(a)

Buggy submission (verdict: Runtime Error):
n, a, b = list(map(int, input().split(' ')))
ab = ''

for i in range(n):
    ab = ab + ('a' * a) + ('b' * b)
    if len(ab) == 0:
        break

print(ab[:n].count('a'))

Buggy submission (verdict: Runtime Error):
n, a, b = list(map(int, input().split(' ')))
ab = ''

while len(ab) <= n:
    ab = ab + ('a' * a) + ('b' * b)
    if len(ab) == 0:
        break

print(ab[:n].count('a'))

Buggy submission (verdict: Runtime Error):
n, a, b = list(map(int, input().split(' ')))
ab = ''

while len(ab) < n:
    ab = ab + ('a' * a) + ('b' * b)
    if len(ab) == 0:
        break

print(ab[:n].count('a'))

Buggy submission (verdict: Runtime Error):
n, a, b = list(map(int, input().split(' ')))
ab = ''

while len(ab) < n and a + b != 0:
    ab = ab + ('a' * a) + ('b' * b)

print(ab[:n].count('a'))

Buggy submission (verdict: Runtime Error):
n, a, b = list(map(int, input().split(' ')))
ab = ''

while len(ab) < n and a + b != 0 :
    ab = ab + ('a' * a) + ('b' * b)

print(ab[:n].count('a'))

Buggy submission (verdict: Runtime Error):
n, a, b = list(map(int, input().split(' ')))
ab = ''

while len(ab) < n:
    ab = ab + ('a' * a) + ('b' * b)

print(ab[:n].count('a'))
Problem p02766 (python)

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


# 再帰処理：関数の中でその関数自身が呼び出されること。→ 繰り返し処理の実装が可能
def conversion(_n, _m):
    if int(_n / _m):
        return conversion(int(_n / _m), _m) + str(_n % _m)
    return str(_n % _m)


digit = (conversion(n, m))
print(len(digit))

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


# 再帰処理：関数の中でその関数自身が呼び出されること。→ 繰り返し処理の実装が可能
def conversion(_n, _m):
    if int(_n / _m):
        return conversion(int(_n / _m), _m) + str(_n % _m)
    return str(_n % _m)


print(conversion(n, m))
Problem p02753 (python)

Fixed submission:
S = input()
if S == 'AAA' or S == 'BBB':
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
S = int(input())
if S == 'AAA' or S == 'BBB':
    print('No')
else:
    print('Yes')
Problem p02754 (python)

Fixed submission:
inputarray = input().split(' ')
N = int(inputarray[0])
A = int(inputarray[1])
B = int(inputarray[2])
blue = 'b'
red = 'r'
amari = N % (A+B)
if A >= amari: 
    countnum = N // (A+B) * A +amari
else:
    countnum = N // (A+B) * A +A
print(countnum)

Buggy submission (verdict: Runtime Error):
inputarray = input().split(' ')
N = int(inputarray[0])
A = int(inputarray[1])
B = int(inputarray[2])
blue = 'b'
red = 'r'
ballcolumn = ''
for i in range(round(N/(A+B))+1):
    ballcolumn+=blue*A
    ballcolumn+=red*B
targetstring = ballcolumn[:N]
print(targetstring.count('b'))

Buggy submission (verdict: Runtime Error):
inputarray = input().split(' ')
N = int(inputarray[0])
A = int(inputarray[1])
B = int(inputarray[2])
blue = 'b'
red = 'r'
ballcolumn = ''
for i in range(10**100):
    ballcolumn+=blue*A
    ballcolumn+=red*B
targetstring = ballcolumn[:N]
print(targetstring.count('b'))

Buggy submission (verdict: Runtime Error):
inputarray = input().split(' ')
N = int(inputarray[0])
A = int(inputarray[1])
B = int(inputarray[2])
blue = 'b'
red = 'r'
ballcolumn = ''
for i in range(10):
    ballcolumn+=blue*A
    ballcolumn+=red*B
targetstring = ballcolumn[:N]
print(targetstring.count('b'))
Problem p02759 (python)

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

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input().split(' '))
num = 0
if A == B == C:
    print(-1)
elif A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        A_c = A
        B_c = B
        C_c = C
        A = B_c /2 + C_c / 2
        B = A_c / 2 + C_c /2
        C = A_c /2 + B_c / 2
        num += 1
    print(num)
else:
    print(0)

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

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

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

Buggy submission (verdict: Runtime Error):
if N%2 == 0:
  print(int(N/2))
else:
  print(int(round(N/2)))

Buggy submission (verdict: Runtime Error):
if N%2 == 0:
  print(int(N/2))
else:
  print(int(round(N/2)))

Buggy submission (verdict: Runtime Error):
N=101
if N%2 == 0:
  print(int(N/2))
else:
  print(int(round(N/2))

Buggy submission (verdict: Runtime Error):
if N%2 == 0:
  print(N/2)
else:
  print(math.ceil(N/2))

Buggy submission (verdict: Runtime Error):
if N%2 == 0:
  print(N/2)
else:
  print(ceil(N/2))
Problem p03345 (python)

Fixed submission:
a,b,c,k = map(int, input().split())
cheak = 10**18
ans = a-b
def calc(a,b,c,k):
    if a == b:
        return 0
    elif ans < 0:
        if k % 2 == 1:
            return -ans
        else:
            return ans
    else:
        if k % 2 == 1:
            return -ans
        else:
            return ans
ans_n = calc(a,b,c,k)
if ans_n > cheak:
    print("Unfair")
else:
    print(ans_n)

Buggy submission (verdict: Runtime Error):
A,B,C,K = map(int,input().split())
N = [A,B,C]
N2 = N[:]
for i in range(K):
    N2[0] = N[1] + N[2]
    N2[1] = N[0] + N[2]
    N2[2] = N[0] + N[1]
    N = N2.copy
ans = N2[0] - N2[1]
if abs(ans) > 10**18:
    print('Unfair')
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
A,B,C,K = map(int,input().split())
N = [A,B,C]
N2 = N[:]
for i in range(K):
    N2[0] = N[1] + N[2]
    N2[1] = N[0] + N[2]
    N2[2] = N[0] + N[1]
    N = N2.copy
print(N2)
ans = N2[0] - N2[1]
if abs(ans) > 10**18:
    print('Unfair')
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N = list(map(int,input().split()))
N2 = N[:-1]
for i in range(N[3]):
    N2[0] = N[1] + N[2]
    N2[1] = N[0] + N[2]
    N2[2] = N[0] + N[1]
    N = N2.copy
ans = N2[0] - N2[1]
if abs(ans) > 10**18:
    print('Unfair')
else:
    print(ans)
Problem p04005 (python)

Fixed submission:
A,B,C = map(int,input().split(' '))
num_list = [A,B,C]
list_s = sorted(num_list)
if A % 2 == 1 and B % 2 == 1 and C % 2 == 1:
    print(list_s[0]*list_s[1])
else:
    print(0)

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input())
num_list = [A,B,C]
list_s = sorted(num_list)
if A % 2 == 1 and B % 2 == 1 and C % 2 == 1:
    print(list_s[0]*list_s[1])
else:
    print(0)

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input())
num_list = [A,B,C]
 list_s = sorted(num_list)
if A % 2 == 1 and B % 2 == 1 and C % 2 == 1:
    print(list_s[0]*list_s[1])
else:
    print(0)
Problem p02729 (python)

Fixed submission:
from scipy.misc import comb
n, m = map(int, input().split())
# nC2+mC2を求めればよい
print(comb(n, 2, exact=True) + comb(m, 2, exact=True))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n, m = map(int, input().split())
# nC2+mC2を求めればよい
print(comb(n, 2, exact=True) + comb(m, 2, exact=True))
Problem p03186 (python)

Fixed submission:
def abg(a,b,c):
    if c>a+b:
        return a+2*b+1
    else:
        return b+c
a,b,c=map(int,input().split())
print(abg(a,b,c))

Buggy submission (verdict: Runtime Error):
l,n=map(int,input().split())
x_lst=[int(input())for i in range(n)]
ans=0
a=0
while len(x_lst):
    if x_lst[0]>l-x_lst[-1]:
        a=x_lst.pop(0)
        ans+=a
        x_lst=list(map(lambda x:x-a,x_lst))
    else:
        a=x_lst.pop(-1)
        ans+=l-a
        x_lst=list(map(lambda x:[x+l-a,x-a][x>=a],x_lst))
print(ans)
Problem p03242 (python)

Fixed submission:
print(input().replace("1","a").replace("9","1").replace("a","9"))

Buggy submission (verdict: Runtime Error):
def main(n:int,lst:list)->int:
    b = True
    lst1 = []
    lst2 = []
    for e in lst:
        if b:
            lst1.append(e)
        else:
            lst2.append(e)
        b = not b
    lst1.sort()
    lst2.sort()
    c1 = [["",0],0]
    c2 = [["",0],0]
    last =lst1[0]
    a = 0
    for e in lst1:
        if last == e:
            a +=1
        else:
            if a >= c1[0][1]:
                c1[1] = c1[0][1]
                c1[0][0] = e
                c1[0][1] = a
            elif a > c1[1]:
                c1[1] = a
            last = e
            a = 1
    if a >= c1[0][1]:
        c1[1] = c1[0][1]
        c1[0][0] = e
        c1[0][1] = a
    elif a > c1[1]:
        c1[1] = a

    last =lst2[0]
    a = 0
    for e in lst2:
        if last == e:
            a +=1
        else:
            if a >= c2[0][1]:
                c2[1] = c2[0][1]
                c2[0][0] = e
                c2[0][1] = a
            elif a > c2[1]:
                c2[1] = a
            last = e
            a = 1
    if a >= c2[0][1]:
        c2[1] = c2[0][1]
        c2[0][0] = e
        c2[0][1] = a
    elif a > c2[1]:
        c2[1] = a

    if c1[0][0] == c2[0][0]:
        if c1[0][1] > c2[0][1] or(c1[0][1] == c2[0][1] and c2[1] > c1[1]):
            return n - c1[0][1] - c2[1]
        else:
            return n - c2[0][1] - c1[1]
    else:
        return n - c1[0][1] - c2[0][1]

n = int(input())
lst = input().split()
print(main(n,lst))

Buggy submission (verdict: Runtime Error):
import collections
def main(n:int,lst:list)->int:
    b = True
    lst1 = []
    lst2 = []
    for e in lst:
        if b:
            lst1.append(e)
        else:
            lst2.append(e)
        b = not b
    c1 = collections.Counter(lst1).most_common()
    c2 = collections.Counter(lst2).most_common()
    if c1[0][0] == c2[0][0]:
        if c1[0][1] > c2[0][1]:
            if len(c2) == 1:
                return n - c1[0][1]
            else:
                return n - c1[0][1] - c2[1][1]
        else:
            if len(c1) == 1:
                return n - c2[0][1]
            else:
                return n - c2[0][1] - c1[1][1]
    else:
        return n - c1[0][1] - c2[0][1]

n = int(input())
lst = list(map(int,input().split()))
print(main(n,lst))
Problem p03272 (python)

Fixed submission:
N,i=map(int,input().split())
print(N-i+1)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
lst=list(input() for i in range(h))
n_h=h
for i in range(len(lst)):
    if "#" not in lst[h-i-1]:
        n_h-=1
        lst.pop(h-i-1)
lst=list(map(list,lst))
for i in range(w):
    T=True
    for b in range(n_h):
        if lst[b][w-i-1]=="#":
            T=False
            break
    if T:
        for b in range(h):
            lst[b].pop(w-i-1)
for a in lst:
    print("".join(a))
Problem p03327 (python)

Fixed submission:
print("AB"+["D","C"][len(input())<4])

Buggy submission (verdict: Runtime Error):
print("AB"+["C","D"][len(input()<4)])
Problem p03776 (python)

Fixed submission:
import math
N,A,B=map(int,input().split())
lst=list(map(int,input().split()))
lst.sort()
a=lst[-A:]
print(sum(a)/A)
b=lst.count(a[0])
c=a.count(a[0])
if c!=A:
    print(int(math.factorial(b)/(math.factorial(c)*math.factorial(b-c))))
else:
    l=[]
    i=min([b-c,B-A])
    for k in range(0,i+1):
        l.append(math.factorial(b)/(math.factorial(c+k)*math.factorial(b-c-k)))
    print(int(sum(l)))

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,input().split())
lst=list(map(int,input().split()))
lst.sort()
a=lst[-A:]
print(sum(a)/A)
b=lst.count(a[0])
c=lst.count(a[0])
print(b!/(c!*(b-c)!))
Problem p02984 (python)

Fixed submission:
n = int(input())
dam = list(map(int,input().split()))
mountain =[0]*n
all_water = sum(dam)
def dam_water(num):
  sum_dam = 0
  for i in range(num,n,2):
    sum_dam += dam[i]
  return sum_dam

mountain[0] = all_water - 2 * (dam_water(1))

for i in range(1,n):
  mountain[i] = 2*dam[i-1] - mountain[i-1]

print(" ".join(map(str,mountain)))

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

n = int(input())
a = list(map(int,input().split()))
b = [1 for i in range(n)]
c = [1 for i in range(n-1)]
left = np.diag(b) + np.diag(c,k=1)
left[n-1][0] +=1
g = np.linalg.inv(left)
aa = np.dot(g,a)
aa = [int(aa[i]*2) for i in range(n)]

print(' '.join(map(str, aa)))

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

n = int(input())
a = list(map(int,input().split()))
b = [1 for i in range(n)]
c = [1 for i in range(n-1)]
left = np.diag(b) + np.diag(c,k=1)
left[n-1][0] +=1
tmparr = np.linalg.solve(left, a)
tmparr = [int(tmparr[i]*2) for i in range(n)]

print(' '.join(map(str, tmparr)))

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

left = np.zeros((n, n))

for i in range(n):
  left[i][i] +=1
  if i == n-1:
    left[i][0] += 1
  else:
    left[i][i+1] +=1

tmparr = solve(left, a)

tmparr = [int(tmparr[i]*2) for i in range(n)]

print(' '.join(map(str, tmparr)))
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
a = [int(input()) for i in range(m)]
dp=[0]*(n+1)
if m==0:
  for i in range(n,-1,-1):
    if i==n or i==n-1:
      dp[i]=1
    else:
      dp[i]=dp[i+1]+dp[i+2]
  print(dp[0]%1000000007)
else:
  j=-1
  for i in range(n,-1,-1):
    if i==a[j]:
      if m>j*(-1):
        j-=1
    else:
      if i==n or i==n-1:
        dp[i]=1
      else:
        dp[i]=dp[i+1]+dp[i+2]
  print(dp[0]%1000000007)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a = [int(input()) for i in range(m)]
dp=[0]*(n+1)
j=-1
for i in range(n,-1,-1):
  if i==a[j]:
    if m>j*(-1):
      j-=1
  else:
    if i==n or i==n-1:
      dp[i]=1
    else:
      dp[i]=dp[i+1]+dp[i+2]
print(dp[0]%1000000007)
Problem p02759 (python)

Fixed submission:
N= int(input())

count = 0

if N % 2 == 0:
    print(int(N/2))
else:
    print(int(N/2) + 1)

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

sclist = []
for count in range(M):
    d = list(map(int,input().split()))
    sclist.append(d)

flag = False;
for count in range(10**(N-1),10**(N)):
    flag = False
    for count1 in range(M):
        s = sclist[count1][0]
        c = sclist[count1][1]
        if str(count)[s-1] == str(c):
            flag = True
        else:
            flag = False
            break
    if flag == True:
        print(count)
        break

if flag == False and M != 0:
    print(-1)
elif flag == False and M == 0:
    print(10**(N-1))

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

sclist = []
for count in range(M):
    d = list(map(int,input().split()))
    sclist.append(d)

flag = False;
for count in range(10**(N-1),10**(N)):
    flag = False
    for count1 in range(M):
        s = sclist[count1][0]
        c = sclist[count1][1]
        if str(count)[s-1] == str(c):
            flag = True
        else:
            flag = False
            break
    if flag == True:
        print(count)
        break

if flag == False and M != 0:
    print(-1)
elif flag == False and M == 0:
    print((N-1)** 10)