Harryxun/stf_run huggingface dataset:
import collections


class unionFind:
    parent = []

    def __init__(self, N):
        self.parent = [i for i in range(N)]

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            self.parent[x] = self.root(self.parent[x])
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y):
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            return


N, M = map(int, input().split())
G = unionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    G.unite(a, b)


for i in range(N):
    G.root(i)

C = collections.Counter(G.parent).most_common()


print(C[0][1])


### FIXED CODE ###

import collections
import sys
sys.setrecursionlimit(10**6)
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(M)]


class unionFind:
    parent = []

    def __init__(self, N):
        self.parent = [i for i in range(N)]

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            self.parent[x] = self.root(self.parent[x])
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y):
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            return


G = unionFind(N)

for a, b in AB:
    G.unite(a, b)

for i in range(N):
    G.root(i)

C = collections.Counter(G.parent).most_common()

print(C[0][1])
R = int(input("R:"))
G = int(input("G:"))
B = int(input("B:"))
N = int(input("N:"))
r = 0
g = 0
X = N - r*R - g*G
num = 0
while X >= 0:
	while X >= 0:
			if X % B == 0:
				num += 1
			r += 1
			X = N - r*R - g*G
	g += 1
	r = 0
	X = N - r * R - g * G

print(num)

### FIXED CODE ###

