AtCoder Beginner Contest 118 - B +/- A

You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq A \leq B \leq 20

-----Input-----
Input is given from Standard Input in the following format:
A B

-----Output-----
If A is a divisor of B, print A + B; otherwise, print B - A.

-----Sample Input-----
4 12

-----Sample Output-----
16

As 4 is a divisor of 12, 4 + 12 = 16 should be printed.

Difficulty: EASY

Starter code:

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


(A, B) = map(int, input().split())
print((A + B, B - A)[B % A != 0])


(A, B) = map(int, input().split())
if B // A == B / A:
	print(A + B)
else:
	print(B - A)


(a, b) = [int(k) for k in input().split()]
if b % a:
	print(abs(b - a))
else:
	print(a + b)


(a, b) = map(int, input().split())
print([a + b, b - a][b % a > 0])


print((lambda a, b: b - a if b % a else a + b)(*[int(i) for i in input().split()]))


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


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


(a, b) = [int(x) for x in input().split()]
if b % a == 0:
	print(a + b)
else:
	print(b - a)


(A, B) = map(int, input().split())
C = B % A
if C == 0:
	print(A + B)
else:
	print(B - A)


(a, b) = (int(i) for i in input().split())
print(a + b if b % a == 0 else b - a)


(a, b) = map(int, input().split())
print(b + a * (2 * (not b % a) - 1))


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


import math
(A, B) = map(int, input().split())
print(B + A - 2 * A * math.ceil(B % A / 20))


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


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


(A, B) = [int(i) for i in input().split()]
print(A + B if B % A == 0 else B - A)


str_line = input().split(' ')
num_1 = int(str_line[0])
num_2 = int(str_line[1])
if num_2 % num_1 == 0:
	ans = num_1 + num_2
else:
	ans = num_2 - num_1
print(ans)


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


import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	(A, B) = list(map(int, readline().split()))
	if B % A == 0:
		print(A + B)
	else:
		print(B - A)
	return

def __starting_point():
	main()
__starting_point()


(A, B) = [int(a) for a in input().split(' ')]
print(A + B if B % A == 0 else B - A)


from fractions import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import sys
sys.setrecursionlimit(10000000)
mod = 998244353

def readInts():
	return list(map(int, input().split()))

def I():
	return int(input())
(a, b) = readInts()
print(a + b if b % a == 0 else b - a)


(A, B) = [int(s) for s in input().split(' ')]
print(A + B if B % A == 0 else B - A)


(A, B) = map(int, input().split())
ans = A + B if B % A == 0 else B - A
print(ans)


(N, K) = list(map(int, input().split()))
print(N + K) if K % N == 0 else print(K - N)


(a, b) = list(map(int, input().split()))
print(a + b - a * 2 * (b % a != 0))


import sys
input = sys.stdin.readline

def main():
	(A, B) = list(map(int, input().split()))
	if B % A == 0:
		print(A + B)
	else:
		print(B - A)

def __starting_point():
	main()
__starting_point()


(a, b) = [int(i) for i in input().split()]
print([a + b, b - a][b % a != 0])


(A, B) = map(int, input().split())
print(B % A == 0 and A + B or B - A)


a = list(map(int, input().split()))
print(a[0] + a[1] if a[1] % a[0] == 0 else a[1] - a[0])


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


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


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


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


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


(A, B) = map(int, input().split())
if A > 0 and B % A == 0:
	print(B + A)
else:
	print(B - A)


[A, B] = list(map(int, input().split()))
if B % A == 0:
	print(A + B)
else:
	print(B - A)


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


(A, B) = [int(n) for n in input().split()]
print(A + B if B % A == 0 else B - A)


(a, b) = [int(e) for e in input().split()]
if b % a == 0:
	print(a + b)
else:
	print(b - a)


(A, B) = (int(x) for x in input().split())
print(A + B if B % A == 0 else B - A)


(x, y) = map(int, input().split())
print([y - x, x + y][y % x == 0])


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	(a, b) = Input()
	print(a + b if b % a == 0 else b - a)
main()


(A, B) = map(int, input().split())
x = A + B if B % A == 0 else B - A
print(x)


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


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


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


(a, b) = map(int, input().split())
print(b - a * (2 * (b % a > 0) - 1))


(a, b) = [int(s) for s in input().split()]
if b % a == 0:
	print(a + b)
else:
	print(b - a)


A = list(map(int, input().split()))
print(sum(A) if A[1] % A[0] == 0 else A[1] - A[0])


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


import sys

def input():
	return sys.stdin.readline().strip()

def I():
	return int(input())

def LI():
	return list(map(int, input().split()))

def IR(n):
	return [I() for i in range(n)]

def LIR(n):
	return [LI() for i in range(n)]

def SR(n):
	return [S() for i in range(n)]

def S():
	return input()

def LS():
	return input().split()
INF = float('inf')
(a, b) = LI()
if b % a == 0:
	print(a + b)
else:
	print(b - a)


def lcm(a, b):
	return a * b // math.gcd(a, b)
MOD = 10 ** 9 + 7
(a, b) = list(map(int, input().split()))
if b % a == 0:
	print(a + b)
else:
	print(b - a)


(a, b) = map(int, input().split())
print('{}'.format(a + b if b % a == 0 else b - a))


(A, B) = map(int, open(0).read().split())
print(A + B if B % A == 0 else B - A)


(A, B) = map(int, input().split())
mod = B % A
if mod == 0:
	print(A + B)
else:
	print(B - A)


(a, b) = [int(_) for _ in input().split()]
print(a + b if b % a == 0 else b - a)


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


a = [int(i) for i in input().split()]
print(a[0] + a[1] if a[1] % a[0] == 0 else a[1] - a[0])


(A, B) = [int(_) for _ in input().split()]
print(A + B if B % A == 0 else B - A)


(A, B) = map(int, input().split())
s = B % A
if s == 0:
	print(A + B)
else:
	print(B - A)


(a, b) = map(int, input().split())
print([b - a, a + b][b % a < 1])


(A, B) = input().split()
if int(B) % int(A) == 0:
	print(int(A) + int(B))
else:
	print(int(B) - int(A))


(A, B) = map(int, input().split())
if round(B % A) == 0:
	print(A + B)
else:
	print(B - A)


(A, B) = (int(X) for X in input().split())
if B % A == 0:
	print(B + A)
else:
	print(B - A)


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


(A, B) = tuple(map(int, input().split()))
if B % A == 0:
	print(A + B)
else:
	print(B - A)


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


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


(A, B) = map(int, input().split())
print('{}'.format(A + B if B % A == 0 else B - A))


(a, b) = [int(x) for x in input().split()]
print([a + b, b - a][int(bool(b % a))])