Harryxun/stf_run huggingface dataset:
from math import gcd #直して
n = int(input())
a = list(map(int, input().split()))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

fact = [0] * (1000001)
pri = []
for i in range(n):
    f = factorization(a[i])
    for fac, c in f:
        fact[fac] = max(fact[fac], c)

fact_list = []
for i in range(1000001):
    if fact[i] > 0:
        fact_list.append((i, fact[i]))




ans = 0
for i in range(n):
    m = modinv(a[i])
    for fac, c in fact_list:
        m *= pow(fac, c, mod)
        m %= mod

    ans += m
    ans %= mod

print(ans)


### FIXED CODE ###

from fractions import gcd #直して
n = int(input())
a = list(map(int, input().split()))

mod = 10**9+7
l = 1
for i in range(n):
    l = a[i] // gcd(l, a[i]) * l
    

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

d = 0
for i in range(n):
    d += modinv(a[i])

print((l*d) % mod)
# Quick Sort #
# 安定かどうかの判定の計算量を減らすことができなかったので，悪いことをした...
def partition(A, p, r):
    x = A[r][1]
    i = p-1
    for k in range(p, r):
        if A[k][1] <= x:
            i += 1
            A[i], A[k] = A[k], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q-1)
        quick_sort(A, q+1, r)

def bubble_sort(c, n):
    x = c[:]
    for i in range(n):
        for k in range(n-1, i, -1):
            if x[k][1] < x[k-1][1]:
                x[k], x[k-1] = x[k-1], x[k]
    return x

def is_stable(_in, out):
    n = len(_in)
    for i in range(n):
        for k in range(i+1, n):
            for a in range(n):
                for b in range(a+1, n):
                    if _in[i][1] == _in[k][1] and _in[i] == out[b] and _in[k] == out[a]:
                        return False
    return True

n = int(input())
a = []
for i in range(n):
    mrk, num = input().split()
    num = int(num)
    a.append((mrk, num))
b = a[:]
quick_sort(b, 0, n-1)
if n > 10000:
    print("Not stable")
else:
# BubbleSortは常に安定
    c = bubble_sort(a[:], n)
    if b == c:
        print("Stable")
    else:
        print("Not stable")
for i in b:
    print(*i)


### FIXED CODE ###

def bubble_sort(c, n):
    x = c[:]
    for i in range(n):
        for k in range(n-1, i, -1):
            if x[k][1] < x[k-1][1]:
                x[k], x[k-1] = x[k-1], x[k]
    return x

def selection_sort(c, n):
    x = c[:]
    for i in range(n):
        mink = i
        for k in range(i, n):
            if x[k][1] < x[mink][1]:
                mink = k
        x[i], x[mink] = x[mink], x[i]
    return x

n = int(input())
c = []
for i in list(input().split()):
    c.append((i[0], int(i[1]))) # tupleで渡す

b = bubble_sort(c, n)
print(" ".join(map(str, [i[0]+str(i[1]) for i in b])))
# bubble_sortは常に安定なソート
stable = True
print("Stable")

s = selection_sort(c, n)
print(" ".join(map(str, [i[0]+str(i[1]) for i in s])))
if b != s:
    stable = False
if stable:
    print("Stable")
else:
    print("Not stable")
# coding: utf-8
# Your code here!

k = int(input())

lunlun = []

end = False
while True:
    val = 0
    while True:
        val += 1
        val_list = [int(x) for x in list(str(val))]
        is_lun = True 
        for x in range(len(val_list) - 1):
            if abs(val_list[x] - val_list[x + 1]) <= 1:
                continue
            else:
                is_lun = False
        if is_run:
            lunlun.append(val)
        else:
            continue
        if len(lunlun) == k:
            end = True
            break
    if end:
        break

print(lunlun[k - 1])


### FIXED CODE ###

k = int(input())

nums = []
def inc(num):
    if num > 3234566667:
        return None
    if num <= 3234566667:
      nums.append(num)

    num_str = str(num)
    end = num_str[-1:]
    end_num = int(end)

    if end_num < 9:
        inc(int(num_str + str(end_num + 1)))
   
    inc(int(num_str + end))
    
    if end_num > 0:
        inc(int(num_str + str(end_num - 1)))

for i in range(1, 10):
    inc(i)

