Buggy python submission (verdict: Time Limit Exceeded):
# http://ja.wikipedia.org/wiki/%E3%83%97%E3%83%AA%E3%83%A0%E6%B3%95

class vertex:
    def __init__(self):
        self.min_distance = float("inf")
        self.distance = float("inf")
        self.parent = None
        self.minimum_adjacency_list = []
        self.is_in_Q = True
        self.is_in_V = False

def is_single_in_V(v,p):
    a = v[p[0]].is_in_V
    b = v[p[1]].is_in_V
    return ( a and not b ) or ( not a and b )
def all_in_V(v):
    for e in v:
        if not e.is_in_V:
            return False
    return True
def add_in_V(v,pa):
    v[pa[0]].is_in_V = True
    v[pa[1]].is_in_V = True

def solve(nu,mu,du):
    V= []
    E = []
    vertexes = [vertex() for i in xrange(nu)]
    vertexes[0].distance = 0
    V.append(vertexes[0])
    vertexes[0].is_in_V = True
    distances = [ e[2] for e in du ]
    passess = [ e[0:2] for e in du]

    while True:
        if all_in_V(vertexes):
            break
        min_dist = float("inf")
        for i in xrange(len(du)):
            pas = passess[i]
            if is_single_in_V(vertexes,pas):
                min_dist = min( min_dist, distances[i] )
        ind = distances.index(min_dist)
        E.append(min_dist)
        add_in_V(vertexes,passess[ind])
    print sum(E)/100 - len(E)




while True:
    n = input()
    if n == 0:
        exit()
    m = input()
    data = []
    for i in xrange(n):
        data.append( map(int,raw_input().split(",")) )
    solve(n,m,data)

Fixed submission:
def solve(nu,mu,du):
    E = []
    vs = [False]*nu
    vs[0] = True

    while True:
        min_dist,ind = float("inf"),float("inf")
        for i in xrange(len(du)):
            if ( ( vs[du[i][0]] and not vs[du[i][1]] ) or ( not vs[du[i][0]] and vs[du[i][1]]) ) and min_dist > du[i][2]:
                min_dist,ind,pf,pt = du[i][2],i,du[i][0],du[i][1]
        E.append(min_dist)
        vs[pf] = vs[pt] = True
        du.pop(ind)
        if all(vs):
            break

        for i in xrange(len(du)):
            try:
                if vs[du[i][0]] and vs[du[i][1]]:
                    du.pop(i)
            except:
                pass

    print sum(E)/100 - len(E)

while True:
    n = input()
    if n == 0:
        exit()
    m = input()
    data = []
    for i in xrange(m):
        data.append( map(int,raw_input().split(",")) )
    solve(n,m,data)

Buggy python submission (verdict: Runtime Error):
# http://ja.wikipedia.org/wiki/%E3%83%97%E3%83%AA%E3%83%A0%E6%B3%95

class vertex:
    def __init__(self):
        self.min_distance = float("inf")
        self.distance = float("inf")
        self.parent = None
        self.minimum_adjacency_list = []
        self.is_in_Q = True
        self.is_in_V = False

def is_single_in_V(v,p):
    a = v[p[0]].is_in_V
    b = v[p[1]].is_in_V
    return ( a and not b ) or ( not a and b )
def all_in_V(v):
    for e in v:
        if not e.is_in_V:
            return False
    return True
def add_in_V(v,d):
    v[d[0]].is_in_V = True
    v[d[1]].is_in_V = True

def remove_all_in_V_pass(v,d):
    for i in xrange(len(d)):
        try:
            if v[d[i][0]].is_in_V and v[d[i][1]].is_in_V:
                d.pop(i)
        except:
            pass
def solve(nu,mu,du):
    V= []
    E = []
    vertexes = [vertex() for i in xrange(nu)]
    vertexes[0].distance = 0
    V.append(vertexes[0])
    vertexes[0].is_in_V = True
    distances = [ e[2] for e in du ]
    passess = [ e[0:2] for e in du]

    while True:
        if all_in_V(vertexes):
            break
        min_dist = float("inf")
        ind = float("inf")
        for i in xrange(len(du)):
            pas = passess[i]
            if is_single_in_V(vertexes,pas):
                if min_dist > du[i][2]:
                    min_dist = du[i][2]
                    ind = i

        E.append(min_dist)
        add_in_V(vertexes,du[ind])
        du.pop(ind)
        remove_all_in_V_pass(vertexes,du)
    print sum(E)/100 - len(E)

