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

Fixed submission:
from sys import stdin

s = stdin.readline().rstrip()

li = ["A","T"]
li2 = ["C","G"]

if s in li:
    li.pop(li.index(s))
    print(li[0])
else:
    li2.pop(li2.index(s))
    print(li2[0])

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

n,q = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]

for i in range(q):
    kotoba = s[li[i][0]-1:li[i][1]]
    kai = kotoba.count("AC")
    print(kai)
Problem p03136 (python)

Fixed submission:
from sys import stdin
import bisect

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

li.sort()

if sum(li[:n-1]) > li[-1]:
    print("Yes")
    exit()

print("No")

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

li.sort()

if sum(li[:-1]) > li[i]:
    print("Yes")
else:
    print("No")
Problem p03151 (python)

Fixed submission:
from sys import stdin
from itertools import accumulate
import bisect

n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))

pra = []
mai = 0
kosuu = 0
atari = 0

for i in range(n):
    if a[i]-b[i] < 0:
        mai += b[i]-a[i]
        kosuu += 1
        continue
    elif a[i]-b[i] > 0:
        pra.append(a[i]-b[i])
    atari += 1

if sum(pra) < mai:
    print(-1)
    exit()
if atari == n:
    print(0)
    exit()
pra.sort(reverse=True)

pra = list(accumulate(pra))
print(bisect.bisect(pra,mai)+kosuu+1)

Buggy submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))

pra = []
mai = []
kosuu = 0
for i in range(n):
    if a[i]-b[i] < 0:
        mai.append(b[i]-a[i])
        continue
    elif a[i]-b[i] > 0:
        pra.append(a[i]-b[i])
    kosuu += 1

pra.sort(reverse=True)

if sum(pra) < sum(mai):
    print(-1)
    exit()

if kosuu == n:
    print(0)
    exit()

count = 1
now = 0
while mai:
    if pra[now] < mai[0]:
        count += 1
        now += 1
        continue
    else:
        pra[now] -= mai[0]
        count += 1
    mai.pop(0)
print(count)
Problem p03160 (python)

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

def score(li,n):
    dp = [-1 for _ in li]
    dp[0] = 0
    dp[1] = abs(li[1]-li[0])
    if n == 1:
        return dp[0]
    elif n == 2:
        return dp[1]
    else:
        for i in range(2,n):
            dp[i] = min(dp[i-2]+abs(li[i]-li[i-2]),dp[i-1]+abs(li[i]-li[i-1]))
        return(dp[n-1])
    
print(score(li,n))

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