sort_nums = sorted(nums)
print(sorted(nums)[k - 1])
i=input
p=print
s=i()
p=i()
p('Yes') if (s+s).count(p) else p('No')

### FIXED CODE ###

s=input()
p=input()
print('Yes'if p in s*2 else'No')
N, K = map(int, input().split())
l = soted(map(int, input().split()))
print(sum(l[:-K]))


### FIXED CODE ###

N, K = map(int, input().split())
l = sorted(map(int, input().split()), reverse=True)
print(sum(l[:K]))
import math
n = int(input())
n1 = int(math.sqrt(n))
cnt = 10**18
for i in range(1, n1+1):
  if n % i == 0:
      j = (n/i) - 1
      ans = i-1
      cnt = min(cnt, j+ans)
  else:
    continue
print(int(cnt))

### FIXED CODE ###

a, b = map(int,input().split())
if 1 <= a <= 9 and 1<=b<=9:
  print(a*b)
else:
  print(-1)
def resolve():
    import math
    from fractions import Fraction
    mod = 10**9 + 7
    n = int(input())
    dic1 = {}
    dic1["all0"] = 0
    dic1["b0"] = 0
    dic1[Fraction(0,1)] = 0
    for i in range(n):
        a, b = map(int, input().split())
        if a == 0 and b == 0:
            dic1["all0"] += 1
        elif b == 0:
            dic1["b0"] += 1
        else:
            c = math.gcd(a,b)
            a = a//c
            b = b//c
            if Fraction(a,b) in dic1:
                dic1[Fraction(a,b)] += 1
            else:
                dic1[Fraction(a,b)] = 1

    ans = 1
    all0 = 0
    for i in dic1:
        if i == "all0":
            all0 = dic1["all0"]
            continue
        elif i == "b0":
            counter = Fraction(0, 1)
            ans *= (2 ** dic1[i] + 2 ** dic1[counter] - 1)
            ans %= mod
            dic1[i] = 0
            dic1[counter] = 0
        elif i == Fraction(0,1):
            counter = "b0"
            ans *= (2 ** dic1[i] + 2 ** dic1[counter] - 1)
            ans %= mod
            dic1[i] = 0
            dic1[counter] = 0

        elif -1 * (Fraction(1,i)) in dic1:
            counter = -1 * (Fraction(1,i))
            ans *= (2**dic1[i]+2**dic1[counter]-1)
            ans %= mod
            dic1[i] = 0
            dic1[counter] = 0
        else:
            ans *= (dic1[i]+1)
            ans %= mod
    ans += all0
    print(ans%mod-1)
resolve()



### FIXED CODE ###

def resolve():
    n = int(input())
    n = n%10
    if n == 3:
        print("bon")
    elif n == 0 or n == 1 or n == 6 or n == 8:
        print("pon")
    else:
        print("hon")
resolve()
#082_D
s = input()
x, y = map(int, input().split())
xgo, ygo = [], []

flg = True
cnt = 0
for i in range(len(s)):
    if s[i] == 'T':
        if flg and cnt > 0:
            xgo.append(cnt)
        elif cnt > 0:
            ygo.append(cnt)
        flg = (flg + 1) % 2
        cnt = 0
    else:
        cnt += 1
        
if flg and cnt > 0:
    xgo.append(cnt)
elif cnt > 0:
    ygo.append(cnt)
    
def search(L, x):
    dp = [[False for _ in range(20000)] for _ in range(len(L)+1)]
    dp[0][10000] = True
    
    for i in range(1, len(L)+1):
        for j in range(-sum(L), sum(L)+1):
            k = j + 10000
            if dp[i-1][k-L[i-1]]:
                dp[i][k] = True
            if dp[i-1][k+L[i-1]]:
                dp[i][k] = True

    return dp[len(L)][10000+x]

print('Yes' if search(xgo, x) and search(ygo, y) else 'No')

### FIXED CODE ###

#082_D
s = input()
x, y = map(int, input().split())
xgo, ygo = [], []

cnt = 0
flg = True
check = True if s[0] == 'F' else False
for i in range(len(s)):
    if s[i] == 'T':
        if flg and cnt > 0:
            xgo.append(cnt)
        elif cnt > 0:
            ygo.append(cnt)
        cnt = 0
        flg = (flg + 1) % 2
    else:
        cnt += 1

