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

Fixed submission:
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
points=0
renzoku=[1 for i in range(k)]
for i in range(n):
	if i<k:
		if t[i]=='r':
			points+=p
		if t[i]=='s':
			points+=r
		if t[i]=='p':
			points+=s
	else:
		if t[i]==t[i-k]:
			renzoku[i%k]+=1
			if renzoku[i%k]%2==1:
				if t[i]=='r':
					points+=p
				if t[i]=='s':
					points+=r
				if t[i]=='p':
					points+=s
		else:
			renzoku[i%k]=1
			if t[i]=='r':
				points+=p
			if t[i]=='s':
				points+=r
			if t[i]=='p':
				points+=s
print(points)

Buggy submission (verdict: Runtime Error):
#降順ソートの方がうまくいきそう
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())),reverse=True)
cs=[]
sum=0
for i in range(n):
	sum+=a[i]
	cs.append(sum)

#和が引数以上の場合をカウントする
def overX(x):
	count=0
	#両手が違う人を握るときのみ考える
	if a[0]*2<x:
		return 0
	else:
		for i in range(n):
			if a[i]+a[0]<x:
				count+=0
			else:
				lb, ub = 0, n
				#パターンAのにぶたん。左がOなので[lb,ub)で持つ。
				while ub-lb>1:
					mid=(lb+ub)//2
					if a[i]+a[mid]>=x:
						lb=mid
					else:
						ub=mid
				count+=lb+1
		return count
#print(overX(130))

#overX>=mなる最大のxを探す->xは小さい方が実現しやすいのでパターンA->[lb,ub)でもつ
lb=1 #実現しやすい方
ub=2*10**5
while ub-lb>1:
	mid=(ub+lb)//2
	if overX(mid)>=m:
		lb=mid
	else:
		ub=mid
#ub=overX(x)>=mなる最小のx。これ以上大きくするとmに満たなくなる。
maxx=lb

hp=0
#maxx+1以上の要素をすべてたす
#和がmaxx+1以上になる組み合わせの数だけhpを加え、countをインクリメントする
if a[0]*2>=maxx+1:
	for i in range(n):
		if a[i]+a[0]<maxx+1:
			break
		else:
			lb, ub = 0, n
			#パターンAのにぶたん。左がOなので[lb,ub)で持つ。
			while ub-lb>1:
				mid=(lb+ub)//2
				if a[i]+a[mid]>=maxx+1:
					lb=mid
				else:
					ub=mid
			#a[0]からa[lb]は、a[i]と足した時にx以上になり条件を満たす。
			hp+=a[i]*(lb+1)+cs[lb]
hp+=(m-overX(maxx+1))*maxx
print(hp)
Problem p02891 (python)

Fixed submission:
#O(2n)程度を見込む解答
s=input()
k=int(input())
ss=s+s
n=len(s)

ppp=1
for i in range(n-1):
	if s[i]!=s[i+1]:
		ppp=0
		break
		
