TnT/CodeNet4Repair huggingface dataset:
Problem:
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?

Incorrect submission (verdict: Wrong Answer):

x = int(input())

print(x*(x+1)/2)

Fixed, accepted submission:

x = int(input())

print(int(x*(x+1)/2))
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
a,b,c = map(int,(input().split()))
num = []
num +=[a,b,c]

five = num.count(5)
seven = num.count(7)
print(five)
if five == 2 and seven ==1:
    print("YES")
else:
    print("NO")

Fixed, accepted submission:
a,b,c = map(int,(input().split()))
num = []
num +=[a,b,c]

five = num.count(5)
seven = num.count(7)

if five == 2 and seven ==1:
    print("YES")
else:
    print("NO")
Problem:
An elementary school student Takahashi has come to a variety store.  He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?  Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.

Incorrect submission (verdict: Wrong Answer):
a,b,c=map(int,input().split())

if a+b<=c:
 print("Yes")
else:
 print("No")

Fixed, accepted submission:
a,b,c=map(int,input().split())

if a+b>=c:
 print("Yes")
else:
 print("No")
Problem:
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?

Incorrect submission (verdict: Wrong Answer):
x = int(input())
print((1+x)*x/2)

Fixed, accepted submission:
x = int(input())
print(int((1+x)*x/2))
Problem:
E869120 found a chest which is likely to contain treasure.   However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.   He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`.  One more thing he found is a sheet of paper with the following facts written on it:    * Condition 1: The string S contains a string T as a contiguous substring.   * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.  Print the string S.   If such a string does not exist, print `UNRESTORABLE`.

Incorrect submission (verdict: Wrong Answer):
s = input()
t = input()
def check(a, b):
  if a == '?':
    return True
  else:
    if a == b:
      return True
    else:
      return True
cand = []
for i in range(len(s)-len(t)):
  flag = True
  c = list(s)
  for j in range(len(t)):
    if not check(s[i+j], t[j]):
      flag = False
      break
    c[i+j] = t[j]
  if flag:
    s = ''.join(c)
    s.replace('?', 'a')
    cand.append(s)
if len(cand):
  cand.sort()
  print(cand[0])
else:
  print("UNRESTORABLE")
    

Fixed, accepted submission:
s = input()
t = input()
def check(a, b):
  if a == '?':
    return True
  else:
    return a == b
  
cand = []
for i in range(len(s)-len(t)+1):
  flag = True
  c = list(s)
  for j in range(len(t)):
    if not check(s[i+j], t[j]):
      flag = False
      break
    c[i+j] = t[j]
  if flag:
    cs = ''.join(c)
    cand.append(cs.replace('?', 'a'))
if len(cand):
  cand.sort()
  print(cand[0])
else:
  print("UNRESTORABLE")
Problem:
It is September 9 in Japan now.  You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?

Incorrect submission (verdict: Wrong Answer):
n = input()

if n[0]==9 or n[1]==9:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
n = input()

if n[0]=="9" or n[1]=="9":
  print("Yes")
else:
  print("No")
Problem:
Snuke has a favorite restaurant.  The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.  So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.

Incorrect submission (verdict: Wrong Answer):
n =int(input())
print(n*800+200*(n+14)//15)

Fixed, accepted submission:
n =int(input())
print(n*800-200*((n)//15))
Problem:
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j).   Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares.   Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game.   When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares.  The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.

Incorrect submission (verdict: Wrong Answer):
H, W = list(map(int, input().split()))
c = [input() for _ in range(H)]

moves = [(-1, 0), (1, 0), (0, -1), (0, 1)] 

def bfs():
    visited = [[False for _ in range(W)] for _ in range(H)]
    dist = [[[] for _ in range(W)] for _ in range(H)]
    routes = [(0, 0)] 
    visited[0][0] = True

    hop_count = 0 
    while len(routes) > 0:
        x, y = routes.pop(0)
        for move in moves:
            cx, cy = x + move[0], y + move[1]
            if cx < 0 or cy < 0 or cx >= W or cy >= H or c[cy][cx] == '#' or visited[cy][cx]:
                continue
            if cx == W-1 and cy == H-1: 
                return sum([line.count('.')for line in c]) - len(dist[y][x]) - 2
            visited[cy][cx] = True
            routes.append((cx, cy))
            dist[cy][cx] += dist[y][x] + [(x, y)] 
        print(routes)
    return -1

print(bfs()) 

Fixed, accepted submission:
from collections import deque

H, W = list(map(int, input().split()))
c = [input() for _ in range(H)]

moves = [(-1, 0), (1, 0), (0, -1), (0, 1)]

def bfs():
    visited = [[False for _ in range(W)] for _ in range(H)]
    dist = [[0 for _ in range(W)] for _ in range(H)]
    routes = deque()
    routes.append((0, 0))
    visited[0][0] = True

    while len(routes) > 0:
        x, y = routes.popleft()
        for move in moves:
            cx, cy = x + move[0], y + move[1]
            if cx < 0 or cy < 0 or cx >= W or cy >= H or c[cy][cx] == '#' or visited[cy][cx]:
                continue
            if cx == W-1 and cy == H-1:
                return sum([line.count('.')for line in c]) - dist[y][x] - 2
            visited[cy][cx] = True
            routes.append((cx, cy))
            dist[cy][cx] = dist[y][x] + 1
    return -1

print(bfs())
Problem:
n! = n × (n − 1) × (n − 2) × ...  × 3 × 2 × 1      を n の階乗といいます。例えば、12 の階乗は      12! = 12 × 11 × 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1 = 479001600      となり、末尾に 0 が 2 つ連続して並んでいます。  整数 n を入力して、n! の末尾に連続して並んでいる 0 の数を出力するプログラムを作成してください。ただし、n は 20000 以下の正の整数とします。

Incorrect submission (verdict: Wrong Answer):
import math

while True:
    try:
        n = int(input())
    except:
        break
 
    s = 0
    fac = math.factorial(n)

    while fac % 10 == 0:
        fac = fac // 10
        s += 1

    print(s) 

Fixed, accepted submission:
import math

while True:
    n = int(input())
    if n == 0: break
 
    s = 0
    fac = math.factorial(n)

    while fac % 10 == 0:
        fac = fac // 10
        s += 1

    print(s)
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

Incorrect submission (verdict: Wrong Answer):
a = int(input())
b = int(input())
h = int(input())
print(((a+b)*h)/2)

Fixed, accepted submission:
a = int(input())
b = int(input())
h = int(input())
print(((a+b)*h)//2)
Problem:
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied:    * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds.  Find all favorite numbers and print the sum of those.

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

    divisors.sort()
    return divisors

n = int(input())

for i in range(1, 1000):
    if n%i == n//i:
        print(i, n%i)
    #if ((n-i)/i)%1 == 0:
        #print(i)



ans = 0
for i in make_divisors(n):
    if i > n ** 0.5:
        ans += i-1

print(ans)
print(1)

Fixed, accepted submission:
#%%
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)

    divisors.sort()
    return divisors

n = int(input())


ans = 0
for i in make_divisors(n):
    if i >= n ** 0.5 + 1:
        ans += i-1

print(ans)
Problem:
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order:    * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times.   * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana.  The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?

Incorrect submission (verdict: Wrong Answer):
N,H = input().split()
n = int(N)
h = int(H)
da = 0
db = []
for i in range(n):
    a,b = tuple(map(int,input().split()))
    da = max(a,da)
    db.append(b)
db.sort()      


total = 0 
i = 0
while total < h:
    if len(db) == 0:
        i += (h - total)//da
        break
    elif db[-1] >= da:
        total += db.pop()
    else:
        total += da
    i += 1
print(str(i))

Fixed, accepted submission:
import math
N,H = input().split()
n = int(N)
h = int(H)
da = 0
db = [0] * n
for i in range(n):
    a,b = tuple(map(int,input().split()))
    da = max(a,da)
    db[i] = b
db.sort()      


total = 0 
i = 0
while total < h:
    if db[-1] >= da:
        total += db.pop()
        if len(db) == 0:
            i += math.ceil((h - total)/da) + 1
            break
    else:
        i += math.ceil((h - total)/da) 
        break
    i += 1
print(str(i))
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
a,b,c=map(int,input().split())

l=[]
for i in range(b):
    l.append((a*i)%b)
t=0
for i in range(len(l)):
    if l[i]==c:
        t+=1
        break
if t!=0:
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a,b,c=map(int,input().split())

l=[]
for i in range(b):
    l.append((a*i)%b)
t=0
for i in range(len(l)):
    if l[i]==c:
        t+=1
        break
if t!=0:
    print("YES")
else:
    print("NO")
Problem:
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i.  At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly:    * Choose a (connected) rope with a total length of at least L, then untie one of its knots.  Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.

Incorrect submission (verdict: Wrong Answer):
n, l = map(int, input().split())
a = list(map(int, input().split()))
b = [a[i]+a[i+1] for i in range(n-1)]
start = -1
for ind, length in enumerate(b):
    if length >= l:
        start = ind+1
        break
if start<0:
    print("Impossible")
else:
    print("Ppossible")
    for i in range(1,start):
        print(i)
    for i in range(start, n)[::-1]:
        print(i)


Fixed, accepted submission:
n, l = map(int, input().split())
a = list(map(int, input().split()))
b = [a[i]+a[i+1] for i in range(n-1)]
start = -1
for ind, length in enumerate(b):
    if length >= l:
        start = ind+1
        break
if start<0:
    print("Impossible")
else:
    print("Possible")
    for i in range(1,start):
        print(i)
    for i in range(start, n)[::-1]:
        print(i)
Problem:
We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}.  Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2.  Find the inversion number of B, modulo 10^9 + 7.  Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j.

Incorrect submission (verdict: Wrong Answer):
n, k = map(int, input().split())
a = list(map(int, input().split()))
 
mod = 10 ** 9 + 7

b = [[0, 0] for _ in range(n)]
for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            if i > j:
                b[i][0] += 1
            else:
                b[i][1] += 1
ans = 0
sigmakp = int(((k * (k+1)) % mod) / 2) % mod
sigmakn = int(((k * (k-1)) % mod) / 2) % mod
for i in range(n):
    mae = (sigmakn * b[i][1]) % mod
    ushiro = (sigmakp * b[i][0]) % mod
    ans = ((mae + ushiro) % mod + ans) % mod 
print(ans)

Fixed, accepted submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
 
mod = 10 ** 9 + 7

b = [[0, 0] for _ in range(n)]
for i in range(n):
    for j  in range(i,n):
        if a[i] > a[j]:
                b[i][1] += 1
        elif a[i] < a[j]:
        		b[i][0] +=1


b[i][0]=b[i][0]%mod		
b[i][1]=b[i][1]%mod	
ans = 0
sigmakp = ((k * (k+1) ) // 2) % mod

sigmakn = ((k * (k-1)) // 2) % mod

for i in range(n):
    mae = int(sigmakn * b[i][0]) % mod
    ushiro = int(sigmakp * b[i][1]) % mod
    ans = int((mae + ushiro) + ans) % mod 
print(ans)
Problem:
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs.  Determine if it is possible that there are exactly X cats among these A + B animals.

Incorrect submission (verdict: Wrong Answer):
a, b, x = map(int, input().split())
if a <= x <= a + b:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
a, b, x = map(int, input().split())
if a <= x <= a + b:
  print("YES")
else:
  print("NO")
Problem:
M-kun is a competitor in AtCoder, whose highest rating is X.   In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given:    * From 400 through 599: 8-kyu   * From 600 through 799: 7-kyu   * From 800 through 999: 6-kyu   * From 1000 through 1199: 5-kyu   * From 1200 through 1399: 4-kyu   * From 1400 through 1599: 3-kyu   * From 1600 through 1799: 2-kyu   * From 1800 through 1999: 1-kyu  What kyu does M-kun have?

Incorrect submission (verdict: Wrong Answer):
number = int(input())
if number in range(400, 599):
  print('8')



Fixed, accepted submission:
number = int(input())
if number in range(400, 600):
    print('8')
elif number in range(600, 800):
    print('7')
elif number in range(800, 1000):
    print('6')
elif number in range(1000, 1200):
    print('5')
elif number in range(1200, 1400):
    print('4')
elif number in range(1400, 1600):
    print('3')
elif number in range(1600, 1800):
    print('2')
elif number in range(1800, 2000):
    print('1')
Problem:
Two students of AtCoder Kindergarten are fighting over candy packs.  There are three candy packs, each of which contains a, b, and c candies, respectively.  Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.  Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.

Incorrect submission (verdict: Wrong Answer):
a, b, c = input().split()

if (a == b+c) or (b == a+c) or (c == a+b):
  print('Yes')
else:
  print('No')
  

Fixed, accepted submission:
a, b, c = map(lambda x : int(x), input().split())
 
if (a == b+c) or (b == a+c) or (c == a+b):
  print('Yes')
else:
  print('No')
Problem:
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements?  Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:    * r_1 + c_1 = r_2 + c_2   * r_1 - c_1 = r_2 - c_2  For example, in the following figure, the bishop can move to any of the red squares in one move:  

Incorrect submission (verdict: Wrong Answer):
h,w = map(int,input().split())

print((h*w//2) + 1)


Fixed, accepted submission:
h,w = map(int,input().split())

if h*w % 2 == 1 or 0 < h*w % 2 < 1:
    ans = (h*w//2) + 1
else:
    ans = h*w//2

if h > 1 and w == 1:
    ans = 1
elif w > 1 and h == 1:
    ans = 1

print(ans)
Problem:
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.  Determine if we can visit all the towns by traversing each of the roads exactly once.

Incorrect submission (verdict: Wrong Answer):
from collections import Counter
import sys
A = []
for i in range(3):
    a,b = map(int,input().split())
    A.append(a)
    A.append(b)
c = Counter(A)
for i in c.values():
    if i >=2:
        print('NO')
        sys.exit()
print('YES')

Fixed, accepted submission:
from collections import Counter
import sys
A = []
for i in range(3):
    a,b = map(int,input().split())
    A.append(a)
    A.append(b)
c = Counter(A)
for i in c.values():
    if i >=3:
        print('NO')
        sys.exit()
print('YES')
Problem:
You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S.

Incorrect submission (verdict: Wrong Answer):
iipt=lambda:int(input())
miipt=lambda:list(map(int,input().split(" ")))
import bisect
 
N=iipt()
c=miipt()
M=iipt()
qu=miipt()
ans=0
for q in qu:
    a=0
    b=N-1
    while b-a>1:
        x=(a+b)//2
        if c[a]==q or c[b]==q:
            ans+=1
            break
        if c[x]<q:
            a=x
        else:
            b=x
    else:
        if c[a]==q or c[b]==q:
            ans+=1
            break
    """        
    if a==-1 or b==N:
        print(q,a,b)
        ans-=1"""

print(ans)


Fixed, accepted submission:
iipt=lambda:int(input())
miipt=lambda:list(map(int,input().split(" ")))
import bisect
 
N=iipt()
c=miipt()
M=iipt()
qu=miipt()
ans=0
for q in qu:
    a=0
    b=N-1
    while b-a>1:
        x=(a+b)//2
        if c[a]==q or c[b]==q:
            ans+=1
            break
        if c[x]<q:
            a=x
        else:
            b=x
    else:
        if c[a]==q or c[b]==q:
            ans+=1

    """        
    if a==-1 or b==N:
        print(q,a,b)
        ans-=1"""

print(ans)
Problem:
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.

Incorrect submission (verdict: Wrong Answer):
import sys

n=int(input())
s=str(input())
list=[]
for i in range(1,n):
	a=s[0:i]
	b=s[i:]
	print(a)
	print(b)
	count=0
	for j in range(97,97+26):
		if (chr(j) in a)and(chr(j) in b):
			count+=1
	list.append(count)
print(max(list))

Fixed, accepted submission:
import sys

n=int(input())
s=str(input())
list=[]
for i in range(1,n):
	a=s[0:i]
	b=s[i:]
	count=0
	for j in range(97,97+26):
		if (chr(j) in a)and(chr(j) in b):
			count+=1
	list.append(count)
print(max(list))
Problem:
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N).  For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.  We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:    * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.  Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
A=[0]+[int(_) for _ in input().split()]
ans=[]
for i in range(N,0,-1):
    bai=N//i
    print(i,sum(A[i*b] for b in range(2,bai+1)))
    if A[i]!=sum(A[i*b] for b in range(2,bai+1))%2:
        ans+=[i]
print(len(ans))
print(*ans[::-1],sep=' ')

Fixed, accepted submission:
N=int(input())
A=[0]+[int(_) for _ in input().split()]
ans=[0]*(N+1)
result=[]
for i in range(N,0,-1):
    bai=N//i
    if A[i]!=sum(ans[i*b] for b in range(2,bai+1))%2:
        ans[i]=1
        result+=[i]
print(len(result))
print(*result)
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%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)

Fixed, accepted submission:
n = int(input())
if n%2 == 1:
    a = n-1
else:
    a = n
ans = []
for i in range(a-1):
    for j in range(i+1,a):
        if i+j+2 == a+1:
            continue
        else:
            ans += [[i+1,j+1]]
            # print(i+1,j+1)
if n%2 == 1:
    for i in range(n-1):
        ans += [[i+1,n]]
        # print(i+1,n)
print(len(ans))
for i in ans:
    print(*i)