Harryxun/stf_run huggingface dataset:
def main():
    N = int(input())
    B = [int(_) for _ in input().split()]

    #出力用
    outs = []

    for i in range(N):
        for k in range(N-1,-1,-1):
            if B[k] == k:
                del B[k]
                outs.append(k)
                break
        else:
            print(-1)
            return

    for out in outs:
        print(out)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    B = [int(_) for _ in input().split()]

    #出力用
    outs = []

    for i in range(N):
        for k in range(N-1-i,-1,-1):
            if B[k] == k+1:
                del B[k]
                outs.insert(0,k+1)
                break
        else:
            print(-1)
            return

    for out in outs:
        print(out)

if __name__ == '__main__':
    main()
d,k = [int(x) for x in input().split()]
print((100 ** d) * k

### FIXED CODE ###

D, N =map(int,input().split())
if N == 100:
  N = 101
print(N*(100**D))
a = [int(input()) for i in range(4)]
sum = 0
for i in range(a[0]):
    if i + 1 <= K:
        sum += a[2]
    else:
        sum += a[3]
print(sum)


### FIXED CODE ###

a = [int(input()) for i in range(4)]
sum = 0
for i in range(a[0]):
    if i + 1 <= a[1]:
        sum += a[2]
    else:
        sum += a[3]
print(sum)
while 1:
  l=raw_input()
  if l.find("?")==2:
    break
  print eval(l)

### FIXED CODE ###

while 1:
  l=raw_input()
  if l.find("?")==-1:
    print eval(l)
  else: 
    break
S = input()
T = input()
 
if S == T[:-1]:
  print("YES")
  else
  print("NO")

### FIXED CODE ###


    
s = input()
t = input()

if t[:-1] == s:
    print("Yes")
else:
    print("No")
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]


for i in range(2**(len(S)-1)):
    op_list = ['+']*(len(S)-1)
    for j in range(len(S)-1):

        if (i>>j)&1:
            op_list[j]='-'
    s = ""
    for j in range(len(S)-1):
        s = s + S[j] + op_list[j]

    s = s + S[len(S)-1]

    if 7==eval(s):
        print(s,"=7", sep="")
        sys.exit()

### FIXED CODE ###

import sys

E = list(input())

A,B,C,D = map(int, E)

sum = 0
for i in range(2**3):

    op_list = ['-', '-', '-']
    sum1 = 0
    for j in range(len(E)):
        if (i>>j) & 1:
            op_list[j]  = '+'
    sum = eval(E[0]+op_list[0]+E[1]+op_list[1]+E[2]+op_list[2]+E[3])

    if sum==7:
        print(A,op_list[0],B,op_list[1],C,op_list[2],D,"=7", sep="")
        sys.exit()
N = int(input())
A = list(map(int, input().split()))
V = [[] for _ in range(N+1)]

for i in range(N):
    if i == 0:
        V[0] = 1
        continue
    V[i] = (V[i-1]*2 - A[i])
V[N]=0

for i in range(N):
    j = N - i -1
    if V[j] > A[j+1] + V[j+1]:
        V[j] = A[j+1] + V[j+1]
 
ans = sum(V)+sum(A)

if A[0] != 0:
    ans = -1

if min(V[:N-1]) <= 0:
    ans = -1

print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
V = [0]*(N+1)
flug = 0
Lsum= sum(A)
 
V[0] = 1
for i in range(N):
    V[i+1] = (V[i]*2 - A[i+1])
    if V[i+1] < 0 :
        flug = 1
    Lsum = Lsum - A[i+1]
    if V[i+1] > Lsum :
        V[i+1] = Lsum
 
ans = sum(V)+sum(A)
if A[0] != 0 or A[N] == 0:
    ans = -1
if flug == 1:
   ans = -1
if N == 0 and A[0] != 1:
    ans = -1
elif N == 0 and A[0] == 1:
    ans = 1
 
print(ans)
from collections import defaultdict

N = int(input())
prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,
        43,47,53,59,61,67,71,73,79,83,89,97]
ans = 0
factor = defaultdict(int)
for i in range(1,N+1):
    for j in prime:
        while i != 1:
            if i % j == 0:
                factor[j] += 1
                i = i // j
            else:
                break

