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

Fixed submission:
import re
s=input()
s=s[::-1]
#print(s)

#dream|dreamer|erase|eraser

#maerd|remaerd|esare|resare
t=re.split('maerd|remaerd|esare|resare', s)
#print(len(t))
#print(t.count(''))
if len(t)==t.count(''):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
N=int(input())
t=0
x=0
y=0
for i in range(N):
    t_next,x_next,y_next=map(int,input().split())
    zikan=t_next - t
    kyori=abs(x_next-x)+abs(y_next-y)
    if kyori>zikan or (zikan-kyori)%2==1:
        print('NO')
        exit(0)
    t,x,y=t_next,x_next,y_next
print('YES')
Problem p02601 (python)

Fixed submission:
import sys

def check(r,g,b):
    return r<g and g<b

r,g,b=input().split()
r,g,b=int(r),int(g),int(b)

K=int(input())+1

#print(r,g,b,K)

for i in range(K):
    for j in range(K-i):
        for k in range(K-i-j):
            if check(r*2**(i),g*2**(j),b*2**(k)):
                print("Yes")
                sys.exit(0)
print("No")

Buggy submission (verdict: Runtime Error):
7 2 5
3
Problem p02614 (python)

Fixed submission:
H, W, K = map(int, input().split())
c = [input() for i in range(H)]

