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

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

# 部分文字列の和を算出
array = []
now_num = 1
count = 0
for i in s:
  if now_num == int(i):
    count += 1
  else:
    array.append(count)
    count = 1
    now_num = 1 - now_num

if count != 0:
  array.append(count)

if len(array) % 2 == 0:
  array.append(0)

res = 0
add = 2 * k + 1
ans = 0
left = 0
right = 0
tmp = 0

for i in range(len(array))[::2]:
    next_left = i
    next_right = min(i+add, len(array))
    # 尺取法
    while next_left > left:
        tmp -= array[left]
        left += 1
    while next_right > right:
        tmp += array[right]
        right += 1
    ans = max(tmp,ans)

print(ans)

Buggy submission (verdict: Runtime Error):
aa

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

s = list(str(input()))

first_index=0
last_index=0

res = 0
for f in range (first_index, n+1):
  for l in range (last_index, n+1):
    if f < l:
      continue
    check = 0
    for i in range(f, l+1):
      if s[i] == 0:
        check += 1
    if check <= k:
      if l-f > res:
        res = l-f

print(res)
Problem p03079 (python)

Fixed submission:
s = list(input().split())
if s.count(s[0]) == 3:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = list(input().split)
if s.count(s[0]) ==3:
  print('Yes')
else:
  print('No')
Problem p03086 (python)

Fixed submission:
s = list(input())

res = 0
max = 0
for i in s:
  if i == 'A' or i == 'T' or i == 'C' or i == 'G':
    res += 1
  elif max <res:
    max = res
    res = 0
  else:
    res = 0

if max < res:
  max = res

print(max)

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

res = 0
max = 0
for i in s:
  if i == 'A' or i == 'T' or i == 'C' or i == 'G':
    res += 1
  elif max <res:
    max = res
    res = 0
  else:
    res = 0

if max < res:
  max = res
-
print(max)
Problem p03087 (python)

Fixed submission:
# 累積和の考え方
#   listに積み重ねた数値を出しておくことで特定範囲の数値を求める時間を短縮する
#   例：ABBBBAABBBBAB があるときに(l,r)にAがいくつ含まれるかを求める場合は以下のように(1長い)listを作る
#      BBABBBAABBBBAA
#      000111123333345
#   このリストの文字列のr-lで出せる(3,7)ならstr[7]-str[3]を出すと3-1で2となる

n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]

# 累積和のリストを作成
cumsum = [0]*(n+1)
for i in range(1, n):
    if s[i-1] == 'A' and s[i] == 'C':
        cumsum[i+1]+=cumsum[i]+1
    else:
        cumsum[i+1]=cumsum[i]

# 012345   index
# 123456   input
# ACACAC   s
# 0011223  cumsum
for left, right in lr:
    print(cumsum[right]-cumsum[left])

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

for cnt in range(q):
  l, r = list(map(int , input()))
  print(s[l-1:r].count('AC'))
Problem p03164 (python)

Fixed submission:
n,w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

sum_v = sum([wv[i][1] for i in range(n)])

# dp[i][j]: i番目の品物までで価値がj以上であるときの重さの最小値
dp = [[float('inf')]*(sum_v+1) for _ in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for j in range(sum_v+1):
        # 品物を選ぶ場合
        if (j - wv[i][1] >= 0):
            dp[i+1][j] = min(dp[i][j], dp[i][j-wv[i][1]] + wv[i][0])
        # 品物を選ばない場合
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
ans = 0
for i in range(sum_v+1):
    if dp[n][i] <= w:
        ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j < wv[i][0]:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-wv[i][0]] + wv[i][1])
print(dp[N][W])
Problem p03290 (python)

Fixed submission:
d,g = map(int, input().split())

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

ans=float('inf')
for bit in range(2**d):
    b = 0
    score = 0
    num = 0
    # ボーナスを貰えるまで問題を解く場合を計算
    # bit探索し、ボーナスを貰うパターンを網羅する
    for i in range(d):
        if (bit >> i) & 1:
            # 問題を解いた点 + ボーナス
            score += pc[i][0] * (i+1) * 100 + pc[i][1]
            # 解いた問題数
            num += pc[i][0]
        else:
            # ボーナスを貰えるまで解かない問題の場合
            # この値には最終的にはボーナスを貰えるまでは解かない、最大点がもらえる問題の番号が入る
            b = i

    # ボーナスを貰えるまでは解かない問題による加点と回答の更新を行う
    for j in range(pc[b][0]):
        if score>=g and num<ans:
            ans=num
        score+=(b+1)*100
        num+=1

