Harryxun/stf_run huggingface dataset:
if b<=c and a<= d:
    print(0)
elif d >= a and c <= b and a >= c and b <= d:
    print(b-c)
elif d >= b and a>=c:
    print(b-a)
elif b >=d and c>=a:
    print(d-c)
elif c <= a and d <=a:
    print(0) 
else:
    print(d-a)

### FIXED CODE ###

a , b , c, d=map(int,input().split())
if b<=c and a<= c:
    print(0)
elif d >= b and c <= b and a <= c:
    print(b-c)
elif d >= b and a>=c:
    print(b-a)
elif b >=d and c>=a:
    print(d-c)
elif c <= a and d <=a:
    print(0) 
else:
    print(d-a)
a = input()
b= input()
 
if (a*b%2 == 0):
	print('Even')
else:
    print('Odd')

### FIXED CODE ###

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

c = a*b

if c%2 == 0:
    print("Even")
else:
    print("Odd")
n,k=tuple(int,input().split())
s=list(input())
s[k-1]=s[k-1].lower()
print("".join(s))


### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
s[k-1]=s[k-1].lower()
print("".join(s))
S = input()

nagasa = len(S)
ichi_list = []
counter = 0
for i in range(nagasa):
    if S[i] == 'A' or S[i] == 'T' or S[i] == 'C' or S[i] == 'G':
        counter += 1
    else:
        counter = ichi_list.append(counter)
        counter = 0

print(max(ichi_list))

### FIXED CODE ###

S = input()
nagasa = len(S)
ichi_list = []
counter = 0
for i in range(nagasa):
    if S[i] == 'A' or S[i] == 'T' or S[i] == 'C' or S[i] == 'G':
        counter += 1
    else:
        ichi_list.append(counter)
        counter = 0

ichi_list.append(counter)
print(max(ichi_list))
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])[::-1]
i=0
for num,v in b:
	for j in range(num):
		if a[i]<v and i<n:
			a[i]=v
			i+=1
		else:
			print(sum(a))
			exit()
else:
	print(sum(a))

### FIXED CODE ###

n,m=map(int,input().split())
a=sorted(map(int,input().split()))
b=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])[::-1]
i=0
for num,v in b:
	for j in range(num):
		if i<n and a[i]<v:
			a[i]=v
			i+=1
		else:
			print(sum(a))
			exit()
else:
	print(sum(a))
import sys
n = int(input())
s = list(input())
a_li = []
b_li = []
c_li = []
for i,ss in enumerate(s):
    if ss == 'R':
        a_li.append(i)
    elif ss == 'G':
        b_li.append(i)
    else:
        c_li.append(i)
if len(a_li) == 0 or len(b_li)== 0 or len(c_li) == 0:
    print(0)
    sys.exit()
