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

Fixed submission:
s = input()
d = 0

if s == "RRR":
    d = 3
elif s in {"RRS", "SRR"}:
    d = 2
elif s in {"RSR", "RSS", "SSR", "SRS"}:
    d = 1
else:
    d = 0

print(d)

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

for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            sum = l[i] + l[j] + l[k]
            if sum - max(l[i], l[j], l[k]) > max(l[i], l[j], l[k]):
                if l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                    t += 1

print(t)

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

for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            sum = l[i] + l[j] + l[k]
            if sum - max(l[i], l[j], l[k]) > max(l[i], l[j], l[k]):
                if l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                    t += 1

print(t)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
if n != 0:
    l = list(map(int, input().split()))
else:
    l = []

diff = 10**18
ans = 10**18

for i in range(-10000, 10000):
    if i in l:
        continue
    else:
        if abs(x-i) < diff:
            ans = i
            diff = abs(x-i)

print(ans)

Buggy submission (verdict: Runtime Error):
import collections

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

if n == 0:
    print(x)
    exit()
    
p = list(map(int, input().split()))
l = [i for i in range(1, 101)]

def calc(a):
    return abs(a - x)

if x in l:
    l.remove(x) 
for i in p:
    if i in l:
        l.remove(i)

l2 = list(map(calc, l))
m = min(l2)

if collections.Counter(l2)[m] == 2:
    print(-m + x)
else:
    print(m + x)

Buggy submission (verdict: Runtime Error):
import bisect
import collections

x, n = map(int, input().split())
p = list(map(int, input().split()))
l = [i for i in range(1, 101)]

def calc(a):
    return abs(a - x)

if n == 0:
    print(x)
    exit()

if x in l:
    l.remove(x) 
for i in p:
    if i in l:
        l.remove(i)

l2 = list(map(calc, l))
m = min(l2)

if collections.Counter(l2)[m] == 2:
    print(-m + x)
else:
    print(m + x)
Problem p02582 (python)

Fixed submission:
l = input()

if l == 'SSS':
	print(0)

elif l == 'SSR' or l == 'RSS' or l == 'SRS' or l == 'RSR':
	print(1)

elif l == 'SRR' or l == 'RRS':
	print(2)
  
elif l == 'RRR':
	print(3)

Buggy submission (verdict: Runtime Error):
if l == 'SSS':
	print(0)

elif l == 'SSR' or l == 'RSS' or l == 'SRS' or l == 'RSR':
	print(1)

elif l == 'SRR' or l == 'RRS':
	print(2)
  
elif l == 'RRR':
	print(3)
Problem p02554 (python)

Fixed submission:
n=int(input())
ans=10**n-2*(9**n)+8**n
ans=ans%1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=10**n-2*(9**n)+8**n
ans=ans%1000000007
print(ans)
Problem p02687 (python)

Fixed submission:
s = input()
if s == 'ARC':
    print('ABC')
else:
    print('ARC')

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
h_list = [int(i) for i in input().split()]
data = [list(map(int, input().split())) for _ in range(m)]

ten_set =set(np.array(range(1,n+1)))
ans_set =set([])
exist_set = set(np.array(range(1,n+1)))
for i in range(m):
    if h_list[data[i][0]-1] < h_list[data[i][1]-1]:
        ans_set.add(data[i][1])
        if data[i][0] in ans_set:
            ans_set.remove(data[i][0])
    elif h_list[data[i][0]-1] > h_list[data[i][1]-1]:
        
        ans_set.add(data[i][0])
        if data[i][1] in ans_set:
            ans_set.remove(data[i][1])
    elif h_list[data[i][0]-1] == h_list[data[i][1]-1]:
        if data[i][0] in ans_set:
            ans_set.remove(data[i][1])
        if data[i][1] in ans_set:
            ans_set.remove(data[i][1])
    exist_set.add(data[i][0])
    exist_set.add(data[i][1])

sa_set = ten_set − exist_set
ans_set = ans_set.union(sa_set)
print(len(ans_set))
Problem p02658 (python)

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

# a = [0, 10, 10, 10, 10]

a.sort()
r = 1
t = 10 ** 18
for x in a:
  r *= x
  if r > t:
    break
if r <= t:
  print(r)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
 
r = 1
t = 10 ** 18
for i in a:
  r *= a[i]
  if r > t:
    print(-1)
    return
print(r)

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

r = 1
t = 10 ** 18
for i in a:
  r *= a
  if r > t:
    print(-1)
    return
