Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.buffer.readline
 
def main():
    a,b,c,d = map(int,input().split())
    MOD = 10**9+7
    P= c+d+5
    fac = [0 for _ in range(P+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,P+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    def comb(x,y):
        return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)
    
if _name_ == "_main_":
    main()


### FIXED CODE ###

import sys
import math
input = sys.stdin.buffer.readline
 
def main():
    a,b,c,d = map(int,input().split())
    MOD = 10**9+7
    N = c+d+5
    fac = [0 for _ in range(N+1)]
    fac[0],fac[1] = 1,1
 
    for i in range(2,N+1):
        fac[i] = (fac[i-1]*i)%MOD
        
    def comb(x,y):
        return (fac[x+y]*pow(fac[x],MOD-2,MOD)*pow(fac[y],MOD-2,MOD))%MOD
 
    print((comb(c+1,d+1)-comb(c+1,b)-comb(d+1,a)+comb(a,b))%MOD)
    
if __name__ == "__main__":
    main()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import re
import math
import collections
import itertools
import functools

def dbg(*args):
    print("DBG: ", file=sys.stderr, end="")
    print(*args, file=sys.stderr)

Mat = collections.namedtuple("Mat", "r c")

def mat_mul(ms):
    return Mat(ms[0].r, ms[-1].c)

def cost(m1, m2):
    return m1.r * m1.c * m2.c

def solve(n, ms):
    if n == 1: return 0

    dp = {}
    for i in range(n):
        dp[(i,i)] = 0

    for l in range(2, n+1):
        for i in range(n-l+1):
            #cost_min = math.inf
            cost_min = float("inf")
            for j in range(l-1):
                dbg("l, i, j: %d %d %d", l, i, j)
                m_lhs = mat_mul(ms[i:i+j+1])
                m_rhs = mat_mul(ms[i+j+1:i+l])
                #dbg("m_lhs, m_rhs: %r %r", m_lhs, m_rhs)
                cost_lhs = dp[(i,i+j)]
                cost_rhs = dp[(i+j+1,i+l-1)]
                #dbg("cost_lhs, cost_rhs: %d %d", cost_lhs, cost_rhs)
                cost_mul = cost(m_lhs, m_rhs)
                #dbg("cost_mul: %d", cost_mul)
                cost_now = cost_mul + cost_lhs + cost_rhs
                #dbg("cost_now: %d", cost_now)
                if cost_min > cost_now:
                    cost_min = cost_now
            dp[(i,i+l-1)] = cost_min

    #dbg(dp)
    return dp[(0,n-1)]

def main():
    n = int(input())

    ms = []
    for _ in range(n):
        r,c = map(int, input().split())
        ms.append(Mat(r,c))

    print(solve(n, ms))

if __name__ == "__main__": main()

### FIXED CODE ###

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

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)

Mat = collections.namedtuple("Mat", "r c")

def mat_mul(ms):
    return Mat(ms[0].r, ms[-1].c)

def cost(m1, m2):
    return m1.r * m1.c * m2.c

def solve(n, ms):
    if n == 1: return 0

    dp = {}
    for i in range(n):
        dp[(i,i)] = 0

    for l in range(2, n+1):
        for i in range(n-l+1):
            #cost_min = math.inf
            cost_min = float("inf")
            for j in range(l-1):
                dbg("l, i, j: %d %d %d", l, i, j)
                m_lhs = mat_mul(ms[i:i+j+1])
                m_rhs = mat_mul(ms[i+j+1:i+l])
                dbg("m_lhs, m_rhs: %r %r", m_lhs, m_rhs)
                cost_lhs = dp[(i,i+j)]
                cost_rhs = dp[(i+j+1,i+l-1)]
                dbg("cost_lhs, cost_rhs: %d %d", cost_lhs, cost_rhs)
                cost_mul = cost(m_lhs, m_rhs)
                dbg("cost_mul: %d", cost_mul)
                cost_now = cost_mul + cost_lhs + cost_rhs
                dbg("cost_now: %d", cost_now)
                if cost_min > cost_now:
                    cost_min = cost_now
            dp[(i,i+l-1)] = cost_min

    dbg(dp)
    return dp[(0,n-1)]

