Harryxun/stf_run huggingface dataset:
pyramid=[]
if n==1:
  x,y,h=map(int,input().split())
  print(x,y,h)
else:
  x,y,h=map(int,input().split())
  pyramid.append([x,y,h])
ans=[[0 for i in range(101)] for i in range(101)]
flag=1
for i in range(n):
  if pyramid[i][2]!=0:
    for cx in range(101):
      for cy in range(101):
        H=pyramid[i][2]+abs(pyramid[i][0]-cx)+abs(pyramid[i][1]-cy)
        if flag==1:
          ans[cx][cy]=H
        else:
          if ans[cx][cy]!=H:
            ans[cx][cy]=0
  flag=0
for i in range(101):
  for j in range(101):
    if ans[i][j]!=0:
      print(i,j,ans[i][j])

### FIXED CODE ###

from sys import exit
n=int(input())
pyramid=[]
for i in range(n):
  x,y,h=map(int,input().split())
  pyramid.append([x,y,h])
flag=0
for i in range(n):
  if flag==0 and pyramid[i][2]!=0:
    flag=-1
  elif flag==-1 and pyramid[i][2]!=0:
    flag=1
if flag==-1:
  for i in range(n):
    if pyramid[i][2]!=0:
      print(pyramid[i][0],pyramid[i][1],pyramid[i][2])
      exit()
ans=[[0 for i in range(101)] for i in range(101)]
for i in range(n):
  if pyramid[i][2]!=0:
    for cx in range(101):
      for cy in range(101):
        H=pyramid[i][2]+abs(pyramid[i][0]-cx)+abs(pyramid[i][1]-cy)
        if flag==1:
          ans[cx][cy]=H
        else:
          if ans[cx][cy]!=H:
            ans[cx][cy]=0
    flag=0
for i in range(101):
  for j in range(101):
    if ans[i][j]!=0:
      print(i,j,ans[i][j])
def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f

def f(n):
    cnt = 0
    while True:
        if n == 0:
            break
        n = n % popcount(n)
        cnt += 1
    return cnt

