Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    S=input()
    n=len(S)
    A="dream dreamer erase eraser".split()
    #print(A)
    global cond
    cond=[]
    def dfslike_dreameraser(varS):#string->bool,resursion
        #print(varS)
        if len(varS)==0:
            cond.append(1)
            return 
        for word in A:
            if varS[:len(word)]==word:
                dfslike_dreameraser(varS[len(word):])
        return 
        
    dfslike_dreameraser(S)
    #print(cond)
    print(["NO","YES"][cond!=[]])
#%%submit!
resolve()

### FIXED CODE ###

#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
import random
def resolve():
    
    S=input()
    A="dream dreamer erase eraser".split()
    #print(A)
    que=[S]
    while(que!=[]):
        t=len(que)
        #print(t)
        vS=que.pop(random.randint(0,t-1))
        if vS=="":
            print("YES")
            return
        for w in A:
            r=len(w)
            if vS[:r]==w:
                que.append(vS[r:])
        #print(que,"k")    

    print("NO")
#%%submit!
resolve()
# 公式解説を見てからやった
# 複数サイクルでき、1-K回移動可能
# N < 5000?多分、O(N * 2N)くらいで行けそうに見えるが。。。

if __name__ == "__main__":

	N,K = map(int,input().split())
	P = [ int(p)-1 for p in input().split() ]
	C = list(map(int,input().split()))

	# 一度計算したサイクル情報を一応キャッシュしておく。。。
	# あんまり意味なさそう
	cycleIDs = [ -1 for _ in range(N) ]
	cycleInfs = []


	# print(P)

	ans = -1e19
	cycleID = 0

	for n in range(N):

		v = n
		currentCycleItemCnt = 0
		currentCycleTotal = 0

		if cycleIDs[v] != -1:
			currentCycleItemCnt, currentCycleTotal = cycleInfs[ cycleIDs[v] ]
			# print(currentCycleItemCnt, currentCycleTotal)
		else:
			while True:
				# 全頂点について、属するサイクルを計算する
				currentCycleItemCnt += 1
				currentCycleTotal += C[v]

				v = P[v]
				if v == n:
					# サイクル発見
					cycleInfs.append( (currentCycleItemCnt, currentCycleTotal) )
					cycleID += 1
					break

				# 一応、一度サイクルを計算した頂点については、
				# その頂点の属するサイクルの情報をメモっておく。。。
				cycleIDs[v] = cycleID

		procCnt = 0
		currentCycleSumTmp = 0

		while True:

			# 頂点vにコマが置かれた時の最高スコアを計算し、
			# これまでの最高スコアを上回ったら、これまでの最高スコアを更新する
			procCnt += 1
			currentCycleSumTmp += C[v]
			if K < procCnt:
				break

			cycleLoopCnt = 0
			if procCnt < K and 0 < currentCycleTotal:
				cycleLoopCnt = ( K - procCnt ) // currentCycleItemCnt

			print("v=", v, "currentCycleSumTmp=", currentCycleSumTmp, "procCnt, cycleLoopCnt, currentCycleTotal=", procCnt, cycleLoopCnt, currentCycleTotal)
			tmp = currentCycleSumTmp + cycleLoopCnt * currentCycleTotal
			ans = max( ans, tmp )

			v = P[v]
			if v == n:
				# サイクル終了
				break

	print(ans)


### FIXED CODE ###

# 公式解説を見てからやった
# 複数サイクルでき、1-K回移動可能
# N < 5000?多分、O(N * 2N)くらいで行けそうに見えるが。。。

