Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N=int(input())
ab=[list(map(int, input().split())) for _ in range(N-1)]
to=[[] for _ in range(N)]
color=[0 for _ in range(N-1)]
for i in range(N-1):
    a, b=ab[i]
    a-=1
    b-=1
    to[a].append([b, i])
    to[b].append([a, i])

def dfs(v, p=-1, c=-1):
    k=1
    for i in range(len(to[v])):
        u, index=to[v][i]
        if u==p:
            continue
        if k==c:
            k+=1
        color[index]=k
        dfs(u, v, k)
        k+=1

dfs(0)
print(max(color))
for i in range(N-1):
    print(color[i])

Fixed submission:
import sys
sys.setrecursionlimit(200000)

N=int(input())
ab=[list(map(int, input().split())) for _ in range(N-1)]
ans=[0 for _ in range(N-1)]

def dfs(v, c=-1, p=-1):
  k=1
  for i in range(len(to[v])):
    u, id=to[v][i]
    if u==p:
      continue
    if k==c:
      k+=1
    ans[id]=k
    k+=1
    dfs(u, ans[id], v)

to=[[] for _ in range(N)]
for i in range(N-1):
  a, b=ab[i][0]-1, ab[i][1]-1
  to[a].append([b, i])
  to[b].append([a, i])

dfs(0)
print(max(ans))
for a in ans:
  print(a)

Buggy python submission (verdict: Runtime Error):
N=int(input())
ab=[list(map(int, input().split())) for _ in range(N-1)]
ans=[0 for _ in range(N-1)]

def dfs(v, c=-1, p=-1):
  k=1
  for i in range(len(to[v])):
    u, id=to[v][i]
    if u==p:
      continue
    if k==c:
      k+=1
    ans[id]=k
    k+=1
    dfs(u, ans[id], v)

to=[[] for _ in range(N)]
for i in range(N-1):
  a, b=ab[i][0]-1, ab[i][1]-1
  to[a].append([b, i])
  to[b].append([a, i])

dfs(0)
print(max(ans))
for a in ans:
  print(a)
               

Fixed submission:
import sys
sys.setrecursionlimit(200000)

N=int(input())
ab=[list(map(int, input().split())) for _ in range(N-1)]
ans=[0 for _ in range(N-1)]

def dfs(v, c=-1, p=-1):
  k=1
  for i in range(len(to[v])):
    u, id=to[v][i]
    if u==p:
      continue
    if k==c:
      k+=1
    ans[id]=k
    k+=1
    dfs(u, ans[id], v)

to=[[] for _ in range(N)]
for i in range(N-1):
  a, b=ab[i][0]-1, ab[i][1]-1
  to[a].append([b, i])
  to[b].append([a, i])

dfs(0)
print(max(ans))
for a in ans:
  print(a)
Buggy python submission (verdict: Runtime Error):
N, T=map(int, input().split())
lst=[list(map(int, input().split())) for _ in range(N)]
MAXN, MAXT=3001, 3001
dp1=[[0 for _ in range(MAXT)] for _ in range(MAXN)]
dp2=[[0 for _ in range(MAXT)] for _ in range(MAXN)]
for i in range(1, N+1):
  A, B=lst[i-1]
  for j in range(1, MAXT):
    dp1[i][j]=max(dp1[i-1][j], dp1[i-1][j-A]+B) if j>=A else dp1[i-1][j]
for i in range(N, 0, -1):
  A, B=lst[i-1]
  for j in range(1, MAXT):
    dp2[i][j]=max(dp2[i+1][j], dp2[i+1][j-A]+B) if j>=A else dp2[i+1][j]
ans=dp1[N-1][T-1]+lst[-1][1]
for i in range(1, N):
  A, B=lst[i-1]
  for j in range(T):
    ans=max(ans, dp1[i-1][j]+dp2[i+1][T-1-j]+B)
print(ans)