while True:
    n = input()
    if n == 0:
        exit()
    m = input()
    data = []
    for i in xrange(n):
        data.append( map(int,raw_input().split(",")) )
    solve(n,m,data)

Fixed submission:
def solve(nu,mu,du):
    E = []
    vs = [False]*nu
    vs[0] = True

    while True:
        min_dist,ind = float("inf"),float("inf")
        for i in xrange(len(du)):
            if ( ( vs[du[i][0]] and not vs[du[i][1]] ) or ( not vs[du[i][0]] and vs[du[i][1]]) ) and min_dist > du[i][2]:
                min_dist,ind,pf,pt = du[i][2],i,du[i][0],du[i][1]
        E.append(min_dist)
        vs[pf] = vs[pt] = True
        du.pop(ind)
        if all(vs):
            break

        for i in xrange(len(du)):
            try:
                if vs[du[i][0]] and vs[du[i][1]]:
                    du.pop(i)
            except:
                pass

    print sum(E)/100 - len(E)

while True:
    n = input()
    if n == 0:
        exit()
    m = input()
    data = []
    for i in xrange(m):
        data.append( map(int,raw_input().split(",")) )
    solve(n,m,data)

Buggy python submission (verdict: Runtime Error):
# http://ja.wikipedia.org/wiki/%E3%83%97%E3%83%AA%E3%83%A0%E6%B3%95

class vertex:
    def __init__(self):
        self.is_in_V = False

def is_single_in_V(v,p):
    a = v[p[0]].is_in_V
    b = v[p[1]].is_in_V
    return ( a and not b ) or ( not a and b )

def all_in_V(v):
    for e in v:
        if not e.is_in_V:
            return False
    return True

def add_in_V(v,d):
    v[d[0]].is_in_V = True
    v[d[1]].is_in_V = True

def remove_all_in_V_pass(v,d):
    for i in xrange(len(d)):
        try:
            if v[d[i][0]].is_in_V and v[d[i][1]].is_in_V:
                d.pop(i)
        except:
            pass

def solve(nu,mu,du):
    E = []
    vertexes = [vertex() for i in xrange(nu)]
    vertexes[0].is_in_V = True

    while True:
        if all_in_V(vertexes):
            break
        min_dist,ind = float("inf"),float("inf")
        for i in xrange(len(du)):
            if is_single_in_V(vertexes,du[i][0:2]):
                if min_dist > du[i][2]:
                    min_dist = du[i][2]
                    ind = i
        E.append(min_dist)
        add_in_V(vertexes,du[ind])
        du.pop(ind)
        remove_all_in_V_pass(vertexes,du)
    print sum(E)/100 - len(E)

while True:
    n = input()
    if n == 0:
        exit()
    m = input()
    data = []
    for i in xrange(n):
        data.append( map(int,raw_input().split(",")) )
    solve(n,m,data)

Fixed submission:
def solve(nu,mu,du):
    E = []
    vs = [False]*nu
    vs[0] = True

    while True:
        min_dist,ind = float("inf"),float("inf")
        for i in xrange(len(du)):
            if ( ( vs[du[i][0]] and not vs[du[i][1]] ) or ( not vs[du[i][0]] and vs[du[i][1]]) ) and min_dist > du[i][2]:
                min_dist,ind,pf,pt = du[i][2],i,du[i][0],du[i][1]
        E.append(min_dist)
        vs[pf] = vs[pt] = True
        du.pop(ind)
        if all(vs):
            break

        for i in xrange(len(du)):
            try:
                if vs[du[i][0]] and vs[du[i][1]]:
                    du.pop(i)
            except:
                pass

    print sum(E)/100 - len(E)