V = sum(v)
# dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値
dp = [[-1] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
	for j in range(V + 1):
		# i+1番目を選ぶ場合
		if j - v[i] >= 0:
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
		# i+1番目を選ばない場合
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

# dp[N][j]がW以下であるようなjの最大値が答えになる
ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j

print(ans)

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

n,k = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

def score(li,n,k):
    dp = [-1 for _ in li]
    dp[0] = 0
    if n == 1:
        return 0
    elif n <= k:
        return abs(li[-1]-li[0])
    for i in range(1,n):
        dp[i] = min([dp[j] + abs(li[j] - li[i]) for j in range(max(0, i - k), i)])
    return dp[n-1] 

print(score(li,n,k))
Problem p03163 (python)

Fixed submission:
from sys import stdin
n,w = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
def knapsack(n,w,li):
    #li[i][0]が重さ,li[i][1]が価値
    dp = [[0 for i in range(w+1)]for j in range(n+1)]
    #dp[i][total_w]はi-1回目までの商品を加えた時に重さがtotal_wを超えないような値の最大値
    for i in range(n):
        for total_w in range(w+1):
            if total_w - li[i][0] >= 0:
                dp[i+1][total_w] = max(dp[i][total_w],dp[i][total_w-li[i][0]]+li[i][1])
            else:
                dp[i+1][total_w] = dp[i][total_w]
    return max(dp[-1])
print(knapsack(n,w,li))

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

V = sum(v)
# dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
	for j in range(V + 1):
		# i+1番目を選ぶ場合
		if j - v[i] >= 0:
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
		# i+1番目を選ばない場合
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

# dp[N][j]がW以下であるようなjの最大値が答えになる
ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j

print(ans)

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

n,w = [int(x) for x in stdin.readline().rstrip().split()]
nw = [0]*n
nv = [0]*n
for i in range(n):
    nw[i],nv[i] = [int(x) for x in stdin.readline().rstrip().split()]
def knapsack(n,w,nw,nv):
    dp = [[0*(w+1)]for j in range(n+1)]
    #dp[i][total_w]はi-1回目までの商品を加えた時に重さがtotal_wを超えないような値の最大値
    for i in range(n):
        for total_w in range(w+1):
            if total_w - nw[i] >= 0:
                dp[i+1][total_w] = max(dp[i][total_w],dp[i][total_w-nw[i]]+nv[i])
            else:
                dp[i+1][total_w] = dp[i][total_w]
    return dp[-1][-1]
print(knapsack(n,w,nw,nv))

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

n,w = [int(x) for x in stdin.readline().rstrip().split()]
nw = [0]*n
nv = [0]*n
for i in range(n):
    nw[i],nv[i] = [int(x) for x in stdin.readline().rstrip().split()]
def knapsack(n,w,nw,nv):
    dp = [[0*(w+1)]for j in range(n+1)]
    #dp[i][total_w]はi-1回目までの商品を加えた時に重さがtotal_wを超えないような値の最大値
    for i in range(n):
        for total_w in range(w+1):
            if total_w - nw[i] >= 0:
                dp[i+1][total_w] = max(dp[i][total_w],dp[i][total_w-nw[i]]+nv[i])
            else:
                dp[i+1][total_w] = dp[i][total_w]
    return dp[-1][-1]
print(knapsack(n,w,nw,nv))
Problem p03238 (python)

Fixed submission:
from sys import stdin
import bisect

n = int(stdin.readline().rstrip())

if n == 1:
    print("Hello World")
    exit()

li = [int(stdin.readline().rstrip()) for _ in range(n)]

print(sum(li))

Buggy submission (verdict: Runtime Error):
n = int(input())
low = 0
hi = 10**9

li = []
lin = []

for _ in range(n):
    x,y,h = map(int,input().split())
    if h != 0:
        li.append((x,y,h))
    lin.append((x,y,h))

for i in range(101):
    for j in range(101):
        flag = True
        h = li[0][2]+abs(i-li[0][0])+abs(j-li[0][1])
        for a,b,c in lin:
            if max(h-abs(i-a)-abs(j-b),0) != c:
                flag = False
                break
        if flag:
            print(i,j,h)
            exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
if n == 1:
    print("Hello World")
else:
    a,b = map(int,input().split())
    print(a+b)
Problem p03239 (python)

Fixed submission:
from sys import stdin
import bisect

n,t = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
li2 = []
for i in range(n):
    if li[i][1] <= t:
        li2.append(li[i][0])
if len(li2) == 0:
    print("TLE")
    exit()
li2.sort()
print(li2[0])

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

n,t = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)]
li2 = []
for i in range(n):
    if li[i][0] <= t:
        li2.append(li[i][0])

li2.sort()

print(li2[0])
Problem p03241 (python)

