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

N, Q = map(int, input().split())
S = input()
l_r = []
for i in range(Q):
    l_r.append(list(map(int, input().split())))
demand_count = []
for i in range(len(l_r)):
    print(S[l_r[i][0]-1: l_r[i][1]].count("AC"))

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
a=[0]*n
for i in range(n):
    if i:
        a[i]=a[i-1]+(s[i-1:i+1]=='AC')
for _ in range(q):
    l,r=map(int,input().split())
    print(a[r-1]-a[l-1])
### BUGGY CODE ###

from sys import stdin
import math
import bisect
import heapq
import numpy as np
from math import factorial

inf = 10**3
n,m = [int(x) for x in stdin.readline().rstrip().split()]

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]
nu = []

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    #k：中継
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
point = 0
for i in range(m):
    d = [[inf for i in range(n)]for j in range(n)]
    lin = li[:i]+li[i+1:]
    for j in range(m-1):
        d[lin[j][0]-1][lin[j][1]-1] = 1
        d[lin[j][1]-1][lin[j][0]-1] = 1
    for k in range(n):
        d[k][k] = 0
    lis = warshall_floyd(d)
    for i in lis:
        if inf in i:
            point += 1
            break
print(point)

### FIXED CODE ###

from sys import stdin

inf = 10**3
n,m = [int(x) for x in stdin.readline().rstrip().split()]

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]
nu = []

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    #k：中継
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
point = 0
for i in range(m):
    d = [[inf for i in range(n)]for j in range(n)]
    lin = li[:i]+li[i+1:]
    for j in range(m-1):
        d[lin[j][0]-1][lin[j][1]-1] = 1
        d[lin[j][1]-1][lin[j][0]-1] = 1
    for k in range(n):
        d[k][k] = 0
    lis = warshall_floyd(d)
    for i in lis:
        if inf in i:
            point += 1
            break
print(point)
### BUGGY CODE ###

import sys

A=[[0,0,0]]
size = 0

def insert(A,x):
    global size

    fp=A[0][1]
    try:
        i=[e[0] for e in A].index(-1)
        A[i]=[x,fp,0]
        A[fp][2]=i
        A[0][1]=i
    except:
        A.append([x,fp,0])
        A[fp][2]=len(A)-1
        A[0][1]=len(A)-1     
    size += 1    

def delete(A,x):
    global size
    p =A[0][1]
    while A[p][0]!=x:
        p=A[p][1]
        if p==0: return
    fp=A[p][1]
    bp=A[p][2]
    A[fp][2]=bp
    A[bp][1]=fp
    A[p]=[-1,-1,-1]
    size -= 1
    return

def deletefirst(A):
    global size
    if size == 0: return
    p=A[0][1]
    fp=A[p][1]
    A[0][1]=fp
    A[fp][2]=0
    A[p]=[-1,-1,-1]
    size -= 1
    return 0

def deletelast(A):
    global size
    if size == 0: return
    p=A[0][2]
    bp=A[p][2]
    A[0][2]=bp
    A[bp][1]=0
    A[p]=[-1,-1,-1]
    size -= 1
    return 0

n = int(raw_input())
for i in range(n):
    s = (raw_input().split())
    if s[0] == 'insert':
        insert(A,int(s[1]))
    elif s[0] == 'delete':
        delete(A,int(s[1]))
    elif s[0] == 'deleteFirst':
        deletefirst(A)
    elif s[0] == 'deleteLast':
        deletelast(A)

e = A[0][1]
while e!=0:
    print A[e][0],
    e = A[e][1]

### FIXED CODE ###

import sys,gc
    
A=[]
fp =0
bp =0

n=int(raw_input())
while n:
    s = raw_input()
    if s[0] == 'i':
        A.append(int(s[7:]))
        fp += 1
    elif s[6] == ' ':
        try:
            i = A[::-1].index(int(s[7:]))
            if i!=-1:
                del A[-i-1]
                fp -=1
        except:
            pass
    elif s[6] == 'F':
        A.pop()
        fp -=1
    elif s[6] == 'L':
        bp +=1
    n -=1

for e in A[bp:fp+1][::-1]:
    print int(e),
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w = inpl()
s = [list(input()) for i in range(h)]
seq = [0]*(h-1) + [1]*(w-1)
d = set()
if s[0][0] != '#':
    print('Impossible')
    quit()
