Harryxun/stf_run huggingface dataset:
import numpy as np
from scipy.sparse.csgraph import floyd_warshall, dijkstra



n = int(input())
matrix = np.zeros((n, n),dtype=np.int64)
for i in range(n-1):
    a, b, c = map(int, input().split())
    matrix[a-1][b-1] = c
    matrix[b-1][a-1] = c
min_span_matrix = dijkstra(matrix, directed=False,
                                 return_predecessors=False)
q, k = map(int, input().split())
for i in range(q):
    x, y = map(int, input().split())
    print(int(min_span_matrix[x-1][k-1] + min_span_matrix[k-1][y-1]))


### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)


n = int(input())
query = [[] for i in range(n)]
for i in range(n-1):
    a, b, c = map(int, input().split())
    query[a-1].append((b-1, c))
    query[b-1].append((a-1, c))
q, k = map(int, input().split())
stack = deque([(k-1, 0, -1)])
dist = [0] * n
while stack:
    now, cnt, per = stack.pop()
    lis = query[now]
    dist[now] = cnt
    for nx, c in lis:
        if nx == per:
            continue
        if c != 0:
            stack.append((nx, cnt+c, now))
for i in range(q):
    x, y = map(int, input().split())
    print(dist[x-1] + dist[y-1])
a,b = map(int,input().split())

n = list(map(int,input().split()))
nnn = [pow(2,i) for i in range(45)]
n.sort()
n.reverse()
kkk = len(str(bin(n[0]))) - 2
k = [[0,0] for i in range(kkk)]
nn = 1
co = 0
su = 0
for i in range(kkk):
	for j in range(a):
		if n[j] & nn > 0:
			k[i][1] += 1
		else:
			k[i][0] += 1
	nn *= 2
if nn != 1:
	nn //= 2
for i in range(kkk):
	if k[kkk-1-i][0] => k[kkk-1-i][1]:
		if su + pow(2,kkk-1-i) <= b:
			su += pow(2,kkk-1-i)
if su < b:
	nn *= 2
	while True:
		if su + nn > b:
			break
		else:
			co += nn*a
			nn *= 2
for i in range(a):
	co += su ^ n[i]
print(co)


### FIXED CODE ###

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

fm = 0
for i in range(40,0,-1):
    x = 2**(i-1)
    p = 0
    q = 0
    for j in a:
        b = x & j
        p += x ^ b
        q += b
    if q >= p:
        fm += q
    else:
        if m >= x:
            fm += p
            m -= x
        else:
            fm += q
print(fm)
N, K = map(int, input().split())
N = (N - K)
container = []
result = 0
for i in range(int(N)):
    result = abs(i - N)
    container.append(result)
print(min(container))

### FIXED CODE ###

n, k = map(int, input().split())
if n==0 or k==1:
    print(0)
    exit()
elif n<k:
    print(min(n, abs(n-k)))
    exit()
elif n % k == 0:
    print(0)
    exit()
else:
    mx = n%k
print(min(abs(mx-k), mx))
import math

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

# A, B の正の公約数から互いに素となる組み合わせを選ぶとき、最大でいくつ選べる？
# 最大公約数を求める
gcd = math.gcd(A, B)


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


# 最大公約数を素因数分解する
f = factorization(gcd)
# 1のケースでは1を出力する
if f == [[1, 1]]:
    print(1)
else:
    # 要素数＋１が選択可能な個数
    ans = len(f) + 1
    print(ans)

### FIXED CODE ###

import fractions

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

# A, B の正の公約数から互いに素となる組み合わせを選ぶとき、最大でいくつ選べる？
# 最大公約数を求める
gcd = fractions.gcd(A, B)


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


# 最大公約数を素因数分解する
f = factorization(gcd)
# 1のケースのみ1を出力する
if f == [[1, 1]]:
    print(1)
else:
    # 要素数＋１が選択可能な個数
    ans = len(f) + 1
    print(ans)