print(ans)

Buggy submission (verdict: Runtime Error):
d,g = map(int, input().split())

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

ans=float('inf')
for bit in range(2**d):
    b = 0
    score = 0
    num = 0
    # ボーナスを貰えるまで問題を解く場合を計算
    # bit探索し、ボーナスを貰うパターンを網羅する
    for i in range(d):
        if (bit >> i) & 1:
            # 問題を解いた点 + ボーナス
            score += pc[0][i] * (i+1) * 100 + pc[1][i]
            # 解いた問題数
            num += pc[0][i]
        else:
            # ボーナスを貰えるまで解かない問題の場合
            # この値には最終的にはボーナスを貰えるまでは解かない、最大点がもらえる問題の番号が入る
            b = i

    # ボーナスを貰えるまでは解かない問題による加点と回答の更新を行う
    for j in range(pc[b][0]):
        if score>=g and num<ans:
            ans=num
        score+=(b+1)*100
        num+=1

print(ans)
Problem p03425 (python)

Fixed submission:
n = int(input())
# M,A,R,C,H
num = [0] * 5
check_list = ['M','A','R','C','H']
for _ in range(n):
    s = input()
    for i, c in enumerate(check_list):
        if s[0] == c:
            num[i]+=1
            break
ans = 0
for i in range(5-2):
    for j in range(i+1, 5-1):
        for k in range(j+1, 5):
            ans += num[i]*num[j]*num[k]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
# M,A,R,C,H
num = [0] * 5
check_list = ['M','A','R','C','H']
for _ in range(n):
    s = input()
    for i, c in enumerate(check_list):
        if s[0] == c:
            num[i]+=1
            break
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            ans += num[i]*num[j]*num[k]
print(ans)
Problem p03471 (python)

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

for x in range(n+1):
    for y in range(n+1-x):
        tmp = n-x-y
        if (x*10000+y*5000+tmp*1000) == s:
            print('{} {} {}'.format(x,y,tmp))
            exit(0)

print('-1 -1 -1')

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

for x in range(n):
    for y in range(n):
        tmp = n-x-y
        tmp2 = s-x*10000-y*5000
        if tmp*1000 == tmp2 and tmp >= 0:
            print(f'{x} {y} {tmp}')
            exit(0)

print('-1 -1 -1')

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

for x in range(n):
    for y in range(n):
        tmp = n-x-y
        tmp2 = s-x*10000-y*5000
        if tmp*1000 == tmp2:
            print(f'{x} {y} {tmp}')
            exit(0)

print('-1 -1 -1')
Problem p03504 (python)

Fixed submission:
n, c = map(int, input().split())
# input時に前処理として以下のことをしておく
#   * 開始時間を-1(-0.5の制約だが、-1しても変わらないので-1する)しておく

# テレビ局の番組をチャンネルごとに登録
r = [[0 for i in range(c)] for j in range(100000)]
for _ in range(n):
    s,t,c = map(int, input().split())
    for j in range(s-1, t):
        r[j][c - 1] = 1
# print(*r,sep='\n')

ans = 0
for i in range(len(r)):
    ans = max(ans, sum(r[i]))
print(ans)


# 補足
# チャンネル数4の場合以下のような配列ができる
# 1行でとある時間のチャンネル状態(1: 録画する, 0: 録画しない)がつく
#[0, 0, 0, 0]
#[0, 0, 1, 0]
#[1, 1, 1, 0]  <- この時間で3チャンネル録画が必要
#[1, 1, 0, 0]  <- この時間で2チャンネル録画が必要
#[1, 1, 0, 0]
#[1, 0, 0, 0]

Buggy submission (verdict: Runtime Error):
n, c = map(int, input().split())
# input時に前処理として以下のことをしておく
#   * 開始時間を-1(-0.5の制約だが、-1しても変わらないので-1する)しておく

# テレビ局の番組をチャンネルごとに登録
r = [[0 for i in range(c)] for j in range(100)]
for _ in range(n):
    s,t,c = map(int, input().split())
    for j in range(s-1, t):
        r[j][c - 1] = 1
