Harryxun/stf_run huggingface dataset:
import sys
from itertools import accumulate
N = int(input())
S = input()
if S == '.'*N or S == '#'*N:
    print(0)
    sys.exit()
else:
    ind1 = 0
    for i, x in enumerate(S):
        if x == '#':
            ind1 = i
            break
    num = 0
    for i, x in enumerate(S[::-1]):
        if x == '.':
            num = i
            break
    ind2 = N - num
    s = S[ind1:ind2]
    if len(s) == 0:
        print(0)
        sys.exit()
    else:
        a = s.split('.')
        b = s.split('#')
        aa = []
        bb = []
        for x, y in zip(a, b):
            if len(x) != 0:
                aa.append(len(x))
            if len(y) != 0:
                bb.append(len(y))
        d = [0] + list(accumulate(aa))
        e = [0] + list(accumulate(bb))
        p = d[-1]
        ls = []
        for i in range(len(d)):
            ls.append(e[i]+p-d[i])
        print(min(ls))
        

### FIXED CODE ###

import sys
from itertools import accumulate
N = int(input())
S = input()

if S == '.'*N or S == '#'*N:
    print(0)
    sys.exit()

ind1 = 0
for i, x in enumerate(S):
    if x == '#':
        ind1 = i
        break
num = 0
for i, x in enumerate(S[::-1]):
    if x == '.':
        num = i
        break
ind2 = N - num
s = S[ind1:ind2]
if len(s) == 0:
    print(0)
    sys.exit()

a = s.split('.')
b = s.split('#')
aa = []
bb = []
for x in a:
    if len(x) != 0:
        aa.append(len(x))
for x in b:
    if len(x) != 0:
        bb.append(len(x))
c = [0] + list(accumulate(aa))
d = [0] + list(accumulate(bb))
ls = []
for i in range(len(c)):
    ls.append(c[i] + d[-1] - d[i])
print(min(ls))
import math
A, B = map(int, input().strip().split())

minAB = min(A,B);

hurui = [True] * (minAB+1)
"""
upper = int(math.sqrt(minAB+1))
ans = 1

for i in range(2, upper+1):

    if not(hurui[i]):
        continue
    
    for j in range(2*i, minAB+1, i):
        hurui[j] = False

    if A % i == 0  and B % i == 0:
        ans += 1
"""
print(ans)

### FIXED CODE ###

import math
A, B = map(int, input().strip().split())

divisors = []

minAB = min(A,B)
maxAB = max(A,B)
upper = int(math.sqrt(minAB+1) + 1)
ans = 1