print(r)
Problem p02675 (python)

Fixed submission:
n = int(input())


n %= 10

if n == 0 or n == 1 or n == 6 or n==8:
  print('pon')
elif n == 2 or n==4 or n==5 or n==7 or n==9:
  print('hon')
else:
  print('bon')

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

n %= 10

if n == 0 or 1 or 6 or 8:
  print('pon')
elif n == 2 or 4 or 5 or 7 or 9:
  print('hon')
else:
  print('bon')
Problem p03699 (python)

Fixed submission:
n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
 
ss = sum(s)
if ss % 10 == 0:
  # sの中で10で割り切れない最小の数を引けば良い
  s.sort()
  m = [t for t in s if t%10!=0]
  if len(m) == 0:
    print(0)
  else:
    print(ss-min(m))
else:
  print(ss)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
 
ss = sum(s)
if ss % 10 == 0:
  # sの中で10で割り切れない最小の数を引けば良い
  s.sort()
  m = [t for t in s if t%10!=0]
  if len(m) == 0:
    print(0)
   else:
    print(ss-min(m))

Buggy submission (verdict: Runtime Error):
def minus_min(s):
  sum(s)-min(s)

n = int(input())
s = []
for i in range(n):
  s.append(input())

ss = sum(s)
if ss % 10 == 0:
  # sの中で10で割り切れない最小の数を引けば良い
  s.sort()
  m = [t for t in s if t%10!=0]
  if len(m) == 0:
    print(0)
   else:
    print(ss-min(m))
Problem p02630 (python)

Fixed submission:
n=int(input())
a=list(map(int, input().split()))
q=int(input())
num=[0]*(10**5)
tot=0
for i in range(n):
    num[a[i]-1]+=1
    tot+=a[i]

for _ in range(q):
    b,c=map(int, input().split())
    tot+=(num[b-1]*(c-b))
    num[c-1]+=num[b-1]
    num[b-1]=0
    print(tot)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
q=int(input())
num=[0]*(10**5-1)
tot=0
for i in range(n):
    num[a[i]-1]+=1
    tot+=a[i]

for _ in range(q):
    b,c=map(int, input().split())
    tot+=(num[b-1]*(c-b))
    num[c-1]+=num[b-1]
    num[b-1]=0
    print(tot)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
q=int(input())
num=[0]*(10**5-1)
tot=0
for i in range(n):
    num[a[i]-1]+=1
    tot+=a[i]

for i in range(q):
    b,c=map(int, input().split())
    tot+=num[b-1]*(c-b)
    print(tot)
    num[c-1]+=num[b-1]
    num[b-1]=0
Problem p02663 (python)

Fixed submission:
h1,m1,h2,m2,k=map(int,input().split())

if m1<=m2:
    print(max((h2-h1)*60+m2-m1-k,0))
else:
    print(max((h2-h1-1)*60+m2+60-m1-k,0))

Buggy submission (verdict: Runtime Error):
h1,m1,h2,m2,k=map(int,input().split())

if m1<=m2:
    print(max((h2-h1)*60+m2-m1-k),0)
else:
    print(max((h2-h1-1)*60+m2+60-m1-k,0))
Problem p02697 (python)