fact_l = list(dict(factor).items())
for i, x in enumerate(fact_l):
    if x[1] >= 74:
        n_74 = i + 1
    if x[1] >= 24:
        n_24 = i + 1
    if x[1] >= 14:
        n_14 = i + 1
    if x[1] >= 4:
        n_4 = i + 1
    if x[1] >= 2:
        n_2 = i + 1

print(n_74+n_24*(n_2-1)+n_14*(n_4-1)+n_4*(n_4-1)*(n_2-2)//2)

### FIXED CODE ###

from collections import defaultdict

N = int(input())
prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,
        43,47,53,59,61,67,71,73,79,83,89,97]
ans = 0
factor = defaultdict(int)
for i in range(1,N+1):
    for j in prime:
        while i != 1:
            if i % j == 0:
                factor[j] += 1
                i = i // j
            else:
                break

fact_l = list(dict(factor).items())
fact_l.sort()
n_74 = 0
n_24 = 0
n_14 = 0
n_4 = 0
n_2 = 0
for i, x in enumerate(fact_l):
    if x[1] >= 74:
        n_74 = i + 1
    if x[1] >= 24:
        n_24 = i + 1
    if x[1] >= 14:
        n_14 = i + 1
    if x[1] >= 4:
        n_4 = i + 1
    if x[1] >= 2:
        n_2 = i + 1

