Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
H,W,K = list(map(int,input().split()))
C = [list(input()) for _ in range(H)]

def F1(c):
    for i in range(W):
        for j in range(H-1,-1,-1):
            if c[j][i] != 'X': continue
            for k in range(j-1,-1,-1):
                if c[k][i] != 'X':
                    c[j][i], c[k][i] = c[k][i], c[j][i]
                    break
    return c

def F2(c):
    delete_sum = 0
    for i in range(H):
        for j in range(W):
            if c[i][j] == 'X': continue
            tmp = c[i][j]
            count = 1
            for k in range(j+1,W):
                if c[i][k] == tmp:
                    count += 1
                else:
                    break
            if count >= K:
                for k in range(j,W):
                    if c[i][k] == tmp:
                        delete_sum += int(c[i][k])
                        c[i][k] = 'X'
                    else:
                        break
    return c, delete_sum

MAX = 0
for i in range(H):
    for j in range(W):
        tmpC = []
        for k in range(H):
            tmpC.append(C[k][:])
        tmpC[i][j] = 'X'
        tmpC = F1(tmpC)
        point = 0
        for k in range(1000):
            tmpC, delete_sum = F2(tmpC)
            if delete_sum == 0:
                break
            tmpC = F1(tmpC)
            point += 2**k*delete_sum
        MAX = max(MAX,point)
print(MAX)


Fixed submission:
H,W,K = list(map(int,input().split()))
C = [list(input()) for _ in range(H)]

def F1(c):
    for i in range(W):
        for j in range(H-1,-1,-1):
            if c[j][i] != 'X': continue
            for k in range(j-1,-1,-1):
                if c[k][i] != 'X':
                    c[j][i], c[k][i] = c[k][i], c[j][i]
                    break
    return c

def F2(c):
    delete_sum = 0
    for i in range(H):
        for j in range(W):
            if c[i][j] == 'X': continue
            tmp = c[i][j]
            count = 1
            for k in range(j+1,W):
                if c[i][k] == tmp:
                    count += 1
                else:
                    break
            if count >= K:
                for k in range(j,W):
                    if c[i][k] == tmp:
                        delete_sum += int(c[i][k])
                        c[i][k] = 'X'
                    else:
                        break
    return c, delete_sum

MAX = 0
for i in range(H):
    for j in range(W):
        tmpC = []
        for k in range(H):
            tmpC.append(C[k][:])
        tmpC[i][j] = 'X'
        tmpC = F1(tmpC)
        point = 0
        for k in range(1000):
            tmpC, delete_sum = F2(tmpC)
            if delete_sum == 0:
                break
            tmpC = F1(tmpC)
            point += 2**k*delete_sum
        MAX = max(MAX,point)
print(MAX)
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
HW = [list(map(str,input().split())) for _ in range(h)]
sharp = 0
for i in range(w):
  for j in range(h):
    if HW[i][j] == '#':
      sharp += 1

min_root = h + w - 1
if sharp == min_root:
  print('Possible')
else:
  print('Impossible')


Fixed submission:
def main():
  H, W = list(map(int, input().split()))

  count = 0

  for i in range(H):
    row = input()
    for j in range(W):
      if(row[j] == '#'):
        count += 1

  print("Possible" if W + H - 1 == count else "Impossible")

if __name__ == "__main__":
  main()

Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
HW = [list(map(int,input().split())) for _ in range(h)]
min_root = h + w - 1
if sharp == min_root:
  print('Possible')
else:
  print('Impossible')


Fixed submission:
def main():
  H, W = list(map(int, input().split()))

  count = 0

  for i in range(H):
    row = input()
    for j in range(W):
      if(row[j] == '#'):
        count += 1

  print("Possible" if W + H - 1 == count else "Impossible")

if __name__ == "__main__":
  main()

Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
HW = [list(map(int,input().split())) for _ in range(h)]
sharp = HW.count('#')
min_root = h + w - 1
if sharp == min_root:
  print('Possible')
else:
  print('Impossible')

