Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02881 (python)

Fixed submission:
import math
N = int(input())
N_root = math.sqrt(N)
M = int(N_root)
list = []
for i in range(1,M+1):
  if N%i == 0:
    list.append(i+N//i-2)
list = sorted(list)
print(list[0])

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
N_root = math.sqrt(N)
M = int(N_root)
list = []
for i in range(1,M):
  if N%i == 0:
    list.append(i+N//i-2)
list = sorted(list)
print(list[0])
Problem p03077 (python)

Fixed submission:
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
X = min(A, B, C, D, E)
if X >= N:
  print(5)
else:
  if N%X == 0:
    print(4+N//X)
  else:
    print(5+N//X)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
X = min(A, B, C, D, E)
if X >= N:
  print(5)
else:
  if N%X == 0:
    print(4+N//X)
  elese:
    print(5+N//X)
Problem p03705 (python)

Fixed submission:
N, A, B = map(int, input().split())
if A > B:
  print(0)
else:
  if N == 1 and A == B:
    print(1)
  elif N == 1:
    print(0)
  else:
    print((B-A)*(N-2)+1)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
if A > B:
  print(0)
elif A == B:
  print(1)
elif B-A >=N:
  print(0)
else: 
  print((B-A)*X+1)
Problem p02596 (python)

Fixed submission:
#!/usr/bin/env python3
"""
数列777...は奇数故，Kが偶数だったら×

"""
from numba import njit


@njit(cache=True)
def func(a, b):
    return a * b


def main():
    import sys
    input = sys.stdin.readline

    K = int(input())

    # mod Kを考える(mod=module(剰余))
    x = 7 % K
    for i in range(1, K + 1):
        if x == 0:
            print(i)
            return
        x = (x * 10 + 7) % K
    print(-1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    
    input = sys.stdin.readline

    K = int(input())
    res = 7

    if K % 2:
        while res < 10 ** 7:
            cal = func(K, res)
            k = str(cal)
            if k.count('7') == len(k):
                print(len(k))
                break
            res += 7
        else:
            print('-1')
    else:
        print('-1')


if __name__ == '__main__':
    main()
Problem p02762 (python)

Fixed submission:
#!/usr/bin/env python3
def main():
    from collections import deque

    N, M, K = map(int, input().split())
    friends = [set() for _ in range(N + 1)]
    for _ in range(M):
        a, b = map(int, input().split())
        friends[a].add(b)
        friends[b].add(a)
    blocks = [set() for _ in range(N + 1)]
    for _ in range(K):
        c, d = map(int, input().split())
        blocks[c].add(d)
        blocks[d].add(c)

    friends_chain = []
    seen = [-1] * (N + 1)
    cnt = 0
    for person in range(1, N + 1):
        if seen[person] != -1:
            continue
        q = deque([person])
        friends_chain.append(set(q))
        while q:
            now = q.pop()
            seen[now] = cnt
            for next in friends[now]:
                if seen[next] != -1:
                    continue
                friends_chain[-1].add(next)
                q.append(next)
        cnt += 1

    for person in range(1, N + 1):
        res = friends_chain[seen[person]]
        tmp_ans = len(res) - len(friends[person]) - 1
        for block in blocks[person]:
            tmp_ans -= 1 if block in res else 0
        print(tmp_ans, end=' ')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
def main():
    import sys

    sys.setrecursionlimit(10 ** 5)

    def dfs(now: int, chain: set):
        """nowを現在の頂点として，つながっている頂点をglaphに集合として記録"""
        if seen[now]:
            return chain
        seen[now] = i
        for next in friends[now]:
            chain.add(now)
            dfs(next, chain)

    N, M, K = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * M]
    CD = [tuple(map(int, input().split())) for _ in [0] * K]

    friends = [set() for _ in [0] * (N + 1)]
    for f in AB:
        friends[f[0]].add(f[1])
        friends[f[1]].add(f[0])
    blocks = [set() for _ in [0] * (N + 1)]
    for b in CD:
        blocks[b[0]].add(b[1])
        blocks[b[1]].add(b[0])

    friends_chain = []
    seen = [0] * (N + 1)
    cnt = 1
    for i in range(1, N + 1):
        if not seen[i]:
            glaph = set()
            dfs(i, glaph)
            friends_chain.append(glaph)
            cnt += 1

    ans = [0] * (N + 1)
    for person in range(1, N + 1):
        res = set(friends_chain[seen[person] - 1])
        for block in blocks[person]:
            res.discard(block)
        for friend in friends[person]:
            res.discard(friend)
        ans[person] = len(res) - 1
    
    for hoge in ans[1:]:
        print(hoge, end=' ')


if __name__ == '__main__':
    main()
Problem p02792 (python)

Fixed submission:
#!/usr/bin/env python3
def main():
    import numpy as np

    N = int(input())

    cnt = np.zeros((10, 10), dtype=np.int64)
    for n in [str(x) for x in range(1, N + 1)]:
        cnt[int(n[0])][int(n[-1])] += 1

    print((cnt[:, :] * cnt.T[:, :]).sum())


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
def main():
    import numpy as np

    N = int(input())

    cnt = np.zeros((10, 10), dtype=np.int64)
    for n in map(str, range(1, N + 1)):
        cnt[int(n[0])][int(n[-1])] += 1

    print(np.sum(cnt * cnt.T))


if __name__ == '__main__':
    main()
Problem p02987 (python)

Fixed submission:
from collections import defaultdict

S = defaultdict(int)
for i in input():
    S[i] += 1

if len(S.values()) == 2:
    a, b = S.values()
    if a == b == 2:
        print('Yes')
        exit()
print('No')

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

S = defaultdict(int)
for i in input():
    S[i] += 1

a, b, *_ = S.values()
if a == b == 2:
    print('Yes')
else:
    print('No')
Problem p03013 (python)

Fixed submission:
def resolve():
    import sys
    
    read = sys.stdin.read
    readline = sys.stdin.readline

    N, M = map(int, readline().split())
    a = set(int(x) for x in read().split())
    
    dp = [0] * (N + 2)
    dp[0] = 1

    for i in range(N):
        now = dp[i]
        if i + 1 not in a:
            dp[i + 1] += now
        if i + 2 not in a:
            dp[i + 2] += now

    print(dp[N] % 1_000_000_007)


resolve()

Buggy submission (verdict: Runtime Error):
import sys

def resolve():
    read = sys.stdin.read
    readline = sys.stdin.readline

    N, M = map(int, readline().split())
    a = [int(x) for x in read().split()]
    
    dp = [0] * N * 2
    dp[0] = 1
    for i in range(N):
        one = i + 1
        two = i + 2
        now = dp[i]
        if one not in a:
            dp[one] += now
        if two not in a:
            dp[two] += now
    print(dp[N] % 1_000_000_007)


resolve()
Problem p03053 (python)

Fixed submission:
from collections import deque


def resolve():
    H, W = map(int, input().split())
    A, q = [], deque([])
    for i in range(H):
        A.append(list(input()))
        if '#' in A[i]:
            for j in range(W):
                if A[i][j] == '#':
                    q.append((i, j))

    dy = [0, 1, 0, -1]
    dx = [1, 0, -1, 0]
    cnt = -1

    # 1回目で各黒マスを拡張して，2回目以降は拡張した黒マスから拡張してく
    nq = deque([])
    while q:
        y, x = q.popleft()
        for i in range(4):
            ny = y + dy[i]
            nx = x + dx[i]
            if 0 <= ny < H and 0 <= nx < W and A[ny][nx] == '.':
                nq.append((ny, nx))
                A[ny][nx] = '#'
        if q == deque([]):
            q = nq
            nq = deque([])
            cnt += 1
    print(cnt)


if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
def resolve():
    H, W = map(int, input().split())
    A, white = [], []
    for i in range(H):
        A.append(list(input()))
        if '.' in A[i]:
            for j in range(W):
                if A[i][j] == '.':
                    white.append([i, j])

    dy = [0, 1, 0, -1]
    dx = [1, 0, -1, 0]
    cnt = 0

    # 各白マスから黒マスまでの最短距離を探索し，その最大値を出力
    for sy, sx in white:
        dis = [[float('inf')] * W for _ in range(H)]
        dis[sy][sx] = 0
        q = deque([(sy, sx)])
        update = False
        while q:
            y, x = q.popleft()
            for i in range(4):
                ny = y + dy[i]
                nx = x + dx[i]
                if (1
                        and 0 <= ny < H
                        and 0 <= nx < W
                        and dis[ny][nx] == float('inf')):
                    dis[ny][nx] = dis[y][x] + 1
                    q.append((ny, nx))
                    if A[ny][nx] == '#':
                        cnt = max(dis[ny][nx], cnt)
                        update = True
            if update:
                break
    print(cnt)


if __name__ == "__main__":
    resolve()
Problem p03137 (python)

Fixed submission:
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
if m<=n:
  print(0)
else:
  d=[]
  for i in range(m-1):
    d.append(x[i+1]-x[i])
  d=sorted(d)
  print(sum(d[:m-n]))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
if n<=m:
  print(0)
else:
  d=[]
  for j in range(n-1):
    d.append(x[i+1]-x[i])
  d=sorted(d)
  print(sum(d[:m]))
Problem p03208 (python)

Fixed submission:
n,k=map(int,input().split())
h=sorted([int(input()) for _ in range(n)])
x=10**9
for i in range(n-k+1):
  x=min(x,h[i+k-1]-h[i])
print(x)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=sorted([int(input()) for _ in range(n)])
x=10**9
for i in range(n-k+1):
  x=min(x,h[i+k]-h[i])
print(x)
Problem p03774 (python)

Fixed submission:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]
ans=[[] for _ in range(n)]
for i in range(n):
  p,q=a[i]
  for j in range(m):
    r,s=c[j]
    d=abs(p-r)+abs(q-s)
    ans[i].append((d,j+1))
  ans[i]=sorted(ans[i])
for i in ans:
  print(i[0][1])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
c=[list(map(int,input().split())) for _ in range(m)]
ans=[[] for _ in range(n)]
for i in range(n):
  for j in range(n):
    p,q=a[i]
    r,s=c[j]
    d=abs(p-r)+abs(q-s)
    ans[i].append((d,j+1))
  ans[i]=sorted(ans[i])
for i in ans:
  print(ans[0][1])
Problem p03803 (python)

Fixed submission:
a,b = map(int,input().split())
if a==b:
  print("Draw")
elif a==1:
  print("Alice")
elif b==1:
  print("Bob")
elif a>b:
  print("Alice")
else:
  print("Bob")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())
if a==b:
  print("Draw")
elif a==1:
  print("Alice")
elif b==1:
  print("Bob")
elif a>b:
  print("Alice")
else:
  print("Bob")
Problem p03835 (python)

Fixed submission:
k,s=map(int,input().split())
a=0
for i in range(k+1):
  for j in range(k+1):
    if s-i-j <=k and s-i-j >=0:
      a+=1
print(a)

Buggy submission (verdict: Runtime Error):
k,s=map(int,input().split())
a=0
for i in range(k+1):
  for j in range(k+1):
    if s-i-j <=k and s-i-j >=0:
      a+=1
print(ans)
Problem p02627 (python)

Fixed submission:
if __name__ == '__main__':
    a = input()
    b = a.upper()

    if (a == b):
        print('A')
    else:
        print("a")

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
import matplotlib.pyplot as plt

#def main(S, b):
if __name__ == '__main__':
    a = input()
    b = a.upper()

    if (a == b):
        print('A')
    else:
        print("a")
Problem p02793 (python)

Fixed submission:
import fractions 
#from functools import reduce
import functools

MOD = 10**9+7


def main():
    # N = int(input())
    # A = list(map(int, input().split()))
    N, *A = map(int, open(0).read().split())
            
    x = 1
    for a in A:
        x *= a //  fractions.gcd(x, a)
        
    b = sum(x//a for a in A)
    print(b%MOD)
    
if __name__== "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import fractions 
#from functools import reduce
import functools

MOD = 10**9+7


def main():
    N, *A = map(int, open(0).read.split())
    # N = int(input())
    # A = list(map(int, input().split()))

    # def lcm(x, y):
    #     return x * y // fractions.gcd(x, y)
        
    
    # x = functools.reduce(lcm, A, 1)

    x=1
    for a in A:x*=a//fractions.gcd(x, a)

    
    b = sum(x//a%MOD for a in A)
    print(b%MOD)
if __name__== "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import fractions 
#from functools import reduce
import functools

MOD = 10**9+7


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

    x = 1
    ans = 0
    # for a in A:
    #     tmp = gcd(x, a)
    #     # ans += (i) * A[i] // tmp + A[i] * x //tmp  
    #     x = (x * a) // tmp

    def lcm(x, y):
        return x * y // fractions.gcd(x, y)
        
    
    x = functools.reduce(lcm, A, 1)
        
    b = sum(x//a for a in A)
    print(b%MOD)
main()

Buggy submission (verdict: Runtime Error):
import numpy as np
#from fractions import gcd
#from functools import reduce
import functools

MOD = 10**9+7


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

    x = 1
    ans = 0
    # for a in A:
    #     tmp = gcd(x, a)
    #     # ans += (i) * A[i] // tmp + A[i] * x //tmp  
    #     x = (x * a) // tmp
    x = functools.reduce(functools.gcd, A, 1)
        
    b = 0
    A = np.array(A)
    # for a in A:
    #     b += x // a
    b = np.sum(x//A, axis=0)
    print(b%MOD)
main()

Buggy submission (verdict: Runtime Error):
import numpy as np
from fractions import gcd

MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))


def main():
    x = 1
    ans = 0
    for a in A:
        tmp = gcd(x, a)
        # ans += (i) * A[i] // tmp + A[i] * x //tmp  
        x = (x * a) // tmp
    
    b = 0
    A = np.array(A)
    # for a in A:
    #     b += x // a
    b = np.sum(x//a)
        
    print(b%MOD)
main()

Buggy submission (verdict: Runtime Error):
import numpy as np
from fractions import gcd

MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))

x = 1
ans = 0
for a in range(A):
    tmp = gcd(x, a)
    # ans += (i) * A[i] // tmp + A[i] * x //tmp  
    x = (x * a) // tmp
    
b = 0
for a in range(A):
    b += x // a
    
print(b%MOD)
Problem p02835 (python)

Fixed submission:
a, b, c = map(int, input().split())

if a+b+c>=22:
    print("bust")
else:
    print("win")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
MOD = 10 **9 + 7
 
ni = [0 for _ in range(60)]
for i in range(N):
    tmp = A[i]
    count = 0
    while(True):
        if tmp % 2 == 1:
            ni[count] += 1
        count += 1
        tmp = tmp // 2
        if tmp == 0:
            break
ans = 0
for j in range(60):
    ans += (ni[j] * (N-ni[j])) * 2 ** j 
 
print(ans%MOD)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
MOD = 10 **9 + 7
 
ni = [0 for _ in range(60)]
for i in range(N):
    tmp = A[i]
    count = 0
    while(True):
        if tmp % 2 == 1:
            ni[count] += 1
        count += 1
        tmp = tmp // 2
        if tmp == 0:
            break
ans = 0
for j in range(60):
    ans += (ni[j] * (N-ni[j])) * 2 ** j 
 
print(ans%MOD)
Problem p02891 (python)

Fixed submission:
import math

S = input()
K = int(input())
#print(S)
cnt = 1
ans = 0
for i in range(1,len(S)):
    if S[i] == S[i-1]:
        cnt += 1
    else:
        ans += cnt //2 
        cnt = 1
ans += cnt //2 
#print("ans", ans)    
ans *= K
#print("ans*K",ans)

if S[0] == S[-1]:
    cntf = 1
    cnte = 1
    for i in range(1,len(S)):
        #print(S[i], S[i-1] )
        if S[i] == S[i-1]:
            cntf += 1
        else:
            break
    #print("---------------")
    for i in range(1,len(S)):
        #print(S[-i], S[-i+1] )
        if S[-i-1] == S[-i]:
            cnte += 1
        else:
            break
    #print(cnte, cntf)
    if cnte % 2 ==1 and cntf % 2 ==1:
        #print("bbbb")
        ans += (K-1)  

    if cnte == len(S):
        #print("aaa")
        ans = len(S) * K // 2
print(ans)

Buggy submission (verdict: Runtime Error):
import math

S = input()
K = int(input())
#print(S)
cnt = 1
ans = 0
for i in range(1,len(S)):
    if S[i] == S[i-1]:
        cnt += 1
    else:
        ans += cnt //2 
        cnt = 1
ans += cnt //2 
#print("ans", ans)    
ans *= K
#print("ans*K",ans)
if S[0] == S[-1]:
    cntf = 1
    cnte = 1
    for i in range(1,len(S)):
        #print(S[i], S[i-1] )
        if S[i] == S[i-1]:
            cntf += 1
        else:
            break
    #print("---------------")
    for i in range(1,len(S)):
        #print(S[-i], S[-i+1] )
        if S[-i-1] == S[-i]:
            cnte += 1
        else:
            break
    #print(cnte, cntf)
    if cnte % 2 ==1 and cntf % 2 ==1:
        #print("bbbb")
        ans += (K-1)  

if cnte == len(S):
    ans = len(S) * K // 2
print(ans)
Problem p03042 (python)

Fixed submission:
def main(f, e):
    if 0 <f <13:
        if 0<e<13:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if 0<e<13:
            print("YYMM")
        else:
            print("NA")
if __name__ == "__main__":
    S = input()

    a = int(S[:2])
    b = int(S[2:])
    main(a, b)

Buggy submission (verdict: Runtime Error):
def main(f, e):
    if f==0 or e==0:
        print("NA")
        return 0
    if f <13:
        elif e < 13:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if e < 13:
            print("YYMM")
        else:
            print("NA")

if __name__ == "__main__":
    S = input()

    a = int(S[:2])
    b = int(S[2:])
    main(a, b)

Buggy submission (verdict: Runtime Error):
S = input()

f = int(S[:2])
e = int(S[2:])

if f==0 or e==0:
    print("NA")
    return 0

if f <13 and f>0:
    if e < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if e < 13:
        print("YYMM")

Buggy submission (verdict: Runtime Error):
S = input()

f = int(S[:2])
e = int(S[2:])

if f==0 or e==0:
    print("NA")
    return 0

if f <13 and f>0:
    if e < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if e < 13:
        print("YYMM")

Buggy submission (verdict: Runtime Error):
S = input()

f = int(S[:2])
e = int(S[2:])

if f==0 or e==0:
    print("NA")
    return 0

if f <13 and f>0:
    if e < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if e < 13:
        print("YYMM")
Problem p03346 (python)

Fixed submission:
#N, *a = map(int, open(0).read().split())
def main():
    N = int(input())
    a=[]
    for i in range(N):
        a.append(int(input()))

    b = [0 for _ in range(N+2)]
    cnt = 1
    ans = 0
    flag = 1
    i = 0
    for i in reversed(range(N)):
        if b[a[i]+1] > 0:
            b[a[i]] = b[a[i]+1] + 1
        else:
            b[a[i]] = 1
        
    return N-max(b)
print(main())

Buggy submission (verdict: Runtime Error):
#N, *a = map(int, open(0).read().split())
def main():
    N = int(input())
    a=[]
    for i in range(N):
        a.append(int(input()))

    b = [0 for _ in range(N+1)]
    cnt = 1
    ans = 0
    flag = 1
    i = 0
    for i in reversed(range(N)):
        if b[a[i]+1] > 0:
            b[a[i]] = b[a[i]+1] + 1
        else:
            b[a[i]] = 1
        
    return N-max(b)
print(main())
Problem p02725 (python)

Fixed submission:
import sys
from copy import deepcopy
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def cal(a,b,k):
    return min(abs(a-b), k-abs(a-b))

def cal2(l):
    n = len(l)
    ans = 0
    for i in range(n-1):
        ans += l[i+1] - l[i]
    return ans
def main():
    k,n = map(int, input().split())
    As = list(map(int, input().split()))
    le = list()
    for i in range(n):
        if i == n-1:
            le.append(cal(As[i], As[0] , k) )
        else:
            le.append(As[i+1]- As[i])
    print(k-max(le))
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from copy import deepcopy
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def cal(a,b,k):
    return min(abs(a-b), k-abs(a-b))

def cal2(l):
    n = len(l)
    ans = 0
    for i in range(n-1):
        ans += l[i+1] - l[i]
    return ans
def main():
    k,n = map(int, input().split())
    As = list(map(int, input().split()))
    le = list()
    for i in range(n):
        if i == n-1:
            le.append(cal(As[i], As[0],k))
        else:
            le.append(As[i], As[i+1])
    print(k-max(le))
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from copy import deepcopy
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def cal(a,b):
    return min(abs(a-b), k-abs(a-b))

def cal2(l):
    n = len(l)
    ans = 0
    for i in range(n-1):
        ans += l[i+1] - l[i]
    return ans
def main():
    k,n = map(int, input().split())
    As = list(map(int, input().split()))
    le = list()
    for i in range(n):
        if i == n-1:
            le.append(cal(As[i], As[0]))
        else:
            le.append(As[i], As[i+1])
    print(k-max(le))
if __name__ == '__main__':
    main()
Problem p02729 (python)

Fixed submission:
import sys
from math import ceil, floor, factorial
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def comb(n, r):
    if n-r < 0:
        return 0
    return factorial(n) // (factorial(n - r) * factorial(r))


def main():
    n,m = map(int, input().split())
    print((comb(n,2)) + (comb(m,2)))
    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from math import ceil, floor, comb
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n,m = map(int, input().split())
    print((comb(n,2)) + (comb(m,2)))
    return

if __name__ == '__main__':
    main()
Problem p02777 (python)

Fixed submission:
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def main():
    s,t = input().split()
    a,b  = map(int, input().split())
    u = input().split('\n')[0]
    
    if s==u:
        print(a-1,b)
    else:
        print(a, b-1)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def main():
    s,t = input().split()
    a,b  = map(int, input().split())
    u = int(input())
    
    if u == s:
        print(a-1)
    else:
        print(b-1)
    return

if __name__ == '__main__':
    main()