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

Fixed submission:
import sys
sys.setrecursionlimit(10000000)

N = int(input())
edges = [[] for i in range(N+1)]
alledges = []
for i in range(N-1):
    a, b = map(int, input().split())
    alledges.append((a, b))
    edges[a].append(b)
    edges[b].append(a)

def dfs(node, parent):
    used = {col[(node, parent)]}
    curcol = 1
    for n in edges[node]:
        if n == parent: continue

        while curcol in used: curcol += 1

        col[(node, n)] = curcol
        col[(n, node)] = curcol

        dfs(n, node)

        used.add(curcol)
        
col = {}
start = max(range(1, N+1), key = lambda x : len(edges[x]))

for i, n in enumerate(edges[start]):
    col[(start, n)] = i + 1
    col[(n, start)] = i + 1
    dfs(n, start)



done = set()
print(len(edges[start]))
for e in alledges:
    print(col[e])

Buggy submission (verdict: Runtime Error):
N = int(input())
edges = [[] for i in range(N+1)]
alledges = []
for i in range(N-1):
    a, b = map(int, input().split())
    alledges.append((a, b))
    edges[a].append(b)
    edges[b].append(a)

def dfs(node, parent):
    used = {col[(node, parent)]}
    curcol = 1
    for n in edges[node]:
        if n == parent: continue

        while curcol in used: curcol += 1

        col[(node, n)] = curcol
        col[(n, node)] = curcol

        dfs(n, node)

        used.add(curcol)
        
col = {}
start = max(range(1, N+1), key = lambda x : len(edges[x]))

for i, n in enumerate(edges[start]):
    col[(start, n)] = i + 1
    col[(n, start)] = i + 1
    dfs(n, start)



done = set()
print(len(edges[start]))
for e in alledges:
    print(col[e])
Problem p02882 (python)

Fixed submission:
W, H, X = map(int, input().split())
X /= W
if W*H==X:
    print(0)
    quit()
import math
if H*2*X/pow(H,2)<=W:
    print(90 - math.atan(2*X/pow(H,2)) * 180/math.pi)
else:
    angle = 90 - math.atan(W*W/(2*(W*H-X))) * 180/math.pi
    print(angle)

Buggy submission (verdict: Runtime Error):
W, H, X = map(int, input().split())
X /= W
import math
angle = 90 - math.atan(2*X/pow(H,2)) * 180/math.pi
if angle >= 45:
    print(angle)
else:
    angle = 90 - math.atan(W*W/(2*(W*H-X))) * 180/math.pi
    print(angle)
Problem p02900 (python)

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

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

num = gcd(A, B)

if num < 2:
    print(1)
    quit()

length = int(num ** 0.5) + 2
isPrime = [True for i in range(length)]
isPrime[2] = True
for i in range(2, length):
    if isPrime[i]:
        for j in range(2 * i, length, i):
            isPrime[j] = False

count = 1

cur = 2
while num != 1 and cur < length:
    if isPrime[cur] and num % cur == 0:
        while num % cur == 0:
            num //= cur
        count += 1
    cur += 1

print(count + (num != 1))

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

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

num = gcd(A, B)

if num < 2:
    print(1)
    quit()

length = int(num ** 0.5) + 2
isPrime = [True for i in range(length)]
isPrime[2] = True
for i in range(2, length):
    if isPrime[i]:
        for j in range(2 * i, length, i):
            isPrime[j] = False

count = 1

cur = 2
while num != 1:
    if isPrime[cur] and num % cur == 0:
        while num % cur == 0:
            num //= cur
        count += 1
    cur += 1

print(count)

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

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

num = gcd(A, B)

if num < 2:
    print(1)
    quit()

length = int(num ** 0.5) + 1
isPrime = [True for i in range(length)]
isPrime[2] = True
for i in range(2, length):
    if isPrime[i]:
        for j in range(2 * i, length, i):
            isPrime[j] = False

count = 1

cur = 2
while num != 1:
    if isPrime[cur] and num % cur == 0:
        while num % cur == 0:
            num //= cur
        count += 1
    cur += 1

print(count)

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

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

num = gcd(A, B)

