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())
if(N%2 == 0):
    for i in range(1,N):
        for j in range(i+1,N+1):
            if(i+j != N+1):
                print(*[i,j])
else:
    for i in range(1,N):
        for j in range(i+1,N+1):
            if(i+j != N):
                print(*[i,j])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = []
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        if i + j == N:
            continue
        ans.append((i, j))
print(len(ans))
for x, y in ans:
    print(x, y)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    ans = []
    for i in range(1, n + 1):
        for j in range(i + 1, n + 1):
            if i == j or i + j == n + (n + 1) % 2:
                continue
            ans.append([i, j])
    if n % 2 and n > 3:
        for i in range(1, n):
            ans.append([i, n])
    print(len(ans))
    for a in ans:
        print(" ".join(map(str, a)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    # Nが偶数の場合、完全N//2-partiteグラフ
    # Nが奇数の場合、完全(N-1)//2-partiteグラフに全ての頂点と隣接している頂点Nを加えたもの
    ans = []

    def f(n):
        for i in range(1, n // 2 + 1):
            for j in range(1, n + 1):
                if j != i and j != n - i:
                    if j < i:
                        ans.append((j, i))
                    else:
                        ans.append((i, j))
                    if j < n - i:
                        ans.append((j, n - i))
                    else:
                        ans.append((n - i, j))

    if N % 2 == 0:
        f(N)
    else:
        if N >= 5:
            f(N - 1)
        for i in range(1, N):
            ans.append((i, N))

    ans = set(ans)
    print(len(ans))
    for i, j in ans:
        print(i, j)
        
if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
def agc032_b():
    n = int(input())
    A = [[n], []]

    t = 1
    for i in range(n-1, 0, -2):
        if i == 1: A[t] += [i]
        else: A[t] += [i, i-1]
        t = abs(t-1)

    odd = False
    if sum(A[0]) != sum(A[1]):
        odd = True
        if n % 2 == 1:
            if A[0][-1] == 1: A[1].append(1)
            else: A[0].append(1)
        else:
            if A[0][-1] == 1:
                A[0] = A[0][:-2] + [3,2,1]
                A[1] = A[1][:-2] + [4,1]
            else:
                A[0] = A[0][:-2] + [4,1]
                A[1] = A[1][:-2] + [3,2,1]

    #print(A[0], A[1])
    cnt = len(A[0]) * len(A[1])
    if odd: cnt -= 1
    print(cnt)
    for a in A[0]:
        for b in A[1]:
            if a == b: continue
            print('{} {}'.format(a, b))

if __name__ == '__main__':
    agc032_b()

Submission status: Wrong Answer

Solution code:
n=int(input())

#Sはn以上になる
#単純グラフのため、末端は一つとしか接続しない点がでてくる
#つまりsはn以下
#Sはnとしてよい

tree=[[] for _ in range(n)]

for i in range(n):
    for j in range(n):
        if i!=j:
            tree[i].append(j)

ans=[]
if n%2==0:
    for i in range(n):
        for item in tree[i]:
            if item+1!=n-i:
                ans.append([i+1,item+1])

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

print(len(ans[:len(ans)//2]))
for item in ans[:len(ans)//2]:
    print(item[0],item[1])

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline
graph = []
cnt = 0

N=int(input())
if N%2 == 0:
    
    for i in range(1,N):
        for j in range(i+1,N+1):
            if i+j == N+1:
                continue
            else:
                cnt+=1
                graph.append([i,j])
                
else:
    print(N*(N-1)//2)
    for i in range(1,N):
        for j in range(i+1,N+1):
            if i + j == N:
                continue
            else:
                cnt+=1
                graph.append([i,j])
print(cnt)
for gr in graph:
    print(*gr)

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline
graph = []
cnt = 0

N=int(input())
if N%2 == 0:
    
    for i in range(1,N):
        for j in range(i+1,N+1):
            if i+j == N+1:
                continue
            else:
                cnt+=1
                graph.append([i,j])
                
else:
    print(N*(N-1)//2)
    for i in range(1,N):
        for j in range(i+1,N+1):
            if i + j == N:
                continue
            else:
                cnt+=1
                graph.append([i,j])
for gr in graph:
    print(*gr)

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

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

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

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

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

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

Submission status: Wrong Answer

Solution code:
from itertools import combinations
N = int(input())

def main(N):
    # 合計になる2頂点のグループを作って、その塊でつないでいく
    group_cnt = -(-N//2)
    group_sum = N if N % 2 == 1 else N+1
    print((group_cnt - 1) * group_sum)
    edge = set()
    loop_num = group_cnt if N % 2 == 0 else group_cnt - 1
    for comb in combinations(range(1, loop_num+1), 2):
        for i in (comb[0], group_sum-comb[0]):
            for j in (comb[1], group_sum-comb[1]):
                edge.add((i, j))
    if N % 2 == 1:
        for i in range(1, N):
            edge.add((i, N))
    for e in edge:
        print(*e)

main(N)

Submission status: Wrong Answer

Solution code:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    table = [
        [1 for _ in range(N)] for _ in range(N)
    ]
    for i in range(N//2):
        table[i][N-i-1] = table[N-i-1][i] = 0
    size = 0
    answer = []
    for i in range(N):
        for j in range(i+1, N):
            if table[i][j]:
                answer.append((i+1, j+1))
                size += 1
    print(size)
    for a in answer:
        print(*a)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
ans=[]
for i in range(1,n):
    for j in range(i+1,n+1):
        if i+j==n:
            continue
        ans.append([i,j])
print(len(ans))
for i in range(len(ans)):
    print(*ans[i])

Submission status: Wrong Answer

Solution code:
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n = ni()

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def solve():
  N = int(input())
  ans = []
  if N%2==0:
    for i in range(1,N+1):
      for j in range(i+1,N+1):
        if i+j!=N+1:
          ans.append(' '.join([str(i),str(j)]))
  else:
    for i in range(1,N):
      for j in range(i+1,N):
        if i+j!=N:
          ans.append(' '.join([str(i),str(j)]))
    for i in range(1,N):
      ans.append(' '.join([str(N),str(i)]))
  return ans
print(*solve(),sep='\n')

Submission status: Wrong Answer

Solution code:
import sys
from itertools import product

input = sys.stdin.readline


def main():
    N = int(input())

    ans = []
    if N % 2 == 0:
        groups = [(1 + i, N - i) for i in range(N // 2)]
    else:
        groups = [(1 + i, N - 1 - i) for i in range((N - 1) // 2)] + [(N,)]

    for i in range(len(groups) - 1):
        group_a = groups[i]
        group_b = groups[i + 1]
        for a, b in product(group_a, group_b):
            ans.append(f"{a} {b}")

    if len(groups) >= 3:
        group_a = groups[0]
        group_b = groups[-1]
        for a, b in product(group_a, group_b):
            ans.append(f"{a} {b}")

    print("\n".join(ans))


if __name__ == "__main__":
    main()

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, log2
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:
	S = N*(N+1)//2 - N
else:
	S = N*(N+1)//2 - N - 1

ans = []
for i, j in combinations(range(1, N+1), 2):
	if j == S-i:
		continue
	ans.append((i, j))

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = N
if N % 2 == 0:
    S += 1
    
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:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()

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

    print('\n'.join(map(lambda a: '{} {}'.format(a[0], a[1]), ans)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N = I()
count = 0
print(nCr(N,2)-N//2)
for i in range(1,N+1):
  for j in range(1,N+1):
    if i+j != N+1 and i<j:
      print(i,j)

Submission status: Wrong Answer

Solution code:
n = int(input())
r = []
for i in range(1, n+1):
    for j in range(i+1, n+1):
        if n-i == j:
            continue
        else:
            r.append([i, j])
print(len(r))
for i in r:
    print(*i)

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-i == j:
            continue
        else:
            print(i, j)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = n % 2

for i in range(1,n+1):
    for j in range(i+1,n+1):
        if x == 0:
            if i == n+1-j:
                continue
            print(i,j)
        else:
            if i == (n-j):
                continue
            print(i,j)

Submission status: Wrong Answer

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

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, n):
            if j != n + 1 - i and j != i:
                print(i, j)
else:
    for i in range(1, n+1):
        for j in range(1, n+1):
            if j != n - i and i != j:
                print(i, j)

Submission status: Wrong Answer

Solution code:
n = int(input())

for i in range(n-1):
    print(i+1, n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = set()
for i in range(1, N+1):
  for j in range(i+1, N+1):
    ans.add((i, j))

if N % 2 == 1: # 奇数
  num = N*(N+1)//2 - N
  for i in range(1, N+1):
    j = N - i
    ans.discard((i, j))
else: # 偶数
  num = N*(N+1)//2 - (N+1)
  for i in range(1, N+1):
    j = N + 1 - i
    ans.discard((i, j))

print(num)
for a in ans:
  print(*a)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    edges = []
    M = N*(N-1)//2 - N//2
    
    if N%2 == 1:
        for i in range(1, N):
            for j in range(i+1, N+1):
                if i + j != N:
                    edges.append((i, j))
    else:
        for i in range(1, N):
            for j in range(i, N+1):
                if i + j != N + 1:
                    edges.append((i, j))
    print(M)
    for a, b in edges:
        print(a, b)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  print(n-1)
  for i in range(1,n):
    print(i,n)

main()
# print(main())

Submission status: Wrong Answer

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

for i in range(1, n+1):
    for j in range(i+1, n+1):
        if i+j == k:
            continue
        print(*[i, j])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
S=[]
for i in range(1,N):
 for j in range(i+1,N+1):
  S.append([i,j])
if N%2==1:
 for i in range(1,N//2+1):
  S.remove([i,N-i])
else:
 for i in range(1,N//2+1):
  S.remove([i,N+1-i])
for j in S:
 print(*j)

Submission status: Wrong Answer

Solution code:
n = int(input())

if n % 2 == 0:
    pairs = [(i, n+1-i) for i in range(1, n//2+1)]
    x = len(pairs)
    if n == 4:
        print(4 * (x - 1))
        for i in range(2):
            for j in range(2):
                print(pairs[0][i], pairs[1][j])
    else:
        print(4 * x)
        for k in range(n//2):
            for i in range(2):
                for j in range(2):
                    print(pairs[i%x][i], pairs[(i+1)%x][j])

else:
    pairs = [(i, n-i) for i in range(1, n//2+1)]
    x = len(pairs)
    if n == 3:
        print(2)
        print(1, 3)
        print(2, 3)
    else:
        print(4 * x)
        for k in range(n//2-1):
            for i in range(2):
                for j in range(2):
                    print(pairs[i % x][i], pairs[(i + 1) % x][j])
        print(n, pairs[0][0])
        print(n, pairs[0][1])
        print(n, pairs[-1][0])
        print(n, pairs[-1][1])

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 i+j!=n+1:
                print(i,j)
else:
    for i in range(1,n):
        for j in range(i+1,n+1):
            if i+j!=n:
                print(i,j)

Submission status: Wrong Answer

Solution code:
n = int(input())

sm = n*(n+1)//2
if n == 3:
  print(2)
  print(1, 3)
  print(2, 3)
elif n == 4:
  print(4)
  print(1, 2)
  print(1, 3)
  print(2, 4)
  print(3, 4)
elif n % 2:
  m = (n-1)//2
  print(m*2+4)
  a = [[i, n-i-2] for i in range(m)]
  for i in range(m-1):
    for j in range(2):
      for k in range(2):
        print(a[i][j]+1, a[i+1][k]+1)
  for i in range(2):
    print(a[m-1][i]+1, n)
    print(n, a[0][i]+1)
else:
  print(n*2)
  a = [[i, n-i-1] for i in range(n//2)]
  for i in range(n//2):
    for j in range(2):
      for k in range(2):
        print(a[i][j]+1, a[(i+1)%(n//2)][k]+1)

Submission status: Wrong Answer

Solution code:
n = int(input())

g = [[1] * (n + 1) for _ in range(n + 1)]

if n % 2:
    for i in range(1, n + 1):
        j = n - i
        g[i][j] = 0
        g[j][i] = 0

else:
    for i in range(1, n + 1):
        j = n + 1 - i
        g[i][j] = 0
        g[j][i] = 0

for i, row in enumerate(g[1:], 1):
    for j, bl in enumerate(row[i+1:], i+1):
        if bl:
            print(i, j)

Submission status: Wrong Answer

Solution code:
#AGC032-B Balanced Neighbors
"""
まずnが偶数の場合を考える。
1...nの数列を考えた時に、
1+n,2+n-1,3+n-2…を１頂点として考えると、全てその値が等しいグラフになる。
次に奇数の場合を考える。
n-1までのグラフを偶数の場合と同じように構築した後、
nはn-1までの2頂点の合計と等しい値になる。
よって、最後に全頂点をnとつなぎ合わせると条件を満たすグラフに成る。
"""
import sys
from collections import defaultdict
dic1 = defaultdict(int)
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n = int(readline())
mid = 1+(n//2)*2
for i in range(1,(n//2)*2+1):
    dic1[i] = mid-i
for i in range(1,(n//2)*2):
    res = dic1[i]
    for j in range(i+1,(n//2)*2+1):
        if j == res:
            continue
        print(i,j)

if not even(n):
    for i in range(1,n):
        print(n,i)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    print(n*(n-1)//2-n//2)
    if n%2==0:
        for i in range(1,n//2+1):
            for j in  range(i+1,n+1):
                if j==n-i+1:continue
                print(i,j)
    else:
        for i in range(1,n):
            for j in  range(i+1,n+1):
                if i%2==1 and j==i+1:continue
                print(i,j)        

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
from itertools import groupby, accumulate, product, permutations, combinations
def solve(N):
    pairs = []
    if N%2==1: #和がN
        total = N
        pairs.append([N])
    else: #和がN+1
        total = N+1
    for i in range(1,(total+1)//2):
        pairs.append([i,total-i])
    print((len(pairs)-1)*N)
    for pair1, pair2 in combinations(pairs,2):
        for i in pair1:
            for j in pair2:
                print(i,j)
    return
solve(N)

Submission status: Wrong Answer

Solution code:
N = int(input())

def solve_m(N):
    if N==3:
        return 2
    ans = 4
    for i in range(4,N):
        ans += i
    return ans

def solve_edge(N):
    print(1,3)
    if N==3:
        print(2,3)
        return
    print(1,2)
    print(2,4)
    print(3,4)
    if N==4:
        return
    for i in range(5,N+1):
        for j in range(1,i):
            print(i,j)
    return

print(solve_m(N))
solve_edge(N)

Submission status: Wrong Answer

Solution code:
N = int(input())

def solve_m(N):
    if N==3:
        return 2
    ans = 4
    for i in range(4,N):
        ans += i
    return ans

def solve_edge(N):
    print(1,3)
    print(2,3)
    if N==3:
        return
    print(2,4)
    print(3,4)
    if N==4:
        return
    for i in range(5,N+1):
        for j in range(1,i):
            print(i,j)
    return

print(solve_m(N))
solve_edge(N)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
print(n*(n-1)//2-n//2)

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

Submission status: Wrong Answer

Solution code:
N = input()
print(2)
print("1 3")
print("2 3")

Submission status: Wrong Answer

Solution code:
n = int(input())

x = n//2 +1
print(n-1)
for i in range(1, x):
    print(i, x)
    print(n-i+1, x)

Submission status: Wrong Answer

Solution code:
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    if N % 2 == 1:
        for i in range(1, N):
            print(N, i)
        for j in range(1, N):
            for k in range(j + 1, N):
                if j + k == N:
                    continue
                else:
                    print(j, k)
    else:
        for i in range(2, N):
            print(N, i)
            print(1, i)
        for j in range(2, N):
            for k in range(j + 1, N):
                if j + k == N + 1:
                    continue
                else:
                    print(j, k)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
no_group = []
if n % 2 ==0:
  for  i in range(1,n//2+1):
    no_group.append([i,n-i+1])
else:
  for i in range(1,n//2+1):
    no_group.append([i,n-i])
  no_group.append([n])
  
sub_list = [[0 for i in range(n)] for i in range(n)]
for g in no_group:
  if len(g) == 2:
    sub_list[g[0]-1][g[1]-1] = 1
    sub_list[g[1]-1][g[0]-1] = 1

for i in range(n):
  for j in range(i,n):
    if i != j and sub_list[i][j] == 0:
      print(i+1,j+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
es = []
if n%2==0:
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            if j!=n+1-i:
                es.append((i, j))
else:
    for i in range(1, n):
        for j in range(i+1, n):
            if j!=n-i:
                print(i, j)
    for i in range(1, n):
        es.append((i, n))
print(len(es))
for i,j in es:
    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(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):
            if j!=n-i:
                print(i, j)
    for i in range(1, n):
        print(i, n)

Submission status: Wrong Answer

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