N,M=map(int,input().split())
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
    a,b=map(int,input().split())
    branch[a]|={b}
    branch[b]|={a}
jisuu=[len(branch[i]) for i in range(N+1)]
path=[0]
if jisuu.count(1)>=2:
    start=jisuu.index(1)
    visited={start}
    check=[[start]]
    while len(check)>0:
        c=check.pop()
        now=c[-1]
        for nex in branch[now]:
            if nex not in visited:
                if jisuu[nex]==1:
                    path=c+[nex]
                    check=[]
                    break
                else:
                    check.append(c+[nex])
                    visited|={nex}
else:
    for i in range(1,1+N):
        if jisuu[i]==2:
            a,b=list(branch[i])
            if jisuu[a]==2:
                start=i
                goal=a
                nex=b
                break
            elif jisuu[b]==2:
                start=i
                goal=b
                nex=a
                break
    visited={start,nex}
    check=[[start,nex]]
    while len(check)>0:
        c=check.pop()
        now=c[-1]
        for nex in  branch[now]:
            if nex not in visited:
                if nex==goal:
                    path=c+[nex]
                    check=[]
                    break
                else:
                    check.append(c+[nex])
                    visited|={nex}
print(len(path))
print(" ".join(map(str,path)))

### FIXED CODE ###

N,M=map(int,input().split())
from collections import deque,defaultdict
branch=defaultdict(set)
for i in range(M):
    a,b=map(int,input().split())
    branch[a-1]|={b-1}
    branch[b-1]|={a-1}
path=deque([0])
for x in branch[0]:
    path.append(x)
    break
used=set(path)
while True:
    A,B=False,False
    if len(branch[path[0]]-used)==0:
        A=True
    else:
        for x in branch[path[0]]:
            if x in used:
                continue
            path.appendleft(x)
            used|={x}
            break
    if len(branch[path[-1]]-used)==0:
        B=True
    else:
        for x in branch[path[-1]]:
            if x in used:
                continue
            path.append(x)
            used|={x}
            break
    if A and B:
        break
path=[p+1 for p in path]
print(len(path))
print(" ".join(map(str,path)))
ans = 0

for i in range(N-1):
    for j in range(i+1, N):
        print(i, j)
        ans += ((A[i]% (10**9 + 7))*(A[j]% (10**9 + 7))) % (10**9 + 7)
        
print(ans % (10**9 + 7))

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
S = []
e = 0
for i in A:
    e += i
    S.append(e)
    
ans = 0
for i in range(N-1):
    ans += A[i]%(10**9+7)*((S[N-1] - S[i])%(10**9+7))
    
print(ans%(10**9+7))
A, B, C, K = map( int, input().split())

l = [1] * A
l += [0] * B
l += [-1] * C

print( sum(l[:K]) )

### FIXED CODE ###

A, B, C, K = map( int, input().split())
ret = min( A, K )
if A < K:
  ret -= max( 0, K - A - B )
print( ret )
import math
import sys
sys.setrecursionlimit(100000)

a, b = map(int, input().split())
gcd = math.gcd(a, b)
if gcd <= 0:
    print(0)
else:
    result = int(a*b / gcd)
    print(result)


### FIXED CODE ###

from fractions import gcd
import sys
sys.setrecursionlimit(100000)

a, b = map(int, input().split())
gcd = gcd(a, b)
if gcd <= 0:
    print(0)
else:
    result = int(a*b / gcd)
    print(result)
n, k = input().split()
a = input().split()

n = int(n)

for i in range(10000-n):
    c = str(n+i)
    
    for j in a:
        if j in c:
            break
    
    else:
        ans = c
        break
        
print(ans)

### FIXED CODE ###

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

for i in range(10*n - n):
    c = str(n+i)
    
    for j in a:
        if j in c:
            break
    
    else:
        ans = c
        break
        
print(ans)
from itertools import combinations
 
x1 = int(input())
x2 = input()
RGB = {"R", "G", "B"}

