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

Fixed submission:
import math
A, B, H, M =map(int, input().split())
Min = 60*H + M
long_v = 0.5
short_v = 6
diff = 5.5*Min%360
print((A**2 + B**2 - 2*A*B*math.cos(math.radians(diff)))**0.5)

Buggy submission (verdict: Runtime Error):
A, B, H, M =map(int, input().split())
Min = 60*H + M
long_v = 0.5
short_v = 6
diff = 5.5*Min%360
print((A**2 + B**2 - 2*A*B*math.cos(math.radians(diff)))**0.5)
Problem p02678 (python)

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



path = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    path[A-1].append(B) 
    path[B-1].append(A)
    
    

visited = [False for _ in range(N)]
que = [1]
visited[0] = True
sign = [-1 for _ in range(N)]

while True:
    next_que = []
    if not que:
        break
#     for q in que:
#         probable_room = path[q-1]
#         for p in probable_room:
    else:
        for q in que:
            probable_room = path[q-1]
            for p in probable_room:
#                 if p == q:
#                     continue
                if visited[p-1]:
                    continue
                else:
#                 print(1111)
                    visited[p-1] = True
                    sign[p-1] = q
                    next_que.append(p)
    que = next_que
if all(visited):
    print("Yes")
    for i in range(1,N):
        print(sign[i])
else:
    print("No")

Buggy submission (verdict: Runtime Error):
visited = [False for _ in range(N)]
que = [1]
visited[0] = True
sign = [-1 for _ in range(N)]

while True:
    next_que = []
    if not que:
        break
#     for q in que:
#         probable_room = path[q-1]
#         for p in probable_room:
    else:
        for q in que:
            probable_room = path[q-1]
            for p in probable_room:
#                 if p == q:
#                     continue
                if visited[p-1]:
                    continue
                else:
#                 print(1111)
                    visited[p-1] = True
                    sign[p-1] = q
                    next_que.append(p)
    que = next_que
if all(visited):
    print("Yes")
    for i in range(1,N):
        print(sign[i])
else:
    print("No")
Problem p02684 (python)

Fixed submission:
N, K = map(int,input().split())
A = [int(i)-1 for i in input().split()]

visited = [0]
visited_flg = [0 for _ in range(N)]
visited_flg[0] = 1
now_city = 0

next_city = A[0]
# visited.append(A[0])

if K <= N:
    p = 0
    for _ in range(K):
        p = A[p]
    print(p + 1)
    exit()


while True:
    next_city = A[now_city] 
    if visited_flg[next_city]:
        break
    
    now_city = next_city
    visited.append(now_city)
    visited_flg[now_city] = 1
    

loop_start = next_city
loop_city =  visited[visited.index(loop_start):]
k =  (K- len(visited)) % len(loop_city)
print(loop_city[k]+1)

Buggy submission (verdict: Runtime Error):
visited = [0]
visited_flg = [0 for _ in range(N)]
visited_flg[0] = 1
now_city = 0

next_city = A[0]
# visited.append(A[0])

# if K <= N:
#     p = 0
#     for _ in range(K):
#         p = A[p]
#     print(p + 1)
#     exit()


while True:
    next_city = A[now_city] 
    if visited_flg[next_city]:
        break
    
    now_city = next_city
    visited.append(now_city)
    visited_flg[now_city] = 1
    

loop_start = next_city
loop_city =  visited[visited.index(loop_start):]
k =  (K- len(visited)) % len(loop_city)
print(loop_city[k]+1)
Problem p02719 (python)

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

if x>=y:
    x=x%y
a=y-x
b=x

print(min(a,b))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
def gcd(x, y):
    if x>y:
        if y==0:
            return x
        return gcd(y,x%y)
    else:
        if x==0:
            return y
        return gcd(x,y%_)
if (n%m==0):
    print(0)
else:
    print(gcd(n,m))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
import math
print(math.gcd(n,m))
Problem p02802 (python)

Fixed submission:
n,m=map(int,input().split())
TF=[0]*n
p=[0]*n
for _ in range(m):
    i,s =map(str,input().split())
    i=int(i)-1
    if (s=="WA") and (TF[i]==1):
        pass
    elif (s=="WA") and (TF[i]==0):
        p[i]+=1
    elif (s=="AC") and (TF[i]==0):
        TF[i]=1
    elif (s=="AC") and (TF[i]==1):
        pass
