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

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

p_m=1
for n in range(N):
    p_m*=LA[n]
    
LA_absolute=[i*(-1) if i<0 else i for i in LA]


if p_m>=0:
    print(sum(LA_absolute))
else:
    print(sum(LA_absolute)-2*min(LA_absolute))

### FIXED CODE ###

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

Minus=0
Zero=0
L_absolute=[]

for i in LA:
    if i<0:
        L_absolute.append(i*(-1))
        Minus+=1
    elif i==0:
        Zero=1
    else:
        L_absolute.append(i)
        
L_absolute.sort()

if Zero==1:
    ans=sum(L_absolute)
elif Minus%2==1:
    ans=sum(L_absolute)-2*L_absolute[0]
else:
    ans=sum(L_absolute)
    
print(ans)
### BUGGY CODE ###

def resolve():
    import numpy as np
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    for m in range(k):
        B = np.zeros(n + 1, dtype=np.int64)
        for i in range(n):
            l = max(0, i - A[i])
            r = min(n, i + A[i] + 1)
            B[l] += 1
            if r < n:
                B[r] -= 1
        A = np.cumsum(B)[:-1]
        if np.all(A == n):
            break

    for a in A:
        print(a, end=" ")

resolve()


### FIXED CODE ###

from numba import jit
import numpy as np

@jit
def resolve():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())), dtype=np.int64)
    for m in range(k):
        B = np.zeros(n + 1, dtype=np.int64)
        for i in range(n):
            l = max(0, i - A[i])
            r = min(n, i + A[i] + 1)
            B[l] += 1
            if r < n:
                B[r] -= 1
        A = np.cumsum(B)[:-1]
        if np.all(A == n):
            break

    for a in A:
        print(a, end=" ")

resolve()
### BUGGY CODE ###

N = int(input())
S = input()
def Zalgo2(S):
    N = len(S)
    A = [0]*N
    A[0] = N
    i = 1
    j = 0
    while i < N:
        while i + j < N and S[j] == S[i + j]:
            j += 1
        A[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < N and k + A[k] < j:
            A[i + k] = A[k]
            k += 1
        i += k
        j -= k
    for i in range(N):
        A[i] = min(i, A[i])
    return A
print(max([max(Zalgo2(S[i:])[1:]) for i in range(N - 1)]))

### FIXED CODE ###

N = int(input())
S = input()
r = 1
ans = 0
for i in range(N):
    while True:
        if S.rfind(S[i : r + 1]) >= r + 1:
            r += 1
            ans = max(ans, r - i)
        else:
            break
print(ans)
### BUGGY CODE ###

s = input()
n = int(input())
for i in range(n):
	com = input().split()
	if com[0] == '1':
		s = s[::-1]
	else:
		s = com[2]*(com[1]=='1') + s + com[2]*(com[1]=='2')
print(s)

### FIXED CODE ###

from collections import deque

s = deque(input())
n = int(input())
status = True

for i in range(n):
	com = input().split()
	if com[0] == '1':
		status = not status
	elif int(com[1])+status == 2:
		s.appendleft(com[2])
	else:
		s.append(com[2])
        
if not status:
	s.reverse()
print("".join(s))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in range(N):
    ans = ans*A[i]

if ans<= 10**18:
    print(ans)
    exit(0)
else:
    print(-1)

### FIXED CODE ###

import sys  # sys.exit()を使いたいので

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

if 0 in a:
# 0が1つでもあれば0です
    print(0)
else:
# 0がない場合
    cur = 1  # 現在の数値
    for x in a:
        cur *= x
        if cur > 10 ** 18:
        # 10**18を超えたので終了します
            print(-1)
            sys.exit()
    print(cur)  # 10**18以下なので、出力します
### BUGGY CODE ###

#!/usr/bin/env python3
import sys

#count '<'
def count_S(S, N):
    ret=S.find('>')
    #print("<",S,N,ret)
    if ret==-1:
        ret=N
    return ret

#count '>'
def count_L(S, N):
    ret=S.find('<')
    if ret==-1:
        ret=N
    #print(">",S,N,ret)
    return ret

def count_L_slow(S, N):
    ret=0
    for i in range(N):
        if S[i:i+1]=='>':
            ret+=1
        else:
            break
    return ret

def solve(S: str):
    answer=0

    cnt_l=count_L(S,len(S))
    answer+=int((cnt_l+1)*cnt_l/2)
    i=cnt_l
    while i<len(S):
        cnt_s=count_S(S[i:],len(S[i:]))
        cnt_l=count_L(S[i+cnt_s:],len(S[i+cnt_s:]))
        answer+=int((cnt_s+1)*cnt_s/2)
        answer+=int((cnt_l+1)*cnt_l/2)
        if cnt_l>cnt_s:
           answer-=cnt_s
        else:
           answer-=cnt_l
        #answer+=(cnt_l+1)*cnt_l//2
        #print("cnt_s,cnt_l",cnt_s, cnt_l,answer)
        i+=cnt_s+cnt_l

    print(answer)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python3
import sys

#count '<'
def count_S(S, N):
    ret=S.find('>')
    #print("<",S,N,ret)
    if ret==-1:
        ret=N
    return ret

#count '>'
def count_L(S, N):
    ret=S.find('<')
    if ret==-1:
        ret=N
    #print(">",S,N,ret)
    return ret

def count_S_slow(S, ns, N):
    ret=0
    for i in range(ns,N):
        if S[i:i+1]=='<':
            ret+=1
        else:
            break
    return ret

def count_L_slow(S, ns, N):
    ret=0
    for i in range(ns,N):
        if S[i:i+1]=='>':
            ret+=1
        else:
            break
    return ret

def solve(S: str):
    answer=0
    
    numS=len(S)
    cnt_l=count_L(S,len(S))
    answer+=(cnt_l+1)*cnt_l//2
    i=cnt_l
    while i<len(S):
        cnt_s=count_S_slow(S,i,numS)
        cnt_l=count_L_slow(S,i+cnt_s,numS)
        answer+=(cnt_s+1)*cnt_s//2
        answer+=(cnt_l+1)*cnt_l//2
        if cnt_l>cnt_s:
           answer-=cnt_s
        else:
           answer-=cnt_l
        #answer+=(cnt_l+1)*cnt_l//2
        #print("cnt_s,cnt_l",cnt_s, cnt_l,answer)
        i+=cnt_s+cnt_l

    print(answer)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

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

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

dp = [10**9]*n
dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))

