Harryxun/stf_run huggingface dataset:
import sys
dataset = sys.stdin.readlines()

seq = 0

while dataset[seq] != '-':
 s = dataset[seq]
 n = int(dataset[seq+1][0])
 for i in range(seq + 2, seq + 2 + n):
  h = int(dataset[i])
  s = s[h:] + s[0:h]
 print(s)
 seq += 2 + n
 

### FIXED CODE ###

import sys
dataset = sys.stdin.readlines()

seq = 0

while dataset[seq] != '-\n':
 s = dataset[seq]
 l = len(s) - 1
 s = s[:l]
 seq += 1
 n = dataset[seq]
 l = len(n) - 1
 n = int(n[:l])
 seq += 1
 for i in range(seq, seq + n):
  h = dataset[i]
  l = len(h) - 1
  h = int(h[:l])
  s = s[h:] + s[0:h]
 print(s)
 seq += n
N = int(input())
if N == 1:
  print('Hello World')
else:
  A, B = map(int, input().split())
  print(A + B)

### FIXED CODE ###

N = int(input())
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A + B)
import collections

def getls():
    return [ipt for ipt in input().split()]
def getlsi():
    return [int(ipt) for ipt in input().split()]
#Topological sort Gは辞書として渡す
def tsort(N,G,dic):
    res = 0
    #Topological Sort
    if dic[N] != -1:
        return dic[N]
    for node in G[N]:
        res = max(res,tsort(node,G,dic)+1)
    dic[N] = res
    return dic[N]

[n,m] = getlsi()
dic_next = collections.defaultdict(list)
dp = [-1] * n
for i in range(m):
    [x,y] = getlsi()
    dic_next[x-1].append(y-1)
ans = 0
for i in range(n):
    ans = max(ans,tsort(i,dic_next,dp))
print(ans)


### FIXED CODE ###

import collections
import sys
sys.setrecursionlimit(10**6)

def getls():
    return [ipt for ipt in input().split()]
def getlsi():
    return [int(ipt) for ipt in input().split()]
#Topological sort Gは辞書として渡す
def tsort(N,G,dic):
    res = 0
    #Topological Sort
    if dic[N] != -1:
        return dic[N]
    for node in G[N]:
        res = max(res,tsort(node,G,dic)+1)
    dic[N] = res
    return dic[N]

[n,m] = getlsi()
dic_next = collections.defaultdict(list)
dp = [-1] * n
for i in range(m):
    [x,y] = getlsi()
    dic_next[x-1].append(y-1)
ans = 0
for i in range(n):
    ans = max(ans,tsort(i,dic_next,dp))
print(ans)
N, M = list(map(int, input().split()))
G = [[] for _ in range(N+1)]
x = [None] * (N+1)

def dfs(s):
    for t, d in G[s]:
        if x[t] is None:
            x[t] = x[s] + d
            if not dfs(t):
                return False
        else:
            if x[t] != x[s] + d:
                return False
    return True

for _ in range(M):
    L, R, D = map(int, input().split())
    G[L-1].append([R-1,  D])
    G[R-1].append([L-1, -D])

ans = True
for i in range(N):
    if x[i] is None:
        x[i] = 0
        ans &= dfs(i)

print("Yes" if ans else "No")

### FIXED CODE ###

import sys
sys.setrecursionlimit(200002)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
x = [None] * (N)

def dfs(s):
    global x, G
    for t, d in G[s]:
        if x[t] is None:
            x[t] = x[s] + d
            if not dfs(t):
                return False
        else:
            if x[t] != x[s] + d:
                return False
    return True

for _ in range(M):
    L, R, D = map(int, input().split())
    G[L-1].append([R-1,  D])
    G[R-1].append([L-1, -D])

ans = True
for i in range(N):
    if x[i] is None:
        x[i] = 0
        ans &= dfs(i)

print("Yes" if ans else "No")
k = int(input())
i = 1
if a%2 ==1:
    while True:
        s = 0
        for j in range(i):
            s += (10**j)*7
        if s % k == 0:
            print(i)
            break
        i += 1
else:
    print(-1)

### FIXED CODE ###

import sys
k = int(input())
d = 0
for i in range(k+1):
  d = (10*d) + 7
  d %= k
  if d == 0:
    print(i+1)
    sys.exit()