def main():
    n = int(input())

    ms = []
    for _ in range(n):
        r,c = map(int, input().split())
        ms.append(Mat(r,c))

    print(solve(n, ms))

if __name__ == "__main__": main()
x, y, z, k = [ int(v) for v in input().split() ]
a_list = sorted([ -int(v) for v in input().split() ], reverse = True )
b_list = sorted([ -int(v) for v in input().split() ], reverse = True )
c_list = sorted([ -int(v) for v in input().split() ], reverse = True )


def most_dericious(a,b,c):
	return a_list[a] + b_list[b] + c_list[c]
out_cakes_list= []
for i in range(k):
	if i == 0:
		dericious_heap = [ (most_dericious(x-1,y-1,z-1),(x-1,y-1,z-1)) ]
		heapq.heapify(dericious_heap)
	out_cakes = (heapq.heappop(dericious_heap))
	p, q, r = out_cakes[1][0], out_cakes[1][1], out_cakes[1][2]

	if p-1 >= 0 and (most_dericious(p-1,q,r),(p-1,q,r)) not in dericious_heap:
		heapq.heappush(dericious_heap,(most_dericious(p-1,q,r),(p-1,q,r)))
	if q-1 >= 0 and (most_dericious(p,q-1,r),(p,q-1,r)) not in dericious_heap:
		heapq.heappush(dericious_heap,(most_dericious(p,q-1,r),(p,q-1,r)))
	if r-1 >= 0 and (most_dericious(p,q,r-1),(p,q,r-1)) not in dericious_heap:
		heapq.heappush(dericious_heap,(most_dericious(p,q,r-1),(p,q,r-1)))
	out_cakes_list.append(out_cakes)

out_cakes_list = sorted(out_cakes_list)
for i in range(k):
	print(-out_cakes_list[i][0])

### FIXED CODE ###


import heapq
x, y, z, k = [ int(v) for v in input().split() ]
x_list = sorted([ int(v) for v in input().split() ], reverse = True)
y_list = sorted([ int(v) for v in input().split() ], reverse = True)
z_list = sorted([ int(v) for v in input().split() ], reverse = True)

cake_list = []
num_set = set([0])

def hash2(a,b,c):
    return 10**8*a+10**4*b+c


def maling_cake(a,b,c):
    d = x_list[a]+y_list[b]+z_list[c]
    return (-d,a,b,c)

for i in range(k):
    if i == 0:
        print(-maling_cake(0,0,0)[0])
        if x > 1: 
            heapq.heappush(cake_list, maling_cake(1,0,0))
            num_set.add(hash2(1,0,0))
        if y > 1: 
            heapq.heappush(cake_list, maling_cake(0,1,0))
            num_set.add(hash2(0,1,0))
        if z > 1: 
            heapq.heappush(cake_list, maling_cake(0,0,1))
            num_set.add(hash2(0,0,1))
        
    else:
        di, ai, bi, ci = heapq.heappop(cake_list)
        if ai < x - 1:
            if hash2(ai+1,bi,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai+1,bi,ci))
                num_set.add(hash2(ai+1,bi,ci))
        if bi < y - 1:
            if hash2(ai,bi+1,ci) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi+1,ci))
                num_set.add(hash2(ai,bi+1,ci))
        if ci < z - 1:
            if hash2(ai,bi,ci+1) not in num_set:
                heapq.heappush(cake_list, maling_cake(ai,bi,ci+1))
                num_set.add(hash2(ai,bi,ci+1))
        print(-di)
"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = readline().decode('utf8').rstrip()
lis = list(S)
print(lis)
if lis[0] == 'A' and 2 <= lis.index('C') <= len(lis) - 1:
    st = ''.join(lis[1:lis.index('C')] + lis[lis.index('C') + 1:])
    print(st)
    if st.lower():
        print('AC')
    else:
        print('WA')

