Harryxun/stf_run huggingface dataset:
import sys
from collections import *
import heapq
import math
# from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
# def input():
#     return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
a=list(map(int,input().split()))
rlst=ruiseki(a)
# print(rlst)
lst=[]
for i in range(n+1):
    for j in range(i+1,n+1):
        # print(i,j)
        lst.append(rlst[j]-rlst[i])
# print(lst)
tmp=math.log2(rlst[-1])
now=int(tmp)

while now>=0:
    anslst=[]
    for i in range(len(lst)):
        if 1&(lst[i]>>now)==1:
            anslst.append(lst[i])
    if len(anslst)>=k:
        lst=anslst
    now-=1
# print(lst)
ans=lst[0]
for i in range(k):
    ans=ans&lst[i]
print(ans)

### FIXED CODE ###

import sys
from collections import *
import heapq
import math
# from math import gcd
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
# def input():
#     return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
a=list(map(int,input().split()))
rlst=ruiseki(a)
# print(rlst)
lst=[]
for i in range(n+1):
    for j in range(i+1,n+1):
        # print(i,j)
        lst.append(rlst[j]-rlst[i])
# print(lst)
tmp=math.log(rlst[-1],2)
now=int(tmp)

while now>=0:
    anslst=[]
    for i in range(len(lst)):
        if 1&(lst[i]>>now)==1:
            anslst.append(lst[i])
    if len(anslst)>=k:
        lst=anslst
    now-=1
# print(lst)
ans=lst[0]
for i in range(k):
    ans=ans&lst[i]
print(ans)
N,K,C=map(int,input().split())
S=input()
i=0
data1=[0 for i in range(0,N)]
if S[0]=='o':
    for j in range(0,C+1):
        data1[j]=(1,C+1)
    i=C+1
else:
    data1[0]=(0,1)
    i=1
while N-1>=i:
    if S[i]=='o':
        for j in range(0,C+1):
            if N>i+j:
                data1[i+j]=(data1[i-1][0]+1,min(i+C+1,N))
        i+=C+1
    else:
        data1[i]=(data1[i-1][0],i+1)
        i+=1

data2=[0 for i in range(0,N)]
if S[-1]=='o':
    for j in range(0,C+1):
        data2[j]=1
    i=C+1
else:
    data2[0]=0
    i=1
while N-1>=i:
    if S[-i-1]=='o':
        for j in range(0,C+1):
            if N>i+j:
                data2[i+j]=data2[i-1]+1
        i+=C+1
    else:
        data2[i]=data2[i-1]
        i+=1

for i in range(0,N):
    if S[i]=='o':
        if i==0:
            if K>data2[N-2]:
                print(i+1)
        elif N-1>i:
            work,nextday=data1[i-1]
            if nextday!=N:
                nextday=max(nextday,i+1)
                if K>work+data2[N-1-nextday]:
                    print(i+1)
            else:
                if K>work:
                    print(i+1)
        elif i==N-1:
            if K>data1[N-2][0]:
                print(i+1)



### FIXED CODE ###

N,K,C=map(int,input().split())
S=input()
i=0
data1=[0 for i in range(0,N)]
if S[0]=='o':
    for j in range(0,C+1):
        if N>j:
            data1[j]=(1,min(N,C+1))
    i=C+1
else:
    data1[0]=(0,1)
    i=1
while N-1>=i:
    if S[i]=='o':
        for j in range(0,C+1):
            if N>i+j:
                data1[i+j]=(data1[i-1][0]+1,min(i+C+1,N))
        i+=C+1
    else:
        data1[i]=(data1[i-1][0],i+1)
        i+=1

data2=[0 for i in range(0,N)]
if S[-1]=='o':
    for j in range(0,C+1):
        if N>j:
            data2[j]=1
    i=C+1
else:
    data2[0]=0
    i=1
while N-1>=i:
    if S[-i-1]=='o':
        for j in range(0,C+1):
            if N>i+j:
                data2[i+j]=data2[i-1]+1
        i+=C+1
    else:
        data2[i]=data2[i-1]
        i+=1

if N==1:
    print(1)
else:
    for i in range(0,N):
        if S[i]=='o':
            if i==0:
                if K>data2[N-2]:
                    print(i+1)
            elif N-1>i:
                work,nextday=data1[i-1]
                if nextday!=N:
                    nextday=max(nextday,i+1)
                    if K>work+data2[N-1-nextday]:
                        print(i+1)
                else:
                    if K>work:
                        print(i+1)
            elif i==N-1:
                if K>data1[N-2][0]:
                    print(i+1)