if flg and cnt > 0:
    xgo.append(cnt)
elif cnt > 0:
    ygo.append(cnt)

flg1, flg2 = len(xgo)==0, len(ygo)==0

sum_x, sum_y = sum(xgo), sum(ygo)
dp1 = [[False for _ in range(2*sum_x+1)] for _ in range(len(xgo)+1)]
dp2 = [[False for _ in range(2*sum_y+1)] for _ in range(len(ygo)+1)]

if check:
    dp1[1][sum_x+xgo[0]] = True
    for i in range(2, len(xgo)+1):
        for j in range(-sum_x, sum_x+1):
            if 0 <= j+sum_x-xgo[i-1] <= 2*sum_x:
                if dp1[i-1][j+sum_x-xgo[i-1]]:
                    dp1[i][j+sum_x] = True
            if 0 <= j+sum_x+xgo[i-1] <= 2*sum_x:
                if dp1[i-1][j+sum_x+xgo[i-1]]:
                    dp1[i][j+sum_x] = True
else:
    dp1[0][sum_x] = True
    for i in range(1, len(xgo)+1):
        for j in range(-sum_x, sum_x+1):
            if 0 <= j+sum_x-xgo[i-1] <= 2*sum_x:
                if dp1[i-1][j+sum_x-xgo[i-1]]:
                    dp1[i][j+sum_x] = True
            if 0 <= j+sum_x+xgo[i-1] <= 2*sum_x:
                if dp1[i-1][j+sum_x+xgo[i-1]]:
                    dp1[i][j+sum_x] = True

dp2[0][sum_y] = True
for i in range(1, len(ygo)+1):
    for j in range(-sum_y, sum_y+1):
        if 0 <= j+sum_y-ygo[i-1] <= 2*sum_y:
            if dp2[i-1][j+sum_y-ygo[i-1]]:
                dp2[i][j+sum_y] = True
        if 0 <= j+sum_y+ygo[i-1] <= 2*sum_y:
            if dp2[i-1][j+sum_y+ygo[i-1]]:
                dp2[i][j+sum_y] = True
                
if flg1:
    flgx = (x == 0)
elif abs(x) > sum_x:
    flgx = False
else:
    flgx = dp1[len(xgo)][sum_x+x]
    
if flg2:
    flgy = (y == 0)
elif abs(y) >sum_y:
    flgy = False
else:
    flgy = dp2[len(ygo)][sum_y+y]
    
print('Yes' if flgx and flgy else 'No')
n = int(input())
x=[]
y=[]
h=[]
for i in range(0,n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)



for i in range(0,101):
    for j in range(0,101):
        tmph=0
        flag = True
        for k in range(0,n):
            if tmph == 0 and h[k] != 0:
                tmph=abs(x[0]-i)+abs(y[0]-j)+h[0]
            calch = abs(x[k]-i)+abs(y[k]-j)+h[k]
            if tmph != calch and h[k] != 0:
                flag = False
                break
        if flag == False:
            continue
        else:
            ansx=i
            ansy=j
            ansh=tmph

print(ansx,ansy,ansh)


        


### FIXED CODE ###