for i in range(n):
    if TF[i]==0:
        p[i]=0
ac=sum(TF)
pe=sum(p)
print(ac,pe)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
TF=[0]*n
p=[0]*n
for _ in range(m):
    i,s =map(str,input().split())
    i=int(i)-1
    if (s=="WA") and (TF[i]==1):
        pass
    elif (s=="WA") and (TF[i]==0):
        p[i]+=1
    elif (s=="AC") and (TF[i]==0):
        TF[i]=1
    elif (s=="AC") and (TF[i]==1):
        pass
for i in range(m):
    if TF[i]==0:
        p[i]=0
ac=sum(TF)
pe=sum(p)
print(ac,pe)
Problem p03862 (python)

Fixed submission:
n,x = map(int,input().split())
a=list(map(int,input().split()))
ans=0
if a[0]>x:
    ans+=a[0]-x
    a[0]=x
for i in range(len(a)-1):
    if a[i]+a[i+1]>x:  
        b=a[i+1]-x+a[i]
        a[i+1]=x-a[i]
        ans+=b
print(ans)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=list(map(int,input().split()))
eat=0
if a[0]>x:
    eat+=(a[0]-x)
    a[0]=x
for i in range(1,n-1):
    if a[i-1]+a[i]>x:
        f=(a[i-1]+a[i]-x)
        eat+=f
        a[i]=a[i-f]
print(eat)
Problem p02727 (python)

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    X, Y, A, B, C = input_nums()
    P = input_nums()
    Q = input_nums()
    R = input_nums()
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort()

    P = sorted(P[:X])
    Q = sorted(Q[:Y])
    res = []
    res = P + Q + R
    res.sort(reverse=True)
    print(sum(res[:X+Y]))
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    X, Y, A, B, C = input_nums()
    P = input_nums()
    Q = input_nums()
    R = input_nums()
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)
    res = []
    res += P[:X]
    res += Q[:Y]
    res.sort(reverse=True)
    index = 0
    maxindex = len(R)-1
    for i in range(len(res)):
        if res[i] < R[index] and index <= maxindex:
            res[i] = R[index]
            index += 1
    print(sum(res))
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    X, Y, A, B, C = input_nums()
    P = input_nums()
    Q = input_nums()
    R = input_nums()
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)
    res = []
    res += P[:X]
    res += Q[:Y]
    res.sort(reverse=True)
    index = 0
    for i in range(len(res)):
        if res[i] < R[index]:
            res[i] = R[index]
            index += 1
    print(sum(res))
if __name__ == '__main__':
    main()
Problem p02982 (python)

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
import numpy as np

def main():
    N, D = input_nums()
    Xs = {}
    for i in range(N):
        Xs[i] = np.array(input_nums())
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            a = np.sqrt(np.sum(np.square(Xs[i] - Xs[j])))
            if a == int(a):
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
import numpy as np

def main():
    N, D = input_nums()
    Xs = {}
    for i in range(N):
        Xs[i] = np.array(input_nums())
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            a = np.sqrt(np.sum(np.square(Xs[i] - Xs[j])))
            if a == int(a):
                cnt += 1
    print(cnt)


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

Fixed submission:
from sys import stdin

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

def count_div(a, b, div):
    ac = a // div
    if ac * div < a:
        ac += 1
    bc = b // div
    if bc * div > b:
        bc -= 1
    return bc - ac + 1

if __name__ == '__main__':
    A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]

    nc = count_div(A, B, C)
    
    nd = count_div(A, B, D)
    
    CD = int(C * D / gcd(C, D))
    ncd = count_div(A, B, CD)
    
    n = B - A + 1
    
    ans = n - (nc + nd - ncd)
    print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import math

def count_div(a, b, div):
    ac = a // div
    if ac * div < a:
        ac += 1
    bc = b // div
    if bc * div > b:
        bc -= 1
    return bc - ac + 1

