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

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(i) for i in input().split()] + [0]

count = 0
tmp = 1
for i in range(1, N+1):
    if A[i] == A[i - 1]:
        tmp += 1
    else:
        # 等しくなくなったら
        count += tmp // 2
        tmp = 1  # tmp のリセット

print(count)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

count = 0
tmp = 1
for i in range(1, N):
    if A[i] == A[i - 1]:
        tmp += 1
    else:
        # 等しくなくなったら
        count += tmp // 2
        tmp = 1  # tmp のリセット

print(count)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

count = 0
tmp = 1
for i in range(1, N+1):
    if A[i] == A[i - 1]:
        tmp += 1
    else:
        # 等しくなくなったら
        count += tmp // 2
        tmp = 1  # tmp のリセット

print(count)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(i)for i in input().split()]

count = 0
i = 1
while i <= (N-1):
    if A[i] == A[i - 1]:
        j = i + 1
        if j <= (N-1):
            while True:
                if A[j] == A[j - 1]:
                    count += 1
                    j += 1
                else:
                    count += 2
                    i = j
                    break
        else:
            count += 2
            break
    else:
        i += 1

print(count // 2)
Problem p03304 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

n, m, d = [int(i) for i in input().split()]

"""
from scipy.special import perm, comb

d == 0
def expectation_0(n, m, d):
    return sum([i * comb(m-1, k) * (n/n**2)**k * (1 - n/n**2)**(m-1-k) for k in range(0, m-1)])

d != 0
def expectation_0(n, m, d):
    return sum([i * comb(m-1, k) * (2(n-d)/n**2)**k * (1 - 2(n-d)/n**2)**(m-1-k) for k in range(0, m-1)])

def expectation(p, m):
        return sum([k * comb(m-1, k) * p**k * (1 - p)**(m-1-k) for k in range(0, m-1)])
"""
if d == 0:
    p = 1 / n  # n / n**2
    print((m - 1) * 1/n)

else:
    p = 2 * (n - d) / n**2
    print((m - 1) * p)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from scipy.special import perm, comb

n, m, d = [int(i) for i in input().split()]

"""
d == 0
def expectation_0(n, m, d):
    return sum([i * comb(m-1, k) * (n/n**2)**k * (1 - n/n**2)**(m-1-k) for k in range(0, m-1)])

d != 0
def expectation_0(n, m, d):
    return sum([i * comb(m-1, k) * (2(n-d)/n**2)**k * (1 - 2(n-d)/n**2)**(m-1-k) for k in range(0, m-1)])
"""
def expectation(p, m):
        return sum([k * comb(m-1, k) * p**k * (1 - p)**(m-1-k) for k in range(0, m-1)])


if d == 0:
    p = 1 / n  # n / n**2
    print(expectation(p, m))

else:
    p = 2 * (n - d) / n**2
    print(expectation(p, m))
Problem p03633 (python)

Fixed submission:
def gcd(a, b):
    a = int(a)
    b = int(b)
    m = int(0)
    while(b > 0):
        m = a 
        a = b
        b = m % a
    return a
    

def lcm(a, b):
    return int(a * b // gcd(a, b))

n = int(input())
t = []
for i in range(0, n):
    t.append(int(input()))
cur = t[0]
for i in range(1, n):
    cur = lcm(cur, t[i])
print(int(cur))

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    a = int(a)
    b = int(b)
    m = int(0)
    while(b > 0):
        m = a 
        a = b
        b = m % a
    return a
    

def lcm(a, b):
    return int(a * b / gcd(a, b))

n = int(input())
t = []
for i in range(0, n):
    t.append(int(input()))
cur = t[0]
for i in range(1, n):
    cur = lcm(cur, t[i])
print(int(cur))

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    m = 0
    res = 0
    while(b > 0):
        m = a 
        a = b
        b = m % a
        res = a
    return res
    

def lcm(a, b):
    return a * b / gcd(a, b)

n = int(input())
t = []
for i in range(0, n):
    t.append(int(input()))
cur = t[0]
for i in range(1, n):
    cur = lcm(cur, t[i])
print(int(cur))
Problem p03000 (python)

Fixed submission:
N,X=map(int,input().split())
list=list(map(int,input().split()))
sum=0
cnt=1
for i in range(N):
    sum+=list[i]
    if sum <=X:
        cnt+=1
    else:
        break
print(cnt)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
list=list(map(int,input().split()))
sum=0
cnt=1
for i in range(N+1):
    sum+=list[i]
    if sum <=X:
        cnt+=1
    else:
        break
print(cnt)
Problem p03273 (python)

Fixed submission:
H,W=map(int,input().split())
st=set()
list=list()
for i in range(H):
    S=input()
    if S.count('.') != W:
        list.append(S)
    tmp=S
    tmp=[int(i) for i,x in enumerate(tmp) if x == '.']
    if not st:
        tmp_set = set(tmp)
        st=st.union(tmp_set)
    else:
        tmp_set = set(tmp)
        st &=tmp_set
for x in list:
    str=''
    if not st:
        for i in range(W):
            str+=x[i]
    else:
        for i in range(W):
            if i not in st:
                str+=x[i]
    print(str)
    str=''

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
st=set()
list=list()
for i in range(H):
    S=input()
    if S.count('.') != W:
        list.append(S)
    tmp=[*S]
    tmp=[int(i) for i,x in enumerate(tmp) if x == '.']
    if not st:
        tmp_set = set(tmp)
        st=st.union(tmp_set)
    else:
        tmp_set = set(tmp)
        st &=tmp_set
for x in list:
    str=''
    if not st:
        for i in range(W):
            str+=x[i]
    else:
        for i in range(W):
            if i not in st:
                str+=x[i]
    print(str)
    str=''

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
set1=set()
list=list()
for i in range(H):
    S=input()
    if S.count('.') != W:
        list.append(S)
    tmp=[*S]
    tmp=[int(i) for i,x in enumerate(tmp) if x == '.']
    if not set1:
        tmp_set = set(tmp)
        set1=set1.union(tmp_set)
    else:
        tmp_set = set(tmp)
        set1 &=tmp_set
for x in list:
    str=''
    if not set1:
        for i in range(W):
            str+=x[i]
    else:
        for i in range(W):
            if i not in set1:
                str+=x[i]
    print(str)
    str=''
Problem p03281 (python)

Fixed submission:
N=int(input())
list=list()
cnt=0
for i in range(105,N+1,2):
    list=[j for j in range(1,200)if i%j<1]
    if len(list) >=8:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
import sympy
N=int(input())
list=list()
for i in range(105,N+1,2):
    dict=sympy.factorint(i)
    result=2**sum(dict.values())
    if result >=8:
        list.append(i)
print(len(list))
Problem p03423 (python)

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

Buggy submission (verdict: Runtime Error):
print(int(int(input)/3))
Problem p03543 (python)

Fixed submission:
N = int(input())
print('Yes' if N%1000%111 == 0 or N%1110 < 10 else 'No')

Buggy submission (verdict: Runtime Error):
N = int(input())
print('Yes' if N%1000%111 == 0 or N%1110 < 10)
Problem p03262 (python)

Fixed submission:
def gcd(x,y):
    while x%y:
        x%=y
        x,y=(y,x)
    return y
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs(xlist[i])
m=xlist[-1]
while xlist!=[0]*n:
    for i in range(n):
        
        xlist[i]%=m
        if xlist[i]>0:
            m=gcd(m,xlist[i])
print(m)

Buggy submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs(xlist[i])
m=xlist[-1]
while xlist!=[0]*n:
    for i in range(n):
        
        xlist[i]%=m
        if xlist[i]>0:
            m=math.gcd(m,xlist[i])
print(m)

Buggy submission (verdict: Runtime Error):
import math
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs(xlist[i])
m=xlist[-1]
while xlist!=[0]*n:
    for i in range(n):
        
        xlist[i]%=m
        if xlist[i]>0:
            m=math.gcd(m,xlist[i])
print(m)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
xlist=list(map(int,input().split()))
xlist.sort(key=lambda xx:abs(xx-x))
m=abs(xlist[0]-x)
for i in range(n):
    xlist[i]-=x
    xlist[i]=abs[xlist[i]]
while xlist==[0]*n:
   for i in range(n):
        xlist[i]%=m
        if xlist[i]>0:
            m=min((m,xlist[i]))
print(m)
Problem p03274 (python)

Fixed submission:
N,K=map(int,input().split())
x=list(map(int,input().split()))
tmin=1000000000
for i in range(N-K+1):
    a=x[i+K-1]
    b=x[i]
    res=a-b+min([abs(a),abs(b)])
    if tmin>res:
        tmin=res
print(tmin)

Buggy submission (verdict: Runtime Error):
import bisect
N,K=map(int,input().split())
x=list(map(int,input().split()))
min=1000000000

a=bisect.bisect_left(x,0)
flist=[]
for i in range(a-K,a):
    if i+K-1>N-1 or i<0:
        pass
    else:
        flist.append(i)








for i in flist:
    if x[i+K+1]<0:
        if min>-x[i]:
            min=-x[i]
    elif x[i]>=0:
        if min>x[i+K-1]:
            min=x[i+K-1]
    elif x[i]+x[i+K-1]>=0:
        if min>x[i+K-1]-x[i]*2:
            min=x[i+K-1]-x[i]*2
    else:
        if min>x[i+K-1]*2-x[i]:
            min=x[i+K-1]*2-x[i]
print(min)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
x=list(map(int,input().split()))
min=1000000000
for i in range(N-K+1):
    if x[i+K+1]<0:
        if min>-x[i]:
            min=-x[i]
    elif x[i]>=0:
        if min>x[i+K-1]:
            min=x[i+K-1]
    elif x[i]+x[i+K-1]>=0:
        if min>x[i+K-1]-x[i]*2:
            min=x[i+K-1]-x[i]*2
    else:
        if min>x[i+K-1]*2-x[i]:
            min=x[i+K-1]*2-x[i]
print(min)
Problem p03281 (python)

Fixed submission:
n=int(input())
if n<105:
    print(0)
elif n<135:
    print(1)
elif n<165:
    print(2)
elif n<189:
    print(3)
elif n<195:
    print(4)
else:
    print(5)

Buggy submission (verdict: Runtime Error):
n=map(int,input().split())
if n<=105:
    print(0)
elif n<=135:
    print(1)
elif n<=189:
    print(2)
else:
    print(3)

Buggy submission (verdict: Runtime Error):
n=map(int,input().split())
if n<=105:
    print(0)
elif n<=135:
    print(1)
elif n<=189:
    print(2)
Problem p03379 (python)

Fixed submission:
n=int(input())
x=list(map(int,input().split()))
N=int(n/2)
y=sorted(x)
a=y[N-1]
b=y[N]
for j in range(n):
    if x[j]<=a:
        print(b)
    else:
        print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
x=list(map(int,input().split()))
N=int(n/2)
y=sorted(x)
a=y[N-1]
b=y[N]
for j in range(n):
    if x[j]<a:
        print(b)
    elif x[j]==a:
        print(y[N+1])
    else:
        print(a)
Problem p03436 (python)

Fixed submission:
from collections import deque

h,w=[int(i) for i in input().split() ]

graph=[[None for i in range(w+2)] for j in range(h+2)]
wnum=0
for i in range(w+2):
    graph[0][i]=['#',None]
    graph[h+1][i]=['#',None]
for j in range(h+2):
    graph[j][0]=['#',None]
    graph[j][w+1]=['#',None]
for i in range(h):
    a=input()
    for j in range(w):
        if a[j]=='.':
            wnum+=1
        graph[i+1][j+1]=[a[j],None]

q=deque([])
q.append((1,1))
graph[1][1][1]=0
d_min=None
while len(q)!=0:
    x,y=q.popleft()
    for cx,cy in ((x-1,y),(x+1,y),(x,y-1),(x,y+1)):
        if graph[cx][cy][0]=='.':
            if graph[cx][cy][1]==None:
                graph[cx][cy][1]=graph[x][y][1]+1
                if (cx,cy)==(h,w):
                    d_min=graph[cx][cy][1]
                    break
                q.append((cx,cy))
if d_min!=None:
   print(wnum-d_min-1)
else:
   print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque

h,w=[int(i) for i in input().split() ]

graph=[[None for i in range(w+2)] for j in range(h+2)]
wnum=0
for i in range(w+2):
    graph[0][i]=['#',None]
    graph[h+1][i]=['#',None]
for j in range(h+2):
    graph[j][0]=['#',None]
    graph[j][w+1]=['#',None]
for i in range(h):
    a=input()
    for j in range(w):
        if a[j]=='.':
            wnum+=1
        graph[i+1][j+1]=[a[j],None]

q=deque([])
q.append((1,1))
graph[1][1][1]=0
d_min=None
while len(q)!=0:
    x,y=q.popleft()
    for cx,cy in ((x-1,y),(x+1,y),(x,y-1),(x,y+1)):
        if graph[cx][cy][0]=='.':
            if graph[cx][cy][1]==None:
                graph[cx][cy][1]=graph[x][y][1]+1
                if (cx,cy)==(h,w):
                    d_min=graph[cx][cy][1]
                    break
                q.append((cx,cy))
print(wnum-d_min-1)
Problem p03447 (python)

Fixed submission:
x=int(input())
a=int(input())
b=int(input())
print((x-a)%b)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[]
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort()
xi=0
i=0
x=[None for i in range(10**5)]
while i<m:
    x[l[0][0]]=0
    if l[i][0]==xi:
        if x[l[i][1]]==None:
            x[l[i][1]]=l[i][2]+x[l[i][0]]
            i+=1
        else:
            print('No')
            break
    else:
        xi+=1
if i<m:
    pass
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
x=input()
a=input()
b=input()
print((x-a)%b)
Problem p03450 (python)

Fixed submission:
n,m=map(int,input().split())
graph=[[] for i in range(n+1) ]
dist=[None for i in range(n+1)]
dist[0]=0
result=[True]

for i in range(m):
    l,r,d=(int(i) for i in input().split())
    graph[l].append((r,-d))
    graph[r].append((l,d))
def haba(i):
    if dist[i]== None:
        stack=[]
        dist[i]=0
        stack.append(i)
        while len(stack)!=0 :
            l=stack.pop()
            for r,d in graph[l]:
                b=dist[l]+d
                if dist[r]==None :
                    dist[r]=b
                    stack.append(r)
                elif dist[r]!=b:
                     result[0]=False
                     return
        return 
    else:
        return 

for i in range(n+1):
    haba(i)
if result[0]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[]
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort()
xi=0
i=0
x=[None for i in range(10**5)]
while i<m:
    x[l[0][0]]=0
    if l[i][0]==xi:
        if x[l[i][1]]==None:
            x[l[i][1]]=l[i][2]+x[l[i][0]]
            i+=1
        else:
            print('No')
            break
    else:
        xi+=1
if i<m:
    pass
else:
    print('Yes')
Problem p03455 (python)

Fixed submission:
a,b=map(int,input().split())
if a*b%2 :
    print('Odd')
else:
    print('Even')

Buggy submission (verdict: Runtime Error):
def a(t,x,y):
    n=abs(x)+abs(y)
    if (t-n)%2==0 and t-n>=0 :
        return 1
    else :
        return 0
N=int(input())
result=1
tn,xn,yn=0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    tn=t-tn
    xn=x-xn
    yn=y-yn
    result*=a(tn,xn,yn)
    #print (result)
if result==1:
    print ('Yes')
else:
    print ('No')

Buggy submission (verdict: Runtime Error):
def a(t,x,y):
    n=abs(x)+abs(y)
    if (t-n)%2==0 and t-n>=0 :
        return 1
    else :
        return 0
N=int(input())
result=1
tn,xn,yn=0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    tn=t-tn
    xn=x-xn
    yn=y-yn
    result*=a(tn,xn,yn)
    print (result)
if result==1:
    print ('Yes')
else:
    print ('No')
Problem p03589 (python)

Fixed submission:
N=int(input())
def ok(h,n,w,N):
    if 4*h*n*w==N*(n*w+n*h+h*w):
        return 1
    else:
        return 0

def kiyaku(a,b):
    if b%a==0:
        return 1
    else:
        return 0

def solve(N):

    for i in range(N//4+1,3*N//4+1):
        for j in range(3*N//4+1,3501):
            if 4*i*j-N*(i+j)>0 and kiyaku(4*i*j-N*(i+j),N*i*j):
                return (i,j,N*i*j//(4*i*j-N*(i+j)))
h,n,w=solve(N)
print(h,n,w)

Buggy submission (verdict: Runtime Error):
N=int(input())
def ok(h,n,w,N):
    if 4*h*n*w==N*(n*w+n*h+h*w):
        return 1
    else:
        return 0

def kiyaku(a,b):
    if b%a==0:
        return 1
    else:
        return 0

def solve(N):

    for i in range(N//4+1,3*N//4+1):
        for j in range(3*N//4+1,3501):
            if kiyaku(4*i*j-N*(i+j),N*i*j) and 4*i*j-N*(i+j)>0:
                return (i,j,N*i*j//(4*i*j-N*(i+j)))

    return (-1,-1,-1)
h,n,w=solve(N)
print(h,n,w)
Problem p02898 (python)

Fixed submission:
a,b=map(int,input().split())
height=list(map(int,input().split()))
count=0
for i in range (a):
    if int(height[i])>=b:
       count+=1
print(count)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
height=list(input())
count=0
for i in range (a):
    if height[i]>=b:
       count+=count
print(count)
Problem p03262 (python)

Fixed submission:
from functools import reduce


def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


def _gcd(*n):
    return reduce(gcd, n)


N, X = map(int, input().split())
x = list(map(int, input().split()))
x = sorted(x + [X])
diff = [x[i+1] - x[i] for i in range(N)]
print(_gcd(*diff))

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce


def _gcd(*n):
    return reduce(gcd, n)


N, X = map(int, input().split())
x = list(map(int, input().split()))
x = sorted(x + [X])
diff = [x[i+1] - x[i] for i in range(N)]
print(_gcd(*diff))
Problem p03076 (python)

Fixed submission:
#１のくらいのみ見れはいい？
import numpy as np
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
ls=[a,b,c,d,e]
ls_1=[]
for i in range(len(ls)):
    ls_1.append(int(str(ls[i])[-1]))
ls_1=np.array(ls_1)
ls_1_10=10-ls_1
ls_1_10[ls_1_10==10]=0
#ls_1_10=ls_1[ls_1 < 10]#１０を除いたロス
a=np.argmax(ls_1_10)#最大の１の位を探す
ls_non=np.delete(ls_1_10, a, 0)
#ls_non_10=ls_non[ls_non < 10]
ls=np.array(ls)
ans=np.sum(ls) + np.sum(ls_non)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
ls=[a,b,c,d,e]
ls_1=[]
for i in range(len(ls)):
    ls_1.append(int(str(ls[i])[-1]))
ls_1=np.array(ls_1)
ls_1=10-ls_1
ls_1_10=ls_1[ls_1 < 10]#１０を除いたロス
a=np.argmax(ls_1_10)#最大の１の位を探す
ls_non=np.delete(ls_1_10, a, 0)
#ls_non_10=ls_non[ls_non < 10]
ls=np.array(ls)
ans=np.sum(ls) + np.sum(ls_non)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
ls=[a,b,c,d,e]
ls_1=[]
for i in range(len(ls)):
    ls_1.append(int(str(ls[i])[-1]))
ls_1=np.array(ls_1)
ls_1=10-ls_1
ls_1_10=ls_1[ls_1 < 10]#１０を除いたロス
a=np.argmax(ls_1_10)#最大の１の位を探す
ls_non=np.delete(ls_1_10, a, 0)
#ls_non_10=ls_non[ls_non < 10]
ls=np.array(ls)
ans=np.sum(ls) + np.sum(ls_non)
print(ans)
Problem p03086 (python)

Fixed submission:
import copy
ls=list(input())
ans=0
#ans1=0
ans_ls=[]
#print(ls)
for i in range(len(ls)):
    if ls[i]=='A' or ls[i] == 'C' or ls[i] == 'G' or ls[i] == 'T':
        ans=ans+1
        #print(ans)
    else:
        #print(ans)
        ans1=ans
        #print(ans1)
        ans_ls.append(ans1)
        ans=0
ans_ls.append(ans)
#print(ans_ls)
print(max(ans_ls))

Buggy submission (verdict: Runtime Error):
ls=list(input())
ans=0
ans_ls=[]
for i in range(len(ls)):
    if ls[i ]=='A' or ls[i] == 'C' or ls[i] == 'G' or ls[i] == 'T':
        ans=ans+1
    else:
        ans1=ans
        ans_ls.append(ans1)
        ans=0

print(max(ans_ls))
Problem p02947 (python)

Fixed submission:
n = int(input())
s = ["".join(sorted(input())) for _ in range(n)]

ans, d = 0, {}
for i in range(n):
    if s[i] in d.keys():
        ans += d[s[i]]
        d[s[i]] = d[s[i]] + 1
    else:
        d[s[i]] = 1
print(ans)

Buggy submission (verdict: Runtime Error):
def hoge(n):
    if n == 1:
        return 1
    else:
        return n * hoge(n-1)

n = int(input())
s = [sorted(input()) for i in range(n)]

count = 0
c = 0
t = []
for i in range(n - 1):
    if i not in t:
        for j in range(n - i - 2):
            if s[i] == s[j]:
                c += 1
                t.append(j)
        count += hoge(c + 1) // 2
        c = 0
    
print(count)
Problem p02784 (python)

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

if sum(A) >= H:
    print("Yes")
else:
    print("No")

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

A.sort(reverse=True)
if H - A[0] - A[1] <= 0:
    print("Yes")
else:
    print("No")
Problem p02797 (python)

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

for i in range(2, 10**6):
    if gcd(S, i) == 1:
        break

ans = []
ans.extend([S for _ in range(K)])
ans.extend([i for _ in range(N-K)])

ans_str = ""
for j in range(len(ans)):
    ans_str += str(ans[j])
    ans_str += " "
ans_str = ans_str[:len(ans_str) - 1]
print(ans_str)

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

for i in range(S + 1, 10**6):
    if gcd(S, i) == 1:
        p = gcd(S, i)
        break

ans = []
ans.extend([S for _ in range(K)])
ans.extend([p for _ in range(N-K)])
print(ans)
Problem p03160 (python)

Fixed submission:
# dp[i]: i+1にくるまでにかかったコストの最小値
N = int(input())
h = list(map(int, input().split()))
dp = [float("inf") for _ in range(N)]
dp[0] = 0
for i in range(N-1):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
    if i < N-2:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]))
print(dp[-1])

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

dp = [1000000 for i in range(N+10)]
dp[1] = 0

for i in range(1, N-1):
    dp[i + 1] = min(dp[i + 1], abs(h[i + 1] - h[i]) + dp[i])
    dp[i + 2] = min(dp[i + 2], abs(h[i + 2] - h[i]) + dp[i])

print(dp[N])
Problem p03162 (python)

Fixed submission:
import numpy as np
N = int(input())
abc = []
for i in range(N):
    abc.append(list(map(int, input().split())))
    
dp = np.zeros(shape=(N, 3), dtype=int)
dp[0, :] = abc[0]
for i in range(N-1):
    dp[i+1, 0] = max(dp[i+1, 0], dp[i, 1] + abc[i+1][0], dp[i, 2] + abc[i+1][0])
    dp[i+1, 1] = max(dp[i+1, 1], dp[i, 0] + abc[i+1][1], dp[i, 2] + abc[i+1][1])
    dp[i+1, 2] = max(dp[i+1, 2], dp[i, 0] + abc[i+1][2], dp[i, 1] + abc[i+1][2])
print(max(dp[N-1, :]))

Buggy submission (verdict: Runtime Error):
import numpy as np
# dp[i][j]: i+1日目に活動jをしたときのi+1日目までの幸福度の最大値
N = int(input())
abc = []
for i in range(N):
    abc.append(list(map(int, input().split())))
dp = np.zeros(shape=(N, 3), dtype=int)
dp[0, :] = abc[0]
for i in range(N-1):
    dp[i+1, 0] = max(dp[i+1, 0], dp[i, 1] + abc[i+1][0], dp[i, 2] + abc[i+1][0])
    dp[i+1, 1] = max(dp[i+1, 1], dp[i, 0] + abc[i+1][1], dp[i, 2] + abc[i+1][1])
    dp[i+1, 2] = max(dp[i+1, 2], dp[i, 0] + abc[i+1][2], dp[i, 1] + abc[i+1][2])
print(max(dp[N-1, :]))
Problem p03163 (python)

Fixed submission:
# pypyはnumpyが使えないみたい
#import numpy as np
# dp[i][j]: i+1個目までの品物で重量の総和がj以下である時の価値の最大値

N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    tmp = list(map(int, input().split()))
    w.append(tmp[0])
    v.append(tmp[1])
    
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
        else:
            #dp[i+1][j] = max(dp[i][j], dp[i+1][j])
            dp[i+1][j] = dp[i][j]
print(dp[N][W])

Buggy submission (verdict: Runtime Error):
import numpy as np
# dp[i][j]: i+1個目までの品物で重量の総和がj以下である時の価値の最大値

N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    tmp = list(map(int, input().split()))
    w.append(tmp[0])
    v.append(tmp[1])
    
dp = np.zeros(shape=(N+1, W+1), dtype=int)
for i in range(N):
    for j in range(W+1):
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
        else:
            #dp[i+1][j] = max(dp[i][j], dp[i+1][j])
            dp[i+1][j] = dp[i][j]
print(dp[N][W])