Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    ans = []
    for _ in range(n):
        a_num = int(input())
        t = []
        for _ in range(a_num):
            t.append(tuple(map(int, input().split())))
        t = tuple(t)
        ans.append(t)
   
    r = 0
    for bit in range(1 << n):
        honest = []
        for i1 in range(n):
            mask = 1<<i1
            if bit & mask:
                honest.append(i1)

        flag = 1
        if not honest:
            flag = 0
        for eh in honest:
            say = ans[eh]
            for esay in say:
                if esay[0] - 1 in honest:
                    if esay[1] == 0:
                        flag = 0
                else:
                    if esay[1]:
                        flag = 0
        if flag:
            r = max(r, len(honest))
    print(r)

if __name__ == '__main__':
    main(

Fixed submission:

def main():
    n = int(input())
    ans = []
    for _ in range(n):
        a_num = int(input())
        t = []
        for _ in range(a_num):
            t.append(tuple(map(int, input().split())))
        t = tuple(t)
        ans.append(t)

    r = 0
    for bit in range(1 << n):
        honest = []
        for i1 in range(n):
            mask = 1<<i1
            if bit & mask:
                honest.append(i1)
        flag = 1       
        for eh in honest:
            say = ans[eh]
            for esay in say:
                if esay[0] - 1 in honest:
                    if esay[1] == 0:
                        flag = 0
                else:
                    if esay[1]:
                        flag = 0
        if flag:
            r = max(r, len(honest))
    print(r)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
d = ['SUN','MON','TUE','WED','THUv,'FRI','SAT'].index(input())
print(7 - d)

Fixed submission:
d = ['SUN','MON','TUE','WED','THU','FRI','SAT'].index(input())
print(7 - d)
Buggy python submission (verdict: Runtime Error):

import sys
input = sys.stdin.readline
from math import factorial
large_p = 10**9 + 7

def comb_mod(n, r, large_p):
    a, b = 1, 1
    r = min(r, n - r)
    for i in range(r):
        a = a * (n - i) % large_p
        b = b * (r - i) % large_p
    return a * pow(b, large_p - 2, large_p) % large_p

def main():
    x, y = map(int, input().split())
    p1, p2 = 0, 0
    p1_2, P2_2 = 0, 0
    for i1 in range(1, x//2 + 1):
        if x - i1 == (y - i1 * 2) * 2:
            p1 = i1
            p2 = y - i1 * 2
            break
    for i2 in range(1, y//2 + 1):
        if (x - i2 * 2) * 2 == y - i2:
            p1_2 = i2
            p2_2 = x - i2 * 2

    p1 = min(p1, p1_2)
    p2 = min(p2, p2_2)
    r = comb_mod(p1 + p2, p1, large_p)
    print(r)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
large_p = 10**9 + 7

def comb_mod(n, r, large_p):
    a, b = 1, 1
    r = min(r, n - r)
    for i in range(r):
        a = a * (n - i) % large_p
        b = b * (r - i) % large_p
    return a * pow(b, large_p - 2, large_p) % large_p

def main():
    x, y = map(int, input().split())
    if (x + y) % 3 != 0:
        print(0)
        sys.exit()
    p1, p2 = 0, 0
    for i1 in range(0, x + 1):
        if x - i1 == (y - i1 * 2) * 2:
            p1 = i1
            p2 = y - i1 * 2
            break
    if p1 < 0 or p2 < 0 or (p1 == 0 and p2 == 0):
        print(0)
        sys.exit()

    r = comb_mod(p1 + p2, p1, large_p)
    print(r)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
#from bisect import bisect_left
from itertools import combinations
def main():
    n, *l = map(int, read().split())
    com = tuple(combinations(l, 3))
    r = 0
    for c in com:
        r += sum(c) > max(c) * 2
    print(r)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
from bisect import bisect_left
def main():
    n, *l = map(int, read().split())
    l.sort()
    r = n * (n - 1) * (n - 2) // 6
    for i1 in range(n - 2):
        for i2 in range(i1 + 1, n - 1):
            r -= (n - bisect_left(l, l[i1] + l[i2]))
    print(r)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
#from bisect import bisect_left
from itertools import combinations
def main():
    n, *l = map(int, read().split())
    com = tuple(combinations(l, 3))
    r = 0
    for c in com:
        r += sum(c) > max(c) * 2
    print(r)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
from bisect import bisect_left
def main():
    n, *l = map(int, read().split())
    l.sort()
    r = n * (n - 1) * (n - 2) // 6
    for i1 in range(n - 2):
        for i2 in range(i1 + 1, n - 1):
            r -= (n - bisect_left(l, l[i1] + l[i2]))
    print(r)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
r = ((r//2) + (r%2))  / n
print(r)

Fixed submission:
n = int(input())
r = ((n//2) + (n%2))  / n
print(r)

Buggy python submission (verdict: Runtime Error):
n = int(input())
r = ((r//2) + (r%2))  / r
print(r)

Fixed submission:
n = int(input())
r = ((n//2) + (n%2))  / n
print(r)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

if (a - b) % 2 == 0:
  r = int(abs(a - b)/2 + min(a, b) )
else:
  r = 'IMPOSSIBLE'
print(r)

Fixed submission:
a, b = map(int, input().split())
 
if (a - b) % 2 == 0:
  r = int(abs(a - b)/2 + min(a, b))
else:
  r = 'IMPOSSIBLE'
print(r)
Buggy python submission (verdict: Runtime Error):
S = input()

if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
  r = 'Bad'
else:
  r - 'Good'

print(r)

Fixed submission:
S = input()
 
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
  r = 'Bad'
else:
  r = 'Good'
 
print(r)
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import sqrt
def main():
    w, h, x, y = map(int, input().split())
    if w / x == 2 and h / y == 2:
        r = x * h
        print(r, 1)
    elif w / x == 2 or h / y == 2:
        if w / x == 2:
            r = x * h
            print(r, 0)
        else:
            r = y * w
            print(r, 0)
    else:
        print(w * h / 2, 0)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    w, h, x, y = map(int, input().split())
    if x == 0 or y == 0:
        print(w * h / 2, 0)
    elif w / x == 2 and h / y == 2:
        r = x * h
        print(r, 1)
    elif w / x == 2 or h / y == 2:
        if w / x == 2:
            r = x * h
            print(r, 0)
        else:
            r = y * w
            print(r, 0)
    else:
        print(w * h / 2, 0)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import sqrt
def main():
    w, h, x, y = map(int, input().split())
    if w / x == 2 and h / y == 2:
        r = x * h
        print(r, 1)
    elif w / x == 2 or h / y == 2:
        if w / x == 2:
            r = x * h
            print(r, 0)
        else:
            r = y * w
            print(r, 0)
    else:
        print(w * h / 2, 0)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    w, h, x, y = map(int, input().split())
    if x == 0 or y == 0:
        print(w * h / 2, 0)
    elif w / x == 2 and h / y == 2:
        r = x * h
        print(r, 1)
    elif w / x == 2 or h / y == 2:
        if w / x == 2:
            r = x * h
            print(r, 0)
        else:
            r = y * w
            print(r, 0)
    else:
        print(w * h / 2, 0)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
S = input()

r = S[:K]
r = r + S[K].lower()
r = r + S[K+1:]

print(r)

Fixed submission:
N, K = map(int,input().split())
S = input()
K = K - 1
r = S[:K]
r = r + S[K].lower()
r = r + S[K+1:]
 
print(r)
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    def dfs(node):
        for adjnode in edges[node]:
            if colors[adjnode[0]] == -1:
                if adjnode[1] % 2 == 0:
                    colors[adjnode[0]] = colors[node]
                else:
                    colors[adjnode[0]] = colors[node] ^ 1
                dfs(adjnode[0])
    # input
    n = int(input())
    edges = {e: [] for e in range(n)}
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        edges[u].append((v, w))
        edges[v].append((u, w))
    # process
    colors = [-1] * n
    colors[0] = 0
    dfs(0)
    # output
    print(*colors, sep='\n')


if __name__ == '__main__':
    main()

Fixed submission:
from copy import deepcopy
from collections import deque
def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    def unite(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True
    def roots():
        return [i for i, x in enumerate(par) if x < 0]

    n = int(input())
    par = [-1] * n
    uvw = {e:[] for e in range(n)}

    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        uvw[u].append((u, v, w))
        uvw[v].append((v, u, w))
        unite(u, v)
    root_node = roots()[0]
    color = [-1] * n
    color[root_node] = 0
    node_next = deque()
    node_next.append(root_node)
    node_next_next = deque()
    node_seen = set()

    while len(node_seen) < n:
        while node_next:
            node_togo = node_next.popleft()
            if node_togo in node_seen:
                continue
            else:
                node_seen.add(node_togo)
            # 次の層のノード群情報を取得し、「次にみるノードlist」にいれる。
            node_adj = uvw[node_togo]
            node_next_next += [i[1] for i in node_adj]
            # 次の層を処理＝色塗りする
            for adj in node_adj:
                if adj[1] in node_seen or color[adj[1]] != -1:
                    continue
                if adj[2] % 2 == 0:
                    color[adj[1]] = color[node_togo]
                else:
                    color[adj[1]] = color[node_togo] ^ 1
        node_next = deepcopy(node_next_next)
        node_next_next = deque()
    print(*color, sep='\n')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
l1 = []
for _ in range(6):
  l1.append(int(input())
 
if (l1[4] - l1[0]) > l1[5]:
  r = ':('
else:
  r = 'Yay!'
  
  
print(r)

Fixed submission:
l1 = []
for _ in range(6):
  l1.append(int(input()))
 
if (l1[4] - l1[0]) > l1[5]:
  r = ':('
else:
  r = 'Yay!'
  
  
print(r)

Buggy python submission (verdict: Runtime Error):
l1
for _ in range(6):
  l1.append(int(input()))

if (l1[4] - l1[0]) < l1[5]:
  r = ':('
else:
  r = 'Yay!'
  
  
print(r)

Fixed submission:
l1 = []
for _ in range(6):
  l1.append(int(input()))
 
if (l1[4] - l1[0]) > l1[5]:
  r = ':('
else:
  r = 'Yay!'
  
  
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int, input().split()))

h.append(9999)
dp = [[0]*(n+1) for _ in range(n)]

def do_dp():
  for i in range(1,n):
    for j in range(n-1):
      #print("i:{} j:{}".format(i, j))
      if dp[i][j+1] == 0:
        dp[i][j+1] = dp[i-1][j] + abs(h[j] - h[j+1])
      else:
        dp[i][j+1] = min(dp[i][j+1],dp[i-1][j] + abs(h[j] - h[j+1]))
      if dp[i][j+2] == 0:
        dp[i][j+2] = dp[i-1][j] + abs(h[j] - h[j+2])
      else:
        dp[i][j+2] = min(dp[i][j+2],dp[i-1][j] + abs(h[j] - h[j+2]))
      #print(dp)
  return dp[n-1][n-1]
  
r = do_dp()
print(r)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))

dp=[0] * n
for i in range(1, n):
  if i - 2 < 0:
    dp[i] = dp[i-1] + abs(h[i] - h[i-1])
  else:
    dp[i] = min(dp[i-2]+abs(h[i] - h[i-2]) ,dp[i-1]+abs(h[i]-h[i-1]) )
  
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
def main():
    n, w_max = map(int, input().split())
    dp = [[0] * (w_max + 1) for _ in range(n + 1)]
    items = [tuple(map(int, input().split())) for _ in range(n)]
    for i1 in range(1, n + 1):
        w, v = items[i1 - 1][0], items[i1 - 1][1]
        for col in range(1, w_max + 1):
            if w <= col:
                dp[i1][col] = max(dp[i1 - 1][col], dp[i1 - 1][col - w] + v)
            else:
                dp[i1][col] = dp[i1 - 1][col]

    print(dp[-1][-1])

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n, w_max = map(int, input().split())
    items = [tuple(map(int, input().split())) for _ in range(n)]
    inf = float('inf')
    dp = [[inf] * 100001 for _ in range(n + 1)]
    dp[0][0] = 0
    for i1 in range(1, n + 1):
        w, v = items[i1 - 1][0], items[i1 - 1][1]
        for col in range(1, 100001):
            if v >= col:
                tmp1 = w
            else:
                tmp1 = dp[i1 - 1][col - v] + w
            dp[i1][col] = min(dp[i1 - 1][col], tmp1)
    for i2 in range(100000, 0, -1):
        if dp[-1][i2] <= w_max:
            print(i2)
            sys.exit()

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
n, w = map(int, input().split())

dp = [0]*(w+1)

for _ in range(n):
  wei, v = map(int, input().split())
  dp_1 = dp[:]
  for j in range(w + 1):
    if j - wei >= 0:
      dp[j] = dp_1[j-wei] + v if (dp_1[j-wei] + v) > dp_1[j] else dp[j]
  
print(dp[w])

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n, w_max = map(int, input().split())
    items = [tuple(map(int, input().split())) for _ in range(n)]
    inf = float('inf')
    dp = [[inf] * 100001 for _ in range(n + 1)]
    dp[0][0] = 0
    for i1 in range(1, n + 1):
        w, v = items[i1 - 1][0], items[i1 - 1][1]
        for col in range(1, 100001):
            if v >= col:
                tmp1 = w
            else:
                tmp1 = dp[i1 - 1][col - v] + w
            dp[i1][col] = min(dp[i1 - 1][col], tmp1)
    for i2 in range(100000, 0, -1):
        if dp[-1][i2] <= w_max:
            print(i2)
            sys.exit()

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    p = tuple(map(float, input().split()))
    
    dp = [[0.0] * (n + 1) for _ in range(n + 1)]
    dp[0][0] = 1.0 
    for i0 in range(1, n + 1):
        dp[i0][0] = dp[i0-1][0] * pr[i0-1]

    for i1 in range(1, n + 1):
        pe = p[i1 - 1]
        pre = 1 - pe
        for i2 in range(1, i1 + 1):
            dp[i1][i2] = dp[i1-1][i2] * pre + dp[i1-1][i2-1] * pe

    r = sum(dp[n][n//2+1:])
    print(r)

if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    p = tuple(map(float, input().split()))
    # pr = [1 - pi for pi in p]
    # DPの二次元配列を行i1＝コインの枚数、列i2＝表がでたコインの枚数、で構築する。
    # DP[][]の初期値は0。ただし0列(表が0枚になる確率)をまず初期化する。
    # DP[i1][i2]の値は、DP[i1-1][i2] * pr + DP[i1-1][i2-1] * p
    # 「表の枚数＞裏の枚数になる確率」は、DPの最下行のX列から右の列の価の合計。
    dp = [[0.0] * (n + 1) for _ in range(n + 1)]
    # ０列目を初期化する。
    dp[0][0] = 1.0 #コイン0枚目で表が０枚の確率＝１
    for i0 in range(1, n + 1):
        dp[i0][0] = dp[i0-1][0] * (1 - p[i0-1])

    for i1 in range(1, n + 1):
        pe = p[i1 - 1]
        pre = 1 - pe
        for i2 in range(1, i1 + 1):
            dp[i1][i2] = dp[i1-1][i2] * pre + dp[i1-1][i2-1] * pe

    r = sum(dp[n][n//2+1:])
    print(r)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    p = tuple(map(float, input().split()))
    pr = [1 - pi for pi in p]
    # DPの二次元配列を行i1＝コインの枚数、列i2＝表がでたコインの枚数、で構築する。
    # DP[][]の初期値は0。ただし0列(表が0枚になる確率)をまず初期化する。
    # DP[i1][i2]の値は、DP[i1-1][i2] * pr + DP[i1-1][i2-1] * p
    # 「表の枚数＞裏の枚数になる確率」は、DPの最下行のX列から右の列の価の合計。
    dp = [[0.0] * (n + 1) for _ in range(n + 1)]
    # ０列目を初期化する。
    dp[0][0] = 1.0 #コイン0枚目で表が０枚の確率＝１
    for i0 in range(1, n + 1):
        dp[i0][0] = dp[i0-1][0] * pr[i0-1]

    for i1 in range(1, n + 1):
        for i2 in range(1, n + 1):
            dp[i1][i2] = dp[i1-1][i2] * pr[i1-1] + dp[i1-1][i2-1] * p[i1-1]
    r = sum(dp[n][n//2+1:])
    print(r)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    n = int(input())
    p = tuple(map(float, input().split()))
    # pr = [1 - pi for pi in p]
    # DPの二次元配列を行i1＝コインの枚数、列i2＝表がでたコインの枚数、で構築する。
    # DP[][]の初期値は0。ただし0列(表が0枚になる確率)をまず初期化する。
    # DP[i1][i2]の値は、DP[i1-1][i2] * pr + DP[i1-1][i2-1] * p
    # 「表の枚数＞裏の枚数になる確率」は、DPの最下行のX列から右の列の価の合計。
    dp = [[0.0] * (n + 1) for _ in range(n + 1)]
    # ０列目を初期化する。
    dp[0][0] = 1.0 #コイン0枚目で表が０枚の確率＝１
    for i0 in range(1, n + 1):
        dp[i0][0] = dp[i0-1][0] * (1 - p[i0-1])

    for i1 in range(1, n + 1):
        pe = p[i1 - 1]
        pre = 1 - pe
        for i2 in range(1, i1 + 1):
            dp[i1][i2] = dp[i1-1][i2] * pre + dp[i1-1][i2-1] * pe

    r = sum(dp[n][n//2+1:])
    print(r)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    dp = [[0] * (n + 1) for _ in range(n+1)]

    for len in range(1, n + 1):
        for i in range(0, n - len + 1):
            j = i + len
            if (n - len) % 2 == 0:
                dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1])
            else:
                dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1])
    print(dp[0][n])


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    dp = [[0] * (n + 1) for _ in range(n+1)]

    for len in range(1, n + 1):
        for i in range(0, n - len + 1):
            j = i + len
            if (n - len) % 2 == 0:
                dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1])
            else:
                dp[i][j] = min(dp[i+1][j] - a[i], dp[i][j-1] - a[j-1])
    print(dp[0][n])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
import sys
input = sys.stdin.readline
from itertools import chain

dp = []
dp2 = []
aac = []

def fdp(l, r):
    global dp, dp2
    if dp2[l][r]:
        return dp[l][r]
    else:
        dp2[l][r] = 1
        if l == r:
            return 0
        result_tmp = float('inf')
        for kugiri in range(l, r):
            result_tmp = min(result_tmp, fdp(l, kugiri) + fdp(kugiri+1, r))
        result = result_tmp + (aac[r+1] - aac[l])
        dp[l][r] = result
        return result
def main():
    global dp, dp2, aac
    n = int(input())
    a = tuple(map(int, input().split()))
    aac = list(accumulate(a))
    aac = tuple(chain([0], aac))
    dp = [[0] * n for _ in range(n)]
    dp2 = [[0] * n for _ in range(n)]
    fdp(0, n - 1)
    print(dp[0][-1])
if __name__ == '__main__':
    main()

Fixed submission:
from itertools import accumulate
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from itertools import chain

dp = []
dp2 = []
aac = []

def fdp(l, r):
    global dp, dp2
    if dp2[l][r]:
        return dp[l][r]
    else:
        dp2[l][r] = 1
        if l == r:
            return 0
        result_tmp = float('inf')
        for kugiri in range(l, r):
            result_tmp = min(result_tmp, fdp(l, kugiri) + fdp(kugiri+1, r))
        result = result_tmp + (aac[r+1] - aac[l])
        dp[l][r] = result
        return result
def main():
    global dp, dp2, aac
    n = int(input())
    a = tuple(map(int, input().split()))
    aac = list(accumulate(a))
    aac = tuple(chain([0], aac))
    dp = [[0] * n for _ in range(n)]
    dp2 = [[0] * n for _ in range(n)]
    fdp(0, n - 1)
    print(dp[0][-1])
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
s = input().split()
r = 0
if s[0] == '1':
  r += 900
else:
  r += 100
if s[1] == '1':
  r += 90
else:
  r += 10 
if s[2] == '1':
  r += 9
else:
  r += 1 

print(r)

Fixed submission:
s = input()
r = 0
if s[0] == '1':
  r += 900
else:
  r += 100
if s[1] == '1':
  r += 90
else:
  r += 10 
if s[2] == '1':
  r += 9
else:
  r += 1 
print(r)
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int, input().split())
r = max(A,B,C)*9 + sum(A, B, C)
print(int(r))

Fixed submission:
A,B,C = map(int, input().split())
r = max(A,B,C)*9 + A+B+C
print(int(r))
Buggy python submission (verdict: Runtime Error):

dp = []
train = []

def subq(l, r):
    global dp, train
    if l == 0 or r == 0:
        return 0
    else:
        tmp1 = dp[l][r]
        if tmp1 != -1:
            return tmp1
        else:
            tmp2 = train[l][r] + subq(l - 1, r) + subq(l, r - 1) -  subq(l - 1, r - 1)
            dp[l][r] = tmp2
            return tmp2

def main():
    global dp, train
    n, m, q = map(int, input().split())
    dp = [[-1] * (n+1) for _ in range(n+1)]
    train = [[0] * (n+1) for _ in range(n+1)]
    for _ in range(m):
        l, r = input().split()
        l = int(l)
        r = int(r)
        train[int(l)][int(r)] += 1


    for _ in range(q):
        p, q = input().split()
        p = int(p)
        q = int(q)
        r = subq(q, q) - subq(p-1, q) - subq(q, p-1) + subq(p-1, p-1)
        print(r)

if __name__ == '__main__':
    main()


Fixed submission:

import sys
sys.setrecursionlimit(10**6)
dp = []
train = []

def subq(l, r):
    global dp, train
    if l == 0 or r == 0:
        return 0
    else:
        tmp1 = dp[l][r]
        if tmp1 != -1:
            return tmp1
        else:
            tmp2 = train[l][r] + subq(l - 1, r) + subq(l, r - 1) -  subq(l - 1, r - 1)
            dp[l][r] = tmp2
            return tmp2

def main():
    global dp, train
    n, m, qn = map(int, input().split())
    dp = [[-1] * (n+1) for _ in range(n+1)]
    train = [[0] * (n+1) for _ in range(n+1)]
    for _ in range(m):
        l, r = map(int, input().split())
        train[int(l)][int(r)] += 1

    for _ in range(qn):
        p, q = map(int, input().split())
        r = subq(q, q) - subq(p-1, q) - subq(q, p-1) + subq(p-1, p-1)
        print(r)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
R = int(input())
 
if R < 1200:
  r = 'ABC'
elif R < 2800:
  r = 'ARC':
else:
  r ='AGC'
print(r)

Fixed submission:
R = int(input())
 
if R < 1200:
  r = 'ABC'
elif R < 2800:
  r = 'ARC'
else:
  r ='AGC'
 
print(r)

Buggy python submission (verdict: Runtime Error):
R = int(input())

if R < 1200:
  r = 'ABC'
elif R < 2800:
  r = 'ARC':
else:
  r ='AGC'

print(r)

Fixed submission:
R = int(input())
 
if R < 1200:
  r = 'ABC'
elif R < 2800:
  r = 'ARC'
else:
  r ='AGC'
 
print(r)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())

r = abs(a-b) + abs(a-c) + abs(b-c)
r = r - max(abs(a-b) , abs(a-c) , abs(b-c))
print(int(r))

Fixed submission:
a, b, c = map(int, input().split())
 
r = abs(a-b) + abs(a-c) + abs(b-c)
r = r - max(abs(a-b) , abs(a-c) , abs(b-c))
print(int(r))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
if abs(a - c) <= d:
  r = 'Yes'
elif abs(a - b) <= d and abs(b - c) <= d:
  r = 'Yes'
else:
  r = 'No'

print(int(r))

Fixed submission:
a, b, c, d = map(int, input().split())
if abs(a - c) <= d:
  r = 'Yes'
elif abs(a - b) <= d and abs(b - c) <= d:
  r = 'Yes'
else:
  r = 'No'
  
print(r)