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

Fixed submission:
# https://atcoder.jp/contests/abc157/submissions/10475457

import sys
readline = sys.stdin.readline

N, M, K = map(int, readline().split())

F = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, readline().split())
    F[a].append(b)
    F[b].append(a)

B = [[] for _ in range(N + 1)]
for _ in range(K):
    c, d = map(int, readline().split())
    B[c].append(d)
    B[d].append(c)

seen = [-1] * (N + 1)
group = 0


def dfs(graph, s):
    stack = [s]
    seen[s] = group
    n_connection = 1

    while stack:
        u = stack.pop()
        for v in graph[u]:
            if seen[v] == -1:
                n_connection += 1
                seen[v] = group
                stack.append(v)

    return n_connection


union = {}
for i in range(1, N + 1):
    if seen[i] == -1:
        n = dfs(F, i)
        union[group] = n
        group += 1

ans = []
for i in range(1, N + 1):
    tmp = 0
    tmp += union[seen[i]] - 1
    tmp -= len(F[i])
    for j in B[i]:
        if seen[j] == seen[i]:
            tmp -= 1
    ans.append(tmp)

print(" ".join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc157/submissions/10475457

import sys
readline = sys.stdin.readine

N, M, K = map(int, readline().split())

F = [[] for _ in range(N + 1)]
for _ in range(M):
    a, b = map(int, readline().split())
    F[a].append(b)
    F[b].append(a)

B = [[] for _ in range(N + 1)]
for _ in range(K):
    c, d = map(int, readline().split())
    B[c].append(d)
    B[d].append(c)

seen = [-1] * (N + 1)
group = 0


def dfs(graph, s):
    stack = [s]
    seen[s] = group
    n_connection = 1

    while stack:
        u = stack.pop()
        for v in graph[u]:
            if seen[v] == -1:
                n_connection += 1
                seen[v] = group
                stack.append(v)

    return n_connection


union = {}
for i in range(1, N + 1):
    if seen[i] == -1:
        n = dfs(F, i)
        union[group] = n
        group += 1

ans = []
for i in range(1, N + 1):
    tmp = 0
    tmp += union[seen[i]] - 1
    tmp -= len(F[i])
    for j in B[i]:
        if seen[j] == seen[i]:
            tmp -= 1
    ans.append(tmp)

print(" ".join(map(str, ans)))
Problem p02781 (python)

Fixed submission:
import sys
read = sys.stdin.read

n, k = map(int, read().split())


def count(d, k):
  if k == 0:
    return 1
  elif k == 1:
    return d
  elif k == 2:
    return d * (d - 1) // 2
  else:
    return d * (d - 1) * (d - 2) // 6


def solve(n, k):
  digit = len(str(n))
  if digit == 0 and k > 0:
    return 0
  if k == 0:
    return 1
  res = 0
  if digit > k:
    res += count(digit - 1, k) * (9 ** k)
  a = 10 ** (digit - 1)
  d, mod = n // a, n % a
  res += count(digit - 1, k - 1) * (9 ** (k - 1)) * (d - 1)
  res += solve(mod, k - 1)
  return res


print(solve(n, k))

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
n, k = map(int, read().split())


def count(digit, k):
    elif k == 0:
        return 1
    elif k == 1:
        return digit
    elif k == 2:
        return digit * (digit - 1) // 2
    else:
        return digit * (digit - 1) * (digit - 2) // 6


def solve(n, k):
    if k == 0:
        return 1
    digit = len(str(n))
    res = 0
    if digit > k:
        res += count(digit - 1, k) * (9 ** k)
    pow10 = 10 ** (digit - 1)
    d, mod = n // pow10, n % pow10
    res += count(digit - 1, k - 1) * (9 ** (k - 1)) * (d - 1)
    res += solve(mod, k - 1)
    return res


print(solve(n, k))
Problem p02792 (python)

Fixed submission:
n=input()
intn=int(n)
ln=len(n)

if intn<10:
  print(n)
  quit()

def count(i,j):
  res=0
  if i==j:
    res+=1
  if ln==2:
    if 10*i+j<=intn:
      res+=1
  else:
    res+=(10**(ln-2)-1)//9
    if i<int(n[0]):
      res+=10**(ln-2)
    elif i==int(n[0]):
      tn=int(n[1:-1])
      if j<=intn%10:
        res+=tn+1
      else:
        res+=tn
  return res

res=0
for i in range(1,10):
  for j in range(1,10):
    res+=count(i,j)*count(j,i)
print(res)

Buggy submission (verdict: Runtime Error):
n=input()
intn=int(n)
ln=len(n)

if intn<10:
  print(n)
  quit()

def count(i,j):
  res=0
  if i==j:
    res+=1
  if ln==2:
    if 10*i+j<=n:
      res+=1
  else:
    res+=(10**(ln-2)-1)//9
    if i<int(n[0]):
      res+=10**(ln-2)
    elif i==int(n[0]):
      tn=int(n[1:-1])
      if j<=intn%10:
        res+=tn+1
      else:
        res+=tn
  return res

res=0
for i in range(1,10):
  for j in range(1,10):
    res+=count(i,j)*count(j,i)
print(res)
Problem p02815 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
mod=10**9+7
n, *clst = map(int, read().split())
if n == 1:
  print(clst[0]*2%mod)
  quit()
clst.sort(reverse=True)
res=sum(i*item for i, item in enumerate(clst,2))
print((4**(n-1)*res)%mod)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read

import heapq
mod = 10**9+7
n, *clst = map(int, read().split())
if n == 1:
  print(2*clst[0] % mod)
  quit()
heapq.heapify(clst)
import numpy as np
clst=np.sort(clst)
d=2**(n-2)
start = 2**(n-1)+(n-1)*d
end = 2**(n-1)-1
q=np.arange(start,end,-d)

res=np.sum(clst*q)
print(2**n*res % mod)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read

import heapq
mod = 10**9+7
n, *clst = map(int, read().split())
if n == 1:
  print(2*clst[0] % mod)
  quit()
heapq.heapify(clst)
import numpy as np
clst=np.sort(clst)
q=np.arange(2**(n-1)+(n-1)*2**(n-2),2**(n-1)-1,-2**(n-2))

res=np.sum(clst*q)
print(2**n*res % mod)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import heapq
mod = 10**9+7
n, *clst = map(int, read().split())
if n == 1:
  print(2*clst[0] % mod)
  quit()
heapq.heapify(clst)
import numpy as np
clst=np.array(clst)
q=np.arange(2**(n-1)+(n-1)*2**(n-2),2**(n-1)-1,-2**(n-2))
res=np.sum(clst*q)
print(2**n*res % mod)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10**9+7
n, *clst = map(int, read().split())
if n == 1:
  print(2*clst[0] % mod)
  quit()
import numpy as np
clst=np.array(clst)
clst=np.sort(clst)
q=np.arange(2**(n-2)+n*2**(n-2),2**(n-1)-1,-2**(n-2))
 
res = np.sum(clst*q)
print(2**n*res % mod)
Problem p02819 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x=int(readline())
def a(n):
  for i in range(2, int(n ** 0.5 + 1)):
    if n % i == 0:
      return False
  return True
  

while True:
  if a(x):
    print(x)
    quit()
  x+=1

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x=int(readline())
def a(n):
  for i in range(2, int(n ** 0.5 + 1)):
    if n % i == 0:
      return False
  return True
  
  
n=x+1
while True:
  if a(n):
    pint(n)
    quit()
  n+=1
Problem p02832 (python)

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

n = int(readline())
c = 1
r = 0
p = 0
a = True
for i, j in enumerate(readline().split()):
  if c != int(j):
    continue
  else:
    a = False
    c += 1
    r += i - p
    p = i + 1
if a:
  print(-1)
else:
  print(r + n - p)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.buffer.readline
 
n = int(readline())
num = 1
res = 0
for i in readline().split():
  if num != int(i):
    res += 1
  else:
    i += 1

if res == n:
  print(-1)
else:
  print(res)
Problem p03208 (python)

Fixed submission:
n,k = map(int, input().split())
lst = [int(input()) for _ in range(n)]
lst.sort()
print(min(lst[i + k - 1] - lst[i] for i in range(n - k + 1)))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
lst = [int(input()) for _ in range(n)]
lst.sort()
print(min(h[i + k - 1] - h[i] for i in range(n - k + 1)))
Problem p03286 (python)

Fixed submission:
n = int(input())
s = "1" if n % 2 == 1 else "0"
n = - n // - 2
while n:
  mod = (n % 2) ** 2
  s = "{}".format(mod) + s
  n = n // - 2
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = '1' if n % 2 == 1 else 0
n = - n // - 2
while n:
  mod = abs(n % 2)
  s = str(mod) + s
  n = n // - 2
print(s)
Problem p03806 (python)

Fixed submission:
n, ma, mb = [int(i) for i in input().split()]
lst = [[int(i) for i in input().split()] for _ in range(n)]
lst.sort(key=lambda x: x[2])
dic = {}
def push(k,v):
    if k in dic:
        dic[k] = min(dic[k],v)
    else:
        dic[k] = v


for i in lst:
    k, v = i[0] * mb - i[1] * ma, i[2]
    l = [[j, dic[j]] for j in dic]
    for item in l:
        push(item[0] + k, item[1] + v)
    push(k, v)

print(dic[0] if 0 in dic else '-1')

Buggy submission (verdict: Runtime Error):
n, ma, mb = [int(i) for i in input().split()]
lst = [[int(i) for i in input().split()] for _ in range(n)]
lst.sort(key=lambda x: x[2])

def push(k,v):
    if k in dic:
        dic[k] = min(dic[k],v)
    else:
        dic[k] = v


for i in lst:
    k, v = i[0] * mb - i[1] * ma, i[2]
    l = [[j, dic[j]] for j in dic]
    for item in l:
        push(item[0] + k, item[1] + v)
    push(k, v)

print(dic[0] if 0 in dic else '-1')
Problem p03835 (python)

Fixed submission:
k,s = [int(i) for i in input().split()]
def a(n):
  return int(n * (n + 1) / 2)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)

