Harryxun/stf_run huggingface dataset:
import itertools

N = int(input())
a = list(int(i) for i in input().split())

while True:
    for c in itertools.combinations(a, 3):
        if c[0] ^ c[2] == c[1]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[1])
        elif c[1] ^ c[2] == c[0]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[0])
        elif c[0] ^ c[1] == c[2]:
            if len(a) == 3:
                print("Yes")
                exit()
            else:
                a.remove(c[2])
    print("No")
    exit()

### FIXED CODE ###

a = [input() for i in range(2)]
 
N = int(a[0])
data = a[1].split(' ')
 
data = [int(i) for i in data]
 
result = []
a = 0
for i in range(N):
    a = a ^ data[i]
    
if a == 0:
    print('Yes')
    exit()
    
print('No')
from math import floor
T = int(input())
for i in range(T):
    memo = {}
    def buy(A):
        if A < B:
            return False
        else:
            if A % B > C:
                return False
            else:
                A = floor((C-A%B)/B)*B+A%B+D
                if A not in memo:
                    memo[A] = 0
                    return buy(A)
                else:
                    return(True)
    A,B,C,D = map(int,input().split())
    if B > D:
        print("No")
    else:
        if buy(A):
            print("Yes")
        else:
            print("No")

### FIXED CODE ###

from math import floor
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
T = int(input())
for i in range(T):
    A,B,C,D = map(int,input().split())
    if B > D or B > A:
        print("No")
    else:
        if A%B>C:
            print("No")
        else:
            d = gcd(B,D%B)
            r = (A%B)%d
            if B - d + r > C:
                print("No")
            else:
                print("Yes")
import sys
for i in sys.stdin.readlines() :
    l = list(int, i.split(" "))
    a = l[0]
    b = l[1]
    if a == 0 and b == 0 :
        break
    else :
        sorted(l)
        print(l[0],l[1])

### FIXED CODE ###

import sys
while True :
    ab = list(map(int,sys.stdin.readline().split()))
    a = ab[0]
    b = ab[1]
    if a == 0 and b == 0 :
        break
    else :
        ab = sorted(ab)
        print(ab[0],ab[1])
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

if K<=N:
  nex=0
  for i in range(K):
    
    ans=A[nex]
    nex=ans
  print(ans)
  sys.exit()
    
n=[0]*N
n[0]=A[0]

for i in range(N):
  if A[n[i]-1] in n:
    a=n.index(A[n[i]-1])
    le=len(n[a:i+1]) #ループ
    break
  n[i+1]=A[n[i]-1]

k_remain=(K-len(n[:i+1])+le)%le

print(n[a:i+1][k_remain-1])

### FIXED CODE ###

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

n=[-1]*(N+2)
n[1]=0
i=0 #カウンター
place_now=1 #いる場所

while True:
  
  i+=1 #何回飛んだか
  place_now=A[place_now-1] #飛んだ時の場所
  
  
  if n[place_now] != -1:
    a=n[place_now] #ループの開始点
    loop=i-a #ループする長さ
    break
  
  n[place_now]=i #その場所につくのに何回飛んだか
  
if a>=K:
  print(n.index(K))
elif a<K:
  k_remain=(K-a)%loop+a
  print(n.index(k_remain))
I=lambda:map(int,input().split())
n,m=I()
g=[[]for _ in range(n+1)]
v=[1 for _ in range(n+1)]
v[1]=0

for _ in range(m):
  a,b=I()
  g[a]+=[b]
  g[b]+=[a]

def D(x):
  for j in g[x]:
    if v[j]:
      v[j]=0
      return [j]+D(j)
      break
  else:
    return []
z=D(1)[::-1]+[1]+D(1)
print(len(z))
print(*z)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
I=lambda:map(int,input().split())
n,m=I()
g=[set() for _ in range(n+1)]
v=[1 for _ in range(n+1)]
v[1]=0

for _ in range(m):
  a,b=I()
  g[a].add(b)
  g[b].add(a)

def dfs(x):
  for j in g[x]:
    if v[j]:
      v[j]=0
      l=dfs(j)
      l.append(j)
      return l
      break
  else:
    return []
z=dfs(1)+[1]+dfs(1)[::-1]
print(len(z))
print(*z)
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
count=0
a=0
b=0