if __name__ == "__main__":

	N,K = map(int,input().split())
	P = [ int(p)-1 for p in input().split() ]
	C = list(map(int,input().split()))

	# 一度計算したサイクル情報を一応キャッシュしておく。。。
	# あんまり意味なさそう
	cycleIDs = [ -1 for _ in range(N) ]
	cycleInfs = []


	# print(P)

	ans = -1e10
	cycleID = 0

	for n in range(N):

		v = n
		currentCycleItemCnt = 0
		currentCycleTotal = 0

		if cycleIDs[v] != -1:
			currentCycleItemCnt, currentCycleTotal = cycleInfs[ cycleIDs[v] ]
			# print(currentCycleItemCnt, currentCycleTotal)
		else:
			while True:
				# 全頂点について、属するサイクルを計算する
				currentCycleItemCnt += 1
				currentCycleTotal += C[v]

				v = P[v]
				if v == n:
					# サイクル発見
					cycleInfs.append( (currentCycleItemCnt, currentCycleTotal) )
					cycleID += 1
					break

				# 一応、一度サイクルを計算した頂点については、
				# その頂点の属するサイクルの情報をメモっておく。。。
				cycleIDs[v] = cycleID

		procCnt = 0
		currentCycleSumTmp = 0

		while True:

			# 頂点vにコマが置かれた時の最高スコアを計算し、
			# これまでの最高スコアを上回ったら、これまでの最高スコアを更新する
			procCnt += 1
			currentCycleSumTmp += C[v]
			if K < procCnt:
				break

			cycleLoopCnt = 0
			if procCnt < K and 0 < currentCycleTotal:
				cycleLoopCnt = ( K - procCnt ) // currentCycleItemCnt

			# print("v=", v, "currentCycleSumTmp=", currentCycleSumTmp, procCnt)
			tmp = currentCycleSumTmp + cycleLoopCnt * currentCycleTotal
			ans = max( ans, tmp )

			v = P[v]
			if v == n:
				# サイクル終了
				break

	print(ans)
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    a.sort(
    print(sum(a[n::2]))
    return


#main
if __name__ == '__main__':
    solve()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    a = LI()
    a.sort()
    print(sum(a[n::2]))
    return


#main
if __name__ == '__main__':
    solve()
a=int(input())
b=int(input())
x=[1,2,3]
x.remove(a)
x.remove(b)
return(x)

### FIXED CODE ###

x='123'
for _ in range(2): 
  x=x.replace(input(),'')
print(x)
while True:
  m, f, r = map(int, raw_input().split())
  if m == -1 and f == -1 and r == -1:
    break
  elif m == -1 or f == -1 or m + f < 30:
    print 'F'
  elif m + f >= 80:
    print 'A'
  elif m + f >= 65 and m + f < 80:
    print 'B':
  elif m + f >= 50 and m + f < 65:
    print 'C'
  elif m + f >= 30 and m + f < 50:
    if r >= 50:
      print 'C'
    else:
      print 'D'

### FIXED CODE ###

while True:
  m, f, r = map(int, raw_input().split())
  if m == -1 and f == -1 and r == -1:
    break
  if m == -1 or f == -1 or m + f < 30:
    print 'F'
  elif m + f >= 80:
    print 'A'
  elif m + f >= 65 and m + f < 80:
    print 'B'
  elif m + f >= 50 and m + f < 65:
    print 'C'
  elif m + f >= 30 and m + f < 50:
    if r >= 50:
      print 'C'
    else:
      print 'D'
import numpy as np
N=int(raw_input())
a=map(int,raw_input().split(' '))

ans=[]

if len(set(a))==1:
  p=0
else:
  p=N-1

def check(l):
  for i in range(len(l)-1):
    if l[i]>l[i+1]:
      return 0
  return 1

l=0
u=N-1
while not check(a):
  p=np.argmax(a[0:u+1])
  m=max(a[0:u+1])
  if p==u:
    u-=1
  else:
    if m>0:
      for i in range(p+1,u+1):
        ans+=[(p+1, i+1)]
        a[i]+=a[p]
    else:
      p=np.argmin(a[0:u+1])
      m=min(a[0:u+1])
      for i in range(p):
        ans+=[(p+1, i+1)]
        a[i]+=a[p]

print len(ans)
for an in ans:
  x,y=an
  print x,y

### FIXED CODE ###

N=int(raw_input())
a=map(int,raw_input().split(' '))

flg=0
if abs(max(a))>=abs(min(a)):
  m=max(a)
  flg=1
else:
  m=min(a)

for i in range(len(a)):
  if a[i]==m:
    p=i
    break

print 2*N-1
for i in range(N):
  print p+1, i+1
  a[i]+=a[p]

if flg:
  for i in range(N-1):
    print i+1, i+2
    a[i+1]+=a[i]
else:
  for i in range(N-1)[::-1]:
    print i+2, i+1
    a[i]+=a[i+1]
#print a
from scipy.special import comb

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

ans = comb(n,2,exact=True) + comb(m,2,exact=True)


### FIXED CODE ###

from math import factorial
n,m = map(int,input().split())

if n == 0:
   N = 0
elif n == 1:
    N = 0
else:
    N = factorial(n)/factorial(2)/factorial(n-2)
if m == 0:
   M = 0
elif m == 1:
    M = 0
else:
    M = factorial(m)/factorial(2)/factorial(m-2)

print(int(N+M))
k = iinput()
li= input().split()
li.sort()
sum=0
for k in range(len(li)):
  
  if k%2==0:
   
    sum=sum+li[k]
 
print(sum)

### FIXED CODE ###

k = int(input())
li= list(map(int, input().split()))
li.sort()
sum=0
for k in range(len(li)):
  
  if k%2==0:
   
    sum=sum+li[k]
 
print(sum)
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())))[a-x::]
q=sorted(list(map(int,input().split())))[b-y::]
r=sorted(list(map(int,input().split())))[::-1]
if c<x+y:
  r+=[0]*(x+y-c)