# print(*r,sep='\n')

ans = 0
for i in range(len(r)):
    ans = max(ans, sum(r[i]))
print(ans)


# 補足
# チャンネル数4の場合以下のような配列ができる
# 1行でとある時間のチャンネル状態(1: 録画する, 0: 録画しない)がつく
#[0, 0, 0, 0]
#[0, 0, 1, 0]
#[1, 1, 1, 0]  <- この時間で3チャンネル録画が必要
#[1, 1, 0, 0]  <- この時間で2チャンネル録画が必要
#[1, 1, 0, 0]
#[1, 0, 0, 0]
Problem p03575 (python)

Fixed submission:
n, m = map(int, input().split())
edges = [[0 for _ in range(50)] for _ in range(50)]
for _ in range(m):
    a,b = map(int, input().split())
    edges[a-1][b-1] = 1
    edges[b-1][a-1] = 1

def dfs(start):
    if visited[start]:
        return
    visited[start] = 1
    for i in range(n):
        if edges[start][i]:
            dfs(i)

ans = m
# edgeを一つづつ見ていく
for i in range(m-1):
    for j in range(i+1, m):
        if not edges[i][j]:
            continue
        # エッジを削除した場合に、連結しているかをdfsで確認
        #   visited: 訪れたかどうかを表す変数
        visited = [0] * n
        edges[i][j] = 0
        edges[j][i] = 0
        dfs(0)
        # お片付け、削除したedgeを元に戻しておく
        edges[i][j] = 1
        edges[j][i] = 1
        # 全て訪れられていたら、そのエッジはなくても非連結にならないので、bridgeではない
        if sum(visited) == n:
            ans -=1

print(ans)

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

def dfs(start):
    if visited[start]:
        return
    visited[start] = 1
    for i in range(n):
        if edges[start][i]:
            dfs(i)

ans = m
# edgeを一つづつ見ていく
for i in range(m-1):
    for j in range(i+1, m):
        if not edges[i][j]:
            continue
        # エッジを削除した場合に、連結しているかをdfsで確認
        #   visited: 訪れたかどうかを表す変数
        visited = [0] * n
        edges[i][j] = 0
        edges[j][i] = 0
        dfs(0)
        # お片付け、削除したedgeを元に戻しておく
        edges[i][j] = 1
        edges[j][i] = 1
        # 全て訪れられていたら、そのエッジはなくても非連結にならないので、bridgeではない
        if sum(visited) == n:
            ans -=1

print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
edges = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
    a,b = map(int, input().split())
    edges[a-1][b-1] = 1
    edges[b-1][a-1] = 1

def dfs(start):
    if visited[start]:
        return
    visited[start] = 1
    for i in range(n):
        if edges[start][i]:
            dfs(i)

ans = m
# edgeを一つづつ見ていく
for i in range(m-1):
    for j in range(i+1, m):
        if not edges[i][j]:
            continue
        # エッジを削除した場合に、連結しているかをdfsで確認
        #   visited: 訪れたかどうかを表す変数
        visited = [0] * n
        edges[i][j] = 0
        edges[j][i] = 0
        dfs(0)
        # お片付け、削除したedgeを元に戻しておく
        edges[i][j] = 1
        edges[j][i] = 1

        # 全て訪れられていたら、そのエッジはなくても非連結にならないので、bridgeではない
        if sum(visited) == n:
            ans -=1

print(ans)
Problem p03633 (python)

Fixed submission:
n = int(input())
t = [int(input()) for _ in range(n)]

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

#2数の積/最大公約数=最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

if n == 1:
    print(t[0])
    exit(0)
ans = lcm(t[0], t[1])
for i in range(1, n-1):
    ans = lcm(ans, t[i+1])
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
t = [int(input()) for _ in range(n)]

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

#2数の積/最大公約数=最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

ans = lcm(t[0],t[1])
for i in range(1, n-1):
    ans = lcm(ans,t[i+1])
print(ans)
Problem p03695 (python)

Fixed submission:
n = int(input())
a = map(int, input().split())
c = [0]*9

for i in a:
    col = i//400
    if 3200 <= i:
        c[8] += 1
    else:
        c[col] = 1
print(max(1,sum(c[:8])),sum(c))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
c = [0]*9

for i in a:
    col = i//400
    if 4800<= i:
        c[8] += 1
    else:
        c[col] = 1
