Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline
from bisect import *
from heapq import *
up=2*10**5
maxi=10**10
kind=[heapify([]) for i in range(up)]

class segtree:
    x_unit=maxi # 要素として入れられる最大値
    x_func=min
    def __init__(self,n):
        self.n=n
        self.x=[self.x_unit]*(2*n)
    def build(self, seq):
        for i,j in enumerate(seq, start=self.n):  # n番目からseqをx配列に移していく
            self.x[i] = j
        for i in range(self.n-1, 0, -1):
            self.x[i] = self.x_func(self.x[i*2], self.x[i*2+1])
            # セグ木トーナメント表の左右を比較
            # 例えばn=8の時、seq[4]はx[12]に、seq[5]はx[13]に入っている
            # さらにx[14]とx[15]の間に来るのはx[7]、x[12]とx[13]の間に来るのはx[6]
            # x_funcに従って値を取得
    def set_val(self,i,j): # 1点更新
        i += self.n
        self.x[i]=j
        while i>1:
            i//=2 # 更新後、木の上へと登っていくついでに更新
            self.x[i]=self.x_func(self.x[i*2], self.x[i*2+1])
    def fold(self,l,r): # 区間[l, r)の最小値などを取得 
        l+=self.n
        r+=self.n
        val_l=self.x_unit
        val_r=self.x_unit
        while l<r:
            if l & 1: # lが奇数
                val_l=self.x_func(val_l,self.x[l])
                l+=1 # 偶数に調節
            if r & 1: # rが奇数
                r-=1 # 開区間なので1個前は偶数番目の要素
                val_r=self.x_func(val_r,self.x[r])
            l //= 2
            r //= 2
        return self.x_func(val_l,val_r)

n,q=map(int, input().split())
shozoku=[-1]*n
rating=[0]*n
for i in range(n):
    a,b=map(int, input().split())
    heappush(kind[b-1],a)
    shozoku[i]=b-1
    rating[i]=a
#print(kind)
seg=segtree(up)
root=[maxi for i in range(up)]

for i in range(up):
    if kind[i]!=[]:
        rate=kind[i][-1]
        root[i]=rate
seg.build(root)

for i in range(q):
    c,d=map(int, input().split())
    c-=1
    d-=1
    if rating[c]==kind[shozoku[c]][-1] and len(kind[shozoku[c]])==1:
        kind[shozoku[c]]=heapify([])
        seg.set_val(shozoku[c], 2<<30)
    elif rating[c]==kind[shozoku[c]][-1]:
        kind[shozoku[c]]=heapify(kind[shozoku[c]][:-1])
        seg.set_val(shozoku[c], kind[shozoku[c]][-1])
    else:
        ind=bisect_right(kind[shozoku[c]],rating[c])
        kind[shozoku[c]]=heapify(kind[shozoku[c]][:ind-1]+kind[shozoku[c]][ind:])
    heappush(kind[d], rating[c])
    seg.set_val(d, kind[d][-1])
    shozoku[c]=d
    print(seg.x[1])


### FIXED CODE ###

*x,=map(int, input().split())
for i in range(5):
    if x[i]==0:
        print(i+1)
        break
a,b,c=map(int,input().spilt())
if((a+b)>=c):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b,c = map(int,input().split())
if a+b>=c:
  print("Yes")
else:
  print("No")
n=input()

if(n[0] == 1):
  n[0] = 9
else:
  n[0] = 1
if(n[1] == 1):
  n[1] = 9
else:
  n[1] = 1
if(n[2] == 1):
  n[2] = 9
else:
  n[2] = 1

### FIXED CODE ###

n = int(input())
if n == 111:
  print(999)
if n == 119:
  print(991)
if n == 191:
  print(919)
if n == 199:
  print(911)
if n == 911:
  print(199)
if n == 919:
  print(191)
if n == 991:
  print(119)
if n == 999:
  print(111)
from numba import njit
from sys import stdin, setrecursionlimit


@njit(cache=True)
def cmb(n, r, mod=10 ** 9 + 7):
    r = min(r, n - r)
    x = y = 1
    for i in range(r):
        x *= n - i
        x %= mod
        y *= i + 1
        y %= mod
    return x * pow(y, mod - 2, mod) % mod


