Buggy python submission (verdict: Time Limit Exceeded):
# Debug Print
isdbg  = True
def dprint(*value,sep=' ',end='\n'):
    if isdbg:
        print(*value,sep=sep,end=end)
    
# 入力を格納
H,W,N = map(int,input().split())
    
#XY = [[0 for i in range(W)] for i in range(H)]
BL = {}
for i in range(N):
    x1,y1 = map(int,input().split())
    #XY[x1-1][y1-1] = 1
    BL[str(x1-1) + "," + str(y1-1)] = x1+y1-2
    
    
# 初期位置
#if isdbg:
#    for i in range(W):
#        for j in range(H):
#            dprint(XY[i][j],end='')
#        dprint()

TL = sorted(BL.items(), key=lambda x: x[1])
#print(TL)
    
if len(TL) == 0:
    print(H)
    exit(0)
    
min = H
for b in TL:
    x,y = map(int,b[0].split(','))
    sx = x-1
    sy = y
    
    isflg = True
    #dprint("\t",sx,sy)

    if str(sx)+","+str(sy) in BL :          
        isflg = False  
         
    while sx > 0 and sy > 0 :
        sx = sx - 1
        sy = sy - 1
        if str(sx)+","+str(sy) in BL :          
            isflg = False  
            break

    if isflg and sy == 0:
        if min> x:
            min = x

print(min)

Fixed submission:
# Debug Print
isdbg  = False
#isdbg  = True
def dprint(*value,sep=' ',end='\n'):
    if isdbg:
        print(*value,sep=sep,end=end)
    
# 入力を格納
H,W,N = map(int,input().split())

if isdbg:
    XY = [[0 for i in range(W)] for i in range(H)]
BL = {}
for i in range(N):
    x1,y1 = map(int,input().split())
    if isdbg:
        XY[x1-1][y1-1] = 1

    if x1-1 in BL :
        BL[x1-1].append(y1-1)
    else:
        BL[x1-1] = [y1-1]

TL = sorted(BL.items(),key= lambda x: x[0])

# 初期位置
if isdbg:
    for i in range(W):
        for j in range(H):
            dprint(XY[i][j],end='')
        dprint()
#print(TL)

maxr = 1
for i in range(H-1):

    if i+1 in BL:
        l = BL[i+1]
        l.sort()
        #print(l,maxr)
        for ll in l :
            if maxr > ll:
                print(i+1)
                exit(0)
            elif maxr == ll:
                maxr -= 1
                break
            else:
                break
        
    maxr += 1

print(H)

Buggy python submission (verdict: Runtime Error):
# Debug Print
isdbg  = True
def dprint(*value,sep=' ',end='\n'):
    if isdbg:
        print(*value,sep=sep,end=end)

# 入力を格納
H,W,N = map(int,input().split())

XY = [[0 for i in range(W)] for i in range(H)]
BL = {}
for i in range(N):
    x1,y1 = map(int,input().split())
    XY[x1-1][y1-1] = 1
    BL[str(x1-1) + "," + str(y1-1)] = x1+y1-2

 
# 初期位置
if isdbg:
    for i in range(W):
        for j in range(H):
            dprint(XY[i][j],end='')
        dprint()    

TL = sorted(BL.items(), key=lambda x: x[1])
#print(TL)

if len(TL) == 0:
    print(H)
    exit(0)

min = H
for b in TL:
    x,y = map(int,b[0].split(','))
    sx = x-1
    sy = y
    
    isflg = True
    if sx <= 0 or sy <= 0:
        continue

    #dprint("\t",sx,sy)

    while sx > 0 and sy > 0 :
        sx = sx - 1
        sy = sy - 1
        if str(sx)+","+str(sy) in BL :          
            isflg = False  
            break

    if isflg and sy == 0:
        min = x
        break

for x in range(H):
    if str(x)+","+str(0) in BL :
        if min > x :
            min = x
            break
print(min)

Fixed submission:
# Debug Print
isdbg  = False
#isdbg  = True
def dprint(*value,sep=' ',end='\n'):
    if isdbg:
        print(*value,sep=sep,end=end)
    
# 入力を格納
H,W,N = map(int,input().split())

if isdbg:
    XY = [[0 for i in range(W)] for i in range(H)]
BL = {}
for i in range(N):
    x1,y1 = map(int,input().split())
    if isdbg:
        XY[x1-1][y1-1] = 1

    if x1-1 in BL :
        BL[x1-1].append(y1-1)
    else:
        BL[x1-1] = [y1-1]

TL = sorted(BL.items(),key= lambda x: x[0])

# 初期位置
if isdbg:
    for i in range(W):
        for j in range(H):
            dprint(XY[i][j],end='')
        dprint()
#print(TL)

maxr = 1
for i in range(H-1):

    if i+1 in BL:
        l = BL[i+1]
        l.sort()
        #print(l,maxr)
        for ll in l :
            if maxr > ll:
                print(i+1)
                exit(0)
            elif maxr == ll:
                maxr -= 1
                break
            else:
                break
        
    maxr += 1

print(H)

Buggy python submission (verdict: Runtime Error):
# Debug Print
isdbg = False
def dprint(*value,sep=' ',end='\n'):
    if isdbg:
        print(*value,sep=sep,end=end)

# 入力を格納
H,W,N = map(int,input().split())
XY = [[0 for i in range(W)] for i in range(H)]
for i in range(N):
    x1,y1 = map(int,input().split())
    XY[x1-1][y1-1] = 1

# 初期位置
if isdbg:
    for i in range(W):
        for j in range(H):
            dprint(XY[i][j],end='')
        dprint()

x = 0
y = 0
while x < W and XY[x+1][y] != 1:
   #print()

    # 斜め下方向に走査
    mx = x
    my = y
    while mx < W-1 and my < H-1:
        if XY[mx][my] == 0:
            # 高橋君が動けなくなる位置を発見
            if XY[mx+1][my] == 1:
                print(mx+1)
                exit(0)
        else:
            # 途上に1があったらサーチをやめる
            break
        mx +=1
        my +=1

    if isdbg:
        for i in range(W):
            for j in range(H):
                if i == x and j == y:
                    dprint(2,end='')
                else:
                    dprint(XY[i][j],end='')
            dprint()
        dprint("--")

    x = x + 1

Fixed submission:
# Debug Print
isdbg  = False
#isdbg  = True
def dprint(*value,sep=' ',end='\n'):
    if isdbg:
        print(*value,sep=sep,end=end)
    
# 入力を格納
H,W,N = map(int,input().split())

if isdbg:
    XY = [[0 for i in range(W)] for i in range(H)]
BL = {}
for i in range(N):
    x1,y1 = map(int,input().split())
    if isdbg:
        XY[x1-1][y1-1] = 1

    if x1-1 in BL :
        BL[x1-1].append(y1-1)
    else:
        BL[x1-1] = [y1-1]

TL = sorted(BL.items(),key= lambda x: x[0])

# 初期位置
if isdbg:
    for i in range(W):
        for j in range(H):
            dprint(XY[i][j],end='')
        dprint()
#print(TL)

maxr = 1
for i in range(H-1):

    if i+1 in BL:
        l = BL[i+1]
        l.sort()
        #print(l,maxr)
        for ll in l :
            if maxr > ll:
                print(i+1)
                exit(0)
            elif maxr == ll:
                maxr -= 1
                break
            else:
                break
        
    maxr += 1

print(H)