Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
X=sys.stdin.readline().strip()

cnt_of_one=0
for x in X:
    if x=="1": cnt_of_one+=1

cnt_of_one_plus_one=cnt_of_one+1
cnt_of_one_minus_one=cnt_of_one-1

amari_cnt_of_one_plus_one=0
amari_cnt_of_one_minus_one=0
for i,x in enumerate(X[::-1]):
    if x=="1":    #その桁の値が1の時だけ数を足す
        amari_cnt_of_one_plus_one+=pow(2,i,cnt_of_one_plus_one)
        amari_cnt_of_one_plus_one%=cnt_of_one_plus_one
        amari_cnt_of_one_minus_one+=pow(2,i,cnt_of_one_minus_one)
        amari_cnt_of_one_minus_one%=cnt_of_one_minus_one

def popcount(n):
    ret=0
    while 0<n:
        ret+=n%2
        n/=2
    return ret

def f(n):
    ret=0   #余りが0になるまでの割った回数
    while 0<n:
        n%=popcount(n)
        ret+=1
    return ret

for i,x in enumerate(X):
    keta=N-i-1
    if x=="0":
        syoki_amari=(amari_cnt_of_one_plus_one+pow(2,keta,cnt_of_one_plus_one))%cnt_of_one_plus_one
        if syoki_amari==0:
            print 1
        else:
            print 1+f(syoki_amari)
    elif x=="1":
        syoki_amari=(amari_cnt_of_one_minus_one-pow(2,keta,cnt_of_one_minus_one))%cnt_of_one_minus_one
        if syoki_amari==0:
            print 1
        else:
            print 1+f(syoki_amari)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
X=sys.stdin.readline().strip()

cnt_of_one=0
for x in X:
    if x=="1": cnt_of_one+=1

cnt_of_one_plus_one=cnt_of_one+1
cnt_of_one_minus_one=cnt_of_one-1

amari_cnt_of_one_plus_one=0
amari_cnt_of_one_minus_one=0
for i,x in enumerate(X[::-1]):
    if x=="1":    #その桁の値が1の時だけ数を足す
        amari_cnt_of_one_plus_one+=pow(2,i,cnt_of_one_plus_one)
        amari_cnt_of_one_plus_one%=cnt_of_one_plus_one
        if cnt_of_one_minus_one==0: #2進数の全ての桁が0の場合は、0で除算はできないので場合分け
            amari_cnt_of_one_minus_one=0
        else:
            amari_cnt_of_one_minus_one+=pow(2,i,cnt_of_one_minus_one)
            amari_cnt_of_one_minus_one%=cnt_of_one_minus_one

def popcount(n):
    ret=0
    while 0<n:
        ret+=n%2
        n/=2
    return ret

def f(n):
    ret=0   #余りが0になるまでの割った回数
    while 0<n:
        n%=popcount(n)
        ret+=1
    return ret

for i,x in enumerate(X):
    keta=N-i-1
    if x=="0":
        syoki_amari=(amari_cnt_of_one_plus_one+pow(2,keta,cnt_of_one_plus_one))%cnt_of_one_plus_one
        if syoki_amari==0:
            print 1
        else:
            print 1+f(syoki_amari)
    elif x=="1":
        if cnt_of_one_minus_one==0: #2進数の全ての桁が0という意味だから
            print 0 #値が0になるまでの操作回数は0回
        else:
            syoki_amari=(amari_cnt_of_one_minus_one-pow(2,keta,cnt_of_one_minus_one))%cnt_of_one_minus_one
            if syoki_amari==0:
                print 1
            else:
                print 1+f(syoki_amari)
mod=10**6+3

