Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

s = input()
t = input()

lens = len(s)
lent = len(t)

dp = [[{'str': '', 'len': 0} for _ in range(lent+1)] for _ in range(lens+1)]

for i in range(1, lens+1):
    for j in range(1, lent+1):
        if s[i-1] == t[j-1]:
            candidate = max(dp[i-1][j-1]['len']+1, dp[i-1][j]['len'], dp[i][j-1]['len'])
            if candidate == dp[i-1][j-1]['len']+1:
                dp[i][j] = {'str': dp[i-1][j-1]['str'] + s[i-1], 'len': candidate}
                continue
            elif candidate == dp[i-1][j]['len']:
                dp[i][j] = {'str': dp[i-1][j]['str'], 'len': candidate}
                continue
            else:
                dp[i][j] = {'str': dp[i][j-1]['str'], 'len': candidate}
        else:
            candidate = max(dp[i-1][j]['len'], dp[i][j-1]['len'])
            if candidate == dp[i-1][j]['len']:
                dp[i][j] = {'str': dp[i-1][j]['str'], 'len': candidate}
                continue
            else:
                dp[i][j] = {'str': dp[i][j-1]['str'], 'len': candidate}

print(dp[lens][lent]['str'])


Fixed submission:
# -*- coding: utf-8 -*-

s = input()
t = input()

lens = len(s)
lent = len(t)

dp = [[0 for _ in range(lent+1)] for _ in range(lens+1)]

ans_index = []

for i in range(1, lens+1):
    for j in range(1, lent+1):
        if s[i-1] == t[j-1]:
            candidate = max(dp[i-1][j-1]+1, dp[i-1][j], dp[i][j-1])
            if candidate == dp[i-1][j-1]+1:
                dp[i][j] = dp[i-1][j-1]+1
                continue
            elif candidate == dp[i-1][j]:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = dp[i][j-1]
        else:
            candidate = max(dp[i-1][j], dp[i][j-1])
            if candidate == dp[i-1][j]:
                dp[i][j] = dp[i-1][j]
                continue
            else:
                dp[i][j] = dp[i][j-1]

i, j = lens, lent
ans = ''
while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
        continue
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
        continue
    else:
        ans = s[i-1] + ans
        i -= 1
        j -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 0
nums = set([])
for _ in range(N):
    A = int(input())
    if A in nums:
        ans -= 1
        nums.clear(A)
    else:
        ans += 1
        nums.add(A)
print(ans)


Fixed submission:
N = int(input())
ans = 0
nums = set()
for _ in range(N):
    A = int(input())
    if A in nums:
        ans -= 1
        nums.remove(A)
    else:
        ans += 1
        nums.add(A)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
nums = []
for _ in range(N):
    A = int(input())
    if A in nums:
        ans -= 1
        nums.remove(A)
    else:
        ans += 1
        nums.append(A)
print(ans)


Fixed submission:
N = int(input())
ans = 0
nums = set()
for _ in range(N):
    A = int(input())
    if A in nums:
        ans -= 1
        nums.remove(A)
    else:
        ans += 1
        nums.add(A)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
nums = [0] * 10000
data = list(map(int, input().split()))
for A in data:
    nums[A-1] += 1
    nums[A] += 1
    nums[A+1] += 1
print(max(nums))


Fixed submission:
N = int(input())
nums = [0] * 100002
data = list(map(int, input().split()))
for A in data:
    nums[A-1] += 1
    nums[A] += 1
    nums[A+1] += 1
print(max(nums))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split())))
l1, l2 = 0, 0
while len(A) > 1:
    if A[-1] == A[-2] and l1 == 0:
        l1 = A[-1]
        A = A[:-2]
    elif A[-1] == A[-2] and l2 == 0:
        l2 = A[-1]
        break
    else:
        A = A[:-1]
print(l1 * l2)


Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))[::-1]
l1, l2 = 0, 0
flag = True
for i in range(N-1):
    if A[i] > A[i+1]:
        flag = True
        pass
    elif l1 == 0:
        l1 = A[i]
        flag = False
    elif l2 == 0 and flag:
        l2 = A[i]
        break
    else:
        flag = True

print(l1 * l2)
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
N = int(input())
color = [0]
data = list(map(int, input().split()))
for i in range(N):
    color.append(color[i] + data[i])

def num(i):
    for j in range(N):
        if color[j] <= i < color[j + 1]:
            return str(j + 1)

grid = [[num(h * W + w) for w in range(W)] for h in range(H)]

for h in range(H):
    if h % 2 == 0:
        print(" ".join(grid[h]))
    else:
        print(" ".join(grid[h][::-1]))


