Harryxun/stf_run huggingface dataset:
N = int(input())
if N < 5002:
    if N % 2  == 0:
        sans = [6 * i  + 3 for i in range(N-2)]
        ans = sans + [2,4]
    if N % 2 == 1:
        sans = [6 * i  + 3 for i in range(N-3)]
        ans = sans + [2,4,6]
    if N == 3:
        ans = [2,3,25]
else:
    sans = [6 * i  + 3 for i in range(4999)]
    nis = [2 * i + 2 for i in range(N - 50000 )]
    if N == 20000:
        nis[-1] = 5
    else:
        if (len(nis) * (nis[0] + nis[-1]) //2) % 3 == 1:
            nis[-1] += 2
        elif    (len(nis) * (nis[0] + nis[-1]) //2) % 3 == 2:
            nis[-1] += 2
            nis[-2] += 2
    ans = sans + nis
print(ans)        

### FIXED CODE ###

N = int(input())
if N < 5002:
    if N % 2  == 0:
        sans = [6 * i  + 3 for i in range(N-2)]
        ans = sans + [2,4]
    if N % 2 == 1:
        sans = [6 * i  + 3 for i in range(N-3)]
        ans = sans + [2,4,6]
    if N == 3:
        ans = [2,3,25]
else:
    sans = [6 * i  + 3 for i in range(5000)]
    nis = [2 * i + 2 for i in range(N - 5000 )]
    if (len(nis) * (nis[0] + nis[-1]) //2) % 3 == 1:
        nis[-1] += 2
    elif    (len(nis) * (nis[0] + nis[-1]) //2) % 3 == 2:
        nis[-1] += 2
        nis[-2] += 2
    ans = sans + nis
ans = map(str,ans)
print(" ".join(ans))
def insertionSort( nums, n, g ):
	cnt = 0
	for i in range( g, len( nums ) ):
	    v = nums[i]
	    j = i - g
	    while 0 <= j and v < nums[j]:
	        nums[ j+g ] = nums[j]
	        j -= g
	        cnt += 1
	    nums[ j+g ] = v
	
	return cnt


def shellSort( nums, n ):
	cnt = 0
	g = []
	val =0
	for i in range( 0, n ):
		val = 3*val+1
		if  n < val:
			break
		g.append( val )

	g.reverse( )
	m = len( g )
	print( m )
	print( " ".join( map( str, g ) ) )
	for i in range( 0, m ):
		cnt += insertionSort( nums, n, g[i] )
	print( cnt )

n = int( input( ) )
nums = []
for i in range( 0, n ):
	nums.append( int( input( ) ) )

shellSort( nums, n )
for i in nums:
	print( i )

### FIXED CODE ###

import sys
 
def insertionSort( nums, n, g ):
    cnt = 0
    i = g
    while i < n:
        v = nums[i]
        j = i - g
        while 0 <= j and v < nums[j]:
            nums[ j+g ] = nums[j]
            j -= g
            cnt += 1
        nums[ j+g ] = v
        i += 1
    return cnt
         
def shellSort( nums, n ):
    g = []
    val = 1
    while val <= n:
        g.append( val )
        val = 3*val+1
     
    g.reverse( )
    m = len( g )
    print( m )
    print( " ".join( map( str, g ) ) )
    cnt = 0
    for i in range( m ):
        cnt += insertionSort( nums, n, g[i] )
    print( cnt )
     
n = int( sys.stdin.readline( ) )
nums = []
for i in range( n ):
    nums.append( int( sys.stdin.readline( ) ) )
 
shellSort( nums, n )
print( "\n".join( map( str, nums ) ) )
A,B = 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))
import sys
import math
MOD = 10 ** 9 + 7

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

def mod_inv(a):
    x = extgcd(a,MOD)[0]
    return (MOD+x%MOD)%MOD

input = sys.stdin.readline
n,a,b = map(int,input().split())
x1 = 1

a = min(a,n-a)
b = min(b,n-b)
if a > b:
    a,b = b,a

for i in range(n-a+1,n+1):
    x1 = x1 * i % MOD
for i in range(1,a+1):
    x1 = x1 * mod_inv(i)

x2 = x1
for i in range(n-b+1,n-a+1):
    x2 = x2 * i % MOD
for i in range(a+1,b+1):
    x2 = x2 * mod_inv(i)
    x2 = x2 % MOD

t = []
nn = n
while nn > 0:
    t.append(nn % 2)
    nn //= 2
x0 = 1
for i in range(len(t)):
    x0 = x0 ** 2
    x0 = x0 % MOD
    if t[n-i-1] == 1:
        x0 *= 2
        x0 = x0 % MOD
print ((x0 - x1 - x2 - 1) % MOD)




### FIXED CODE ###

import sys
import math
MOD = 10 ** 9 + 7

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

def mod_inv(a):
    x = extgcd(a,MOD)[0]
    return (MOD+x%MOD)%MOD

input = sys.stdin.readline
n,a,b = map(int,input().split())
x1 = 1

a = min(a,n-a)
b = min(b,n-b)
if a > b:
    a,b = b,a

for i in range(n-a+1,n+1):
    x1 = x1 * i % MOD
x11 = 1
for i in range(1,a+1):
    x11 = x11 * i % MOD
x1 = x1 * mod_inv(x11) % MOD

x2 = x1
for i in range(n-b+1,n-a+1):
    x2 = x2 * i % MOD
x21 = 1
for i in range(a+1,b+1):
    x21 = x21 * i % MOD
x2 = x2 * mod_inv(x21) % MOD

t = []
nn = n
while nn > 0:
    t.append(nn % 2)
    nn //= 2
x0 = 1
for i in range(len(t)):
    x0 = x0 ** 2
    x0 = x0 % MOD
    if t[len(t)-i-1] == 1:
        x0 *= 2
        x0 = x0 % MOD
print ((x0 - x1 - x2 - 1) % MOD)
import numpy as np
n, m, q = map(int, input().split())
kukan = np.zeros((N+1, N+1))
for _ in range(m):
    l, r = map(int, input().split())
    kukan[r][l] += 1

# まず終点の側から考える
# iまでに終わる線分の数はi-1までの累積和
for i in range(1, n+1):
    kukan[i] += kukan[i-1]
# 次に始点の側から考える
# i以降に始まる線分の数はi-1までの総和
for i in range(1, n+1):
    kukan[:, i] += kukan[i-1]

for i in range(q):
    p, q = list(map(int, input().split()))
    print(int(kukan[q][q] - kukan[q][p-1] - kukan[p-1][q] + kukan[p-1][p-1]))


### FIXED CODE ###

import numpy as np
n, m, q = map(int, input().split())
kukan = np.zeros((n+1, n+1))
for _ in range(m):
    l, r = map(int, input().split())
    kukan[r][l] += 1

# まず終点の側から考える
# iまでに終わる線分の数はi-1までの累積和
for i in range(1, n+1):
    kukan[i] += kukan[i-1]
# 次に始点の側から考える
# i以降に始まる線分の数はi-1までの総和
for i in range(1, n+1):
    kukan[:, i] += kukan[:, i-1]
# print(kukan)
for i in range(1, q+1):
    p, q = list(map(int, input().split()))
    print(int(kukan[q][q] - kukan[q][p-1] - kukan[p-1][q] + kukan[p-1][p-1]))
n = int(input())
for _ in range(n):
    d1, d2 = map(int, input().split(" "))
    if d1 == d2:
        count += 1
    else:
        count = 0
    
    
    if count >= 3:
        print("yes")
        break
if count < 3:
    print("no")

### FIXED CODE ###

def judge():
    cnt = 0  # 今何連続でゾロ目が出ているか記録しておきます

    for _ in range(N):
        x, y = map(int, input().split())
        if x == y:
            # ゾロ目ストリークが1増えました
            cnt += 1
        else:
            # ゾロ目ストリークが切れました
            cnt = 0

        if cnt == 3:
            # 3連続になった瞬間、return True していいです
            return True

    # ダメでした
    return False

N = int(input())

if judge():
    # judge() で Trueが返ってくるとこっちに進みます
    print("Yes")
else:
    # Falseだとこっちです
    print("No")
#!/usr/bin/env python3
import sys

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors

def lef(a, b):
    return a*a*a*a + a*a*a*b + a*a*b*b + a*b*b*b + b*b*b*b

def solve(X: int):
    divs = make_divisors(X)
    for d in divs:
        base = 0
        upper = X // d
        while(lef(base+d,base) < upper):
            base+=1
        if lef(base+d,base) == upper:
            print(base+d,base)
            return

        base = -d//2-1
        while(lef(base+d,base) < upper) and (base > d//2):
            base -= 1
        if lef(base+d, base) == upper:
            print(base+d, base)
            return

        base = -d
        while(lef(base+d,base) < upper) and (base < -d//2):
            base += 1
        if lef(base+d, base) == upper:
            print(base+d, base)
            return

        base = -d
        while(lef(base+d,base) < upper):
            base -= 1
        if lef(base+d, base) == upper:
            print(base+d, base)
            return
    raise
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

def solve(X: int):

    for i in range(-150, 150):
        for j in range(-150, 150):
            if j**5 - i**5 == X:
                print(j, i)
                return
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()
a=int(input())
b=int(input())
c=a+b
 
if  a%3==0 or b%3==0 or c%3==0: print("Possible")
else: print("Impossible")

### FIXED CODE ###

a,b=map(int,input().split())
c=a + b
 
if  a%3==0 or b%3==0 or c%3==0: print("Possible")
else: print("Impossible")
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
from collections import defaultdict

def main():
  h, w, d = map(int, input().split())
  mat_a = numpy.array([list(map(int, input().split())) for _ in range(h)])
  q = int(input())
  x_to_pos = dict()
  
  for i in range(h):
    for j in range(w):
      x_to_pos[mat_a[i, j]] = (i, j)
      
  def calc_score(p1, p2):
    return sum([abs(x-y) for x, y in zip(p1, p2)])
  
  visited = numpy.zeros((h, w))
  costs = defaultdict(dict)
  for x in range(1, d+1):
    c = x
    cost = 0
    costs[c%d][c%d] = 0
    while True:
      cp = x_to_pos[c]
      c += d
      if c > (h*w):
        break
      np = x_to_pos[c]
      cost += calc_score(cp, np)
      costs[c%d][c] = cost
      
  for _ in range(q):
    cost = 0
    l, r = map(int, input().split())
    print(abs(costs[l%d][l] - costs[l%d][r]))

if __name__=='__main__':
  main()



### FIXED CODE ###

#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
from collections import defaultdict

def main():
  h, w, d = map(int, input().split())
  mat_a = numpy.array([list(map(int, input().split())) for _ in range(h)])
  q = int(input())
  x_to_pos = dict()
  
  for i in range(h):
    for j in range(w):
      x_to_pos[mat_a[i, j]] = (i, j)
      
  def calc_score(p1, p2):
    return sum([abs(x-y) for x, y in zip(p1, p2)])
  
  visited = numpy.zeros((h, w))
  costs = defaultdict(dict)
  for c in range(1, d+1):
    cost = 0
    costs[c%d][c] = 0
    while True:
      cp = x_to_pos[c]
      c += d
      if c > (h*w):
        break
      np = x_to_pos[c]
      cost += calc_score(cp, np)
      costs[c%d][c] = cost
  
  for _ in range(q):
    l, r = map(int, input().split())
    print(abs(costs[l%d][l] - costs[l%d][r]))

if __name__=='__main__':
  main()
l = list(input)
s = set(l)
for i in s:
    if l.count(i)%2 != 0:
        print("No")
        exit()
print("Yes")

### FIXED CODE ###

l = list(input())
s = set(l)
for i in s:
    if l.count(i)%2 != 0:
        print("No")
        exit()
print("Yes")
n = int(input())
a = list(map(int, input().split()))

s = set()
c = 0

for i in range(n):
    if 1 <= a[i] <= 399:
        s.add(1)

    elif 400 <= a[i] <= 799:
        s.add(2)

    elif 800 <= a[i] <= 1199:
        s.add(3)

    elif 1200 <= a[i] <= 1599:
        s.add(4)

    elif 1600 <= a[i] <= 1999:
        s.add(5)

    elif 2000 <= a[i] <= 2399:
        s.add(6)

    elif 2400 <= a[i] <= 2799:
        s.add(7)

    elif 2800 <= a[i] <= 3199:
        s.add(8)

    else:
        c += 1

if len(s):
    print(len(s), len(s)+c)
elif:
    print(1, c)


### FIXED CODE ###

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

s = set()
c = 0

for i in range(n):
    if 1 <= a[i] <= 399:
        s.add(1)

    elif 400 <= a[i] <= 799:
        s.add(2)

    elif 800 <= a[i] <= 1199:
        s.add(3)

    elif 1200 <= a[i] <= 1599:
        s.add(4)

    elif 1600 <= a[i] <= 1999:
        s.add(5)

    elif 2000 <= a[i] <= 2399:
        s.add(6)

    elif 2400 <= a[i] <= 2799:
        s.add(7)

    elif 2800 <= a[i] <= 3199:
        s.add(8)

    else:
        c += 1

if len(s):
    print(len(s), len(s)+c)
else:
    print(1, c)
import numpy as np
K = input()
lunlun_number = [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
for _ in range(9):
    tmp = []
    for n in lunlun_number[-1]:
        if n % 10 != 0:  # 末尾が0の場合は-1した数がルンルン数にならないのでそれ以外を採用
            tmp.append(n * 10 + (n % 10 - 1))
        tmp.append(n * 10 + (n % 10))
        if n % 10 != 9:  # 末尾が9のときは+1した数がルンルン数にならないのでそれ以外を採用
            tmp.append(n * 10 + (n % 10 + 1))
    lunlun_number.append(tmp)
lunlun_number = np.array(lunlun_number).flatten()
print(lunlun_number[K - 1])


### FIXED CODE ###

import numpy as np
K = int(input())
lunlun_number = [[1, 2, 3, 4, 5, 6, 7, 8, 9]]
for _ in range(9):
    tmp = []
    for n in lunlun_number[-1]:
        if n % 10 != 0:  # 末尾が0の場合は-1した数がルンルン数にならないのでそれ以外を採用
            tmp.append(n * 10 + (n % 10 - 1))
        tmp.append(n * 10 + (n % 10))
        if n % 10 != 9:  # 末尾が9のときは+1した数がルンルン数にならないのでそれ以外を採用
            tmp.append(n * 10 + (n % 10 + 1))
    lunlun_number.append(tmp)
lunlun_number = [flatten for inner in lunlun_number for flatten in inner]
print(lunlun_number[K - 1])
A, B, C = map(int, input().split())
rest: int = C - (A - B)
result: int = (rest if rest >= 0 else 0)
print(result)


### FIXED CODE ###

A, B, C = map(int, input().split())
rest = C - (A - B)
result = (rest if rest >= 0 else 0)
print(result)
N = int(input())
h = list(map(int,input().split()))
cost = [1000000]*N
cost[0] = 0
cost[1] = abs(h([1]-h[0])
for i in range(2, N):
  cost[i] = min((abs(h[i-1] - h[i]) + cost[i-1]),cost[i])
  cost[i] = min((abs(h[i-2] - h[i]) + cost[i-2]), cost[i])
print(cost[-1])

### FIXED CODE ###

N = int(input())
h = list(map(int,input().split()))
cost = [10**9]*N
cost[0] = 0
cost[1] = abs(h[1]-h[0])
for i in range(2, N):
  cost[i] = min((abs(h[i-1] - h[i]) + cost[i-1]),cost[i])
  cost[i] = min((abs(h[i-2] - h[i]) + cost[i-2]), cost[i])
print(cost[-1])
n,k = map(int,input().split())
a = list(map(int,input().split()))
a = [(a[i]+1)/2 for i in range(n)]
acc = [0]+list(sum(a))
ans = 0
for i in range(n-k+1):
  ans = max(ans,acc[i+k]-acc[i])
print(ans)


### FIXED CODE ###

from itertools import accumulate
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [0]+[(p+1)/2 for p in P]
S = list(accumulate(P))
B = []
for j in range(N-K+1):
    B.append(S[j+K]-S[j])
ans = max(B)
print(ans)
n,k = map(int, input().split())
# お菓子を持っているすぬけ君かを判断する配列d 1ならもってる 0はもってない
d = [0] * n
# お菓子iを持っているのはどのすぬけ君か？
for i in range(k):
    # お菓子iを持っている人数m人
    m = int(input())
    # お菓子iを持っているすぬけ君のリスト
    a = list(map(int, input().split()))
    for j in a:
        # すぬけ君a[j]は少なくとも一つ以上のお菓子を持っている
        d[a[j]-1] = 1 
        
#いたずらされる人数ans人
ans = 0
for i in range(n):
    if d[i] == 0:
        ans += 1

print(ans)

### FIXED CODE ###

# ABC166 B
n,k = map(int, input().split())
# お菓子を持っているすぬけ君かを判断する配列d 1ならもってる 0はもってない
d = [0] * n
# お菓子iを持っているのはどのすぬけ君か？
for i in range(k):
    # お菓子iを持っている人数m人
    m = int(input())
    # お菓子iを持っているすぬけ君のリスト
    a = list(map(int, input().split()))
    for j in range(m):
        # すぬけ君a[j]は少なくとも一つ以上のお菓子を持っている
        d[a[j]-1] = 1 
        
#いたずらされる人数ans人
ans = 0
for i in range(n):
    if d[i] == 0:
        ans += 1

print(ans)
impport numpy as np
n,w=map(int,input())
wv=list(map(int,input().split()))
wv=np.array(wv)
dp=[0]*(w+1)
dp=np.array(dp)
for w,v in wv:
  dp[w:]=max(dp[w:],dp[:-w]+v)
print(dp[w])

### FIXED CODE ###

import numpy as np
n,W=map(int,input().split())
wv=[list(map(int,input().split())) for i in range(n)]
wv=np.array(wv)
dp=[0]*(W+1)
dp=np.array(dp)
for w,v in wv:
  dp[w:]=np.maximum(dp[w:],dp[:-w]+v)
print(dp[W])
n=int(input())
b=list(map(int,input().split()))
s_b=sorted(list(set(b)),reverse=True)
ans=[]
for itr in range(n):
  for j in s_b:
    try:
      if len(b)>=j:
        if b[j-1]==j:
          b.pop(j-1)
          ans.append(j)
          break
    except:
      print("error")
    if j==1:
      print(-1)
      exit()
ans.reverse()
for i in range(n):
  print(ans[i])


### FIXED CODE ###

n=int(input())
b=list(map(int,input().split()))
s_b=sorted(list(set(b)),reverse=True)
if 1 not in s_b:
  print(-1)
  exit()
ans=[]
for itr in range(n):
  for j in s_b:
    if len(b)>=j:
      if b[j-1]==j:
        b.pop(j-1)
        ans.append(j)
        break
    if j==1:
      print(-1)
      exit()
ans.reverse()
for i in range(n):
  print(ans[i])
s = [i for i in input()]
 
result = 1
i = 0
while i < len(s)-1:
  if s[i] == s[i+1]:
    i = i + 2
      if i > len(s):
        result = result - 1
  else:
    i = i + 1
  result = result + 1
  
print(result)

### FIXED CODE ###

s = [i for i in input()]
result = 1
i = 0

while i < len(s)-1:
  if s[i] == s[i+1]:
    i += 3
    result += 2
  else:
    i += 1
    result += 1
    
if i == len(s):
  result -= 1
elif i > len(s):
  result -= 2
  
print(result)
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()

# (鍵の購入コスト, 開けられる宝箱)
keys = [None] * M
for i in range(M):
    c, _ = MAP()
    # どの宝箱を開けられるのかをbitで持っておく
    s = 0
    for a in [a-1 for a in LIST()]:
        s += 1 << a
    keys[i] = (c, s)

# dp[i][j] := i個目の鍵まで見て、集合jの宝箱を開けるための最小コスト
dp = list2d(2, 1<<N, INF)
dp[0][0] = 0
for i in range(M):
    # 今回の鍵で開けられる宝箱の集合s
    s = keys[i][1]
    c = keys[i][0]
    cur = i % 2
    nxt = (i+1) % 2
    # 今回の鍵を買わない遷移
    dp[nxt] = dp[cur].copy()
    for j in range(1<<N):
        if dp[cur][j] != INF:
            m = j | s
            # 買う遷移：遷移元の開けられる宝箱の集合j | 今回の鍵で開けられる宝箱の集合s
            dp[nxt][m] = min(dp[nxt][m], dp[cur][j]+c)
ans = dp[M%2][-1]

if ans != INF:
    print(ans)
else:
    print(-1)


### FIXED CODE ###

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()

# (鍵の購入コスト, 開けられる宝箱)
keys = [None] * M
for i in range(M):
    c, _ = MAP()
    # どの宝箱を開けられるのかをbitで持っておく
    s = 0
    for a in [a-1 for a in LIST()]:
        s += 1 << a
    keys[i] = (c, s)

# dp[i][j] := i個目の鍵まで考えて、集合jの宝箱を開けるための最小コスト
dp = list2d(M+1, 1<<N, INF)
dp[0][0] = 0
for i in range(M):
    # 今回の鍵で開けられる宝箱の集合s
    s = keys[i][1]
    c = keys[i][0]
    for j in range(1<<N):
        # 今回の鍵を買わない遷移
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        # 買う遷移：遷移元の開けられる宝箱の集合j | 今回の鍵で開けられる宝箱の集合s
        dp[i+1][j|s] = min(dp[i+1][j|s], dp[i][j]+c)
ans = dp[M][-1]

if ans != INF:
    print(ans)
else:
    print(-1)
n = input()

print ,
for i in xrange(1, n+1):
    if i % 3 == 0 or i % 10 == 3:
        print i,

### FIXED CODE ###

n = input()

print '',
for i in xrange(1, n+1):
    x = i
    if x % 3 == 0:
        print i,
    else:
        while x:
            if x % 10 == 3:
                print i,
                break
            x /= 10
s = input()
K = int(input())
substring = []
for i in range(len(s) + 1):
	for j in range(i+1, len(s) + 1):
		if j == 0:
			substring.append(s[i])
		else:
			substring.append(s[i:j])
substring.sort()
if K <= 1 or len(s) <= 1:
	print(s)
else:
	print(substring[K + 1])

### FIXED CODE ###

s = input()
K = int(input())
substr = set()
for i in range(len(s)):
    for j in range(i+1, i+K+1):
        substr.add(s[i:j])
print(sorted(substr)[K-1])
p = 3.141592
r = int(input())
print("{0:.6f}{1:.6f}",format(r*2 * p,2 * r * p))


### FIXED CODE ###

import math

r = float(input())

print(f'{math.pi * r ** 2} {2 * math.pi * r}')
a,b,c,x=map(int,input().split())

count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if k*50+j*100+i*500==x:
                count+=1
                
print(count)

### FIXED CODE ###

a, b, c, x = map(int, [input() for i in range(4)])

count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if k*50+j*100+i*500==x:
                count+=1
                
print(count)
n=int(input())
s=[]
s=input().split()
q=int(input())
for i in range(q):
 x,y=map(int,input().split())
 s=re.sub(x,y,s)
 
for j in range(q):
 ans+=int(s[j])
 
print(ans)

### FIXED CODE ###

n=int(input())
a_list=list(map(int,input().split()))
cnt = [0] * int(1e5 + 10)
sum=0
for i in a_list:
 cnt[i] +=1
 sum+=i
  
q=int(input())
ans=0
 
for j in range(q):
 x,y=map(int,input().split())
 sum+=(y-x)*cnt[x]
 cnt[y]+=cnt[x]
 cnt[x]=0
 print(sum)
PDList = list(input())


for index, PD in enumerate(PDList):
    if PD != '?': continue

    if PD == '?' and len(PDList) == 1:
        PDList[index] = 'D'
        break

    if index == 1:
        if PDList[index + 1] == 'D' or PDList[index + 1] == '?': PDList[index] = 'P'
        else: PDList[index] = 'D'
        continue

    if PDList[index - 1] == 'P':
        PDList[index] = 'D'
        continue

    if PDList[index + 1] == 'D':
        PDList[index] = 'P'
        continue

    if PDList[index - 1] == 'D' and PDList[index + 1] == '?':
        PDList[index] = 'P'
        continue


    PDList[index] = 'D'
    continue


print(''.join(PDList))

### FIXED CODE ###

PDList = list(input())


for index, PD in enumerate(PDList):
    if PD != '?': continue

    if PD == '?' and len(PDList) == 1:
        PDList[index] = 'D'
        break

    if index == 0:
        if PDList[index + 1] == 'D' or PDList[index + 1] == '?': PDList[index] = 'P'
        else: PDList[index] = 'D'
        continue

    if PD == '?' and index == len(PDList) - 1:
        PDList[index] = 'D'
        continue


    if PDList[index - 1] == 'P':
        PDList[index] = 'D'
        continue

    if PDList[index + 1] == 'D':
        PDList[index] = 'P'
        continue

    if PDList[index - 1] == 'D' and PDList[index + 1] == '?':
        PDList[index] = 'P'
        continue


    PDList[index] = 'D'
    continue


print(''.join(PDList))
def g():
 from itertools import*
 n=int(input())
 a=[input().split()for _ in[0]*n]
 for b in a:
  b[3:5]=b[4],b[3]
 for d,e in combinations(a,2):
  for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
   f=[d[i]for i in p]
   if f[0]==e[0]and f[5]==e[5]:
    f=f[1:5]*2
    for k in range(4):
     if f[k:k+4]==e[1:5]:return'No'
 return'Yes'
print(g())


### FIXED CODE ###

def f():
 for c in range(n):
  for d in a[c+1:]:
   for p in([0,1,2,3,4,5],[1,5,2,0,4,3],[2,1,5,3,0,4],[3,0,2,5,4,1],[4,1,0,3,5,2],[5,1,4,3,2,0]):
    if[d[p[0]],d[p[5]]]==a[c][::5]:
     b=[d[i]for i in p[1:5]]*2
     for k in range(4):
      if b[k:k+4]==a[c][1:5]:return"No"
 return"Yes"
n=int(input())
a=[input().split()for _ in[0]*n]
for b in a:b[3:5]=b[4],b[3]
print(f())
a, b = map(int, input().split(" "))
for i in range(1, 1009):
    if int(i * 0.08) == a and int(i * 0.1) == b:
        print(i)
        return
print(-1)

### FIXED CODE ###

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

found = False
for i in range(1, 10000):
    if int(i * 0.08) == a and int(i * 0.1) == b:
        print(i)
        found = True
        break

if not found:
    print(-1)