Harryxun/stf_run huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
m = 0
for i in range(N):
    m +=B[a[i] - 1]
for i in range(N-1):
    if a[i] + 1 == a[i + 1]:
        m +=C[a[i] - 1]
print(m)
         
    
    

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
m = 0
for i in range(N):
    m += B[A[i] - 1]
for t in range(N-1):
    if A[t] + 1 == A[t + 1]:
        m += C[A[t] - 1]
print(m)
N=int(input())
x=list(int(100*i+10*i+i) for i in range(1,9))
y=list(t for t in x if t>=N)
print(min(y))

### FIXED CODE ###

N=int(input())
x=list(int(100*i+10*i+i) for i in range(1,10))
y=list(t for t in x if t>=N)
print(min(y))
import fractions as frac
a,b,c,d = map(int,input().split())


lcm = (c * d) // frac.gcd(c,d)
if a % lcm != 0:
    s = lcm - a % lcm
else:
    s = 0
e = b % lcm
m = ((b - e) - (a + s)) // lcm
modgcd = (b - a + 1) - (s + (lcm - 1) * m + e)

if a % c != 0:
    s = c - a % c
else:
    s = 0
e = b % c
m = ((b - e) - (a + s)) // c
modc = (b - a + 1)- (s + (c - 1) * m + e)

if a % d != 0:
    s = d - a % d
else:
    s = 0
e = b % d
m = ((b - e) - (a + s)) // d
modd = (b - a + 1) - (s + (d - 1) * m + e)

print((b - a + 1)-(modc + modd - modgcd))


### FIXED CODE ###

s=input()

for i in range(3):
    if s[i] in s[i+1]:
        print('Bad')
        break
else:
    print("Good")
Num=int(Input())
Str=str(Input())
print(str.count("ABC"))

### FIXED CODE ###

N = int(input())
S = str(input())
print(S.count("ABC"))
#ABC042B
l,n=(int(x) for x in input().split())
sente1=input()
sente2=input()
sente3=input()
mylist=[sente1,sente2,sente3]
mylist.sort()
print(''.join(mylist))

### FIXED CODE ###

# 入力
N,L=map(int,input().split())

l=[]
for i in range(N):
  l.append(input())

# ソート
l.sort()

# 出力
print(''.join(l))
import math
N = int(input())
ans = (1+N)*N/2
for i in range(1,N+1):
  for j in range(1,i):
    ans += math.gcd(i,j)*3
for i in range(!,N+1):
  for j in range(1,i):
    if i== j:
      break
    for k in range(1,j):
      if i == k or j == k:
        break
      else:
        ans += math.gcd(i,j,k)*6
print(ans)

### FIXED CODE ###

import math
N = int(input())
ans = (1+N)*N/2
for i in range(1,N+1):
  for j in range(1,i):
    ans += math.gcd(i,j)*6
for i in range(1,N+1):
  for j in range(1,i):
    if i== j:
      break
    for k in range(1,j):
      if i == k or j == k:
        break
      else:
        ans += math.gcd(k,math.gcd(i,j))*6
print(int(ans))
S = input()
K = int(input())

if S[0] == '1':
    print(S[1])
else:
    print(S[0])


### FIXED CODE ###

S = input()
K = int(input())

if len(S) > K:
    print(S[K-1])
else:
    num = '1'
    for s in S:
        if s != '1':
            num = s
            break
    print(num)
X = 
Y = 
if X < Y;
print("<")
elif X=Y;
print("=")
else;
print(">")

### FIXED CODE ###

x,y = map(str, input().split())
 
print(">" if x > y else "<" if x < y else "=")
import sys, heapq
from collections import deque
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, K = map(int, input().split())
V_init = deque(map(int, input().split()))
max_score = 0
hands = [0] * K
heapq.heapify(hands)

for i_rget in range(K + 1):
	for i_lget in range(max(K - i_rget, 0) + 1):
		for i_del in range(max(K - i_rget - i_lget, 0) + 1):
			score = 0
			hands = [0] * K
			V = deque.copy(V_init)
			for i in range(i_rget + 1):
				if i > 0 and V:
					tmp = V.pop()					
					heapq.heappush(hands, tmp)
					score += tmp
				
			for i in range(i_lget + 1):
				if i > 0 and V:
					tmp = V.popleft()
					heapq.heappush(hands, tmp)
					score += tmp
			
			for i in range(i_del + 1):
				if i > 0:
					tmp = heapq.heappop(hands)
					score -= tmp
			
			if score > max_score:
				max_score = score