peint(sum([1 for i, rgb in zip(combinations(range(x1), 3), combinations(x2, 3)) if set(rgb) == RGB and (i[1] - i[0]) != (i[2] - i[1])]))

### FIXED CODE ###

import math
from itertools import product
 
x = int(input())

s = 0
for a, b, c in product(range(1, x+1), repeat=3):
  s += math.gcd(math.gcd(a, b), c)
print(s)
fact_list=[None]*300001
inv_fact_list=[None]*300001
fact_list[0]=1
inv_fact_list[0]=1
def inv(n):
    if inv_fact_list[n]!=None:
        return inv_fact_list[n]
    s=1
    for i in range(30):
        if i!=23 and i!=26:
            s=(s*n)%998244353
        n=(n**2)%998244353
    inv_fact_list[n]=s
    return s

def comb(n,r):
    if r==0 or r==n:
        return 1
    if r==1 or r==n-1:
        return n
    return (((fact_list[n]*inv(fact_list[n-r]))%998244353)*inv(fact_list[r]))%998244353

for i in range(1,300001):
    fact_list[i]=(fact_list[i-1]*i)%998244353

s=input().split()
n,a,b,k=int(s[0]),int(s[1]),int(s[2]),int(s[3])
res=0
for i in range(n+1):
    if k-a*i<0:
        break
    if (k-a*i)%b==0 and 0<=(k-a*i)//b<=n:
        res=(res+comb(n,i)*comb(n,(k-a*i)//b))%998244353
print(res)

"""
def enc(n):
    if n==0:
        return "("
    s=""
    while n>0:
        s+=chr(n%86+40)
        n//=86
    return s

def dec(s):
    n=0
    for i in range(len(s)):
        n+=(86**i)*(ord(s[i])-40)
    return n
"""

### FIXED CODE ###

fact_list=[None]*300001
inv_fact_list=[None]*300001
fact_list[0]=1
inv_fact_list[0]=1
"""
def inv(n):
    if inv_fact_list[n]!=None:
        return inv_fact_list[n]
    m=fact_list[n]
    s=1
    for i in range(30):
        if i!=23 and i!=26:
            s=(s*m)%998244353
        m=(m**2)%998244353
    inv_fact_list[n]=s
    return s
def enc(n):
    if n==0:
        return "("
    s=""
    while n>0:
        s+=chr(n%86+40)
        n//=86
    return s
 
def dec(s):
    n=0
    for i in range(len(s)):
        n+=(86**i)*(ord(s[i])-40)
    return n
"""
def comb(n,r):
    if r==0 or r==n:
        return 1
    if r==1 or r==n-1:
        return n
    if inv_fact_list[n-r]!=None:
        invnr=inv_fact_list[n-r]
    else:
        m=fact_list[n-r]
        invnr=1
        for i in range(30):
            if i!=23 and i!=26:
                invnr=(invnr*m)%998244353
            m=(m**2)%998244353
        inv_fact_list[n-r]=invnr
    if inv_fact_list[r]!=None:
        invr=inv_fact_list[r]
    else:
        m=fact_list[r]
        invr=1
        for i in range(30):
            if i!=23 and i!=26:
                invr=(invr*m)%998244353
            m=(m**2)%998244353
        inv_fact_list[r]=invr
    return (((fact_list[n]*invnr)%998244353)*invr)%998244353
 
for i in range(1,300001):
    fact_list[i]=(fact_list[i-1]*i)%998244353
 
s=input().split()
n,a,b,k=int(s[0]),int(s[1]),int(s[2]),int(s[3])
res=0
for i in range(n+1):
    if k-a*i<0:
        break
    if (k-a*i)%b==0 and 0<=(k-a*i)//b<=n:
        res=(res+comb(n,i)*comb(n,(k-a*i)//b))%998244353
print(res)
def su(c):
  if c == 1:
    return 1
  else:
    return c + su(c - 1)

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

c = b - a

east = su(c)

print(east - b)

### FIXED CODE ###

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

c = b - a

east = (1 + c) * c // 2

print(east - b)
n = input().replace(" ","")

print(['No','Yes'][is_square_num(n)])



def is_square_num(n):
    
    mod256 = [
        0, 1, 4, 9, 16, 17, 25, 33, 36, 41,
        49, 57, 64, 65, 68, 73, 81, 89, 97, 100,
        105, 113, 121, 129, 132, 137, 144, 145, 153, 161,
        164, 169, 177, 185, 193, 196, 201, 209, 217, 225,
        228, 233, 241, 249 ]

    mod100 = [
        0, 1, 4, 9, 16, 21, 24, 25, 29, 36, 41, 44, 49, 56, 61, 64, 69, 76, 81, 84, 89, 96
    ]
    if not n % 256 in mod256:
        return False
    
    if not n % 100 in mod100:
        return False

    import math
    x = math.sqrt(n)

    # import numpy
    # x = numpy.sqrt(n)
    
    return x.is_integer()



### FIXED CODE ###



def is_square_num(n):
    
    mod256 = [
        0, 1, 4, 9, 16, 17, 25, 33, 36, 41,
        49, 57, 64, 65, 68, 73, 81, 89, 97, 100,
        105, 113, 121, 129, 132, 137, 144, 145, 153, 161,
        164, 169, 177, 185, 193, 196, 201, 209, 217, 225,
        228, 233, 241, 249 ]

    mod100 = [
        0, 1, 4, 9, 16, 21, 24, 25, 29, 36, 41, 44, 49, 56, 61, 64, 69, 76, 81, 84, 89, 96
    ]
    if not n % 256 in mod256:
        return False
    
    if not n % 100 in mod100:
        return False

    import math
    x = math.sqrt(n)

    # import numpy
    # x = numpy.sqrt(n)
    
    return x.is_integer()


n = input().replace(" ","")

print(['No','Yes'][is_square_num(int(n))])
import sys

n, q = map(int, input().split())
sys.setrecursionlimit(n)

adj_list = [[] for _ in range(n + 1)]

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

val = [0] * (n + 1)
visited = [False] * (n + 1)

for i in range(q):
    p, x = map(int, input().split())
    val[p] += x


def dfs(val, adj_list, visited, cur, prev):
    if prev != -1:
        val[cur] += val[prev]

    visited[cur] = True

    for next in adj_list[cur]:
        if visited[next] is False:
            dfs(val, adj_list, visited, next, cur)


dfs(val, adj_list, visited, 1, -1)

for i in range(n):
    print(val[i + 1], end="")
    if i != n - 1:
        print(" ", end="")
    else:
        print()


### FIXED CODE ###

from collections import deque

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

adj_list = [[] for _ in range(n + 1)]
val = [0] * (n + 1)
visited = [False] * (n + 1)

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

for i in range(q):
    p, x = map(int, input().split())
    val[p] += x

dq = deque()
prev = -1
cur = 1
dq.append([cur, prev])

while len(dq) > 0:

    cur, prev = dq.popleft()
    if prev != -1:
        val[cur] += val[prev]
    visited[cur] = True

    for next in adj_list[cur]:
        if visited[next] is False:
            dq.append([next, cur])

print(*val[1:])
if N/K==1:
    print(0)
else:
    print(int(N/K)+1-int(N/K))

### FIXED CODE ###

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

if N%K==0:
    print(0)
else:
    print(int(N/K)+1-int(N/K))
a,b,k=map(int,input().split())
s=range(a,b+1)
for i in sorted(set(s[:k])|set(a[:-k])):
    print(i)


### FIXED CODE ###

a,b,k=map(int,input().split())
s=range(a,b+1)
for i in sorted(set(s[:k]) | set(s[-k:])):
    print(i)
a, b = map(int, raw_input(). split())
return a * b, 2 * (a + b)

### FIXED CODE ###

a, b = map(int, raw_input(). split())
print a * b, 2 * (a + b)
n = int(input())
l = []
for _ in range(n):
	l.append(int(input()))
list(set(l.sorted()))
print(len(l))

### FIXED CODE ###

n = int(input())
l = []
for _ in range(n):
	l.append(int(input()))
print(len(list(set(l))))
import bisect
def f(x,a):
  b = bisect.bisect_left(a,x)
  return True if x==a[b] else False
MOD = 10**9+7
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]
a.sort()
x = 0
y = 1
for i in range(N):
  if f(i,a) and f(i+1,a):
    print(0)
    exit()
  elif f(i+1,a):
    z = 0
  else:
    z = x + y
  x = y
  y = z
print(z%MOD)


### FIXED CODE ###

import bisect
def f(x,a):
  global M
  b = bisect.bisect_left(a,x)
  if x==a[min(b,M)]:
    return True
  else:
    return False
MOD = 10**9+7
N,M = map(int,input().split())
a = [-1]+[int(input()) for _ in range(M)]
a.sort()
x = 0
y = 1
for i in range(N):
  if f(i,a) and f(i+1,a):
    print(0)
    exit()
  elif f(i+1,a):
    z = 0
  else:
    z = x + y
  x = y
  y = z
print(z%MOD)
L,R = map(int, input().split())
MIN = R*2
for i in range(L,R):
    for j in range(i+1, R+1):
        mod = ij % 2019

        if MIN > mod:
            MIN = mod
 
print(MIN)

### FIXED CODE ###

N,A,B = map(int, input().split())
if N*A >= B:
    print(B)
else:
    print(N*A)
N = int(input())
d = list(map(int, input().split()))

d.sort()

left = d[int(N/2)]
right = d[int(N/2) +1]

dif = right - left

print(dif)

### FIXED CODE ###

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

d.sort()
left = d[int(N/2-1)]
right = d[int(N/2)]

dif = right - left

print(dif)
a = list(map(int, input().split()))
if (4 * a[0] - a[1]) % 2 == 0 and 2 * t >= (4 * a[0] - a[1]) >= 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a = list(map(int, input().split()))
if (4 * a[0] - a[1]) % 2 == 0 and 2 * a[0] >= (4 * a[0] - a[1]) >= 0:
    print('Yes')
else:
    print('No')
n = int(input())
d = {'0': 0}

for i in range(n):
    tp = ''.join(sorted(input()))
    if tp in d:
        d[tp] = sum(list(range(d[tp] + 2)))
    else:
        d.update({tp: 0})

print(sum(d.values()))


### FIXED CODE ###

n = int(input())

s = []

for i in range(n):
    s.append(''.join(sorted(input())))

t = {}
for i in range(n):
    if s[i] in t:
        t[s[i]] += 1
    else:
        t[s[i]] = 1

print(sum(t[k]*(t[k]-1)//2 for k in t)) # t[k] Combi 2のlistのsumが答えになる
R, C = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(R)]
B = [list(map(int, input().split())) for _ in range(R)]

dp = [0] * R
dp[0] = s = 1 << 6400

for row_a, row_b in zip(A, B):
    for i, (a, b) in enumerate(zip(row_a, row_b)):
        d = abs(a - b)
        if i > 0:
            dp[i] |= dp[i - 1]
        dp[i] <<= d
        dp[i] >>= d

g = dp[-1]
for i in range(6401):
    if g & (s << i) or g & (s >> i):
        print(i)
        quit()

### FIXED CODE ###

R, C = map(int, input().split())

A = [list(map(int, input().split())) for _ in range(R)]
B = [list(map(int, input().split())) for _ in range(R)]

dp = [0] * C
dp[0] = s = 1 << 6400

for row_a, row_b in zip(A, B):
    for i, (a, b) in enumerate(zip(row_a, row_b)):
        d = abs(a - b)
        if i > 0:
            dp[i] |= dp[i - 1]
        dp[i] = (dp[i] << d) | (dp[i] >> d)

g = dp[-1]
for i in range(6401):
    if g & (s << i) or g & (s >> i):
        print(i)
        quit()
import string
x=input()
a=string.acsii_lowercase
for i in a
  if i not in x:
    print(i)
    exit()
print("None")


### FIXED CODE ###

import string
S = str(input())
a = set(S)
b = set(string.ascii_lowercase)
c = b - a
if len(list(c)) == 0:
    print(None)
else:
    print(sorted(list(c))[0])
N=int(input())

for i in range(1,N+1):
    if i%3==0 or i%5==0 or i%15==0:
        continue
        cal+=i

print(cal)


### FIXED CODE ###

N=int(input())
cal=0
for i in range(1,N+1):
    if i%3==0 or i%5==0 or i%15==0:
        continue
    cal+=i

print(cal)
import itertools
N,M = map(int,input().split())
L=[]
for i in range(M):
    a,b=map(int,input().split())
    L.append([a,b])
 
number=[]
for i in range(1,N+1):
    number.append(i)
    
ans=0
 
for v in itertools.permutations(number,N):
    a=0
    v=list(v)
    for j in range(N-1):
        if ([v[j],v[j+1]] not in L ) and ([v[j+1],v[j]] not in L):
            a=1
    if a==0 and v[0]==1:
        ans+=1
 
print(ans)
import itertools
N,M = map(int,input().split())
L=[]
for i in range(M):
    a,b=map(int,input().split())
    L.append([a,b])
 
number=[]
for i in range(1,N+1):
    number.append(i)
    
ans=0
 
for v in itertools.permutations(number,N):
    a=0
    v=list(v)
    for j in range(N-1):
        if ([v[j],v[j+1]] not in L ) and ([v[j+1],v[j]] not in L):
            a=1
    if a==0 and v[0]==1:
        ans+=1
 
print(ans)


### FIXED CODE ###

from itertools import permutations
n, m = map(int, input().split())
path = []
for i in range(m):
    a, b = map(int, input().split())
    path.append([a,b])
    path.append([b,a])
import itertools
per = [i for i in range(2,n+1)]
data = list(itertools.permutations(per, n-1))    
flg = 0
for k in range(len(data)):
    tmp = [[1, data[k][0]]]
    for i in range(n-2):
        tmp.append([data[k][i],data[k][i+1]])
    cnt = 0
    for var in tmp:
        if var in path:
            cnt += 1
    if cnt == len(tmp):
        flg += 1
print(flg)
N, R = map(int, input().split())
 
if N >= 10: print(K)
else: print(100*(10-K))

### FIXED CODE ###

N, R = map(int, input().split())
 
if N >= 10: print(R)
else: print(R + 100*(10-N))
A,B,C,D,E,F = map(int,input().split())

W = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1-i,100*B):
        W.add(i+j)
        
S = set()
for i in range(0,F+1,C):
    for j in range(0,F+1-i,D):
        S.add(i+j)

rate = 0
for w in W:
    for s in S:
        if 0 < w+s <= F and s/(w+s) <= E/(E+100):
            if s/(w+s) > rate:
                rate= s/(w+s)
                res1,res2 = w+s,s
                
print(res1,res2)

### FIXED CODE ###

A,B,C,D,E,F = map(int,input().split())

W = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1-i,100*B):
        W.add(i+j)
        
S = set()
for i in range(0,F+1,C):
    for j in range(0,F+1-i,D):
        S.add(i+j)

rate = 0
for w in W:
    for s in S:
        if 0 < w+s <= F and s/(w+s) <= E/(E+100):
            if s/(w+s) >= rate:
                rate= s/(w+s)
                res1,res2 = w+s,s
                
print(res1,res2)
a = input()
b = inout()

if (a==b[:len(a)-1]):
  print(`Yes`)
else:
  print(`No`)

### FIXED CODE ###

a = input()
b = input()
 
if (a==b[:len(a)]):
  print("Yes")
else:
  print("No")

#print(b[:len(a)-1])
import itertools
n = int(input())
a = list(map(int, input().split()))
idList = [i for i in range(1, n+1)]
temp = 0
for i in range(n):
    tar = a[temp]
    if (tar >= n):
        del a[i]
        del idList[i]

    else:
        temp += 1

com = list(itertools.combinations(idList, 2))

num = len(com)
ans = 0
for i in range(num):
    aa = com[i]
    # print(aa)
    idA = aa[0]
    idB = aa[1]
    dif = abs(idA - idB)
    height = a[idA - 1] + a[idB - 1]

    if (height == dif):
        ans += 1

print(ans)


### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))

minus = [0] * N
plus = [0] * N

for i in range(N):
    minus[i] = (i + 1) - A[i]
    plus[i] = (i + 1) + A[i]

count = Counter(minus)
most = count.most_common()
num = len(most)

countPP = Counter(plus)
#mostPP = countPP.most_common()
#check = mostPP[:][0]
ans = 0

for i in range(num):
    elm = most[i]
    fir = elm[0]
    sec = elm[1]
    # if (fir in check):

    aa = countPP[fir]
    #    print(aa)
    ans += aa * sec

    # try countPP[tar]:

print(ans)
import itertools
a=int(input())
b=list(map(int,input().split()))
aak=list(itertools.combinations(b,a-1))
ans=[]
def gud(a,b):
  if a%b==0:
    return b
  else:
    return gud(b,a%b)
for i in aak:
  for v in range(a-2):
    i+=(gud(i[v],i[v+1]),)
    i+=1
  ans+=[i[-1]]
print(max(ans))

### FIXED CODE ###

from fractions import*
a=int(input())
b=list(map(int,input().split()))
alis=[b[0]]
blis=[b[-1]]
for i in range(a-1):
  alis.extend([gcd(alis[-1],b[i+1])])
  blis.extend([gcd(blis[-1],b[-i-2])])
blis=list(reversed(blis))+[0]
alis=[0]+alis
ans=[]
for i in range(a):
	ans+=[gcd(alis[i],blis[i+1])]
print(max(ans))
a=input()
b=0
for i in range(len(a)-1):
  a[i]!=a[i+1]:
    b=b+1
if a[-2]!=a[-1]:
  b=b+1
print(b)

### FIXED CODE ###

a=input()
b=0
for i in range(len(a)-1):
  if a[i]!=a[i+1]:
    b=b+1
print(b)
import queue

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

road = [[] for i in range(m)]

for i in range(m):
    a, b = map(int, input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)

# cost to isMin
result = [[999999999999999, None, False] for i in range(n)]

# from tom
q = queue.Queue()

result[0] = [0, None, True]
for i in road[0]:
    q.put([0,i])

while not q.empty():
    n = q.get()
    if(not result[n[1]][2]):
        result[n[1]]=[result[n[0]][0]+1, n[0], True]
        for i in road[n[1]]:
            q.put([n[1], i])

flag = True
for i in result:
    if(not i[2]):
        flag = False
        break

if(flag):
    print("Yes")
    for i in range(1,len(result)):
        print(result[i][1]+1)
else:
    print("No")


    



### FIXED CODE ###

import queue

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

road = [[] for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)

# cost to isMin
result = [[999999999999999, None, False] for i in range(n)]

# from tom
q = queue.Queue()

result[0] = [0, None, True]
for i in road[0]:
    q.put([0,i])

while not q.empty():
    n = q.get()
    if(not result[n[1]][2]):
        result[n[1]]=[result[n[0]][0]+1, n[0], True]
        for i in road[n[1]]:
            q.put([n[1], i])

flag = True
for i in result:
    if(not i[2]):
        flag = False
        break

if(flag):
    print("Yes")
    for i in range(1,len(result)):
        print(result[i][1]+1)
else:
    print("No")
a=int(input())
b=int(input())   
if b%a==0:
	print(a+b)
else:
	print(b-a)

### FIXED CODE ###

a,b=map(int,input().split())
if b%a==0:
	print(a+b)
else:
	print(b-a)