Sum of Maximum GCD from two arrays
There are quite a few ways to reduce the number of lines in your program, and improve the readability of your program:


If you want to return a certain number when A and B are empty, use a guard clause.

Personally I'd default to -1, rather than 1.
When building a list, you can use C = [A, B], rather than appending.
You don't need to build an array, to unpack it into a function. itertools.product(A, B) is fine.
The list gcds is the same as the first index of D. It'd be simpler if you just used D.
The lists E and sums are unused, and so should be removed.
The 'comments', commented out code, is generally unhelpful and distract from the algorithm. I'd recomend removing them.
Rather than building a list with D = [] for i in ...: d.append(i), you can use a list comprehension.
Rather than building a list that may take ~2275GB of RAM, you may instead want to use a generator / generator comprehension.
max works on a list of tuples.


And so I'd rather use:

import itertools
import math

def maximumGcdAndSum(A, B):
    if not (a or b):
        return -1
    nums = (
        (math.gcd(a, b), a + b)
        for a, b in itertools.product(A, B)
    )
    return max(nums)[1]

if __name__ == "__main__":
    n = int(input().strip())
    A = list(map(int, input().strip().split(' ')))
    B = list(map(int, input().strip().split(' ')))
    res = maximumGcdAndSum(A, B)
    print(res)


This however is likely to still produce a time limit exceeded error. I'm thinking of a better algorithm.