print(max(1,sum(c[:8])),sum(c))
Problem p02681 (python)

Fixed submission:
s=input()
t=input()
if len(t)==len(s)+1 and t[0:len(s)]==s:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n,k=map(int,input().split())
l=list(map(int,input().split()))
d=defaultdict(int)
for i in range(n):
    d[i+1]=l[i]
visited=set()
l=[]
i=1
while True:
    l.append(i)
    if i not in visited:
        visited.add(i)
    else:
        break
    i=d[i]
first=l.index(l[-1])
if k<first:
    print(l[k])
else:
    k=(k-first)%((len(l)-1)-first)
    k+=first
    print(l[k])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n,k=map(int,input().split())
l=list(map(int,input().split()))
d=defaultdict(int)
for i in range(n):
    d[i+1]=l[i]
visited=set()
l=[]
i=1
while True:
    l.append(i)
    if i not in visited:
        visited.add(i)
    else:
        break
    i=d[i]
first=l.index(l[-1])

k=(len(l)-first)%((len(l)-1)-first)
k+=first
if k<first:
    print(l[k])
else:
    print(l[k-1])
Problem p02684 (python)

Fixed submission:
from collections import defaultdict
n,k=map(int,input().split())
l=list(map(int,input().split()))
d=defaultdict(int)
for i in range(n):
    d[i+1]=l[i]
visited=set()
l=[]
i=1
while True:
    l.append(i)
    if i not in visited:
        visited.add(i)
    else:
        break
    i=d[i]
first=l.index(l[-1])
if k<first:
    print(l[k])
else:
    k=(k-first)%((len(l)-1)-first)
    k+=first
    print(l[k])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n,k=map(int,input().split())
l=list(map(int,input().split()))
d=defaultdict(set)
def dfsutil(s,a):
    visited[s]=True
    for i in d[s]:
        if visited[i]==False:
            return dfsutil(i,a+1)
    return a,s,i
def dfsutil2(s,k,a):
    visited[s]=True
    if a==k:
        return s
    for i in d[s]:
        if visited[i]==False:
            return dfsutil2(i,k,a+1)
    
visited=defaultdict(bool)

for i in range(len(l)):
    d[i+1].add(l[i])
c=dfsutil(1,1)
# print(c)
if c[1] in d[c[1]]:
    if k>=c[0]:
        print(c[1])
    else:
        visited=defaultdict(bool)
        print(dfsutil2(1,k,0))   
else:
    if k<=c[0]:
        print(dfsutil2(1,k,0))
    if k>c[0]:
        visited=defaultdict(bool)
        c1=dfsutil(c[2],1)
        if c[2]!=1:
            
            k=k-(c[0]-c1[0])
            
        # visited=defaultdict(bool)
        # print(c)
        # print(c1)
        # print(k)
        k=k%c1[0]
        # print(k)
        # print(c1)
        # print(c1)
        
        # print(k)
        visited=defaultdict(bool)
        if k==0:
            print(c[2])
        else:
            print(dfsutil2(c[2],k,0))
Problem p03165 (python)

