Harryxun/stf_run huggingface dataset:
n = int(input())
hp_list = list(map(int, input().split()))
i = min(hp_list)
while True:
    dividable = True
    for j in hp_list:
        if j % i != 0:
            dividable = False
    if dividable:
        break
    else:
        for j in range(2, i + 1):
            if i % j == 0:
                i /= j
                break
print(i)

### FIXED CODE ###

from fractions import gcd

input()
a = list(map(int, input().split()))
l = a[0]
for i in a[1:]:
    l = gcd(l,i)
print(l)
import sys

args = [int(input()) for i in range(6)]

 if (args[4] - arg[0]) > args[5]:
    print(":(")
print("Yay!")

### FIXED CODE ###

import sys

loops1 = 4
loops2 = 5
arg1 = 0
arg2 = 1

i=0
j=0

args = [int(input()) for i in range(6)]

for i in range(arg1,loops1):
	for j in range(arg2,loops2):
		if (args[j] - args[i]) > args[5]:
			print(":(")
			sys.exit()
print("Yay!")
k, x = (int(x) for x in input().split())

if k*500 >= x :
	print(Yes)
else:
	Print(No)

### FIXED CODE ###

k, x = (int(x) for x in input().split())

if k*500 >= x :
	print('Yes')	
else:
	print('No')
N=int(input())
a=[int(input()) for i in range(N+1)][::-1]
def check(P):
    b=[a[i]%P for i in range(1,N+1)]
    if N<P:
        for i in b:
            if i!=0:
                return False
        return True
    else:
        c=[0 for i in range(P-1)]
        for i in range(N):
            c[i%(P-1)]+=b[i]
            c[i%(P-1)]%=P
        for i in c:
            if i!=0:
                return False
        return True
Plist=[]
X=[1 for i in range(N+1)]
X[0]=0;X[1]=0
for i in range(2,N+1):
    for j in range(i,N+1,i):
        if i==j:
            if X[i]==0:
                break
        else:
            X[j]=0
for j in range(N+1):
    if X[j]==1:
        if check(j):
            print(j)
    

### FIXED CODE ###

def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    if x%y==0:
        return y
    else:
        return gcd(x%y,y)
N=int(input())
a=[int(input()) for i in range(N+1)][::-1]
#N=10000
#a=[i+1 for i in range(N+1)]
g=abs(a[0])
for i in range(1,N+1):
    g=gcd(g,abs(a[i]))
def check(P):
    b=[a[i]%P for i in range(1,N+1)]
    if a[0]%P!=0:
        return False
    if N<P:
        for i in b:
            if i!=0:
                return False
        return True
    else:
        c=[0 for i in range(P-1)]
        for i in range(N):
            c[i%(P-1)]+=b[i]
            c[i%(P-1)]%=P
        for i in c:
            if i!=0:
                return False
        return True
Plist=set()
X=[1 for i in range(max(N+1,3))]
X[0]=0;X[1]=0
i=2
while(i*i<=N):
    for j in range(i,N+1,i):
        if i==j:
            if X[i]==0:
                break
        else:
            X[j]=0
    i+=1
i=2
tmp=g
while(i*i<=g):
    if tmp%i==0:
        Plist.add(i)
        while(1):
            if tmp%i==0:
                tmp=tmp//i
            else:
                break
    i+=1
if tmp>1:
    Plist.add(tmp)
for j in range(N+1):
    if X[j]==1:
        Plist.add(j)
Plist=sorted(list(Plist))
for p in Plist:
    if check(p):
        print(p)
N = int(input())
A = list(map(int,input().split()))

c = 0
i =2

if N ==1 or N ==2:
    print(1)
    exit()
while i<N+1:
    if (A[i-1]-A[i-2])*(A[i]-A[i-1])<0:
        c=c+1
        i = i+1
    i = i+1
print(c+1)

### FIXED CODE ###

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

if N ==1 or N ==2:
    print(1)
    exit()
