Harryxun/stf_run huggingface dataset:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**8
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,M,R = LI()
    r = _LI()
    root = [[] for _ in range(N)]
    for _ in range(M):
        a,b,c = LI()
        root[a-1].append((b-1,c))
        root[b-1].append((a-1,c))

    memo = [[0] * r for _ in range(R)]

    min_r = INF
    for x in itertools.permutations(r):
        it = 0
        s = x[0]
        for t in x[1:]:
            if memo[s][t]:
                it = memo[s][t]
            else:
                node = [INF] * N
                q = [(s,0)]
                while q:
                    u,l = q.pop()
                    node[u] = l
                    for v,m in root[u]:
                        if node[v] > l + m:
                            q.append((v,l+m))
                it += node[t]
                memo[s][t] = node[t]
                memo[t][s] = node[t]
            s = t
        min_r = min(min_r,it)
    print(min_r)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**8
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,M,R = LI()
    r = _LI()
    root = [[] for _ in range(N)]
    for _ in range(M):
        a,b,c = LI()
        root[a-1].append((b-1,c))
        root[b-1].append((a-1,c))

    memo = [[0] * N for _ in range(N)]

    min_r = INF
    for x in itertools.permutations(r):
        it = 0
        s = x[0]
        for t in x[1:]:
            if memo[s][t]:
                it += memo[s][t]
            else:
                node = [INF] * N
                q = collections.deque()
                q.append((s,0))
                node[s] = 0
                while q:
                    u,l = q.popleft()
                    for v,m in root[u]:
                        if node[v] > l + m:
                            node[v] = l + m
                            q.append((v,l+m))
                memo[s][t] = node[t]
                memo[t][s] = node[t]
                it += node[t]
            s = t
        min_r = min(min_r,it)
    print(min_r)

if __name__ == '__main__':
    main()
#!/usr/bin/env python
from itertools import permutations
N,M=map(int,raw_input().split())
path=[]
all_list=[]
count=0
 
for i in range(M):
    path.append(map(int,raw_input().split()))

NN=N*(N-1)/2
all_list=map(list,permutations(range(1,NN+1),2))
for i in range(len(all_list)):
    for j in range(M):
        if all_list[i]==path[j]:
            count=count+1
 
print count

### FIXED CODE ###

#!/usr/bin/env python

numbers = raw_input().split()

A = int(numbers[0])
B = int(numbers[1])

if A == B :
   print "Draw"
elif A == 1:
   print "Alice"
elif B == 1:
   print "Bob"
elif A > B:
   print "Alice"
elif B > A:
   print "Bob"
s = list(input())
s = s.insert(4,' ')
print(''.join(s))


### FIXED CODE ###

s = input()
print(s[:4] + ' ' + s[4:])
i = 1
while True:
  n = input()
  if n == 0:
    break
  print("Case {0}: {1}").format(i,n)
  i += 1

### FIXED CODE ###

i = 1
while True:
  n = input()
  if n == "0":
    break
  print("Case {0}: {1}".format(i,n))
  i += 1
from collections import deque

H,W,K=map(int,input().split())
x1,y1,x2,y2 = map(lambda x: int(x)-1,input().split())
S=[list(input()) for _ in range(H)]

def bfs(x0,y0,x_goal,y_goal):
  seen = [[0 for i in range(W)] for j in range(H)]
  d = [[0 for i in range(W)] for j in range(H)]
  todo = deque()
  if S[x0][y0]=='@':return 0
  seen[x0][y0] = 1
  todo.append((x0,y0))
  while todo:
    x0,y0 = todo.popleft()
    dx,dy = (1,-1,0,0),(0,0,1,-1)
    for i in range(4):
      for k in range(K):
        x,y = x0+dx[i]*(k+1), y0+dy[i]*(k+1)
        if x<0 or x>=H:break
        if y<0 or y>=W:break
        if seen[x][y]==1:continue
        if S[x][y]=='@':break
        seen[x][y] = 1
        todo.append((x,y))
        d[x][y] = d[x0][y0] + 1
        if x==x_goal and y == y_goal: return d[x][y]

ans = bfs(x1,y1,x2,y2)
print(ans if ans > 0 else -1)

### FIXED CODE ###

from collections import deque

