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

Fixed submission:
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

ans = 0
buf = ""
for i in range(N):
    t = T[i]

    if t == "r":
        if i >= K:
            if buf[i - K] == "p":
                buf = buf + " "
                continue
        ans += P
        buf = buf + "p"
    elif t == "p":
        if i >= K:
            if buf[i - K] == "s":
                buf = buf + " "
                continue
        ans += S
        buf = buf + "s"
    elif t == "s":
        if i >= K:
            if buf[i - K] == "r":
                buf = buf + " "
                continue
        ans += R
        buf = buf + "r"

print(ans)

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

ans = 0
buf = ""
for i in range(N):
    t = T[i]

    if t == "r":
        if i >= K:
            if buf[i - K] == "p":
                buf = buf + " "
                continue
        ans += P
        buf += buf + "p"
    elif t == "p":
        if i >= K:
            if buf[i - K] == "s":
                buf = buf + " "
                continue
        ans += S
        buf += buf + "s"
    elif t == "s":
        if i >= K:
            if buf[i - K] == "r":
                buf = buf + " "
                continue
        ans += R
        buf += buf + "r"

print(ans)
Problem p02897 (python)

Fixed submission:
N = int(input())

print(int(N / 2 + 0.5) / N)

Buggy submission (verdict: Runtime Error):
import fractions

A, B = map(int, input().split())

C = fractions.gcd(A, B)

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b += 1
    if n > 1:
        fct.append(n)
    return act

print(len(list(set(factorize(C))) + 1)
Problem p02948 (python)

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

c = [[] for _ in range(M)]

for i in range(N):
    a, b = map(int, input().split())

    if a > M:
        continue
    c[M - a].append(b)

import heapq

h = []
heapq.heapify(h)
ans = 0

for i in range(M - 1, -1, -1):
    for b in c[i]:
        heapq.heappush(h, -b)
    if len(h) > 0:
        ans += -1 * heapq.heappop(h)

print(ans)

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

reward = [[] for _ in range(M)]

for i in range(N):
    a, b = map(int, input().split())

    if a > M:
        continue
    c[m - a].append(b)

import heapq

h = []
heapq.heapify(h)
ans = 0

for i in range(M - 1, -1, -1):
    for b in c[i]:
        heapq.heappush(h, -b)
    if len(h) > 0:
        ans += -1 * heapq.heappop(h)

print(ans)
Problem p02831 (python)

Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a, b = (int(_) for _ in input().split())

z = lcm(a,b)
print(z)

Buggy submission (verdict: Runtime Error):
import math

a, b = (int(_) for _ in input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a,b))
Problem p03013 (python)

Fixed submission:
n, m = (int(_) for _ in input().split())
x = [int(input()) for i in range(m)]
xi = 0

if m == 0:
    x = [999999]

a = [1,1]
if x[xi] == 1:
    xi = min(len(x)-1,xi+1)
    a[1] = 0

for i in range(n-1):
    if x[xi]-2 == i:
        a.append(0)
        xi = min(len(x)-1,xi+1)
    else:
        a.append(a[i+1]+a[i])

print(a[n]%1000000007)

Buggy submission (verdict: Runtime Error):
n, m = (int(_) for _ in input().split())
x = [int(input()) for i in range(m)]
xi = 0

if m == 0:
    x = [999999]

a = [1,1]
if x[xi] == 1:
    xi += 1
    a[1] = 0

for i in range(n-1):
    if x[xi]-2 == i:
        a.append(0)
        xi = min(len(x)-1,xi+1)
    else:
        a.append(a[i+1]+a[i])

print(a[n]%1000000007)

Buggy submission (verdict: Runtime Error):
n, m = (int(_) for _ in input().split())  
x = [int(input()) for i in range(m)]
xi = 0

a = [1,1]
if x[xi] == 1:
    xi += 1
    a[1] = 0

for i in range(n-1):
    if x[xi]-2 == i:
        a.append(0)
        xi = min(len(x)-1,xi+1)
    else:
        a.append(a[i+1]+a[i])

