Buggy python submission (verdict: Time Limit Exceeded):
import sys
import fractions, math
from functools import reduce

def gcd(i, j, k):
    return fractions.gcd(i, fractions.gcd(j, k))

def solve(K: int):
    counter = 0
    for i in range(1, K+1):
        for j in range(i, K+1):
            for k in range(j, K+1):
                c = gcd(i, j, k)
                if i == j and j == k:
                    counter += c
                elif i == j or j == k:
                    counter += 3 * c
                else:
                    counter += 6 * c
    print(counter)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python3
import sys
import fractions, math
from functools import reduce

def solve(K: int):
    counter = 0
    L = [0] * 201
    for i in range(1, K+1):
        for j in range(1, K+1):
            L[math.gcd(i, j)] += 1
    for i in range(1, K+1):
        for j in range(1, K+1):
            counter += math.gcd(i, j) * L[j]
    print(counter)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import fractions, math
from functools import reduce

def gcd(i, j, k):
    return fractions.gcd(i, fractions.gcd(j, k))

def solve(K: int):
    counter = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                counter += gcd(i, j, k)
    print(counter)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python3
import sys
import fractions, math
from functools import reduce

def solve(K: int):
    counter = 0
    L = [0] * 201
    for i in range(1, K+1):
        for j in range(1, K+1):
            L[math.gcd(i, j)] += 1
    for i in range(1, K+1):
        for j in range(1, K+1):
            counter += math.gcd(i, j) * L[j]
    print(counter)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()