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

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

A.sort(reverse=True)
print(sum(A[K:]))

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

if n == k:
    sum = 0
else:
    h.sort(reverse=True)
    sum = 0
    hh = h[k: n - k + 1]
    for i in range(n-k):
        sum += int(hh[i])

print(str(sum))

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

if n == k:
    sum = 0
else:
    h.sort(reverse=True)
    sum = 0
    hh = h[k: n - k + 1]
    for i in range(n-k):
        sum += int(hh[i])

print(str(sum))

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

h.sort(reverse=True)
sum = 0
hh = h[k: n - k + 1]
for i in range(n-k):
    sum += int(hh[i])

print(str(sum))

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

h.sort(reverse=True)
sum = 0
hh = h[k: n - k + 1]
for i in range(n-k):
    sum += int(hh[i])

print(str(sum))
Problem p02578 (python)

Fixed submission:
N=int(input())
a_list = list(map(int,input().split()))
ans = 0
min = a_list[0]
for i in range(1,N):
  if min > a_list[i]:
    ans += min-a_list[i]
  else:
    min = a_list[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
a_list = list(map(int,input().split()))
ans = 0
min = a_list[0]
for i in range(1,N+1):
  if min > a_list[i]:
    ans += a_list[i]-min
  else:
    min = a_list[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
a_list = list(map(int,input().split()))
ans = 0
min = a_list[0]
for i in range(1,N):
  if min > a_list[i]:
    ans += a_list[i]-m
  else:
    min = a_list[i]
print(ans)
Problem p02771 (python)

Fixed submission:
num=list(map(int,input().split()))
print('Yes' if len(num) == len(set(num))+1 else 'No')

Buggy submission (verdict: Runtime Error):
num=list(map(int,input().split()))
print('Yes' if len(num) == len(set(num) + 1) else 'No')
Problem p03013 (python)

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

step=[0]*(n+1)
for _ in range(m):
    a=int(input())
    step[a-1]=-1

if step[0]!=-1:
    step[0]=1
if step[1]!=-1:
    step[1]=1
for i in range(n-1):
    if step[i]==-1:
        continue
    if step[i+1]!=-1:
        step[i+1]+=step[i]
    if step[i+2]!=-1:
        step[i+2]+=step[i]
print(step[n-1]%c_mod)

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

step=[0]*n
for _ in range(m):
    a=int(input())
    step[a-1]=-1

if step[0]!=-1:
    step[0]=1
if step[1]!=-1:
    step[1]=1
for i in range(2,n):
    if step[i]==-1:
        continue
    if step[i-1]!=-1:
        step[i]+=step[i-1]
    if step[i-2]!=-1:
        step[i]+=step[i-2]
print(step[n-1]%c_mod)

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

step=[0]*n
for _ in range(m):
    a=int(input())
    step[a-1]=-1

if step[0]!=-1:
    step[0]=1
if step[1]!=-1:
    step[1]=1
for i in range(n):
    if step[i]==-1:
        continue
    if step[i-1]!=-1:
        step[i]+=step[i-1]
    if step[i-2]!=-1:
        step[i]+=step[i-2]
print(step[n-1]%c_mod)
Problem p03775 (python)

Fixed submission:
n=int(input())
ans=len(str(n))
for i in range(1, int(n**0.5)+1):
    if n % i != 0:
        continue
    a=i
    b=i
    if i != n // i:
        b=n//i
    ans=min(ans,len(str(max(a,b))))
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=len(str(n))
for i in range(1, int(n**0.5)+1):
    if n % i != 0:
        continue
    a=i
    if i != n // i:
        b=n//i
    ans=min(ans,len(str(max(a,b))))
print(ans)
Problem p02577 (python)

Fixed submission:
N = int(input())

N_letter = str(N)
M = (len(N_letter))
S = 0
for i in range(M):
	S = S + int(N_letter[i])

if (S/9) ==  int(S/9):
	print("Yes")
else:
	print("No")

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

SUM_N = sum(N_letter)
if (SUM_N/9) ==  int(SUM_N/9):
	print("Yes")
else:
	print("No")

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

SUM_N = sum(N_letter)
if int(SUM_N/9) =  isinstance(i, int):
	print("Yes")
elseif:
	print("No")
Problem p02833 (python)

Fixed submission:
import numpy as np
N = int(input())
n2 = N % 2
if n2 != 0:
  ans = 0
elif N <= 2:
  ans =0
else:
  a = int(np.log(N) // np.log(5))
  A = [N // (2 * (5 ** (i + 1))) for i in range(a)]
  ans = np.sum(A)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
n2 = N % 2
if n2 != 0:
  ans = 0
else:
  F = list(range(2, N+1, 2))
  a5 = int(np.log(N) // np.log(5))
  B = []
  for i in range(a5):
    a=2 * (5 ** (i+1))
    b = [f for f in F if f % a == 0]
    B.append(len(b))
  ans = np.sum(B)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
n = N % 2
if n == 1:
  ans = 0
else:
  AB = list(range(N, 1, -2))
  a = int(np.log(N) / np.log(5))
  ab = []
  for i in range(a):
    a5 = 2 * 5 ** (i + 1)
    for Ab in AB:
      if Ab % a5 == 0:
        ab.append(Ab)
  ans = np.sum(ab)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
n = N % 2
if n == 1:
  ans = 0
else:
  AB = list(range(N, 1, -2))
  AB = [ab for ab in AB if ab % 10 == 0]
  AB = [np.log10(ab) for ab in AB]
  AB = [int(ab) for ab in AB]
  ans = np.sum(AB)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
n = N % 2
if n == 1:
  ans = 0
else:
  AB = list(range(N, 1, -2))
  AB = [len(str(ab)) - 1 for ab in AB if ab % 10 ==0]
  ans = np.sum(AB)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
n = N % 2
if n == 1:
  ans = 0
else:
  AB = [N]
  for i in range(N // 2 -1):
    ab = AB[-1] - 2
    AB.append(ab)
  AB = [int(np.log10(ab)) for ab in AB if ab % 10 ==0]
  ans = np.sum(AB)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
if N < 2:
  Ans = 1
else:
  n = N % 2
  AB = [N]
  if n == 0:
    ni = N //2 -1
  else:
    ni = N //2
  for i in range(ni):
    ab = AB[-1] - 2
    AB.append(ab)
  Ans = str(np.prod(AB))
Ans = list(reversed(Ans))
ans = []
for i in range(len(Ans)):
  if Ans[i] == '0':
    ans.append(i)
  else:
    break
print(len(ans))
Problem p02847 (python)

Fixed submission:
S = str(input())
Week = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
for i, day in enumerate(Week):
  if day == S:
    until = 7 - i
    print(until)
  else:
    pass

Buggy submission (verdict: Runtime Error):
[A, B, X] = list(map(int, input().split()))
keta = list(range(1, 17, 1))
retun_N = []
for d in keta:
  max_x = (X - B * d) / A
  max_x = int(max_x)
  max_ket = len(str(max_x))
  if max_ket == d:
    retun_N.append(max_x)
if len(retun_N) != 0:
  print(retun_N[-1])
else:
  print("0")
Problem p02881 (python)

Fixed submission:
import math
N = int(input())
n = int(math.sqrt(N))
divisor = [i for i in range(1, n + 1) if N % i == 0]
XY = [div + N // div - 2 for div in divisor]
print(min(XY))

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
n = int(math.sqrt(N))
divisor = [i for i in range(1, n) if N % i == 0]
XY = [div + N // div - 2 for div in divisor]
print(min(XY))

Buggy submission (verdict: Runtime Error):
N = int(input())
divisor = [i for i in range(2, N // 2 + 1) if N % i == 0]
XY = [div + N // div - 2 for div in divisor]
print(min(D))
Problem p03013 (python)

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

a = [-1]
for i in range(m):
    a.append(int(input()))
a.append(n+1)
m += 1

ans = 1
for i in range(m):
    if a[i+1]-a[i]-1 == 0:
        ans = 0
        break
    elif a[i+1]-a[i]-1 == 1:
        continue
    else:
        dp = [1] + [0]*(a[i+1]-a[i]-2)
    for j in range(1, a[i+1]-a[i]-1):
        dp[j] = dp[j-1] + dp[j-2]
    ans *= dp[-1]

print(ans%1000000007)

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

a = [-1]
for i in range(m):
    a.append(int(input()))
a.append(n+1)

m += 1
ans = 1
dp = []
for i in range(m):
    if a[i-1]-a[i]-1 == 0:
        ans = 0
        break
    elif a[i-1]-a[i]-1 == 1:
        continue
    else:
        dp.clear()
        dp = [1] + [0]*(a[i+1]-a[i]-2)
    for j in range(1, a[i+1]-a[i]-1):
        dp[j] = dp[j-1] + dp[j-2]
    ans *= dp[-1]

print(ans%1000000007)
Problem p03042 (python)

Fixed submission:
s = list( map( int, input() ) )

n1 = s[0]*10 + s[1]
n2 = s[2]*10 + s[3]

if n1 > 0 and n1 <=12:
    if n2 > 0 and n2 <= 12:
        ans = 'AMBIGUOUS'
    else:
        ans = 'MMYY'
else:
    if n2 > 0 and n2 <= 12:
        ans = 'YYMM'
    else:
        ans = 'NA'

print(ans)

Buggy submission (verdict: Runtime Error):
if (n1 == 0 or n2 == 0) or (n1 > 12 and n2 > 12):
    print('NA')
elif n1 <= 12:
    print('MMYY')
elif n2 <= 12:
    print('YYMM')
else:
    print('AMBIGUOUS')
Problem p02577 (python)

Fixed submission:
def sum_i(N):
    return sum(list(int(i) for i in str(N)))


print("No") if sum_i(input()) % 9 else print("Yes")

Buggy submission (verdict: Runtime Error):
map(input, N)
sum = lambda i :sum+i for i in str(N)
if sum/9 print "Yes" else "No"
Problem p02622 (python)

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

count=0
for idx, i in enumerate(s):
  if s[idx]!=t[idx]:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
import sys
readline= sys.stdin.buffer.readline

s, t = map(str,readline().split())

count=0
for idx, i in enumerate(s):
  if s[idx]!=t[idx]:
    count+=1
print(count)
Problem p03315 (python)

Fixed submission:
s=str(input())
count=0
for i in range(4):
  if s[i]=='+':
    count+=1;
  else:
    count-=1
print(count)

Buggy submission (verdict: Runtime Error):
s=str(input())
count=0
for i in range(s):
  if s[i]=='+':
    count+=1;
  else:
    count-=1
print(count)
Problem p03013 (python)

Fixed submission:
N, M = map(int,input().split())
a = list(int(input()) for i in range(M))
a.append(N+1)
a.insert(0,-1)
if a[0] == 0:
  print(0)
  exit()
#パターン数はフィボナッチ数列で通り数が増える
def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
#aとa+1の間の距離nに対して、フィボナッチ数列n+1番目数のパターンが有る
ans = 1
if M > 1:
    for i in range(len(a)-1):
        n = a[i+1]-a[i]-1
        if n == 0:
            print(0)
            exit()
        ans = ans*Fib(n)%1000000007
        i += 1
    print(ans)
elif M == 1:
    print(Fib(a[1])%1000000007 * Fib(N-a[1])%1000000007)
elif M == 0:
    print(Fib(N+1)%1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
a = list(int(input()) for i in range(M))
a.append(N+1)

if a[0] = 0:
  print(0)
  exit()
#パターン数はフィボナッチ数列で通り数が増える
def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
#aとa+1の間の距離nに対して、フィボナッチ数列n+1番目数のパターンが有る
ans = 1
if M > 1:
    for i in range(len(a)-1):
        n = a[i+1]-a[i]-1 #間の距離n
        if n == 0:
            print(0)
            exit()
        ans = ans*Fib(n+1)%1000000007
        i += 1
    print(ans)
elif M == 1:
    print(Fib(a[0])%1000000007 * Fib(N-a[0])%1000000007)
elif M == 0:
    print(Fib(N)%1000000007)
Problem p02578 (python)

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

sum = 0

for i in range(1, len(A)):
  if A[i] < A[i-1]:
    sum += A[i-1] - A[i]
    A[i] = A[i-1]
    
print(sum)

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

sum = 0

for i in range(1, len(A)):
  if A[i] < A[i-1]:
    sum += A[i-1] - A[i]
    A[i] = A[i-1]
    
print(sum)

Buggy submission (verdict: Runtime Error):
inputs = input().split()
N = int(inputs[0])
A = list(map(int, inputs[1:]))

sum = 0

for i in range(1, N):
  if A[i] < A[i-1]:
    sum += A[i-1] - A[i]
    A[i] = A[i-1]
    
print(sum)

Buggy submission (verdict: Runtime Error):
inputs = input().split()
N = int(inputs[0])
A = list(map(int, input[1:]))

sum = 0

for i in range(1, N):
  if A[i] < A[i-1]:
    sum += A[i-1] - A[i]
    A[i] = A[i-1]
    
print(sum)

Buggy submission (verdict: Runtime Error):
inputs = input().split()
N = int(inputs[0])
A = list(map(int, input[1:]))

sum = 0

for i in range(1:N):
  if A[i] < A[i-1]:
    sum += A[i-1] - A[i]
    A[i] = A[i-1]
    
print(sum)
Problem p02771 (python)

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

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

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

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

Buggy submission (verdict: Runtime Error):
a = map(int, raw_input().split())
if (a[0] == a[1]) and (a[0] != a[2]):
  print("Yes")

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

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

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

Buggy submission (verdict: Runtime Error):
a = map(int, raw_input().strip().split())
if a[0] == a[1] or a[0] == a[2] or a[2] == a[1]:
  if a[0] == a[1] and a[2] == a[1]:
    print("No")
  else:
    print("Yes")
else:
  print("No)
Problem p02773 (python)

Fixed submission:
n = int(input())
dict = {}
for i in range(n):
  a = input()
  if (not (a in dict.keys())):
    dict[a] = 1
  else:
    dict[a] += 1
b = max(dict.values())
list = []
for i in dict.keys():
  if dict[i] == b:
    list.append(i)
list.sort()
for i in list:
  print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
dict = {}
for i in range(n):
  a = input()
  if (not (a in list)):
    dict[a] = 0
  else:
    dict[a] += 1
b = max(dict.values())
for i in dict.keys():
  if dict[i] == b:
    print(i+"\n")
Problem p03135 (python)

Fixed submission:
t, x = map(float, input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
t, x = map(double, input().split())
print(t/x)
Problem p03137 (python)

Fixed submission:
n,m=input().split()
n=int(n)
m=int(m)
a = input().split()
for i in range(m):
  a[i]=int(a[i])
a.sort()
  
if n>=m :
  sum=0
else:
  b=[]
  sum=a[m-1]-a[0]
  for i in range(m-1):
    b+=[a[i+1]-a[i]]
  b.sort()
  b.reverse()
  for i in range(n-1):
    if b[i]>0:
      sum-=b[i]
    else:
      sum+=b[i]
print(sum)

Buggy submission (verdict: Runtime Error):
n,m=input().split()
n=int(n)
m=int(m)
a = input().split()
for i in range(m):
  a[i]=int(a[i])
  
if n>=m :
  sum=0
else:
  b=[]
  sum=0
  for i in range(m):
    b+=[a[i+1]-a[i]]
  b.sort().reverse()
  for i in range(N-1):
    sum+=b[i]
print(sum)
Problem p02729 (python)

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


def a1():
    if a[0] == 1 or a[0] == 0:
        a[0] = 0
        return a[0]
    else:
        return a[0] * (a[0] - 1) / 2


def b1():
    if a[1] == 1 or a[1] == 0:
        a[1] = 0
        return a[1]
    else:
        return a[1] * (a[1] - 1) / 2


print(int(a1() + b1()))

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


def a1():
    if a[0] == 1 or a[0] == 0:
        a[0] = 1
        return a[0]
    else:
        return a[0] * (a[0] - 1) / 2


def b1():
    if a[1] == 1 or a[1] == 0:
        a[1] = 1
        return a[1]
    else:
        return a[1] * (a[1] - 1) / 2


print(a() * b())

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split()))
if a[0] == 1 or a[0] == 0:
  a[0] = 1
  return a[0]
else: 
  return a[0]*(a[0] - 1)/2
if a[1] == 1 or a[1] == 0:
  a[1] = 1
  return a[1] 
else: 
  return a[1]*(a[1] - 1)/2
print(a[0]*a[1])

Buggy submission (verdict: Runtime Error):
a = list(map(int, input().split()))
if a[0] == 1:
  a[0] = 1
  return a[1]
else: 
  return a[0]*(a[0] - 1)
if a[1] == 1:
  a[1] = 1
  return a[1] 
else: 
  return a[1]*(a[1] - 1)
print(a[0]*a[1])
Problem p02759 (python)

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

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

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

Buggy submission (verdict: Runtime Error):
if int(input()) == 1:
    print(1)
elif int(input()) % 2 == 0:
    print(0.5)
else:
    print(0.6)
Problem p02781 (python)

Fixed submission:
N = input()
K = int(input())
dp= [[[0]*2 for i in range(len(N)+1)] for _ in range(len(N)+1)]
if len(N)<K:
  print(0)
  exit()
dp[0][0][0]=1
for i in range(len(N)):
  for j in range(len(N)):
    if int(N[i])!=0:
      dp[i+1][j+1][1]+=dp[i][j][1]*9+dp[i][j][0]*(int(N[i])-1)
      dp[i+1][j][1] += dp[i][j][1]+dp[i][j][0]
      dp[i+1][j+1][0] += dp[i][j][0] 
    if int(N[i])==0:
      dp[i+1][j+1][1] += dp[i][j][1]*9
      dp[i+1][j][1] += dp[i][j][1]
      dp[i+1][j][0] += dp[i][j][0]
print(dp[len(N)][K][0]+dp[len(N)][K][1])

Buggy submission (verdict: Runtime Error):
N = input()
K = int(input())
dp= [[[0]*2 for i in range(len(N)+1)] for _ in range(len(N)+1)]
dp[0][0][0]=1
for i in range(len(N)):
  for j in range(len(N)):
    if int(N[i])!=0:
      dp[i+1][j+1][1]+=dp[i][j][1]*9+dp[i][j][0]*(int(N[i])-1)
      dp[i+1][j][1] += dp[i][j][1]+dp[i][j][0]
      dp[i+1][j+1][0] += dp[i][j][0] 
    if int(N[i])==0:
      dp[i+1][j+1][1] += dp[i][j][1]*9
      dp[i+1][j][1] += dp[i][j][1]
      dp[i+1][j][0] += dp[i][j][0]
print(dp[len(N)][K][0]+dp[len(N)][K][1])

Buggy submission (verdict: Runtime Error):
N = input()
K = int(input())
dp= [[[0]*2 for i in range(len(N)+1)] for _ in range(len(N)+1)]
dp[0][0][0]=1
for i in range(len(N)):
  for j in range(len(N)):
    if int(N[i])!=0:
      dp[i+1][j+1][1]+=dp[i][j][1]*9+dp[i][j][0]*(int(N[i])-1)
      dp[i+1][j][1] += dp[i][j][1]+dp[i][j][0]
      dp[i+1][j+1][0] += dp[i][j][0] 
    if int(N[i])==0:
      dp[i+1][j+1][1] += dp[i][j][1]*9
      dp[i+1][j][1] += dp[i][j][1]
      dp[i+1][j][0] += dp[i][j][0]
print(dp[len(N)][K][0]+dp[len(N)][K][1])
Problem p02891 (python)

Fixed submission:
import sys
input = sys.stdin.readline
def inputs():
    return [int(x) for x in input().split()]
S = list(input())
N = int(input())
if len(S)==2:
  print(N//2)
  exit()
ans = 0
flag=0
if S[0]==S[-2]:
  cnt=1
  cntb=1
  for i in range(len(S)-2):
    if S[i]==S[i+1]:
      cnt+=1
    else:
      break
  for j in range(len(S)-2,0,-1):
    if S[j]==S[j-1]:
      cntb +=1
    else:
      break
  if cnt==cntb==len(S)-1 and cnt%2==1:
    S[0]="aaaaaa"
    ans+=1
    flag=2
  elif cntb%2!=0:
    if cnt%2==0:
      S[0]="aaa"
      ans+=1
    else:
      S[0]="aaa"
      ans+=1
      flag = 1
for i in range(len(S)-2):
    if S[i]==S[i+1]:
        ans +=1
        S[i+1]="aa"
if flag==0:
	print(ans*N)
elif flag==1:
  print(ans*(N-1)+ans-1)
else:
  print(ans*N-(N+2-1)//2)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def inputs():
    return [int(x) for x in input().split()]
S = list(input())
N = int(input())
ans = 0
flag=0
if S[0]==S[-2]:
  if S[-2]!=S[-3]:
    	flag = 1
  ans+=1
  S[-2]="aaaa"
for i in range(len(S)-2):
    if S[i]==S[i+1]:
        ans +=1
        S[i+1]="aa"
if flag==0:
	print(ans*N)
else:
  print(ans*N-1)
Problem p02951 (python)

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

Buggy submission (verdict: Runtime Error):
A,B,C=list(mao(int,input().split()))
print(max(0,C-(A-B)))
Problem p02984 (python)

Fixed submission:
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
r = np.array([0]*(N+1))
for i in range(N):
  r[i+1] = A[i]-r[i]
x = r[N]
#print(r)
r[1::2] = r[1::2]*2-x
r[0::2] = r[0::2]*2+x
r = r[:N]
r = list(map(str,r))
print(" ".join(r))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
r = [0]*(N+1)
for i in range(N):
  r[i+1] = A[i]-r[i]
x = r[N]
r[1::2] = r[1::,2]-x
r[0::2] = r[1::,2]+x
r = list(map(str,r))
print(" ".join(r))
Problem p02990 (python)

Fixed submission:
import math
N,K = [int(x) for x in input().split()]
inf = 10**9+7
for i in range(1,K+1):
  k = i-1
  kumi = math.factorial(K-i+k)//(math.factorial(K-i)*math.factorial(k))%inf
  a = math.factorial(N-K+1)
  b = math.factorial(i)
  if (N-K+1-i)<0:
    print(0)
    continue
  c = math.factorial(N-K+1-i)
  a = a//b
  a = a//c%inf
  ans = kumi*a
  print(int(ans%inf))

Buggy submission (verdict: Runtime Error):
import math
N,K = [int(x) for x in input().split()]
inf = 10**9+7
for i in range(1,K+1):
  k = i-1
  kumi = math.factorial(K-i+k)//(math.factorial(K-i)*math.factorial(k))%inf
  a = math.factorial(N-K+1)
  b = math.factorial(i)
  c = math.factorial(N-K+1-i)
  a = a//b
  a = a//c%inf
  ans = kumi*a
  print(int(ans%inf))

Buggy submission (verdict: Runtime Error):
import math
N,K = [int(x) for x in input().split()]
inf = 10**9+7
for i in range(1,K+1):
  k = i-1
  kumi = math.factorial(K-i+k)//(math.factorial(K-i)*math.factorial(k))%inf
  ans = kumi*math.factorial(N-K+1)//(math.factorial(i)*math.factorial(N-K+1-i))
  print(int(ans%inf))

Buggy submission (verdict: Runtime Error):
import math
N,K = [int(x) for x in input().split()]
inf = 10**9+7
for i in range(1,K+1):
  k = i-1
  kumi = math.factorial(K-i+k)//(math.factorial(K-i)*math.factorial(k))
  ans = kumi*math.factorial(N-K+1)//(math.factorial(i)*math.factorial(N-K+1-i))
  print(int(ans%inf))
Problem p03012 (python)

Fixed submission:
N = int(input())
S = list(map(int,input().split()))
su = [0]*(N+1)
um = [0]*(N+1)
ans = 10000000
for i in range(N):
    su[i+1] = su[i]+S[i]
    um[i+1] = um[i]+S[N-1-i]

for i in range(N+1):
  ans = min(abs(su[N-i]-um[i]),ans)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = list(map(int,input().split()))
S.sorted()
a = N//2
su = 0
um = 0
for i in range(N):
  if i<a:
    su +=S[i]
  else:
    um +=S[i]
print(abs(su-um))
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
am = [int(input()) for i in range(M)]
safe = [True]*(N+1)
for i in am:
    safe[i] = False
dp = [0]*(N+1)
dp[0]=1
for i in range(N):
    if safe[i+1]:
        dp[i+1] += dp[i]
    if i+2<=N:
        if safe[i+2]:
            dp[i+2] += dp[i]
print(dp[N]%(10**9+7))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
am = [int(input()) for i in range(M)]
dp = [0]*(N+1)
if not 1 in am:
	dp[1]=1
if not 2 in am:
	dp[2]=1
for i in range(1,N):
    if not (i+1) in am:
        dp[i+1] += dp[i]
    if not (i+2) in am:
        if i+2<=N:
            dp[i+2] += dp[i]
print(dp[N]%(10**9+7))
Problem p03041 (python)

Fixed submission:
N,K = list(map(int,input().split()))
S = list(input())
S[K-1]=S[K-1].swapcase()
print("".join(S))

Buggy submission (verdict: Runtime Error):
N,K = list(map(int,input().split()))
S = list(input())
S[K-1]．lower()
print("".join(S))
Problem p03242 (python)

Fixed submission:
S = list(input())
for i in range(3):
  if S[i]=="9":
    S[i]="1"
  elif S[i]=="1":
    S[i] ="9"
print("".join(S))

Buggy submission (verdict: Runtime Error):
S = input()
for i in range(3):
  if S[i]=="9":
    S[i]="1"
  elif S[i]=="1":
    S[i] ="9"
print(S)