Fixed submission:
n,m=map(int, input().split())
if m%2==1:
    for i in range(m//2):
        print(i+1,m-i)
    for i in range(m//2+1):
        print(m+i+1,2*m+1-i)
else:
    for i in range(m//2):
        print(i+1,m+1-i)
    for i in range(m//2):
        print(m+i+2,2*m+1-i)

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

def using_sqrt(limit):
    n = 0
    for k in range(2, limit+1):
        factor = 0
        
        # 2以外の偶数は素数ではないので無視する
        if k % 2 == 0 and k != 2:
            continue
        
        # 繰り返しの上限を対象の平方根にする
        for divisor in range(2, math.floor(math.sqrt(k))+1):
            if k % divisor == 0:
                factor += 1
                
        if factor == 0:
            n += 1
            
    return n

for i in range(n):
    if m%using_sqrt(i)==0:
        ans=i
        break
for j in range(m):
    print(i+1,i+1+ans)
Problem p02784 (python)

Fixed submission:
h,n=map(int,input().split())
a=sorted(list(map(int,input().split())),reverse=True)

for i in range(n):
    h-=a[i]
if h>0:
    print('No')
else:
    print('Yes')

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

for i in range(n):
    h-=a[i]
if h>0:
    print('No')
else:
    print('Yes')
Problem p02885 (python)

Fixed submission:
a,b=map(int,input().split())
print(max(0,a-b*2))

Buggy submission (verdict: Runtime Error):
print(max(0,a-b*2))
Problem p02887 (python)

Fixed submission:
n=int(input())
s=input()
ans=1
flag=s[0]

for i in range(n-1):
  if s[i+1]!=flag:
    ans+=1
    flag=s[i+1]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=1

for i in range(n-1):
  flag=s[0]
  if s[i+1]!=flag:
    ans+=flag
    flag=s[i+1]
print(flag)
Problem p02947 (python)

Fixed submission:
n = int(input())
count = 0
dic = {}
for _ in range(n):
    key = ''.join(sorted(input()))
    if key in dic:
        count += dic[key]
        dic[key] += 1
    else:
        dic[key] = 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
count = 0
dic = {}
for _ in range(n):
    key = ''.join(sorted(input()))
    if key in dic:
        c += dic[key]
        dic[key] += 1
    else:
        dic[key] = 1
print(count)
Problem p02971 (python)

Fixed submission:
n=int(input())
a=[int(input()) for i in range(n)] 
m=a[0]
k=0

for i in range(n):
    if m<a[i]:
        m=a[i]
        k=i

for j in range(n):
    if j==k:
        print(sorted(a)[-2])
    else:
        print(m)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)] 
m=a[0]

for i in range(n):
    if m<a[i]:
        m=a[i]
        k=i

for j in range(n):
    if j==k:
        print(sorted(a)[-2])
    else:
        print(m)
Problem p03061 (python)

Fixed submission:
import fractions

n=int(input())
a=list(map(int, input().split()))
ans=[0]*n
left=[0]*n
right=[0]*n
max_=0

for i in range(n):
  if i==0:
    left[i]=a[0]
  else:
    left[i]=fractions.gcd(left[i-1],a[i])
for i in range(n-1,-1,-1):
  if i==n-1:
    right[i]=a[n-1]
  else:
    right[i]=fractions.gcd(right[i+1],a[i])
for i in range(n):
  if i==0:
    ans=right[1]
  elif i==n-1:
    ans=left[n-2]
  else:
    ans=fractions.gcd(left[i-1],right[i+1])
  if ans>max_:
    max_=ans
    
print(max_)

Buggy submission (verdict: Runtime Error):
import fractions
n=int(input())
a=list(map(int, input().split()))
ans=[0]*(n-1)
ans2=[0]*(n-1)

for i in range(1,n):
    ans[i-1] = fractions.gcd(a[0], a[i])
for i in range(0,n):
    if i==1:
        continue
    else:
        ans2[i-2] = fractions.gcd(a[1], a[i])
s_ans=sorted(ans)
s_ans2=sorted(ans2)

if n==2:
    print(max(a))
else:
    print(max(s_ans[1],s_ans2[1]))

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int, input().split()))
ans=[0]*(n-1)
ans2=[0]*(n-2)

for i in range(1,n):
    ans[i-1] = math.gcd(a[0], a[i])
for i in range(2,n):
    ans2[i-2] = math.gcd(a[1], a[i])
sorted(ans)
sorted(ans2)

if n==3:
    print(max(ans[0],ans2[0]))
elif n==2:
    print(max(a))
else:
    print(max(ans[1],ans2[1]))
Problem p03068 (python)

Fixed submission:
n=int(input())
s=list(input())
k=int(input())
p=s[k-1]

for i in range(n):
    if s[i]!=p:
        s[i]='*'
print(''.join(s))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
k=int(input())
p=s[k]
q=[0]*n
for i in range(n):
  if s[i]!=p:
    s[i]='*'
      
print(''.join(s))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
k=int(input())
p=s[k]
for i in range(n):
    if s[i]!=p:
        s[i]='*'
print(''.join(s))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
k=int(input())
for i in range(n):
    if s[i]!=s[k]:
        s[i]='*'
print(''.join(s))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
k=int(input())
for i in range(n):
    if s[i]!=s[k]:
        s[i]='*'
print(' '.join(s))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
k=int(input())
for i in range(n):
    if s[i]!=s[k]:
        s[i]='*'
print(print(' '.join(s)))
Problem p03074 (python)

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

judge=[0]
max_=0
for i in range(n-1):
  if s[i]!=s[i+1]:
    judge.append(i+1)
judge.append(n)

if len(judge)//2<=k:
  print(len(s))