i=0
j=0
ans=0
for k in range(x+y):
  if r[k]>p[i] and i<x and p[i]<=q[j]:
    ans+=r[k]
    i+=1
  elif r[k]>q[j] and j<y:
    ans+=r[k]
    j+=1
  else:
    break
if i==x:
  p1=0
else:
  p1=sum(p[i:])
if j==y:
  q1=0
else:
  q1=sum(q[j:])
print(ans+p1+q1)

### FIXED CODE ###

x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())))[a-x::]
q=sorted(list(map(int,input().split())))[b-y::]
r=sorted(list(map(int,input().split())))[::-1]
p.append(10**9)
q.append(10**9)
if c<x+y:
  r+=[0]*(x+y-c)
i=0
j=0
ans=0
for k in range(x+y):
  if r[k]>p[i] and i<x and p[i]<=q[j]:
    ans+=r[k]
    i+=1
  elif r[k]>q[j] and j<y:
    ans+=r[k]
    j+=1
  else:
    break
if i==x:
  p1=0
else:
  p1=sum(p[i:x])
if j==y:
  q1=0
else:
  q1=sum(q[j:y])
print(ans+p1+q1)
n = int(input())
A = list(map(int, input().split())).sort(reverse=True)
B = list(map(int, input().split())).sort(reverse=True)
C = list(map(int, input().split())).sort(reverse=True)

dp_b = [0] * n
j = 0
for i in range(n):
  while j < n:
    if B[i] >= C[j]:
      dp_b[i] = j
      break
    j += 1
  if j == n:
    dp_b[i] = n

for i in range(1, n):
  dp_b[i] = dp_b[i] + dp_b[i-1]

ans = 0
j = 0
for i in range
  while j < n:
    if A[i] >= B[j]:
      if j == 0:
        break
      else:
        ans += B[j-1]
        break
    j += 1
    if j == n:
      ans += B[n-1]
  
print(ans)

### FIXED CODE ###

n = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

dp_b = [0] * n
j = 0
for i in range(n):
    while j < n:
        if B[i] >= C[j]:
            dp_b[i] = j
            break
        j += 1
    if j == n:
        dp_b[i] = n

for i in range(1, n):
    dp_b[i] = dp_b[i] + dp_b[i - 1]

ans = 0
j = 0
for i in range(n):
    while j < n:
        if A[i] >= B[j]:
            if j == 0:
                break
            else:
                ans += dp_b[j - 1]
                break
        j += 1
    if j == n:
        ans += dp_b[n - 1]