while count<k:
    if A[a]<B[b]:
        if k-count>=A[a]:
            count+=A[a]
            ans+=1
            if a<len(A)-1:
                a+=1
            else:
                A[a]=10**10
        else:
            print(ans)
            break
                
    if A[a]>B[b]:
        if k-count>=B[b]:
            count+=B[b]
            ans+=1
            if b<len(B)-1:
                b+=1
            else:
                B[b]=10**10
    
        else:
            print(ans)
            break
    
    if A[a]==B[b]:
        if k-count>=B[b]:
            if A[a+1]<B[b+1]:
                count+=A[a]
                ans+=1
                if a<len(A)-1:
                    a+=1
                else:
                    A[a]=10**10
            else:
                count+=B[b]
                ans+=1
                if b<len(B)-1:
                    b+=1
                else:
                    B[b]=10**10
        else:
            print(ans)
            break

### FIXED CODE ###

n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a,b=[0],[0]
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

ans,j=0,m
for i in range(n+1):
    if a[i]>k:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)
x1, y1, x2, y2 = map(int, input().split())

def vector(x1, y1, x2, y2):
    return x2 - (y2 - y1), y2 + (x2 - x1)

x3, y3 = vector(x1, y1, x2, y2)
x4, y4 = vector(x2, y2, x3, y3)

print(x3, y3, x4, y4)

### FIXED CODE ###

c = [list(map(int, input().split())) for i in range(3)]

f = c[0][0]
s = c[0][1] - f
t = c[0][2] - f

for i in c:
    i_f = i[0]

    if i[1] != i_f + s or i[2] != i_f + t:
        print("No")
        exit()

print("Yes")
n, m = map(int, input().split())
p = list(map(int, input().split()))
g = []
for i in range(m):
    g.append(list(map(int, input().split())))
l = [[] for i in range(n+1)]
for pi in g:  
    l[pi[0]].append(pi[1])
    l[pi[1]].append(pi[0])
x =  [0]*n
for i in range(n):
  x[p[i]-1] = i+1
ans = 0
def saiki(a):
  c = l[a]
  while len(c) > 0:
    z = c.pop()
    y[z-1] = i
    saiki(z)
#Union find
y = [0] * n
for i in range(0,n):
  if y[i] == 0:
    y[i] = i
  saiki(i)
for i in range(n):
  c = x[i]
  if y[c-1] == y[i]:
    ans +=1
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
p = list(map(int, input().split()))
g = []
for i in range(m):
    g.append(list(map(int, input().split())))
l = [[] for i in range(n+1)]
for pi in g:  
    l[pi[0]].append(pi[1])
    l[pi[1]].append(pi[0])
x =  [0]*n
for i in range(n):
  x[p[i]-1] = i+1
ans = 0
#Union find
y = [-1] * n
for i in range(0,n):
  if y[i] == -1:
    y[i] = i
  c = l[i+1]
  while len(c) > 0:
    z = c.pop()
    y[z-1] = y[i]
    for j in range(len(l[z])):
      if y[l[z][j]-1] == -1:
        c.append(l[z][j])
    l[z] =[]
    
for i in range(n):
  c = x[i]
  if y[c-1] == y[i]:
    ans +=1
print(ans)
n,t=map(int,input().split())
dp=[-1 for i in range(t+1)]
s=[0 for i in range(t+1)]
d=[]
dp[0]=0
s[0]=0
for i in range(n):
    d.append(list(map(int,input().split())))
d=sorted(d,key=lambda x: -x[1])
for i in range(n):
    for j in range(t,-1,-1):
        if dp[j]>=0 and j+d[i][0]<=t:
            if dp[j+d[i][0]]<dp[j]+d[i][1]:
                dp[j+d[i][0]]=dp[j]+d[i][1]
                if i<n:
                    s[j+d[i][0]]=d[i+1][1]
ans=0
for i in range(t):
    ans=max(ans,dp[i]+s[i])
print(max(ans,dp[t]))

### FIXED CODE ###

n,t=map(int,input().split())
dp=[[-1 for j in range(2)] for i in range(t+1)]
dp[0][0]=0
d=[]
for i in range(n):
    d.append(list(map(int,input().split())))
d.sort()
for i in range(n):
    for j in range(t,-1,-1):
        for k in range(1,-1,-1):
            if k==0:
                if dp[j][k]>=0 and j+d[i][0]<t:
                    dp[j+d[i][0]][k]=max(dp[j+d[i][0]][k],dp[j][k]+d[i][1])
            if k==1:
                if dp[j][0]>=0:
                    dp[j][k]=max(dp[j][k],dp[j][0]+d[i][1])