isPrime = [True for i in range(num + 1)]
isPrime[2] = True
for i in range(2, num+1):
    if isPrime[i]:
        for j in range(2 * i, num+1, i):
            isPrime[j] = False

count = 1

cur = 2
while num != 1:
    if isPrime[cur] and num % cur == 0:
        while num % cur == 0:
            num //= cur
        count += 1
    cur += 1

print(count)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

N, Q = map(int, input().split())
edges = [[] for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)

tally = [0 for i in range(N+1)]
for i in range(Q):
    p, x = map(int, input().split())
    tally[p] += x

count = [0 for i in range(N + 1)]
visited = [False for i in range(N+1)]

stack = [(1, 0)]
while stack:
    root, curCount = stack.pop()
    
    visited[root] = True
    curCount += tally[root]
    count[root] = curCount
    for neighbour in edges[root]:
        if visited[neighbour]: continue
        stack.append((neighbour, curCount))

print(*count[1:])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
edges = [[] for i in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)

tally = [0 for i in range(N+1)]
for i in range(Q):
    p, x = map(int, input().split())
    tally[p] += x

count = [0 for i in range(N + 1)]
visited = [False for i in range(N+1)]
def dfs(root, curCount):
    visited[root] = True
    curCount += tally[root]
    count[root] = curCount
    for neighbour in edges[root]:
        if visited[neighbour]: continue
        dfs(neighbour, curCount)

dfs(1, 0)

print(*count[1:])
Problem p03162 (python)

Fixed submission:
N = int(input())

vals = [[0, 0, 0] for i in range(N)]

for i in range(N):
    v1, v2, v3 = map(int, input().split())
    vals[i][0] = v1
    vals[i][1] = v2
    vals[i][2] = v3

dp = [[0 for i in range(3)] for j in range(N)]

dp[0][0] = vals[0][0]
dp[0][1] = vals[0][1]
dp[0][2] = vals[0][2]

for i in range(1, N):
    for activity in range(3):
        for pastActivity in range(3):
            if activity == pastActivity: continue
            
            dp[i][activity] = max(dp[i][activity],
                                  dp[i-1][pastActivity] + vals[i][activity])

print(max(dp[-1]))

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

vals = [[0, 0, 0] for i in range(N)]

for i in range(N):
    v1, v2, v3 = map(int, input().split())
    vals[i][0] = v1
    vals[i][1] = v2
    vals[i][2] = v3

dp = [[0 for i in range(N)] for j in range(3)]

dp[0][0] = vals[0][0]
dp[0][1] = vals[0][1]
dp[0][2] = vals[0][2]

for i in range(1, N):
    for activity in range(3):
        for pastActivity in range(3):
            if activity == pastActivity: continue
            
            dp[i][activity] = max(dp[i][activity],
                                  dp[i-1][pastActivity] + vals[i][activity])

print(max(dp[-1]))
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000 + 1)

N, M = map(int, input().split())

maxDist = [0 for i in range(N+1)]
in_degree = [0 for i in range(N+1)]
adj_list = [[] for i in range(N+1)]

for i in range(M):
    x, y = map(int, input().split())
    adj_list[x].append(y)
    in_degree[y] += 1

for node in range(1, N+1):
    adj_list[0].append(node)
    in_degree[node] += 1

# dp[i] = maximum length of path ending at i
flattenedNodes = []
def dfs(node):
    for child in adj_list[node]:
        maxDist[child] = max(maxDist[child], 1 + maxDist[node])
        in_degree[child] -= 1
        if in_degree[child] == 0:
            dfs(child)
            
dfs(0)
print(max(maxDist) - 1)

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

maxDist = [0 for i in range(N+1)]
in_degree = [0 for i in range(N+1)]
adj_list = [[] for i in range(N+1)]

for i in range(M):
    x, y = map(int, input().split())
    adj_list[x].append(y)
    in_degree[y] += 1

for node in range(1, N+1):
    adj_list[0].append(node)
    in_degree[node] += 1