Fixed submission:
def main():
  H, W = list(map(int, input().split()))

  count = 0

  for i in range(H):
    row = input()
    for j in range(W):
      if(row[j] == '#'):
        count += 1

  print("Possible" if W + H - 1 == count else "Impossible")

if __name__ == "__main__":
  main()
Buggy python submission (verdict: Runtime Error):
k,t = map(int,input().split())
A = list(map(int,input().split()))
at = max(A)
print(max(2*at−1−k,0))


Fixed submission:
k, t = map(int, input().split())
a = list(map(int, input().split()))
print(max(2*max(a)-k-1, 0))

Buggy python submission (verdict: Runtime Error):
k,t = map(int,input().split())
A = list(map(int,input().split()))
at = max(A)
print(max(at−1−(k−at),0))

Fixed submission:
k, t = map(int, input().split())
a = list(map(int, input().split()))
print(max(2*max(a)-k-1, 0))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if a == b == c:
  print(1)
elif a == b or b == c or c == a:
  print(2)
elif:
  print(3)

Fixed submission:
a,b,c = map(int,input().split())
if a == b == c:
  print(1)
elif a == b or b == c or c == a:
  print(2)
else:
  print(3)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n):
  b = A[i]
  if i+1 == A[b]:
    ans += 1
print(ans//2)
  


Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n):
    if A[A[i]-1] == i+1:
        ans += 1
print(ans//2)

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n):
  if i+1 == A[A[i]]:
    ans += 1