Buggy submission (verdict: Runtime Error):
k,s = [int(i) for i in input().split()]
def a(n):
return int(n * (n + 1) / 2)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)

Buggy submission (verdict: Runtime Error):
k,s = [int(i) for i in input().split()]
def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if s <= k:
  print(a(s + 1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:
  print(0)

Buggy submission (verdict: Runtime Error):
k,s = [int(i) for i in input().split()]
def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if s <= k:
  print(a(s+1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))

Buggy submission (verdict: Runtime Error):
k,s = [int(i) for i in input().split()]


def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if k >= s:
  print(a(s+1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
elif s > k and s < 2 * k:
  print(a(s + 1) - 3 * a(s - k))
else:

Buggy submission (verdict: Runtime Error):
k,s = [int(i) for i in input().split()]


def a(n):
  if n == 1:
    return n
  else:
    return n + a(n-1)
  
if k >= s:
  print(a(s+1))
elif s >= 2 * k and s <= 3 * k:
  print(a(3 * k - s + 1))
else:
  print(a(s + 1) -3 * a(s - k))
Problem p03986 (python)

Fixed submission:
x = input()
res = [x[0]]
for i in x[1:]:
  if i == 'S':
    res += [i]
  elif not res:
    res += [i]
  else:
    if res[-1] == 'S':
      res.pop()
    else:
      res += [i]
print(len(res))

Buggy submission (verdict: Runtime Error):
x = input()
res = [x[0]]
for i in x[1:]:
  if i == 'S':
    res += [i]
  else:
    if res[-1] == 'S':
      res.pop()
    else:
      res += [i]
print(len(res))
Problem p02685 (python)

Fixed submission:
#!/usr/bin/env python3

N, M, K = map(int, input().split())
mod = 998244353

table = [0]
inv_table = [0]
M_table = []

tmp = pow(M - 1, N - 1, mod)
for i in range(K + 1):
    if i > 0:
        tmp *= pow(M - 1, mod - 2, mod)
        tmp %= mod
    M_table.append(tmp)

tmp = 1
for i in range(1, N + 1):
    tmp *= i
    tmp %= mod
    table.append(tmp)

tmp = 1
for i in range(1, N + 1):
    tmp *= pow(i, mod - 2, mod)
    tmp %= mod
    inv_table.append(tmp)

def cmb(n, r):
    if r == 0:
        return 1
    if n == r:
        return 1
    return table[n] * inv_table[r] * inv_table[n - r]

if M == 1:
    if N - 1 == K:
        print(1)
    else:
        print(0)
    exit()

ans = 0
for i in range(K + 1):
    ans += M * M_table[i] * cmb(N - 1, i)
    ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

N, M, K = map(int, input().split())
mod = 998244353

table = [0]
inv_table = [0]
M_table = []

tmp = pow(M - 1, N - 1, mod)
for i in range(K + 1):
    if i > 0:
        tmp *= pow(M - 1, mod - 2, mod)
        tmp %= mod
    M_table.append(tmp)

tmp = 1
for i in range(1, N + 1):
    tmp *= i
    tmp %= mod
    table.append(tmp)

tmp = 1
for i in range(1, N + 1):
    tmp *= pow(i, mod - 2, mod)
    tmp %= mod
    inv_table.append(tmp)

def cmb(n, r):
    if r == 0:
        return 1
    if n == r:
        return 1
    return table[n] * inv_table[r] * inv_table[n - r]

if M == 1:
    if K >= cmb(N, 2):
        print(1)
    else:
        print(0)

ans = 0
for i in range(K + 1):
    ans += M * M_table[i] * cmb(N - 1, i)
    ans %= mod

print(ans)
Problem p02763 (python)

Fixed submission:
import sys
import bisect
import copy

N = int(sys.stdin.readline().rstrip())
S = list(sys.stdin.readline().rstrip())
Q = int(sys.stdin.readline().rstrip())

cnt = [0] * 26
cumcnt = [cnt]

for i, s in enumerate(S):
    tmp = copy.copy(cumcnt[i])
    tmp[ord(s) - ord("a")] += 1
    cumcnt.append(tmp)

q_remove = {}
q_add = {}

for _ in range(Q):
    t, i, c = sys.stdin.readline().rstrip().split()
    t = int(t)
    i = int(i)
    d = S[i - 1]
    if t == 1:
        if d != c:
            if d not in q_remove.keys():
                q_remove[d] = [i]
            else:
                bisect.insort(q_remove[d], i)
            if c not in q_add.keys():
                q_add[c] = [i]
            else:
                bisect.insort(q_add[c], i)
            S[i - 1] = c 
    else:
        c = int(c)
        cnt_l = copy.copy(cumcnt[i - 1])
        cnt_r = copy.copy(cumcnt[c])
        for q, idx in q_add.items():
            x = bisect.bisect_right(idx, i - 1)
            y = bisect.bisect_right(idx, c)
            cnt_l[ord(q) - ord("a")] += x
            cnt_r[ord(q) - ord("a")] += y
        for q, idx in q_remove.items():
            x = bisect.bisect_right(idx, i - 1)
            y = bisect.bisect_right(idx, c)
            cnt_l[ord(q) - ord("a")] -= x
            cnt_r[ord(q) - ord("a")] -= y
        ans = 0
        for l, r in zip(cnt_l, cnt_r):
            if r - l > 0:
                ans += 1
        print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import bisect
import copy

N = int(sys.stdin.readline().rstrip())
S = list(sys.stdin.readline().rstrip())
Q = int(sys.stdin.readline().rstrip())

cnt = [0] * 26
cumcnt = [cnt]

for i, s in enumerate(S):
    tmp = copy.copy(cumcnt[i])
    tmp[ord(s) - ord("a")] += 1
    cumcnt.append(tmp)

q_remove = {}
q_add = {}

for _ in range(Q):
    t, i, c = sys.stdin.readline().rstrip().split()
    t = int(t)
    i = int(i)
    d = S[i - 1]
    if t == 1:
        if d != c:
            if d not in q_remove.keys():
                q_remove[d] = [i]
            else:
                # q_remove[d].append(i)
                bisect.insort(q_remove[d], i)
            if c not in q_add.keys():
                q_add[c] = [i]
            else:
                # q_add[c].append(i)
                bisect.insort(q_add[d], i)
    else:
        c = int(c)
        cnt_l = copy.copy(cumcnt[i - 1])
        cnt_r = copy.copy(cumcnt[c])
        for q, idx in q_add.items():
            x = bisect.bisect_right(idx, i - 1)
            y = bisect.bisect_right(idx, c)
            cnt_l[ord(q) - ord("a")] += x
            cnt_r[ord(q) - ord("a")] += y
        for q, idx in q_remove.items():
            x = bisect.bisect_right(idx, i - 1)
            y = bisect.bisect_right(idx, c)
            cnt_l[ord(q) - ord("a")] -= x
            cnt_r[ord(q) - ord("a")] -= y
        ans = 0
        for l, r in zip(cnt_l, cnt_r):
            if r - l > 0:
                ans += 1
        print(ans)
Problem p02771 (python)

Fixed submission:
nums = list(map(int, input().split(" ")))
if len(set(nums)) == 2:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
nums = list(map(int, input.split(" ")))
if len(set(nums)) == 2:
    print("Yes")
else:
    print("No")
Problem p02777 (python)

Fixed submission:
s, t = input().split(" ")
a, b = map(int, input().split(" "))
if input() == s:
    print(a - 1, b)
else:
    print(a, b - 1)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split(" "))
p = np.array(list(map(int, input().split(" "))))
ex = np.array([(i + 1) / 2 for i in p])
ans = np.sum(ex[0: K])
max_ans = ans
for i in range(K, N):
    diff = ex[i] - ex[i - K]
    ans += diff
    if diff > 0:
        max_ans = ans
print(max_ans)
Problem p02829 (python)

Fixed submission:
A = int(input())
B = int(input())
ans = [1, 2, 3]
ans.remove(A)
ans.remove(B)
print(ans[0])

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
ans = [1, 2, 3]
ans.pop(A)
ans.pop(B)
print(ans[0])
Problem p03013 (python)

Fixed submission:
import collections
mod = 10 ** 9 + 7
N, M = map(int, input().split())
a = collections.deque([])
for _ in range(M):
    a_m = int(input())
    if len(a) > 0 and a_m == a[-1] + 1:
        print(0)
        exit()
    a.append(a_m)

dp = [1]

if len(a) > 0:
    if 1 != a[0]:
        dp.append(1)
    else:
        dp.append(0)
        a.popleft()
else:
    dp.append(1)

for i in range(2, N + 1):
    if len(a) > 0:
        if i != a[0]:
            tmp = dp[0] + dp[1]
        else:
            tmp = 0
            a.popleft()
    else:
        tmp = dp[0] + dp[1]
    dp[0] = dp[1]
    dp[1] = tmp

print(dp[-1] % mod)

Buggy submission (verdict: Runtime Error):
import collections
mod = 10 ** 9 + 7
N, M = map(int, input().split())
a = collections.deque([])
for _ in range(M):
    a_m = int(input())
    if len(a) > 0 and a_m == a[-1] + 1:
        print(0)
        exit()
    a.append(a_m)

dp = [1]

if len(a) > 0 and 1 != a[0]:
    dp.append(1)
else:
    dp.append(0)
    a.popleft()

for i in range(2, N + 1):
    if len(a) > 0:
        if i != a[0]:
            tmp = dp[0] + dp[1]
        else:
            tmp = 0
            a.popleft()
    else:
        tmp = dp[0] + dp[1]
    dp[0] = dp[1]
    dp[1] = tmp

print(dp[-1] % mod)
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
a,b = map(Decimal,input().split())
print(int(a*b))

Buggy submission (verdict: Runtime Error):
a,b = map(float,input().split())
print(a//b)

Buggy submission (verdict: Runtime Error):
a,b = map(float,input().split())
print(int(a/b))
Problem p02701 (python)

Fixed submission:
n = int(input())
set1 = set([])
for _ in range(n):
  s = input()
  set1.add(s)
 
print(len(set1))

Buggy submission (verdict: Runtime Error):
n = int(input())
set1 = set([])
for _ in range():
  s = input()
  set1.add(s)
 
print(len(set1))
Problem p02695 (python)

Fixed submission:
import itertools

n,m,q =map(int,input().split())
a =[0]*q
b =[0]*q
c =[0]*q
d =[0]*q

for i  in range(q):
    a[i],b[i],c[i],d[i]= map(int,input().split())
    
A=list(itertools.combinations_with_replacement([i for i in range(1,m+1)],n))


g=[]
for v in A:
    e=0
    for i in range(q):
        
        if v[b[i]-1]-v[a[i]-1] ==c[i]:
            e += d[i]
            
        
    g += [e]
print(max(g))

Buggy submission (verdict: Runtime Error):
import itertools

n,m,q =map(int,input().split())
a =[0]*q
b =[0]*q
c =[0]*q
d =[0]*q

for i  in range(q):
    a[i],b[i],c[i],d[i]= map(int,input().split())
    
A=list(itertools.combinations([i for i in range(1,m+1)],n))

e=0

g=[]
for v in A:
    e=0
    for i in range(q):
        
        if v[b[i]-1]-v[a[i]-1] ==c[i]:
            e += d[i]
            
        
    g += [e]
print(max(g))
Problem p02729 (python)

Fixed submission:
import math
N,M =map(int,input().split())
if N==1 :
    N1=0
elif N==0:
    N1=0
else:
    N1=(math.factorial(N))//(math.factorial(N-2)*2)
    
if M==1:    
    M1=0
    
elif M ==0:
    M1=0
else:
    M1=(math.factorial(M))//(math.factorial(M-2)*2)
    
print(str(N1+M1))

Buggy submission (verdict: Runtime Error):
import math
N,M =map(int,input().split())
if N!=1:
    N1=(math.factorial(N))//(math.factorial(N-2)*2)

else:
    N1=0
    
if M !=1:
    M1=(math.factorial(M))//(math.factorial(M-2)*2)
else:
    M1=0
    
print(str(N1+M1))

Buggy submission (verdict: Runtime Error):
import math
N,M =map(int,input().split())

N1=(math.factorial(N))//(math.factorial(N-2)*2)
M1=(math.factorial(M))//(math.factorial(M-2)*2)

print(str(N1+M1))

Buggy submission (verdict: Runtime Error):
N,M =map(str,input().split())

N1=math.factorial(N)//(math.factorial(N-2)*2)
M1=math.factorial(M)//(math.factorial(M-2)*2)

print(N1+M1)
Problem p02777 (python)

Fixed submission:
s,t =map(str,input().split())
a,b =map(int,input().split())
u=input()
if u==s:
    print(a-1,b)
else:
    print(a,b-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[i for i in input().split()]

print('YES' if len(set(a)==n) else 'NO')
Problem p02779 (python)

Fixed submission:
n=int(input())
a=[i for i in input().split()]

print('YES' if len(set(a))==n else 'NO')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[i for i in input().split()]

print('YES' if len(set(a)==n) else 'NO')

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[i for i in input().split()]
print(len(set(a)))
print('YES' if len(set(a)==n) else 'NO')
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
 
p = list(map(int,range(1,4)))
p.remove(a)
p.remove(b)
print(p[0])

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

x =[1,2,3]
x = x.remove(a)
x = x.remove(b)

print(x[0])
Problem p02847 (python)

Fixed submission:
s = input()
a =['SUN','MON','TUE','WED','THU','FRI','SAT']

print(7-a.index(s))

Buggy submission (verdict: Runtime Error):
s = input()
a =['SUN','MON','TUS','WED','THU','FRI','SAT']
if s!= 'SUN':
	print(a.index(s))
else:
  print(7)

Buggy submission (verdict: Runtime Error):
s = input()
a =['SUN','MON','TUS','WED','THU','FRI','SAT']
if a!= 'SUN':
	print(a.index(s))
else:
  print(7)
Problem p02629 (python)

Fixed submission:
import sys

def main(n):
    c = "abcdefghijklmnopqrstuvwxyz"
    m = {}
    for i in range(0, 26):
        m[i+1] = c[i]

    s = ""
    while n > 0:
        if n%26 == 0:
            t = 26
            n //= 26
            n -= 1
        else:
            t = n%26
            n //= 26
        s = m[t] + s
    return s

n = int(sys.stdin.readline().strip())
print(main(n))

Buggy submission (verdict: Runtime Error):
import sys

def main(n):
    c = "abcdefghijklmnopqrstuvwxyz"
    m = {}
    for i in range(0, 26):
        m[i+1] = c[i]

    s = ""
    while n > 0:
        s = m[(n%26)] + s
        n /= 26
    return s

n = int(sys.stdin.readline().strip())
print(main(n))
Problem p02771 (python)

Fixed submission:
def equ(a,b):
  return 1*(a==b)
a,b,c = map(int,input().split())
ans = equ(a,b)+equ(b,c) +equ(c,a)
print('Yes' if ans ==1 else 'No')

Buggy submission (verdict: Runtime Error):
def equ(a,b):
  return 1*(a==b)
a,b,c = map(input().split())
ans = equ(a,b)+equ(b,c) +equ(c,a)
print('Yes' if ans ==1 else 'No')
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()
if a<3200:
  print('red')
else:
  print(s)

Buggy submission (verdict: Runtime Error):
a=input()
s=input()
if a<3200:
  print('red')
else:
  print(s)