Problem:


Score : 700 points

Problem Statement

You are given an integer N.
Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:

The graph is simple and connected.

There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.

It can be proved that at least one such graph exists under the constraints of this problem.

Constraints

All values in input are integers.

3 \leq N \leq 100

Input

Input is given from Standard Input in the following format:

N

Output

In the first line, print the number of edges, M, in the graph you made. In the i-th of the following M lines, print two integers a_i and b_i, representing the endpoints of the i-th edge.

The output will be judged correct if the graph satisfies the conditions.

Sample Input 1

3

Sample Output 1

2
1 3
2 3

For every vertex, the sum of the indices of the vertices adjacent to that vertex is 3.



Sample input:
3


Sample output:
2
1 3
2 3

Submission status: Wrong Answer

Solution code:
n=int(input())
g0=[i for i in range(1,n+1)]
t=n*(n+1)//2
if t%2:
    s=t//3
    sm=0
    g1=[]
    nk=1
    while nk!=0:
        gx=g0.pop(-1)
        sm+=gx
        g1.append(gx)
        nk=s-sm
        if nk in g0:
            g0.remove(nk)
            g1.append(nk)
            break
    sm=0
    g2=[]
    nk=1
    while nk!=0:
        gx=g0.pop(-1)
        sm+=gx
        g2.append(gx)
        nk=s-sm
        if nk in g0:
            g0.remove(nk)
            g2.append(nk)
            break
    le0,le1,le2=len(g0),len(g1),len(g2)
    print(le0*(le1+le2)+le1*le2)
    for x0 in g0:
        for x12 in g1+g2:
            print(x0,x12)
    for x1 in g1:
        for x2 in g2:
            print(x1,x2)

else:
    s=t//2
    sm=0
    g1=[]
    nk=1
    while nk!=0:
        gx=g0.pop(-1)
        sm+=gx
        g1.append(gx)
        nk=s-sm
        if nk in g0:
            g0.remove(nk)
            g1.append(nk)
            break
    print(len(g0)*len(g1))
    for x0 in g0:
        for x1 in g1:
            print(x0,x1)

Submission status: Wrong Answer

Solution code:
n = int(input())

