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())
m = 0
s = (n-1)*n//2

g = [[] for _ in range(n)]
for i in range(n):
    j = i+1
    if j != n:
        k = n-j
        #print(j, k)
        for a in range(1, n+1):
            if a == j or a == k:
                continue
            else:
                if a > j:
                    g[i].append(a-1)
    #else:
        #for a in range(1, n):
            #g[i].append(a-1)
#print(g)
cnt = 0
edge = []
for v in range(n):
    cnt += len(g[v])
    for u in g[v]:
        edge.append((v+1, u+1))
print(cnt)
for v, u in edge:
    print(v, u)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    ans = []
    tmp = [i for i in range(2, n + 1) if i != n - (n & 1)]
    l = 0
    r = n - 3 - (n & 1)
    for i in range(n // 2):
        ans.append(tmp[::1])
        tmp[l] -= 1
        tmp[r] += 1
        l += 1
        r -= 1
    ans += ans[::-1]
    for i in range(1, n):
        for t in ans[i - 1]:
            if i < t:
                print(i, t)




    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from itertools import combinations as comb

N = int(input())
n = N-1 if N%2 else N
s = set()

for i in range(1, N+1):
    if N%2:
        a, b = i, N-i
    else:
        a, b = i, N-i+1
    if a<b:
        s.add((a, b))

for i in comb(range(1, N+1), 2):
    if not i in s:
        print(*i)

Submission status: Wrong Answer

Solution code:
n = int(input())
edges = int(n*(n-1)/2)
print(edges)
for i in range(1, n):
    for j in range(i+1, n+1):
        print(str(i) + ' ' + str(j))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

if N%2 == 0:
	print(N*(N-2)//2)
	for i, j in combinations(range(1, N+1), 2):
		if i+j == N+1:
			continue
		print(i, j)

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    if n % 2 == 0:
        ans = []
        for i in range(1, n//2):
            ans.append([i, i+1])
            ans.append([i, n-i])
            ans.append([n-i+1, i+1])
            ans.append([n-i+1, n-1])
        if n >= 6:
            ans.append([1, n//2])
            ans.append([1, n//2+1])
            ans.append([n, n//2])
            ans.append([n, n//2+1])
        print(len(ans))
        for p, q in ans:
            print(p, q)
    else:
        ans = []
        n -= 1
        for i in range(1, n//2):
            ans.append([i, i+1])
            ans.append([i, n-i])
            ans.append([n-i+1, i+1])
            ans.append([n-i+1, n-1])
        ans.append([1, n+1])
        ans.append([n, n+1])
        if n >= 4:
            ans.append([n//2, n+1])
            ans.append([n//2+1, n+1])
        print(len(ans))
        for p, q in ans:
            print(p, q)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    if n % 2 == 0:
        ans = []
        for i in range(1, n//2):
            ans.append([i, i+1])
            ans.append([i, n-i])
            ans.append([n-i+1, i+1])
            ans.append([n-i+1, n-1])
        print(len(ans))
        for p, q in ans:
            print(p, q)
    else:
        ans = []
        n -= 1
        for i in range(1, n//2):
            ans.append([i, i+1])
            ans.append([i, n-i])
            ans.append([n-i+1, i+1])
            ans.append([n-i+1, n-1])
        ans.append([1, n+1])
        ans.append([n, n+1])
        if n >= 4:
            ans.append([n//2, n+1])
            ans.append([n//2+1, n+1])
        print(len(ans))
        for p, q in ans:
            print(p, q)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
B=[]
if N%2==0:
  for i in range(1,N):
    for j in range(i+1,N+1):
      A.append((i,j))
  for i in range(N//2):
    B.append((i+1,N-i))
  D=set(A)-set(B)
  for a,b in D:
    print(a,b)
else:
  for i in range(1,N):
    for j in range(i+1,N+1):
      A.append((i,j))
  for i in range(N//2):
    B.append((i+1,N-i-1))
  D=set(A)-set(B)
  for a,b in D:
    print(a,b)

Submission status: Wrong Answer

Solution code:
N = int(input())
edges = []
for i in range(1, N // 2 + 1):
    j = N - i + 1
    for k in range(1, N+1):
        if k == i or k == j:
            continue
        if i < k:
            edges.append((i, k))
        if j < k:
            edges.append((j, k))
if N % 2 == 1:
    i = N // 2 + 1
    for k in range(i+1, N+1):
        edges.append((i, k))
print(len(edges))
for a, b in edges:
    print(a, b)

Submission status: Wrong Answer

Solution code:
n = int(input())

print( n*(n+1)//2 - n//2)

com = []

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

for i in range(len(com) - 1):
    for j in com[i]:
        for k in com[i+1 : ]:
            for l in k:
                print('{} {}'.format(j,l))

Submission status: Wrong Answer

Solution code:
n = int(input())

print( n*(n+1)//2 - n/2)

com = []

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

for i in range(len(com) - 1):
    for j in com[i]:
        for k in com[i+1 : ]:
            for l in k:
                print('{} {}'.format(j,l))

Submission status: Wrong Answer

Solution code:
N = int(input())

print(N*(N-1)//2-N//2)
for i in range(1, N):
    for j in range(i+1, N+1):
        if i == N-j:
            continue
        print(i, j)

Submission status: Wrong Answer

Solution code:
N = int(input())

# 全結合netから一部を消すとうまくいく
# N:evenだと 1,2,3,4,5,6 なら、(1,6)(2,5)などのペアを消す
# N:odd だと 1,2,3,4,5 なら5を残して、(1,4)(2,3)のペアを消す

S = set()
for i in range(1,N):
  for j in range(i+1,N+1):
    S.add((i,j))
    
#print(S)
if N%2 == 0:
  for i in range(1,N+1):
    if i >= N-i+1:
      break
    S.remove((i,N-i+1))
    #print(i,N-i+1)
else:
  for i in range(1,N):
    if i >= N-i+1:
      break
    S.remove((i,N-i+1))
    #print(i,N-i+1)
print(len(S))
for item in S:
  print(" ".join(list(map(str, item))))

Submission status: Wrong Answer

Solution code:
import sys
bbn=1000000007
	
#+++++

def mk_path(a_i, max_n, ret):
	#a_i = 1 ... max_n
	#7 => 7,(6,1),(5,2),(4,3)
	#8 => (8,1),(7,2),(6,3),(5,4)
	off=0 if max_n % 2 == 1 else 1
	
	for i in range(a_i+1, max_n+1):
		if i == max_n - a_i + off:
			continue
		else:
			ret.append((a_i, i))
			
	return 
	
def check_constraint(graph, n):
	cc=[0]*n
	for f,t in graph:
		cc[f-1] += t
		cc[t-1] += f
	
	pa(('max:',max(cc),', min:', min(cc) ))
	return
	
		
def main():
	n = int(input())
	ret=[]
	for i in range(1,n+1):
		mk_path(i,n,ret)
	
	#check_constraint(ret, n)
	for f,t in ret:
		pass
		print(f,t)

	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

answer = []
for i in range(1, N + 1):
  for j in range(i + 1, N + 1):
    if i + j != N + 1:
      answer.append((i, j))

print(len(answer))
for a in answer:
  print(*a)

Submission status: Wrong Answer

Solution code:
N = int(input())

answer = []
for i in range(1, N + 1):
  for j in range(i + 1, N + 1):
    if i + j != N + 2:
      answer.append((i, j))

print(len(answer))
for a in answer:
  print(*a)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
answer_set = set()
for i in range(1, N):
    for j in range(i+1, N+1):
        if i+j == N:
            continue
        else:
            answer_set.add((i, j))

print(len(answer_set))
for x in answer_set:
    print(*x)

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
answer_set = set()
for i in range(1, N):
    for j in range(i+1, N+1):
        if i+j == N:
            continue
        else:
            answer_set.add((i, j))

print(len(answer_set))
for x in answer_set:
    print(*x)

Submission status: Wrong Answer

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


def main():
    n = int(input())
    ans = []
    s = n * (n-1) // 2 - n - 1
    if n & 1:
        s += 1
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if i + j != n:
                ans.append((i, j))
    print(len(ans))
    for i, j in ans:
        print(i, j)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())

pairs = [[i for i in range(1, n + 1)] for _ in range(n)]

ans = []
if n % 2 == 0:
    for i in range(n-1):
        for j in range(i + 1, n):
            x = pairs[i][j]
            if x == i + 1 or x == n - i:
                continue
            ans.append((i + 1, x))
else:
    for i in range(n-1):
        for j in range(i + 1, n):
            x = pairs[i][j]
            if x == i + 1:
                continue
            if i != n - 1 and x == n - i:
                continue
            ans.append((i + 1, x))

print(len(ans))
for x, y in ans:
    print(x, y)

Submission status: Wrong Answer

Solution code:
n=int(input())
m=n//2*2
ans=[]
for i in range(1,m//2):
  for j in range(1+i,m-i+1):
    ans.append((i,j))
    ans.append((n+1-j,n+1-i))
if n%2:
  for i in range(1,n):
    ans.append((i,n))
print(len(ans))
for i in ans:
  print(*i,sep=" ")

Submission status: Wrong Answer

Solution code:
n=int(input())
m=n//2*2
ans=[]
for i in range(1,m//2):
  for j in range(1+i,m-i+1):
    ans.append((i,j))
    ans.append((n-j,n-i))
if n%2:
  for i in range(1,n):
    ans.append((i,n))
print(len(ans))
for i in ans:
  print(*i,sep=" ")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

if n % 2 == 0:
    # 1 <-> n, 2 <-> n-1... is Pair
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if i + j != n + 1:
                print(str(i) + " " + str(j))
else:
    # Each edge has (sum - N)
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if i + j != n:
                print(str(i) + " " + str(j))

Submission status: Wrong Answer

Solution code:
N = int(input())

ret = []
for i in range(1, N + 1) :
    for j in range(i + 1, N + 1) :
        if N % 2 == 0 and i + j == N + 1 :
            continue
        if N % 2 == 1 and i + j == N :
            continue
        ret.append((i, j))
        
for r in ret :
    print(*r)

Submission status: Wrong Answer

Solution code:
n = int(input())

ans = []
if n % 2:
    for i in range(1, n):
        for j in range(1, n + 1):
            if i + j != n and i != j:
                ans.append((i, j))
else:
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if i + j != n + 1 and i != j:
                ans.append((i, j))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

if N % 2:
    s = N
else:
    s = 1 + N

for i in range(1, N):
    for j in range(i + 1, N + 1):
        if i + j == s:
            continue
        print(i, j)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
t = []
res = set()
for i in range(1, N // 2 + 1):
  if N % 2:
    t.append((i, N - i))
  else: t.append((i, N - i + 1))
for i in range(1, N):
  for x in t:
    if i in x: continue
    res.add(tuple(sorted((i, x[0]))))
    res.add(tuple(sorted((i, x[1]))))
if N % 2:
  for i in range(1, N):
    res.add((i, N))
print(len(res))
for r in res:
  print(r)

Submission status: Wrong Answer

Solution code:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
s = sum(range(N + 1))

group_cnt = 2
while s * (group_cnt - 1) % group_cnt != 0:
    group_cnt += 1

groups = [set() for _ in range(group_cnt)]
sums = [[0, i] for i in range(group_cnt)]

for n in reversed(range(1, N + 1)):
    for i, (_, v) in enumerate(sums[1:], start=1):
        sums[i][0] -= n
        groups[v].add(n)
    sums.sort()

ans = set()
for group in groups:
    for v in set(range(1, N + 1)) - group:
        for u in group:
            ans.add((min(v, u), max(v, u)))

print(len(ans))
for r in ans:
    print(*r)

Submission status: Wrong Answer

Solution code:
n=int(input())
if n%2==0:
  m=(n**2-2*n)//2
  print(m)
  for i in range(1,n+1):
    for j in range(i,n+1):
      if j == i or j== n+1-i:continue
      print(i,j)
else:
  m=n+((n-1)**2-(n-1)*2)//2
  print(m)
  for i in range(1,n):
    for j in range(i+1,n+1):
      if j == n-i: continue
      print(i,j)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
if n%2==1:
    ans=[]
    for i in range(1,n+1):
        for j in range(1,n+1):
            if i<j:
                if not i+j==3:
                    ans.append([i,j])
    print(len(ans))
    for i in ans:
        print(i[0],i[1])

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    if n==3:
        print(2)
        print(1,3)
        print(2,3)
    elif n%2==0:
        print(((n+1)*(n-2))//2)
        for i in range(1,n+1):
            for j in range(i+1,n+1):
                if i+j!=n+1:
                    print(i,j)
    else:
        n-=1
        print(((n+1)*(n-2))//2+n+1)
        for i in range(1,n+1):
            for j in range(i+1,n+1):
                if i+j!=n+1:
                    print(i,j)
        for i in range(1,n+1):
            print(i,n+1)
main()

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
tmp=(n+1)//2*(n-2)
# print(tmp)
if n%2==0:
    print(n*(n-2)//2)
else:
    print(((n-1)*(n-2))//2)
for i in range(n):
    for j in range(i+1,n):
        if (i+1)+(j+1)!=n+(n+1)%2:
            print(i+1,j+1)

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
tmp=(n+1)//2*(n-2)
print(tmp)
for i in range(n):
    for j in range(i+1,n):
        if (i+1)+(j+1)!=n+(n+1)%2:
            print(i+1,j+1)

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
tmp=(n+1)//2*(n-2)
print(tmp)
for i in range(n):
    for j in range(i+1,n):
        if (i+1)+(j+1)!=n+(n+1)%2:
            print(str(i+1)+" "+str(j+1))

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
tmp=(n+1)//2*(n-2)
print(tmp)
for i in range(n):
    for j in range(i+1,n):
        if (i+1)+(j+1)!=n+1:
            print(str(i+1)+" "+str(j+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
M = (N * (N - 1)) // 2

ans_lst = [[1] * N for _ in range(N)]

if N % 2 == 0:
    for i in range(N):
        ans_lst[i][N - i - 1] = 0
else:
    for i in range(N - 1):
        ans_lst[i][N - i -2] = 0
#output
M = 0
for i in range(N):
    for j in range(1, N):
        if ans_lst[i][j] == 1:
            M += 1

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

Submission status: Wrong Answer

Solution code:
N = int(input())

M = N - 1 if N % 2 == 1 else N

A = []
for i in range(1, N + 1):
    for j in range(1, N + 1):
        if i < j and j != M:
            A.append((i, j))

print(len(A))
for a in A:
    print(*a)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

else:
    for i in range(1,n):
        for j in range(1,i):
            if j + i != n:
                print(i,j)

Submission status: Wrong Answer

Solution code:
n=int(input())
if n==3:
    print(2)
    print(1,3)
    print(2,3)
    exit()
elif n==4:
    print(4)
    print(1,2)
    print(1,3)
    print(2,4)
    print(3,4)

Submission status: Wrong Answer

Solution code:
N = int(input())

for u in range(1, N) :
    for v in range(u+1, N+1) :
        if u + v == N + (N % 2 != 1) :
            continue
        else :
            print(u, v)

Submission status: Wrong Answer

Solution code:
# 考察が甘い

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


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

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = [[j for j in range(i+1,N)]for i in range(N)]
for i in range(N):
    if len(ans[i]) >= N%2+i+1:
        ans[i][-(N%2+i+1)] = -1
        
for i in range(N):
    for j in ans[i]:
        if j >= 0:
            print(i+1,j+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def main():
    N = int(input())
    if N == 3:
        print(1,3)
        print(2,3)
    elif N == 4:
        print(1,2)
        print(1,3)
        print(4,2)
        print(4,3)
    else:
        if N%2 == 0:
            for i in range(N//2-1):
                print(i+1,i+2)
                print(i+1,N-i-1)
                print(N-i,i+2)
                print(N-i,N-i-1)
            for i in range(2):
                print(N//2+i,1)
                print(N//2+i,N)
        else:
            for i in range(N//2-1):
                print(i+1,i+2)
                print(i+1,N-i-2)
                print(N-i-1,i+2)
                print(N-i-1,N-i-2)
            print(N//2,N)
            print(N//2+1,N)
            print(N,1)
            print(N,N-1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

M = N * (N - 1) // 2
for S in range(N, M+1):
    A = [[0] * N for _ in range(N)]
    E = 0
    for i in range(N):
        s = S - sum(A[i])
        if s < 0:
            break
        for j in reversed(range(i+1,N)):
            if s - i - 1 > j + 1 or s == j + 1:
                E += 1
                A[i][j] = j + 1
                A[j][i] = i + 1
                s -= j + 1
            if s == 0:
                break
        else:
            continue
    else:
        print(E)
        for i in range(N):
            for j in range(i+1,N):
                if A[i][j] > 0:
                    print(i+1, j+1)
        break

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []
if N % 2 == 0:
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            if j <= i or i + j == N + 1:
                continue
            ans.append((i, j))
else:
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            if j <= i or i + j == N:
                continue
            ans.append((i, j))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
flag=0
if n%2==0:flag=1
for i in range(1,n):
    for j in range(i+1,n+1):
        if i+j!=n+flag:print(i,j)

Submission status: Wrong Answer

Solution code:
"""
234 23
134 14
124 14
123 23
"""
import copy
N = 100
initial = [list(range(1, N + 1)) for i in range(N)]

for i in range(N):
    initial[i].pop(i)
# print(initial)
neighbors = copy.deepcopy(initial)

S = sum(neighbors[-1])  # S候補の最大値

while True:
    # print(S)
    # print(neighbors)
    for i, tyouten in enumerate(neighbors):
        delta = sum(tyouten) - S
        # print(delta)
        if delta in tyouten:
            tyouten.remove(delta)
            neighbors[delta - 1].remove(i + 1)
        elif delta == 0:
            continue
        else:
            S -= 1
            neighbors = copy.deepcopy(initial)
            break
    else:
        break

# print(neighbors)

ans = []
for i, tyouten in enumerate(neighbors):
    for j in tyouten:
        if j > i+1:
            ans.append(str(i+1)+" "+str(j))

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=set()
for i in range(1,n+1):
    if n%2==0:
        s.add((i,n-i))
    else:
        s.add((i,n+1-i))
m=len(s)
print(n*(n-1)//2-m)
for i in range(1,n+1):
    for j in range(i+1,n+1):
        if (i,j) in s:
            pass
        else:
            print(i,j)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = 0
for i in range(1, N):
  for j in range(i + 1, N + 1):
    if i + j + (N % 2) != N + 1:
      s+=i
print(s)
for i in range(1, N):
  for j in range(i + 1, N + 1):
    if i + j + (N % 2) != N + 1:
      print(i, j)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = 0
for i in range(1, N):
  for j in range(i + 1, N + 1):
    if i + j + (N % 2) != N + 1:
      s+=i
print(s)
for i in range(1, N):
  for j in range(i + 1, N + 1):
    if i + j + (N % 2) != N + 1:
      print(i, j)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

Submission status: Wrong Answer

Solution code:
def graph(n):
	if n == 3:
		print(1, 3)
		print(2, 3)
	elif n == 4:
		print(1, 2)
		print(1, 4)
		print(3, 4)
	else:
		print(1, n)
		print(n - 1, n)
		graph(n - 2)

N = int(input())
print(N - 1)  # グラフの本数M
graph(N)

Submission status: Wrong Answer

Solution code:
n = int(input())

ans = []
if n & 1 == 1:
    for i in range(n):
        if i + 1 != n:
            ans.append((i+1, n))
    n -= 1

for i in range(n):
    for j in range(1, n+1):
        if j != n - i and j != i + 1:
            ans.append((i+1, n))

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

Submission status: Wrong Answer

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

# 1. make validate graph fragment (all index are includede completely)
fragments = []
if n % 2 == 0:
    # even case: (1, n), (2, n-1), ..., (n//2, n//2+1)
    fragments = [(i + 1, n - i) for i in range(n // 2)]
else:
    # odd case: (1, n-1), (2, n-2), ..., (n//2-1, n//2+1), (n)
    fragments = [(i + 1, n - i - 1) for i in range(n // 2)]
    fragments.append((n,))

# 2. each vertex connect all vertex excepy for one's belonging graph's element
edges = []
for i, frag in enumerate(fragments):
    for vtx in frag:
        other_frags = fragments[:i] + fragments[i + 1:]
        edges.extend([(vtx, o_vtx) for o_frag in other_frags for o_vtx in o_frag])

# 3. delete duplicated edge (remain (a, b) edge for a < b)
for edge in edges:
    if edge[0] > edge[1]:
        del edge


print(len(edges))
for edge in edges:
    print(' '.join(str(i) for i in edge))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = []

if n % 2 == 0:
    temp = n + 1
else:
    temp = n

for i in range(1, n):
    for j in range(i+1, n+1):
        if i + 1 != temp:
            ans.append((i, j))

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

from itertools import combinations

def main():
    n = int(input())
    base = list(range(1, n + 2))
    if n % 2 == 0:
        numbers = [[base[i], base[n-1-i]] for i in range(n // 2)]
    else:
        numbers = [[n]]
        for i in range(n //2):
            numbers.append([base[i], base[n-2-i]])

    for first, second in combinations(numbers, 2):
        for fv in first:
            for sv in second:
                print(fv, sv)


if __name__ == '__main__':
    main()