s[0][0] = '.'
for i in itertools.permutations(seq,h+w-2):
    if i in d:
        continue
    d.add(i)
    t = [['' for k in range(w)] for j in range(h)] 
    for k in range(h):
        for j in range(w):
            tmp = s[k][j]
            t[k][j] = tmp
    nx = ny = 0
    # print('t')
    # print(t)
    # print('s')
    # print(s)
    # print(i)
    for j in i:
        if j:
            nx += 1
        else:
            ny += 1
        if t[ny][nx] == '#':
            t[ny][nx] = '.'
    for j in t:
        if '#' in j:
            break
    else:
        print('Possible')
        # print(i)
        # print(t)
        break
else:
    print('Impossible')


### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w = inpl()
s = [list(input()) for i in range(h)]
if s[0][0] != '#':
    print('Impossible')
    quit()
s[0][0] = '.'
for i in itertools.combinations(range(h+w-2),h-1):
    # print(i)
    cnt = [1] * (h+w-2)
    for l in range(h+w-2):
        if l in i:
            cnt[l] = 0 
    # print(cnt)
    t = [['' for k in range(w)] for j in range(h)] 
    for k in range(h):
        for j in range(w):
            tmp = s[k][j]
            t[k][j] = tmp
    nx = ny = 0
    # print('t')
    # print(t)
    # print('s')
    # print(s)
    # print(i)
    for j in cnt:
        if j:
            nx += 1
        else:
            ny += 1
        if t[ny][nx] == '#':
            t[ny][nx] = '.'
    for j in t:
        if '#' in j:
            break
    else:
        print('Possible')
        # print(i)
        # print(t)
        break
else:
    print('Impossible')
### BUGGY CODE ###

N = int(input())
arr = list(map(int, input().split()))
count = 0
for i in range(1, N + 1):
  flg = True
  for j in range(i):
    if arr[i - 1] > arr[j]:
      flg = False
      break
  if flg:
    count += 1

print(count)

### FIXED CODE ###

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

mi = 10000000
count = 0
for i in range(N):
  if a[i] <= mi:
    mi = a[i]
  if a[i] == mi:
    count += 1

print(count)
### BUGGY CODE ###

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

for j in range(k):
    b *= a[j]

for i in range(1, n-k+1):
    c = b
    b *= a[k+i-1]
    b /= a[i-1]
    if b > c:
        print('Yes')
    else:
        print('No')




### FIXED CODE ###

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

for i in range(1, n-k+1):
    if a[k+i-1] > a[i-1]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()

fact = [1]*(n+1)
for i in range(2,n+1):
    fact[i] = fact[i-1]*i

a.sort(reverse = True)
res = 0
for i in range(n-k+1):
    res += a[i] * fact[n-i-1]//(fact[k-1]*fact[n-i-k])
    res = res%MOD

a.reverse()
for i in range(n-k+1):
    res -= a[i] * fact[n-i-1]//(fact[k-1]*fact[n-i-k])
    res = res%MOD

print(res)


### FIXED CODE ###

import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n, k = MAP()
a = LIST()