print(dp[n-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,k = map(int,input().split())
h = tuple(map(int,input().split()))

dp = [0] + [float("inf")]*(n-1)
for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])
### BUGGY CODE ###

a = input().split()
n = int(a[0])
m = int(a[1])
qq = int(a[2])
ll = list()
r = list()

for _ in range(m):
    a = input().split()
    ll.append(int(a[0]))
    r.append(int(a[1]))

p = list()
q = list()

for _ in range(qq):
    a = input().split()
    p.append(int(a[0]))
    q.append(int(a[1]))

x = [[0] * n for _ in range(n)]

for i in range(m):
    x[ll[i] - 1][r[i] - 1] += 1

c = list()

for i in range(n):
    c.append(list())
    for j in range(n):
        a = x[i][j]

        if 0 < j:
            a += c[i][j - 1]

        c[i].append(a)

for i in range(qq):
    r = 0

    for j in range(p[i] - 1, q[i]):
        r += c[j][q[i] - 1]
        if 1 < p[i]:
            r -= c[j][p[i] - 2]

    print(r)


### FIXED CODE ###

a = input().split()
n = int(a[0])
m = int(a[1])
qq = int(a[2])

x = [[0] * n for _ in range(n)]

for _ in range(m):
    a = input().split()
    x[int(a[0]) - 1][int(a[1]) - 1] += 1

c = list()

for i in range(n):
    c.append(list())
    for j in range(n):
        a = x[i][j]

        if 0 < j:
            a += c[i][j - 1]

        c[i].append(a)

z = list()

for i in range(n):
    z.append(list())
    for j in range(n):
        a = c[i][j]

        if 0 < i:
            a += z[i - 1][j]

        z[i].append(a)

for _ in range(qq):
    r = 0
    a = input().split()
    p = int(a[0])
    q = int(a[1])

    if 0 < q:
        r += z[q - 1][q - 1]

    if 0 < q and 1 < p:
        r -= z[q - 1][p - 2] + z[p - 2][q - 1]

    if 1 < p:
        r += z[p - 2][p - 2]

    print(r)
### BUGGY CODE ###

from math import sqrt
N, P = list(map(int, input().split()))
if N == 1:
    print(P)
    exit()

