Harryxun/stf_run huggingface dataset:
a = [[0] * 3 for i in range(3)]
for i in range(3):
    a[i] = list(map(int, input().split(' ')))

n = int(input())

for i in range(n):
    b = int(input())
    
    for r in range(3):
        for c in range(3):
            if a[r][c] == b:
                a[r][c] = 0

a = np.array(a)
sum1 = a.sum(axis=0)
sum2 = a.sum(axis=1)
naname1 = a[0][0] + a[1][1] + a[2][2]
naname2 = a[0][2] + a[1][1] + a[2][0]

if 0 in sum1 or 0 in sum2 or naname1 == 0 or naname2 == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import numpy as np

a = [[0] * 3 for i in range(3)]
for i in range(3):
    a[i] = list(map(int, input().split(' ')))

n = int(input())

for i in range(n):
    b = int(input())
    
    for r in range(3):
        for c in range(3):
            if a[r][c] == b:
                a[r][c] = 0

a = np.array(a)
sum1 = a.sum(axis=0)
sum2 = a.sum(axis=1)
naname1 = a[0][0] + a[1][1] + a[2][2]
naname2 = a[0][2] + a[1][1] + a[2][0]

if 0 in sum1 or 0 in sum2 or naname1 == 0 or naname2 == 0:
    print('Yes')
else:
    print('No')
n=int(input())
v=list(map(int,input().split()))
v.sort(key=int)
for i in range(n-1):
  z=(v[i]+v[i+1])/2
  v[i]=z
  v[i+1]=z
print(v[n])

### FIXED CODE ###

n=int(input())
v=list(map(int,input().split()))
v.sort(key=int)
for i in range(n-1):
  z=(v[i]+v[i+1])/2
  v[i]=z
  v[i+1]=z
print(v[n-1])
n ,k = map(int(input().split()))

print(n-k+1)

### FIXED CODE ###

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

print(n-k+1)
a,b = map(int,input().split())
t = b - a
n = [1]
x = 1

for i in range(2,999):
  x = i + x
  n.append(x)

else:
  for j in range(0,len(n)):
    if n[j+1] - n[j] == t:
      break
print(n[j] - a)
    

### FIXED CODE ###

a,b=map(int,input().split())
total=0
for i in range(1,b-a+1):
  total+=i
print(total-b)
T, X = map(int(), input().split)
print(float(T/X))

### FIXED CODE ###

T, X = map(int, input().split())
print(float(T/X))
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
x = input()
b = []
c = [0, 1, 1]
for i in range(n+2):
    cnt = 0
    for j in range(7):
        if i >> j & 1:
            cnt += 1
    b.append(cnt)

for i in range(3, n+2):
    c.append(c[i % b[i]]+1)

ans = []
tmp1 = 0
tmp2 = 0
cnt = x.count("1")
for i in range(n):
    if x[i] == "1":
        tmp1 += pow(2, n-(i+1), cnt+1)
        tmp2 += pow(2, n-(i+1), cnt-1)

for i in range(n):
    if x[i] == "1":
        ans.append(c[(tmp2 - pow(2, n-(i+1), cnt-1)) % (cnt-1)]+1)
    else:
        ans.append(c[(tmp1 + pow(2, n-(i+1), cnt+1)) % (cnt+1)]+1)

for i in ans:
    print(i)



### FIXED CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
x = input()
b = []
c = [0, 1, 1]
for i in range(n+2):
    cnt = 0
    for j in range(101):
        if i >> j & 1:
            cnt += 1
    b.append(cnt)

for i in range(3, n+2):
    c.append(c[i % b[i]]+1)

ans = []
tmp1 = 0
tmp2 = 0
cnt = x.count("1")
if cnt != 1:
    for i in range(n):
        if x[i] == "1":
            tmp1 += pow(2, n-(i+1), cnt+1)
            tmp2 += pow(2, n-(i+1), cnt-1)
    for i in range(n):
        if x[i] == "1":
            ans.append(c[(tmp2 - pow(2, n-(i+1), cnt-1)) % (cnt-1)]+1)
        else:
            ans.append(c[(tmp1 + pow(2, n-(i+1), cnt+1)) % (cnt+1)]+1)

    for i in ans:
        print(i)
