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

import bisect


class DualSegmentTree():

    def __init__(self, n):
        INF = float("inf")
        self.size = 1
        while self.size < n:
            self.size *= 2
        self.node = [INF] * (2*self.size - 1)

    def update(self, begin, end, val):
        begin += (self.size - 1)
        end += (self.size - 1)
        while begin < end:
            if (end - 1) & 1:
                end -= 1
                self.node[end] = min(val, self.node[end])
            if (begin - 1) & 1:
                self.node[begin] = min(val, self.node[begin])
                begin += 1
            begin = (begin - 1) // 2
            end = (end - 1) // 2

    def get_val(self, i):
        i += (self.size - 1)
        val = self.node[i]
        while i > 0:
            i = (i - 1) // 2
            val = min(val, self.node[i])
        return val

n, q = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]
d = [int(input()) for i in range(q)]
INF = float("inf")

st = DualSegmentTree(len(d)+1)

for i in range(n):
    a, b = info[i][0] - info[i][2], info[i][1] - info[i][2]  
    l = bisect.bisect_left(d, a)
    r = bisect.bisect_left(d, b)
    st.update(l, r, info[i][2])

for i in range(q):
    tmp = st.get_val(i)
    if tmp == float("inf"):
        print(-1)
    else:
        print(tmp)

### FIXED CODE ###

import sys
import bisect


class DualSegmentTree():

    def __init__(self, n):
        INF = float("inf")
        self.size = 1
        while self.size < n:
            self.size *= 2
        self.node = [INF] * (2*self.size - 1)

    def update(self, begin, end, val):
        begin += (self.size - 1)
        end += (self.size - 1)
        while begin < end:
            if (end - 1) & 1:
                end -= 1
                self.node[end] = min(val, self.node[end])
            if (begin - 1) & 1:
                self.node[begin] = min(val, self.node[begin])
                begin += 1
            begin = (begin - 1) // 2
            end = (end - 1) // 2

    def get_val(self, i):
        i += (self.size - 1)
        val = self.node[i]
        while i > 0:
            i = (i - 1) // 2
            val = min(val, self.node[i])
        return val

n, q = map(int, input().split())
info = [list(map(int, sys.stdin.readline().split())) for i in range(n)]
d = [int(sys.stdin.readline()) for i in range(q)]
INF = float("inf")

st = DualSegmentTree(len(d)+1)

for i in range(n):
    a, b = info[i][0] - info[i][2], info[i][1] - info[i][2]  
    l = bisect.bisect_left(d, a)
    r = bisect.bisect_left(d, b)
    st.update(l, r, info[i][2])

for i in range(q):
    tmp = st.get_val(i)
    if tmp == float("inf"):
        print(-1)
    else:
        print(tmp)
### BUGGY CODE ###

import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
N = int(X[0])
M = int(X[1])

H = []
Y = [0 for j in range(N)]

for i in range(N):
    H.append(int(lines[1].split(' ')[i]))

for j in range(M):
    A = int(lines[j+2].split(' ')[0])
    B = int(lines[j+2].split(' ')[1])
    if int(H[A-1]) <= int(H[B-1]):      
      Y[A-1] = -1
    if int(H[B-1]) <= int(H[A-1]):
      Y[B-1] = -1

good = 0
for i in range(N):
    if Y[i] ==0:
        good +=1
print(good)


### FIXED CODE ###

import sys

lines = sys.stdin.readlines()

X = lines[0].split(' ')
N = int(X[0])
M = int(X[1])

H = []
Y = []

H=lines[1].split(' ')

for j in range(M):
    A = int(lines[j+2].split(' ')[0])
    B = int(lines[j+2].split(' ')[1])
    if int(H[A-1]) <= int(H[B-1]):      
      Y.append(A-1)
    if int(H[B-1]) <= int(H[A-1]):
      Y.append(B-1)
Z = len(set(Y))
print(N-Z)
### BUGGY CODE ###


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


