Problem p02997 (python)

Fixed submission:
n,k = map(int,input().split())
if k > (n-1)*(n-2)/2:
  print(-1)
else:
  p = (n-1)*(n-2)/2 - k
  print(n-1+int(p))
  for i in range(2,n+1):
    print(1,i)
  x = 2
  y = 3
  for _ in range(int(p)):
    print(x,y)
    y = y + 1
    if y == n + 1:
      x = x + 1
      y = x + 1

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
if k > (n-1)*(n-2)/2:
  print(-1)
else:
  p = (n-1)*(n-2)/2 - k
  print(N-1+int(p))
  for i in range(2,n+1):
    print(1,i)
  x = 2
  y = 3
  for _ in range(int(p)):
    print(x,y)
    y = y + 1
    if y == n + 1:
      x = x + 1
      y = x + 1

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
if k > (n-1)*(n-2)/2:
  print(-1)
else:
  p = (n-1)*(n-2)/2 - k
  print(int(N-1+p))
  for i in range(2,n+1):
    print(1,i)
  x = 2
  y = 3
  for _ in range(int(p)):
    print(x,y)
    y = y + 1
    if y == n + 1:
      x = x + 1
      y = x + 1

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
if k > (n-1)*(n-2)/2:
  print(-1)
else:
  p = (n-1)*(n-2)/2 - k
  for i in range(2,n+1):
    print(1,i)
  x = 2
  y = 3
  for _ in range(p):
    print(x,y)
    y = y + 1
    if y == n:
      x = x + 1
      y = x + 1

Buggy submission (verdict: Runtime Error):
n,k = map(list(int,input().split()))
if k > (n-1)*(n-2)/2:
  print(-1)
else:
  p = (n-1)*(n-2)/2 - k
  for i in range(2,n+1):
    print(1,i)
  x = 2
  y = 3
  for _ in range(p):
    print(x,y)
    y = y + 1
    if y == n:
      x = x + 1
      y = x + 1

Buggy submission (verdict: Runtime Error):
n,k = map(list(int,input()))
if k > (n-1)*(n-2)/2:
  print(-1)
else:
  p = (n-1)*(n-2)/2 - k
  for i in range(2,n+1):
    print(1,i)
  x = 2
  y = 3
  for _ in range(p):
    print(x,y)
    y = y + 1
    if y == n:
      x = x + 1
      y = x + 1

Buggy submission (verdict: Runtime Error):
a=input().split()
N=int(a[0])
K=int(a[1])
if K > (N-1)*(N-2)/2　:
  print(-1)
else:
  p = (N-1)*(N-2)/2 - K
  for i in range(2,N+1):
    print(1,i)
  for i in range(2,N):
    i = N + 1 - i
    if p >= (i+1)(N-2-i/2):
      q = p - (i+1)(N-2-i/2)
      for j in range(2,i+3):
        for k in range(j+1,N+1):
          print(j,k)
      l = i
      break
  if q > 0:
    for i in range(1,q):
      print(l+3,l+3+i)

Buggy submission (verdict: Runtime Error):
a=input().split()
N=int(a[0])
K=int(a[1])
if K > (N-1)*(N-2)/2　:
  print(-1)
p = (N-1)*(N-2)/2 - K
else:
  for i in range(2,N+1):
    print(1,i)
  for i in range(2,N):
    i = N + 1 - i
    if p >= (i+1)(N-2-i/2):
      q = p - (i+1)(N-2-i/2)
      for j in range(2,i+3):
        for k in range(j+1,N+1):
          print(j,k)
      l = i
      break
  if q > 0:
    for i in range(1,q):
      print(l+3,l+3+i)

Buggy submission (verdict: Runtime Error):
a=input().split()
N=int(a[0])
K=int(a[1])
if K > (N-1)*(N-2)/2 or K < N-2:
  print(-1)
else:
  p = [0]*N
  p[2] = (N-1)*(N-2)/2
  for i in range(2,N-1):
    p[i+1] = p[i] + i - N + 1
  t = 0
  for i in range(2,N):
    if p[i] == K:
      l = i
      break
    else:
      t = t + 1
  if t == N - 2:
    print(-1)
  else:
    print(N-1)
    for j in range(l-1):
      print(j+1,j+2)
    for j in range(l+1,N+1):
      print(l,j)