Fixed submission:
H, W = map(int, input().split())
N = int(input())
# color = [0]
data = list(map(int, input().split()))
# for i in range(N):
#    color.append(color[i] + data[i])

# def num(i):
#    for j in range(N):
#        if color[j] <= i < color[j + 1]:
#            return str(j + 1)

# grid = [[num(h * W + w) for w in range(W)] for h in range(H)]
col = 1
count = 1
grid = [["" for w in range(W)] for h in range(H)]
for h in range(H):
    for w in range(W):
        grid[h][w] = str(col)
        if count == data[col - 1]:
            count = 1
            col += 1
        else:
            count += 1

for h in range(H):
    if h % 2 == 0:
        print(" ".join(grid[h]))
    else:
        print(" ".join(grid[h][::-1]))

Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
N = int(input())
color = [0]
data = list(map(int, input().split()))
for i in range(N):
    color.append(color[i] + data[i])

def num(i):
    for j in range(N):
        if color[j] <= i < color[j + 1]:
            return str(j + 1)

for h in range(H):
    line = ""
    for w in range(W):
        if h % 2 == 0:
            line = line + num(h * W + w)
            if w == W - 1:
                break
            line = line + " "
        else:
            line = num(h * W + w) + line
            if w == W - 1:
                break
            line = " " + line
    print(line)


Fixed submission:
H, W = map(int, input().split())
N = int(input())
# color = [0]
data = list(map(int, input().split()))
# for i in range(N):
#    color.append(color[i] + data[i])

# def num(i):
#    for j in range(N):
#        if color[j] <= i < color[j + 1]:
#            return str(j + 1)

# grid = [[num(h * W + w) for w in range(W)] for h in range(H)]
col = 1
count = 1
grid = [["" for w in range(W)] for h in range(H)]
for h in range(H):
    for w in range(W):
        grid[h][w] = str(col)
        if count == data[col - 1]:
            count = 1
            col += 1
        else:
            count += 1

for h in range(H):
    if h % 2 == 0:
        print(" ".join(grid[h]))
    else:
        print(" ".join(grid[h][::-1]))
Buggy python submission (verdict: Runtime Error):

import math

A,B,C,D = [int(i) for i in input().split()]

CD = C * D // math.gcd(C,D)

