Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
al=[int(input()) for i in range(m)]
mod=1000000007
ms=[0]*n

def dd(n):
    if ms[n-1]>0:
        return ms[n-1]
    if n==1:
        ms[n-1]=1
        return 1
    if n==2:
        ms[n-1]=2
        return 2
    m=dd(n-1)+dd(n-2)
    ms[n-1]=m
    return m

ans=1
now=0
b=-1
for a in al:
    if a-1==b:
        print(0)
        exit()
    b=a
    if a-1!=now:
        ans=(ans%mod)*(dd(a-now-1)%mod)%mod
    now=a+1

ans=(ans%mod)*(dd(n-al[-1]-1)%mod)%mod
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
n,m=map(int,input().split())
al=[int(input()) for i in range(m)]+[n+1]
mod=1000000007
ms=[0]*(n+1)

def dd(n):
    if ms[n]>0:
        return ms[n]
    if n==1:
        ms[n]=1
        return 1
    if n==2:
        ms[n]=2
        return 2
    m=dd(n-1)+dd(n-2)
    ms[n]=m
    return m

ans=1
now=0
b=-1
for a in al:
    if a-1==b:
        print(0)
        exit()
    b=a
    if a-1!=now:
        ans=(ans%mod)*(dd(a-now-1)%mod)%mod
    now=a+1

print(ans)
N = int(input())
sum = 0
for k in range(N):
  for j in range(k):
  	if k % j == 0：
    	sum += k
print(f)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1, n + 1):
    y = n // i
    ans += y * (y + 1) * i // 2
print(ans)
n, x = map(int, input().split())
s = list(map(int, input().split()))
s = sorted(s)
MOD = 10**9 + 7

frac = [0]*(n+1)
frac[0] = 1
for i in range(0,n):
    frac[i+1] = (i+1) * frac[i]
    frac[i+1] %= MOD

def solve(x, cnt, visited):
    ans = 0
    flag = False
    if cnt == n:
        return x
    for i in range(n):
        if not visited[i]:
            if s[i] <= x:
                if not flag:
                    ans += (x % s[i]) * frac[n - (cnt + 1)]
                    flag = True
                else:
                    tmp_visited = visited[0:]
                    tmp_visited[i] = True
                    ans += solve(x % s[i], cnt + 1, tmp_visited) % MOD
                    ans %= MOD
            else:
                tmp_visited = visited[0:]
                tmp_cnt = 0
                for j in range(i, n):
                    if not tmp_visited[j]:
                        tmp_visited[j] = True
                        tmp_cnt += 1
                ans += solve(x, cnt + tmp_cnt, tmp_visited) * frac[tmp_cnt] % MOD
                ans %= MOD
                break
    return ans
    
    
print(solve(x, 0, visited = [False]*n) % MOD)

### FIXED CODE ###

n, x = map(int, input().split())
s = list(map(int, input().split()))
MOD = 10 ** 9 + 7

s = sorted(s, reverse=True)
max_ = max(s[0], x)
dp = [[0] * (max_ + 1) for i in range(n + 1)]
dp[0][x] = 1

for i in range(n):
    for val in range(max_ + 1):
        dp[i + 1][val % s[i]] += dp[i][val]
        dp[i + 1][val % s[i]] %= MOD
        dp[i + 1][val] += dp[i][val] * (n - i - 1)
        dp[i + 1][val] %= MOD

ans = 0
for i, num in enumerate(dp[-1]):
    ans += num * i
    ans %= MOD
print(ans)
a,b,c,d=(int(x) for x in input().split())

if(a < 0 or c < 0 or b < 0 or d < 0):
    print("")
else:
    if(b <= d):
	    if(b >= c and c >= a):
  		    print("Yes")
	    else:
  		    print("No")
    else:
        if(c <= a & a <= d):
            print("Yes")
        else:
          	print("No")

### FIXED CODE ###

x = int(input())

if(x < 1 or x > 5):
  print("")
else:
  for i in range(x):
    print("ACL",end='')