print(-1)
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = list(map(int, sys.stdin.readline().split()))

if K % 2 == 1:
    print(0)
    exit()
if N == 1:
    if K == 0:
        print(1)
    else:
        print(0)
    exit()

# 解説AC
# dp[i][j][k]: i まで決まってて、保留の数が j、確定した奇妙さが k
dp = [[[0] * (K + 1) for _ in range(N)] for _ in range(N)]
# dp = np.zeros((N, N, K + 1), dtype=int)
dp[0][0][0] = 1
dp[0][1][2] = 1
for i, j, k in itertools.product(range(1, N), range(N - 1), range(K + 1)):
    if k - j * 2 < 0:
        continue
    # i == pi
    # 保留の数はそのまま
    # 奇妙さは保留の数だけ増える
    dp[i][j][k] += dp[i - 1][j][k - j * 2] * 1
    # i == p_j または j == p_i (j < i)
    # 保留の数はそのまま
    # 奇妙さは保留の数だけ増える
    # パターン数はうさぎの保留数j + かめの保留数j
    dp[i][j][k] += dp[i - 1][j][k - j * 2] * (j * 2)
    # i == p_j かつ j == p_j (j < i)
    # 保留数が1減る
    # パターン数はうさぎの保留数j * かめの保留数j
    dp[i][j][k] += dp[i - 1][j + 1][k - j * 2] * (j + 1) ** 2
    if j - 1 >= 0:
        # 両方保留
        # そのまま増やす
        dp[i][j][k] += dp[i - 1][j - 1][k - j * 2]

    dp[i][j][k] %= MOD
print(dp[-1][0][K])


### FIXED CODE ###

import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = list(map(int, sys.stdin.readline().split()))

if K % 2 == 1:
    print(0)
    exit()
if N == 1:
    if K == 0:
        print(1)
    else:
        print(0)
    exit()
if K == 0:
    print(1)
    exit()

# 解説AC
# dp[i][j][k]: i まで決まってて、保留の数が j、確定した奇妙さが k
dp = [[[0] * (K + 1) for _ in range(N)] for _ in range(N)]
dp[0][0][0] = 1
dp[0][1][2] = 1
for i, j, k in itertools.product(range(1, N), range(N - 1), range(K + 1)):
    if k - j * 2 < 0:
        continue
    # i == pi
    # 保留の数はそのまま
    # 奇妙さは保留の数だけ増える
    dp[i][j][k] += dp[i - 1][j][k - j * 2] * 1
    # i == p_j または j == p_i (j < i)
    # 保留の数はそのまま
    # 奇妙さは保留の数だけ増える
    # パターン数はうさぎの保留数j + かめの保留数j
    dp[i][j][k] += dp[i - 1][j][k - j * 2] * (j * 2)
    # i == p_j かつ j == p_j (j < i)
    # 保留数が1減る
    # パターン数はうさぎの保留数j * かめの保留数j
    dp[i][j][k] += dp[i - 1][j + 1][k - j * 2] * (j + 1) ** 2
    if j - 1 >= 0:
        # 両方保留
        # そのまま増やす
        dp[i][j][k] += dp[i - 1][j - 1][k - j * 2]

    dp[i][j][k] %= MOD
print(dp[-1][0][K])
A,B = [int(i) for i in input().split()]

flag=0
for i in range(1,1050):
    if int(i*0.08)==A and int(i*0.1)==B:
        ans = i
        flag=1
        break

if flag==1:
    print(ans)
else:
    print(-1)


### FIXED CODE ###

S=input()

if S=='AAA' or S=='BBB':
    print('No')
else:
    print('Yes')
a,b,c,d = map(int, input()split())
while (a>0 and c>0):
  c = c - b 
  if c <= 0:
    break
  a = a - d
print("Yes" if c <= 0 else "No")

### FIXED CODE ###

A, B, C, D = map(int, input().split())
while (A>0 and C > 0):
    C = C - B
    if C <= 0:
        break
    A = A - D
print("Yes" if C<=0 else "No")
import sys
input = sys.stdin.readline
from collections import *

N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9+7
p, n = [], []
flag = False

