Problem p02817 (python)

Fixed submission:
s,t=input().split()
print(t+s)

Buggy submission (verdict: Runtime Error):
def main():
  import bisect
  import sys
  from itertools import accumulate
  input = sys.stdin.readline
  def hsnum(x):
    num = 0
    for i in a:
      y = x-i
      num += n-bisect.bisect_left(a,y)
    return num
  n,m = map(int, input().split())
  a = list(map(int, input().split()))
  a.sort()
  suma = [0]+list(accumulate(a))
  lx = 0
  rx = 2*10**5+2
  error = 0
  while lx+1 < rx:
    mx = (lx+rx)//2
    if hsnum(mx) < m:
      rx = mx
    elif hsnum(mx) > m:
      lx = mx + 1
    else:
      lx = mx
      break
  if hsnum(lx)>m:
    lx += 1
  error = hsnum(lx)-m
  ans = 0
  for i in a:
    rema = lx - i
    j = bisect.bisect_left(a,rema)
    ans += (n-j)*i-suma[j]
  ans += suma[n]*n
  print(ans-error*lx)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
  import bisect
  import sys
  from itertools import accumulate
  input = sys.stdin.readline
  def hsnum(x):
    num = 0
    for i in a:
      y = x-i
      num += n-bisect.bisect_left(ls,y)
    return num
  n,m = map(int, input().split())
  a = list(map(int, input().split()))
  a.sort()
  suma = [0]+list(accumulate(a))
  lx = 0
  rx = 2*10**5+2
  error = 0
  while lx < rx:
    mx = (lx+rx)//2
    if hsnum(mx) < m:
      rx = mx
    elif hsnum(mx) > m:
      if hsnum(mx+1) < m:
        error = hsnum(mx)-m
        lx = mx
        break
      lx = mx + 1
    else:
      lx = mx
      break
  ans = 0
  for i in a:
    rema = lx - i
    j = bisect.bisect_left(a,rema)
    ans += (n-j)*i+suma[n]-suma[j]
  print(ans-error*lx)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
  import bisect
  import sys
  from itertools import accumulate
  input = sys.stdin.readline
  def hsnum(ls,x):
    num = 0
    for i in range(n):
      y = x-ls[i]
      num += n-bisect.bisect_left(ls,y)
    return num
  n,m = map(int, input().split())
  a = list(map(int, input().split()))
  a.sort()
  suma = [0]+list(accumulate(a))
  lx = 0
  rx = 2*10**5+2
  error = 0
  while lx < rx:
    mx = (lx+rx)//2
    if hsnum(a,mx) < m:
      rx = mx
    elif hsnum(a,mx) > m:
      if hsnum(a,mx+1) < m:
        error = hsnum(a,mx)-m
        lx = mx
        break
      lx = mx + 1
    else:
      lx = mx
      break
  ans = 0
  for i in a:
    rema = lx - i
    j = bisect.bisect_left(a,rema)
    ans += (n-j)*i+suma[n]-suma[j]
  print(ans-error*lx)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import bisect
    import sys
    from itertools import accumulate
    input = sys.stdin.readline
    def hsnum(ls,x):
        num = 0
        for i in range(n):
            y = x-ls[i]
            num += n-bisect.bisect_left(ls,y)
        return num
    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    suma = [0]+list(accumulate(a))
    lx = 0
    rx = 2*10**5+2
    error = 0
    while lx < rx:
        mx = (lx+rx)//2
        if hsnum(a,mx) < m:
            rx = mx
        elif hsnum(a,mx) > m:
            if hsnum(a,mx+1) < m:
                error = hsnum(a,mx)-m
                lx = mx
                break
            lx = mx + 1
        else:
            lx = mx
            break
    ans = 0
    for i in range(n):
        rema = lx - a[i]
        j = bisect.bisect_left(a,rema)
        ans += (n-j)*a[i]+suma[n]-suma[j]
    print(ans-error*lx)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import bisect
import sys
from itertools import accumulate
input = sys.stdin.readline
def hsnum(ls,x,n):
    num = 0
    for i in range(n):
        y = x-ls[i]
        num += n-bisect.bisect_left(ls,y)
    return num
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
suma = [0]+list(accumulate(a))
lx = 0
rx = 2*10**5+2
error = 0
while lx < rx:
    mx = (lx+rx)//2
    if hsnum(a,mx,n) < m:
        rx = mx
    elif hsnum(a,mx,n) > m:
        if hsnum(a,mx+1,n) < m:
            error = hsnum(a,mx,n)-m
            lx = mx
            break
        lx = mx + 1
    else:
        lx = mx
        break
ans = 0
for i in range(n):
    rema = lx - a[i]
    j = bisect.bisect_left(a,rema)
    ans += (n-j)*a[i]+suma[n]-suma[j]
print(ans-error*lx)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
print(t+s)