def pow_r(x, n):
    if n == 0:
        return 1
    if n % 2 == 0:
        return pow_r(x ** 2, n // 2)
    else:
        return x * pow_r(x ** 2, (n - 1) // 2)

if __name__ == "__main__":
    n = int(input())
    x = input()
    xList = list(x)
    k = len(xList) - 1
    for i in range(n):
        xList[i] = str(int(xList[i]) ^ 1)
        xNum = int("".join(xList), 2)
        print(f(xNum))
        xList[i] = str(int(xList[i]) ^ 1)


### FIXED CODE ###

def f(n):
    cnt = 1
    while n > 0:
        n  %= bin(n).count('1')
        cnt += 1
    return cnt

if __name__ == "__main__":
    n = int(input())
    x = input()
    d = x.count('1')
    if d == 1:
        for i in x[:-1]:
            if i == '0':
                print(1)
            else:
                print(0)
        if x[-1] == '1':
            print(0)
        else:
            print(2)
        exit()

    ans = []
    M = 0
    for i in x:
        M <<= 1
        if i == '1':
            M += 1
    p = M % (d + 1)
    m = M % (d - 1)
    for i in range(n):
        if x[i] == '0':
            ans.append(f((p + pow(2, n - i - 1, d + 1)) % (d + 1)))
        else:
            ans.append(f((m - pow(2, n - i - 1, d - 1)) % (d - 1)))
    print(*ans, sep='\n')
s = list(input())
n = len(s)
for i in range(0,n-2):
	if i == n-2:
		if s[i] == s[i+1]:
			n-=1
		break
	if s[i]==s[i+1]:
		s[i+1]+=s[i+2]
		s.pop(i+2)
		n-=1
print(n)

### FIXED CODE ###

s = list(input())
ans = 0
length = 1
Si = s[0]
loop = [0]
for i in loop:
	Si_1 = ""
	for j in range(0,length):
		Si_1 += s[i+1+j]
	if Si == Si_1:
		length += 1
		i -= 1
		loop.append(i+1)
	else:
		ans += 1
		i += length - 1
		length = 1
		Si = Si_1
		loop.append(i+1)
	if i + length + 1 == len(s):
		ans += 1
		break
print(ans)
import math
from functools import reduce


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


n,k=map(int,input().split())
A=list(map(int,input().split()))
print("POSSIBLE" if k%gcd_list(A)==0 and k<=max(A) else "IMPOSSIBLE")

### FIXED CODE ###

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


def gcd_list(A):
    num=A[0]
    for i in A:
        num=gcd(num,i)
    return num


n,k=map(int,input().split())
A=list(map(int,input().split()))
print("POSSIBLE" if k%gcd_list(A)==0 and k<=max(A) else "IMPOSSIBLE")
N = int(input())
a = list(map(int, input().split()))

late = [0 for i in range(9)]

for n in a:
    late[n//400] += 1

max_a = min_a = 8-late[:-1].count(0)
if late[8] and not min_a:
    min_a = 1

if late[8]:
    max_a = min(max_a+late[8], 8)

print(min_a, max_a)

### FIXED CODE ###


from collections import Counter

N = int(input())
a = Counter(list(map(lambda x: x//400, map(int, input().split()))))

c = n = 0
for key in [0,1,2,3,4,5,6,7]:
    if a[key]:
        c += 1
        
for key in [8,9,10,11,12]:
    n += a[key]
        
max_n = c+n
if c:
    min_n = c
else:
    min_n = 1
print(min_n, max_n)
from fractions import gcd

INF = 2 << 30
V = 1002
G = [[] for _ in xrange(V)]
visited = [False]*V

def add_edge(fro, to, cap):
    G[fro].append([to,cap,len(G[to])])
    G[to].append([fro,0,len(G[fro])-1])

def dfs(v,t,f):
    if v == t:
        return f
    visited[v] = True
    for i,(to,cap,rev) in enumerate((G[v])):
        if visited[to] or cap == 0:            
            continue        
        d = dfs(to,t,min(f,cap))
        if d > 0:
            G[v][i][1] -= d
            G[to][rev][1] += d
            return d
    return 0

def max_flow(s,t):
    flow = 0
    while True:
        for i in xrange(V):
            visited[i] = False
        f = dfs(s,t,INF)
        if f == 0:
            return flow
        flow += f

while True:
    m,n = map(int,raw_input().split())
    if m|n == 0:
        break
    V = m+n+2
    G = [[] for _ in xrange(V)]
    visited = [True] * V
    data = []
    dbg = 0
    while len(data) < n+m:
        dbg += 1
        data += map(int,raw_input().split())            
        if dbg >= 1500:
            break
    blue = data[:m]
    red = data[m:]
    for i in xrange(m):
        add_edge(V-2,i,1)
    for i in xrange(m,m+n):
        add_edge(i,V-1,1)
    for i,b in enumerate(blue):
        for j,r in enumerate(red,m):
            if gcd(b,r) != 1:
                add_edge(i,j,1)
    print max_flow(V-2,V-1)

### FIXED CODE ###

from fractions import gcd

V = 1001
G = []
visited = []
match = []

def add_edge(u,v):
    G[u].append(v)
    G[v].append(u)

def dfs(v):
    visited[v] = True
    for u in G[v]:
        w = match[u]
        if w < 0 or not visited[w] and dfs(w):
            match[v] = u
            match[u] = v
            return True

def bipartite_matching():
    global match,visited
    res = 0
    match = [-1]*V
    for v in xrange(V):
        if match[v] < 0:
            visited = [False]*V
            if dfs(v):
                res += 1
    return res

while True:
    m,n = map(int,raw_input().split())
    V = m+n
    if V == 0:
        break
    G = [[] for _ in xrange(V)]
    data = []
    while len(data) < V:
        data += map(int,raw_input().split())
    for i,b in enumerate(data[:m]):
        for j,r in enumerate(data[m:],m):
            if gcd(b,r) != 1:
                add_edge(i,j)
    print bipartite_matching()
def solve():
    N, A, B = map(int, input().split())
    n_times = N // (A+B)
    amari = N % (A+B)
    cnt = 0
    if amari != 0:
        S = 'b' * A + 'r' * B
        S = S[:amari]

        for ball in S:
            if ball == 'b':
                cnt += 1
    
    print(n_times * A + cnt)

if __name__ == '__main__':
    solve()

### FIXED CODE ###

def solve():
    N, A, B = map(int, input().split())

    n_times = N // (A+B)
    amari = N % (A+B)

    cnt = 0
    if A <= amari:
        cnt = A
    else:
        cnt = amari
    
    print(n_times * A + cnt)

if __name__ == '__main__':
    solve()
import sys

def isleft(ox, oy, ax, ay, px, py):
    oax, oay = ax - ox, ay - oy
    opx, opy = px - ox, py - oy
    if oax * opy > oay * opx:
        return 1
    else:
        return 0

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
    A, B, C, P = (x1, y1), (x2, y2), (x3, y3), (xp, yp)
    if isleft(*A, *B, *P) == isleft(*B, *C, *P) == isleft(*C, *A, *P):
        print("YES")
    else:
        print("NO")

### FIXED CODE ###

import sys

def isleft(ox, oy, ax, ay, px, py):
    oax, oay = ax - ox, ay - oy
    opx, opy = px - ox, py - oy
    if oax * opy > oay * opx:
        return 1
    else:
        return 0

for line in sys.stdin:
    x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())
#    A, B, C, P = (x1, y1), (x2, y2), (x3, y3), (xp, yp)
#    if isleft(*A, *B, *P) == isleft(*B, *C, *P) == isleft(*C, *A, *P):
    if isleft(x1, y1, x2, y2, xp, yp) == isleft(x2, y2, x3, y3, xp, yp) == isleft(x3, y3, x1, y1, xp, yp):
        print("YES")
    else:
        print("NO")
n = map(int,input().split())
#xlist = list(map(int,input().split()))

mlist=[n]
i=0
while(True):
    i=i+1
    if n % 2 == 0:
        mlist.append(n/2)
    else:
        mlist.append(3*n+1)
    for item in mlist:
        if mlist[0]==item:
            break

print(i)


### FIXED CODE ###

#n = map(int,input().split())
mlist = list(map(int,input().split()))

i=0
while(True):
    if mlist[i] % 2 == 0:
        mlist.append(mlist[i]/2)
    else:
        mlist.append(3*mlist[i]+1)
    
    breakFlg = False
    for num in range(0,i):
        if int(mlist[num])==int(mlist[i]):
            if num!=i:
                breakFlg = True
    i=i+1
    if(breakFlg):
        break
print(i)
temp1 = input().split(" ")
temp1 = [int(i) for i in temp1]
x = temp1[0]
n = temp1[1]

if not n == 0:
    temp2 = input().split(" ")
    temp2 = [int(i) for i in temp2]
else:
    temp2 = []

counter = 1
while True:
    if n == 0:
        print(x)
        break

    mx = x - counter
    px = x + counter

    if not mx in pn:
        print(mx)
        break
    if not px in pn:
        print(px)
        break

    counter += 1

### FIXED CODE ###

temp1 = input().split(" ")
temp1 = [int(i) for i in temp1]
x = temp1[0]
n = temp1[1]

if not n == 0:
    temp2 = input().split(" ")
    temp2 = [int(i) for i in temp2]
else:
    temp2 = input()
    temp2 = []

pn = temp2

counter = 0
while True:
    if n == 0:
        print(x)
        break

    mx = x - counter
    px = x + counter

    if not mx in pn:
        print(mx)
        break
    if not px in pn:
        print(px)
        break

    counter += 1
import numpy as np
# import sys
# import copy
# def input(): return sys.stdin.readline().rstrip()
# input = sys.stdin.readline
# input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
A = np.array(list(map(int, (input().split()))))
# A = list(map(int, (input().split())))
nd = np.zeros((N,N), dtype=bool)
# print(*A)
for i in range(K):
    # cnt = [0]*N
    for j in range(N):
        nd[j, max(j-A[j],0):min(j+A[j]+1,N)] = True
        # for k in range(max(j-A[j],0), min(j+A[j]+1,N)):
        #     cnt[k] += 1
    # print(nd)
    A = np.count_nonzero(nd, axis=0)
    if A[0] == A[N-1] == N:
        break
    # A = copy.copy(cnt)
    # print(*A)

print(*A)

### FIXED CODE ###

import numpy as np
from numba import njit
import sys
# import copy
# def input(): return sys.stdin.readline().rstrip()
# input = sys.stdin.readline
input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10 ** 7)

N, K = map(int, input().split())
# A = np.array(list(map(int, (input().split()))))
A = np.array(input().split(), dtype=np.int64)
# A = list(map(int, (input().split())))
# nd = np.zeros((N,N), dtype=bool)
# print(*A)

# @njit('(i8[::1],)', cache=True)
@njit(cache=True)
def loop(A):
    for i in range(K):
        # cnt = [0]*N
        cnt = np.zeros_like(A)
        for j, x in enumerate(A):
            # nd[j, max(j-A[j],0):min(j+A[j]+1,N)] = True
            l = max(j-x,0)
            r = min(j+x+1,N)
            cnt[l] += 1
            if r<N:
                cnt[r] -= 1
            # for k in range(max(j-A[j],0), min(j+A[j]+1,N)):
            #     cnt[k] += 1
        # print(nd)
        # A = np.count_nonzero(nd, axis=0)
        # print(cnt)
        A = np.cumsum(cnt)
        if A[0] == A[N-1] == N:
            break
        # print(*A)
    return A

A = loop(A)
print(*A)
N, M = map(int, input().split())
INF = 10**9

edges = []

for i in range(M):
    edges.append(list(map(int, input().split())))

dist = [[INF for j in range(N)] for i in range(N)]

for i in range(N):
    dist[i][i] = 0

for i in range(M):
    a, b, c = edges[i]
    a, b = a - 1, b - 1
    dist[a][b] = c[i]
    dist[b][a] = c[i]
    
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j])

res = M
for i in range(M):
    a, b, c = edges[i]
    a, b = a - 1, b - 1
    shortest = False
    for j in range(N):
        if dist[j][a] + c == dist[j][b]:
            shortest = True
            break
    if shortest:
        res -= 1

print(res)


### FIXED CODE ###

N, M = map(int, input().split())
INF = 10**9

edges = []

for i in range(M):
    edges.append(list(map(int, input().split())))

dist = [[INF for j in range(N)] for i in range(N)]

for i in range(N):
    dist[i][i] = 0

for i in range(M):
    a, b, c = edges[i]
    a, b = a - 1, b - 1
    dist[a][b] = c
    dist[b][a] = c
    
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j])