def main():
  H,W,K=map(int,input().split())
  x1,y1,x2,y2 = map(lambda x: int(x)-1,input().split())
  S=[list(input()) for _ in range(H)]
  INF = 10**20

  def bfs(x0,y0,x_goal,y_goal):
    seen = [[0 for i in range(W)] for j in range(H)]
    d = [[INF for i in range(W)] for j in range(H)]
    d[x0][y0] = 0
    todo = deque()
    seen[x0][y0] = 1
    todo.append((x0,y0))
    while todo:
      x0,y0 = todo.popleft()
      dx,dy = (1,-1,0,0),(0,0,1,-1)
      for i in range(4):
        for k in range(K):
          x,y = x0+dx[i]*(k+1), y0+dy[i]*(k+1)
          if x<0 or x>=H:break
          if y<0 or y>=W:break
          if d[x][y] < d[x0][y0] + 1: break
          if S[x][y]=='@':break
          if seen[x][y]: continue
          seen[x][y] = 1
          todo.append((x,y))
          d[x][y] = d[x0][y0] + 1
          if x==x_goal and y == y_goal: return d[x][y]
    return d[x_goal][y_goal]

  ans = bfs(x1,y1,x2,y2)
  print(ans if ans < INF else -1)
  
if __name__ == "__main__":
  main()
import functools
import operator

N = int(input())
A = list(map(int,input().split()))
result = functools.reduce(operator.mul, A)
if '0' in A :
    print(0)
else :
    if result > 10**18 :
        print('-1')
    else :
        print(result)

### FIXED CODE ###

A,B = map(int,input().split())
print(A*B)
N,K=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
print(sum[:K])

### FIXED CODE ###

N,K=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)
print(sum(l[:K]))
import math
M = 256
while 1:
    N = int(raw_input())
    if N == 0: break
    H = 1e32
    l = map(int,raw_input().split())
    for S in range(16):
        for A in range(16):
            for C in range(16):
                R = S
                O = [0]*N
                for i in range(N):
                    R = (A*R+C)%M
                    O[i] = (l[i]+R)%M
                X = [O.count(i) for i in set(O)]
                tmp = -sum(float(x)/N*math.log(float(x)/N) for x in X)
                if tmp < H:
                    H = tmp
                    ans = [S,A,C]
    print " ".join(map(str,ans))

### FIXED CODE ###

import math,itertools as it
M = 256
while 1:
    N = int(raw_input())
    if N == 0: break
    H = 1e10
    I = map(int,raw_input().split())
    for S,A,C in it.product(range(16),repeat=3):
        R = S
        O = [0]*M
        for i in I:
            R = (A*R+C)%M
            O[(i+R)%M] += 1
        tmp = -sum(1.0*x/N*math.log(1.0*x/N,2) for x in O if x > 0)
        if tmp < H:
            H = tmp
            ans = [S,A,C]
    print " ".join(map(str,ans))
#049 C

S = input()
A = 'dream'
B = 'dreamer'
C = 'erase'
D = 'eraser'

S=S[::-1]
A=A[::-1]
B=B[::-1]
C=C[::-1]
D=D[::-1]

tmp =""
for i in S:
    tmp +=i
    print(tmp)
    for j in [A,B,C,D]:
        if tmp == j:
            S=S.replace(tmp,"",1)
            print(S)
            tmp=""
if len(S)==0:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

#049 C

S = input()
A = 'dream'
B = 'dreamer'
C = 'erase'
D = 'eraser'

S=S[::-1]
A=A[::-1]
B=B[::-1]
C=C[::-1]
D=D[::-1]

tmp =""
for i in S:
    tmp +=i
    for j in [A,B,C,D]:
        if tmp == j:
            S=S.replace(tmp,"",1)
            tmp=""
if len(S)==0:
    print('YES')
else:
    print('NO')
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 0; i < N-1; i++) {
    
    for (int j = 0; j < i+1;j++){
      
      if ((i+1)%(j+1) == 0) {
        ans += 2;
        
      }
    }
  }
  
  cout <<  ans;
}


### FIXED CODE ###

N = int(input())
ans = 0
for i in range(N-1):
    ans += (N-1)//(i+1)
    
print(ans)
n,q = map(int,input().split())
s = input()
m = [list(map(int,input().split())) for i in range(q)]
count = [0]*(n+1)
 
for i in range(n):
    if S[i:i+2] == 'AC':
        comu[i+1] = comu[i] + 1
    else:
        comu[i+1] = comu[i]
 