for Ai in A:
    if Ai==0:
        flag = True
    elif Ai>0:
        p.append(Ai)
    else:
        n.append(Ai)

if len(p)==0 and K%2==1:
    if 0 in A:
        print(0)
    else:
        n.sort(reverse=True)
        ans = 1
        
        for ni in n[:K]:
            ans *= ni
            ans %= MOD
        
        print(ans)
    exit()
    
p.sort()
n.sort(reverse=True)
apl = [1]
anl = [1]

for pi in p:
    apl.append(apl[-1]*pi%MOD)

for ni in n:
    anl.append(anl[-1]*ni%MOD)

p.reverse()
n.reverse()
apr = [1]
anr = [1]

for pi in p:
    apr.append(apr[-1]*pi%MOD)

for ni in n:
    anr.append(anr[-1]*ni%MOD)

#p.reverse()
#n.reverse()

f = True

for i in range(0, len(n)+1, 2):
    if len(p)>=K-i>=0 and i<=len(n):
        if f:
            ans = anr[i]*apr[K-i]
            f = False
            continue
            
        a = p[K-i-1]*p[K-i-2]
        b = n[i-1]*n[i-2]
        
        if b>a:
            ans = anr[i]*apr[K-i]%MOD

print(ans%MOD)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9+7
p, n = [], []

for i in range(N):
    if A[i]>=0:
        p.append(A[i])
    else:
        n.append(A[i])

ok = False

if len(p)>0:
    if N==K:
        if len(n)%2==0:
            ok = True
    else:
        ok = True
else:
    if K%2==0:
        ok = True

if not ok:
    A.sort(key=lambda x: abs(x))
    ans = 1
    
    for Ai in A[:K]:
        ans *= Ai
        ans %= MOD

    print(ans)
    exit()

p.sort(reverse=True)
n.sort()

if K%2==1:
    ans = p[0]
    p = p[1:]
else:
    ans = 1
    
l = []
    