for i in range(1, upper):
    if minAB % i == 0:
        divisors.append(i)
        if i != minAB//i:
            divisors.append(minAB//i)

divisors.sort()
#print(divisors)

flag = [True] * len(divisors)
for i, num in enumerate(divisors):
    if maxAB % num != 0:
        flag[i] = False
        continue
    for x in divisors:
        if x == 1 :
            continue
        if x > math.sqrt(num):
            break
        if num % x ==0:
            flag[i] = False
            break

print(flag.count(True))
N,M,K=map(int,input("入力してください").split())
costA=list(map(int,input().split()))
costB=list(map(int,input().split()))
costA=[0]+costA
costB=[0]+costB

for i in range(N):
    costA[i+1]+=costA[i]
    
for i in range(M):
    costB[i+1]+=costB[i]

print(costA)
print(costB)

costB.append(float("inf"))

def upper_bound(list1,K):
    low=0
    high=len(list1)-1 #index
    while high-low!=1:
        mid=(high+low)//2
        if list1[mid]>K:
            high=mid
        else:
            low=mid
    return high  #条件を満たす左側の要素数

number=[]
for i in range(N+1): #A側の机の本を固定 残りの時間でBを二分探索
    time=K-costA[i]
    number.append(i+upper_bound(costB,time)-1)
    print(i)
    print(upper_bound(costB,time))
    print(number)
    
print(max(number))


### FIXED CODE ###

N,M,K=map(int,input().split())
costA=list(map(int,input().split()))
costB=list(map(int,input().split()))
costA=[0]+costA
costB=[0]+costB

for i in range(N):
    costA[i+1]+=costA[i]
    
for i in range(M):
    costB[i+1]+=costB[i]

"""print(costA)
print(costB)"""

""

def upper_bound(list1,K):
    low=0
    high=len(list1) #index
    while high-low!=1:
        mid=(high+low)//2
        if list1[mid]>K:
            high=mid
        else:
            low=mid
    return low  #条件を満たす左側の要素数

number=[]
#print(costA)
#print(costB)
for i in range(N+1): #A側の机の本を固定 残りの時間でBを二分探索
    time=K-costA[i]
    if time<0:
        break
    #print(i,upper_bound(costB,time))
    number.append(i+upper_bound(costB,time))

"""print(i)
    print(upper_bound(costB,time))
    print(number)"""
    
print(max(number))



"""
print(cumcost)
#以下二分探索 必要なのはソート済みリストと検索したい値
#upper bound 基準値よりも大きい最初の値を返す
#lower bound 基準値以上の最初の値を返す
#欲しい値はl基準値以下の最大値=upper bound値−１の位置の値
    #冊数は+1なので、求める値はupper_bound
# 検索したい値＝K分を超えない最大の値
low=0
high=len(cumcost)-1
while high-low!=1: #差が１になったら終了
    print(high)
    print(low)
    mid=(high+low)//2 #pythonの//は切り捨て徐算
    if cumcost[mid]>K:  #推測した値が大きすぎた ### 値のダブり注意
        high=mid
    else: # 推測した値小さすぎた#cumcost<=K
        low=mid 
#条件を満たす値の個数 (upper_bound)
    #条件を満たすのが左・・・high
    #条件を満たすのが右・・・len(cumcost)--1-low
upper_bound=high #最終的な値はupper_bound
print(upper_bound)
"""
"""境界線が端っこにあると上手に探索できない
→例外処理で乗り切るか　探索のやり方自体を変更するか　どちらが良いか？"""
s = str(input())
n = int(input())
print(s.count('ABC')) if len(s)==n

### FIXED CODE ###

N = int(input())
S = str(input())
print(S.count("ABC"))
n,d=map(int,input().split())
if n%(2*d+i)==0:
  print(n//(2*d+1))
else:
  print(n//(2*d+1)+1)

### FIXED CODE ###

n,d=map(int,input().split())
if n%(2*d+1)==0:
  print(n//(2*d+1))
else:
  print(n//(2*d+1)+1)
sum = 0
for i in map(int, input().split()):
    if i==1:
        sum += 300000
    elif i==2:
        sum+200000
    elif i==3:
        sum += 100000
if sum == 600000:
    sum += 400000
print(s)

### FIXED CODE ###

s = 0
for i in map(int, input().split()):
    if i==1:
        s+=300000
    elif i==2:
        s+=200000
    elif i==3:
        s+=100000
if s==600000:
    s=1000000
print(s)
s = str(input())
s[:5] = '2018'
print(s)

### FIXED CODE ###

s = str(input())
t = s.replace("2017","2018")
print(t)
x = input()
y = input()
z = len(y)
if z <= x:
  print(y)
else:
  print(y[:x])

### FIXED CODE ###

x = input()
y = input()
z = len(y)
if z <= int(x):
  print(y)
else:
  print(y[:int(x)]+'...')
n=input()
if a[0] == '9' or a[1] == '9':
  print('Yes')
else:prnit('No')

### FIXED CODE ###

a=input()
if a[0] == '9' or a[1] == '9':
  print('Yes')
else:print('No')
= input()
flag = True
for i in range((len(s)-1)//2):
	if s[i] == s[len(s)-i-1]:
		continue
	else:
		flag = False
		break

if flag:
	left = s[:(len(s)-1)//2]
	right = s[(len(s)+3)//2-1:]
	if left == right:
		print("Yes")
	else:
		print("No")
else:
	print("No")


### FIXED CODE ###

s= input()
flag = True
for i in range((len(s)-1)//2):
	if s[i] == s[len(s)-i-1]:
		continue
	else:
		flag = False
		break

if flag:
	left = s[:(len(s)-1)//2]
	right = s[(len(s)+3)//2-1:]
	if left == right:
		print("Yes")
	else:
		print("No")
else:
	print("No")
import numpy as np
N = int(input())
A = list(map(int,input().split()))

chofuku_dict = {}
chofuku = []

for a in A:
    if a not in chofuku_dict:
        chofuku_dict[a] = 1
    else:
        chofuku.append(a)
        
chofuku = set(chofuku)

A = list(set(A))
A.sort()

bl = np.array([0] + [1]*A[-1])

ans = 0
for a in A:
    if bl[a] == 0:
        continue
    if a in chofuku:
        continue
    bl[a] = 0
    ans += 1
    bl[2*a::a] = 0
print(ans)

### FIXED CODE ###

x = list(map(int,input().split()))
print(x.index(0)+1)
# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d

L = int(input())

A = [int(input()) for _ in range(L)]

INF = int(1e15)
dp = [[INF] * (L + 1)] for _ in range(5)]

for i in range(4):
    dp[i][0] = 0

for i in range(n):
    dp[0][i + 1] = dp[0][i] + A[i]  # 全部取り除く
    dp[1][i + 1] = min(dp[j][i] for j in range(2)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[2][i + 1] = min(dp[j][i] for j in range(3)) + (1 if A[i] % 2 == 0 else 0)
    dp[3][i + 1] = min(dp[j][i] for j in range(4)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[4][i + 1] = min(dp[j][i] for j in range(5)) + A[i]  # 全部取り除く


print(min(dp[i][L] for i in range(1, 5)))


### FIXED CODE ###

# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d

L = int(input())

A = [int(input()) for _ in range(L)]

INF = int(1e15)
dp = [[INF] * (L + 1) for _ in range(5)]

for i in range(4):
    dp[i][0] = 0

for i in range(L):
    dp[0][i + 1] = dp[0][i] + A[i]  # 全部取り除く
    dp[1][i + 1] = min(dp[j][i] for j in range(2)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[2][i + 1] = min(dp[j][i] for j in range(3)) + (1 if A[i] % 2 == 0 else 0)
    dp[3][i + 1] = min(dp[j][i] for j in range(4)) + (A[i] % 2 if A[i] != 0 else 2)
    dp[4][i + 1] = min(dp[j][i] for j in range(5)) + A[i]  # 全部取り除く


print(min(dp[i][L] for i in range(1, 5)))
import copy

combinations = []
def make_combination(n):
    S = [0 for i in range(n)]
    rec(0, n, S)

def rec(i, n, S):
    global combinations
    if i == n:
        combinations.append(copy.copy(S))
        return None
    rec(i+1, n, S)
    S[i] = 1
    rec(i+1, n, S)
    S[i] = 0

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

make_combination(n)
for m in M:
    flag = False
    for co in combinations:
        sum = 0
        for i in range(n):
            sum += A[i] * co[i]
            if sum >= m:
                break
        if sum == m:
            flag = True
            break

    if flag:
        print('yes')
    else:
        print('no')



### FIXED CODE ###

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

# 上限と下限でフィルター
max_A = 0
min_A = float('inf')
for num in A:
    max_A += num
    if num < min_A:
        min_A = num

def rec(i, m):
    if m < 0:
        return False
    elif m == 0:
        return True
    if i >= n:
        return False

    rst = rec(i+1, m - A[i]) or rec(i+1, m)
    return rst

for m in M:
    if m < min_A or max_A < m:
        print('no')
    elif rec(0, m):
        print('yes')
    else:
        print('no')
N = int(input())
# スペース区切りの整数の入力
A = list(map(int, input().split()))
C=A[:]
C=list(set(C))

#print(A)
#print(C)
def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

anslist=[]

if len(C)==1:
  ans=C[0]

elif len(C)==2:
  sol=max(C[0],C[1])

else:
  for i in range(3):
    B=A[:]
    B.remove(C[i])
    sol=0
    for b in B:
        sol=gcd(sol,b)
    anslist.append(sol)
    ans=max(anslist)

#print(anslist)
print(ans)



### FIXED CODE ###

N = int(input())
# スペース区切りの整数の入力
A = list(map(int, input().split()))


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

list1=[0]
L=0
for a in A:
    L=gcd(L,a)
    list1.append(L)

list2=[0]
R=0
for a in reversed(A):
    R=gcd(R,a)
    list2.append(R)

list2.reverse()

ans=[]

for i in range(N):
    ans.append(gcd(list1[i],list2[i+1]))

print(max(ans))
n=input()

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

b=map(bin,a)

c=map(rfind('1')-1,c)

print(min(c))

### FIXED CODE ###

import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))
i = 0
a=[]
while 1:
    try:
         a.append(float(raw_input()))
         i += 1
a.sort()
print a[len(a)-1] - a[0]

### FIXED CODE ###

a=[]
while True:
    try:
        a.append(float(raw_input()))
    except:
        break

a.sort()
print a[len(a)-1] - a[0]
a = list(map(int, input().split()))

if a[0]-a[1]=0 or a[1]-a[2]=0 or a[2]-a[3]=0:
    print("Bad")
else:
    print("Good")

### FIXED CODE ###

a = list(map(int, input()))

if a[0]-a[1]==0 or a[1]-a[2]==0 or a[2]-a[3]==0:
    print("Bad")
else:
    print("Good")
Python 3 
File
Edit
View
Insert
Cell
Kernel
Widgets
Help

import math
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
arrayp=[1]
for iii in range(n-1):
    arrayp+=[1]
arrayq=[1]
for jjj in range(n-1):
    arrayq+=[1]
pnum=0
qnum=0
for i in range(n-1):
    prank=0
    for ii in range(p[i]):
        if arrayp[ii]==1:
            prank+=1
    pnum=pnum+(prank-1)*math.factorial(n-i-1)
    arrayp[p[i]-1]=0
for j in range(n-1):
    qrank=0
    for jj in range(q[j]):
        if arrayq[jj]==1:
            qrank+=1
    qnum=qnum+(qrank-1)*math.factorial(n-j-1)
    arrayq[q[j]-1]=0
print(abs(pnum-qnum))
8

### FIXED CODE ###

import math
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
arrayp=[1]
for iii in range(n-1):
    arrayp+=[1]
arrayq=[1]
for jjj in range(n-1):
    arrayq+=[1]
pnum=0
qnum=0
for i in range(n-1):
    prank=0
    for ii in range(p[i]):
        if arrayp[ii]==1:
            prank+=1
    pnum=pnum+(prank-1)*math.factorial(n-i-1)
    arrayp[p[i]-1]=0
for j in range(n-1):
    qrank=0
    for jj in range(q[j]):
        if arrayq[jj]==1:
            qrank+=1
    qnum=qnum+(qrank-1)*math.factorial(n-j-1)
    arrayq[q[j]-1]=0
print(abs(pnum-qnum))
H,W = map(int,input().split())

if H == 1 or W == 1:
  return 1
else:
  cnt = (H * W + 1) // 2
  return cnt

### FIXED CODE ###

H,W = map(int,input().split())
 
if H == 1 or W == 1:
  print(1)
else:
  cnt = (H * W + 1) // 2
  print(cnt)
N = int(input())
H = list(map(int,input().split()))

ans = 0
tmp = H[0]

for i in range(len(H)-1):
    if H[i] <= H[i+1]:
        tmp = H[i+1]
    else:
        ans += tmp - H[i+1]
else:
    ans += H[i+1]

print(ans)

### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))

ans = 0
tmp = h = H[0]

for h in H[1:]:
    if h >= tmp:
        tmp = h
    else:
        ans += tmp - h
        tmp = h
else:
    ans += h

print(ans)
N, M = map(int, input().split())
if M % 2 == 1:
  print(-1)
else:
  E = []
  A = [[] for _ in range(N)]
  for _ in range(M):
    i, j = map(int, input().split())
    E.append([i-1, j-1])
    A[i-1].append(j-1)
    A[j-1].append(i-1)

  tree = [[] for _ in range(N)]
  visited = [False] * N
  queue = [0]
  visited[0] = True
  while queue:
    i = queue.pop()
    for j in A[i]:
      if not visited[j]:
        tree[i].append(j)
        tree[j].append(i)
        visited[j] = True
        queue.append(j)

  D = [0] * N
  for i, j in E:
    if i not in tree[j]:
      print(i+1, j+1)
      D[i] += 1

  def f(parent, i):
    for j in tree[i]:
      if j == parent:
        continue
      f(i, j)
      if D[j] % 2 == 0:
        print(i+1, j+1)
        D[i] += 1
      else:
        print(j+1, i+1)
        D[j] += 1
    return

  f(0, 0)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

N, M = map(int, input().split())
if M % 2 == 1:
  print(-1)
  exit()
  
E = []
A = [[] for _ in range(N)]
for _ in range(M):
  i, j = map(int, input().split())
  E.append([i-1, j-1])
  A[i-1].append(j-1)
  A[j-1].append(i-1)

tree = [[] for _ in range(N)]
visited = [False] * N
queue = [0]
visited[0] = True
while queue:
  i = queue.pop()
  for j in A[i]:
    if not visited[j]:
      tree[i].append(j)
      tree[j].append(i)
      visited[j] = True
      queue.append(j)

D = [0] * N
for i, j in E:
  if i not in tree[j]:
    print(i+1, j+1)
    D[i] += 1

def f(parent, i):
  for j in tree[i]:
    if j == parent:
      continue
    f(i, j)
    if D[j] % 2 == 0:
      print(i+1, j+1)
      D[i] += 1
    else:
      print(j+1, i+1)
      D[j] += 1
  return

f(0, 0)
import sys
import sympy
def input(): return sys.stdin.readline().strip()

i  = lambda: int(input())

N = i()

pfd = sympy.factorint(N)

check_num = []

for pf in pfd.keys():
    tmp_num = []
    for i in range(1, pfd[pf] + 1):
        tmp_num.append(pf ** i)
        for n in check_num:
            tmp_num.append(n * (pf ** i))
    check_num += tmp_num

count = 0
for n in check_num:
    if N / n < n:
        count += n-1

print(count)

### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()
def prime_factors(n):
    i = 2
    factors = {}
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            if i in factors.keys():
                factors[i] += 1
            else:
                factors[i] = 1
    if n > 1:
        if n in factors.keys():
            factors[n] += 1
        else:
            factors[n] = 1
    return factors

i  = lambda: int(input())

N = i()

pfd = prime_factors(N)

check_num = []

for pf in pfd.keys():
    tmp_num = []
    for i in range(1, pfd[pf] + 1):
        tmp_num.append(pf ** i)
        for n in check_num:
            tmp_num.append(n * (pf ** i))
    check_num += tmp_num

count = 0
for n in check_num:
    if N // (n-1) == N % (n-1):
        count += n-1

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

sum = 0
for n in range(N-1):
  if a[n]>a[n+1]:
    dif=a[n]-a[n+1]
    a[n+1]=a[n+1]+dif
    sum+=dif
print(sum)
		

### FIXED CODE ###

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

sum = 0
for n in range(N-1):
	if a[n]>a[n+1]:
		dif=a[n]-a[n+1]
		a[n+1]=a[n+1]+dif
		sum=sum+dif
print(sum)
a, b, c = input().split()
print(c, a, b)

### FIXED CODE ###

a, b, c = input().split()
print(c, a, b)
n = int(input())
b = list(map(int, input().split()))
b.reverse()
ans_set = [0]*n

for i in range(n):
    if ans == -1:
        break
    
    for j in range(n):
        if b[j] == n-j:
            ans = b.pop(j)
            ans_set[n-1] = ans
            n -= 1
            break
            
        elif b[j] > n-j:
            ans = -1
            print(ans)
            break

        if n == 0:
            break

if ans != -1:
    for k in ans_set:
        print(k)

### FIXED CODE ###

n = int(input())
b = list(map(int, input().split()))
b.reverse()
ans_set = [0]*n
ans = 0

for i in range(n):
    if ans == -1:
        break
    
    for j in range(n):
        if b[j] == n-j:
            ans = b.pop(j)
            ans_set[n-1] = ans
            n -= 1
            break
            
        elif b[j] > n-j:
            ans = -1
            print(ans)
            break

        if n == 0:
            break

if ans != -1:
    for k in ans_set:
        print(k)
x=[i for i in range(input())]
print(sum(x))

### FIXED CODE ###

x=[i for i in range(1,int(input())+1)]
print(sum(x))
def resolve():
    X = int(input())
    powered = set()
    for i in range(100):
        powered.add(i**5)
    for b in powered:
        if X+b in powered:
            a = int((b+X)**(1/5))
            b = int(b**(1/5))
            print(a, b)
            return
        if X-b in powered:
            a = int((b+X)**(1/5))
            b = -int(b**(1/5))
            print(a, b)
            return
            
    assert False


if '__main__' == __name__:
    resolve()


### FIXED CODE ###

def resolve():
    X = int(input())
    for a in range(-200, 201):
        for b in range(-200, 201):
            if a**5 - b**5 == X:
                print(a, b)
                return
    assert False


if '__main__' == __name__:
    resolve()
import numpy as np
while 1:
    n = input()
    if n == 0: break
    p = np.array(sorted([map(int, raw_input().split()) for i in range(n)]))
    dist = [p[i] - p[0] for i in range(1,n)]
    m = input()
    q = np.array(sorted([map(int, raw_input().split()) for i in xrange(m)]))
    for p1 in q:
        for i in range(n-1):
            f = True
            for p2 in q:
                if np.all(p1 + dist[i] == p2):
                    f = False
                    break
            if f: break
        else:
            print p1[0] - p[0][0], p1[1] - p[0][1]

### FIXED CODE ###

while 1:
    n = input()
    if n == 0: break
    p = set([tuple(map(int, raw_input().split())) for i in range(n)])
    m = input()
    q = set([tuple(map(int, raw_input().split())) for i in xrange(m)])
    ret = False
    for px, py in p:
        if ret: break
        for qx, qy in q:
            if ret: break
            dx = qx - px
            dy = qy - py
            for x, y in p:
                mx = x + dx
                my = y + dy
                if (mx, my) not in q:
                    break
            else:
                print dx, dy
                ret = True
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))    
    score = 0
    pre = -1
    for i in a:
        score += b[i]
        if(i==pre+1):
            score += c[i-2]
            pre =i
    print(score)

if __name__ == "__main__":
    main()

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
 
ans=0
pre=-1
 
for i in a:
  ans += b[i-1]
  if(i==pre+1):
    ans += c[i-2]
  pre=i
  
print(ans)
a = int(input());
b = int(input());

if (a >= 1 and a <= 9 and b >= 1 and b <= 9):
  print(a*b)
else:
  print("-1")


### FIXED CODE ###

import sys
import math
import bisect
 
 
sys.setrecursionlimit(1000000000)
def input():
    return sys.stdin.readline().strip()
 
def iinput():
    return int(input())
 
def finput():
    return float(input())
 
def tinput():
    return input().split()
 
def rinput():
    return map(int, tinput())
 
def rlinput():
    return list(rinput())
 
def modst(a, s):
    res = 1
    while s:
        if s % 2:
            res *= a
        a *= a
        s //= 2
    return res

 
def main():
    a, b = rinput()
    if a >= 10 or b >= 10:
        print(-1)
    else:
        print(a * b)
main()
n = input()
for i in range(1,n+1):
  x = i
  if x%3==0:
    print ' %d', % x
    continue
  elif x<=n:
    if x%10==3:
      print ' %d', % x
      break
    else:
      x /= 10
      if x==0:
        break

### FIXED CODE ###

import sys
n = input()
for i in range(1,n+1):
  x = i
  if x%3==0:
    sys.stdout.write(' %d' % i)
    continue
  while x<=n:
    if x%10==3:
      sys.stdout.write(' %d' % i)
      break
    else:
      x /= 10
      if x==0:
        break
sys.stdout.write('\n')
num = input()
l =[]

for i in range(num):
   l.append(input())

max = l[1] - l[0]
for i in range(num):
   for j in range(num-1):
      if max < l[j] - l[i]
         max = l[j] - l[i]
print max

### FIXED CODE ###

length = int(input())
minv = int(input())
maxv = -2000000000
for j in range(1, length):
    hoge = int(input())
    maxv = max(maxv, hoge-minv)
    minv = min(minv, hoge)
print (maxv)
s = input()
print(s[0] + str(len(s) - 2) + s[-1])s

### FIXED CODE ###

s = input()
print(s[0] + str(len(s) - 2) + s[- 1])
s=input()
if s[-1] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre=[0 for i in range(13)]
    pre[int(s[-1])] += 1
for i in range(1, len(s)):
    data=[0 for i in range(13)]
    tmp = 10**i % 13
    if s[len(s)-1-i] == "?":
        for j in range(10):
            for k in range(13):
                data[(tmp*j+k)%13] += pre[k]
    else:
        tmp = tmp*int(s[len(s)-1-i]) % 13
        for k in range(13):
            data[(tmp+k)%13] += pre[k]
    pre = data.copy()
print(data[5]%(10**9+7))

### FIXED CODE ###

s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])
N = int(input())
A = list(map(int, input().split()))
if N > 1:
    for i in range(N-1):
        if A[i]>A[i+1]:
            A[i] -= 1
    for i in range(N-1):
        if A[i] > A[i+1]:
            print("No")
            break
    else:
        print("Yes")
elif N == 1:
    print("Yes")


### FIXED CODE ###

a, b,c = map(int, input().split())
d = c-(a-b)
if d<0:
    d = 0
print(d)
import itertools 
n = int(input())
p = list(map(int,input().split()))
q= list(map(int,input().split()))

cnt=0
for v in itertools.permutations(range(1,n+1), n):
    cnt +=1
    if(p==v):
        a = cnt
    if(q==v):
        b = cnt

print(abs(a-b))

### FIXED CODE ###

import itertools
n = int(input())
p = tuple(((map(int,input().split()))))
q = tuple(((map(int,input().split()))))

num = []
for i in range(1,n+1):
    num.append(i)
ans = []
for i in itertools.permutations(num,n):
    ans.append(i)

print(abs(ans.index(p)-ans.index(q)))
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

addans=0

for i in range(1,n) :
  if a[i-1]+1 == a[i] :
    addans += c[a[i-2]]
    print(addans)
print(sum(b)+addans)

### FIXED CODE ###

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

addans=0

for i in range(n-1) :
  if a[i]+1 == a[i+1] :
    addans += c[a[i]-1]
print(sum(b)+addans)