Fixed submission:
N, T=map(int, input().split())
lst=[list(map(int, input().split())) for _ in range(N)]
MAXN, MAXT=3001, 3001
dp1=[[0 for _ in range(MAXT)] for _ in range(MAXN+1)]
dp2=[[0 for _ in range(MAXT)] for _ in range(MAXN+1)]
for i in range(1, N+1):
  A, B=lst[i-1]
  for j in range(1, MAXT):
    dp1[i][j]=max(dp1[i-1][j], dp1[i-1][j-A]+B) if j>=A else dp1[i-1][j]
for i in range(N, 0, -1):
  A, B=lst[i-1]
  for j in range(1, MAXT):
    dp2[i][j]=max(dp2[i+1][j], dp2[i+1][j-A]+B) if j>=A else dp2[i+1][j]
ans=dp1[N-1][T-1]+lst[-1][1]
for i in range(1, N):
  A, B=lst[i-1]
  for j in range(T):
    ans=max(ans, dp1[i-1][j]+dp2[i+1][T-1-j]+B)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a, b, x = map(int, input().split())

if x>=(a*a*b)/2:
    print(90-math.degrees(math.atan(a**3/(2*(a*a*b-x)))))
else:
    print(90-math.degrees(math.asin(4*x/(a*b*b))/2))

Fixed submission:
import math

a, b, x=map(int, input().split())
ans=math.degrees(math.atan(2*(a*a*b-x)/a**3) if x>=a**2*b/2 else math.atan(a*b**2/(2*x)))
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B=map(int, input().split())
ans=a-2*b if a-2*b>0 else 0
print(ans)

Fixed submission:
a, b=map(int, input().split())
ans=a-2*b if a-2*b>0 else 0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
INF = 10**10

def warshall_floyd(d):
    # d[i][j]: ij間の最小コスト
    # i=jのとき0, i!=jのときINFで初期化
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])
    return d

N, M, L = map(int, input().split())
dist = [[INF for _ in range(N)] for _ in range(N)]
for i in range(N):
    dist[i][i] = 0
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1; b -= 1
    dist[a][b] = c; dist[b][a] = c
dist = warshall_floyd(dist)

dist2 = [[INF for _ in range(N)] for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            dist2[i][i] = 0
        else:
            if dist[i][j] <= L:
                dist2[i][j] = 1
dist2 = warshall_floyd(dist2)

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    s -= 1; t -= 1
    if dist2[s][t] == INF:
        print(-1)
    else:
        print(dist2[s][t]-1)

Fixed submission:
INF = 10**10

def warshall_floyd(d):
    # d[i][j]: ij間の最小コスト
    # i=jのとき0, i!=jのときINFで初期化
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])
    return d

N, M, L = map(int, input().split())
dist = [[INF for _ in range(N)] for _ in range(N)]
for i in range(N):
    dist[i][i] = 0
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1; b -= 1
    dist[a][b] = c; dist[b][a] = c
dist = warshall_floyd(dist)

