Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys
input = sys.stdin.readline


def solve(N, A, fromR=True):
    res = 0
    L, R = None, None

    while A:
        fromR = 1 - fromR

        if L is None:
            L = A.pop() if fromR else A.popleft()
            R = L
            continue

        if len(A) > 1:
            if fromR:
                x = A.pop()
                y = A.pop()
            else:
                x = A.popleft()
                y = A.popleft()
            res += abs((R + L) - (x + y))
            R, L = x, y
            continue

        if len(A) == 1:
            x = A.pop()
            res += max(abs(R - x), abs(L - x))
            continue

    return res


if __name__ == "__main__":
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A = deque(sorted(A))

    ans1 = solve(N, A.copy(), 0)
    ans2 = solve(N, A, 1)
    ans = max(ans1, ans2)
    print(ans)


Fixed submission:
from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
x = deque(a)
y = deque(a)


def align(a, fromLeft=1):
    if fromLeft:
        p = a.popleft()
    else:
        p = a.pop()
    q = p

    res = 0
    fromLeft = 1 - fromLeft
    while a:
        p1 = a.popleft() if fromLeft else a.pop()
        if a:
            q1 = a.popleft() if fromLeft else a.pop()
            res += abs(p - p1) + abs(q - q1)
            p = p1
            q = q1
        else:
            res += max(abs(p - p1), abs(q - p1))
        fromLeft = 1 - fromLeft
    return res


ans = max(align(x, 1), align(y, 0))
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = [int(readline()) for _ in range(n)]

a.sort()
deq = deque(a)

ans = 0

left, right = deq.popleft(), 0
cnt = 1


def comparison(left, right, x, y):
    if y == 0:
        return max(abs(left - x), abs(right - x))

    if right == 0:
        return abs(left*2 - x - y)
    else:
        return abs(left+right-x-y)


while deq:
    if len(deq) == 1:
        x = deq.pop()
        y = 0
    else:
        if cnt:
            x = deq.pop()
            y = deq.pop()
        else:
            x = deq.popleft()
            y = deq.popleft()

    ans += comparison(left, right, x, y)
    left, right = x, y
    cnt = 1-cnt

print(ans)

Fixed submission:
from collections import deque
n = int(input())
a = [int(input()) for _ in range(n)]
a.sort()
x = deque(a)
y = deque(a)


def align(a, fromLeft=1):
    if fromLeft:
        p = a.popleft()
    else:
        p = a.pop()
    q = p

    res = 0
    fromLeft = 1 - fromLeft
    while a:
        p1 = a.popleft() if fromLeft else a.pop()
        if a:
            q1 = a.popleft() if fromLeft else a.pop()
            res += abs(p - p1) + abs(q - q1)
            p = p1
            q = q1
        else:
            res += max(abs(p - p1), abs(q - p1))
        fromLeft = 1 - fromLeft
    return res


ans = max(align(x, 1), align(y, 0))
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
N, M = map(int, input().split())
S = input()
T = input()

L = N // gcd(N, M) * M
memo = [0] * (L + 10)


ok = True

ds = L // N
for i in range(N):
    memo[i * ds] = S[i]
dt = L // M
for i in range(M):
    if not memo[i * dt]:
        continue
    if memo[i * dt] != T[i]:
        ok = False

if ok:
    print(L)
else:
    print(-1)

Fixed submission:
n, m = map(int, input().split())
s = input()
t = input()


def euclid(x, y):
    x, y = max(x, y), min(x, y)
    if y == 0:
        return x
    return euclid(y, x % y)


lcm = n * m // euclid(n, m)
nn = lcm // n
mm = lcm // m
ss = s[0::mm]
tt = t[0::nn]

if ss == tt:
    print(lcm)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
from math import gcd
N, M = map(int, input().split())
S = input()
T = input()

L = N // gcd(N, M) * M
memo = [0] * L


ok = True

