Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())
a=sorted(list(map(int, input().split())), reverse = True)
bc = sorted([list(map(int, input().split())) for _ in range(m)], key = lambda x:x[1], reverse = True)
i=0
j=0
cnt=0
ans=0
while True:
    if a[i]<bc[j][1]:
        ans+=min(n-cnt, bc[j][0])*bc[j][1]
        cnt+=min(n-cnt, bc[j][0])
        j+=1
    else:
        ans+=a[i]
        i+=1
        cnt+=1
    if cnt==n:
        break
print(ans)
    

### FIXED CODE ###

n, m = map(int, input().split())
a=sorted(list(map(int, input().split())), reverse = True)
bc = sorted([list(map(int, input().split())) for _ in range(m)], key = lambda x:x[1], reverse = True)
i=0
j=0
cnt=0
ans=0
while True:
    if j<m and a[i]<bc[j][1]:
        ans+=min(n-cnt, bc[j][0])*bc[j][1]
        cnt+=min(n-cnt, bc[j][0])
        j+=1
    else:
        ans+=a[i]
        i+=1
        cnt+=1
    if cnt==n:
        break
print(ans)
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
from itertools import permutations
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return


def main():
    n,m = map(int, input().split())
    graph = [[0 for _ in range(m)] for _ in range(m)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1][b-1] = 1
        graph[b-1][a-1] = 1
    # n!通りの並べ方があり，各並べ方について成立するかどうかを調べる．
    # 成立しないと判明した時点で探索をやめる
   
    a = [i+1 for i in range(n)]
    p = permutations(a)

    def check(x):
        # x: (1,3,4,6,7,2)
        for i in range(n-1):
            if not graph[x[i]-1][x[i+1]-1]:
                return False
        return True
    cnt = 0
    for x in p:
        if x[0] != 1:
            continue
        if check(x):
            cnt += 1       
    print(cnt)
    return

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
from itertools import permutations
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return


def main():
    n,m = map(int, input().split())
    graph = [[0 for _ in range(n)] for _ in range(n)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1][b-1] = 1
        graph[b-1][a-1] = 1
    # n!通りの並べ方があり，各並べ方について成立するかどうかを調べる．
    # 成立しないと判明した時点で探索をやめる
   
    a = [i+1 for i in range(n)]
    p = permutations(a)

    def check(x):
        # x: (1,3,4,6,7,2)
        for i in range(n-1):
            if not graph[x[i]-1][x[i+1]-1]:
                return False
        return True
    cnt = 0
    for x in p:
        if x[0] != 1:
            continue
        if check(x):
            cnt += 1       
    print(cnt)
    return

if __name__ == '__main__':
    main()
n, h, w = map(int, input().split())
tup_list = []
for i in range(n):
    tup_list.append((input().split()))
count = 0
for tuple in tup_list:
    if tuple[0] > h and tuple[1] > w:
        count += 1
print(count)


### FIXED CODE ###

nhw_list = list(map(int, input().split()))
tup_list = []
for i in range(nhw_list[0]):
    tup_list.append(list(map(int, input().split())))
count = 0
for tuple in tup_list:
    if tuple[0] >= nhw_list[1] and tuple[1] >= nhw_list[2]:
        count += 1
print(count)
n=int(input())
l=[int(input()) for i in range(n)]
for j in range(n):
    l2=l
    l2[i]=0
    print(max(l2))


### FIXED CODE ###

n=int(input())
l=[int(input()) for i in range(n)]
ma=sorted(l)[-2:]
for j in l:
    if j==ma[1]:
        print(ma[0])
    else:
        print(ma[1])
A=int(input())
B=int(input())

if A >= 13 :
  X=B
     print( '%d' % X )
elif X<=12 && X>=6 :
  X=B/2
     print( '%d' % X )
else:
     print( '0')

### FIXED CODE ###

A,B = (int(i) for i in input().split()) 
C=B/2
if A >= 13 :
  print( '%d' % B )
elif A<=12 and A>=6 :
  print( '%d' % C )
else:
  print( '0')
bingo=[]
for i in range(3):
  a=list(map(int,input().split()))
  bingo.append(a)
  
n=int(input())
for i in range(n):
  b=int(input())
  for j in range(3):
    if b in bingo[i]:
      bingo[i][bingo[i].index(b)]=0
      