else:
  for i in range(len(judge)-1):
    if s[judge[i]]=='0':
      ans=judge[min(i+2*k,len(judge)-1)]-judge[i]
    else:
      ans=judge[min(i+2*k+1,len(judge)-1)]-judge[i]
    if ans>max_:
      max_=ans
  print(max_)

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

judge=[0]
max_=0
for i in range(n-1):
  if s[i]!=s[i+1]:
    judge.append(i+1)
judge.append(n)

if len(judge)//2<=k:
  print(len(s))
else:
  for i in range(len(judge)-2*k):
    if s[judge[i]]=='0':
      ans=judge[i+2*k]-judge[i]
    else:
      ans=judge[i+2*k+1]-judge[i]
    if ans>max_:
      max_=ans
  print(max_)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
c=list(input())
place=[-1]
dist=[0]*n
for i in range(len(c)-1):
    if c[i]!=c[i+1]:
        place.append(i)
place.append(n-1)
for i in range(len(place)-2*k-2):
    dist[i]=place[i+2*k+2]-place[i]
print(max(max((dist))-1),n)
Problem p03241 (python)

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

ans=0
for i in range(1,int(m**0.5)+1):
    if m%i==0:
        if i<=m//n:
            tmp=i
        if i>=n:
            tmp=m//i
        if tmp>ans:
            ans=tmp
print(ans)

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

for i in range(1,int(m**0.5)+1):
    if m%i==0:
        if i<=m//n:
            tmp=i
        if i>=n:
            tmp=m//i
            print(tmp)
            sys.exit()
print(tmp)
Problem p03244 (python)

Fixed submission:
import collections
n=int(input())
v=list(map(int,input().split()))
c1=collections.Counter(v[::2])
c2=collections.Counter(v[1::2])
c1_v1=c1.most_common()[0][0]
c2_v1=c2.most_common()[0][0]
c1_n1=c1.most_common()[0][1]
c2_n1=c2.most_common()[0][1]

if c1_v1!=c2_v1:
    print(n-c1_n1-c2_n1)