ans = 1
tmp = P
# start = int(sqrt(P))
# for i in range(start, 1, -1):
#     newtmp, rest = divmod(tmp, (i**N))
#     print(i, tmp, rest, ans)
#     if rest == 0:
#         ans = ans * i
#         tmp = newtmp

for i in range(2, int(sqrt(P)) + 1):
    while True:
        newtmp, rest = divmod(tmp, (i**N))
        # print(i, tmp, rest, ans)
        if rest:
            break
        else:
            ans = ans * i
            tmp = newtmp
    if newtmp == 0:
        break

print(ans)


### FIXED CODE ###

N, P = list(map(int, input().split()))
if N == 1:
    print(P)
    exit()
elif P == 1:
    print("1")
    exit()

ans = 1
tmp = P

for i in range(2, int(pow(P, 1 / N)) + 1):
    po = pow(i, N)
    while tmp % po == 0:
        tmp = tmp // po
        ans = ans * i
        # print(i, tmp, ans)

    if tmp < po:
        break

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

_, *_XL = open(0).read().split()

XL = list(zip(*[map(int, iter(_XL))]*2))

ans = 0
t = -10**10 # 数直線のマイナス方向からスタートする

arms = [(X-L, X+L) for X, L in XL]

arms_sorted = sorted(arms, key=lambda k:k[1])

for s, e in arms_sorted:
    if t <= s:
        t = e
    else:
        arms.remove((s, e))

print(len(arms))

### FIXED CODE ###

_, *_XL = open(0).read().split()

XL = list(zip(*[map(int, iter(_XL))]*2))

ans = 0
t = -10**10 # 数直線のマイナス方向からスタートする

arms = [(X-L, X+L) for X, L in XL]
arms_sorted = sorted(arms, key=lambda k:k[1])

ans = 0

for s, e in arms_sorted:
    if t <= s:
        t = e
        ans += 1
        
print(ans)
### BUGGY CODE ###

class Trie:
    class Node:
        def __init__(self,c):
            self.c=c
            self.next_c_id={}
            #self.common=0
            self.end=-1

    def __init__(self):
        self.trie=[self.Node('')]
    
    def add(self,id,s):
        i=0
        now=0
        ary=[0]
        while i<len(s) and s[i] in self.trie[now].next_c_id:
            now=self.trie[now].next_c_id[s[i]]
            ary.append(now)
            #self.trie[now].common+=1
            i+=1
        while i<len(s):
            self.trie[now].next_c_id[s[i]]=len(self.trie)
            now=len(self.trie)
            ary.append(now)
            self.trie.append(self.Node(s[i]))
            #self.trie[now].common+=1
            i+=1
        self.trie[now].end=id
        return ary
    
    def search(self,s):
        i=0
        now=0
        ary=[0]
        while i<len(s) and s[i] in self.trie[now].next_c_id:
            now=self.trie[now].next_c_id[s[i]]
            ary.append(now)
            i+=1
        if i<len(s):return []
        return ary

def main(s):
    tr=Trie()
    s.sort(key=lambda x:len(x))
    #for id,x in enumerate(s):
    #    tr.add(id,x)
    ans=0
    for i,x in enumerate(s):
        ary=tr.add(i,x)
        #ary=tr.search(x)
        seen=set(())
        #print(x,ary)
        while ary:
            id=ary.pop()
            for nv in seen.intersection(tr.trie[id].next_c_id.keys()):
                if tr.trie[tr.trie[id].next_c_id[nv]].end>=0 and tr.trie[tr.trie[id].next_c_id[nv]].end!=i:
                    ans+=1
            seen.add(tr.trie[id].c)
        #print(x,ans)
    print(ans)

if __name__=='__main__':
    n=int(input())
    s=[list(input()) for _ in range(n)]
    [x.reverse() for x in s]
    main(s)


### FIXED CODE ###

class Trie:
    class Node:
        def __init__(self,c):
            self.c=c
            self.next_c_id={}
            #self.common=0
            self.end=-1

    def __init__(self):
        self.trie=[self.Node('')]
    
    def add(self,id,s):
        i=0
        now=0
        ary=[0]
        while i<len(s) and s[i] in self.trie[now].next_c_id:
            now=self.trie[now].next_c_id[s[i]]
            ary.append(now)
            #self.trie[now].common+=1
            i+=1
        while i<len(s):
            self.trie[now].next_c_id[s[i]]=len(self.trie)
            now=len(self.trie)
            ary.append(now)
            self.trie.append(self.Node(s[i]))
            #self.trie[now].common+=1
            i+=1
        self.trie[now].end=id
        return ary

