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

Fixed submission:
N,M,C = list(map(int,input().split()))
import numpy as np
B = np.array(input().split() ,dtype=np.int64)
ret =0
for i in range(N):
    if( np.sum(B * np.array(input().split() ,dtype=np.int64)) +C>0):
        ret += 1
print(ret)

Buggy submission (verdict: Runtime Error):
N,M,C = list(map(int,input().split()))
import numpy as np
B = np.array(input().split() ,dtype=np.int64)
ret  =0
for i in range(N):
    if( np.sum(np.matmul(B , np.array(input().split() ,dtype=np.int64))) +C>0):
        ret += 1
print(ret)

Buggy submission (verdict: Runtime Error):
N,M,C = list(map(int,input().split()))
import numpy as np
B = np.array(input().split() ,dtype=np.int64)
ret  =0
for i in range(N):
    if( np.sum(np.matmul(B , np.array(input().split() ,dtype=np.int64))) +C>0):
        ret += 1
print(ret)
Problem p03163 (python)

Fixed submission:
N, W = list(map(int, input().split()))
wvList = [list(map(int, input().split())) for _ in range(N)]


from collections import defaultdict
dp = defaultdict(int)
dp[0]=0

for wv in wvList:
    w,v = wv
    tp = defaultdict(int,{ i[0]+w : i[1]+v  for i in dp.items() if i[0]+w<=W})
    for i in set(list(dp.keys())+list(tp.keys())):
        dp[i] = max(dp[i],tp[i])

print(max(dp.values()))

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

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

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

l = wvlist[0][0]
for wv in wvlist():
	l = lcm(wv[0],l)
  
dp = np.zeros((N,W+1))
for i, wv in enumerate(wvList):
    for j in range(1, W + 1,l):
        if j - wv[0] >= 0:
            dp[i][j] = np.max(dp[i-1][j-wv[0]] + wv[1], dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]

print(np.max(dp))
Problem p03165 (python)

Fixed submission:

sList, tList = input(), input()

dp = [[0] * (len(tList) + 1) for _ in range(len(sList)+1)]


# 横方向で回す
for i, s in enumerate(sList, start=1):
    for j, t in enumerate(tList, start=1):
        dp[i][j] = max([dp[i][j - 1], dp[i-1][j],
                        dp[i-1][j-1] + 1 if s == t else 0])
m = dp[i][j]
ans = ""
# traceback
cnt = 0
while i + j != 0:
    if dp[i - 1][j - 1] == m - 1 and tList[j-1] == sList[i-1]:
        ans = tList[j-1] + ans
        i -= 1
        j -= 1
        m -= 1
    else:
        if dp[i - 1][j] == m:
            i -= 1
        elif dp[i][j-1] == m:
            j -= 1
    cnt += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
sList, tList = input(), input()
dp = np.zeros((len(sList)+1, len(tList)+1), dtype=np.int16)


# 横方向で回す
for i, s in enumerate(sList, start=1):
    for j, t in enumerate(tList, start=1):
        dp[i][j] = np.max([dp[i][j - 1], dp[i-1][j],
                           dp[i-1][j-1] + 1 if s == t else 0])
m = dp[i][j]
ans = ""
# traceback
cnt = 0
while i + j != 0:
    if dp[i - 1][j - 1] == m - 1 and tList[j-1] == sList[i-1]:
        ans = tList[j-1] + ans
        i -= 1
        j -= 1
        m -= 1
    else:
        if dp[i - 1][j] == m:
            i -= 1
        elif dp[i][j-1] == m:
            j -= 1
    cnt += 1
print(ans)
Problem p03294 (python)

Fixed submission:
input()
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
li  = list(map(int,input().split(" ")))
s  = lcm(li[0],li[1])
for i in range(len(li)-2):
    s = lcm (s,li[i+2])
def f(m):
    r = 0
    for i  in li:
        r += m%i
    return r
print(f(s-1))

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
li  = list(map(int,input().split(" ")))
s  = lcm(li[0],li[1])
for i in range(len(li)-2):
    s = lcm (s,li[i+2])
def f(m):
    r = 0
    for i  in li:
        r += m%i
    return r
print(f(s-1))

Buggy submission (verdict: Runtime Error):
li  = list(map(int,input().split(" ")))
s  = lcm(li[0],li[1])
for i in range(len(li)-2):
    s = lcm (s,li[i+2])