ans=0
for i in range(t+1):
    for j in range(2):
        ans=max(ans,dp[i][j])
print(ans)
import numpy as np
N,M = map(int,input().split())
a = 0
w = 0
lis = np.zeros(N + 1)
for i in range(M):
  p,s = map(str,input().split())
  if lis[p] == 0 and s == "AC":
    a += 1
    lis[p] = 1
  elif lis[p] != 0 and s == "AC":
    continue
  elif lis[p] == 0 and s == "WA":
    w += 1
  elif lis[p] != 0 and s == "WA":
    continue
    
print(a,w)



### FIXED CODE ###

N,M = map(int,input().split())
a = 0
w = 0
lis = [[] for _ in range(N)]
for i in range(M):
  p,s = map(str,input().split())
  p = int(p)
  lis[p - 1].append(s)
for j in range(N):
  if lis[j].count("AC") > 0:
    a += 1
    w += lis[j].index("AC")

    
print(a,w)
n = int(input())
bx = 0
by = 0
bt = 0
def p(t,x,y):
  if abs(x)+abs(y) > t:
    return True
  elif (t-abs(x)-abs(y))%2 == 1:
    return True
  else:
    return False
for _ in range(n):
  at,ax,ay = map(int,input().split())
  if p(at-bt,bx-ax,by-ay):
    print(p(t,bx-ax,by-ay))
    print("No")
    exit()
  bx = ax
  by = ay
  bt = at
print("Yes")  

### FIXED CODE ###

n = int(input())
bx = 0
by = 0
bt = 0
def p(t,x,y):
  if abs(x)+abs(y) > t:
    return True
  elif (t-abs(x)-abs(y))%2 == 1:
    return True
  else:
    return False
for _ in range(n):
  at,ax,ay = map(int,input().split())
  if p(at-bt,bx-ax,by-ay):
    print("No")
    exit()
  bx = ax
  by = ay
  bt = at
print("Yes")
n, m = (int(_) for _ in input().split())  
skp = [[int(i) for i in input().split()] for i in range(m+1)]
sk, p = skp[:-1], skp[-1]

def judge(sw_status, sk, p):
  sk = np.array(sk) - 1
  num = sw_status[sk[1:]].sum()%2
  if num == p:
    light = 1
  else:
    light = 0
  return light

# sw_status = np.array([0 for i in range(n)])
ans = 0
for i in range(2**n):
  sw_status = [j for j in bin(i)][2:]
  for SK, P in zip(sk, p):
  	j = judge(sw_status, SK, P)
    if j==0:
      break
    else:
      ans += 1

print(ans)

### FIXED CODE ###

import numpy as np
n, m = (int(_) for _ in input().split())  
skp = [[int(i) for i in input().split()] for i in range(m+1)]
sk, p = skp[:-1], skp[-1]

def judge(sw_status, sk, p):
    sk = (np.array(sk) - 1).tolist()
    num = sw_status[[sk[1:]]].sum()%2
    if num == p:
        light = 1
    else:
        light = 0
    return light

ans = 0
for i in range(2**n):
    sw_status = np.array([j for j in bin(i)[2:].zfill(n)]).astype(int)
    for SK, P in zip(sk, p):
        j = judge(sw_status, SK, P)
        if j is 0:
            break
    if j is 1:
        ans += 1

print(ans)
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

def bin(arr, val):
    l,r = 0, len(arr)-1
    while l <= r:
        mid = (l + r)//2
        if arr[mid] == val: return 1
        elif arr[mid] <= val: l = mid + 1
        elif arr[mid] >= val: r = mid - 1
    return 0

x,n = imap()
p = sorted(iarr())

for i in range(n):
    a,b = x-i,x+i
    if not bin(p,a): ans = a; break
    if not bin(p,b): ans = b; break

if n==0: ans = x
print(ans)



### FIXED CODE ###

import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

def bin(arr, val):
    l,r = 0, len(arr)-1
    while l <= r:
        mid = (l + r)//2
        if arr[mid] == val: return 1
        elif arr[mid] <= val: l = mid + 1
        elif arr[mid] >= val: r = mid - 1
    return 0

x,n = imap()
p = sorted(iarr())

for i in range(n+1):
    a,b = x-i,x+i
    if not bin(p,a): ans = a; break
    if not bin(p,b): ans = b; break

if n==0: ans = x
print(ans)
n,q=map(int,input().split())
a=[]
b=[]
s=[0]


