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

Fixed submission:
S = input()

num0 = S.count("0")
num1 = len(S)-num0

print(min(num0,num1)*2)

Buggy submission (verdict: Runtime Error):
import sys
import numba


S_raw = sys.stdin.readline().strip()

@numba.jit
def check_next(S):
    S = list(S)
    before_num=S[0]
    for i in range(len(S)):
        if S[i]!=before_num:
            S.pop(i-1)
            #S = list(S)
            S.pop(i-1)
            new_S = S
            return S,1
            break
    return S,0


cnt=0
N=0

while cnt<50000:
    S_raw, check_cnt = check_next(S_raw)
    N += check_cnt
    if check_cnt==0:
        break
    cnt+=1
    
print(N*2)

Buggy submission (verdict: Runtime Error):
import sys


S_raw = sys.stdin.readline().strip()

def check_next(S):
    S = list(S)
    before_num=S[0]
    for i in range(len(S)):
        if S[i]!=before_num:
            S.pop(i-1)
            #S = list(S)
            S.pop(i-1)
            new_S = S
            return S,1
            break
    return S,0


cnt=0
N=0

while cnt<50000:
    S_raw, check_cnt = check_next(S_raw)
    N += check_cnt
    if check_cnt==0:
        break
    cnt+=1
    
print(N*2)

Buggy submission (verdict: Runtime Error):
import sys


S_raw = sys.stdin.readline().strip()

def check_next(S):
    S = list(S)
    before_num=S[0]
    for i in range(len(S)):
        if S[i]!=before_num:
            S.pop(i-1)
            #S = list(S)
            S.pop(i-1)
            new_S = S
            return S,1
            break
    return S,0


cnt=0
N=0

while cnt<10**5:
    S_raw, check_cnt = check_next(S_raw)
    N += check_cnt
    if check_cnt==0:
        break
    cnt+=1
    
print(N*2)

Buggy submission (verdict: Runtime Error):
import sys


S_raw = sys.stdin.readline().strip()

def check_next(S):
    S = list(S)
    before_num=S[0]
    for i in range(len(S)):
        if S[i]!=before_num:
            S.pop(i-1)
            #S = list(S)
            S.pop(i-1)
            new_S = S
            return S,1
            break
    return S,0


cnt=0
N=0

while cnt<20:
    S_raw, check_cnt = check_next(S_raw)
    N += check_cnt
    if check_cnt==0:
        break
    cnt+=1
    
print(N*2)
Problem p02725 (python)

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