inv=[0]*mod
inv[1]=1
for i in range(2,mod):
    inv[i]=-(mod//i)*inv[mod%i]%mod

data=[1]
for i in range(1,mod):
    data.append(data[-1]*i%mod)

Q=int(input())
xdn=[list(map(int,input().split())) for i in range(Q)]

for x,d,n in xdn:
    k=x*inv[d]%mod
    if k+n-1>=mod:
        print(0)
    else:
        print(pow(d,k+n-1,mod)*data[k+n-1]*inv[pow(d,k-1,mod)*data[k-1]%mod]%mod)




### FIXED CODE ###

mod=10**6+3

inv=[0]*mod
inv[1]=1
for i in range(2,mod):
    inv[i]=-(mod//i)*inv[mod%i]%mod

data=[1]
for i in range(1,mod):
    data.append(data[-1]*i%mod)

Q=int(input())
xdn=[list(map(int,input().split())) for i in range(Q)]

for x,d,n in xdn:
    if d==0:
        print(pow(x,n,mod))
        continue
    if x==0:
        print(0)
        continue
    k=x*inv[d]%mod
    if k+n-1>=mod:
        print(0)
    else:
        print(pow(d,k+n-1,mod)*data[k+n-1]*inv[pow(d,k-1,mod)*data[k-1]%mod]%mod)
import sys
N,M=map(int,input().split())
A=[0]*N
B=[0]*N
for i in range(0,N):
  A[i],B[i]=map(int,input().split())
index=sorted(range(len(A)), key=lambda k: A[k])

cost=0
get=0
for i in index:
  if get+B[i]<=M:
    get += B[i]
    cost += A[i]*B[i]
  else:
    cost += A[i]*(M-get)
    print(cost)
	sys.exit()

### FIXED CODE ###

import sys
N,M=map(int,input().split())
A=[0]*N
B=[0]*N
for i in range(0,N):
  A[i],B[i]=map(int,input().split())
index=sorted(range(len(A)), key=lambda k: A[k])
cost=0
get=0
for i in index:
  if get+B[i]<M:
    get += B[i]
    cost += A[i]*B[i]
  else:
    cost += A[i]*(M-get)
    print(cost)
    sys.exit()
s=input()
n=len(s)
ans=0
for i in range(n):
  for j in range(i,n):
      bubun=s[i:j+1]
      flag=True
      for c in bubun:
          if(c not in ['A','G','C','T']):
          flag = False
      if(flag):
        ans = max(ans,len(bubun))
print(ans)


### FIXED CODE ###

s = input()
n = len(s) # 文字列の長さを取得しておく

res = 0 # 条件になければ0
for i in range(n): # Sの部分文字列を全探索するループ：重複を許す（i==jの時は1文字の部分文字列になる）が入替を許さないループ
    for j in range(i, n):
        sub = s[i: j+1] # i文字目からからj文字目までの部分文字列

        flg = True
        for c in sub: # Python的for文
            if(c not in ['A', 'G', 'C', 'T']): flg = False # こちらも、in はこういう時便利です

        if(flg): res = max(res, len(sub)) # ACGT文字列の長さnumの最大値を保持する

print(res)
n,m = list(map(int, input().split()))
s = [0 for i in range(n+1)]
t = [-1 for i in range(n+1)]
for i in range(m):
    x = int(input())
    s[x] = 1

def dx(r):
    global t
    if t[r]>=0:
        return t[r]
    x=0
    y=0
    #print(i)
    if s[r+1]==0 and r==n-2:
        return 2
    if s[r+1]==1 and r==n-2:
        return 1
    if r==n-1:
        return 1
    if r==n:
        return 0
    if s[r+1] == 0:
        x=dx(r+1)
    if s[r+2] == 0:
        y=dx(r+2)
    #print([i,x,y])
    t[r]=(x+y)%1000000007
    return (x+y)%1000000007

ans=dx(0)

print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
n,m = list(map(int, input().split()))
s = [0 for i in range(n+1)]
t = [-1 for i in range(n+1)]
for i in range(m):
    x = int(input())
    s[x] = 1

def dx(r):
    global t
    if t[r]>=0:
        return t[r]
    x=0
    y=0
    #print(i)
    if s[r+1]==0 and r==n-2:
        return 2
    if s[r+1]==1 and r==n-2:
        return 1
    if r==n-1:
        return 1
    if r==n:
        return 0
    if s[r+1] == 0:
        x=dx(r+1)
    if s[r+2] == 0:
        y=dx(r+2)
    #print([i,x,y])
    t[r]=(x+y)%1000000007
    return (x+y)%1000000007

ans=dx(0)

print(ans)
import collections
import sys
S = input()[::-1]
    
MOD=2019
X = [0]
for i, s in enumerate(S):
    X.append((X[-1]+int(s)*pow(10,i,MOD))%MOD)
    
c = collections.Counter(X)
ans = 0
for v in C.values():
    ans += v * (v - 1) // 2
print(ans)

### FIXED CODE ###

from collections import Counter
S = input()[::-1]
MOD = 2019

X = [0]
for i, s in enumerate(S):
    X.append((X[-1] + int(s) * pow(10, i, MOD)) % MOD)

C = Counter(X)
ans = 0
for v in C.values():
    ans += v * (v - 1) // 2
print(ans)
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

l = [a, b, c, d, e]
l_times_ten = []
amari_list = []
time = 0
for i in range(len(l)):
    amari = l[i] % 10
    if amari == 0:
        l_times_ten.append(l[i])
    elif amari != 0:
        amari_list.append(amari)
        l_tmp =  l[i] +(10 - amari)
        l_times_ten.append(l_tmp)
max_total_time = sum(l_times_ten)
adding = 10 - min(amari_list)
min_total_time = max_total_time - adding
print(min_total_time)

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

l = [a, b, c, d, e]
l_times_ten = []
amari_list = []
for i in range(len(l)):
    amari = l[i] % 10
    if amari == 0:
        l_times_ten.append(l[i])
    elif amari != 0:
        amari_list.append(amari)
        l_tmp =  l[i] +(10 - amari)
        l_times_ten.append(l_tmp)
# print(l_times_ten)
# print(amari_list)
max_total_time = sum(l_times_ten)
# print(min(amari_list))
if len(amari_list) != 0:
    adding = 10 - min(amari_list)
else:
    adding = 0
min_total_time = max_total_time - adding
print(min_total_time)
N=int(input())
A=list(map(int, input().split()))
A=list(map(abs, A))
A.sort()
print(sum(A[1:]-A[0]))

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
cnt=0
for i in range(N):
  if A[i]<0:
    A[i]*=-1
    cnt+=1
A=list(map(abs, A))
A.sort()
if cnt&1==0:
  print(sum(A))
else:
  print(sum(A[1:])-A[0])
a, b = map(int, input().split())
 
if a > b:
    print(a+a-1)
elif a < b:
    print(b+b-1)
else
    print(a+b)

### FIXED CODE ###


a, b = map(int, input().split())
 
if a > b:
    print(a+a-1)
elif a < b:
    print(b+b-1)
else:
    print(a+b)
a, b = list(map(int, input().split()))
number = 1
outlet_number = a
while outlet_number <= b:
    outlet_number += a - 1
    number += 1
print(number)

### FIXED CODE ###

forecasts     = input()
real_weathers = input()

correct_number = 0
for date in range(len(forecasts)):
    if forecasts[date] == real_weathers[date]:
        correct_number += 1
print(correct_number)
P = []
S = []
for i in range(2):
    pp, ss  = map(int, input().split())
    P.append(pp)
    S.append(ss)

A = P[0]
V = S[0]
B = P[1]
W = S[1]
T = int(input())


def run():
	if A < B:
		c = (B + V*T) - (A + W*T)
		if c <= 0 :
			return 'YES'
		else :
			return 'NO'
	elif A > B:
		c = (B - V*T) - (A - W*T) 
		if c >= 0 :
			return 'YES'
		else :
			return 'NO'
	else :
		return 'YES'
print(run())

### FIXED CODE ###

a = input()
nickname = a[0:3]
print(nickname)
while 1:
 H, W = map(int,raw_input().split())
 if H + W == 0:
???break
 for h in range(H):
  if h % 2 == 0:
   if W % 2 == 0:
    print ('#.'*(W//2))
   else:
    print ('#.'*(W//2)+'#')
  else:
   if: W % 2 == 0:
    print ('.#'*(W//2))
 else:
  print ('.#'*(W//2)+'.')
 print ''

### FIXED CODE ###

while 1:
 H, W = map(int,raw_input().split())
 if H + W == 0:break
 for h in range(H):
  if h % 2 == 0:
   if W % 2 == 0:
    print ('#.'*(W//2))
   else:
    print ('#.'*(W//2)+'#')
  else:
   if W % 2 == 0:
    print ('.#'*(W//2))
   else:
    print ('.#'*(W//2)+'.')
 print ''
import math
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))
i.append(b)
ans=0
l=[]
for j in range(1,a+1):
    l.append(abs(i[j]-i[j-1]))
for k in range(1,a):
    if k==1:
        ans=l[1]-l[0]
    else:
        ans=math.gcd(ans,l[k]-l[k-1])
print(ans)

### FIXED CODE ###

import fractions
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))

ans=0
l=[]
for j in range(a):
    l.append(abs(b-i[j]))
for k in range(0,a):
    if k==0:
        ans=l[0]
    else:
        ans=fractions.gcd(ans,l[k])
print(ans)
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
ans=0
for i in range(k):
  ans=a[ans]-1
  if ans in b:
    d=len(b)-b.index(ans)
    e=b.index(ans)
    break
  else: b.append(ans)

f=(k-e)%d

print(b[e+f])

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
adj=[1]*n
b=[1]
now=0
while adj[now]:
  adj[now]=0
  now=a[now]-1
  b.append(now+1)
loop_start=b.index(b[-1])
loop=b[loop_start:-1]
p=len(loop)
if k<loop_start:
  print(b[k])
else:
  k-=loop_start
  k%=p
  print(loop[k])
def trans(cur, prev, score, paths, N):
    # inf check
    if cur in prev_paths:
        return 'inf'
    if cur == N and not cur in paths:
        return score

    nodes = paths[cur]
    for n, s in nodes:
        score += s
        prev_paths[cur] = 1
        return trans(n, prev_paths, score, paths, N)


N, M = map(int, input().split())

paths = {}
prev_paths = {}
for i in range(M):
    a, b, c = map(int, input().split())
    if a in paths:
        paths[a].append((b, c))
    else:
        paths[a] = [(b, c)] 

cur_node = 1
prev_node = -1
score = trans(cur_node, prev_paths, 0, paths, N)
print(score)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def set_enable_goal(cur_node, back_paths, enable_goal):
    if cur_node in back_paths:
        for next_node in back_paths[cur_node]:
            if enable_goal[next_node - 1] == 0:
                enable_goal[next_node - 1] = 1
                set_enable_goal(next_node, back_paths, enable_goal)


N, M = map(int, input().split())
MIN = float('-inf')
INF_LIMIT = -MIN

back_paths = {}
all_paths = {}
for i in range(M):
    a, b, c = map(int, input().split())
    if a in all_paths:
        all_paths[a].append((b, c))
    else:
        all_paths[a] = [(b, c)]

    if b in back_paths:
        back_paths[b].append(a)
    else:
        back_paths[b] = [a]


# path cut
enable_goal= [0 for i in range(N)]
enable_goal[N - 1] = 1
set_enable_goal(N, back_paths, enable_goal)

for a, paths in all_paths.items():
    if not enable_goal[a - 1]:
        all_paths[a] = []
    else:
        valid_paths = []
        for b, c in paths:
            if enable_goal[b - 1]:
                valid_paths.append((b, c))
        all_paths[a] = valid_paths


scores = [MIN for i in range(N)]
scores[0] = 0

is_inf = False
for n in range(N):
    for a in all_paths.keys():
        for b, c in all_paths[a]:
            scores[b - 1] = max(scores[b - 1], scores[a - 1] + c)

# loop check
if not is_inf:
    prev_score = scores[N - 1]
    for a in all_paths.keys():
        for b, c in all_paths[a]:
            scores[b - 1] = max(scores[b - 1], scores[a - 1] + c)
    if prev_score != scores[N - 1]:
        is_inf = True


if is_inf:
    print('inf')
else:
    print(scores[N - 1])
x=int(input())
for i in range(x**0.5+100):
  if i*(i+1)//2>=x:
    print(i)
    break

### FIXED CODE ###

x=int(input())
for i in range(int(2*x**0.5)+100):
  if i*(i+1)//2>=x:
    print(i)
    break
n = int(input())
ans = 0
for i in range(a,n):
  ans += i
  
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1,n+1):
  ans += i
  
print(ans)
#include <bits/stdc++.h>

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    string line;
    cin >> line;
    cout << (ALL (find, line, '7') == line.end() ? "No" : "Yes") << endl;
    return 0;
}


### FIXED CODE ###

def main():
    line = str(input())
    print("No" if line.find("7") == -1 else "Yes")
    return


main()
n=int(input())
a = [int(input()) for _ in range(n)]
ans=0
a.sort()
for i in range(n+1):
    if sum(a)%10 == 0:
        if a[i]%10 == 0:
            continue
        else:
            a[i]=0
    else:
        print(sum(a))
        exit(0)
print(0)

### FIXED CODE ###

n=int(input())
a = [int(input()) for _ in range(n)]
ans=0
a.sort()
for i in range(n):
    if sum(a)%10 == 0:
        if a[i]%10 == 0:
            pass
        else:
            a[i]=0
    else:
        print(sum(a))
        exit(0)
print(0)
a,b,c,k = map(int,input().split())

xa = min(a,k)
k1 = k-xa
xb = min(b,k1)
k2 = k1-xb
xc = k2

print(xa-xc)

### FIXED CODE ###

s = input()
t = input()

if (len(s) == len(t)-1) and (s == t[:len(t)-1]):
    print("Yes")
else:
    print('No')
n = int(input())
zahyou = []
for i in range(n):
    a = input().split()
    zahyou.append(a)
import math
import itertools
import statistics


def distance(x1,x2,y1,y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)

allen = 0
for i in zahyou:
    for j in zahyou:
        allen += distance(int(i[0]),int(j[0]),int(i[1]),int(j[1]))

ans = allen/ n
print(ans)

### FIXED CODE ###

n = int(input())
zahyou = []
for i in range(n):
    a = input().split()
    zahyou.append(a)
import math


def distance(x1,x2,y1,y2):
    return math.sqrt((x1-x2)**2 + (y1-y2)**2)

allen = 0
for i in zahyou:
    for j in zahyou:
        allen += distance(int(i[0]),int(j[0]),int(i[1]),int(j[1]))

ans = float(allen/n)
print(ans)
from fractions import gcd

MOD = 1000000000 + 7

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

l = 1
ans = 0
for a in A:
    g = gcd(a, l)
    ans = (ans * (a // g)) % MOD
    l = l * a // g
    ans = (ans + (l / a) % MOD) % MOD
print(int(ans))


### FIXED CODE ###

from fractions import gcd

MOD = 1000000000 + 7

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

l = 1
ans = 0
for a in A:
    g = gcd(a, l)
    l = (l // g) * a
    ans = (ans * (a // g)) % MOD
    ans = (ans + (l // a)) % MOD
print(int(ans))
s=list(input())

for i in range(10):
  if s[i]=='h' and s[i+1]=='i':
    print('Yes')
    exit()
  
print('No')    
    

### FIXED CODE ###

s=str(input())
a=len(s)
b=['hi','hihi','hihihi','hihihihi','hihihihihi']
if a%2!=0:
  print('No')
elif s in b:
  print('Yes')
else:
  print('No')
import math
A, B, C, D = map(int, input().split())

lcm_cd = C * D // math.gcd(C, D)
divBbyC = B // C
divBbyD = B // D
divBbyCD = B // lcm_cd
divAmbyC = (A - 1) // C
divAmbyD = (A - 1) // D
divAmbyCD = (A - 1) // lcm_cd

ans = (B - divBbyC - divBbyD + divBbyCD) - ((A - 1) - divAmbyC - divAmbyD + divAmbyCD)
print(ans)


### FIXED CODE ###

import fractions 
A, B, C, D = map(int, input().split())

lcm_cd = C * D // fractions.gcd(C, D)
divBbyC = B // C
divBbyD = B // D
divBbyCD = B // lcm_cd
divAmbyC = (A - 1) // C
divAmbyD = (A - 1) // D
divAmbyCD = (A - 1) // lcm_cd

ans = (B - divBbyC - divBbyD + divBbyCD) - ((A - 1) - divAmbyC - divAmbyD + divAmbyCD)
print(ans)
from math import sqrt

class Edge:
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost

def dijkstra(G, s):
    from heapq import heappush, heappop
    l = len(G)
    dist = [float('inf')] * l
    done = [False] * l
    dist[s] = 0
    pq = []
    heappush(pq, (0, s))
    while pq:
        c, v = heappop(pq)
        done[v] = True
        for e in G[v]:
            cost = dist[v] + e.cost
            if cost < dist[e.to] and not done[e.to]:
                dist[e.to] = cost
                heappush(pq, (cost, e.to))
    return dist

xs, ys, xt, yt = map(int, input().split())
N = int(input())
xyr = [[int(i) for i in input().split()] for _ in range(N)]
xyr += [[xs, ys, 0], [xt, yt, 0]]

G = [[] for _ in range(N + 2)]

for i, (x, y, r) in enumerate(xyr):
    for j, (x2, y2, r2) in enumerate(xyr[i + 1:]):
        w = max(0, sqrt((x - x2)**2 + (y - y2)**2) - r - r2)
        G[i].append(Edge(i + j + 1, w))
        G[i + j + 1].append(Edge(i, w))

print(dijkstra(G, len(G) - 2)[-1])


### FIXED CODE ###

_, x = map(int, input().split())
a = [int(i) for i in input().split()]
cnt = 0

for i in range(len(a) - 1):
    s = a[i] + a[i + 1]
    if x < s:
        sub = s - x
        a[i + 1] = max(0, a[i + 1] - sub)
        cnt += sub
print(cnt)
import numpy as np
import math

k=int(input())
a_t=1/k
a=a_t*10**(len(str(k))-1)
c=100
buf=0
index=0
b=a
for i in range(1,10):
        b=b-math.floor(b)
        buf=math.floor(b*10)
        #print(i,buf)
        if c>buf:
                index=i
        c=min(c,buf)
        b=b*10
#print(index)
m=math.ceil(a*10**index)
#print(m)
product=k*m
print(sum(int(i) for i in str(product)))

### FIXED CODE ###

import numpy as np

s=input()
t=input()

print('YES' if s[0]==t[2] and s[1]==t[1] and s[2]==t[0] else 'NO')
#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)


N = int(input())
abc = int_mtx(N)

#f_inf = float("inf")
#dp = [f_inf]*N
dp = np.array([[0,0,0]]*N)

dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1,N):
    dp[i][0] = max(dp[i-1][1]+abc[i][0],dp[i-1][2]+abc[i][0])
    dp[i][1] = max(dp[i-1][0]+abc[i][1],dp[i-1][2]+abc[i][1])
    dp[i][2] = max(dp[i-1][0]+abc[i][2],dp[i-1][1]+abc[i][2])

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



### FIXED CODE ###


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

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)


N = int(input())
abc = int_mtx(N)

#f_inf = float("inf")
#dp = [f_inf]*N
dp = np.array([[0,0,0]]*N)

dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]

for i in range(1,N):
    dp[i][0] = max(dp[i-1][1]+abc[i][0],dp[i-1][2]+abc[i][0])
    dp[i][1] = max(dp[i-1][0]+abc[i][1],dp[i-1][2]+abc[i][1])
    dp[i][2] = max(dp[i-1][0]+abc[i][2],dp[i-1][1]+abc[i][2])

print(max(dp[N-1]))
sum_div = 0
M = []
for i in range(5):
    num = int(input())
    sum_div += num // 10
    mod = num % 10
    if mod != 0:
        M.append(mod)

waiting = 10*(len(M)-1) + min(M)
total = sum_div*10 + waiting
print(total)


### FIXED CODE ###

sum_div = 0
M = []
for i in range(5):
    num = int(input())
    sum_div += num // 10
    mod = num % 10
    if mod != 0:
        M.append(mod)

if M:
    waiting = 10*(len(M)-1) + min(M)
else:
    waiting = 0
total = sum_div*10 + waiting
print(total)
s = map(input().split())
print(s[1])s = list(map(str,input().split()))
print("A"+s[1][0]+"C")

### FIXED CODE ###

s = list(map(str,input().split()))
print("A"+s[1][0]+"C")
import sys
sys.setrecursionlimit(2147483647)

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

if n==2:
    print(aa[0],aa[1])
    exit()

aa.sort()

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 = 10**9+7
N = 10 ** 6  # 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)

import bisect
ans=0
(a,b)=(0,0)

for item in aa[:n//2+1]:
    i=bisect.bisect_left(aa,item*2)
    tmp=cmb(aa[min(n-1,i)],item,p)
    #print(aa[min(n-1,i)],item,tmp)
    if ans<tmp:
        ans=tmp
        (a,b)=(aa[min(n-1,i)],item)
    

print(a,b)

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)

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

if n==2:
    print(aa[0],aa[1])
    exit()

aa.sort()

nn=max(aa)

c=0
tmp=10**9

for a in aa:
    if abs(nn/2.0-a)<tmp:
        tmp=abs(nn/2.0-a)
        c=a

print(nn,c)
def main(): 
  import sys
  input = sys.stdin.readline
  n,p = [int(i) for i in input().split()]
  s = input()
  ans = 0
  if p == 2:
    s = list(s)
    for i,si in enumerate(s):
      if int(si)%2 == 0:
        ans += i+1
    print(ans)
    exit()

  elif p == 5:
    s = list(s)
    for i,si in enumerate(s):
      if int(si)%5 == 0:
        ans += i+1
    print(ans)
    exit()

  chk = [0]*p
  chk[0] = 1

  for i in range(1,n):
    m = s[:-i]
    k = int(int(m)%p)
    chk[k] += 1
  r = int(int(s)%p)
  chk[r] += 1
  for i in chk:
    ans += i*(i-1)/2
  print(int(ans))
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,p = [int(i) for i in input().split()]
s = input()
ans = 0

import math
def nCr(n, r):
  if n < r:
    return 0
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
    print(ans)
    exit()

else:
  chk = [0]*p
  chk[0] = 1
  m = 0
  for i in range(n)[::-1]:
    m = (int(s[i])*pow(10,n-1-i,p)+m)%p
    chk[m] += 1
  for i in chk:
    ans += nCr(i,2)
  print(ans)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

a = int(input())
b = int(input())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")


### FIXED CODE ###

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

a, b = map(int, input().split())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")