def mpow(a, n):
    if n == 0:return 1
    if n == 1:return a%MOD
    if n%2 == 1:return (a%MOD * mpow(a, n-1)%MOD)%MOD
    t = mpow(a, n//2)
    return (t*t)%MOD

fac = [1]*(n+1)
inv_fac = [1]*(n+1)
for i in range(n):
    fac[i+1] = (fac[i]*(i+1))%MOD
inv_fac[n] = mpow(fac[n], MOD-2)
for i in range(n, 0, -1):
    inv_fac[i-1] = (inv_fac[i]*i)%MOD

def cmb(n, r):
    if n == 0 and r == 0:return 1
    if n<r or n<0:return 0
    return (fac[n]*(inv_fac[r]*inv_fac[n-r])%MOD)%MOD
 
a.sort(reverse = True)
res = 0
for i in range(n-k+1):
    res += (a[i]*cmb(n-i-1, k-1))%MOD
    res = res%MOD
 
a.reverse()
for i in range(n-k+1):
    res -= (a[i]*cmb(n-i-1, k-1))%MOD
    res = res%MOD
 
print(res)
### BUGGY CODE ###

# D - Even Relation

# ある頂点からの距離の偶奇が一致する点を同じ色で塗る

from scipy.sparse.csgraph import dijkstra

N = int(input())

neighbor = [[0]*N for _ in range(N)]

for _ in range(N-1):
    u, v, w = map(int, input().split())
    neighbor[u-1][v-1] = w
    neighbor[v-1][u-1] = w

dist_from_0 = dijkstra(neighbor, indices = 0)

for i in range(N):
    print(0 if dist_from_0[i]%2 == 0 else 1)

### FIXED CODE ###

# D - Even Relation

# 木なのでノードAB間の辺を辿ればそれがAB間の最短経路となる
# 全ての｢辺｣についてループする

from collections import deque

N = int(input())

edge = [[] for _ in range(N)]

for _ in range(N-1):
    u, v, w = map(int, input().split())
    edge[u-1].append([v-1, w])
    edge[v-1].append([u-1, w])

color = [0] + [-1]*(N-1)
d = deque([0])

while d:
    current_point = d.pop()
    for current_edge in edge[current_point]:
        if color[current_edge[0]] == -1:
            color[current_edge[0]] = (color[current_point] + current_edge[1]) % 2
            d.append(current_edge[0])

for idx in range(N):
    print(color[idx])
### BUGGY CODE ###

from collections import deque
r, c = list(map(int, input().split()))
sy, sx = [0, 0]
gy, gx = [r-1, c-1]

s = [list(map(str, list(input()))) for i in range(r)]

N = r*c
G = [[] for _ in range(N)]
dist = [-1]*N
que = deque()
for i in range(r):
    for j in range(c):
        if s[i][j] == '#':
            que.append(i*c+j)
            dist[i*c+j] = 0
        for x, y in ([0, 1], [0, -1], [1, 0], [-1, 0]):
            if 0 <= i+y <= r-1 and 0 <= j+x <= c-1:
                G[i*c+j].append((i+y)*c+j+x)

while que:
    v = que.popleft()
    d = dist[v]
    for w in G[v]:
        if dist[w] > -1:
            continue
        dist[w] = d + 1
        que.append(w)

ans = max(dist)
print(ans)


### FIXED CODE ###

# import numpy as np
# import scipy as sp
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
# import sys ; sys.exit() # プログラム終了
# from copy import deepcopy ; b=deepcopy(a)
# chr(ord('a') + 1)
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#
from copy import deepcopy
from collections import deque

d = deque()
h, w = map(int, input().split())
s = [list(map(str, list(input()))) for i in range(h)]
used = [[True for j in range(w)] for i in range(h)]
# used = [[True]*w]*h
for i in range(h):
    for j in range(w):
        if (s[i][j] == "#"):
            d.append([i, j])
            used[i][j] = False


ans = -1
while (d):

    tmp = deque()
    while(d):
        i, j = d.popleft()

        if i+1 < h and used[i+1][j]:
            s[i+1][j] = "#"
            tmp.append([i+1, j])
            used[i+1][j] = False

        if i-1 >= 0 and used[i-1][j]:
            s[i-1][j] = "#"
            tmp.append([i-1, j])
            used[i-1][j] = False

        if j+1 < w and used[i][j+1]:
            s[i][j+1] = "#"
            tmp.append([i, j+1])
            used[i][j+1] = False

        if j-1 >= 0 and used[i][j-1]:
            s[i][j-1] = "#"
            tmp.append([i, j-1])
            used[i][j-1] = False

    d = tmp
    ans += 1

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

# coding: utf-8
def binary_search(x, L2):
    l, r = 0, len(L2)-1
    mid = (r + l) // 2
    while r - l > 1:
        mid = (r + l) // 2
        if L2[mid] == x:
            return len(L2) - mid
        elif L2[mid] > x:
            l = mid
        elif L2[mid] < x:
            r = mid
    if L2[r] > c:
        return r
    else:
        return l

N = int(input())
L = list(map(int, input().split()))
L.sort()
L = L[::-1]
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        c = a - b
        r = binary_search(c, L)
        if r > j and L[r] > c:
            ans += r - j
print(ans)

### FIXED CODE ###

# coding: utf-8
from bisect import bisect_left
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        ans += bisect_left(L, a+b) - 1 - j
print(ans)
### BUGGY CODE ###

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

dp = [0] + [float("inf")] * (n-1)
dp[1] = abs(h[0]-h[1])

for i in range(2,n):
    j = 1
    while j <= k and j <= i:
        cost = dp[i-j]+abs(h[i]-h[i-j])
        if cost < dp[i]:
            dp[i] = cost
        j += 1
    
print(dp[-1])

### FIXED CODE ###

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

inf = 10**10
dp = [0] + [inf] * (n-1)

for i in range(1,n):
    j = 1
    while j <= k and j <= i:
        dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]), dp[i])
        j += 1
    
print(dp[-1])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
#幅優先探索
#TLE
import sys

N=input()

a=[[] for i in range(N+1)]
#隣接リスト
for i in range(N-1):
	x,y,z=list(map(int,raw_input().split()))
	a[x].append((y,z))
	a[y].append((x,z))

#print a

Q,K=list(map(int,raw_input().split()))


