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

Fixed submission:
n = int(input())
A, B = [], []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
result = 0
for a, b in zip(A[::-1], B[::-1]):
    piyo = (a+result) % b
    if piyo == 0:
        continue
    result += b - piyo
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
A, B = [], []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
result = 0
for a, b in zip(A[::-1], B[::-1]):
    piyo = (a+result) % b
    if piyo == 0:
        continue
    result += b - piyo
print(result
Problem p02688 (python)

Fixed submission:
N,K = map( int ,input().split())
N_list = [0]*N
for i in range(K):
    d = int(input())
    num_list = [int(i) for i in input().split()]
    for j in range(len(num_list)):
        N_list[num_list[j]-1] +=1
print(N_list.count(0))

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K = map( int ,input().split())
A = np.array([[0] * N for i in range(K)])
sum_A = np.array([0]*N)
x = 0
for i in range(K):
    d = int(input())
    num_list = [int(i) for i in input().split()]
    for j in range(len(num_list)):
        A[d-1][num_list[j]-1] = 1
for k in range(K):
    sum_A += A[k] 
for l in range(K):
    if sum_A[l] == 0:
        x += 1
print(x)
Problem p02699 (python)

Fixed submission:
S,W = map(int,input().split())
if W>=S:
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def ConZ(i):
    z_num = i+int(i*(i-1)/2)
    return z_num
#def ConN(i):
    #n_num = int(i*(i-1)/2)
    #return n_num

def cmb(n):
    over = reduce(mul, range(n, n - 2, -1))
    under = reduce(mul, range(1,2 + 1))
    return over // under


S = input()[::-1]
keta = 1
A_num = 0
x = 0
mod = [0]*2019
for i in range(len(S)):
    A_num += (int(S[i:i+1])*keta)%2019
    if A_num >= 2019:
        A_num = A_num%2019
    mod[A_num] +=1
    keta*=10
    
#print(mod)
x += ConZ(mod[0])
del mod[0]

for j in range(len(mod)):
    x+=cmb(mod[j])
print(x)
Problem p02725 (python)

Fixed submission:
K,N = map(int, input().split())
A = [int(N) for N in input().split()]
#print(A[0])
max1 = 0
max2 = 0
for i in range(0,N-1):
    max1 = A[i+1]-A[i]
    if max1>max2:
        max2=max1
if A[0]==0:
    lastlength = K-A[N-1]
    if lastlength >max2:
        max2=lastlength
else:
    lastlength = K-A[N-1]+A[0]
    if lastlength>max2:
        max2=lastlength
print(K-max2)

Buggy submission (verdict: Runtime Error):
K,N = map(int, input().split())
A = [int(N) for N in input().split()]
#print(A[0])
max1 = 0
max2 = 0
for i in range(0,N-1):
    max1 = A[i+1]-A[i]
    if max1>max2:
        max2=max1
if a[0]==0:
    lastlength = 20-A[N-1]
    if lastlength >max2:
        max2=lastlength
else:
    lastlength = A[N-1]-A[0]
    if lastlength>max2:
        max2=lastlength
print(20-max2)
Problem p02773 (python)

Fixed submission:
import collections
N = int(input()) 
S = [0]*N
m = 0
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
X = c.most_common()[0][1]
list = []
for i in range(0,len(c.most_common())):
    if counts[i] == X:
        list.append(values[i])
        m+=1
    else:
        break
list.sort()
for i in range(0,m):
    print(list[i])

Buggy submission (verdict: Runtime Error):
import collections
N = int(input()) 
S = [0]*N
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
X = c.most_common()[0][1]
for i in range(0,len(c.most_common())):
    if c.most_common()[i][1] == X:
        list.append(c.most_common()[i][0])
list.sort()
print(list)
for i in range(len(list)):
    print(list[i])

Buggy submission (verdict: Runtime Error):
import collections
N = int(input()) 
S = [0]*N
for i in range(N):
    S[i] = input()
c = collections.Counter(S)
values,counts = zip(*c.most_common())
X = c.most_common()[0][1]
print(X)
for i in range(0,len(c.most_common())):
    if c.most_common()[i][1] == X:
        list.append(c.most_common()[i][0])
list.sort()
print(list)
for i in range(len(list)):
    print(list[i])
Problem p02785 (python)

Fixed submission:
N,K = map(int, input().split())
H = list(map(int,input().split()))
H.sort(reverse=True)
K = min(N,K)
S = sum(H[K:N])
print(S)

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
H = list(map(int,input().split()))
H.sort(reverse=True)
if K-1 ==len(H):
    S = 0
elif K == 0:
    S = sum(H)
else:
    for i in range(K):
        del H[i]
    S =sum(H)
print(S)
Problem p02831 (python)

Fixed submission:
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    while x%y != 0:
        z = x%y
        x = y
        y = z
    else:
        return y
def lcm(m,n):
    return int(m * n /gcd(m,n))

A,B = map( int ,input().split())
print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return int((x * y) / math.gcd(x, y))

A,B = map( int ,input().split())
#print(math.gcd(A,B))
print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return int((x * y) /math.gcd(x, y))

A,B = map( int ,input().split())
#print(math.gcd(A,B))
print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A,B = map( int ,input().split())
#print(math.gcd(A,B))
print(lcm(A,B))
Problem p02676 (python)

Fixed submission:
k = int(input())
s = input()

if len(s) > k:
    print(s[0:k] + '...')
else:
    print(s)

Buggy submission (verdict: Runtime Error):
length = input()
input_str = input()

if len(input_str) > length:
    print(input_str + '...')
else:
    print(input_str)

Buggy submission (verdict: Runtime Error):
length = input()
input_str = input()

if len(input_str) > length:
    print(input_str + '...')
else:
    input_str
Problem p02759 (python)

Fixed submission:
n = int(input())

if n % 2 ==0:
    print(int(n/2))
else:
    print(int((n+1)/2))

Buggy submission (verdict: Runtime Error):
list_1 = list(map(int,input().split()))
list_2 = list(map(int,input().split()))
list_3 = list(map(int,input().split()))

#n,m = map(int,raw_input().split())
#list_a = []
#for i in range(M) 
list_a=list_1


for x in list_2:
    list_a.append(x)


for x in list_3:
    list_a.append(x)


N = int(input())
#list_b = [int(x) for x in input().split()]
#list_b = list(map(int,input().split()))


list_b=[]
for k in range(N):
    b=int(input())
    list_b.append(b)


list_c = [0,0,0,0,0,0,0,0,0]
for i in range(N):
    for j in range(9):
        if list_a[j] == list_b[i]:
            list_c[j] = 1

flag=0
if list_c[0]==1 and list_c[1]==1 and list_c[2]==1:
    flag=1
if list_c[3]==1 and list_c[4]==1 and list_c[5]==1:
    flag=1
if list_c[6]==1 and list_c[7]==1 and list_c[8]==1:
    flag=1
if list_c[0]==1 and list_c[3]==1 and list_c[6]==1:
    flag=1
if list_c[1]==1 and list_c[4]==1 and list_c[7]==1:
    flag=1
if list_c[2]==1 and list_c[5]==1 and list_c[8]==1:
    flag=1
if list_c[0]==1 and list_c[4]==1 and list_c[8]==1:
    flag=1
if list_c[2]==1 and list_c[4]==1 and list_c[6]==1:
    flag=1
    
if flag == 1:
    print('Yes')
else:
    print('No')
Problem p02819 (python)

Fixed submission:
x=int(input())
def hantei(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

if x==2:
    print(2)
    exit()

while True:
    if hantei(x)==1:
        print(x)
        break
    x+=1

Buggy submission (verdict: Runtime Error):
x=int(input())
def hantei(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

if x==2:
    pritn(2)
    exit()

while True:
    if hantei(x)==1:
        print(x)
        break
    x+=1
Problem p02831 (python)

Fixed submission:
a,b=map(int,input().split())
from fractions import gcd
print(int(a*b/gcd(a,b)))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
from math import gcd
print(int(a*b/gcd(a,b)))
Problem p02879 (python)

Fixed submission:
A,B = map(int,input().split())
if A>9 or B>9:
    print(-1)
else:
    print(A*B)

Buggy submission (verdict: Runtime Error):
N = int(input())

for i in range(10):
    for j in range(10):
        if N == i*j:
            print('Yes')
        if i*j == 81 and N!=81:
            print('No')
        if N == i*j:
            break
    if N== i*j:
        break

Buggy submission (verdict: Runtime Error):
N = int(input())

for i in range(10):
    for j in range(10):
        if N == i*j:
            print('Yes')
        if i*j == 81 and N!=81:
            print('No')
        if N == i*j:
            break
    if N== i*j:
        break
Problem p02897 (python)

Fixed submission:
N =int(input())
if N%2 == 0:
    print(0.5)
else:
    print((N+1)/2/N)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in a:
    ans[i-1]=a.index(i)+1
print(*ans)
Problem p02935 (python)

Fixed submission:
n=int(input())
v=list(map(int,input().split()))
v.sort(reverse=True)
for i in range(n-1):
    a=v.pop()
    b=v.pop()
    v.append((a+b)/2)
    v.sort(reverse=True)
print(v[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
v=list(map(int,input().split()))
v.sort(reverce=True)
for i in range(n-1):
    a=v.pop()
    b=v.pop()
    v.append((a+b)/2)
    v.sort(reverse=True)
print(v[0])
Problem p02880 (python)

Fixed submission:
n = int(input())
for i in range(1,10):
  for j in range(1,10):
    if i*j == n:
      print("Yes")
      exit()
print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(1,10):
  for j in range(1,10):
    if i*j == n:
      print(Yes)
      exit()
print(No)

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(1,10):
  for j in range(1,10):
    if i*j == n:
      print(Yes)
      return;
print(No)

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(1,10):
  for j in range(1,10):
    if i*j == n:
      print(Yes)
      return 0;
print(No)

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(1,10):
  for j in range(1,10):
    if i*j = n:
      print(Yes)
      return
print(No)
Problem p02897 (python)

Fixed submission:
n = int(input())
if(n%2==0):
  print(1/2)
else:
  print((n+1)/2/n)

Buggy submission (verdict: Runtime Error):
n = int(input())
if(n%2==0):
  print(1/2)
else:
  print((n+1)/2n)

Buggy submission (verdict: Runtime Error):
n = int(input())
if(n%2==0):
  print(1/2)
else:
  print(((n+1)/2n))

Buggy submission (verdict: Runtime Error):
n = int(input())
if(n%2==0):
  print(1/2)
else:
  print(((n+1)/2n)
Problem p02916 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
s = 0
for i in a:
  s += b[i-1] 
  if i -1 == a[a.index(i)-1] and a.index(i)>0:
    s+= c[i-2]
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
s = b[a[0]-1]
i for a[i] in range(1,n):
  s += b[a[i]-1] 
  if a[i-1] + 1 ==a[i]:
    s+= c[i-1]
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
s = b[a[0]-1]
i for a[i] in range(1,n):
  s += b[a[i]-1] 
  if a[i-1] + 1 ==a[i]:
    s+= c[i-1]
print(s)
Problem p02933 (python)

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

Buggy submission (verdict: Runtime Error):
a = int(input())
s =input()
if a >=3200:
  print(S)
else:
  print("red")

Buggy submission (verdict: Runtime Error):
if a >= 3200:
  print(s)
else:
  print("red")
Problem p02959 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
s = 0
for i in range(n):
  if a[i] + a[i+1] <= b[i]:
    s += a[i] + a[i+1]
    a[i+1] = 0
  elif a[i] + a[i+1] > b[i] and a[i] <= b[i]:
    s += b[i]
    a[i+1] -= b[i] - a[i]
  elif a[i] > b[i]:
    s += b[i]
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
  if a[i] + a[i+1] <= b[i]:
    s += a[i] + a[i+1]
    a[i+1] = 0
  elif a[i] + a[i+1] > b[i] and a[i] <= b[i]:
    s += b[i]
    a[i+1] -= b[i] - a[i]
  elif a[i] > b[i]:
    s += a[i]
print(s)
Problem p02987 (python)

Fixed submission:
s = list(input())
s.sort()
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = list(input())
if s[0] == s[1] and s[2] == s[3] and s[0] !== s[2]:
  print("Yes")
else:
  print("No")
Problem p03012 (python)

Fixed submission:
n = int(input())
w = [int(i) for i in input().split()]
s = []
for i in range(1,n):
  a = sum(w[:i])
  b = sum(w[i:])
  s.append(abs(b-a))
print(min(s))

Buggy submission (verdict: Runtime Error):
n = int(input())
w = [int(i) for i in input().split()]
s = []
for i in range(1,n):
  s.append(abs(sum(w[:i])-sum(w[i:]))
print(min(s))
Problem p03041 (python)

Fixed submission:
n, k = map(int, input().split())
s = list(input())
if s[k-1] == "A":
  s[k-1] = "a"
elif s[k-1] == "B":
  s[k-1] = "b"
else:
  s[k-1] = "c"
print("".join(s))

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = list(input())
if s[k-1] == A:
  s[k-1] = a
elif s[k-1] == B:
  s[k-1] = b
else:
  s[k-1] = c
print("".join(s))
Problem p02682 (python)

Fixed submission:
A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
K = int(input())

if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    N = K - A - B
    print(A - N)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
K = int(input())

if K > A:
    N = K - A
    all_number = 1*A
    print(all_number)

    if N > B:
        N = N - B
        if N > C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    else:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
K = int(input())

if K > A:
    N = K - A //2
    all_number = 1*A //3

    if N > B:
        N = N - B
        if N > C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    else:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
K = int(input())

if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N > B:
        N = N - B
        if N > C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    elif N <= B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
K = int(input())

if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N >= B:
        N = N - B
        if N >= C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    elif N < B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Buggy submission (verdict: Runtime Error):
if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N >= B:
        N = N - B
        if N >= C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    elif N < B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
K = int(input())

all_number = 0

if K >= A:
    N = K - A
    all_number = 1*A

    if N == 0:
        print(all_number)

    elif N >= B:
        N = N - B
        all_number = all_number - 1*N
        print(all_number)

    elif N < B:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)
Problem p02699 (python)

Fixed submission:
s,w = map(int,input().split())

if s<=w:
  print("unsafe")
else:
  print("safe")

Buggy submission (verdict: Runtime Error):
s,w = int(input())

if s<=w:
  print("unsafe")
else:
  print("safe")
Problem p02711 (python)

Fixed submission:
n = int(input())
num = []
while n>0:
  num.append(n%10)
  n //= 10

ans = 0
for i in num:
  if i == 7:
    ans+=1
    break
  else:
    ans = 0
    
if ans >= 1:
  print("Yes")
elif ans==0:
  print("No")

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

if 7 in n:
  print("Yes")
else:
  print("No")
Problem p02729 (python)

Fixed submission:
m,n =  map(int, input().split())
print(n*(n-1)//2+m*(m-1)//2)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input())
if n >= 2:
	for i in range(n):
		i *= i
if m >= 2:
	for j in range(m):
    	j *= j
print(i+j//4)

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

num1 = 1
list_M = []

for i in M:
  list_M.append(i)
  num1 += 1

num2 = 1
list_n = []
for j in N:
  list_N.append(j)
  num2 += 1

add_list = []
for k in M:
  for l in N:
    add_list.append(list_m[k] + list[l])

odd = 0

for m in add_list:
  if m % 2 == 0:
    odd += 1
    
print(odd)
Problem p02682 (python)

Fixed submission:
a,b,c,k=list(map(int,input().split()))
ans=0
if(k<=a):
  ans=k
elif(a<k and k<=a+b):
  ans=a
elif(a+b<k and k<=a+b+c):
  ans=a-(k-a-b)

print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c,k=list(map(int,input().split()))
A=[1]*a
B=[0]*b
C=[-1]*c
s=A+B+C
ans=0
for i in range(k):
  ans+=s[i]
print(ans)
Problem p02693 (python)

Fixed submission:
K = int(input())
a,b = list(map(int, input().split()))
n = 0
while True:
  n += 1
  if a <= n*K and n*K <= b:
    print('OK')
    break
  if b < n*K:
    print('NG')
    break

Buggy submission (verdict: Runtime Error):
N,M=list(map(int, input().split()))
src=[i+1 for i in range(M*2+1)]
if N%2==0:
  for m in range(M//2):
    a=src[m]
    b=src[M-m]
    print('{} {}'.format(a,b))
  for m in range(M//2):
    a=src[M+1+m]
    b=src[-(m+1)]
    print('{} {}'.format(a,b))
else:
  for m in range(M//2):
    a=src[m]
    b=src[M-1-m]
    print('{} {}'.format(a,b))
  for m in range(M-(M//2)):
    a=src[M+m]
    b=src[-(m+1)]
    print('{} {}'.format(a,b))

Buggy submission (verdict: Runtime Error):
N,M=list(map(int, input().split()))
src=[i+1 for i in range(M*2+1)]
if N%2==0:
  for m in range(M//2):
    a=src[m]
    b=src[M-m]
    print('{} {}'.format(a,b))
  for m in range(M//2):
    a=src[M+1+m]
    b=src[-(m+1)]
    print('{} {}'.format(a,b))
else:
  for m in range(M//2):
    a=src[m]
    b=src[M-1-m]
    print('{} {}'.format(a,b))
  for m in range(M-(M//2)):
    a=src[M+m]
    b=src[-(m+1)]
    print('{} {}'.format(a,b))
Problem p02695 (python)

Fixed submission:
import itertools
N,M,Q=list(map(int,input().split()))
src=[]
for q in range(Q):
  src.append(list(map(int,input().split())))
ML=[n+1 for n in range(M)]
X=list(itertools.combinations_with_replacement(ML,N))
L=[]
for x in X:
  a=0
  for s in src:
    if x[s[1]-1] - x[s[0]-1] == s[2]:
      a+=s[3]
  L.append(a)
print(max(L))

Buggy submission (verdict: Runtime Error):
import itertools
N,M,Q=list(map(int,input().split()))
src=[list(map(int,input().split())) for q in range(Q)]
ML=[n+1 for n in range(M)]
X=list(itertools.combinations_with_replacement(ML,N))
L=[]
for x in X:
  a=0
  for s in src:
    if x[s[1]] - x[s[0]] == s[2]:
      a+=s[3]
  L.append(a)
print(max(L))
Problem p02723 (python)

Fixed submission:
a,b,c,d,e,f = input()
if c == d and e == f:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):

src = input()
if src[3] == src[4] and src[5] == src[6]:
  print('Yes')
else:
  print('No')
Problem p03186 (python)

Fixed submission:
A, B, C = map(int, input().split())

P = min(A+B+1, C)
print(P+B)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split)

P = min(A+B+1, C)
print(P+B)
Problem p02699 (python)

Fixed submission:
s, w =  map(int, input().split())
if s <= w:
    print('unsafe')
else:
    print('safe')

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

def sheep_wold(S=S, W=W):
    if S <= W:
        print('unsafe')
    else:
        print('safe')

Buggy submission (verdict: Runtime Error):

S = input()
W = input()

if S <= W:
    print('unsafe')
else:
    print('safe')
Problem p02685 (python)

Fixed submission:
n,m,k=[int(x) for x in input().split()]
#TODO Mutiply wih m
if m==1:
  if k==n-1: print(1)
  else: print(0)
  exit()
sumi=0
mod=998244353
prodi=pow(m-1,n-1,mod)
invi=pow(m-1,mod-2,mod)
for j in range(n-1,n-1-k-1,-1):
  sumi+=prodi
  sumi%=mod
  prodi*=j
  prodi%=mod
  prodi*=pow(n-j,mod-2,mod)
  prodi%=mod
  prodi*=invi
  prodi%=mod 
sumi*=m
sumi%=mod
print(sumi)

Buggy submission (verdict: Runtime Error):
n,m,k=[int(x) for x in input().split()]
#TODO Mutiply wih m
sumi=0
mod=998244353
prodi=pow(m-1,n-1,mod)
invi=pow(m-1,mod-2,mod)
for j in range(n-1,n-1-k-1,-1):
  sumi+=prodi
  sumi%=mod
  prodi*=n-j/j+1
  prodi%=mod
  prodi*=pow(j+1,mod-2,mod)
  prodi%=mod
  prodi*=invi
  prodi%=mod
sumi+=prodi
sumi%=mod
sumi*=m
sumi%=mod
Problem p02688 (python)

Fixed submission:
n, k = map(int, input().split())
list = []
for p in range(k):
  d = int(input())
  k_list = [int(x) for x in input().split()]
  m = len(k_list)
  for q in k_list:
    if not q in list:
      list.append(q)
l = len(list)
print(n - l)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
list = []
for p in range(k):
  m = int(input())
  k_list = list(map(int, input().split()))
  for q in k_list:
    if not q in list:
      list.append(q)
k_l = len(k_list)
print(n-k_l)
Problem p02685 (python)

Fixed submission:
import sys

input = sys.stdin.readline

def comb(n, r):
    return (fact[n] * revfact[n-r] * revfact[r]) % mod

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

fact = [1] * (N + 1)
for i in range(1, N + 1):
    fact[i] = (fact[i-1] * i) % mod #n!を計算
# print('fact:{}'.format(fact))
revfact = [1] * (N + 1) #逆元を定義
revfact[N] = pow(fact[N], mod - 2, mod) #n!のmod-2乗を計算
# print('revfact:{}'.format(revfact))
for i in reversed(range(1, N)): #N-1から1まで
    revfact[i] = ((i + 1) * revfact[i + 1]) % mod
# print('revfact:{}'.format(revfact))

ans = 0
for k in range(K + 1):
    ans += (M * pow(M - 1, N - 1 - k, mod) * comb(N - 1, k)) % mod
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
from operator import mul #掛け算をする関数
from functools import reduce
from scipy.special import comb

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

for i in range(N)[::-1]:
    now = col
    now *= int(comb(N-1,i))
    if i <= K:
        ans += now
    col *= M-1

print(ans%mod)
Problem p02682 (python)

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

if k <= a:
  print(k)
elif k <= a+b:
  print(a)
else:
  print(2*a - k + b)

Buggy submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())

if k <= a:
  print(k)
elif k <= a+b:
  print(a)
else:
  print(a - (k - (a + b))
Problem p02729 (python)

Fixed submission:
import math
def comb(n, r):
    if(n>=r):
        return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
    else:
        return 0
        
m,n = map(int, input().split())
ans = comb(m, 2) + comb(n, 2)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
def comb(n, r):
    if(n>=r):
        return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
    else:
        return 0

f = open("input.txt", "r")
sys.stdin = f

m,n = map(int, input().split())
ans = comb(m, 2) + comb(n, 2)
print(ans)