• + 1 comment

    how should I optimize my code, it is able to pass only two test cases and in rest time exceeded

    # Enter your code here. Read input from STDIN. Print output to STDOUT
    import math
    inp = list(map(int,input().split())) 
    x=inp[0]
    y=inp[1]
    length = len(str(y))+1
    total = 0
    ls1 = set()
    ls2 = set()
    for i in range(1,x+1):
        for j in range(1,y+1):
            ls1.add((i*j*pow(10,length)))
            ls2.add(int(str(i^j).zfill(length)))
    for i in ls1:
        for j in ls2:
            total = total+(i+j)
    print(total)