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

Fixed submission:
a=list(map(int,input().split()))
a=sorted(a)

dist1=a[2]-a[0]
dist2=a[2]-a[1]

if (dist1%2)==0 and (dist2%2)==0:
  ans=(dist1+dist2)//2
  print(ans)
  
elif (dist1%2)==1 and (dist2%2)==1:
  ans=(dist1+dist2)//2
  print(ans)
  
elif (dist1%2)==0 and (dist2%2)==1:
  ans=(dist1//2)+(dist2+1)//2
  print(ans+1)
  
else:
  ans=(dist2//2)+(dist1+1)//2
  print(ans+1)

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

dist1=a[2]-a[0]
dist2=a[2]-a[1]

if (dist1%2)==0 and (dist2%2)==0:
  ans=(dist1+dist2)//2
  print(ans)
  
elif (dist1%2)==1 and (dist2%2)==1:
  ans=(dist1+dist2)//2
  print(ans)
  
elif (dist1%2)==2 and (dist2%2)==1:
  ans(dist1//2)+(dist2+1)//2
  print(ans)
  
else:
  ans(dist2//2)+(dist1+1)//2
  print(ans)
Problem p03399 (python)

Fixed submission:
a,b,c,d=(int(input()) for i in range(4))
print(min(a,b)+min(c,d))

Buggy submission (verdict: Runtime Error):
a,b,c,d=input() for i in range(4)
print(max(a,b)+max(c,d))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
print(max(a,b)+max(c,d))
Problem p03407 (python)

Fixed submission:
a,b,c=map(int,input().split())
print('Yes' if a+b >= c else 'No')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input.split())
print('Yes' if a+b >= c else 'No')
Problem p03415 (python)

Fixed submission:
a,b,c=(input() for _ in range(3))
print(a[0]+b[1]+c[2])

Buggy submission (verdict: Runtime Error):
a,b,c=(input() for _ in range(2))
print(a[0]+b[1]+c[2])

Buggy submission (verdict: Runtime Error):
a,b,c=(input() for _ in range(2))
print('a[0]+b[1]+c[2]')
Problem p03423 (python)

Fixed submission:
n=int(input())
print(n//3)

Buggy submission (verdict: Runtime Error):
n=input()
print(n//3)
Problem p03447 (python)

Fixed submission:
x,a,b=(int(input()) for _ in range(3))
print((x - a)%b)

Buggy submission (verdict: Runtime Error):
x,a,b=int((input() for _ in range(3)))
print((x - a)%b)

Buggy submission (verdict: Runtime Error):
x,a,b=(int,input() for _ in range(3))
print((x - a)%b)

Buggy submission (verdict: Runtime Error):
x,a,b=(input() for _ in range(3))
print((x - a)%b)
Problem p03473 (python)

Fixed submission:
s=int(input());print(48-s)

Buggy submission (verdict: Runtime Error):
print(48-int(input())
Problem p03475 (python)

Fixed submission:
n=int(input())
yo=[]
for _ in range(n-1):
  a=list(map(int,input().split()))
  yo.append(a)
  
def ans(x):
  if x==n-1:
    return 0
  else:
    t=0
    for i in range(x,n-1):
      if t<=yo[i][1]:
        t=yo[i][1]+yo[i][0]
      else:
        s=t-yo[i][1]
        if s%yo[i][2]==0:
          t=t+yo[i][0]
        else:
          mo=s%yo[i][2]
          t=t+yo[i][2]-mo+yo[i][0]
    return t
    
for j in range(n):
  print(ans(j))

Buggy submission (verdict: Runtime Error):
int(input())
yo=[]
for _ in range(n-1):
  a=list(map(int,input().split()))
  yo.append(a)
  
def ans(x):
  if x==n-1:
    return 0
  else:
    t=0
    for i in range(x,n-1):
      if t<=yo[i][1]:
        t=yo[i][1]+yo[i][0]
      else:
        s=t-yo[i][1]
        if s%yo[i][2]==0:
          t=t+yo[i][0]
        else:
          mo=s%yo[i][2]
          t=t+yo[i][2]-mo+yo[i][0]
    return t
    
for j in range(n):
  print(ans(j))
Problem p03493 (python)

Fixed submission:
s=input()
print(s.count('1'))

Buggy submission (verdict: Runtime Error):
s=input()
print(s.count('1')
Problem p03545 (python)

Fixed submission:
s=input()
ans=[]

for i in range(2**3):
  a=int(s[0])
  for j in range(3):
    if ((i>>j)&1):
      a+=int(s[j+1])
    else:
      a-=int(s[j+1])
      
  if a==7:
    ans.append(i)
    
u=ans[0]
ans1=[]
for j in range(3):
  if ((u>>j)&1):
      ans1.append('+')
  else:
      ans1.append('-')
      
print(s[0]+ans1[0]+s[1]+ans1[1]+s[2]+ans1[2]+s[3]+'=7')

Buggy submission (verdict: Runtime Error):
s=input()
ans=[]

for i in range(2**3):
  a=int(s[0])
  for j in range(3):
    if ((i>>j)&1):
      a+=int(s[j+1])
    elif ((i>>j)&0):
      a-=int(s[j+1])
      
  if a==7:
    ans.append(i)
    
u=ans[0]
ans1=[]
for j in range(3):
  if ((i>>j)&1):
      ans1.append('+')
  elif ((i>>j)&0):
      ans1.append('-')
      
print(s[0]+ans1[0]+s[1]+ans1[1]+s[2]+ans1[2]+s[3]+'=7')

Buggy submission (verdict: Runtime Error):
s=input()
ans=[]

for i in range(2**3):
  a=int(s[0])
  for j in range(3):
    if ((i>>j)&1):
      a+=int(s[j+1])
    elif ((i>>j)&0):
      a-=int(s[j+1])
      
  if a==7:
    ans.append(i)
    
u=ans[0]
ans1=[]
for j in range(3):
  if ((i>>j)&1):
      ans1.append('+')
  else:
      ans1.append('-')
      
print(s[0]+ans1[0]+s[1]+ans1[1]+s[2]+ans1[2]+s[3]+'=7')
Problem p03547 (python)

Fixed submission:
a,b=input().split()
print('<' if a<b else '>' if a>b else '=')

Buggy submission (verdict: Runtime Error):
a,b=map(input().split())
print('<' if a<b else '>' a>b else '=')
Problem p03555 (python)

Fixed submission:
a=input()
b=input()
print('YES' if a[0]==b[2] and a[1]==b[1] and a[2]==b[0] else 'NO')

Buggy submission (verdict: Runtime Error):
def bs_left(list, target):
    low = 0
    high = len(list)

    while low < high:
        mid = (low + high) // 2
        if target > list[mid]:
            low = mid + 1
        else:
            high = mid
    return low

def bs_right(list, target):
    low = 0
    high = len(list)
    while low < high:
        mid = (low + high) // 2
        if target < list[mid]:
            high = mid
        else:
            low = mid + 1
    return low

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

ans = 0
for b in B:
    ans += (bs_left(A, b) * (n - bs_right(C, b)))
print(ans)
Problem p03633 (python)

Fixed submission:
import math

n=int(input())
ans=int(input())

if n>1:
  
  for x in range(n-1):
    s=int(input())
    ans=ans*s//(math.gcd(ans,s))
    
  
print(ans)

Buggy submission (verdict: Runtime Error):
import math

n=int(input())
ans=int(input())

if n>1:
  
  for x in range(n-1):
    s=int(input())
    ans=int(ans*s/(math.gcd(ans,s)))
    
  
print(ans)
Problem p03635 (python)

Fixed submission:
n,m=map(int,input().split())
print((m-1)*(n-1))

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

x2=0
x4=0
x1=0
for x in a:
  if x%2==0:
    x2+=1
  if x%4==0:
    x4+=1
  if x%2==1:
    x1+=1
    
if x4+x1==n:
  if x4>=x1-1:
    print('Yes')
  else:
    print('No')
  
else:
  if x4>=x1:
    print('Yes')
  else:
    
    print('No')
Problem p03730 (python)

Fixed submission:
a,b,c=map(int,input().split())
ch=0
for x in range(b):
  if (x*a)%b==c:
    ch+=1
    
if ch>0:
  print('YES')
else:
  print('NO')

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

if c>a:
  print('YES')
else:
  print('NO')
Problem p03737 (python)

Fixed submission:
a,b,c=input().split()
print(a[0].upper()+b[0].upper()+c[0].upper())

Buggy submission (verdict: Runtime Error):
a,b,c=import().split()
print(a[0].upper()+b[0].upper()+c[0].upper())
Problem p02609 (python)

Fixed submission:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    X = input().rstrip('\n')

    M = X.count("1")
    flg = 0
    if M == 1:
        flg = 1
    x_major = 0
    x_minor = 0
    for i in range(N):
        add = int(X[i])
        x_major = (x_major * 2 + add)%(M+1)
        if flg == 0:
            x_minor = (x_minor * 2 + add)%(M-1)
    for i in range(N):
        if X[i] == "1":
            if flg:
                print(0)
                continue
            val = (x_minor - pow(2, N-i-1, M-1)) % (M-1)
        else:
            val = (x_major + pow(2, N-i-1, M+1)) % (M + 1)
        cnt = 1
        while val:
            val = val % bin(val).count("1")
            cnt += 1
        print(cnt)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    X = input().rstrip('\n')

    M = X.count("1")
    x_major = 0
    x_minor = 0
    for i in range(N):
        add = int(X[i])
        x_major = (x_major * 2 + add)%(M+1)
        x_minor = (x_minor * 2 + add)%(M-1)
    for i in range(N):
        if X[i] == "1":
            val = (x_minor - pow(2, N-i-1, M-1)) % (M-1)
        else:
            val = (x_major + pow(2, N-i-1, M+1)) % (M + 1)
        cnt = 1
        while val:
            val = val % bin(val).count("1")
            cnt += 1
        print(cnt)


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

Fixed submission:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

    D = int(input())
    C = list(map(int, input().split()))
    S = []
    for _ in range(D):
        S.append(list(map(int, input().split())))
    ans = 0
    last = [-1] * 26
    days = [[-1] for _ in range(26)]
    T = []
    for d in range(D):
        t = int(input()) - 1
        T.append(t)
        ans += S[d][t]
        last[t] = d
        days[t].append(d)
        for i in range(26):
            ans -= C[i] * (d - last[i])
    for t in range(26):
        days[t].append(D)

    M = int(input())
    for _ in range(M):
        d, q = map(int, input().split())
        d -= 1
        q -= 1
        t = T[d]
        ans += S[d][q]
        ans -= S[d][t]
        i = bisect_left(days[q], d)
        ans += C[q] * (d - days[q][i-1]) * (days[q][i] - d)
        j = bisect_left(days[t], d)
        ans -= C[t] * (d - days[t][j-1]) * (days[t][j+1] - d)
        #print(days[q], days[t])
        T[d] = q
        days[q].append(d)
        days[q].sort()
        days[t].remove(d)
        print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from bisect import bisect_left
    input = sys.stdin.readline

    D = int(input())
    C = list(map(int, input().split()))
    S = []
    for _ in range(D):
        S.append(list(map(int, input().split())))
    ans = 0
    last = [-1] * 26
    days = [[-1] for _ in range(26)]
    T = []
    for d in range(D):
        t = int(input()) - 1
        T.append(t)
        ans += S[d][t]
        last[t] = d
        days[t].append(d)
        for i in range(26):
            ans -= C[i] * (d - last[i])
    for t in range(26):
        days[t].append(D)

    M = int(input())
    for _ in range(M):
        d, q = map(int, input().split())
        d -= 1
        q -= 1
        t = T[d]
        ans += S[d][q]
        ans -= S[d][t]
        i = bisect_left(days[q], d)
        ans += C[q] * (d - days[q][i-1]) * (days[q][i] - d)
        j = bisect_left(days[t], d)
        ans -= C[t] * (d - days[t][i-1]) * (days[t][i+1] - d)
        #print(days[q], days[t])
        T[d] = q
        days[q].append(d)
        days[q].sort()
        days[t].remove(d)
        print(ans)


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

Fixed submission:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    if N == 2:
        if A[0] == A[1]:
            print(0)
        elif A[0] < A[1]:
            print(-1)
        else:
            if (A[0] - A[1]) %2 == 0:
                print((A[0] -  A[1])//2)
            else:
                print(-1)
        exit()

    g1 = A[0]
    g2 = A[1]
    g3 = 0
    for i in range(2, N):
        g3 ^= A[i]
    n1 = g1.bit_length()
    n2 = g2.bit_length()
    n3 = g3.bit_length()
    NN = max(n1, n2, n3)
    ans = 0
    cnt = 0
    while True:
        cnt += 1
        if cnt == 10000:
            print(-1)
            exit()
        for i in range(NN):
            if (g1 >> i & 1) ^ (g2 >> i & 1) != (g3 >> i & 1):
                r1 = g1 % (1 << i) + 1
                r2 = (1<<i) - g2 % (1 << i)
                if r1 < r2:
                    g1 -= r1
                    g2 += r1
                    ans += r1
                    break
                elif r1 > r2:
                    g1 -= r2
                    g2 += r2
                    ans += r2
                    break
                else:
                    print(-1)
                    exit()
            if g1 ^ g2 == g3:
                if ans != A[0]:
                    print(ans)
                else:
                    print(-1)
                exit()


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    if N == 2:
        assert False
        if A[0] == A[1]:
            print(0)
        elif A[0] < A[1]:
            print(-1)
        else:
            if (A[0] - A[1]) %2 == 0:
                print((A[0] -  A[1])//2)
            else:
                print(-1)
        exit()

    g1 = A[0]
    g2 = A[1]
    g3 = 0
    for i in range(2, N):
        g3 ^= A[i]
    n1 = g1.bit_length()
    n2 = g2.bit_length()
    n3 = g3.bit_length()
    NN = max(n1, n2, n3)
    ans = 0
    for i in range(NN-1, -1, -1):
        if g1 ^ g2 == g3:
            if ans != A[0]:
                print(ans)
            else:
                print(-1)
            exit()
        if (g1 >> i & 1) ^ (g2 >> i & 1) != (g3 >> i & 1):
            r1 = g1 % (1 << i) + 1
            r2 = (1<<i) - g2 % (1 << i)
            if r1 < r2:
                g1 -= r1
                g2 += r1
                ans += r1
            else:
                g1 -= r2
                g2 += r2
                ans += r2
    print(-1)


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

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline

    def check(S, T):
        assert len(S) == len(T)
        for s, t in zip(S, T):
            if s == t or s == '?' or t == '?':
                continue
            return 0
        return 1

    A = input().rstrip('\n')
    B = input().rstrip('\n')
    C = input().rstrip('\n')
    la = len(A)
    lb = len(B)
    lc = len(C)
    AB = [1] * 10010
    BC = [1] * 10010
    AC = [1] * 10010
    for i in range(-lb, la+1):
        AB[i] = check(A[max(0, i):min(la, i+lb)], B[max(0, -i):min(lb, la-i)])
    for i in range(-lc, lb+1):
        BC[i] = check(B[max(0, i):min(lb, i+lc)], C[max(0, -i):min(lc, lb-i)])
    for i in range(-lc, la+1):
        AC[i] = check(A[max(0, i):min(la, i+lc)], C[max(0, -i):min(lc, la-i)])

    ans = la+lb+lc
    for i in range(-lb-lc-3, la+lc+3):
        if not AB[i]:
            continue
        for j in range(-lb-lc-3, la+lb+3):
            if BC[j-i] and AC[j]:
                l = min(0, i, j)
                r = max(la, lb+i, lc+j)
                #print(i, j, l, r, r-l)
                ans = min(ans, r-l)
    print(ans)


if __name__ == '__main__':
    main()

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

    def check(S, T):
        assert len(S) == len(T)
        for s, t in zip(S, T):
            if s == t or s == '?' or t == '?':
                continue
            return 0
        return 1

    A = input().rstrip('\n')
    B = input().rstrip('\n')
    C = input().rstrip('\n')
    la = len(A)
    lb = len(B)
    lc = len(C)
    AB = [1] * 6000
    BC = [1] * 6000
    AC = [1] * 6000
    for i in range(-lb, la+1):
        lab = min(la, lb)
        AB[i] = check(A[max(0, i):min(lab, i+lb)], B[max(0, -i):min(lab, lb-i)])
    for i in range(-lc, lb+1):
        lbc = min(lb, lc)
        BC[i] = check(B[max(0, i):min(lbc, i+lc)], C[max(0, -i):min(lbc, lc-i)])
    for i in range(-lc, la+1):
        lca = min(la, lc)
        AC[i] = check(A[max(0, i):min(lca, i+lc)], C[max(0, -i):min(lca, lc-i)])

    ans = la+lb+lc
    for i in range(-lb-lc, la+lc+1):
        if not AB[i]:
            continue
        for j in range(-lc, lb+1):
            if BC[j] and AC[i+j]:
                l = min(0, i, i+j)
                r = max(la, lb+i, lc+i+j)
                #print(i, j, l, r, r-l)
                ans = min(ans, r-l)
    print(ans)


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

Fixed submission:
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    N, x, d = map(int, input().split())

    if d == 0:
        if x:
            print(N+1)
        else:
            print(1)
        exit()

    if d < 0:
        x = x + d * (N-1)
        d *= -1
    dic = defaultdict(list)

    for i in range(N+1):
        mod = (x * i) % d
        st = (i * (i+1)) // 2
        ed = (i * (N + N-i+1)) // 2
        st = st * d + (x-d) * i
        ed = ed * d + (x-d) * i
        dic[mod].append((st, ed))
    ans = 0
    for mod in dic:
        L = dic[mod]
        L.sort(key=lambda t: t[0])
        ed_prev = L[0][0] - 1
        for st, ed in L:
            if st > ed_prev:
                ans += (ed - st) // d + 1
                ed_prev = ed
            elif ed > ed_prev:
                ans += (ed - ed_prev) // d
                ed_prev = ed
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    N, x, d = map(int, input().split())
    
    assert d != 0
    if d == 0:
        if x:
            print(N+1)
        else:
            print(0)
        exit()

    if d < 0:
        x = x + d * (N-1)
        d *= -1
    dic = defaultdict(list)

    for i in range(N+1):
        mod = (x * i) % d
        st = (i * (i+1)) // 2
        ed = (i * (N + N-i+1)) // 2
        st = st * d + (x-d) * i
        ed = ed * d + (x-d) * i
        dic[mod].append((st, ed))
    ans = 0
    for mod in dic:
        L = dic[mod]
        L.sort(key=lambda t: t[0])
        ed_prev = L[0][0] - 1
        for st, ed in L:
            if st > ed_prev:
                ans += (ed - st) // d + 1
                ed_prev = ed
            elif ed > ed_prev:
                ans += (ed - ed_prev) // d
                ed_prev = ed
    print(ans)


if __name__ == '__main__':
    main()

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

M = (N * (N+1)) // 2 + 1
print(M) if X // D != 0 else 0
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())
mod = 2019

if R - L >= mod:
    print(0)
else:
    L = L % mod
    R = R % mod
    if L >= R:
        print(0)
    else:
        ans = float('inf')
        for i in range(L, R+1):
            for j in range(i+1, R+1):
                ans = min(ans, (i * j) % mod)
        print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())
mod = 2019

L = L % mod
R = R % mod
if L >= R:
    print(0)
else:
    ans = float('inf')
    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j)%mod)
print(ans)
Problem p02991 (python)

Fixed submission:
def main():
    import sys
    from collections import deque
    input = sys.stdin.buffer.readline

    N, M = map(int, input().split())
    adj = [[] for _ in range(N*3+5)]
    for _ in range(M):
        u, v = map(int, input().split())
        adj[u].append(v+N+1)
        adj[u+N+1].append(v+2*N+2)
        adj[u+2*N+2].append(v)

    s, t = map(int, input().split())
    que = deque()
    que.append(s)
    seen = [-1] * (N*3+5)
    seen[s] = 0
    while que:
        v = que.popleft()
        for u in adj[v]:
            if seen[u] == -1:
                seen[u] = seen[v] + 1
                que.append(u)

    if seen[t] == -1:
        print(-1)
    else:
        assert seen[t] % 3 == 0
        print(seen[t] // 3)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    from collections import deque
    input = sys.stdin.buffer.readline

    N, M = map(int, input().split())
    adj = [[] for _ in range(N*3+5)]
    for _ in range(M):
        u, v = map(int, input().split())
        adj[u].append(v+N+1)
        adj[u+N+1].append(v+2*N+2)
        adj[u+2*N+2].append(v)

    s, t = map(int, input().split())
    que = deque()
    que.append(s)
    seen = [-1] * (N*3+5)
    seen[1] = 0
    while que:
        v = que.popleft()
        for u in adj[v]:
            if seen[u] == -1:
                seen[u] = seen[v] + 1
                que.append(u)

    if seen[t] == -1:
        print(-1)
    else:
        assert seen[t] % 3 == 0
        print(seen[t] // 3)


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

Fixed submission:
from collections import Counter


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

vector = [0] * ((N * (N - 1)) // 2)
cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        x = ball[i][0] - ball[j][0]
        y = ball[i][1] - ball[j][1]
        if x < 0:
            x, y = -x, -y
        elif x == 0:
            if y < 0:
                y = -y
        vector[cnt] = x * (10 ** 10) + y
        cnt += 1
C = Counter(vector)
if N == 1:
    print(1)
else:
    print(N - C.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter


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

vector = [0] * ((N * (N - 1)) // 2)
cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        x = ball[i][0] - ball[j][0]
        y = ball[i][1] - ball[j][1]
        if x < 0:
            x, y = -x, -y
        elif x == 0:
            if y < 0:
                y = -y
        vector[cnt] = x * (10 ** 10) + y
        cnt += 1
C = Counter(vector)
print(N - C.most_common()[0][1])
Problem p03007 (python)

Fixed submission:
from collections import deque


N = int(input())
A = list(map(int, input().split()))
A.sort()
queue_plus = deque()
queue_minus = deque()
for A_i in A:
    if A_i < 0:
        queue_minus.append(A_i)
    else:
        queue_plus.append(A_i)

xy = [[] for _ in range(N-1)]
cnt = 0
if len(queue_plus) == 0:
    x = queue_minus.pop()
    y = queue_minus.pop()
    xy[cnt] = [x, y]
    cnt += 1
    queue_plus.append(x - y)
elif len(queue_minus) == 0:
    x = queue_plus.popleft()
    y = queue_plus.popleft()
    xy[cnt] = [x, y]
    cnt += 1
    queue_minus.append(x - y)
while len(queue_plus) > 0 and len(queue_minus) > 1:
    x = queue_plus.pop()
    y = queue_minus.pop()
    xy[cnt] = [x, y]
    cnt += 1
    queue_plus.append(x - y)
while len(queue_plus) > 1 and len(queue_minus) > 0:
    x = queue_minus.pop()
    y = queue_plus.pop()
    xy[cnt] = [x, y]
    cnt += 1
    queue_minus.append(x - y)
if len(queue_plus) + len(queue_minus) == 1:
    if len(queue_plus) > 0:
        print(queue_plus.pop())
    else:
        print(queue_minus.pop())
else:
    x = queue_plus.pop()
    y = queue_minus.pop()
    xy[cnt] = [x, y]
    ans = x - y
    print(ans)
for x_y in xy:
    print(" ".join(map(str, x_y)))

Buggy submission (verdict: Runtime Error):
from collections import deque


N = int(input())
A = list(map(int, input().split()))
A.sort()
queue_plus = deque()
queue_minus = deque()
for A_i in A:
    if A_i < 0:
        queue_minus.append(A_i)
    else:
        queue_plus.append(A_i)

xy = [[] for _ in range(N-1)]
cnt = 0
if len(queue_plus) == 0:
    x = queue_minus.pop()
    y = queue_minus.pop()
    xy[cnt] = [x, y]
    cnt += 1
    queue_plus.append(x - y)
if len(queue_minus) == 0:
    x = queue_plus.popleft()
    y = queue_plus.popleft()
    xy[cnt] = [x, y]
    cnt += 1
    queue_minus.append(x - y)
while len(queue_plus) > 0 and len(queue_minus) > 1:
    x = queue_plus.pop()
    y = queue_minus.pop()
    xy[cnt] = [x, y]
    cnt += 1
    queue_plus.append(x - y)
while len(queue_plus) > 1 and len(queue_minus) > 0:
    x = queue_minus.pop()
    y = queue_plus.pop()
    xy[cnt] = [x, y]
    cnt += 1
    queue_minus.append(x - y)
x = queue_plus.pop()
y = queue_minus.pop()
xy[cnt] = [x, y]
ans = x - y
print(ans)
for x_y in xy:
    print(" ".join(map(str, x_y)))