print(ans)
N, M = map(int, input().split())
A = [0] * M
B = [0] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n+1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]
    
u = UnionFind(N)
for i in range(M):
    u.union(A[i], B[i])
     
print(u.size(i))

### FIXED CODE ###

N, M = map(int, input().split())
A = [0] * M
B = [0] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * (n+1)

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]
    
u = UnionFind(N)
for i in range(M):
    u.union(A[i], B[i])
    
ans = 1
for i in range(1, N+1):
    ans = max(ans, u.size(i))
print(ans)
s = int(input())
h = s/3600
m = (s%3600)/60
s = ((s%3600)%60)
print(h+":"+m+":"+s)

### FIXED CODE ###

s = int(input())
h = int(s/3600)
m = int((s%3600)/60)
s = ((s%3600)%60)
print(str(h)+":"+str(m)+":"+str(s))
from math import log2
L=int(input())
ans=[]
i=1
while True:
    if 2**i>L:
        last=i
        break
    ans.append([i,i+1,2**(i-1)])
    ans.append([i,i+1,0])
    i+=1
"""for i in ans:
    print(i)
print(last)"""
num=2**(last-1)
a=L-num
while a>0:
    ans.append([int(log2(a))+1,last,num])
    num+=2**(int(log2(a)))
    a=L-num
for i in ans:
    print(*i)


### FIXED CODE ###

from math import log2
L=int(input())
ans=[]
i=1
while True:
    if 2**i>L:
        last=i
        break
    ans.append([i,i+1,2**(i-1)])
    ans.append([i,i+1,0])
    i+=1
"""for i in ans:
    print(i)
print(last)"""
num=2**(last-1)
a=L-num
while a>0:
    ans.append([int(log2(a))+1,last,num])
    num+=2**(int(log2(a)))
    a=L-num
print(last,len(ans))
for i in ans:
    print(*i)
S = input()
max_count = 0
counter = 0
for i in S:
  if i == 'S':
    if max_counter < counter:
      max_count = counter
      counter = 0
  elif i == 'R':
    counter += 1

if max_counter < counter:
  max_count = counter

print(max_counter)


### FIXED CODE ###

S = input()
max_count = 0
counter = 0
for i in S:
  if i == 'S':
    if max_count < counter:
      max_count = counter
      counter = 0
  elif i == 'R':
    counter += 1

if max_count < counter:
  max_count = counter

print(max_count)
import sys
N, M = map(int, input().split())
xrd = [[] for i in range(N)]
x = [None]*N


def check(s):
    for t, d in xrd[i]:
        if x[t] is None:
            x[t] = x[s] + d
            check(t)
        else:
            if x[t] != x[s] + d:
                print("No")
                sys.exit()


for i in range(M):
    L, R, D = map(int, input().split())
    xrd[L-1].append([R-1, D])
    xrd[R-1].append([L-1, -D])

for i in range(N):
    if x[i] is None:
        x[i] == 0
        check(i)


print("Yes")


### FIXED CODE ###

import sys
sys.setrecursionlimit(200002)

N, M = map(int, input().split())
G = [[] for _ in range(N)]
x = [None] * N

def fail():
    print("No")
    exit()

def dfs(s):
    global x, G
    for t, d in G[s]:
        if x[t] is None:
            x[t] = x[s] + d
            dfs(t)
        else:
            if x[t] != x[s] + d:
                fail()

for _ in range(M):
    L, R, D = map(int, input().split())
    G[L-1].append([R-1,  D])
    G[R-1].append([L-1, -D])

for i in range(N):
    if x[i] is None:
        x[i] = 0
        dfs(i)

print("Yes")
a,b=map(int,raw_input().split())
if  a > b:
print 'a > b'
elif  a < b:
print 'a < b'
else:
print 'a == b'

### FIXED CODE ###

a,b=map(int,raw_input().split())
if a > b:
    print 'a > b'
