Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x,y,z):
    for i in range(x, 0, -1):
        if x%i==0 and y%i==0 and z%i==0:
            #print(i)
            return i
            break
            
    

def main():
    import sys
    N = int(sys.stdin.readline())
    total=0
    for i in range(1, N+1):
        for j in range(i, N+1):
            for k in range(j, N+1):
                if i==j and j==k:
                    total +=gcd(i, j, k)
                elif i==j or j==k or i==k:
                    total +=gcd(i, j, k)*3
                else:
                    total +=gcd(i, j, k)*6
                
    print(total)
    


if __name__=='__main__':
    main()

Fixed submission:
def gcd(x,y,z):
    for i in range(x, 0, -1):
        if x%i==0 and y%i==0 and z%i==0:
            #print(i)
            return i
            break
            
    

def main():
    import sys
    N = int(sys.stdin.readline())
    total=0
    for i in range(1, N+1):
        for j in range(i, N+1):
            for k in range(j, N+1):
                if i==j and j==k:
                    total +=gcd(i, j, k)
                elif i==j or j==k or i==k:
                    total +=gcd(i, j, k)*3
                else:
                    total +=gcd(i, j, k)*6
                
    print(total)
    


if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    import fractions as f
    N = int(sys.stdin.readline())
    total=0
    for i in range(1, N+1):
        for j in range(i, N+1):
            for k in range(j, N+1):
                if i==j and j==k:
                    total+=f.gcd(f.gcd(i,j), f.gcd(j,k))
                elif i==j or j==k or i==k:
                    total+=f.gcd(f.gcd(i,j), f.gcd(j,k))*3
                else:
                    total+=f.gcd(f.gcd(i,j), f.gcd(j,k))*6
    print(total)
    


if __name__=='__main__':
    main()

Fixed submission:
def gcd(x,y,z):
    for i in range(x, 0, -1):
        if x%i==0 and y%i==0 and z%i==0:
            #print(i)
            return i
            break
            
    

def main():
    import sys
    N = int(sys.stdin.readline())
    total=0
    for i in range(1, N+1):
        for j in range(i, N+1):
            for k in range(j, N+1):
                if i==j and j==k:
                    total +=gcd(i, j, k)
                elif i==j or j==k or i==k:
                    total +=gcd(i, j, k)*3
                else:
                    total +=gcd(i, j, k)*6
                
    print(total)
    


if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    import fractions as f
    N = int(sys.stdin.readline())
    total=0
    for i in range(1, N+1):
        for j in range(1, N+1):
            for k in range(1, N+1):
                total+=f.gcd(f.gcd(i,j), f.gcd(j,k))
    print(total)
    


if __name__=='__main__':
    main()

Fixed submission:
def gcd(x,y,z):
    for i in range(x, 0, -1):
        if x%i==0 and y%i==0 and z%i==0:
            #print(i)
            return i
            break
            
    

def main():
    import sys
    N = int(sys.stdin.readline())
    total=0
    for i in range(1, N+1):
        for j in range(i, N+1):
            for k in range(j, N+1):
                if i==j and j==k:
                    total +=gcd(i, j, k)
                elif i==j or j==k or i==k:
                    total +=gcd(i, j, k)*3
                else:
                    total +=gcd(i, j, k)*6
                
    print(total)
    


if __name__=='__main__':
    main()