while True:
    n = input()
    if n == 0:
        exit()
    m = input()
    data = []
    for i in xrange(m):
        data.append( map(int,raw_input().split(",")) )
    solve(n,m,data)

Buggy python submission (verdict: Runtime Error):
def solve(nu,mu,du):
    E = []
    vs = [False]*nu
    vs[0] = True

    while True:
        if all(vs):
            break
        min_dist,ind = float("inf"),float("inf")
        for i in xrange(len(du)):
            p_from = du[i][0]
            p_to = du[i][1]
            if vs[p_from] and vs[p_to]:
                du.pop(i)
                continue
            if ( vs[p_from] and not vs[p_to] ) or ( not vs[p_from] and vs[p_to]):
                if min_dist > du[i][2]:
                    min_dist,ind,pf,pt = du[i][2],i,p_from,p_to
        E.append(min_dist)
        vs[pf] = vs[pt] = True
        du.pop(ind)
    print sum(E)/100 - len(E)

while True:
    n = input()
    if n == 0:
        exit()
    m = input()
    data = []
    for i in xrange(m):
        data.append( map(int,raw_input().split(",")) )
    solve(n,m,data)

Fixed submission:
def solve(nu,mu,du):
    E = []
    vs = [False]*nu
    vs[0] = True

    while True:
        min_dist,ind = float("inf"),float("inf")
        for i in xrange(len(du)):
            if ( ( vs[du[i][0]] and not vs[du[i][1]] ) or ( not vs[du[i][0]] and vs[du[i][1]]) ) and min_dist > du[i][2]:
                min_dist,ind,pf,pt = du[i][2],i,du[i][0],du[i][1]
        E.append(min_dist)
        vs[pf] = vs[pt] = True
        du.pop(ind)
        if all(vs):
            break

        for i in xrange(len(du)):
            try:
                if vs[du[i][0]] and vs[du[i][1]]:
                    du.pop(i)
            except:
                pass

    print sum(E)/100 - len(E)

while True:
    n = input()
    if n == 0:
        exit()
    m = input()
    data = []
    for i in xrange(m):
        data.append( map(int,raw_input().split(",")) )
    solve(n,m,data)

Buggy python submission (verdict: Runtime Error):
def solve(nu,mu,du):
    E = []
    vs = [False]*nu
    vs[0] = True

    while True:
        min_dist,ind = float("inf"),float("inf")
        for i in xrange(len(du)):
            p_from = du[i][0]
            p_to = du[i][1]
            if vs[p_from] and vs[p_to]:
                du.pop(i)
                break
            if ( vs[p_from] and not vs[p_to] ) or ( not vs[p_from] and vs[p_to]):
                if min_dist > du[i][2]:
                    min_dist,ind,pf,pt = du[i][2],i,p_from,p_to
        E.append(min_dist)
        vs[pf] = vs[pt] = True
        du.pop(ind)
        if all(vs):
            break

    print sum(E)/100 - len(E)

while True:
    n = input()
    if n == 0:
        exit()
    m = input()
    data = []
    for i in xrange(m):
        data.append( map(int,raw_input().split(",")) )
    solve(n,m,data)

Fixed submission:
def solve(nu,mu,du):
    E = []
    vs = [False]*nu
    vs[0] = True

    while True:
        min_dist,ind = float("inf"),float("inf")
        for i in xrange(len(du)):
            if ( ( vs[du[i][0]] and not vs[du[i][1]] ) or ( not vs[du[i][0]] and vs[du[i][1]]) ) and min_dist > du[i][2]:
                min_dist,ind,pf,pt = du[i][2],i,du[i][0],du[i][1]
        E.append(min_dist)
        vs[pf] = vs[pt] = True
        du.pop(ind)
        if all(vs):
            break

        for i in xrange(len(du)):
            try:
                if vs[du[i][0]] and vs[du[i][1]]:
                    du.pop(i)
            except:
                pass

    print sum(E)/100 - len(E)

while True:
    n = input()
    if n == 0:
        exit()
    m = input()
    data = []
    for i in xrange(m):
        data.append( map(int,raw_input().split(",")) )
    solve(n,m,data)