def hantei(l):
  for i in range(3):
    if all([l[i][j]==0 for j in range(3)]):
      return 'Yes'
    
    elif all([l[j][i]==0 for j in range(3)]):
      return 'Yes'
    
    elif l[0][0]==0 and l[1][1]==0 and l[2][2]==0:
      return 'Yes'
    
    elif l[0][2]==0 and l[1][1]==0 and l[2][0]==0:
      return 'Yes'
    
    else:
      return 'No'
    
print(hantei(bingo))
    
    

### FIXED CODE ###

bingo=[]
for i in range(3):
  a=list(map(int,input().split()))
  bingo.append(a)
  
n=int(input())
for i in range(n):
  b=int(input())
  for j in range(3):
    if b in bingo[j]:
      bingo[j][bingo[j].index(b)]=0
      
def hantei(l):
  for i in range(3):
    if all([l[i][j]==0 for j in range(3)]):
      return 'Yes'
    
    elif all([l[j][i]==0 for j in range(3)]):
      return 'Yes'
    
    elif l[0][0]==0 and l[1][1]==0 and l[2][2]==0:
      return 'Yes'
    
    elif l[0][2]==0 and l[1][1]==0 and l[2][0]==0:
      return 'Yes'
    
    else:
      continue
      
  return 'No'
    
#print(bingo)
print(hantei(bingo))
A, B, C, D = [int(x) for x in input().split()]
t = A // D#HPが０になるもしくはギリギリの回数9
a = C // B#10大きいほうが勝利，同じ場合は高橋の勝利
if t >＝ a:#たかはしが倒されるほうがターン数は多くかかる
    print("Yes")
else:
    print("No")

### FIXED CODE ###

A, B, C, D = [int(x) for x in input().split()]
run = True
while run:
    C -= B
    if C <= 0:
        run = False
        result = "Yes"
        continue
    A -= D
    if A <= 0:
        run = False
        result = "No"
        continue
print(result)
import fractions

def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

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

### FIXED CODE ###

def prime(n):
    for i in range(2,n):
        if n%i==0:
            False
            return
    return True

n=int(input())

i=0
while True:
    if prime(n+i):
        print(n+i)
        exit()
    else:
        i+=1
N,M = map(int,input().split())

ans = N*M + M(M-1)//2
print(ans)

### FIXED CODE ###

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