else:
    if c1_n1==n//2:
        if c2_n1==n//2:
            print(n//2)
        else:
            c2_n2=c2.most_common(2)[1][1]
            print(n-c1_n1-c2_n2)
    else:
        c1_n2=c1.most_common(2)[1][1]
        if c2_n1==n//2:
            print(n-c1_n2-c2_n1)
        else:
            c2_n2=c2.most_common(2)[1][1]
            print(min(n-c1_n2-c2_n1,n-c1_n1-c2_n2))

Buggy submission (verdict: Runtime Error):
import collections
n=int(input())
v=list(map(int,input().split()))
c1=collections.Counter(v[::2])
c2=collections.Counter(v[1::2])
c1_v1=c1.most_common()[0][0]
c2_v1=c2.most_common()[0][0]
c1_n1=c1.most_common()[0][1]
c2_n1=c2.most_common()[0][1]
c1_n2=c1.most_common(2)[1][1]
c2_n2=c2.most_common(2)[1][1]

if c1_v1!=c2_v1:
    print(n-c1_n1-c2_n1)
else:
    if c1_n1==n//2:
        if c2_n1==n//2:
            print(n//2)
        else:
            print(n-c1_n1-c2_n2)
    else:
        if c2_n1==n//2:
            print(n-c1_n2-c2_n1)
        else:
            print(n-c1_n2-c2_n2)
Problem p03273 (python)

Fixed submission:
import numpy as np
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
np_a=np.array(a)
np_at=np_a.T
at=np_at.tolist()

r=[]
c=[]

for i in range(h):
    if a[i].count('#')==0:
        r.append(i)
for i in range(w):
    if at[i].count('#')==0:
        c.append(i)

for i in range(len(r)):
    del a[r[i]-i]
for j in range(len(c)):
    for i in range(h-len(r)):
        del a[i][c[j]-j]

for i in range(h-len(r)):
    print(''.join(a[i]))

Buggy submission (verdict: Runtime Error):
import numpy as np
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
np_a=np.array(a)
np_at=np_a.T
at=np_at.tolist()

r=[]
c=[]

for i in range(h):
    if a[i].count('#')==0:
        r.append(i)
for i in range(w):
    if at[i].count('#')==0:
        c.append(i)

k=h-len(r)
for i in r:
    del a[i]
for j in c:
    for i in range(k):
        del a[i][j]

for i in range(k):
    print(''.join(a[i]))
Problem p03289 (python)

Fixed submission:
import sys
s=input()
cnt=0
if s[0]!='A':
    print('WA')
elif s[1].isupper():
    print('WA')
elif s[-1].isupper():
    print('WA')
else:
    for i in range(2,len(s)-1):
        if s[i]=='C':
            cnt+=1
        else:
            if s[i].isupper():
                print('WA')
                sys.exit()
    if cnt==1:
        print('AC')
    else:
        print('WA')

Buggy submission (verdict: Runtime Error):
import sys
s=input()
cnt=0
if s[0]!='A':
    print('WA')
elif s[1].isuper():
    print('WA')
elif s[-1].isuper():
    print('WA')
else:
    for i in range(2,len(s)-1):
        if s[i]=='C':
            cnt+=1
        else:
            if s[i].isupper():
                print('WA')
                sys.exit()
    if cnt==1:
        print('AC')
    else:
        print('WA')
Problem p03316 (python)

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

if n%(sum(s))==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s=list(input())
n=int(s)
if n%(sum(s))==0:
  print('Yes')
else:
  print('No')
Problem p03565 (python)

Fixed submission:
s=list(input())
t=list(input())
a=-1

for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[j+i]!=t[j] and s[j+i]!='?':
            break
        if (s[j+i]==t[j] or s[j+i]=='?') and j==len(t)-1:
            a=i

if a<0:
    print('UNRESTORABLE')
else:
    for i in range(len(s)):
        if i>=a and i-a<len(t):
            s[i]=t[i-a]
        if s[i]=='?':
            s[i]='a'
    print(''.join(s))

Buggy submission (verdict: Runtime Error):
s=list(input())
t=list(input())
a=-1

for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[j+i]!=t[j] and s[j+i]!='?':
            break
        if (s[j+i]==t[j] or s[j+i]=='?') and j==len(t)-1:
            a=i

if a<0:
    print('UNRESTORABLE')
else:
    for i in range(len(s)):
        if i>=a:
            s[i]=t[i-a]
        if s[i]=='?':
            s[i]='a'
    print(''.join(s))

Buggy submission (verdict: Runtime Error):
s=list(input())
t=list(input())
a=-1

for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        if s[j+i]!=t[j] and s[j+i]!='?':
            break
        if (s[j+i]=='?' or s[j+i]=='?') and j==len(t)-1:
            a=i

if a<0:
    print('UNRESTORABLE')
else:
    for i in range(len(s)):
        if i>=a:
            s[i]=t[i-a]
        if s[i]=='?':
            s[i]='a'
    print(''.join(s))
Problem p02582 (python)

Fixed submission:
# -*- using:utf-8 -*-

if __name__ == "__main__":
  s = list(input())
  sum = 0
  for i in range(3):
    if s[i] == 'R':
      sum = 1
  if s[0] == 'R' and s[1] =='R':
    sum += 1
  if s[1] == 'R' and s[2] == 'R':
    sum += 1
  print(sum)

Buggy submission (verdict: Runtime Error):
# -*- using:utf-8 -*-
class main:
  def function(x, k, d):
    for i in range(k):
      if abs(x + d) >= abs(x - d):
        x = x - d
      if abs(x + d) < abs(x - d):
        x = x + d
    print(x)

if __name__ == "__main__":
  x, k, d = map(int, input().split())
  main.function(x,k,d)
Problem p03160 (python)

Fixed submission:
N = int(input())
h = list(map(int , input().split()))
dp = [10**9+1]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
h = list(map(int , input().split()))
dp = [-1]*N
import sys
sys.setrecursionlimit(100000)
def dfs(i,c):
    if i == N:
        return 10000
    if dp[i] != -1:
        return dp[i]
    else:
        if i == N-1:
            return abs(h[i] - c)
        dp[i] = min(dfs(i+1, h[i])+abs(h[i]-c),dfs(i+2, h[i])+abs(h[i]-c))
        return dp[i]
print(dfs(0,h[0]))

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

def dfs(i,c):
    if i == N:
        return 10000
    if i == N-1:
        return abs(h[i] - c)
    return min(dfs(i+1, h[i])+abs(h[i]-c),dfs(i+2, h[i])+abs(h[i]-c))

print(dfs(0,h[0]))
Problem p03162 (python)

Fixed submission:
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]

dp = [[-1]*3 for i in range(N)]
import sys
sys.setrecursionlimit(10**9)
def dfs(i,j):
    if i == N:
        return 0
    if dp[i][j] != -1:
        return dp[i][j]
    else:
        if j==0:
            dp[i][j] = max(dfs(i+1,1)+abc[i][1], dfs(i+1,2)+abc[i][2])
        elif j==1:
            dp[i][j] = max(dfs(i+1,0)+abc[i][0], dfs(i+1,2)+abc[i][2])
        else:
            dp[i][j] = max(dfs(i+1,0)+abc[i][0], dfs(i+1,1)+abc[i][1])
        return dp[i][j]
print(max(dfs(0,0), dfs(0,1), dfs(0,2)))

Buggy submission (verdict: Runtime Error):
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]

