Harryxun/stf_run huggingface dataset:
t=list(input())

if t[0]=="A" and not t[1]=="C" and not t[-1]=="C":
    rs=1
else:
    rs=0

if t[1].isupper()==True or t[-1].isupper()==True:
    rs -=1

del t[:2]
del t[-1]

if not t.count("C")==1:
    rs -=1

if rs==1:
    t.remove("C")

for i in t:
    if i.isupper()==True:
        rs -=1

if rs==1:
    print("AC")
else:
    print("WA")


### FIXED CODE ###

t=int(input())

if t<1200:
    print("ABC")
elif t<2800:
    print("ARC")
else:
    print("AGC")
import sys
import fractions


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    m = 0
    for i in range(2, int(n ** 0.5) + 1):
        m = max(m, fractions.gcd(n, i))
    print(n // m + m - 2)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    t = n
    mt = 10 ** 20
    for i in range(1, int(n ** 0.5) + 1):
        if t % i == 0:
            mt = min(mt, (i - 1) + (t // i - 1))
    print(mt)


if __name__ == '__main__':
    solve()
N = int(input())
A = list(map(int,input().split()))

if 0 in A:
    print(0)

x = 1
for i in range(N):
    x = x * A[i]
    if x>10**18:
        x = -1
print(x)

### FIXED CODE ###

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

print(a*b)
while True:
    a,op,b=map(istr,input().split())
    a=int(a)
    b=int(b)
    if op=="?":
        break
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    else:
        print(int(a/b))




### FIXED CODE ###

while True:
    a,op,b=map(str,input().split())
    a=int(a)
    b=int(b)
    if op=="?":
        break
    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="*":
        print(a*b)
    else:
        print(int(a/b))
n,q = map(int,input().split())
s = [0 for i in range(n-1)]
for i in range(n-1):
    a,b = map(int,input().split())
    s[i] = [a,b]
s.sort()
ans = [-1 for i in range(n)]
for i in range(n-1):
    ans[s[i][1]-1] = s[i][0]-1
count = [0 for i in range(n)]
for i in range(q):
    p,x = map(int,input().split())
    count[p-1] += x
ans1 = [0 for i in range(n)]
ans1[0] = count[0]
for i in range(1,n):
    ans1[i] = ans1[ans[i]] + count[i]
for i in range(n):
    print(ans1[i])

### FIXED CODE ###

n,m = map(int,input().split())
ans = 0
import heapq
g = [[] for i in range(100000)]
for i in range(n):
    a,b = map(int,input().split())
    a -= 1
    g[a].append(-b)
for i in range(100000):
    heapq.heapify(g[i])
p = []
heapq.heapify(p)
for i in range(m):
    if len(g[i]) != 0:
        heapq.heappush(p,[heapq.heappop(g[i]),i])
    if len(p) != 0:
        x = heapq.heappop(p)
        ans += -x[0]
        if len(g[x[1]]) != 0:
            heapq.heappush(p,[heapq.heappop(g[x[1]]),x[1]])            
print(ans)
def k(n):
  if n%26!=0:
    return n%26
  else:
    return 26
L=list(range(1,366))
L=list(map(k,L))
L=reversed(L)
for i in range(365):
  print(L[i])

### FIXED CODE ###

def k(n):
  if n%26!=0:
    return n%26
  else:
    return 26
L=list(range(1,366))
L=list(map(k,L))
for i in range(365):
  print(L[i])
import math
n, p = [int(i) for i in input().split()]
max_x = int(p**(1/n))
ans = 1
if n >= p:
    print(1)
else:
    for i in range(max_x+1, 1, -1):
        if p % int(math.pow(i,n)) == 0:
            ans = i
            break
    print(ans)

### FIXED CODE ###

n, p = [int(i) for i in input().split()]
tmp = p**(1/n)
if tmp - int(tmp) > 0.999:
    max_x = int(tmp) + 1
else:
    max_x = int(tmp)
ans = 1
for i in range(max_x, 1, -1):
    if p % pow(i,n) == 0:
        ans = i
        break
print(ans)
h,a = map(int,inpit().split())
ans = 0
for k in range(100000000):
  h = h-a
  if h <=0:
    ans = k+1
    break
print(ans)

### FIXED CODE ###

h,a = map(int,input().split())
ans = 0
for k in range(100000000):
  h = h-a
  if h <=0:
    ans = k+1
    break
print(ans)
a = (int)input()
b = (int)input()

if a >= 13:
  print(b)
elif a >= 6 && a <= 12:
  print(b/2)
else:
  print(0)
    


### FIXED CODE ###

a,b = map(int, input().split())
 
ans=0
if a <= 5:
	ans = 0
elif a >= 6 and a<=12:
	ans = b/2
else:
	ans = b
 
print(int(ans))
n = int(input())
A = list(map(int, input().split()))

ans1 = 0
sum = A[0]
for a in A[1:]:
    if (sum + a) * sum < 0:
        sum += a
    else:
        fugo = sum // abs(sum)
        nextsum = - fugo
        a_should_be = nextsum - sum
        dif = abs(a_should_be - a)
        sum += a_should_be
        ans1 += dif

print(ans1)

ans2 = A[0] + 1
sum = - (A[0] // abs(A[0]))

for a in A[1:]:
    if (sum + a) * sum < 0:
        sum += a
    else:
        fugo = sum // abs(sum)
        nextsum = - fugo
        a_should_be = nextsum - sum
        dif = abs(a_should_be - a)
        sum += a_should_be
        ans2 += dif
        
print(ans2) 
#A[0]を反転したほうがいいパターンの処理

### FIXED CODE ###

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

if A[0] != 0:
    ans1 = 0
    sum = A[0]
else:
    ans1 = 1
    sum = 1
# A[0]=0 のときは1にする。下で-1にするパターンも試している。なお0は不可。

for a in A[1:]:
    if (sum + a) * sum < 0:
        sum += a
    else:
        nextsum = 1 if sum < 0 else -1
        # fugo = sum // abs(sum) 割り算のときは0に気をつけろ！
        a_should_be = nextsum - sum
        dif = abs(a_should_be - a)
        sum = nextsum
        ans1 += dif

#A[0]を反転したほうがいいパターンの処理
ans2 = abs(A[0]) + 1
sum = 1 if A[0] < 0 else -1
#ある意味、ここでA[0]=0のときに-1にすることもやっている

for a in A[1:]:
    if (sum + a) * sum < 0:
        sum += a
    else:
        nextsum = 1 if sum < 0 else -1
        a_should_be = nextsum - sum
        dif = abs(a_should_be - a)
        sum = nextsum
        ans2 += dif
        
print(min(ans1, ans2))
import itertools
n,m,q=list(map(int,input().split()))
q_l=[list(map(int,input().split())) for _ in range(q)]
#print(q_l)
#bar_l = [(i,j,k) for i in range(0,m+1) for j in range(i,m+1) for k in range(j,m+1)]
bar_m = [i for i in range(m)]
#print(bar_m)
bar_l = list(itertools.combinations_with_replacement(bar_m,m))
#print(bar_l)
score = 0
for bar in bar_l:
    score_tmp=0
    for queue in q_l:
        if bar[queue[1]-1]-bar[queue[0]-1]==queue[2]:
            score_tmp+=queue[3]
    #print(score_tmp)
    if score<score_tmp:
        score=score_tmp
print(score)


### FIXED CODE ###

import itertools
n,m,q=list(map(int,input().split()))
q_l=[list(map(int,input().split())) for _ in range(q)]
#bar_l = [(i,j,k) for i in range(0,m+1) for j in range(i,m+1) for k in range(j,m+1)]
bar_m = [i for i in range(m)]
bar_l = list(itertools.combinations_with_replacement(bar_m,n))
score = 0
for bar in bar_l:
    score_tmp=0
    for queue in q_l:
        if bar[queue[1]-1]-bar[queue[0]-1]==queue[2]:
            score_tmp+=queue[3]
    #print(score_tmp)
    if score<=score_tmp:
        score=score_tmp
        #print(bar)
print(score)
import time
import random

timestart = time.time() 
D = int(input())
c = list(map(int,input().rstrip().split(" ")))
s = []
ta = []
ta_buf = []

man = 0
man_buf = 0
kankaku = [0 for i in range(27)]
for i in range(D):
    s.append(list(map(int,input().rstrip().split(" "))))

for i in range(D):
    p = 0
    t = 0
    for i2 in range(26):
        if p < s[i][i2] + c[i2] * kankaku[i2] * (kankaku[i2] * 2) // 2:
            p = s[i][i2] + c[i2] * kankaku[i2] * (kankaku[i2] * 2) // 2
            t = i2 + 1
    kankaku[t - 1] = -1
    ta.append(t)
    for i in range(26):
        kankaku[i] += 1

t.append(-1)
for i in range(D):
    man += s[i][ta[i]]
    last[ta[i]] = i + 1
    for i2 in range(26):
        man -= (i + 1 - last[i2]) * c[i2]

while timestart + 1.900 > time.time():
    for i in range(D):
        ta_buf[i] = ta[i]
    a = randint(0,360)
    b = a + randint(1,4)
    ta_buf[a], ta_buf[b] = ta_buf[b],ta_buf[a]

    for i in range(D):
        man_buf += s[i][ta_buf[i]]
        last[ta_buf[i]] = i + 1
        for i2 in range(26):
            man_buf -= (i + 1 - last[i2]) * c[i2]

    if man_buf > man:
        man = man_buf
        for i in range(D):
            ta[i] = ta_buf[i]

for i in range(D):
    print(ta[i] + 1)

### FIXED CODE ###

D = int(input())
c = list(map(int,input().rstrip().split(" ")))
s = []
kankaku = [0 for i in range(27)]
for i in range(D):
    s.append(list(map(int,input().rstrip().split(" "))))

for i in range(D):
    p = 0
    t = 0
    for i2 in range(26):
        if p < s[i][i2] + c[i2] * kankaku[i2] * (kankaku[i2] * 2) // 2:
            p = s[i][i2] + c[i2] * kankaku[i2] * (kankaku[i2] * 2) // 2
            t = i2 + 1
    kankaku[t - 1] = -1
    print(t)
    for i in range(26):
        kankaku[i] += 1
import sys

input = sys.stdin.readline

def main():
    x, n = map(int, input().rstrip().split())
    if n == 0:
        print(x)
        sys.exit()
    else:
        p = list(map(int, input().rstrip().split()))
        if x > max(p):
            print(x)
            sys.exit()
        else:
            p_x = set(range(min(p), max(p)+1))
            p_temp = set(p)
            p_diff = p_x - p_temp
            p_temp = list(p_diff).sort()
            p_dir = []

        for i in range(len(p_temp)):
            p_dir.append(abs(p_temp[i] - x))
        print(p_temp[p_dir.index(min(p_dir))])
  
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys

input = sys.stdin.readline

def main():
    x, n = map(int, input().rstrip().split())
    if n == 0:
        print(x)
        sys.exit()
    else:
        p = list(map(int, input().rstrip().split()))
        if x > max(p):
            print(x)
            sys.exit()
        else:
            p_x = set(range(102))
            p_temp = set(p)
            p_diff = p_x - p_temp
            p_temp = list(p_diff)
            p_temp = sorted(p_temp)
            p_dir = []

        for i in range(len(p_temp)):
            p_dir.append(abs(p_temp[i] - x))
        print(p_temp[p_dir.index(min(p_dir))])
  
if __name__ == "__main__":
    main()
n, k = map(int, input().split())
a = list(map(int, input().split()))
a_copy = [] + a
a_digit = [0 for i in range(n)]
digit = []
k_bin = list(map(int, str(bin(k)).replace("0b", "")))

same = True
for _ in range(len(k_bin)):
  for i in range(n):
    a_digit[i] = a[i] % 2
    a[i] = int(a[i] / 2)
  if a_digit.count(0) >= n / 2:
    if same:
      if k_bin[i] == 0:
        digit.append(0)
      else:
        digit.append(1)
    else:
      digit.append(1)
  else:
    digit.append(0)
    if k_bin[i] == 1:
      same = False

x = 0
for i in range(len(digit)):
  x += 2 ** i * digit[i]
ans = 0
for ai in a_copy:
  ans += ai ^ x
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))

X = 0
k = 1 << 41
for _ in range(41):
  k = k >> 1
  if X + k > K:
    continue
  
  count = 0
  for i in range(N):
    if A[i] & k:
      count += 1
  
  if count < N / 2:
    X += k
    
ans = 0
for i in range(N):
  ans += A[i] ^ X
  
print(ans)
x,a,b = map(int,input().split())
print((x-a)%b)

### FIXED CODE ###

x = int(input())
a = int(input())
b = int(input())
print((x-a)%b)
n = int(input())
h_list = list(int, input().split())

ans, cnt = 0, 0
tmp = 0
for h in h_list:
    if h > tmp:
        ans = max(cnt, ans)
        cnt = 0
    else: cnt += 1
print(max(cnt, ans))

### FIXED CODE ###

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

ans, cnt = 0, 0
tmp = 0
for h in h_list:
    if h > tmp:
        ans = max(cnt, ans)
        cnt = 0
    else: cnt += 1
    tmp = h
        
print(max(cnt, ans))
H , A = input().split().
count = 0
while H > 0:
    H -= A
    count +=1

print(count)


### FIXED CODE ###

H , A = map(int,input().split())
count = 0
while H > 0:
    H -= A
    count +=1

print(count)
from operator import itemgetter
n = int(input())

list_p = []
for i in range(n):
    for j in range(n - i):
        if i*j == 100:
            list_p.append([i, j, i+j])
list_sorted = sorted(list_p, key=itemgetter(2))
print(list_sorted[0][0] + list_sorted[0][1] - 2)

### FIXED CODE ###

from operator import itemgetter
n = int(input())

list_p = []
for i in range(1, int(n**0.5)+1):

    j = n / i

    if j.is_integer():
        list_p.append([i, j, i+j])

list_sorted = sorted(list_p, key=itemgetter(2))
print(int(list_sorted[0][0] + list_sorted[0][1] - 2))
from collections import defaultdict as dd
from collections import deque
import collections as col
d=dd(list)
q=deque([])

N,M=map(int, input().split())
for _ in range(M):
    f=0
    i,j=map(int, input().split())
    if i>j:
        i,j=j,i
    d[i].append(j)
chk=[0]*N
chk[0]=1
temp=1
a=0
while a<N:
    for i in range(len(d[temp])):
        chk[d[temp][i]-1]=1
        q.append(d[temp][i])

    if len(q)>0:
        while a<N:
            if chk[a]==0:
                q.append(a+1)
            a+=1
    else:
        temp=q.pop()

ans=0
for i in  range(len(d)):
    ans=max(ans,len(col.Counter(d[i]))+1)
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

def find(x):
    if par[x]==x:
        return x
    else:
        par[x]=find(par[x])
        return par[x]

def union(a,b):
    a=find(a)
    b=find(b)
    if a==b:
        return
    
    if rank[a]<rank[b]:
        par[a]=b
        rank[b]+=rank[a]
        rank[a]=rank[b]
    else:
        par[b]=a
        rank[a]+=rank[b]
        rank[b]=rank[a]

    return

def chk(a,b):
    if par[a]==par[b]:
        print('Yes')
    else:
        print('No')

    return

N,M=map(int, input().split())

par=(list(range(N+1)))
rank=[1]*(N+1)

for _ in range(M):
    A,B=map(int, input().split())
    union(A,B)

print(max(rank))
N,X=map(int,input().split())
L=list(map(int,input().split()))

D=[0]*(N)

D[0]=0
count=1
for i in range(1,N):
  D[i]=D[i-1]+L[i-1]
  if D[i]<=X:
    count+=1
  else:
    break
print(count)


### FIXED CODE ###

X,A=map(int,input().split())
if X < A:
  print('0')
else:
  print('10')
import statistics
import math

N = int(input())
A = list(map(int, input().split()))
b = 0
li = []
for i in range(N):
  li.append(abs(A[i]-(b+i+1)))
if max(A) == N:  
  print(sum(li))
else :
  mode = max(li)
  mode = statistics.mode(li)
  b = -mode
  li.clear()
  for i in range(N):
    li.append(abs(A[i]-(b+i+1)))
  print(sum(li))


### FIXED CODE ###

import statistics

N = int(input())
A = list(map(int, input().split()))
B = []
li = []
for i in range(N):
  B.append(A[i] - (i+1))
b = int(statistics.median(B))
for i in range(N):
  li.append(abs(A[i] - (b+i+1)))
print(sum(li))
a, b = list(map(int, input()))
print(max(a+b, a-b, a*b))

### FIXED CODE ###

a, b = list(map(int, input().split()))
print(max(a+b, a-b, a*b))
product = a*b
if product%2==0:
    print("Even")
elif product%2==1:
    print('Odd')

### FIXED CODE ###

a,b = map(int,input().split())
 
product = a*b
if product%2==0:
    print("Even")
elif product%2==1:
    print('Odd')
# unionfind

class UnionFind(object):

    def __init__(self, n):
        self.n = n
        self.parent = list(range(self.n + 1))
        self.rank = [0]*n

    def find_parent(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find_parent(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        xp = self.find_parent(x)
        yp = self.find_parent(y)
        if xp == yp:
            return None
        else:
            self.parent[xp] = yp
            return None


N, M = map(int, input().split())
uf = UnionFind(N+1)

for _ in range(M):
    x, y, z = map(int, input().split())
    uf.unite(x, y)

res = [0] * (N + 1)
res_c = 0
for i in range(1, N + 1):
    j = uf.find_parent(i)
    if res[j] == 0:
        res_c += 1
    res[j] += 1

print(N - (sum(res) - res_c))


### FIXED CODE ###

# unionfind


class UnionFind(object):

    def __init__(self, n):
        self.n = n
        self.parent = list(range(self.n))
        self.rank = [0]*n

    def find_parent(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find_parent(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find_parent(x)
        y = self.find_parent(y)
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


N, M = map(int, input().split())
uf = UnionFind(N+1)

for _ in range(M):
    xx, yy, zz = map(int, input().split())
    uf.unite(xx, yy)

res = [0] * (N + 1)
res_c = 0
for i in range(1, N + 1):
    j = uf.find_parent(i)
    if res[j] == 0:
        res_c += 1
    res[j] += 1

print(N - (sum(res) - res_c))
# Circle in a Rectangle

a = [int(i) for i in input().rstrip().split()]
rectangle = [a[0], a[1]]
circleCenter = [a[2], a[3]]
circleRadius = a[4]

if a[2] - a[4] >= 0 and a[2] + a[4] <= a[0]:
    if a[3] - [4] >= 0 and a[3] + a[4] <= a[1]:
        print('Yes')
    else:
        print('No')
else:
    print('No')



### FIXED CODE ###

# Circle in a Rectangle

a = [int(i) for i in input().rstrip().split()]
rectangle = [a[0], a[1]]
circleCenter = [a[2], a[3]]
circleRadius = a[4]

if a[2] - a[4] >= 0 and a[2] + a[4] <= a[0]:
    if a[3] - a[4] >= 0 and a[3] + a[4] <= a[1]:
        print('Yes')
    else:
        print('No')
else:
    print('No')
N, *A = map(int, open(0).read().split())

A = [0] + A
B = [0] * (N + 1)
sum_B = 0
for i in range(N, 0, -1):
    if sum(B[j] for j in range(i, N + 1, i)) % 2 != A[i]:
        B[i] = 1
        sum_B += 1
print(sum_B)
print(*[i for i, b in enumerate(B) if b])


### FIXED CODE ###

from bisect import bisect_left


def solve():
    S = input()
    T = input()
    if not set(T) <= set(S):
        return -1

    pos = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
    for i, c in enumerate(S):
        pos[c].append(i)
    ans = 0
    cur_pos = 0
    for t in T:
        nxt_idx = bisect_left(pos[t], cur_pos)
        if nxt_idx == len(pos[t]):
            ans += len(S)
            cur_pos = 0
            nxt_idx = bisect_left(pos[t], cur_pos)
            cur_pos = pos[t][nxt_idx] + 1
        else:
            cur_pos = pos[t][nxt_idx] + 1

    return ans + cur_pos


print(solve())
def main(int_list):
  sorted_list = sorted(int_list)
  print str(sorted_list[0]) + ' ' + str(sorted_list[1]) + ' ' + str(sorted_list[2]) 

int_list = []
input_string = raw_input()
input_list = raw_input().split(' ')
for i in input_list:
  int_list.append(int(i))

main(int_list)

### FIXED CODE ###

a, b, c = sorted(map(int, raw_input().split()))
print a, b, c
A,B=map(int,input().split())
if (A-2*B)>=0:
  print(A-2B)
else:
  print('0')

### FIXED CODE ###

A,B=map(int,input().split())
if A-2*B>=0:
  print(A-2*B)
else:
  print(0)
S = input()
x = list(set(S))
print("Yes" if len(set(S)) == 2 and len(S.remove(x[0])) == 2 and len(S.remove(x[1])) == 2 else "No")


### FIXED CODE ###

S = input()
x = list(set(S))
print("Yes" if len(set(S)) == 2 and S.count(x[0]) == 2 and S.count(x[1]) == 2 else "No")
n = int(input())
h = map(lambda x: int(x), input().split(' '))
flg = 0

for i in range(n):
    if i > 0:
        if h[i + 1] >= h[i]:
            pass
        else:
            if flg == 1:
                print('No')
                continue
            h[i] -= 1
            flg = 1

            if h[i + 1] >= h[i]:
                pass
            else:
                print('No')


### FIXED CODE ###

n = int(input())
h = input().split(' ')

for i in reversed(range(n)):
    if i < n - 1:

        h[i] = int(h[i])
        h[i + 1] = int(h[i + 1])

        if h[i] > h[i + 1]:
            h[i] -= 1
            if h[i] > h[i + 1]:
                print('No')
                exit()

print('Yes')
def make_divisors(n,m):
    divisors = []
    for i in range(1, int(n)):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
print(c[-1+k])

### FIXED CODE ###

def make_divisors(n,m):
    divisors = []
    for i in range(1,n+1):
        if n % i == 0 and m % i == 0:
            divisors.append(i)
    divisors.sort()
    return divisors
n,m,k = map(int,input().split())
if n <= m:
    c = make_divisors(n,m)
else:
    c = make_divisors(m,n)
c.reverse()
print(c[k-1])
n = int(input())
a = list(map(int, input().split()))
answer = sorted(a)[1]
for b in range(answer).reverse():
    cnt = 2
    flag = True
    for i in range(n):
        if a[i] % answer != 0:
            cnt -= 1
        if cnt == 0:
            flag = False
    if flag:
        break
    answer -= 1
print(answer)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
answer = sorted(a)[1]
if n == 2:
    pass
else:
    for b in reversed(range(answer)):
        cnt = 2
        flag = True
        for i in range(n):
            if a[i] % answer != 0:
                cnt -= 1
            if cnt == 0:
                flag = False
                break
        if flag:
            break
        answer -= 1
print(answer)
from itertools import gcd
n=int(input())
a,b=map(int,input().split())
d=a+b
for i in range(n-1):
    e,f=map(int,input().split())
    d=d*(e+f)//gcd(d,e+f)
print(d)

### FIXED CODE ###

n=int(input())
a,b=map(int,input().split())
for i in range(n-1):
    e,f=map(int,input().split())
    if (a//e+(1 if a%e!=0 else 0))*f>=b:
        b=f*(a//e+(1 if a%e!=0 else 0))
        a=e*(a//e+(1 if a%e!=0 else 0))
    else:
        a=e*(b//f+(1 if b%f!=0 else 0))
        b=f*(b//f+(1 if b%f!=0 else 0))
print(a+b)
n,m=map(int,input().split())
for i in range(m):
  l,r=list(map(int,input().split()))
ans=0
dif=max(l)-min(r)
if(diff>=0):
  ans=diff+1
else:
  ans=0


### FIXED CODE ###

minlist=[]
maxlist=[]
 
n,m=map(int,input().split())
for i in range(m):
  l,r=list(map(int,input().split()))
  minlist.append(l)
  if r>0:
    maxlist.append(r)
ans=0
dif=min(maxlist)-max(minlist)
if(dif>=0):
  ans=dif+1
else:
  ans=0
print(ans)
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if e-a>=k
  print('Yay!')
else:
  print(':(')


### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if e-a<=k:
  print('Yay!')
else:
  print(':(')
n = int(input())
alist = list(map(int, input().split()))
maxa, mina = max(alist), min(alist)

ans = []
if abs(maxa) >= abs(mina):
  p = alist.index(maxa) + 1
  for i in range(n):
    alist[i] += maxa
    ans.append((p, i+1))
  for i in range(n-1):
    alist[i+1] += a[i]
    ans.append((i+1, i+2))
else:
  p = alist.index(mina) + 1
  for i in range(n):
    alist[i] += mina
    ans.append((pos, i+1))
  for i in range(n-2, -1, -1):
    alist[i] += a[i+1]
    ans.append((i+2, i+1))

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

### FIXED CODE ###

n = int(input())
alist = list(map(int, input().split()))
maxa, mina = max(alist), min(alist)

ans = []
if abs(maxa) >= abs(mina):
  p = alist.index(maxa) + 1
  for i in range(n):
    alist[i] += maxa
    ans.append((p, i+1))
  for i in range(n-1):
    alist[i+1] += alist[i]
    ans.append((i+1, i+2))
else:
  p = alist.index(mina) + 1
  for i in range(n):
    alist[i] += mina
    ans.append((p, i+1))
  for i in range(n-2, -1, -1):
    alist[i] += alist[i+1]
    ans.append((i+2, i+1))

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