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

def main():
    from itertools import accumulate
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10 ** 9 + 7

    X = [[0] * N for i in range(61)]
    for i, a in enumerate(A):
        for j in range(61):
            if (1 << j) & a:
                X[j][i] = 1

    for i in range(61):
        X[i] = list(accumulate((X[i])))


    ans = 0
    for i, a in enumerate(A):
        for j in range(61):
            x = X[j][-1] - X[j][i]
            if (1 << j) & a:
                ans += (1 << j) * ((N - i - 1) - x)
                ans %= MOD

            else:
                ans += (1 << j) * x
                ans %= MOD


    print(ans % MOD)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    def accumulate(array):
        for i in range(len(array) - 1):
            array[i + 1] += array[i]
        return array

    N = int(input())
    A = list(map(int, raw_input().split()))
    MOD = 10 ** 9 + 7

    X = [[0] * N for i in range(61)]
    for i, a in enumerate(A):
        for j in range(61):
            if (1 << j) & a:
                X[j][i] = 1

    for i in range(61):
        X[i] = accumulate(X[i])


    ans = 0
    for i, a in enumerate(A):
        for j in range(61):
            x = X[j][-1] - X[j][i]
            if (1 << j) & a:
                ans += ((1 << j) % MOD) * ((N - i - 1) - x)
                ans %= MOD

            else:
                ans += ((1 << j) % MOD) * x
                ans %= MOD


    print(ans % MOD)


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


def main():

    N,M = map(int,input().split())
    A = [i for i in map(int,input().split())]

    for i in range(M):
        B,C = map(int,input().split())
        A.sort()
        tarLen=len([i for i in A if i < C])
        B = tarLen if tarLen < B else B
        for i in range(B):
            A[i]=C
            B -= 1
    
    print(sum(A))


if __name__== "__main__":
    main() 


### FIXED CODE ###


def main():

    N,M = map(int,input().split())
    A = [i for i in map(int,input().split())]
    A.sort()
    tmpC = 0
    targetList = []

    for i in range(M):

        element = list(map(int,input().split()))
        targetList.append(element)

    targetList.sort(key=lambda x:x[1],reverse=True)
    
    flag = False
    ans = 0
    for b,c in targetList:
        for j in range(b):
            if N > tmpC and A[tmpC] < c:
                ans += c
                tmpC +=1
            else:
                flag = True
                break
        if flag:
            break
    
    if tmpC < N:

        ans += sum(A[tmpC:])


    print(ans)






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

a = int(input())
b = list(map(int, input().split()))
c = 0
for i in range(a-1):
  for j in range(1,a-i):
     c += b[i]*b[i+j]
print(c % (10**9+7))



### FIXED CODE ###

a = int(input())
b = list(map(int, input().split()))
c = 0
sum = sum(b)
for i in range(a-1):
  sum = sum - b[i]
  c += b[i]*(sum)
print(c%(10**9+7))
### BUGGY CODE ###

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

l.sort()
cnt = 0
import itertools
import bisect
for a, b in itertools.combinations(l, r=2):
  #print(a, b, end=' : ')

  left = bisect.bisect_left(l, max(a - b, b))
  right = bisect.bisect_right(l, a + b - 1)

  #print(left, right)
  
  cs = right - left
  if left <= bisect.bisect_left(l, a) <= right:
    cs -= 1
  if left <= bisect.bisect_left(l, b) <= right:
    cs -= 1
  if cs > 0:
    cnt += cs

print(cnt)


### FIXED CODE ###

import bisect

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

l.sort()

ans=0
for i in range(n):
  for j in range(i+1,n):
    a=l[i]
    b=l[j]
    le=bisect.bisect_left(l,max(a-b,b-a)+1)
    ri=bisect.bisect_right(l,a+b-1)
    #print(le,ri)
    f=0
    if le<=i<=ri:
      f-=1
    if le<=j<=ri:
      f-=1
    if ri-le+f>0:
      ans+=ri-le+f
    #print(a,b,ans)