N=int(input())

S=[]
for n in range(N):
    s=input()
    s=''.join(sorted(s))
    S.append(s)

key=sorted(list(set(S)))

total=0
for k in key:
    t=S.count(k)
    if(t>=2):
        total+=cmb(S.count(k),2)

print(total)

### FIXED CODE ###


N=int(input())
S=[]
total=0

for s in range(N):
    tmp=input()
    S.append("".join(sorted(tmp)))

S=sorted(S)
S_key=list(set(S))
count=[0]*len(S_key)
S_dict=dict(zip(S_key,count))


for s in S:
    total+=S_dict[s]
    S_dict[s]+=1

print(total)
### BUGGY CODE ###

def solve(aaa):
    l = 1
    r = 200000
    while l < r:
        m = (l + r) // 2
        if check(m, aaa):
            r = m
        else:
            l = m + 1
    return r


def check(d, aaa):
    if d == 1:
        return all(a1 < a2 for a1, a2 in zip(aaa, aaa[1:]))
    l = 0
    word = [[0, 0]]
    for a in aaa:
        if l >= a:
            if not carry(d, word, a):
                return False
        l = a
    return True


def carry(d, word, i):
    while word[-1][0] > i:
        word.pop()
    while word[-1] == [i, d]:
        word.pop()
        i -= 1
    if i == 0:
        return False
    if word[-1][0] == i:
        word[-1][1] += 1
    else:
        word.append([i, 2])
    return True


n = int(input())
aaa = list(map(int, input().split()))
print(solve(aaa))


### FIXED CODE ###

def solve(aaa):
    l = 1
    r = 200000
    while l < r:
        m = (l + r) // 2
        if check(m, aaa):
            r = m
        else:
            l = m + 1
    return r


def check(d, aaa):
    if d == 1:
        return all(a1 < a2 for a1, a2 in zip(aaa, aaa[1:]))
    l = 0
    word = {}
    for a in aaa:
        if l >= a:
            if not carry(d, word, a):
                return False
            for i in list(word.keys()):
                if a < i:
                    del word[i]
        l = a
    return True


def carry(d, word, i):
    while i > 0:
        if i in word:
            if word[i] < d:
                word[i] += 1
                return True
            del word[i]
        else:
            word[i] = 2
            return True
        i -= 1
    return False


n = int(input())
aaa = list(map(int, input().split()))
print(solve(aaa))
### BUGGY CODE ###

N, M = map(int, input().split())
A = [int(x) for x in input().split()]
mp = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
dp = [''] * (N+1)
for i in range(1, N+1):
    cand = []
    for x in A:
        if i - mp[x] < 0:
            continue
        if dp[i-mp[x]] == '' and mp[x] != i:
            continue
        cand.append(max(int(str(dp[i - mp[x]]) + str(x)), int(str(x) + str(dp[i - mp[x]]))))
    if cand:
        dp[i] = max(cand)
    else:
        dp[i] = ''
print(dp[N])

### FIXED CODE ###

import math
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
mp = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
dp = [''] * (N+1)
for i in range(1, N+1):
    cand = []
    for x in A:
        if i - mp[x] < 0:
            continue
        if dp[i-mp[x]] == '' and mp[x] != i:
            continue
        if dp[i-mp[x]] == '':
            cand.append(x)
        else:
            before = dp[i - mp[x]]
            pre = (int(math.log10(before)) + 1) * 10 * x + before
            suf = before * 10 + x
            cand.append(max(pre, suf))
    if cand:
        dp[i] = max(cand)
    else:
        dp[i] = ''
print(dp[N])
### BUGGY CODE ###

import bisect
import copy
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
table = [True for i in range(N)]
cands = [i for i in range(N)]
for i in range(N):
    if table[i]:
        idx = bisect.bisect_left(cands, i)
        del cands[idx]
        if i < N-1 and A[i] == A[i+1]:
            table[i] = False
        new_cands = copy.deepcopy(cands)
        for j in cands:
            if A[j] % A[i] == 0:
                table[j] = False
                idx = bisect.bisect_left(new_cands, j)
                del new_cands[idx]
        cands = copy.deepcopy(new_cands)