for i in range(0,n-1):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
    s.append(0)
for i in range(0,q):
    P,X=map(int,input().split())
    s[P-1]=s[P-1]+X


for j in range(0,n-1):
    s[b[j]-1]=s[b[j]-1]+s[a[j]-1]

print(' '.join(map(str,s)))

### FIXED CODE ###

a=int(input())
s=input()

if a>=3200:
    print(s)
else:
    print('red')
a = list(map(int,input().split()))
a[0], a[1] = a[1], a[0]
a[0], a[2] = a[2], a[0]
 
print(a[0]+" "+a[1]+" "+a[2])

### FIXED CODE ###

a = list(map(int,input().split()))
a[0], a[1] = a[1], a[0]
a[0], a[2] = a[2], a[0]
 
print(a[0], a[1], a[2])
import sys
input = sys.stdin.readline

N = int(input())
S = input().rstrip()

num = S.count('1')

n1 = num + 1
n2 = num - 1

start1 = 0
start2 = 0
pow1 = [1]
pow2 = [1]
for i in range(N):
    s = int(S[-1-i])
    start1 = (start1 + pow1[-1] * s) % n1
    start2 = (start2 + pow2[-1] * s) % n2
    pow1.append(pow1[-1] * 2 % n1)
    pow2.append(pow2[-1] * 2 % n2)


def count(m):
    ret = 1
    while m != 0:
        k = bin(m).count("1")
        m %= k
        ret += 1
    return ret
    


ans = []
for i in range(N):
    s = int(S[i])
    if s == 0:
        l = (start1 + pow1[-i-2]) % n1
        ans.append(count(l))
    else:
        l = (start2 - pow2[-i-2]) % n2
        ans.append(count(l))

print(*ans, sep="\n")

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input())
S = input().rstrip()

num = S.count('1')

n1 = num + 1
n2 = num - 1

def count(m):
    ret = 1
    while m != 0:
        k = bin(m).count("1")
        m %= k
        ret += 1
    return ret


if n2 != 0:
    start1 = 0
    start2 = 0
    pow1 = [1]
    pow2 = [1]
    for i in range(N):
        s = int(S[-1-i])
        start1 = (start1 + pow1[-1] * s) % n1
        start2 = (start2 + pow2[-1] * s) % n2
        pow1.append(pow1[-1] * 2 % n1)
        pow2.append(pow2[-1] * 2 % n2)


    ans = []
    for i in range(N):
        s = int(S[i])
        if s == 0:
            l = (start1 + pow1[-i-2]) % n1
            ans.append(count(l))
        else:
            l = (start2 - pow2[-i-2]) % n2
            ans.append(count(l))

    print(*ans, sep="\n")
else:
    start1 = 0
    pow1 = [1]
    for i in range(N):
        s = int(S[-1-i])
        start1 = (start1 + pow1[-1] * s) % n1
        pow1.append(pow1[-1] * 2 % n1)

        


    ans = []
    for i in range(N):
        s = int(S[i])
        if s == 0:
            l = (start1 + pow1[-i-2]) % n1
            ans.append(count(l))
        else:
            ans.append(0)

    print(*ans, sep="\n")
N=int(input())
a=list(map(int,input().split()))
while len(a)>=2:
	a.sort()
	x,y=map(int,a.pop())
	a.append((x+y)/2)

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
while len(a)>1:
	a.sort()
	x=a.pop(0)
	y=a.pop(0)
	a.append((x+y)/2)
print(a[0])
lst_str = [input() for _ in range(5)]
lst_int = [int(x) for x in lst_str]
lst_diff = []

sum_lst = sum(lst_int)
for i in lst_str:
    val = 10 - int(i[-1])#一の位
    if val != 10:
        lst_diff.append(val)
# print(lst_diff)

diff = sum(lst_diff) - max(lst_diff)

ans = sum_lst + diff
print(ans)

### FIXED CODE ###

lst_str = [input() for _ in range(5)]
lst_int = [int(x) for x in lst_str]

sum_lst = sum(lst_int)

lst_diff = []
for i in lst_str:
    val = int(i[-1])
    if val != 0:
        lst_diff.append(10 - val)

if lst_diff == []:
    lst_diff = [0]
diff = sum(lst_diff) - max(lst_diff)

ans = sum_lst + diff
print(ans)
n, m = map(int, input().split())
q = []
for i in range(m):
    a, b = map(int, input().split())
    q.append({a, b})