else:
    print('WA')


### FIXED CODE ###

"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = list(readline().decode('utf8').rstrip())
bl = S[0] == 'A'
bl &= ('C' in S[2:-1])

if bl:
    S.remove('A')
    S.remove('C')

bl &= all('a' <= x <= 'z' for x in S)

print('AC' if bl else 'WA')
N = input()
d = dict()
for x in map(int, input().split())
	if d.get(x) is None:
    	d[x] = 0
	d[x] += 1

print(sum((min(d[x], abs(d[x]-x) for x in d))))


### FIXED CODE ###

N = input()
d = dict()
for x in map(int, input().split()):
  if d.get(x) is None:
    d[x] = 0
  d[x] += 1

print(sum((d[x]-x if d[x]>=x else d[x]) for x in d))
a,b = map(int(input().split())
if a>b
   print(a+'<'+b)
if a<b
   print(a+'>'+b)
else
   print(a+'='+b)


### FIXED CODE ###

a,b = map(int,input().split())
if a>b:
   c = '>'
elif a<b:
   c = '<'
else:
   c = '=='
print('a',c,'b')
import math
s1, s2 = input().split()
s1 += s2
a = int(s1)
if floor(math.sqrt(a)) * floor(math.sqrt(a)) == a:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import math
s1, s2 = input().split()
s1 += s2
a = int(s1)
if math.floor(math.sqrt(a)) * math.floor(math.sqrt(a)) == a:
  print("Yes")
else:
  print("No")
N, M, K = map(int,input().split())
tree = [-1 for i in range(N)]
fc = [0 for i in range(N)]
bc = [0 for i in range(N)]
ans = ""

def find(x):
    # x を引数に取り、xのroot番号を取得するメモ化再帰
    if tree[x] < 0:
        return x
    tree[x] = find(tree[x])
    return tree[x]

def unite(x, y):
    # x, y を引数に取り、x(自分)をy(相手)のrootに接続する関数
    rootx = find(x)
    rooty = find(y)
    if rootx == rooty:
        return
    if rootx < rooty:
        x , y = y, x
    tree[rooty] += tree[rootx]
    tree[rootx] = rooty
    return

for i in range(M):
    a, b = map(int,input().split())
    fc[a-1] += 1
    fc[b-1] += 1
    unite(a-1, b-1)

for i in range(K):
    c, d = map(int,input().split())
    if find(c-1) == find(d-1):
        bc[c-1] += 1
        bc[d-1] += 1

for i in range(N):
    cnt = -tree[find(i)] - 1 - fc[i] - bc[i]
    ans += str(cnt)

print(' '.join(ans))

### FIXED CODE ###

N, M, K = map(int,input().split())
uf = [-1 for _ in range(N)]
fc = [0] * N
bc = [0] * N
ans = [0] * N

def find(x):
    # x を引数に取り、xのroot番号を取得するメモ化再帰
    if uf[x] < 0:
        return x
    uf[x] = find(uf[x])
    return uf[x]

def unite(x, y):
    # x, y を引数に取り、x(自分)をy(相手)のrootに接続する関数
    x = find(x)
    y = find(y)
    if x == y:
        return
    if x < y:
        x , y = y, x
    uf[y] += uf[x]
    uf[x] = y

for m in range(M):
    a, b = map(int,input().split())
    fc[a-1] += 1
    fc[b-1] += 1
    unite(a-1, b-1)

for k in range(K):
    c, d = map(int,input().split())
    if find(c-1) == find(d-1):
        bc[c-1] += 1
        bc[d-1] += 1

for i in range(N):
    cnt = -uf[find(i)] - 1 - fc[i] - bc[i]
    ans[i] = cnt

print(*ans)
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

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

lcm_num = lcm(N,M)

X_s = ["" for i in range(lcm_num)]
X_t = ["" for i in range(lcm_num)]

# print(X_s,X_t)

for i in range(N):
    tmp = i*lcm_num // N + 1
    X_s[tmp-1] = S[i]


for i in range(M):
    tmp = i*lcm_num // M + 1
    X_t[tmp-1] = T[i]

# print(X_s,X_t)

for s,t in zip(X_s,X_t):
    if s == "" or t == "" :
        continue
    elif s == t:
        continue
    else:
        print(-1)
        exit()

print(lcm_num)


### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

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

lcm_num = lcm(N,M)
lN = lcm_num // N
lM = lcm_num // M
gcd_num = lN * lM

for i in range(0,lcm_num,gcd_num):
    if S[i//lN] == T[i//lM]:
        continue
    else:
        print(-1)
        exit()

print(lcm_num)
a, b, c = input().split()

if a < b and b < c:
  print 'No'

if a < c and c < b:
  print('Yes')

if b < c and c < a:
  print('Yes')

if b < a and a < c:
  print('No')
  
if c < a and a < b:
  print('Yes')
  
if c < b and b < a:
  print('No')

### FIXED CODE ###

a, b, c = input().split()
if (int(a) < int(c) and int(c) < int(b)) or (int(b) < int(c) and int(c) < int(a)):
  print('Yes')
else:
  print('No')
N = int(input())
A = list(map(int,input().split()))
if A[0] == 0 or A[N-1] == 0:
  A_tmp = A[0]
  A_ = A[1:N]
  A_.append(A_tmp)
  A = A_
  flag = 1
else:
  flag = 0
if A[0]<A[N-1]:
  start = A[0]
else:
  start = A[N-1]
for i in range(2*start,1,-2):
  ans = [i]
  A_tmp = A[:]
  A_tmp[0] -= ans[0]//2
  A_tmp[N-1] -= ans[0]//2 
  for j in range(1,N):
    if A_tmp[j-1]<A_tmp[j]:
      ans.append(A_tmp[j-1]*2)
      A_tmp[j] -= ans[j]//2
      A_tmp[j-1] -= ans[j]//2
    else:
      ans.append(A_tmp[j]*2)
      A_tmp[j] -= ans[j]//2
      A_tmp[j-1] -= ans[j]//2
  if sum(A_tmp)==0:
    break
if flag == 1:
  tmp = [0]*N
  tmp[1:] = ans[:N-1]
  tmp[0] = ans[N-1]
  ans = tmp
ans = map(str,ans)
print(' '.join(ans))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
S = sum(A)//2
S = 2*(S - sum(A[1::2]))
ans = [S]
for i in range(1,N):
  ans.append(2*A[i-1]-ans[i-1])
print(' '.join(map(str,ans)))
import math
N = int(input())
A_array = list(map(int, input().split()))

A_array.sort()

use_array = [0] * A_array[-1]

ans = 0

for i in range(N):
    if i != 0:
        if A_array[i] == A_array[i - 1]:
            use_array[a - 1] = 1
            continue
    if i != N - 1:
        if A_array[i] == A_array[i + 1]:
            use_array[a - 1] = 1
            continue
    a = A_array[i]
    for j in range(1, int(math.sqrt(a)) + 1):
        if a % j == 0:
            if use_array[j - 1] == 1 or use_array[a // j - 1] == 1:
                break
    else:
        ans += 1
    use_array[a - 1] = 1

print(ans)


### FIXED CODE ###

import math
N = int(input())
A_array = list(map(int, input().split()))

A_array.sort()

ans = 0

if A_array[0] == 1:
    if N >= 2 and A_array[1] != 1 or N == 1:
        print(1)
    else:
        print(0)
    exit()


ng_array = [0] * (10 ** 6)


for i, a in enumerate(A_array):
    if i != 0 and a == A_array[i - 1]:
        continue
    j = 2
    while a * j <= 10 ** 6:
        ng_array[a * j - 1] = 1
        j += 1


for i in range(N):
    a = A_array[i]
    if i != 0:
        if A_array[i] == A_array[i - 1]:
            continue
    if i != N - 1:
        if A_array[i] == A_array[i + 1]:
            continue
    if ng_array[a-1] == 0:
        ans += 1
print(ans)
a = int(input())
b = int(input())
c = [i for i in range(1,4)]
for j in range(1,4):
    if c[j] != a and c[j] != b:
        print(int(c[j]))


### FIXED CODE ###

a = int(input())
b = int(input())
c = [i for i in range(1,4)]
for j in range(0,len(c)):
    if c[j] != a and c[j] != b:
        print(int(c[j]))
m = int(input()) // 2
a = sorted(map(int, input().split()))
print(a[n] - a[m - 1])


### FIXED CODE ###

n = int(input())
a = sorted(map(int, input().split()))
print(a[n // 2] - a[n // 2 - 1])
import math
n = int(input())
r = [None] * n
min = math.inf
max = -math.inf
for i in range(n):
    r[i] = int(input())

for i in range(n):
    if min > r[i]:
        min = r[i]
        for j in range(i+1,n):
            if max < r[j] - min:
                max = r[j] - min
print(max)

### FIXED CODE ###

n = int(input())
minv = int(input())
maxv = (10**9)*(-1)
for j in range(1,n):
    r = int(input())
    if maxv < (r - minv):
        maxv = r - minv
    if minv > r:
        minv = r
print(maxv)
def main(s):
    isEven = int(len(s)%2)
    ran = (len(s)-1)/2 if isEven else (len(s)/2)
    count = 0
    for i in range(ran):
        if s[i] != s[-(i+1)]:
            count += 1
    return count

s = input()
print(main(s))

### FIXED CODE ###

def main(s):
    isEven = int(len(s)%2)
    ran = int((len(s)-1)/2 if isEven else (len(s)/2))
    count = 0
    for i in range(ran):
        if s[i] != s[-(i+1)]:
            count += 1
    return count

s = input()
print(main(s))
a, b = input().split()

if a > b * 2:
  ret = a - b * 2
else:
  ret = 0
  
print(ret)



### FIXED CODE ###

x = input().split()
 
a = int(x[0])
b = int(x[1])
 
if a > b * 2:
  ret = a - b * 2
else:
  ret = 0
  
print(ret)
print(sys.argv[0] ** 3)

### FIXED CODE ###

# -*- coding:UTF-8 -*-
print(int(input()) ** 3)
import math
a, b, x = list(map(float, input().split()))

# %%
# a, b, x = [3, 1, 8]
if x/a > a*b/2:
    # 台形
    y = 2*x/(a**2) - b
    # print(90-math.degrees(math.atan(   (a/(b-y))  )))
    print(90-math.degrees(math.atan2(a, b-y)))
else:
    # 三角形
    # print(90-math.degrees(math.atan( (2*x/(a*b)) / b  )))
    print(90-math.degrees(math.atan2(2*x/(a*b), 

### FIXED CODE ###

import math
a, b, x = list(map(float, input().split()))

# %%
# a, b, x = [3, 1, 8]
if x/a > a*b/2:
    # 台形
    y = 2*x/(a**2) - b
    # print(90-math.degrees(math.atan(   (a/(b-y))  )))
    print(90-math.degrees(math.atan2(a, b-y)))
else:
    # 三角形
    # print(90-math.degrees(math.atan( (2*x/(a*b)) / b  )))
    print(90-math.degrees(math.atan2(2*x/(a*b), b)))
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if (a+v*t)>=(b+w*t) and (b-a)%(v-w)==0:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

if v<=w:
    print('NO')
elif a<b:
    if (a+v*t)>=(b+w*t):
        print('YES')
    else:
        print('NO')
else:
    if (a-v*t)<=(b-w*t):
        print('YES')
    else:
        print('NO')
n=int(input())
lst=list(map(int,input().strip().split()))[:n]
print(findnumberofTriangles(lst))
count=0 
for i in range(0,n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if(lst[i]!=lst[j] and lst[j]!=lst[k] and lst[k]!=lst[i]):
                if (lst[i] +lst[j] > lst[k] and 
                    lst[i] + lst[k] > lst[j] and 
                    lst[k] + lst[j] > lst[i]): 
                    count += 1
print(count)

### FIXED CODE ###

n=int(input())
lst=list(map(int,input().strip().split()))[:n]
count=0 
for i in range(0,n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if(lst[i]!=lst[j] and lst[j]!=lst[k] and lst[k]!=lst[i]):
                if (lst[i] +lst[j] > lst[k] and 
                    lst[i] + lst[k] > lst[j] and 
                    lst[k] + lst[j] > lst[i]): 
                    count += 1
print(count)
a,b = int(input())


if a<10 and b<10:
    print(a*b)
else:
    print(-1)

### FIXED CODE ###

a,b = map(int, input().split())

if a<10 and b<10:
    print(a*b)
else:
    print(-1)
# -*- coding: utf-8 -*-
from decimal import *

a, b, c = map(int, input().split())

a = Decimal(a)
b = Decimal(b)
c = Decimal(c)

if a**(1/2) + b**(1/2) < c**(1/2):
    print("Yes")

else:
    print("No")

### FIXED CODE ###

# -*- coding: utf-8 -*-

K=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

a = int(input())

num = a-1
print(K[num])
rgb=list(map(int,input().split()))
rgb.sorted()
X=int(join(rgb))
ans = "Yes" if X%4==0 else "No"
print(ans)

### FIXED CODE ###

r,g,b=map(str,input().split())
X=int(r+g+b)
ans = "YES" if X%4==0 else "NO"
print(ans)
# -*- coding: utf-8 -*-
A,B,C,D = list(map(int, list(input())))

if A+B+C+D == 7:
    print(A+'+'+B+'+'+C+'+'+D+'=7')
elif A+B+C-D == 7:
    print(A+'+'+B+'+'+C+'-'+D+'=7')
elif A+B-C+D == 7:
    print(A+'+'+B+'-'+C+'+'+D+'=7')
elif A+B-C-D == 7:
    print(A+'+'+B+'-'+C+'-'+D+'=7')
elif A-B+C+D == 7:
    print(A+'-'+B+'+'+C+'+'+D+'=7')
elif A-B+C-D == 7:
    print(A+'-'+B+'+'+C+'-'+D+'=7')
elif A-B-C+D == 7:
    print(A+'-'+B+'-'+C+'+'+D+'=7')
elif A-B-C-D == 7:
    print(A+'-'+B+'-'+C+'-'+D+'=7')



### FIXED CODE ###

# -*- coding: utf-8 -*-
A,B,C,D = list(map(int, list(input())))

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')
def conv(s):
  return ord(s) - 97

n = int(input())

ls = []
for i in range(n):
    ls.append(input())

lss = []
for i in range(n):
    ll = [0] * 25
    lss.append(ll)

for i in range(n):
    for j in range(10):
        lss[i][conv(ls[i][j])]+=1

ans = 0
for i in range(n):
    for j in range(n-i-1):
        if lss[i] == lss[i+j+1]:
            ans+=1
print(ans)

### FIXED CODE ###

def sum_list(i):
    return int((i*(i+1))/2)

n = int(input())
ls = []
for i in range(n):
    ls.append(''.join(sorted(input())))

ls.sort()
ans = 0
count = 0

for i in range(len(ls)):
    if (ls[i] == ls[i+1]):
        count += 1
    else:
        ans += sum_list(count)
        count = 0
    if (i == n-2):
      ans += sum_list(count)
      break

print(ans)
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
dic = {}
for i in range(1, n+1):
  dic[i] = [p[i-1], c[i-1]]
INF = 10**20
ans = -INF
for j in range(1, n+1):
  state = [True] * 5001
  max_score = -INF
  max_idx = 0
  score = 0
  now = dic[j][0]
  cnt = 0
  lst = []
  flg = True
  for _ in range(k):
    if not state[now]:
      flg = False
      break
    score += dic[now][1]
    cnt += 1
    if max_score < score:
      max_score = score
      max_idx = cnt
    lst.append(score)
    state[now] = False
    now = dic[now][0]
  if score <= 0 or flg:
    ans = max(max_score, ans)
  else:
    q = k // cnt
    r = k % cnt
    if r >= max_idx:
      x = score * q + max_score
      ans = max(ans, x)
    else:
      if q >= 1:
        x = score * (q - 1) + max_score
        y = score * q + max(lst[:r])
        ans = max(ans, x, y)
      else:
        ans = max(ans, max_score)
print(ans)
    


### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
dic = {}
for i in range(1, n+1):
  dic[i] = [p[i-1], c[i-1]]
INF = 10**20
ans = -INF
for j in range(1, n+1):
  state = [True] * 5001
  max_score = -INF
  max_idx = 0
  score = 0
  now = dic[j][0]
  cnt = 0
  lst = []
  flg = True
  for _ in range(k):
    if not state[now]:
      flg = False
      break
    score += dic[now][1]
    cnt += 1
    if max_score < score:
      max_score = score
      max_idx = cnt
    lst.append(score)
    state[now] = False
    now = dic[now][0]
  if score <= 0 or flg:
    ans = max(max_score, ans)
  else:
    q = k // cnt
    r = k % cnt
    if r >= max_idx:
      x = score * q + max_score
      ans = max(ans, x)
    else:
      if q >= 1:
        if r == 0:
          x = score * (q - 1) + max_score
          ans = max(ans, x)
        else:
          x = score * (q - 1) + max_score
          y = score * q + max(lst[:r])
          ans = max(ans, x, y)
      else:
        ans = max(ans, max_score)
print(ans)
m = map(int,raw_input().split())
for i in range(len(m)+1):
 if(m[i-1]==0):
  break
 print"Case %d* %d",%(i,m[i-1])

### FIXED CODE ###

i=0

while True:
    a = int(input())
    if(a==0):
      break
    i = i+1
    print "Case %d: %d" %  (i,a)
n=int(input())
if n%2:
  a=list(map(int,input().split()))
  s=[[a[0],0,0],[0,a[1],0],[a[0]+a[2],0,a[2]],[0,max([a[0]+a[3],a[1]+a[3]]),0]]+[[0,0,0]for i in range(4,n)]
  for i in range(4,n):
    if i%2:
      s[i][1]=max(s[i-2][1],s[i-3][0])+a[i]
    else:
      s[i][0]=s[i-2][0]+a[i]
      s[i][2]=max([s[i-2][2],s[i-3][1],s[i-4][0]])+a[i]
  print(max([s[-1][2],s[-2][1],s[-3][0]]))
else:
  a=list(map(int,input().split()))
  s=[a[0],a[1]]+[0 for i in range(2,n)]
  for i in range(2,n):
    if i%2:
      s[i]=max([s[i-2],s[i-3]])+a[i]
    else:
      s[i]=s[i-2]+a[i]
  print(max(s[-2:]))

### FIXED CODE ###

n=int(input())
if n%2:
  a=list(map(int,input().split()))
  s=[[a[0],0,0],[0,a[1],0],[a[0]+a[2],0,a[2]]]+[[0,0,0]for i in range(3,n)]
  for i in range(3,n):
    if i%2:
      s[i][1]=max(s[i-2][1],s[i-3][0])+a[i]
    else:
      s[i][0]=s[i-2][0]+a[i]
      s[i][2]=max([s[i-2][2],s[i-3][1],s[i-4][0]])+a[i]
  print(max([s[-1][2],s[-2][1],s[-3][0]]))
else:
  a=list(map(int,input().split()))
  s=[a[0],a[1]]+[0 for i in range(2,n)]
  for i in range(2,n):
    if i%2:
      s[i]=max([s[i-2],s[i-3]])+a[i]
    else:
      s[i]=s[i-2]+a[i]
  print(max(s[-2:]))