if __name__ == '__main__':
    A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]

    nc = count_div(A, B, C)
    
    nd = count_div(A, B, D)
    
    CD = int(C * D / math.gcd(C, D))
    ncd = count_div(A, B, CD)
    
    n = B - A + 1
    
    ans = n - (nc + nd - ncd)
    print(ans)
Problem p03161 (python)

Fixed submission:
from sys import stdin
N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]

INF = 10**18
dp = [INF] * (N + K)

dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        if i + j < N:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
        else:
            break
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split())))

INF = 10**18
dp = np.array([INF] * 10**5)
h = np.concatenate([h, np.array([0]*(10**5 - len(h)))])

dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

print(dp[N-1])

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

INF = 10**18
dp = [INF] * 10**5
h = h + [0]*(10**5 - len(h))

dp[0] = 0

for i in range(N):
    for j in range(1, K+1):
        dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

print(dp[N-1])
Problem p03324 (python)

Fixed submission:
from sys import stdin

D, N = map(int, stdin.readline().rstrip().split())

if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    else:
        print(100*N)
elif D == 2:
    if N == 100:
        print(1010000)
    else:
        print(10000*N)

Buggy submission (verdict: Runtime Error):
from sys import stdin

D, N = map(int, stdin.readline().rstrip().split())

if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    print(100*N)
elif D == 2:
    if N == 100:
        pritn(1010000)
    else:
        print(10000*N)
Problem p03862 (python)

Fixed submission:
from sys import stdin

N, x = [int(x) for x in stdin.readline().rstrip().split()]
candys = [int(x) for x in stdin.readline().rstrip().split()]

count = 0

# xより多く入っている箱のキャンディは必ず食べる必要がある。
for i in range(N):
    if candys[i] > x:
        num = candys[i] - x
        candys[i] = x
        count += num
        # print(candys)

# print('count = ', count)
# print('---------------------------')

# 隣り合った箱を見て、xを越えていれば食べる
for i in range(N-1):
    if candys[i] + candys[i+1] > x:
        num = candys[i] + candys[i+1] - x
        count += num
        candys[i+1] = candys[i+1] - num
        # print(candys)
# 結果
print(count)

Buggy submission (verdict: Runtime Error):
from sys import stdin

N, x = [int(x) for x in stdin.readline().rstrip().split()]
candys = [int(x) for x in stdin.readline().rstrip().split()]

count = 0

# xより多く入っている箱のキャンディは必ず食べる必要がある。
for i in range(N):
    if candys[i] > x:
        num = candys[i] - x
        candys[i] = x
        count += num
        print(candys)

print('count = ', count)
print('---------------------------')

# 隣り合った箱を見て、xを越えていれば食べる
for i in range(N-1):
    if candys[i] + candys[i+1] > x:
        num = candys[i] + candys[i+1] - x
        count += num
        candys[i+1] = candys[i+1] - num
        print(candys)
# 結果
print(count)
Problem p02548 (python)

Fixed submission:

def main():
    N = int(input())
    ans = sum((N-1)//i for i in range(1, N))
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
def main():
    N = input()
    ans = 0
    for c in range(1, N):
        ans += solve(N-c)
    print(ans)

def solve(n):
    res = 0
    for i in range(1,n//2):
        if n % i == 0:
            res += 1
    return res

main()
Problem p02573 (python)

Fixed submission:
N, M = (int(x) for x in input().split())
import collections
Parent = [i for i in range(N)]
def fp(i):
    global Parent
    if Parent[i] == i:
        return i
    else:
        Parent[i] = fp(Parent[i])
        return Parent[i]

for _ in range(M):
    a, b = (int(x) for x in input().split())
    par_a, par_b = fp(a-1), fp(b-1)
    if par_a < par_b:
        Parent[par_b] = par_a
    else:
        Parent[par_a] = par_b

Groupsize = collections.defaultdict(lambda:0)
for i in range(N):
    i = fp(i)
    Groupsize[i] +=1
ans = max(gs for gs in Groupsize.values())
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = (int(x) for x in input().split())
import collections
Parent = [i for i in range(N)]
def fp(i):
    global Parent
    if Parent[i] == i:
        return i
    else:
        Parent[i] == fp(Parent[i])
        return Parent[i]

for _ in range(M):
    a, b = (int(x) for x in input().split())
    Parent[max(a,b)-1] = fp(min(a,b)-1)

Groupsize = collections.defaultdict(lambda:0)
for i in range(N):
    i = fp(i)
    Groupsize[i] +=1
ans = max(gs for gs in Groupsize.values())
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = (int(x) for x in input().split())
import collections
Parent = [i for i in range(N)]
for _ in range(M):
    a, b = (int(x) for x in input().split())
    Parent[max(a,b)-1] = min(a,b)-1

def fp(i):
    global Parent
    if Parent[i] == i:
        return i
    else:
        Parent[i] == fp(Parent[i])
        return Parent[i]


Groupsize = collections.defaultdict(lambda:0)
for i in range(N):
    i = fp(i)
    Groupsize[i] +=1
ans = max(gs for gs in Groupsize.values())
print(ans)
Problem p03407 (python)

Fixed submission:
A, B, C = map(int, input().split())
print('Yes' if A+B>=C else 'No')

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input())
print('Yes' if A+B*2 >= C else 'No')
Problem p03409 (python)

Fixed submission:
N = int(input())
Red = sorted([tuple(map(int, input().split())) for _ in range(N)])
Blue = sorted([tuple(map(int, input().split())) for _ in range(N)])

ans = 0
for bx,by in Blue:
    C = [(y,x) for x,y in Red if x<bx and y<by] #候補
    if len(C) == 0:
        continue
    ans += 1
    C.sort(reverse=True)
    Red.remove((C[0][1],C[0][0]))
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
Red = sorted([tuple(map(int, input().split())) for _ in range(N)])
Blue = sorted([tuple(map(int, input().split())) for _ in range(N)])

ans = 0
switch = lambda X:(X[1],X[0])
for b in Blue:
    C = [switch(r) for r in Red if r < b] #候補
    if len(C) == 0:
        continue
    ans += 1
    C.sorted(reverse=True)
    Red.remove(switch(C[0]))
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
Red = sorted([tuple(map(int, input().split())) for _ in range(N)])
Blue = sorted([tuple(map(int, input().split())) for _ in range(N)])

ans = 0
for b in Blue:
    C = [r for r in Red if r < b] #候補
    if len(C) == 0:
        continue
    ans += 1
    pair = (0,0)
    for c in C:
        if c[1] > pair[1]:
            pair = c
    Red.remove(pair)
print(ans)
Problem p03416 (python)

Fixed submission:
N = {} #10000以上key以下の回文数の個数
cnt = 0
for i in range(10000, 100000):
    L = list(str(i))
    if L == list(reversed(L)):
        cnt += 1
    N[i] = cnt
A, B = map(int, input().split())
print(N[B]-N[A-1] if A > 10000 else N[B])

Buggy submission (verdict: Runtime Error):
N = {} #10000以上key以下の回文数の個数
cnt = 0
for i in range(10000, 100000):
    L = list(str(i))
    if L == list(reversed(L)):
        cnt += 1
    N[i] = cnt
A, B = map(int, input().split())
print(N[B]-N[A-1])
Problem p03450 (python)

Fixed submission:
N, M = map(int, input().split())
LRD = [tuple(int(x) for x in input().split()) for _ in range(M)]
Graph = [[] for _ in range(N)]
for l,r,d in LRD:
    Graph[r-1].append((l-1,d))
    Graph[l-1].append((r-1,-d))

seen = set()
Dfr = [0] * N #dist from Root
for root in range(N):
    if root in seen: continue
    seen.add(root)
    V = [root]
    while len(V) != 0: #bfs
        v = V.pop(0)
        for nv,d in Graph[v]:
            if nv in seen and Dfr[nv] != Dfr[v] + d: #bfsで発見済みの値が異なる⇔矛盾
                print('No')
                exit()
            if nv in seen: continue
            else:
                seen.add(nv)
                Dfr[nv] = Dfr[v] + d
                V.append(nv)
print('Yes')

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
LRD = [tuple(int(x) for x in input().split()) for _ in range(M)]

import numpy as np
Graph = np.full((N,N), np.inf)
for l,r,d in LRD:
    Graph[r-1,l-1] = d
    Graph[l-1,r-1] = -d
import scipy.sparse.csgraph as csg
try:
    Graph = csg.johnson(Graph)
    for l,r,d in LRD:
        if Graph[r-1,l-1] != d or Graph[l-1,r-1] != -d:
            ans = 'No'
            break
    else:
        ans = 'Yes'
except csg.NegativeCycleError:
    ans = 'No'
print(ans)
Problem p03472 (python)

Fixed submission:
N, H = map(int, input().split())
slash = 0
Throw = []
for _ in range(N):
    a, b = map(int, input().split())
    slash = max(slash, a)
    if b > a: Throw.append(b)    
#slash=斬撃最大ダメージ、投げてslash超のダメージが出るならばその剣をダメージが大きい順に投げる
import heapq as hq
Throw = [-th for th in Throw if th > slash]
hq.heapify(Throw)

dmg, cnt = 0, 0
while len(Throw) != 0:
    if dmg >= H: break
    dmg += -hq.heappop(Throw)
    cnt += 1
if dmg < H:
    from math import ceil
    cnt += ceil((H-dmg)/slash)
print(cnt)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left as bsl

def main():
    with open(0) as f:
        N, H = map(int, f.readline().split())
        ab = list(map(int, f.read().split()))
    max_slash = max(ab[0::2])
    throw = [x for x in ab[1::2] if x > max_slash]
    throw.sort(reverse=True)
    throw = [sum(throw[0:i]) for i in range(1,len(throw)+1)]
    index = bsl(throw, H)
    l = len(throw)
    if index < l:
        print(index + 1)
    else:
        H += -throw[l-1]
        print(l + (H+max_slash-1)//max_slash)

main()

Buggy submission (verdict: Runtime Error):
N, H = map(int, input().split())
slash = 0
Throw = []
for _ in range(N):
    a, b = map(int, input().split())
    slash = max(slash, a)
    if b > a: Throw.append(b)    
#slash=斬撃最大ダメージ、投げてslash超のダメージが出るならばその刀をダメージが大きい順に投げる
Throw = sorted([th for th in Throw if th > slash], reversed=True)
dmg, cnt = 0, 0
for throw in Throw:
    if dmg >= H: break
    dmg += throw
    cnt += 1
if dmg < H:
    from math import ceil
    cnt += ceil((H-dmg)/slash)
print(cnt)
Problem p03480 (python)

Fixed submission:
S = list(input())
lenS = len(S)
S = S + ['.']
K = lenS
i = 0
ps = S[0]
for s in S:
    if s != ps:
        K = min(K, max(i, lenS-i))
        ps = s
    i += 1
print(K)

Buggy submission (verdict: Runtime Error):
def main():
    S = input() + '.'
    count = 0
    data = []
    for i, s in enumerate(S[1:]):
        count += 1
        if s != S[i]:
            data.append(count)
            count = 0
    data.append(0)
    ans = max([min(data[i-1]+data[i], data[i]+data[i+1]) for i in range(1,len(data)-1)])
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
S = list(input())
lenS = len(S)
front = S.index('0' if S[0] == '1' else '1')
S.reverse()
end = S.index('0' if S[0] == '1' else '1')
ans = lenS - min(front, end)
print(ans)
Problem p03486 (python)

Fixed submission:
s = sorted(x for x in input())
t = sorted([x for x in input()], reverse=True)
print('Yes' if s < t else 'No')

Buggy submission (verdict: Runtime Error):
S = sorted(x for x in input())
T = sorted([x for x in input()], reverse=True)
for s,t in zip(S,T):
    if s < t:
        ans = 'Yes'
        break
    if s > t:
        ans = 'No'
print(ans)
Problem p03487 (python)

Fixed submission:
N = input()
A = sorted([int(x) for x in input().split()])
import bisect as bs
ans = 0
f = lambda X, x: bs.bisect_right(X,x) - bs.bisect_left(X,x)
for a in set(A):
    cnt = f(A,a)
    if cnt < a:
        ans += cnt
    else:
        ans += cnt-a
print(ans)

Buggy submission (verdict: Runtime Error):
N = input()
A = sorted([int(x) for x in input().split()])
import bisect as bs
ans = 0
f = lambda X, x: bs.bisect_right(X,x) - bs.bisect_left(X.x)
for a in set(A):
    cnt = f(A,a)
    if cnt < a:
        ans += cnt
    else:
        ans += cnt-a
print(ans)
Problem p03488 (python)

Fixed submission:
from collections import defaultdict
def main():
    S = input() + 'T'
    x, y = map(int, input().split())
    #データ加工
    moveX, moveY = [], []
    if S[0] == 'T': moveX.append(0)
    move ={0:moveX, 1:moveY}
    direct = 0
    step = 0
    for s in S:
        if s == 'T':
            if step > 0:
                move[direct].append(step)
                step = 0
            direct ^= 1 
        else:
            step += 1
    #判定
    if possible(x, moveX[1:], moveX[0]) and possible(y, moveY):
        print('Yes')
    else:
        print('No')


def possible(target, move, offset=0):
    l = len(move)
    dp = [defaultdict(lambda:False) for _ in range(l+1)]
    #初期化
    dp[0][0] = True
    for i,m in enumerate(move):
        for key in dp[i]:
            dp[i+1][key+m] = True
            dp[i+1][key-m] = True
    return dp[l][target-offset]


main()

Buggy submission (verdict: Runtime Error):
import numpy as np
s = input()
x, y = (int(x) for x in input().split())
Move = []
cnt = 0
s += 'T'
for c in s:
    if c == 'F':
        cnt += 1
    else:
        Move.append(cnt)
        cnt = 0
Move = np.array(Move)
X = Move[Move.index % 2 == 0]
Y = Move[Move.index % 2 == 1]
lenX = len(X)-1
Xmoveable = {X[0] + sum(-X[i+1] if bit & (1<<i) else X[i+1] for i in range(lenX)) for bit in range(2**lenX)}
lenY = len(Y)
Ymoveable = {sum(-Y[i] if bit & (1<<i) else Y[i] for i in range(lenY)) for bit in range(2**lenY)}

if x in Xmoveable and y in Ymoveable:
    print('Yes')
else:
    print('No')
Problem p03493 (python)

Fixed submission:
s = input()
ans = s.count('1')
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = s.count(1)
print(ans)
Problem p03544 (python)

Fixed submission:
N = int(input())
L = [0] * (N+1)
L[0] = 2
L[1] = 1
for i in range(2,N+1):
    L[i] = L[i-1] + L[i-2]
print(L[N])

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [] * (N+1)
L[0] = 2
L[1] = 1
for i in range(2,N+1):
    L[i] = L[i-1] + L[i-2]
print(L[N])
Problem p03545 (python)

Fixed submission:
List = [int(n) for n in input()]
ans = [List[0]] * 4
for i in range(8):
    for j in range(3):
        if i & (1<<j):
            ans[j+1]= -List[j+1]
        else:
            ans[j+1] = List[j+1]
    if sum(ans) == 7:
        break
ans = [str(ans[0])] + ['+' + str(x) if x>=0 else str(x) for x in ans[1:]]
print("".join(ans) + '=7')

Buggy submission (verdict: Runtime Error):
ABCD = input().strip()
for i in range(8):
    ope = [{0:'+', 1:'-'}[i & (1<<j)] for j in range(3)]
    fomula = ABCD[0] + ope[0] + ABCD[1] + ope[1] + ABCD[2] + ope[2] + ABCD[3]
    if eval(fomula) == 7:
        print(f'{fomula}=7')
        break

Buggy submission (verdict: Runtime Error):
ABCD = input()
for i in range(8):
    ope = [{0:'+', 1:'-'}[i & (1<<j)] for j in range(3)]
    fomula = ABCD[0] + ope[0] + ABCD[1] + ope[1] + ABCD[2] + ope[2] + ABCD[3]
    if eval(fomula) == 7:
        print(f'{fomula}=7')
        break

Buggy submission (verdict: Runtime Error):
ope = {0:'+', 1:'-'}
ABCD = input()
for i in range(8):
    i = [i & (1<<j) for j in range(3)]
    fomula = ABCD[0] + ope[i[0]] + ABCD[1] + ope[i[1]] + ABCD[2] + ope[i[2]] + ABCD[3]
    if eval(fomula) == 7:
        print(f'{fomula}=7')
        break