def main(s):
    tr=Trie()
    s.sort(key=lambda x:len(x))
    ans=0
    for i,x in enumerate(s):
        ary=tr.add(i,x)
        seen=set(())
        while ary:
            id=ary.pop()
            for nv in seen&tr.trie[id].next_c_id.keys():
                if tr.trie[tr.trie[id].next_c_id[nv]].end>=0 and tr.trie[tr.trie[id].next_c_id[nv]].end!=i:
                    ans+=1
            seen.add(tr.trie[id].c)
    print(ans)

if __name__=='__main__':
    a2n=lambda x:ord(x)-ord('a')
    n=int(input())
    s=[list(map(a2n,list(input()))) for _ in range(n)]
    [x.reverse() for x in s]
    main(s)
### BUGGY CODE ###

a=int(input())
num=[int(i) for i in input().split()]
num_dict={}
for i in num:
    if i not in num_dict:
        num_dict[i]=1
    else:
        num_dict[i]+=1
for i in range(a):
    counter=0
    tmp=num_dict[num[i]]-1
    for key,value in num_dict.items():
        if key==num[i]:
            value=tmp
        if value>=2:
            counter+=int(value*(value-1)/2)
    print(counter)

### FIXED CODE ###

a=int(input())
num=[int(i) for i in input().split()]
num_dict={}
num_min1_dict={}
sum_num=0
for i in num:
    if i not in num_dict:
        num_dict[i]=1
    else:
        num_dict[i]+=1

num_to_sum_dict={}
for key, value in num_dict.items():
    sum_num+=value*(value-1)/2

for key,value in num_dict.items():
    tmp=sum_num-value*(value-1)/2+(value-1)*(value-2)/2
    num_to_sum_dict[key]=tmp

for i in range(a):
    print(int(num_to_sum_dict[num[i]]))
### BUGGY CODE ###

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

ans = 10 ** 9
for Y in As:
    cands = []
    cs = []
    for A in As + [0]: # 最終要素は番兵
        if A < Y:
            cands += sorted(cs)[:max(0, len(cs) - K + 1)]
            cs = []
        else:
            cs += [A]

    if len(cands) < Q: continue
    X = sorted(cands)[Q - 1]

    ans = min(ans, X - Y)

print(ans)


### FIXED CODE ###

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

ans = 10 ** 9
for Y in sorted(As)[:N - Q - K + 2]:
    cands = []
    cs = []
    for A in As + [0]: # 最終要素は番兵
        if A < Y:
            if len(cs) >= K:
                cands += sorted(cs)[:len(cs) - K + 1]
            cs = []
        else:
            cs += [A]

    if len(cands) < Q: continue
    X = sorted(cands)[Q - 1]

    ans = min(ans, X - Y)

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

import sys
input = sys.stdin.readline

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

DP=[[-1]*N for i in range(N)]
for i in range(N):
    for j in range(N):
        DP[i][j]=min(i,j,N-1-i,N-1-j)

USED=[[1]*N for i in range(N)]
ANS=0
    
for p in P:
    q,r=divmod(p-1,N)
    ANS+=DP[q][r]
    DP[q][r]-=1
    USED[q][r]=0

    Q=[(q,r)]

    while Q:
        x,y=Q.pop()

        for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
            if 0<=z<N and 0<=w<N:
                if DP[z][w]>DP[x][y]+USED[z][w]:
                    DP[z][w]=DP[x][y]+USED[z][w]
                    Q.append((z,w))

print(ANS)

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

DP=[[0]*N for i in range(N)]
for i in range(N):
    for j in range(N):
        DP[i][j]=min(i,j,N-1-i,N-1-j)

USED=[[1]*N for i in range(N)]
ANS=0

def update(z,w):
    if 0<=z<N and 0<=w<N:
        if DP[z][w]>DP[x][y]+USED[z][w]:
            DP[z][w]=DP[x][y]+USED[z][w]
            Q.append((z,w))
    

for p in P:
    q,r=divmod(p-1,N)
    ANS+=DP[q][r]
    DP[q][r]-=1
    USED[q][r]=0

    Q=[(q,r)]

    while Q:
        x,y=Q.pop()

        update(x+1,y)
        update(x-1,y)
        update(x,y+1)
        update(x,y-1)

print(ANS)
### BUGGY CODE ###