cnt = 0
array = list(range(1, n+1))
while cnt != 10000:
    a = q.pop()
    for j in q:
        if len(j & a) != 0:  # jとaに共通の値があるならば
            j |= a
            count = 0
            break
        else:  # jとaに共通の値がなければ
            q = [a] + q
    if count > len(q):
        break
    count += 1
    for i in q:
        tmp = list(i)
        if tmp == array:
            cnt += 1
print(cnt)


### FIXED CODE ###

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

path_matrix = []

#無向行列の初期化
for n in range(N):
    path_matrix.append([False] * N)

#まず無向グラフを表す行列を作る
for m in range(M):
    a,b = map(int, input().split())
    path_matrix[a-1][b-1] = True
    path_matrix[b-1][a-1] = True
#無向グラフを表す行列はpath_matrix[i][j]iの部分が各頂点でjが他の頂点との繋がりを意味する
#最初はvisited、つまり訪問したことのあるノードはひとつもないので、Falseにする
visited = [False] * N #この問題は各頂点をすべて通る方法を調べること
def dfs(now,depth):
    if visited[now]:#もし現在位置が訪問済みなら
        return 0
    if depth == N-1:#もし深さが最大までいったらすべての頂点を探索し終えたので１を返す
        return 1
    
    visited[now] = True#現在位置を訪問済みにする(これをしないとループし続ける)
    total_path = 0
    for i in range(N):
        if path_matrix[now][i]:#もし飛べる先があるのなら、その飛んだ先のノードで今いる位置と深さを更新した上で、もっと掘り下げてみる
            total_path += dfs(i,depth+1)#もし深さが最大まで行ったらすべての頂点について探索が終了したので1加える

    visited[now] = False

    return total_path