Fixed submission:
from sys import stdin
n,m = map(int,stdin.readline().rstrip().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
li = make_divisors(m)
point = 1
if n == 1:
    print(m)
    exit()
for i in range(1,len(li)):
    if m//li[i] < n:
        point = li[i-1]
        break
print(point)

Buggy submission (verdict: Runtime Error):
from sys import stdin
n,m = map(int,stdin.readline().rstrip().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
li = make_divisors(m)
for i in range(1,len(li)):
    if m//li[i] < n:
        point = li[i-1]
        break
print(point)

Buggy submission (verdict: Runtime Error):
from sys import stdin
n,m = map(int,stdin.readline().rstrip().split())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
li = make_divisors(m)
for i in range(1,len(li)):
    if m//li[i] < n:
        point = li[i-1]
        break
print(point)
Problem p03244 (python)

Fixed submission:
from sys import stdin
from itertools import groupby

n = int(stdin.readline().rstrip())

li = list(map(int,stdin.readline().rstrip().split()))

li1 = []
li2 = []

for i in range(n):
    if i % 2 == 0:
        li1.append(li[i])
    else:
        li2.append(li[i])

li1.sort()
li2.sort()

lin = []
lin2 = []

for key, value in groupby(li1):
    lin.append((key,len(list(value))))
for key, value in groupby(li2):
    lin2.append((key,len(list(value))))

lin.sort(key=lambda x:(x[1]))
lin2.sort(key=lambda x:(x[1]))

point = 0

if lin[-1][0] == lin2[-1][0] and lin[-1][1] == lin2[-1][1]:
    if len(lin) == 1:
        print(n//2)
    else:
        if lin[-2][1] >= lin2[-2][1]:
            print(n-lin[-2][1]-lin2[-1][1])
        else:
            print(n-lin[-1][1]-lin2[-2][1])

elif lin[-1][0] == lin2[-1][0]:
    if len(lin) == 1:
        print(n//2-lin2[-2][1])
    elif len(lin2) == 1:
        print(n//2-lin[-2][1])
    else:
        if lin[-2][1] >= lin2[-2][1]:
            print(n-lin[-1][1]-lin2[-2][1])
        else:
            print(n-lin[-2][1]-lin2[-1][1])
else:
    print(n-lin[-1][1]-lin2[-1][1])

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

ki = li[::2]
gu = li[1::2]

ki.sort()
gu.sort()

from itertools import groupby

ki_li = []
gu_li = []

for key, value in groupby(ki):
    ki_li.append((key,len(list(value))))

for key, value in groupby(gu):
    gu_li.append((key,len(list(value))))

ki_li.sort(key=lambda x:(x[1]*(-1)))
gu_li.sort(key=lambda x:(x[1]*(-1)))

if ki_li[0][0] == gu_li[0][0]:
    if ki_li[0][1] > gu_li[0][1]:
        if len(gu_li) >= 2:
            ans = n-ki_li[0][1]-gu_li[1][1]
        else:
            ans = n-ki_li[0][1]
    elif ki_li[0][1] == gu_li[0][1]:
        if ki_li[1][1] >= gu_li[1][1]:
            ans = n-gu_li[0][1]-ki_li[1][1]
        else:
            ans = n-ki_li[0][1]-gu_li[1][1]
    else:
        if len(ki_li) >= 2:
            ans = n-gu_li[0][1]-ki_li[1][1]
        else:
            ans = n-gu_li[0][1]
else:
    ans = n-gu_li[0][1]-ki_li[0][1]

print(ans)
Problem p03262 (python)

Fixed submission:
from sys import stdin
import fractions


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

li = list(map(int,stdin.readline().rstrip().split()))
lin = []
for i in range(len(li)):
    lin.append(abs(li[i]-x))
poi = lin[0]
for i in range(len(lin)-1):
    poi = fractions.gcd(poi,lin[i+1])

print(poi)

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
li = list(map(int,input().split()))
lin = [abs(i-x) for i in li]
print(lin)
import fractions#python3.4ではmathではなくこちらのライブラリを用いる
def gcd_all(list):
    return gcd_all([fractions.gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]
gcd = gcd_all(lin)

print(gcd)

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

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

li = list(map(int,stdin.readline().rstrip().split()))

def gcd_all(list):
    return gcd_all([fractions.gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]
lin = []
for i in range(len(li)):
    lin.append(abs(li[i]-x))
gcd = gcd_all(lin)
print(gcd)
Problem p03263 (python)

Fixed submission:
from sys import stdin
h,w = map(int,stdin.readline().rstrip().split())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(h)]
point = 0
lin = []
#まず行ごとにまとめて右に1つづつスライド
for i in range(h):
    for j in range(w-1):
        if li[i][j] %2 == 1:
            li[i][j] -= 1
            li[i][j+1] += 1
            lin.append([i+1,j+1,i+1,j+2])
            point += 1
#右端のを１つづつ下にスライド
for i in range(h-1):
    if li[i][w-1] %2 == 1:
        li[i][w-1] -= 1
        li[i+1][w-1] += 1
        lin.append([i+1,w,i+2,w])
        point += 1
print(point)
for i in lin:
    print(*i)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import numpy as np
h,w = map(int,stdin.readline().rstrip().split())
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(h)]
point = 0
lin = []
#まず行ごとにまとめて右に1つづつスライド
for i in range(h):
    for j in range(w-1):
        if li[i][j] %2 == 1:
            li[i][j] -= 1
            li[i][j+1] += 1
            lin.append([i+1,j+1,i+1,j+2])
            point += 1
#右端のを１つづつ下にスライド
for i in range(h-1):
    if li[i][w-1] %2 == 1:
        li[i][w-1] -= 1
        li[i+1][w-1] += 1
        lin.append([i+1,w,i+2,w])
        point += 1
print(point)
for i in lin:
    print(*i)
Problem p03282 (python)

Fixed submission:
from sys import stdin

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

zantei = 1
kai = 0
for i in s:
    if i == "1":
        kai += 1
    else:
        zantei = int(i)
        break

if zantei == 1:
    print(1)

elif kai >= k:
    print(1)
else:
    print(zantei)

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

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

for i in s:
    if i != "1":
        zantei = int(i)
        break

if zantei == 1:
    print(1)
else:
    print(zantei)

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

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

for i in s:
    if i != "1":
        zantei = int(i)
        break

if zantei == 1:
    print(1)
 
else:
    print(zantei)
Problem p03353 (python)

Fixed submission:
from sys import stdin

s = stdin.readline().rstrip()
n = int(stdin.readline().rstrip())
li = []

for i in range(1,6):
    for j in range(len(s)-i+1):
        li.append(s[j:j+i])
li = list(set(li))
li.sort()
print(li[n-1])

Buggy submission (verdict: Runtime Error):
from sys import stdin
import bisect
from itertools import accumulate
import numpy as np

s = stdin.readline().rstrip()
n = int(stdin.readline().rstrip())
li = []

for i in range(1,len(s)+1):
    for j in range(len(s)-i+1):
        li.append(s[j:j+i])
li = list(set(li))
li.sort()
print(li[n-1])
Problem p03355 (python)

Fixed submission:
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())


finish = set()
S = len(s)

for i in range(S):
    for j in range(1,6):
        finish.add(s[i:i+j])

finish = list(finish)
finish.sort()

print(finish[k-1])

Buggy submission (verdict: Runtime Error):
from sys import stdin
from sys import setrecursionlimi
setrecursionlimit(10 ** 7)

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())

def main():
    finish = set()
    S = len(s)
    for i in range(S):
        for j in range(i+1,S+1):
            finish.add(s[i:j])

    finish = list(finish)
    finish.sort()
    print(finish[k-1])

if __name__ == "__main__":
    main()
Problem p03386 (python)

Fixed submission:
from sys import stdin
a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
if b-a < c*2:
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+c):
        print(i)
    for j in range(b-c+1,b+1):
        print(j)

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

a,b,k= [int(x) for x in stdin.readline().rstrip().split()]

li = [i for i in range(a,b+1)]

lin = []

for i in range(k):
    lin.append(li[i])
    lin.append(li[len(li)-i-1])

lin = list(set(lin))
lin.sort()

for i in lin:
    print(i)
Problem p03425 (python)

Fixed submission:
from sys import stdin
from itertools import combinations
from math import factorial

n = int(stdin.readline().rstrip())
li = [stdin.readline().rstrip() for _ in range(n)]

lin = [0]*5

for i in range(len(li)):
    if li[i][0] == "M":
        lin[0] += 1
    elif li[i][0] == "A":
        lin[1] += 1
    elif li[i][0] == "R":
        lin[2] += 1
    elif li[i][0] == "C":
        lin[3] += 1
    elif li[i][0] == "H":
        lin[4] += 1
        
lis = list(combinations(lin, 3))

point = 0
for i in lis:
    point += i[0]*i[1]*i[2]

print(point)

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

n = int(stdin.readline().rstrip())
li = [stdin.readline().rstrip() for _ in range(n)]

lin = [0]*n

for i in range(len(lin)):
    if li[i][0] == "M":
        lin[0] += 1
    elif li[i][0] == "A":
        lin[1] += 1
    elif li[i][0] == "R":
        lin[2] += 1
    elif li[i][0] == "C":
        lin[3] += 1
    elif li[i][0] == "H":
        lin[4] += 1

from itertools import combinations
lis = list(combinations(lin, 3))


point = 0
for i in lis:
    point += i[0]*i[1]*i[2]

print(point)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import numpy as np
import math
from math import factorial
from itertools import combinations

n = int(stdin.readline().rstrip())
li = [stdin.readline().rstrip() for _ in range(n)]

lin = []

for i in range(n):
    if li[i][0] in "MARCH":
        lin.append(li[i][0])

liv = list(combinations(lin, 3))
point = 0
for i in liv:
    if i[0] != i[1] and i[0] != i[2] and i[2] != i[1]:
        point += 1
print(point)
Problem p03433 (python)

Fixed submission:
from sys import stdin
from itertools import combinations

n = int(stdin.readline().rstrip())
a = int(stdin.readline().rstrip())

if a >= n:
    print("Yes")

else:
    if n%500 <= a:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
from sys import stdin
import heapq
inf = 10**10
h,w = [int(x) for x in stdin.readline().rstrip().split()]
point = 0
li = [["#" for i in range(w)]for j in range(h)]
for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        if s[j] == ".":
            point += 1
        li[i][j] = s[j]

def dijkstra(start, W):
    distance_list = [inf] * len(W)
    distance_list[start] = 0
    done_list = []
    wait_heap = []
    for i, d in enumerate(distance_list):
        heapq.heappush(wait_heap, (d, i))
    while wait_heap:
        p = heapq.heappop(wait_heap)
        i = p[1]
        if i in done_list:
            continue
        done_list.append(i)
        for j, x in enumerate(W[i]):
            if x != 0 and j not in done_list:
                d = min(distance_list[j], distance_list[i]+x)
                distance_list[j] = d
                heapq.heappush(wait_heap, (d, j))
    return distance_list

a = [[0 for i in range(w)]for j in range(h)]
for i in range(h):
    for j in range(w):
        a[i][j] = i*w + j

lin = [[0 for i in range(h*w)]for j in range(h*w)]

for i in range(h):
    for j in range(w-1):
        if li[i][j] == "." and li[i][j+1] == ".":
            lin[a[i][j]][a[i][j+1]] = 1
            lin[a[i][j+1]][a[i][j]] = 1

for i in range(h-1):
    for j in range(w):
        if li[i][j] == "." and li[i+1][j] == ".":
            lin[a[i][j]][a[i+1][j]] = 1
            lin[a[i][j]][a[i+1][j]] = 1

lis = dijkstra(0,lin)
if lis[h*w-1] == inf:
    print(-1)
    exit()

print(point-lis[-1]-1)
Problem p03438 (python)

Fixed submission:
from sys import stdin
n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))
A = sum(a);B = sum(b)
count_1 = 0
count_2 = 0
total = B-A
for i,j in zip(a,b):
    if i < j:
        count_1 += (j-i+1)//2
    else:
        count_2 += i-j