# dp[i] = maximum length of path ending at i
flattenedNodes = []
def dfs(node):
    for child in adj_list[node]:
        maxDist[child] = max(maxDist[child], 1 + maxDist[node])
        in_degree[child] -= 1
        if in_degree[child] == 0:
            dfs(child)
            
dfs(0)
print(max(maxDist) - 1)

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

maxDist = [0 for i in range(N)]
in_degree = [1 for i in range(N)]
adj_list_f = [[] for i in range(N)]
adj_list_b = [[] for i in range(N)]

for i in range(M):
    x, y = map(lambda x:int(x)-1, input().split())
    adj_list_f[x].append(y)
    adj_list_b[y].append(x)
    in_degree[y] += 1

# dp[i] = maximum length of path ending at i
def dfs(node):
    children = adj_list_f[node] if node != -1 else [i for i in range(N)]
    for child in children:
        if node == -1:
            maxDist[child] = max(maxDist[child], 1)
        else:
            maxDist[child] = max(maxDist[child], 1 + maxDist[node])
        in_degree[child] -= 1
        if in_degree[child] == 0:
            dfs(child)
            
dfs(-1)
print(max(maxDist) - 1)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
print(a*b)
Problem p03160 (python)

Fixed submission:
def func(arr):
    crr=[0 for i in range(len(arr))]
    crr[0]=0
    crr[1]=abs(arr[1]-arr[0])
    for i in range(2,len(arr)):
        crr[i]=min(abs((arr[i]-arr[i-1]))+crr[i-1],abs((arr[i]-arr[i-2]))+crr[i-2])
    print(crr[-1])

b=input()
cr=list(map(int,input().split()))
func(cr)

Buggy submission (verdict: Runtime Error):
def func(arr):
    crr=[0 for i in range(len(arr))]
    crr[0]=arr[0]
    crr[1]=arr[1]-arr[0]
    for i in range(2,len(arr)):
        crr[i]=min(abs((arr[i]-arr[i-1]))+crr[i-1],abs((arr[i]-arr[i-2]))+crr[i-2])
    print(crr)
    