b=[]
for i in range(Q):
	b.append(map(int, raw_input().split()))
#print b



#訪問判別フラグ
F=(N+1)*[0]

#Queue
queue=[]

#距離
dist=[0 for i in range(N+1)]

p=-1
v=-1
length=0
#幅優先探索
queue.append(K)
while len(queue) != 0:
	v=queue.pop(0)
	F[v]=1
	for u,length in a[v]:
		if F[u]==0:
			queue.append(u)
			dist[u]=dist[v]+length


#print dist


for x in range(len(b)):
	print dist[ b[x][0] ]+ dist[ b[x][1] ]




### FIXED CODE ###

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


N=input()


a=[[] for i in range(N+1)]

#隣接リスト
for i in range(N-1):
	x,y,z=list(map(int,raw_input().split()))
	a[x].append((y,z))
	a[y].append((x,z))

#print a
	

Q,K=list(map(int,raw_input().split()))


b=[]
for i in range(Q):
	b.append(map(int, raw_input().split()))
#print b



#訪問判別フラグ
F=(N+1)*[0]

#Stack
S=[]

#距離
dist=[0 for i in range(N+1)]

#先頭から深さ優先探索
S.append(K)
former_v=0
v=0
while len(S) != 0:
	v=S.pop()
	
	if F[v]==0:
		F[v]=1

		for u,length in a[v]:
			if F[u]==0:
				S.append(u)
				dist[u]=dist[v]+length
				#print dist

#print dist



for x in range(len(b)):

	print dist[ b[x][0] ]+ dist[ b[x][1] ]
### BUGGY CODE ###