count = max(count_1,count_2)
if count <= total:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from sys import stdin
n = int(stdin.readline().rstrip())
a = list(map(int,stdin.readline().rstrip().split()))
b = list(map(int,stdin.readline().rstrip().split()))
A = sum(A);B = sum(B)
count = 0
total = B-A
for i,j in zip(a,b):
    if i < j:
        count += (j-i+1)//2
    else:
        count += i-j
if count <= total:
    print("Yes")
else:
    print("No")
Problem p03488 (python)

Fixed submission:
from itertools import groupby
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

s = input()

x,y = map(int,input().split())

d = [len(i) for i in s.split('T')]

x_li = d[2::2]
y_li = d[1::2]

now_x = [0]
now_y = [0]

x -= d[0]

for i in x_li:
    nx = set()
    for j in now_x:
        nx.add(j-i)
        nx.add(j+i)
    now_x = nx

for i in y_li:
    ny = set()
    for j in now_y:
        ny.add(j-i)
        ny.add(j+i)
    now_y = ny

if x in now_x and y in now_y:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from itertools import groupby

s = list(input())
x,y = map(int,input().split())

li = []

for key, value in groupby(s):
    li.append((key,len(list(value))))

x_li = []
y_li = []

now = 0
for i in li:
    if i[0] == "F":
        if now%2 == 0:
            x_li.append(i[1])
        else:
            y_li.append(i[1])
    else:
        now += i[1]

x_flag = False
y_flag = False

def possible(n,now,final,li):
    global x_flag,y_flag
    if n == len(li):
        if now == final:
            if li == x_li:
                x_flag = True
            else:
                y_flag = True
    else:
        return possible(n+1,now-li[n],final,li),possible(n+1,now+li[n],final,li)

possible(0,0,x,x_li)
possible(0,0,y,y_li)

if x_flag and y_flag:
    print("Yes")
else:
    print("No")
Problem p03544 (python)

Fixed submission:
from sys import stdin

n = int(stdin.readline().rstrip())

li = [0]*87

li[0] = 2
li[1] = 1

for i in range(2,87):
    li[i] = li[i-1] + li[i-2]

print(li[n])

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

n = int(stdin.readline().rstrip())

li = [0]*86

li[0] = 2
li[1] = 1

for i in range(2,86):
    li[i] = li[i-1] + li[i-2]

print(li[n])