# 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%2 + 2
    neighbor[v-1][u-1] = w%2 + 2

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])
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(H: int, W: int, A: "List[str]"):
    holes = [[float('inf')] * W for _ in range(H)]
    for i,l in enumerate(A):
        for j, c in enumerate(l):
            if c == '#':
                holes[i][j] = 0
    for i in range(H):
        for j in range(1, W):
            holes[i][j] = min(holes[i][j], holes[i][j-1] + 1)
        for j in range(W - 2, -1, -1):
            holes[i][j] = min(holes[i][j], holes[i][j+1] + 1)

    for j in range(W):
        for i in range(1, H):
            holes[i][j] = min(holes[i][j], holes[i-1][j] + 1)
        for i in range(H - 2, -1, -1):
            holes[i][j] = min(holes[i][j], holes[i+1][j] + 1)

    ret = -float('inf')
    for i in range(H):
        for j in range(W):
            ret = max(ret, holes[i][j])
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(W) ]  # type: "List[str]"
    result = solve(H, W, A)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *


def solve(H: int, W: int, A: "List[str]"):
    queue = deque()

    rem = H * W
    visited = [True] * ((W+2) * (H+2))
    for i in range(W+2):
        visited[i] = False
        visited[(W + 2) * (H + 1) + i] = False
    for i in range(H+2):
        visited[(W + 2) * i] = False
        visited[(W + 2) * i + (W + 1)] = False

    for i in range(H):
        l = A[i]
        for j in range(W):
            if l[j] == '#':
                queue.append((i+1, j+1, 0))
                k = i * (W + 2) + j
                visited[k] = False

    ret = 0
    while queue:
        i, j, n = queue.popleft()
        k = i * (W + 2) + j
        if not visited[k] and 0 < n:
            continue
        visited[k] = False
        ret = n
        rem -= 1

        if rem == 0:
            break

        if visited[k - 1]:
            queue.append((i, j - 1, n + 1))
        if visited[k + 1]:
            queue.append((i, j + 1, n + 1))

        if visited[k - (W + 2)]:
            queue.append((i - 1, j, n + 1))
        if visited[k + (W + 2)]:
            queue.append((i + 1, j, n + 1))
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    result = solve(H, W, A)
    print(result)

if __name__ == '__main__':
    main()
S = str(input())
if S[-3:] = "nny":
    print("Cloudy")
elif S[-2:] = "dy":
    print("Rainy")
else:
    print("Sunny")

### FIXED CODE ###

S = str(input())
if S[-3:] == "nny":
    print("Cloudy")
elif S[-2:] == "dy":
    print("Rainy")
else:
    print("Sunny")
n=int(input)
print(n**2)

### FIXED CODE ###

n=int(input())
print(n**2)
N, M = map(int, input().split())
ans = [-1]*N
for i in range(M):
    s,m =map(int, input().split())
    if ans[s-1]!=m and ans[s-1]!=-1:
        print(-1)
        exit()
    ans[s-1]=m
if ans[0]==0:
    print(-1)
    exit()
if ans[0]==-1 and ans[1]==0:
    ans[0]=1
for i in range(N):
    if ans[i]==-1:
        ans[i]=0
Ans = [str(a) for a in ans]
print(''.join(Ans))

### FIXED CODE ###

N, M = map(int, input().split())
S = []
C = []
for i in range(M):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)

for i in range(10000):
    tmp = str(i)
    if len(tmp)!=N:
        continue
    flag = True
    for j in range(M):
        if int(tmp[S[j] - 1]) != C[j]:
            flag = False
    if flag == True:
        print(tmp)
        exit()
else:
    print(-1)
# coding: utf-8
from math import factorial
N, K = map(int, input().split())
mod = 10**9 + 7
def combination(n, r):
    if n > r:
        return int(factorial(n) / (factorial(r) * factorial(n - r)))
    else:
        return 1
for i in range(1, K+1):
    if i%2 == 0:
        print(combination(N-K+1, i)*2%mod)
    else:
        print(combination(N-K+1, i)%mod)

### FIXED CODE ###

# coding: utf-8
from math import factorial
def combination(n, r):
    if n >= r and n >= 0 and r >= 0:
        return int(factorial(n) // (factorial(r) * factorial(n - r)))
    else:
        return 0
N, K = map(int, input().split())
mod = 10**9 + 7

for i in range(1, K+1):
    print(combination(N-K+1, i) * combination(K-1, i-1)%mod)
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num == 0 or blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    rest = int(num % all_ball)
    if rest <= blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + blue)



### FIXED CODE ###