R,G,B,N = map(int, input().split())
count = 0
for r in range(N // R + 1) :
    for g in range((N - r*R) // G + 1) :
        if (N - r*R - g*G) %B == 0 :
            count += 1
print(count)
k=[0]*(10**9+1)
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
	k[a[i]-1]+=1
	if k[a[i]-1]>a[i]:
		ans+=1
b=set()
for i in range(n):
	if k[a[i]-1]<a[i]-1 and a[i] not in b:
		ans+=k[a[i]-1]
	b.add(a[i])
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
cnt=1
for i in range(n-1):
	if a[i]==a[i+1]:
		cnt+=1
	else:
		if cnt>=a[i]:
			x=cnt-a[i]
		else:
			x=10**10
		ans+=min(cnt,x)
		cnt=1
if cnt>=a[-1]:
	x=cnt-a[-1]
else:
	x=10**10
ans+=min(cnt,x)
print(ans)
retu = input( )
print(int(retu.split(",")[32]))

### FIXED CODE ###

retu = "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"

retu = retu.split(",")
retuint=[]
for i in retu :
	retuint.append(int(i))

index=input()

print(retuint[int(index)-1])
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
b.append(0)
i=0
count=0
while True:
    if i==n+1:
        break
    elif a[i]>b[i]:
        i+=1
        count+=min(a[i],b[i])
    else:
        count+=min(a[i],b[i])
        c=b[i]-a[i]
        count+=min(a[i+1],c)
        if c>a[i+1]:
            a[i+1]=0
            i+=1
        else:
            a[i+1]-=c
            i+=1
print(count)


### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sum = 0
attack = 0
mon = a[0]
for i in range(n):
    if mon >= b[i]:
        sum += b[i]
        mon = a[i+1]
    else:
        sum += mon
        attack = b[i] - mon
        mon = max(0, a[i+1] - attack)
        sum += (a[i+1] - mon)
print(sum)
weather = ["Sunny","Cloudy","Rainly"]
S = input()
print(wether[(weather.index(S)+1)%3])

### FIXED CODE ###

weather = ["Sunny","Cloudy","Rainy"]
S = input()
print(weather[(weather.index(S)+1)%3])
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

if N == 1 and M == 0:
  print(0)
  exit()

sc = [LIST() for _ in range(M)]

ans = [-1]*N
for s, c in sc:	
  if N >= 2 and s == 1 and c == 0:
    print(-1)
    exit()
  if ans[s-1] != -1 and ans[s-1] != c: #既に値が入ってる
    print(-1)
    exit()
  ans[s-1] = c
    
if ans[0] == -1:
  ans[0] = 1

for i in range(N):
  if ans[i] == -1:
    ans[i] = 0
    
for n in ans:
  print(n, end="")

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
if N%2 == 0:
  print(int(N/2))
else:
  print(int(N/2+1))
import collections
n,k=map(int,input().split())
A=list(map(int,input().split()))
c=collections.Counter(A)
tot=0
for i in range(k):
  tot+=c.most_common()[i][1]
print(n-tot)

### FIXED CODE ###

import collections
n,k=map(int,input().split())
A=list(map(int,input().split()))
c=collections.Counter(A)
tot=0
for i in c.most_common(min(k,len(set(A)))):
  tot+=i[1]
print(n-tot)
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

red = P[:X]
green = Q[:Y]
ans = sum(red) + sum(green)

ridx = 0
redidx = -1
greenidx = -1

for i in range(X+Y):
    if red[redidx] < green[greenidx] and abs(redidx) <= len(red):
        if red[redidx] < R[ridx]:
            ans -= red[redidx]
            ans += R[ridx]
            ridx += 1
            redidx -= 1
    elif red[redidx] > green[greenidx] and abs(greenidx) <= len(green):
        if green[greenidx] < R[ridx]:
            ans -= green[greenidx]
            ans += R[ridx]
            ridx += 1
            greenidx -= 1

    if ridx == len(R):
        break

print(ans)


### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)

red = P[:X]
green = Q[:Y]
ans = sum(red + green)
rg = sorted(red + green)

for i in range(min(C, X+Y)):
    if rg[i] < R[i]:
        ans += R[i] - rg[i]

print(ans)
a,b,c=(str, input().split())

print(a[0]+b[1]+c[2])

### FIXED CODE ###

a=input()
b=input()
c=input()

print(a[0]+b[1]+c[2])
n,m=list(map(int,input().split()))
s=list(map(int,input().split()))

a.sort()
term=[]
if n-m>=0:
    print(0)
else:
    for i in range(m-1):
        term.append(s[i+1]-s[i])
    
    term.sort()

    for i in range(n-1):
        del term[-1]
    
    print(sum(term))

### FIXED CODE ###

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

s.sort()
term=[]
if n-m>=0:
    print(0)
else:
    for i in range(m-1):
        term.append(s[i+1]-s[i])
    
    term.sort()

    for i in range(n-1):
        del term[-1]
    
    print(sum(term))
from collections import Counter
import math

n = int(input())
s = [input() for _ in range(n)]
ans = 0
while len(s) > 0:
    count = 1
    si = Counter([x for x in s[0]])
    j = 1
    while j < len(s):
        if si == Counter([x for x in s[j]]):
            count += 1
            s.pop(j)
        else:
            j += 1
    ans += math.factorial(count) // (2 * math.factorial(count-2))
    s.pop(0)
print(ans)


### FIXED CODE ###

n = int(input())
s = [[x for x in input()] for _ in range(n)]
ans = 0
d = {}
for i in range(n):
    key = "".join(sorted(s[i]))
    if key in d:
        ans += d[key]
        d[key] += 1
    else:
        d[key] = 1

print(ans)
import math
A, B = map(int, input().split())
ans = A * B / math.gcd(A, B)

print(int(ans))

### FIXED CODE ###

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

A, B = map(int, input().split())
ans = A * B // gcd(A, B)

print(int(ans))
n = int(input())
ns= int(input().spit())
for i in range(n):
    ns[i]= int(ns[i])
asum = sum(ns)
amin = min(ns)
amax = max(ns)

print(amin, amax, asum))


### FIXED CODE ###

n=int(input())
ns=input().split()
for i in range(len(ns)):
    ns[i]=int(ns[i])
asum=sum(ns)
amin=min(ns)
amax=max(ns)
print(amin,amax,asum)
import bisect
import itertools

n, a, b, c = map(int, input().split())
l = sorted([int(input()) for i in range(n)])
ABC = [a, b, c]
ans = float("inf")

def dfs(i, abc):
    global ans
    sum_a = 0
    l1 = l[:]
    if i == 3:
        for k in itertools.permutations([0, 1, 2], 3):
            for j in k:
                index = bisect.bisect_left(l1, ABC[j])
                if abc[j] == 0:
                    if index < len(l1):
                        sum_a += l1[index] - ABC[j]
                        l1.remove(l1[index])
                    else:
                        sum_a += float("inf")
                elif abc[j] == 1:
                    if index > 0:
                        sum_a += ABC[j] - l1[index - 1]
                        l1.remove(l1[index - 1])
                    else:
                        sum_a += float("inf")
                else:
                    sum_ = float("inf")
                    for x in range(2, len(l1) + 1):
                        for y in itertools.combinations(l1, x):
                            if sum_ > abs(sum(y) - ABC[j]):
                                sum_ = abs(sum(y) - ABC[j]) + (x - 1) * 10
                                l2 = l1[:]
                                for z in y:
                                    l2.remove(z)
                    l1 = l2[:]
                    sum_a += sum_
            ans = min(ans, sum_a)
        return 0
    dfs(i + 1, abc[:i] + [abc[i]] + abc[i + 1:])
    dfs(i + 1, abc[:i] + [abc[i] + 1] + abc[i + 1:])
    dfs(i + 1, abc[:i] + [abc[i] + 2] + abc[i + 1:])

dfs(0, [0, 0, 0])
print(ans)

### FIXED CODE ###

def dfs(i, A, B, C):
    global ans
    if i == n:
        if A and B and C:
            s = 0
            ABC = [A, B, C]
            for i in range(3):
                s += (len(ABC[i]) - 1) * 10 + abs(sum(ABC[i]) - abc[i])
            ans = min(ans, s)
    else:
        dfs(i + 1, A + [l[i]], B, C)
        dfs(i + 1, A, B + [l[i]], C)
        dfs(i + 1, A, B, C + [l[i]])
        dfs(i + 1, A, B, C)

n, a, b, c = map(int, input().split())
l = [int(input()) for i in range(n)]
abc = [a, b, c]
ans = float("inf")
dfs(0, [], [], [])
print(ans)
N.i=map(int,input().split())
print(N-i+1)

### FIXED CODE ###

N,i=map(int,input().split())
print(N-i+1)
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""
import numpy as np
import sys

EMPTY = (0, 0, frozenset())


def solve(values, _nb, max_capacity):
    dp = [0] * (max_capacity + 1)
    for w, v in values:
        # dp = dp[:w] + [max(dp[j], dp[j - w] + v) for j in range(w, max_capacity + 1)]
        dp = dp[:w] + [
            np.max(dpj, dpjw + v)
            for dpj, dpjw in zip(dp[w:], dp[: (max_capacity + 1 - w)])
        ]
    return dp[max_capacity]


def solve_slow(values, nb, max_capacity):
    dp = [[0 for _ in range(max_capacity + 1)] for _ in range(nb + 1)]
    for i in range(1, nb + 1):
        w, v = values[i - 1]
        for j in range(1, max_capacity + 1):
            if w <= j:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
            else:
                dp[i][j] = dp[i - 1][j]
    # print("\n".join(map(str, dp)))
    return dp[nb][max_capacity]


def do_job():
    "Do the work"
    # first line is number of test cases
    N, W = map(int, input().split())
    values = []
    for _ in range(N):
        values.append(list(map(int, input().split())))
    result = solve(values, N, W)
    print(result)


def print_output(testcase, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


### FIXED CODE ###

# DP
def main():
    N, W = map(int, input().split())

    dp = [-1] * (W + 1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(W - w, -1, -1):
            if dp[i] == -1:
                continue
            if dp[i + w] < dp[i] + v:
                dp[i + w] = dp[i] + v
    print(max(dp))


main()
a,b=map(int,input().split())
if a%2==0:print("Even")
  elif b%2==0:print("Even")
    elif print("Odd")

### FIXED CODE ###

a,b=map(int,input().split())
if (a)%2 == 0:
  print("Even")
elif (b)%2 == 0:
	print("Even")
else:
  print("Odd")
N=int(input())
a_list = list(map(int,input().split()))
ans = 0
min = a_list[0]
for i in range(1,N+1):
  if min > a_list[i]:
    ans += a_list[i]-min
  else:
    min = a_list[i]
print(ans)

### FIXED CODE ###

N=int(input())
a_list = list(map(int,input().split()))
ans = 0
min = a_list[0]
for i in range(1,N):
  if min > a_list[i]:
    ans += min-a_list[i]
  else:
    min = a_list[i]
print(ans)
a=int(input())
if a<1200:
  print(ABC)
elif 1199<a<2800:
  print(ARC)
else:
  print(AGC)
  
  

### FIXED CODE ###

a=int(input())
if a<1200:
  print("ABC")
elif 1199<a<2800:
  print("ARC")
else:
  print("AGC")
a,b=int(input()).split()

result = a * c
print(result)

### FIXED CODE ###

a,b=(int(x) for x in input().split())

result = a * b
print(result)
import math
A,B,C,D=map(int,input().split())


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


#print(len([x for x in range(A,B) if x%2!=0 and x%3!=0]))

size=B-A+1
#C
C2=A%C
if C2 is 0:
    Csize=size
else:
    C2=C-C2
    Csize=size-C2

#D
D2=A%D
if D2 is 0:
    Dsize=size
else:
    D2=D-D2
    Dsize=size-D2

cd =lcm(C,D)

#c,dの最小公倍数
cd2=A%cd
if cd2 is 0:
    CDsize=size
else:
    cd2=cd-cd2
    CDsize=size-cd2

#Cの個数
Cq=(Csize-1)//C
print(Cq)

#Dの個数
Dq=(Dsize-1)//D
print(Dq)

#CDの個数
CDq=(CDsize-1)//cd
print(CDq)

Q=(Cq+1)+(Dq+1)-(CDq+1)
Q=size-Q
print(Q)












"""
listsize=B-A-1
Q=0
for i in range(listsize+1):
    number=i+A
    if number % C is not 0 and number % D is not 0:
        Q+=1
print(Q)
"""




### FIXED CODE ###

from fractions import gcd
A,B,C,D=map(int,input().split())


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

size=B

cd=lcm(C,D)
allC=size//C
allD=size//D
allcd=size//cd
ALL=size-(allC+allD-allcd)

size=A-1
cd=lcm(C,D)
pC=size//C
pD=size//D
pcd=size//cd
P=size-(pC+pD-pcd)

print(ALL-P)
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    H,W,N=map(int,input().split())
    a,b=[0]*N,[0]*N
    for i in range(N):
        a[i],b[i]=map(int1,input().split())
    unique_a=list(set(a))
    unique_b=list(set(b))
    unique_a.sort()
    unique_b.sort()
    d_a,d_b={},{}
    tmp_a=0
    if unique_a:
        d_a[unique_a[0]]=tmp_a
        for i in range(len(unique_a)-1):
            tmp_a+=min(unique_a[i+1]-unique_a[i],3)
            d_a[unique_a[i+1]]=tmp_a
    tmp_b=0
    if unique_b:
        d_b[unique_b[0]]=tmp_b
        for i in range(len(unique_b)-1):
            tmp_b+=min(unique_b[i+1]-unique_b[i],3)
            d_b[unique_b[i+1]]=tmp_b
    c=[[0]*(tmp_b+1) for _ in range(tmp_a+1)]
    for i in range(N):
        c[d_a[a[i]]][d_b[b[i]]]+=1
    s=[[0]*(tmp_b+2) for _ in range(tmp_a+2)]
    for i in range(tmp_a+1):
        for j in range(tmp_b+1):
            s[i+1][j+1]=s[i][j+1]+s[i+1][j]-s[i][j]+c[i][j]
    ans=[0]*10
    for i in range(tmp_a-1):
        for j in range(tmp_b-1):
            ans[s[i+3][j+3]-s[i][j+3]-s[i+3][j]+s[i][j]]+=1
    ans[0]=(H-2)*(W-2)-sum(ans[1:])
    for row in ans:
        print(row)
    
    

if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    H,W,N=map(int,input().split())
    s=set()
    for i in range(N):
        s.add(tuple(map(int1,input().split())))
    ans=[0]*10
    used=set()
    for y,x in s:
        for dy in range(-1,2):
            for dx in range(-1,2):
                if 0>y+dy-1 or y+dy+1>=H or 0>x+dx-1 or x+dx+1>=W or (y+dy,x+dx) in used:
                    continue
                tmp=0
                used.add((y+dy,x+dx))
                for ddy in range(-1,2):
                    for ddx in range(-1,2):
                        if (y+dy+ddy,x+dx+ddx) in s:
                            tmp+=1
                ans[tmp]+=1
    ans[0]=(H-2)*(W-2)-sum(ans[1:])
    for row in ans:
        print(row)
    
    

if __name__ == '__main__':
    main()
n = int(input())
a = [int(i) for i in input().split()]

for i in range(len(a)):
    v = a[i]
    j = i 

    while j >= 0 and a[j]>v:
        a[j+1] = a[j]
        j-=1
    a[j+1]=v

print(" ".join(a))

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]

for i in range(len(a)):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j]>v:
        a[j+1] = a[j]
        j-=1
    a[j+1]=v
    print(" ".join([str(i) for i in a]))
a, b, k = map(int, input().split())

ans = 0

lista = range(a+1)
aa = lista.pop(0)

listb = range(b+1)
bb = listb.pop(0)

if (a < b):
    li = [i for i in lista if a % i == 0 && b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]
else:
    li = [i for i in listb if a % i == 0 && b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]

print(ans)

### FIXED CODE ###

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

ans = 0

lista = list(range(a+1))
aa = lista.pop(0)

listb = list(range(b+1))
bb = listb.pop(0)

if (a < b):
    li = [i for i in lista if a % i == 0 and b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]
else:
    li = [i for i in listb if a % i == 0 and b % i == 0]
    li = sorted(li, reverse=True)
    ans = li[k-1]

print(ans)
def solve(N):
    s = 1
    e = int(pow(N, 0.5)) + 1
    ds = []
    for i in range(s, e):
        if N % i == 0:
            m = N // i - 1
            if N // m == N % m:
                ds.append(N // i)

    return sum([i - 1 for i in ds])

if __name__ == "__main__":
    N = int(input())
    print(solve(N))


### FIXED CODE ###

def solve(N):
    s = 1
    e = int(pow(N, 0.5)) + 1
    ds = []
    for i in range(s, e):
        if N % i == 0:
            m = (N // i) - 1
            if m and N // m == N % m:
                ds.append(N // i)
                # print(f"{N} = {m} * {N // m} + {N % m}")

    return sum([i - 1 for i in ds])


assert (solve(8) == 3 + 7)
assert (solve(10) == 4 + 9)
assert (solve(1000000000000) == 2499686339916)
if __name__ == "__main__":
    N = int(input())
    print(solve(N))
s = int(input())
#最後に切った場所がiであるようなパターンの数をdp[i]とする
dp=[0]*(s+1)
dp[0]=1
for i in range(3,s+1):
  dp[i]=dp[i-1]+dp[i-3]
  dp.append(dp[i])
  score=dp[s]%(10**9+7)
print(score)

### FIXED CODE ###

s = int(input())
#最後に切った場所がiであるようなパターンの数をdp[i]とする
dp=[0]*(s+1)
dp[0]=1
if s<3:
  print("0")  
else:
  for i in range(3,s+1):
    dp[i]=dp[i-1]+dp[i-3]
    dp.append(dp[i])
    score=dp[s]%(10**9+7)
  print(score)
import sys
input = sys.stdin.readline

L,N=map(int,input().split())
X=[0]+[int(input()) for i in range(N)]

def LENG(a,b,start):
    if b==0:
        if start>a:
            return a
        else:
            return L-a

    if a>b:
        a,b=b,a

    return a+L-b


CANDI=[(N+1)//2,(N+1)//2-1,(N+1)//2+1]
#(i+2)//2*(-1)**i

ANS=0
for start in CANDI:
    if start==0:
        continue

    s=start
    t=(s+(-1)**0)%(N+1)
    ANS1=0


    
    for i in range(2,N+3):
        ANS1+=LENG(X[s],X[t],X[start])
        #print(s,t,i,ANS1)
        
        s,t=t,(t-i*((-1)**i))%(N+1)

        

        if s==0:
            break
    #print(ANS1)

    s=start
    t=(s-(-1)**0)%(N+1)
    ANS2=0
    for i in range(2,N+3):
        ANS2+=LENG(X[s],X[t],X[start])
        #print(s,t,i,ANS2)
        s,t=t,(t+i*((-1)**i))%(N+1)

        if s==0:
            break
    #print(ANS2)

    ANS=max(ANS,ANS1,ANS2)

print(ANS)
    


### FIXED CODE ###

import sys
input = sys.stdin.readline

L,N=map(int,input().split())
X=[0]+[int(input()) for i in range(N)]

S=[]

for i in range(N):
    S.append(X[i+1]-X[i])
S.append(L-X[-1])

#print(S)

DIS=L-S[-1]
ANS=L-S[-1]
MINUS=0
PLUS=L-S[-1]

#print(DIS)

for i in range(N-1):
    if i%2==0:
        MINUS+=S[-i-2]
        PLUS+=S[-i//2-1]-S[-i-2]

    else:
        MINUS+=S[-i-2]-S[-i-1+i//2]
        PLUS-=S[-i-2]

    DIS+=PLUS-MINUS

    if ANS<DIS:
        ANS=DIS

    #print(DIS,PLUS,MINUS)

S=S[::-1]

DIS=L-S[-1]
MINUS=0
PLUS=L-S[-1]

#print(DIS)

for i in range(N-1):
    if i%2==0:
        MINUS+=S[-i-2]
        PLUS+=S[-i//2-1]-S[-i-2]

    else:
        MINUS+=S[-i-2]-S[-i-1+i//2]
        PLUS-=S[-i-2]

    DIS+=PLUS-MINUS

    if ANS<DIS:
        ANS=DIS

    #print(DIS,PLUS,MINUS)

print(ANS)
s=input()
t=input()
c=0
for i in range(len(s)):
  if s[i]!=t[i]:
    c+=1
print(c)    

### FIXED CODE ###

a=int(input())
print(a+a**2+a**3)
R,G,B,N = map(int,input().split())
for r in range(N+1):
  for g in range(N+1):
    n = N-R*r-G*g
    if n >=0 and n%B==0:
      b=n/B
      print(r,g,b) 

### FIXED CODE ###

N,K = map(int,input().split())
print(N-K+1)
from math import gcd
a,b=map(int,input().split())
print(a*b//gcd(a,b))

### FIXED CODE ###

def gcd(a,b):
    if b == 0:
        return a
    elif a<b:
        return gcd(b,a)
    else:
        return gcd(b, a % b)
a,b=map(int,input().split())
print(a*b//gcd(a,b))
n,m = map(int, intput().split())
print('Yes' if n==m else 'No')

### FIXED CODE ###

n,m = map(int, input().split())
print('Yes' if n == m else 'No')
import math
a=input().split()
A=int(a[0])
B=int(a[1])
print(math.gcd(A,B))

### FIXED CODE ###

import fractions
a=input().split()
A=int(a[0])
B=int(a[1])
def lcm(x,y):
  return(x*y)//fractions.gcd(x,y)
print(lcm(A,B))
n = int(input())
a = list(map(int,input().split()))
ans = 0
while all(A%2 == 0 for A in a):
a = (i/2 for i in a )
ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = 0
while all(A%2 == 0 for A in a):
	a = [i/2 for i in a ]
	ans += 1
print(ans)