n = int(input())
x=[]
y=[]
h=[]
for i in range(0,n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
 
 
 
for i in range(0,101):
    for j in range(0,101):
        tmph=0
        flag = True
        for k in range(0,n):
            if tmph == 0 and h[k] != 0:
                tmph=abs(x[k]-i)+abs(y[k]-j)+h[k]
                break
        for k in range(0,n):
            calch = tmph - abs(x[k]-i)-abs(y[k]-j)
            if h[k] != max(calch,0):
                flag = False
                break
        if flag == False:
            continue
        elif tmph == 0:
            flag2 = True
            for c in range(0,101):
                if i == x[c] and j == y[c]:
                    flag2 = False
                    break
            if flag2:
                ansx = i
                ansy = j
                ansh = 1
        else:
            ansx=i
            ansy=j
            ansh=tmph
 
print(ansx,ansy,ansh)
n=int(input())
p,m=[],[]
z=0
for i in list(map(int,input().split())):
    if i<0:m.append(i)
    elif i==0:
        z+=1
    else:p.append(i)
if p and m:
    print(sum(p)-sum(m))
    if z:
        for h in range(z-1):
            print("0 0")
        now=0
    else:now=p.pop()
    for j in m[1:]:
        print(now,j)
        now-=j
    print(m[0],now)
    now=-now+m[0]
    for j in p[1:]:
        print(now,j)
        now-=j
    print(p[0],now)
elif p:
    if z:
        print(sum(p))
        for h in  range(z-1):
            print("0 0")
        now=0
        f=p.pop()
        for i in p:
            print(now,i)
            now-=i
        print(f,now)
    else:
        print(sum(p)-2*min(p))
        p.sort()
        now=p[0]
        k=p.pop()
        for j in p[1:]:
            print(now,j)
            now-=j
        print(k,now)
else:
    if z:
        print(-sum(m))
        for h in  range(z-1):
            print("0 0")
        now=0
    else:
        m.sort()
        print(-sum(m)+2*max(m))
        now=m.pop()
    for i in p:
        print(now,i)
        now-=i



### FIXED CODE ###

n=int(input())
p,m=[],[]
z=0
for i in list(map(int,input().split())):
    if i<0:m.append(i)
    elif i==0:
        z+=1
    else:p.append(i)
if p and m:
    print(sum(p)-sum(m))
    if z:
        for h in range(z-1):
            print("0 0")
        now=0
    else:now=p.pop()
    for j in m[1:]:
        print(now,j)
        now-=j
    if p:
        print(m[0],now)
        now=-now+m[0]
        for j in p[1:]:
            print(now,j)
            now-=j
        print(p[0],now)
    else:
        print(now,m[0])
elif p:
    if z:
        print(sum(p))
        for h in  range(z-1):
            print("0 0")
        now=0
        f=p.pop()
        for i in p:
            print(now,i)
            now-=i
        print(f,now)
    else:
        print(sum(p)-2*min(p))
        p.sort()
        now=p[0]
        k=p.pop()
        for j in p[1:]:
            print(now,j)
            now-=j
        print(k,now)
else:
    if z:
        print(-sum(m))
        for h in  range(z-1):
            print("0 0")
        now=0
    else:
        m.sort()
        print(-sum(m)+2*max(m))
        now=m.pop()
    for i in m:
        print(now,i)
        now-=i
alp=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
s=list(input())
s_ = list(set(s))
#print(s)
#print(s_)
s.sort()
s_.sort()
#print(s)
#print(s_)
        
l=[]
cnt=0
for i in range(len(alp)):
            if s.count(alp[i]):a
                        pass
            else:
                        l.append(alp[i])
                        cnt+=1
#print(l)
if cnt==0:
            print('None')
else:
            print(min(l))
exit()


### FIXED CODE ###

alp=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
s=list(input())
s_ = list(set(s))
#print(s)
#print(s_)
s.sort()
s_.sort()
#print(s)
#print(s_)
        
l=[]
cnt=0
for i in range(len(alp)):
            if s.count(alp[i]):
                        pass
            else:
                        l.append(alp[i])
                        cnt+=1
#print(l)
if cnt==0:
            print('None')
else:
            print(min(l))
exit()
nums = [int(e) for e in input().split()]
for i in range(len(nums)):
    for j in range(i):
        if nums[i]<nums[j]:
            a = nums[i]
            nums[i] = nums[j]
            nums[j] = a

nums_2 = " ".join(nums)
print(nums_2)


### FIXED CODE ###

nums = [int(e) for e in input().split()]
for i in range(len(nums)):
    for j in range(i):
        if nums[i]<nums[j]:
            a = nums[i]
            nums[i] = nums[j]
            nums[j] = a

nums_2 = " ".join(map(str, nums))
print(nums_2)
def main():
    n, r = map(int, input().split())
    if n >= 10:
        print(r)
    else:
        print(100 * (10 - k))


if __name__ == "__main__":
    main()


### FIXED CODE ###


def main():
    n, r = map(int, input().split())
    if n >= 10:
        print(r)
    else:
        print(r + (100 * (10 - n)))


if __name__ == "__main__":
    main()
a, b = map(int, input().split(" "))
ans = upper((a + b)/2)
print(ans)

### FIXED CODE ###

import math

a, b = map(int, input().split(" "))
ans = math.ceil((a + b)/2)
print(ans)
N = int(input())
A = [input() for i in range(N)]
maxA = max(A)
secA = sorted(set(A))[-2]
num=A.count(maxA)
#print(N,A,maxA,secA,num)

for i in range(N):
  if num>1:
    print(maxA)
  elif A[i]==maxA:
    print(secA)
  else:
    print(maxA)

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
maxA = max(A)
secA = sorted(A)[-2]
num=A.count(maxA)
#print(N,A,maxA,secA,num)
 
for i in range(N):
  if num>1:print(maxA)
  elif A[i]==maxA:print(secA)
  else:print(maxA)
N = int(input())
P = list(map(int, input().split()))

ans=0
p_min=S[0]
for i in range(N):
    if p_min >= P[i]:
        ans++
        p_min = P[i]

print(ans)


### FIXED CODE ###

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

ans=0
p_min=P[0]
for i in range(N):
    if p_min >= P[i]:
        ans += 1
        p_min = P[i]

print(ans)
h, n = map(int, input().split())
a = []
b = []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)