if ppp==1:
	print(n*k//2)
else:		
	counts=0
	i=0
	while i<n-1:
		if s[i]!=s[i+1]:
			i+=1
		else:
			i+=2
			counts+=1
			
	countss=0
	i=0
	while i<n*2-1:
		if ss[i]!=ss[i+1]:
			i+=1
		else:
			i+=2
			countss+=1
			
	if countss==counts*2:
		print(counts*k)
	else:
		print(counts*k+k-1)

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

ss=""
for i in range(k):
	ss+=s

count=0

i=0
while i<len(ss):
	if ss[i]!=ss[i+1]:
		i+=1
	else:
		i+=2
		count+=1
print(count)
Problem p02916 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
sum =0;
for i in range(len(a)):
    sum += b[a[i]-1]
    if i +1 < n and a[i+1] - a[i] == 1:
        sum += c[a[i]-1]
print(sum)

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

manzoku=0;

for i in range(len(A)):
	manzoku+=B[A[i]-1]
	if i+1<n and A[i+1]-A[i]==1:
		manzoku+=C[A[i]-1]
print(manzoku)

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

manzoku=0;

for i in range(len(A)):
	manzoku+=B[A[i]-1]
	if i+1<n and A[i+1]-A[i]==1 :
		manzoku+=C[A[i]-1]
print(manzoku)

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

manzoku=0;

for i in range(len(A)):
	a=A[i]
	manzoku+=B[a-1]
	if i+1<n and A[i+1]-A[i]==1 :
		manzoku+=C[a-1]
	i+=1
print(manzoku)

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

manzoku=0;
i=0; #A[i]を参照する
while i<len(A):
	a=A[i]
	manzoku+=B[a]
	if i+1<n and A[i+1]-A[i]==1 :
		manzoku+=C[a]
	i+=1
print(manzoku)

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

manzoku=0
i=0 #A[i]を参照する
while i<len(A):
	a=A[i]
	manzoku+=a
	if A[i+1]-A[i]==1 :
		manzoku+=C[a]
	i+=1
print('manzoku')

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

manzoku=0
i=0 #A[i]を参照する
while i<len(A):
	a=A[i]
	manzoku+=a
	if A[i+1]-A[i]==1 :
		manzoku+=C[a]
	i+=1
print(manzoku)
Problem p02933 (python)

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

Buggy submission (verdict: Runtime Error):
a=int(input())
b=str(input())
if a>=3200:
	print(s)
else:
	print('red')

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

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
if a>=3200:
	print(s)
else:
	print('red')
Problem p02935 (python)

Fixed submission:
n=int(input())
v=list(map(int, input().split()))
v.sort()
sum=v[0]
for i in range(1,len(v)):
	sum=(sum+v[i])/2
print(sum)

Buggy submission (verdict: Runtime Error):
n=int(input())
v=list(map(int, input().split()))
v.sort()
sum=v[0]
for i in range(1,len(v))
	sum=(sum+v[i])/2
print(sum)
Problem p02954 (python)

Fixed submission:
#print('RRRLLRL'.index('LR'))
#print('RRRLLRLR'.index('LR'))
#=>4
#str.index(検索文字列,開始位置,終了位置)

#indexは見つからないとエラー
#findは見つからないと-1を出力

#s='RRLRLR'
#bubun=s[0:3]
#print(bubun)
#=>RRL


def stateRL(s):
	state=[0]*len(s)
	r=s.count('R')
	l=s.count('L')
	state[r-1]=1+(r-1)//2+l//2
	state[r]=1+r//2+(l-1)//2
	return state

s=input()
n=len(s)

state=[]

kireme=-1
nkireme=s.find('LR',0)

while nkireme!=-1:
	bubun=s[kireme+1:nkireme+1:]
	state+=stateRL(bubun)
	kireme=nkireme
	nkireme=s.find('LR',kireme+1)

bubun=s[kireme+1::]
state+=stateRL(bubun)
	
for i in range(n):
	print(state[i],end=' ')

Buggy submission (verdict: Runtime Error):
#print('RRRLLRL'.index('LR'))
#print('RRRLLRLR'.index('LR'))
#=>4
#str.index(検索文字列,開始位置,終了位置)

#indexは見つからないとエラー
#findは見つからないと-1を出力

#s='RRLRLR'
#bubun=s[0:3]
#print(bubun)
#=>RRL


def stateRL(s):
	state=[0]*len(s)
	r=s.count('R')
	l=s.count('L')
	state[r-1]=1+(r-1)//2+l//2
	state[r]=1+r//2+(l-1)//2
	return state

s=input()
n=len(s)

state=[]

kireme=-1
nkireme=s.find('LR',0)

while nkireme!=-1:
	bubun=s[kireme+1:nkireme+1:]
	state+=stateRL(bubun)
	kireme=nkireme
	nkireme=s.find('LR',kireme+1)

bubun=s[kireme::]
state+=stateRL(bubun)
	
for i in range(n):
	print(state[i],end=' ')
Problem p02989 (python)

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

d.sort()

print(d[n//2]-d[n//2-1])

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

import fractions

def lcm(x,y):
	return (x*y)//fractions.gcd(x,y)

lcmcd=lcm(c,d)
divc=b//c-(a-1)//c
divd=b//d-(a-1)//c
divcd=b//lcmcd-(a-1)//lcmcd

print(b-a+1-divc-divd+divcd)

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

import fractions

def lcm(x,y):
	return (x*y)//fractions.gcd(x,y)

lcmcd=lcm(c,d)
divc=b//c-(a-1)//c
divd=b//d-(a-1)//c
divcd=b//lcmcd-(a-1)//lcmcd

print(b-a+1-divc-divd+divcd)
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
dp=[-1 for i in range(n+1)] #dp[i]=はi段目
for i in range(m):
	a=int(input())
	dp[a]=0
dp[0]=1
if dp[1]<0:
	dp[1]=1
for i in range(2,n+1):
	if dp[i]<0:
		dp[i]=(dp[i-1]+dp[i-2])%1000000007
print(dp[n]%1000000007)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*m
for i in range(m):
	a[i]=int(input())
	
def pattern(n):
	if n==0:
		return 1
	if n==1:
		return 1
	return pattern(n-1)+pattern(n-2)%1000000007

def renzoku(m):
	total=0
	for i in range(m-1):
		if a[i]==a[i+1]-1:
			total=1
			break;
	return total
	
if renzoku(m):
	print(0)
	
elif m==0:
	print(pattern(n))
	
else:
	total=pattern(n-a[m-1]-1)*pattern(a[0]-1)%1000000007
	for i in range(m-1):
		total*=pattern(a[i+1]-a[i]-2)
	print(total%1000000007)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*m
for i in range(m):
	a[i]=int(input())
	
def pattern(n):
	if n==0:
		return 1
	if n==1:
		return 1
	return pattern(n-1)+pattern(n-2)

def renzoku(m):
	total=0
	for i in range(m-1):
		if a[i]==a[i+1]-1:
			total=1
			break;
	return total
	
if renzoku(m):
	print(0)
	
elif m==0:
	print(pattern(n))
	
else:
	total=pattern(n-a[m-1]-1)*pattern(a[0]-1)%1000000007
	for i in range(m-1):
		total*=pattern(a[i+1]-a[i]-2)
	print(total%1000000007)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[0]*m
for i in range(m):
	a[i]=int(input())
	
def pattern(n):
	if n==0:
		return 1
	if n==1:
		return 1
	return pattern(n-1)+pattern(n-2)

def renzoku(m):
	total=0
	for i in range(m-1):
		if a[i]==a[i+1]-1:
			total=1
			break;
	return total
	
if renzoku(m):
	print(0)
	
elif m==0:
	print(pattern(n))
	
else:
	total=pattern(n-a[m-1]-1)*pattern(a[0]-1)
	for i in range(m-1):
		total*=pattern(a[i+1]-a[i]-2)
	print(total%1000000007)
Problem p02659 (python)

Fixed submission:
import sys

input = sys.stdin.readline

value_list = input().split()

A = int(value_list[0])
B = float(value_list[1])

print(A * round(B * 100) // 100)

Buggy submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline
n1, n2 = map(int, input().split())

print(math.floor(n1*n2))
Problem p02987 (python)

Fixed submission:
import collections

s = input()

if list(collections.Counter(list(s)).values()) == [2, 2]:
    print("Yes")
else:
    print("No")

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


count = 0
for i in range(len(A) - 2):
    if (A[i] > A[i + 1]) and (A[i + 1] > A[i + 2]):
       count += 1
    elif (A[i + 2] > A[i + 1]) and (A[i + 1] > A[i]):
        count += 1
    else: 
        pass
print(count)
Problem p02627 (python)

Fixed submission:
a = input()
if a >= 'a' and a <='z':
  print('a')
if a >= 'A' and a <='Z':
  print('A')

Buggy submission (verdict: Runtime Error):
a = input()
if a >= 'a' && a <='z':
  print('a')
if a >= 'A' && a <='Z':
  print('A')
Problem p02693 (python)

Fixed submission:
K = int(input())
A, B = map(int, input().split())
judge = False
for i in range(A, B+1):
  if i % K == 0:
    print('OK')
    judge = True
    break
if not judge:
  print('NG')

Buggy submission (verdict: Runtime Error):
A, B, N = map(int, input().split())
f = [int(A*x/B) - (A * int(x/B)) for x in range(N+1)]
print(max(f))

Buggy submission (verdict: Runtime Error):
K = int(input())
A, B = map(int, input().split())
judge = False
for i in range(A, B+1):
  if i % K == 0:
    print('OK')
    judge = True
    break
if !judge:
  print('NG')
Problem p02712 (python)

Fixed submission:
N = int(input())
res = 0
for i in range(N+1):
  if i % 3 != 0 and i % 5 != 0:
    res += i
print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
res = 0
for i in range(N+1):
  if i % 3 != 0 && i % 5 != 0:
    res += i
print(res)
Problem p02627 (python)

Fixed submission:
str=input()
a=str.isupper()
if a==True:
    print("A")
else:
    print("a")

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


def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

ans=num2alpha(num).lower()

print(ans)
Problem p02707 (python)

Fixed submission:
import collections

N = int(input())
A_list = list(map(int, input().split()))
A_collection = collections.Counter(A_list)

for i in range(N):
    print(A_collection[i+1])

Buggy submission (verdict: Runtime Error):
N = int(input())
A_list = list(map(int, input().split()))
A_set = sorted(set(A_list), reverse=True)
A_output = []
for i in range(len(A_set)):
    A_output[i] =len(A_list) - len(A_list.remove(A_set[i]))
    
print(A_output.reverse)
Problem p02712 (python)

Fixed submission:
N = int(input())

print(sum(filter(lambda x : (x%3 != 0) and (x%5 !=0), range(N+1))))

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

print(sum(filter(lambda x : x%3 != 0 or x%5 !=, range(N))))
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())

cities = {}
output = []
for i in range(M):
    x, y = map(int, input().split())
    cities[i+1] = [x,y]
    output.append(y)

ID = {}
county_old = 0
sorted_counties_years = sorted(cities.values())
for county,year in sorted_counties_years:
    if county_old == 0:
        county_old = county
        count = 1
        ID[year] = '{:06}{:06}'.format(county, count)
        count += 1
        continue
    elif county_old == county:
        ID[year] = '{:06}{:06}'.format(county, count)
        count += 1
    else:
        county_old = county
        count = 1
        ID[year] = '{:06}{:06}'.format(county, count)
        count += 1
for i in output:
    print(ID[i])

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

cities = {}
output = []
for i in range(M):
    x, y = map(int, input().split())
    cities[i+1] = [x,y]
    output.append(y)

ID = {}
county_old = 0
sorted_counties_years = sorted(cities.values())
for county,year in sorted_counties_years:
    if county_old == 0:
        county_old = county
        count = 1
        ID[year] = f'{county:06}{count:06}'
        count += 1
        continue
    elif county_old == county:
        ID[year] = f'{county:06}{count:06}'
        count += 1
    else:
        county_old = county
        count = 1
        ID[year] = f'{county:06}{count:06}'
        count += 1
for i in output:
    print(ID[i])

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

cities = {}
output = []
for i in range(M):
    x, y = map(int, input().split())
    cities[i+1] = [x,y]
    output.append(y)

ID = {}
county_old = 0
sorted_counties_years = sorted(cities.values())
for county,year in sorted_counties_years:
    if county_old == 0:
        county_old = county
        count = 1
        ID[year] = f'{county:06}{count:06}'
        count += 1
        continue
    elif county_old == county:
        ID[year] = f'{county:06}{count:06}'
        count += 1
    else:
        county_old = county
        count = 1
        ID[year] = f'{county:06}{count:06}'
        count += 1
for i in output:
    print(ID[i])
Problem p02785 (python)

Fixed submission:
[n,k]=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]
h.sort()
if n<=k:
  print("0")
else:
  print(str(sum(h[:len(h)-k])))

Buggy submission (verdict: Runtime Error):
[n,k]=[int(x) for x in onput().split()]
h=[int(x) for x in lnput().split()]
if n<=k:
  print("0")
else:
  print(str(sum(h[k:])))
Problem p02790 (python)

Fixed submission:
[a,b] = [int(x) for x in input().split()]

if a <= b:
    print('{}'.format(a)*b) 
else:
    print('{}'.format(b)*a)

Buggy submission (verdict: Runtime Error):
[a,b] = [int(x) for x in input().split()]

if a <= b:
    print(f'{a}'*b) 
else:
    print(f'{b}'*a)
Problem p03805 (python)

Fixed submission:
import itertools

[n,m] = [int(x) for x in input().split()]
data = [[int(x) for x in input().split()] for _ in range(m)]

total = 0
for x in itertools.permutations(range(2,n+1)):
    
    route = [1,]+list(x)
    
    for x in range(len(route)-1):
        flg = False
        
        for y in data:
            if {route[x],route[x+1]} == set(y):
                flg = True
                break
                
        if flg == False:
            break
            
    else:
        total += 1
        
print(total)

Buggy submission (verdict: Runtime Error):
[n,m] = [int(x) for x in input().split()]
data = [[int(x) for x in input().split()] for _ in range(m)]

total = 0
for x in itertools.permutations(range(2,n+1)):
    
    route = [1,]+list(x)
    
    for x in range(len(route)-1):
        flg = False
        
        for y in data:
            if {route[x],route[x+1]} == set(y):
                flg = True
                break
                
        if flg == False:
            break
            
    else:
        total += 1
        
print(total)
Problem p02623 (python)

Fixed submission:
n,m,k=map(int,input().split())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))