N,M = map(int,input().split())
A = []
A = list(map(int,input().split()))
list.sort(A, reverse = True)
if A[M] >= sum(A)/(4*M):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N,M = map(int,input().split())
A = []
A = list(map(int,input().split()))
list.sort(A, reverse = True)
if A[M-1] >= (sum(A))/(4*M):
    print('Yes')
else:
    print('No')
from collections import deque
N, M = map(int, input().split())
graph = [[] for _ in range(M)]
for i in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
    graph[b].append(a)
#print(graph)

queue = deque()
seen = [-1] * N
steps = [-1] * N
steps[0] = 0
parents = [-1] * N
queue.append(0)
while queue:
    node = queue.popleft()

    seen[node] = 1
    #print("now: "+str(node))
    for next in graph[node]:
        if seen[next] > -1:
            continue
        #print("next: " + str(next))
        queue.append(next)
        seen[next] = 1
        steps[next] = steps[node] + 1
        parents[next] = node

print("Yes")
for a in parents[1:]:
    print(a+1)

### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for i in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
    graph[b].append(a)
#print(graph)

queue = deque()
seen = [-1] * N
steps = [-1] * N
steps[0] = 0
parents = [-1] * N
queue.append(0)
while queue:
    node = queue.popleft()

    seen[node] = 1
    #print("now: "+str(node))
    for next in graph[node]:
        if seen[next] > -1:
            continue
        #print("next: " + str(next))
        queue.append(next)
        seen[next] = 1
        steps[next] = steps[node] + 1
        parents[next] = node

print("Yes")
for a in parents[1:]:
    print(a+1)
a = list(map(int, input().split()))
a.sort(reversed = True)
print(int(a[0])*10+a[1]+a[2])


### FIXED CODE ###

a = list(map(int, input().split()))
a.sort(reverse = True)
print(int(a[0])*10+a[1]+a[2])
#input
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))

#output
import numpy as np
import math
A = np.sort(A)

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

q = np.full(N, 0)
for i in range(N-K+1):
    q[i] = cmb(N-i-1, N-K-i)

r = -q + np.flip(q)

print((A*r).sum() % (10**9 + 7))

### FIXED CODE ###

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

#output
import math

A.sort()
mod = 10**9+7

