Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x,y):
    if y == 0:
        return x
    elif x == 1 or y == 1:
        return 1
    else:
        return gcd(y,x%y)


n = int(input())
i = 1
j = 1
k = 1
ans = 0
while i < n+1:
    j = 1
    while j < n+1:
        k = 1
        p = gcd(i,j)
        while k < n+1:
            ans += gcd(k,p)
            k += 1
        j += 1
    i += 1
print(ans)

Fixed submission:
def gcd(x,y):
    if y == 0:
        return x
    elif x == 1 or y == 1:
        return 1
    else:
        return gcd(y,x%y)

G = []
i,j = 1,1
while i < 201:
    j = 1
    g0 = []
    while j < 201:
        g0.append(gcd(i,j))
        j += 1
    g0 = tuple(g0)
    G.append(g0)
    i += 1
n = int(input())
i = 1
j = 1
k = 1
ans = 0
while i < n+1:
    j = 1
    while j < n+1:
        k = 1
        p = G[i-1][j-1]
        while k < n+1:
            ans += G[k-1][p-1]
            k += 1
        j += 1
    i += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
i = 1
j = 1
k = 1
ans = 0
while i < n+1:
    j = 1
    while j < n+1:
        k = 1
        p = gcd(i,j)
        while k < n+1:
            if (p-1)*(k-1) == 0:
                ans += 1
            else:
                ans += gcd(k,p)
            k += 1
        j += 1
    i += 1
print(ans)

Fixed submission:
def gcd(x,y):
    if y == 0:
        return x
    elif x == 1 or y == 1:
        return 1
    else:
        return gcd(y,x%y)

G = []
i,j = 1,1
while i < 201:
    j = 1
    g0 = []
    while j < 201:
        g0.append(gcd(i,j))
        j += 1
    g0 = tuple(g0)
    G.append(g0)
    i += 1
n = int(input())
i = 1
j = 1
k = 1
ans = 0
while i < n+1:
    j = 1
    while j < n+1:
        k = 1
        p = G[i-1][j-1]
        while k < n+1:
            ans += G[k-1][p-1]
            k += 1
        j += 1
    i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
i = 1
j = 1
k = 1
ans = 0
while i < n+1:
    j = 1
    while j < n+1:
        k = 1
        while k < n+1:
            ans += math.gcd(i,math.gcd(j,k))
            k += 1
        j += 1
    i += 1
print(ans)

Fixed submission:
def gcd(x,y):
    if y == 0:
        return x
    elif x == 1 or y == 1:
        return 1
    else:
        return gcd(y,x%y)

G = []
i,j = 1,1
while i < 201:
    j = 1
    g0 = []
    while j < 201:
        g0.append(gcd(i,j))
        j += 1
    g0 = tuple(g0)
    G.append(g0)
    i += 1
n = int(input())
i = 1
j = 1
k = 1
ans = 0
while i < n+1:
    j = 1
    while j < n+1:
        k = 1
        p = G[i-1][j-1]
        while k < n+1:
            ans += G[k-1][p-1]
            k += 1
        j += 1
    i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
n = int(input())
i = 1
j = 1
k = 1
ans = 0
while i < n+1:
    j = 1
    while j < n+1:
        k = 1
        while k < n+1:
            ans += gcd(i,gcd(j,k))
            k += 1
        j += 1
    i += 1
print(ans)

Fixed submission:
def gcd(x,y):
    if y == 0:
        return x
    elif x == 1 or y == 1:
        return 1
    else:
        return gcd(y,x%y)

G = []
i,j = 1,1
while i < 201:
    j = 1
    g0 = []
    while j < 201:
        g0.append(gcd(i,j))
        j += 1
    g0 = tuple(g0)
    G.append(g0)
    i += 1
n = int(input())
i = 1
j = 1
k = 1
ans = 0
while i < n+1:
    j = 1
    while j < n+1:
        k = 1
        p = G[i-1][j-1]
        while k < n+1:
            ans += G[k-1][p-1]
            k += 1
        j += 1
    i += 1
print(ans)