else:
    for i in range(n):
        if x[i] == "1":
            tmp1 += pow(2, n-(i+1), cnt+1)
    for i in range(n):
        if x[i] == "1":
            ans.append(0)
        else:
            ans.append(c[(tmp1 + pow(2, n-(i+1), cnt+1)) % (cnt+1)]+1)

    for i in ans:
        print(i)
n, m = [int(i) for i in input().split(" ")]
score_dict = {}

for i in range(m):
    p, s = input().split(" ")
    if p not in score_dict:
        score_dict[p] = []
    
    score_dict[p].append(s)

ac_count = 0
wa_count = 0

for i in score_dict.values():
    tmp = i[:i.index("AC")+1]
    if "AC" in tmp:
        ac_count += 1
    
    wa_count += tmp.count("WA")

print("{0} {1}".format(ac_count, wa_count)) 

### FIXED CODE ###

n, m = [int(i) for i in input().split(" ")]
score_dict = {}
 
for i in range(m):
    p, s = input().split(" ")
    if p not in score_dict:
        score_dict[p] = []
    
    score_dict[p].append(s)
 
ac_count = 0
wa_count = 0
 
for i in score_dict.values():

    if "AC" in i:
        ac_count += 1
        wa_count += i.index("AC")
 
print("{0} {1}".format(ac_count, wa_count))
81 58

### FIXED CODE ###

a,b=map(int,input().split())
print(int(a+b/2))
N = int(input())
a = [int(input()) for _ in range(N)]

n = 0
ans = 1
for _ in range(N):
  ans += 1
  if a[a[n] - 1] == n + 1:
    ans = -1
    break
  elif a[a[n] - 1] == 2:
    break
  n = a[a[n] - 1]

print(ans)

### FIXED CODE ###

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

n = 0
count = 0
for i in range(N - 1):
  count += 1
  n = a[n] - 1
  if n == 1:
    break 

print(count if n == 1 else -1)
def factrial(n):
    if n == 1:
        return 1
    else:
        return n * factrial(n - 1)

def combination(n, r):
    return factrial(n) // (factrial(n - r) * factrial(r))

x, y = map(int, input().split())
if (x - y) % 3 != 0:
    print(0)
elif 2 * y - x < 0 or 2 * x - y < 0:
    print(0)
else:
    vertical = (2 * y - x) // 3
    horizontal = (2 * x - y) // 3
    total = vertical + horizontal
    print(combination(total, horizontal))

### FIXED CODE ###

def multiple_of_n(x, y, n=3):
    return (x - y) % n == 0

