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

Fixed submission:
T = [int(input()) for _ in range(5)]

ans = 1000
for i in range(5):
    tmp = 0
    for j in range(5):
        if i==j:
            tmp += T[j]
        else:
            tmp += T[j] + (-T[j])%10
    ans = min(tmp,ans)
print(ans)

Buggy submission (verdict: Runtime Error):
T = [int(input()) for _ in range(5)]

ans = 643

for i0 in range(5):
  tmp = i0
  tmp += (10-tmp)//10
  l = range(5)
  l.remove(i0)
  for i1 in l:
    tmp += i1
    tmp += (10-tmp)//10
    l.remove(i1)
    for i2 in l:
      tmp += i2
      tmp += (10-tmp)//10
      l.remove(i2)
      for i3 in l:
        tmp += i3
        tmp += (10-tmp)//10
        l.remove(i3)
        for i4 in l:
          tmp += i4
          ans = min(ans,tmp)
print(ans)
Problem p03090 (python)

Fixed submission:
N = int(input())
 
erace1 = 1
erace2 = (N//2)*2
ans = []
for i in range(1,N):   
    for j in range(i+1,N+1):
        if i!=erace1 or j!=erace2: 
            ans.append([i,j])
        else:
            erace1 += 1
            erace2 -= 1
            
print(len(ans))
for a,b in ans:
    print(a,b)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = []
for i in range(1,N):   
    for j in range(i+1,N+1):
        if i+j != (N//2)*2 + 1
            ans.append([i,j])
            
print(len(ans))
for a,b in ans:
    print(a,b)
Problem p03096 (python)

Fixed submission:
N = int(input())
C = [int(input()) for _ in range(N)]
C = [x for x,y in zip(C[:-1],C[1:]) if x!=y] + [C[-1]]

DP = [1]
dic = {}

for i in range(len(C)):   
    DP.append((DP[-1]+dic.get(C[i],0))%(10**9+7))    
    dic[C[i]] = DP[-1]
print(DP[-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
C = [int(input()) for _ in range(N)]
   
i=0 
dic = {}
while i+1<len(C):
    dic[C[i]] = -1
    if C[i]==C[i+1]:
        C.pop(i+1)
    else:
        i+=1

DP = [1]
for i in range(len(C)):  
    if dic[C[i]]==-1:   
        DP.append(DP[-1])
    else:
        DP.append((DP[-1]+DP[dic[C[i]]])%(10**9+7))
    dic[C[i]] = i+1            
print(DP[-1])
Problem p03126 (python)

Fixed submission:
N,M = map(int,input().split())
Likes = [N for _ in range(M)] 
for _ in range(N): 
    temp = [int(i) for i in input().split()]    
    for k in range(1,len(temp)):
        Likes[temp[k]-1] -= 1
print(Likes.count(0))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
Likes = [N for _ in range(M)] 
for _ in range(N): 
    temp = [int(i) for i in input().split()]    
    for k in range(1,len(temp)):
        Likes[temp[k-1]] -= 1
print(Likes.count(0))
Problem p03128 (python)

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

dp = [-1 for _ in range(10010)]
dp[0] = 0            

MatchNum = [0,2,5,5,4,5,6,3,7,6]

for i in range(1,10005):
    for x in A:          
        if i-MatchNum[x] >= 0:
            tmp = dp[i-MatchNum[x]]*10 + x
            dp[i] = max(tmp,dp[i])
print(dp[N])

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

dp = [-1 for _ in range(1010)]
dp[0] = 0            

MatchNum = [0,2,5,5,4,5,6,3,7,6]

for i in range(1,1005):
    for x in A:          
        if i-MatchNum[x] >= 0:
            tmp = dp[i-MatchNum[x]]*10 + x
            dp[i] = max(tmp,dp[i])
print(dp[N])
Problem p03141 (python)

Fixed submission:
N = int(input())
F = []
for i in range(N):
  a,b = map(int,input().split())
  F.append([a+b,a,b])
F.sort(key=lambda x:x[0],reverse=True)
ans = 0
for i in range(N):
  if i%2==0:
    ans += F[i][1]
  else:
    ans -= F[i][2]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
F = []
for i in range(N):
  a,b = map(int,input().split())
  F.append([a+b],a,b)
F.sort(key=lambda x:x[0],reverse=True)
ans = 0
for i in range(N):
  if i%2==0:
    ans += F[i][1]
  else:
    ans -= F[i][2]
print(ans)
Problem p03161 (python)

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

K=min(K,N-1)
dp = [10**10]*N
dp[0] = 0
for i in range(1,K):
  for j in range(0,i):
    dp[i] = min(dp[i],dp[j]+abs(H[i]-H[j]))
for i in range(K,N):
  for j in range(i-K,i):
    dp[i] = min(dp[i],dp[j]+abs(H[i]-H[j]))
print(dp[-1])

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

dp = [10**10]*N
dp[0] = 0
for i in range(1,K):
  for j in range(0,i):
    dp[i] = min(dp[i],dp[j]+abs(H[i]-H[j]))
for i in range(K,N):
  for j in range(i-K,i):
    dp[i] = min(dp[i],dp[j]+abs(H[i]-H[j]))
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N,K = int(input().split())
H = [int(i) for i in input().split()]

dp = [10**10]*N
dp[0] = 0
for i in range(1,K):
  for j in range(0,i):
    dp[i] = min(dp[i],dp[j]+abs(H[i]-H[j]))
for i in range(K,N):
  for j in range(i-K,i):
    dp[i] = min(dp[i],dp[j]+abs(H[i]-H[j]))
print(dp[-1])
Problem p03163 (python)

Fixed submission:
N,W = map(int,input().split())
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
  w,v = map(int,input().split())
  for j in range(W+1):
    dp[i+1][j] = max(dp[i+1][j],dp[i][j])
    if j+w<=W:
      dp[i+1][j+w] = max(dp[i][j]+v,dp[i+1][j+w])
print(max(dp[N]))

Buggy submission (verdict: Runtime Error):
N,W = map(int,input().split())
dp = [0]*(N+1)
for _ in range(N):
  w,v = map(int,input().split())
  for i in range(W,W-w-1,-1):
    dp[i] = max(dp[i-w]+w,dp[i])
print(max(dp))
Problem p03165 (python)

Fixed submission:
import sys
def main():
  S=list(sys.stdin.readline())[:-1]
  T=list(sys.stdin.readline())[:-1]
  lS=len(S)
  lT=len(T)
  dp=[[0]*(lS+1) for _ in range(lT+1)]
  for iT in range(lT):
    for iS in range(lS):
      if S[iS]==T[iT]:
        dp[iT+1][iS+1] = max(dp[iT+1][iS],dp[iT][iS+1],dp[iT][iS]+1)
      else:
        dp[iT+1][iS+1] = max(dp[iT+1][iS],dp[iT][iS+1])

  iS = lS
  iT = lT
  ans = ""
  while(iS>0 and iT>0):
    if dp[iT][iS]==dp[iT-1][iS-1]:
      iS -= 1
      iT -= 1
    elif dp[iT][iS]==dp[iT][iS-1]:
      iS -= 1
    elif dp[iT][iS]==dp[iT-1][iS]:
      iT -= 1
    else:
      ans = S[iS-1]+ans
      iS -= 1
      iT -= 1
  print(ans)

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
import sys
def main():
  S=list(sys.stdin.readline())[:-1]
  T=list(sys.stdin.readline())[:-1]
  lS=len(S)
  lT=len(T)
  dp=[[0]*lS for _ in range(lT)]
  for iT in range(lT):
    for iS in range(lS):
      if S[iS]==T[iT]:
        if iS-1>=0 and iT-1>=0:
          dp[iT][iS] = dp[iT-1][iS-1]+1
        else:
          dp[iT][iS] = 1
      else:
        if iS-1>=0 and (iT-1<0 or dp[iT][iS-1]>=dp[iT-1][iS]):
          dp[iT][iS] = dp[iT][iS-1]
        elif iT-1>=0 and (iS-1<0 or dp[iT-1][iS]>=dp[iT][iS-1]):
          dp[iT][iS] = dp[iT-1][iS]

  iS = lS-1
  iT = lT-1
  ans = ""
  while(iS>0 and iT>0):
    if dp[iT][iS]==dp[iT-1][iS-1]:
      iS -= 1
      iT -= 1
    elif dp[iT][iS]==dp[iT][iS-1]:
      iS -= 1
    else:
      ans = S[iS]+ans
      iS -= 1
      iT -= 1
  if dp[iT][iS]=1:
    if iS == 0:
      ans = S[0]+ans
    else:
      ans = T[0]+ans
  print(ans)

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
import sys
def main():
  S=list(input())
  T=list(input())
  lS=len(S)
  lT=len(T)
  ans=[[]*lS for _ in range(lT)]
  for iT in range(lT):
    for iS in range(lS):
      if S[iS]==T[iT]:
        if iS-1>=0 and iT-1>=0:
          ans[iT][iS]=ans[iT-1][iS-1]+S[iS]
        else:
          ans[iT][iS]=S[iS]
      else:
        if iS-1>=0 and (iT-1<0 or len(ans[iT][iS-1])>=len(ans[iT-1][iS])):
          ans[iT][iS]=ans[iT][iS-1]
        elif iT-1>=0 and (iS-1<0 or len(ans[iT-1][iS])>=len(ans[iT][iS-1])):
          ans[iT][iS]=ans[iT-1][iS]
  print(ans[lT-1][lS-1])

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
lS=len(s)
lT=len(t)
ans=[[""]*lS for _ in range(lT)]
for iT in range(lT):
  for iS in range(lS):
    if S[iS]==T[iT]:
      if iS-1>=0 and iT-1>=0:
        ans[iT][iS]=ans[iT-1][iS-1]+S[iS]
      else:
        ans[iT][iS]=S[iS]
    else:
      if iS-1>=0 and (iT-1<0 or len(ans[iT][iS-1])>=len(ans[iT-1][iS])):
        ans[iT][iS]=ans[iT][iS-1]
      elif iT-1>=0 and (iS-1<0 or len(ans[iT-1][iS])>=len(ans[iT][iS-1])):
        ans[iT][iS]=ans[iT-1][iS]
print(ans[lT-1][lS-1])
Problem p03166 (python)

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

path = [[] for _ in range(N)]
pin = [0]*N
for _ in range(M):
  ip,op = map(int,input().split())
  pin[op-1]+=1
  path[ip-1].append(op-1)

cur = []
for i in range(N):
  if pin[i]==0:
    cur.append(i)

ans = 0
while cur:
  ans += 1
  nxt = []
  for ip in cur:
    for op in path[ip]:
      pin[op] -= 1
      if pin[op]==0 and not(op in nxt):
        nxt.append(op)
  cur = [x for x in nxt]
print(ans-1)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
dp=[0]*(N+1)
path = [[] for _ in range[N]]
for i in range(M):
  x,y = map(int,input().split())
  path[x].append(y)
  dp[y]=-1
  
cur = []
for i in range(1,N+1):
  if dp[i]==0:
    cur.append(i)

while(cur):
  nxt = set()
  for x in cur:
    for y in path[x]:
      dp[y] = max(dp[y],dp[x]+1)
      nxt.add(y)
  cur = []
  for x in nxt:
    cur.append(y)
print(max(dp))
Problem p03196 (python)

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    N,P = map(int,input().split())
    if N==1:
        print(P)
    elif N>50:
        print(1)
    else:
        ans = 1
        insuu = 2
        while insuu**N<=P:
            if P%(insuu**N)==0:
                ans *= insuu
                P //= insuu**N
            else:
                insuu += 1
        print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    N,P = map(int,input().split())
    if N==1:
        print(P)
    else:
        ans = 1
        insuu = 2
        while insuu**N<=P:
            if P%(insuu**N)==0:
                ans *= insuu
                P //= insuu**N
            else:
                insuu += 1
        print(ans)

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

Fixed submission:
D = int(input())
if(D==22):
    print('Christmas Eve Eve Eve')
elif(D==23):
    print('Christmas Eve Eve')
elif(D==24):
    print('Christmas Eve')
else:
    print('Christmas')

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

PforL = [1]
HforL = [1]
for i in range(1,51):
    PforL.append(PforL[i-1]*2+1)
    HforL.append(HforL[i-1]*2+3)

def recursive(n,x):
    if x<=n:
        return 0
    if x<=HforL[n-1]+1:
        return recursive(n-1,x-1)
    else:
        return PforL[n-1]+1+recursive(n-1,x-HforL[n-1]-2)

print(recursive(N,X))
Problem p03214 (python)

Fixed submission:
N = int(input())
A = [int(a) for a in input().split()]

tmp = 100

ave = sum(A)/N

for i in range(N):
    if abs(A[i]-ave) < tmp:
        tmp = abs(A[i]-ave)
        ans = i
print(ans)

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

A_sum = [0]
[A_sum.append(A_sum[-1]+int(a)) for a in input().split()]

score = []
for r in range(1,N+1):
    for l in range(0,r):
        score.append(A_sum[r]-A_sum[l])

ans = 0
for i in range(40,-1,-1):
    count = 0
    score_a = []
    for j in score:
        if (j & (1<<i)):
            count += 1
            score_a.append(j)
    if count >= K:
        ans += (1<<i)
        score = [i for i in score_a]

print(ans)
Problem p03223 (python)

Fixed submission:
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

A.sort()

B = []
for i in range(N):
    if i==0 or i==N-1:
        B.append((-1)**i)
    else:
        B.append(((-1)**i)*2)
B.sort()

print(max(abs(sum([A[i]*B[i] for i in range(N)])),abs(sum([A[i]*B[N-1-i] for i in range(N)]))))

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

B = []
for i in range(N):
    if i==0 or i==N-1:
        B.append((-1)**i)
    else:
        B.append(((-1)**i)*2)
B.sort()

print(max(abs(sum([A[i]*B[i] for i in range(N)])),abs(sum([A[i]*B[N-1-i] for i in range(N)]))))

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

B = []
for i in range(N):
    if i==0 or i==N-1:
        B.append((-1)**i)
    else:
        B.append(((-1)**i)*2)
B.sort()

print(max(abs(sum([A[i]*B[i] for i in range(N)])),abs(sum([A[i]*B[N-1-i] for i in range(N)]))))

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

A.sort()

B = []
for i in range(N):
    if i==0 or i==N-1:
        B[].append((-1)**i)
    else:
        B[i].append(((-1)**i)*2)
B.sort()

print(max(abs(sum([A[i]*B[i] for i in range(N)])),abs(sum([A[i]*B[N-1-i] for i in range(N)]))))
Problem p03224 (python)

Fixed submission:
N = int(input())
t = [2,1]
h = [[1],[1]]
while t[1]<=N:
    if t[1]==N:
        print("Yes")
        print(t[0])
        [print("{0} {1}".format(len(h[i])," ".join([str(j) for j in h[i]]))) for i in range(len(h))]
        break
    else:
        [h[i].append(t[1]+1+i) for i in range(len(h))]
        h.append([t[1]+1+i for i in range(len(h))])
        t[1]+=t[0]
        t[0]+=1
else:
    print("No")
    exit()

Buggy submission (verdict: Runtime Error):
N = int(input())
t = [2,1]
h = [[1],[1]]
while t[1]<=N:
    if t[1]==N:
        print("Yes")
        print(t[0])
        [print("{0} {1}".format(len(h[i])," ".join([str(j) for j in h[i]]))) for i in ra
nge(len(h))]
        break
    else:
        [h[i].append(t[1]+1+i) for i in range(len(h))]
        h.append([t[1]+1+i for i in range(len(h))])
        t[1]+=t[0]
        t[0]+=1
else:
    print("No")
    exit()
Problem p03241 (python)

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

m = M
f = {}
while m%2 == 0:
    f[2] = f.get(2,0) + 1
    m = m//2

k = 3
l = int(m**0.5)+1
while m != 1:
    if k > l:
        f[m] = f.get(m,0)+1
        break
    while m%k == 0:
        f[k] = f.get(k,0)+1
        m = m//k
    k += 2
C=[1]
for k in f:
    C_tmp = []
    for c in C:
        for i in range(f[k]):
            C_tmp.append(c*(k**(i+1)))
    C.extend(C_tmp)
ans_r = M
for c in C:
    if c>=N and c<ans_r:
        ans_r = c
print(M//ans_r)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
l = m//n
if M+1-N < l:
    for i in range(N,M+1):
        if M%i == 0:
            print(M//i)
            break
else:
    for i in range(l,-1,-1):
        if m % i == 0:
            print(i)
            break

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
def f(N,M+1):
    if M%i ==0:
        return(M//i)
print(f(N,M+1))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
for i in range(M+1):
    if M%(N+i) == 0:
        print(M//i)
        break
    elif M%(M//N-i)==0:
        print(M//N-i)
        break
Problem p03245 (python)

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

num_type = sum(XY[0])%2 
for xy in XY:
    if(sum(xy)%2 != num_type):
        print(-1)
        break
else:
    m = 40-num_type
    print(m)
    D = [2**i for i in range(38,-1,-1)]
    if not(num_type):
        D.append(1)

    print(' '.join(map(str,D)))
    for xy in XY:
        p = xy
        w = ""
        for i in range(m):
            if 0<=p[0]-p[1] and 0<=p[0]+p[1]:
                w += "R"
                p[0] -= D[i]
            elif 0>p[0]-p[1] and 0<=p[0]+p[1]:
                w += "U"
                p[1] -= D[i]
            elif 0<=p[0]-p[1] and 0>p[0]+p[1]:
                w += "D"
                p[1] += D[i]
            else:
                w += "L"
                p[0] += D[i]
        print(w)

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

num_type = sum(XY[0])%2
for xy in XY:
    if(sum(xy)%2 != num_type):
        print(-1)
        break
else:
    print(20-num_type)
    print(' '.join(map(str,[1]*(20-num_type))))
    for xy in XY:
        ans = ""
        num = 0
        if xy[0] > 0:
            num += xy[0]
            ans += "R"*xy[0]
        elif xy[0] < 0:
            num += -xy[0]
            ans += "L"*(-xy[0])
        if xy[1] > 0:
            num += xy[1]
            ans += "U"*xy[1]
        elif xy[1] < 0:
            num += -xy[1]
            ans += "D"*(-xy[1])
        while(num<(20-num_type)):
            num += 1
            if num%2:
                ans += "R"
            else:
                ans += "L"
        print(ans)
Problem p03261 (python)

Fixed submission:
N = int(input())
W = []
W.append(input())
for _ in range(N-1):
    new_W = input()
    if new_W in W:
        print("No")
        break
    if new_W[0] != W[-1][-1]:
        print("No")
        break
    W.append(new_W)
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())
W = []
W.append(input())
for _ in range(N-1):
    W.append(input())
    if W[-1] in W[:-2]
        print("No")
        break
    if W[-1][0] != W[-2][-1]:
        print("No")
        break
else:
    print("Yes")
Problem p03262 (python)

Fixed submission:
def gcd(a,b):
    while b:
        a, b = b, a % b
    return a
N,X = map(int,input().split())
x = [int(i) for i in input().split()]
ans = abs(X-x[0])
now = X
for i in x:
    if abs(now - i) % ans:
        ans = gcd(ans, abs(now-i))
    now = i

print(ans)

Buggy submission (verdict: Runtime Error):
import fraction

N,X = map(int,input().split())
x = [int(i) for i in input().split()]
ans = abs(X-x[0])
now = X
for i in x:
    if abs(now - i) % ans:
        ans = fraction.gcd(ans, abs(now-i))
    now = i

print(ans)
Problem p03287 (python)

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

B = {}
B[0] = 1
tmp = 0
ans = 0

for a in A:
        tmp = (tmp+a)%M
        ans += B.get(tmp,0)
        B[tmp] = B.get(tmp,0)+1

print(ans)

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

B = [0]*M
B[0] = 1
tmp = 0
ans = 0



for a in A:
        tmp = (tmp+a)%M
        ans += B[tmp]
        B[tmp] += 1

print(ans)

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

B = [0]*M
B[0] = 1
tmp = 0
ans = 0



for a in A:
        tmp = (tmp+a)%M
        ans += B[tmp]
        B[tmp] += 1

print(ans)
Problem p03290 (python)

Fixed submission:
import math
D,G = map(int,input().split())
p=[]
c=[]
for i in range(D):
    p_tmp,c_tmp = map(int,input().split())
    p.append(p_tmp)
    c.append(c_tmp)

ans = sum(p)
for i in range(2**D):
    score_tmp = 0
    ans_tmp = 0
    for j in range(D):
        if (i>>j)%2 == 1:
            score_tmp += p[j]*(j+1)*100+c[j]
            ans_tmp += p[j]

    if ans_tmp >= ans:
        continue
    elif score_tmp >= G:
        ans = ans_tmp
        continue
    else:
        for j in range(D):
            if (i>>(D-1-j))%2 == 1:
                continue
            elif score_tmp + p[D-1-j]*(D-j)*100 < G:
                break
            else:
                ans_tmp += math.ceil((G - score_tmp)/((D-j)*100))
                ans = min(ans,ans_tmp)
                break

print(ans)

Buggy submission (verdict: Runtime Error):
import math

D,G = map(int,input().split())
PC = [0] + [[int(i) for i in input().split()] for _ in range(D)]

ans = 1e9
for i in range(2**D - 1):
    inSolve = -1
    score_tmp = 0
    solved = 0
    for j in range(D):
        if (i>>j)%2 == 1:
            score_tmp += (j+1)*100*PC[j][0]+PC[j][1]
            solved += PC[j][0]
        else:
            inSolve = max(j,inSolve)
    if score_tmp < G and inSolve != -1:
        if math.ceil((G-score_tmp)/((inSolve+1)*100)) <= PC[inSolve][0]:
            ans = min(ans,solved + math.ceil((G-score_tmp)/((inSolve+1)*100)))
    elif score_tmp >= G:
        ans = min(ans,solved)
print(ans)
Problem p03292 (python)

Fixed submission:
A = list(map(int,input().split()))
B = [abs(A[0]-A[1]),abs(A[0]-A[2]),abs(A[1]-A[2])]
B.sort()
print(B[0]+B[1])

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
requests = []
for _ in range(M):
        a,b = map(int,input().split())
        requests.append([a,b])

ans = 1
requests = sorted(requests, key=lambda x:(x[1],x[0]))
b = min(requests, key=lambda x:x[1])[1]
for i in range(M):
        if requests[i][0] < b:
                continue
        else:
                ans += 1
                b = min(requests[i:], key=lambda x:x[1])[1]

print(ans)
Problem p03305 (python)

Fixed submission:
import heapq
import sys
from itertools import accumulate

n,m,s,t = map(int,next(sys.stdin).split(" "))
inf = 1000000000000000
gyen = [dict() for _ in range(n)]
gsnuk = [dict() for _ in range(n)]

for _ in range(m):
        u,v,a,b = map(int,next(sys.stdin).split(" "))
        gyen[u-1][v-1] = gyen[v-1][u-1] = a
        gsnuk[u-1][v-1] = gsnuk[v-1][u-1] = b

def dijkstra(graph, start):
        dist = [inf for _ in range(n)]
        dist[start] = 0
        q = [(0,start)]
        while q:
                du, u = heapq.heappop(q)
                if dist[u] < du:
                        continue
                for v,d in graph[u].items():
                        if dist[v] > du+d:
                                dist[v] = du+d
                                heapq.heappush(q, (dist[v], v))
        return dist

yen = dijkstra(gyen,s-1)
snuke = dijkstra(gsnuk,t-1)

ans = list(accumulate([y+s for y,s in zip(yen,snuke)][::-1],min))
[print(inf-ans[i]) for i in range(n-1,-1,-1)]

Buggy submission (verdict: Runtime Error):
import heapq
import sys
from itertools import accumulate
import operator as op

n,m,s,t = map(int,next(sys.stdin).split(" "))
inf = 1000000000000000
gyen = [dict() for _ in range(n)]
gsnuk = [dict() for _ in range(n)]

for line in sys.stdin.readlines():
        u,v,a,b = map(int,line.strip().split(" "))
        gyen[u-1][v-1] = gyen[v-1][u-1] = a
        gsnuk[u-1][v-1] = gsnuk[v-1][u-1] = b

def dijkstra(graph, start):
        dist = [inf for _ in range(n)]
        dist[start] = 0
        q = [(0,start)]
        while q and rem>0:
                du, u = heapq.heappop(q)
                if dist[u] < du:
                        continue
                for i in graph[u]:
                        if dist[i[0]] > du+i[1]:
                                dist[i[0]] = du+i[1]
                                heapq.heappush(q, (dist[i[0]], i[0]))
        return dist

yen = dijkstra(gyen,s-1)
snuke = dijkstra(gsnuk,t-1)

ans = list(accumulate([y+s for y,s in zip(yen,snuke)][::-1],min))
[print(inf-ans[i]) for i in range(n-1,-1,-1)]