def main():
    h, n = map(int, input().split())
    ab = []
    for i in range(n):
        ab.append(tuple(map(int, input().split())))

    dp = []
    for i in range(h+1):
        dp.append(10**18)
    dp[h] = 0
    for i in range(h, 0, -1):
        for j in range(n):
            dp[max(0, i-ab[j][0])] = min(dp[max(0, i - ab[j][0])], dp[i] + ab[j][1])

    print(dp[0])


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    h, n = map(int, input().split())
    ab = []
    for i in range(n):
        ab.append(tuple(map(int, input().split())))

    dp = []
    for i in range(h+1):
        dp.append(10**18)
    dp[h] = 0
    for i in range(h, 0, -1):
        for j in range(n):
            dp[max(0, i-ab[j][0])] = min(dp[max(0, i - ab[j][0])], dp[i] + ab[j][1])

    print(dp[0])


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

n = int(input())
x_bin = input()
x = int(x_bin, 2)

pc = x_bin.count('1')
pc_p = pc + 1
pc_m = pc - 1

d = {0: 1}
for i in range(1, n):
    d[i] = d[i-1] * 2

rest = {0: 0}
for i in range(1, pc + 1):
    rest[i] = rest[i % bin(i).count('1')] + 1

for i in range(n, 0, -1):
    if x_bin[n-i] == '1':
        if pc_m != 0:
            a = (x - d[i-1]) % pc_m
            print(rest[a] + 1)
        else:
            print(0)
    else:
        a = (x + d[i-1]) % pc_p
        print(rest[a] + 1)


### FIXED CODE ###

n = int(input())
x_bin = input()
x = int(x_bin, 2)

pc = x_bin.count('1')
pc_p = pc + 1
pc_m = pc - 1

if pc == 1:
    for i, v in enumerate(x_bin):
        if v == '1':
            print(0)
        else:
            if i != n-1:
                if x_bin[-1] == '0':
                    print(1)
                else:
                    print(2)
            else:
                print(2)
    exit()

p = {0: 1}
m = {0: 1}
for i in range(1, n):
    p[i] = p[i-1]*2 % pc_p
    m[i] = m[i-1]*2 % pc_m

rest = {0: 0}
for i in range(1, pc + 1):
    rest[i] = rest[i % bin(i).count('1')] + 1

x_p = x % pc_p
x_m = x % pc_m

for i in range(n, 0, -1):
    if x_bin[n-i] == '1':
        a = (x_m - m[i-1]) % pc_m
        print(rest[a] + 1)
    else:
        a = (x_p + p[i-1]) % pc_p
        print(rest[a] + 1)
### BUGGY CODE ###

import math 
a,b,n=map(int,input().split())
def calc(x):
    global a,b
    return math.floor(a*x/b)-a*math.floor(x/b)
kind=set()
bef=-100
count=0
for i in range(1,n+1):
    num=calc(i)
    if num in kind:
        if 0==num:
            if bef!=0:
                if count==0:
                    count+=1
                else:
                    break
    kind.add(num)
    bef=num
print(max(kind))

### FIXED CODE ###

import math
a,b,n=map(int,input().split())
def calc(x):
    global a,b
    return math.floor(a*x/b)-a*math.floor(x/b)
print(calc(min(n,b-1)))
### BUGGY CODE ###

