Buggy python submission (verdict: Time Limit Exceeded):
N = int(input()) + 1
NumberList = list()
for i in range(1,N):
    for j in range(i,N):
        for k in range(j,N):
            NumberList.append([i,j,k])

Answer = 0

def getGCD(abc):
    a = int(abc[2])
    b = int(abc[1])
    c = int(abc[0])
    if a == b and b == c:
        d = 1
    elif a == b or b == c or c == a:
        d = 3
    else:
        d = 6
        
    surplus = b % c
    while surplus != 0:
        b = int(c)
        c = int(surplus)
        surplus = b % c
    surplus = a % c
    while surplus != 0:
        a = int(c)
        c = int(surplus)
        surplus = a % c
    return c * d

for abc in NumberList:
    Answer += getGCD(abc)
print(Answer)


Fixed submission:
N = int(input()) + 1

Answer = 0

def getGCD(a,b,c):
    if a == b and b == c:
        d = 1
    elif a == b or b == c or c == a:
        d = 3
    else:
        d = 6
        
    surplus = a % c
    while surplus != 0:
        a = int(c)
        c = int(surplus)
        surplus = a % c
    surplus = b % c
    while surplus != 0:
        b = int(c)
        c = int(surplus)
        surplus = b % c
    return c * d


for i in range(1,N):
    for j in range(i,N):
        for k in range(j,N):
            Answer += getGCD(k,j,i)
            
print(Answer)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input()) + 1
NumberList = list()
for i in range(1,N):
    for j in range(1,N):
        for k in range(1,N):
            NumberList.append([i,j,k])

Answer = 0

def getGCD(abc):
    abc.sort(reverse=True)
    a = int(abc[0])
    b = int(abc[1])
    c = int(abc[2])
    surplus = b % c
    while surplus != 0:
        b = int(c)
        c = int(surplus)
        surplus = b % c
    surplus = a % c
    while surplus != 0:
        a = int(c)
        c = int(surplus)
        surplus = a % c
    return c

for abc in NumberList:
    Answer += getGCD(abc)
print(Answer)


Fixed submission:
N = int(input()) + 1

Answer = 0

def getGCD(a,b,c):
    if a == b and b == c:
        d = 1
    elif a == b or b == c or c == a:
        d = 3
    else:
        d = 6
        
    surplus = a % c
    while surplus != 0:
        a = int(c)
        c = int(surplus)
        surplus = a % c
    surplus = b % c
    while surplus != 0:
        b = int(c)
        c = int(surplus)
        surplus = b % c
    return c * d


for i in range(1,N):
    for j in range(i,N):
        for k in range(j,N):
            Answer += getGCD(k,j,i)
            
print(Answer)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input()) + 1
NumberList = list()
for i in range(1,N):
    for j in range(1,N):
        for k in range(1,N):
            NumberList.append([i,j,k])

Answer = 0

def getGCD(abc):
    abc.sort(reverse=True)
    a = int(abc[0])
    b = int(abc[1])
    c = int(abc[2])
    surplus = a % b
    while surplus != 0:
        a = int(b)
        b = int(surplus)
        surplus = a % b
    if b > c:
        b,c = c,b
    surplus = c % b
    while surplus != 0:
        c = int(b)
        b = int(surplus)
        surplus = c % b
    return b

for abc in NumberList:
    Answer += getGCD(abc)
print(Answer)


Fixed submission:
N = int(input()) + 1

Answer = 0

def getGCD(a,b,c):
    if a == b and b == c:
        d = 1
    elif a == b or b == c or c == a:
        d = 3
    else:
        d = 6
        
    surplus = a % c
    while surplus != 0:
        a = int(c)
        c = int(surplus)
        surplus = a % c
    surplus = b % c
    while surplus != 0:
        b = int(c)
        c = int(surplus)
        surplus = b % c
    return c * d


for i in range(1,N):
    for j in range(i,N):
        for k in range(j,N):
            Answer += getGCD(k,j,i)
            
print(Answer)