print(a[n]%1000000007)
Problem p03207 (python)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
b = sorted(a ,reverse = True)
res = int(b[0]/2 + sum(b[1:]))
print(res)

Buggy submission (verdict: Runtime Error):
N = input()
a = [input() for i in range(N)]
b = sorted(a ,reverse = True)
res = sum(b[0]/2,sum(b[1:]))
print(res)
Problem p03209 (python)

Fixed submission:
a = list(map(int, input().split()))
c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(a[0]-1,-1,-1):
    if b[i][0] * 2 + 1 <= c:
        c = c - b[i][0]*2 - 1
        res = res + b[i][1] * 2 + 1
    elif b[i][0] <= c: 
        c = c - b[i][0]
        res = res + b[i][1]
        if c > 0:
            c = c - 1
            res = res + 1
    c = c - 1

if c > 0:
    res = res + c

print(res)

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

c = a[1]
res = 0

b = [[5,3,1]]
for i in range(1,a[0]+1):
    tmp = [b[i-1][0]*2+3,b[i-1][1]*2+1,i+1]
    b.append(tmp)

for i in range(50-1,0,-1):
    c = c - 1
    if b[i][0] < c:
        c = c - b[i][0] - 1
        res = res + b[i][1] + 1
if c == 1:
    res = res + 1

print(res)
Problem p03774 (python)

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

for i in range(a[0]):
    b.append(list(map(int,input().split(" "))))

for i in range(a[1]):
    c.append(list(map(int,input().split(" "))))

for i in range(a[0]):
    d = 0
    e = 9999999999
    for ii in range(a[1]):
        if e > abs(b[i][0] - c[ii][0]) + abs(b[i][1] - c[ii][1]):
            e = abs(b[i][0] - c[ii][0]) + abs(b[i][1] - c[ii][1])
            d = ii
    ans.append(d+1)
    
for i in range(a[0]):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split(" ")))
b = list()
c = list()
ans = list()

for i in range(a[0]):
    b.append(list(map(int,input().split(" "))))

for i in range(a[1]):
    c.append(list(map(int,input().split(" "))))

for i in range(a[0]):
    d = 0
    e = 99999999
    for ii in range(a[1]):
        if e > abs(b[i][0] - c[ii][0]) + abs(b[i][1] - c[ii][1]):
            e = abs(b[i][0] - c[ii][0]) + abs(b[i][1] - c[ii][1]):
            d = ii
    ans.append(d)
    
for i in range(a[0]):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split(" ")))
H = list()
C = list()
result = list()
for i in range(A[0]):
    H.append(list(map(int,input().split(" "))))
for i in range(A[1]):
    C.append(list(map(int,input().split(" "))))

for i in range(A[0]):
    res = 0
    tmp = 99999999
    for ii in range(A[1]):
        if tmp > abs(H[i][0] - C[ii][0]) + abs(H[i][1] - C[ii][1]):
            res = ii
    result.append(res)

for i in range(A[1]):
    print(result[i])

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split(" ")))
H = list()
C = list()
result = list()
for i in range(A[0]):
    H.append(list(map(int,input().split(" "))))
for i in range(A[1]):
    C.append(list(map(int,input().split(" "))))
    
for i in range(A[0]):
    res = 0
    tmp = 99999999
    for ii in range(A[1]):
        if tmp > abs(H[i*2-1] - C[i*2-1]) + abs(H[i*2] - C[i*2]):
            res = ii
    result.append(res)

for i in range(A[1]):
    print(result[i])
Problem p02831 (python)

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

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

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

print(lcm(a,b))

Buggy submission (verdict: Runtime Error):
import math
x, y = map(int, input().split())
def func(x, y):
    return (x * y) / int(math.gcd(x, y))

print(int(func(x, y)))

Buggy submission (verdict: Runtime Error):
import math
x, y = map(int, input().split())
def func(x, y):
    return (x * y) / math.gcd(x, y)

print(int(func(x, y)))

Buggy submission (verdict: Runtime Error):
import math
x, y = map(int, input().split())
def func(x, y):
    return (x * y) // math.gcd(x, y)

print(func(x, y))