ans=0
for i in range(1,n+1):
  A[i]+=A[i-1]


for j in range(1,m+1):
  B[j]+=B[j-1]


b_cnt=m
for a_cnt in range(n+1):
  if A[a_cnt]>k:
    continue
  while A[a_cnt]+B[b_cnt]>k:
    b_cnt-=1 

  ans=max(ans,a_cnt+b_cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))
i=0
j=0
count=0
ans=0
for i in range(1,n+1):
  A[i]=A[i]+A[i-1]


for j in range(1,m+1):
  B[i]=B[i]+B[i-1]

a_cnt=0
b_cnt=m
for a_cnt in range(n+1):
  if A[a_cnt]>k:
    continue
  while A[a_cnt]+B[b_cnt]>k:
    b_cnt-=1 
  ans=max(ans,a_cnt+b_cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))
i=0
j=0
count=0
ans=0
for i in range(1,n):
  A[i]=A[i]+A[i-1]


for j in range(1,m):
  B[i]=B[i]+B[i-1]

a_cnt=0
b_cnt=m
for a_cnt in range(n+1):
  if A[a_cnt]>k:
    continue
  #print('A',A[a_cnt])
  while A[a_cnt]+B[b_cnt]>k:
    #print('B',B[b_cnt+1])
    b_cnt-=1 
  ans=max(ans,a_cnt+b_cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))