print(ans//3)
### BUGGY CODE ###

from collections import deque
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
d=deque()
b=[]
for i in range(h):
  s=input()
  for j in range(w):
    if s[j]=="#":d.append([i,j])
  b.append(list(s))
count=0
while len(d)!=0:
  for i in range(len(d)):
    x=d.popleft()
    if x[0]<h-1:
      if b[x[0]+1][x[1]]==".":b[x[0]+1][x[1]]=count;d.append([x[0]+1,x[1]])
    if 0<x[0]:
      if b[x[0]-1][x[1]]==".":b[x[0]-1][x[1]]=count;d.append([x[0]-1,x[1]])
    if x[1]<w-1:
      if b[x[0]][x[1]+1]==".":b[x[0]][x[1]+1]=count;d.append([x[0],x[1]+1])
    if 0<x[1]:
      if b[x[0]][x[1]-1]==".":b[x[0]][x[1]-1]=count;d.append([x[0],x[1]-1])
  count+=1
print(count-1) 

### FIXED CODE ###

from collections import deque
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
d=deque()
dc=0
b=[]
for i in range(h):
  t=[]
  s=input()
  for j in range(w):
    if s[j]=="#":d.append((i,j));dc+=1;t.append(1)
    else:t.append(0)
  b.append(t)
count=0
while dc!=0:
  ld=dc
  dc=0
  for i in range(ld):
    x=d.popleft()
    if x[0]<h-1:
      if b[x[0]+1][x[1]]==0:b[x[0]+1][x[1]]=1;d.append((x[0]+1,x[1]));dc+=1
    if 0<x[0]:
      if b[x[0]-1][x[1]]==0:b[x[0]-1][x[1]]=1;d.append((x[0]-1,x[1]));dc+=1
    if x[1]<w-1:
      if b[x[0]][x[1]+1]==0:b[x[0]][x[1]+1]=1;d.append((x[0],x[1]+1));dc+=1
    if 0<x[1]:
      if b[x[0]][x[1]-1]==0:b[x[0]][x[1]-1]=1;d.append((x[0],x[1]-1));dc+=1
  count+=1
print(count-1)
### BUGGY CODE ###

import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, M = map(int, input().split())
e = dd(list)

for _ in range(M):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)
mxd = 0
res = [[-1] * 11 for _ in range(N + 1)]
Q = int(input())
qd = [0] * Q
qc = [0] * Q
for i in range(Q):
  v, d, c = map(int, input().split())
  qd[i] = d
  qc[i] = c
  res[v][d] = i
  mxd = max(mxd, d)
#print(qc)

#print(mxd)
for t in range(mxd):
  tres = [x[: ] for x in res]
  for x in range(1, N + 1):
    for y in e[x]:
      for i in range(t + 1, 11):
        tres[y][i] = max(tres[y][i], res[x][i])
  res = tres
#print(res)
for r in res[1: ]:
  x = -1
  for i in range(11):
    if r[i] != -1: x = max(x, r[i])
  if x == -1: print(0)
  else: print(qc[x])

### FIXED CODE ###

import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, M = map(int, input().split())
e = dd(list)

for _ in range(M):
  u, v = map(int, input().split())
  e[u].append(v)
  e[v].append(u)
mxd = 0
res = [[-1] * 11 for _ in range(N + 1)]
Q = int(input())
qd = [0] * Q
qc = [0] * Q
for i in range(Q):
  v, d, c = map(int, input().split())
  qd[i] = d
  qc[i] = c
  res[v][d] = i
  mxd = max(mxd, d)
#print(qc)

#print(mxd)
for t in range(mxd):
  tres = [x[: ] for x in res]
  for x in range(1, N + 1):
    for y in e[x]:
      for i in range(t + 1, 11):
        res[y][i] = max(res[y][i], tres[x][i])

#print(res)
for r in res[1: ]:
  x = -1
  for i in range(11):
    if r[i] != -1: x = max(x, r[i])
  if x == -1: print(0)
  else: print(qc[x])
### BUGGY CODE ###