def f(m):
    r = 0
    for i  in li:
        r += m%i
    return r
print(f(s-1))
Problem p03435 (python)

Fixed submission:
import numpy as np
A= np.array([list(map(int,input().split())) for I in range (3)])

for I in range (2):
    j,k,l = A[1]-A[0]
    if not (j==k and k==l):
        print ( "No")
        quit()
    j,k,l = A[2]-A[0]
    if not (j==k and k==l):
        print ( "No")
        quit()
print("Yes")

Buggy submission (verdict: Runtime Error):
import numpy as np
A= np.array([list(map(int,input()split())) for I in range (3)])

for I in range (2):
    j,k,l = A[1]-A[0]
    if not (j==k and k==l):
        print ( "No")
        quit()
    j,k,l = A[2]-A[0]
    if not (j==k and k==l):
        print ( "No")
        quit()
print("Yes")
Problem p03558 (python)

Fixed submission:
k = int(input())
from collections import deque
d = deque( )
d.append((1,1))
discovered = set()
while True:
  node, cost = d.popleft()
  discovered |= {node}
  if node == 0: 
  	print(cost)
  	quit()
  if (node*10)%k not in discovered:
    d.appendleft( ((node*10)%k  ,cost))
  if (node+1)%k not in discovered:
    d.append((node+1,cost+1))

Buggy submission (verdict: Runtime Error):
k = int(input())
from collections import deque
d = deque([1])
discovered = {1:1}
while true:
  q = d.popleft()
  if q == 0: 
  	print(discovered[q])
  	quit()
  if (q*10)%k not in discovered:
    if (q*10)%k == 0:
      
    d.appendleft((q*10)%k)
    discovered[(q*10)%k] = discovered[q]
  if q+1 not in discoverd:
    d.append(q+1)
    discovered[q+1] = discovered[q]+1
Problem p03598 (python)

Fixed submission:
N = int(input())
K = int(input())
x = list(map(int,input().split()))
res = 0
for i in x:
  res += 2* min(i,K-i)
print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())
x = list(map(int,input().split()))
res = 0
for i in x:
  res += 2* min(x,K-x)
print(res)
Problem p03679 (python)

Fixed submission:
X,A,B = list(map(int,input().split()))
if A >= B:
  print("delicious")
else:
  if B-A <= X:
    print("safe")
  else:
    print("dangerous")

Buggy submission (verdict: Runtime Error):
X,A,B = list(map(int,input()))
if A >= B:
  print("delicious")
else:
  if B-A <= X:
    print("safe")
  else:
    print("dangerous")
Problem p03695 (python)

Fixed submission:
rates  = [399,799,1199,1599,1999,2399,2799,3199]
from collections import defaultdict


def return_index(score):
  for i in rates:
    if score <= i:
      return rates.index(i)
  else:
    return 8

N = int(input())
A = list(map(int,input().split()))
d = defaultdict(int)
for a in A:
  d[return_index(a)] += 1
key_len = len(d.keys())
num_of_9s = d[8]
has_9 = 1 if num_of_9s > 0 else 0
print("{} {}".format(max(1,key_len-has_9),key_len-has_9+num_of_9s ))

Buggy submission (verdict: Runtime Error):
rates  = [399,799,1199,1599,1999,2399,2799,3199]
from collections import defaultdict


def return_index(score):
  for i in rates:
    if score <= i:
      return rates.index(i)
  else:
    return 8

N = int(input())
A = list(map(int,input().split()))
d = defaultdict(int)
for a in A:
  d[return_index(a)] += 1
num_of_9s = d[8]
has_9 = 1 if num_of_9s > 0 else 0
print("{} {}".format(len(d.keys()-has_9 ),len(d.keys())-has_9+num_of_9s ))
Problem p03721 (python)

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

AB =sorted([tuple(map(int,input().split())) for i in range(N)])

B=0

for a,b in AB:
  #print(K,N,a,b,B)
  B+=b
  if B>=K :
    print(a)
    quit()
  #B+=b

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

AB =sorted([tuple(map(int,input().split())) for i in range(N)],key=lambda x:-x[0])

B=1

