Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

r,g,b,n=map(int,input().split())
tmp=0
A=0
B=0
for i in range(3001):
    if(r*i>3001):break
    for j in range(3001):
        A=r*i+g*j
        B=n-A
        if(A>3001|B<0):break
        if(((B%b)==0)&((B/b)<3001)):
            tmp+=1
print(tmp)

### FIXED CODE ###

R, G, B, N = map(int, input().split())
 
ans = 0
for r in range(N//R + 1):
    for g in range((N - (R*r))//G + 1):
        if(N - (R*r) - (G*g)) % B == 0:
            ans += 1
print(ans)
### BUGGY CODE ###

n = int(input())
ary = list(map(int,input().split()))
a = sorted(ary)
c = (len(ary)+1)//2-1
for i in range(n):
    b = a.copy()
    b.remove(ary[i])
    print(b[c])

### FIXED CODE ###

n = int(input())
ary = list(map(int,input().split()))
a = sorted(ary)
b = (len(ary)+1)//2-1
for i in range(n):
    if a[b] < ary[i]:
        print(a[b])
    elif a[b] == ary[i]:
        print(a[b+1])
    elif a[b] > ary[i]:
        print(a[b+1])
### BUGGY CODE ###

H, W = map(int, input().split())
state = [[0 if a == '.' else 1 for a in list(input())] for _ in range(H)]

checked = [[False for _ in range(W)] for _ in range(H)]
qs = []
for h in range(H):
    for w in range(W):
        if state[h][w] == 1:
            checked[h][w] = True
            qs.append((h, w))

Next = [[[] for _ in range(W)] for _ in range(H)]
for h in range(H):
    for w in range(W):
        if h != 0:
            Next[h][w].append((h-1, w))
        if h != H-1:
            Next[h][w].append((h+1, w))
        if w != 0:
            Next[h][w].append((h, w-1))
        if w != W-1:
            Next[h][w].append((h, w+1))

c = -1
while qs:
    qqs = []
    for h, w in qs:
        for nh, nw in Next[h][w]:
            if not checked[nh][nw]:
                qqs.append((nh, nw))
                checked[nh][nw] = True
    qs = qqs
    c += 1
print(c)

### FIXED CODE ###

import sys
input = sys.stdin.readline

B = int(1E8)

def main():

    H, W = map(int, input().split())
    
    l = 0
    q = []
    checked = []
    for h in range(H):
        S = input()
        L = []
        for w in range(W):
            if S[w] == '#':
                l += 1
                L.append(True)
                q.append(B*h+w)
            else:
                L.append(False)
        checked.append(L)

    Next = [[[] for _ in range(W)] for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if h != 0:
                Next[h][w].append(B*(h-1) + w)
            if h != H-1:
                Next[h][w].append(B*(h+1) + w)
            if w != 0:
                Next[h][w].append(B*h + w-1)
            if w != W-1:
                Next[h][w].append(B*h + w+1)

    c = -1
    for _ in range(H+W+2):
        qq = []
        if len(q) == 0:
            break
        for hw in q:
            h, w = hw//B, hw%B
            for nhw in Next[h][w]:
                nh, nw = nhw//B, nhw%B
                if not checked[nh][nw]:
                    qq.append(B*nh + nw)
                    checked[nh][nw] = True
        q = qq
        c += 1

    print(c)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

s = input()
q = int(input())
m = 0
for i in range(q):
    Q = input().split()
    if(Q[0] == '1'):m = m ^ 1
    elif(Q[0] == '2'):
        if(Q[1] == '1'):
            if(m == 0):s = Q[2] + s
            else:s = s + Q[2]
        elif(Q[1] == '2'):
            if(m == 0):s = s + Q[2]
            else:s = Q[2] + s
if(m == 1):s = s[::-1]
print(s)

### FIXED CODE ###

s = input()
q = int(input())
m = 0
t = ''
l = ''
for i in range(q):
    Q = input().split()
    if(Q[0] == '1'):
        m = m ^ 1
        # t,l = l[::-1],t[::-1]
    elif(Q[0] == '2'):
        if(Q[1] == '1'):
            if(m == 0):t += Q[2]
            else:l += Q[2]
        elif(Q[1] == '2'):
            if(m == 0):l += Q[2]
            else:t += Q[2]
# print(t,s,l)
s = t[::-1] + s + l

if(m == 1):s = s[::-1]
print(s)
### BUGGY CODE ###

s=list(input())
s1=reversed(s)
l=["dream","dreamer","erase","eraser"]
s2=[]
for item in s1:
  s2.insert(0,item)
  str=''.join(s2)
  if str in l:
    s2=[]
if len(s2)==0:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

s=list(input())
s1=reversed(s)
l=["dream","dreamer","erase","eraser"]
s2=[]
for item in s1:
  s2.insert(0,item)
  str=''.join(s2)
  if str in l:
    s2=[]
  elif len(s2)>7:
    break
if len(s2)==0:
  print("YES")
else:
  print("NO")
### BUGGY CODE ###

import numpy as np

R, C, K = map(int,input().split())
MAP = np.zeros((R, C), dtype=np.int64)
DP = np.zeros((R+1, C+1, 4), dtype=np.int64)

for _ in range(K):
    r, c, v = map(int,input().split())
    MAP[r-1][c-1] = v

for i in range(R):
    for j in range(C):
        DP[i+1][j+1][0] = max(DP[i+1][j+1][0], DP[i][j+1].max())
        DP[i+1][j+1] = np.amax([DP[i+1][j+1], DP[i+1][j]], axis=0)
        if MAP[i][j] == 0:
            continue
        DP[i+1][j+1][1] = max(DP[i+1][j+1][1], DP[i][j+1].max() + MAP[i][j])
        DP[i+1][j+1][1:] = np.amax([DP[i+1][j+1][1:], DP[i+1][j][:3] + MAP[i][j]], axis=0)

print(max(DP[R][C]))

### FIXED CODE ###

R, C, K = map(int,input().split())
MAP = [[0 for i in range(C)] for j in range(R)]
DP = [[[0 for i in range(C+1)] for j in range(4)] for k in range(R+1)]
 
for _ in range(K):
    r, c, v = map(int,input().split())
    MAP[r-1][c-1] = v
 
for i in range(R):
    for j in range(4):
        for k in range(C):
            DP[i+1][j][k+1] = max(DP[i][3][k+1], DP[i+1][j][k])
            if j == 0:
                continue
            v = MAP[i][k]
            if v == 0:
                continue
            DP[i+1][j][k+1] = max(DP[i+1][j][k+1], max(DP[i][3][k+1], DP[i+1][j-1][k]) + v)

print(DP[R][3][C])
### BUGGY CODE ###

N = int(input())
word = [input() for i in range(N)]
sorted_word = [sorted(list(word[i])) for i in range(N)]
count = 0
for i in range(N-1):
  for j in range(1,N-i):
    if sorted_word[i] == sorted_word[i+j]:
      count += 1
print(count)



### FIXED CODE ###

N = int(input())
ans = 0
dict_word = {}
for i in range(N):
  sorted_word = str(''.join(sorted(list(input()))))
  try:
    ans += dict_word[sorted_word]
    dict_word[sorted_word] += 1
  except:
    dict_word[sorted_word] = 1
print(ans)
### BUGGY CODE ###

import sys


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

if n % k == 0:
    print('0')
    sys.exit(0)

n_list = [n]

while(True):
    n = abs(n - k)
    if n in n_list:
        break
    else:
        n_list.append(n)

n_list.sort()
print(n_list[0])

### FIXED CODE ###

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

m = n // k
n = n - m * k
print(min(n, abs(n-k)))
### BUGGY CODE ###

N=int(input())
S=input()
ans=0
tmp=0
for k in range(2,N):
  for j in range(1,k):
    i=int(2*j-k)
    if i>=0:
      if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
        tmp+=1
ans=S.count("R")*S.count("G")*S.count("B")-tmp
print(ans)

### FIXED CODE ###

n=int(input())
s=input()
sum=0
r=int(s.count('R'))
g=int(s.count('G'))
b=int(s.count('B'))
for k in range(n):
    for j in range(k):
        i=2*j-k
        if i+1>0:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                sum=sum+1
print(r*g*b-sum)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import numpy as np

n, k = map(int, input().split())
p = list(map(int, input().split()))
np_p = np.array(p)

def main2():
    ans = 0
    for i in range(n-k+1):
        ans = max(ans, ((np_p[i:i+k]+1)/2).sum())
    print(ans)

main2()


### FIXED CODE ###

# -*- coding: utf-8 -*-
 
n, k = map(int, input().split())
p = list(map(int, input().split()))

summation = 0
exp_val = []
for i in range(n):
    summation += (p[i]+1)/2
    exp_val.append(summation)
exp_val.insert(0, 0)
#print(exp_val)

ans = 0
for i in range(n-k+1):
    m = exp_val[k+i] - exp_val[i]
    ans = max(ans, m)

print(ans)
### BUGGY CODE ###

N,X,E=map(int,input().split())
D=E+(E==0)*10**8
f,c,r={},[0]*10**8,0
for x,y,z in sorted(((((N-k)*j+~-k)*k//2+k*X//D)*(E!=0),j,k*X%D)for k in range(N+1)for j in[0,2]):
 if c[z]+y<1:
  f[z]=x
 r+=(x-f[z]+1)*(c[z]<y)
 c[z]-=y-1
print(r)

### FIXED CODE ###

N, X, D = map(int, input().split())
if D == 0:
    r = N+1
    if X == 0:
        r = 1
    print(r)
else:
    if D < 0:
        X, D = -X, -D
    d = dict()
    for k in range(N+1):
        M = (k*X) % D
        F = (k*X)//D + ((k-1)*k)//2 #(1..k-1)
        L = (k*X)//D + (2*N-k-1)*k//2# (N-k..N-1)
        if M not in d:
            d[M] = list()
        d[M].append((F, 0))
        d[M].append((L, 1))
    r = 0
    for m in d:
        d[m] = sorted(d[m])
        fc = 0
        f = 0
        for x in d[m]:
            if not x[1]:
                fc += 1
                if fc == 1:
                    f = x[0]
            if x[1]:
                fc -= 1
                if fc == 0:
                    r += x[0] - f + 1
    print(r)
### BUGGY CODE ###

h,w = map(int,input().split())
al = []
for _ in range(h):
    a = list(map(int,input().split()))
    al.append(a)

bl = []
for _ in range(h):
    b = list(map(int,input().split()))
    bl.append(b)

abl = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    for j in range(w):
        abl[i][j] = al[i][j] - bl[i][j]

from collections import defaultdict
dic = defaultdict(set)

dic[(0,0)].add(abl[0][0])
dic[(0,0)].add(-abl[0][0])
for i in range(h):
    for j in range(w):
        for v in dic[(i,j)]:
            if j + 1 < w:
                if -6400 <= v+abl[i][j+1] <= 6400:
                    dic[(i,j+1)].add(v+abl[i][j+1])
                if -6400 <= v-abl[i][j+1] <= 6400:
                    dic[(i,j+1)].add(v-abl[i][j+1])
            if i + 1 < h:
                if -6400 <= v+abl[i+1][j] <= 6400:
                    dic[(i+1,j)].add(v+abl[i+1][j])
                if -6400 <= v-abl[i+1][j] <= 6400:
                    dic[(i+1,j)].add(v-abl[i+1][j])

ans = float("inf")
for i in dic[(h-1, w-1)]:
    ans = min(abs(i), ans)
print(ans)




### FIXED CODE ###

h,w = map(int,input().split())

bitdp = [[0 for j in range(w)] for i in range(h)]
al = []
bl = []
for _ in range(h):
   a = list(map(int,input().split()))
   al.append(a)
for _ in range(h):
   b = list(map(int,input().split()))
   bl.append(b)
abl = [[] for i in range(h)]
for i in range(h):
   for j in range(w):
      abl[i].append(abs(al[i][j] - bl[i][j]))

bitdp[0][0] = 1 << h*w+abl[0][0]
for i in range(h):
   for j in range(w):
      if j != w-1:
         bitdp[i][j+1] |= bitdp[i][j] << abl[i][j+1] | bitdp[i][j] >> abl[i][j+1]
      if i != h-1:
         bitdp[i+1][j] |= bitdp[i][j] << abl[i+1][j] | bitdp[i][j] >> abl[i+1][j]

ans = []
for i in range(h*w*2+1):
   if (bitdp[-1][-1] >> i & 1):
      ans.append(abs(h*w-i))

print(min(ans))
### BUGGY CODE ###

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

ans = 0

for i in range(N):
    x = a[i]
    cnt = a.count(x-1) + a.count(x) + a.count(x+1)
    ans = max(ans, cnt)

print(ans)

### FIXED CODE ###

from collections import Counter

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

for i in range(N):
    a.append(a[i]+1)
    a.append(a[i]-1)

ans = Counter(a)

print(ans.most_common()[0][1])
### BUGGY CODE ###

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

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

n = int(input())
a = list(map(int, input().split()))
l = 1
for ai in a:
    l = lcm(l, ai)

ans = 0
mod = 10**9 + 7
for ai in a:
    ans += l // ai
    ans %= mod

print(ans)

### FIXED CODE ###

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

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

n = int(input())
a = list(map(int, input().split()))
l = 1
for ai in a:
    l = lcm(l, ai)

ans = 0
mod = 10**9 + 7
for ai in a:
    ans += l // ai

print(ans % mod)
### BUGGY CODE ###

n = int(input())
height = [int(x) for x in input().split()]
cnt =0

for i_index, i in enumerate(height[:-1]):
    if i+i_index >= n:
        continue

    for j_index, j in enumerate(height[i_index+i:]):
        if j+i == j_index+i:
            cnt += 1
            # print(i,j,j_index)
            
print(cnt)

### FIXED CODE ###

# n = int(input())
# height = [int(x) for x in input().split()]
# cnt =0

# for i_index, i in enumerate(height[:-1]):
#     if i+i_index >= n:
#         continue

#     for j_index, j in enumerate(height[i_index+i+1:]):
#         if j+i == j_index+i+1:
#             cnt += 1
#             # print(i,j,j_index)
            
# print(cnt)
def count(dic,x):
    if x in dic:
        dic[x]+=1
    else:
        dic[x]=1
 
N=int(input())
A=list(map(int,input().split()))
dic1={}
dic2={}
s=0
for i in range(N):
    count(dic1,i-A[i])
    count(dic2,i+A[i])
for x in dic1:
    if x in dic2:
        s+=dic1[x]*dic2[x]
print(s)
### BUGGY CODE ###

n,k=map(int,input().split())
a=tuple(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(max(0,i-k),i)))
print(l[-1])

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])
### BUGGY CODE ###

import numpy as np
N, M = map(int,input().split())
P_Y_list = np.array([input().split() for _ in range(0, M)], dtype='int')
col_1 = P_Y_list[:,0]
years = [np.sort(P_Y_list[np.where(col_1==i)][:,1]) for i in set(col_1)]
for l in P_Y_list:
    #left = str(l[0]).zfill(6)
    #right = str(np.where(years[list(set(col_1)).index(l[0])]==l[1])[0][0]+1).zfill(6)
    print((str(l[0]).zfill(6))+(str(np.where(years[list(set(col_1)).index(l[0])]==l[1])[0][0]+1).zfill(6)))

### FIXED CODE ###

import numpy as np
N, M = map(int,input().split())
P_Y_list = np.array([input().split() for _ in range(0, M)], dtype='int')
counts = (np.zeros(N+1)).astype(int)
id_list = []

sort_ind = np.argsort(P_Y_list[:,1])
sorted_P_Y = P_Y_list[sort_ind]

for p, y in sorted_P_Y:
    counts[p] += 1
    id_list.append(str(p).zfill(6) + str(counts[p]).zfill(6))
id_list = np.array(id_list)
id_list = id_list[np.argsort(sort_ind)]
for id in id_list:
    print(id)
### BUGGY CODE ###

from numpy import int64
from numba import njit
from scipy.optimize import minimize,Bounds

d,*s=map(int,open(0).read().split())
s=int64(s)
@njit('i8(f8[:])')
def func(x):
    x=x.astype(int64)
    if x.max()>25 or x.min()<0:return 0
    last=[0]*26
    score=0
    for i,v in enumerate(x,1):
        last[v]=i
        c=0
        for j in range(26):
            c+=s[j]*(last[j]-i)
        score=score+s[i*26+v]-c
    return-score

x0=[0]*d
res=minimize(func,x0,method='Powell',bounds=Bounds(0,25)).x.astype(int64)+1
for t in res:print(t)

### FIXED CODE ###

from time import time
from random import randint

from numba import njit
from numpy import int64

@njit('i8(i8[:],i8[:])')
def func(s,x):
    last=[0]*26
    score=0
    for i,v in enumerate(x,1):
        last[v]=i
        c=0
        for j in range(26):
            c+=s[j]*(last[j]-i)
        score=score+s[i*26+v]-c
    return score

def main():
    start=time()
    d,*s=map(int,open(0).read().split())
    s=int64(s)
    x=int64(([*range(26)]*15)[:d])
    M=func(s,x)
    while time()-start<1:
        y=x.copy()
        y[randint(0,d-1)]=randint(0,25)
        t=func(s,y)
        if t>M:
            M=t
            x=y
    print(*x+1,sep='\n')

main()
### BUGGY CODE ###

N = int(input())
S = tuple([s for s in input()])
B = {'R','G','B'}
ans = 0
d = {}
d['R'] = 0
d['G'] = 1
d['B'] = 2
num = [[0,0,0]for _ in range(N+1)]
for i in range(N):
    num[i+1][d[S[i]]] = num[i][d[S[i]]]+1
    for a in list(B-{S[i]}):
        num[i+1][d[a]] = num[i][d[a]]
num = num[1:]
for i in range(N-2):
    s = S[i]
    for j in range(i+1,N-1):
        if S[j] != s:
            l = j-i
            t = (B-{s,S[j]}).pop()
            L = 0
            R = 0
            if l > N-j-1:
                ans += num[N-1][d[t]]-num[j][d[t]]
            else:
                L = num[j+l-1][d[t]]-num[j][d[t]]
                R = num[N-1][d[t]]-num[j+l][d[t]]
                ans += L+R
print(ans)

### FIXED CODE ###

N = int(input())
S = tuple([s for s in input()])
B = {'R','G','B'}
ans = 0
d = {}
d['R'] = 0
d['G'] = 1
d['B'] = 2
num = [[0,0,0]for _ in range(N+1)]
for i in range(N):
    for j in range(3):
        num[i+1][j] = num[i][j]
        if d[S[i]] == j:
            num[i+1][j] += 1
num = tuple(num[1:])
for i in range(N-2):
    s = S[i]
    for j in range(i+1,N-1):
        if S[j] != s:
            l = j-i
            t = (B-{s,S[j]}).pop()
            L = 0
            R = 0
            if l > N-j-1:
                ans += num[N-1][d[t]]-num[j][d[t]]
            else:
                L = num[j+l-1][d[t]]-num[j][d[t]]
                R = num[N-1][d[t]]-num[j+l][d[t]]
                ans += L+R
print(ans)
### BUGGY CODE ###

import queue
import copy
def dfs(L,start,end):
    stack = [start]

    visited = [start]

    path =[ 0 for i in range((len(L)))]

    while stack:
        node = stack.pop()
        for n in L[node]:
            if n[0] not in visited:

                path[n[0]] = path[node]  + n[1]

                stack.append(n[0])
                visited.append(n[0])

    return path

N = int(input())
p = []
node = []
for i in range(N-1):
    l = list(map(int,input().split()))
    p.append(l)
    if l[0] not in node:
        node.append(l[0])
    if l[1] not in node:
        node.append(l[1])

Q,K = map(int,input().split())
xy = []
for i in range(Q):
    xy.append(list(map(int,input().split())))

L = [ [] for i in range(N+1)]
for l in p:
    L[l[0]].append([l[1],l[2]])
    L[l[1]].append([l[0],l[2]])

d = dfs(L,K,0)

for i in range(Q):
    print(d[xy[i][0]]+ d[xy[i][1]])


### FIXED CODE ###

import sys
def dfs(L,start):
    stack = [start]

    path =[-1]*len(L)
    path[start] = 0
    while stack:
        node = stack.pop()
        for n in L[node]:
            if path[n[0]] < 0:
                path[n[0]] = path[node]  + n[1]
                stack.append(n[0])

    return path

#input
input = sys.stdin.readline
N = int(input())
p = []
for i in range(N-1):
    l = list(map(int,input().split()))
    p.append(l)

Q,K = map(int,input().split())
xy = []
for i in range(Q):
    xy.append(list(map(int,input().split())))

#neigher list
L = [ [] for i in range(N+1)]
for l in p:
    L[l[0]].append([l[1],l[2]])
    L[l[1]].append([l[0],l[2]])

d = dfs(L,K)

for i in range(Q):
    print(d[xy[i][0]]+ d[xy[i][1]])
### BUGGY CODE ###

import numpy as np

N = int(input())
A = list(map(int, input().split()))
a = sorted(A)
res = list(np.cumsum(a))

ans = 0
for i in range(len(res)):
    num = res[i]
    idx = i+1
    
    while(num*2 >= a[idx]):
        num += a[idx]
        idx += 1
        
        if(idx >= len(res)-1):
            break
       
    if(idx >= len(res)-1):
        print(N-i)
        break

### FIXED CODE ###

import numpy as np

N = int(input())
A = list(map(int, input().split()))
a = sorted(A)
res = list(np.cumsum(a))

ans = 0
idx = 1
for i in range(len(res)):
    num = res[i]
    if(idx <= i):
        idx = i+1
    while(num*2 >= a[idx]):
        num += a[idx]
        idx += 1
        
        if(idx >= len(res)-1):
            break
       
    if(idx >= len(res)-1):
        print(N-i)
        break
### BUGGY CODE ###

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

while m>0:
  for i in range(n):
    if A[i]==max(A):
      A[i]=A[i]//2
      m-=1
      break
print(sum(A))

### FIXED CODE ###

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

q=[]
for a in A:
  heapq.heappush(q,-a)
  
for _ in range(m):
  p=-heapq.heappop(q)//2
  heapq.heappush(q,-p)
print(-sum(q))
### BUGGY CODE ###

import itertools

N = int(input())
L_list = list(map(int, input().split()))
ans = 0
for (i, j, k) in itertools.combinations(range(N), 3):
    if (
        L_list[i] < L_list[j] + L_list[k]
        and L_list[j] < L_list[k] + L_list[i]
        and L_list[k] < L_list[i] + L_list[j]
    ):
        ans += 1
print(ans)

### FIXED CODE ###

from bisect import bisect_left
N = int(input())
L_list = list(map(int, input().split()))
L_list.sort()

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a, b = L_list[i], L_list[j]
        r = bisect_left(L_list, a+b)
        ans += max(0,r-j-1)
print(ans)
### BUGGY CODE ###

from math import factorial as fac
n = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
mx = A[0]; A = A[1:]
mn = A[0]
t = 0
mxf = fac(mx)
for a in A:
    _t = mxf // (fac(mx-a)*fac(a))
    if t < _t:
        t = _t
        mn = a
    else:
        break
print(mx, mn)

### FIXED CODE ###

n = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
mx = A[0]; A = A[1:]
mn = A[0]
for a in A[1:]:
    if abs(mn-mx/2) > abs(a-mx/2):
        mn = a
    else:
        break
print(mx, mn)
### BUGGY CODE ###

#!/usr/bin/env python3

n, m = map(int, input().split())
h = list(map(int, input().split()))
not_good = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a - 1] > h[b - 1]:  # bはダメ
        not_good.append(b)
    elif h[a - 1] == h[b - 1]:
        not_good.append(a)
        not_good.append(b)
    else:
        not_good.append(a)
ans = 0
for i in range(1, n + 1):
    if i not in not_good:
        ans += 1
        # print(i, end=" ")
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
n, m = map(int, input().split())
h = list(map(int, input().split()))
not_good = []
for i in range(m):
    a, b = map(int, input().split())
    if h[a - 1] > h[b - 1]:  # bはダメ
        not_good.append(b)
    elif h[a - 1] == h[b - 1]:
        not_good.append(a)
        not_good.append(b)
    else:
        not_good.append(a)
ans = 0
not_good = list(set(not_good))
not_good.sort()
# print(not_good)
idx = 0
for i in range(1, n + 1):
    if i < not_good[idx]:
        ans += 1
        # print(i, end=" ")
    elif i == not_good[idx]:
        idx += 1
        if idx == len(not_good):
            ans += n - i
            break
    else:
        pass
print(ans)
### BUGGY CODE ###

n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
L=len(format(max(a),"b"))
s=[0]*L
for i in range(n):
  c=format(a[i], 'b').zfill(L)
  for j in range(len(c))[::-1]:
    s[j]+=int(c[j])
ans=0
for i in range(len(s))[::-1]:
  ans+=2**(i)*(s[L-i-1])*(n-s[L-i-1])
  ans%=mod
print(ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))
s=[0]*61
for i in range(n):
  c=format(a[i], 'b')
  L=len(c)
  for j in range(L)[::-1]:
    s[L-j-1]+=int(c[j])
ans=0
for i in range(61):
  ans+=2**(i)*(s[i])*(n-s[i])
  ans%=mod
print(ans)
### BUGGY CODE ###

import numpy as np
MOD = int(1e9 + 7)
N = int(1e5)
M = 13

s = input()
dp = np.zeros((N,M),dtype=np.int64)
dp[0,0] = 1
m = list(range(M))
t = list(range(10))

for i in range(len(s)):
    for j in m:
        for k in t:
            if s[i] == "?" or s[i] == str(k):
                dp[i+1,(j*10 +k) % M] += dp[i,j]
                dp[i+1,(j*10 +k) % M] %= MOD


print(dp[len(s),5])


### FIXED CODE ###

MOD = int(1e9 + 7)
N = int(1e5)
M = 13

s = input()
dp = [[0 for x in range(M)] for x in range(N+10)]
dp[0][0] = 1

for i in range(len(s)):
    for j in range(M):
        for k in range(10):
            if s[i] == "?" or s[i] == str(k):
                dp[i+1][(j*10 +k) % M] += dp[i][j]
                dp[i+1][(j*10 +k) % M] %= MOD


print(dp[len(s)][5])