print(dfs(0,0))
n,k,*_=open(0);print(((int(n)-2)//(int(k)-1))+1)

### FIXED CODE ###

n,k=input().split();print(((int(n)-2)//(int(k)-1))+1)
from itertools import groupby

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

B = [len(list(group)) for key, group in groupby(sorted(A))]
C = []
for i, val in enumerate(B):
	if val % 2 == 0: C.append(2)
	else: C.append(1)

D = [len(list(group)) for key, group in groupby(sorted(C))]

if D[1] % 2 == 0:
	answer = D[0] +D[1]
else:
	answer = D[0] +D[1] - 1

print(answer)

### FIXED CODE ###

N = int(input())

A = len(set(list(map(int, input().split()))))

if A % 2 == 0:
    print(A - 1)
else:
    print(A)
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(W+10)] for _ in range(N+5)]
dp[0][0] = 0

for w in range(W+1):
    for n in range(N):
        Wi = wv[n][0]
        Vi = wv[n][1]
        if Wi <= w:
            dp[n+1][w] = max(dp[n][w], dp[n][w-Wi] + Vi)
        dp[n+1][w] = max(dp[n][w], dp[n+1][w])

print(dp[N][W])

### FIXED CODE ###

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

INF = 10 ** 10
dp = [INF] * N

dp[0] = 0

for i in range(1, N):
    dp[i] = min(dp[i], dp[i-1] + abs(H[i] - H[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(H[i] - H[i-2]))

print(dp[N-1])
def main():
    S = input()

    cnt_A, cnt_B = 0

    for i in range(len(S)):
        if S[i] == "A":
            cnt_A += 1
        else:
            cnt_B += 1

    if cnt_A == 3 or cnt_B == 3:
        print('{}'.format('No'))
    else:
        print('{}'.format('Yes'))


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    S = input()

    cnt_A = 0
    cnt_B = 0

    for i in range(len(S)):
        if S[i] == "A":
            cnt_A += 1
        else:
            cnt_B += 1

    if cnt_A == 3 or cnt_B == 3:
        print('{}'.format('No'))
    else:
        print('{}'.format('Yes'))


if __name__ == '__main__':
    main()
import math
N,M=map(int,input().split())
S=input()
T=input()

n=N//math.gcd(N,M)
m=M//math.gcd(N,M)
g=math.gcd(N,M)
judge=True

for i in range(g):
    if S[i*n]!=T[i*m]:
        judge=False

if judge==True:
    print(N*M//g)
else:
    print(-1)

### FIXED CODE ###

import fractions
N,M=map(int,input().split())
S=input()
T=input()

n=N//fractions.gcd(N,M)
m=M//fractions.gcd(N,M)
g=fractions.gcd(N,M)
judge=True

for i in range(g):
    if S[i*n]!=T[i*m]:
        judge=False

if judge==True:
    print(N*M//g)
else:
    print(-1)
n, m = map(int, input().split())
s = input()
t = input()

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

g = gcd(n, m)
bl = True
for k in range(g):
    i, j = k * n // g, k * m // g
    if s[i] != s[j]:
        bl = False

print(lcm(n, m)) if bl else print('-1')

### FIXED CODE ###

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

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

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

g = gcd(n, m)
bl = True
for k in range(g):
    i, j = k * n // g, k * m // g
    if s[i] != t[j]: # s[i] != s[j] にしてた...
        bl = False

print(lcm(n, m)) if bl else print('-1')
n=int(input())

def euc(a,b):
  if a==b:
    return a
  else:
    return euc(max(a,b)-min(a,b),min(a,b))

mons=list(map(int,input().split()))
for i in range(n-1):
  p=euc(mons[i],mons[i+1])
  if p==1:
    ans=1
    break
    
  else:
    mons[i+1]=p

if ans==1:
  print(1)
else:
  print(mons[n-1])


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
def euc(x,y):
  x,y=max(x,y),min(x,y)
  if x%y==0:
    return y
  else:
    return euc(y,x%y)
k=a[0]
for i in range(1,n):
  k=euc(a[i],k)
print(k)
miu = input().split()[1]
sella = input()
 
sella[int(miu)-1] = sella[int(miu)-1].lower()
 
print(sella)

### FIXED CODE ###

miu = input().split()
sella = input()

for x in range(0, int(miu[0])):
	if x == int(miu[1])-1:
		print(sella[x].lower(), end='')
	else:
		print(sella[x], end='')
a, b = map(int, input().split())
c=a+b
print(str(c/2))

### FIXED CODE ###

R = int(input())
G = int(input())
print(2*G-R)
import numpy as np
def acinput():
    return list(map(int, input().split(" ")))




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


a, b, c, d = acinput()
l = lcm(c, d)
CD = b//l-(a-1)//l
nC = b//c-(a-1)//c
nD = b//d-(a-1)//d

res = b-a+1-(nC+nD-CD)
print(int(res))


### FIXED CODE ###

def gcd(a,b):
    while b > 0:
        a, b = b, a % b
    return a


def acinput():
    return list(map(int, input().split(" ")))
def lcm(x, y):
    return x*y //gcd(x, y)

a, b, c, d = acinput()
l = lcm(c, d)
CD = b//l-(a-1)//l
nC = b//c-(a-1)//c
nD = b//d-(a-1)//d

res = b-a+1-(nC+nD-CD)
print(int(res))
def grinp(h):
  ret=[]
  for i in range(h):
    ret.append(list(input()))
  return ret
h,w=map(int,input().split())
grid=grinp(h)
fa=False
for i in range(h):
  for j in range(w):
    if grid[i][j]==".":
      continue
    fl=0
    if i!=0 and grid[i-1][j]=="#":
      fl+=1
    if i!=h-1 and grid[i+1][j]=="#":
      fl+=1
    if j!=0 and grid[i][j-1]=="#":
      fl+=1
    if j!=h-1 and grid[i][j+1]=="#":
      fl+=1
    if fl==0:
      fa=True
      break
  if fa:
    break
if fa:
  print("No")
else:
  print("Yes")
    

### FIXED CODE ###

def grinp(h):
  ret=[]
  for i in range(h):
    ret.append(list(input()))
  return ret
h,w=map(int,input().split())
grid=grinp(h)
fa=False
for i in range(h):
  for j in range(w):
    if grid[i][j]==".":
      continue
    fl=0
    if i!=0 and grid[i-1][j]=="#":
      fl+=1
    if i!=h-1 and grid[i+1][j]=="#":
      fl+=1
    if j!=0 and grid[i][j-1]=="#":
      fl+=1
    if j!=w-1 and grid[i][j+1]=="#":
      fl+=1
    if fl==0:
      fa=True
      break
  if fa:
    break
if fa:
  print("No")
else:
  print("Yes")
import math

x1, y1, x2, y2 = list(map(int, input().split()))

exp_dist = abs(x1 - x2)**2 + abs(y1 - y2)**2

print(math.sqrt(exp_dist))

### FIXED CODE ###

import math

x1, y1, x2, y2 = list(map(float, input().split()))

exp_dist = abs(x1 - x2)**2 + abs(y1 - y2)**2

print(math.sqrt(exp_dist))