S=list(map(str,input()))
N=len(S)
M=(N//10+1)*10
Q=[0]*N
for i in range(N):
  p=i
  for j in range(M):
    if S[p]=="R":
      p=p+1
    else:
      p=p-1
  Q[p]=Q[p]+1
print(*Q)

### FIXED CODE ###

S=list(map(str,input()))
N=len(S)
Q=[0]*N
R=[]
R1=[0]*N
L1=[0]*N
L=[]
V=[0]*N
for i in range(0,N):
  if S[i]=="R" and S[i+1]=="L":
    R.append(i)
  elif S[i]=="L" and S[i-1]=="R":
    L.append(i)
  else: V[i]=1

for i in R+L:
  Q[i]=1

x=0
for r in R:
  while x!=r:
    R1[x]=r
    x=x+1
x=N-1
for l in reversed(L):
  while x!=l:
    L1[x]=l
    x=x-1

for i in range(N):
  if V[i]==1:
    if S[i]=="R":
      if (R1[i]-i)%2==0:
        Q[R1[i]]=Q[R1[i]]+1
      else:
        Q[R1[i]+1]=Q[R1[i]+1]+1
    else:
      if (i-L1[i])%2==0:
        Q[L1[i]]=Q[L1[i]]+1
      else:
        Q[L1[i]-1]=Q[L1[i]-1]+1

print(*Q)
### BUGGY CODE ###

n = int(input())
a = [ int(i) for i in input().split()]
b = []
for i in range(n):
    b.append((a.index(i+1))+1)
print(*b)
    


### FIXED CODE ###

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

def main():
    R, G, B, N = [int(x) for x in input().split()]

    ct = 0
    for r in range(N + 1):
        for g in range(N + 1):
            b = (N-R*r-G*g) / B
            if b < 0: continue
            if (b % 1) == 0:
                ct += 1

    print(ct)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    R, G, B, N = [int(x) for x in input().split()]

    ct = 0
    for r in range(N + 1):
        for g in range(N + 1):
            b = (N-R*r-G*g) / B
            if b < 0: break
            if (b % 1) == 0:
                ct += 1

    print(ct)

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

N = int(input())
AN = list((map(int,input().split(" "))))

AN.sort(reverse=True)

num = 0
count = 0

def bbb(ccc):
    ddd = ccc
    while True:
        if ddd == 2:
            return True
        ddd = ddd / 2
        if ddd % 2 != 0:
            return False

while True:

    if len(AN) == 0:
        break

    A = AN.pop(num)

    for i in range(len(AN)):
        if bbb(A + AN[i]):
            AN.pop(i)
            count += 1
            break

print(count)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split(" ")))
A.sort()
used = [0] * N
pow2_set = reversed([ 1<<i for i in range(36)])
ans = 0
for pow2 in pow2_set:
    l,r = 0,N-1
    while l < r:
        if A[l] + A[r] < pow2:
            l += 1
        elif A[l] + A[r] == pow2:
            if used[l] == 0 and used[r] == 0:
                ans += 1
                used[l],used[r] = 1,1
            else:
                if used[l] == 1:
                    l += 1
                if used[r] == 1:
                    r -= 1
        else:
            r -= 1
 
print(ans)
### BUGGY CODE ###

def main():
    s = input()
    mod = 2019

    s2 = ''
    R = [0] * mod
    R[0] += 1
    for i in range(len(s)):
        s2 = ''.join([s[-i - 1], s2])
        R[int(s2) % mod] += 1

    print(sum([r * (r - 1) // 2 for r in R]))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    s = input()
    mod = 2019

    n = 0
    R = [0] * mod
    R[0] += 1
    for i in range(len(s)):
        n += int(s[-i - 1]) * pow(10, i, mod)
        R[n % mod] += 1

    print(sum([r * (r - 1) // 2 for r in R]))


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

N = int(input())
A = []
tmp = 0
for i in range(N):
  A.append(int(input()))
for j in range(N):
  tmp = A[j]
  A[j] = 0
  print(max(A))
  A[j] = tmp

### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
A_sort = list(sorted(A))
for i in range(N):
  print([A_sort[-2], A_sort[-1]][A[i] < A_sort[-1]])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys

N,M=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

match=[None,2,5,5,4,5,6,3,7,6]

dp=[ None for i in range(N+1) ] 
dp[0]=""

for i in range(N+1):
	for a in A:
		match_cnt=match[a]
		if 0<=i-match_cnt and dp[i-match_cnt] is not None:
			if dp[i] is None:
				dp[i]=dp[i-match_cnt]+str(a)
			else:
				if int(dp[i])<int( dp[i-match_cnt]+str(a) ):
					dp[i]=dp[i-match_cnt]+str(a)
				
print dp[N]


### FIXED CODE ###

T=[(1,2),(2,5),(3,5),(4,4),(5,5),(6,6),(7,3),(8,7),(9,6)]

N,M=map(int, raw_input().split())
A=map(int, raw_input().split())


P=[]
for i in A:
	P.append(T[i-1])


dp=[ None for i in range(N+1) ]
dp[0]=""


for i in range(N):
	#print "i :::: ",i,dp
	if dp[i] is not None:
		for num, match in P:
			if i+match<=N:

				if dp[i+match] is None:
					dp[i+match]=dp[i]+str(num)
				else:
					l1=len(dp[i+match])
					l2=len(dp[i]+str(num))
					if l1>l2:
						pass
					elif l1<l2:
						dp[i+match]=dp[i]+str(num)
					else:
						dp[i+match]=max( dp[i+match] , dp[i]+str(num) )


print dp[N]