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

Fixed submission:
K = int(input())

from collections import deque

nlist = deque([1,2,3,4,5,6,7,8,9])

for i in range(K):
    sample = nlist.popleft()
        
    if sample%10 != 0:
        nlist.append(sample*10 - 1 + sample%10)
            
    nlist.append(sample*10 + sample%10)
        
    if sample%10 != 9:
        nlist.append(sample*10 + 1 + sample%10)
    
print(sample)

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

nlist = [1,2,3,4,5,6,7,8,9]
sample = 0
count = 0

def BFS(count,nlist,sample):
    if count == K:
        print(sample)
        return
    else:
        sample = nlist.pop(0)
        
        if sample%10 != 0:
            nlist.append(sample*10 - 1 + sample%10)
            
        nlist.append(sample*10 + sample%10)
        
        if sample%10 != 9:
            nlist.append(sample*10 + 1 + sample%10)
            
        count+=1

        BFS(count,nlist,sample)
        
BFS(count,nlist,sample)

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

nlist = [1,2,3,4,5,6,7,8,9]
sample = 0
count = 0

def BFS(count,nlist,sample):
    if count == K:
        print(sample)
        return
    else:
        sample = nlist.pop(0)
        
        if sample%10 != 0:
            nlist.append(sample*10 - 1 + sample%10)
            
        nlist.append(sample*10 + + sample%10)
        
        if sample%10 != 9:
            nlist.append(sample*10 + 1 + sample%10)
            
        count+=1

        BFS(count,nlist,sample)
        
BFS(count,nlist,sample)

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

nlist = [1,2,3,4,5,6,7,8,9]
sample = 0
count = 0

def BFS(count,nlist,sample):
    if count == K:
        print(sample)
        return
    else:
        sample = nlist.pop(0)
        
        if sample%10 != 0:
            nlist.append(sample*10 - 1 + sample%10)
            
        nlist.append(sample*10 + + sample%10)
        
        if sample%10 != 9:
            nlist.append(sample*10 + 1 + + sample%10)
            
        count+=1

        BFS(count,nlist,sample)
        
BFS(count,nlist,sample)
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()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

alist = []
ans = 0

for i in range(X):
    alist.append(p[i])
    
for j in range(Y):
    alist.append(q[j])
    
for k in range(C):
    alist.append(r[k])
    
alist.sort(reverse=True)
    
for k in range(X+Y):
    ans += alist[k]

print(ans)

Buggy submission (verdict: Runtime Error):
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()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

alist = []
ans = 0

for i in range(X):
    alist.append(p[i])
    
for j in range(Y):
    alist.append(q[j])
    
alist.sort(reverse=True)
ans = sum(alist)

a2 = [alist[0]]
r2 = [r[0]]

for i in range(1,len(alist)):
    a2.append(alist[i]+a2[i-1])
    r2.append(r[i]+r2[i-1])

ans = a2[-1]

for i in range(C-1):
    ans = max(ans,a2[i]+r2[C-i-1])
    
print(ans)
Problem p02732 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
import collections as col
 
num_list = set(A)
ca = col.Counter(A)

num = 0

for i in num_list:
    if ca[i] == 1:
        continue
    else:
        num += (ca[i]*(ca[i]-1))//2
        
for i in A:
    ans = num - (ca[i]-1)
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
import collections as col
 
num _list= set(A)
ca = col.Counter(A)

num = 0

for i in num_list:
    if ca[i] == 1:
        continue
    else:
        num += (ca[i]*(ca[i]-1))//2
        
for i in A:
    ans = num - (ca[i]-1)
    print(ans)
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):
a,b,c = list(map(int,input().split()))

if c-a-b > 0 and 4*a*b < (c-a-b)**2:
    print("Yes")
else:
    print("No")
Problem p02750 (python)

Fixed submission:
import sys
from bisect import bisect_right
 
N,T = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(N)]

b0 = []
ab1 = []

#aが0とそれ以外で分ける
for a,b in ab:
    if a == 0:
        #+1は店間の移動を先に考慮
        b0.append(b+1)
    else:
        ab1.append([(b+1)/a, a, b])

N0 = len(b0)
N1 = len(ab1)

b0.sort()

#bは累積和で時間計算可能（最後にどこまで足せるかを調べる）
if N0>0:
    b_ruiseki = [0]*N0
    b_ruiseki[0] = b0[0]
    for i in range(1,N0):
        b_ruiseki[i] = b_ruiseki[i-1] + b0[i]