elif a < b:
    print 'a < b'
else:
    print 'a == b'
A, B, C = map(int, input().split())
list = [A, B, C]
ans = list(set(list))
if len(ans) == 2:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

A, B, C = map(int, input().split())
l = [A, B, C]
ans = list(set(l))
if len(ans) == 2:
    print('Yes')
else:
    print('No')
N = int(input())
B = list(map(int,input().split()))
B_copy = B.copy

def func(B,i,C):
    if(C[0:i].count(True) + 1 == B[i]):
        print(B[i])
        C[i] = True
        next = -1
        for j in range(N-1,-1,-1):
            if C[j] == False:
                next = j
                break
        if next == -1:
            return
        func(B,next,C)
    else:
        next = -1
        for j in range(i-1,-1,-1):
            if C[j] == False:
                next = j
                break
        func(B,next,C)

flag = 0
for i in range(N):
    if B[i] > i + 1:
        flag = -1
        break

if(flag == -1):
    print(-1)
else:
    C = [False] * N
    func(B,N-1,C)
        



### FIXED CODE ###

N = int(input())
b = list(map(int,input().split()))
tmp = b[:]
ans = []
i = N-1
while i >= 0:
    if tmp[i] == 1:
        tmp[i] = float('inf')
        ans.append(b[i])
        while i < N:
            tmp[i] -= 1
            i += 1
    i -= 1
if len(ans) == N:
    for i in ans:
        print(i)
else:
    print(-1)
S = list(input())
for i in range(len(S)):
  if i % 2 == 0:
   	if S[i] == ("R" or "U" or "D"):
      continue
   	else:
      print("No")
      exit()
  else:
    if S[i] == ("L" or "U" or "D"):
      continue
    else:
      print("No")
      exit()
print("Yes")


### FIXED CODE ###

s = input()
if s == "Sunny":
  print("Cloudy")
elif s == "Cloudy":
  print("Rainy")
else:
  print("Sunny")
a,b,c = input().split(,)
print(a+" "+b+" "+c)

### FIXED CODE ###

a,b,c = input().split(",")
print(a+" "+b+" "+c)
A = list(map(int,input().split()))
N = len(A)
c = 1
for i in N:
  c *= A[i]
print(c)
if c >= 10**18:
  print(-1)


### FIXED CODE ###

n=int(input())
ls=[int(s) for s in input().split(" ")]

if 0 in ls:
  print(0)
else:
  num=1
  for i in ls:
    num*=i
    if num>10**18:
      num=-1
      break

  print(num)
import numpy as np

n,m=map(int,input().split())
road=[list(map(int,input().split())) for i in range(m)]
road.sort()
ans=np.unique(road,return_counts=True)
for i in range(n):
    print(ans[1][i])


### FIXED CODE ###

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

c=[flatten for inner in road for flatten in inner]

for i in range(1,n+1):
    print(c.count(i))
A = int(input()) #¥500
B = int(input()) #¥100
C = int(input()) #¥50
X = int(input())
count = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      if (X == a*500 + b*100 + c*50):
        count += 1
print(count)

### FIXED CODE ###

X = int(input())
A = int(input())
B = int(input())

print((X-A) % B)
N, A, B= int(input()), int(input()), int(input())
train = A * N
if train <= B:
    print(train)
else:
    print(B)

### FIXED CODE ###

get = input().split()
N = int(get[0])
A = int(get[1])
B = int(get[2])
train = A * N
if train <= B:
    print(train)
else:
    print(B)
a,b = map(int, raw_input().split)
d = a / b
r = a % b
f = float(a) / float(b)
print " ".join(d, r, f)

### FIXED CODE ###

a,b = map(int, raw_input().split())
d = a / b
r = a % b
f = float(a) / float(b)
print " ".join([str(d), str(r), str('%.5f' % f)])
import numpy as np

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

can_ride = h_i[h_i>=K]
print(len(can_ride))

### FIXED CODE ###

import numpy as np
 