def main():
    n = int(input())
    p = list(map(int, input().split()))
    count = 0
    for i in range(n):
        min_i = min(p[:i+1])
        if p[i] == min_i:
            count += 1
    print(count)


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n = int(input())
    p = list(map(int, input().split()))
    count = 0
    min_num = n+1
    for i in p:
        if i < min_num:
            min_num = i
            count += 1
    print(count)


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

goods,coupon=map(int,input().split())
l=sorted(list(map(int,input().split())),reverse=True)
for i in range(coupon):
  l[0]/=2
  l.sort(reverse=True)
print(sum(list(map(int,l))))

### FIXED CODE ###

import heapq
n,m=map(int,input().split())
l=list(map(lambda x:-int(x),input().split()))
heapq.heapify(l)
for _ in range(m):
  heapq.heappush(l,-(-heapq.heappop(l)//2))
print(-sum(l))
### BUGGY CODE ###

from collections import Counter

N = int(input())
s = input()
cnt = Counter(s)
R = cnt.get('R', 0)
G = cnt.get('G', 0)
B = cnt.get('B', 0)
ans = R * G * B
for i in range(N-1):
  for j in range(i+1, N):
    if s[i] != s[j] and 2*j-i < N and s[i] != s[2*j-i] and s[j] != s[2*j-i]:
      ans -= 1
print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
s = input()
cnt = Counter(s)
R = cnt.get('R', 0)
G = cnt.get('G', 0)
B = cnt.get('B', 0)
ans = R * G * B
for i in range(N-1):
  for j in range(i+1, N):
    if s[i] != s[j] and 2*j-i < N and s[i] != s[2*j-i] and s[j] != s[2*j-i]:
      ans -= 1
print(ans)
### BUGGY CODE ###

def resolve():
    import numpy as np
    from scipy.sparse.csgraph import shortest_path
    from scipy.sparse import csr_matrix
    n, x, y = map(int, input().split())
    netw = np.zeros((n, n))
    for i in range(n):
        for j in range(n):
            if abs(j-i) == 1:
                netw[i][j] = 1
    netw[x-1][y-1] = 1
    netw[y-1][x-1] = 1
    netw = np.array(netw)
    ans = {}
    a = shortest_path(netw)
    for i in range(n-1):
        for j in range(i+1, n):
            if a[i][j] in ans:
                ans[a[i][j]] += 1
            else:
                ans[a[i][j]] = 1
    for i in range(1, n):
        if i in ans:
            print(ans[i])
        else:
            ans[i] =0
            print(ans[i])
        
resolve()

### FIXED CODE ###

def resolve():
    n,x,y = map(int, input().split())
    ans = {}
    for i in range(1, n):
        for j in range(i+1, n+1):
            dist1 = j-i
            dist2 = abs(x-i)+1+abs(y-j)
            dist =min (dist1, dist2)
            if dist in ans:
                ans[dist] += 1
            else:
                ans[dist] = 1
    for i in range(1,n):
        if i not in ans:
            ans[i] =0
        print(ans[i])
resolve()
### BUGGY CODE ###

from collections import Counter

N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353

Pre = [[Counter() for _ in range(S+1)] for _ in range(N+1)]

Pre[0][0][0] = 1

for i, a in enumerate(A):
    for j in range(S+1):
        if len(Pre[i][j]) > 0:
            Pre[i + 1][j] += Pre[i][j]
        if a + j <= S:
            for key, value in Pre[i][j].items():
                Pre[i + 1][j + a][key + 1] += value
ans = 0
for key, value in Pre[N][S].items():
    ans += pow(2, N - key, mod) * value
    ans %= mod

print(ans % mod)

### FIXED CODE ###

import numpy as np

N, S = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
f = np.zeros(3100, np.int64)

ans = 0
f[0] = 1
for a in A:
    g = f.copy()
    f[a:] += g[:-a]
    f += g
    f %= mod

print(f[S])
### BUGGY CODE ###

import sys
from collections import deque
H, W = map(int, input().split())
c = [int(i) + 1 for i in input().split()]
d = [int(i) + 1 for i in input().split()]

s = []
s.append('#'*(W+4))
s.append('#'*(W+4))
for i in range(H):
    a = input()
    s.append('##' + a + '##')
s.append('#'*(W+4))
s.append('#'*(W+4))

q = deque([]) # 探索開始点
qq = deque([])
q.append((c[0], c[1], 0))
visited = [[False for __ in range(W+4)] for _ in range(H+4)]

while q:
    xx, yy, kaisuu = q.popleft()
    if visited[xx][yy] == True:
        continue
    qq.append((xx, yy))
    ls = deque()
    while qq:
        x, y = qq.pop()
        visited[x][y] = True
        ls.append((x, y, kaisuu))
        if x == d[0] and y == d[1]:
            num = 0
            for i in range(10**100):
                num += 1
            print(kaisuu)
            sys.exit()
        if s[x+1][y] == '.' and visited[x+1][y] == False:
            qq.append((x+1, y))
        if s[x-1][y] == '.' and visited[x-1][y] == False:
            qq.append((x-1, y))
        if s[x][y+1] == '.' and visited[x][y+1] == False:
            qq.append((x, y+1))
        if s[x][y-1] == '.' and visited[x][y-1] == False:
            qq.append((x, y-1))
    for u in ls:
        a, b, e = u
        for i in range(-2, 3):
            for j in range(-2, 3):
                if i == 0 and j == 0:
                    continue
                if abs(i) == 1 and abs(j) == 1:
                    continue
                if s[a+i][b+j] == '.' and visited[a+i][b+j] == False:
                    q.append((a+i, b+j, e+1))
print(-1)

### FIXED CODE ###

import sys
from collections import deque
H, W = map(int, input().split())
c = [int(i) + 1 for i in input().split()]
d = [int(i) + 1 for i in input().split()]

s = []
s.append('#'*(W+4))
s.append('#'*(W+4))
for i in range(H):
    a = input()
    s.append('##' + a + '##')
s.append('#'*(W+4))
s.append('#'*(W+4))

q = deque([]) # 探索開始点
qq = deque([])
q.append((c[0], c[1], 0))
visited = [[False for __ in range(W+4)] for _ in range(H+4)]

while q:
    xx, yy, kaisuu = q.popleft()
    if visited[xx][yy] == True:
        continue
    qq.append((xx, yy))
    ls = deque()
    while qq:
        x, y = qq.pop()
        visited[x][y] = True
        ls.append((x, y, kaisuu))
        if x == d[0] and y == d[1]:
            print(kaisuu)
            sys.exit()
        if s[x+1][y] == '.' and visited[x+1][y] == False:
            qq.append((x+1, y))
        if s[x-1][y] == '.' and visited[x-1][y] == False:
            qq.append((x-1, y))
        if s[x][y+1] == '.' and visited[x][y+1] == False:
            qq.append((x, y+1))
        if s[x][y-1] == '.' and visited[x][y-1] == False:
            qq.append((x, y-1))
    for u in ls:
        a, b, e = u
        for i in range(-2, 3):
            for j in range(-2, 3):
                if i == 0 and j == 0:
                    continue
                if abs(i) == 1 and abs(j) == 0:
                    continue
                if abs(j) == 1 and abs(i) == 0:
                    continue
                if s[a+i][b+j] == '.' and visited[a+i][b+j] == False:
                    q.append((a+i, b+j, e+1))
print(-1)
### BUGGY CODE ###

h, w = map(int, input().split())
maze = []
for i in range(h):
    maze.append(list(input()))

import collections
#print(dat)
def clear_maze(sx, sy, gx, gy):
    INF = 100000000
    field_x_length = len(maze)
    field_y_length = len(maze[0])
    distance = [[INF for i in range(40)] for j in range(40)]
    def bfs():
        queue = collections.deque([])
        queue.appendleft((sx, sy))
        distance[sx][sy] = 0
        while len(queue):
            x, y = queue.pop()
            if x == gx and y == gy:
                break
            #print("seek {0} {1}".format(x, y))
            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
                if (0 <= nx and nx < field_x_length and 0 <= ny and ny < field_y_length and maze[nx][ny] != '#' and distance[nx][ny] == INF):
                    queue.appendleft((nx, ny))
                    distance[nx][ny] = distance[x][y] + 1
        return distance[gx][gy]
    return bfs()

res = -1
for yy in range(0, h):
    for xx in range(0, w):
        if maze[yy][xx] == "#":
            continue
        for yyy in range(yy, h):
            for xxx in range(0, w):
                if maze[yyy][xxx] == "#":
                    continue
                step = clear_maze(yy, xx, yyy, xxx)
                #print("s={0},{1} g={2},{3} cost = {4}".format(xx,yy,xxx,yyy,step))
                if step == 100000000:
                    continue
                res = max(res, step)
print(res)


### FIXED CODE ###

from pprint import pprint

INF = 1000000
dx = [1, -1, 0,  0]
dy = [0,  0, 1, -1]

# 入力
h, w = map(int, input().split())
maze = []
for i in range(h):
    maze.append(list(input()))

# ワーシャルフロイド用に枠を作る。
# 2次元マップしてもいいが面倒なので、１次元にする。[0 - x][0 - y]を[0- x * y]にflattenする
wsmap = lambda a, b: (a * w + b)
dp = []
# 辺がない時はINFを入れのでデフォルト値とする
for i in range(h * w):
    dp.append([INF] * (h * w))

# 迷路ををグラフにする。
for y in range(h):
    for x in range(w):
        if maze[y][x] == "#": # そのマスが壁なら何もしない(他のマストの連結はないので)
            continue
        # ワーシャルフロイドでは自分自身へのコストは0にしておく。
        dp[wsmap(y, x)][wsmap(y, x)] = 0
        # ４方向に移動できるかの判定
        for dir in range(len(dx)):
            nx, ny = x + dx[dir], y + dy[dir]
            if -1 < nx and nx < w and -1 < ny and ny < h: # 枠をはみ出ないかチェック
                if maze[ny][nx] != "#": # そのマスが壁でないなら
                    #print(wsmap(y, x))
                    #print("--")
                    #print("y, x {0}, {1}".format(ny, nx))
                    #print(wsmap(ny, nx))
                    dp[wsmap(y, x)][wsmap(ny, nx)] = 1 # コストを1にする

# ワーシャルフロイドする
for kk in range(h * w):
    for ii in range(h * w):
        for jj in range(h * w):
            dp[ii][jj] = min(dp[ii][jj], dp[ii][kk] + dp[kk][jj])

# これで結果が出たので
#print(dp)
res = -1
for i in range(h * w):
    for j in range(h * w):
        if dp[i][j] != INF:
            res = max(res, dp[i][j])
print(res)
### BUGGY CODE ###

ns = int(raw_input())
s = list(set(raw_input().split()))
nt = int(raw_input())
t = raw_input().split()
ans = 0
for i in t:
	if i in s: ans += 1
print ans

### FIXED CODE ###

input()
l = raw_input().split()
input()
print len(set(l) & set(raw_input().split()))
### BUGGY CODE ###

mod=10**9+7
n=int(input())
T=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
Tres=[0]*n
Ares=[0]*n
Tres[0]=[0,T[0]]
Ares[-1]=[0,A[-1]]
for i in range(1,n):
  if T[i]!=T[i-1]:
    Tres[i]=[0,T[i]]
  else:
    Tres[i]=[1,T[i]]
  if A[-i-1]!=A[-i]:
    Ares[-i-1]=[0,A[-i-1]]
  else:
    Ares[-i-1]=[1,A[-i-1]]
ans=1
for i in range(n):
  ta,tb=Tres[i]
  aa,ab=Ares[i]  
  if ta==1 and aa==1:
    ans*=min(tb,ab)%mod
  elif ta==0 and aa==1 and tb>ab:
    ans=0
  elif ta==1 and aa==0 and tb<ab:
    ans=0
  elif ta==0 and aa==0 and tb!=ab:
    ans=0
print(ans%mod)

### FIXED CODE ###

mod=10**9+7
n=int(input())
T=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
Tres=[0]*n
Ares=[0]*n
Tres[0]=(0,T[0])
Ares[n-1]=(0,A[n-1])
for i in range(1,n):
  if T[i]>Tres[i-1][1]:
    Tres[i]=(0,T[i])
  else:
    Tres[i]=(1,T[i])
  if A[n-i-1]>Ares[n-i][1]:
    Ares[n-i-1]=(0,A[n-i-1])
  else:
    Ares[n-i-1]=(1,A[n-i-1])
if Tres[0]<=Ares[0]:
  ans=1
else:
  ans=0
for i in range(1,n):
  ta,tb=Tres[i]
  aa,ab=Ares[i]  
  if ta==aa==1:
    ans=ans*min(tb,ab)%mod
  elif ta==0 and aa==1 and tb>ab:
    ans=0
  elif ta==1 and aa==0 and tb<ab:
    ans=0
  elif ta==0 and aa==0 and tb!=ab:
    ans=0
print(ans%mod)
### BUGGY CODE ###

import math

def get_spf(n):
	ans = [i for i in range(n + 1)]

	for p in range(2, n + 1):
		if ans[p] == p:
			for i in range(p**2, n + 1, p):
				if ans[i] == i:
					ans[i] = p

	return ans

def get_pf(n, spf):
	ans = []

	while n > 1:
		ans.append(spf[n])
		n = int(n / spf[n])

	return ans

if __name__ == "__main__":
	line = input().split(" ")

	a, b = int(line[0]), int(line[1])

	# spf = get_spf(max(math.ceil(math.sqrt(a)), math.ceil(math.sqrt(b))))
	spf = get_spf(max(a, b))

	primes_a = set(get_pf(a, spf))
	primes_b = set(get_pf(b, spf))

	ans = []
	for e in primes_a:
		if e in primes_b:
			ans.append(e)

	print(1 + len(ans))

### FIXED CODE ###

import math

def is_prime(n):
	if n < 2: return False

	for i in range(2, math.ceil(math.sqrt(n))):
		if n % i == 0:
			return False

	return True

def get_pf(n):
	ans = [1]

	for p in range(2, math.ceil(math.sqrt(n))):
		while n % p == 0:
			n = int(n / p)
			ans.append(p)

	if n != 1:
		ans.append(n)

	return ans

if __name__ == "__main__":
	line = input().split(" ")

	a, b = int(line[0]), int(line[1])

	if a > b:
		a, b = b, a

	primes_a = set(get_pf(a))
	primes_b = set(get_pf(b))

	# if b % a == 0 and is_prime(a):
	# 	primes_a.add(a)
	# 	primes_b.add(a)

	ans = []
	for e in primes_a:
		if e in primes_b:
			ans.append(e)

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

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

for i in range(n):
    print(sorted(x[0:i] + x[i+1:])[(n-1)//2])

### FIXED CODE ###

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

sorted_x = sorted(x)
l = sorted_x[n//2]
s = sorted_x[n//2-1]

for i in x:
    if i <= s:
        print(l)
    else:
        print(s)
### BUGGY CODE ###

N = int(input())
A = list(int(input()) for _ in range(N))

A_sort = sorted(A)

for i in range(N):
    v = A[i]
    if v < max(A):
        print(max(A))
    else:
        print(A_sort[-2])


### FIXED CODE ###

N = int(input())
A = list(int(input()) for _ in range(N))
m = max(A)

A_sorted = sorted(A)

for i in range(N):
    v = A[i]
    if v < m:
        print(m)
    else:
        print(A_sorted[-2])
### BUGGY CODE ###

from sys import stdin
import numpy as np


def main():
    N, K, Q = [int(x) for x in stdin.readline().rstrip().split()]
    As = [int(stdin.readline().rstrip()) for _ in range(Q)]
    score = np.asarray([K] * N)
    for A in As:
        score -= 1
        score[A - 1] += 1
    for s in score:
        print('Yes' if 0 < s else 'No')


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin


def main():
    N, K, Q = [int(x) for x in stdin.readline().rstrip().split()]
    As = [int(stdin.readline().rstrip()) for _ in range(Q)]
    score = [0] * N
    for A in As:
        score[A - 1] += 1
    for s in score:
        x = K - (Q - s)
        print('Yes' if 0 < x else 'No')


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

s=input()
n=len(s)
DP=[[0]*13 for _ in range(n+1)]
DP[0][0]=1
for i in range(n):
  r=pow(10,n-1-i,13)
  if s[i]=="?":
    for j in range(10):
      for k in range(13):
        DP[i+1][k]+=DP[i][(k-r*j)%13]
  else:
    for k in range(13):
      DP[i+1][k]+=DP[i][(k-r*int(s[i]))%13]
print(DP[n][5]%(10**9+7))

### FIXED CODE ###

mod=10**9+7
s=input()
n=len(s)
R=[[[0]*13 for _ in range(10)] for __ in range(13)]
for i in range(13):
  for j in range(10):
    for k in range(13):
      R[i][j][k]=(k-i*j)%13

P=[0]*(n+1)
P[0]=1
for i in range(n):
  P[i+1]=(P[i]*10)%13

DP=[[0]*13 for _ in range(n+1)]
DP[0][0]=1
for i in range(n):
  r=P[n-1-i]
  if s[i]=="?":
    for k in range(13):
      DP[i+1][k]=sum(DP[i][R[r][j][k]] for j in range(10))
      DP[i+1][k]%=mod
  else:
    for k in range(13):
      DP[i+1][k]=DP[i][R[r][int(s[i])][k]]
      DP[i+1][k]%=mod
print(DP[n][5]%mod)
### BUGGY CODE ###

N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
count=0
for i in range(N):
  x=s.count(s[i])
  count+=(x-1)/2
print(int(count))

### FIXED CODE ###

n=int(input())
d=[list(input()) for i in range(n)]
count=0
ans=0
for i in range(n):
  d[i].sort()
d.sort()

for i in range(n-1):
  if d[i]==d[i+1]:
    count+=1
  elif d[i]!=d[i+1]:
    x=count+1
    count=0
    ans+=(x*(x-1))/2
  if i==(n-2):
    x=count+1
    count=0
    ans+=(x*(x-1))/2
  
print(int(ans))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000)

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

dp = [0] * N
dp[1] = abs(H[1]-H[0])

def func(i):
    if i == N:
        return 0
    else:
        dp[i] = min([dp[i-k]+abs(H[i-k]-H[i]) for k in range(1, K+1) if i-k>=0])
        func(i+1)

func(2)
print(dp[N-1])

### FIXED CODE ###

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

dp = [0] * N
dp[1] = abs(H[1]-H[0])

for i in range(2, N):
    dp[i] = min([dp[i-k] + abs(H[i-k]-H[i]) for k in range(1, 1+K) if 0 <= i-k])

print(dp[-1])
### BUGGY CODE ###

import math
n,a=map(int,input().split())
list=list(map(int,input().split()))
list.sort()
x=0
for i in range(a):
   x = max(list)/2
   x=math.floor(x)
   list.pop()
   list.append(x)
   list.sort()
print(sum(list))

### FIXED CODE ###

import heapq
N, M = list(map(int,input().split()))
h = []
for i in input().split():
  heapq.heappush(h,-int(i))
for i in range(M):
  x = -heapq.heappop(h)
  x //=2
  heapq.heappush(h,-x)
print(-sum(h))
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
x = 1
for e in a:
  x *= e
if x > 10**18:
  print(-1)
else:
  print(x)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
x = 1
if 0 in a:
  print(0)
  exit()
for e in a:
  x *= e
  if x > 10**18:
    print(-1)
    exit()
print(x)