b=input()
ar=list(map(int,input().split())
func(ar)
Problem p03493 (python)

Fixed submission:
print((lambda s: int(s[0])+int(s[1])+int(s[2]))(input()))

Buggy submission (verdict: Runtime Error):
print({
  '000': 0,
  '001': 1,
  '010': 1,
  '011': 2,
  '100': 1,
  '101': 2,
  '110': 2,
  '111' 3
}[input()])
Problem p03672 (python)

Fixed submission:
print((lambda s: [len(t) for t in [s[:i] for i in reversed(range(len(s)))] if (len(t)%2==0 and t[:len(t)//2]==t[len(t)//2:])])(input())[0])

Buggy submission (verdict: Runtime Error):
print((lambda s:[s for s in reversed(range(len(s))) if len(s)%2==0 and s[:len(s)//2]==s[len(s)//2:]][0])(input()))
Problem p03362 (python)

Fixed submission:
m = 55555

p = [True] * m
for i in range(3, m):
    if not p[i]:
        continue
    for j in range(2, m):
        if j * i >= len(p):
            break
        p[i*j] = False

n = int(input())
if n <= 5:
    t = [2, 3, 5, 7, 11]
    print(" ".join([str(a) for a in t[:n]]))
else:
    ans = []
    for i in range(m):
        if len(ans) == n:
            break
        t = i*5+7
        if not p[t]:
            continue
        ans.append(t)
    print(" ".join([str(a) for a in ans]))

Buggy submission (verdict: Runtime Error):
m = 55555

p = [False] * m
for i in range(3, m):
  if not p[i]:
    continue
  for j in range(2, m):
    if j * i >= len(p):
      break
    p[i*j] = False
    
n = int(input())

ans = []
for i in range(m):
  if len(ans)==n:
    break
  t = i*5+7
  if not p[t]:
    continue
  ans.append(t)
print(" ".join(ans))
Problem p03007 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
m = n//2

a.sort()
if a[0] >= 0:
    minus = [a[0]]
    plus = a[1:n]
elif a[n-1] <= 0:
    minus = a[0:n-1]
    plus = [a[n-1]]
else:
    for i in range(n):
        if a[i] > 0:
            point = i
            break
    minus = a[0:point]
    plus = a[point:n]
print(sum(plus)-sum(minus))
for i in range(n-1):
    mi = minus.pop(0)
    pl = plus.pop(0)
    if len(minus) >= len(plus):
        print(str(pl) +' '+str(mi))
        plus.append(pl-mi)
    else:
        minus.append(mi-pl)
        print(str(mi) +' '+str(pl))

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

a.sort()
minus = a[0:n//2]
plus = []
i = n//2
while a[i] < 0 and i < n:
    minus.append(a[i])
    i += 1
for j in range(i, n):
    plus.append(a[j])
print(sum(plus)-sum(minus))
for i in range(n-1):
    mi = minus.pop(0)
    pl = plus.pop(0)
    if len(minus) >= len(plus):
        print(str(pl) +' '+str(mi))
        plus.append(pl-mi)
    else:
        minus.append(mi-pl)
        print(str(mi) +' '+str(pl))
Problem p03030 (python)

Fixed submission:
N = int(input())
S_P = []
for i in range(N):
    S , P = input().split()
    S_P.append([ S , int(P) , i])
S_P.sort( key = lambda x : x[0] )
state = S_P[0][0]
S_P_sort = []
temp = []
for S , P , i in S_P:
    if S != state:
        temp.sort( key = lambda x : x[1] , reverse = True)
        S_P_sort.extend(temp)
        state = S
        temp = []
        temp.append([S , P, i])
    else:
        temp.append([S , P, i])
temp.sort( key = lambda x : x[1] , reverse = True)
S_P_sort.extend(temp)
for j in range(N):
    print(S_P_sort[j][2]+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
S_P = []
for i in range(N):
    S , P = input().split()
    S_P.append([ S , int(P) , i])
S_P.sort( key = lambda x : x[0] )
state = S_P[0][0]
S_P_sort = []
temp = []
for S , P , i in S_P:
    if S != state:
        temp.sort( key = lambda x : x[1])
        S_P_sort.extend(temp)
        S_P_sort.append([S , P, i])
        state = S
        temp = []
    else:
        temp.append([S , P, i])
for j in range(N):
    print(S_P_sort[j][2]+1)
Problem p03035 (python)

Fixed submission:
a, b = map(int, input().split())
if a <= 5:
    print(0)
elif 6 <= a <= 12:
    print(int(b / 2))
else:
    print(b)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
A = sorted(list(map(int, input().split())))
for i in range(m):
    b, c = map(int, input().split())
    for j in range(b):
        A[j] = max(A[j], c)
    A = sorted(A)
print(sum(A))
Problem p03047 (python)

Fixed submission:
#n = int(input())
#m = int(input())
#k = int(input())
#n, m = map(int, input().split())
n,  k = map(int, input().split())
#a = list(map(int, input().split()))
#table = []
'''
for i in range h:
    temp = list(map(int, input().split()))
    table.append(temp)
'''
print(n-k+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
#m = int(input())
k = int(input())
#n, m = map(int, input().split())
#n, m, k = map(int, input().split())
#a = list(map(int, input().split()))
#table = []
'''
for i in range h:
    temp = list(map(int, input().split()))
    table.append(temp)
'''
print(n-k+1)
Problem p03048 (python)

Fixed submission:
#n = int(input())
#m = int(input())
#k = int(input())
#n, m = map(int, input().split())
r, g, b, n = map(int, input().split())
#a = list(map(int, input().split()))
#table = []
'''
for i in range h:
    temp = list(map(int, input().split()))
    table.append(temp)
'''
count = 0
for i in range(n//r+1):
    for j in range((n-r*i)//g+1):
        if (n-r*i-g*j)%b == 0:
            count +=1
print(count)

Buggy submission (verdict: Runtime Error):
#n = int(input())
#m = int(input())
#k = int(input())
#n, m = map(int, input().split())
r, g, b, n = map(int, input().split())
#a = list(map(int, input().split()))
#table = []
'''
for i in range h:
    temp = list(map(int, input().split()))
    table.append(temp)
'''
count = 0
for i in range(n//r+1):
    for j in range((n-r*i)//g+1)
        if (n-r*i-g*j)%b == 0:
            count +=1
print(count)
Problem p03059 (python)

Fixed submission:
a, b, t = map( int, input().split() )
print(b*(t//a))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
mina = 10**9
minus = 0
sumA = 0
for a in A:
    if a < 0:
        minus += 1
        a = -a
    sumA += a
    mina = min(a, mina)
if minus % 2 == 1:
    sumA -= 2 * mina
print(sumA)

Buggy submission (verdict: Runtime Error):
import fractions
n = int(input())
a = list(map(int, input().split()))
forward = [0, a[0]]
back =[0, a[n-1]]
for i in range(1,n-1):
    forward.append(fractions.gcd(forward[i], a[i]))
    back.append(fractions.gcd(back[i], a[n-i-1]))

back.reverse()

ans = max(forward[n-2], back[0])
for i in range(n-2):
    ans = max(ans, fractions.gcd(forward[i], back[i]))
print(ans)
Problem p03061 (python)

Fixed submission:
import fractions
n = int(input())
a = list(map(int, input().split()))
forward = [0]
back =[0]
for i in range(0,n-1):
    forward.append(fractions.gcd(forward[i], a[i]))
    back.append(fractions.gcd(back[i], a[n-i-1]))
ans = 0
for i in range(n):
    ans = max(ans, fractions.gcd(forward[i], back[n-1-i]))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
forward = [0]
back =[0]
for i in range(0,n-1):
    forward.append(fractions.gcd(forward[i], a[i]))
    back.append(fractions.gcd(back[i], a[n-i-1]))

back.reverse()

ans = 0
for i in range(n):
    ans = max(ans, fractions.gcd(forward[i], back[i]))
print(ans)

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

import math
def gcd(list):
    gcd = list[0]
    for a in list:
        gcd = math.gcd(gcd, a)
    return gcd

max_gcd = 0
for i in range(n):
    Ai = A.pop(i)
    max_gcd = max(max_gcd, gcd(A))
    A.insert(i, Ai)

print(max_gcd)
Problem p03062 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
mina = abs(A[0])
minus = 0
sumA = 0
for a in A:
    if a < 0:
        minus += 1
        a = -a
    sumA += a
    mina = min(a, mina)
if minus % 2 == 1:
    sumA -= 2 * mina
print(sumA)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
mina = 10*10
minus = False
sumA = 0
for a in A:
    if a < 0:
        if minus:
            minus = False
        else:
            minus = True
    	a = -a
    sumA += a
    mina = min(a, mina)


if minus:
    sumA -= 2*mina
print(sumA)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
mina = 10*10
minus = False
sumA = 0
for a in A:
    if a < 0:
        if minus:
            minus = False
        else:
            minus = True
    	a = -a
    sumA += a
    mina = min(a, mina)


if minus:
    sumA -= 2*mina
print(sumA)
Problem p03086 (python)

Fixed submission:
s = input()
l = len(s)
a = [0]*l
for i in range(l):
    if s[i] == "A" or s[i] =="T" or s[i] =="C" or s[i] =="G":
        a[i] = 1
m = 0
if a[0] == 1:
  m = 1
for i in range(1,l):
    a[i] = (a[i-1]+1)*a[i]
    if m < a[i]:
        m = a[i]

print(m)

Buggy submission (verdict: Runtime Error):
s = input()
l = len(s)
a = [0]*l
for i in range(l):
    if s[i] == "A" or s[i] =="T" or s[i] =="C" or s[i] =="G":
        a[i] = 1
m = 0
if a[0] = 1:
  m = 1
for i in range(1,l):
    a[i] = (a[i-1]+1)*a[i]
    if m < a[i]:
        m = a[i]

print(m)
Problem p02621 (python)

Fixed submission:
a = int(input())
print(a+a*a+a*a*a)

Buggy submission (verdict: Runtime Error):
a = input()
print(a + a*a + a*a*a)
Problem p02743 (python)

Fixed submission:
def solve():
  a, b, c = map(int, raw_input().strip().split())
  d = c - a - b
  if d <= 0: return False
  return 4 * a * b < d * d

print 'Yes' if solve() else 'No'

Buggy submission (verdict: Runtime Error):
def solve():
	a, b, c = map(int, raw_input().strip().split())
    d = c - a - b
    if d <= 0: return False
    return 4 * a * b < d * d

print 'Yes' if solve() else 'No'
Problem p02811 (python)

Fixed submission:
k,x = map(int, raw_input().strip().split())
print 'Yes' if k*500>=x else 'No'

Buggy submission (verdict: Runtime Error):
k,x = map(int, raw_input.strip().split())
print 'Yes' if k*500>=x else 'No'
Problem p02921 (python)

Fixed submission:
s = raw_input()
t = raw_input()
ans = 0
for i in xrange(len(s)):
  if s[i] == t[i]: ans += 1
print ans

Buggy submission (verdict: Runtime Error):
s = raw_input()
t = raw_input()
ans = 0
for i in len(s):
  if s[i] == t[i]: ans += 1
print ans
Problem p02972 (python)

Fixed submission:
n = input()
a = [0] + map(int, raw_input().split())
b = [0 for _ in range(n + 1)]
used = []

for i in xrange(n, 0, -1):
  sum = 0
  for j in xrange(2 * i, n + 1, i):
    sum += b[j]
  if sum % 2 != a[i]:
    used.append(i)
    b[i] = 1
print len(used)
for x in used: print x,
print

Buggy submission (verdict: Runtime Error):
n = input()
a = map(int, raw_input().split())
b = [0 for _ in range(n)]
used = []

for i in xrange(n, 0, -1):
  sum = 0
  for j in xrange(2 * i, n + 1, i):
    sum += b[j]
  if sum % 2 != a[i]:
    used.append(i)
    b[i] = 1
print len(used)
for x in used: print x,
print
Problem p02789 (python)

Fixed submission:
n,m=map(int,input().split())
if(n==m):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n,m=int(input())
if(n==m) print('Yes')
else print('No')
Problem p03000 (python)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
 
point = 0
cnt = 1
while cnt<=N:
  point += L[cnt-1]
  if point <= X:
    cnt += 1
  else:
    break
 
print(cnt)

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

point = 0
cnt = 1
while point<=X:
  point += L[cnt-1]
  if point <= X:
    cnt += 1
  else:
    break

print(cnt)
Problem p03037 (python)

Fixed submission:
N, M = map(int, input().split())
l = []
r = []
for _ in range(M):
  s, t = map(int, input().split())
  l.append(s)
  r.append(t)
  
lm = max(l)
rm = min(r)
print(max([rm - lm + 1, 0]))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
l = []
r = []
for _ in range(M):
  s, t = map(int, input().split())
  l.append(s)
  r.append(t)
  
lm = max(l)
rm = min(r)
print(max[rm - lm + 1, 0])
Problem p03128 (python)

Fixed submission:
N, M = map(int, input().split())
a = list(map(int, input().split()))
mn = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

msort = lambda s: -s[0]

b = list(map(lambda i: [i, mn[i]], a))
b.sort(key = msort)
dp = [-100] * (N + 1)
dp[0] = 0
for i in range(2, N + 1):
  for n in b:
    if i >= n[1] and dp[i - n[1]] >= 0:
      dp[i] = max([dp[i], dp[i - n[1]] + 1])

match = N
ans = ''
while match > 0:
  for n in b:
    if match >= n[1] and dp[match] == dp[match - n[1]] + 1:
      ans += str(n[0])
      match -= n[1]
      break
    
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().split()))
mn = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

msort = lambda s: -s[0]

b = list(map(lambda i: [i, mn[i]], a))
b.sort(key = msort)
dp = [-100] * (N + 1)
dp[0] = 0
for i in range(2, N + 1):
  for n in b:
    if i >= n[1] and dp[i - n[1]] >= 0:
      dp[i] = max([dp[i], dp[i - n[1]] + 1])

match = N
ans = ''
while match > 0:
  for n in b:
    if dp[match] == dp[match - n[1]] + 1:
      ans += str(n[0])
      match -= n[1]
      break
    
print(ans)