for a,b in AB:
  a,b=tuple(map(int,
  if B>=K :
    print(a)
    quit()
  B+=b
Problem p03759 (python)

Fixed submission:
a,b,c = list(map(int,input().split()))
if a+c == 2*b:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a,b,c = list(map(int,input()))
if a+c ==c:
  print("YES")
else:
  print("NO")
Problem p03773 (python)

Fixed submission:
print((lambda a : (a[0]+a[1])%24)(list(map(int,input().split())) ))

Buggy submission (verdict: Runtime Error):
print((lambda a,b : (a+b)//24)(list(map(int,input().split())) ))
Problem p04043 (python)

Fixed submission:
if [5,5,7] == list(map(int,sorted(input().split()))):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
if [5,5,7] == list(map(int,input().split().sorted())):
  print("YES")
else:
  print("NO")
Problem p04047 (python)

Fixed submission:
a = input()
lst = list(map(int,input().split(" ")))
lst.sort()
ans=0
for i in range(int(len(lst)/2)):
  ans += lst[len(lst)-2*i-2]
 
print(ans)

Buggy submission (verdict: Runtime Error):
def tri_len(x,y):
  if x== y:
    return x
  elif x < y:
    return tri_len(y-x,x)+2*x
  else:
    return tri_len(x-y,y)+2*y
import sys
sys.setrecursionlimit(100000)

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

print( n+tri_len(x,n-x))

Buggy submission (verdict: Runtime Error):
def tri_len(x,y):
  if x== y:
    return x
  elif x < y:
    return tri_len(y-x,x)+2*x
  else:
    return tri_len(x-y,y)+2*y
import sys
sys.setrecursionlimit(10000)

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

print( n+tri_len(x,n-x))

Buggy submission (verdict: Runtime Error):
a = input()
lst = input().split(" ")
lst.sort()
ans=0
for i in range(int(len(lst))):
  ans += lst[len(lst)-2*i-2]

print(ans)
Problem p02687 (python)

Fixed submission:
def main():
    S = input()
    if(S == "ABC"):
        print("ARC")
    else:
        print("ABC")
main()

Buggy submission (verdict: Runtime Error):
def main()
    S = input()
    if(S == "ABC"):
        print("ABC")
    else:
        print("ARC")
main()
Problem p02743 (python)

Fixed submission:
a, b, c = map(int, input().split())
if(c - a - b >= 0 and a * b * 4 < (c - a - b)**2):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(long, input().split())
if(a * b * 4 < (c - a - b)**2):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import math
a, b, c = map(int, input().split())
log_ab = math.log10(a*b)
log_cab = math.log10(c - a - b)
log_2 = math.log10(2)
if(log_ab < 2 * log_cab - 2 * log_2):
    print("Yes")
else:
    print("No")
Problem p03543 (python)

Fixed submission:
def main():
    N = input()
    c = [c for c in N]
    if((c[0] == c[1] and c[0] == c[2]) or (c[1] == c[2] and c[1] == c[3])):
        print("Yes")
    else:
        print("No")

main()

Buggy submission (verdict: Runtime Error):
def main():
    N = input()
    c_list = [c for c in N]
    if((c[0] == c[1] and c[0] == c[2]) or (c[1] == c[2] and c[1] == c[3])):
        print("Yes")
    else:
        print("No")

main()
Problem p02697 (python)

Fixed submission:
n,m = map(int,input().split())
l=1
if n%2==1:
    r=n
    for i in range(m):
        d=min(abs(l-r),n-abs(l-r))
        print(l,r)
        l+=1
        r-=1
else:
    if n%4==0:
        r=n-1
    else:
        r=n
    rev=False
    for i in range(m):
        d=min(abs(l-r),n-abs(l-r))
        if d == n//2:
            rev=True
            l+=1
            print(l,r)
        else:
            print(l,r)
        l+=1
        r-=1

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l=1
if n%2==1:
    r=n
    for i in range(m):
        print(l,r,min(abs(l-r)))
        l+=1
        r-=1
else:
    if n%4==0:
        r=n
    else:
        r=n-1
    print(l,r,min(abs(l-r),n-abs(l-r)))
    for i in range(m-1):
        l+=1
        r-=1
        print(l,r,min(abs(l-r),n-abs(l-r)))
        if min(abs(l-r),n-abs(l-r))==n//2-1:
            l+=1
Problem p02705 (python)

Fixed submission:
r=int(input())





print(2*r*3.14159265)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
bs=[0 for _ in range(n)]
for x in a:
    bs[x-1]+=1


for x in bs:
    print(x)
Problem p02713 (python)

Fixed submission:
import sys
sys.setrecursionlimit(4100000)


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


k=int(input())
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    d=gcd(i,j)
    for l in range(1,k+1):
      if d!=1:
        ans+=gcd(d,l)
      else:
        ans+=1


print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a%b)


k=input()
ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    d=gcd(i,j)
    for l in range(1,k+1):
      if d!=1:
        ans+=gcd(d,l)
      else:
        ans+=1


print(ans)
Problem p02814 (python)

Fixed submission:
def gcd(a,b):
    if a % b == 0:
        return b
    else:
        return gcd(b,a%b)

n,m = map(int,input().split())
a = list(map(int,input().split()))
a = [a[i]//2 for i in range(n)]
l = 1
b = -1
for x in a:
    if l % x != 0:
        l = l * x // gcd(l,x)
    c = 0
    while x % 2 == 0:
        x = x // 2
        c += 1
    if b != -1 and b != c:
        print(0)
        exit()
    elif b == -1:
        b = c
        
ans = m // l
ans = (ans + 1) // 2
print(ans)
#print(l)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)

n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(set(a))
b=[x//2 for x in a]
b.sort(reverse=1)
v,w=b[0],b[1]
l=v*w//gcd(v,w)
for x in b:
  if l%x!=0:
    l=l*x//gcd(l,x)
ans=((m//l)+1)//2

print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)

n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(set(a))
b=[x//2 for x in a]
b.sort(reverse=1)
v,w=b[0],b[1]
l=v*w//gcd(v,w)
for x in b:
  if l%x!=0:
    l=l*x//gcd(l,x)
ans=((m//l)+1)//2

print(ans)
Problem p03087 (python)

Fixed submission:
n,q=map(int,input().split())
s=input()
c=[0 for _ in range(n)]
p=''
d=0
for i in range(n):
  x=s[i]
  if p=='A' and x=='C':
    d+=1
  p=x
  c[i]=d
for i in range(q):
  ans=0
  l,r=map(int,input().split())
  ans=c[r-1]-c[l-1]

  print(ans)

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
c=[0 for _ in range(n)]
p=''
for i in range(1,n):
  x=s[i]
  if p=='A' and x='C':
    c[i-1]=1
  p=x
for i in range(q):
  ans=0
  l,r=map(int,input().split())
  ans=sum(c[l-1:r-1])
 # if s[]
  print(ans)

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
s=input()
for i in range(n):
  l,r=map(int,input().split())
  print(s[l-1:r].count('AC'))
Problem p03476 (python)

Fixed submission:
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

q = int(input())
n = 100000
ass = primes(n)
lkn = []
for p in ass:
    l = (p + 1) // 2
    if l in ass:
        lkn.append(p)
cnt = 0
pre = 1
ans = {}
lkn.append(100001)
for p in lkn:
    for i in range(pre,p,2):
        ans[i] = cnt
    cnt += 1
    pre = p
for i in range(q):
    l,r = map(int,input().split())
    l = max(l-2,1)
    print(ans[r] - ans[l])
    #print(ans[r],ans[l])
#print(lkn)

Buggy submission (verdict: Runtime Error):
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

q = int(input())
n = 100000
ass = primes(n)
lkn = []
for p in ass:
    l = (p + 1) // 2
    if l in ass:
        lkn.append(p)
cnt = 0
pre = 1
ans = {}
for p in lkn:
    for i in range(pre,p,2):
        ans[i] = cnt
    cnt += 1
    pre = p
for i in range(q):
    l,r = map(int,input().split())
    l = max(l-2,1)
    print(ans[r] - ans[l])
    #print(ans[r],ans[l])
#print(lkn)
Problem p03477 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
if a+b>c+d:
  print('Left')
elif a+b==c+d:
  print('Balanced')
else:
  print('Right')

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
if a+b>c+d:
  print('Left')
elif a+b=c+d:
  print('Balanced')
else:
  print('Right')
Problem p03485 (python)

Fixed submission:
a,b=map(int,input().split())
print((a+b+1)//2)

Buggy submission (verdict: Runtime Error):
a,b=map(int.input().split())
print((a+b+1)//2)
Problem p03563 (python)

Fixed submission:
r=int(input())
g=int(input())
print(g*2-r)

Buggy submission (verdict: Runtime Error):
r,g=map(int,input().split())
print(g*2-r)
Problem p03623 (python)

Fixed submission:
x,a,b=map(int,input().split())
c=abs(x-a)
d=abs(x-b)
print('A' if c<d else 'B')

Buggy submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
print(min(abs(x-a)),abs(x-b))
Problem p03680 (python)

Fixed submission:
n=int(input())
ans=1
a=[]
for i in range(n):
  a.append(int(input()))
x=a[0]
if x==2:
  print(ans)
  exit()
for i in range(n):
  x=a[x-1]
  if x==2:
    print(ans+1)
    exit()
  else:
    ans+=1
print(-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=1
a=[]
for i in range(n):
  a.append(int(input()))
x=a[0]
if x=-2:
  print(ans)
  exit()
for i in range(n):
  x=a[x-1]
  if x==2:
    print(ans+1)
    exit()
  else:
    ans+=1
print(-1)
Problem p03761 (python)

Fixed submission:
n=int(input())
#t=list(input())
#t.sort()
abc='abcdefghijklmnopqrstuvwxyz'
c=0
y=''
a=[0 for i in range(len(abc))]
'''
for i in range(len(abc)):
  a[i]=t.count(abc[i])
print(a,t)
'''
s=['' for i in range(n)]
for i in range(n):
  s[i]=input()

ans=''
for x in abc:
  z=100
  v=100
  for w in s:
    z=w.count(x)
    v=min(z,v)
  ans+=x*v
    
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
abc='abcdefghijklmnopqrstuvwxyz'
ans=''
for x in abc:
  z=100
  v=100
  for i in range(n):
    s=input()
    z=s.count(x)
    v=min(z,v)
  ans+=x*v   
print(ans)
Problem p03860 (python)

Fixed submission:
_,s,_=input().split()
print('A'+s[0]+'C')

Buggy submission (verdict: Runtime Error):
_,s_=input().split()
print('A'+s[0]+'C')
Problem p02684 (python)

Fixed submission:
n, k = [int(i) for i in input().split()]
towns = [int(i) for i in input().split()]
ind_ = 1
ts = []
visited = [0]*n
loop_s = None
while(True):
    ind_ = towns[ind_-1]
    if visited[ind_-1]:
        loop_s = ts.index(ind_)
        break
    else:
        visited[ind_-1] = 1
        ts.append(ind_)
if k <= len(ts):
    print(ts[k-1])
else:
    init = len(ts[:loop_s])
    loop_l = len(ts) - init
    loop = ts[loop_s:]
    print(loop[((k-init)%loop_l)-1])

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
towns = [int(i) for i in input().split()]
ind_ = 1
ts = []
roop_s = None
for i in range(k):
    ind_ = towns[ind_-1]
    if ind_ in ts:
        roop_s = ts.index(ind_)
        break
    else:
        ts.append(ind_)
init = len(ts[:roop_s])
roop_l = len(ts) - init
roop = ts[roop_s:]
print(roop[((k-init)%roop_l)-1])

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
towns = [int(i) for i in input().split()]
ind_ = 1
ts = []
roop_s = None
for i in range(k):
    ind_ = towns[ind_-1]
    if ind_ in ts:
        roop_s = ts.index(ind_)
        break
    else:
        ts.append(ind_)
init = len(ts[:roop_s])
roop_l = len(ts) - init
roop = ts[roop_s:]
print(roop[((k-init)%roop_l)-1])

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
towns = [int(i) for i in input().split()]
ind_ = 1
ts = []
roop_s = None
for i in range(15):
    ind_ = towns[ind_-1]
    if ind_ in ts:
        roop_s = ts.index(ind_)
        break
    else:
        ts.append(ind_)
init = len(ts[:roop_s])
roop_l = len(ts) - init
roop = ts[roop_s:]
print(roop[((k-init)%roop_l)-1])
Problem p02702 (python)

Fixed submission:
s = input()
l = len(s)
dp = [0]*2019
dp[0] = 1
r = 0
for i in range(1, l + 1):
    r += int(s[-i]) * pow(10, i - 1, 2019)
    r %= 2019
    dp[r] += 1
    
print(sum([(i * (i - 1)) // 2 for i in dp]))

Buggy submission (verdict: Runtime Error):
import numpy as np
s = input()
cnt = 0
ss = []
nums = np.array([(i+1)*2019 for i in range(200000//2019) if not "0" in str((i+1)*2019)])
for start in range(len(s)):
  end = start + 3
  while(end+1<=len(s)):
    if int(s[start:end+1]) in nums:
      cnt += 1
    end += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import numpy as np
s = input()
cnt = 0
ss = []
nums = np.array([(i+1)*2019 for i in range(200000//2019) if not "0" in str((i+1)*2019)])
for start in range(len(s)):
  end = start + 3
  while(end+1<=len(s)):
    if int(s[start:end+1]) in nums:
      cnt += 1
    end += 1
print(cnt)
Problem p02917 (python)

Fixed submission:
N = int(input())
B = [int(i) for i in input().split()]
A = [0]*N

for i in range(N):
    if i == 0:
        A[i] = B[0]
    else:
        if i < N-1:
            if B[i-1] <= B[i]:
                A[i] = B[i-1]
                A[i+1] = B[i]
            else:
                A[i] = B[i]
                # A[i+1] = B[i+1]
        else:
            A[i] = B[-1]
print(sum(A))

Buggy submission (verdict: Runtime Error):
N = int(input())
B = [int(i) for i in input().split()]
A = [0]*N

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

Buggy submission (verdict: Runtime Error):
N = int(input())
B = [int(i) for i in input().split()]
A = [0]*N

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

Buggy submission (verdict: Runtime Error):
N = int(input())
foods = [int(i) for i in input().split()]
eff = sum([int(i) for i in input().split()])
plus = [int(i) for i in input().split()]
if foods[-1]-2 in plus:
  print(eff + plus[foods[-1]-2])
else:
  print(eff)
Problem p03160 (python)

Fixed submission:
N = int(input())

hights = [int(h) for h in input().split()]


eval = []

def chmin(a,b):
    if a > b:
        b = a
        return True
    return False

for i in range(N):
    if i == N:
        break
    elif i == 0:
        eval.append(0)
        continue
    elif i == 1:
        eval.append(abs(hights[i] - hights[i-1] ))
        continue

    to_next = abs(hights[i] - hights[i-1]) + eval[i-1]
    prev_to_next = abs(hights[i] - hights[i-2]) + eval[i-2]
    if prev_to_next > to_next:
        eval.append(to_next)
    else:
        eval.append(prev_to_next)
print(eval[N-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
steps = [int(i) for i in input().split()]
dp = [float('inf')]*N
for i in range(N):
  if i == 0:
    dp[0] = 0
    dp[1] = abs(steps[1] - steps[0])
    dp[2] = abs(steps[2] - steps[0])
  else:
    # 現在位置までのコスト + 隣に行くコスト　を登録済みのDPテーブルと比較し、小さい方で更新
    if i+1 < N:
    	dp[i+1] = min(abs(steps[i] - steps[i+1]) + dp[i], dp[i+1])
    if i+2 < N:
    	dp[i+2] = min(abs(steps[i] - steps[i+2]) + dp[i], dp[i+2])
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N = input()
input = input()
hights = [int(h) for h in input.split()]

print(hights)

eval = []

def chmin(a,b):
    if a > b:
        b = a
        return True
    return False

for i in range(N):
    if i == N:
        break
    elif i == 0:
        eval.append(0)
        continue
    elif i == 1:
        eval.append(abs(hights[i] - hights[i-1] ))
        continue

    to_next = abs(hights[i] - hights[i-1]) + eval[i-1]
    prev_to_next = abs(hights[i] - hights[i-2]) + eval[i-2]
    if prev_to_next > to_next:
        eval.append(to_next)
    else:
        eval.append(prev_to_next)
print(eval)
print(eval[N-1])
Problem p03844 (python)

Fixed submission:
a, op, b = map(str, input().split())
if op == "+":
    print(int(a)+int(b))
else:
    print(int(a)-int(b))

Buggy submission (verdict: Runtime Error):
a, op, b = map(str, input().split())
print(eval(f"{a}{op}{b}"))