cntC = (B // C) - (A // C)
cntD = (B // D) - (A // D)
cntCD = (B // CD) - (A // CD)

if A % C == 0:
    cntC += 1
if A % D == 0:
    cntD += 1
if A % CD == 0:
    cntCD += 1

ans = B - A + 1 - (cntC + cntD - cntCD)
print(ans)

Fixed submission:

def calGCD(x,y):
    while(y > 0):
        x, y = y, x % y
    return x

A,B,C,D = [int(i) for i in input().split()]

CD = C * D // calGCD(C,D)

cntC = (B // C) - (A // C)
cntD = (B // D) - (A // D)
cntCD = (B // CD) - (A // CD)

if A % C == 0:
    cntC += 1
if A % D == 0:
    cntD += 1
if A % CD == 0:
    cntCD += 1

ans = B - A + 1 - (cntC + cntD - cntCD)
print(ans)
Buggy python submission (verdict: Runtime Error):
ans = list("keyence")

S = input()
for i in range(len(S)):
  if S[i] == ans[0]:
    ans.pop(0)

if len(ans) == 0:
  print("YES")
else:
  print("NO")

Fixed submission:
ans = "keyence"

s = input()
flag=0
if ans in s:
  flag=1
  print("YES")
else:
  for i in range(1,len(ans)):
    if s[:i] == ans[:i] and s[i-len(ans):] == ans[i-len(ans):]:
      flag=1
      print("YES")
      break
if flag==0:
  print("NO")
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
if (A*B % 2 = 0):
  print("No")
else:
  print("Yes")

Fixed submission:
A, B = map(int, input().split())
if (A*B % 2 == 0):
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
import math
 
N, X = map(int, input().split())
town = list(map(int, input().split()))
 
for i in range(N):
  if town[i] < X:
    town[i] = X - town[i]
  else:
    town[i] = town[i] - X
    
if N == 1:
  print("qaaq")
  
gcd = town[0]
for i in range(1, N):
  gcd = math.gcd(gcd, town[i])
print(gcd)
  

Fixed submission:
import fractions
  

N, X = map(int, input().split())
town = list(map(int, input().split()))
 
for i in range(N):
  if town[i] < X:
    town[i] = X - town[i]
  else:
    town[i] = town[i] - X
  
gcd = town[0]
for i in range(1, N):
  gcd = fractions.gcd(gcd, town[i])
print(gcd)

Buggy python submission (verdict: Runtime Error):
import math
 
N, X = map(int, input().split())
town = list(map(int, input().split()))
 
for i in range(N):
  if town[i] < X:
    town[i] = X - town[i]
  else:
    town[i] = town[i] - X
  
gcd = town[0]
for i in range(1, N):
  gcd = math.gcd(gcd, town[i])
print(gcd)

Fixed submission:
import fractions
  

N, X = map(int, input().split())
town = list(map(int, input().split()))
 
for i in range(N):
  if town[i] < X:
    town[i] = X - town[i]
  else:
    town[i] = town[i] - X
  
gcd = town[0]
for i in range(1, N):
  gcd = fractions.gcd(gcd, town[i])
print(gcd)

Buggy python submission (verdict: Runtime Error):
import math

N, X = map(int, input().split())
town = list(map(int, input().split()))

for i in range(N):
  if town[i] < X:
    town[i] = X - town[i]
  else:
    town[i] = town[i] - X

if N ==1:
  print(town[0])
  
else:
  gcd = math.gcd(town[0], town[1])
  for i in range(2, N):
    gcd = math.gcd(gcd, town[i])
  print(gcd)
  
  

Fixed submission:
import fractions
  

N, X = map(int, input().split())
town = list(map(int, input().split()))
 
for i in range(N):
  if town[i] < X:
    town[i] = X - town[i]
  else:
    town[i] = town[i] - X
  
gcd = town[0]
for i in range(1, N):
  gcd = fractions.gcd(gcd, town[i])
print(gcd)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N, X = map(int, input().split())
town = list(map(int, input().split()))

for i in range(N):
  if town[i] < X:
    town[i] = X - town[i]
  else:
    town[i] = town[i] - X

print(gcd_list(town))
  
  

Fixed submission:
import fractions
  

N, X = map(int, input().split())
town = list(map(int, input().split()))
 
for i in range(N):
  if town[i] < X:
    town[i] = X - town[i]
  else:
    town[i] = town[i] - X
  
gcd = town[0]
for i in range(1, N):
  gcd = fractions.gcd(gcd, town[i])
print(gcd)
Buggy python submission (verdict: Runtime Error):
N , M = map(int, input())
print(N-M+1)

Fixed submission:
N,M = map(int, input().split())
print(N-M+1)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
ans = A*B - A - B + 1
print(ans)

Fixed submission:
A, B = map(int, input().split())
print(A*B - A - B + 1)

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())

print(A*B - A - B + 1)

Fixed submission:
A, B = map(int, input().split())
print(A*B - A - B + 1)
Buggy python submission (verdict: Runtime Error):
import math
N = 5000000000000000
print(N)
S = input()
K = int(input())
for i in S:
  num = int(i)
  if N * math.log(num) > math.log(K):
    print(num)
    break
  else:
    K -= num

Fixed submission:
import math
N = 5000000000000000
S = input()
K = math.log(int(input()))
for i in S:
  num = int(i)
  if num == 1:
    if num == int(math.exp(K)):
      print(num)
      break
    else:
      K = math.log(int(math.exp(K)-1))
      continue
  kk = N * math.log(num)
  if kk >= K:
    print(num)
    break
  else:
    K -= kk
Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())
if N < 100:
  print((100**D)*N)
else:
  print(((100**D)*101)

Fixed submission:
D, N = map(int, input().split())
if N < 100:
  print((100**D)*N)
else:
  print((100**D)*101)
Buggy python submission (verdict: Runtime Error):
N, C, D = map(int, input().split())
check = [i*i for i in range(N+1)]
time = 0
stop = N * N
 
print(check)
if C * D % 2 ==1:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 0:
    print(i, j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break
elif (C+D) % 2 == 0:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 1:
    print(i, j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break
else:
 for i in range(2*N):
  tt = i * i
  if C - tt in check or D - tt in check:
   continue
  else:
   for j in range(2*N):
    print(i,j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break

Fixed submission:
N = int(input())
while(N%10 == 0):
 N /= 10
if N == 1:
 print(10)
else:
 s = str(N)
 array = list(map(int, list(s)))
 print(sum(array))

Buggy python submission (verdict: Runtime Error):
N, C, D = map(int, input().split())
check = [i*i for i in range(N)]
time = 0
stop = N * N

if C * D % 2 ==1:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 0:
    print(i, j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break
elif (C+D) % 2 == 0:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 1:
    print(i, j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break
else:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 0:
    if C % 2 == 1:
     if D - j * j not in check:
      print(i, j)
      time += 1
      if stop == time:
       break
    else:
     if C - j * j not in check:
      print(i, j)
      time += 1
      if stop == time:
       break
   if stop == time:
    break


Fixed submission:
N = int(input())
while(N%10 == 0):
 N /= 10
if N == 1:
 print(10)
else:
 s = str(N)
 array = list(map(int, list(s)))
 print(sum(array))

Buggy python submission (verdict: Runtime Error):
N, C, D = map(int, input().split())
check = [i*i for i in range(N)]
time = 0
stop = N * N

if C * D % 2 ==1:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 0:
    print(i, j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break
elif (C+D) % 2 == 0:
 for i in range(2*N):
  for j in range(2*N):
   if (i + j) % 2 == 1:
    print(i, j)
    time += 1
    if stop == time:
     break
  if stop == time:
   break



 

Fixed submission:
N = int(input())
while(N%10 == 0):
 N /= 10
if N == 1:
 print(10)
else:
 s = str(N)
 array = list(map(int, list(s)))
 print(sum(array))
Buggy python submission (verdict: Runtime Error):
N = int(input())

start = int(input())
flag = 0
if start != 0:
 flag = 1
t = 0

for i in range(N-1):
 k = int(input())
 if k == start:
  t += start
 elif k == start + 1:
  t += 1
  start = k
 elif k == 0:
  start = 0
 elif k > start + 1:
  t = -1
  break
 else:
  t += k
  start = k

if flag ==1:
 t = -1
print(t)

Fixed submission:
A,B,C,K= map(int, input().split())
 
if (A-B) > 10e18 or (B-A) > 10e18:
 print("Unfair")
elif K % 2 == 1:
 print(B-A)
else:
 print(A-B)

Buggy python submission (verdict: Runtime Error):
A,B,C,K= map(int, input().split())

if (A-B) ** 2 **0.5 > 10e18:
 print("Unfair")
elif K % 2 == 1:
 print(A-B)
else:
 print(B-A)


Fixed submission:
A,B,C,K= map(int, input().split())
 
if (A-B) > 10e18 or (B-A) > 10e18:
 print("Unfair")
elif K % 2 == 1:
 print(B-A)
else:
 print(A-B)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,K= map(int, input().split())

for i in range(K):
 sum = A + B + C
 A = sum - A
 B = sum - B
 C = sum - C

if A-B > 10e18 or B-A > 10e18:
 print("Unfair")
else:
 print(A-B)

Fixed submission:
A,B,C,K= map(int, input().split())
 
if (A-B) > 10e18 or (B-A) > 10e18:
 print("Unfair")
elif K % 2 == 1:
 print(B-A)
else:
 print(A-B)
Buggy python submission (verdict: Runtime Error):
N = int(input())

start = int(input())
flag = 0
if start != 0:
flag = 1
t = 0

for i in range(N-1):
 k = int(input())
 if k == start:
  t += start
 elif k == start + 1:
  t += 1
  start = k
 elif k == 0:
  start = 0
 elif k > start + 1:
  t = -1
  break
 else:
  t += k
  start = k

if flag ==1:
 t = -1
print(t)

Fixed submission:
N = int(input())

start = int(input())
flag = 0
if start != 0:
 flag = 1
t = 0

for i in range(N-1):
 k = int(input())
 if k == start:
  t += start
 elif k == start + 1:
  t += 1
  start = k
 elif k == 0:
  start = 0
 elif k > start + 1:
  t = -1
  break
 else:
  t += k
  start = k

if flag ==1:
 t = -1
print(t)

Buggy python submission (verdict: Runtime Error):
N = int(input())

start = int(input())
flag = 0
if start != 0:
flag = 1
t = 0

for i in range(N-1):
 k = int(input())
 if k == start:
  t += start
 elif k == start + 1:
  t += 1
  start = k
 elif k == 0:
  start = 0
 elif k > start + 1:
  t = -1
  break
 else:
  t += k
  start = k

if flag ==1:
 t = -1
print(t)

Fixed submission:
N = int(input())

start = int(input())
flag = 0
if start != 0:
 flag = 1
t = 0

for i in range(N-1):
 k = int(input())
 if k == start:
  t += start
 elif k == start + 1:
  t += 1
  start = k
 elif k == 0:
  start = 0
 elif k > start + 1:
  t = -1
  break
 else:
  t += k
  start = k

if flag ==1:
 t = -1
print(t)
Buggy python submission (verdict: Runtime Error):
#ABC 070: C [beta]
from fractions import gcd

N = int(input())
clocks = []
for i in range(N):
  clocks.append(int(input()))

a = clocks[0]
for i in range(1, N):
  a = gcd(a, clocks[i])
  b = b * clocks[i] / a

print(b)

Fixed submission:
#ABC 070: C [beta]
from fractions import gcd

N = int(input())
clocks = []
for i in range(N):
  clocks.append(int(input()))

b = clocks[0]
for i in range(1, N):
  a = gcd(b, clocks[i])
  b = b * clocks[i] // a

print(b)

Buggy python submission (verdict: Runtime Error):
#ABC 070: C [beta]
from fractions import gcd

N = int(input())
clocks = []
for i in range(N):
  clocks.append(int(input()))

a = clocks[0]
for i in range(1, N):
  a = gcd(a, clocks[i])
  b = a * clocks[i] / a

print(b)

Fixed submission:
#ABC 070: C [beta]
from fractions import gcd

N = int(input())
clocks = []
for i in range(N):
  clocks.append(int(input()))

b = clocks[0]
for i in range(1, N):
  a = gcd(b, clocks[i])
  b = b * clocks[i] // a

print(b)

Buggy python submission (verdict: Runtime Error):
#ABC 070: C [beta]
from fraction import gcd

N = int(input())
clocks = []
for i in range(N):
  clocks.append(int(input()))

a = clocks[0]
for i in range(1, N):
  a = gcd(a, clocks[i])
  b = a * clocks[i] / a

print(b)

Fixed submission:
#ABC 070: C [beta]
from fractions import gcd

N = int(input())
clocks = []
for i in range(N):
  clocks.append(int(input()))

b = clocks[0]
for i in range(1, N):
  a = gcd(b, clocks[i])
  b = b * clocks[i] // a

print(b)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N = int(input())
A = [int(input()) for _ in range(N)]

l = deque()

for a in A:
    if len(l) == 0:
        l.append(a)
    else:
        tmp_deque = deque()
        while len(l) > 0:
            num = l.popleft()
            if num >= a:
                tmp_deque.append(num)
            else:
                break
        tmp_deque.append(a)
        l.extendleft(tmp_deque)
        

print(len(l))


Fixed submission:
from collections import deque

def replace(l, a, max_idx, min_idx):
    if max_idx == min_idx:
        l[max_idx] = a
        return

    center = (max_idx + min_idx)//2
    if l[center] >= a:
        return replace(l, a, max_idx, center+1)
    else:
        return replace(l, a, center, min_idx)


N = int(input())
A = [int(input()) for _ in range(N)]


l = []

for a in A:
    if len(l) == 0:
        l.append(a)
    elif l[-1] >= a:
        l.append(a)
    else:
        replace(l, a, len(l)-1, 0)

print(len(l))
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())

if math.floor(math.log(N, 2)) == math.log(N, 2):
    print("No")
    exit()
else:
    print("Yes")

i = 1
print(N+1, N+2)
while i < N:
    if i+2 <= N:
        print(1, i+1)
        print(i+1, i+2)
        print(1, i+2+N)
        print(i+2+N, i+1+N)
        i += 2
    else:
        print(i-1, i+1)
        print(N+3, i+1+N)


Fixed submission:
import math
 
N = int(input())
 
if math.floor(math.log(N, 2)) == math.log(N, 2):
    print("No")
    exit()
else:
    print("Yes")
 
i = 1
print(N+1, N+2)
for i in range(1, N, 2):
    if i+2 <= N:
        print(1, i+1)
        print(i+1, i+2)
        print(1, i+2+N)
        print(i+2+N, i+1+N)
    else:
        print(i-1, i+1)
        tmp = (i+1) ^ (i-1) 
        print(N+tmp+1, i+1+N)

Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())

if math.floor(math.log(N, 2)) == math.log(N, 2):
    print("No")
    exit()
else:
    print("Yes")

i = 1
print("{} {}".format(N+1, N+2))
while i < N:
    if i+2 <= N:
        print("1 {}".format(i+1))
        print("{} {}".format(i+1, i+2))
        print("1 {}".format(i+2+N))
        print("{} {}".format(i+2+N, i+1+N))
        i += 2
    else:
        print("{} {}".format(i-1, i+1))
        print("{} {}".format(N+3, i+1+N))


Fixed submission:
import math
 
N = int(input())
 
if math.floor(math.log(N, 2)) == math.log(N, 2):
    print("No")
    exit()
else:
    print("Yes")
 
i = 1
print(N+1, N+2)
for i in range(1, N, 2):
    if i+2 <= N:
        print(1, i+1)
        print(i+1, i+2)
        print(1, i+2+N)
        print(i+2+N, i+1+N)
    else:
        print(i-1, i+1)
        tmp = (i+1) ^ (i-1) 
        print(N+tmp+1, i+1+N)