Buggy python submission (verdict: Runtime Error):
from copy import deepcopy
from collections import deque

n,m,q=map(int,raw_input().split())
e=[]
g1=[[] for _ in xrange(n)]
for i in xrange(m):
    u,v=map(int,raw_input().split())
    u-=1;v-=1
    g1[u].append(v)
    g1[v].append(u)
    e.append((u,v))
d1=[10**9]*n
d1[0]=0
dq=deque([0])
while len(dq)>0:
    now=dq.popleft()
    for nx in g1[now]:
        if d1[nx]>d1[now]+1:
            dq.append(nx)
            d1[nx]=d1[now]+1

pe=deepcopy(e)
qu=[]
for i in xrange(q):
    r=int(raw_input())
    r-=1
    pe[r]=(-1,-1)
    qu.append(r)
g2=[[] for _ in xrange(n)]
for i in xrange(m):
    u,v=pe[i]
    if u==-1 and v==-1:continue
    g2[u].append(v)
    g2[v].append(u)
d2=[10**9]*n
d2[0]=0
dq=deque([0])
while len(dq)>0:
    now=dq.popleft()
    for nx in g2[now]:
        if d2[nx]>d2[now]+1:
            dq.append(nx)
            d2[nx]=d2[now]+1
            
def dfs(now):
    global cnt
    ok[now]=True
    cnt+=1
    for nx in g2[now]:
        if not ok[nx] and d2[now]+1==d1[nx]:
            d2[nx]=d2[now]+1
            dfs(nx)
    return

cnt=0
ok=[False]*n
for i in xrange(n):
    if d1[i]==d2[i]:
        cnt+=1
        ok[i]=True
ans=[0]*(q+1)
ans[q]=n-cnt
for i in xrange(q-1,-1,-1):
    r=qu[i]
    u,v=e[r]
    if (d2[u]!=10**9 and d2[u]==d2[v]) or (ok[u] and ok[v]):
        ans[i]=n-cnt
        continue
    if not ok[u] and not ok[v]:
        ans[i]=n-cnt
        g2[u].append(v)
        g2[v].append(u)
        continue
    if ok[u]:
        g2[u].append(v)
        g2[v].append(u)
        if d2[u]+1==d1[v]:
            d2[v]=d2[u]+1
            dfs(v)
    else:
        g2[u].append(v)
        g2[v].append(u)
        if d2[v]+1==d1[u]:
            d2[u]=d2[v]+1
            dfs(u)
    ans[i]=n-cnt
for i in xrange(1,q+1):
    print ans[i]

Fixed submission:
from collections import deque

def make_DAG(s,n,g):
    newg=[[] for _ in xrange(n)]
    dist=[float("inf")]*n
    dist[s]=0
    dq=deque([s])
    visited=[False]*n
    visited[s]=True
    indeg=[0]*n
    while len(dq)>0:
        now=dq.popleft()
        for nx in g[now]:
            if dist[nx]>=dist[now]+1:
                if not visited[nx]:
                     visited[nx]=True
                     dq.append(nx)
                newg[now].append(nx)
                dist[nx]=dist[now]+1
                indeg[nx]+=1
    return newg,dist,indeg

def bfs_count(s,DAG,indeg):
    indeg[s]-=1
    if indeg[s]!=0:return 0
    dq=deque([s])
    cnt=1
    while len(dq)>0:
        now=dq.popleft()
        for nx in DAG[now]:
            if ok.has_key((now,nx)):continue
            ok[(now,nx)]=True
            indeg[nx]-=1
            if indeg[nx]==0:
                cnt+=1
                dq.append(nx)
    return cnt

n,m,q=map(int,raw_input().split())
e=[]
g=[[] for _ in xrange(n)]
for i in xrange(m):
    u,v=map(int,raw_input().split())
    u-=1;v-=1
    g[u].append(v)
    g[v].append(u)
    e.append((u,v))
DAG,dist,indeg=make_DAG(0,n,g)
ans=0
ok={}
for i in xrange(q):
    r=int(raw_input())
    r-=1
    u,v=e[r]
    if abs(dist[u]-dist[v])==0:
        print ans
        continue
    if dist[u]<dist[v]:
        if not ok.has_key((u,v)):
            ok[(u,v)]=True
            ans+=bfs_count(v,DAG,indeg)
    else:
        if not ok.has_key((v,u)):
            ok[(v,u)]=True
            ans+=bfs_count(u,DAG,indeg)
    print ans