def combination(g1, g2, inverse, n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min([r, n - r])
    return g1[n] * g2[r] * g2[n - r] % mod

def make_inv(mod, N):
    g1 = [1, 1]
    g2 = [1, 1]
    inverse = [0, 1]
    for i in range(2, N + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((- inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)
    return g1, g2, inverse

mod = 10 ** 9 + 7

x, y = map(int, input().split())
if multiple_of_n(2 * x, y) and multiple_of_n(2 * y, x):
    vertical = (2 * y - x) // 3
    horizontal = (2 * x - y) // 3
    total = vertical + horizontal
    g1, g2, inverse = make_inv(mod, total)
    print(combination(g1, g2, inverse, total, horizontal, mod))
else:
    print(0)
a, b = map(int, input(" "))
if b == 0:
  print(a)
elif b == 1:
  print(a*100)
else:
  print(a*10000)

### FIXED CODE ###

a, b = map(int, input().split(" "))
b += int(b/100)
print(b*(100**a))
import collections
n,m = map(int,raw_input().split(' '))
h = [0] * (m+1)
for _ in range(n):
	a,b =  map(int, raw_input().split(' '))
		for d in range(m, -1, -1):
			if d - a >=0: h[d] = max(h[d], h[d-a] + b)

print h[m]


### FIXED CODE ###

import collections
import heapq
n,m = map(int,raw_input().split(' '))

elems = [map(int, raw_input().split(' ')) for _ in range(n)]
elems.sort(key = lambda x:x[0])
heap = []

j = 0
cumul = 0
for i in range(1,m+1):

	while(j < len(elems) and elems[j][0] <= i): 
		heapq.heappush(heap,-elems[j][1])
		j+=1
	if heap:
		cumul -= heapq.heappop(heap)

print cumul
def check(A):
  check_result = []
  for i in range(1, len(A)):
    check_result.append(list(set(A[i-1])&set(A[i])))
  if len(check_result) != len(A):
    return check_result
  return False

N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
for i in range(len(A)):
  A[i].pop(0)
while True:
  check_result = check(A)
  if check_result:
    A = check_result
  else:
    if not A[0]:
      print(0)
      break
    else:
      print(len(A[0]))
      break

### FIXED CODE ###

A, B = map(int, input().split())
print(A+B if B%A==0 else B-A)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
d=0
e=0
ans=0
while c<k:
  if e<m and (a[d]>b[e] or (a[d]==b[e] and a[d+1]>=b[e+1])):
    c+=b[e]
    e+=1
    ans+=1
  elif d<n:
    c+=a[d]
    d+=1
    ans+=1
  else:
    break
if c==k:
  print(ans)
else:
  print(ans-1)

### FIXED CODE ###

n, m, k = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
aa = [0]
bb = [0]
 
for s in range(n):
    aa.append(aa[s] + a[s])
for s in range(m):
    bb.append(bb[s] + b[s])      
ans = 0
j = m
 
for i in range(n+1):
    if aa[i] > k:
        break
    while bb[j] > k - aa[i]:
        j -= 1
    ans = max(ans, i+j)
        
print(ans)
import sys
input = sys.stdin.readline
N = int(input())
node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)
def dfs(neighbor,start,visited):
    global k
    global c
    if sum(visited) == N:
        return 0
    for i in neighbor[start]:
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            dfs(neighbor,i,visited)
        else:
            continue
    return 0
m = max(node)
#nn = node.index(m)
nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)

dfs(neigh,nn,visited)
ans2 = ' '.join([str(ans[i]) for i in range(N)])
print(sum(c)-max(c))
print(ans2)


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
N = int(input())


node = [0 for i in range(N)]
neigh = [[] for j in range(N)]
ans = [0 for i in range(N)]
visited = [0 for i in range(N)]
k = 1

for i in range(N-1):
    ai,bi = map(int,input().split())
    node[ai-1] += 1
    node[bi-1] += 1
    neigh[ai-1].append(bi-1)
    neigh[bi-1].append(ai-1)
c = list(map(int,input().split()))
c.sort(reverse=True)
flag = False
def dfs(neighbor,start):
    global flag
    global k
    if sum(visited) == N:
        return 0

    for i in neighbor[start]:
        
        if visited[i] == 0:
            ans[i] = c[k]
            k += 1
            visited[i] = 1
            try:
                dfs(neighbor,i)
            except RuntimeError:
                flag = True
                return 0




m = max(node)
nn = node.index(m)
#nn = [node[i] for i in range(N) if node[i] == m][0]
visited[nn] = 1
ans[nn] = max(c)

dfs(neigh,nn)
"""
if flag:
    print(100)
    print(' '.join([str(i) for i in range(N)]))
    exit()
"""
ans2 = ' '.join([str(ans[i]) for i in range(N)])


print(sum(c)-max(c))
print(ans2)
import itertools
N = int(input())
SK = {"M":0,"A":1,"R":2,"C":3,"H":4}
SD = [0]*5
del_list = []
A = ["M","A","R","C","H"]
for x in range(N):
    tmp = str(input())
    if tmp[0] in A:
        SD[SK[tmp[0]]] +=1
C = 0
for x in range(5)
    if SD[x] == 0 :
        del_list.append(x)
        C +=1
del_list.reverse()
for x in del_list:
    SD.pop(x)
    
if C >2:
    print(0)
else:
    Z = 5-C
    k = itertools.combinations(range(Z), 3)
    ans = 0
    for x in k:
        ans += SD[x[0]]*SD[x[1]]*SD[x[2]]
    print(ans)

### FIXED CODE ###

import itertools
N = int(input())
SK = {"M":0,"A":1,"R":2,"C":3,"H":4}
SD = [0]*5
del_list = []
A = ["M","A","R","C","H"]
for x in range(N):
    tmp = str(input())
    if tmp[0] in A:
        SD[SK[tmp[0]]] +=1
C = 0
for x in range(5):
    if SD[x] == 0 :
        del_list.append(x)
        C +=1
del_list.reverse()
for x in del_list:
    SD.pop(x)
    
if C >2:
    print(0)
else:
    Z = 5-C
    k = itertools.combinations(range(Z), 3)
    ans = 0
    for x in k:
        ans += SD[x[0]]*SD[x[1]]*SD[x[2]]
    print(ans)
N, x, y = map(int, input().split())

out = [0] * (N)

for i in range(1,N):
    for j in range(i+1,N+1):
        # i,jの距離を求める ３パーターンのうち一番短いパターン
        # i→jパターン abs(j-i)
        # i→x→y→jパターン abs(i-x)+1+abs(j-y)
        # i→y→x→jパターン abs(i-y)+1+abs(j-x)
        dist = min(abs(j-i), abs(i-x)+1+abs(j-y), abs(i-y)+1+abs(j-x))
        out[dist] += 1

for i in range(1,N):
    print(out[i])


### FIXED CODE ###

S = input()  # ここで標準入力

if S[2] == S[3] and S[4] == S[5]:
    print('Yes')
else:
    print('No')
# !/usr/bin python3
# -*- coding: utf-8 -*-

rgb = int(input().join())

if rgb % 4:
    print('YES')

else:
    print('NO')

### FIXED CODE ###

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

rgb = int(input().replace(" ", ""))

if rgb % 4 == 0:
    print('YES')

else:
    print('NO')
n,k,s = map(int, input().split())
for i in range(2,s//2):
    if s%i != 0:
        xx = i
        break
ans = [xx]* n
for i in range(k):
    ans[i] = s
print(' '.join(map(str, ans)))

### FIXED CODE ###

n,k,s = map(int, input().split())
if s<5:
    xx = 1 + s
else:
    for i in range(2,s):
        if s%i != 0:
            xx = i
            break
ans = [xx]* n
for i in range(k):
    ans[i] = s
print(' '.join(map(str, ans)))
S = input()
T = input()
cnt = 0

if S[0] === T[0]:
    cnt += 1

if S[1] === T[1]:
    cnt += 1

if S[2] === T[2]:
    cnt += 1

print(cnt)

### FIXED CODE ###

S = input()
T = input()
cnt = 0

for i in range(3):
    if S[i] == T[i]:
        cnt += 1

print(cnt)
a,b,c = int(input().split())
if a==b:
  print(c)
elif b==c:
  print(a)
else:
  print(b)

### FIXED CODE ###

a,b,c = map(int,input().split())
print(a if b==c else b if a==c else c)
import copy
s=list(map(str,input()))
t=list(map(str,input()))
def converta(s):
  for i in range(len(s)):
    if s[i]=='?':
      s[i]='a'
  return s
res=[]
for i in range(len(s)-len(t)+1):
    c=copy.copy(s)
    ok=True
    for j in range(len(t)):
        if t[j]!=s[i+j] and s[i+j]!='?':
            ok=False
            break
        else:
            c[i+j]=t[j]
    if ok:
        res.append(converta(c))
ans=min(res)
if res==[]:
  print('UNRESTORABLE')
else:
  print(''.join(ans))

### FIXED CODE ###

import copy
s=list(map(str,input()))
t=list(map(str,input()))
def converta(s):
  for i in range(len(s)):
    if s[i]=='?':
      s[i]='a'
  return s
res=[]
for i in range(len(s)-len(t)+1):
    c=copy.copy(s)
    ok=True
    for j in range(len(t)):
        if t[j]!=s[i+j] and s[i+j]!='?':
            ok=False
            break
        else:
            c[i+j]=t[j]
    if ok:
        res.append(''.join(converta(c)))
if res==[]:
  print('UNRESTORABLE')
else:
  print(sorted(res)[0])
import math
S = int(input())

x,y = 1,S

for i in xrange(2,1+int(math.sqrt(S))):
    if S%i == 0:
        x = i
        y = S//i
        if y <= 10**9:
            break
    
    
print("{} {} {} {} {} {}".format(0,0,0,x,y,x))


### FIXED CODE ###

import math
S = int(input())

x,y = 1,S
ret = int(math.sqrt(S))
if(ret**2 == S):
    print("{} {} {} {} {} {}".format(0,0,0,ret,ret,ret))
else:
    print("{} {} {} {} {} {}".format(0,0,ret+1,(ret+1)**2-S,1,ret+1))
def yesno(S)

if S=="AAA" or S=="BBB":
  return "No"
else:
  return "Yes"
S=input()
print(yesno(S))


### FIXED CODE ###

def yesno(S):
  if S=="AAA" or S=="BBB":
    return "No"
  else:
    return "Yes"
S=input()
print(yesno(S))
(a, b, c)=list(int, input().split())
s=a*b/2
print(s)


### FIXED CODE ###

a,b,c = [int(x) for x in input().split()]
s = int(a * b / 2)
print(s)
s=input()
hug=0
for i in range(len(s)//2):
  if s[i]!=s[n-1-i]:
    hug=hug+1
print(hug)

### FIXED CODE ###

s=input()
hug=0
for i in range(len(s)//2):
  if s[i]!=s[len(s)-1-i]:
    hug=hug+1
print(hug)
a,b,c = map(int, input().split())
if  b−a == c−b:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a,b,c = map(int,input().split())
if b-a == c-b:
    print("YES")
else:
    print("NO")
a, op, b = (i for i in input().split())

if op == '+':
  print(a+b)
else:
  print(a-b)

### FIXED CODE ###

a, op, b = (i for i in input().split())

if op == '+':
  print(int(a)+int(b))
else:
  print(int(a)-int(b))
# D
N = int(input())
s = list(map(int, list(input())))

res = 0
i = 0



L = 0
for i in range(N):
    if s[i] == 1:
        L = i
        break
for i in range(N):
    if s[i] == 1:
        M = i        

        
def calc_add(temp_list):
    return sum(temp_list)
def calc_add_2(temp_list):
    if len(temp_list) <= 1:
        return 0
    else:
        res = 0
        # use 101 for left
        dp_l = [0]*len(temp_list)
        # use 101 for right 
        dp_r = [0]*len(temp_list)
        # do not use 101
        dp_c = [0]*len(temp_list)
        for i in range(len(temp_list) - 1):
            if temp_list[i] > 1:
                dp_l[i+1] = max(dp_l[i] + temp_list[i] - 1, dp_c[i] + temp_list[i])
            else:
                dp_l[i+1] = dp_c[i] + temp_list[i]
            if temp_list[i] > 1:
                dp_r[i+1] = max(dp_l[i] + temp_list[i+1], dp_c[i] + temp_list[i+1], dp_r[i] + temp_list[i+1] - 1)
            else:
                dp_r[i+1] = dp_c[i] + temp_list[i+1]
            dp_c[i+1] = max(dp_l[i], dp_r[i], dp_c[i])
        
        return max(dp_l[-1], dp_r[-1], dp_c[-1])
    

cont0 = 1
cont00 = 1
temp_list = []

for i in range(L, M+1):
    if s[i] == 1:
        if cont0 == 1:
            temp_list.append(1)
            cont0 = 0
            cont00 = 0
        else:
            temp_list[-1] += 1
    else:
        if cont00 == 1:
            pass
        elif cont0 == 1:
            cont00 = 1
            res += calc_add(temp_list)
            temp_list = []
        else:
            cont0 = 1
            
    if i == M:
        res += calc_add(temp_list)
        temp_list = []
        
print(res)

### FIXED CODE ###

# D
N = int(input())
s = list(map(int, list(input())))

        
def calc_add(temp_list):
    if len(temp_list) <= 1:
        return 0
    else:
        res = 0
        # use 101 for left
        dp_l = [0]*len(temp_list)
        # use 101 for right 
        dp_r = [0]*len(temp_list)
        # do not use 101
        dp_c = [0]*len(temp_list)
        for i in range(len(temp_list) - 1):
            if temp_list[i] > 1:
                dp_l[i+1] = max(dp_l[i] + temp_list[i] - 1, dp_c[i] + temp_list[i])
            else:
                dp_l[i+1] = dp_c[i] + temp_list[i]
            if temp_list[i] > 1:
                dp_r[i+1] = max(dp_l[i] + temp_list[i+1], dp_c[i] + temp_list[i+1], dp_r[i] + temp_list[i+1] - 1)
            else:
                dp_r[i+1] = dp_c[i] + temp_list[i+1]
            dp_c[i+1] = max(dp_l[i], dp_r[i], dp_c[i])
        
        return max(dp_l[-1], dp_r[-1], dp_c[-1])
    

cont0 = 1
cont00 = 1
temp_list = []
res = 0

for i in range(N):
    if s[i] == 1:
        if cont0 == 1:
            temp_list.append(1)
            cont0 = 0
            cont00 = 0
        else:
            temp_list[-1] += 1
    else:
        if cont00 == 1:
            pass
        elif cont0 == 1:
            cont00 = 1
            res += calc_add(temp_list)
            temp_list = []
        else:
            cont0 = 1
            
    if i == N - 1:
        res += calc_add(temp_list)
        
print(res)
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
N, K = map(int, input().split())
Ps = list(map(int, input().split()))
Cs = list(map(int, input().split()))
scores = list()
max_list = list()
for i in range(N):
    next = Ps[i] - 1
    scores = [Cs[next]]
    while next != i:
        next = Ps[next] - 1
        scores.append(Cs[next]+scores[-1])
    l = len(scores)
    if scores[-1] <= 0:
        if K <= l:
            max_list.append(max(scores[:K]))
        else:
            max_list.append(max(scores))
    else:
        if K <= l:
            max_list.append(max(scores[:K]))
        else:
            a, b = divmod(K, l)
            max_list.append(a*scores[-1] + max(scores[:b]))
    #print(scores)
print(max(max_list))


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
N, K = map(int, input().split())
Ps = list(map(int, input().split()))
Cs = list(map(int, input().split()))
max_list = list()
for i in range(N):
    next = Ps[i] - 1
    scores = [Cs[next]]
    while next != i:
        next = Ps[next] - 1
        scores.append(scores[-1] + Cs[next])
    l = len(scores)
    if K <= l:
        max_list.append(max(scores[:K]))
    else:
        if scores[-1] < 0:
            max_list.append(max(scores))
        else:
            a, b = divmod(K, l)
            cand1 = 0
            if b!=0:
                cand1 = a*scores[-1] + max(scores[:b])
            cand2 = (a-1)*scores[-1] + max(scores)
            max_list.append(max(cand1, cand2))
    #print(scores)
print(max(max_list))
s=input()
lis=[]
n=1
output=0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        lis.append(n)
        n=1
    else:
        n+=1

    if i==len(s)-2:
        lis.append(n)
print(lis)

loop=True
while loop:
    a=lis[0]
    b=lis[1]
    if a==b:
        output+=a*2
        del lis[0]
        del lis[0]
    elif a<b:
        output+=a*2
        lis[1]-=a
        del lis[0]
    elif a>b:
        if len(lis)<2:
            output+=b*2
            loop=False
        else:
            lis[2]+=abs(b-a)
            output+=b*2
            del lis[0]
            del lis[0]
    if len(lis)==0 or len(lis)==1:
        loop=False
print(output)
    
            



### FIXED CODE ###

s=input()
n0=0
n1=0
for i in s:
    if i=="0":
        n0+=1
    else:
        n1+=1
print(2*min(n0,n1))
N = input()
dic = defaultdict(int)

for s in N:
  dic[s] += 1
  
  if dic[s] > 1:
    print('no')
    exit()

print('yes')

### FIXED CODE ###

from collections import defaultdict 

N = input()
dic = defaultdict(int)
 
for s in N:
  dic[s] += 1
  
  if dic[s] > 1:
    print('no')
    exit()
 
print('yes')
N=int(input())
if N==1:
  print("Hello World")
else:
  A,B=map(int,input().split())
  print(A+B)

### FIXED CODE ###

N=int(input())
if N==1:
  print("Hello World")
else:
  A=int(input())
  B=int(input())
  print(A+B)
import heapq
n,m = map(int,input().split())
AB =[tuple(map(int,input().split())) for i in range(n)]
ans,memo=0,0
hq=[]
AB.sort(key=lambda tup:tup[0])
for day in range(m):
	for i in range(memo,n):
		if AB[i][0]<=(day+1):
			heapq.push(hq,AB[i][1])
			memo+=1
		else:
			break
	ans += -heapq.heappop(hq)
print(ans)




### FIXED CODE ###

import heapq
n,m = map(int,input().split())
AB =[tuple(map(int,input().split())) for i in range(n)]
ans,memo=0,0
hq=[]
AB.sort(key=lambda tup:tup[0])
for day in range(m):
	for i in range(memo,n):
		if AB[i][0]<=(day+1):
			heapq.heappush(hq,-AB[i][1])
			memo+=1
		else:
			break
	if len(hq):	
		ans += -heapq.heappop(hq)
print(ans)
import sys
sys.setrecursionlimit(100000)

def f(a,b,N):
    
    def cur(n):
        if n<0: return -1
        if memo[n]!=-1: return memo[n]
        tmp=[]
        for i in range(3):
            if n-a[i]>=0: tmp.append(cur(n-a[i])+b[i])
        memo[n]=max(tmp)
        return memo[n]
    
    memo=[0]+[-1]*(N)
    return cur(N)

import sys
N=int(input())

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

N=f(A,B,N)
N=f(B,A,N)
print(N)


### FIXED CODE ###

def f(a,b,N):

    tmpa,tmpb=[],[]
    for i in range(3):
        if a[i]<b[i]:
            tmpa.append(a[i])
            tmpb.append(b[i])
    a,b=tmpa,tmpb

    if len(a)==0: return N
    elif len(a)==1: return (N//a[0])*b[0]+N%a[0]

    elif len(a)==2:
        if a[0]<a[1]: a,b=a[::-1],b[::-1]

        i,ans=0,N
        while i*a[0]<=N:
            j=(N-i*a[0])//a[1]
            ans=max(ans,i*b[0]+j*b[1]+(N-i*a[0]-j*a[1]))
            i+=1
        return ans

    else:
        memo=[i for i in range(N+1)]

        for i in range(1,N+1):
            tmp=[]
            for j in range(len(a)):
                if i-a[j]>=0: tmp.append(memo[i-a[j]]+b[j])
            if tmp!=[]: memo[i]=max(tmp)
        return memo[N]

import sys
N=int(input())

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

N=f(A,B,N)
N=f(B,A,N)
print(N)