print(n_74+(n_24*(n_2-1))+(n_14*(n_4-1))+(n_4*(n_4-1)*(n_2-2)//2))
def func (x):
	if x:
		return int(x)*func(x-1)
	else:
		return (1)
def comb (x,y):
	return func(x)//func(x-y)//func(y)

w,h,ax,ay,bx,by=map(int,input().split())
dx=min(w-abs(ax-bx),abs(ax-bx))
dy=min(h-abs(ay-by),abs(ay-by))
ans=1
if dx*2==w:ans*=2
if dy*2==h:ans*=2
ans*=comb(dx+dy,dx)
print(ans%100000007)

### FIXED CODE ###

from math import factorial
def comb (x,y):
	return factorial(x)//factorial(x-y)//factorial(y)

w,h,ax,ay,bx,by=map(int,input().split())
dx=abs(ax-bx)
dx=min(dx,w-dx)
dy=abs(ay-by)
dy=min(dy,h-dy)
an=1
if dx*2==w:an*=2
if dy*2==h:an*=2
an*=comb(dx+dy,dx)
print(an%int(1E8+7))
s = input().strip()
enki = set('ATCG')
count = 0
maxlen = 0
for i in range(len(s)):
    if s[i] in enki:
        count += 1
    else:
        maxlen = max(maxlen, count)
        count = 0

return maxlen

### FIXED CODE ###

S = input()
 
len = 0
ans = 0
for ch in S:
    if ch in 'ACGT':
        len += 1
        ans = max(ans, len)
    else:
        len = 0
print(ans)
a, b, c = map(int, input().split())

print(max([a+b, a-b, a*b]))

### FIXED CODE ###

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

print(max([a+b, a-b, a*b]))
def main():
    import sys
    input = sys.stdin.readline
    def gcd(a, b):
        if b == 0:
            return a
        return gcd(b, a % b)
    
    N, M = [int(x) for x in input().strip().split()]
    S = input().strip()
    T = input().strip()
    L = ((N * M) // gcd(N, M))
    ans = ['0'] * L
    for n in range(N):
        ans[L//N*n] = S[n%N]
    for m in range(M):
        if ans[(L//M)*m] == '0':
            ans[(L//M)*m] = T[m%M]
        elif ans[(L//M)*m] == T[m%M]:
            continue
        else:
            print(-1)
            return
    print(L)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    from collections import defaultdict
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline

    def gcd(a, b):
        if b == 0:
            return a
        return gcd(b, a % b)
    
    N, M = [int(x) for x in input().strip().split()]
    S = input().strip()
    T = input().strip()
    L = (N * M) // gcd(N, M)
    d = defaultdict(int)
    for n in range(N):
        d[L//N*n] = S[n]
    for m in range(M):
        if d[L//M*m] == 0 or d[L//M*m] == T[m]:
            continue
        else:
            print(-1)
            return
    print(L)

if __name__ == '__main__':
    main()
from collections import Counter
N = int(input())
X = []
for _ in range(N):
  X.append(list(map(int, input().split())))
  
A = []
for i in range(N):
  for j in range(i+1,N):
    A.append((abs(X[i][0]-X[j][0]), abs(X[i][1]-X[j][1])))
    
C = Counter(A)
print(N - C.most_common()[0][1])

### FIXED CODE ###

from collections import Counter
N = int(input())
X = []
for _ in range(N):
  X.append(list(map(int, input().split())))
  
if N == 1:
  print(1)
  exit(0)
A = []
for i in range(N):
  for j in range(N):
    if i==j:
      continue
    A.append((X[i][0]-X[j][0], X[i][1]-X[j][1]))
    
C = Counter(A)
print(N - C.most_common()[0][1])
N, M = open(0).readline().split()
from collections import Counter
cnt = Counter([int(x) for x in open(0).read().split()])
print('\n'.join(map(str,cnt.values())))

### FIXED CODE ###

N, M, *cnt = open(0).read().split()
from collections import Counter
cnt = Counter(cnt)
for i in range(1,int(N)+1):
    print(cnt[str(i)])
a=int(input())
if a<1200:
	print('ABC')
elif 1200<a<2800:
	print('ARC')
else
	print('AGC')


### FIXED CODE ###

a=input()
if int(a)<1200:
    print("ABC")
elif int(a)<2800:
    print("ARC")
else:
    print("AGC")
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    h,n = map(int,ipt().split())
    atks = [tuple(map(int,ipt().split())) for i in range(n)]
    dam = [10**18]*(h+1)
    dam[0] = 0
    for i in range(1,h+1):
        for aj,bj in atks:
            if aj > i and dam[i] > bj:
                dam[i] = bj
            elif dam[i] > dam[i-aj]+bj:
                dam[i] = dam[i-aj]+bj

    print(dam[h])

    return None

if __name__ == '__main__':
    main()


### FIXED CODE ###

import numpy as np
h, n = map(int,input().split())
a = np.zeros(n,dtype=int)
b = np.zeros(n,dtype=int)
for i in range(n):
    ai ,bi = map(int,input().split())
    a[i] = ai
    b[i] = bi

mh = np.zeros(10001,dtype=int)
for i in range(1,h+1):
    mh[i] = (mh[i-a]+b).min()

print(mh[h])
n,m= map(int,input().split())
a = [int(input()) for _ in range(m)]
d = [0]*(n+1)
if not 1 in a : d[1] = 1
if not 2 in a : d[2] = d[1] + 1
for i in range(3,n+1):
    if i not in a :
        d[i] = ( d[i-1] + d[i-2] ) % 1000000007
print(d[n])

### FIXED CODE ###

# DP
mod = 1000000007
 
n, m = map(int, input().split())
b_list = [True] * (n+1)
dp = [0 for _ in range(n+1)]
for i in range(m):
    b_list[int(input())] = False
 
dp[0] = 1
for i in range(n):
    for j in range(i+1, min(n, i+2)+1):
        if b_list[j] == True:
            dp[j] += dp[i]
            dp[j] %= mod
# print(b_list)
# print(dp)
print(dp[n])
n = int(input())
a = list(map(int, input().split())
m = int(input())
b = list(map(int, input()))

la = len(a)
lb = len(b)
l = min(la, lb)

for i in range(l):
    if a[i] < b[i]:
        print(1)
        break
    elif a[i] > b[i]:
        print(2)
        break
else:
    if la < lb:
        print(1)
    else:
        print(2)


### FIXED CODE ###

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

la = len(a)
lb = len(b)
l = min(la, lb)

for i in range(l):
    if a[i] > b[i]:
        print(0)
        break
    elif a[i] < b[i]:
        print(1)
        break
else:
    if la >= lb:
        print(0)
    else:
        print(1)
S = input()
if S = "Sunny":
    ans = "Cloudy"
elif S = "Cloudy":
    ans = "Rainy"
else:
    ans = "Sunny"
print(ans)

### FIXED CODE ###

S = input()
if S == "Sunny":
    ans = "Cloudy"
elif S == "Cloudy":
    ans = "Rainy"
else:
    ans = "Sunny"
print(ans)
N = int(input())
b_list = list(map(int,input().split()))
answer_list = []

for i in range(N):
    if b_list[i] > i+1:
        print(-1)
        break


    
    for j in range(N-i, 0, -1):
        
        if b_list[j-1] == j:
            answer_list.append(b_list[j-1])
            b_list.pop(j-1)
            
            break

answer_list.reverse()


for i in range(N):
    print(answer_list[i])

### FIXED CODE ###

N = int(input())
b_list = list(map(int,input().split()))
answer_list = []
check = 0

for i in range(N):
    if b_list[i] > i+1:
        print(-1)
        check = 1
        break

if check == 0:
    for i in range(N):     
        for j in range(N-i, 0, -1):
            
            if b_list[j-1] == j:
                answer_list.append(b_list[j-1])
                b_list.pop(j-1)
                
                break

    answer_list.reverse()


    for i in range(N):
        print(answer_list[i])
import math
def f(k):
    aaa = 1/math.sqrt(5)*(((1+math.sqrt(5))/2)**k-((1-math.sqrt(5))/2)**k)%1000000007
    return aaa
    
n,m = map(int,input().split())
start = []
for i in range(m):
    start.append(int(input()))

if start == []:
    print(f(n-1))
else:
    pstart = [-1]+start+[n+1] #スタートとゴールを追加
    newlist = [] #距離のリスト
    for j in range(n-1):
        newlist.append(pstart[j+1]-pstart[j]) #障害物同士の距離を測る
    if 1 in newlist[1:len(newlist)-1]:
                 print(0)
    else: #ちゃんと距離が出そうなとき
        for w in newlist:
            ans = 1
            ans = ans*f(w-1)%1000000007      
        print(ans)         

### FIXED CODE ###

def Fib(n):
    a,b = 1,1
    if n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        for i in range(n-2):
            a,b = b,a+b
        return b
    
n,m = map(int,input().split())
start = []
for i in range(m):
    start.append(int(input()))

if start == []:
    print(Fib(n+1)%1000000007)
else:
    pstart = [-1]+start+[n+1] #スタートとゴールを追加
    newlist = [] #距離のリスト
    for j in range(len(pstart)-1):
        newlist.append(pstart[j+1]-pstart[j]) #障害物同士の距離を測る
    if 1 in newlist[1:len(newlist)-1]:
                 print(0)
    else: #ちゃんと距離が出そうなとき
        ans = 1
        #print(newlist)
        for w in newlist:
            #print(Fib(w-1))
            #print(ans)
            ans = (ans*Fib(w-1))%1000000007
        print(ans)
from math import sqrt

n = int(input())
for i in range(sqrt(n), 1, -1):
  if n % i == 0:
    print(i + n/i -2)
    break
else:
  print(n-1)

### FIXED CODE ###

from math import sqrt

n = int(input())
for i in range(int(sqrt(n)), 1, -1):
  if n % i == 0:
    print(i + n//i -2)
    break
else:
  print(n-1)
inputs = input().split(' ')

d = inputs[0:2]
takahashi = {'Name': 'Takahashi', 'Hp': int(d[0]), 'Power': d[1]}
d = inputs[2:4]
aoki = {'Name': 'Aoki', 'Hp': int(d[0]), 'Power': d[1]}

players = [aoki, takahashi]
N =len(players)
while True:
    for i in range(N):
        players[i-1]['HP'] -= players[i]['Power']
        if players[i-1]['HP'] <= 0:
            if players[i]['Name'] == 'Takahashi':
                print('Yes')
            else:
                print('No')

### FIXED CODE ###

# B

inputs = input().split(' ')

d = inputs[0:2]
takahashi = {'Name': 'Takahashi', 'Hp': int(d[0]), 'Power': int(d[1])}
d = inputs[2:4]
aoki = {'Name': 'Aoki', 'Hp': int(d[0]), 'Power': int(d[1])}

players = [takahashi, aoki]

def compute(players):
    N =len(players)
    while True:
        for i in range(N):
            players[i-1]['Hp'] -= players[i]['Power']
            if players[i-1]['Hp'] <= 0:
                if players[i]['Name'] == 'Takahashi':
                    print('Yes')
                else:
                    print('No')
                return 

compute(players)
x, n = map(int, input().split(" "))
if n != 0:
  p=list(map(int, input().split(" ")))
else:
  p=[]
lst = list(range(0, x * 2))
for i in p:
  lst.remove(i)
for i in range(x + 2):
  if x - i in lst or x - i < 0:
    print(x - i)
    break
  elif x + i in lst:
    print(x + i)
    break

### FIXED CODE ###

x, n = map(int, input().split(" "))
if n != 0:
  p=list(map(int, input().split(" ")))
else:
  p=[]
lst = list(range(-1, x * 2 + 1))
for i in p:
  if i in lst:
    lst.remove(i)
for i in range(x + 2):
  if x - i in lst or x - i < 0:
    print(x - i)
    break
  elif x + i in lst:
    print(x + i)
    break
n=int(input())
arr=[[0,0,0]+[list(map(int,input().split())) for _ in range(n)]]
for i in range(n):
  t1,x1,y2=arr[i]
  t2,x2,y2=arr[i+1]
  if abs(x1-x2)+abs(y1-y2)>t1+t2:
    print('No')
    exit()
  if (abs(x1-x2)+abs(y1-y2))%2!=(t1+t2)%2:
    print('No')
    exit()
print('Yes')

### FIXED CODE ###

n=int(input())
flag=True
ts=0
xs=0
ys=0
for i in range(n):
  te,xe,ye=map(int,input().split())
  if (te-ts)%2 == ((xe+ye)-(xs+ys))%2 and ((xe+ye)-(xs+ys))<=(te-ts):
    flag = True
  else:
    flag = False
    break;
  ts,xs,ys=te,xe,ye
if flag:
  print('Yes')
else:
  print('No')
if(S == "ABC"){
print("ARC")
}elif(S=="ARC"){
print("ABC")
}

### FIXED CODE ###

args = input()
if args == "ABC":
 print("ARC")
elif(args=="ARC"):
 print("ABC")
W=input()
s=0
while True:
 T=list(input())
 if T==['END_OF_TEXT']:
  break
 else:
   for i in T:
    if i==W:
        s+=1
print(s)
     
 

### FIXED CODE ###

W=input()
s=0
while True:
 T=list(input().split())
 if T==['END_OF_TEXT']:
   break
 else:
   for i in T:
     if i.lower()==W.lower():
        s+=1
print(s)
def main():
    from collections import Counter
    import sys
    input = sys.stdin.buffer.readline

    _ = int(input())
    A = [int(i) for i in input().split()]

    ans = 0
    c = Counter(A)
    B = sorted(c.keys(), reverse=True)

    for b in B:
        if c[b] == 0:
            continue
        a = (2 ** b.bit_length()) - b
        if a == b:
            cur = c[b]//2
        else:
            if a in c.keys():
                cur = min(c[a], c[b])
            else:
                cur = 0
        ans += cur
        # c[b] -= cur
        c[a] -= cur

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

S = input()

ans = 0
f = -1

for i, s in enumerate(S):
    if f != -1 and s == 'W':
        ans += i - f
        f += 1
    elif f == -1 and s == 'B':
        f = i

print(ans)
n=int(input())
l=[0]
c=0
l.append(map(int,input().split()))
for i in range(1,n+1,2):
  if l[i]&1:
    c+=1
print(c)

### FIXED CODE ###

n=int(input())
l=[0]
c=0
l=l+(list(map(int,input().split())))

try:
  for i in range(1,n+1,2):
    if l[i]&1:
      c+=1
except:
  pass
print(c)
H, W = map(int, input().split())
graph = [list(input()) for _ in range(H)]


def count_bomb(x, y):
    bomb = 0
    one_steps = ((1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (1, -1), (-1, 1), (-1, -1))
    for dx, dy in one_steps:
        nx, ny = x + dx, y + dy
        if (0 <= nx < H) and (0 <= ny <= W):
            if graph[nx][ny] == "#":
                bomb += 1
    return bomb


for x in range(H):
    for y in range(W):
        if graph[x][y] == ".":
            graph[x][y] = count_bomb(x, y)
for line in graph:
    print(line)


### FIXED CODE ###

H, W = map(int, input().split())
Slist = [["."] * (W + 2), ]
for _ in range(H):
    line = list(input())
    line.insert(0, ".")
    line.append(".")
    Slist.append(line)
Slist.append(["."] * (W + 2))
# print(Slist)
point_tuple = ((-1, -1), (-1, 0), (-1, 1),
               (0, -1), (0, 1),
               (1, -1), (1, 0), (1, 1))
for i in range(1, H + 1):
    for j in range(1, W + 1):
        # print(Slist[i][j], i, j)
        if Slist[i][j] == ".":
            counter = 0
            for a, b in point_tuple:
                if Slist[i - a][j - b] == "#":
                    counter += 1
            Slist[i][j] = str(counter)

for i in range(1, H + 1):
    print("".join(Slist[i][1:-1]))
from collections import deque

def isCLKWISE(ph):
    a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]]
    b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]]
    crs = a[0]*b[1] - a[1]*b[0]
    if crs < 0 :
        return False
    else :
        return True
    
def ConvexHullScan(P):
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) :
                break
            else :
                del phU[-2]
                if len(phU) == 2 :
                    break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) :
                break
            else :
                del phL[-2]
                if len(phL) == 2 :
                    break
    ph = phU + phL[1:-1]
    return ph

n = int(input())
P = deque([])
for i in range(n):
    P.append([int(x) for x in input().split()])
    
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
for q in Q:
    idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
    R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

### FIXED CODE ###

def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            try :
                if isCLKWISE(phU) : break
                else : del phU[-2]
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            try :
                if isCLKWISE(phL) : break
                else : del phL[-2]
            except IndexError : break
    ph = phU + phL[1:-1]
    return ph
  
P = [[int(x) for x in input().split()] for _ in range(int(input()))]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])
from bisect import bisect_left as bl
def primes(n):
  tf = [True] * (n + 1)
  tf[0] = tf[1] = False
  for i in range(2, int(n ** (1 / 2) + 1)):
    if tf[i]:
      for j in range(i ** 2, n + 1, i):
        tf[j] = False
  return [i for i in range(n + 1) if tf[i]]

def search_pair(x, prime_lst):
  cnt = 0
  for prime in prime_lst:
    if prime > x // 2:
      break
    i = bl(prime_lst, x - prime)
    if prime_lst[i] == x - prime:
      cnt += 1
  return cnt

prime_lst = primes(1000000)

while True:
  n = int(input())
  if n == 0:
    break
  print(search_pair(n, prime_lst))



### FIXED CODE ###

from bisect import bisect_left as bl
def primes(n):
  tf = [True] * (n + 1)
  tf[0] = tf[1] = False
  for i in range(2, int(n ** (1 / 2) + 1)):
    if tf[i]:
      for j in range(i ** 2, n + 1, i):
        tf[j] = False
  return [i for i in range(n + 1) if tf[i]]

def search_pair(x, prime_lst, len_prime):
  cnt = 0
  for prime in prime_lst:
    if prime > x // 2:
      break
    i = bl(prime_lst, x - prime)
    if i < len_prime and prime_lst[i] == x - prime:
      cnt += 1
  return cnt

prime_lst = primes(1000000)
len_prime = len(prime_lst)

while True:
  n = int(input())
  if n == 0:
    break
  print(search_pair(n, prime_lst, len_prime))
n = int(input())
array = [int(i) for i in input().split()]
ans=-1e14

for i in range(n, 2*n+1):
    l_array = sorted(array[:i])
    r_array = sorted(array[i:])
    ans = max(ans, sum(l_array[i-n:])-sum(r_array[:n]))

print(ans)

### FIXED CODE ###

h,w = [int(i) for i in input().split()]

def solve(h,w):
    ans = min(h,w)
    for i in range(1,h):
        p1 = w*i
        p2 = (h-i)*(w//2)
        p3 = h*w-p1-p2
        ans = min(ans, max(p1,p2,p3)-min(p1,p2,p3))
    return ans 

ans = min(solve(h,w), solve(w,h))
if h*w % 3 == 0:
    ans = 0

print(ans)
x,n=map(int,input().split())
if(n!=0):
    a = list(map(int,input().split()))
flag=True
k = 0

while(True):
    b = x - k
    c = x + k
    if(not(b in a)):
        print(b)
        break
    elif(not(c in a)):
        print(c)
        break
    k = k + 1

### FIXED CODE ###

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

flag=True
k = 0

while(True):
    b = x - k
    c = x + k
    if(not(b in a)):
        print(b)
        flag = False
        break
    elif(not(c in a) and flag):
        print(c)
        break
    k = k + 1