print(table.count(True))


### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
A.sort()
a_max = max(A)
table = [True for i in range(a_max+1)]
for a in A:
    i = 2
    k = a * 2
    while k <= a_max:
        table[k] = False
        k += a
count = 0
for i, a in enumerate(A):
    if i < N - 1 and A[i] == A[i+1]:
        table[a] = False
    if table[a]:
        count += 1
print(count)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

import numpy as np

def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    ans = []
    for i in range(1, n+1):
        ans.append(a_list.index(i)+1)

    print(*ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

import numpy as np

def main():
    n = int(input())
    a_list = np.array(list(map(int, input().split())))

    print(*np.argsort(a_list)+1)


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

#create date: 2020-06-14 10:29

import sys
stdin = sys.stdin
from itertools import accumulate

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, k = na()
    a = na()
    def step():
        b = [0] * n
        for i, ai in enumerate(a):
            start, stop = i - ai, i + ai + 1
            if start > 0:
                b[start] += 1
            else:
                b[0] += 1
            if stop < n:
                b[stop] -= 1
        return list(accumulate(b))

    for i in range(k):
        anext = step()
        if sum(a) == sum(anext):
            print(*a)
            quit()
        a = anext
    print(*a)


if __name__ == "__main__":
    main()

### FIXED CODE ###

#create date: 2020-06-14 10:29

import sys
stdin = sys.stdin
from itertools import accumulate

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, k = na()
    a = na()
    def step():
        b = [0] * n
        for i, ai in enumerate(a):
            start, stop = i - ai, i + ai + 1
            if start > 0:
                b[start] += 1
            else:
                b[0] += 1
            if stop < n:
                b[stop] -= 1
        return list(accumulate(b))

    for i in range(k):
        anext = step()
        if sum(a) == sum(anext):
            print(*a)
            quit()
        a = anext
    print(*a)


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

N, M = map(int, input().split())
friend_list = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, input().split())
    friend_list[a][b] = 1
    friend_list[b][a] = 1

ans = 0
for friend in friend_list:
    sum_friend = sum(friend)
    ans = max(ans, sum_friend)
print(ans + 1)


### FIXED CODE ###

from collections import Counter


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

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

        if x == y:
            return

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

        self.par[y] = x
        self.size[x] += self.size[y]
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1

    def same_check(self, x, y):
        return self.find(x) == self.find(y)


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

for _ in range(M):
    a, b = map(int, input().split())
    uf.union(a, b)

ans = max(uf.size)

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

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

s=sorted(s)
t=0
c=1
ct=[]
for i in range(1,n):
    if i==n-1:
        if s[t]==s[i]:
            ct.append(c+1)
        else:
            ct.append(c)
            ct.append(1)
    else:
        if s[t]==s[i]:
            c+=1
        else:
            t=i
            ct.append(c)
            c=1
u=0
for i in ct:
    if i==max(ct):
        print(s[u])
    u+=i


### FIXED CODE ###

n=int(input())
s=[]
for i in range(n):
    s.append(input())
s=sorted(s)
t=0
c=0
ct=[]
for i in range(1,n):
    c+=1
    if s[t]!=s[i]:
        ct.append(c)
        c=0
        t=i
ct.append(c+1)
u=0
cm=max(ct)
for i in ct:
    if i==cm:
        print(s[u])
    u+=i
### BUGGY CODE ###

def p_e():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    ans = [-1]

    for a in A:
        is_set = False
        for i, l in enumerate(ans):
            if l < a:
                ans[i] = a
                is_set = True
                break

        if not is_set:
            ans.append(a)

    print(len(ans))


if __name__ == '__main__':
    p_e()


### FIXED CODE ###