print(max_score)

### FIXED CODE ###

import sys, heapq, copy
from collections import deque
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

N, K = map(int, input().split())
V_init = deque(map(int, input().split()))
max_score = 0
hands = [0] * K
heapq.heapify(hands)

for i_rget in range(K + 1):
	for i_lget in range(max(K - i_rget, 0) + 1):
		tmp = 0
		score = 0
		hands = [0] * K
		V = copy.copy(V_init)
		for i in range(i_rget + 1):
			if i > 0 and V:
				tmp = V.pop()					
				heapq.heappush(hands, tmp)
				score += tmp
			
		for i in range(i_lget + 1):
			if i > 0 and V:
				tmp = V.popleft()
				heapq.heappush(hands, tmp)
				score += tmp
		
		for i in range(max(K - i_rget - i_lget, 0) + 1):
			if i > 0:
				tmp = heapq.heappop(hands)
				if tmp < 0:
					score -= tmp
				else:
					break
		
		if score > max_score:
			max_score = score

print(max_score)
n=int(input())
h=list(map(int,input(),split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n,1):
  dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
dp=[0]*n
dp[1]=abs(h[1]-h[0])
for i in range(2,n,1):
    dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]))
print(dp[n-1])
N, K = map(int, input().split())
Alist = list(map(int, input().split()))

gone = []

isLooped = False


def dfs(index):
    if index in gone:
        isLooped = True
        return

    gone.append(index)
    dfs(Alist[index-1])


dfs(1)

last = gone[-1]


loopStartIndex = gone.index(Alist[last-1])
if K > loopStartIndex:
    divK = (K - loopStartIndex) % len(gone[loopStartIndex:])
    print(gone[divK])
else:
    print(gone[K])


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
s = []
ord = [-1 for i in range(n+1)]
v = 1
c = 1
l = 0
while ord[v] == -1:
    ord[v] = len(s)
    s.append(v)
    v = a[v-1]
c = len(s) - ord[v]
l = ord[v]
if k < l:
    print(s[k])
else:
    k -= l
    k %= c
    print(s[l+k])
l = input().split()
a=input()

b=a.split("-")


if len(b[0]) == l[0] and len(b[1])==l[1] and and len(b)<3:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

a=input()
print(48-int(a))
input = int(input())
a = []
i = 1
while(i <= input):
  if i%3 == 0 and i%5 == 0:
    a[i] = FizzBuzz
  elif i%3 == 0:
    a[i] = Fizz
  elif i%5 == 0:
    a[i] = Buzz
  else:
    a[i] = i
  i += 1
sum = 0
for j in a:
  if a[j] != "Fizz" and a[j] != "Buzz" and a[j] != "FizzBuzz":
    sum = sum + a[j]
print(sum)


### FIXED CODE ###

input = input()
a = []
i = 1
while(i <= int(input)):
    if i%3 == 0 or i%5 == 0:
        pass
    else:
        a.append(i)
    i += 1
res = 0
for j in a:
  res = res + j
print(res)
import sys
from collections import defaultdict
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
D = defaultdict(lambda: [])
gain = [0]*N
for i in range(N + M - 1):
    a, b = map(int, input().split())
    D[a - 1].append(b - 1)
    gain[b - 1] += 1

ans = [None]*N
def rec(u, p):
    ans[u] = p
    for v in D[u]:
        gain[v] -= 1
    for v in D[u]:
        if gain[v] == 0 and ans[v] is None:
            rec(v, u)

root = gain.index(0)
rec(root, -1)

for i in range(N):
    print(ans[i] + 1)


### FIXED CODE ###

import sys
from collections import defaultdict
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
AB = []
D = defaultdict(lambda: [])
for i in range(N + M - 1):
    a, b = map(int, input().split())
    AB.append((a - 1, b - 1))
    D[a - 1].append(b - 1)