ans = 0
for h in range(2**H):
  for w in range(2**W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if (h >> i) & 1:
          continue
        if (w >> j) & 1:
          continue
        if c[i][j] == '#':
          cnt +=1
    if cnt == K:
      ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
H, W, K = map(int, input().split())
c = [input() for i in range(H)]
max_num = count_num(c)

ans = 0
for h in range(2**H):
  for w in range(2**W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if (h >> i) & 1:
          continue
        if (w >> j) & 1:
          continue
        if c[i][j] == '#'
          cnt +=1
    if cnt == K:
      ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
H, W, K = map(int, input().split())
c = [input() for i in range(H)]
max_num = count_num(c)

ans = 0
for h in range(2**H):
  for w in range(2**W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if (h >> i) & 1:
          continue
        if (w >> j) & 1:
          continue
        if x[i][j] == '#'
          cnt +=1
    if cnt == K:
      ans +=1
print(ans)
Problem p02646 (python)

Fixed submission:
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

ans = 'NO'
distance = abs(B-A)
if V == W:
  pass
else:
  t = distance/(V-W)
  if 0 < t <= T:
    ans = 'YES'

print(ans)

Buggy submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

ans = 'NO'
distance = abs(B-A)

t = distance/(V-W)

if 0 < t <= T:
  ans = 'YES'

print(ans)

Buggy submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

ans = 'NO'
t = (B-A)/(V-W)

if 0 < t <= T:
  ans = 'YES'

print(ans)
Problem p02718 (python)

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

cnt = 0
th = sum(A)/(4*M)

for i in range(len(A)):
  if A[i] >= th:
    cnt += 1

ans = 'Yes' if cnt >= M else 'No'
print(ans)

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

cnt = 0
th = sum(A)/(4*M)

for i in range(len(A)):
  if A[i] >= th:
    cnt += 1

ans = 'Yes' if cnt >= M else 'No'
print(ans)
Problem p02748 (python)

Fixed submission:
import sys

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for e in sys.stdin:
  c.append(list(map(int, e.split())))

ans = min(a) + min(b)

for i in range(len(c)):
  temp_val = a[c[i][0]-1] + b[c[i][1]-1] - c[i][2]
  if temp_val < ans:
    ans = temp_val

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for e in sys.stdin:
  c.append(list(map(int, e.split())))

ans = min(a) + min(b)

for i in range(len(c)):
  temp_val = a[c[i][0]] + b[c[i][1]] - c[i][2]
  if temp_val < ans:
    ans = temp_val

print(ans)
Problem p02818 (python)

Fixed submission:
A, B, K= map(int, input().split())
 
if A >= K:
  ans_t = A - K
  ans_a = B
elif B >= ( K - A):
  ans_t = 0
  ans_a = B - ( K - A)
else:
  ans_t = 0
  ans_a = 0
 
print( '{} {}'.format( ans_t, ans_a))

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

if A >= K:
  ans_t = A - K
  ans_a = B
elif B >= ( K - A):
  ans_t = 0
  ans_a = B - ( K - A)
else:
  ans_t = 0
  ans_a = 0

print( ’{} {}’.format( ans_t, ans_a))
Problem p02741 (python)

Fixed submission:
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k-1])

Buggy submission (verdict: Runtime Error):
import math
h, w = map(int, input().split())

if h == 1 or w == 1:
  print(1)
elif h % 2 == 0 or w % 2 ==0:
  print(int((h * w) // 2))
else:
  print(int(math.ceil((h * w) // 2)))
Problem p02613 (python)

Fixed submission:
N = int(input())
x = [input() for i in range(N)]
AC = 0
WA = 0
TLE = 0
RE = 0
for t in range(N):
    if x[t] == 'AC':
        AC += 1
    elif x[t] == 'WA':
        WA += 1
    elif x[t] == 'TLE':
        TLE += 1
    else:
        RE += 1
print('AC x',AC)
print('WA x',WA)
print('TLE x',TLE)
print('RE x',RE)

Buggy submission (verdict: Runtime Error):
x = [input() for i in range(N)]
AC = 0
WA = 0
TLE = 0
RE = 0
for t in range(N):
    if x[t] == 'AC':
        AC += 1
    elif x[t] == 'WA':
        WA += 1
    elif x[t] == 'TLE':
        TLE += 1
    else:
        RE += 1
print('AC x',AC)
print('WA x',WA)
print('TLE x',TLE)
print('RE x',RE)
Problem p02687 (python)

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

Buggy submission (verdict: Runtime Error):
S = int(input())
if S == 'ABC':
    print('ARC')
else:
    print('ABC')
Problem p02727 (python)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
IronMan = sorted(p)
CaptainAmerica = sorted(q)
for i in range(X):
    r.append(IronMan.pop())
for i in range(Y):
    r.append(CaptainAmerica.pop())
SpiderMan = sorted(r)[::-1]
print(sum(SpiderMan[:X+Y]))

Buggy submission (verdict: Runtime Error):
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
IronMan = sorted(p)
CaptainAmerica = sorted(q)
for i in range(X):
    r.append(IronMan.pop())
for i in range(Y):
    CaptainAmerica.append(q.pop())
SpiderMan = sorted(r)[::-1]
print(sum(SpiderMan[:X+Y]))

Buggy submission (verdict: Runtime Error):
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
sorted(p)
sorted(q)
for i in range(X):
    r.append(p.pop())
for i in range(Y):
    r.append(q.pop())
SpiderMan = sorted(r)[::-1]
print(sum(SpiderMan[:X+Y]))

Buggy submission (verdict: Runtime Error):
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
sorted(p)
sorted(q)
for i in range(X):
    r.append(p.pop())
for i in range(Y):
    r.append(q.pop())
SpiderMan = sorted(r)[::-1]
print(sum(SpiderMan[:X+Y]))
Problem p02718 (python)

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
asum = sum(a)
r = 0
for i in range(n):
  if a[i] >= asum/(4*m):
    r += 1
print("Yes" if r >= m else "No")

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A)
cnt = 0
for a in A:
  if a >= S / (4*M):
	cnt += 1
if cnt >= M:
  print("Yes")
else:
  print("No")
Problem p03674 (python)

Fixed submission:
def comb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7  # 出力の制限
N = 10**6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))

appeared = set()
dup_right = 0
dup = 0
for i, x in enumerate(a):
    if x in appeared:
        dup_right = n - i
        dup = x
        break
    appeared.add(x)
dup_left = 0
for i, x in enumerate(a):
    if x == dup:
        dup_left = i
        break

for k in range(1, n + 2):
    print((comb(n + 1, k, MOD) - comb(dup_right + dup_left, k - 1, MOD) + MOD) % MOD)

Buggy submission (verdict: Runtime Error):
def comb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7  # 出力の制限
N = 10**4
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))

appeared = set()
dup_right = 0
dup = 0
for i, x in enumerate(a):
    if x in appeared:
        dup_right = n - i
        dup = x
        break
    appeared.add(x)
dup_left = 0
for i, x in enumerate(a):
    if x == dup:
        dup_left = i
        break

print("dup_right", dup_right)
print("dup_left", dup_left)

print(n)
for i in range(2, n + 2):
    res = comb(n + 1, i, MOD)
    if dup_right + dup_left >= i - 1:
        res = res - comb(dup_right + dup_left, i - 1, MOD) % MOD
    print(res)
Problem p02639 (python)

Fixed submission:
a = list(map(int, input().split()))
n = len(a)
print((n * (n+1) // 2) - sum(a))

Buggy submission (verdict: Runtime Error):
a = list(map(,int, input().split()))
n = len(a)
print((n * (n+1) // 2) - sum(a))
Problem p02658 (python)

Fixed submission:
n = int(input())
a =list(map(int, input().split()))
if 0 in a:
  print(0)
else :
  prod = 1
  for x in a:
    prod *= x
    if prod:
      if prod > 10**18:
        print(-1)
        break
    else :
      print(0)
      break
  else :
    print(prod)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
prod = math.prod(a, start=1)
if prod > 10**18:
  print(-1)
else :
  print(prod)
Problem p02767 (python)

Fixed submission:
N = int(input())
X = list(map(int,input().split()))
m = sum(X)//N
def fun(X,m):
  s = 0
  for i in X:
    s += (i-m)**2
  return s

print(min(fun(X,m),fun(X,m+1)))

Buggy submission (verdict: Runtime Error):
N = int(input())
X = list(int,input().split())
m = sum(X)//N
def fun(X,m):
  s = 0
  for i in X:
    s += (i-m)**2
  return s

print(min(fun(X,m),fun(X,m+1)))
Problem p03125 (python)

Fixed submission:
A,B=map(int,input().split())
if B%A==0:
  print(A+B)
else:
  print(B-A)

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
if B%A==0:
  print(A+B)
 else :
  print(B-A)
Problem p03167 (python)

Fixed submission:
H,W = map(int,input().split())
M = []
for i in range(H):
  M.append(input())
d = {}
d[(1,1)]=0
flag = False
for j in range(1,W):
  if flag or M[0][j]=="#":
    d[(1,j+1)] = 0
    flag = True
    continue
  d[(1,j+1)]=1
flag = False
for j in range(1,H):
  if flag or M[j][0]=="#":
    d[(j+1,1)] = 0
    flag = True
    continue
  d[(j+1,1)]=1
for l in range(1,H):
  for m in range(1,W):
    if M[l][m]==".":
      d[(l+1,m+1)]=(d[(l,m+1)]+d[(l+1,m)])%(1000000007)
    else :
      d[(l+1,m+1)] = 0
print(d[(H,W)])

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
M = []
for i in range(H):
  M.append(input())
d = {}
for j in range(W):
  d[(1,j+1)] = 1
for k in range(H):
  d[(k+1,1)] = 1
for l in range(1,H):
  for m in range(1,W):
    if M[l][m]==".":
      if M[l-1][m]=="#":
        d[(l+1,m+1)]=(d[(l+1,m)])%(1000000007)
      elif M[l][m-1]=="#":
        d[(l+1,m+1)]=(d[(l,m+1)])%(1000000007)
      else :
        d[(l+1,m+1)]=(d[(l,m+1)]+d[(l+1,m)])%(1000000007)
print(d[(H,W)])
Problem p02713 (python)

Fixed submission:
import math
import collections

k = int(input())

gcd_sum_dict = collections.defaultdict(int)
for i in range(1, k+1):
    gcd_sum_dict[i] = 0
    for j in range(1, k+1):
        gcd_sum_dict[i] += math.gcd(i, j)

ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        ans += gcd_sum_dict[math.gcd(i, j)]

print(ans)

Buggy submission (verdict: Runtime Error):
import math

k = int(input())

gcd_sum_dict = collections.defaultdict(int)
for i in range(1, k+1):
    gcd_sum_dict[i] = 0
    for j in range(1, k+1):
        gcd_sum_dict[i] += gcd(i, j)

ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        ans += gcd_sum_dict[gcd(i, j)]

print(ans)
Problem p02715 (python)

Fixed submission:
n, k = map(int, input().split())
mod = 10**9 + 7
s = [0 for i in range(k+1)]
ret = 0

for i in range(k, 0, -1):
    p = int(k/i)
    c = pow(p, n, mod)
    for j in range(2, k+1):
        if i*j <= k:
            c -= s[i*j]
        else:
            break
    
    s[i] = c%mod

    ret = (ret + (c%mod)*i)%mod

print(ret)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
mod = 10**9 + 7
s = [0 for i in range(k+1)]
ret = 0

for i in range(k, 0, -1):
    p = int(k/i)
    f = pow(p, n, mod)
    for j in range(2, k+1):
        if i*j <= k:
            c -= s[i*j]
        else:
            break
    
    s[i] = c%mod

    ret = (ret + (c%mod)*i)%mod

print(ret)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
mod = 10**9 + 7
s = [0 for i in range(k+1)]
ret = 0

for i in range(k, 0, -1):
    p = int(k/i)
    f = pow(p, n, mod)
    for j in range(2, k+1):
        if i*j <= k+1:
            c -= s[i*j]
        else:
            break
    
    s[i] = c%mod

    ret = (ret + (c%mod)*i)%mod

print(ret)
Problem p02717 (python)

Fixed submission:
x, y, z = map(str, input().split())

print(" ".join([z, x, y]))

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

print(' '.join(z, x, y))
Problem p02720 (python)

Fixed submission:
k = int(input())

def fun(k):
    lun_luns = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    index = 0
    while True:
        if len(lun_luns) >= k:
            break
        num = lun_luns[index]
        mod = num%10
        n = num*10
        if mod == 9:
            lun_luns.extend([n+mod-1, n+mod])
        elif mod == 0:
            lun_luns.extend([n, n+1])
        else:
            lun_luns.extend([n+mod-1, n+mod, n+mod+1])
        index += 1
    
    return lun_luns[k-1]

print(fun(k))

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

def fun(k):
    lun_luns = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    index = 0
    while True:
        if len(lun_luns) >= k:
            break
        num = lun_luns[index]
        mod = num%10
        if mod == 9:
            lun_luns.extend([n+mod-1, n+mod])
        elif mod == 0:
            lun_luns.extend([n, n+1])
        else:
            lun_luns.extend([n+mod-1, n, n+mod+1])
        index += 1
    
    return lun_luns

print(fun(k)[k-1])
Problem p03471 (python)

Fixed submission:
n, y = map(int, input().split())
flag = False
for i in range(int(y/10000)+1):
    for j in range(int((y-i*10000)/5000)+1):
        k = n - i - j
        if i*10000 + j*5000 + k*1000 == y:
            print(i, j, k)
            flag = True
            break
    if flag:
        break
if not flag:
    print(-1, -1, -1)

Buggy submission (verdict: Runtime Error):
def fun(n, y):
    for i in range(y//10000+1):
        for j in range((y - 10000*i)//5000+1):
            k = (y - 10000*i - 5000*j)//1000
            if i + j + k == n:
                print(i, j, k)
                break

    print(-1, -1, -1)

fun(n, y)
Problem p04001 (python)

Fixed submission:
s = input()
n = len(s)

ans = 0

for bit in range(1 << (n - 1)):
    f = s[0]

    for i in range(n - 1):
        # ここのif文の判定基準が理解できていません。
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]

    ans += sum(map(int, f.split("+")))

print(ans)

Buggy submission (verdict: Runtime Error):

def fun(s):
    n = len(s)
    ans = 0
    for bit in range(1 << (n-1)):
        f = s[0]
        for i in range(n-1):
            if bit & (1 << i):
                print(1 << i)
                f += "+"
            f += s[i+1]
        ans += sum(map(int, f.split('+')))

    return ans

print(fun(s))
Problem p02909 (python)

Fixed submission:
S = input()
if S == 'Sunny':
  print('Cloudy')
elif S == 'Cloudy':
  print('Rainy')
elif S == 'Rainy':
  print('Sunny')

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int,input().split()))
A = sorted(A)
if N == 1:
  a = A[0]
  for j in range(M):
    a = a//2
  print(a)
elif N > 1:  
  for i in range(M):
    aa = A.index(max(A))
    A[aa] = A[aa]//2
  print(sum(A))
Problem p02982 (python)

Fixed submission:
N, D = map(int, input().split())
import math
X = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    X.append(array)
var = 0
for i in range(N-1):
  for k in range(N-1-i):
    s = 0
    for j in range(D):      
      s = s + (X[i+1+k][j] - X[i][j])*(X[i+1+k][j] - X[i][j])
    if math.sqrt(s) - (int(math.sqrt(s))) ==0:
      var = var+1
print(var)

Buggy submission (verdict: Runtime Error):
N, D = map(int, input().split())
​
# 2次元配列
X = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    X.append(array)
var = 0
for i in range(N-1):
  for k in range(N-1-i):
    s = 0
    for j in range(D):      
      s = s + (X[i+1+k][j] - X[i+k][j])*(X[i+1+k][j] - X[i+k][j])
    if s**0.5 - (int(s**0.5)) ==0:
      var = var+1
print(var)
Problem p02628 (python)

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

p = sorted(p)

print(sum(p[:k]))

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

print(sum(p[:k]))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()).sort()
print(sum(p[:k]))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = sorted(list(map(int, input().split())))
print(sum[:k])
Problem p02658 (python)

Fixed submission:
import sys

n = int(input())
As = list(map(int, input().split()))

Flag = True
ans = 1

if (0 in As):
  print(0)
  sys.exit()


for i in range(n):
  ans = ans * As[i]
  if (ans > 10**18):
    if (Flag):
      print(-1)
      Flag = False
      sys.exit()
  
if (Flag):
  print(ans)

Buggy submission (verdict: Runtime Error):
import sys

n = int(input())
As = list(map(int, input().split()))

ans = 1
for i in range(n):
  ans = ans*As[i]
  	if ans > 10**18:
      print(-1)
      sys.exit()

print(ans)

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

ans = 1
for i in range(n):
  ans = ans * As[i]
  if (ans > 10**18):
    print(-1)
    sys.exit()
  
print(ans)
Problem p02713 (python)

Fixed submission:
import math

k = int(input())

cnt = 0
for a in range(1, k+1):
  for b in range(1, k+1):
    for c in range(1, k+1):
      cnt += math.gcd(math.gcd(a, b), c)

print(cnt)

Buggy submission (verdict: Runtime Error):
import numpy as np

k = int(input())

cnt = 0
for a in range(k):
  for b in range(k):
    for c in range(k):
      cnt += np.gcd.reduce([a+1, b+1, c+1])

print(cnt)
Problem p02743 (python)

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

if(c-a-b < 0):
  print('No')
elif( 4*a*b < (c-a-b)**2 ) :
  print('Yes')
else:
  print('No')

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

if( 4*a*b < (c-a-b)**2 ) :
  print('Yes')
else:
  print('No')
Problem p02767 (python)

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

if (len(set(x)) == 1):
  print(0)
else:
  ans = []
  for p in range(min(x), max(x)):
    sigma = 0
    for i in x:
      sigma += (p-i)**2
    ans.append(sigma)
  print(min(ans))

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

ans = []
for p in range(min(x), max(x)):
  sigma = 0
  for i in x:
    sigma += (p-i)**2
  ans.append(sigma)

print(min(ans))
Problem p02780 (python)

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

ans = sum(p[:k])

psum = [0] * n
psum[0] = p[0]
for i in range(1, n):
  psum[i] = psum[i-1] + p[i]

anss = [0] * n
for i in range(n-k):
  anss[i] = psum[i+k] - psum[i]

print((max(ans, max(anss))+k)/2)

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

p = [ (p+1)/2 for p in ps]

pn_max = 0
for i in range(0, n-2):
  pn = 0
  for j in range(k):
  	pn += ps[i+j]
  pn_max = max(pn_max, pn)

print((pn_max+k)/2)
Problem p02783 (python)

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

q   = h // a
mod = h % a

if(mod == 0):
  ans = q
else:
  ans = q + 1

print(ans)

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

# 最強の魔法の特定
a_max = max(a for a, b in ab)
# 動的計画法用の配列の定義及び初期化
dp = [0]*(h + a_max)

for i in range(h + a_max):
	dp[i] = min(dp[i - a] + b for a, b in ab)

print(min(dp[h:]))
Problem p02787 (python)

Fixed submission:
n,m=map(int, input().split())
s=[list(map(int, input().split())) for i in range(m)]
x=max(a for a,b in s)
dp=[0]*(n+x)
for i in range(0,n+x):
  if i>0:
    dp[i]=min(dp[i-a]+b for a,b in s)
print(min(dp[n:]))

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

# 最強の魔法の特定
a_max = max(a for a, b in ab)
# 動的計画法用の配列の定義及び初期化
dp = [0]*(h + a_max)

for i in range(h + a_max):
  if i > 0:
	dp[i] = min(dp[i - a] + b for a, b in ab)

print(min(dp[h:]))
Problem p02802 (python)

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

points    = [0] * n
penalty   = [0] * n
penalties = 0

for i in range(m):
  q, ans = input().split()
  q = int(q) - 1
  # まだ正解が出ていない場合
  if(points[q] == 0):
    # 正解の場合
    if(ans == 'AC'):
      points[q] = 1
      penalties += penalty[q]
    # 不正解の場合
    else:
      penalty[q] += 1

print('{} {}'.format(sum(points), penalties))

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

points    = [0] * n
penalties = [0] * n

for i in range(m):
  q, ans = input().split()
  # まだ正解が出ていない場合
  if(int(q) == 0):
    continue:
  if(points[int(q) - 1] == 0):
    # 正解の場合
    if(ans == 'AC'):
      points[int(q) - 1] = 1
    # 不正解の場合
    else:
      penalties[int(q) - 1] += 1

print(sum(points), sum(penalties))
Problem p02921 (python)

Fixed submission:
def main():
    S = input()
    T = input()
    ans = 0
    for i in range(3):
        if S[i] == T[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    print(int((N*(N-1))//2))

if __name__ == '__main__':
    main()
Problem p02924 (python)

Fixed submission:
def main():
    N = int(input())
    print(int((N*(N-1))//2))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def get_max(n):
    if n==1:
        return 0
    if n % 2 == 0:
        return (n/2+(n-1))*n/2/2-1 + get_max((n-1)/2)
    else:
        return ((n-1)/2+(n-1))*(n+1)/2/2 + get_max((n-1)/2)

def main():
    N = int(input())
    print(int(get_max(N)))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def get_max(n):
    if n==1:
        return 0:
    if n % 2 == 0:
        return n*(n-1)/2
    else:
        return ((n+1)/2+n)*(n+1)/2/2 + get_max((n-1)/2)

def main():
    N = int(input())
    print(int(get_max(N)))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = input()
    ans = 0
    for i in range(N):
        ans += i
    print(ans)

if __name__ == '__main__':
    main()