else:
    b_ruiseki = []
#探索範囲が28店まででいいからソートする
ab1.sort()

INF = T + 100
 
dp = [[INF]*31 for i in range(N1+1)]
dp[0][0] = 0
ans = 0
for i in range(N1):
    # dp[i+1][j] : 0~i番目までの店を見て，j個選ぶときの最小時間
    for j in range(31):
        if j > i+1:
            break
        if j == 0:
            dp[i+1][j] = 0
        else:
            dp[i+1][j] = min(dp[i][j], dp[i][j-1]+1 + ab1[i][1]*(dp[i][j-1]+1) + ab1[i][2])

for j in range(31):
    if dp[N1][j] > T:
        break    
    # a>0をj店舗めぐった後にa=0を何店舗めぐれるか
    num0 = bisect_right(b_ruiseki, T - dp[N1][j])
    ans = max(ans, j + num0)
        
    
print(ans)

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

import sys

time = 0
mintime = 10**9

for shop in range(N):
    time += 1
    for i in range(len(ab)):
        t = time + ab[i][0]*time + ab[i][1]
        if t < mintime:
            mintime = t
            go = i
    mintime = 10**9
    time = time + ab[go][0]*time + ab[go][1]
    
    if time > T+0.5:
        print(shop)
        sys.exit()
    
    ab.pop(go)
    
print(shop+1)
Problem p02801 (python)

Fixed submission:
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
C = input()
for i in range(len(alpha)):
    if C == alpha[i]:
        print(alpha[i+1])

Buggy submission (verdict: Runtime Error):
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","a"]
C = input()
for i in range(len(alpha)):
    if C == alpha[i]:
        print(alpha[i+1])
Problem p02802 (python)

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

AC = [0]*N
WA = [0]*N
miss = 0

for i in range(M):
    p,S = list(map(str,input().split()))
    p = int(p)-1
    
    if S == 'AC' and AC[p] == 0:
        AC[p] = 1
        miss += WA[p]
        
    WA[p] += 1
        
print(sum(AC),miss)

Buggy submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
ps = []
for i in range(M):
    ps.append(list(map(str,input().split())))
    
import sys

if M == 0:
    print(0,0)
    sys.exit()

ps_new = sorted(ps , key=lambda x: x[0])
toi = []

for i in range(M):
    toi.append(ps[i][0])
    
toi2 = toi[0]
toi3 = [toi2]

for i in range(M):
    if toi2 != toi[i]:
        toi3.append(toi[i])
        toi2 = toi[i]
toi3.append("0")

toi = ps_new[0][0]
j = 0
count1 = 0
count2 = 0
count3 = 0

for i in range(M):
    if toi == ps[i][0]:
        count2 += 1
        if count2 == 1:
            shokai = i
        if ps_new[i][1] == "AC":
            count1 += 1
            j += 1
            toi = toi3[j]
            count2 = 0
            count3 = count3 + (i-shokai)
    elif toi != ps[i][0] and ps_new[i][1] == "AC":
        count+=1
print(count1,count3)

Buggy submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
ps = []
for i in range(M):
    ps.append(list(map(str,input().split())))
    
ps_new = sorted(ps , key=lambda x: x[0])
toi = []

for i in range(M):
    toi.append(ps[i][0])
    
toi2 = toi[0]
toi3 = [toi2]

for i in range(M):
    if toi2 != toi[i]:
        toi3.append(toi[i])
        toi2 = toi[i]
toi3.append("0")

toi = ps_new[0][0]
j = 0
count1 = 0
count2 = 0
count3 = 0

for i in range(M):
    if toi == ps[i][0]:
        count2 += 1
        if count2 == 1:
            shokai = i
        if ps_new[i][1] == "AC":
            count1 += 1
            j += 1
            toi = toi3[j]
            count2 = 0
            count3 = count3 + (i-shokai)
            
print(count1,count3)
Problem p02813 (python)

Fixed submission:
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

import itertools

A = [i+1 for i in range(N)]
all_permutation_list = list(itertools.permutations(A))
a = all_permutation_list.index(P)
b = all_permutation_list.index(Q)
print(abs(a - b))

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(str,input().split()))
Q = list(map(str,input().split()))

import itertools
 