Buggy submission (verdict: Runtime Error):
K,N=map(int,input())
A=list(map(int,input().split())
L_max=0
for i in range(A):
    if i<len(A)-1:
        l=A[i+1]-A[i]
    else:
        l=K-A[-1]+A[0]
    if L_max<l:
        L_max=l
ans=sum(A)-L_max
print(ans)
Problem p02777 (python)

Fixed submission:
S,T=input().split()
A,B=map(int,input().split())
U=input()
if S==U:
    print(A-1,B)
elif T==U:
    print(A,B-1)

Buggy submission (verdict: Runtime Error):
S,T=input().split()

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

U=input()

if S==U:
    A=A-1

elif T==U:
    B=B-1
else:
    pass

print(A,B)
Problem p03042 (python)

Fixed submission:
S=input()
a=int(S[0]+S[1])
b=int(S[2]+S[3])
if (a==0 or a>12) and 0<b<=12:
    print("YYMM")
elif 0<a<=12 and 0<b<=12:
    print("AMBIGUOUS")
elif 0<a<=12 and (b==0 or b>12):
    print("MMYY")
else:
    print("NA")

Buggy submission (verdict: Runtime Error):
S=input()
a=int(S[0]+S[1])
b=int(S[2]+S[3])
if (a==0 a>12) and 0<b<=12:
    print("YYMM")
elif 0<a<=12 and 0<b<=12:
    print("AMBIGUOUS")
elif 0<a<=12 and b>12:
    print("MMYY")
else:
    print("NA")
Problem p02693 (python)

Fixed submission:
n=int(input())
temp=list(map(int,input().rstrip().split()))
a=temp[0]
b=temp[1]
rem=(a%n)
left=n-rem
if b>=(left+a) :
    print("OK")
elif a%n ==0 or b%n==0:
    print("OK")
else :
    print("NG")

Buggy submission (verdict: Runtime Error):
n=int(input())
temp=list(map(int,input().rstrip().split()))
a=temp[0]
b=temp[2]
if (b-a)>n :
    print("OK")
elif n==1 :
  print("OK")
else :
    print("NG")

Buggy submission (verdict: Runtime Error):
n=int(input())
temp=list(map(int,input().rstrip().split()))
a=temp[0]
b=temp[2]
if (b-a)>n :
    print("Yes")
else :
    print("No")
Problem p02699 (python)

Fixed submission:
def main():
    s,w=map(int,input().split())
    print('unsafe' if w>=s else 'safe')
main()

Buggy submission (verdict: Runtime Error):
def main():
    s=input()
    c=0
    for i in range(len(s)):
        for j in range(i+5, len(s)+1):
            if int(s[i:j])%2019==0:
                c+=1
    print(c)
main()
Problem p02831 (python)

Fixed submission:
from fractions import gcd
def main():
    a,b=map(int,input().split())
    print(a*b//gcd(a,b))
 
main()

Buggy submission (verdict: Runtime Error):
from math import gcd
def main():
    a,b=map(int,input().split())
    print(a*b//gcd(a,b))

main()
Problem p03013 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()

def main():
    n,m=map(int,input().split())
    if n == 1:
        print(1)
        return
    aa=[]
    for _ in range(m):
        aa.append(int(input()))
    for i in range(m-1):
        if aa[i]+1==aa[i+1]:
            print(0)
            return
    cc = [0] * n
    i = 0
    j = 2 
    cc[0] = 1
    if m < 1 or aa[0] > 1:
        cc[1] = 1
    else:
        cc[1] = 0
        i += 1
    while j < n:
        if i < m and aa[i] == j:
            i+=1
        else:
            cc[j]=cc[j-1]+cc[j-2]
        j+=1
    print((cc[n-1]+cc[n-2])%1000000007)

main()

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def main():
    n,m=map(int,input().split())
    if n == 1:
        print(1)
        return
    aa=[]
    for _ in range(m):
        aa.append(int(input()))
    for i in range(m-1):
        if aa[i]+1==aa[i+1]:
            print(0)
            return
    cc = [0] * n
    i = 0
    j = 2 
    cc[0] = 1
    if aa[0] > 1:
        cc[1] = 1
    else:
        cc[1] = 0
        i += 1
    while j < n:
        if i < m and aa[i] == j:
            i+=1
        else:
            cc[j]=cc[j-1]+cc[j-2]
        j+=1
    print((cc[n-1]+cc[n-2])%1000000007)

main()
Problem p03072 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(sum(max([0] + a[:i]) <= a[i] for i in range(n)))

Buggy submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
print(sum(max(x[:i] <= x[i] for i in range(n))
Problem p03250 (python)

Fixed submission:
a,b,c=sorted(input().split())
print(eval("{}{}+{}".format(c,b,a)))

Buggy submission (verdict: Runtime Error):
a,b,c=sorted(input().split())
print(eval(f"{c}{b}+{a}"))
Problem p02915 (python)

Fixed submission:
print(int(input())**3)

Buggy submission (verdict: Runtime Error):
i=input();print(i**3)
Problem p02951 (python)

Fixed submission:
l=list(map(int,input().split()))
a = l[0]
b = l[1]
c = l[2]


print(max(c - (a-b), 0))

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

print(max(c - (a-b), 0))

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

print(max(c - (a-b), 0))

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()

print(max(c - (a-b), 0))
Problem p03315 (python)

Fixed submission:
S=input()
print(-S.count('-')+S.count('+'))

Buggy submission (verdict: Runtime Error):
S=print()
print(-S.count('-')+S.count('+'))

Buggy submission (verdict: Runtime Error):
S=print()
print(-S.count('-'+S.count('+'))
Problem p02594 (python)

Fixed submission:
x=input()
x=int(x)
if x>=30:
    print('Yes')
else:
    print("No")

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

if x>=30:
    print('Yes')
else:
    print("No")
Problem p03803 (python)

Fixed submission:
a=input().strip().split(" ")

b=[int(i) for i in a]

for i in range(2):
    if(b[i]==1):
        b[i]=int(13)
    else:
        b[i]=b[i]-1

if(b[0]>b[1]):
    print("Alice")
elif(b[0]==b[1]):
    print("Draw")
else:
    print("Bob")

Buggy submission (verdict: Runtime Error):
a=input().strip().split(" ")

b=[int(i) for i in a]

for i in range(2):
    if(b[i]==1):
        b[i]="13"
    else:
        b[i]=b[i]-1

if(b[0]>b[1]):
    print("Alice")
elif(b[0]==b[1]):
    print("Draw")
else:
    print("Bob")
Problem p02578 (python)

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

ans=0

for i in range(n-1):
    if a[i]>a[i+1]:
        ans+=a[i]-a[i+1]
        a[i+1]=a[i]
print(ans)

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

ans=0

for i in range(n-1):
    if a[i]>a[i+1]:
        ans+=a[i]-a[i+1]
        a[i+1]=a[i]
print(ans)

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

ans=0

for i in range(n):
    if [a(i)]>[a(i+1)]:
        ans+=[a(i)]-[a(i+1)]
print(ans)
Problem p02693 (python)

Fixed submission:
k=int(input())
a,b=map(int,input().split())
s=""
for i in range(a,b+1):
  if i%k==0:
    s="OK"
    print(s)
    break
if s!="OK":
  print("NG")

Buggy submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
for i in range(A,B+1):
  if i%K==0:
    print("OK")
    exec()
print("NG")

Buggy submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
a=0
for i in range(A,B+1):
  if i%k==0:
    a+=1
if a==1:
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
a=0
if i in range(A,B+1):
  if i%k==0:
    a+=1
if a==1:
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
a=0
if i in range(A,B+1):
  if k%i==0:
    a+=1
if a==1:
  print("OK")
else:
  print("NG")
Problem p02711 (python)

Fixed submission:
N=input()
if N.count("7"):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=input()
if 7 in n:
  print("Yes")
else:
  print("No")
Problem p02723 (python)

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

Buggy submission (verdict: Runtime Error):
s=list(map(str,input().split()))
if s[2]==s[3] and s[4]==s[5]:
  print("Yes")
else:
  print("No")
Problem p02729 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readline().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)

Buggy submission (verdict: Runtime Error):
N,M=map(int,inputt().split())
x = M * (M - 1) // 2
x += N * (N - 1) // 2
print(x)

Buggy submission (verdict: Runtime Error):
N,M=map(int,inputt().split())
print((N*(N-1))/2+(M*(M-1))/2)

Buggy submission (verdict: Runtime Error):
N,M=map(int,inputt().split())
print(N*(N-1)/2+M*(M-1)/2)

Buggy submission (verdict: Runtime Error):
N,M=map(int,inputt().split())
print(N*(N-1)+M*(M-1))

Buggy submission (verdict: Runtime Error):
N,M=map(int,inputt().split())
print(N*(N-1)+N*M)
Problem p02753 (python)

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

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

if S="AAA" or S="BBB":
  print("NO")
else:
  print("Yes")
Problem p02777 (python)

Fixed submission:
S,T=input().split()
a,b=map(int,input().split())
U=input()

if S==U:
  print(a-1,b)
else:
  print(a,b-1)

Buggy submission (verdict: Runtime Error):
S,T=map(input().split())
a,b=mao(int,input().split())
U=input()

if S==U:
  print(a-1,b)
else:
  print(a,b-1)
Problem p02847 (python)

Fixed submission:
s=input()
day=['SUN','MON','TUE','WED','THU','FRI','SAT']
for i in range(7):
  if s==day[i]:
    print(7-i)

Buggy submission (verdict: Runtime Error):
s=input()
day=['SUN','MON','TUE','WED','THU','FRI','SAT']
for i in range(7):
  if s=day[i]:
    print(7-i)
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()

if a>=3200:
  print(s)
else:
  print('red')

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

if a>=3200:
  print(s)
else:
  print('red')
Problem p03011 (python)

Fixed submission:
P,Q,R=map(int,input().split())
min=P+Q
if min>Q+R:
  min=Q+R
if min>R+P:
  min=R+P
print(min)

Buggy submission (verdict: Runtime Error):
P,Q,R=map(int,input().split())
min=P+Q
if min>Q+R:
  min=Q+R
if min>R+P:
  min=R+P:
print(min)
Problem p03075 (python)

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

if x[-1]-x[0]<=k:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
x=[(int(input()) for i in range(5)]
k=int(input())

if x[-1]-x[0]<=k:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
x=list(int(input()) for i in range())
k=int(input())

if x[-1]-x[0]<=k:
  print("Yay!")
else:
  print(":(")
Problem p02596 (python)

Fixed submission:
n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  b = 0
  for i in range(1000000):
    if a % n == 0:
      print(i+1)
      b = 1
      break
    a = (a%n) * 10 + 7
  if b == 0:
    print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  b = 0
  for i in range(1000000):
    if a % n == 0:
      print(i+1)
      b = 1
      break
    a = (a%n) * 10 + 7
	if b == 0:
      print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  for i in range(1000000)
    if a % n == 0:
      print(i+1)
      break
    a = a * 10 + 7
Problem p02762 (python)

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

parents = [-1] * N
friend = [set() for _ in range(N)]

def find(x):
	if parents[x] < 0:
		return x
	else:
		parents[x] = find(parents[x])
		return parents[x]

def union(x, y):
	x = find(x)
	y = find(y)

	if x == y:
		return

	if parents[x] > parents[y]:
		x, y = y, x

	parents[x] += parents[y]
	parents[y] = x

for _ in range(M):
	A, B = map(int, input().split())
	union(A-1, B-1)
	friend[A-1].add(B-1)
	friend[B-1].add(A-1)

a = [-parents[find(i)]-len(friend[i])-1 for i in range(N)]

for _ in range(K):
	C, D = map(int, input().split())
	if find(C-1) == find(D-1):
		a[C-1] -= 1
		a[D-1] -= 1
print(*a)

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

parents = [-1] * N
friend = [set() for _ in range(N)]

def find(x):
	if parents[x] < 0:
		return x
	else:
		parents[x] = find(parents[x])
		return parents[x]

def union(x, y):
	x = find(x)
	y = find(y)

	if x == y:
		return

	if parents[x] > parents[y]:
		x, y = y, x

	parents[x] += parents[y]
	parents[y] = x

for _ in range(M):
	A, B = map(int, input().split())
	union(A-1, B-1)
	friend[A-1].add(B-1)
	friend[B-1].add(A-1)

a = [-parents[find(i)]-len(friend[i])-1 for i in range(N)]

for _ in range(K):
	C, D = map(int, input().split())
	if find[C-1] == find[D-1]:
		a[C-1] -= 1
		a[D-1] -= 1
print(*a)
Problem p02790 (python)

Fixed submission:
a, b = map(str, input().split())
s = ''
if a > b:
	for _ in range(int(a)):
		s += b
else:
	for _ in range(int(b)):
		s += a
print(s)

Buggy submission (verdict: Runtime Error):
a, b = map(string, input().split())
s = ''
if a > b:
	for _ in range(int(a)):
		s += b
else:
	for _ in range(int(b)):
		s += a
print(s)
Problem p02987 (python)

Fixed submission:
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]
if A == B and C == D and A != C:
  print('Yes')
elif A == C and B == D and A != B:
  print('Yes')
elif A == D and B == C and A != B:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S = input()
if A == B and C == D and A != C:
  print('Yes')
elif A == C and B == D and A != B:
  print('Yes')
elif A == D and B == C and A != B:
  print('Yes')
else:
  print('No')
Problem p03012 (python)

Fixed submission:
N = int(input())
W = list(map(int, input().split()))
 
l = [0] * N
r = [0] * N
 
for i in range(N):
  if i == 0:
    r[i] = W[0]
    l[i] = W[N-1]
  else:
    r[i] = r[i-1] + W[i]
    l[i] = l[i-1] + W[N-i-1]
 
ans = 100000
for i in range(N-1):
  ans = min([abs(r[i] - l[N-i-2]), ans])
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
W = map(int, input().split())
 
l = [0] * N
r = [0] * N
 
for i in range(N):
  if i == 0:
    r[i] = W[0]
    l[i] = W[N-1]
  else:
    r[i] = r[i-1] + W[i]
    l[i] = l[i-1] + W[N-i-1]
 
ans = 100000
for i in range(N-1):
  ans = min([abs(r[i] - l[N-i-2]), ans])
print(ans)

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

l = [0] * N
r = [0] * N

for i in range(N):
  if i == 0:
    r[i] = W[0]
    l[i] = W[N-1]
  else:
    r[i] = r[i-1] + W[i]
    l[i] = l[i-1] + W[N-i-1]

ans = 100000
for i in range(N):
  ans = min([abs(r[i] - l[N-i-1]), ans])
print(ans)
Problem p03041 (python)

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

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
if S[K-1] == 'A':
  S[K-1] = 'a'
elif S[K-1] == 'B':
  S[K-1] = 'b'
else:
  S[K-1] = 'c'
print(S)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
if S[K-1] == 'A':
  S[K-1] = 'a'
elif S[K-1] == 'B':
  S[K-1] = 'b'
else:
  S[K-1] = 'c'
print(S)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
if S[K-1] == 'A':
  S[K-1] = 'a'
elif S [K-1] == 'B':
  S[K-1] = 'b'
else:
  S[K-1] = 'c'
print(S)
Problem p02693 (python)

Fixed submission:
n = int(input())
a, b = map(int, input().split())
for i in range(a, b + 1):
  if i % n == 0:
    print("OK")
    quit()
print("NG")

Buggy submission (verdict: Runtime Error):
n = int(input())
a, b = map(int, input().split())
for i in range(a, b + 1):
  if i % n == 0:
	print("OK")
    quit()
print("NG")
Problem p02847 (python)

Fixed submission:
n = input()
if n == "SAT":
    print(1)
elif n == "MON":
    print(6)
elif n == "TUE":
    print(5)
elif n == "WED":
    print(4)
elif n == "THU":
    print(3)
elif n == "FRI":
    print(2)
else:
    print(7)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n == "SAT":
    print(1)
elif n == "MON":
    print(6)
elif n == "TUE":
    print(5)
elif n == "WED":
    print(4)
elif n == "THU":
    print(3)
elif n == "FRI":
    print(2)
else:
    print(7)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print("red")

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()
if s >= 3200:
  print(s)
else:
  print("red")
Problem p02847 (python)

Fixed submission:
S = input()

if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
elif S == 'SAT':
    print(1)

Buggy submission (verdict: Runtime Error):
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(1)
elif S == 'TUE':
    print(2)
elif S == 'WED':
    print(3)
elif S == 'THU':
    print(4)
elif S == 'FRI':
    print(5)
elif S == 'SAT':
    print(6)
Problem p03327 (python)

Fixed submission:
N = int(input())

if N >= 1000:
    print( 'ABD' )

else :
    print( 'ABC' )

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

if N >= 1000:
    print( 'ABD' )

else :
    print( 'ABC' )
Problem p02688 (python)

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


snk = [False]*n

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    
    for i in a:
        snk[i-1] = True

print(snk.count(False))

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

snk = [False] * n

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    
    for i+1 in a:
        snk[i] = True
 
print(snk.count(False))
Problem p02725 (python)

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

diff = 0
total = 0
for i in range(n-1):
    diff = max(abs(a[i] - a[i+1]), diff)
    total += abs(a[i] - a[i+1])
    
diff_tmp = abs(a[n-1] - k) + a[0]
diff = max(diff_tmp, diff)
total += abs(a[n-1] - k) + a[0] - diff

print(total)

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

# 時計回り
r_ans = 10**9
if a[0] + a[n-1] >= k:
    r_ans = a[n-1] - a[0]
    # print(a[n-1] - a[0])

# 反時計回り
else:
    max_n = 0
    for i in range(n-1):
        diff = abs(a[i] - a[i+1])
        max_n = max(diff, max_n)
    # print(k - max_n)
    l_ans = k - max_n

print(min(r_ans, l_ans))
Problem p02785 (python)

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

monsters.sort()

total_hp = 0
if(len(monsters) > k):
    for i in range(n-k):
        total_hp += monsters[i]
        
    print(total_hp)
else: print(0)

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

monsters.sort(reverse=True)

if(len(monsters) > k):
    for i in range(k):
        monsters.pop(i)
        
    total_hp = sum(monsters)
    print(total_hp)
else: print(0)
Problem p02831 (python)

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

def gcd(a, b):
    while b != 0:
        a, b = b, a%b
    return a
    
def lcm(a, b):
    return int(a*b/gcd(a, b))

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import collections
from functools import reduce
from operator import mul

a,b = map(int, input().split())

def prime_factorization(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
    
def my_index(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default

prime_a = collections.Counter(prime_factorization(a))
prime_b = collections.Counter(prime_factorization(b))

a_keys = list(prime_a.keys())
b_keys = list(prime_b.keys())

ans = []
for a_key in a_keys:
    suffix = my_index(b_keys, a_key)
    if suffix != -1:
        if a_keys[suffix] > b_keys[suffix]:
            ans.append(a_key ** prime_a[a_key])
        else:
            ans.append(a_key ** prime_b[suffix])
    else:
        ans.append(a_key ** prime_a[a_key])

for b_key in b_keys:
    suffix = my_index(a_keys, b_key)
    if suffix == -1: ans.append(b_key ** prime_b[b_key])

print(reduce(mul, ans))
Problem p02987 (python)

Fixed submission:
s = input()

origin = list(set(list(s)))

if len(origin) > 2:
    print("No")
    exit()
a=0
b=0
for i in s:
    if i == origin[0]: a+=1
    elif i == origin[1]: b+=1

if a==2:
    print("Yes")
else:
    print("No")

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

orgin = set(list(s))

if len(orgin) > 2:
    print("No")
    exit()

a=0
b=0
for i in s:
    if i == origin[0]: a+=1
    elif i == origin[1]: b+=1

if a==2:
    print("Yes")
else:
    print("No")
Problem p02831 (python)

Fixed submission:
import sys
input = sys.stdin.readline

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

abs = 1
for i in list(range(1,min(A,B)+1))[::-1]:
    if A%i==0 and B%i==0:
        abs = i
        break

print(int(A*B/abs))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

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

print(int(np.lcm(A,B)))

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

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

print(int(A*B/math.gcd(A,B)))

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

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

print(int(A*B/math.gcd(A,B)))