Fixed submission:
s1=input()
s2=input()
n=len(s1)
m=len(s2)
# import numpy as np
dp=[[0 for i in range(m+1)]for i in range(n+1)]
for i in range(1,n+1):
    for j in range(1,m+1):
        if s1[i-1]==s2[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
# print(np.array(dp))
ans=""
# print(dp[-1][-1])
i=n
j=m
while i>0 and j>0:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ans=s1[i-1]+ans
        i-=1
        j-=1
print(ans)

Buggy submission (verdict: Runtime Error):
s1=input()
s2=input()
n=len(s1)
m=len(s2)
import numpy as np
dp=[[0 for i in range(m+1)]for i in range(n+1)]
for i in range(1,n+1):
    for j in range(1,m+1):
        if s1[i-1]==s2[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
# print(np.array(dp))
ans=""
print(dp[-1][-1])
i=n
j=m
while i>0 and j>0:
    if dp[i][j]==dp[i-1][j]:
        i-=1
    elif dp[i][j]==dp[i][j-1]:
        j-=1
    else:
        ans=s1[i-1]+ans
        i-=1
        j-=1
print(ans)

Buggy submission (verdict: Runtime Error):
s1=input()
s2=input()
n=len(s1)
m=len(s2)
import numpy as np
dp=[["" for i in range(m+1)]for i in range(n+1)]
for i in range(1,n+1):
    for j in range(1,m+1):
        if s1[i-1]==s2[j-1]:
            dp[i][j]=dp[i-1][j-1]+s1[i-1]
        else:
            a=dp[i-1][j]
            b=dp[i][j-1]
            if len(a)>len(b):
                dp[i][j]=a
            else:
                dp[i][j]=b
# print(np.array(dp))
print(dp[-1][-1])
Problem p02657 (python)

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

print(a*b)

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

print(a*b)

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

print(a*b)
Problem p02641 (python)

Fixed submission:
#H, W = map(int,input().split())
#N = int(input())
#al = list(map(int,input().split()))
X, N = map(int,input().split())
pl = list(map(int,input().split()))

lst = [i for i in range(-101,200)]

anslst = []
for n in lst:
    if not n in pl:
        anslst.append(n)



an = 1000
idx = 0
for i in range(len(anslst)):
    tmp = abs(X - anslst[i])
    if tmp < an:
        an = tmp
        idx = i


ans = anslst[idx]
print(ans)

Buggy submission (verdict: Runtime Error):
#H, W = map(int,input().split())
#N = int(input())
#al = list(map(int,input().split()))
X, N = map(int,input().split())
pl = list(map(int,input().split()))

lst = [i for i in range(1,101)]

anslst = []
for n in lst:
    if not n in pl:
        anslst.append(n)


ans = 101
idx = 0
for i in range(len(anslst)):
    tmp = abs(X-anslst[i])
    if tmp < ans:
        ans = tmp
        idx = i


print(anslst[idx])
Problem p02684 (python)

Fixed submission:
from collections import defaultdict


def inpl():
    return list(map(int, input().split()))


N, K = inpl()
aa = inpl()

s = 1

route = [s]
ed = set([s])

for i in range(1, K + 1):
    s = aa[s - 1]
    if s in ed:
        Li = route.index(s)
        Ri = len(route)
        idx = Li + (K - Li) % (Ri - Li)
        print(route[idx])
        break
    else:
        route.append(s)
        ed.add(s)
        continue
else:
    print(s)

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

visited_towns = []
for i in range(N):
    next_town  = al[visited_towns[i] - 1]
    if next_town in visited_towns:
        loop_sta = visited_towns.index((next_town)) #　visited_townsにおけるループ開始のインデックス
        loop_end = len(visited_towns) #visited_townsにおけるループの終わりのインデックス
        loop_length = loop_end - loop_sta #繰り返すループの長さ
        amari = (K - loop_sta) % loop_length
        ans = visited_towns[loop_sta + amari]
        print(ans)
        exit()
    else:
        visited_towns.append(next_town)

print(visited_towns[-1])

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

route = [1]
for i in range(N):
    next_town = al[route[i] - 1]
    if route.count(next_town) ==1 :
        loop_start = route.index(next_town)
        loop_end = len(route)
        loop_length = loop_end - loop_start
        if K >= loop_end:
            amari = (K - loop_start) % loop_length
            ans = route[loop_start + amari]
            # print(route)
            print(ans)
            exit()
    else:
        route.append(next_town)

ans = route[-1]
print(ans)

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

route = [1]
for i in range(N):
    next_town = al[route[i]-1]
    if len(route) != len(set(route)):
        loop_start = route.index(next_town)
        loop_end = len(route)
        loop_length = loop_end - loop_start
        if K >= loop_end:
            amari = (K - loop_start)%loop_length
            ans = route[loop_start + amari]
            #print(route)
            print(ans)
            exit()
    else:
        route.append(next_town)

ans = route[-1]
print(ans)
Problem p02743 (python)

Fixed submission:
from decimal import Decimal
a,b,c = map(int,input().split())
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
if Decimal.sqrt(a) + Decimal.sqrt(b) < Decimal.sqrt(c):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math
from decimal import Decimal
a,b,c = map(int,input().split())

if Decimal.sqrt(a) + Decimal.sqrt(b) < Decimal.sqrt(c):
    print('Yes')
else:
    print('No')
Problem p02780 (python)

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

c_s_list = [0] #Cumulative sum_list
c_sum = 0 #Cumulative sum
for dice in p_list:
    average = (dice + 1) / 2 #ダイスの期待値
    c_sum += average
    c_s_list.append(c_sum)

ans = 0
for i in range(N-K+1):
    tmp = c_s_list[i+K] - c_s_list[i]
    if tmp >= ans:
        ans = tmp
print(ans)

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


ruisekiwa_list = []
ruisekiwa = 0
for saikoro in p_list:
    ruisekiwa += (1 + saikoro) / 2
    ruisekiwa_list.append(ruisekiwa)
sum_K_max = 0

ans_lis = []
for i in range(N-K):
    sum_K = ruisekiwa_list[i + K] - ruisekiwa_list[i]
    ans_lis.append(sum_K)
print(max(ans_lis))
Problem p02842 (python)

Fixed submission:
n = int(input())

dic = {}
for i in range(1,50000):
    dic[int(i * 1.08)] = i

if n in dic:
    print(dic[n])
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
from decimal import Decimal
n = int(input())

ansdic = {}
for i in range(1,5001):
  ansdic[i] = int(i * Decimal(1.08))

print(ansdic[n])
Problem p02899 (python)

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

lst = [[] for _ in range(n)]
for i in range(1,n+1):
  lst[al[i-1]-1] = i
print(*lst)

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

lst = []*n
for i in range(1,n+1):
  lst[al[i-1]-1] = i
print(*lst)

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

lst = []*(n+1)
for i in range(1,n+1):
  lst[al[i-1]] = i
print(*lst)
Problem p02995 (python)

Fixed submission:
import fractions
A, B, C, D = map(int,input().split())

def lcm(x, y): #最小公倍数
    return (x * y) // fractions.gcd(x, y)

n_C = B//C - (A-1)//C # Cで割り切れる数の数
n_D = B//D - (A-1)//D
CandD = lcm(C,D)
n_CandD = B//CandD - (A-1)//CandD

# CでもDでも割けれない数 = 全体 - CでもDでも割り切れる数
ans = B-A+1 - (n_C + n_D - n_CandD)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int,input().split())

def lcm(x, y): #最小公倍数
    return (x * y) // math.gcd(x, y)

n_C = B//C - (A-1)//C # Cで割り切れる数の数
n_D = B//D - (A-1)//D
CandD = lcm(C,D)
n_CandD = B//CandD - (A-1)//CandD

# CでもDでも割けれない数 = 全体 - CでもDでも割り切れる数
ans = B-A+1 - (n_C + n_D - n_CandD)
print(ans)
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())