N, K = map(int, input().split())
h_i = list(map(int, input().split()))
h_i = np.array(h_i)
can_ride = h_i[h_i>=K]
print(len(can_ride))
x = int(input())
a = x[0]
b = x[1]
c = x[2]
d = x[3]
if a + b + c + d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d))
elif a + b + c - d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d))
elif a + b - c + d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d))
elif a + b - c - d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d))
elif a - b + c + d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d))
elif a - b + c - d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d))
elif a - b - c + d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d))
elif a - b - c - d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d))

### FIXED CODE ###

x = input()
a = int(x[0])
b = int(x[1])
c = int(x[2])
d = int(x[3])
if a + b + c + d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a + b + c - d == 7:
  print(str(a) + "+" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a + b - c + d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a + b - c - d == 7:
  print(str(a) + "+" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
elif a - b + c + d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "+" + str(d) + "=7")
elif a - b + c - d == 7:
  print(str(a) + "-" + str(b) + "+" + str(c) + "-" + str(d) + "=7")
elif a - b - c + d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "+" + str(d) + "=7")
elif a - b - c - d == 7:
  print(str(a) + "-" + str(b) + "-" + str(c) + "-" + str(d) + "=7")
import numpy as np

@njit
def main():
    R, C, K = map(int, input().split())
    scores = np.zeros((R,C), np.int64)
    for _ in range(K):
        r, c, v = map(int, input().split())
        scores[r-1][c-1] = v
    dp=np.zeros((R+1,C+1,4), np.int64)

    for i in range(1, R+1):
        for j in range(1, C+1):
            for k in range(4):
                dp[i][j][k] = max(dp[i][j-1][k],
                                dp[i-1][j][3])
            for k in range(3, 0, -1):
                dp[i][j][k] = max(dp[i][j][k],
                                  dp[i][j][k-1] + scores[i-1][j-1])

    answer = dp[R][C][3]
    print(answer)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from numba import jit
import numpy as np

@jit
def main():
    R, C, K = map(int, input().split())
    scores = np.zeros((R,C), np.int64)
    for _ in range(K):
        r, c, v = map(int, input().split())
        scores[r-1][c-1] = v
    dp=np.zeros((R+1,C+1,4), np.int64)

    for i in range(1, R+1):
        for j in range(1, C+1):
            for k in range(4):
                dp[i][j][k] = max(dp[i][j-1][k],
                                dp[i-1][j][3])
            for k in range(3, 0, -1):
                dp[i][j][k] = max(dp[i][j][k],
                                  dp[i][j][k-1] + scores[i-1][j-1])

    
    return dp[R][C][3]

print(main())
def checkABC(S):
    count = 0
    for i in range(len(S)):
        if S[i] == 'A':
            if S[i+1] == 'B':
                if S[i+2] == 'C':
                    count += 1
    
    return count


N = int(input())

S = list(input())

print(checkABC(S))

### FIXED CODE ###

def checkABC(S):
    count = 0
    for i in range(len(S)):
        if S[i] == 'A':
            if i+1 < len(S) and S[i+1] == 'B':
                if i+2 < len(S) and S[i+2] == 'C':
                    count += 1
    
    return count


N = int(input())

S = list(input())

print(checkABC(S))
import collections
from math import factorial

N = int(input())
S = [0]*N
for i in range(N):
    s = list(str(input()))
    s.sort()
    S[i] = "".join(s)
print(S)

c = collections.Counter(S)
cnt = 0
r = 2
for n in c.values():
    if n >= 2:
        cnt += factorial(n) / factorial(r) / factorial(n - r)
print(int(cnt))


### FIXED CODE ###

import collections
from math import factorial

N = int(input())
S = [0]*N
for i in range(N):
    s = list(str(input()))
    s.sort()
    S[i] = "".join(s)

c = collections.Counter(S)
cnt = 0
r = 2

for n in c.values():
    if n >= 2:
        a = factorial(n)
        b = factorial(r)*factorial(n - r)
        cnt += a/b
print(int(cnt))