t = 0
c =1
for i in range(1,N):

    if A[i]-A[i-1]>0:
        if t == -1:
            c +=1
            t = 0
        else:
            t = 1
    elif A[i]-A[i-1]<0:
        if t == 1:
            c +=1
            t = 0
        else:
            t = -1    
print(c)
while 1:
  try:
    a, b, c, d, e, f = map(int, raw_input().split())
    g = b / e
    x = (c - g * f) / (float(a) - g)
    y = (c - a * x) / float(b)
    print str(x) + " " + str(y)
  except EOFError:
    break

### FIXED CODE ###

while 1:
    try:
        a, b, c, d, e, f = map(float, raw_input().split())
        x = (c * e - b * f) / (a * e - b * d)
        y = (f * a - c * d) / (a * e - d * b)
        if x == -0.000:
            x = 0.000
        if y == -0.000:
            y = 0.000
        print str('%.3f' % x) + " " + str('%.3f' % y)
    except:
        break
string = input()
lengch = len(string)
halfLengch = lengch // 2
  startString = list(string[:halfLengch + 1])
endString = list(string[halfLengch + 2::-1])
countHug = 0

for i in startString :
  for j in endString :
    if i != j :
      countHug += 1

print(countHug)

### FIXED CODE ###

string = input()
lengch = len(string)
halfLengch = lengch // 2
startString = list(string[:halfLengch])
endString = list(string[:halfLengch - 1:-1])
countHug = 0
 
for i,j in zip(startString, endString) :
    if i != j :
      countHug += 1
 
print(countHug)
n = int(input())
h = [int(i) for i in input().split()]
x = 1
if n==1:
	print(x)
else:
	if h[1] >= h[0]:
		x += 1
	
	for i in range(2, n):
		hh=h[0:i-1]
    	if h[i] >= max(hh):
        	x += 1
	print(x)

### FIXED CODE ###

n = int(input())
h = [int(i) for i in input().split()]
x = 1
if n == 1:
    print(x)
else:
    if h[1] >= h[0]:
        x += 1

    for i in range(2, n):
            hh = h[0:i]
            if h[i] >= max(hh):
                x += 1
    print(x)
N,M = map(int,input().split())