all_count = 0
for a in a_li:
    for b in b_li:
        tmp = len(c_li)
        lili = []
        if (2*b - a)  in c_li:
            lili.append(2*b - a)
        if (2*a - b)  in c_li:
            lili.append(2*a - b)
        if (a + b)% 2 == 0 and (a + b)//2   in c_li:
            lili.append((a + b)//2)
        tmp -= len(set(lili))
        all_count += tmp
print(all_count)

### FIXED CODE ###

n = list(input())
if '7' in n:
    print('Yes')
else:
    print('No')
import itertools
import heapq
import sys
import functools
import operator
import numpy as np
input = sys.stdin.readline
#-------------
n,k = map(int,input().split())
a = list(map(int,input().split()))
#-------------
a.sort(reverse = True)
w = 10**9 + 7
ans = 1
if k%2 == 1:
  for i in range(k):
    ans *= a[i]
  print(ans % w)

else:
  if n%2 == 0:
    a_new = [a[2*i]*a[2*i+1] for i in range(n//2)]
    a_new.sort(reverse = True)
    for j in range(k//2):
      ans *= a_new[j]
    print(ans % w)
      
  else:
    a_plus = heapq.nlargest(k, a)
    a_minus = heapq.nsmallest(k, a)
    a_plus.sort(reverse = True)
    a_minus.sort()
    a_plus_new = [a_plus[2*i]*a_plus[2*i+1] for i in range(len(a_plus)//2)]
    a_minus_new = [a_minus[2*i]*a_minus[2*i+1] for i in range(len(a_minus)//2)]
    a_new = a_plus_new + a_minus_new
    a_new.sort(revserse = True)
    for j in range(k//2):
      ans *= a_new[j]
    print(ans % w)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
s = input()
print(s)s=input()
out = s[0] + str(len(s)-2) + s[-1]
print(out)

### FIXED CODE ###

list = input()
print(list[0]+str(len(list)-2)+list[-1])
n , m , k = map(int, input().split())
r = [[] for i in range(n)]
bk = [[] for i in range(n)]
for i in range(m):
    a , b = map(int, input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)
for i in range(k):
    c , d = map(int, input().split())
    bk[c-1].append(d-1)
    bk[d-1].append(c-1)


v=[0]*n
l=[0]*n
w=[0]*n

def dfs(now,c):
    global ln
    if v[now]==1:
        return
    v[now]=1
    ln+=1
    w[now]=c
    l[c]=ln
    for i in r[now]:
        dfs(i,c)
    return

for i in range(n):
    ln=0
    dfs(i,i)

ans =[]
for i in range(n):
    d=0
    for j in bk[i]:
        if w[j]==w[i]:
            d+=1
    ans.append(str(l[w[i]]-1-d-len(r[i])))
print(' '.join(ans))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
n , m , k = map(int, input().split())
r = [[] for i in range(n)]
bk = [[] for i in range(n)]
for i in range(m):
    a , b = map(int, input().split())
    r[a-1].append(b-1)
    r[b-1].append(a-1)
for i in range(k):
    c , d = map(int, input().split())
    bk[c-1].append(d-1)
    bk[d-1].append(c-1)


v=[0]*n
l=[0]*n
w=[0]*n

def dfs(now,c):
    global ln
    if v[now]==1:
        return
    v[now]=1
    ln+=1
    w[now]=c
    l[c]=ln
    for i in r[now]:
        dfs(i,c)
    return

for i in range(n):
    ln=0
    dfs(i,i)

ans =[]
for i in range(n):
    d=0
    for j in bk[i]:
        if w[j]==w[i]:
            d+=1
    ans.append(str(l[w[i]]-1-d-len(r[i])))
print(' '.join(ans))
n, a, b, c = list(map(int, input().split()))
ss = []
for i in range(n):
    ss.append(input())
ans = []
num_dic = {"A": a,"B": b, "C": c}

for i in range(n):
    s = ss[i]
    if num_dic[s[0]] == 0 and num_dic[s[1]] == 0:
        print("No")
        import IPython;IPython.embed()
        exit()
    elif num_dic[s[0]] > num_dic[s[1]]:
        num_dic[s[0]] -= 1
        num_dic[s[1]] += 1
        ans.append(s[0])
    elif num_dic[s[0]] < num_dic[s[1]]:
        num_dic[s[0]] += 1
        num_dic[s[1]] -= 1
        ans.append(s[1])
    elif i == n -1:
        ans.append(s[0])
    elif s[0] in s[i+1]:
        num_dic[s[0]] += 1
        num_dic[s[1]] -= 1
        ans.append(s[0])
    else:
        num_dic[s[0]] -= 1
        num_dic[s[1]] += 1
        ans.append(s[1])
print("Yes")
for a in ans:
    print(a)


### FIXED CODE ###

n, a, b, c = list(map(int, input().split()))
ss = []
for i in range(n):
    ss.append(input())
ans = []
num_dic = {"A": a,"B": b, "C": c}

for i in range(n):
    s = ss[i]
    if num_dic[s[0]] == 0 and num_dic[s[1]] == 0:
        print("No")
        exit()
    elif num_dic[s[0]] > num_dic[s[1]]:
        num_dic[s[0]] -= 1
        num_dic[s[1]] += 1
        ans.append(s[1])
    elif num_dic[s[0]] < num_dic[s[1]]:
        num_dic[s[0]] += 1
        num_dic[s[1]] -= 1
        ans.append(s[0])
    elif i == n -1:
        ans.append(s[0])
        num_dic[s[0]] -= 1
        num_dic[s[1]] += 1
    elif s[0] in ss[i+1]:
        num_dic[s[0]] += 1
        num_dic[s[1]] -= 1
        ans.append(s[0])
    else:
        num_dic[s[0]] -= 1
        num_dic[s[1]] += 1
        ans.append(s[1])
print("Yes")
for a in ans:
    print(a)
import numpy as np

N, K = map(int,input().split())
A = list(map(int,input().split()))
zero_padding = len(bin(max(A))[2:])
add = np.array([0]*zero_padding)
for i in range(len(A)):
    n = i
    n =bin(n)[2:]
    num = list(map(int, str(n)))
    num = [0]*(zero_padding-len(n)) +num
    add = add + np.array(num)
result = [1]*len(bin(9)[2:])
length = min(len(result),len(add))
for j in range (1,length+1):
    if add[-j] <= N//2:
        result[-j] =0 
best = int(''.join(map(str, result)),2)
ans = 0
for i in range (len(A)):
    ans +=int(bin(best ^ A[i]),2)
print(ans)


### FIXED CODE ###

T, X = map(int,input().split())
print(T/X)
print (x*3)

### FIXED CODE ###

x=int(input())
print(x**3)
x = []

while true:
  a = input
  if a ==0:
    break
  else:
    x.append(a)

for i in range(len(x)):
  print "case %d: %d"  %(i+1, x[i])

### FIXED CODE ###

i = 0

while True:
  i += 1
  x = input()
  if x == 0:
    break
  print "Case %d: %d" %(i, x)
import math
import numpy as np

x,y = map(int,input().split()) 

A = np.array([[1, 2],
             [2, 1]])

b = np.array([x, y])
 
sol_auto = np.linalg.solve(A, b)


if sol_auto[0].is_integer() == True and sol_auto[1].is_integer() == True:
    k = math.factorial(sol_auto[0]+sol_auto[1])/(math.factorial(sol_auto[0])*math.factorial(sol_auto[1]))

    print(int(k%1000000007))
else:
    print(0)

### FIXED CODE ###

import math
import numpy as np

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 
N = 10**6
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )





x,y = map(int,input().split()) 

if (x+y) % 3 == 0:

    A = np.array([[1, 2],
                  [2, 1]])

    b = np.array([x, y])

    N = np.linalg.solve(A, b)


    if N[0].is_integer() == True and N[1].is_integer() == True and N[0] >=0 and N[1] >=0:
          
        print(cmb(int(N[0]+N[1]),int(N[0]),mod))

    else:
        print(0)

else:
    print(0)
from math import gcd
ans = 0
K = int(input())
 
for i in range(1, K+1):
	for j in range(1,K+1):
  		for k in range(1,K+1):
    		ans = ans + gcd(gcd(i,j), k)
      
print(ans)

### FIXED CODE ###

from math import gcd
ans = 0
K = int(input())
 
for i in range(1, K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans += gcd(gcd(i,j), k)
      
print(ans)
s = input()
l = []
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
        l.append(1)
    else:
        l.append(0)
tmp = 0
counter = []
for i in range(len(l)):
    if l[i] == 0:
        counter.append(tmp)
        tmp = 0
    else:
        tmp += 1

print(max(counter))

### FIXED CODE ###

s = input()
l = []
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'T' or s[i] == 'G' or s[i] == 'C':
        l.append(1)
    else:
        l.append(0)
tmp = 0
counter = []
for i in range(len(l)):
    if l[i] == 0:
        counter.append(tmp)
        tmp = 0
    else:
        if i == len(l) - 1:
            tmp += 1
            counter.append(tmp)
        else:
            tmp += 1

print(max(counter))
import swapcase
print(' '.swapcase(1200))

### FIXED CODE ###

s = input()
print(s.swapcase())
N, M = map(int, input().split())
s = [list(map(int, input().split()))[1:] for i in range(M)]
p = list(map(int, input().split()))
total = 0
j = 0
for i in range(2 ** N):
  now = format(i, '10b')
  for k in range(M):
    tmp = 0
    for l in s[k]:
      tmp += int(now[-l])
    if tmp % 2 == p[k]:
      j += 1
  if j == M :
    total += 1
  j = 0
print(total)


### FIXED CODE ###

n, m = map(int, input().split())
switch = []
for i in range(m):
    switch.append(list(map(int, input().split())))
p = list(map(int, input().split()))

ans = 0
for i in range(2**n):
    i = format(i, "0{}b".format(n))
    flag = 1
    for j in range(m):
        count = 0
        for k in range(switch[j][0]):
            if i[switch[j][k+1]-1] == "1":
                count += 1
        if count % 2 == p[j]:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        ans += 1
print(ans)
l  = raw_input().split()
a = int(l[0])*int(l[1])
b = int(l[0])*2+int(l[1])*2
print a ,b

l = raw_input().split()

### FIXED CODE ###

l  = raw_input().split()

a = int(l[0])*int(l[1])
b = int(l[0])*2+int(l[1])*2
print a ,b
n,k,*a=map(int,open(0).read().split())
for i in range(n-k):print('YNeos'[a[i+k]>a[i]::2]))

### FIXED CODE ###

import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()

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

show_flg=False
show_flg=True

ans=0

n,k=LI()
a=LI()
for i in range(n-k):
    if a[i]<a[i+k]:
        Yn(1)
    else:
        Yn(0)


#show(n,m)
from collections import deque

N = int( input() )

hi = 0
while 1 << hi + 1 <= N:
  hi += 1

ans_A = deque()
ans_B = deque()
ptr = 1
for i in range( hi, -1, -1 ):
  ans_A.append( ptr )
  ans_B.append( ptr )
  ptr += 1
  if N >> i & 1:
    ans_A.append( ptr )
    ans_B.appendleft( ptr )
    ptr += 1

print( len( ans_A ) * 2 )
print( * ( ans_A + ans_B ) )


### FIXED CODE ###

from collections import deque

N = int( input() ) + 1 # empty counts

hi = 0
while 1 << hi + 2 <= N:
  hi += 1

ans_A = deque()
ans_B = deque()
ptr = 1
for i in range( hi, -1, -1 ):
  ans_A.append( ptr )
  ans_B.append( ptr )
  ptr += 1
  if N >> i & 1:
    ans_A.append( ptr )
    ans_B.appendleft( ptr )
    ptr += 1

print( len( ans_A ) * 2 )
for i in range( len( ans_A ) ):
  print( ans_A[ i ], end = ' ' )
for i in range( len( ans_B ) ):
  print( ans_B[ i ], end = ' \n'[ i + 1 == len( ans_B ) ] )
n, k = map(int,input().split())
lst = list(map(int,input().split()))

a=[]#種類の記憶

for i in range(n):
  if a.count(lst[i]) == 0:
    a.append(lst[i])
c=[]#カウント用
for j in a:
  c.append(lst.count(j))
ans = 0
while k < len(c):
  i = c.index(min(c)) #最小の個数のインデックス
  ans += min(c)
  del c[i]
print(ans)

### FIXED CODE ###

S = input()

res = 0
for s in S:
    if s == "1":
        res += 1
print(res)
S = input().strip()
T = input().strip()
rS = []
for i in range(len(S)):
    rS.append(S[i])
for i in range(len(rS) - len(T)):
    eq = True
    for j in range(len(T)):
        if not(rS[- i - j - 1] == T[- j - 1] or rS[- i - j - 1] == "?"):
            eq = not(eq)
            break
    if eq:
        for j in range(len(T)):
            rS[- i - j - 1] = T[- j - 1]
        break
if eq:
    for i in range(len(rS)):
        if rS[i] == "?":
            rS[i] = "a"
    for i in range(len(rS)):
        print(rS[i], end='')
    print("")
else:
    print("UNRESTORABLE")

### FIXED CODE ###

S = input().strip()
T = input().strip()
rS = []
if len(S) >= len(T):
    for i in range(len(S)):
        rS.append(S[i])
    for i in range(len(rS) - len(T), -1, -1):
        eq = True
        for j in range(len(T)):
            if not(rS[i + j] == T[j] or rS[i + j] == "?"):
                eq = not(eq)
                break
        if eq:
            for j in range(len(T)):
                rS[i + j] = T[j]
            break
    if eq:
        for i in range(len(rS)):
            if rS[i] == "?":
                rS[i] = "a"
        for i in range(len(rS)):
            print(rS[i], end='')
        print("")
    else:
        print("UNRESTORABLE")
else:
    print("UNRESTORABLE")
H, W, M = list(map(int, input().split()))
hrz = [0]*H
vrt = [0]*W
targets = set()
for _ in range(M):
    h, w = list(map(lambda x: int(x) - 1, input().split()))
    targets.add((h, w))
    hrz[h] += 1
    vrt[w] += 1

hrz_max = max(hrz)
vrt_max = max(vrt)
for h in [i for i in range(H) if hrz[i] == hrz_max]:
    for w in [i for i in range(H) if vrt[i] == vrt_max]:
        if not (h, w) in targets:
            print(hrz_max+vrt_max)
            exit()
print(hrz_max+vrt_max-1)


### FIXED CODE ###

H, W, M = list(map(int, input().split()))

targets = set()
row = [0]*H
col = [0]*W

for _ in range(M):
    h, w = list(map(lambda x: int(x) - 1, input().split()))
    row[h] += 1
    col[w] += 1
    targets.add((h, w))

r_max = max(row)
c_max = max(col)
ans = 0

maxed_h = set([h for h in range(H) if row[h] == r_max])
maxed_w = set([w for w in range(W) if col[w] == c_max])
bomb_option_sites_n = len(maxed_h)*len(maxed_w)
targets_on_bomb_option = 0
for th, tw in targets:
    if th in maxed_h and tw in maxed_w:
        targets_on_bomb_option += 1

if bomb_option_sites_n == targets_on_bomb_option:
    print(r_max + c_max - 1)
else:
    print(r_max + c_max)
H,W =map(int,input().split())
if H==1 or W==1:
  print(1)
elif H%2==0:
  print(W*H//2)
else:
  if W%2==1:
    print(W*(H//2)+W//2+1)
  else:
    print(W*(H//2)+W//2)

### FIXED CODE ###

K =int(input())
A =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[K-1])
a, b = list(map(int, input().split()))

if b==1:
    print(0)
else:
    tap = 1
    n = a
    while n < b:
        n -= 1
        n += a
        tap+=1

print(tap)


### FIXED CODE ###

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

if b==1:
    print(0)
else:
    tap = 1
    n = a
    while n < b:
        n -= 1
        n += a
        tap+=1

    print(tap)
N, i = input().split(" ")
print(N - i + 1)

### FIXED CODE ###

N, i = (int(i) for i in input().split(" "))
print(N - i + 1)
#!/usr/bin/env python3
import sys
import math
from functools import reduce

def solve(N: int, A: "List[int]"):
    res = A[0]
    for a in A[1:]:
        res = math.gcd(res,a)
    print(res)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import math

def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)

def solve(N: int, A: "List[int]"):
    res = A[0]
    B = A[1:]
    for a in B:
        res = gcd(res,a)

    print(res)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()
N, K = map(int, input().split())
A = list(map(int, input().split()))

now = 1
temp_l = [0]*N
temp_count = [-1]*N
temp_count[0] = 0
for i in range(N):
    pre = now
    now = A[pre-1]
    if temp_l[now-1] == 1:
        end = now
        temp = i+1
        break
    else:
        temp_l[now-1] = 1
        temp_count[now-1] = i+1

s_index = temp_count[end-1]
repeat = temp - s_index
K -= s_index
K = K % repeat

print(temp_count.index(K+s_index)+1)

### FIXED CODE ###

S = list(input())
T = list(input())

ans = 'Yes'
for i in range(len(S)):
    if S[i] != T[i]:
        ans = 'No'

print(ans)
H, N = map(int, input().split())
A = map(int, input().split())
sum = 0

for val in A:
	sum = sum + val

if sum >= H 
	print("Yes")
  
print("No")


### FIXED CODE ###

H, A = map(int, input().split())
i = 0

while H > 0:
	H = H - A
	i = i + 1

print(i)
import sys
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    a=[int(input()) for i in range(M)]
    dp=[1]*(N+2)
    dp[1]=0 if a[0]==1 else 1
    for i in a:
        dp[i]=0
    for i in range(1,N):
        if dp[i+1]!=0:
            dp[i+1] = (dp[i]+dp[i-1]) % 1000000007
    print(dp[N])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    a=[int(input()) for i in range(M)]
    dp=[1]*(N+1)
    if M!=0:
        dp[1]=0 if a[0]==1 else 1
        for i in a:
            dp[i]=0
    for i in range(1,N):
        if dp[i+1]!=0:
            dp[i+1] = (dp[i]+dp[i-1]) % 1000000007
    print(dp[N])


if __name__ == '__main__':
    main()
5
3 3 3 3 3

### FIXED CODE ###

n=int(input())
a=list(map(int, input().split()))
cnt=0
for i in range(1,n):
    if a[i-1]>a[i]:
        cnt+=a[i-1]-a[i]
        a[i]=a[i-1]
print(cnt)
import numpy as np
import math
N,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(N):
    if i==0:
        ans=x[i]-X
    else:
        ans=math.gcd(ans,x[i]-X)
print(ans)

### FIXED CODE ###

import fractions

N,X=map(int,input().split())
x=map(int,input().split())
x=list(x)
for i in range(N):
    if i==0:
        ans=x[i]-X
    else:
        ans=fractions.gcd(ans,x[i]-X)
print(abs(ans))
import sys

def main():
    l=sys.stdin.readline().split()
    print l[1]+l[0]

main()

### FIXED CODE ###

import sys

def main():
    l=sys.stdin.readline().split()
    print(l[1]+l[0])

main()
a,b,x=map(int,input().split())
v=a*a*b/2
k=(v-x)/(a*b)
g=x/(a*b)
if x<=v:
  print(math.atan(b/g)*180/math.pi)
else:
  print(math.atan(b/k)*180/math.pi)

### FIXED CODE ###

a,b,x=map(int,input().split())
v=a*a*b/2
import math
k=(2*v-x)*2/(a*a)
g=2*x/(a*b)
if x<=v:
  print(math.atan(b/g)*180/math.pi)
else:
  print(math.atan(k/a)*180/math.pi)