Buggy submission (verdict: Runtime Error):
import math
x, y = map(int, input().split())
def func(x, y):
    return (x * y) // math.gcd(x, y)

print(func(x, y))
Problem p02847 (python)

Fixed submission:
S = str(input())
if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
else :
    print(1)

Buggy submission (verdict: Runtime Error):
S = str(input())
if S = "SUN":
    print(7)
if S = "MON":
    print(6)
if S = "TUE":
    print(5)
if S = "WED":
    print(4)
if S = "THU":
    print(3)
if S = "FRI":
    print(2)
if S = "SAT":
    print(1)
Problem p02777 (python)

Fixed submission:
c = input().split()
n = [int(c) for c in input().split()]
idx = c.index(input())
n[idx] -= 1
print(" ".join([str(c) for c in n]), end="\n")

Buggy submission (verdict: Runtime Error):
c = input().split()
n = input().split()
idx = c.index(input())
n[idx] -= 1
print("".join(n), end="\n")
Problem p02835 (python)

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

if a+b+c > 21:
  print('bust')
else:
  print('win')

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

dDic = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1 }

print(int(dDic[s]))
Problem p02836 (python)

Fixed submission:
s = list(input())

count = 0
for i in range(len(s)//2):
  if s[i] != s[-1-i]:
    count+=1

print(count)

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

if len(s) % 2 != 0:
  if len(s) / 2 > len(s)//2:
    s.pop(len(s)//2+1) 
  else:
    s.pop(len(s)//2-1) 
    

s1List = s[:len(s)//2][::-1] 
s2List = s[len(s)//2:]

count = 0
for i in range(len(s1List)):
  if s1List[i] != s2List[i]:
    count += 1
  
print(count)
Problem p03631 (python)

Fixed submission:
n = input()

if n[0] == n[2]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = input()

if n[0] == n[3]:
  print("Yes")
else:
  print("No")
Problem p03803 (python)

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

if cardArray[0]== cardArray[1]:
  print("Draw")
elif cardArray[0] < cardArray[1]:
  if cardArray[0] == 1:
    print("Alice")
  else:
    print("Bob")
else:
  if cardArray[1] == 1:
    print("Bob")
  else:
    print("Alice")

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

if cardArray[0]== carArray[1]:
  print("Draw")
elif cardArray[0] < cardArray[1]:
  if cardArray[0] == 1:
    print("Alice")
  else:
    print("Bob")
else:
  if cardArray[1] == 1:
    print("Bob")
  else:
    print("Alice")

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

if cardArray[0]== carArray[1]:
  print("Draw")
elif cardArray[0] < cardArray[1]:
  if cardArray[0] == 1:
    print("Alice")
  else:
    print("Bob")
else:
  if cardArray[1] == 1:
    print("Bob")
  print("Alice")

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

if cardArray[0]== carArray[1]:
  print("Draw")
elif cardArray[0] < cardArray[1]:
  if cardArray[0] == 1:
    print("Alice")
  else:
    print("Bob")
else:
  print("Bob")

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

if cardArray[0]= carArray[1]:
  print("Draw")
elif cardArray[0] < cardArray[1]:
  if cardArray[0] == 1:
    print("Alice")
  else:
    print("Bob")
else:
  print("Bob")
Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
ais = []
for _ in range(m):
    ai = int(input())
    ais.append(ai)
dp = [0]*(n+1)
dp[0]=1
if len(ais)>0 and ais[0]==1:
  dp[1]=0
  ais.pop(0)
else:
  dp[1]=1
for i in range(2,n+1):
    if len(ais)>0 and ais[0]==i:
        dp[i] = 0
        ais.pop(0)
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[n]%1000000007)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
ais = []
for _ in range(m):
    ai = int(input())
    ais.append(ai)
dp = [0]*(n+1)
dp[0]=1
if ais[0]==1:
  dp[1]=0
  ais.pop(0)
else:
  dp[1]=1
for i in range(2,n+1):
    if len(ais)>0 and ais[0]==i:
        dp[i] = 0
        ais.pop(0)
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp[n]%1000000007)
Problem p02970 (python)

Fixed submission:
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc134/tasks/abc134_b

import math
n, d = [int(x) for x in input().split()]
print(math.ceil(n / (d * 2 + 1)))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

n = int(input())
print(int((n - 1) / 2) if n % 2 == 1 else int(n / 2) - 1)
Problem p02987 (python)

Fixed submission:
s = str(input())
s1 = set(s)
s2 = list(s)
cnt = 0
if len(s1) != 2:
    print("No")
else:
    for i in range(1,len(s2)):
        if s[0] == s[i]:
            cnt += 1
    if cnt == 1:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
from math import factorial
n,k = map(int, input().split())
mod = 10**9+7
def comb(n,r):
    return factorial(n) // (factorial(r) * factorial(n - r))
# a = comb(n, r)
for i in range(1,k+1):
    if n -k + 1 >= i :
        a = comb(n-k+1,i)
        b = comb(k-1,i-1)
        print((a*b)%mod)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
mod = 10**9+7
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

for i in range(1,k+1):
        a = cmb(n-k+1,i)
        b = cmb(k-1,i-1)
        print((a*b)%mod)

Buggy submission (verdict: Runtime Error):
from math import factorial
n,k = map(int, input().split())
mod = 10**9+7
# a = comb(n, r)
for i in range(1,k+1):
    if n-k+1 < i:
        print(0)
    else:
        a = factorial(n-k+1) //factorial(i) //factorial(n-k+1 - i)
        print((a*(i**(k-i)))%mod)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = set(map(int, input().split()))
p = list(p)
p.sort()
if len(p) % 2 == 1 and n % 2 == 1:
    print(0)
else:
    p = list(p)
    cnt = p[len(p)//2] - p[len(p)//2 -1]
    print(cnt)
Problem p03011 (python)

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

c.remove(max(c))

print(sum(c))

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

if m > 0:
    broken = set(map(int,sys.stdin))
else:
    broken = set()
    
dp = [0]*(n+1)
dp[0] = 1
dp[1] = 1 if 1 not in broken else 0

MOD = 10**9 + 7

for i in range(2,n+1):
    if i in broken:
        continue
    dp[i] =(dp[i-1]+dp[i-2])% MOD
    
print(dp[n])

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

if m > 0:
    broken = set(map(int,sys.stdin))
else:
    broken = set()
    
dp = [0]*(n+1)
dp[0] = 1
dp[1] = 1 if 1 not in broken else 0

MOD = 10**9 + 7

for i in range(2,n+1):
    if i in broken:
        continue
    dp[i] =　(dp[i-1]+dp[i-2])% MOD
    
print(dp[-1])
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
a=set([int(input()) for i in range(m)])
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:dp[i]=0
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
A = set([int(input()) for _ in range(m)])
mod = 1000000007
dp = [0]*(n+1)
dp[0],dp[1] = 1,1
for i in range(2,n+1):
    dp[i] = (dp[i-1] + dp[i-2])%mod
    if i in a:dp[i] = 0
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
A = set([int(input()) for _ in range(m)])
mod = 1000000007
dp = [0]*(n+1)
dp[0],dp[1] = 1,1
for i in range(2,n+1):
    dp[i] = (dp[i-1] + dp[i-2])
    if i in a:dp[i] = 0
print(dp[n])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
A = [int(input()) for _ in range(m)]
mod = 1000000007
dp = [0]*(n+1)
dp[0],dp[1] = 1,1
for i in range(2,n+1):
    dp[i] = (dp[i-1] + dp[i-2])
    if i in a:dp[i] = 0
print(dp[n])
Problem p03834 (python)

Fixed submission:
a,b,c = input().split(",")
print(a,b,c)

Buggy submission (verdict: Runtime Error):
*a, = map(int,input().split())
print(max(a)-min(a))
Problem p02793 (python)

Fixed submission:
import sys
import random
import math
#file = open('test.in', 'r') 
file = sys.stdin

def gcd(x, y):
	if (y == 0):
		return x
	else:
		return gcd(y, x % y)


n = (int)(input())
v = list(map(int, input().split()))
lcm = 1
for i in range(n):
	lcm = (v[i] * lcm) // gcd(v[i], lcm)
sm = 0
for i in range(n):
	sm = sm + (lcm // v[i])
print(sm % 1000000007)

Buggy submission (verdict: Runtime Error):
import sys
import random
import math
#file = open('test.in', 'r') 
file = sys.stdin
n = (int)(input())
v = list(map(int, input().split()))
lcm = 1
for i in range(n):
	lcm = (v[i] * lcm) // math.gcd(v[i], lcm)
sm = 0
for i in range(n):
	sm = sm + (lcm // v[i])
print(sm % 1000000007)

Buggy submission (verdict: Runtime Error):
import sys
import random
import math
#file = open('test.in', 'r') 
file = sys.stdin
n = (int)(input())
v = list(map(int, input().split()))
lcm = 1
for i in range(n):
	lcm = (v[i] * lcm) // math.gcd(v[i], lcm)
sm = 0
for i in range(n):
	sm = sm + (lcm // v[i])
print(sm % 1000000007)

Buggy submission (verdict: Runtime Error):
import sys
import random
import math
#file = open('test.in', 'r') 
file = sys.stdin
n = input()
v = list(map(int, input().split()))
lcm = 1
for i in range(n):
	lcm = (v[i] * lcm) // math.gcd(v[i], lcm)
sm = 0
for i in range(n):
	sm = sm + (lcm // v[i])
print(sm % 1000000007)
Problem p02777 (python)

Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
U = input()

data = {
    str(S): A,
    str(T): B,
}

data[str(U)] -= 1

s = data[str(S)]
t = data[str(T)]
print('{} {}'.format(s, t))

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

data = {
    str(S): A,
    str(T): B,
}

data[str(U)] -= 1

s = data[str(S)]
t = data[str(T)]
print(f'{s} {t}')

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

data = {
    str(S): A,
    str(T): B,
}

data[f'{U}'] -= 1

s = data[str(S)]
t = data[str(T)]
print(f'{s} {t}')
Problem p02781 (python)

Fixed submission:

# 桁DP問題
N = int(input())
K = int(input())

dp = [[[0,0] for _ in range(4)] for _ in range(101)]

dp[0][0][0] = 1

# i = Nの●桁目
# j = 0以外の数字を何回利用しているか
# k == 0 Nを超えないように注意が必要
# k == 1 N以下が保証されている

keta = len(str(N))
for i in range(keta):
  for j in range(4):
    for k in range(2):
      num = int(str(N)[i])

      for n in range(10):
        ni, nj, nk = i+1, j, k

        if n != 0:
          nj += 1 # 0以外の数字を利用した数が増えた
        if nj > K: 
          continue # すでにKを使い切っているときはカウントしない
        if k == 0:
          if n > num:
            continue # Nを超えているので飛ばす
          if n < num:
            nk = 1 # 何でもOK

        dp[ni][nj][nk] += dp[i][j][k]

print(dp[keta][K][0] + dp[keta][K][1])

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())

dp = [[[0,0] for _ in range(4)] for _ in range(101)]

dp[0][0][0] = 1

# i = Nの●桁目
# j = 0以外の数字を何回利用しているか
# k == 0 Nを超えないように注意が必要
# k == 1 N以下が保証されている

keta = len(str(N))
for i in range(keta):
  for j in range(4):
    for k in range(2):
      num = int(str(N)[i])

      for n in range(10):
        ni, nj, nk = i+1, j, k

        if n != 0:
          nj += 1 # 0以外の数字を利用した数が増えた
        if nj > K: 
          continue # すでにKを使い切っているときはカウントしない
        if k == 0:
          if n > num:
            continue # Nを超えているので飛ばす
          if n < num:
            nk = 1 # 何でもOK

        dp[ni][nj][nk] += dp[i][j][k]

print(dp[keta][K][0] + dp[keta][K][1])N = int(input())
K = int(input())

dp = [[[0,0] for _ in range(4)] for _ in range(101)]

dp[0][0][0] = 1

# i = Nの●桁目
# j = 0以外の数字を何回利用しているか
# k == 0 Nを超えないように注意が必要
# k == 1 N以下が保証されている

keta = len(str(N))
for i in range(keta):
  for j in range(4):
    for k in range(2):
      num = int(str(N)[i])

      for n in range(10):
        ni, nj, nk = i+1, j, k

        if n != 0:
          nj += 1 # 0以外の数字を利用した数が増えた
        if nj > K: 
          continue # すでにKを使い切っているときはカウントしない
        if k == 0:
          if n > num:
            continue # Nを超えているので飛ばす
          if n < num:
            nk = 1 # 何でもOK

        dp[ni][nj][nk] += dp[i][j][k]

print(dp[keta][K][0] + dp[keta][K][1])
Problem p02820 (python)

Fixed submission:



N, K = map(int,input().split())
R, S, P = map(int, input().split())
T = input()

point = 0

judge = {"r": R, "s": S, "p": P}
skip = [False] * N

for i in range(N):
  if i < K:
    if T[i] == "r":
      point += judge["p"]
    elif T[i] == "s":
      point += judge["r"]
    elif T[i] == "p":
      point += judge["s"]
  else:
    # K回前を意識しないといけない
    if T[i-K] != T[i] or skip[i-K]:
      if T[i] == "r":
        point += judge["p"]
      elif T[i] == "s":
        point += judge["r"]
      elif T[i] == "p":
        point += judge["s"]
    else:
      skip[i] = True
      
print(point)

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

count = 0
result = []

def get(x):
  if x == "r":
    return ("p", P)
  elif x == "s":
    return ("r", R)
  elif x == "p":
    return ("s", S)


for i in range(N):
  x = T[i]
  hand, point = get(x)
  if i < K:
    # 前回の結果は気にしなくても良いとき
    result.append((hand, point))
  elif hand != result[i-K][0]:
    result.append((hand, point))
  else:
    if i + K >= N:
      # 後のことを考えなくて良いとき
      result.append((hand, 0))
    else:
      next = list(filter(lambda x: x not in (T[i+2], hand), ["r", "s", "p"]))[0]
      result.append((next, 0))

print(sum(list(map(lambda x: x[1], result))))
Problem p02916 (python)

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

ans = sum(b)
for i in range(1, n):
  if a[i] == a[i - 1] + 1:
    ans += c[a[i - 1] - 1]

print(ans)

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

ans = sum(b)
for i in range(1, n):
  if a[i] == a[i - 1] + 1 and i != n:
    ans += c[a[i] - 1]

print(ans)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()
print(s if a >= 3200 else "red")

Buggy submission (verdict: Runtime Error):
a = input()
s = input()
print(s if a >= 3200 else "red")
Problem p03104 (python)

Fixed submission:

# XORの性質を覚える必要がある
# 解説動画を"最後まで"みるとわかりやすい

from functools import reduce

A, B = map(int, input().split())

def get(x):
  # 何かしらの法則をみつける
  return [x, 1, x + 1, 0][x % 4]

# XORの性質
print( get(B) ^ get(A - 1) )

Buggy submission (verdict: Runtime Error):

from functools import reduce

A, B = map(int, input().split())

def xor(x, y):
  return x ^ y

print(reduce(xor, list(range(A, B+1))))
Problem p03307 (python)

Fixed submission:

n = int(input())
print(n*2 if n%2 == 1 else n)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
print(int(n * 2 / math.gcd(n, 2)))
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r * r)

Buggy submission (verdict: Runtime Error):
r = input()
rr = input()
rrr = r * rr
print(rrr)

Buggy submission (verdict: Runtime Error):
r = input()
r2 = r * r
print(r2)

Buggy submission (verdict: Runtime Error):
r = input()
print(r * r)

Buggy submission (verdict: Runtime Error):
temp1 = r
temp2 = temp1 * 2
print(temp2)

Buggy submission (verdict: Runtime Error):
temp = r
print(temp * 2)

Buggy submission (verdict: Runtime Error):
print(r * r)

Buggy submission (verdict: Runtime Error):
return r * r