i=0
j=0
count=0
ans=0
for i in range(1,n):
  A[i]=A[i]+A[i-1]


for j in range(1,m):
  B[i]=B[i]+B[i-1]


a_cnt=0
b_cnt=m
for a_cnt in range(n+1):
  if A[a_cnt]>k:
    continue
  #print('A',A[a_cnt])
  b_cnt=0
  while A[a_cnt]+B[b_cnt]>k:
    #print('B',B[b_cnt+1])
    b_cnt-=1 
  ans=max(ans,a_cnt+b_cnt)
print(ans)
Problem p02659 (python)

Fixed submission:
a,b =input().split()
a=int(a)
b=int(b.replace(".",""))


print(a*b//100)

Buggy submission (verdict: Runtime Error):
a,b=map(str,input().split())
a=int(a)
b=int(b*1000)

c=b/1000

x=int(a*b)

print(x)

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

x=int(a*b)
print('{.0}'.format(x))
Problem p02723 (python)

Fixed submission:
s = input()
if s[2]==s[3] and s[4]==s[5]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
K, N = map(int,input().split())
N = N-1
A = list(map(int, input().split()))
A_d = [ A[i+1]-A[i] for i in range(0, len(A)-1)]
A_d.append(K-A[-1]+A[0])
print(A_d)
A_d2 = (A_d+A_d[1:])*2
print(A_d2)
res = K
for i in range(len(A_d2)-1):
    if res > sum(A_d2[i:i+N]):
        res = sum(A_d2[i:i+N])
print(res)
Problem p02685 (python)

Fixed submission:
import itertools

n, m, k = map(int, input().split())


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


p = 998244353
N = n   # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0

l2 = m*(m-1)**(n-k-1)
for _k in range(k, -1, -1):
    # print(_k)

    ncr = cmb(n - 1, _k, p)
    ans += ncr * l2
    ans %= p
    l2 %= p
    l2 *= (m - 1)


print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

n, m, k = map(int, input().split())


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


p = 998244353
N = n   # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0

l2 = m*(m-1)**(n-k-2)
for _k in range(k, -1, -1):
    # print(_k)

    l2 %= p
    l2 *= (m - 1)
    l2 %= p

    ncr = cmb(n - 1, _k, p)
    ans += ncr * l2
    ans %= p


print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

n, m, k = map(int, input().split())


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


p = 998244353
N = n   # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0

l2 = m*(m-1)**(n-k-2)
for _k in range(k, -1, -1):
    # print(_k)

    l2 %= p
    l2 *= (m - 1)

    ncr = cmb(n - 1, _k, p)
    ans += ncr * l2
    ans %= p


print(ans)

Buggy submission (verdict: Runtime Error):
import itertools

n, m, k = map(int, input().split())


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


p = 998244353
N = n   # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0

l2 = m*(m-1)**(n-k-2)
for _k in range(k, -1, -1):
    # print(_k)
    l2 *= (m - 1)
    l2 %= p
    ncr = cmb(n - 1, _k, p)
    ans += ncr * l2
    ans %= p


print(ans)
Problem p02689 (python)

Fixed submission:
N, M = map(int, input().split())
H = [int(h) for h in input().split()]
ans = [1] * N


# print(H)

for i in range(M):
    a, b = map(int, input().split())
    AH = H[a - 1]
    BH = H[b - 1]
    # print(AH, BH)
    if AH >= BH:
        ans[b - 1] = 0
    if BH >= AH:
        ans[a - 1] = 0


print(ans.count(1))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
AB = []
H = input().split()
Hall = [1] * N
 
# print(H)
for i in range(M):
    a, b = map(int, input().split())
    AB.append([a, b])
    AH = H[a - 1]
    BH = H[b - 1]
    if AH >= BH:
        Hall[b - 1] = 0
    if BH >= AH:
        Hall[a - 1] = 0
 
 
print(Hall.count(1))
import numpy as np
N, M = map(int, input().split())
Problem p02711 (python)

Fixed submission:
x = input()
if ("7" in x) == True:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x = input()
for i in range(len(x)):
  if x[i] == "7":
    return "Yes"
Problem p02723 (python)

Fixed submission:
s = input()
     
if (s[2] == s[3]) & (s[4] == s[5]):
  print("Yes")
else:
  print("No")

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

if s[2] == s[3] & s[4] == s[5]:
  print("Yes")
else:
  print("No")
Problem p02682 (python)

Fixed submission:
a, b, c, k = map(int, input().split())
s = 0
if a >= k:
    s = k
elif  a + b >= k:
    s = a
else:
    s = a - (k - a - b) 
print(s)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
k = int(input())
s = 0
if  a + b >= k:
    s = a
else:
    s = a - (c - b) 
print(s)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
k = int(input())
s = 0
if  a + b >= k:
    s = a
else:
    s = a - c 
print(s)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
k = int(input())
s = 0
if 0 < a and 0 < k:
    s += a
    k -= a
elif 0 < b and 0 < k:
    k -= b
elif 0 < c and 0 < k:
    s -= c
    k -= c
print(s)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
k = int(input())
s = 0
while(0 < a and 0 < k):
    s += 1
    k -= 1
    a -= 1
while(0 < b and 0 < k):
    k -= 1
    b -= 1
while(0 < c and 0 < k):
    s -= 1
    k -= 1
    c -= 1
print(s)