Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def attackCounter(array, cnt):
    if len(array) == sum(array):
        cnt += len(array)
        return cnt
    else :
        cnt += len(array)
        array = [i // 2 for i in array] * 2
        return attackCounter(array, cnt)

H = int(input())
cnt = attackCounter([H], 0)
print(cnt)

### FIXED CODE ###

import math

log = int(math.log2(int(input())))

num = 0
for i in range(log + 1):
    num = num + (2 ** i)

print(num)
### BUGGY CODE ###

def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    dp = [10**10]*(h+1)
    dp[0] = 0
    for i in range(h):
        for a, b in ab:
            j = i+a
            if j > h:
                j = h
            dp[j] = min(dp[j], dp[i]+b)
    print(dp[-1])


main()


### FIXED CODE ###

def main():
    h, n = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    dp = [10**10]*(h+1)
    dp[0] = 0
    for i in range(h):
        for a, b in ab:
            j = i+a
            if j > h:
                j = h
            dp[j] = min(dp[j], dp[i]+b)
    print(dp[-1])


main()
### BUGGY CODE ###

data = input().split()

a,b,c = int(data[0]), int(data[1]), int(data[2])

for i in range (a, b + 1):
    if (i < a + c or i > b - c):
        print(i)


### FIXED CODE ###

data = input().split()

a,b,c = int(data[0]), int(data[1]), int(data[2])

for i in range (a, min(b+1,a + c)):
    if (i < a + c or i > b - c):
        print(i)

for j in range (max(i + 1, b - c + 1), b + 1):
    if (j < a + c or j > b - c):
        print(j)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
# l = list()
# r = list()
s_list = list()
for i in range(q):
    l_i, r_i = map(int, input().split())
    # l.append(l_i)
    # r.append(r_i)
    s_list.append(s[l_i-1:r_i])

for i in range(q):
    print(s_list[i].count('AC'))

### FIXED CODE ###

def main():
    # n, q = map(int, input().split())
    # s = input()
    # # l = list()
    # # r = list()
    # s_list = list()
    # # s_tuple = tuple()
    # for _ in range(q):
    #     l_i, r_i = map(int, input().split())
    #     # l.append(l_i)
    #     # r.append(r_i)
    #     s_list.append(s[l_i - 1:r_i])
    #     # s_tuple = s_tuple + tuple(s[l_i - 1:r_i])
    # 
    # s_tuple = tuple(s_list)
    # 
    # for i in s_tuple:
    #     print(i.count('AC'))
    N, Q = map(int, input().split())
    S = input()
    cnt = [0] * (N + 1)
    for i in range(N):
        cnt[i + 1] = cnt[i] + (1 if S[i:i+2] == 'AC' else 0)
    for i in range(Q):
        l, r = map(int, input().split())
        print(cnt[r - 1] - cnt[l - 1])


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
I=lambda:list(map(int,sys.stdin.readline().split()))
n,m=I()
e=[(I()[0],[1<<n-i for i in I()])for _ in'_'*m]
I=9**9
dp=[I]*2**n
dp[0]=0
for i,d in enumerate(dp):
    if d==I:continue
    for a,c in e:
        b,x=i,d+a
        for j in c:b|=j
        if dp[b]>x:dp[b]=x
print(-(dp[-1]==I)or dp[-1])

### FIXED CODE ###

import sys
input=sys.stdin.readline
n,m=map(int,input().split())
e=[(int(input().split()[0]),list(map(int,input().split())))for _ in range(m)]
INF=10**18
dp=[INF]*2**n
dp[0]=0
for i in range(2**n):
    if dp[i]>=INF:continue
    for a,c in e:
        bit=i
        for j in c:
            bit|=2**(n-j)
        dp[bit]=min(dp[bit],dp[i]+a)
a=dp[-1]
if a>=INF:
    print(-1)
else:
    print(dp[-1])
### BUGGY CODE ###

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

A = list(map(int, input().split()))
B = list(map(int, input().split()))

Acum = [0]*n
Bcum = [0]*m
Acum[0] = A[0]
Bcum[0] = B[0]

for i in range(1,n):
  Acum[i] = Acum[i-1] + A[i]  
for i in range(1,m):
  Bcum[i] = Bcum[i-1] + B[i]

mx = 0
for i in range(n+1):
  cnt = 0
  if i==0:
    rest = k
  else:
    rest = k - Acum[i-1]
    cnt = i
    if rest<0:continue
  
  for j in range(m):
    if rest<Bcum[j]:
      cnt += j
      break
  if rest>=Bcum[-1]:
    cnt += m
  if cnt>mx:
    mx = cnt
    
print(mx)

### FIXED CODE ###

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

A = list(map(int, input().split()))
B = list(map(int, input().split()))

Acum = [0]*n
Bcum = [0]*m
Acum[0] = A[0]
Bcum[0] = B[0]

for i in range(1,n):
  Acum[i] = Acum[i-1] + A[i]  
for i in range(1,m):
  Bcum[i] = Bcum[i-1] + B[i]

mx = 0

import bisect
for i in range(n+1):
  cnt = 0
  if i==0:
    rest = k
  else:
    rest = k - Acum[i-1]
    cnt = i
    if rest<0:continue
  
  idx = bisect.bisect_right(Bcum, rest)
  cnt += idx

  if cnt>mx:
    mx = cnt
    
print(mx)
#print(bisect.bisect_right([0,1], 0))
### BUGGY CODE ###

n,k=map(int,input().split())
ans=[]

for n in range(1,n+1):
    a,b=map(int,input().split())
    for x in range(1,b+1):
        ans.append(a)

ans=sorted(ans)

print(ans[k-1])


### FIXED CODE ###

n,k = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
a.sort()
now = 0
for i in a:
  now += i[1]
  if now >= k:
    print(i[0])
    break
### BUGGY CODE ###

# ABC071-C　
N = int(input())
A_list = list(map(int, input().split()))

A_set = set(A_list)
A_set = sorted(A_set, reverse=True)

side_list = [0, 0]

for i in range(len(A_set)):   # 大きい順に取っていき，リストで個数を確認する
    if len(side_list) >= 4:
        break
    count = A_list.count(A_set[i])    # リストの個数を確認
    if count == 2 or count == 3:
        side_list.append(A_set[i])
    if count >= 4:
        side_list.append(A_set[i])
        side_list.append(A_set[i])
        
side_list.sort(reverse = True)
print(side_list[0] * side_list[1])

### FIXED CODE ###

# ABC071-C
N = int(input())
A = sorted(list(map(int, input().split())), reverse = True)

for i in range(N-1):
    if A[i] == A[i+1]:
        A[i+1] = 0
    elif A[i] != A[i+1]:
        A[i] = 0
A.sort(reverse = True)
print(A[0] * A[1])
### BUGGY CODE ###

n,m = map(int, input().split())
from collections import defaultdict
a = []
l = [[] for _ in range(n)]
for i in range(m):
    p,y = map(int, input().split())
    l[p-1].append(y)
    a.append([p,y])
l = list(map(sorted, l))
for p, y in a:
    print("{:0>6}{:0>6}".format(p,l[p-1].index(y)+1))


### FIXED CODE ###

n,m = map(int, input().split())
l = [[] for _ in range(n)]
for i in range(m):
    p,y = map(int, input().split())
    l[p-1].append((y, i))
ans = [None]*m
for i,pre in enumerate(l):
    pre.sort()
    for j,(a,b) in enumerate(pre):
        ans[b] = "{:0>6}{:0>6}".format(i+1,j+1)
print("\n".join(ans))
### BUGGY CODE ###

# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import deque
import pprint

inf = 10**18
mod = 10**9+7

n,m = map(int, input().split())
s = input()
t = input()
f=fractions.gcd(n,m)           #最大公約数
f2=n*m//f                          #最小公倍数


x = f2//n
y = f2//m

z = ['' for i in range(f2)]
for i in range(n):
    z[i*x] = s[i]
for i in range(m):
    if z[i*y] != '' and z[i*y] != t[i]:
        print(-1)
        sys.exit()
print(f2)

### FIXED CODE ###

# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import deque
import pprint

inf = 10**18
mod = 10**9+7

n,m = map(int, input().split())
s = input()
t = input()
f=fractions.gcd(n,m)           #最大公約数
f2=n*m//f                          #最小公倍数


x = f2//n
y = f2//m

for i in range(n):
    if (x*i)%y==0:
        if s[i] != t[x*i//y]:
            print(-1)
            sys.exit()
print(f2)
### BUGGY CODE ###

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

pathes = {i: set() for i in range(1, n + 1)}
for _ in range(m):
  ai, bi = map(int, input().split()) 
  pathes[ai].add(bi)
  pathes[bi].add(ai)

queue = [None] * n
queue[0] = 1
idx = 1

ans = [None] * n 

for i in queue:
  if idx == n:
    continue
  next_room = pathes[i] - set(queue)
  for j in next_room:
    ans[j-1] = str(i)
    queue[idx] = j
    idx += 1

ans[0] = "Yes"

print("\n".join(ans))


### FIXED CODE ###

from collections import deque

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

pathes = {i: set() for i in range(1, n + 1)}
for _ in range(m):
  ai, bi = map(int, input().split()) 
  pathes[ai].add(bi)
  pathes[bi].add(ai)

queue = deque()
queue.append(1)

ans = [None] * n 

for _ in range(n):
  if len(queue) == 0:
    break;
  i = queue.popleft()
  next_room = pathes[i]
  for j in next_room:
    if ans[j-1] == None:
      ans[j-1] = str(i)
      queue.append(j)

ans[0] = "Yes"

print("\n".join(ans))
### BUGGY CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))
 
max_exp = 0
ind = 0
for i in range(N - K + 1):
    exp = K + (sum(p[i:i+K]) - K) / 2
    if max_exp < exp:
        max_exp = exp
print(max_exp)

### FIXED CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))
 
max_exp = exp = K + (sum(p[0:K]) - K) / 2
for i in range(1, N - K + 1):
    exp -= p[i-1] / 2
    exp += p[i + K - 1] / 2
    if max_exp < exp:
        max_exp = exp

print(max_exp)
### BUGGY CODE ###

from collections import Counter
N = int(input())
*A, = map(int, input().split())
A.sort()
c = Counter(A)
ans = 0
d = [False]*(10**6+1)
for i in range(N):
    if c[A[i]] == 1:
        ok = True
        for j in range(1, int(A[i]**0.5)+2):
            if A[i] % j == 0 and (d[j] or d[A[i]//j]):
                ok = False
                break
        if ok:
            ans += 1
    d[A[i]] = True

print(ans)


### FIXED CODE ###

from collections import Counter
N = int(input())
*A, = map(int, input().split())
A.sort()
c = Counter(A)
ans = 0
d = [0]*(10**6+1)
for i in range(N):
    if d[A[i]] == 0:
        if c[A[i]] == 1:
            ans += 1
        j = A[i]
        while j <= (10**6):
            d[j] += 1
            j += A[i]
print(ans)
### BUGGY CODE ###

from math import sqrt, floor

p = [2]
for i in range(3, 50000, 2):
    for j in range(3, floor(sqrt(i)) + 1, 2):
        if not i % j:
            break
    else:
        p.append(i)

while True:
    n = int(input())
    if not n:
        break
    n2 = n // 2
    cnt = 0
    for i in p:
        if n2 < i:
            break
        if n - i in p:
            cnt += 1
    print(cnt)

### FIXED CODE ###

from math import sqrt, floor

p = [2]
for i in range(3, 50000, 2):
    for j in range(3, floor(sqrt(i)) + 1, 2):
        if not i % j:
            break
    else:
        p.append(i)
sp = set(p)

while True:
    n = int(input())
    if not n:
        break
    if n & 1:
        print(int(n - 2 in sp))
        continue
    n2 = n // 2
    cnt = 0
    for i in p:
        if n2 < i:
            break
        if n - i in sp:
            cnt += 1
    print(cnt)
### BUGGY CODE ###

from collections import deque
import sys
input = sys.stdin.readline

def main():
    N,M = map(int,input().split())
    paylist = [[] for _ in range(M)]
    for _ in range(N):
        a,b = map(int,input().split())
        if M >= a:
            paylist[a-1].append(b)

    work = []
    payment = 0
    for i in range(M):
        work += paylist[i]
        work.sort()
        if work != []:
            payment += work.pop()

    print(payment)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import heapq
import sys
input = sys.stdin.readline

def main():
    N,M = map(int,input().split())
    paylist = [[] for _ in range(M)]
    for _ in range(N):
        a,b = map(int,input().split())
        if M >= a:
            heapq.heappush(paylist[a-1],-b)
    work = []
    payment = 0
    for i in range(M):
        for j in paylist[i]:
            heapq.heappush(work,j)
        if work:
            payment += heapq.heappop(work)

    print(-payment)

if __name__ == "__main__":
    main()
### BUGGY CODE ###


base = 1234
mod = 10**9+7
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
base_m = pow(base, N-1, mod)
ans = set(range(N))
for k in range(30):
    tmp = set()
    mask = 1<<k
    a_k = []
    a_k_r = []
    b_k = []
    for i in range(N):
        if a[i]&mask:
            a_k.append(1)
            a_k_r.append(0)
        else:
            a_k.append(0)
            a_k_r.append(1)
        if b[i]&mask:
            b_k.append(1)
        else:
            b_k.append(0)
    b_hash = b_k[0]
    a_hash = a_k[0]
    a_hash_r = a_k_r[0]
    for i in range(1, N):
        b_hash = (b_hash*base+b_k[i])%mod
        a_hash = (a_hash*base+a_k[i])%mod
        a_hash_r = (a_hash_r*base+a_k_r[i])%mod
    for i in range(N):
        if a_hash == b_hash:
            tmp.add(i)
        if a_hash_r == b_hash:
            tmp.add(i)
        a_hash = ((a_hash-a_k[i]*base_m)*base+a_k[i])%mod
        a_hash_r = ((a_hash_r-a_k_r[i]*base_m)*base+a_k_r[i])%mod
    ans&=tmp
ans = sorted(list(ans))
for k in ans:
    x = a[k]^b[0]
    print(k, x)



    


### FIXED CODE ###


base = 123
mod = 10**9+7
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
base_m = pow(base, N-1, mod)
ans = [True]*N
for k in range(30):
    tmp = []
    mask = 1<<k
    a_k = []
    a_k_r = []
    b_k = []
    for i in range(N):
        if a[i]&mask:
            a_k.append(1)
            a_k_r.append(0)
        else:
            a_k.append(0)
            a_k_r.append(1)
        if b[i]&mask:
            b_k.append(1)
        else:
            b_k.append(0)
    b_hash = b_k[0]
    a_hash = a_k[0]
    a_hash_r = a_k_r[0]
    for i in range(1, N):
        b_hash = (b_hash*base+b_k[i])%mod
        a_hash = (a_hash*base+a_k[i])%mod
        a_hash_r = (a_hash_r*base+a_k_r[i])%mod
    for i in range(N):
        if a_hash == b_hash or a_hash_r == b_hash:
            pass
        else:
            ans[i] = False
        a_hash = ((a_hash-a_k[i]*base_m)*base+a_k[i])%mod
        a_hash_r = ((a_hash_r-a_k_r[i]*base_m)*base+a_k_r[i])%mod
for i in range(N):
    if ans[i]:
        x = a[i]^b[0]
        print(i, x)
### BUGGY CODE ###

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

money=1000
stocks=0

for i in range(N): 
    if i==N-1:
        #売る
        while stocks>0:
            money += A[i]
            stocks-=1    
    elif A[i+1]>A[i]:
        #買う
        while money>=A[i]:
            money -= A[i]
            stocks+=1
    elif A[i+1]<A[i]:
        #売る
        while stocks>0:
            money += A[i]
            stocks-=1
print(money)

### FIXED CODE ###

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

money=1000
stocks=0

for i in range(N): 
    if i==N-1:
        #売る
        money+=(A[i]*stocks)
        stocks=0
    elif A[i+1]>A[i]:
        #買う
        plus_stock,money=divmod(money,A[i])
        stocks+=plus_stock
    elif A[i+1]<A[i]:
        #売る
        money+=(A[i]*stocks)
        stocks=0
print(money)
### BUGGY CODE ###

# /usr/bin/python
# -*- coding: utf-8 -*-
import sys

n,k = map(int, sys.stdin.readline().rstrip().split())
hn = list(map(int, sys.stdin.readline().rstrip().split()))
dp = [-1] * n

dp[0] = 0
for i in range(1,n):
  dp[i] = sys.maxsize
  for j in range(1,min(k+1,i+1)):
    ret = dp[i-j]+abs(hn[i-j]-hn[i])
    if dp[i] > ret:
      dp[i] = ret
print(dp[n-1])



### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
import sys
import numpy as np

n,k = map(int, sys.stdin.readline().rstrip().split())
h = np.array(list(map(int, sys.stdin.readline().rstrip().split())))

dp = np.zeros(n, dtype=np.int)

for i in range(1,n):
  if i < k:
    dp[i] = np.min(dp[:i] + np.abs(h[i]-h[:i]))
  else:
    dp[i] = np.min(dp[i-k:i] + np.abs(h[i]-h[i-k:i]))

print(dp[n-1])
### BUGGY CODE ###

#!/usr/bin/env python3

R, C, K = list(map(int, input().split()))

rck = {}
for i in range(K):
    tmp = list(map(int, input().split()))
    rck[(tmp[0], tmp[1])] = tmp[2]


dp = [[[0 for i in range(4)] for j in range(R+1)] for i in range(C+1)]

# print(rck)
for r_i in range(1, R+1):
    for c_i in range(1, C+1):

        tmp0 = max(dp[c_i-1][r_i][0], dp[c_i][r_i-1][3])
        tmp1 = max(dp[c_i-1][r_i][1], dp[c_i][r_i-1][3])
        tmp2 = max(dp[c_i-1][r_i][2], dp[c_i][r_i-1][3])
        tmp3 = max(dp[c_i-1][r_i][3], dp[c_i][r_i-1][3])
        # print(c_i, r_i)
        # print(tmp0, tmp1, tmp2, tmp3)

        index = (r_i, c_i)

        if index in rck:
            dp[c_i][r_i][3] = max(tmp3, tmp2+rck[index])
            dp[c_i][r_i][2] = max(tmp2, tmp1+rck[index])
            dp[c_i][r_i][1] = max(tmp1, tmp0+rck[index])
            dp[c_i][r_i][0] = tmp0
        else:
            dp[c_i][r_i][3] = tmp3
            dp[c_i][r_i][2] = tmp2
            dp[c_i][r_i][1] = tmp1
            dp[c_i][r_i][0] = tmp0

print(dp[-1][-1][-1])


### FIXED CODE ###

#!/usr/bin/env python3

R, C, K = list(map(int, input().split()))

V = [[] for i in range(R)]
for i in range(K):
    r, c, v = list(map(int, input().split()))
    V[r-1].append([c, v])


# dp = [[[0 for j in range(R+1)] for i in range(C+1)]

# print(rck)
dp = [0] * (C+1)
for r in range(1, R+1):
    tmp0 = 0
    tmp1 = 0
    tmp2 = 0
    tmp3 = 0
    V[r-1].sort()
    for c, v in V[r-1]:
        tmp0 = max(dp[c], tmp0)
        tmp1 = max(dp[c], tmp1)
        tmp2 = max(dp[c], tmp2)
        tmp3 = max(dp[c], tmp3)

        tmp3 = max(tmp3, tmp2+v)
        tmp2 = max(tmp2, tmp1+v)
        tmp1 = max(tmp1, tmp0+v)

        dp[c] = max(tmp0, tmp1, tmp2, tmp3)
    for i in range(1, C+1):
        dp[i] = max(dp[i], dp[i-1])
    # print(dp)

print(dp[-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def solve():
    INF = float('inf')

    def max2(x, y): return x if x >= y else y

    R, C, K = map(int, input().split())
    Vss = [[0]*(C+1) for _ in range(R+1)]
    for _ in range(K):
        r, c, v = map(int, input().split())
        Vss[r][c] = v

    dpMax = [0]*(C+1)
    for i in range(1, R+1):
        dp0 = [0]*(C+1)
        dp1 = [-INF]*(C+1)
        dp2 = [-INF]*(C+1)
        dp3 = [-INF]*(C+1)
        for j in range(1, C+1):
            V = Vss[i][j]
            dp0[j] = max2(dp0[j-1], dpMax[j])
            dp1[j] = max2(dp0[j] + V, dp1[j-1])
            dp2[j] = max2(dp1[j-1] + V, dp2[j-1])
            dp3[j] = max2(dp2[j-1] + V, dp3[j-1])
            dpMax[j] = max(dp0[j], dp1[j], dp2[j], dp3[j])

    ans = dpMax[C]
    print(ans)


solve()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def solve():
    INF = float('inf')

    def max2(x, y): return x if x >= y else y

    R, C, K = map(int, input().split())
    Vss = [[0]*(C+1) for _ in range(R+1)]
    for _ in range(K):
        r, c, v = map(int, input().split())
        Vss[r][c] = v

    dpMax = [0]*(C+1)
    for i in range(1, R+1):
        dp0 = [0]*(C+1)
        dp1 = [-INF]*(C+1)
        dp2 = [-INF]*(C+1)
        dp3 = [-INF]*(C+1)
        for j in range(1, C+1):
            V = Vss[i][j]
            dp0[j] = max2(dp0[j-1], dpMax[j])
            dp1[j] = max2(dp0[j] + V, dp1[j-1])
            dp2[j] = max2(dp1[j-1] + V, dp2[j-1])
            dp3[j] = max2(dp2[j-1] + V, dp3[j-1])
            dpMax[j] = max(dp0[j], dp1[j], dp2[j], dp3[j])

    ans = dpMax[C]
    print(ans)


solve()
### BUGGY CODE ###

n = int(input())
ans = 0
tbl1 = [[0]*10 for i in range(10)]
tbl2 = [[0]*10 for i in range(10)]
# for j in range(10):
#     for k in range(10):
#         cnt1 = 0
#         cnt2 = 0
#         for i in range(1,n+1):
#             s = str(i)
#             if s[0] == str(k)and s[-1] == str(j):
#                 cnt1 += 1
#             if s[0] == str(j) and s[-1] == str(k):
#                 cnt2 += 1
#         ans += cnt1*cnt2
for i in  range(1,n+1):
    s = str(i)
    for j in range(10):
        for k in range(10):
            if s[0] == str(k)and s[-1] == str(j):
                tbl1[k][j] += 1
            if s[0] == str(j) and s[-1] == str(k):
                tbl2[j][k] += 1
for j in range(10):
        for k in range(10):
            ans += tbl1[k][j] * tbl2[j][k]
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
tbl1 = [[0]*10 for i in range(10)]
tbl2 = [[0]*10 for i in range(10)]
# for j in range(10):
#     for k in range(10):
#         cnt1 = 0
#         cnt2 = 0
#         for i in range(1,n+1):
#             s = str(i)
#             if s[0] == str(k)and s[-1] == str(j):
#                 cnt1 += 1
#             if s[0] == str(j) and s[-1] == str(k):
#                 cnt2 += 1
#         ans += cnt1*cnt2
for i in  range(1,n+1):
    s = str(i)
    for j in range(10):
        for k in range(10):
            if s[0] == str(k)and s[-1] == str(j):
                tbl1[k][j] += 1
            if s[0] == str(j) and s[-1] == str(k):
                tbl2[j][k] += 1
for j in range(10):
        for k in range(10):
            ans += tbl1[k][j] * tbl2[j][k]
print(ans)
### BUGGY CODE ###

k, s = map(int, input().split())

count = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                count += 1

print(count)

### FIXED CODE ###

k, s = map(int, input().split())

count = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y and s - x - y <= k:
            count += 1

print(count)
### BUGGY CODE ###

from collections import Counter

N = int(input())
S = list(input())
s_c = Counter(S)

a = s_c["R"] * s_c["B"] * s_c["G"]

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for _ in range(j + 1, N):
            if (S[i] != S[j] and S[i] != S[_] and S[j] != S[_]) and \
                not (j - i != _ - j):
                a -= 1
print(a)

### FIXED CODE ###

from collections import Counter

N = int(input())
S = list(input())
s_c = Counter(S)

a = s_c["R"] * s_c["B"] * s_c["G"]

for i in range(N):
    for j in range(i + 1, N):
        k = 2 * j - i
        if k >= N:
            break
        elif (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]) and \
            not (j - i != k - j):
            a -= 1
print(a)
### BUGGY CODE ###

import numpy as np


N = int(input())
A = list(map(int, input().strip().split(' ')))

B = np.zeros(N)
R = []
I = np.arange(1, N+1)

for i in I[::-1]:
    if B[i-1] % 2 != A[i-1]:
        B[((i % I) == 0)] += 1
        R.append(i)

R.sort()
print(len(R))
if R:
    print(' '.join(map(str, R)))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().strip().split(' ')))
R = [0 for i in range(N+1)]
ans = []

for _ in range(N):
    i = N - _
    a = A[i-1]
    if sum(R[i::i]) % 2 != a:
        R[i] = 1
        ans.append(i)

ans.sort()
print(len(ans))
if ans:
    print(' '.join(map(str, ans)))
### BUGGY CODE ###

import bisect
import sys
input = sys.stdin.readline

n = int(input())
a = int(input())

color = [a]
color_min = a

for _ in range(1, n):
    a = int(input())
    if color_min >= a:
        bisect.insort_left(color, a)
        color_min = a
    else:
        j = bisect.bisect_left(color, a)
        color.pop(j-1)
        bisect.insort_left(color, a)
        color_min = color[0]

print(len(color))


### FIXED CODE ###

from collections import deque
from bisect import bisect_left

n = int(input())
a = [int(input()) for _ in range(n)]

b = deque([])

for ai in a:
    if len(b) == 0:
        b.append(ai)
    else:
        if ai <= b[0]:
            b.appendleft(ai)
        else:
            idx = bisect_left(b, ai)
            b[idx-1] = ai

print(len(b))