def main():
    mod = 10 ** 9 + 7
    n, k = map(int, stdin.readline().split())
    a = list(map(int, stdin.readline().split()))
    a.sort()
    ans = 0
    a_cmb = [0] * n
    for i in range(n):
        a_cmb[i] = cmb(i, k - 1, mod)
    for i in range(n - k + 1):
        ans -= a[i] * a_cmb[n - 1 - i]
        ans %= mod
    for i in range(k - 1, n):
        ans += a[i] * a_cmb[i]
        ans %= mod
    print(ans % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

### FIXED CODE ###

from sys import stdin, setrecursionlimit


def main():
    mod = 10 ** 9 + 7
    n, k = map(int, stdin.readline().split())
    a = list(map(int, stdin.readline().split()))
    a.sort()
    ans = 0

    m = n + 1

    fac = [0] * m
    finv = [0] * m
    inv = [0] * m

    def initialize_cmb(m):
        fac[0] = 1
        finv[0] = 1
        if m > 1:
            fac[1] = 1
            finv[1] = 1
            inv[1] = 1
            for i in range(2, m):
                fac[i] = fac[i-1] * i % mod
                inv[i] = mod - inv[mod % i] * (mod // i) % mod
                finv[i] = finv[i - 1] * inv[i] % mod

    def cmb(n, k, mod=10 ** 9 + 7):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod

    initialize_cmb(m)

    for i in range(n - k + 1):
        ans -= a[i] * cmb(n - 1 - i, k - 1)
        ans %= mod
    for i in range(k - 1, n):
        ans += a[i] * cmb(i, k - 1)
        ans %= mod
    print(ans % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
a,b = map(int,raw_input().split())
if a < b:
      print(a < b)
elif a > b:
      print(a > b)
else:
      print(a == b)

### FIXED CODE ###

a,b = map(int,input().split())
if a < b:
      print("a < b")
elif a > b:
      print("a > b")
else:
      print("a == b")
s = input()
if s = "RRR":
  print(3)
  elif s = "RRS" or s = "SRR":
    print(2)
    elif s = "SSS":
      print(0)
      else:
        print(1)

### FIXED CODE ###

s = input()
if s == "RRR":
  print(3)
if s == "SSS":
  print(0)
if s == "RRS":
  print(2)
if s == "SRR":
  print(2)
if s == "RSS":
  print(1)
if s == "SRS":
  print(1)
if s == "SSR":
  print(1)
if s == "RSR":
  print(1)
def common():
????X = raw_input()
  Y = raw_input()
????a = len(X)
????b = len(Y)
????k1 = [0 for i in range(b+1)]
????
????for i in range(a):
????????k2 = k1 + []
????????for j in range(b):
????    if X[i] == Y[j]:
?????????????? k1[j+1] = k2[j] + 1
      elif k1[j+1] < k1[j]:
????????????????k1[j+1] = k1[j]
  
  return k1[-1]

n = input()
for l in range(n):
????print common()

### FIXED CODE ###

def common():
  X = raw_input()
  Y = raw_input()
  a = len(X)
  b = len(Y)
  k1 = [0 for i in range(b+1)]
 
  for i in range(a):
     k2 = k1 + []
     for j in range(b):
       if X[i] == Y[j]:
          k1[j+1] = k2[j] + 1
       elif k1[j+1] < k1[j]:
          k1[j+1] = k1[j]
 
  return k1[-1]
 
n = input()
for l in range(n):
  print common()
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n,x=map(int,input().split())
x_lst=list(map(int,input().split()))
x_lst=list(map(lambda a:abs(a-x),x_lst))
print(gcd_list(x_lst))

### FIXED CODE ###

import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n,x=map(int,input().split())
x_lst=list(map(int,input().split()))
x_lst=list(map(lambda a:abs(a-x),x_lst))
print(gcd_list(x_lst))
a = input()
b = int(input())
ar = list(a)
ar.sort()
br = []
for i in range(len(a)):
    if a[i] == ar[0]:
        try:
            for j in range(1,b+1):
                br.append(a[i:i+j])
        except indexError:
            break
cr = set(br)
if len(cr) < b:
    for i in range(len(a)):
        if ar[i] == ar[1]:
            try:
                for j in range(1,b+1):
                    br.append(a[i:i+j])
            except indexError:
                break
dr = set(br)
er = sorted(dr)
print(er[b-1])

### FIXED CODE ###

a = input()
b = int(input())
ar = set(list(a))
arr = sorted(ar)
br = []
for i in range(len(a)):
    if a[i] == arr[0]:
        try:
            for j in range(1,b+1):
                br.append(a[i:i+j])
        except indexError:
            break
cr = set(br)
if len(cr) < b:
    for i in range(len(a)):
        if a[i] == arr[1]:
            try:
                for j in range(1,b+1):
                    br.append(a[i:i+j])
            except indexError:
                break
dr = set(br)
er = sorted(dr)
print(er[b-1])
import sys

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    out = 'NO'
    t = (B - A) / (V - W)
    if isinstance(t, int):
        if t<=T:
            out = 'YES'
        
    print(out)
main()

### FIXED CODE ###

import sys

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    out = 'NO'

    if V==W:
        if B==A:
            out = 'YES'
            print(out)
            sys.exit()
        else:
            print(out)
            sys.exit()

    if B < A:
        t = (B - A) / (W - V)
    else:
        t = (B - A) / (V - W)
        
    if t >= 0:
        if t<=T:
            out = 'YES'
    
    print(out)
main()
N, M = map(int, input().split(" "))
a_n = list(set(map(int, input().split(" "))))
g = a.copy()
 
while not any(x%2 for x in g):
  g = [i //2 for i in g]
  if not all(x%2 for x in g): 
    print(0); exit(0)

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
 
def lcm(a, b):
  return a * b // gcd(a, b)
 
tot = 1
 
for x in a:
  tot = lcm(tot, x//2)
print((M//tot+1)//2)

### FIXED CODE ###

N,M = map(int, input().split())
a_n = list(map(int, input().split()))
g = a_n.copy()
 
while not any(x%2 for x in g): g = [x//2 for x in g]
if not all(x%2 for x in g): print(0); exit(0)
def gcd(a,b):
  while b: a,b = b,a%b
  return a
lcm = lambda a,b: a*b//gcd(a,b)
tot = 1
for x in a_n: tot = lcm(tot,x//2)
print((M//tot+1)//2)
#!/usr/bin/python3

import os
import sys


def main():
    N = read_int()
    A = read_ints()
    print(solve(N, A))


MOD = 1000000007


def solve(N, A):
    c = 1
    nums = [0, 0, 0]

    for a in A:
        z = nums.count(a)
        c *= z
        c %= MOD
        nums[nums.index(a)] = a + 1

    return c


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/python3

import os
import sys


def main():
    N = read_int()
    A = read_ints()
    print(solve(N, A))


MOD = 1000000007


def solve(N, A):
    c = 1
    nums = [0, 0, 0]

    for a in A:
        z = nums.count(a)
        if z == 0:
            return 0
        c *= z
        c %= MOD
        nums[nums.index(a)] = a + 1

    return c


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()
def digitSum(n):
    # 桁数を判定する
    if len(str(n)) is 1:
        return n
    dst = sum(list(map(int, str(n))))
    return digitSum(dst)


if __name__ == "__main__":
  n = N
  result = digitSum(n)

    print(int(result))

### FIXED CODE ###

N = int(input())
if N % 9 == 0:
  print('Yes')
else:
  print('No')
n,q = map(int,raw_input().split())
A = [2**31-1 for i in range(n)]
B = [2**31-1]*317
for i in range(q):
    comi,xi,yi = map(int,raw_input().split())
    if comi and yi<316:
        print min(A[xi:yi+1])
    elif comi and yi >= 316 and xi/316+1 != yi/316:
        print min(min(A[xi:(xi/316 + 1)*316]),min(B[xi/316+1:yi/316]),min(A[(yi/316)*316:yi+1]))
    elif comi and yi >= 316 and xi/316+1 == yi/316:
        print min(min(A[xi:(xi/316 + 1)*316]),min(A[(yi/316)*316:yi+1]))
    else:
        A[xi]=yi
        B[xi/316] = min(B[xi/316],yi)

### FIXED CODE ###

# coding: utf-8

n, q = map(int,raw_input().split())
A = [(1<<31) - 1 for i in xrange(100000)]
B = [(1<<31) - 1 for i in xrange(101)]
 
def update(i,x):
    if A[i] == (1<<31) - 1:
        A[i] = x
        B[i/1000] = min(x, B[i/1000])
    else:
        A[i] = x
        MIN = (1<<31) - 1
        for j in xrange(i/1000 * 1000, (i/1000 + 1) * 1000):
            if A[j] < MIN:
                MIN = A[j]
        B[i/1000] = MIN
 
def find(s,t):
    MIN = (1<<31) - 1
    if s/1000 == t/1000 or s/1000 + 1 == t/1000:
        for i in xrange(s, t+1):
            if A[i] < MIN:
                MIN = A[i]
    else:
        #left range
        for i in xrange(s, (s/1000 + 1) * 1000):
            if A[i] < MIN:
                MIN = A[i]
        #middle range
        for j in xrange(s/1000 + 1, t/1000):
            if B[j] < MIN:
                MIN = B[j]
         
        #right range
        for i in xrange(t/1000 * 1000, t+1):
            if A[i] < MIN:
                MIN = A[i]
    print MIN   
     
for i in xrange(q):
    com, s, t = map(int,raw_input().split())
    if com: #find
        find(s,t)
    else: #update
        update(s,t)
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    if a[i] % 6 == or a[i] % 10:
        print('APPROVED')
        break

print('DENIED')

### FIXED CODE ###

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

for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 == 0 or a[i] % 5 == 0:
            continue
        else:
            print('DENIED')
            exit()

print('APPROVED')
INF = 10**10
arr = [INF,2,5,5,4,5,6,3,7,6]
N,M = map(int,input().split())
src = sorted(list(map(int,input().split())))

dp = [-INF]*(N+1)
dp[0] = 0
for i in range(N):
    for j in src:
        if i + arr[j] <= N:
            dp[i + arr[j]] = max(dp[i + arr[j]], dp[i] + 1)
ans = ''
while(N > 0):
    for i in src[::-1]:
        if dp[N-arr[i]] == dp[N] - 1:
            ans += str(i)
            N -= arr[i]
            break
print(ans)

### FIXED CODE ###

INF = 10**10
arr = [INF,2,5,5,4,5,6,3,7,6]
N,M = map(int,input().split())
src = sorted(list(map(int,input().split())))

dp = [-INF]*(N+1)
dp[0] = 0
for i in range(N):
    for j in src:
        if i + arr[j] <= N:
            dp[i+arr[j]] = max(dp[i+arr[j]],dp[i] + 1)
dim = dp[N]
ans  = ''
while(dim > 0):
    for i in src[::-1]:
        if N >= arr[i] and dp[N-arr[i]] + 1 == dp[N]:
            ans += str(i)
            N -= arr[i]
            dim -= 1
            break
print(ans)
s = input()
if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
elif len(s) != 26:
    used = [False] * 26
    for i in range(len(s)):
        used[ord(s[i]) - ord("a")] = True
    for i in range(26):
        if used[i] is False:
            s += chr(ord("a") + i)
            print(s)
            break
else:
    ss = []
    s = list(s)
    done = False
    used = [False] * 26
    for i in range(25):
        #print("load", s[i])
        if s[i] > s[i+1]:
            used[ord(s[i]) - ord("a")] = True
            #print(s[i])
            for i in range(26):
                if used[i] is False:
                    ss[-1] = chr(ord("a") + i)
                    print("".join(ss))
                    done = True
                    break
                if done:
                    break
        else:
            ss += s[i]
            used[ord(s[i]) - ord("a")] = True


### FIXED CODE ###

def next_permutation(case):
    for index in range(1, len(case)):
        Px_index = len(case) - 1 - index
        # Start travelling from the end of the Data Structure
        Px = case[-index - 1]
        Px_1 = case[-index]

        # Search for a pair where latter the is greater than prior
        if Px < Px_1:
            suffix = case[-index:]
            pivot = Px
            minimum_greater_than_pivot_suffix_index = -1
            suffix_index = 0

            # Find the index inside the suffix where ::: [minimum value is greater than the pivot]
            for Py in suffix:
                if pivot < Py:
                    if minimum_greater_than_pivot_suffix_index == -1 or \
                            suffix[minimum_greater_than_pivot_suffix_index] >= Py:
                        minimum_greater_than_pivot_suffix_index = suffix_index
                suffix_index += 1
            # index in the main array
            minimum_greater_than_pivot_index = minimum_greater_than_pivot_suffix_index + Px_index + 1

            # SWAP
            temp = case[minimum_greater_than_pivot_index]
            case[minimum_greater_than_pivot_index] = case[Px_index]
            case[Px_index] = temp

            # Sort suffix
            new_suffix = case[Px_index + 1:]
            new_suffix.sort()

            # Build final Version
            new_prefix = case[:Px_index + 1]
            next_permutation = new_prefix + new_suffix
            return next_permutation
        elif index == (len(case) - 1):
            # This means that this is at the highest possible lexicographic order
            return False


s = input()
if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
elif len(s) != 26:
    used = [False] * 26
    for i in range(len(s)):
        used[ord(s[i]) - ord("a")] = True
    for i in range(26):
        if used[i] is False:
            s += chr(ord("a") + i)
            print(s)
            break
else:
    dat = []
    for i in range(len(s)):
        dat.append(ord(s[i]) - ord("a"))
    #print(dat)
    #print(next_permutation(dat))
    dat = next_permutation(dat)
    res = ""
    t = "".join(list(map(lambda x: chr(ord("a") + x), dat)))
    for i in range(26):
        print(t[i], end="")
        if s[i] != t[i]:
            break
    print("")
import sys
input = sys.stdin.readline
N,L = map(int,input().split())
lst = [L]
for i in range(n-1):
  lst.append(lst[-1]-1)
arr = [abs(i) for i in lst]
del lst[arr.index(min(arr))]
print(sum(lst))


### FIXED CODE ###

import sys
input = sys.stdin.readline
N,L = map(int,input().split())
lst = [L]
for i in range(N-1):
  lst.append(lst[-1]+1)
arr = [abs(i) for i in lst]
del lst[arr.index(min(arr))]
print(sum(lst))
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

if __name__ == "__main__":
    n,x = map(int,input().split())
    X = list(map(int,input().split()))
    X.sort()
    a = bisect.bisect_left(X,x)
    X.insert(a,x)
    ans = []
    for i in range(1,len(X)):
        diff = X[i] - X[i-1]
        ans.append(diff)
    d = ans[0]
    for i in range(1,len(ans)):
        d = math.gcd(d,ans[i])
    print(d)
    

### FIXED CODE ###

import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

if __name__ == "__main__":
    n,x = map(int,input().split())
    X = list(map(int,input().split()))
    X.sort()
    a = bisect.bisect_left(X,x)
    X.insert(a,x)
    ans = []
    for i in range(1,len(X)):
        diff = X[i] - X[i-1]
        ans.append(diff)
    d = ans[0]
    for i in range(1,len(ans)):
        d = gcd(d,ans[i])
    print(d)
from decimal import *
a,b,c=map(int,input().split(' '))

if Decimal(a)**0.5+Decimal(b)**0.5<Decimal(c)**0.5:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

from decimal import *
a,b,c=map(int,input().split(' '))

if Decimal(a).sqrt()+Decimal(b).sqrt()<Decimal(c).sqrt():
  print("Yes")
else:
  print("No")
import numpy as np
h, w, d = map(int, input().split())
a = np.array([list(map(int, input().split())) for _ in range(h)])
q = int(input())
num = h * w
mass = np.array([[0, 0] for _ in range(num + 1)])
mp = []
for i in range(h):
    for j in range(w):
        a_ij = a[i][j]
        mass[a_ij] = [i, j]
for i in range(d):
    mass_sort = mass[1+i::d]
    mp_i = np.sum(abs(mass_sort[:-1] - mass_sort[1:]), axis=1)
    mp.append(mp_i.cumsum())
for _ in range(q):
    l, r = map(int, input().split())
    n = (r - l) // d
    u = l % d
    index = (l - (d - u)) // 2
    if index == 0:
        print(mp[-(u+1)][index+n-1])
    else:
        print(mp[-(u+1)][index+n-1]-mp[-(u+1)][index-1])


### FIXED CODE ###

import sys
input = sys.stdin.readline
h, w, d = map(int, input().split())
num = h * w
x = [0] * (num + 1)
y = [0] * (num + 1)
mp = [0] * (num + 1)
for i in range(h):
    for j, a in enumerate(map(int, input().split())):
        x[a], y[a] = [i+1, j+1]
for i in range(d+1, num+1):
    mp[i] = mp[i-d] + abs(x[i] - x[i-d]) + abs(y[i] - y[i-d])
q = int(input())
for _ in range(q):
    l, r = map(int, input().split())
    print(mp[r]-mp[l])
def factors(z):
    ret = []
    for i in range(2, int(z**(1/2))+1):
        if z%i == 0:
            ret.append(i)
            while z%i == 0:
                z //= i
    if z != 1:
        ret.append(z)
    return ret

def eratosththenes(N):
    if N == 0:
        return [0]
    work = [True] * (N+1)
    work[0] = False
    work[1] = False
    for i in range(N+1):
        if work[i]:
            for j in range(2* i, N+1, i):
                work[j] = False
    return work


N = int( input())
A = [ int( input()) for _ in range(N+1)]
E = eratosththenes(N)
Primes = [ i for i in range(N+1) if E[i] == 1]
ANS = []
F = factors(A[0])
for f in F:
    if f >= N+1:
        Primes.append(f)
for p in Primes:
    if p >= N+1:
        check = 1
        for i in range(N+1):
            if A[i]%p != 0:
                check = 0
                break
        if check == 1:
            ANS.append(p)
    else:
        poly = [0]*(p-1)
        for i in range(N+1):
            poly[(N-i)%(p-1)] = (poly[(N-i)%(p-1)] + A[i])%p
        check = 1
        if sum(poly) != 0:
            check = 0
        if check == 1:
            ANS.append(p)
for ans in ANS:
    print(ans)



### FIXED CODE ###

def factors(z):
    ret = []
    for i in range(2, int(z**(1/2))+1):
        if z%i == 0:
            ret.append(i)
            while z%i == 0:
                z //= i
    if z != 1:
        ret.append(z)
    return ret

def eratosththenes(N):
    if N == 0:
        return [0]
    work = [True] * (N+1)
    work[0] = False
    work[1] = False
    for i in range(N+1):
        if work[i]:
            for j in range(2* i, N+1, i):
                work[j] = False
    return work


N = int( input())
A = [ int( input()) for _ in range(N+1)]
E = eratosththenes(N)
Primes = [ i for i in range(N+1) if E[i] == 1]
ANS = []
F = factors( abs(A[0]))
for f in F:
    if f >= N+1:
        Primes.append(f)
for p in Primes:
    if p >= N+1:
        check = 1
        for i in range(N+1):
            if A[i]%p != 0:
                check = 0
                break
        if check == 1:
            ANS.append(p)
    else:
        poly = [0]*(p-1)
        for i in range(N+1):
            poly[(N-i)%(p-1)] = (poly[(N-i)%(p-1)] + A[i])%p
        check = 1
        if sum(poly) != 0 or A[N]%p != 0:
            check = 0
        if check == 1:
            ANS.append(p)
for ans in ANS:
    print(ans)
from collections import deque
X, Y, A, B, C = map(int, input().split())
qa = deque(sorted(list(map(int, input().split())), reverse=True))
qb = deque(sorted(list(map(int, input().split())), reverse=True))
qc = deque(sorted(list(map(int, input().split())), reverse=True))
ans = 0
for _ in range(X):
    if qa[0] >= qc[0]:
        ans += qa.popleft()
    else:
        ans += qc.popleft()

for _ in range(Y):
    if qb[0] >= qc[0]:
        ans += qb.popleft()
    else:
        ans += qc.popleft()
print(ans)

### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
qa = sorted(list(map(int, input().split())), reverse=True)
qb = sorted(list(map(int, input().split())), reverse=True)
qc = sorted(list(map(int, input().split())), reverse=True)
chk = []
chk.extend(qa[:X]+qb[:Y]+qc)
chk.sort(reverse=True)
print(sum(chk[:X+Y]))
doubutsu, ashi = input().split()

#doubutsu = 2 #X
#ashi = 100 #Y

kame = (ashi-2*doubutsu)/2
tsuru = doubutsu - kame

if type(kame) == int and type(tsuru) == int:
    if kame >= 0 and tsuru >= 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

### FIXED CODE ###

listt = input().split()

doubutsu = int(listt[0])
ashi = int(listt[1])

kame = (ashi-2*doubutsu)/2
tsuru = doubutsu - kame

if ashi%2 == 0 and kame >= 0 and tsuru >= 0:
    print('Yes')
else:
    print("No")
n, k = list(map(int, input().split()))

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

prices = sorted(prices)

print(sum(prices[:k])

### FIXED CODE ###

n, k = list(map(int, input().split()))
prices = list(map(int, input().split()))
prices = sorted(prices)
print(sum(prices[:k]))