ans = (N+M)*(N+M-1)//2 - N*M
print(ans)
def f(p, q):
    if q < p:
        return q
    else:
        return f(p, q//p) + q%p

n = int(input())
s = int(input())
flag = 0
if n < s:
    print(-1)
    flag = 1

if flag == 0:
    for i in range(2, int(n**0.5)+2):
        if f(i, n) == s:
            print(i)
            flag = 1
            break
if flag == 0:
    for i in range(1, int(n**0.5)+2):
        if (n-s)%i == 0:
            if f((n-s)//i+1, n) == s:
                print((n-s)//i+1)
                flag = 1
                break

if flag == 0:
    print(-1)

### FIXED CODE ###

def f(p, q):
    if q < p:
        return q
    else:
        return f(p, q//p) + q%p

n = int(input())
s = int(input())
flag = 0
if n < s:
    print(-1)
    flag = 1
if flag == 0 and n == s:
    print(n+1)
    flag = 1
if flag == 0:
    for i in range(2, int(n**0.5)+2):
        if f(i, n) == s:
            print(i)
            flag = 1
            break
if flag == 0:
    for i in range(int(n**0.5), 0, -1):
        if (n-s)%i == 0:
            if f((n-s)//i+1, n) == s:
                print((n-s)//i+1)
                flag = 1
                break

if flag == 0:
    print(-1)
# -*- coding: utf-8 -*-

n, m, l = list(map(int, input().split()))
a = []
b = []

for i in range(n):
    a.append(list(map(int, input().split())))

for i in range(m):
    b.append(list(map(int, input().split())))

for i in range(n):
    for j in range(l):
        mat_sum = 0
        for k in range(m):
            mat_sum += a[n][m] * b[m][l]
        print('{0} '.format(mat_sum), end='')
    print()


### FIXED CODE ###

# -*- coding: utf-8 -*-

n, m, l = list(map(int, input().split()))
a = []
b = []

for i in range(n):
    a.append(list(map(int, input().split())))

for i in range(m):
    b.append(list(map(int, input().split())))

for i in range(n):
    for j in range(l):
        mat_sum = 0
        for k in range(m):
            mat_sum += a[i][k] * b[k][j]
        if j == l - 1:
            print('{0}'.format(mat_sum), end='')
        else:
            print('{0} '.format(mat_sum), end='')
    print()
s = input()

weather = ["Sunny", "Cloudy", "Rainy"]
print(weather[weather.index(s) + 1])


### FIXED CODE ###

s = input()

weather = ["Sunny", "Cloudy", "Rainy"]
print(weather[(weather.index(s) + 1) % 3])
import sys
sys.setrecursionlimit(10**5)

N,Q=map(int,input().split())
tree=[[] for i in range(N)]

for i in range(N-1):
  a,b=map(int,input().split())
  if tree[a-1]==None:
    tree[a-1]=[b-1]
  else:
    tree[a-1].append(b-1)

point=[0]*N

beginpoint=[0]*N

def search(v,sum):
  if v>=N:
    return
  else:
    herepoint=beginpoint[v]
    point[v]=sum+herepoint
    for j in range(len(tree[v])):
      search(tree[v][j],point[v])

for i in range(Q):
  p,x=map(int,input().split())
  p=p-1
  beginpoint[p]=beginpoint[p]+x

search(0,0)
  
print(*point)


### FIXED CODE ###

N,Q=map(int,input().split())
tree={}
for i in range(N-1):
  a,b=map(int,input().split())
  if (a-1) in tree:
    tree[a-1].append(b-1)
  else:
    tree[a-1]=[b-1]
  if (b-1) in tree:
    tree[b-1].append(a-1)
  else:
    tree[b-1]=[a-1]

point=[0]*N

for i in range(Q):
  p,x=map(int,input().split())
  point[p-1]+=x

ans=[0]*N
stack=[]
stack.append([0,0,-1])
while len(stack)>0:
  nodes=stack.pop()
  node=nodes[0]
  sump=nodes[1]
  parent=nodes[2]
  sump=sump+point[node]
  ans[node]=sump
  if node in tree:
      childs=tree[node]
      for child in childs:
        if child!=parent:
          stack.append([child,sump,node])

print(*ans)
import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, M = map(int, input().split())
if M < 2:
    Count = comb(N, 2)
elif N < 2:
    Count = comb(M, 2)
else:
    Count = comb(N, 2) + comb(M, 2)
print(Count)



### FIXED CODE ###

import math


def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N, M = map(int, input().split())
if M < 2 and N < 2:
    Count = 0
elif M < 2:
    Count = comb(N, 2)
elif N < 2:
    Count = comb(M, 2)
else:
    Count = comb(N, 2) + comb(M, 2)
print(Count)
n = int(input())
m = int(input())

sum = 0

if n > 1:
    sum += 2 ** (n // 2)
else:
    sum += 1

if m > 1:
    sum += 2 ** (m // 2)
else:
    sum += 1

print(sum)


### FIXED CODE ###

n, m = map(int, input().split())

count = 0
if n > 1:
  count += n * (n - 1) // 2
if m > 1:
  count += m * (m - 1) // 2
print(count)
n=int(input())
l = sorted(list(map(int, input().split())))
print(l[n/2] - l[n/2-1])


### FIXED CODE ###

n=int(input())
l = sorted(list(map(int, input().split())))
print(l[n//2] - l[n//2-1])
a,b=map(int(),input().split())
print(a*b)

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b)
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
n=  int(sys.stdin.readline())
import numpy as np
l=np.arange(1,n+1)
p=np.arange(2,n)
if n ==1:
    print(0)
else:
    print(sum(p)+1)

### FIXED CODE ###

import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
n=  int(sys.stdin.readline())
if n ==1:
    print(0)
elif n == 2:#なぜ？
    print(1)
else:
    print(n*(n-1)//2)
# ABC119B - Digital Gifts
def main():
    _, XU = open(0).read().split()
    ans, RATE = 0, 380000
    for x, u in zip(*[iter(XU)] * 2):
        x = float(x)
        total += x if u == "JPY" else x * RATE
    print(total)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC119B - Digital Gifts
n = int(input())
lst = [input().rstrip().split() for _ in range(n)]
total = 0

for i in range(n):
    if lst[i][1] == 'JPY':
        total += int(lst[i][0])
    else:
        total += 380000 * float(lst[i][0])
        
print(total)
import fractions
import sys
N,K = map(int,input().split())
L = []
L.append(N)
i = 0
if N == K:
    print(N)
    sys.exit(0)
if N == 0:
    print(0)
    sys.exit(0)
if K == 1:
    print(0)
    sys.exit(0)
Q = 0
while True:
  L.append(abs(N-K))
  N = abs(N-K)
  i += 1
  if i > 10**5:
    Q = min(L)
    break
if (N%2 == 0 and K%2 == 0):
  if N > K:
    print(0)
    sys.exit(0)
  else:
    print(N)
    sys.exit(0)
if (N%2 != 0 and K%2 != 0):
  if N<K:
    print(N)
    sys.exit(0)
  else:
    print(min(N,abs(N-K),Q))
    sys.exit(0)
else:
  if N > K:
   	if N%K == 0:
      print(0)
      sys.exit(0)
    else:
      print(min(N,Q,fractions.gcd(N,K)))
      sys.exit(0)
  else:
    print(min(N,Q))
  

### FIXED CODE ###

import fractions
import sys
N,K = map(int,input().split())
L = []
L.append(N)
i = 0
if N == K:
    print(0)
    sys.exit(0)
if N == 0:
    print(0)
    sys.exit(0)
if K == 1:
    print(0)
    sys.exit(0)
Q = 0
N-=((N//K)*K)
while True:
  L.append(abs(N-K))
  N = abs(N-K)
  i += 1
  if i > 10**5:
    Q = min(L)
    break
if N%K == 0 and N>=K:
    print(0)
else:
    if N < K:
        print(min(N,Q))
    else:
        print(min(N%K,Q,fractions.gcd(N,K)))
s=list(input())
t=list(input())

x=len(s)

ch1=0
ch=0

for i in range(x):
  if s[i]=t[x-1-i]:
    ch+=1

for j in range(x):
  if s[j]=t[j]:
    ch1+=1
    
print('Yes') if ch==x or ch1==x else print('No') 


### FIXED CODE ###

s=list(input())
t=list(input())

S=s+s
c=0

for i in range(len(s)):
  ch=0
  for j in range(len(s)):
    if S[i+j]==t[j]:
      ch+=1
  if ch==len(s):
    c+=1

if c>0:
  print('Yes')
  
else:
  print('No')
import math
a, b = map(int, input().split)
c = int(str(a)+str(b))
if math.sqrt(c) % 2 == 0:
  Yes
else:
  No

### FIXED CODE ###

import math
a, b = map(int, input().split())
c = int(str(a)+str(b))
if math.sqrt(c) - int(math.sqrt(c))== 0:
  print("Yes")
else:
  print("No")
a = input().int()
b = input().int()

if a % b == 0:
  print('Even')
else:
  print('Odd')




### FIXED CODE ###

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

if (a*b) %2 == 0:
  print("Even")
else:
  print('Odd')
n=int(input())
l=list(map(int,input().split()))
cnt=0
for i in range(n):
  if l[i] == i+1:
    change=l[i]
    l[i]=l[i+1]
    l[i+1]=change
    cnt+=1
print(cnt)


### FIXED CODE ###

x,t=map(int,input().split())
print(max(x-t,0))
s = list(input())
s2 = []
for i in range(len(s)):
    s2.append(s[i])
s3 = list(set(s2))
s3.sort()
s4 = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if s3 == s4:
    print('None')
else:
    for i in range(int(len(s4))):
        if s3[i] != s4[i]:
            print(s4[i])
            break

### FIXED CODE ###

s = list(input())
s2 = []
for i in range(len(s)):
    s2.append(s[i])
s3 = list(set(s2))
s3.sort()
s4 = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if s3 == s4:
    print('None')
else:
    for i in range(int(len(s3))):
        if s3[i] != s4[i]:
            print(s4[i])
            break
        if i == len(s3)-1:
            print(s4[i+1])
def main():
    x = int(input())
    if x>=30:
        print("Yes")
    else:
        print("No")  
main(9

### FIXED CODE ###

def main():
    x = int(input())
    if x>=30:
        print("Yes")
    else:
        print("No")  
main()
import numpy as np

n, m = map(int, input().split())
adj = np.zeros((n, n), dtype=np.bool)
for _ in range(m):
  s, t = map(int, input().split())
  adj[s-1, t-1] = True

dp = np.zeros(n, dtype=np.float)
for i in range(n - 2, -1, -1):
  dp[i] = dp[adj[i]].mean() + 1.
  
ans = dp[0]

for i in np.where(adj.sum(axis=1) > 1)[0]:
  dp_i = dp.copy()
  dp_i[i] = (dp_i[adj[i]].sum() - dp_i[adj[i]].max()) / (adj[i].sum() - 1) + 1
  for j in range(i - 1, -1, -1):
    dp_i[j] = dp_i[adj[j]].mean() + 1
  ans = min[ans, dp_i[0]]
    
print(ans)

### FIXED CODE ###

import numpy as np

n, m = map(int, input().split())
adj = np.zeros((n, n), dtype=np.bool)
for _ in range(m):
  s, t = map(int, input().split())
  adj[s-1, t-1] = True
deg = adj.sum(axis=1)

ev = np.zeros(n, dtype=np.float)
for i in range(n - 2, -1, -1):
  ev[i] = ev[adj[i]].mean() + 1.

prob = np.zeros(n, dtype=np.float)
prob[0] = 1.
for i in range(n - 1):
  prob[adj[i]] += prob[i] / deg[i]

decrease = 0.
for i in np.where(deg > 1)[0]:
  now = ev[adj[i]].mean()
  cut = (ev[adj[i]].sum() - ev[adj[i]].max()) / (deg[i] - 1)
  decrease = np.maximum(decrease, (now - cut) * prob[i])
    
print(ev[0] - decrease)
p=list(map(int,input().split()))
cnt=0
for i in range(len(p)-1):
  if(p[i]>p[i+1]):
    cnt++

if(cnt<=2):
  print("YES")
else:
  print("NO")

### FIXED CODE ###

n=input()
p=list(map(int,input().split()))
cnt=0
for i in range(len(p)):
  if(p[i]!=i+1):
    cnt+=1

if(cnt<=2):
  print("YES")
else:
  print("NO")
N,A,B,C=map(int,input().split())
S = [input() for _ in range(N)]
table = [A,B,C]
ans = []

def ci(s):
    if s == 'AB':
        return 0,1
    elif s == 'BC':
        return 1,2
    else:
        return 0,2

if A+B+C == 0:
    print('No')
elif A+B+C == 1:
    for s in S:
        i,j = ci(s)
        print(table,i,j)
        if table[i] == 0 and table[j] == 0:
            print('No')
            exit()
        else:
            if table[i] == 0:
                table[i] = 1
                table[j] = 0
                ans.append(i)
            else:
                table[j] = 1
                table[i] = 0
                ans.append(j)

else:
    for k in range(N):
        i,j= ci(S[k])
        if table[i] > table[j]:
            i,j = j,i
        # print(table,i,j)
        if k + 1 < N:
            i2,j2 = ci(S[k+1])
        if table[i] == 0 and table[j] == 0:
            print('No')
            exit()
        elif table[i] == 0 and table[j] > 0:
            table[i] += 1
            table[j] -= 1
            ans.append(i)
        else:
            table[i] += 1
            table[j] -= 1
            if table[i2] == 0 and table[j2] == 0:
                table[i] -= 2
                table[j] += 2
                ans.append(j)
            else:
                ans.append(i)

print('Yes')
L = ['A','B','C']
for a in ans:
    print(L[a])

### FIXED CODE ###

N,A,B,C=map(int,input().split())
S = [input() for _ in range(N)]
table = [A,B,C]
ans = []

def ci(s):
    if s == 'AB':
        return 0,1
    elif s == 'BC':
        return 1,2
    else:
        return 0,2

if A+B+C == 0:
    print('No')
    exit()
elif A+B+C == 1:
    for s in S:
        i,j = ci(s)
        if table[i] == 0 and table[j] == 0:
            print('No')
            exit()
        else:
            if table[i] == 0:
                table[i] = 1
                table[j] = 0
                ans.append(i)
            else:
                table[j] = 1
                table[i] = 0
                ans.append(j)

else:
    for k in range(N):
        i,j= ci(S[k])
        if table[i] > table[j]:
            i,j = j,i
        # print(table,i,j)
        if k + 1 < N:
            i2,j2 = ci(S[k+1])
        if table[i] == 0 and table[j] == 0:
            print('No')
            exit()
        elif table[i] == 0 and table[j] > 0:
            table[i] += 1
            table[j] -= 1
            ans.append(i)
        else:
            table[i] += 1
            table[j] -= 1
            if k + 1 < N:
                if table[i2] == 0 and table[j2] == 0:
                    table[i] -= 2
                    table[j] += 2
                    ans.append(j)
                else:
                    ans.append(i)
            else:
                ans.append(i)

print('Yes')
L = ['A','B','C']
for a in ans:
    print(L[a])
n, x = map(int, input().split())

a = 'P'
for i in range(1,n):
  a = 'B'+a+'P'+a+'B'
  
print(a[:x].count('P'))
  
  
  

### FIXED CODE ###

n, x = map(int, input().split())

l = [0]*(n+1)
l[0] = 1
for i in range(1,n+1):
  l[i] = l[i-1]*2+3

p = [0]*(n+1)
p[0] = 1
for i in range(1,n+1):
  p[i] = p[i-1]*2+1
  
ans = 0  
def bts(a,b):
  global ans
  if b == 1:
    ans += 0
  elif 1 < b < l[a-1]+1:
    bts(a-1,b-1)
  elif b == l[a-1]+1:
    ans += p[a-1]
  elif b == l[a-1]+2:
    ans += p[a-1]+1
  elif l[a-1]+2 < b < l[a-1]*2+2:
    ans += p[a-1]+1
    bts(a-1,b-2-l[a-1])
  else:
    ans += p[a]

bts(n,x)
  
print(ans)
s_1,s_2,s_3=map(int,input().split())

if s_1==1:
    a++

if s_2==1:
    a++

if s_3==1:
    a++

print(a)

### FIXED CODE ###

num=input()
a=0
 
if int(num[0])==1:
  a+=1
  
if int(num[1])==1:
  a+=1
  
if int(num[2])==1:
  a+=1
  
print(a)
from collections import deque

def main():
    n = int(input())
    A = list(map(int, input().split()))
    ans = 0
    B = [0] * n
    # ansList = []
    ansList = deque()

    def makeList(num):
        start = num + 1
        mul = n // start
        return [start * j - 1 for j in range(1, mul+1)]


    def makeRes(indices):
        flag = 0
        for elm in indices:
            if B[elm] == 1:
                flag = (flag + 1) % 2
        return flag


    for i in range(n-1, -1, -1):
        if i + 1 >  n / 2:
            if A[i] == 1:
                B[i] = 1
                ans += 1
                ansList.appendleft(i+1)
        else:
            indices = makeList(i)
            # print(indices)
            res = makeRes(indices)
            # print(res)
            if A[i] != res:
                B[i] = 1
                ans += 1
                ansList.appendleft(i+1)

    print(ans)

    if ans != 0:
        print(*(list(ansList)))


if __name__ == "__main__":
    main()

### FIXED CODE ###

r = int(input())
print(3 * (r ** 2))
import sys
import numpy as np
N, K = [int(x) for x in input().split()]
x = np.array([int(x) for x in input().split()])
if 0 in x:
    K -= 1
xn = x[(x<0)]
xn = xn[::-1]
xp = x[(x>0)]
ans = []
if len(xn) >= K:
    ans.append(xn[K-1])
if len(xp) >= K:
    ans.append(xp[K-1])

x = x.tolist()
x = sorted(x,key=lambda x:abs(x))[:K]
x = np.array(x)
xn = x[(x<0)]
xp = x[(x>0)]
if len(xp) > 0 and len(xn) > 0:
    ans.append(xp[-1] + abs(xn[-1]) + min(xp[-1],abs(xn[-1])))
print(min(ans))

### FIXED CODE ###

import sys
import numpy as np
N, K = [int(x) for x in input().split()]
x = np.array([int(x) for x in input().split()])
if 0 in x:
    K -= 1
x = x[np.nonzero(x)]
if K == 0:
    print(0)
    sys.exit()
ans = []
for i in range(len(x)-K+1):
    if (x[i] < 0) != (x[i+K-1] < 0):
        ans.append(abs(x[i])+abs(x[i+K-1])+min(abs(x[i]),abs(x[i+K-1])))
    else:
        ans.append(max(abs(x[i]),abs(x[i+K-1])))
print(min(ans))