z = [0]*N
for a, b in AB:
    z[b] += 1

ans = [-1]*N
root = z.index(0)
ok = [False]*N
def rec(u, p):
    ans[u] = p
    ok[u] = True
    for v in D[u]:
        z[v] -= 1
    for v in D[u]:
        if z[v] == 0 and not ok[v]:
            rec(v, u)


rec(root, -1)

for i in range(N):
    print(ans[i] + 1)
K = int(input())
gcd_sum = 0
for a in range(1,K+1):
  a_init = a
  for b in range(1, K+1):
	b_init = b
    for c in range(1, K+1):
      a = a_init
	  b = b_init						
	  m = min(a, b, c)
	  gcd = 1
	  for i in range(2, m+1):
	    if a%i == 0 and b%i == 0 and c%i == 0:
	      a /= i
          b /= i
          c /= i
		  gcd *= i
	  gcd_sum += gcd
print(gcd_sum)


### FIXED CODE ###

def gcd(a, b):
  if a < b:
    a_init = a
    a = b
    b = a_init
  while b != 0:
    r = a % b
    a = b
    b = r
  return a
	
K = int(input())
count = 0
temp = []
for a in range(1, K+1):
	for b in range(1, a):
		temp.append(gcd(a, b))
for c in range(1, K+1):
	for j in range(len(temp)):
		count += gcd(c, temp[j]) * 2
	for k in range(1, K+1):
		count += gcd(c, k)
print(count)
counter = {}
judge = ['AC', 'WA', 'TLE', 'RE']
for c in judge:
    counter[c] = 0

num = int(input())
for i in range(num):
    counter[input()] += 1

for c in judge:
    print('%s x %d' % (c, counter[c]))


### FIXED CODE ###

print((10000-int(input()))%1000)
# -*- coding: utf-8 -*- #

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

ans = k * pow(k-1, n-1)

print(ans)

### FIXED CODE ###

print(len(set(map(int, input().split()))))
dict1 = {}
dict2 = {}

while True:
	log = raw_input()
	if len(log) == 0:
		break
	
	log = log.split(",")[0]
	
	if log in dict1:
		dict1[log] = dict1[log] + 1
	else:
		dict1[log] = 1
		
while True:
	try:
		log = raw_input()
		
		log = log.split(",")[0]
		
		if log in dict2:
			dict2[log] = dict2[log] + 1
		else:
			dict2[log] = 1
			
	except EOFError:
		break

list = dict1.keys()

for var in list:
	if dict1[var] > 0 and dict2[var] > 0:
		print var, dict1[var] + dict2[var]

### FIXED CODE ###

dict1 = {}
dict2 = {}

while True:
	log = raw_input()
	if len(log) == 0:
		break
	
	log = log.split(",")[0]
	
	if log in dict1:
		dict1[log] = dict1[log] + 1
	else:
		dict1[log] = 1
		
while True:
	try:
		log = raw_input()
		
		log = log.split(",")[0]
		
		if log in dict2:
			dict2[log] = dict2[log] + 1
		else:
			dict2[log] = 1
			
	except EOFError:
		break

list = set(dict1) & set(dict2)
for var in list:
	print var, dict1[var] + dict2[var]
def palindrome(word):
  if len(word) <= 1:
    return True
  if word[0] != word[-1]:
    return False
  return palindrome(word[1:-1])
 
word = input().lower()
n = len(word) // 2
issuper = palindrome(word[:n]) and palindrome(word[n+1:])
print("Yes" if issuper else "No"))

### FIXED CODE ###

def palindrome(word):
  if len(word) <= 1:
    return True
  if word[0] != word[-1]:
    return False
  return palindrome(word[1:-1])
 
word = input()
n = len(word) // 2
issuper = palindrome(word[:n]) and palindrome(word[n+1:]) and palindrome(word)
print("Yes" if issuper else "No")
A,B=map(int,input().split())
j=A*12.5
k=(A+1)*12.5
l=B*12.5
m=(B+1)*12.5
N=[]
O=[]
for i in range(j,k+1):
  N.append(i)
for h in range(l,m+1):
  O.append(h)