for i in range(len(p)//2):
    l.append(p[2*i]*p[2*i+1])
    
for i in range(len(n)//2):
    l.append(n[2*i]*n[2*i+1])

l.sort(key=lambda x: abs(x), reverse=True)

for li in l[:K//2]:
    ans *= li
    ans %= MOD
    
print(ans)
import math
a, b = map(int, input().split())
if (b-a) % 2 == 0:
    print(floor((a+b) / 2))
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

a, b = map(int, input().split())
if (b-a) % 2 == 0:
    print((a+b) // 2)
else:
    print("IMPOSSIBLE")
#C - Stones
#黒い石のすぐ右に白い石があるような箇所がないようにしたいです。 

n = int(input())
state = input()
state_list = list(state)
state_list.append(" ")

#specify the locate causing problem
prob_locate = []
prob_num = 0
for i in range(n):
	if state_list[i] == "#" and state_list[i+1] == ".":
		prob_locate.append(i)
		prob_num += 1
if prob_num == 0:
		print(0)
		exit()

#finding optimal position
import random
while prob_num > 0:
	for i in prob_locate:
		r_0 = random.randint(0,1)
		r_1 = random.randint(0,1)
		state_list[(i + r_0)] = ["#", "."][r_1]
	prob_locate = []
	prob_num = 0
	for i in range(n):
		if state_list[i] == "#" and state_list[i+1] == ".":
			prob_locate.append(i)
			prob_num += 1

#checking the difference
statelist.remove(" ")
diff = 0
for i, j in zip(state_list, list(state):
	if i != j: diff += 1

print(diff)
		

### FIXED CODE ###

#毎回関数を呼ぶとおそくなる
n = int(input())
stones = input()
score = stones.count(".")
r = score
for i in range(n):
	if stones[i] == ".":
		r -= 1
	else:
		r += 1
	score = min(r, score)
print(score)
n = int(input())
p = [int(input()) for _ in range(n)]
print(int(sum(p) - max(p)/2)

### FIXED CODE ###

n = int(input())
p = [int(input()) for _ in range(n)]
print(int(sum(p) - max(p)/2))
s=input();l=[]
for i in range(len(s)-1):
 if s[i]!=s[i+1]:l+=[max(i,len(s)-i-1)]
print(min(l))

### FIXED CODE ###

s=input();l=[];n=len(s)
for i in range(n-1):
 if s[i]!=s[i+1]:l+=[max(i+1,n-i-1)]
print(min(l)if l else n)
# coding: utf-8
# Your code here!
import fractions

N = int(input())
arr = list(map(int, input().split()))
L = [0]
R = [0]
B = []

for i in range(N):
    L.append(fractions.gcd(arr[i], L[i]))
    R.append(fractions.gcd(arr[N - i - 1], R[i]))
for i in range(N):
    B.append(math.gcd(L[i],R[N - i - 1]))
print(max(B))

### FIXED CODE ###

# coding: utf-8
# Your code here!
import fractions

N = int(input())
arr = list(map(int, input().split()))
L = [0]
R = [0]
B = []

for i in range(N):
    L.append(fractions.gcd(arr[i], L[i]))
    R.append(fractions.gcd(arr[N - i - 1], R[i]))
for i in range(N):
    B.append(fractions.gcd(L[i],R[N - i - 1]))
print(max(B))
def gcd(a,b): #最大公約数
    if a%b==0: return b
    return gcd(b,a%b)

def ela(g):
    s={}
    i=2
    while i*i<=g:
        while g%i==0:
            g//=i
            s.add(i)
        i+=1
    return s

a,b=map(int,input().split())
G=gcd(max(a,b),min(a,b))
print(len(ela(G))+1)

### FIXED CODE ###

def gcd(a,b):
    if b==0: return a
    return gcd(b,a%b)

def ela(g):
    s={1}
    i=2
    while i*i<=g:
        while g%i==0:
            g//=i
            s.add(i)
        i+=1
    if g!=1: s.add(g)
    return s

a,b=map(int,input().split())
G=gcd(max(a,b),min(a,b))
print(len(ela(G)))
if(sum([int(i) for i in input()]) % 9 == 0):
  print("Yes")
else:
  print("No"

### FIXED CODE ###

if(sum([int(i) for i in input()]) % 9 == 0):
  print("Yes")
else:
  print("No")
# coding: utf-8

n = input()

if n % 2 == 1:
    print(n/2 + 1)
else:
    print(n/2)

### FIXED CODE ###

# coding: utf-8

n = input()

if n % 2 == 1:
    print(n/2 + 1)
else:
    print(n/2)
import collections
n,m = map(int,input().split())
d = {}
indegree = [0]*n
for _ in range(m):
    x,y = map(int,input().split())
    d[x-1] = d.get(x-1,[]) + [y-1]
    indegree[y-1] += 1
dp = [0]
q = collections.deque([i for i in range(n) if indegree[i] == 0])
while q:
    node = q.popleft()
    for nei in d.get(node,[]):
        indegree[nei] -= 1
        dp[nei] = max(dp[nei],dp[node]+1)
        if indegree[nei] == 0:
            q.append(nei)
return max(dp)

### FIXED CODE ###

from collections import deque
 
N, M = map(int, input().split())
adjL = [[] for v in range(N)]
indegs = [0] * N
for _ in range(M):
    x, y = map(int, input().split())
    adjL[x-1].append(y-1)
    indegs[y-1] += 1
 
dp = [0] * N
Q = deque([v for v in range(N) if indegs[v] == 0])
while Q:
    vNow = Q.popleft()
    for v2 in adjL[vNow]:
        dp[v2] = max(dp[v2], dp[vNow] + 1)
        indegs[v2] -= 1
        if indegs[v2] == 0:
            Q.append(v2)
 
print(max(dp))
a,b = map(int, raw_input().split())
print "%d/%d %d%%d %.5f" % (a,b, a,b, a/float(b))

### FIXED CODE ###

a, b = map(int, raw_input().split())
print "%d %d %f" % ((a/b), (a%b), (float(a)/b))
a, b, c, d=map(int,input().split())
if (a+b<c+d):
  print("Right")
elif(a+b=c+d):
  print("Balanced")
else:
  print("Left")

### FIXED CODE ###

a, b, c, d=map(int,input().split())
if a+b<c+d:
  print("Right")
elif a+b==c+d:
  print("Balanced")
else:
  print("Left")
#!/usr/bin/env python3
from collections import Counter
INF = 1e12


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    lA = Counter(A)
    lB = Counter(B)
    if max(Counter(A+B).values()) > N:
        print('No')
        exit(1)

    C = [0] * (N + 1)
    D = [0] * (N + 1)
    for i in range(N):
        C[i + 1] = lA[i + 1] + C[i]
        D[i + 1] = lB[i + 1] + D[i]
    shift = - INF
    for i in range(1, N + 1):
        shift = max(shift, C[i] - D[i - 1])
    print('Yes')
    ans = (B + B + B)[shift + N:shift + 2*N]
    print(' '.join([str(a) for a in ans]))


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import Counter
INF = 1e12


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    lA = Counter(A)
    lB = Counter(B)
    if max(Counter(A+B).values()) > N:
        print('No')
        exit()

    C = [0] * (N + 1)
    D = [0] * (N + 1)
    for i in range(N):
        C[i + 1] = lA[i + 1] + C[i]
        D[i + 1] = lB[i + 1] + D[i]
    shift = - INF
    for i in range(1, N + 1):
        shift = max(shift, C[i] - D[i - 1])
    print('Yes')
    ans = (B + B + B)[N-shift:2*N-shift]
    print(' '.join([str(a) for a in ans]))


if __name__ == "__main__":
    main()
Q = int(input())
AB = [sorted(list(map(int,input().split()))) for i in range(Q)]

for A,B in AB:
    x = math.sqrt(A*B)
    y = int(x)
    if x!=y:
        if y*(y+1)<A*B:
            print(y*2-1)
        else:
            print(y*2-2)
    else:
        if A==B:
            print(y*2-2)
        else:
            print(y*2-3)

### FIXED CODE ###

import math
Q = int(input())
AB = [sorted(list(map(int,input().split()))) for i in range(Q)]

for A,B in AB:
    x = math.sqrt(A*B)
    y = int(x)
    if x!=y:
        if y*(y+1)<A*B:
            print(y*2-1)
        else:
            print(y*2-2)
    else:
        if A==B:
            print(y*2-2)
        else:
            print(y*2-3)
import numpy as np
n=int(input())
a=list(map(int,input().split()))
a=[[x] for x in a]
a=np.array(a)
k=np.zeros((n,n),dtype="i8")
for i in range(n-1):
    k[i][i]=1
    k[i][i+1]=1
k[n-1][0]=1
k[n-1][-1]=1
k=np.linalg.inv(k)
ka=np.dot(k,a)
ans=[]
for x in ka:
    ans.append(int(x[0])*2)
print(*ans)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a0=sum(a)//2-sum(a[1::2])
ans=[a0*2]
for i in range(n-2):
    ans.append(a[i]*2-ans[-1])
ans.append((a[-1]-a0)*2)
print(*ans)
N,M = map(int,input().split())
AB = [[0,0]]*N
for n in range(N):
    AB[n] = list(map(int,input().split()))
work_schedule = [0]*M
sorted_AB = sorted(AB,key=lambda x:(-x[1],x[0]))
for work in sorted_AB:
    cnt = 0
    while True:
        if work[0]-1+cnt >= M:
            break
        elif work_schedule[work[0]-1+cnt] == 0:
            work_schedule[work[0]-1+cnt]  = work[1]
            break
        elif  work_schedule[work[0]-1+cnt] != 0:
            cnt+=1
sum(work_scuedule)

### FIXED CODE ###

from collections import defaultdict
import heapq

n, m = map(int, input().split())
dct = defaultdict(list)

for i in range(n):
    a, b = map(int, input().split())
    dct[a].append(-b)

h = []
res = 0

for i in range(1, m + 1):
    if dct[i]:
        for item in dct[i]:
            heapq.heappush(h, item)
    if h:
        res += heapq.heappop(h)

print(-res)
N = int(input())
A = int(input())
B = int(input())

if N ==1:
    print("Hello World")
else:
    print(A+B)

### FIXED CODE ###

N = int(input())


if N ==1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A+B)
import heapq
 
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
q=[]
cnt_plus=0
for i in range(n):
  if arr[i]>0:
    cnt_plus+=1
    heapq.heappush(q,(-arr[i],1))
  elif arr[i]<0:
    heapq.heappush(q,(arr[i],-1))
  else:
    heapq.heappush(q,(0,0))
pick=[]
prev_plus=0
prev_minus=0
cnt=0
for i in range(k):
  tmp,flag=heapq.heappop(q)
  tmp*=-1
  if flag==0:
    print(0)
    exit()
  if flag==1:
    pick.append(tmp)
    prev_plus=tmp
  if flag==-1:
    if cnt==0:
      prev_minus=tmp
      cnt+=1
    else:
      cnt=0
      pick.append(prev_minus)
      pick.append(tmp)
if cnt==0:
  ans=1
  for i in range(k):
    ans*=pick[i]
    ans%=mod
  print(ans%mod)
else:
  cand_plus=0
  cand_minus=0
  while len(q)!=0:
    tmp,flag=heapq.heappop(q)
    tmp*=-1
    if flag==1 and cand_plus==0:
      cand_plus=tmp
    if flag==-1 and cand_minus==0:
      cand_minus=tmp
  if (k%2==1 and cnt_plus==0) or (cand_plus==0 and cand_minus==0):
    if arr.count(0)!=0:
      print(0)
      exit()
    else:
      q=[]
      for i in range(n):
        heapq.heappush(q,abs(arr[i]))
      ans=1
      for _ in range(k):
        ans*=heapq.heappop(q)
        ans%=mod
      print((-ans)%mod)
  else:
    if prev_plus*cand_plus>=prev_minus*cand_minus:
      pick.append(cand_plus)
    else:
      pick.remove(prev_plus)
      pick.append(prev_minus)
      pick.append(cand_minus)
    ans=1
    for i in range(k):
      ans*=pick[i]
      ans%=mod
    print(ans%mod)

### FIXED CODE ###

import heapq
 
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
q=[]
cnt_plus=0
for i in range(n):
  if arr[i]>0:
    cnt_plus+=1
    heapq.heappush(q,(-arr[i],1))
  elif arr[i]<0:
    heapq.heappush(q,(arr[i],-1))
  else:
    heapq.heappush(q,(0,0))
pick=[]
prev_plus=0
prev_minus=0
cnt=0
for i in range(k):
  tmp,flag=heapq.heappop(q)
  tmp*=-1
  if flag==0:
    print(0)
    exit()
  if flag==1:
    pick.append(tmp)
    prev_plus=tmp
  if flag==-1:
    if cnt==0:
      prev_minus=tmp
      cnt+=1
    else:
      cnt=0
      pick.append(prev_minus)
      pick.append(tmp)
if cnt==0:
  ans=1
  for i in range(k):
    ans*=pick[i]
    ans%=mod
  print(ans%mod)
else:
  cand_plus=0
  cand_minus=0
  while len(q)!=0:
    tmp,flag=heapq.heappop(q)
    tmp*=-1
    if flag==1 and cand_plus==0:
      cand_plus=tmp
    if flag==-1 and cand_minus==0:
      cand_minus=tmp
  if (k%2==1 and cnt_plus==0) or (cand_plus==0 and cand_minus==0):
    if arr.count(0)!=0:
      print(0)
      exit()
    else:
      q=[]
      for i in range(n):
        heapq.heappush(q,abs(arr[i]))
      ans=1
      for _ in range(k):
        ans*=heapq.heappop(q)
        ans%=mod
      print((-ans)%mod)
  else:
    if prev_plus*cand_plus>=prev_minus*cand_minus:
      pick.append(cand_plus)
    else:
      if prev_plus!=0:
        pick.remove(prev_plus)
        pick.append(prev_minus)
        pick.append(cand_minus)
      else:
        pick.append(cand_plus)
    ans=1
    for i in range(k):
      ans*=pick[i]
      ans%=mod
    print(ans%mod)
import numpy as np
H, N = map(int, input().split())
dp = np.zeros((N, H+1))
skills = []
for _ in range(N):
  a, b = map(int, input().split())
  skills.append([a,b])

for i in range(1,H+1):
  for j in range(N):
    if i - skills[j][0] >0:
      dp[j][i] = min(dp[0][i-skills[j][0]], dp[1][i-skills[j][0]], dp[2][i-skills[j][0]])+skills[j][1]
    else:
      dp[j][i] = skills[j][1]

print(int(min(dp.T[-1])))

### FIXED CODE ###

import numpy as np
H, N = map(int, input().split())
dp = np.zeros((N, H+1))
ab = [list(map(int, input().split())) for _ in range(N)]
max_a = max(a for a, _ in ab)
dp = [0]*(H+max_a)
for i in range(1,H+1):
  dp[i] = min(dp[i-a]+b for a,b in ab)
#print(ab)
print(dp[H])
s = input()
A B C K = s.split(" ")

if K <= A:
  print(K)
elif K <= A + B:
  print(A)
elif K <= A + B + C:
  print(A - (K - A))

### FIXED CODE ###

s = input()
A, B, C, K = [int(v) for v in s.split(" ")]

if K <= A:
  print(K)
elif K <= A + B:
  print(A)
elif K <= A + B + C:
  print(A - (K - A - B))
s = input()
if s == "AAA" or s === "BBB":
    print("no")
else:
    print("yes")


### FIXED CODE ###

s = input()
if s == "AAA" or s == "BBB":
    print("No")
else:
    print("Yes")
def main():
    a, b = map(int, input())
    if a >= 13:
        print(b)
    elif 6 <= a <= 12:
        print(b // 2)
    else:
        print(0)


if __name__ == "__main__":
    main()


### FIXED CODE ###


def main():
    a, b = map(int, input().split())
    if a >= 13:
        print(b)
    elif 6 <= a <= 12:
        print(b // 2)
    else:
        print(0)


if __name__ == "__main__":
    main()
import math
x, y = map(int, input().split())
def func(x, y):
    return (x * y) / int(math.gcd(x, y))

print(int(func(x, y)))

### FIXED CODE ###

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

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

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

print(lcm(a,b))
def main():
    import collections
    import sys
    sys.setrecursionlimit(500000)
    input = sys.stdin.readline
    N=int(input())
    S=input()
    if N<=3:
        print(0)
        sys.exit()
    else:
        str_list=list(S[:N])
        result=0
        c=collections.Counter(str_list)
        RGB_list=c.most_common()

        list1=[i for i, x in enumerate(str_list) if x == RGB_list[0][0]]
        list2=[i for i, x in enumerate(str_list) if x == RGB_list[1][0]]
        list3=[i for i, x in enumerate(str_list) if x == RGB_list[2][0]]
        list23=[]
        if RGB_list[2][0]==0 or RGB_list[1][0]==0:
            print(0)
            sys.exit()
        else:
            for i in list3:
                for j in list2:
                    list23+=[2*i-j,2*j-i,(i+j)/2]
            c1=collections.Counter(list23)
            for k in list1:
                for l in c1.keys():
                    if k==l:
                        result+=c1[l]
            print(int(RGB_list[0][1]*RGB_list[1][1]*RGB_list[2][1]-result))

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import collections
    import sys
    sys.setrecursionlimit(5000000)
    input = sys.stdin.readline
    N=int(input())
    S=input()
    if N<=3:
        print(0)
    else:
        str_list=list(S[:N])
        result=0
        c=collections.Counter(str_list)
        RGB_list=c.most_common()

        if len(c)<3:
            print(0)

        else:

            list1=[i for i, x in enumerate(str_list) if x == RGB_list[0][0]]
            list2=[i for i, x in enumerate(str_list) if x == RGB_list[1][0]]
            list3=[i for i, x in enumerate(str_list) if x == RGB_list[2][0]]
            list23=[]

        
            for i in list3:
                for j in list2:
                    list23+=[2*i-j,2*j-i,(i+j)/2]
            c1=collections.Counter(list23)
            for k in list1:
                for l in c1.keys():
                    if k==l:
                        result+=c1[l]
            print(int(RGB_list[0][1]*RGB_list[1][1]*RGB_list[2][1]-result))

if __name__ == '__main__':
    main()
a = list(map(int,input()))
for i in range(5):
  if a[i]==0:
    print(i+1)

### FIXED CODE ###

x = list(map(int,input().split()))
for i in range(5):
  if x[i] == 0:
    print(i+1)
    break
a,b=divmod(int(input()),500)
print(a*1000+(b//5)*5)


### FIXED CODE ###

S = input()
if S[2] == S[3] and S[4] == S[5]:
  print('Yes')
else:
  print('No')