Problem:
Wire I am a craftsman specialized in interior works. A customer asked me to perform wiring work on a wall whose entire rectangular surface is tightly pasted with pieces of panels. The panels are all of the same size (2 m in width, 1 m in height) and the wall is filled with an x (horizontal) by y (vertical) array of the panels. The customer asked me to stretch a wire from the left top corner of the wall to the right bottom corner whereby the wire is tied up at the crossing points with the panel boundaries (edges and vertexes) as shown in the figure. There are nine tied-up points in the illustrative figure shown below.   Fig: The wire is tied up at the edges and vertexes of the panels (X: 4 panels, Y: 6 panels)   Write a program to provide the number of points where the wire intersects with the panel boundaries.
Assume that the wire and boundary lines have no thickness. Input The input is given in the following format.  x  y  A line of data is given that contains the integer number of panels in the horizontal direction x (1 ≤ x ≤ 1000) and those in the vertical direction y (1 ≤ y ≤ 1000). Output Output the number of points where the wire intersects with the panel boundaries. Sample Input 1 4 4 Sample Output 1 5 Sample Input 2 4 6 Sample Output 2 9

Solution (Python):
print((lambda x : int(x[0]) + int(x[1]) + 1 - (lambda *x, f=lambda f, x, y: f(f, y, x % y) if y else x: f(f, *x))(int(x[0]),int(x[1])))(input().split()))

Solution (Python):
print((lambda x : int(x[0]) + int(x[1]) + 1 - (lambda *x, f=lambda f, x, y: f(f, y, x % y) if y else x: f(f, *x))(int(x[0]),int(x[1])))(input().split()))

Solution (Python):
print((lambda x:int(x[0])+int(x[1])+1-(lambda*x,f=lambda f,x,y:f(f,y,x%y) if y else x:f(f,*x))(int(x[0]),int(x[1])))(input().split()))

Solution (Python):
import math
x,y=list(map(int,input().split()))
print(x+y-math.gcd(x,y)+1)

Solution (Python):
def gcd(p,q):
      if p<q:
            return gcd(q,p)
      if p%q==0:
            return q
      else:
            return gcd(q,p%q)

x,y = map(int,list(input().split(" ")))
print(x+y+1-gcd(x,y))

Solution (Python):
x, y = map(int, input().split())
def eu(x, y):
    p, q = max(x, y), min(x, y)
    while p % q != 0:p, q = q, p % q
    return q
print(x + y - eu(x, y) + 1)

Solution (Python):
from math import gcd
x, y = map(int, input().split())
print(x + 1 + y + 1 - gcd(x, y) - 1)

Solution (Python):
import math

a, b = map(int, input().split())
g = math.gcd(a, b)
a1, b1 = a/g, b/g
print(int((a1-1+b1)*g+1))

Solution (Python):
def GCD(M, N) :
    while True :
        if N < M :
            N, M = M, N
        amari = N % M
        if amari == 0 :
            break
        else :
            N, M = M, amari
    return M

x, y = map(int, input().split()) 
gcd = GCD(x, y)
x = x / gcd
y = y / gcd
print(int(x-1 + y-1 + 1) * gcd + 1)

Solution (Python):
import math
x,y = list(map(int, input().split()))
gc = math.gcd(x,y)
print(x+y - gc + 1)

Solution (Python):
import math
a,b = map(int,input().split())
print(a+b-(math.gcd(a,b))+1)

Solution (Python):
from math import gcd
x,y=map(int,input().split())
print(x+y-gcd(x,y)+1)

Solution (Python):
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
x, y = map(int, input().split())
g = gcd(x, y)
print(((x // g - 1) + (y // g - 1) + 1) * g + 1)

Solution (Python):

def calGCD(x,y):
    while(y > 0):
        x, y = y, x % y
    return x

x,y = [int(i) for i in input().split()]
d = calGCD(x,y)

ans = (x-1) + (y-1) + 2 - (d-1)
print(ans)

Solution (Python):
import math
x,y=map(int,input().split())

k=math.gcd(x,y)
if k==1:
    print(x+y)
else:
    m=2*x//k
    print(x+y+1-2*x//m)

Solution (Python):
import math

x, y = map(int, input().split())
g = math.gcd(x, y)
print(x+y-g+1)

Solution (Python):
import math
def intersection(x,y):
    g = math.gcd(x, y)
    if g == 1:
        return x + y
    return intersection(x//g, y//g) * g - (g-1)
print(intersection(*map(int, input().split())))

Solution (Python):
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]
def gcd(a, b):
    if a < b: return gcd(b, a)
    if b == 0: return a
    return gcd(b, a%b)

x, y = il()
a = gcd(x, y)
print(x+y-a+1)

Solution (Python):
import fractions
a,b = map(int,input().split())
print(a + b + 1 -fractions.gcd(a, b))

Solution (Python):
a, b = map(int, input().split())
cnt = 0
for x in range(0, a*2+1, 2):
	if((b*x) % (2*a) == 0):
		cnt += 1
print(a + b - cnt + 2)