dp = [float("inf")] * (2 * h + 1)
dp[0] = 0
for i in range(h):
    for j in range(n):
        dp[i + a[j]] = min(dp[i + a[j]], dp[i] + b[j])

ans = float('inf')
for j in range(h, 2 * h + 1):
    ans = min(ans, dp[j])
print(ans)

### FIXED CODE ###

h, n = map(int, input().split())
a = []
b = []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)

dp = [float("inf")] * (2 * 10000 + 1)
dp[0] = 0
for i in range(h):
    for j in range(n):
        if (i + a[j]) > 2 * 10000:
            dp[2 * 10000] = min(dp[2 * 10000], dp[i] + b[j])
            continue
        dp[i + a[j]] = min(dp[i + a[j]], dp[i] + b[j])

ans = float('inf')
for j in range(h, 2 * 10000 + 1):
    ans = min(ans, dp[j])
print(ans)
H, W = map(int, input().split())
S = []
S.append('.' * (H + 2))
S.extend(['.' + input() + '.' for _ in range(H)])
S.append('.' * (H + 2))

for y in range(1, H + 1):
    for x in range(1, W + 1):
        if S[y][x] == '#' and \
        set([S[y - 1][x], S[y + 1][x], S[y][x - 1], S[y][x + 1]]) == set('.'):
            print("No")
            quit()
print("Yes")


### FIXED CODE ###

H, W = map(int, input().split())
S = []
S.append('.' * (W + 2))
S.extend(['.' + input() + '.' for _ in range(H)])
S.append('.' * (W + 2))

if ''.join(S).count('#') <= 1:
    print("Yes")
    quit()

for y in range(1, H + 1):
    for x in range(1, W + 1):
        if S[y][x] == '#' and set([S[y - 1][x], S[y + 1][x], S[y][x - 1], S[y][x + 1]]) == set('.'):
            print("No")
            quit()
print("Yes")
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
b.reverse()
c.reverse()
pat=0
keepi,keepj=-1,-1
for x in range(n):
  i=a[x]
  if(i!=keepi):
    keepi=i
    patj=0
  else:
    pat+=patj
    continue
  for y in range(n):
    j=b[y]
    if(j!=keepj):
        keepj=j
    else:
        patj+=patk
        continue
    if(j<=i):break
    br=0
    for k in range(n):
      if(c[k]<=j):
        #print(i,j,c[k],k)
        patk=k
        br=1
        break
    if(br==0):patk=n
    patj+=patk
  pat+=patj
print(pat)

### FIXED CODE ###

import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
#print(a)
#print(b)
#print(c)
pat=0
ikeep=-1
for i in range(n):
  x=b[i]
  if(x!=ikeep):
    ikeep=x
  else:
    pat+=paty*patz
    continue
  paty=bisect.bisect_left(a,x)
  patz=n-bisect.bisect_right(c,x)
  #print(paty,patz)
  pat+=paty*patz
print(pat)
#138-e
from collections import defaultdict
import bisect

s = input()
t = input()
n = len(s)
m = len(t)

ans=0
pos=-1

d = defaultdict(list)
for i in range(n):
    if s[i] in t:
        d[s[i]].append(i)
        
for i in range(n):
    if s[i] in t:
        d[s[i]].append(i+n)
        