from bisect import *


def p_e():
    N = int(input())
    # A = [int(input()) for _ in range(N)]
    ans = [-1] * N

    for _ in range(N):
        a = int(input())
        ans[bisect(ans, a - 1) - 1] = a

    print(N - bisect(ans, -1))


if __name__ == '__main__':
    p_e()
### BUGGY CODE ###

n,t = map(int,input().split())
a = list(map(int,input().split()))
ans = [0]*n
flag = max(a)
flag_2 = a.index(flag)
for i in range(n):
  if i <= flag_2:
    ans[i] = flag-a[i]
  else:
    flag = max(a[i:n])
    flag_2 = a.index(flag)
    ans[i] = flag-a[i]
print(ans.count(max(ans)))

### FIXED CODE ###

n,t = map(int,input().split())
a = list(map(int,input().split()))
ans = [0]*n
flag = float("inf")
for i in range(n):
    flag = min(flag,a[i])
    ans[i] = a[i]-flag
print(ans.count(max(ans)))
### BUGGY CODE ###

S = input()
Q = int(input())
QL = [input().split() for _ in range(Q)]

h = ''
t = ''
reverse = False

for q in QL:
    if q[0] == '1':
        reverse = not reverse
    else:
        if q[1] == '1':
            if reverse:
                t = t+q[2]
            else:
                h = q[2]+h
        else:
            if reverse:
                h = q[2]+h
            else:
                t = t+q[2]

s = h + S + t
if reverse:
    print(s[::-1])
else:
    print(s)


### FIXED CODE ###

S = input()
Q = int(input())
QL = [input().split() for _ in range(Q)]

h = ''
t = ''
reverse = False

for q in QL:
    if q[0] == '1':
        reverse = not reverse
    else:
        if q[1] == '1':
            if reverse:
                t = '{}{}'.format(t, q[2])
            else:
                h = '{}{}'.format(q[2], h)
        else:
            if reverse:
                h = '{}{}'.format(q[2], h)
            else:
                t = '{}{}'.format(t, q[2])

s = '{}{}{}'.format(h, S, t)
if reverse:
    print(s[::-1])
else:
    print(s)
### BUGGY CODE ###

import math
N = int(input().strip())
a = list(map(int, input().strip().split()))
A=[0]*N
for i in range (N):
    for j in range (N-1):
        if a[j]==i+1:
            A[i]=A[i]+1
for i in range(N):
    print(A[i])

### FIXED CODE ###

from collections import Counter

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

for i in range(1,N+1):
  print(A[i])
### BUGGY CODE ###

def run(n, m, qq, l, r, p, q):
    cnt = []
    for i in range(qq):
        tmp_cnt = 0
        for j in range(m):
            if p[i] <= l[j] and r[j] <= q[i]:
                tmp_cnt += 1
        cnt.append(tmp_cnt)
    return cnt


def read_line():
    n, m, qq = map(int, input().split())
    l = []
    r = []
    for i in range(m):
        tl, tr = map(int, input().split())
        l.append(tl)
        r.append(tr)
    p = []
    q = []
    for i in range(qq):
        tp, tq = map(int, input().split())
        p.append(tp)
        q.append(tq)
    return (n, m, qq, l, r, p, q)


def main():
    n, m, qq, l, r, p, q = read_line()
    ret = run(n, m, qq, l, r, p, q)
    for i in range(len(ret)):
        print(ret[i])


if __name__ == '__main__':
    main()


### FIXED CODE ###

def run(n, m, qq, l, r, p, q):
    cnt = {}
    sum = {}
    ret = []
    for i in range(n+1):
        for j in range(n+1):
            cnt[i, j] = 0
            sum[i, j] = 0
    for i in range(m):
        cnt[(l[i], r[i])] += 1
    for i in range(1, n+1):
        for j in range(1, n+1):
            sum[i, j] = cnt[i, j] + sum[i-1, j] + sum[i, j-1] - sum[i-1, j-1]
    for i in range(qq):
        ret.append(sum[q[i], q[i]] - sum[p[i]-1, q[i]] - sum[q[i], p[i]-1] + sum[p[i]-1, p[i]-1])
    return ret