Buggy python submission (verdict: Runtime Error):
from copy import deepcopy
from collections import deque
from sys import setrecursionlimit


n,m,q=map(int,raw_input().split())
e=[]
g1=[[] for _ in xrange(n)]
for i in xrange(m):
    u,v=map(int,raw_input().split())
    u-=1;v-=1
    g1[u].append(v)
    g1[v].append(u)
    e.append((u,v))
d1=[10**9]*n
d1[0]=0
dq=deque([0])
while len(dq)>0:
    now=dq.popleft()
    for nx in g1[now]:
        if d1[nx]>d1[now]+1:
            dq.append(nx)
            d1[nx]=d1[now]+1

pe=deepcopy(e)
qu=[]
for i in xrange(q):
    r=int(raw_input())
    r-=1
    pe[r]=(-1,-1)
    qu.append(r)
g2=[[] for _ in xrange(n)]
for i in xrange(m):
    u,v=pe[i]
    if u==-1 and v==-1:continue
    g2[u].append(v)
    g2[v].append(u)
d2=[10**9]*n
d2[0]=0
dq=deque([0])
while len(dq)>0:
    now=dq.popleft()
    for nx in g2[now]:
        if d2[nx]>d2[now]+1:
            dq.append(nx)
            d2[nx]=d2[now]+1

setrecursionlimit(10**8)            
def dfs(now):
    global cnt
    ok[now]=True
    cnt+=1
    for nx in g2[now]:
        if not ok[nx] and d2[now]+1==d1[nx]:
            d2[nx]=d2[now]+1
            dfs(nx)
    return

cnt=0
ok=[False]*n
for i in xrange(n):
    if d1[i]==d2[i]:
        cnt+=1
        ok[i]=True
ans=[0]*(q+1)
ans[q]=n-cnt
for i in xrange(q-1,-1,-1):
    r=qu[i]
    u,v=e[r]
    if (d2[u]!=10**9 and d2[u]==d2[v]) or (ok[u] and ok[v]):
        ans[i]=n-cnt
        continue
    if not ok[u] and not ok[v]:
        ans[i]=n-cnt
        g2[u].append(v)
        g2[v].append(u)
        continue
    if ok[u]:
        g2[u].append(v)
        g2[v].append(u)
        if d2[u]+1==d1[v]:
            d2[v]=d2[u]+1
            dfs(v)
    else:
        g2[u].append(v)
        g2[v].append(u)
        if d2[v]+1==d1[u]:
            d2[u]=d2[v]+1
            dfs(u)
    ans[i]=n-cnt
for i in xrange(1,q+1):
    print ans[i]

Fixed submission:
from collections import deque

def make_DAG(s,n,g):
    newg=[[] for _ in xrange(n)]
    dist=[float("inf")]*n
    dist[s]=0
    dq=deque([s])
    visited=[False]*n
    visited[s]=True
    indeg=[0]*n
    while len(dq)>0:
        now=dq.popleft()
        for nx in g[now]:
            if dist[nx]>=dist[now]+1:
                if not visited[nx]:
                     visited[nx]=True
                     dq.append(nx)
                newg[now].append(nx)
                dist[nx]=dist[now]+1
                indeg[nx]+=1
    return newg,dist,indeg

def bfs_count(s,DAG,indeg):
    indeg[s]-=1
    if indeg[s]!=0:return 0
    dq=deque([s])
    cnt=1
    while len(dq)>0:
        now=dq.popleft()
        for nx in DAG[now]:
            if ok.has_key((now,nx)):continue
            ok[(now,nx)]=True
            indeg[nx]-=1
            if indeg[nx]==0:
                cnt+=1
                dq.append(nx)
    return cnt

n,m,q=map(int,raw_input().split())
e=[]
g=[[] for _ in xrange(n)]
for i in xrange(m):
    u,v=map(int,raw_input().split())
    u-=1;v-=1
    g[u].append(v)
    g[v].append(u)
    e.append((u,v))
DAG,dist,indeg=make_DAG(0,n,g)
ans=0
ok={}
for i in xrange(q):
    r=int(raw_input())
    r-=1
    u,v=e[r]
    if abs(dist[u]-dist[v])==0:
        print ans
        continue
    if dist[u]<dist[v]:
        if not ok.has_key((u,v)):
            ok[(u,v)]=True
            ans+=bfs_count(v,DAG,indeg)
    else:
        if not ok.has_key((v,u)):
            ok[(v,u)]=True
            ans+=bfs_count(u,DAG,indeg)
    print ans