res = M
for i in range(M):
    a, b, c = edges[i]
    a, b = a - 1, b - 1
    shortest = False
    for j in range(N):
        if dist[j][a] + c == dist[j][b]:
            shortest = True
            break
    if shortest:
        res -= 1

print(res)
import sys
input = sys.stdin.readline
N = int(input())
A = 

rbg = [1, 0, 0]
ans = 1
for a in [int(a) for a in input().strip().split()]:
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] += 1

print(ans * 3 % (10 ** 9 + 7))

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
rbg = [0, 0, 0]
ans = 1
A = [int(a) for a in input().strip().split()]
for a in A:
    if rbg.count(a) == 0:
        print(0)
        exit()
    ans = (ans * rbg.count(a)) % (10 ** 9 + 7)
    rbg[rbg.index(a)] += 1

print(ans)
import numpy as np



N,M =[int(i) for i in input().split()]

a = np.ones(M)
b = np.ones(M)

for i in in range(M):
    a[i],b[i] = [int(j) for j in input().split()]
    
ans = np.zeros(N)
    
for i in range(N):
    A = int(a[i]-1)
    B = int(b[i]-1)
    ans[A]+=1
    ans[B]+=1
    
for i in range(N):
    print(ans[i])
    


### FIXED CODE ###

import numpy as np