if n % 2 == 0:
  print(n*(n-2)//2+1)
  for i in range(1,n):
    for j in range(i+1,n+1):
      if i + j != n:
        print(i,j)
else:
  print(n*(n-2)//2)
  for i in range(1,n):
    for j in range(i+1,n+1):
      if i + j != n + 1:
        print(i,j)

Submission status: Wrong Answer

Solution code:
n = int(input())

if n % 2 == 0:
  print(n*(n-2)//2)
  for i in range(1,n):
    for j in range(i+1,n+1):
      if i + j != n:
        print(i,j)
else:
  print(n*(n-2)//2 + 1)
  for i in range(1,n):
    for j in range(i+1,n+1):
      if i + j != n + 1:
        print(i,j)

Submission status: Wrong Answer

Solution code:
n = int(input())

if n % 2 == 0:
  print(n*(n-2)//2)
  for i in range(1,n):
    for j in range(i+1,n+1):
      if i + j != n:
        print(i,j)
else:
  print(n*(n-2)//2 + 1)
  for i in range(n):
    for j in range(i+1,n+1):
      if i + j != n + 1:
        print(i,j)

Submission status: Wrong Answer

Solution code:
n = int(input())

if n % 2 == 0:
  print(n*(n-2)//2)
  for i in range(n):
    for j in range(i+1,n+1):
      if i + j != n:
        print(i,j)
else:
  print(n*(n-2)//2 + 1)
  for i in range(n):
    for j in range(i+1,n+1):
      if i + j != n + 1:
        print(i,j)

Submission status: Wrong Answer

Solution code:
from sys import exit
from numpy.random import rand
# A,B,C = [int(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
N = int(input())
# dic = {}
# for i in range(1,N+1):
#     dic[i] = 0
#偶数ならN+1をつくる
ansgroup = []
if N%2 == 0:
    for i in range(1,N//2+1):
        ansgroup.append([i, N-i+1])
else:
    for i in range(1,N//2+1):
        ansgroup.append([i, N-i])
    ansgroup.append([N])
# print(ansgroup)
for i in range(len(ansgroup)):
    for j in range(i+1,len(ansgroup)):
        for e1 in ansgroup[i]:
            for e2 in ansgroup[j]:
                print(e1,e2)
# ansset = set([ i for i in range(1,N+1)])
# tmpset = set()
# for i in range(1,len(ans)):
#     if ans[i-1][0] == ans[i][0]:
#         tmpset = ans[i][1] | ans[i-1][1]
#     else:
#         print(ans[i-1][0],ansset)
#         ansset = set([ i for i in range(1,N+1)])
# exit()
#奇数ならNをつくる組みあわせがペアそれ以外とぜんぶつながる

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []
lis = []
for i in range(N):
    lis.append(i + 1)
if N % 2 == 0:
    M = (N - 2) * N // 2
    for i in range(1, N // 2 + 1):
        for j in range(1, N):
            if j != i:
                ans.append([i, lis[-j]])
    print(M)
    for i in range(M):
        print(' '.join(map(str, ans[i])))
else:
    M = (N - 1) ** 2 // 2
    for i in range(1, (N - 1) // 2 + 1):
        for j in range(2, N):
            if j != i + 1:
                ans.append([i, lis[-j]])
    for i in range(1, N):
        ans.append([N, i])
    print(M)
    for i in range(M):
        print(' '.join(map(str, ans[i])))

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = list()
i = 0
if n % 2 == 0:
    while not(i == n / 2):
        nums.append((i+1,n-i))
        i += 1
else:
    while not(i == (n-1)/2):
        nums.append((i+1, n-i-1))
        i += 1
    nums.append((n,))
i = 0
while i < len(nums) - 1:
    for a in nums[i]:
        for b in nums[i+1]:
            print(a, b)
    i += 1
if len(nums) >= 3:
    for a in nums[0]:
        for b in nums[-1]:
            print(a, b)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []
lis = []
for i in range(N):
    lis.append(i + 1)
if N % 2 == 0:
    M = (N - 2) * N // 2
    for i in range(1, N // 2 + 1):
        for j in range(1, N):
            if j != i:
                ans.append([i, lis[-j]])
    for i in range(M):
        print(' '.join(map(str, ans[i])))
else:
    M = (N - 1) ** 2 // 2
    for i in range(1, (N - 1) // 2 + 1):
        for j in range(2, N):
            if j != i + 1:
                ans.append([i, lis[-j]])
    for i in range(1, N):
        ans.append([N, i])
    for i in range(M):
        print(' '.join(map(str, ans[i])))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from itertools import permutations

n = int(input())
res = []
for r in permutations(range(1,n+1)):
    c = r[0]+r[2]
    flag = True
    for i in range(1,n-1):
        if r[i-1]+r[i+1]!=c:
            flag = False
            break
    if r[1]==r[n-2]==c:
        pass
    elif r[1]+r[n-1]==c:
        res.append((r[1],r[n-1]))
    else:
        flag = False

    if flag:
        for i in range(n-1):
            res.append((r[i],r[i+1]))
        break

print(len(res))
for r in res:
    print(r[0],r[1])

Submission status: Wrong Answer

Solution code:
N = int(input())
S = 0
for i in range(1, N):
    S += i

Ans = []

if N % 2 == 1:
    for i in range(1, N):
        Ans.append((i, N))
    for i in range(1, N):
        for j in range(i+1, N):
            if j != N-i:
                Ans.append((i, j))


print(len(Ans))
for a in Ans:
    print(" ".join(map(str, a)))

Submission status: Wrong Answer

Solution code:
n = int(input())

if n == 3:
    print("1 3")
    print("2 3")
if n == 4:
    print("1 2")
    print("1 3")
    print("2 4")
    print("3 4")
if n >= 5:
    if n % 2 == 0:
        for i in range(1, n):
            for j in range(i+1, n+1):
                if i + j != n+1:
                    print(str(i)+" "+str(j))
    if n % 2 == 1:
        for i in range(1, n-1):
            for j in range(i+1, n):
                if i + j != n:
                    print(str(i)+" "+str(j))
        for i in range(1, n):
            print(str(i)+" "+str(n))

# for ptn1 in range(2 ** 5):
#     ptn_str1 = format(ptn1, '05b')
#     p1 = []
#     for i, p in enumerate(ptn_str1):
#         if p == '1':
#             p1.append(i+2)
#     for ptn2 in range(2 ** 4):
#         ptn_str2 = format(ptn2, '04b')
#         p2 = []
#         for j, q in enumerate(ptn_str2):
#             if q == '1':
#                 p2.append(j+3)
#         for ptn3 in range(2 ** 3):
#             ptn_str3 = format(ptn3, '03b')
#             p3 = []
#             for k, r in enumerate(ptn_str3):
#                 if r == '1':
#                     p3.append(k+4)
#             for ptn4 in range(2 ** 2):
#                 ptn_str4 = format(ptn4, '02b')
#                 p4 = []
#                 for l, s in enumerate(ptn_str4):
#                     if s == '1':
#                         p4.append(l+5)
#                 adds = [0, 0, 0, 0, 0, 0]
#                 for x in p1:
#                     adds[0] += x
#                     adds[x-1] += 1
#                 for y in p2:
#                     adds[1] += y
#                     adds[y-1] += 2
#                 for z in p3:
#                     adds[2] += z
#                     adds[z-1] += 3
#                 for zz in p4:
#                     adds[3] += zz
#                     adds[zz-1] += 4
#                 if adds[4]+6 == adds[5]+5:
#                     # print("adds5&6"+ptn_str1+"/"+ptn_str2+"/"+ptn_str3+"/"+ptn_str4)
#                     adds[4] += 6
#                     adds[5] += 5
#                 eq = adds[0]
#                 if eq != 0:
#                     equal = True
#                     for s in adds:
#                         if s != eq:
#                             equal = False
#                             break
#                     if equal is True:
#                         print(eq)
#                         print(ptn_str1)
#                         print(ptn_str2)
#                         print(ptn_str3)
#                         print(ptn_str4)

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = list()
i = 0
if n % 2 == 0:
    while not(i == n / 2):
        nums.append((i+1,n-i))
        i += 1
else:
    while not(i == (n-1)/2):
        nums.append((i+1, n-i-1))
        i += 1
    nums.append((n,))
i = 0
while i < len(nums) - 1:
    for a in nums[i]:
        for b in nums[i+1]:
            print(a, b)
    i += 1
if len(nums) > 3:
    for a in nums[0]:
        for b in nums[-1]:
            print(a, b)

Submission status: Wrong Answer

Solution code:
N = int(input())
lists = []

if N % 2 == 1:
    Q = N / 2
    print(2*Q*Q)
    for i in range(N):
        for j in range(N):
            if i != j and i + j != N and i < j:
                print(i, j)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = 0
for i in range(1, N):
    S += i

Ans = []

if N % 2 == 1:
    for i in range(1, N):
        Ans.append((i, N))
    for i in range(1, N):
        for j in range(i, N):
            if j != N-i:
                Ans.append((i, j))


print(len(Ans))
for a in Ans:
    print(" ".join(map(str, a)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import sys

N = int(input())

if N % 2 == 0:
    print((N-2)*(N-1)//2)
    for i in range(N):
        for j in range(i,N):
            if (i+1+j+1) != (N+1) and i != j:
                print(str(i+1)+' '+str(j+1))
else:
    print((N-1)*(N)//2)
    for i in range(N):
        for j in range(i,N):
            if (i+1+j+1) != (N) and i != j:
                print(str(i+1)+' '+str(j+1))

Submission status: Wrong Answer

Solution code:
N = int(input())
if N % 2 == 1:
    M = int(((N - 1) ** 2 // 2))
    print(M)
    for i in range(1, N):
        print(i, N)
    for i in range(1, int((N - 1) / 2) + 1):
        for j in range(i + 1, N):
            if i + j < N:
                print(i, j)
                print(j, N - 1)

else:
    M = int(N * (N - 2) // 2)
    print(M)
    for i in range(N - 2):
        print(1, i + 2)
        print(i + 2, N)
    for i in range(2, int(N / 2) + 1):
        for j in range(i + 1, N):
            if i + j < N + 1:
                print(i, j)
                print(j, N - 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = 0
for i in range(1, N):
    S += i

Ans = []

if N % 2 == 1:
    Ans.append((i, N) for i in range(1, N))
    for i in range(1, N):
        for j in range(i, N):
            if j != N-i:
                Ans.append((i, j))


print(len(Ans))
for a in Ans:
    print(" ".join(map(str, a)))

Submission status: Wrong Answer

Solution code:
n = int(input())

ans = []
count = 0

for i in range(1, n):
    ans.append((i, n))
    count += 1

for i in reversed(range(1, n)):
    for j in range(1, i):
        if i + j == n:
            continue
        ans.append((j, i))
        count += 1

print(count)
for a, b in ans:
    print(a, b)

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = []
for i in range(1, n + 1):
    for j in range(1, n + 1):
        if i != j and i + j != n + 1:
            ans.append(sorted([i, j]))
ans.sort()
for i in range(len(ans)):
    if i % 2 == 0:
        print(*ans[i])

Submission status: Wrong Answer

Solution code:
n = int(input())

m = n - 1
print(m)

print("{} {}".format(1, n))
print("{} {}".format(m, n))

Submission status: Wrong Answer

Solution code:
N = int(input())
group = []

ansanslist = [[0 for i in range(N)] for j in range(N)]
if N % 2 != 0:
    group.append([N])
N -= 1

for i in range(N // 2):
    group.append([i + 1, N - i])

if N % 2 != 0:
    group.append([N // 2 + 1])
anslist = []

for i in range(len(group)):
    for k in group[i]:
        for j in range(len(group)):
            for l in group[j]:
                if i != j:
                    anslist.append([k, l])

anslist.sort()
ansanslist = []
for i, j in anslist:
    if i < j:
        ansanslist.append([i, j])

print(len(ansanslist))
for i, j in ansanslist:
    print(i, j)

Submission status: Wrong Answer

Solution code:
N = int(input())
if N % 2 == 1:
    M = int(((N - 1) ** 2 // 2))
    print(M)
    for i in range(1, N):
        print(i, N)
    for i in range(1, int((N - 1) / 2) + 1):
        for j in range(i + 1, N):
            if i + j < N:
                print(i, j)
                print(j, N - 1)

else:
    M = int(N * (N - 2) // 2)
    print(M)
    for i in range(N - 2):
        print(1, i + 2)
        print(i + 2, N)
    for i in range(2, int(N / 2) + 1):
        for j in range(i + 1, N):
            if i + j < N:
                print(i, j)
                print(j, N - 1)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_list_of_float():
    return [float(f) for f in input().split()]


def get_list_of_char():
    return list(input().strip())


def get_data(n, order=None, **kwargs):
    if not order:
        order = range(len(kwargs))
    it = iter(order)
    var, fn = zip(*sorted(sorted(kwargs.items()), key=lambda _: next(it)))

    rows = []
    for _ in range(n):
        rows.append(input().split())
    columns = zip(*rows)
    exec("global "+", ".join(var)+"\n"+"\n".join(
        v+"=list(map(fn[{}], data[{}]))".format(i, i)
        for i, v in enumerate(var)),
        globals(),
        {"fn": list(fn), "data": list(columns)}
    )
    return


# inputs
N = 0


def set_inputs():
    global N
    N = get_int()
    return


def find(n):
    bits = []
    for i in range(2**(n*(n-1)//2)):
        bits = [(i >> j) % 2 for j in range(n*(n-1)//2)]
        cnt = Counter()
        for j in range(1, n+1):
            cnt[j] = 0
        edges = []
        for x, y in itertools.compress(
                itertools.combinations(range(1, n+1), 2),
                bits
        ):
            cnt[x] += y
            cnt[y] += x
            edges.append((x, y))
        counts = list(cnt.values())
        if len(edges) > 0 and all(v == counts[0] for v in counts):
            print(i, bits, edges)


def solve(n):
    s = n
    if n % 2 == 0:
        s = n + 1
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if i + j == s:
                continue
            print(i, j)


def main():
    setrecursionlimit(100000)
    set_inputs()
    solve(N)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
group = []

ansanslist = [[0 for i in range(N)] for j in range(N)]
if N % 2 != 0:
    group.append([N])
N -= 1

for i in range(N // 2):
    group.append([i + 1, N - i])

if N % 2 != 0:
    group.append([N // 2 + 1])
anslist = []

for i in range(len(group)):
    for k in group[i]:
        for j in range(len(group)):
            for l in group[j]:
                anslist.append([k, l])

anslist.sort()
ansanslist = []
for i, j in anslist:
    if i < j:
        ansanslist.append([i, j])

print(len(ansanslist))
for i, j in ansanslist:
    print(i, j)

Submission status: Wrong Answer

Solution code:
N = int( input())

if N == 3:
    print(2)
    print(1,3)
    print(2,3)
else:
    s = N%2
    N = N//2*2
    ans = 0
    for i in range(2,N//2+1):
        ans += 4*i - 4
    if s == 0:
        print(ans)
    else:
        print(ans)
    print(1, N-1)
    print(1,2)
    print(2,N)
    print(N-1,N)
    for i in range(2,N//2):
        for j in range(1,i+1):
            print(j, i+1)
            print(j, N-i)
            print(N+1-j, i+1)
            print(N+1-j, N-i)
    if s == 1 and N != 2:
        for i in range(1,N+1):
            print(i, N+1)

Submission status: Wrong Answer

Solution code:
n = int(input())

if n%2==0:
    lis=[[i,n+1-i] for i in range(1,int(n/2)+1)]
else:
    lis=[[i,n-i] for i in range(1,int((n-1)/2)+1)] + [[n]]

connect_lis=[]

for i in lis:
    for j in i:
        for k in lis:
            if k!=i:
                for p in k:
                    if j < p:
                        connect_lis.append([j,p])
        

for i in connect_lis:
    print(i[0],i[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
if n%2 ==0:
  print(n*(n+1)//2-n-1)
else:
  print((n-1)*n//2)

if n%2 ==1:
  for i in range(n-1):
    print(i+1,n)
  n = n-1

if n%2 ==0:
  wa = n+1
  for i in range(n):
    for j in range(i+1,n):
      if wa != i+j+2:
        print(i+1,j+1)

Submission status: Wrong Answer

Solution code:
def solve():
  N = int(input())
  fmt = '{} {}'
  ans = []
  sub = []
  if N % 2 == 0:
    for i in range(2, N // 2 + 1):
      ans.append(fmt.format(1, i))
      ans.append(fmt.format(N, i))
      ans.append(fmt.format(1, N + 1 - i))
      ans.append(fmt.format(N, N + 1 - i))
      sub.append((i, N + 1 - i))
  else:
    for i in range(2, (N + 1) // 2):
      ans.append(fmt.format(1, i))
      ans.append(fmt.format(N - 1, i))
      ans.append(fmt.format(1, N - i))
      ans.append(fmt.format(N - 1, N - i))
      sub.append((i, N - i))
    ans.append(fmt.format(N, 1))
    ans.append(fmt.format(N, N - 1))

  for i in range(len(sub)):
    t = sub.pop(0)
    for r in sub:
      ans.append(fmt.format(t[0], r[0]))
      ans.append(fmt.format(t[0], r[1]))
      ans.append(fmt.format(t[1], r[0]))
      ans.append(fmt.format(t[1], r[1]))

  print(len(ans))
  for a in ans:
    print(a)

solve()

Submission status: Wrong Answer

Solution code:
n = int(input())

if n%2==0:
    lis=[[i,n+1-i] for i in range(1,int(n/2)+1)]
else:
    lis=[[i,n-i] for i in range(1,int((n-1)/2)+1)] + [[n]]

connect_lis=[]

for i in lis:
    for j in i:
        for k in lis:
            if k!=i:
                for p in k:
                    if j < p:
                        connect_lis.append([j,p])
        

for i in connect_lis:
    print(i[0],'',i[1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = int(input())

is_even = N % 2
li = [] if is_even == 0 else [[N]]
for i in range(N // 2):
    li.append([i + 1, N - i - is_even])

ans = []
for a in li:
    for b in li:
        if a == b:
            continue
        if len(a) == 1:
            continue
        elif len(b) == 1:
            ans.append([a[0], b[0]])
            ans.append([a[1], b[0]])
        else:
            ans.append([a[0], b[0]])
            ans.append([a[0], b[1]])

print(len(ans))
for x in ans:
    print(x[0], x[1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = int(input())

is_even = N % 2
li = [] if is_even == 0 else [[N]]
for i in range(N // 2):
    li.append([i + 1, N - i - is_even])

ans = []
for a in li:
    for b in li:
        if a == b:
            continue
        if len(a) == 1:
            continue
        elif len(b) == 1:
            ans.append([a[0], b[0]])
            ans.append([a[1], b[0]])
        else:
            ans.append([a[0], b[0]])
            ans.append([a[0], b[1]])
            ans.append([a[1], b[0]])
            ans.append([a[1], b[1]])

print(len(ans))
for x in ans:
    print(x[0], x[1])

Submission status: Wrong Answer

Solution code:
n=int(input())
if n%2==0:
    s=n+1
    res=[]
    for i in range(1,n//2+1):
        res.append([i,s-i])
    #print(res)
    for i in range(len(res)-1):
        for j in range(i+1,len(res)):
            for x in range(2):
                for y in range(2):
                    print(min(res[i][x],res[j][y]),max(res[i][x],res[j][y]))
else:
    s=n
    res=[]
    for i in range(1,n//2+1):
        res.append([i,s-i])
    #print(res)
    for i in range(len(res)-1):
        for j in range(i+1,len(res)):
            for x in range(2):
                for y in range(2):
                    print(min(res[i][x],res[j][y]),max(res[i][x],res[j][y]))
    for i in range(1,n):
        print(i,n)

Submission status: Wrong Answer

Solution code:
N = int( input())
if N == 3:
    print(1,3)
    print(2,3)
else:
    s = N%2
    N = N//2*2
    print(1, N-1)
    print(1,2)
    print(2,N)
    print(N-1,N)
    for i in range(2,N//2):
        for j in range(1,i+1):
            print(j, i+1)
            print(j, N-i)
            print(N+1-j, i+1)
            print(N+1-j, N-i)
    if s == 1 and N != 2:
        for i in range(1,N+1):
            print(i, N+1)

Submission status: Wrong Answer

Solution code:
#b
n = int(input())

pairs = []
if n % 2 == 0:
    for x in range(1, int(n/2) + 1):
        pairs.append([x, n-x + 1])
else:
    for x in range(1, int((n-1)/2) +1):
        pairs.append([x, int((n-1))-x+1])
    pairs.append([n])
# print(f'pairs >>>>> {pairs}')

# connect nodes
edges = []
for x in range(1, n+1):
    for p in pairs:
#         print(f'x: {x}, p: {p}')
        if x in p:
            break
        for node in p:
#             print(sorted([x, node]))
            edges.append(sorted([x, node]))

# print(f'edges >>>>> {edges}')
for e in edges:
    print(' '.join([str(i) for i in e]))

Submission status: Wrong Answer

Solution code:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
if n%2==0:
    print(n*(n-2)//2)
    for i in range(n):
        for j in range(n):
            if i<j and i+j+2!=1+n:
                print(i+1,j+1)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = int(input())

is_even = N % 2
li = [] if is_even == 0 else [[N]]
for i in range(N // 2):
    li.append([i + 1, N - i - is_even])

ans = []
for a in li:
    for b in li:
        if a == b:
            continue
        if len(a) == 1:
            continue
            # print(a[0], b[0])
            # print(a[0], b[1])
        elif len(b) == 1:
            ans.append([a[0], b[0]])
            ans.append([a[1], b[0]])
        else:
            ans.append([a[0], b[0]])
            ans.append([a[0], b[0]])
            ans.append([a[1], b[1]])
            ans.append([a[1], b[1]])

print(len(ans))
for x in ans:
    print(x[0], x[1])

Submission status: Wrong Answer

Solution code:
#b
# n = int(input())
n = 3

pairs = []
if n % 2 == 0:
    for x in range(1, int(n/2) + 1):
        pairs.append([x, n-x + 1])
else:
    for x in range(1, int((n-1)/2) +1):
        pairs.append([x, int((n-1))-x+1])
    pairs.append([n])
# print(f'pairs >>>>> {pairs}')

# connect nodes
edges = []
for x in range(1, n+1):
    for p in pairs:
#         print(f'x: {x}, p: {p}')
        if x in p:
            break
        for node in p:
#             print(sorted([x, node]))
            edges.append(sorted([x, node]))

# print(f'edges >>>>> {edges}')
for e in edges:
    print(' '.join([str(i) for i in e]))

Submission status: Wrong Answer

Solution code:
n=int(input())
if n%2==0:
    s=n+1
    res=[]
    for i in range(1,n//2+1):
        res.append([i,s-i])
    print(res)
    for i in range(len(res)-1):
        for j in range(i+1,len(res)):
            for x in range(2):
                for y in range(2):
                    print(res[i][x],res[j][y])
else:
    s=n
    res=[]
    for i in range(1,n//2+1):
        res.append([i,s-i])
    #print(res)
    for i in range(len(res)-1):
        for j in range(i+1,len(res)):
            for x in range(2):
                for y in range(2):
                    print(res[i][x],res[j][y])
    for i in range(1,n):
        print(i,n)

Submission status: Wrong Answer

Solution code:
def solve():
  N = int(input())
  sub = []
  if N % 2 == 0:
    for i in range(2, N // 2 + 1):
      print(1, i)
      print(N, i)
      print(1, N + 1 - i)
      print(N, N + 1 - i)
      sub.append((i, N + 1 - i))
  else:
    for i in range(2, (N + 1) // 2):
      print(1, i)
      print(N - 1, i)
      print(1, N - i)
      print(N - 1, N - i)
      sub.append((i, N - i))
    print(N, 1)
    print(N, N - 1)

  for i in range(len(sub)):
    t = sub.pop(0)
    for r in sub:
      print(t[0], r[0])
      print(t[0], r[1])
      print(t[1], r[0])
      print(t[1], r[1])

solve()

Submission status: Wrong Answer

Solution code:
N = int(input())
print(N-1)
for i in range(N,2,-1):
    print(1,i)
    print(i-1,i)

Submission status: Wrong Answer

Solution code:
n = int(input())
E = []
for i in range(n):
    for j in range(i+1,n):
        if i+j != (n-n%2)-1:
            E.append((i,j))
for a,b in E:
    print(a+1,b+1)

Submission status: Wrong Answer

Solution code:
#AGC031-B
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
if n%2==0:
    for i in range(n):
        for j in range(n):
            if i<j and i+j+2!=1+n:
                print(i+1,j+1)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())

if N % 2 == 0:
    S = 1 + N
else:
    S = N
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if i+j == S:
            continue
        print(i, j)

Submission status: Wrong Answer

Solution code:
N = int(input())

print(N-1)
for i in range(N-1):
    print(1, N-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
m=n if n&1 else n+1
i=1
while(i<=n):
    j=i+1
    while(j<=n):
        if j!=m-i:
            a+=[(i,j)]
        j+=1
    i+=1

for x in a:
    print(*x)

Submission status: Wrong Answer

Solution code:
n = int(input())
E = []
for i in range(n):
    for j in range(i+1,n):
        if i+j != n-1:
            E.append((i,j))
for a,b in E:
    print(a+1,b+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
group = []

if N % 2 != 0:
    group.append([N])
N -= 1

for i in range(N // 2):
    group.append([i + 1, N - i])

if N % 2 != 0:
    group.append([N // 2 + 1])
anslist = []

for i in range(len(group)):
    for j in range(i + 1, len(group)):
        for k in group[i]:
            for l in group[j]:
                anslist.append([k, l])


print(len(anslist))
for i in anslist:
    print(i[0], i[1])

Submission status: Wrong Answer

Solution code:
n = int(input())

if n%2:
    group = (n-1)//2
    m = (group-1)*2*2+(n-1)
else:
    group = n//2
    m = (group-1)*2*2

l = []
if n%2:
    for i in range(1,(n-1)//2+1):
        l.append((i,n-i))
    l.append((n,))
else:
    for i in range(1,n//2+1):
        l.append((i,n+1-i))

print(m)
for i in range(len(l)):
    for j in range(i+1,len(l)):
        p = l[i]
        o = l[j]
        for point in p:
            for other in o:
                print(str(point)+" "+str(other))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N=int(input())

EDGE=[[1]*(N+1) for i in range(N+1)]
for i in range(N+1):
    EDGE[i][i]=0
    EDGE[0][i]=EDGE[i][0]=0

SUM=[N*(N+1)//2]
for i in range(N):
    SUM.append(SUM[-1]-1)

SUM[0]=0

if N%2==0:
    ANSSUM=N*(N+1)//2-1-N
else:
    ANSSUM=N*(N+1)//2-1-(N-1)

#print(ANSSUM)

for i in range(1,N+1):
    x=SUM[i]-ANSSUM
    EDGE[i][x]=EDGE[x][i]=0

for i in range(1,N+1):
    for j in range(1,N+1):
        if EDGE[i][j]==1:
            print(i,j)
            EDGE[i][j]=EDGE[j][i]=0

Submission status: Wrong Answer

Solution code:
N=int(input())
if N ==3:
    print(2)
    print("1 3")
    print("2 3")
else:
    if N%2==0:
        print(N // 2 * 4)
        for i in range(1, N // 2):
            x = i
            y = N + 1 - x
            nx = x + 1
            ny = y - 1
            print(str(x) + ' ' + str(nx))
            print(str(x) + ' ' + str(ny))
            print(str(y) + ' ' + str(nx))
            print(str(y) + ' ' + str(ny))
        if N > 4:
            print(str(N) + ' ' + str(N//2))
            print(str(N) + ' ' + str(N//2 + 1))
            print(str(1) + ' ' + str(N//2))
            print(str(1) + ' ' + str(N//2 + 1))
    else:
        N -= 1
        print(N // 2 * 4)
        for i in range(1, N // 2):
            x = i
            y = N + 1 - x
            nx = x + 1
            ny = y - 1
            print(str(x) + ' ' + str(nx))
            print(str(x) + ' ' + str(ny))
            print(str(y) + ' ' + str(nx))
            print(str(y) + ' ' + str(ny))
        N += 1
        if N > 3:
            print(str(N) + ' ' + str(N//2))
            print(str(N) + ' ' + str(N//2 + 1))
            print(str(N) + ' ' + str(N - 1))
            print(str(N) + ' ' + str(1))

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []
for i in range(1,N):
    for j in range(i+1,N+1):
        ans.append([i,j])
if N % 2 == 1:
    i = 0
    while i < len(ans):
        if ans[i][0] + ans[i][1] == N:
            ans.pop(i)
        else:
            i += 1
    M = len(ans)
    print(M)
    for i in range(M):
        print(str(ans[i][0])+' '+str(ans[i][1]))
else:
    while i < len(ans):
        if ans[i][0] + ans[i][1] == N+1:
            ans.pop(i)
        else:
            i += 1
    M = len(ans)
    print(M)
    for i in range(M):
        print(str(ans[i][0])+' '+str(ans[i][1]))

Submission status: Wrong Answer

Solution code:
n= int(input())
s = n + (0 if n%2 == 1 else 1)
ans = []
for i in range(n-1):
  for j in range(i+1,n):
    if i+j+2 != s:
      ans.append(str(i+1)+" "+str(j+1))
for t in ans:
  print(t)

Submission status: Wrong Answer

Solution code:
from itertools import combinations, product
from collections import defaultdict

N = int(input())

edges = set()
if N % 2 == 0:
    for i in range(1, N + 1):
        for j in set(range(1, N + 1)) - set([i, N + 1 - i]):
            edges.add((i, j) if i <= j else (j, i))
else:
    for i in range(1, N):
        for j in set(range(1, N)) - set([i, N - i]):
            edges.add((i, j) if i <= j else (j, i))
        edges.add((i, N))
    for i in range(1, N):
        edges.add((i, N))

for i, j in edges:
    print(i, j)