a,b,c=map(int,input().split())
num=0
while (a%2==0 and b%2==0 and c%2==0):
  a,b,c=(b//2+c//2),(a//2+c//2),(a//2+b//2)
  num+=1
  if (num>10**9):
    print(-1)
    break
else:
  print(num)

### FIXED CODE ###

a,b,c=map(int,input().split())
num=0
while (a%2==0 and b%2==0 and c%2==0):
  a,b,c=(b//2+c//2),(a//2+c//2),(a//2+b//2)
  num+=1
  if (num>10**7):
    print(-1)
    break
else:
  print(num)
### BUGGY CODE ###

N = int(input())
nums = [int(e) for e in input().split()]
nums.sort()

for i in range (1,N+1):
    j = 0
    c = 0
    while j < len(nums) and nums[j] == i:
        c = c + 1
    del nums[:c]
    print(c)

### FIXED CODE ###

import collections as col

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

List = col.Counter(List)
Count_List = [0]*n
for i in List:
    Count_List[i-1] = List[i]

for i in range(0,len(Count_List)):
    print(Count_List[i])
### BUGGY CODE ###

n = int(input())

hash = []
for i in range(n):
    command, value = input().split()
    if command == 'insert':
        hash.append(value)
    elif command == 'find':
        if value in hash:
            print('yes')
        else:
            print('no')

### FIXED CODE ###

import sys
dic = set()
L = sys.stdin.readlines()

for Ins in L[1:]:
    ins, op = Ins.split()
    if ins == 'insert':
        dic.add(op)
    if ins == 'find':
        print('yes' if op in dic else 'no')
### BUGGY CODE ###

def main():
    s = str(input())
    q = int(input())
    lst = [list(map(str, input().split())) for _ in range(q)]
    switch = 0  # 0が通常　1が前

    for i in range(q):

        if lst[i][0] == '1':
            switch = 1 - switch

        else:
            f = lst[i][1]
            c = lst[i][2]

            if f == '1':  # 先頭に追加

                if switch == 0:
                    tmp = c + s
                    s = tmp

                else:
                    s += c

            else:

                if switch == 0:
                    s += c

                else:
                    tmp = c + s
                    s = tmp

    if switch == 1:
        s = s[::-1]

    print(s)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    s = str(input())
    q = int(input())
    lst = [list(map(str, input().split())) for _ in range(q)]
    switch = 0  # 0が通常　1が前

    str_lst = [s]
    front_lst = []
    for i in range(q):

        if lst[i][0] == '1':
            switch = 1 - switch

        else:
            f = lst[i][1]
            c = lst[i][2]

            if f == '1':  # 先頭に追加

                if switch == 0:
                    front_lst.append(c)

                else:
                    str_lst.append(c)

            else:

                if switch == 0:
                    str_lst.append(c)

                else:
                    front_lst.append(c)

    front = ''.join(front_lst)
    front = front[::-1]
    after = ''.join(str_lst)
    answer = front + after

    if switch == 1:
        answer = answer[::-1]

    print(answer)


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

n,m = map(int,input().split())
g = 1
for i in range(1,int(1+m/n)):
  if m%i == 0:
    if int(m/i) >= n:
      g = i
    else:
      break
      
print(g)
  

### FIXED CODE ###

n,m = map(int,input().split())
g = 1
def fact(k):
  a = []
  for i in range(1,int(k **(0.5))+1):
    if k%i ==0:
      a.append(i)
      a.append(int(k/i))
  b = list(set(a))
  b.sort()
  return b

g = fact(m)
for i in range(len(g)):
  if g[len(g)-i-1] <= m/n:
    print(g[len(g)-i-1])
    break
### BUGGY CODE ###

from collections import Counter
def merge_dict_add_values(d1, d2):
    return dict(Counter(d1) + Counter(d2))
  
n,m=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
#list_bc=[]
mydict_bc={}
b,c=(int(i) for i in input().split())
mydict_bc[c]=b
for i in range(1,m):
    b,c=(int(i) for i in input().split())
    d2={}
    d2[c]=b
    mydict_bc=merge_dict_add_values(mydict_bc, d2)
#print(n,m,a,mydict_bc)

  
mydict={}

mydict[a[0]]=1
for i in range(1,len(a)):
    d2={}
    d2[a[i]]=1
    mydict=merge_dict_add_values(mydict, d2)
#print(mydict)
    
mydict_r1=merge_dict_add_values(mydict, mydict_bc)
mylist = sorted(mydict_r1.items(), key=lambda x: -x[0])

#print(mylist)
cnt=0
cnt0=0
i=0
while cnt <= n:
    cnt0+=mylist[i][0]*mylist[i][1]
    v=mylist[i][0]
    cnt+=mylist[i][1]
    i+=1

#print(cnt0,v,cnt)
print(cnt0-v*(cnt-n))


### FIXED CODE ###

import heapq
h = []

n,m=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
for i in a:
    heapq.heappush(h, [(-1)*i,1])

for i in range(m):
    b,c=(int(i) for i in input().split())
    heapq.heappush(h, [(-1)*c,b])

num=0
data=0
while num <= n:
    v=heapq.heappop(h)
    data+=v[0]*v[1]
    num+=v[1]

print((-1)*(data-v[0]*(num-n)))
### BUGGY CODE ###

N, M = map(int, input().split())
a = M//N
ans = 0
for i in range(1, a+1):
    if M%i == 0:
        ans = i
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
a = M//N
ans = 0
ok = True
for i in range(1, a+1):
    if M%i == 0:
        ans = i
        if M//i <= a:
            print(M//i)
            ok = False
            break
if ok:
    print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
  n=int(input())
  a=list(map(lambda x:list(map(int,list(bin(int(x))[2:]))),input().split()))
  mod=pow(10,9)+7
  ans=0
  len_ai=[]
  for ai in a:
    len_ai.append(len(ai))
  for i in range(61):# 2^iの位
    bit1=0
    for j in range(n):
      if len_ai[j]>=i+1:
        bit1+=a[j][-i-1]
    ans+=(pow(2,i,mod)*bit1*(n-bit1))%mod
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
def main():
  n=int(input())
  a=list(map(int,input().split()))
  mod=pow(10,9)+7
  ans=0
  bit=[0]*61 #bit[i]:2^iの位が1である物の個数
  for ai in a:
    for j in range(61):
      if ((ai>>j) & 1):
        bit[j]+=1
  for i in range(61):
    ans+=(pow(2,i)%mod)*bit[i]*(n-bit[i])
    ans%=mod
  print(ans)
if __name__=='__main__':
  main()
### BUGGY CODE ###

n,k = map(int,input().split())
p_list = list(map(int,input().split()))
for j in range(n):
  p_list[j] = (p_list[j]+1)/2
c = 0
for i in range(n-k+1):
  c = max(c,sum(p_list[i:i+k]))
print(c)

### FIXED CODE ###

def hoge(x):
  return (int(x)+1)/2

n,k = map(int,input().split())
p_list = list(map(hoge,input().split()))
p_set = [0,p_list[0]]
t = 0
for i in range(1,n):
  p_set.append(p_set[i]+p_list[i])
for j in range(k,n+1):
  t = max(t,p_set[j]-p_set[j-k])
print(t)
### BUGGY CODE ###

a,b,x = map(int,input().split())
count = 0
for i in range(a,b+1):
  if i % x == 0:
    count += 1
print(count)

### FIXED CODE ###

a,b,x = map(int,input().split())
c = (b) // x - (a-1) //x
print(c)