dp = [[-1]*3 for i in range(N)]
import sys
sys.setrecursionlimit(10**10)
def dfs(i,j):
    if i == N:
        return 0
    if dp[i][j] != -1:
        return dp[i][j]
    else:
        if j==0:
            dp[i][j] = max(dfs(i+1,1)+abc[i][1], dfs(i+1,2)+abc[i][2])
        elif j==1:
            dp[i][j] = max(dfs(i+1,0)+abc[i][0], dfs(i+1,2)+abc[i][2])
        else:
            dp[i][j] = max(dfs(i+1,0)+abc[i][0], dfs(i+1,1)+abc[i][1])
        return dp[i][j]
print(max(dfs(0,0), dfs(0,1), dfs(0,2)))

Buggy submission (verdict: Runtime Error):
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]

dp = [[-1]*3 for i in range(N)]
import sys
sys.setrecursionlimit(10**5)
def dfs(i,j):
    if i == N:
        return 0
    if dp[i][j] != -1:
        return dp[i][j]
    else:
        if j==0:
            dp[i][j] = max(dfs(i+1,1)+abc[i][1], dfs(i+1,2)+abc[i][2])
        elif j==1:
            dp[i][j] = max(dfs(i+1,0)+abc[i][0], dfs(i+1,2)+abc[i][2])
        else:
            dp[i][j] = max(dfs(i+1,0)+abc[i][0], dfs(i+1,1)+abc[i][1])
        return dp[i][j]
print(max(dfs(0,0), dfs(0,1), dfs(0,2)))

Buggy submission (verdict: Runtime Error):
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]

dp = [[-1]*3 for i in range(N)]
def dfs(i,j):
    if i == N:
        return 0
    if dp[i][j] != -1:
        return dp[i][j]
    else:
        if j==0:
            dp[i][j] = max(dfs(i+1,1)+abc[i][1], dfs(i+1,2)+abc[i][2])
        elif j==1:
            dp[i][j] = max(dfs(i+1,0)+abc[i][0], dfs(i+1,2)+abc[i][2])
        else:
            dp[i][j] = max(dfs(i+1,0)+abc[i][0], dfs(i+1,1)+abc[i][1])
        return dp[i][j]
print(max(dfs(0,0), dfs(0,1), dfs(0,2)))
Problem p03243 (python)

Fixed submission:
a = input()
if (a[-1] == '0' and (int(a[0]) >= int(a[1]))):
    ans = int(a[0] * 3)
elif(int(a[0]) >= int(a[2]) and int(a[0]) >= int(a[1]) and a[-1] != '0'):
    ans = int(a[0] * 3)
else:
    ans = str(int(a[0])+1)*3
print(ans)

Buggy submission (verdict: Runtime Error):
a = input()
if (a[-1] == '0' and (int(a[0]) >= int(a[2])) or  (int(a[0]) >= int(a[2]) and int(a[0]) >= int(a[1])):
    ans = int(a[0] * 3)
else:
    ans = str(int(a[0])+1)*3
print(ans)

Buggy submission (verdict: Runtime Error):
a = input()
if (a[-1] == '0' and (int(a[0]) >= int(a[2])) or  (int(a[0]) >= int(a[2]) and int(a[0]) >= int(a[1]))::
    ans = int(a[0] * 3)
else:
    ans = str(int(a[0])+1)*3
print(ans)
Problem p02784 (python)

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

h, n = map(int, input().split())
a = [int(i) for i in input().split()]

d = 0
for i in a:
    d += i

if h > d:
    print("No")
else:
    print("Yes")

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

h, n = map(int, input().split())
a = [int(i) for i in input().split()]

a.sort(key = lambda x : -1*x)

if h > a[0] + a[1]:
    print("No")
else:
    print("Yes")

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

h, n = map(int, input().split())
a = [int(i) for i in input().split()]

a.sort(key = lambda x : -1*x)

if h > a[0] + a[1]:
    print("Yes")
else:
    print("No")