return(int(N*(N-1)//2 + M*(M-1)//2))

### FIXED CODE ###

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

print(int(N * (N-1)//2 + M * (M-1)//2))
def awc(s):
    print("ARC" if s == "ABC" else "ABC")

if __name__ == "__main__":
    import sys
    in_str = []
    for line in sys.stdin:
        in_str.append(line)
    awc(s)


### FIXED CODE ###

def awc(s):
    print("ARC" if s == "ABC" else "ABC")

if __name__ == "__main__":
    import sys
    in_str = input()
    awc(in_str)
A,B,K = map(int,input().split())
P = []
for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        P.append(i)
print(P[len(P)-K])

### FIXED CODE ###

A,B,C = map(int,input().split())
t=B//A #聞ける回数
if t>C:
    print(C)
else:
    print(t)
H, W= map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
r_k = 80*3
diffs = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
dp = [[[False] * r_k for _ in range(W+1)] for _ in range(H+1)]
for i in range(H+1):
    dp[i][0][0] = True
for j in range(H+1):
    dp[0][j][0] = True
for i in range(H):
    for j in range(W):
        diff = diffs[i][j]
        for k in range(r_k):
            dp[i + 1][j + 1][abs(k - diff)] = dp[i + 1][j][k] or dp[i][j + 1][k] or dp[i + 1][j + 1][abs(k - diff)]
            if k + diff < r_k:
                dp[i + 1][j + 1][k + diff] = dp[i + 1][j][k] or dp[i][j + 1][k] or dp[i + 1][j + 1][k+diff]

for k in range(r_k):
    if dp[H][W][k]:
        print(k)
        break


### FIXED CODE ###

H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
diffs = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]
max_diff = 0
for diff in diffs:
    max_diff = max(max_diff, max(diff))
r_k = max_diff*(H+W)//2+1
dp = [[[False] * r_k for _ in range(W)] for _ in range(H)]
dp[0][0][0] = True
for i in range(H):
    for j in range(W):
        diff = diffs[i][j]
        dp_ = dp[i][j]
        if j < W-1:
            dpj = dp[i][j + 1]
            for k in range(r_k):
                if dp_[k] == True:
                    dpj[abs(k - diff)] = True
                    if k+diff<r_k:
                        dpj[k + diff] = True
        if i < H - 1:
            dpi = dp[i + 1][j]
            for k in range(r_k):
                if dp_[k] == True:
                    dpi[abs(k-diff)] = True
                    if k+diff < r_k:
                        dpi[k + diff] = True

ans = pow(80, 3)
diff = diffs[H-1][W-1]
for k, flg in enumerate(dp[H - 1][W - 1]):
    if flg:
        ans = min(ans, abs(k-diff), k+diff)
print(ans)
# 整数の入力
list = list(str(input())

flag = 0

for i in list:
    if i == "7":
        print("Yes")
        flag = 1
        break

if flag == 0:
    print("No")

### FIXED CODE ###

list = list(str(input()))

YN_flag = 0

for i in list:
    if i == "7":
        print("Yes")
        YN_flag = 1
        break

if YN_flag == 0:
    print("No")
import collections
n = int(input())
*a, = map(int, input().split())
counter = collections.Counter(a)
d = {key: (value * (value - 1)) // 2 for key, value in counter.items()}
#print(d)
all_sum = sum(d.values())
#print(all_sum)

sum_d = {}
for k in range(n):
    if a[k] not in sum_d:
        if d[a[k]] > 0:
            tmp = ((counter[a[k]] - 1) * (counter[a[k]] - 2)) // 2
        sum_d[a[k]] = all_sum  - d[a[k]] + tmp
        print(sum_d[a[k]])
    else:
        print(sum_d[a[k]])

### FIXED CODE ###

import collections
n = int(input())
*a, = map(int, input().split())
counter = collections.Counter(a)
d = {key: (value * (value - 1)) // 2 for key, value in counter.items()}
#print(d)
all_sum = sum(d.values())
#print(all_sum)

sum_d = {}
for k in range(n):
    if a[k] not in sum_d:
        if d[a[k]] > 0:
            tmp = ((counter[a[k]] - 1) * (counter[a[k]] - 2)) // 2
            sum_d[a[k]] = all_sum  - d[a[k]] + tmp
            print(sum_d[a[k]])
        else:
            print(all_sum)
    else:
        print(sum_d[a[k]])
a = int(imput())
b = int(imput())
if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")


### FIXED CODE ###

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

if a * b % 2 == 0:
    print("Even")
else:
    print("Odd")
n = int(input())

ans = 10**12
for i in range(1, int(ns**0.5)+1):
    print(n%i)
    if n%i==0:
        ans = min(ans, i+n//i)
print(ans-2)

### FIXED CODE ###

n = int(input())

ans = 10**12
for i in range(1, int(n**0.5)+1):
    if n%i==0:
        ans = min(ans, i+n//i)
print(ans-2)
for i in input().split():
    if int(i) % 2 == 0:
        cnt *= 2

print(3**n - cnt)

### FIXED CODE ###

n = int(input())
cnt = 1
for i in input().split():
    if int(i) % 2 == 0:
        cnt *= 2

print(3**n - cnt)
l = list(map(int,input().split()))
    if l[0]+l[1] >= l[2]:
      print(l[1]+l[2])
    else:
      print(l[0]+2*l[1]+1)

### FIXED CODE ###

l = list(map(int,input().split()))
if l[0]+l[1] >= l[2]:
  print(l[1]+l[2])
else:
  print(l[0]+2*l[1]+1)
from math import gcd
a,b,c,d = map(int,input().split())
ans = b - a + 1#ok
a -= 1#ok

g = gcd(c,d)
n = c / g
m = d / g
temp = n*m*g

ans -= -int(a/c) + int(b/c)
ans -= -int(a/d) + int(b/d)
ans += -int(a/temp) + int(b / temp)

print(int(ans))

### FIXED CODE ###

from fractions import gcd
a,b,c,d = map(int,input().split())
ans = b - a + 1#ok
a -= 1#ok

g = gcd(c,d)
temp = c*d//g

cc = -int(a//c) + int(b//c)
dd = -int(a//d) + int(b//d)
cd = -int(a//temp) + int(b // temp)

print(ans - cc - dd + cd)
from collections import defaultdict

import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,k=mis()
    if n>=k:
        n%=k
        print(k%n)
        exit()
    if n<=k//2:print(n)
    else: print(k-n)



if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import defaultdict

import sys
sys.setrecursionlimit(10**6)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    n,k=mis()
    if n>=k:
        n%=k
        print(k%n if n!=0 else 0)
        exit()    
    print(n if n<=k//2 else k-n)



if __name__ == "__main__":
    main()
import math
from fractions import Fraction

ans = 0
N, K = map(int, input().split())
for i in range(N):
	ans += Fraction(1,N)*Fraction(1,2**math.ceil(math.log2(K/(i+1))))
print(float(ans))


### FIXED CODE ###

import math
from fractions import Fraction

ans = 0
N, K = map(int, input().split())
for i in range(1,N+1):
	ans += Fraction(1,2**(math.ceil(math.log2(max(1,K/i)))))
ans = float(ans/N)
print('{:.10f}'.format(ans))
N = int(input())
A = list(map(int, input().split()))

pos = []
neg = []
ans = 0

for e in A:
    if e > 0:
        pos.append(e)
    else:
        neg.append(e)
if len(neg) % 2 == 0:
    ans = sum(pos) - sum(neg)
else:
    """pos.sort(reverse=True)
    neg.sort(reverse=True)
    if len(neg) == N:
        ans = -sum(neg[:-1]) + neg[-1]
    else:"""
    #ans = max(-sum(neg[:-1]) + neg[-1], -sum(neg[:-3]) + sum(neg[-3:]))
    #ans = max(sum(pos[:-1])-pos[-1]-sum(neg), sum(pos) + neg[0] -sum(neg[1:]))
    ans = sum(pos) - sum(neg)
    ans -= 2 * min(min(pos), -max(neg))
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
abs_A = list(map(lambda x: abs(x), A))

pos = []
neg = []
ans = 0

for e in A:
    if e > 0:
        pos.append(e)
    else:
        neg.append(e)
if len(neg) % 2 == 0:
    ans = sum(abs_A)
else:
    """pos.sort(reverse=True)
    neg.sort(reverse=True)
    if len(neg) == N:
        ans = -sum(neg[:-1]) + neg[-1]
    else:"""
    #ans = max(-sum(neg[:-1]) + neg[-1], -sum(neg[:-3]) + sum(neg[-3:]))
    #ans = max(sum(pos[:-1])-pos[-1]-sum(neg), sum(pos) + neg[0] -sum(neg[1:]))
    ans = sum(abs_A)
    ans -= 2 * min(abs_A)
print(ans)
r, d, x = map(int,input().split())
print(x = x * r - d  for _ in range(10))


### FIXED CODE ###

r, d, x = map(int,input().split())
for _ in range(10):
    x = x * r - d
    print(x)
data = int(input()).split(" ")
list = sorted(data)

print("{a} {b} {c}").format(a=list[0], b=list[1], c=list[2])

### FIXED CODE ###

num = list(map(int, input().split()))
num.sort()
print(num[0], num[1], num[2])
def main():
    N = int(input())
    W = []
    for n in range(N):
        W.append(input())
    for i, w in enumerate(W):
        prev_w = w
        if i==0:
            continue
        for wn in W[:i-1]:
            if w == wn:
                print('No')
                return 
        if prev_w[-1] != w[0]:
            print('No')
            return
    print('Yes')
    return

main()


### FIXED CODE ###

s = input()
a,b = s.split(' ')
a = int(a)
b = int(b)
if (a%2 == 0) or (b%2 == 0):
    print('No')
else:
    print('Yes')
a,b =map(int, input().split())
m = a % k
print(min(m, k - m))

### FIXED CODE ###

n,k =map(int, input().split())
m = n % k
print(min(m, k - m))
n = int(input())

s = list()
for i in range(1, int(n**0.5 + 1)):
    if n % i == 0:
        s.append(int(i + n/i))
print(min(s)-2

### FIXED CODE ###

n = int(input())
 
s = list()
for i in range(1, int(n**0.5 + 1)):
    if n % i == 0:
        s.append(int(i + n/i))
print(min(s)-2)
h=S/3600
h=int(h)
m=(S-3600*h)/60
m=int(m)
s=S-h*3600-m*60
s=int(s)
print(h:m:s)

### FIXED CODE ###

S=input()
S=int(S)
h=S/3600
h=int(h)
m=(S-3600*h)/60
m=int(m)
s=S-h*3600-m*60
s=int(s)
h=str(h)
m=str(m)
s=str(s)
print(h+':'+m+':'+s)
# coding:utf8

N = input()
A = list(map(int, input().strip().split()))
s = 0
for i in range(N):
    s += 1.0/(A[i])
s = 1.0/s

print(s)

### FIXED CODE ###

# coding:utf-8
 
num = int(input())
chr = input()
 
if num>=3200:
  print(chr)
else:
  print("red")
N = int(input())
n = list(str(N))
print("Yes" if N%(sum(n)==0 else "No")

### FIXED CODE ###

N = int(input())
NL = list(str(N))
n = [int(i) for i in NL]
print("Yes" if N%(sum(n))==0 else "No")
#D - Div Game
N = int(input())

def Prime_factorize(n):
    cnt = 0
    A = []
    #2の倍数で割っていく
    z = 2
    while n%z==0 and (n>=z):
        cnt += 1
        n //= z
        A.append(z)
        #割るたびに2倍
        z *= 2
    #割る始めの数をfとして保持
    f = 3
    z = 3
    #sqrt(n)以内に全ての素因数は含まれる
    while 2*f <= n:
        if n%z == 0:
            cnt += 1
            n //= z
            A.append(z)

            #割るたびにf倍
            z = z*f
        #fで割り切れなかったら(f+2)してf_divもリセット
        else:
            f += 2
            z = f

    #残ったnが以前に選んだもので割り切れないとき
    if n != 1 and all((n%i != 0 for i in A)):
        A.append(z)
        cnt += 1
    #素数のとき
    if cnt == 0:
        cnt = 1
    return cnt
if N == 1:
    ans = 0
else:
    ans = Prime_factorize(N)
print(ans)

### FIXED CODE ###

A,B = map(int,input().split())

print(A*B)
a, b, c, d, e, f = map(int, input().split())
a, b = 100*a, 100*b
 
dp = [[0, 0] for _ in range(f+1)]
memo = {}
dp[a][0] = a
dp[b][0] = b
for i in range(1, f):
    if dp[i][0]:
        if i+a <= f:
            dp[i+a][0] = dp[i][0] + a
            dp[i+a][1] = dp[i][1]
        if i+b <= f:
            dp[i+b][0] = dp[i][0] + b
            dp[i+b][1] = dp[i][1]
        if i+c <= f and dp[i][1] + c <= dp[i][0] * e // 100:
            x = dp[i+c][0] = dp[i][0]
            y = dp[i+c][1] = dp[i][1] + c
            memo[(x+y, y)] = y/(x+y)
        if i+d <= f and dp[i][1] + d <= dp[i][0] * e // 100:
            x = dp[i+d][0] = dp[i][0]
            y = dp[i+d][1] = dp[i][1] + d
            memo[(x+y, y)] = y/(x+y)
_, z, y = max([(val, z, y) for (z, y), val in memo.items()])
print(z, y)

### FIXED CODE ###

a, b, c, d, e, f = map(int, input().split())
a, b = 100*a, 100*b
 
dp = [[0, 0] for _ in range(f+1)]
memo = {(a, 0):0}
dp[a][0] = a
if b <= f:
    dp[b][0] = b
for i in range(1, f):
    if dp[i][0]:
        if i+a <= f:
            dp[i+a][0] = dp[i][0] + a
            dp[i+a][1] = dp[i][1]
        if i+b <= f:
            dp[i+b][0] = dp[i][0] + b
            dp[i+b][1] = dp[i][1]
        if i+c <= f and dp[i][1] + c <= dp[i][0] * e // 100:
            x = dp[i+c][0] = dp[i][0]
            y = dp[i+c][1] = dp[i][1] + c
            memo[(x+y, y)] = y/(x+y)
        if i+d <= f and dp[i][1] + d <= dp[i][0] * e // 100:
            x = dp[i+d][0] = dp[i][0]
            y = dp[i+d][1] = dp[i][1] + d
            memo[(x+y, y)] = y/(x+y)
_, z, y = max([(val, z, y) for (z, y), val in memo.items()])
print(z, y)
def binarySearch(key, arr, N):
    left = 0
    right = N
    while left < right:
        mid = (left + right) // 2
        if arr[mid] == key:
            return mid
        else if key < arr[mid]:
            right = mid
        else:
            left = mid + 1


N1 = int(input())
arr1 = [int(n) for n in input().split()]
N2 = int(input())
arr2 = [int(n) for n in input().split()]

print(sum([linearSearch(key, arr1) for key in arr2]))



### FIXED CODE ###

def binarySearch(key, arr, N):
    left = 0
    right = N
    while left < right:
        mid = (left + right) // 2
        if arr[mid] == key:
            return 1
        elif key < arr[mid]:
            right = mid
        else:
            left = mid + 1
    return 0


N1 = int(input())
arr1 = [int(n) for n in input().split()]
N2 = int(input())
arr2 = [int(n) for n in input().split()]

print(sum([binarySearch(key, arr1, N1) for key in arr2]))
N, M = list(map(int, input().split(' ')))

root = [[] for i in range(M+1)]
for i in range(M):
  A, B = list(map(int, input().split(' ')))
  root[A].append(B)
  root[B].append(A)

mitisurube = [-1 for i in range(N+1)]
cost = [-1 for i in range(N+1)]
next = [1]
done = {}
cost[1] = 0

while next:
  now_pos = next.pop(0)
  for next_pos in root[now_pos]:
    if cost[next_pos] == -1 or cost[next_pos] > cost[now_pos] + 1:
      cost[next_pos] = cost[now_pos] + 1
      mitisurube[next_pos] = now_pos
      next.append(next_pos)
#print('root')
#print(*root)
#print('cost')
#print(*cost)
#print('mitisirube')
if mitisurube.count(-1) < 3:
  print('Yes')
  print(*mitisurube, sep='\n')
else:
  print('No')

### FIXED CODE ###

from collections import deque

def main():
  N, M = list(map(int, input().split(' ')))

  root = [[] for i in range(N+1)]
  for i in range(M):
    A, B = list(map(int, input().split(' ')))
    root[A].append(B)
    root[B].append(A)

  mitisurube = [-1 for i in range(N+1)]
  next_ = deque()
  next_.append(1)

  while next_:
    now_pos = next_.popleft()
    for next_pos in root[now_pos]:
      if mitisurube[next_pos] == -1:
        mitisurube[next_pos] = now_pos
        next_.append(next_pos)
  #print('root')
  #print(*root)
  #print('mitisirube')
  print('Yes')
  print(*mitisurube[2:], sep='\n')

if __name__ == '__main__':
  main()
a,b,c = map(int, input().split)

A = [a,b,c]
A.sort()
if a+b == c:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

A = [a,b,c]
A.sort()
if A[0]+A[1] == A[2]:
    print("Yes")
else:
    print("No")
import numpy as np
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

card = np.array([i+1 for i in range(N)])

for l, r in LR:
    card = card[(card >= l) & (card <= r)]
    if len(card) == 0:
        break
print(len(card))

### FIXED CODE ###

N, M = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(M)]

card_min = 0
card_max = N
ans = N
#print(card_min, card_max)
for l, r in LR:
    if l > card_min:
        card_min = l
    if r < card_max:
        card_max = r
    #print(card_min, card_max)
    ans = card_max - card_min + 1
    if ans <= 0:
        ans = 0
        break
print(ans)
A = int(input())
B = int(input())
C = int(input())
D = int(input())
print(min([A, B] + min([C, D])))

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
D = int(input())
print(min([A, B]) + min([C, D]))
S = input()
N = len(S)
ans = 0
for i in range(N):
	for j in range(i, N):
      if all('ACGT'.count(c) == 1 for c in S[i : j + 1]):
        ans = max(ans, j - i + 1)
print(ans)


### FIXED CODE ###

S = input()

A = 0
B = 0
for i in S:
  if i == "A" or i == "C" or i == "G" or i == "T":
    B += 1
  else:
    A = max(A,B)
    B = 0
A = max(A,B)
print(A)
S=int(input())

def f(n): 
      
    # single line to find factorial 
    return 1 if (n==1 or n==0) else n * factorial(n - 1); 



possibles=0
biggest_sub=S//3
for i in range(1,biggest_sub+1):
	left=S-3*i
	possibles+=(f(left+i-1)/f(i-1)/f(left))
n=10**9+7
print(possibles%n)

### FIXED CODE ###

#import sys
#input = sys.stdin.readline
Q = 10**9+7
def cmb(n,r):
    if n-r < r: r = n-r
    if r == 0: return 1
    denominator = 1                       #分母
    numerator = 1                         #分子
    for i in range(r):
        numerator *= n-i
        numerator %= Q
        denominator *= i+1
        denominator %= Q
    return numerator*pow(denominator, Q-2, Q)%Q
 
def main():
    S = int( input())
    ans = 0
    for i in range(1, S//3+1):
        t = S - i*3
        ans += cmb(t+i-1,i-1)
        ans %= Q
    print(ans)
        
if __name__ == '__main__':
    main()
n = input()
list = list(map(int, input().split()))

count = 0
can = True
while can:
  for i in range(0, 6):
    a = list[i]
    if a % 2 == 0:
      list[i] = a / 2
    else:
      can = False
  if can == True:
    count += 1
print(count)

### FIXED CODE ###

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

count = 0
can = True
while can:
  for i in range(0, int(n)):
    a = list[i]
    if a % 2 == 0:
      list[i] = a / 2
    else:
      can = False
  if can == True:
    count += 1
print(count)
n = int(input())
dat =[]
link = []
for i in range(n+1):
    link.append([])
cost = [-1] * (n + 1)

for i in range(n - 1):
    a, b, c = map(int, input().split())
    dat.append((a, b, c))
    link[a].append((b,c))
    link[b].append((a,c))

dat_q = []
q, k = map(int, input().split())

for i in range(q):
    x, y = map(int, input().split())
    dat_q.append((x,y))

#print(link)

def search(curcost, current):
    #print("cost{0}, pos {1}: ".format(curcost, current))
    cost[current] = curcost
    for npos, ncost in link[current]:
        if cost[npos] != -1:
            # 戻らない
            continue
        search(curcost + ncost, npos)

search(0, k)

#print(cost)
for i in range(q):
    x,y = dat_q[i]
    print(cost[x] + cost[y])

### FIXED CODE ###

import sys
sys.setrecursionlimit(4100000)

n = int(input())
dat =[]
link = []
for i in range(n+1):
    link.append([])
cost = [-1] * (n + 1)

for i in range(n - 1):
    a, b, c = map(int, input().split())
    dat.append((a, b, c))
    link[a].append((b,c))
    link[b].append((a,c))

dat_q = []
q, k = map(int, input().split())

for i in range(q):
    x, y = map(int, input().split())
    dat_q.append((x,y))

#print(link)

def search(curcost, current):
    #print("cost{0}, pos {1}: ".format(curcost, current))
    cost[current] = curcost
    for npos, ncost in link[current]:
        if cost[npos] != -1:
            # 戻らない
            continue
        search(curcost + ncost, npos)

search(0, k)

#print(cost)
for i in range(q):
    x,y = dat_q[i]
    print(cost[x] + cost[y])