n_ = 10**5 + 3
fun = [1]*(n_+1)
for i in range(1,n_+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n_+1)
rev[n_] = pow(fun[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod
def cmb(n,r):
    if n <= 0 or r < 0 or r > n: return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod
#これだとTLE!
"""
def cmb(n, r):
    if n < r: return 0
    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
"""

M = 0
m = 0
for i, a in enumerate(A):
    M += cmb(i, K-1) * a
    m += cmb(N-i-1, K-1) * a
    M %= mod
    m %= mod

print((M-m) % mod)
3 2 10 20
8 15 13
16 22
n,m,x,y=map(int,input().split())
x1=max(map(int,input().split()))
x2=min(map(int,input().split()))
z=list(range(x+1,y+1))
for i in z:
	if x1<i<=x2:
  		print("No War")
        break
	else:print("War")
print(n,m,x,y,x1,x2)

### FIXED CODE ###

n,m,x,y=map(int,input().split())
x1=max(map(int,input().split()))
x2=min(map(int,input().split()))
z=list(range(x+1,y+1))
for i in z:
	if x1<i<=x2:
		print("No War")
		break
else:
	print("War")
a,b,c=raw_input.split()
ans= a[0]+b[0]+c[0]
print ans.upper()

### FIXED CODE ###

a,b,c=raw_input().split()
ans= a[0]+b[0]+c[0]
print ans.upper()
ABC, ARCw = map(input().split())

if (s=ABC):
    print('ARC')
else:
    print('ABC')

### FIXED CODE ###

S = input()
if(S=='ABC'):
    print('ARC')
else:
    print('ABC')
L = [int(i) for i in input().split()]
L.sorted()
print(L[0] + L[1])

### FIXED CODE ###

L = [int(i) for i in input().split()]
L.sort()
print(L[0] + L[1])
alpha = int(input())
a = [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]

if alpha in a:
  print('A')
else:
  prnt('a')

### FIXED CODE ###

alpha = input()
if alpha.isupper():
  print('A')
else:
  print('a')
from math import factorial

N = int(input())
D = {}
L = [[]for _ in range(N)]
count = 0
for i in range(N):
    L[i] = list(input())
    L[i].sort()
    L[i] = tuple(L[i])
    if L[i] in D:
        D[L[i]] = D[L[i]] + 1
        if D[L[i]] == 2:
            D[L[i]] = D[L[i]] + 1
    else:
        D[L[i]] = 0
for key in D:
    if D[key] > 2:
        count += factorial(D[key]) / factorial(2) / factorial(D[key]-2)
    else:
        count += D[key]

print(int(count))


### FIXED CODE ###

from math import factorial
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N = int(input())
D = {}
L = [[]for _ in range(N)]
count = 0
for i in range(N):
    L[i] = list(input())
    L[i].sort()
    L[i] = tuple(L[i])
    if L[i] in D:
        D[L[i]] = D[L[i]] + 1
        if D[L[i]] == 2:
            D[L[i]] = D[L[i]] + 1
    else:
        D[L[i]] = 0
for key in D:
    if D[key] > 2:
        count += cmb(D[key],2)
    else:
        count += D[key]

print(count)
n = int(input())
a = int(input())
b = int(input())
if n ==1:
    print('Hello World')
if n ==2:
    print(a+b)

### FIXED CODE ###

n = int(input())
if n ==1:
    print('Hello World')
else:
    a = int(input())
    b = int(input())
    print(a+b)
# 146A
S = input()

if S == 'SUN':
    answer = (7)
elif S == 'MON':
    answer = (6)
elif S == 'TUE':
    answer = (5)
elif S == 'WED':
    answer = (4)
elif S == 'THU':
    answer = (3)
elif S == 'FRI':
    answer = (2)


print(answer)

### FIXED CODE ###

# 146A
S = input()

if S == 'SUN':
    answer = (7)
elif S == 'MON':
    answer = (6)
elif S == 'TUE':
    answer = (5)
elif S == 'WED':
    answer = (4)
elif S == 'THU':
    answer = (3)
elif S == 'FRI':
    answer = (2)
elif S == 'SAT':
    answer = (1)

print(answer)
def gcd(x,y):
  if(y==0):
  	return x
  if(x<y):
    x,y=y,x
  return gcd(y,x % y)
def lllen(a,b,c):
  at=a//c
  at=at*c
  b=b//c *c
  ansc=0
  while(at<a):
    at+=c
  ansc=b-at
  if ansc<0 :
  	ansc=0
  else:
  	ansc=ansc//c + 1
  	return ansc

a,b,c,d=map(int , input().strip().split() )
tl=b-a+1

ansc=lllen(a,b,c)
ansd=lllen(a,b,d)
ansl=lllen(a,b,(c*d)//gcd(c,d))
#print(ansc,ansl,ansd)
print(b-a+1 -ansc -ansd + ansl)


  

### FIXED CODE ###

def gcd(x,y):
  if(y==0):
  	return x
  if(x<y):
    x,y=y,x
  return gcd(y,x % y)
def lllen(a,b,c):
  at=a//c
  at=at*c
  b=b//c *c
  ansc=0
  while(at<a):
    at+=c
  ansc=b-at
  if ansc<0 :
  	ansc=0
  else:
  	ansc=ansc//c + 1
  return ansc

a,b,c,d=map(int , input().strip().split() )
tl=b-a+1

ansc=lllen(a,b,c)
ansd=lllen(a,b,d)
ansl=lllen(a,b,(c*d)//gcd(c,d))
#print(ansc,ansl,ansd)
print(b-a+1 -ansc -ansd + ansl)
N, K = map(int, input().split())
A = list(map(int, input().split()))

print(ceil((N - 1) / (K - 1)))


### FIXED CODE ###

from math import ceil

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

print(ceil((N - 1) / (K - 1)))
x = raw_input().split()
if(x[0] * x[1] < x[2]):
  print(x[0] * x[1])
  elif:
    print(x[2])

### FIXED CODE ###

x =  [int(s) for s in input().split()]
if(x[0]*x[1]<x[2]):
  print(x[0]*x[1])
else:
  print(x[2])
array = input().split().sort()

for i in array:
    print(i, end="")


### FIXED CODE ###

#
# 2c
#

def main():
    l = list(map(int, input().split()))
    l.sort()
    print(*l)


if __name__ == '__main__':
    main()
number = int(input())
my_set = set()
for i in range(number):
    input_line = raw_input()
    splitted_line = input_line.split(" ")
    my_set.add((splitted_line[0], - int(splitted_line[1]), i+1))

my_sorted = sorted(my_set)

for item in my_sorted:
    print(item[2])


### FIXED CODE ###

number = int(input())
my_set = set()
for i in range(number):
    input_line = input()
    splitted_line = input_line.split(" ")
    my_set.add((splitted_line[0], - int(splitted_line[1]), i+1))

my_sorted = sorted(my_set)

for item in my_sorted:
    print(item[2])
a,b,c,d = map(int,input().split())
count = 0

if a % c == 0:
    c_start = int(a/c)
else:
    c_start = int(a/c)+1

if a % d == 0:
    d_start = int(a/d)
else:
    d_start = int(a/d)+1

c_end = int(b/c)
d_end = int(b/d)

c_list=[0]*(c_end-c_start+1)
d_list=[0]*(d_end-d_start+1)

for ii in range(len(c_list)):
    jj = c_start + ii
    c_list[ii] = jj * c

for ii in range(len(d_list)):
    jj = d_start + ii
    d_list[ii] = jj * d

union = set(c_list) | set(d_list)

print(b - a + 1 - len(union))


### FIXED CODE ###

import fractions

a,b,c,d = map(int,input().split())

def calc(n):
    return n-n//c-n//d+n//(c*d//fractions.gcd(c, d))

print(calc(b)-calc(a-1))
def main():
    h, w, k = map(int, input().split())
    x1, y1, x2, y2 = map(int, input().split())
 
    # surround the square with '@'
    c = [['@'] * (w+2)]
    for _ in range(h):
        i = input()
        l = ['@']
        for j in i:
            l.append(j)
        l.append('@')
        c.append(l)
    c.append(['@'] * (w+2))
 
    # Dijkstra
    # seen[x][y] = the minimum cost of (x, y)
    # if seen[x][y] == -1, (x, y) is unresearched
    seen = [[-1] * (w+2) for _ in range(h+2)]
 
    # todo[i] == (cost, x, y, direction)
    todo = [(0, x1, y1, 0)]
    heapq.heapify(todo)
 
    # direction
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]
 
    while len(todo) > 0:
        cost, xi, yi, direction = heapq.heappop(todo)
 
        # only straight
        if seen[xi][yi] != -1:
            if (seen[xi][yi]+k-1)//k * k > cost:
                xj, yj = xi + dx[direction], yi + dy[direction]
                if c[xj][yj] == '.':
                    heapq.heappush(todo, (cost+1, xj, yj, direction))
            continue
        seen[xi][yi] = cost
 
        # goal
        if xi == x2 and yi == y2:
            print((cost+k-1)//k)
            exit()
        
        # 4 directions
        for j in range(4):
            xj, yj = xi + dx[j], yi + dy[j]
            if c[xj][yj] == '.':
                if j == direction:
                    if seen[xj][yj] == -1 or (seen[xj][yj]+k-1)//k * k > cost:
                        heapq.heappush(todo, (cost+1, xj, yj, j))
                elif seen[xj][yj] == -1:
                    heapq.heappush(todo, ((cost+k-1)//k * k + 1, xj, yj, j))
 
    print(-1)
 
main()

### FIXED CODE ###

import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
from collections import deque
INF = float('inf')
 
 
def main():
    H, W, K = map(int, readline().split())
    x1, y1, x2, y2 = map(int, readline().split())
    x1 -= 1
    y1 -= 1
    x2 -= 1
    y2 -= 1
    C = read().split()
 
    dist = [[INF] * W for i in range(H)]
    dist[x1][y1] = 0
    d = deque([[x1, y1]])
    dxy = [[1, 0], [0, 1], [-1, 0], [0, -1]]
    while d:
        x, y = d.popleft()
        if (x, y) == (x2, y2):
            print(dist[x][y])
            quit()
        for dx, dy in dxy:
            xx = x
            yy = y
            for i in range(K):
                xx += dx;
                yy += dy
                if 0 <= xx < H and 0 <= yy < W and C[xx][yy] != '@':
                    if dist[xx][yy] <= dist[x][y]:
                        break
                    if dist[xx][yy] == INF:
                        d.append([xx, yy])
                    dist[xx][yy] = dist[x][y] + 1
                else:
                    break
 
    print(-1)
 
 
if __name__ == '__main__':
    main()
import functools

L, R = map(int, input().split())
mod = 2019

@functools.lru_cache(maxsize = None)
for i in range(L, R) :
	for j in range(i + 1, R + 1) :
		if((i * j) % 2019 < mod) :
			mod = (i * j) % 2019
		else :
			pass
	if(mod == 0) :
		break
	else :
		pass
	
print(mod)

### FIXED CODE ###

L, R = map(int, input().split())
mod = 2019

for i in range(L, R) :
	for j in range(i + 1, R + 1) :
		if((i * j) % 2019 < mod) :
			mod = (i * j) % 2019
			x = ((i * j) // 2019) * 2019 + 2019
			if(x > i * R) :
				break
			else :
				pass
		elif(mod == 0) :
			break
		else :
			pass
	if(mod == 0) :
		break
	else :
		pass
	
print(mod)
s = list(str(input()))
n = list(str(input()))
ans = []
for i in range(len(s)-len(n)+1):
    nu = []
    for m in range(i):nu.append(s[m])
    for k in range(len(n)):
        if s[i + k] != n[k] and s[i+k]!="?" and n[k] != "?":
            break
        if k == len(n)-1:
            nu += n
            for h in range(len(s)-(len(n)+i)):
                nu.append(s[-(len(s)-(len(n)+i)+h)])
            while "?" in nu:nu[nu.index("?")] = "a"
            ans.append("".join(nu))
if ans == []:
    print("UNRESTORABLE")
    exit()
a = sorted(ans)
print(a[0])

### FIXED CODE ###

s = list(str(input()))
t = list(str(input()))
ans = []
an = 0
if len(s) < len(t):
    print("UNRESTORABLE")
    exit()
for i in range(len(s)-len(t)+1):
    cou = s[i:i+len(t)]
    for k in range(len(t)):
        if s[i+k] != t[k] and s[i+k] != "?" and t[k] != "?":
            break
        if k == len(t)-1:
            ans.append(s[:i]+t+s[i+len(t):])
for h in range(len(ans)):
    for f in range(len(s)):
        if ans[h][f] == "?":ans[h][f] = "a"
    ans[h] = "".join(ans[h])
if ans == []:
    print("UNRESTORABLE")
    exit()
ans.sort()
print(ans[0])
import sys
from heapq import heappush, heappop

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(N, K, L, R):
    left = [[] for _ in range(N)]
    right = [[] for _ in range(N)]
    score = 0
    for k, l, r in zip(K, L, R):
        k -= 1
        if l < r:
            score += l
            right[k].append(r - l)
        else:
            score += r
            left[k].append(l - r)
    q = []
    for n, xs in enumerate(left, 1):
        for x in xs:
            if len(q) < n:
                heappush(q, x)
            else:
                heappushpop(q, x)
    score += sum(q)
    q = []
    for n, xs in enumerate(right[::-1][1:], 1):
        for x in xs:
            if len(q) < n:
                heappush(q, x)
            else:
                heappushpop(q, x)
    score += sum(q)
    return score

T = int(readline())
for _ in range(T):
    N = int(readline())
    K, L, R = [], [], []
    for _ in range(N):
        k, l, r = map(int, readline().split())
        K.append(k)
        L.append(l)
        R.append(r)
    print(main(N, K, L, R))

### FIXED CODE ###

import sys
from heapq import heappush, heappop, heappushpop

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(N, K, L, R):
    left = [[] for _ in range(N)]
    right = [[] for _ in range(N)]
    score = 0
    for k, l, r in zip(K, L, R):
        k -= 1
        if l < r:
            score += l
            right[k].append(r - l)
        else:
            score += r
            left[k].append(l - r)
    q = []
    for n, xs in enumerate(left, 1):
        for x in xs:
            if len(q) < n:
                heappush(q, x)
            else:
                heappushpop(q, x)
    score += sum(q)
    q = []
    for n, xs in enumerate(right[::-1][1:], 1):
        for x in xs:
            if len(q) < n:
                heappush(q, x)
            else:
                heappushpop(q, x)
    score += sum(q)
    return score

T = int(readline())
for _ in range(T):
    N = int(readline())
    K, L, R = [], [], []
    for _ in range(N):
        k, l, r = map(int, readline().split())
        K.append(k)
        L.append(l)
        R.append(r)
    print(main(N, K, L, R))
import  numpy as mul
import math

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


ans=mul.prod(pyA)


if int(math.log10(ans)) > 17:
	print("-1")
	
else:
	print(ans)

### FIXED CODE ###

N=int(input())
A = [int(x) for x in input().split()]

ans=1
if 0 in A:
    ans = 0
else:
    A.sort(reverse=True)
    for a in A:
        if a > 10**18:
            ans = -1
            break
        else:
            ans *= a
            if ans > 10**18:
                ans = -1
                break
print(ans)
a = int(input())
b = int(input())

if a > 8 or b > 8:
    print(':(')
else:
    print('Yay!')


### FIXED CODE ###

a, b = list(map(int, input().split()))
 
if a > 8 or b > 8:
    print(':(')
else:
    print('Yay!')
S,W = map(int, input().split())
if S > W:
    print(safe)
else:
    print(unsafe)

### FIXED CODE ###

S, W = map(int, input().split())
if S <= W:
    print("unsafe")
else:
    print("safe")
import numpy as np
mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))
A = np.array(A, dtype = np.int64)
tmp = 0
for i in range(61):
    tmp_1 = np.count_nonzero
    tmp += ((tmp_1)*(N - tmp_1)*(2**i)) % mod
    A = A >> 1
print(tmp % mod)

### FIXED CODE ###

import numpy as np
mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))
A = np.array(A, dtype = np.int64)
tmp = 0
for i in range(61):
    tmp_1 = np.count_nonzero(A & 1)
    tmp += ((tmp_1)*(N - tmp_1)*(2**i)) % mod
    A = A >> 1
print(tmp % mod)
import sys
import math
import heapq
from collections import defaultdict, deque
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''C Tsundoku'''
n,m,k=rm()
a=rl()
b=rl()
c=[0]*(n+1)
d=[0]*(b+1)
for i in range(n):
    c[i+1]=c[i]+a[i]
for i in range(m):
    d[i+1]=d[i]+b[i]
ans=0;j=m
for i in range(n+1):
    if c[i]>k:
        break
    while c[i]+d[j]>k:
        j-=1
    ans=max(ans,i+j)
print(ans)

### FIXED CODE ###

import sys
import math
import heapq
from collections import defaultdict, deque
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''C Tsundoku'''
n,m,k=rm()
a=rl()
b=rl()
c=[0]*(n+1)
d=[0]*(m+1)
for i in range(n):
    c[i+1]=c[i]+a[i]
for i in range(m):
    d[i+1]=d[i]+b[i]
ans=0;j=m
for i in range(n+1):
    if c[i]>k:
        break
    while c[i]+d[j]>k:
        j-=1
    ans=max(ans,i+j)
print(ans)
import function
n, start = [int(i) for i in input().split()]
x_list = [int(i) for i in input().split()]
x_list.append(start)
x_list.sort()


current_gcd = x_list[1] - x_list[0]
for i in range(1, n-1):
    gap = x_list[i+1] - x_list[i]
    current_gcd = function.gcd(current_gcd, gap)

print(current_gcd)

### FIXED CODE ###

import fractions
n, start = [int(i) for i in input().split()]
x_list = [int(i) for i in input().split()]

x_list.sort()

current_gcd = 0
for i in range(0, n):
    gap = abs(start - x_list[i])
    current_gcd = fractions.gcd(current_gcd, gap)

print(current_gcd)