Problem:
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.

Incorrect submission (verdict: Wrong Answer):
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):

#                 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):

#                         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


#                     adds[z-1] += 3



#                 if adds[4]+6 == adds[5]+5:
#                     # print("adds5&6"+ptn_str1+"/"+ptn_str2+"/"+ptn_str3+"/"+ptn_str4)
#                     adds[4] += 6
#                     adds[5] += 5


#                     equal = True
#                     for s in adds:

#                             equal = False
#                             break
#                     if equal is True:
#                         print(eq)
#                         print(ptn_str1)
#                         print(ptn_str2)
#                         print(ptn_str3)
#                         print(ptn_str4)



Fixed, accepted submission:
n = int(input())

if n == 3:
    print("2")
    print("1 3")
    print("2 3")
if n == 4:
    print("4")
    print("1 2")
    print("1 3")
    print("2 4")
    print("3 4")
if n >= 5:
    ans = []
    if n % 2 == 0:
        for i in range(1, n):
            for j in range(i+1, n+1):
                if i + j != n+1:
                    ans.append(str(i)+" "+str(j))
                    # 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:
                    ans.append(str(i)+" "+str(j))
                    # print(str(i)+" "+str(j))
        for i in range(1, n):
            ans.append(str(i)+" "+str(n))
            # print(str(i)+" "+str(n))
    ans_len = len(ans)
    print(ans_len)
    for a in ans:
        print(a)

# 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):

#                 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):

#                         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


#                     adds[z-1] += 3



#                 if adds[4]+6 == adds[5]+5:
#                     # print("adds5&6"+ptn_str1+"/"+ptn_str2+"/"+ptn_str3+"/"+ptn_str4)
#                     adds[4] += 6
#                     adds[5] += 5


#                     equal = True
#                     for s in adds:

#                             equal = False
#                             break
#                     if equal is True:
#                         print(eq)
#                         print(ptn_str1)
#                         print(ptn_str2)
#                         print(ptn_str3)
#                         print(ptn_str4)