for l,r in m:
    print(count[r-1]-count[l-1]

### FIXED CODE ###

n,q = map(int,input().split())
s = input()
m = [list(map(int,input().split())) for i in range(q)]
count = [0]*(n+1)
 
for i in range(n):
    if s[i:i+2] == 'AC':
        count[i+1] = count[i] + 1
    else:
        count[i+1] = count[i]
 
for l,r in m:
    print(count[r-1]-count[l-1])
from collections import deque
N, Q = map(int, input().split())
root = [[] for i in range(N)]
ans = [0]*N

for i in range(N-1):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  root[a].append(b)
  root[b].append(a)
  
for i in range(Q):
  p, x = map(int, input().split())
  ans[p-1] += x
  
visit = [False]*N
def dfs(n):
  visit[n] = True
  for go in root[n]:
    if visit[go]:
      continue
    ans[go] += ans[n]
    dfs(go)
    
dfs(0)
print(' '.join(map(str, ans)))

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7


n, q = map(int, input().split())
g = [[] for _ in range(n)]
val = [0] * n

for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

for _ in range(q):
    p, x = map(int, input().split())
    val[p - 1] += x

seen = [False] * n
def dfs(v):
    seen[v] = True
    for nv in g[v]:
        if seen[nv]:
            continue
        val[nv] += val[v]
        dfs(nv)

dfs(0)
print(*val)
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
S=input()

if A<="2019/04/30":
	print("Heisei")
else:
	print("TBD")

### FIXED CODE ###

import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
S=input()

if S<="2019/04/30":
	print("Heisei")
else:
	print("TBD")
if int(kaku) != len(s_list):
    print('No')
else:
    hen_list = [int(x) for x in s_list]

    m = max(hen_list)
    total = sum(hen_list)
    print(m, total)

    if m < total - m:
            print('Yes')
    else:
        print('No')



### FIXED CODE ###

kaku = input()
s_list = input().split(' ')
if not int(kaku) == len(s_list):
    print('No')
else:
    hen_list = [int(x) for x in s_list]
    m = max(hen_list)
    total = sum(hen_list)
    if m < total - m:
            print('Yes')
    else:
        print('No')
n = int(input())
d = list(map(int,input().split()))
 
dd = 0
for i in range(n):
	for j in range((i+1),n):
		if i==j:
			continue
		dd += (d[i]*d[j])
print(ans)

### FIXED CODE ###

n = int(input())
d = list(map(int,input().split()))
 
dd = 0
for i in range(n):
  for j in range((i+1),n):
    if i==j:
      continue
    dd += (d[i]*d[j])
print(dd)
A,B,C,D,E,F=map(int,input().split())
water=[]
suger=[]
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        if 0<100*(i*A+j*B)<=F:
            water.append(100*(i*A+j*B))
        if 100*(i*A+j*B)>F:
            break

for i in range((F*E/(100+E))//C+1):
    for j in range((F*E/(100+E))//D+1):
        if 0<=i*C+j*D<=F*E/(100+E):
            suger.append(i*C+j*D)
        if i*C+j*D>F*E/(100+E):
            break


c=0
w=0
s=0
for i in range(len(water)):
    for j in range(len(suger)):
        if water[i]+suger[j]<=F and water[i]*E/100>=suger[j] and suger[j]/(water[i]+suger[j])>c:
            c=suger[j]/(water[i]+suger[j])
            w=water[i]
            s=suger[j]

print(w+s,s)


### FIXED CODE ###

A,B,C,D,E,F=map(int,input().split())
weight=100*A
suger=0
c=0
for i in range(F//(100*A)+1):
    for j in range(F//(100*B)+1):
        for k in range((i*A+j*B)*E//C+1):
            for l in range((i*A+j*B)*E//D+1):
                if 100*(i*A+j*B)+k*C+l*D<=F and k*C+l*D<=(i*A+j*B)*E and (i*i+j*j+k*k+l*l)!=0 and (k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)>c:
                    c=(k*C+l*D)/(100*(i*A+j*B)+k*C+l*D)
                    weight=100*(i*A+j*B)+k*C+l*D
                    suger=k*C+l*D


print("{} {}".format(weight,suger))
def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
n = (input())
res = (input())
while n > 1:
	x = (input())
	res = (res * x) / gcd(res, x);
	n -= 1
print(res)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import collections
import math
import fractions 

# code start
raw_input = input


def lcm(a,b):
	return a*b/fractions.gcd(int(a),int(b))

def main():
	count = int(input())
	i = 0
	temp = 1
	while(i<count):
		i+=1
		num = int(input())
		temp = lcm(temp,num)
	print(int(temp))


if __name__ == '__main__':
    main()

# code end
o = int(input())
e = int(input())
if len(o)-len(e)==1:
  x = o[-1]
else:
  x = ''
ans = ''
for i in range(len(e)):
  ans += o[i] + e[i]
ans += x
print(ans)

### FIXED CODE ###

o = input()
e = input()
if len(o)-len(e)==1:
  x = o[-1]
else:
  x = ''
ans = ''
for i in range(len(e)):
  ans += o[i] + e[i]
ans += x
print(ans)
import random
import sys

sys.setrecursionlimit(10000)

# n, m = map(int, input().split())
n, m = 200000, 200000
group = {i: 0 for i in range(1, n+1)}
edge = {}
g_mem = {}
g_num = 0
g_con = set()

for i in range(m):
    # a, b = map(int, input().split())
    a, b = random.sample(range(1,n+1), 2)
    if group[a]==0 and group[b] == 0:
        g_num += 1
        group[a] = g_num
        group[b] = g_num
        g_mem[g_num] = 2
    elif group[a] == 0:
        group[a] = group[b]
        g_mem[group[b]] += 1
    elif group[b] == 0:
        group[b] = group[a]
        g_mem[group[a]] += 1
    elif group[a] != group[b]:
        if edge.get(group[a]):
            edge[group[a]].add(group[b])
        else:
            edge[group[a]] = {group[b]}
        if edge.get(group[b]):
            edge[group[b]].add(group[a])
        else:
            edge[group[b]] = {group[a]}

# print(g_mem)
# print(sum(g_mem.values()))
# print(edge)

g_reached = {i: 0 for i in range(1, g_num+1)}

def dps(g_mem, edge, now):
    count = g_mem[now]
    if edge.get(now):
        for e in edge[now]:
            if g_reached[e] == 0:
                g_reached[e] = 1
                count += dps(g_mem, edge, e)
    return count


ans = []
for now in range(1, g_num+1):
    if g_reached[now] == 0:
        g_reached[now] = 1
        ans.append(dps(g_mem, edge, now))

# print(ans)
print(max(ans))


### FIXED CODE ###

import random
import sys

n, m = map(int, input().split())
# n, m = 200000, 200000
group = {i: 0 for i in range(1, n+1)}
edge = {}
g_mem = {}
g_num = 0
g_con = set()

for i in range(m):
    a, b = map(int, input().split())
    # a, b = random.sample(range(1,n+1), 2)
    if group[a]==0 and group[b] == 0:
        g_num += 1
        group[a] = g_num
        group[b] = g_num
        g_mem[g_num] = 2
    elif group[a] == 0:
        group[a] = group[b]
        g_mem[group[b]] += 1
    elif group[b] == 0:
        group[b] = group[a]
        g_mem[group[a]] += 1
    elif group[a] != group[b]:
        if edge.get(group[a]):
            edge[group[a]].add(group[b])
        else:
            edge[group[a]] = {group[b]}
        if edge.get(group[b]):
            edge[group[b]].add(group[a])
        else:
            edge[group[b]] = {group[a]}

# print(g_mem)
# print(sum(g_mem.values()))
# print(edge)

g_reached = {i: 0 for i in range(1, g_num+1)}
ans = list(g_mem.values())
for now in range(1, g_num+1):
    if g_reached[now] == 0:
        g_reached[now] = 1
        if edge.get(now):
            count = g_mem[now]
            queue = set(edge[now])
            while len(queue) > 0:
                next_now = queue.pop()
                if g_reached[next_now] == 0:
                    g_reached[next_now] = 1
                    count += g_mem[next_now]
                    queue |= edge[next_now]
                queue -= {now}
                now = next_now
            ans.append(count)


# print(ans)
if len(ans) > 0:
    print(max(ans))
else:
    print(1)
x = input()
(N, K) = (int(x[0]), int(x[2]))
max_distribution = N - K
if K == 1:
    max_distribution = 0
print(max_distribution)

### FIXED CODE ###

(N, K) = list(map(int, input().split()))
max_distribution = N - K
if K == 1:
    max_distribution = 0
print(max_distribution)
H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))

ans = (H - h) * (W - w)
print(ansj
      

### FIXED CODE ###

H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))

ans = (H - h) * (W - w)
print(ans)
n, m = map(int, input().split())
A = list(map(int, input().split()))

A.sort(reverse=True)

if A[m+1] >= (sum(A) // (4 * m)):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

A.sort(reverse=True)

if A[m-1] >= (sum(A)/(4*m)):
    print("Yes")
else:
    print("No")
nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0
flg = [False for i in range(n)]

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]-1] == False :
			ac += 1
			flg[p[l]] = True
		elif  flg[p[l]-1] == False :
			wa += 1

print(ac)
print(wa)


### FIXED CODE ###

nm = input().split()
n = int(nm[0])
m = int(nm[1])

p = []
r = []

for i in range(m):
	pr = input().split()
	p.append(int(pr[0]))
	r.append(pr[1])

ac = 0
wa = 0
flg = [0 for i in range(n)]

if m != 0:
	for l in range(m):
		if r[l] == 'AC' and flg[p[l]-1] !=  'ac':
			ac += 1
			wa += flg[p[l]-1]
			flg[p[l]-1] = 'ac'
		elif  flg[p[l]-1] != 'ac' :
			flg[p[l]-1] += 1

print(ac)
print(wa)
#!usr/bin/env python3

import sys


def main():
    text = str()
    alphabets = 'abcdefghijklmnopqrstuvwxyz'

    for line in sys.stdin():
        text += line.lower()

    for alphabet in alphabets:
        print('%s : %d' % (alphabet, text.count(alphabet)))


if __name__ == '__main__':
    main()

### FIXED CODE ###

#!usr/bin/env python3

import sys


def main():
    text = str()
    alphabets = 'abcdefghijklmnopqrstuvwxyz'

    for line in sys.stdin:
        text += line.lower()

    for alphabet in alphabets:
        print('%s : %d' % (alphabet, text.count(alphabet)))


if __name__ == '__main__':
    main()
a,b = map(int,input().split())
if (a+b)%2 == 0:
  print((a+b)//2)
else:
  print(IMPOSSIBLE)

### FIXED CODE ###

a,b = map(int,input().split())
if (a+b)%2 == 0:
  print((a+b)//2)
else:
  print("IMPOSSIBLE")
def is_ok(n):
    global N
    return n*(n+1)//2>=N
def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok
N = int(input())
n = meguru_bisect(0,10**7)
s = list(range(1, n+1))
d = n-2
while sum(s) != N:
    s.pop(d)
    d -= 1
for i in s:
    print(i)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
def is_ok(m, n):
    return m*(m+1)//2>=n
def meguru_bisect(ng, ok, n):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid, n):
            ok = mid
        else:
            ng = mid
    return ok
def f(n):
    if n>0:
        m = meguru_bisect(0,10**7, n)
        print(m)
        f(n-m)
N = int(input())
f(N)
N = int(input())
A = [int(input()) for _ in range(N)]

# max(A_2,A_3,...,A_N)
# max(A_1,A_3,...,A_N)
# max(A_1,A_2,...,A_(N-1))

M_1 = max(A)
M_2 = max(A.replace(M_1, 0))

for i in range(N):
  if A[i] != M_1: print(M_1)
  else: print(M_2)

### FIXED CODE ###

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

M = max(A)
M_index = A.index(M)
sub_M = 0
for i in range(N):
  if i != M_index: sub_M = max(sub_M, A[i])

for i in range(N):
  if i == M_index: print(sub_M)
  else: print(M)
n = int(input())
dic = ()
for i in range(n):
    x = input()
    if 'insert' in x:
        dic.append(x.strip('insert '))
    else :
        if x.strip('find ') in dic:
            print('yes')
        else :
            print('no')



### FIXED CODE ###

n = int(input())
dic = set()
for i in range(n):
    x = input()
    if 'insert' in x:
        dic.add(x.strip('insert '))
    else :
        if x.strip('find ') in dic:
            print('yes')
        else :
            print('no')
import numpy as np

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

#base = np.zeros(n)
seen = np.diag(np.ones(n))
temp = 1

for i in range(m):
  a,b = map(int,input().split())
  seen[a-1] += seen[b-1]
  seen[b-1] += seen[a-1]
  
seen = np.where(seen > 0,1,0) - np.diag(np.ones(n))
ans = 0
for i in range(n):
  temp = np.multiply(seen[i],h)
  temp_1 = np.max(temp)
  if (h[i] > temp_1) and (temp_1 != 0):
    ans += 1
  elif temp_1 == 0:
    ans += 1
    
print(ans)

### FIXED CODE ###

import numpy as np
n,m = map(int,input().split())
h = list(map(int,input().split()))

base = np.ones(n)

for i in range(m):
  a,b =  map(int,input().split())
  if h[a-1] > h[b-1]:
    base[b-1] = 0
  elif h[a-1] < h[b-1]:
    base[a-1] = 0
  elif h[a-1] == h[b-1]:
    base[a-1] = 0
    base[b-1] = 0
    
print(int(np.sum(base)))
import numpy as np
N = int(input())
A = np.array([[int(x) for x in input().split()] for _ in range(2)])
ans = 0
for i in range(1,N+1):
  #print(A[0,:i],A[1,i-1:])
  ans = max(ans,sum(A[0,:i])+sum(A[1,i-1:]))
print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.array([[int(x) for x in input().split()] for _ in range(2)])
ans = 0
for i in range(1,N+1):
  #print(A[0,:i],A[1,i-1:])
  ans = max(ans,sum(A[0,:i])+sum(A[1,i-1:]))
print(ans)
a, b = input().split()

if a == 'H' and b == 'H':
    result = 'H'
    
if a == 'D' and b == 'H':
    result = 'D'
    
if a == 'D' and b == 'D':
    result = 'H'

    
print(result)

### FIXED CODE ###

a, b = input().split()

if a == 'H' and b == 'H':
    result = 'H'
    
if a == 'D' and b == 'H':
    result = 'D'
    
if a == 'D' and b == 'D':
    result = 'H'
    
if a == 'H' and b == 'D':
    result = 'D'
    
print(result)
n = int(input())
s = input()
s2 = input()
s3 = input()
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for a in alp:
  for i in range(min(s.count(a),s2.count(a),s3.count(a))):
    ans += a
print(ans)


### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
    s.append(input())
alp = "abcdefghijklmnopqrstuvwxyz"
ans = ""
for a in alp:
    cnt = 1e10
    for ss in s:
        cnt = min(cnt,ss.count(a))
    for i in range(cnt):
        ans += a
print(ans)
x = input
print(x*x*x)

### FIXED CODE ###

x = int(input())
print(x*x*x)
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
dp = [0]*(n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1
for i in range(2,n+1):
  if i in a:
  else:
    dp[i] = dp[i-1]+dp[i-2]
print(dp[-1] % (10**9+7))

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
a = set(a)
dp = [0]*(n+1)
dp[0] = 1
mod = 10**9 + 7
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1
for i in range(2,n+1):
  if i in a:
    continue
  else:
    dp[i] = (dp[i-1]+dp[i-2]) % mod
print(dp[-1] % mod)
x = int(input())
count = 0

def dfs(total, x):
    if total > x:
        return False

    if total == x:
        return total == x

    if dfs(total + 100, x):
        return True

    if dfs(total + 101, x):
        return True

    if dfs(total + 102, x):
        return True

    if dfs(total + 103, x):
        return True

    if dfs(total + 104, x):
        return True

    if dfs(total + 105, x):
        return True

print(1 if dfs(0, x) else 0)


### FIXED CODE ###

x = input()

ans = 0

if len(x) < 3:
    ans = 0

elif len(x) < 4:
    tmp1 = int(x[-2] + x[-1])
    tmp2 = int(x[0])
    if tmp2 * 5 >= tmp1:
        ans = 1

else:
    tmp1 = int(x[-2] + x[-1])
    tmp2 = int(x[-4] + x[-3])
    if tmp2 * 5 >= tmp1:
        ans = 1

print(ans)
a=int(input())
b=int(input())

if a*b%2==0:
  print("Even")
  
else:
  print("0dd")

### FIXED CODE ###

a, b = map(int, input().split())
print("Even" if a*b % 2 == 0 else "Odd")
a = input().split()
A = int(a[0])
B = int(a[1])
C = int(a[2])
if A == C:
 print("Yes")
else:
 print("No")

### FIXED CODE ###

N = input()
A = int(N[0])
B = int(N[1])
C = int(N[2])
if A==C:
 print("Yes")
else:
 print("No")