N_set=set(N)
O_set=set(O)
matched_list=list(N_set&O_set)
print(min(matched_list))

### FIXED CODE ###

import math
A,B=map(int,input().split())
C=[]
for i in range(1,1010):
  if math.floor(i*0.08)==A and math.floor(i*0.1)==B:
    C.append(i)
if len(C)==0:
  print("-1")
else:
  print(min(C))
n, m = map(int, input().split())
A = []
B = []
for i in range(n):
    A.append(map(int, input().split()))
for i in range(m):
    B.append(int(input()))

C = []
for i in range(n):
    C.append(0)
    for j in range(m):
        C[i] += A[i][j] * B[j]
        print(C[i])

### FIXED CODE ###

n, m = map(int, input().split())
A = []
B = []
for i in range(n):
    A.append(input().split())
for i in range(m):
    B.append(int(input()))

C = []
for i in range(n):
    C.append(0)
    for j in range(m):
        C[i] += int(A[i][j]) * B[j]
    print(C[i])
def pri(s,n):
    tab=[i for i in range(n+1) if s[i] and i>=2]
    return(tab)
  
s=[True for _ in range(999999+1)]
i=2
while i**2<=999999:
    if s[i]:
        j=i*2
        while j<=999999:
            s[j]=False
            j+=i
    i+=1

s=pri(s,10000)
while True:
    n = int(input())
    if n == 0: break
    sum = 0

    for i in range(n):
        sum += s[i]
    print(sum)

### FIXED CODE ###

import math
def pri(n):
    l =[True] * n
    l[0] = l[1] = False
    for i in range(2,n):
        if l[i]:
            for j in range(i*2, n, i):
                l[j] = False
    return l
n=105000
s=pri(n)
l=[i for i in range(n) if s[i]]
while True:
    n = int(input())
    if n == 0: break
    print(sum(l[:n]))
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = []
c = []
for i in range(m):
        bb,cc =map(int,input().split())
        b.append(bb)
        c.append(cc)
a.sort()
for i in range(m):
        for j in range(b[i]):
                if a[j] < c[i]:
                        a[j] = c[i]
                a.sort()
print(sum(a))


### FIXED CODE ###

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

def count(h):
    if(h<=0):
        return 0
    else:
        return 1 + 2*count(h/2)

print(count(h))

### FIXED CODE ###

h = int(input())

