Harryxun/stf_run huggingface dataset:
import sys
N, M = map(int, input().split())
S = [0] * M
C = [0] * M
for i in range(M):
    S[i], C[i] = map(int, input().split())

for i in range(1000):
    string = str(i)
    if len(string) != N:
        continue
    flag = True
    for j in range(M):
        if string[S[j] - 1] == str(C[j]):
            None
        else:
            flag = False
            break
    if flag:
        print(i)
        sys.exit(0)
print("-1")


### FIXED CODE ###

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

if n*2>=m:
    print(m//2)
else:
    tmp=m-n*2
    print(n+tmp//4)
A,B,N = map(int,input().split())
maxn =0
if A<B:
    if B/2 <N:
        t = math.ceil(B/2)-1
        ans = tmp = math.floor((A*t)/B)-A*(math.floor(t/B))
    else:
        ans = tmp = math.floor((A*N)/B)-A*(math.floor(N/B))
else:
    for x in range(1,B+1):
        tmp = math.floor((A*x)/B)-A*(math.floor(x/B))
        if maxn < tmp:
            maxn = tmp
    ans =maxn
print(ans)

### FIXED CODE ###

import math
A,B,N = map(int,input().split())
s = min(B-1,N)
print(math.floor((A*s)/B)-A*(math.floor(s/B)))
L=input().split()
a=L[0]
b=L[1]
c=L[2]
d=L[3]
print(max(a*c,b*d,a*d,b*c))

### FIXED CODE ###

L=list(map(int,input().split()))
a=L[0]
b=L[1]
c=L[2]
d=L[3]
print(max(a*c,b*d,a*d,b*c))
n=int(input())
a=list(map(int,input().split(" ")))

a.insert(0,-1)

m=len(a)-1
res=""
k=m
if m%2==0:
    aa=0
else:
    aa=1

for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k-=2
    if k<=0:
        break

if m%2==0:
    s=1
else:
    s=2

k=s
for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k+=2
    if k>=m:
        break

print(res)

### FIXED CODE ###

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

a.insert(0,-1)

m=len(a)-1
res=""

k=m
for i in range(int(m/2)+1):
    res+=str(a[k])+" "
    k-=2
    if k<=0:
        break

if m%2==0:
    s=1
else:
    s=2

if m>1:
    k=s
    for i in range(int(m/2)+1):
        res+=str(a[k])+" "
        k+=2
        if k>=m:
            break

print(res)
n = input()
l = len(n)
n = int(n)
ans = 0


def c(l, n, ans):
    print(ans)
    a = n // (10 ** (l - 1))
    if l == 1:
        if a <= 5:
            return ans + a
        else:
            return ans + 1 + (10 - a)
    elif a == 5 and l > 1:
        if (n // (10 ** (l - 2))) % 10 <= 4:
            return c(l - 1, n % (10 ** (l - 1)), ans + a)
        else:
            return c(l, 10 ** l - n, ans + 1)
    elif a <= 4 and l > 1:
        return c(l - 1, n % (10 ** (l - 1)), ans + a)
    else:
        return c(l, 10 ** l - n, ans + 1)


print(c(l, n, ans))


### FIXED CODE ###

n = str(input())[::-1]
n = n + "0"
l = len(n)
ans = 0
flg = 0
check = 0

for i in range(l):
    check = int(n[i])
    check += flg
    if check == 5:
        if int(n[i + 1]) >= 5:
            ans += 5
            flg = 1
        else:
            ans += 5
            flg = 0
    elif check > 5:
        ans += 10 - check
        flg = 1
    else:
        ans += check
        flg = 0
print(ans + flg)
N, M = [int(a) for a in input().split()]
lol = []
for i in range(M):
  a, b = [int(a) for a in input().split()]
  found_a = -10
  found_b = -10
  for j in range(len(lol)):
    if a in lol[j]:
      found_a = j
      break
  for j in range(len(lol)):
    if b in lol[j]:
      found_b = j
      break
  
  if found_a < 0 and found_b < 0:
    lol.append([a,b])
  elif found_a >= 0 and found_b < 0:
    lol[found_a].append(b)
  elif found_b >= 0 and found_a < 0:
    lol[found_b].append(a)
    
ans = max([len(z) for z in lol])

print(ans)

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]    
      
def program():
  N, M = map(int, input().split())
  uf = UnionFind(N)
  for i in range(M):
    a, b = map(int, input().split())
    uf.union(a-1,b-1)
  
  ans = max([uf.size(i) for i in range(N)])
  return ans

print(program())
# -*- coding;utf-8 -*-

def sieve(n):
    p = 0
    primes = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if(is_prime[i]):
            primes.append(i)
            p += 1
            for j in range(i*2,n,i):#iごとに増える
                is_prime[j] = False
    return p

if(__name__ == "__main__"):
    while(True):
        try:
            n = int(input())
        except:
            break
        print(sieve(n) + "\n")

### FIXED CODE ###

# -*- coding;utf-8 -*-

def sieve(n):
    p = 0
    primes = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if(is_prime[i]):
            primes.append(i)
            p += 1
            for j in range(i*2,n+1,i):#iごとに増える
                is_prime[j] = False
    return p

if(__name__ == "__main__"):
    while(True):
        try:
            n = int(input())
        except:
            break
        print(sieve(n))
N= int(input())
L= list(map(int,input().split()))

v=[]
for i in range(N-1):
  v.append(abs(sum(L[:i+1]-L[i+1:])))

ans=min(v)

print(v)


### FIXED CODE ###

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

v=[]
for i in range(N-1):
  v.append(abs(sum(L[:i+1])-sum(L[i+1:])))

ans=min(v)

print(ans)
n = input()

if n % 2 == 1:
    print(n/2 + 1)
else:
    print(n/2)

### FIXED CODE ###

# coding: utf-8

n = input()

if n % 2 == 1:
    print(n/2 + 1)
else:
    print(n/2)
n=int(intpu())
p=list(map(int,input().split()))
ans=0
for i in range(len(p)-3):
  if p[i]<p[i+1] and p[i+1]<p[i+2] or p[i]<p[i+1] and p[i+1]<p[i+2]:
    ans=ans+1
print(ans)

### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(n-2):
  if p[i]<p[i+1] and p[i+1]<p[i+2] or p[i]>p[i+1] and p[i+1]>p[i+2]:
    ans=ans+1
print(ans)
N, M, K = input().split()
A = input().split()
B = input().split()
ta = 0
cnta = 0
while cnta < int(N) and ta + int(A[cnta]) <= int(K):
    ta += int(A[cnta])
    cnta+=1

tb = 0
cntb = 0
while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
    tb += int(B[cntb])
    cntb += 1
    
ans = cnta + cntb

while cnta >= 0:
    ta -= int(A[cnta])
    cnta -= 1
    while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
        tb += int(B[cntb])
        cntb += 1
    ans = max(ans, cnta + cntb)

print(ans)   


### FIXED CODE ###

N, M, K = input().split()
A = input().split()
B = input().split()
ta = 0
cnta = 0
while cnta < int(N) and ta + int(A[cnta]) <= int(K):
    ta += int(A[cnta])
    cnta+=1

tb = 0
cntb = 0
while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
    tb += int(B[cntb])
    cntb += 1
    
ans = cnta + cntb

while cnta - 1 >= 0:
    ta -= int(A[cnta - 1])
    cnta -= 1
    while cntb < int(M) and ta + tb + int(B[cntb]) <= int(K):
        tb += int(B[cntb])
        cntb += 1
    ans = max(ans, cnta + cntb)

print(ans)
import math
a,b,c,d=map(int, input().split())
e = round(c * d / math.gcd(c, d))

f=math.ceil(a/c) 
g=math.floor(b/c) 
h=math.ceil(a/d) 
k=math.floor(b/d) 
l=math.ceil(a/e)
m=math.floor(b/e)

if e<a:
    print(b-a+1-(g-f+1+k-h+1))
else:
    print(b-a+1-(g-f+1+k-h+1-(m-l+1)))

### FIXED CODE ###

a,b,c,d=map(int,input().split())
 
def gcd(x,y):
   if x % y == 0:
       return y
   return gcd(y, x % y)
 
CD = (c * d) // gcd(c,d)
 
h_b =b - (b // c) - (b // d) + (b // CD)
h_a = (a - 1) - (a - 1) // c - (a - 1) // d + (a - 1) // CD
 
print(h_b - h_a)
P= list(map(int(input().split()))
P.sort()
print(P[0]+P[1])

### FIXED CODE ###

P= list(map(int, input().split()))
P.sort()
print(P[0]+P[1])
K = int(input())
if(K % 2 == 0 | K % 5 == 0):
    print(-1)
N = 7
for i in range(K):
    if　N % K == 0:
        print(i + 1)
        break
    else:
        N = ((N * 10) + 7) % K

### FIXED CODE ###

K = int(input())

t = 7
for i in range(K):
    if t % K == 0:
        print(i + 1)
        break
    t = (t * 10 + 7) % K
else:
    print(-1)
n = int(input())
li = list(map(int, input().split()))
li.sort()
inf = 2*(10**5)+1
isprime = [False]*(inf)
for i in li:
    isprime[i] = [True]
for i in range(len(li)):
    if i+1<len(li):
      if li[i] == li[i+1]:
        isprime[li[i]] = False
for i in li:
    if not isprime[i]:
        continue
    for k in range(i+i, inf, i):
        isprime[k] = False
prime_list = []
for i in range(inf):
    if isprime[i]:
        prime_list.append(i)
print(len(prime_list))


### FIXED CODE ###

n = int(input())
li = list(map(int, input().split()))
li.sort()
inf = (10**6)+1
isprime = [False]*(inf+1)
for i in li:
    isprime[i] = True
temp = 0
for i in li:
    if i == temp:
        isprime[i] = False
    if not isprime[i]:
        continue
    for k in range(i*2, inf+1, i):
        isprime[k] = False
    temp = i
prime_list = []
for i in range(len(li)):
      if i+1<len(li):
            if li[i] == li[i+1]:
                isprime[li[i]] = False
for i in range(1, inf+1):
    if isprime[i]:
        prime_list.append(i)
print(len(prime_list))
A, B, T = input().split( )
print(int(T/A)*B)

### FIXED CODE ###

A, B, T = map(int, input().split())
print(int(T/A)*B)
N, K = map(int, input().split())
c = []

for _ in range(N):
    a, b= map(int, input().split())
    for i in range(b):
        c.append(a)
    if d <= len(c):
        break
        
print(sorted(c)[K-1])

### FIXED CODE ###

N, K = map(int, input().split())
num = [0]*(10**5+1)
for i in range(N):
    a, b= map(int, input().split())
    num[a] += b
for i in range(1, 10**5+1):
    if K <= num[i]:
        print(i)
        exit()
    K -= num[i]
from collections import Counter
from itertools import permutations
n=int(input())
A=[list(map(int,input().split())) for i in range(n)]
B=[(a[0]-b[0],a[1]-b[1]) for a,b in permutations(A,2)]
most=max(Counter(B).values())
print(n-most if n!=1 else 1)

### FIXED CODE ###

from collections import Counter
n=int(input())
A=[list(map(int,input().split())) for i in range(n)]
Per=[(a[0]-b[0],a[1]-b[1]) for a in A for b in A if a!=b]
print(n-Counter(Per).most_common(1)[0][1] if n!=1 else 1)
from collections import Counter
N = int(input())
A = Counter(map(int, input().split()))
B = [0, 0]
for i in A.keys():
    if A[i] >= 2:
        B.append(i)
    if A[i] >= 4:
        B.append(i)
B.sort()
print(B[-1]*B[-2])

### FIXED CODE ###

A, B, C = map(int, input().split())
print(["A", "B"][abs(A-B) > abs(A-C)])
s = input()
s[3] = '7'
print(s)

### FIXED CODE ###

s = input()
print(s[:3]+'8'+s[4:])
# -*- coding: utf-8 -*-

import fraction
from functools import reduce

N = int(input())
TN = [int(input()) for i in range(N)]

# ようは最小公倍数を出せればいいと思う
def lcm_base(x, y):
    return (x * y) // fraction.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(TN))

### FIXED CODE ###

# -*- coding: utf-8 -*-

from functools import reduce

N = int(input())
TN = [int(input()) for i in range(N)]

# ようは最小公倍数を出せればいいと思う
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(TN))
import math
isPrime = [1 for _ in range (10002)]
isPrime[:2] = [0, 0]
for i in range(2, 101):
    for j in range(i*i, 10001, i):
        isPrime[j] = 0
prime = []
for i in range(10001):
    if isPrime[i] == 1:
        prime.append(i)
while True:
    n = int(input())
    if n == 0:
        break
    cnt = 0
    for i in range(n + 1):
        sum = 0
        for j in range(i,n + 1):
            sum += prime[j]
            if sum == n:
                cnt += 1
                break
            if sum > n:
                break
    print(cnt)

        

### FIXED CODE ###

import math
isPrime = [1 for _ in range (10002)]
isPrime[:2] = [0, 0]
for i in range(2, 101):
    for j in range(i*i, 10001, i):
        isPrime[j] = 0
prime = []
for i in range(10001):
    if isPrime[i] == 1:
        prime.append(i)
while True:
    n = int(input())
    if n == 0:
        break
    cnt = 0
    for i in range(len(prime) + 1):
        sum = 0
        for j in range(i,len(prime)):
            sum += prime[j]
            if sum == n:
                cnt += 1
                break
            if sum > n:
                break
    print(cnt)
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
X = int(input())
prices = [100,101,102,103,104,105]

#
# dp = [0 for i in range(2002)]
# for price in prices:
#     dp[price] = 1
# for i in range(len(dp)):
#     for price in prices:
#         if i > price and dp[i-price] == 1:
#             dp[i] = 1
#
# if X > 2000:
#     print("1")
# else:
#     print(dp[X])



dp = [0 for i in range(X + 1)]
for price in prices:
    dp[price] = 1
for i in range(len(dp)):
    for price in prices:
        if i > price and dp[i - price] == 1:
            dp[i] = 1

print(dp[X])


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
X = int(input())
prices = [100,101,102,103,104,105]


dp = [0 for i in range(2002)]
for price in prices:
    dp[price] = 1
for i in range(len(dp)):
    for price in prices:
        if i > price and dp[i-price] == 1:
            dp[i] = 1

if X > 2000:
    print("1")
else:
    print(dp[X])
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
    
N = int(input())
Ts = [None for i in range(N)]

a = int(input())
b = 0
for i in range(N-1):
    b = int(input())
    a = (a*b) // gcd(a,b)
    
print(a)

### FIXED CODE ###

a = input()
b = []

for i in range(len(a)):
    b.insert(0, a[i])
    
if list(a) == b:
    print("Yes")
else:
    print("No")
n = int(input())
s = input().rstrip.split()
for i in (reversed(s)):
    print(s)


### FIXED CODE ###

n = int(input())
s = input().split()
s.reverse()
print(' '.join(s))
import math
print(math.factorial(int(input())%10**9+7)

### FIXED CODE ###

import math

n = int(input())
C = 10**9 + 7
print(math.factorial(n)%C)
import math
n,d=list(map(int,input().split()))
ans=0
for i in range(n):
  x,y=list(map(int,input().split()))
  if (math.sqrt((x*x)+(y*y)))//d>=1:
    ans+=1
print(ans)

### FIXED CODE ###

n,d=list(map(int,input().split()))
ans=0
for i in range(n):
  x,y=list(map(int,input().split()))
  if (x*x)+(y*y)>d*d:
    
    ans+=1
print(n-ans)
N, M = map(int, input().split(' '))
cards = N * M

if N > 1 and M > 1:
    front = (N-1)*2 + (M-1)*2
    print(cards - front)
elif N == 1 and M == 1:
    print(1)
else:
    print(max(N, M) - 2)


### FIXED CODE ###

c = [input(), input(), input()]
print(c[0][0] + c[1][1] + c[2][2])
a,b = input().split(" ")
print("error" if a+b>=10 else a+b)

### FIXED CODE ###

a,b = map(int,input().split())
print("error" if a+b>=10 else a+b)
n, m = [int(i) for i in input().split()]

def init_img(n):
    return [[0 if j == "#" else 1 for j in input()] for i in range(n)]

img = init_img(n)

tmp_img = init_img(m)

flg = False

for i in range(n):
    if flg:
        break

    for j in range(n):
        count = 0
        for k in range(m):
            if img[i+k][j:j+m] == tmp_img[k]:
                count += 1

        if count == 3:
            flg = True

if flg:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

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

def init_img(n):
    return [[0 if j == "#" else 1 for j in input()] for i in range(n)]

img = init_img(n)

tmp_img = init_img(m)

flg = False

for i in range(n):
    if flg:
        break

    if i+m > n:
        break

    for j in range(n):
        count = 0
        if j+m > n:
            break
        
        for k in range(m):
            if img[i+k][j:j+m] == tmp_img[k]:
                count += 1

        if count == m:
            flg = True

if flg:
    print("Yes")
else:
    print("No")
def main():
    S = input()[::-1]
    ans = 0
    mods = [0] * 2019
    mods[0] = 1
    current = 0
    x = 1
    for s in S:
        current = (current + x * int(s)) % 2019
        mods[current % 2019] += 1
        x = x * 10 %2019
    
    for i in len(mods):
        ans += mods[i] * (mods[i]-1)//2
print(ans)
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    S = input()[::-1]
    ans = 0
    mods = [0] * 2019
    mods[0] = 1
    current = 0
    x = 1
    for s in S:
        current = (current + x * int(s)) % 2019
        ans += mods[current % 2019]
        mods[current % 2019] += 1
        x = x * 10 % 2019
    print(ans)

if __name__ == '__main__':
    main()
str=input()
if (str[2]==str[3])&&(str[4]==str[5]):
 print("Yes")
else:
  print("No")

### FIXED CODE ###

str=input()
if str[2]==str[3] and str[4]==str[5]:
 print("Yes")
else:
 print("No")
from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

ls = {}
f = [False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    ls[a-1] = b-1
    
    if a-1 == 0 and b-1 == N-1:
        ans = "POSSIBLE"
    if a-1 == 0:
        f[a-1] = True

for m in range(M):
    if ans == "POSSIBLE":
    if f[m] and ls[m] in ls and  ls[ls[m]] == N-1 :
        ans = "POSSIBLE"

print(ans)

### FIXED CODE ###

from sys import stdin
input = stdin.readline

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

ans = "IMPOSSIBLE"

seta,setb = set(),set()
af,bf = [False]*M,[False]*M

for m in range(M):
    a,b = map(int,(input().split()))
    if a-1 == 0:
        af[m] = True
        seta.add(b-1)
    if b-1 == N-1:
        bf[m] = True
        setb.add(a-1)
    if af[m] and bf[m]:
        ans = "POSSIBLE"
        break
    
for a in seta:
    if ans == "POSSIBLE":
        break
    if a in setb:
        ans = "POSSIBLE"
        break

print(ans)
import sys
input = sys.stdin.readline
n,Q=map(int,input().split())
b_num = 2**(n-1).bit_length()
mx = 10**9
segl=[mx]*2*b_num 
def update(k, x):
    k += b_num-1
    segl[k] = x
    while k+1:
        k = (k-1)//2
        segl[k] = min(segl[k*2+1],segl[k*2+2])
if __name__ == '__main__':
    xs = []
    for i in range(n):
        s,t,x=map(int,input().split())
        xs += [(s-x,True,x,i), (t-x,False,x,i)]
    qs = []
    for _ in range(Q):
        qs.append(int(input()))
    xs.sort(key=lambda x:x[0])
    j = 0
    for x in xs:
        while True:
            if qs[j] < x[0]:
                print(segl[0] if segl[0]!= mx else -1)
                j += 1
                continue
            break
        update(x[3], x[2] if x[1] else mx)
    while Q-j:
        print(-1)
        j+=1


### FIXED CODE ###

import sys
input = sys.stdin.readline

n,Q=map(int,input().split())
b_num = 2**(n-1).bit_length()
mx = 10**9
segl=[mx]*2*b_num 

def update( k, x):
    k += b_num-1
    segl[k] = x
    while k+1:
        k = (k-1)//2
        segl[k] = min(segl[k*2+1],segl[k*2+2])
    
if __name__ == '__main__':
    xs = []
    for i in range(n):
        s,t,x=map(int,input().split())
        xs += [(s-x-0.4,True,x,i), (t-x-0.5,False,x,i)]
    for _ in range(Q):
        xs.append((int(input()),2))
    xs.sort(key=lambda x:x[0])
    for x in xs:
        if x[1]==2:
            print(segl[0] if segl[0]!= mx else -1)
            continue
        update(x[3], x[2] if x[1] else mx)
import sys
input = sys.stdin.readline

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

def sieve_optimized(limit):
    # Preprocessing step takes O(N log log N) time complexity.
    n = limit
    # Filimitd all primes upto n  (including n)
    sievebound = (n-1)//2
    sieve = [-1]*(sievebound + 1)
    # sieve[0] = True
    crosslimit = (int(sievebound**0.5) - 1)
    for i in range(1, crosslimit + 1):
        if sieve[i] == -1:
            for j in range(2*i*(i+1), sievebound + 1, 2*i+1):
                sieve[j] = 2*i + 1
    return sieve

def factorization(n, sieve):
    # Factorisaton query takes O(log N) time after preprocessing.
    divs = [1]
    while n!=1:
        if n&1:
            div = sieve[(n-1)//2]
            if div == -1:
                divs.append(n)
                break
            else:
                n //= div
                divs.append(div)
        else:
            n >>= 1
            divs.append(2)

    return divs

maxnum = 10**6
sieve = sieve_optimized(maxnum)

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

seen = dict()
for i in nums:
    factors = factorization(i, sieve)
    if len(factors) <= 1: continue
    for f in set(factors[1:]):
        if f in seen:
            seen[f] += 1
        else:
            seen[f] = 1

maxval = max(seen.values())

if maxval == n:
    print('not coprime')

elif 1 < maxval < n:
    print('setwise coprime')

else:
    print('pairwise coprime')

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

def sieve_optimized(limit):
    # Preprocessing step takes O(N log log N) time complexity.
    n = limit
    # Filimitd all primes upto n  (including n)
    sievebound = (n-1)//2
    sieve = [-1]*(sievebound + 1)
    # sieve[0] = True
    crosslimit = (int(sievebound**0.5) - 1)
    for i in range(1, crosslimit + 1):
        if sieve[i] == -1:
            for j in range(2*i*(i+1), sievebound + 1, 2*i+1):
                sieve[j] = 2*i + 1
    return sieve

def factorization(n, sieve):
    # Factorisaton query takes O(log N) time after preprocessing.
    divs = [1]
    while n!=1:
        if n&1:
            div = sieve[(n-1)//2]
            if div == -1:
                divs.append(n)
                break
            else:
                n //= div
                divs.append(div)
        else:
            n >>= 1
            divs.append(2)

    return divs

maxnum = 10**6 + 1
sieve = sieve_optimized(maxnum)

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

seen = dict()
maxval = 0
for i in nums:
    factors = factorization(i, sieve)
    if len(factors) <= 1: continue
    for f in set(factors[1:]):
        if f in seen:
            seen[f] += 1
            maxval = max(maxval, seen[f])
        else:
            seen[f] = 1


if maxval == n:
    print('not coprime')

elif 1 < maxval < n:
    print('setwise coprime')

else:
    print('pairwise coprime')
from itertools import product

H, W, K = map(int, input().split())

C = [list(input() for _ in range(H)]

ans = 0

for row_bit in product(range(2), repeat = H):
    for col_bit in product(range(2), repeat = W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == '#' and (row_bit[row] and col_bit[col]):
                    cnt += 1
            if cnt == K:
                ans += 1
print(ans)

### FIXED CODE ###

from itertools import product

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0

for row_bit in product(range(2), repeat=h):
    for col_bit in product(range(2), repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if c[row][col] == "#" and (row_bit[row] and col_bit[col]):
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)
N = int(input())
A = list(map(int, input().split()))
from functools import lru_cache
import sys
sys.setrecursionlimit(100000) 

@lru_cache(None)
def up(i,pre):
    if i == len(A) - 1:
        return abs(A[pre] - A[i])
    res1 = res2 = float("inf")
    res1 = up(i + 1,i)
    if i + 2 <=len(A) -1: 
        res2 = up(i + 2,i)
    return min(abs(A[pre] - A[i]) + res1,abs(A[pre] - A[i]) + res2)

if N > 2:
    print(min(up(1,0),up(2,0)))
else:
    print(up(1,0))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
dp = [0 for _ in range(len(A))]
dp[0] = 0 
for i in range(1,N):
    if i - 2>=0:
        dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]),dp[i-2] + abs(A[i] - A[i-2]))
    else:
        dp[i] =dp[i-1] + abs(A[i] - A[i-1])

print(dp[len(A)-1])