def read_line():
    n, m, qq = map(int, input().split())
    l = []
    r = []
    for i in range(m):
        tl, tr = map(int, input().split())
        l.append(tl)
        r.append(tr)
    p = []
    q = []
    for i in range(qq):
        tp, tq = map(int, input().split())
        p.append(tp)
        q.append(tq)
    return (n, m, qq, l, r, p, q)


def main():
    n, m, qq, l, r, p, q = read_line()
    ret = run(n, m, qq, l, r, p, q)
    for i in range(len(ret)):
        print(ret[i])


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

n=int(input())
a=list(map(int,input().split()))
a2=sorted(a)
num=-1
ans=0
for i in range(n):
    if a2[i]!=num:
        num=a2[i]
        total=a2.count(num)+a2.count(num-1)+a2.count(num+1)
        if total>ans:
            ans=total
    else:
        continue
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[0]*(10**5)
for i in range(n):
    if a[i]==0:
        b[0]+=1
        b[1]+=1
    elif a[i]==(10**5)-1:
        b[(10**5)-1]+=1
        b[(10**5)-2]+=1
    else:
        b[a[i]]+=1
        b[a[i]-1]+=1
        b[a[i]+1]+=1
print(max(b))
### BUGGY CODE ###

N,K,Q = map(int, input().split())


S = []
for _ in range(Q):
    S.append(input())

score_l = [K] * N

for j in S:
        for i in range(len(score_l)):
                if i != int(j)-1:
                        score_l[i]  = score_l[i] - 1


for score in score_l:
        if score <= 0:
                print("No")
        else:
                print("Yes")

### FIXED CODE ###

N,K,Q = map(int, input().split())


S = []
for _ in range(Q):
    S.append(input())

#score_l = [K] * N
seikai_num = [K-Q] * N

for j in S:
        seikai_num[int(j)-1] += 1



for num in seikai_num:
        if num > 0:
                print("Yes")
        else:
                print("No")
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''
import numpy as np


def main():
    N = int(input())
    P = list(map(int, input().split()))

    count = 0
    P = np.array(P)
    for i in range(N):
        # print(i+1, np.count_nonzero(P[:i+1]-P[i] >= 0), P[:i+1])
        if np.count_nonzero(P[:i+1]-P[i] >= 0) == i+1:
            count += 1
    print(count)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''
# import numpy as np


def main():
    N = int(input())
    P = list(map(int, input().split()))

    count = 0
    min_P = 200000
    for i in range(N):
        if min_P > P[i]:
            min_P = P[i]
        if min_P == P[i]:
            count += 1
    print(count)

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

N = int(input())
numbers = list(map(int, input().split()))
l = []
amount = 0
for i in range(N):
    for j in range(N-1):
        if numbers[j] == i+1:
            amount = amount + 1
    print(amount)
    amount = 0

### FIXED CODE ###

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

result = [0] * N
for i in numbers:
    result[i- 1] += 1
    
for i in range(N-1):
    print(result[i])
print(0)
### BUGGY CODE ###

N,A = map(int,input().split())
x = list(map(int,input().split()))
X = N*50
dp = [[[0 for i in range(X+1)] for j in range(N+1)] for k in range(N+1)]
dp[0][0][0] = 1
for k in range(1,N+1):
    for j in range(k+1):
        for i in range(X+1):
            if i - x[k-1] < 0:
                dp[k][j][i] = dp[k-1][j][i]
            elif k >= 1:
                dp[k][j][i] = dp[k-1][j-1][i-x[k-1]] + dp[k-1][j][i]
ans = 0
for j in range(1,N+1):
    ans += dp[-1][j][j*A]
print(ans)

### FIXED CODE ###