# coding: utf-8
import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
count = num // all_ball
rest = num % all_ball
print(count * blue_num + min(rest, blue_num))
a,b=int(input().split())
print(a*b)

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b)
# -*- coding: utf-8 -*-


def selection_sort(A, N):
    for i in xrange(N):
        minj = i
        change = 0
        for j in xrange(i, N):
            if A[j] < A[minj]:
                minj = j
                temp = A[minj]
                A[minj] = A[j]
                A[j] = temp
                change += 1


if __name__ == "__main__":
    N = input()
    A = map(int, raw_input().split())
    result, change = selection_sort(A, N)
    print ' '.join(map(str, result))
    print change

### FIXED CODE ###

#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ??????????????? '''

# ????????????????????°?????????N(N-1)/2????????§???
# ?¨???????:O(n^2)


def selection_sort(A, N):
    swap_num = 0  # ???????????°

    for i in range(N):
        minj = i
        for j in range(i, N, 1):
            if A[j] < A[minj]:
                minj = j
        # swap
        if i != minj:
            tmp = A[i]
            A[i] = A[minj]
            A[minj] = tmp
            swap_num += 1

    return (A, swap_num)


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    # A = [5, 2, 4, 6, 1, 3]
    # N = len(A)
    array_sorted, swap_num = selection_sort(A, N)
    print(' '.join(map(str, array_sorted)))
    print(swap_num)
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A,B,C,D =  list(map(int,input().split(" ")))
CD = lcm(C,D)
A1 = A- 1
ans = (B//C + B//D - B//CD) - (A1//C + A1//D - A1//CD)



ans = (B-A+1) - ans
print(ans)

### FIXED CODE ###

import  fractions

def lcm(x, y):
    return (x * y) //  fractions.gcd(x, y)


def do():
    A,B,C,D =  list(map(int,input().split(" ")))
    CD = lcm(C,D)
    A1 = A- 1
    ans = (B//C + B//D - B//CD) - (A1//C + A1//D - A1//CD)
    ans = (B-A+1) - ans
    print(ans)

if __name__ == "__main__":
    do()
n=int(input())
A=[int(input())for i in range(5)]
if n%min(A)==0 print(n//min(A)+4) else print((n//min(A)+5)


### FIXED CODE ###

n=int(input())
A=[int(input())for i in range(5)]
if n%min(A)==0:
    print(n//min(A)+4)
else:
    print(n//min(A)+5)
import sys
count = 1
while true:
    x = sys.stdin.readline().strip()
    if x == 0:
        break
    print("Case {}: {}".format(count,x))
    count += 1

### FIXED CODE ###

import sys
count = 1
while True:
    x = sys.stdin.readline().strip()
    if x == "0":
        break
    print("Case {}: {}".format(count,x))
    count += 1
input()
    a = list(map(int, input().split()))
    m = 0
    end = 0
    for i in range(len(a)):
        if end < len(a) - 2:
            for j in range(i, len(a) - 1):
                if a[j] >= a[j + 1]:
                    m += 1
                    end = j
                else:
                    m = 0
                    break
    print(m)

### FIXED CODE ###

input()
a = list(map(int, input().split(" ")))
count = 0
arrayCount = []
for i in range(0, len(a) - 1):
    if a[i] >= a[i + 1]:
        count += 1
    else:
        arrayCount.append(count)
        count = 0
arrayCount.append(count)
print(max(arrayCount))
import itertools
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()

if N < M:
    mar = [abs(X[i+1] - X[i]) for i in range(len(M-1))]
    mar.sort()
    print(sum([mar[i] for i in range(M-N)]))
else:
    print(0)


### FIXED CODE ###

import itertools
N, M = list(map(int, input().split()))
X = list(map(int, input().split()))
X.sort()

if N < M:
    mar = [abs(X[i+1] - X[i]) for i in range(M-1)]
    mar.sort()
    print(sum([mar[i] for i in range(M-N)]))
else:
    print(0)
H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for h in range(H):
    for w in range(W):
        uf A[h][w] != -1:
        ans += c[A[h][w]][1]
print(ans)

### FIXED CODE ###

H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for h in range(H):
    for w in range(W):
        if A[h][w] != -1:
            ans += c[A[h][w]][1]
print(ans)
N = 
K = 
print(N-K+1)

### FIXED CODE ###

N,K = map(int,input().split())
print(N - K + 1)
N=int(input())

X=list(map(int, input().split()))

X.sort()
i=X[0]

min=100000000000000000
while i < X[-1]:
    power=0
    for j in range(len(X)):
        power=power+(X[j]-i)**2

    if power<=min:
        min=power

    i=i+1


print(min)

### FIXED CODE ###

N,R=map(int, input().split())

if 0<N<10:
  T=100*(10-N)
  print((R+T))
 
elif N<0:
  print("error")
  
else:
  print(R)
S = input()
 
h = S//3600
S = S - h * 3600
m = S // 60
s = S - m * 60
 
print("%d:%d:%d" %(h,m,s))


### FIXED CODE ###

if __name__ == '__main__':
	S = int(input())
	h = S // 3600
	S %= 3600
	m = S // 60
	S %= 60
	
	print("%d:%d:%d" %(h, m, S))
n = int(raw_input())
n = n +0.000000
if not n%2:
  print 0.500000000
else:
  print((n/2)/n)

### FIXED CODE ###

n = int(raw_input())
if n ==1:
	print 1
else:
	if not n%2:
	  print(0.500000000)
	else:
	  print((int(n/2)+1)/float(n))
import sys
from typing import *


def main(argv):
    # type: (List[str]) -> int
    a, b, *_ = map(int, argv) # type: Tuple[int, int, Any]
    if a % 2 == 0 or b % 2 == 0:
        print("Even")
    else:
        print("Odd")
    return 0

if __name__ == '__main__':
    # main(sys.argv[1:])
    main(input().split())


### FIXED CODE ###

import sys
#from typing import *


def main(argv):
    # type: (List[str]) -> int
    a, b, *_ = map(int, argv) # type: Tuple[int, int, Any]
    if a % 2 == 0 or b % 2 == 0:
        print("Even")
    else:
        print("Odd")
    return 0

if __name__ == '__main__':
    # main(sys.argv[1:])
    main(input().split())
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)
S = str(input())
N = len(S)
M = 13
c = [0]*(N)
for i in range(N):
    c[i] = (10**i)%M
#    c[i] = pow(10,i,M)
#print(c)
c.reverse()
#print(c)
"""
dp = [[0]*M for _ in range(N+1)]
i = int(0)
for j in range(M):
    dp[0][j] = 1
for s in S:
    if s == "?":
        for l in range(10):
            m = l * c[i] % M
            dp[i+1][(M - m) % M] += dp[i][j]
    else:
        m = int(s) * c[i] % M
        dp[i][(M - m) % M] +=dp[i][j]
    i +=1




dp = [[0]*M for _ in range(N)]
c = (10**(N-1))%M
if S[0] == "?":
    for l in range(10):
        dp[0][l*c%M] += 1
else:
    m = int(S[0]) * c%M
    dp[0][m] = 1
S = S[1:]
i = int(1)
for s in S:
    c = (10 ** (N - 1-i)) % M
    if s == "?":
        for j in range(13):
            for l in range(10):
                dp[i][j] += dp[i-1][(j-l*c)%13]
    else:
        st = int(s)
        for j in range(13):
            dp[i][j] = dp[i-1][(j-st*c)%13]
    i +=1

"""
dp = [[0]*M for _ in range(N)]
if S[0] == "?":
    for l in range(10):
        m = l * c[0]%M
        dp[0][m] += 1
else:
    m = int(S[0]) * c[0]%M
    dp[0][m] = 1

for i in range(1,N):
    if S[i] == "?":
        for j in range(M):
            for l in range(10):
                m = l*c[i]%M
                dp[i][j] += dp[i-1][(M+j-m)%M]%mod
    else:
        for j in range(M):
            m = int(S[i])*c[i]%M
            dp[i][j] = dp[i-1][(M+j-m)%M]
    for j in range(M):
        dp[i][j] %=mod

#print(dp)
print(dp[-1][5]%mod)
"""

### FIXED CODE ###

import sys
 
 
def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    s = str(input().rstrip('\n'))
    ls = [[0] * 13 for _ in range(len(s))]
    for i in range(len(s)):
        if i == 0:
            if s[-i-1] == "?":
                for j in range(10):
                    ls[i][j] += 1
            else:
                ls[i][int(s[-i-1])] += 1
        else:
            mult = pow(10, i, 13)
            if s[-i-1] == "?":
                for j in range(13):
                    for k in range(10):
                        ls[i][(k * mult + j) % 13] += ls[i-1][j]
            else:
                st = int(s[-i-1])
                for j in range(13):
                    ls[i][(st * mult + j) % 13] += ls[i-1][j]
        for j in range(13):
            ls[i][j] = ls[i][j] % mod
    print(ls[-1][5])
 
 
if __name__ == '__main__':
    solve()
s = str(input())

def check(text):
    n = len(text)
    if n == 1:
        return True

    left = int((n-1)/2)
    right = int((n+3)/2 - 1)

    print(text[0:left], text[right:n])
    if len(text[0:left]) == len(text[right:n]):
        if text[0:left] == text[right:n] and check(text[0:left]):
            return True
    else:
        if text[0:left] == text[right+1:n] and check(text[0:left]):
            return True
    return False

if check(s):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

def isKaibun(str):
    for i in range(len(str)):
        if str[i] != str[len(str)-i-1]:
            return False
    return True

s = input()

if not isKaibun(s):
    print("No")
elif not isKaibun(s[0:int((len(s) - 1) / 2)]):
    print("No")
elif not isKaibun(s[int((len(s) + 3) / 2)-1:len(s)]):
    print("No")
else:
    print("Yes")
n = int(input())
ans = {i*j for i in range(1,10) for j in range(1,10)}
if n in ans:
  print("Yes")
else:print("No")

### FIXED CODE ###

a, b = map(int, input().split())
if 1 <= a <=9 and 1 <= b <= 9:print(a*b)
else:print('-1')
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, factorial
from copy import deepcopy
 
def main():
    n = int(input()) % (10**9+7)
    num = 0
    ans = (10**n) - 2(9**n) + (8**n) 
    print(ans%810**9+7)
    

if __name__ == "__main__":
    main()

### FIXED CODE ###

import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, factorial
from copy import deepcopy
 
def main():
    n = int(input()) 
    ans = (10**n) - 2*(9**n) + (8**n) 
    print(ans%(10**9+7))
    

if __name__ == "__main__":
    main()
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
import heapq
AB.sort()
heap = []
heapq.heapify(heap)
ans = 0
i = 0
day = 1
while i < N and day <= M:
    while AB[i][0] <= day:
        heapq.heappush(heap,-AB[i][1])
        i += 1
    day += 1
    if not(heap):continue
    ans -= heapq.heappop(heap)

print(ans)

### FIXED CODE ###


N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
import heapq
AB.sort()
heap = []
heapq.heapify(heap)
ans = 0
i = 0
day = 1
while day <= M:
    while i < N and AB[i][0] <= day:
        heapq.heappush(heap,-AB[i][1])
        i += 1
    day += 1
    if not(heap):continue
    ans -= heapq.heappop(heap)

print(ans)
x = list(map(int, input().split()))
print(x)
x = sorted(x)
print(x)
if count(x[1]) == 2:
     print("Yes")
else:
     print("No")


### FIXED CODE ###

x = list(map(int, input().split()))
x = sorted(x)
if x.count(x[1]) == 2:
     print("Yes")
else:
     print("No")
import queue

n,m = map(int,input().split())

dis = [[] for i in range(n)]

for i in range(m):
    g1,g2,L =  map(int,input().split())
    dis[g1-1].append((g2-1,L))
    dis[g2-1].append((g1-1,-L))




geo = [0.5] * n

q = queue.Queue()


for i in range(m):
    if geo[i] == 0.5:
        q.put(i)
        while not q.empty():
            g1 = q.get()
            for g2,L in dis[g1]:
                if geo[g2] == 0.5:
                    geo[g2] = geo[g1] + L
                    q.put(g2)
                else:
                    if geo[g2] != geo[g1] + L:
                        print("No")
                        exit()
print("Yes")



"""
q = queue.Queue(0)
for i in range(1,5):
    q.put(i)
q.put(4)
while not q.empty():
    print(q.get())
"""


### FIXED CODE ###

import collections
from collections import deque
import sys
input = sys.stdin.readline
 
def bfs(s):
    d = deque()
    d.append(s)
    dis[s]=0
    flag=True
    while len(d):
        x = d.popleft()
        for i,j in vec[x]:
            if dis[i] == INF:
                dis[i]=dis[x]+j
                d.append(i)
 
            else:
                if dis[i]==dis[x]+j:
                    continue
                else:
                    print('No')
                    exit()
    return flag
 
 
n,m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
vec= [[] for i in range(n)]
 
for i in range(m):
    vec[a[i][0]-1].append((a[i][1]-1,a[i][2]))
    vec[a[i][1]-1].append((a[i][0]-1,-a[i][2]))
 
INF=float('inf')
dis=[INF]*n
 
for i in range(n):
    if dis[i]==INF:
        bfs(i)
print('Yes')
from math import gcd
N=int(input())
A=[int(i) for i in input().split()]

for i in range(N-1):
    A[-1]=gcd(A[-1],A[i])
print(A[-1])


### FIXED CODE ###

from fractions import gcd
N=int(input())
A=[int(i) for i in input().split()]

for i in range(N-1):
    A[-1]=gcd(A[-1],A[i])
print(A[-1])