if W/2 == x and H/2 == y:
    ans = 1
else:
    ans = 0
print(W*H/2, ans)

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

# 縦に分ける場合
s1, s2 = x * H, (W - x) * H

# 横に分ける場合
s3, s4 = W * y, W * (H - y)

ans = max(min(s1, s2), min(s3, s4))

if min(s1, s2) == min(s3, s4):
    print(f'{ans} 1')
else:
    print(f'{ans} 0')

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

#縦に分ける場合
s1, s2 = x * H, (W-x) *H

#横に分ける場合
s3, s4 = W * y, W * (H-y)

ans = max(min(s1,s2),min(s3,s4))

if min(s1,s2) == min(s3,s4):
    print(f'{ans} 1')
else:
    print(f'{ans} 0')
Problem p03048 (python)

Fixed submission:
R, G, B, N = map(int,input().split())

cnt = 0
for r in range(0,N//R+1):
    for g in range(0,(N-R*r)//G+1):
        if (N - R*r - G*g) % B == 0 :
            #print(r,g,(N-r-g))
            cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
cnt = 0
for r in range(0,N//R+1):
    for g in range(0,(N-R*r)//G+1):
        if (N - R*r - G*g) % B == 0 :
            #print(r,g,(N-r-g))
            cnt += 1

print(cnt)
Problem p03262 (python)

Fixed submission:
import fractions
N, X = map(int,input().split())
xlst = list(map(int,input().split()))

lst = []
for n in xlst:
    difference = abs(X - n)
    lst.append(difference)

ans = lst[0]
for i in range(1,N):
    ans = fractions.gcd(ans, lst[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N, X = map(int,input().split())
xlst = list(map(int,input().split()))

lst = []
for n in xlst:
    difference = abs(X - n)
    lst.append(difference)
ans = lst[0]
for i in range(1,N):
    ans = math.gcd(ans, lst[i])
print(ans)