ds = L // N
for i in range(N):
    memo[i * ds] = S[i]
dt = L // M
for i in range(M):
    if not memo[i * dt]:
        continue
    if memo[i * dt] != T[i]:
        ok = False

if ok:
    print(L)
else:
    print(-1)

Fixed submission:
n, m = map(int, input().split())
s = input()
t = input()


def euclid(x, y):
    x, y = max(x, y), min(x, y)
    if y == 0:
        return x
    return euclid(y, x % y)


lcm = n * m // euclid(n, m)
nn = lcm // n
mm = lcm // m
ss = s[0::mm]
tt = t[0::nn]

if ss == tt:
    print(lcm)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
from math import gcd
N, M = map(int, input().split())
S = input()
T = input()

g = N // gcd(N, M) * M
res = [-1] * g
for i, s in enumerate(S):
    x = (g // N) * i
    res[x] = s

for i, s in enumerate(T):
    x = (g // M) * i
    if res[x] == -1:
        res[x] = s
    elif res[x] != s:
        print(-1)
        exit()

print(g)

Fixed submission:
n, m = map(int, input().split())
s = input()
t = input()


def euclid(x, y):
    x, y = max(x, y), min(x, y)
    if y == 0:
        return x
    return euclid(y, x % y)


lcm = n * m // euclid(n, m)
nn = lcm // n
mm = lcm // m
ss = s[0::mm]
tt = t[0::nn]

if ss == tt:
    print(lcm)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=int(input())
b=int(input())
if n==1:
  print("Hello World")
else:
  print(a+b)

Fixed submission:
n=int(input())
if n==1:
  print("Hello World")
else:
  print(int(input())+int(input()))
Buggy python submission (verdict: Time Limit Exceeded):
def check():
    s=input()
    t=input()

    for i in range(len(s)):
        if s[i]==t[i]:
            continue
        si=s[i]
        ti=t[i]
        t=t.replace(ti, "?")
        t=t.replace(si, ti)
        t=t.replace("?", si)
    
    if s==t:
        return "Yes"
    else:
        return "No"

print(check())        


Fixed submission:
def check():
    s=input()
    t=input()

    d={}

    for i in range(len(s)):
        si=s[i]
        ti=t[i]
        if not si in d:
            d[si]=ti
        else:
            if d[si]==ti:
                continue
            else:
                return "No"
            
    vals=d.values()
    if len(vals)==len(set(vals)):
        return "Yes"
    else:
        return "No"
print(check())
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)

dif = np.abs(A - K)
ans = np.gcd.reduce(dif)
print(ans)

Fixed submission:
N, X=map(int, input().split())
x=[abs(int(i)-X) for i in input().split()]

def gcd(x, y):
    x, y=max(x,y), min(x,y)
    if y==0:
        return x
    else:
        return gcd(y, x%y)

ans=1
for i in range(N):
    if i==0:
        ans=x[i]
    else:
        ans=gcd(ans, x[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
def gcd(x, y):
    x, y=max(x,y), min(x,y)
    if y==0:
        return x
    return gcd(y, x%y)

def lcm(x, y):
    return int(x*y/gcd(x, y))

n=int(input())
a=list(map(int,input().split()))

a_lcm=1
for i in range(n):
    a_lcm=lcm(a_lcm, a[i])

ans=0
for i in a:
    ans+=(a_lcm-1)%i
print(ans)

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

print(sum(a)-n)
Buggy python submission (verdict: Runtime Error):
S=input()
print(S.count("+")-S.count("-")

Fixed submission:
s=input()
p=s.count("+")
m=s.count("-")
print(p-m)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
P = [int(input()) for _ in range(n)]

seen = [0] * (n + 1)
i = 0
counter = 0
while i < n:
    if seen[i]:
        i += 1
        continue

    p = P[i]
    seen[i] = 1
    cnt = 1
    for j in range(i+1, n):
        if P[j] == p + 1:
            seen[j] = 1
            cnt += 1
            p += 1
    i += 1
    counter = max(counter, cnt)

ans = n - counter
print(ans)


Fixed submission:
n = int(input())
order = [0] * (n+1)
for i in range(n):
    p = int(input())
    order[p] = i+1
order[0] = 10**9

cnt = 0
ans = 0
for x, y in zip(order[:-1], order[1:]):
    if x > y:
        ans = max(cnt, ans)
        cnt = 0
    else:
        cnt += 1
ans = max(cnt, ans)

answer = n - ans - 1
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
k=int(input())

candidate=set()

for i in range(1, len(S)+1):
    for j in range(len(S)-i+1):
        candidate.add(S[j:j+i])

candidate=sorted(list(candidate))
print(candidate[k-1])


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

candidate=set()

mx=min(len(S), 5)
for i in range(1, mx+1):
    for j in range(len(S)-i+1):
        candidate.add(S[j:j+i])

candidate=sorted(list(candidate))
print(candidate[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
S = np.array([list(input()) for _ in range(N)], dtype="U1")
S = np.concatenate([S, S], axis=1)
S = S.tolist()


def check(x):
    for i in range(N):
        for j in range(i+1, N):
            if S[i][j + x] != S[j][i + x]:
                return 0
    return N


ans = 0
for x in range(N):
    ans += check(x)

print(ans)


Fixed submission:
import numpy as np
N = int(input())
S = [[ord(i) for i in input()] * 2 for _ in range(N)]
S = np.array(S)

ans = 0
for i in range(N):
    tmp = S[:, i: i + N]
    if (tmp == tmp.T).all():
        ans += 1

ans = ans * N
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))

route=[0]*n
for i in a:
  route[i-1]=1
ans=min(sum(route[:x]),sum(route[x:]))
print(ans(

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

route=[0]*n
for i in a:
  route[i-1]=1
ans=min(sum(route[:x]),sum(route[x:]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=[(int(j),i) for i,j in enumerate(input().split())]
l=int((n-1)/2)

sortedList=sorted(x)
ans=[-1]*n

for i in range(n):
    xx=sortedList[:i]+sortedList[i+1:]
    pos=sortedList[i][1]
    val=xx[l][0]
    ans[pos]=str(val)

print("\n".join(ans))

Fixed submission:
import bisect
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)

left=b[int(n/2)-1]
right=b[int(n/2)]
for i in a:
    pos=bisect.bisect_left(b, i)+1
    if 2*pos<=n:
        print(right)
    else:
        print(left)
Buggy python submission (verdict: Runtime Error):
s=input()
if "".join(sorted(s)=="abc":
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
if "".join(sorted(s))=="abc":
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s=input()
if s.sort()=="abc":
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
if "".join(sorted(s))=="abc":
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input())
if b-a-1<=k:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a,a+k):
    print(i)
  for i in range(b-k+1,b+1):
    print(i)

Fixed submission:
a,b,k=map(int,input().split())
ans=[]
for i in range(k):
    if a+i>b or b-i<a:
        break
    ans.append(a+i)
    ans.append(b-i)
ans=list(set(ans))
ans.sort()
for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
import numpy as np
A, B, C = sorted(list(map(int, input().split())))

d = C - B
A += d
B += d


if (B - A) % 2 == 0:
    ans = d + (B - A) // 2
else:
    ans = d + (B - A + 1) // 2 + 1
print(ans)

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

ans=0

#まず+1, +1を限界まで
b_plus=c-b
b+=b_plus
a+=b_plus
ans+=b_plus

#次に+2を限界まで
a_plus=(c-a)//2
a+=a_plus*2
ans+=a_plus

#微調整
if a!=b:
    ans+=2

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()

if len(c) < 26:
    for i in "abcdefghijklmnopqrstuvwxyz":
        if not i in s:
            ans = s + i
            break

else:
    tmp = ""
    ss = list(s)
    for i in range(len(ss)):
        if i == 0:
            tmp += ss.pop()
            continue

        if ss[-1] > tmp[-1]:
            tmp += ss.pop()
        else:
            ss.pop()
            ans = "".join(ss) + min(tmp)
            break
    else:
        ans = -1

print(ans)


Fixed submission:
s = input()
alp = "abcdefghijklmnopqrstuvwxyz"

if len(s) < 26:
    for i in alp:
        if not i in s:
            ans = s + i
            break

else:
    tmp = []
    ss = list(s)
    for i in range(len(ss)):
        if i == 0:
            tmp.append(ss.pop())
            continue

        if alp.index(ss[-1]) > alp.index(tmp[-1]):
            tmp.append(ss.pop())
            continue
        else:
            remove = ss.pop()
            tmp.sort()
            for j in tmp:
                if j > remove:
                    renew = j
                    break
            ans = "".join(ss) + renew
            break
    else:
        ans = -1

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N=input()
c = Counter(list(map(int,input().split())))
if len(c)==4:
  print("Four")
else:
  print("Three")

Fixed submission:
n=int(input())
s=list(input().split())
if len(set(s))==3:
  print("Three")
if len(set(s))==4:
  print("Four")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
name=[]
initial=[]
for _ in range(n):
    s=input()
    if s[0] in ["M","A","R","C","H"] and not s in name:
        name.append(s)
        initial.append(s[0])
c=Counter(initial)
num=[v for k,v in c.items()]

if len(num)<3:
    print(0)
else:
    ans=0
    for i in range(len(num)-2):
        for j in range(i+1,len(num)-1):
            for k in range(j+1,len(num)):
                #print(i,j,k)
                ans+=num[i]*num[j]*num[k]
    print(ans)


Fixed submission:
from collections import Counter
n=int(input())
name=[]
initial={"M":0,
         "A":0,
         "R":0,
         "C":0,
         "H":0}
for _ in range(n):
    s=input()
    if s[0] in ["M","A","R","C","H"]:
        initial[s[0]]+=1
num=[v for k,v in initial.items()]

if len(num)<3:
    print(0)
else:
    ans=0
    for i in range(len(num)-2):
        for j in range(i+1,len(num)-1):
            for k in range(j+1,len(num)):
                #print(i,j,k)
                ans+=num[i]*num[j]*num[k]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import heapq
inf = 10**5
h, w = map(int, input().split())
wall = 0
grid = []
for _ in range(h):
    inp = input()
    wall += inp.count("#")
    grid.append([1 if i == "." else inf for i in inp])
grid = np.array(grid)
cost = np.ones(grid.shape, dtype=int)*inf

todo = [(0, 0)]     #cost, node
heapq.heapify(todo)
seen = np.zeros(grid.shape, dtype=int)

d = ((1, 0),
     (0, 1),
     (-1, 0),
     (0, -1))

while todo:
    c, n = heapq.heappop(todo)
    ny = n//w
    nx = n%w
    seen[ny][nx] = 1
    cost[ny][nx] = c

    for dx, dy in d:
        x, y =dx+nx, dy+ny
        if 0 <= x and x < w and 0 <= y and y < h and seen[y][x] == 0:
            cn = (min(cost[y][x], c+grid[y][x]), x+w*y)
            heapq.heappush(todo, cn)

if cost[-1][-1] >= inf:
    ans = -1
else:
    ans = h*w - (cost[-1][-1]+1) - wall
print(ans)

Fixed submission:
import numpy as np
from collections import deque
h, w = map(int, input().split())

inf = 1009
grid = np.zeros((h + 2, w + 2), dtype=int)
for i in range(h):
    grid[i + 1][1:-1] = np.array([1 if j == "." else 0 for j in input()])
white = grid.sum()

cost = np.ones((h+2, w+2), dtype=int)*inf
cost[1][1] = 1

d = ((1, 0), (0, 1), (-1, 0), (0, -1))
to = deque([(1, 1)])
while to:
    x, y = to.popleft()
    c = cost[x][y]
    for xi, yi in d:
        nx = x + xi
        ny = y + yi
        if not grid[nx][ny]:
            continue
        to.append((nx, ny))
        cost[nx][ny] = min(cost[nx][ny], c+1)
        grid[nx][ny] = 0

if cost[-2][-2] == inf:
    ans = -1
else:
    ans = white-cost[-2][-2]
print(ans)
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
ans=0
for i in range(1, n+1):
  s=sum(list(str(i)))
  if a<=s and s<=b:
    ans+=1
print(ans)

Fixed submission:
n,a,b=map(int,input().split())
ans=0
for i in range(1, n+1):
  s=list(str(i))
  l=list(map(int,s))
  s=sum(l)
  if a<=s and s<=b:
    ans+=i
print(ans)
Buggy python submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
print(min(n*a,b)

Fixed submission:
n,a,b=map(int,input().split())
print(min(n*a,b))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, C = map(int, input().split())
STC = [tuple(map(int, input().split())) for _ in range(N)]
STC.sort(reverse=True, key=lambda x: x[1])  # tを基準に降順ソート

record = []
while STC:
    s_now, t_now, c_now = STC.pop()

    for i in range(len(record)):
        t, s, c = record[i]
        if c == c_now:
            record[i] = (t_now, s_now, c_now)
            break
        elif s_now > t:
            record[i] = (t_now, s_now, c_now)
            break
    else:
        record.append((t_now, s_now, c_now))

    ans = max(ans, len(record))

print(len(ans))


Fixed submission:
N, C = map(int, input().split())
tmp = []

for _ in range(N):
    s, t, c = map(int, input().split())
    tmp.append((s, t, c))
tmp.sort()

# そもそもCが小さいから力技で行けるはず
video = [(0, 0)]  # t,c
for s, t, c in tmp:
    for i, v in enumerate(video):
        ti, ci = v
        if c == ci:
            video[i] = (t, c)
            break
        if s > ti:
            video[i] = (t, c)
            break
    else:
        video.append((t, c))
    video.sort(reverse=True)

ans = len(video)
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
if len(set(s[:-1])==1 or len(set([1:])==1:
    print("Yes")
else:
    print("No")

Fixed submission:
n=list(input())
if len(set(n[:-1]))==1 or len(set(n[1:]))==1:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()

ab=[]
bc=[]
for i in range(n):
    ab.append(bisect.bisect_left(a, b[i]))
    bc.append(bisect.bisect_left(b, c[i]))

ans=0
for i in bc:
    ans+=sum(ab[:i])

print(ans)

Fixed submission:
import bisect
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 i in b:
    up=bisect.bisect_left(a, i)
    dn=n-bisect.bisect_right(c, i)
    ans+=up*dn

print(ans)
Buggy python submission (verdict: Runtime Error):
print("Yes") "AC" in input() else "No"

Fixed submission:
s=input()
for i,j in zip(s[:-1],s[1:]):
  if i+j=="AC":
    print("Yes")
    exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
AB = (tuple(map(int, input().split())) for _ in range(N))

# 各商品の価格のビットが立っている位置を事前に見とく
bit = []
for a, b in AB:
    tmp = set()
    for i in range(31):
        if a & 1:
            tmp.add(i)
        a //= 2
    bit.append((tmp, b))

def cost(S):
    res = 0
    for T, b in bit:
        if S.issuperset(T):
            res += b
    return res

# Kのビットが立っている位置を調べる
Kbit = set()
Ktmp = K
for i in range(31):
    if Ktmp & 1:
        Kbit.add(i)
    Ktmp //= 2

ans = cost(Kbit)
for i in Kbit:
    T = Kbit.copy()
    T -= {i}            #位置iのビットを0にする
    T |= set(range(i))  #i未満のビットを全部1にする
    ans = max(ans, cost(T))

print(ans)


Fixed submission:
N, K = map(int, input().split())
AB = (tuple(map(int, input().split())) for _ in range(N))

# 各商品の価格のビットが立っている位置を事前に見とく
bit = []
for a, b in AB:
    tmp = set()
    for i in range(31):
        if a & 1:
            tmp.add(i)
        a //= 2
    bit.append((tmp, b))

def cost(S):
    res = 0
    for T, b in bit:
        if S.issuperset(T):
            res += b
    return res

# Kのビットが立っている位置を調べる
Kbit = set()
Ktmp = K
for i in range(31):
    if Ktmp & 1:
        Kbit.add(i)
    Ktmp //= 2

ans = cost(Kbit)
for i in Kbit:
    T = Kbit.copy()
    T -= {i}            #位置iのビットを0にする
    T |= set(range(i))  #i未満のビットを全部1にする
    ans = max(ans, cost(T))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [tuple(map(int, input().split())) for _ in range(N)]
seen = [[False] * N for _ in range(N)]

ans = 0

for i in range(N - 1):
    for j in range(i + 1, N):
        # iからjに行くルートを考える
        path_IJ = A[i][j]
        use = [(i, j)]
        for k in range(N):
            if i == k or j == k:
                continue
            path_IKJ = A[i][k] + A[k][j]

            if path_IJ > path_IKJ:
                print(-1)
                exit()
            elif path_IJ == path_IKJ:
                use = [(i, k), (k, j)]
            else:
                pass

        for x, y in use:
            x, y = min(x, y), max(x, y)
            if not seen[x][y]:
                ans += A[x][y]
                seen[x][y] = True
print(ans)


Fixed submission:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def road():
    N = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(N))

    res = 0
    for s in range(N - 1):
        for t in range(s + 1, N):
            # s-t間に辺を張るかを決める
            dist = A[s][t]
            is_connect = True
            for m in range(N):
                if m in [s, t]:
                    continue
                d = A[s][m] + A[m][t]
                if d < dist:
                    return -1
                elif d == dist:
                    is_connect = False
            if is_connect:
                res += dist
    return res


if __name__ == "__main__":
    print(road())
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
seat = np.zeros(N + 100, dtype=int)
L, R = np.array([input().split() for _ in range(N)], dtype=int).T

np.add.at(seat, L, 1)
np.add.at(seat, R+1, -1)
np.cumsum(seat, out=seat)
print(seat.sum())

Fixed submission:
n=int(input())
ans=0
for _ in range(n):
    l,r=map(int,input().split())
    ans+=r-l+1
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
l=list(map(int,input().split()))
c=Counter(l)

edges=[]
for k,v in c.items():
    if v>=2:
        for i in range(v//2):
            edges.append(k)
edges.sort(reverse=True)
print(edges[0]*edges[1])


Fixed submission:
from collections import Counter
n=int(input())
l=list(map(int,input().split()))
c=Counter(l)

edges=[]
for k,v in c.items():
    if v>=2:
        for i in range(v//2):
            edges.append(k)
if len(edges)>=2:
    edges.sort(reverse=True)
    print(edges[0]*edges[1])
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n=[0]*101
a,b,c,d=map(int,input().split())
n[a]+=1
n[b+1]-=1
n[c]+=1
n[d+1]-=1
for i in range(100):
  n[i+1]+=n[i]
ans=0
for i in n:
  if i==2:
    ans+=1
print(ans)

  


Fixed submission:
n=[0]*101
a,b,c,d=map(int,input().split())
n[a]+=1
n[b]-=1
n[c]+=1
n[d]-=1
for i in range(100):
  n[i+1]+=n[i]
ans=0
for i in n:
  if i==2:
    ans+=1
print(ans)