print(ans//2)
  


Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(n):
    if A[A[i]-1] == i+1:
        ans += 1
print(ans//2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if k >= n:
  print(k*x)
else:
print(k*x+(n-k)*y)

Fixed submission:
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N > K:
    print(K*X+((N-K)*Y))
else:
    print(N*X)
Buggy python submission (verdict: Runtime Error):
s = input()
N = s.count('N')
S = s.count('S')
E = s.count('E')
W = s.count('W')
if ((N >= 1 and S == 0) or (N == 0 and S >= 1) or 
    (E >= 1 and W == 0) or (E == 0 and W >= 1):
  print('NO')
else:
  print('Yes')


Fixed submission:
S =input()
if (('N' in S) == ('S' in S)) and (('W' in S) == ('E' in S)):
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s = input()
N = s.count('N')
S = s.count('S')
E = s.count('E')
W = s.count('W')
if ((N >= 1 and S == 0) or (N == 0 and S >= 1) or 
    (E >= 1 and W == 0) or (E == 0 and W >= 1):
  print('Yes')
else:
  print('No')


Fixed submission:
S =input()
if (('N' in S) == ('S' in S)) and (('W' in S) == ('E' in S)):
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s = input()
N = s.count('N')
S = s.count('S')
E = s.count('E')
W = s.count('W')
if (N >= 1 and S >= 1) or (E >= 1 and W >= 1) or s ='':
  print('Yes')
else:
  print('No')

Fixed submission:
S =input()
if (('N' in S) == ('S' in S)) and (('W' in S) == ('E' in S)):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
l,R, d = map(int, input()).split()

a =0
for i in range(l,R):
  if i % d == 0:
    a = a+1 

print(a)

Fixed submission:
l,R, d = map(int, input().split())

a =0
for i in range(l,R+1):
  if i % d == 0:
    a = a+1 

print(a)
Buggy python submission (verdict: Runtime Error):
def run(a, b, k):
    ans1 = a - k
    if ans1 < 0:
        ans2 = b + ans1
        ans1 = 0
    return ans1, ans2


def main():
    a, b, k = map(int, input().split())
    ans = run(a, b, k)
    print(ans[0], ans[1])


if __name__ == '__main__':
    main()


Fixed submission:
def run(a, b, k):
    ans1 = a - k
    ans2 = b
    if ans1 < 0:
        ans2 = b + ans1
        ans1 = 0
    if ans2 < 0:
        ans2 = 0
    return ans1, ans2


def main():
    a, b, k = map(int, input().split())
    ans = run(a, b, k)
    print(ans[0], ans[1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import math


def run(A, B):
    return A * B // math.gcd(A, B)


def main():
    A, B = map(int, input().split())
    print(run(A, B))


if __name__ == '__main__':
    main()


Fixed submission:
import fractions


def run(A, B):
    return A * B // fractions.gcd(A, B)


def main():
    A, B = map(int, input().split())
    print(run(A, B))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def run(N, a):
    ans = -1
    cnt = 0
    idx = 0
    match = False
    for i in range(1, N+1):
        if idx > N - 1:
            break
        for ai in a[idx:]:
            idx += 1
            if ai == i:
                # print('match', i, ai, idx)
                match = True
                break
            else:
                # print('break', i, ai, idx)
                cnt += 1
    if match:
        ans = cnt
    return ans


def main():
    N = int(input())
    a = list(map(int, input().split()))
    print(run(N, a))


if __name__ == '__main__':
    main()


Fixed submission:
def run(N, a):
    ans = -1
    cnt = 0
    idx = 0
    i = 1
    match = False
    while idx < N:
        ai = a[idx]
        idx += 1
        if ai == i:
            # print('match', i, ai, idx)
            match = True
            i += 1
        else:
            # print('break', i, ai, idx)
            cnt += 1
    if match:
        ans = cnt
    return ans


def main():
    N = int(input())
    a = list(map(int, input().split()))
    print(run(N, a))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import math


def run(N):
    ans = 0
    if N % 2 == 0:
        for i in range(int(math.log(N, 5))):
            ans += N // (10 * (5**i))
    return ans


def main():
    N = int(input())
    print(run(N))


if __name__ == '__main__':
    main()


Fixed submission:
import math


def run(N):
    if N == 0:
        return 0
    ans = 0
    if N % 2 == 0:
        for i in range(int(math.log(N, 5))):
            ans += N // (10 * (5**i))
    return ans


def main():
    N = int(input())
    print(run(N))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import math


def run(N):
    ans = 0
    if N % 2 == 0:
        for i in range(int(math.log(N, 5))):
            ans += N // (10 * (5**i))
    return ans


def main():
    N = int(input())
    print(run(N))


if __name__ == '__main__':
    main()


Fixed submission:
import math


def run(N):
    if N == 0:
        return 0
    ans = 0
    if N % 2 == 0:
        for i in range(int(math.log(N, 5))):
            ans += N // (10 * (5**i))
    return ans


def main():
    N = int(input())
    print(run(N))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def run(N, K, A):
    ret = 0
    for i in range(K+1):
        ret = max(xxor(i, A), ret)
    return ret


def xxor(X, A):
    ret = 0
    for i in range(len(A)):
        ret += X ^ A[i]
    return ret


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    print(run(N, K, A))


if __name__ == '__main__':
    main()

Fixed submission:
def run(N, K, A):
    '''
    K <= 10^12 ~= 2^40
    Kの2進数における各桁ごとの最大となるKを求めることができる(O(logK))
    Kの2進数における最初の1を0に変える位置をk_nとする
    最初に変える位置の前はすべてKと同じ、それ以降は最大を取るものを選択する(O(log(K)))
    k_nが0の場合は、全て同じパターンとしてスキップする
    上記の最大のものを習得する
    '''
    cnt1 = []

    # Kの2進数の桁を取得
    k_n = len(bin(K)) - 2

    # Aの2進数の最大桁を取得
    max_a = len(bin(max(A))) - 2
    max_a = max(max_a, k_n)

    # 数値をビットに変換
    K_bit = '{:b}'.format(K).zfill(max_a)
    A_bit = []
    for i in range(len(A)):
        A_bit.append('{:b}'.format(A[i]).zfill(max_a))

    # 2進数の各桁の値を事前計算
    bit_v = []
    for i in range(max_a):
        bit_v.append(2**(max_a-i-1))

    # A_bitの各桁の1の数を数える(O(NlogK))
    for j in range(max_a):
        cnt = 0
        for i in range(N):
            if A_bit[i][j] == '1':
                cnt += 1
        cnt1.append(cnt)

    # Kの上からi+1桁目を1=>0にすると考える
    # k_n+1桁目の場合はすべて同じ場合
    ret = 1
    for i in range(k_n+1):
        tmp1 = 0
        max_flg = False
        for j in range(max_a):
            if max_a - j == k_n - i:  # Kの対象桁を0とするパターン
                # 1だと0に変える、0だと0のまま
                tmp1 += bit_v[j] * cnt1[j]
                # 1=>0の時はフラグを付与
                if K_bit[j] == '1':
                    max_flg = True
            elif not max_flg:  # Kの各桁をそのままに使うパターン
                # K[j]が0だとcnt1[j]を、1だとN-cnt1[j]をかける
                tmp1 += bit_v[j] * (cnt1[j]**(1-int(K_bit[j]))) * ((N-cnt1[j])**(int(K_bit[j])))
            else:  # Kの前の桁で1=>0として、その後は最大になるようにとるパターン
                tmp1 += bit_v[j] * max(cnt1[j], N - cnt1[j])
        ret = max(ret, tmp1)
    return ret


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    print(run(N, K, A))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def run(a):
    return a[0] * a[1] // 2


def main():
    a = map(int, input().split())
    print(run(a))


if __name__ == '__main__':
    main()


Fixed submission:
def run(a):
    return a[0] * a[1] // 2


def main():
    a = list(map(int, input().split()))
    print(run(a))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def run(K):
    n = 0
    trouts = []
    div = 0
    for i in range(2, 500):
        if K % (i**2) == 0:
            div = i
            break
    if K <= 500:
        for i in range(K):
            n = K
            trouts.append([i+1]*K)
    else:
        n = div
        cnt = K // div
        for i in range(cnt):
            trouts.append([j+1 for j in range(i*div, (i+1)*div)]*(K//(div**2)))
    return (n, trouts)


def main():
    K = int(input())
    n, trouts = run(K)
    print(n)
    for i in range(len(trouts)):
        print(' '.join(map(str, trouts[i])))


if __name__ == '__main__':
    main()


Fixed submission:
def run(K):
    n_max = 500
    '''
    K <= 500の場合は、n = Kとして1行につき1色を塗ればよい
        111
        222
        333
    Kが4の倍数の場合は、n = K/2以下の塗り方ができる
        1234
        5678
        3412
        7856
    上記でn+i+1色をi色に塗り替えても条件を満たす
        1234
        5178
        3412
        7851
    K = 1000の時は、n = 500で満たし、塗り替え操作で501～999まで表現できる
    '''
    n = 0
    trouts = []
    if K <= n_max:
        n = K
        for i in range(K):
            trouts.append([i+1]*K)
    else:
        n = n_max
        change = n_max*2 - K
        c1 = [i for i in range(1, n_max+1)]
        # c - 1 + n_max - c + 1 (c>0)
        # 0 + n_max (c==0)
        c2 = [i for i in range(2, change+1)] + [i for i in range(n_max+1, n_max*2+1-change)]
        if change > 0:
            c2 += [1]
        for i in range(n_max):
            shift = (i//2) * 2
            if i % 2 == 0:
                trouts.append(c1[shift:] + c1[:shift])
            else:
                trouts.append(c2[shift:] + c2[:shift])
    return (n, trouts)


def main():
    K = int(input())
    n, trouts = run(K)
    print(n)
    for i in range(len(trouts)):
        print(' '.join(map(str, trouts[i])))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def run(S):
    s = 0
    f = len(S) - 1
    cnt = 0
    while s < f:
        while S[s] == 'W' or S[f] == 'B':
            if S[s] == 'W':
                s += 1
            elif S[f] == 'B':
                f -= 1
        for i in range(s, f):
            if S[i] == 'B' and S[i+1] == 'W':
                cnt += 1
                S = S[:i] + 'WB' + S[i+2:]
    return cnt


def main():
    S = input()
    print(run(S))


if __name__ == '__main__':
    main()


Fixed submission:
def run(S):
    '''
    Bをすべて右に、Wをすべて左に移動する回数を求める
    '''
    cnt = 0
    n = len(S)
    cnt_B = 0
    cnt_W = 0
    for i in range(len(S)):
        if S[i] == 'B':
            cnt_B += 1
            cnt += n - (i+cnt_B)
        else:
            cnt += i - cnt_W
            cnt_W += 1
    return int(cnt / 2)


def main():
    S = input()
    print(run(S))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import math


def run(n, m, s, t):
    ret = -1
    if s[0] != t[0]:
        return ret
    g = fractions.gcd(n, m)
    if g == 1:
        big = max([n, m])
        small = min([n, m])
        if small == 1:
            for i in range(math.sqrt(n)):
                if big % i == 0:
                    return i
        else:
            return n*m
    n_s = n//g
    m_s = m//g
    mn = n_s * m_s
    small = min([g, mn])
    for j in range(1, g+1):
        n_eval = j*n_s
        m_eval = j*m_s
        eval = True
        for i in range(1, g):
            if i*n_eval >= n:
                eval = False
                continue
            if i*m_eval >= m:
                eval = False
                continue
            if s[i*n_eval] != t[i*m_eval]:
                eval = False
                continue
        if eval:
            return n_eval * m_eval * g
    return -1


def main():
    n, m = map(int, input().split())
    s = input()
    t = input()
    print(run(n, m, s, t))


if __name__ == '__main__':
    main()


Fixed submission:
import fractions
import math


def run(n, m, s, t):
    ret = -1
    if s[0] != t[0]:
        return ret
    g = fractions.gcd(n, m)
    if g == 1:
        big = max([n, m])
        small = min([n, m])
        if small == 1:
            for i in range(math.sqrt(n)):
                if big % i == 0:
                    return i
        else:
            return n*m
    n_s = n//g
    m_s = m//g
    mn = n_s * m_s
    small = min([g, mn])
    for j in range(1, g+1):
        if n_s * m_s < j:
            return -1
        n_eval = j*n_s
        m_eval = j*m_s
        eval = True
        for i in range(1, g):
            if i*n_eval >= n:
                eval = False
                continue
            if i*m_eval >= m:
                eval = False
                continue
            if s[i*n_eval] != t[i*m_eval]:
                eval = False
                continue
        if eval:
            return n_eval * m_eval * g
    return -1


def main():
    n, m = map(int, input().split())
    s = input()
    t = input()
    print(run(n, m, s, t))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import collections


def run(s, t):
    ss = collections.Counter(s)
    tt = collections.Counter(t)
    if sorted(list(ss.values())) == sorted(list(tt.values())):
        return 'Yes'
    else:
        return 'No'


def main():
    s = input()
    t = input()
    print(run(s, t))


if __name__ == '__main__':
    main()


Fixed submission:
def run(a, b, c):
    s = sorted([a, b, c])
    return 10*s[2]+s[1]+s[0]


def main():
    a, b, c = map(int, input().split())
    print(run(a, b, c))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def run(s, t):
    key_s = tuple(s)
    key_t = tuple(t)
    dic_s = {}
    dic_t = {}
    for key in key_s:
        dic_s[key] = s.count(key)
    for key in key_t:
        dic_t[key] = t.count(key)
    if sorted(dic_s.values()) == sorted(dic_t.values()):
        return 'Yes'
    else:
        return 'No'


def main():
    s = input()
    t = input()
    print(run(s, t))


if __name__ == '__main__':
    main()


Fixed submission:
import collections


def run(s, t):
    ss = sorted(list(collections.Counter(s).values()))
    tt = sorted(list(collections.Counter(t).values()))
    if ss == tt:
        return 'Yes'
    else:
        return 'No'


def main():
    s = input()
    t = input()
    print(run(s, t))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def run(n, x, xx):
    xx.append(x)
    xx = sorted(xx)
    d = [xx[i+1]-xx[i] for i in range(n)]
    d = sorted(d)
    min_d = d[0]
    if len(d) == 1:
        return min_d
    for i in range(1, len(d)):
        min_d = fractions.gcd(min_d, d[i])
    return min_d


def main():
    n, x = map(int, input().split())
    xx = list(map(int, input().split()))
    print(run(n, x, xx))


if __name__ == '__main__':
    main()


Fixed submission:
import fractions


def run(n, x, xx):
    xx.append(x)
    xx = sorted(xx)
    d = [xx[i+1]-xx[i] for i in range(n)]
    d = sorted(d)
    min_d = d[0]
    if len(d) == 1:
        pass
    else:
        for i in range(1, len(d)):
            min_d = fractions.gcd(min_d, d[i])
    return min_d


def main():
    n, x = map(int, input().split())
    xx = list(map(int, input().split()))
    print(run(n, x, xx))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import math


def run(n, x, xx):
    xx.append(x)
    xx = sorted(xx)
    d = [xx[i+1]-xx[i] for i in range(n)]
    d = sorted(d)
    min_d = d[0]
    if len(d) == 1:
        return min_d
    for i in range(1, len(d)):
        min_d = math.gcd(min_d, d[i])
        if d[i] % min_d == 0:
            return min_d


def main():
    n, x = map(int, input().split())
    xx = list(map(int, input().split()))
    print(run(n, x, xx))


if __name__ == '__main__':
    main()


Fixed submission:
import fractions


def run(n, x, xx):
    xx.append(x)
    xx = sorted(xx)
    d = [xx[i+1]-xx[i] for i in range(n)]
    d = sorted(d)
    min_d = d[0]
    if len(d) == 1:
        pass
    else:
        for i in range(1, len(d)):
            min_d = fractions.gcd(min_d, d[i])
    return min_d


def main():
    n, x = map(int, input().split())
    xx = list(map(int, input().split()))
    print(run(n, x, xx))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import unittest

from app.ABC103_A import run


class TestSample(unittest.TestCase):
    def test_run(self):
        self.assertEqual(run([1, 6, 3]), 5)
        self.assertEqual(run([11, 5, 5]), 6)
        self.assertEqual(run([100, 100, 100]), 0)


if __name__ == '__main__':
    unittest.main()


Fixed submission:
def run(a):
    return max(a) - min(a)


def read_line():
    a = list(map(int, input().split()))
    return a


def main():
    a = read_line()
    print(run(a))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def run(n, m, ab):
    ab = sorted(ab)
    cnt = 1
    b = ab[0][1]
    for i in range(1, m):
        a = ab[i][0]
        if b < a:
            cnt += 1
        b = ab[i][1]
    return cnt


def read_line():
    n, m = list(map(int, input().split()))
    ab = []
    for i in len(m):
        a, b = list(map(int, input().split()))
        ab.append([a, b])
    return (n, m, ab)


def main():
    n, m, ab = read_line()
    print(run(n, m, ab))


if __name__ == '__main__':
    main()


Fixed submission:
def run(n, m, ab):
    ab = sorted(ab)
    cnt = 1
    b = ab[0][1]
    c = b
    for i in range(1, m):
        a = ab[i][0]
        b = ab[i][1]
        if a < c and c <= b:
            pass
        elif c <= a:
            cnt += 1
            c = b
        else:
            c = b
    return cnt


def read_line():
    n, m = list(map(int, input().split()))
    ab = []
    for i in range(m):
        a, b = list(map(int, input().split()))
        ab.append([a, b])
    return (n, m, ab)


def main():
    n, m, ab = read_line()
    print(run(n, m, ab))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def run(n):
    if n % 2 == 0:
        return n
    else:
        return n * 2


def read_line():
    n = map(int, input().split())
    return n


def main():
    n = read_line()
    print(run(n))


if __name__ == '__main__':
    main()


Fixed submission:
def run(n):
    if n % 2 == 0:
        return n
    else:
        return n * 2


def read_line():
    n = int(input())
    return n


def main():
    n = read_line()
    print(run(n))


if __name__ == '__main__':
    main()