N,M =[int(i) for i in input().split()]

a = np.ones(M)
b = np.ones(M)

for i in range(M):
    a[i],b[i] = [int(j) for j in input().split()]
    
ans = np.zeros(N)
    
for i in range(M):
    A = int(a[i]-1)
    B = int(b[i]-1)
    ans[A]+=1
    ans[B]+=1
    
for i in range(N):
    print(int(ans[i]))
import math
H, W = map(int, input().split())
s = []
flag = 0
ans = "No"
for i in range(W):
  s.append(list(input()))
if flag == 0:
  for i in range(H):
    for j in range(W):
      if s[i][j] == "#":
        if s[max(0, i - 1)][j] == "#" or s[i][max(0, j - 1)] == "#" or s[min(H - 1, i + 1)][j] == "#" or s[i][min(W - 1, j + 1)] == "#":
          continue
        else:
          flag += 1
if flag == 0:
  ans = "Yes"
print(ans)

### FIXED CODE ###

import math
H, W = map(int, input().split())
s = []
flag = 0
ans = "No"
for i in range(H):
  s.append(list(input()))
for i in range(H):
  for j in range(W):
    if flag == 0:
      if s[i][j] == "#":
        if s[max(0, i - 1)][j] == "#" or s[i][max(0, j - 1)] == "#" or s[min(H - 1, i + 1)][j] == "#" or s[i][min(W - 1, j + 1)] == "#":
          continue
        else:
          flag += 1