n_list = [i+1 for i in range(N)]
all_list = list(itertools.permutations(A))
a = all_list.index(P)
b = all_list.index(Q)
print(abs(a - b))
Problem p02814 (python)

Fixed submission:
from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
l = 1
for i in a:
    l *= i // gcd(l, i)
for i in a:
    if l // i % 2 == 0:
        print(0)
        exit()
print(ceil((m // l) / 2))

Buggy submission (verdict: Runtime Error):
from math import gcd
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [i // 2 for i in a]
l = 1
for a in A:
    lcd *= a // gcd(lcd, a)
for a in A:
    if lcd // a % 2 == 0:
        print(0)
        exit()
print((M//lcd+1)//2)

Buggy submission (verdict: Runtime Error):
from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
tmp = 1
for i in range(n):
    lcm = tmp * (a[i]//2) // gcd(tmp,a[i]//2)
    tmp = lcm
for i in range(n):
    if tmp // (a[i]//2) % 2 == 0:
        print(0)
        exit()
print((m//tmp+1)//2)

Buggy submission (verdict: Runtime Error):
from math import gcd, ceil
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i // 2 for i in a]
tmp = 1
for i in a:
    lcm = tmp * (a[i]//2) // gcd(tmp,a[i]//2)
    tmp = lcm
for i in a:
    if tmp // i % 2 == 0:
        print(0)
        exit()
print((m//tmp+1)//2)
Problem p02843 (python)

Fixed submission:
X = int(input())

a = X//100

Xlist = str(X)

import sys

if X <100:
    print(0)
    sys.exit()
    
if a*5+1 <= int(Xlist[-2] + Xlist[-1]) and int(Xlist[-2] + Xlist[-1]) <=99:
    print(0)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
X = int(input())
a = X//100

Xlist = str(X)

import sys

if X <100:
    print(0)
    sys.exit
    
if a*5+1 <= int(Xlist[-2] + Xlist[-1]) and int(Xlist[-2] + Xlist[-1]) <=99:
    print(0)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
X = int(input())
  
a = X//100

Xlist = str(X)

if a*5+1 <= int(Xlist[-2] + Xlist[-1]) and int(Xlist[-2] + Xlist[-1]) <=99:
    print(0)
else:
    print(1)

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

ans = 0

def search(a):
    
    global ans
    
    if a > X:
        return 0
    
    if a == X:
        ans = 1
    
    search(a+100)
    search(a+101)
    search(a+102)
    search(a+103)
    search(a+104)
    search(a+105)
    
    return ans
        
print(search(0))
Problem p02848 (python)

Fixed submission:
N = int(input())
S = input()

alpha = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

ans =[]

for i in range(len(S)):
    for j in range(26):
        if S[i] == alpha[j]:
            ans.append(alpha[j+N])

for i in range(len(ans)):
    print(ans[i], end ="")

Buggy submission (verdict: Runtime Error):
print(chr(ord(S[i]) + N - 90 + 65), end="")

N = int(input())
S = input()

for i in range(len(S)):
    if (ord(S[i]) + N) > 90:
        print(chr(ord(S[i]) + N - 90 + 64), end="")
    else:
        print(chr(ord(S[i]) + N ), end="")
Problem p02865 (python)

Fixed submission:
N = int(input())

if N%2 == 0:
    print(int(N/2)-1)
else:
    print(int(N//2))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
 
count1 = 0
count2 = 0

A_new = sorted(A)
B_new = sorted(B)
 
for i in range(N):
    if B_new[i] >= A_new[i]:
        count2 += 1
 
for i in range(N):
    for j in range(N):
        if A[i] == A_new[j] and B[i] == B_new[j] 
            count1 = 1
            break
        if A[i] == A_new[j] and B[i] < B_new[j]
            break
    if count1 == 1:
        break
 
if count1 == 1 and count2 == N:
    print("Yes")
else:
    print("No")

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

count1 = 0
count2 = 0

AB = []
AB_new = []
A_new = sorted(A)
B_new = sorted(B)

for i in range(N):
    AB.append([A[i],B[i]])
    AB_new.append([A_new[i],B_new[i]])
    
aaa = sorted(AB, key=lambda x:(x[0],x[1]))

for i in range(N):
    if B_new[i] >= A_new[i]:
        count2 += 1

for i in range(N):
    for j in range(N):
        if aaa[i] == AB_new[j]:
            count1 = 1
            break
        if AB_new[j][0] > aaa[i][0]:
            break
    if count1 == 1:
        break

if count1 == 1 and count2 == N:
    print("Yes")
else:
    print("No")
Problem p02882 (python)

Fixed submission:
import math
a,b,x=list(map(int,input().split()))
maxv=a*a*b
sukima=maxv-x
teimenseki=sukima/a
y=teimenseki*2/a
 
if x > (maxv/2):
    print(math.degrees(math.atan(y/a)))
else:
    tei=x/a
    z=tei*2/b
    print(math.degrees(math.atan(b/z)))

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

if 2*x < a*a*b:
    hatena = 2*x/a/b
    print(90-math.degrees(math.atan(hatena/b)))
else:
    hatena = 2*x/a/a - b
    print(90-math.degrees(math.atan(a/(b-hatena))))

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

import math

if 2*x < a*a*b:
    hatena = 2*x/a/b
    print(90-math.degrees(math.atan(hatena/b)))
else:
    hatena = 2*x/a/a - b
    print(90-math.degrees(math.atan(a/(b-hatena))))

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

import math

if 2*x < a*a*b:
    hatena = 2*x/a/b
    print(math.degrees(math.atan(hatena/b)))
else:
    hatena = 2*x/a/a - b
    print(90-math.degrees(math.atan(a/(b-hatena))))

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

import math

if x/(a**2) <= b/2:
    hatena = 2*x/a/b
    print(math.degrees(math.atan(hatena/b)))
else:
    hatena = 2*x/a/a - b
    print(90-math.degrees(math.atan(a/(b-hatena))))

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

import math

if x/a/a >= b/2:
    y = 2*x/(a**2)-b

    print(90-math.degrees(math.atan(a/(b-y))))
else:
    y = 2*x/(a*b)

    print(90-math.degrees(math.atan(y/b)))

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

import math

if x/a/a > b/2:
    y = 2*x/(a**2)-b

    print(90-math.degrees(math.atan(a/(b-y))))
else:
    y = 2*x/(a*b)

    print(90-math.degrees(math.atan(y/b)))

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

import math

if x*2/a > b:
    y = 2*x/(a**2)-b

    print(90-math.degrees(math.atan(a/(b-y))))
else:
    y = 2*x/(a*b)

    print(90-math.degrees(math.atan(y/b)))

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

import math

if x*2 > b:
    y = 0
    y = 2*x/(a**2)-b

    print(90-math.degrees(math.atan(a/(b-y))))
else:
    y = 0
    y = 2*x/(a*b)

    print(90-math.degrees(math.atan(y/b)))

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

if x*2 > b:
    import math

    y = 0
    y = 2*x/(a**2)-b

    print(90+math.degrees(math.atan(a/(y-b))))
else:
    import math

    y = 0
    y = 2*x/(a*b)

    print(90-math.degrees(math.atan(y/b)))

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

if x*2 > b:
    import math

    y = 0
    y = 2*x/(a**2)-b

    print(90-math.degrees(math.atan(a/(y-b))))
else:
    import math

    y = 0
    y = 2*x/(a*b)

    print(90-math.degrees(math.atan(y/b)))
Problem p02945 (python)

Fixed submission:
A,B = list(map(int,input().split()))
 
print(max(A+B,A-B,A*B))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
 
print(max(A+B,A-B,A*B))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

print(max(A+B,A-B,A*B))
Problem p02947 (python)

Fixed submission:
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]

from collections import Counter

c = Counter(s)
keys, values = zip(*c.most_common())
#print(keys)
#print(values)
ans = 0
n = 0
for i in range(len(values)):
    if values[i] > 1:
        n = values[i]
        ans += n*(n-1)//2
        
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]

from collections import Counter
from math import factorial

c = Counter(s)
keys, values = zip(*c.most_common())
#print(keys)
#print(values)
ans = 0
n = 0
for i in range(len(values)):
    if values[i] > 1:
        n = values[i]
        ans += factorial(n) / factorial(2) / factorial(n - 2)
        
print(int(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]

from collections import Counter
from math import factorial

c = Counter(s)
keys, values = zip(*c.most_common())
#print(keys)
#print(values)
ans = 0
n = 0
for i in range(len(values)):
    if values[i] != 1:
        n = values[i]
        ans += factorial(n) / factorial(2) / factorial(n - 2)
        
print(int(ans))
Problem p02969 (python)

Fixed submission:
r = int(input())

print(3*r*r)

Buggy submission (verdict: Runtime Error):
N,D = list(map(int,input().split()))
human = 1
hani = 2*D+1
while hani < N:
    hani = hani + (2*D+1)
    human +=1
    
print(human)

Buggy submission (verdict: Runtime Error):
N,D = list(map(int,input().split()))
human = 1
hani = 2*D+1
haniwhile hani < N:
    hani = hani + (2*D+1)
    human +=1
    
print(human) = kanshi
Problem p02971 (python)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

Asort = sorted(A,reverse=True)
first = max(Asort)
second = max(Asort[1:N])

for i in range(N):
    if A[i] != first:
        print(max(first,A[i]))
    else:
        print(second)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    for j in range(N):
        A_list[j] = A[j]
    
    A_list[i] = 0
    print(max(A_list))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    for j in range(N):
        A_list[j] = A[j]
    
    A_list[i] = 0
    print(max(A_list))
Problem p02995 (python)

Fixed submission:
from fractions import gcd

A,B,C,D = list(map(int,input().split()))

lcm = C*D/gcd(C,D)

a = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//int(lcm))
b = (B) - ((B)//C + (B)//D - (B)//int(lcm))
print(int(b-a))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

A,B,C,D = list(map(int,input().split()))
lcm = C*D/math.gcd(C,D)
a = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//lcm)
b = (B) - ((B)//C + (B)//D - (B)//lcm)
print(int(b-a))

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

 
lcm = C*D/math.gcd(C,D)
a = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//lcm)
b = (B) - ((B)//C + (B)//D - (B)//lcm)
print(int(b-a))

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

lcm = C*D/math.gcd(C,D)
a = (A-1) - ((A-1)//C + (A-1)//D - (A-1)//lcm)
b = (B) - ((B)//C + (B)//D - (B)//lcm)
print(int(b-a))
Problem p02996 (python)

Fixed submission:
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]

sortedAB = sorted(AB, key= lambda x: x[1])

import sys
work = 0

for i in range(N):
    work += sortedAB[i][0]
    if work > sortedAB[i][1]:
        print('No')
        sys.exit()
        
print('Yes')

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

sort_AB = sorted(AB, key= lambda x: x[1])
ans = 'Yes'
tmp = 0

for i in range(N):
    tmp += sortedAB[i][0]
    if tmp > sortedAB[i][1]:
        ans = 'No'
        break
        
print(ans)
Problem p03037 (python)

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

L = []
R = []

for i in range(M):
    inp = input().split()
    L.append(int(inp[0]))
    R.append(int(inp[1]))
    
if max(L) <= min(R):
    print(min(R)-max(L)+1)
else:
    print(0)

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

L = []
R = []

for i in range(M):
    inp = input().split()
    L.append(inp[0])
    R.append(inp[1])
    
if max(L) <= min(R):
    print(min(R)-max(L)+1)
else:
    print(0)
Problem p03160 (python)

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

cost1 = 0
cost2 = 0
cost = [0]
cost.append(abs(h[0]-h[1]))
    
for flog in range(2,len(h)):
    cost1 = cost[flog-2] + abs(h[flog] - h[flog-2])
    cost2 = cost[flog-1] + abs(h[flog] - h[flog-1])
    cost.append(min(cost1,cost2))
    #print(cost)
    
print(cost[-1])

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

dp = [0 for i in range(1010)]

for i in range(N-1):
    if i > 0:
        dp[i+1] = min(dp[i-1]+abs(h[i+1]-h[i-1]),dp[i]+abs(h[i+1]-h[i]))
    else:
        dp[i+1] = dp[i] + abs(h[i+1]-h[i])
        
print(dp[N-1])
Problem p03164 (python)

Fixed submission:
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())
    
dp = [[10**9+1]*(sum(v)+1) for i in range(N+1)]
dp[0][0] = 0

#v[i]を使うかどうか
for i in range(N):
    #価値がjのときの最小の重さ総量
    for j in range(sum(v)+1):
        if j >= v[i]:
            dp[i+1][j] = min(dp[i][j-v[i]]+w[i],dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
            
ans = 0

for i in range(sum(v)+1):
    if dp[N][i] <= W:
        ans = max(ans,i)
print(ans)

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())
    
dp = [[0]*(W+1) for i in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j >= w[i]:
            dp[i+1][j] = max(dp[i][j-w[i]]+v[i],dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
            
print(dp[N][W])