for v in t:
    l = d[v]
    ind = bisect.bisect_right(l, pos)
    ans += l[ind]-pos
    if l:
        if l[ind]<n:
            pos = l[ind]
        else:
            pos = l[ind] - n
    else:
        ans = -1
        break
        
print(ans)
        



### FIXED CODE ###

from collections import defaultdict
import bisect

s = input()
t = input()

n = len(s)
m = len(t)

d = defaultdict(list)

for i,c in enumerate(s):
    if c in t:
        d[c].append(i)

for i,c in enumerate(s):
    if c in t:
        d[c].append(i+n)

pos = -1
ans = 0

for c in t:
    l = d[c]
    if l:
        ind = bisect.bisect_right(l, pos)
        ans += l[ind]-pos
        if l[ind] >= n:
            pos = l[ind] - n
        else:
            pos = l[ind]    
    else:
        ans = -1
        break

print(ans)
_ = input()
print(f"{(1 / sum(1 / x for x in map(int, input().split()))):.16g}")

### FIXED CODE ###

_ = input()
print("{:.16g}".format(1 / sum(1 / x for x in map(int, input().split()))))
class dfs():
    
    def __init__(self, n, el):
        self.n = n
        self.el = el

        self.evenl = [1 for i in range(n)]
        self.neibors = dict([(i,[[],[]]) for i in range(n)])


    def calc(self, nf, used):
        used.append( nf )
        for node in set( self.neibors[nf][0] ) - set(used) :
            if self.evenl[nf] == 1:
                self.evenl[node] = 1
            else:
                self.evenl[node] = 0

            self.calc(node, used)

        for node in set( self.neibors[nf][1] ) - set(used) :
            if self.evenl[nf] == 1:
                self.evenl[node] = 0
            else:
                self.evenl[node] = 1

            self.calc(node, used)


    def set_neibors(self):
        for e in self.el:
            u,v,w = e
            if w % 2 == 0:
                self.neibors[u-1][0].append(v-1)
                self.neibors[v-1][0].append(u-1)
            else:
                self.neibors[u-1][1].append(v-1)
                self.neibors[v-1][1].append(u-1)

n = int(input())
el = []
for i in range(n-1):
    u,v,w = map( int, input().split() )
    el.append( (u,v,w) )    

m = dfs(n,el)
m.set_neibors()
m.calc(0, [])

for item in m.evenl:
    print(item)

### FIXED CODE ###

from collections import deque

n = int(input())
neibors = [[] for i in range(n)]
for i in range(n-1):
    u,v,w = map( int, input().split() )
    neibors[u-1].append( (v-1,w%2) )
    neibors[v-1].append( (u-1,w%2) )

dist = [-1 for i in range(n)]
stack = deque([0])
while( len(stack) != 0 ):
    current = stack.popleft()
    current_dist = dist[current]

    for neibor_n, neibor_w in neibors[current]:
        if dist[neibor_n] == -1:
            stack.append( neibor_n )
            dist[neibor_n] = (neibor_w + current_dist) % 2  

for item in dist:
    print(item)
print((int(input()) - 2) / (int(input()) - 1) + 1)

### FIXED CODE ###

[print(int((n[0] - 2) / (n[1] - 1) + 1)) for n in [list(map(int, input().split()))]]
import numoy as np
N,M = list(map(int,input().split()))
A = input().split()


count = 0
A = np.array(A,dtype='int64')
B = np.cumsum(A)
C = np.append([0],B)

L = (1 for i in range(N+1) for t in range(N+1) if i<t and (C[t] - C[i])%M==0)
print(len(list(L)))

### FIXED CODE ###

import collections
import numpy as np

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

A = np.array(A,dtype='int64')
C = np.append([0],np.cumsum(A))
L = [i%M for i in C]
L_c = collections.Counter(L)

ans = 0
for i in L_c.values():
    S = i * (i-1) / 2
    ans+=S
    
print(int(ans))
a,b = map(int, input().split())

if (a + b) % 2 != 0:
  print("IMPOSSIBLE")
else:
  print(abs((b**2-a**2)/2(a+b)))
  

### FIXED CODE ###

a,b = map(int, input().split())
 
if (a + b) % 2 != 0:
    print("IMPOSSIBLE")
else:
    print(abs(a+b)//2)