if flag == 0:
  ans = "Yes"
print(ans)
a = int(input())
b = int(input())
print a*b
print (a*2)+(b*2)

### FIXED CODE ###

a,b=[int(i) for i in input().split()]
print(a*b,(a+b)*2)
N, K = map(int, input().split())
lst = list(map(int, input().split()))
i = 0
for h_i in lst:
    if h_i < K:
        continue
    else:
        i += 1
print(i)

### FIXED CODE ###

N = int(input())
print(0.5 if N % 2 == 0 else -(-N // 2)/ N)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
aindex=n+1
bindex=m+1
acumsum = [0]
bcumsum = [0]

ab =0
for aa in range(n):
  ab += a[aa]
  acumsum.append(ab)# = ab
  if ab>k:
    aindex= aa
    break

ab =0
for bb in range(m):
  ab += b[bb]
  bcumsum.append(ab)
  if ab>k:
    bindex= bb
    break


from bisect import bisect_left
for i in range(aindex+1):
  j = bisect_left(bcumsum, k-acumsum[i])-1
  ans = max(ans, i+j)
print(ans)

### FIXED CODE ###

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
aindex=n
bindex=m
acumsum = [0]
bcumsum = [0]

ab =0
for aa in range(n):
  ab += a[aa]
  acumsum.append(ab)# = ab
  if ab>k:
    aindex= aa
    break

ab =0
for bb in range(m):
  ab += b[bb]
  bcumsum.append(ab)
  if ab>k:
    bindex= bb
    break

j= bindex
for i in range(aindex+1):
  if acumsum[i] >k:
    break
  while bcumsum[j] > k-acumsum[i]:
    j -=1
  ans = max(ans, i+j)

print(ans)
n, m = map(int,input().split())
f = [False for _ in range(n)]
f[0] = True
for i in range(m):
  x, y = map(int,input().split())
  f[y] = f[y] or f[x]
print(f.count(True))

### FIXED CODE ###

n, m = map(int,input().split())
f = [False for _ in range(n)]
c = [1 for _ in range(n)]
f[0] = True
for i in range(m):
  x, y = map(int,input().split())
  f[y - 1] = f[y - 1] or f[x - 1]
  c[y - 1] += 1
  c[x - 1] -= 1
  if c[x - 1] == 0:
    f[x - 1] = False
ans = 0
for i in range(n):
  if f[i] and c[i] > 0:
    ans += 1
print(ans)
# -*- coding:utf-8 -*-
from operator import itemgetter
n = int(raw_input())
a = [[int(k),i+1] for i,k in enumerate(raw_input().split())]
a.sort(key=itemgetter(0),reverse=True)
u = []
s=[0]*n
a.append([0,0])
for i,p in enumerate(a[:-1]):
    if not p[0] == a[i+1][0]:
        q = p[0] - a[i+1][0]
        y = [z[1] for z in a[:i+1]]
        s[min(y)-1] += (i+1)*q
        u.extend([min(y)]*(i+1)*q)

for t in s:
    print(t)

### FIXED CODE ###

# -*- coding:utf-8 -*-
n = int(raw_input())
a = [[int(k),i+1] for i,k in enumerate(raw_input().split())]
a.sort(reverse=True)
z = [l[1] for l in a]
s=[0]*n
a.append([0,0])
min_a_i = float('inf')
for i,p in enumerate(a[:-1]):
    min_a_i = min(min_a_i, a[i][1])
    if not p[0] == a[i+1][0]:
        q = p[0] - a[i+1][0]
        s[min_a_i-1] += (i+1)*q

for t in s:
    print(t)
N, M = list(map(int, input().split(' ')))
    r = [ None for i in range(N) ]
     
    illegal = False
    for i in range(M):
      s, c = list(map(int, input().split(' ')))
      if r[s-1] is not None and r[s-1] != c:
        illegal = True
        break
      r[s-1] = c
     
    v = -1
    if not illegal:
      for i in range(N):
        if r[i] is None:
          if i == 0 and N != 1:
            r[i] = 1
          else:
            r[i] = 0
      v = sum(r[i] * 10**i for i in range(N))
      if v < 10**(N-1) and not (N == 1 and v == 0):
        v = -1
     
    print(v)

### FIXED CODE ###

N, M = list(map(int, input().split(' ')))
r = [ None for i in range(N) ]

illegal = False
for i in range(M):
  s, c = list(map(int, input().split(' ')))
  if r[s-1] is not None and r[s-1] != c:
    illegal = True
    break
  r[s-1] = c

v = -1
if not illegal:
  for i in range(N):
    if r[i] is None:
      if i == 0 and N != 1:
        r[i] = 1
      else:
        r[i] = 0
  v = sum(r[i] * 10**(N-1-i) for i in range(N))
  if v < 10**(N-1) and not (N == 1 and v == 0):
    v = -1

print(v)
a,b = map(int,inpu().split())

ans = 0
if a < = 5:
    ans = 0
elif a < = 12:
    ans = b/2
else :
    ans = b
print(ans)


### FIXED CODE ###

a,b = map(int,input().split())

ans = 0
if a <= 5:
    ans = 0
elif a <= 12:
    ans = b/2
else :
    ans = b
print(int(ans))
import math
from collections import deque
def main():
    n = int(input())
    a = [int(t)for t in input().split()]

    if all([a_i>0 for a_i in a]):
        print(n-1)
        for i in range(n-1):
            print(i+1,i+2)
        
    elif all([a_i<=0 for a_i in a]):
        print(n-1)
        for i in range(2,n+1)[::-1]:
            print(i,i-1)
    else:
        if abs(min(a))<max(a):
            print(2*n-1)
            pos = list.index(max(a))  
            for i in range(n):
                print(pos,i+1)
            for i in range(2,n+1)[::-1]:
                print(i,i-1)


        else:
            print(2*n-1)
            pos = list.index(min(a))
            for i in range(n):
                print(pos,i+1)  
            
            for i in range(2,n+1)[::-1]:
                print(i,i-1)
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

import math
from collections import deque
def main():
    n = int(input())
    a = [int(t)for t in input().split()]

    if all([a_i>0 for a_i in a]):
        print(n-1)
        for i in range(n-1):
            print(i+1,i+2)
        
    elif all([a_i<=0 for a_i in a]):
        print(n-1)
        for i in range(2,n+1)[::-1]:
            print(i,i-1)
    else:
        if abs(min(a))<max(a):
            print(2*n-1)
            pos = a.index(max(a))  
            for i in range(n):
                print(pos+1,i+1)
            for i in range(n-1):
                print(i+1,i+2)


        else:
            print(2*n-1)
            pos = a.index(min(a))
            for i in range(n):
                print(pos+1,i+1)  
            
            for i in range(2,n+1)[::-1]:
                print(i,i-1)
    
if __name__ == "__main__":
    main()
N = int(input())
A = [abs(int(input())) for _ in range(N)]
#A.sort()
s = sum(A)

def mulmod(p,q,mod):
  return ((p%mod)*(q%mod))%mod
def powermod(p,n,mod):
  if n==0: return 1
  if n==1: return p%mod
  else:    return powermod(p,n//2,mod)**2 * (p**(n%2)) %mod
def dividemod(p,q,mod):
  # modは素数
  return mulmod(p, powermod(q,mod-2,mod), mod)

mod = 998244353

dp = [[0]*(s+1) for _ in range(N)]
# dp[n][s] An-1(0-index)まで加えて、Rの和がsになるのが何通りか（残りのG,Bまで含めて）
dp[0][0] = 2
dp[0][A[0]] = 1
temp_sum = A[0]

for i in range(1,N):
  for j in range(A[i]):
    dp[i][j] = (dp[i-1][j]*2) %mod
  for j in range(A[i], temp_sum+1):
    dp[i][j] = (dp[i-1][j]*2 + dp[i-1][j-A[i]]) %mod
  for j in range(temp_sum+1, temp_sum+1 + A[i]):
    dp[i][j] = (dp[i-1][j-A[i]]) %mod
  temp_sum += A[i]


def part_sum(a,A):
  p=mod
  #初期化
  N=len(a)
  dp=[[0 for i in range(A+1)] for j in range(N+1)]
  dp[0][0]=1

  #DP
  for i in range(N):
    for j in range(A+1):
      if a[i]<=j: #i+1番目の数字a[i]を足せるかも
        dp[i+1][j]=dp[i][j-a[i]]+ dp[i][j]% p
      else: #入る可能性はない
        dp[i+1][j]=dp[i][j]%p
  return dp[N][A]

ps = part_sum(A, s//2)

if s%2 != 0:
    answer = (powermod(3, N, mod) - 3*sum(dp[N-1][(s+1)//2:]))%mod
else:
    answer = (powermod(3, N, mod) - 3*(sum(dp[N-1][(s+1)//2:]) - ps))%mod



print(answer)


### FIXED CODE ###

N = int(input())
S = input()
answers = []

from itertools import accumulate

white_cumsum = list(accumulate([1 if s=='.' else 0 for s in S]))
black_cumsum = list(accumulate([1 if s=='#' else 0 for s in S]))

answers.append(white_cumsum[-1])
answers.append(black_cumsum[-1])

for i in range(N):
  answers.append(black_cumsum[i] + white_cumsum[-1] - white_cumsum[i])
    
answer = min(answers)
print(answer)
from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
mina = max(a)
a.sort()
for i in range(n-1):
    mina = min(mina,math.gcd(a[i],a[i+1]))
print(mina)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
mina = max(a)
def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)
a.sort()
for i in range(n-1):
    mina = min(mina,gcd(a[i],a[i+1]))
print(mina)
#!/usr/bin/env python3

n = int(input())
a = list(map(int, input().split()))


set_odd = set()
set_even = set()

for i in a:
    if i % 2 == 1:
        set_odd.add(i)
    else:
        set_even.add(i)

if len(set_odd) >= 2:
    print(1)
    exit()
elif len(set_odd) == 1:
    if len(set_even) >= 1:
        print(1)
        exit()
    else:
        print(min(set_odd))

# only even number
min_a = min(set_even)
set_even = list(set_even)

ans = []

for i in range(len(set_even)):
    ans_tmp = a[i] % min_a
    if ans_tmp != 0:
        ans.append(ans_tmp)
    if min_a-ans_tmp != 0:
        ans.append(min_a-ans_tmp)

if ans == []:
    print(min(set_even))
else:
    print(min(ans))


### FIXED CODE ###

#!/usr/bin/env python3

import fractions
n = int(input())
a = list(map(int, input().split()))


value = a[0]
for i in range(1, n):
    value = fractions.gcd(value, a[i])
print(value)