def count1(h):
    if(h==0):
        return 0
    if(h==1):
        return 1
    return 1 + 2*count1(h//2)
    
print(count1(h))
import itertools
n=int(input())
a= list(map(int, input().split()))

# aを偶数奇数の要素で振り分け
a1=[]
a2=[]

for i in range(n):
    if i%2==0:
        a1.append(a[i])
    else:
        a2.append(a[i])

# 累積和も作っておく
a3=list(itertools.accumulate(a1))
a4=list(itertools.accumulate(a2))


x1=sum(a1)
x2=sum(a2)


if n%2==0:
    ans=-float('inf')
    for i in range(n//2):
        ans=max(a3[i]+a4-a4[i],ans)
    print(max(ans,x1,x2))
else:
    # 奇数番目だけの要素を選んだ時の最大値
    ans1=sum(a1)-min(a1)
    # dp1[i]=奇数偶数奇数or偶数奇数と移動した時のi番目までのMAX
    dp1 = [-float('inf')] * (n // 2 + 1)
    dp1[0] = a1[0]
    # dp2[i]=奇数偶数or偶数のみと移動した時のi番目までのMAX
    dp2 = [-float('inf')] * (n // 2)
    dp2[0] = a2[0]
    for i in range(n // 2 - 1):
        dp2[i + 1] = max(a3[i] + a2[i + 1], dp2[i] + a2[i + 1])
        if i==0:
            dp1[i + 2] = dp2[i] + a1[i + 2]
        else:
            dp1[i + 2] = max(dp2[i] + a1[i + 2], dp1[i + 1] + a1[i + 2])
    print(max(dp1[-1], dp2[-1],ans1))

### FIXED CODE ###

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

# aを偶数奇数の要素で振り分け
a1=[]
a2=[]

for i in range(n):
    if i%2==0:
        a1.append(a[i])
    else:
        a2.append(a[i])

# 累積和も作っておく
a3=list(itertools.accumulate(a1))
a4=list(itertools.accumulate(a2))


x1=sum(a1)
x2=sum(a2)


if n%2==0:
    ans=-float('inf')
    for i in range(n//2):
        ans=max(a3[i]+x2-a4[i],ans)
    print(max(ans,x1,x2))
else:
    # 奇数番目だけの要素を選んだ時の最大値
    ans1=sum(a1)-min(a1)
    # dp1[i]=奇数偶数奇数or偶数奇数と移動した時のi番目までのMAX
    dp1 = [-float('inf')] * (n // 2 + 1)
    dp1[0] = a1[0]
    # dp2[i]=奇数偶数or偶数のみと移動した時のi番目までのMAX
    dp2 = [-float('inf')] * (n // 2)
    dp2[0] = a2[0]
    for i in range(n // 2 - 1):
        dp2[i + 1] = max(a3[i] + a2[i + 1], dp2[i] + a2[i + 1])
        if i==0:
            dp1[i + 2] = dp2[i] + a1[i + 2]
        else:
            dp1[i + 2] = max(dp2[i] + a1[i + 2], dp1[i + 1] + a1[i + 2])
    print(max(dp1[-1], dp2[-1],ans1))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
if (A = 2) or (B = 2):
  print("Yes")
else:
  print("No")


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
A,B = map(int, input().split())
if (A == 2) or (B == 2):
  print("No")
else:
  print("Yes")
yes="Yes"
no="No"
n=int(input())
a=list(map(int,input().split()))
if max(a)-min(a)>1:exit(print(no))
if a==[a[0]]*n:
  if a[0]==n-1:print(yes)
  elif 2*a[0]<=n:print(yes)
  else:print(no)
else:
  mi=a.count(min(a))
  ma=n-mi
  if mi<max(a):print(yes)
  elif 2*(max(a)-mi)<=y:print(yes)
  else:print(no)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
if max(a)-min(a)>=2:exit(print("No"))
if len(set(a))==1:
  m=a[0]
  if m==n-1 or 2*m<=n:print("Yes")
  else:print("No")
else:
  x=a.count(min(a))
  y=n-x
  if x<max(a) and 2*(max(a)-x)<=y:print("Yes")
  else:print("No")
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

from collections import defaultdict

def main():
	d=defaultdict(int)
	
	n=int(input())
	A=list(map(int,input().split()))
	for x in A:
		d[x]+=1
	
	li=[]
	li2=[]
	for k,v in d.items():
		if v>=2:
			li.append(k)
		if v>=4:
			li2.append(k)

	li.sort(reverse=True)
	li2.sort(reverse=True)
	
	if len(li)<=1 and len(li2)==0:
		print(0)
	elif len(li)==1:
		print(li2[0]**2)
	else:
		print(max(li[0]*li[1],li2[0]**2))
	

if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np

from collections import defaultdict

def main():
	d=defaultdict(int)
	
	n=int(input())
	A=list(map(int,input().split()))
	for x in A:
		d[x]+=1
	
	li=[]
	li2=[]
	for k,v in d.items():
		if v>=2:
			li.append(k)
		if v>=4:
			li2.append(k)

	li.sort(reverse=True)
	li2.sort(reverse=True)
	
	if len(li)<=1 and len(li2)==0:
		print(0)
	elif len(li)>=2 and len(li2)>=1:
		print(max(li[0]*li[1],li2[0]**2))
	elif len(li)>=2:
		print(li[0] * li[1])
	else:
		print(li2[0]**2)
	

if __name__ == "__main__":
	main()
abc = list(input().split())

print(lens(set(abc)))

### FIXED CODE ###

abc = list(input().split())
print(len(set(abc)))
import functools
import operator
import numpy as np

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

# prod = functools.partial(functools.reduce, operator.mul)
for i in range(K, N+1):
    sum_prod = np.prod(A[i-K:i])
    if i > K:
        if sum_prod > tmp_sum_prod:
            print('Yes')
        else:
            print('No')
    tmp_sum_prod = sum_prod


### FIXED CODE ###

import functools
import operator

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

# prod = functools.partial(functools.reduce, operator.mul)
# tmp_sum_prod = prod(A[:K])
for i in range(K, N):
    sum_prod = (A[i]/A[i-K])
    if sum_prod > 1.0:
        print('Yes')
    else:
        print('No')
    tmp_sum_prod = sum_prod
s=input()
a=0
p=''
while i<n:
  if s[i]==p:
    i+=2
  else:
    i+=1
  a+=1
print(a)

### FIXED CODE ###

from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=1

s=StoI()
n=len(s)
dp=[[0]*n for i in range(2)]

for i in range(n):
    if i==0:
        dp[0][i]=1
    elif i==1:
        if s[1]==s[0]:
            dp[0][i]=0
            dp[1][i]=1
        else:
            dp[0][i]=2
            dp[1][i]=1
    else:
        if s[i]==s[i-1]:
            dp[0][i]=dp[1][i-1]+1
            dp[1][i]=max(dp[0][i-2],dp[1][i-2])+1
        else:
            dp[0][i]=max(dp[0][i-1],dp[1][i-1])+1
            dp[1][i]=max(dp[0][i-2],dp[1][i-2])+1

ans=max(dp[0][n-1],dp[1][n-1])
print(ans)
import sys
input = sys.stdin.readline
n,m = map(int, input().split())
print((1900*m + 100(N − M))*2**m)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int, input().split())
print((1900*m + 100*(n - m))*2**m)
import itertools

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


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


p = 998244353
N = n   # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0

l2 = m*(m-1)**(n-k-2)
for _k in range(k, -1, -1):
    # print(_k)

    l2 %= p
    l2 *= (m - 1)

    ncr = cmb(n - 1, _k, p)
    ans += ncr * l2
    ans %= p


print(ans)


### FIXED CODE ###

import itertools

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


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


p = 998244353
N = n   # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0

l2 = m*(m-1)**(n-k-1)
for _k in range(k, -1, -1):
    # print(_k)

    ncr = cmb(n - 1, _k, p)
    ans += ncr * l2
    ans %= p
    l2 %= p
    l2 *= (m - 1)


print(ans)
import numpy as np
a,b = map(int, input().split())
np.full((50,100),'.')

### FIXED CODE ###

import numpy as np
a,b = map(int, input().split())
grid1 = [['.' for j in range(100)] for i in range(50)]
grid2 = [['#' for j in range(100)] for i in range(50)]
a -= 1
b -= 1
x = y = 1

for i in range(a):
    grid2[x][y] = '.'
    y += 2
    if y != y % 100:
        x += 2
    y = y % 100
    if x >= 50 or y >= 100:break

x = y = 1
for i in range(b):
    grid1[x][y] = '#'
    y += 2
    if y != y % 100:
        x += 2
    y = y % 100
    if x >= 50 or y >= 100:break

print(100, 100)
grid = np.concatenate((grid1, grid2), axis=0)
for row in grid:
    print(''.join(row))
def fraction(N):
  if N <= 1:
    return 1
  else:
    return N * fraction(N-1)
print(fraction(int(input())) % (1e9 + 7))


### FIXED CODE ###

def fraction(N):
  w = N
  for x in range(1, N):
    w = (w * x) % (1e9 + 7)
  return w
print("{:.0f}".format(fraction(int(input()))))
n,d=map(int,input().split())
dis = [list(map(int,input().split())) for i in range(n)]

cnt=0
for j in range(n-1):
    dist = 0
    for i in range(d):
        dist += (dis[j][i]-dis[j+1][i])**2
    if is_square(dist) == True: cnt+=1

dist = 0
for i in range(d):
    dist += (dis[0][i]-dis[-1][i])**2
if is_square(dist) == True: cnt+=1
print(cnt)

### FIXED CODE ###

n,d=map(int,input().split())
dis = [list(map(int,input().split())) for i in range(n)]

def is_square(n):
    res=n**0.5
    return res.is_integer()

cnt = 0
for i in range(n):
    for j in range(i+1,n):
        dist = 0
        for k in range(d):
            #i行目とj行目
            dist += (dis[i][k]-dis[j][k])**2
        if is_square(dist) == True: cnt+=1
print(cnt)