N,A = map(int,input().split())
x2 = list(map(int,input().split()))
x = [i-A for i in x2]
maxx = max(max(x2),A)
dp = [[0 for i in range(2*N*maxx+1)] for j in range(N+1)]
start = N*maxx
dp[0][start] = 1
for i in range(1,N+1):
    for j in range(2*start+1):
        if 2*start >= j - x[i-1] >= 0:
            dp[i][j] = dp[i-1][j-x[i-1]] + dp[i-1][j]
        else:
            dp[i][j] = dp[i-1][j]
print(dp[-1][start]-1)
### BUGGY CODE ###

s=input()
q=int(input())
order=1
header=''
footer=''
for _ in range(q):
  tmp=input()
  if tmp=='1':
    order*=-1
  else:
    t, f, c=tmp.split()
    if (int(f)*order)%3==1:
      header=c+header
    else:
      footer=footer+c
s=header+s+footer
print(s) if order==1 else print(s[::-1])

### FIXED CODE ###

s=input()
q=int(input())
order=1
header=''
footer=''
for _ in range(q):
  tmp=input()
  if tmp=='1':
    order*=-1
  else:
    t, f, c=tmp.split()
    if (int(f)*order)%3==1:
      header=c+header
    else:
      footer=footer+c
s=header+s+footer
print(s) if order==1 else print(s[::-1])
### BUGGY CODE ###

from sys import stdin

N, M = map(int, stdin.readline().split())
A = list(map(int, stdin.readline().split()))
low = min(A)
for _ in range(M):
    B, C = map(int, stdin.readline().split())
    if low < C:
        A.extend([C]*B)
A.sort(reverse=True)
A = A[:N]

print(sum(A))

### FIXED CODE ###

from sys import stdin, exit

N, M = map(int, stdin.readline().split())
A = list(map(int, stdin.readline().split()))
p = [(A[i], 1) for i in range(N)]
for _ in range(M):
    B, C = map(int, stdin.readline().split())
    p.append((C, B))

p.sort(reverse=True)

ans, cnt = 0, N
for (v, c) in p:
    use = min(c, cnt)
    ans += use * v
    cnt -= use

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

import itertools
import numpy as np
from math import factorial
n = list(map(int, input().split()))
x = np.array(list(map(int, input().split())))

x = x - n[1]
b = len(x) - np.count_nonzero(x)
x = [i for i in x if i != 0]
x = np.sort(x)

c = 0
for i in range(1, b + 1):
    c += factorial(b) / factorial(i) / factorial(b - i)

cnt = c
for i in range(2, n[0] + 1):
    if len(x) == 0:
        break
    a = np.sum(np.array(list(itertools.combinations(x, i))), axis = 1)
    if a[0] > 0:
        break
    cnt += (c + 1) * (len(a) - np.count_nonzero(a))
            
print(int(cnt))

### FIXED CODE ###

import sys
import numpy as np
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n, a = imap()
x = np.array(iarr()) - a
MAX = 50*50+1

dp = np.zeros((n+1, 2*MAX+1)).astype(int)
dp[0][MAX] = 1
for i in range(n):
    for j in range(2*MAX):
        if j-x[i] < 0 or j-x[i] > 2*MAX:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = dp[i][j] + dp[i][j-x[i]]
print(dp[n][MAX]-1)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
num = 1
for i in range(0,N):
    num *= A[i]
if num>10**18:
    print(-1)
else:
    print(num)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
num = 1
for i in range(0,N):
    if A[i]==0:
      	num=0
      	break
for i in range(0,N):
    if num>10**18:
        break
    else:
        num *=A[i]
if num>10**18:
    print(-1)
else:
    print(num)
### BUGGY CODE ###

from functools import reduce
import math

k = int(input())

s = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            s += gcd(i,j,l)

print(s)



### FIXED CODE ###

from functools import reduce
import math

k = int(input())

s = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            s += gcd(i,j,l)

print(s)