dist2 = [[INF for _ in range(N)] for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            dist2[i][i] = 0
        else:
            if dist[i][j] <= L:
                dist2[i][j] = 1
dist2 = warshall_floyd(dist2)

Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    s -= 1; t -= 1
    if dist2[s][t] == INF:
        print(-1)
    else:
        print(dist2[s][t]-1)
Buggy python submission (verdict: Runtime Error):
S=input()
K=int(input())
count=0
SS=S*K
flag=True
for i in range(1, len(SS)):
  if not flag:
    flag=True
    continue
  if SS[i-1]==SS[i]:
    count+=1
    flag=False
print(count)

Fixed submission:
S=input()
K=int(input())
SS=S+S
SSS=SS+S
count_single=count_double=count_triple=0
flag=True
for i in range(1, len(S)):
  if not flag:
    flag=True
    continue
  if S[i-1]==S[i]:
    count_single+=1
    flag=False
flag=True
for i in range(1, len(SS)):
  if not flag:
    flag=True
    continue
  if SS[i-1]==SS[i]:
    count_double+=1
    flag=False
flag=True
for i in range(1, len(SSS)):
  if not flag:
    flag=True
    continue
  if SSS[i-1]==SSS[i]:
    count_triple+=1
    flag=False
if K==1:
  print(count_single)
elif K==2:
  print(count_double)
else:
  diff21=count_double-count_single
  diff32=count_triple-count_double
  print(count_single+(K//2)*diff21+((K-1)//2)*diff32)

Buggy python submission (verdict: Runtime Error):
S=input()
K=int(input())
count=0
SS=S*K
flag=True
for i in range(1, len(SS)):
  if not flag:
    flag=True
    continue
  else:
    count+=1
    flag=False
print(count)

Fixed submission:
S=input()
K=int(input())
SS=S+S
SSS=SS+S
count_single=count_double=count_triple=0
flag=True
for i in range(1, len(S)):
  if not flag:
    flag=True
    continue
  if S[i-1]==S[i]:
    count_single+=1
    flag=False
flag=True
for i in range(1, len(SS)):
  if not flag:
    flag=True
    continue
  if SS[i-1]==SS[i]:
    count_double+=1
    flag=False
flag=True
for i in range(1, len(SSS)):
  if not flag:
    flag=True
    continue
  if SSS[i-1]==SSS[i]:
    count_triple+=1
    flag=False
if K==1:
  print(count_single)
elif K==2:
  print(count_double)
else:
  diff21=count_double-count_single
  diff32=count_triple-count_double
  print(count_single+(K//2)*diff21+((K-1)//2)*diff32)

Buggy python submission (verdict: Runtime Error):
S=input()
K=int(input())
count=0
SS=S*K
flag=True
print(SS)
for i in range(1, len(SS)):
  if not flag:
    flag=True
    continue

Fixed submission:
S=input()
K=int(input())
SS=S+S
SSS=SS+S
count_single=count_double=count_triple=0
flag=True
for i in range(1, len(S)):
  if not flag:
    flag=True
    continue
  if S[i-1]==S[i]:
    count_single+=1
    flag=False
flag=True
for i in range(1, len(SS)):
  if not flag:
    flag=True
    continue
  if SS[i-1]==SS[i]:
    count_double+=1
    flag=False
flag=True
for i in range(1, len(SSS)):
  if not flag:
    flag=True
    continue
  if SSS[i-1]==SSS[i]:
    count_triple+=1
    flag=False
if K==1:
  print(count_single)
elif K==2:
  print(count_double)
else:
  diff21=count_double-count_single
  diff32=count_triple-count_double
  print(count_single+(K//2)*diff21+((K-1)//2)*diff32)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

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

d = defaultdict(list)
for i in range(N):
    for j in range(i+1, N):
        s = S[i:j+1]
        d[s].append([i, j])
ans = 0
for k in d.keys():
    if len(k) <= ans:
        continue
    l = len(d[k])
    for i in range(l):
        for j in range(i+1, l):
            if d[k][i][1] >= d[k][j][0]:
                continue
            else:
                ans = len(k)
print(ans)

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

dp = [[0 for _ in range(N+1)] for _ in range(N+1)]
for i in range(N-1, -1, -1):
    for j in range(N-1, -1, -1):
        if S[i] == S[j]:
            dp[i][j] = dp[i+1][j+1] + 1
        else:
            dp[i][j] = 0

ans = 0
for i in range(N):
    for j in range(N):
        ans = max(ans, min(dp[i][j], j-i))
print(ans)
Buggy python submission (verdict: Runtime Error):
m, d = map(int, input().split())
if m < 4 or d < 22:
  print("0")
else:
  res=0
  for i in range(22, d+1):
    d1, d2 = int(d/10), d%10
    res += 1 if d1*d2<=m else 0
   print(res)

Fixed submission:
m, d = map(int, input().split())
if m < 4 or d < 22:
  print("0")
else:
  res=0
  for i in range(22, d+1):
    d1, d2 = int(i/10), i%10
    if d2 < 2:
      continue
    res += 1 if d1*d2<=m else 0
  print(res)
Buggy python submission (verdict: Runtime Error):
a=input()
s=input()
if a >= 3200:
  print(s)
else:
  print("red")

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

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

Fixed submission:
a=int(input())
s=input()
if a >= 3200:
  print(s)
else:
  print("red")
Buggy python submission (verdict: Runtime Error):
a,b=map(int, input().split())
print(max(a+b, a-bm a*b))

Fixed submission:
a,b=map(int, input().split())
print(max(a+b, a-b, a*b))
Buggy python submission (verdict: Runtime Error):
k,x=map(int, input().split())
print(" ".join([x-k+i for i in range(1, 2k)]))

Fixed submission:
k,x=map(int, input().split())
print(" ".join([str(x-k+i) for i in range(1, 2*k)]))

Buggy python submission (verdict: Runtime Error):
k,x=map(int, input().split())
print(" ".join([x-k+1+i for i in range(2k+1)]))

Fixed submission:
k,x=map(int, input().split())
print(" ".join([str(x-k+i) for i in range(1, 2*k)]))

Buggy python submission (verdict: Runtime Error):
k, x=map(int, input().split())
print(" ".join([x-i for i in range(-k, k+1)]))

Fixed submission:
k,x=map(int, input().split())
print(" ".join([str(x-k+i) for i in range(1, 2*k)]))

Buggy python submission (verdict: Runtime Error):
a,b=map(int, input().split())
print(" ".join([x-i for i in range(-k, k)]))

Fixed submission:
k,x=map(int, input().split())
print(" ".join([str(x-k+i) for i in range(1, 2*k)]))
Buggy python submission (verdict: Runtime Error):
import bisect
n, m = map(int, input().split())
work = [list(map(int, input().split())) for i in range(n)]
dic = {}
for w in work:
    a, b = w[0], w[1]
    if a not in dic.keys():
        dic[a]=[b]
    else:
        index=bisect.bisect_right(dic[a], b)
        dic[a].insert(index, b)
dic_=sorted(dic.items(), key=lambda x:x[0])
res = 0
while m > 0:
    print(dic_)
    flag=True
    for i in range(len(dic_)):
        if dic_[i][0] >= m:
            flag=False
            if i==0:
                break
            res+=dic_[i][1].pop(-1)
    if flag:
        dic_[-1][1].pop(-1)
    m-=1

Fixed submission:
import heapq
from collections import deque

N, M=map(int, input().split())
AB=[list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:(x[0], x[1]))
for i in range(N):
  AB[i][1]=-AB[i][1]
d=deque(AB)
ans=0
h=[]
for i in range(M+1):
  if not d and not h:
    break
  while d and d[0][0]<=i:
    heapq.heappush(h, d.popleft()[1])
  if h:
    ans-=heapq.heappop(h)
print(ans)

Buggy python submission (verdict: Runtime Error):
from itertools import bisect
n, m = map(int, input().split())
work = [map(int, input().split()) for i in range(n)]
dic = {}
for w in work:
  a, b = w[0], w[1]
  if a not in dic.keys():
    dic[a]=[b]
  else:
    index=bisect.bisect_right(dic[a], b)
    dic[a].insert(index, b)
res = 0
while m > 0:
  index=bisect.bisect_left(dic.keys(), m)
  res+=dic[index].pos(len(dic[index])-1)
print(res)

Fixed submission:
import heapq
from collections import deque

N, M=map(int, input().split())
AB=[list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:(x[0], x[1]))
for i in range(N):
  AB[i][1]=-AB[i][1]
d=deque(AB)
ans=0
h=[]
for i in range(M+1):
  if not d and not h:
    break
  while d and d[0][0]<=i:
    heapq.heappush(h, d.popleft()[1])
  if h:
    ans-=heapq.heappop(h)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
MOD=10**9+7

S=input()
N=len(S)
dp=[[0 for _ in range(13)] for _ in range(N)]
if S[0]=="?":
    for k in range(10):
        dp[0][k]=1
else:
    dp[0][int(S[0])]=1
for i in range(N-1):
    c=S[i+1]
    nums=[]
    if c=="?":
        nums=[i for i in range(10)]
    else:
        nums=[int(c)]
    for num in nums:
        for j in range(13):
            dp[i+1][(10*j+num)%13]+=dp[i][j]
print(dp[-1][5]%MOD)


Fixed submission:
S=input()
dp=[[0 for _ in range(13)] for _ in range(len(S))]
MOD=10**9+7
if S[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(S[0])]+=1
for i in range(1, len(S)):
  cur_nums=[i for i in range(10)] if S[i]=='?' else [int(S[i])]
  for cur in cur_nums:
    for rem in range(13):
      dp[i][(10*rem+cur)%13]=(dp[i][(10*rem+cur)%13]+dp[i-1][rem])%MOD
print(dp[-1][5])

Buggy python submission (verdict: Time Limit Exceeded):
MOD=10**9+7

S=input()
N=len(S)
dp=[[0 for _ in range(13)] for _ in range(N)]
if S[0]=="?":
    for k in range(10):
        dp[0][k]=1
else:
    dp[0][int(S[0])]=1
for i in range(N-1):
    c=S[i+1]
    if c=="?":
        for j in range(13):
            for k in range(10):
                dp[i+1][(j*10+k)%13]+=dp[i][j]
    else:
        for j in range(13):
            dp[i+1][(j*10+int(c))%13]+=dp[i][j]
print(dp[-1][5]%MOD)


Fixed submission:
S=input()
dp=[[0 for _ in range(13)] for _ in range(len(S))]
MOD=10**9+7
if S[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(S[0])]+=1
for i in range(1, len(S)):
  cur_nums=[i for i in range(10)] if S[i]=='?' else [int(S[i])]
  for cur in cur_nums:
    for rem in range(13):
      dp[i][(10*rem+cur)%13]=(dp[i][(10*rem+cur)%13]+dp[i-1][rem])%MOD
print(dp[-1][5])

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
dp=[[0 for _ in range(13)] for _ in range(len(S))]
MOD=10**9+7
if S[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(S[0])]+=1
for i in range(1, len(S)):
  cur_nums=[i for i in range(10)] if S[i]=='?' else [int(S[i])]
  for cur in cur_nums:
    for rem in range(13):
      dp[i][(10*rem+cur)%13]=(dp[i][(10*rem+cur)%13]+dp[i-1][rem])%MOD
print(dp[-1][5])

Fixed submission:
S=input()
dp=[[0 for _ in range(13)] for _ in range(len(S))]
MOD=10**9+7
if S[0]=='?':
  for i in range(10):
    dp[0][i]=1
else:
  dp[0][int(S[0])]+=1
for i in range(1, len(S)):
  cur_nums=[i for i in range(10)] if S[i]=='?' else [int(S[i])]
  for cur in cur_nums:
    for rem in range(13):
      dp[i][(10*rem+cur)%13]=(dp[i][(10*rem+cur)%13]+dp[i-1][rem])%MOD
print(dp[-1][5])
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int, input().split())).insert(0, 0)
B=[0]*(n+1)
for i in range(n, 0, -1):
  if sum([B[j] for j in range(i, n+1, i)])&1!=A[i]:
    B[i]+=1
res=[]
for i in range(n):
  if B[i]==1:
    res.append(i)
print(len(res))
if res:
  print(" ".join([str(e) for e in res]))
    

Fixed submission:
n=int(input())
A=[0]+list(map(int, input().split()))
B=[0]*(n+1)
B[n//2+1:]=A[n//2+1:]
for i in range(n//2, 0, -1):
  B[i]=(sum([B[j] for j in range(2*i, n+1, i)])+A[i])&1
res=[]
for i in range(n+1):
  if B[i]==1:
    res.append(i)
print(len(res))
if res:
  print(*res)
Buggy python submission (verdict: Runtime Error):
import math
N, D=map(int, input())
Xs=[list(map(int, input().split())) for _ in range(N)]
cnt=0
for i in range(N):
  for j in range(i+1, N):
    dis=0
    for k in range(D):
      dis+=(X[i][k]-X[j][k])**2
    dis=math.sqrt(dis)
    if dis==int(dis):
      cnt+=1
print(cnt)

Fixed submission:
import math
N, D=map(int, input().split())
X=[list(map(int, input().split())) for _ in range(N)]
cnt=0
for i in range(N):
  for j in range(i+1, N):
    dis=0
    for k in range(D):
      dis+=(X[i][k]-X[j][k])**2
    dis=math.sqrt(dis)
    if dis==int(dis):
      cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
B=[0]*N
for i in range(N):
  flg=True
  for j in range(i, i+N):
    B[i]+=A[j%N] if flg else (-1)*A[j%N]
    flg=not flg
print(" ".join(str(b) for b in B))

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
B=[0]*N
for i in range(N):
  B[0]+=A[i] if i&1==0 else (-1)*A[i]
for i in range(1, N):
  B[i]=2*A[i-1]-B[i-1]
print(" ".join(str(b) for b in B))
Buggy python submission (verdict: Runtime Error):
N, M=map(int, input().split())
A=[int(input()) for _ in range(M)]
mod=10**9+7
step=[0]*(N+1)
step[1]=0 if 1 in A else 0
step[2]=0 if 2 in A else 1 if 1 in A else 0
for i in range(3, N+1):
  if i in A:
    continue
  step[i]=(step[i-1]+step[i-2])%mod
print(step[-1])

Fixed submission:
N, M=map(int, input().split())
A=[int(input()) for _ in range(M)]
mod=10**9+7
step=[1]*(N+1)
for a in A:
  step[a]=0
for i in range(2, N+1):
  step[i]=(step[i-1]+step[i-2])%mod*step[i]
print(step[-1])
Buggy python submission (verdict: Time Limit Exceeded):
H, W=map(int, input().split())
S=[]
S.append("".join(["#" for _ in range(W+2)]))
S.extend(["#"+input()+"#" for _ in range(H)])
S.append("".join(["#" for _ in range(W+2)]))
co1=[[0 for _ in range(W+2)] for _ in range(H+2)]
co2=[[0 for _ in range(W+2)] for _ in range(H+2)]

for i in range(1, H+2):
    ppos=0
    for j in range(W+2):
        if S[i][j]=="#":
            if S[i][j-1]==".":
                for k in range(ppos, j):
                    co1[i][k]=j-ppos
            ppos=j+1

for j in range(1, W+2):
    ppos=0
    for i in range(H+2):
        if S[i][j]=="#":
            if S[i-1][j]==".":
                for k in range(ppos, i):
                    co2[k][j]=i-ppos
            ppos=i+1

ans=0
for i in range(1, H+2):
    for j in range(1, W+2):
        ans=max(ans, co1[i][j]+co2[i][j]-1)
print(ans)


Fixed submission:
H, W=map(int, input().split())
frame=["".join(["#" for _ in range(W+2)])]
S=frame+["#"+input()+"#" for _ in range(H)]+frame
score=[[0 for _ in range(W+2)] for _ in range(H+2)]
for i in range(H+2):
  sharp_j=0
  for j in range(W+2):
    if S[i][j]=="#":
      for k in range(sharp_j+1, j):
        score[i][k]+=j-sharp_j-1
      sharp_j=j
for j in range(W+2):
  sharp_i=0
  for i in range(H+2):
    if S[i][j]=="#":
      for k in range(sharp_i+1, i):
        score[k][j]+=i-sharp_i-2
      sharp_i=i
ans=0
for i in range(H+2):
  for j in range(W+2):
    ans=max(ans, score[i][j])
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
import heapq

N, K=map(int, input().split())
V=list(map(int, input().split()))
lim=min(N, K)
ans=0
for num in range(lim+1):
    for A in range(num+1):
        B=num-A
        d=deque(V)
        hands=[]
        while d and len(h)<A:
            hands.append(d.popleft())
        while d and len(h)<A+B:
            hands.append(d.pop())
        heapq.heapify(hands)
        cnt=K-num
        while len(hands) and hands[0]<0 and cnt>0:
            cnt-=1
            heapq.heappop(hands)
        ans=max(ans, sum(hands))
print(ans)

Fixed submission:
import heapq
from collections import deque

N, K=map(int, input().split())
V=list(map(int, input().split()))
limitAB=min(N, K)
ans=0
for num in range(limitAB+1):
  for A in range(num+1):
    B=num-A
    d=deque(V)
    h=[]
    while d and len(h)<A:
      heapq.heappush(h, d.popleft())
    while d and len(h)<A+B:
      heapq.heappush(h, d.pop())
    cnt=0
    while h and h[0]<0 and cnt<K-(A+B):
      heapq.heappop(h)
      cnt+=1
    ans=max(ans, sum(h))
print(ans)

Buggy python submission (verdict: Runtime Error):
N, K=map(int, input().split())
D=list(map(int, input().split()))
limit=min(N, K)
ans=0
for A in range(limit+1):
  for B in range(limit-A+1):
    jewels=D[:A]+D[-B:] if B>0 else D[:A]
    jewels.sort()
    for k in range(min(len(jewels)-1, K-(A+B))):
      if jewels[k]>=0:
        break
      jewels.pop(0)
    ans=max(ans, sum(jewels))
print(ans)

Fixed submission:
import heapq
from collections import deque

N, K=map(int, input().split())
V=list(map(int, input().split()))
limitAB=min(N, K)
ans=0
for num in range(limitAB+1):
  for A in range(num+1):
    B=num-A
    d=deque(V)
    h=[]
    while d and len(h)<A:
      heapq.heappush(h, d.popleft())
    while d and len(h)<A+B:
      heapq.heappush(h, d.pop())
    cnt=0
    while h and h[0]<0 and cnt<K-(A+B):
      heapq.heappop(h)
      cnt+=1
    ans=max(ans, sum(h))
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B=map(int, input().split())
ans=B//2
if B=>13:
  ans=B
elif B<=5:
  ans=0
print(ans)

Fixed submission:
A, B=map(int, input().split())
if A<=5:
  print(0)
elif 6<=A<=12:
  print(B//2)
else:
  print(B)
Buggy python submission (verdict: Time Limit Exceeded):
N, M=map(int, input().split())
lst=[list(map(int, input().split())) for _ in range(M)]
ans=set(i for i in range(N))
for L, R in lst:
  L, R=L-1, R-1
  ans-=set(i for i in range(L))
  ans-=set(i for i in range(R+1, N))
print(len(ans))

Fixed submission:
N, M=map(int, input().split())
lst=[list(map(int, input().split())) for _ in range(M)]
maxL, minR=-1, N
for L, R in lst:
  L, R=L-1, R-1
  maxL=max(maxL, L)
  minR=min(minR, R)
if minR>=maxL:
  print(minR-maxL+1)
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N, M=map(int, input().split())
lst=[list(map(int, input().split())) for _ in range(M)]
ok=[1 for _ in range(N)]
for L, R in lst:
  L, R=L-1, R-1
  for i in range(L):
    ok[i]=0
  for i in range(R+1, N):
    ok[i]=0
print(sum(ok))

Fixed submission:
N, M=map(int, input().split())
lst=[list(map(int, input().split())) for _ in range(M)]
maxL, minR=-1, N
for L, R in lst:
  L, R=L-1, R-1
  maxL=max(maxL, L)
  minR=min(minR, R)
if minR>=maxL:
  print(minR-maxL+1)
else:
  print(0)