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

Fixed submission:
n,m,l=map(int,input().split())

#基本的にワーシャルフロイドの場合、行列式のリストで距離を保管する
from scipy.sparse import csr_matrix
from scipy.sparse import csgraph 
d = [[10**12 for i in range(n+1)] for i in range(n+1)]
for i in range(m):
    x,y,z = map(int,input().split())
    #有向グラフか無向グラフかによってここで場合わけが生じる
    d[x][y] = z
    d[y][x] = z
    
for i in range(n+1):
    d[i][i] = 0 #自身のところに行くコストは０
q=int(input())
que=[]
for _ in range(q):
    s,t=map(int,input().split())
    que.append((s,t))
       
csr=csr_matrix(d)
K=csgraph.shortest_path(csr,method="FW",directed=True)
e = [[10**12 for i in range(n+1)] for i in range(n+1)]

for i in range(1,n+1):
    for j in range(1,n+1):
        if K[i][j]<=l:
            e[i][j]=1
            
for i in range(n+1):
    e[i][i]=0
    

A=csr_matrix(e)
ANS=csgraph.shortest_path(A,method="FW",directed=True)

for some in que:
    s,t=some[0],some[1]
    if int(ANS[s][t])<10**12:
        print(int(ANS[s][t])-1)
    else:
        print(-1)

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

#基本的にワーシャルフロイドの場合、行列式のリストで距離を保管する
from scipy.sparse import csr_matrix
from scipy.sparse import csgraph 

d = [[10**12 for i in range(n+1)] for i in range(n+1)]

for i in range(m):
    x,y,z = map(int,input().split())
    #有向グラフか無向グラフかによってここで場合わけが生じる
    d[x][y] = z
    d[y][x] = z
    
for i in range(n+1):
    d[i][i] = 0 #自身のところに行くコストは０
q=int(input())
que=[]
for _ in range(q):
    s,t=map(int,input().split())
    que.append((s,t))
       
csr=csr_matrix(d)
K=csgraph.shortest_path(csr,method="FW",directed=True)
e = [[10**12 for i in range(n+1)] for i in range(n+1)]

for i in range(1,n+1):
    for j in range(1,n+1):
        if K[i][j]<=l:
            e[i][j]=1
            
for i in range(n+1):
    e[i][i]=0
    

A=csr_matrix(e)
ANS=csgraph.shortest_path(A,method="FW",directed=True)

for some in que:
    s,t=some[0],some[1]
    if int(ANS[s][t])<10**12:
        print(int(ANS[s][t])-1)
    else:
        print(-1)
Problem p02900 (python)

Fixed submission:
a,b=map(int,input().split())
import fractions
gcds=fractions.gcd(a,b)
cnt=0
primelist=[2]

while gcds%2==0:
    gcds=gcds//2
    cnt+=1
#この時点でgcdsは奇数になっているはずである
n = 10**6
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
                #エラトステネスの篩
prime.remove(2)

for some in prime:
    if gcds%some==0:
        while gcds%some==0:
            gcds=int(gcds/some)
        primelist.append(some)  

if gcds!=1 and cnt>=1:
    primelist.append("larger")
    primelist.append(1)
    
elif gcds!=1 and cnt==0:
    primelist.append("larger")
    primelist.remove(2)
    primelist.append(1)
elif gcds==1 and cnt>=1:
    primelist.append(1)
elif gcds==1 and cnt==0:
    primelist.remove(2)
    primelist.append(1)

print(len(primelist))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
import math
gcds=math.gcd(a,b)
cnt=0
primelist=[2]

while gcds%2==0:
    gcds=gcds//2
    cnt+=1
#この時点でgcdsは奇数になっているはずである
n = 10**6
prime = {i for i in range(2,n)}
for i in range(2,n):
    if i in prime:
        for j in range(i*2,n,i):
            if j in prime:
                prime.remove(j)
                #エラトステネスの篩
prime.remove(2)

for some in prime:
    if gcds%some==0:
        while gcds%some==0:
            gcds=int(gcds/some)
        primelist.append(some)  

if gcds!=1 and cnt>=1:
    primelist.append("larger")
    primelist.append(1)
    
elif gcds!=1 and cnt==0:
    primelist.append("larger")
    primelist.remove(2)
    primelist.append(1)
elif gcds==1 and cnt>=1:
    primelist.append(1)
elif gcds==1 and cnt==0:
    primelist.remove(2)
    primelist.append(1)

print(len(primelist))
Problem p02909 (python)

Fixed submission:
S=input()
if S=="Rainy":
  print("Sunny")
if S=="Sunny":
  print("Cloudy")
if S=="Cloudy":
  print("Rainy")

Buggy submission (verdict: Runtime Error):
s=input()
if s==‘Sunny’:
    print(‘Cloudy’)
elif s==‘Cloudy’:
    print(‘Rainy’)
elif s==‘Rainy’:
    print(‘Sunny’)
Problem p02913 (python)

Fixed submission:
# who says a pun?

# 今日の精進問題第三問目ｎ

n = int(input())
s = list(input())
# dp[L][K]=一番目は左からL番目、二番目は左からK番目からスタートするとした時の共通文字列の中で長さが最大のもの
dp = [[0 for i in range(n + 2)] for j in range(n + 2)]
# もしi>=jであるならば答えは当然ゼロ
# 0<i<jである時だけで考える
for j in range(n, 1, -1):
    # j=n,n-1,,,,,,,,2の値をとる
    for i in range(1, j):

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

Buggy submission (verdict: Runtime Error):

# who says a pun?

# 今日の精進問題第三問目ｎ

n = int(input())
s = list(input())[:-1]
# dp[L][K]=一番目は左からL番目、二番目は左からK番目からスタートするとした時の共通文字列の中で長さが最大のもの
dp = [[0 for i in range(n + 2)] for j in range(n + 2)]
# もしi>=jであるならば答えは当然ゼロ
# 0<i<jである時だけで考える
for j in range(n, 1, -1):
    # j=n,n-1,,,,,,,,2の値をとる
    for i in range(1, j):

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

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
f = open('input.txt', 'r')
sys.stdin = f
input = sys.stdin.readline

# who says a pun?

# 今日の精進問題第三問目ｎ

n = int(input())
s = list(input())[:-1]
# dp[L][K]=一番目は左からL番目、二番目は左からK番目からスタートするとした時の共通文字列の中で長さが最大のもの
dp = [[0 for i in range(n + 2)] for j in range(n + 2)]
# もしi>=jであるならば答えは当然ゼロ
# 0<i<jである時だけで考える
for j in range(n, 1, -1):
    # j=n,n-1,,,,,,,,2の値をとる
    for i in range(1, j):

        if s[i - 1] == s[j - 1]:
            dp[i][j] = dp[i + 1][j + 1] + 1
        else:
            dp[i][j] = 0
ans = 0
for j in range(2, n + 1):
    for i in range(1, j):
        ans = max(ans, min(dp[i][j],j-i))
print(ans)
Problem p02929 (python)

Fixed submission:
# problem 7
# cell inversion
N = int(input())
S = input()
if S[0]=="W":
    print(0)
    exit()
mod = 10**9 + 7
D = [-1]  # left -1 right 1
for i in range(2*N-1):
    if S[i] != S[i+1]:
        D.append(D[-1])
    else:
        D.append(D[-1]*(-1))
left = []
for i in range(2*N):
    if D[i] < 0:
        left.append(i)
sums = [0 for i in range(2*N)]
for i in range(2*N):
    if D[i] > 0:
        sums[i] += 1
for i in range(2*N-2, -1, -1):
    sums[i] += sums[i+1]
ans = 1
for i in range(2, N+1):
    ans *= i
    ans %= mod
if len(left)!=N:
    print(0)
    exit()
for i in range(N):
    ans *= sums[left[i]]-(N-1-i)
    ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
# problem 7
# cell inversion
N = int(input())
S = input()
if S[0]=="W":
    print(0)
    exit()
mod = 10**9 + 7
D = [-1]  # left -1 right 1
for i in range(2*N-1):
    if S[i] != S[i+1]:
        D.append(D[-1])
    else:
        D.append(D[-1]*(-1))
left = []
for i in range(2*N):
    if D[i] < 0:
        left.append(i)
sums = [0 for i in range(2*N)]
for i in range(2*N):
    if D[i] > 0:
        sums[i] += 1
for i in range(2*N-2, -1, -1):
    sums[i] += sums[i+1]
ans = 1
for i in range(2, N+1):
    ans *= i
    ans %= mod
for i in range(N):
    ans *= sums[left[i]]-(N-1-i)
    ans %= mod
print(ans)
Problem p02937 (python)

Fixed submission:
# -*- coding: UTF-8 -*-
import math
import bisect
# f=open("test.txt")
# line=f.readline()
# lists=[]
# while line:
#     lists.append("".join(list(line)[:-1]))
#     line=f.readline()
# 
# f.close()
# 
# s=lists[0]
# t=lists[1]

s=input()
t=input()

alpha=list("abcdefghijklmnopqrstuvwxyz")

dic_s={alpha[i]:0 for i in range(26)}
dic_t={alpha[i]:0 for i in range(26)}

a={alpha[i]:[] for i in range(26)}
b={alpha[i]:[] for i in range(26)}


for i in range(len(s)):
  
    if dic_s[s[i]]==0:
        dic_s[s[i]]=+1
    a[s[i]].append(i+1)


for j in range(len(t)):
    
    if dic_t[t[j]]==0:
        dic_t[t[j]]=+1
    b[t[j]].append(j+1)
for i in range(26):
	a[alpha[i]].append(10**9)
flag=True

for i in range(26):
    if dic_t[alpha[i]]>0 and dic_s[alpha[i]]==0:
        flag=False

place=[0,0]

if flag:
    #文字を構成できる場合
    for i in range(len(t)):
        string=t[i]
        num=bisect.bisect_right(a[string],place[0])  
        if a[string][num]==10**9:
            place[1]+=1
            place[0]=a[string][0]
        else:
            place[0]=a[string][num]
  

    print(place[0]+place[1]*len(s))

else:
    #構成できない場合
    print(-1)

Buggy submission (verdict: Runtime Error):
# -*- coding: UTF-8 -*-
import math
# f=open("test.txt")
# line=f.readline()
# lists=[]
# while line:
#     lists.append("".join(list(line)[:-1]))
#     line=f.readline()
# 
# f.close()
# 
# s=lists[0]
# t=lists[1]

s=input()
t=input()

alpha=list("abcdefghijklmnopqrstuvwxyz")

dic_s={alpha[i]:0 for i in range(26)}
dic_t={alpha[i]:0 for i in range(26)}

a={alpha[i]:[] for i in range(26)}
b={alpha[i]:[] for i in range(26)}


for i in range(len(s)-1):
    if dic_s[s[i]]==0:
        dic_s[s[i]]=+1
        a[s[i]].append(i+1)


for j in range(len(t)-1):
    if dic_t[t[j]]==0:
        dic_t[t[j]]=+1
        b[t[j]].append(j+1)

flag=True

for i in range(26):
    if dic_t[alpha[i]]>0 and dic_s[alpha[i]]==0:
        flag=False

place=[0,0]

def binary(now,string):
    left=a[string][0]
    right=a[string][-1]
    #sのなかでstringがあり得る最大の位置
    #左のインデックスと右のインデックスを決める
    #now=現在いるindex
    flag=True
    if now>right:
        place[0]=left
        place[1]+=1

    elif now<left:
        place[0]=left
    else:
        indexl=0
        indexr=dic_s[string]-1
        for _ in range(20):
            c=math.floor((indexl+indexr)/2)
            if a[string][c]<=now:
                indexl=c
                indexr=indexr
            elif a[string][c]>now:
                indexl=indexl
                indexr=c
        place[0]=a[string][indexr]

if flag:
    #文字を構成できる場合
    for i in range(len(t)):
        string=t[i]
        now=place[0]
        binary(now,string)

    print(place[0]+place[1]*len(s))

else:
    #構成できない場合
    print(-1)
Problem p02949 (python)

Fixed submission:
# Coins Respawn
import sys
sys.setrecursionlimit(10**7)
from collections import deque
N, M, P = map(int, input().split())
graph = []
d = deque()

# グラフの整形

from_1 = [[] for i in range(N+1)]
from_N = [[] for i in range(N+1)]

for _ in range(M):
    a, b, c = map(int, input().split())
    from_1[a].append(b)
    from_N[b].append(a)
    d.append((a, b, P-c))


accessible_1 = [False for i in range(N+1)]
accessible_N = [False for i in range(N+1)]


def dfs_1(s):
    accessible_1[s] = True
    for node in from_1[s]:
        if accessible_1[node] == False:
            dfs_1(node)


def dfs_N(s):
    accessible_N[s] = True
    for node in from_N[s]:
        if accessible_N[node] == False:
            dfs_N(node)


dfs_1(1)
dfs_N(N)

isok = [False for i in range(N+1)]
for i in range(N+1):
    if accessible_1[i] and accessible_N[i]:
        isok[i] = True


while d:
    p, q, weight = d.popleft()
    if isok[p] and isok[q]:
        graph.append((p, q, weight))

# ベルマンフォード


def bellman_ford(s,n):
    dist = [10**20 for i in range(n+1)]
    dist[s] = 0
    for i in range(1, n+1):
        flag = False
        for some in graph:
            a, b, d = some[0], some[1], some[2]
            newlen = dist[a]+d
            if newlen < dist[b]:
                flag = True
                dist[b] = newlen
        if not flag:
            break
        if i == n:
            return False
    return dist

K=bellman_ford(1,N)
if K==False:
     print(-1)
else:
    print(max(0,-K[N]))

Buggy submission (verdict: Runtime Error):
# Coins Respawn

from collections import deque
N, M, P = map(int, input().split())
graph = []
d = deque()

# グラフの整形

from_1 = [[] for i in range(N+1)]
from_N = [[] for i in range(N+1)]

for _ in range(M):
    a, b, c = map(int, input().split())
    from_1[a].append(b)
    from_N[b].append(a)
    d.append((a, b, P-c))


accessible_1 = [False for i in range(N+1)]
accessible_N = [False for i in range(N+1)]


def dfs_1(s):
    accessible_1[s] = True
    for node in from_1[s]:
        if accessible_1[node] == False:
            dfs_1(node)


def dfs_N(s):
    accessible_N[s] = True
    for node in from_N[s]:
        if accessible_N[node] == False:
            dfs_N(node)


dfs_1(1)
dfs_N(N)

isok = [False for i in range(N+1)]
for i in range(N+1):
    if accessible_1[i] and accessible_N[i]:
        isok[i] = True


while d:
    p, q, weight = d.popleft()
    if isok[p] and isok[q]:
        graph.append((p, q, weight))

# ベルマンフォード


def bellman_ford(s,n):
    dist = [10**20 for i in range(n+1)]
    dist[s] = 0
    for i in range(1, n+1):
        flag = False
        for some in graph:
            a, b, d = some[0], some[1], some[2]
            newlen = dist[a]+d
            if newlen < dist[b]:
                flag = True
                dist[b] = newlen
        if not flag:
            break
        if i == n:
            return False
    return dist

K=bellman_ford(1,N)
if K==False:
     print(-1)
else:
    print(max(0,-K[N]))
Problem p02972 (python)

Fixed submission:
n=int(input())
lists=list(map(int,input().split()))
lists.insert(0,0)
anslists=[0]*(n+1)
for j in range(n,0,-1):
# j=n,n-1,.......,2,1という感じ
    numbers=n//j
    if numbers==1:
        anslists[j]=lists[j]
    else:
        check=0
        for i in range(2,numbers+1):
            check+=anslists[i*j]
            
        if check%2==0:
            anslists[j]=lists[j]
            
        else:
            
            if lists[j]==1:
                anslists[j]=0
                
            if lists[j]==0:
                anslists[j]=1
                

printA=0

del anslists[0]


Anslist=[]
for k in range(n):
    if anslists[k]==1:
        printA+=1
        Anslist.append(k+1)
print(printA)
print(*Anslist)

Buggy submission (verdict: Runtime Error):
n=int(input())
lists=list(map(int,input().split()))
anslists=[0]*(n)

for i in range(n-1,-1,-1):
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
　　    
        for some in range(number):
               check+=anslists[(i+1)*(some+1)]
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
Anscnt=0
Anslist=[]
for j in range(n):
    if anslists[j]==1:
        Anslist.append(j+1)
        Anscnt+=1
print(Anscnt)
print(*Anslist)

Buggy submission (verdict: Runtime Error):
n=int(input())
lists=list(map(int,input().split())
anslists=[0]*(n+1)

for i in range(n-1,-1,-1):
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
        cnt=0
        check=0
        while cnt<=number-1:
           check+=anslists[i+cnt*(i+1)]
           cnt+=1
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
           
           
print(*anslists)

Buggy submission (verdict: Runtime Error):
n=int(input())
lists=list(map(int,input().split())
anslists=[0]*(n+1)

for i in range(n-1,-1,-1):
    cnt=0
    check=0
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
        while cnt<=number-1:
           check+=anslists[i+cnt*(i+1)]
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
           
           
print(*anslists)
Problem p02995 (python)

Fixed submission:
#a以上b以下の整数のうちcでもdでも割り切れないものの個数を求めてください
#1以上b以下の整数の条件を満たすものから1以上a-1以下のもので条件を満たすものを取り除くようにすればいい
import fractions

a,b,c,d=map(int,input().split())
x=c*d//fractions.gcd(c,d)
n=b-((b//c)+(b//d)-b//(x))
m=(a-1)-((a-1)//c+(a-1)//d-(a-1)//(x))
print(n-m)

Buggy submission (verdict: Runtime Error):
#a以上b以下の整数のうちcでもdでも割り切れないものの個数を求めてください
#1以上b以下の整数の条件を満たすものから1以上a-1以下のもので条件を満たすものを取り除くようにすればいい
import fractions
x=c*d//fractions.gcd(c,d)
a,b,c,d=map(int,input().split())
n=b-((b//c)+(b//d)-b//(x))
m=(a-1)-((a-1)//c+(a-1)//d-(a-1)//(x))
print(n-m)

Buggy submission (verdict: Runtime Error):
#a以上b以下の整数のうちcでもdでも割り切れないものの個数を求めてください
#1以上b以下の整数の条件を満たすものから1以上a-1以下のもので条件を満たすものを取り除くようにすればいい
import math
x=c*d//math.gcd(c,d)
a,b,c,d=map(int,input().split())
n=b-((b//c)+(b//d)-b//(x))
m=(a-1)-((a-1)//c+(a-1)//d-(a-1)//(x))
print(n-m)
Problem p03006 (python)

Fixed submission:
n=int(input())
lists=[]
if n>=2:
    for i in range(n):
        a,b=map(int,input().split())
        lists.append([a,b])
    diflist=[]
    for i in range(n):
        for j in range(n):
            if i!=j:
                add=(lists[i][0]-lists[j][0],lists[i][1]-lists[j][1])
                diflist.append(add)
            else:
                continue
    import collections
    dic=collections.Counter(diflist)
    value=dic.values()
    a=max(value)
    print(n-a)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
n=int(input())
lists=[]
for i in range(n):
    a,b=map(int,input().split())
    lists.append([a,b])
diflist=[]
for i in range(n):
    for j in range(n):
        if i!=j:
            add=(lists[i][0]-lists[j][0],lists[i][1]-lists[j][1])
            diflist.append(add)
        else:
            continue
import collections
dic=collections.Counter(diflist)
value=dic.values()
a=max(value)
print(n-a)
Problem p03032 (python)

Fixed submission:
n,k=map(int,input().split())
lists=list(map(int,input().split()))
ans=0
nums=min(n,k)
for j in range(1,nums+1):
    #スライドするときの数 j=0,1,2,3,4......numsまでとることができる
    #n<kの時max n　かつかくjに対して取り除けるのはk-j回めまでである
    #n>=kの時max k かつ　かくｊに対して取り除けるのはk-j回までである
    for m in range(j+1):
        sublist=lists[:m]+lists[n+m-j:]
        sublist=sorted(sublist)
        sublist.append(0)
        del_some=0
        while del_some<k-j and min(sublist)<0:
            del sublist[0]
            del_some+=1
        p=sum(sublist)
        ans=max(ans,p)
print(ans)

Buggy submission (verdict: Runtime Error):
# equeue

from collections import deque
import heapq


def main():
    N, K = map(int, input().split())
    V = list(map(int, input().split()))
    res = 0
    for pull in range(K+1):
        push = K - pull
        if push < 0:
            continue
        for left_push in range(push+1):
            tmp_que = deque(V)
            tmp_heap = []
            heapq.heapify(tmp_heap)
            right_push = push - left_push
            for _ in range(left_push):
                heapq.heappush(tmp_heap, tmp_que.popleft())
            for _ in range(right_push):
                heapq.heappush(tmp_heap, tmp_que.pop())

            tmp_res = sum(tmp_que)
            for i in range(min(push, pull)):
                x = heapq.heappop(tmp_heap)
                if x >= 0:
                    heapq.heappush(tmp_heap, x)
                    break

            res = max(res, sum(tmp_heap))
    print(res)
    return


if __name__ == "__main__":
    main()
Problem p03037 (python)

Fixed submission:
n,m=list(map(int, input().split() ))
Firstlis=[]
Secondlis=[]
for i in range(m):
  s=list(map(int,input().split()))
  S1=s[0]
  S2=s[1]
  Firstlis.append(S1)
  Secondlis.append(S2)
Min=max(Firstlis)
Max=min(Secondlis)
if Max>=Min:
    print(Max-Min+1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,m=list(map(int, input().split() ))
Firstlis=[]
Secondlis=[]
for i in range(m):
  s=list(map(int,inout().split()))
S1=s[0]
S2=s[1]
Firstlis.append(S1)
Secondlis.append(S2)
Min=max(Firstlis)
Max=min(Secondlis)
print(Max-Min)

Buggy submission (verdict: Runtime Error):
n,m=list(map(int, input().split() ))
ists=[]
for i in range(m):
  s=list(map(int,inout().split()))
  ists.append(s)
ans=0
justified=True
for j in range(n):
  for k in range(m):
    if ists[k][0]<=j<=ists[k][1]:
      continue
    else:
      justified=False
      break
  if justified:
    ans+=1
    justified=True

print(ans)

Buggy submission (verdict: Runtime Error):
n,m=list(map(int,input().split()))
ists=[]
for i in range(m):
  s=list(map(int,inout().split()))
  ists.append(s)
ans=0
justified=True
for j in range(n):
  for k in range(m):
    if ists[k][0]<=j<=ists[k][1]:
      continue
    else:
      justified=False
      break
  if justified:
    ans+=1
print(ans)
Problem p03039 (python)

Fixed submission:
##mod,nについての制約は自分でいかに記入する
mod=10**9+7
def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist
 #あるかずxのn乗をmodで割ったあまりを返す関数pow_cal(x,n,mod)
def pow_cal(x,n,mod):
    if n==0:
         return 1
    elif n==1:
         return x%mod
    elif n>=2:
        if n%2==0:
             return (pow_cal(x,n//2,mod)**2)%mod
        else:
             return (x*pow_cal(x,n//2,mod)**2)%mod

def find_inv_power(n,mod):
    #0!からn!までの逆元を素数modで割ったあまりリストを作る関数
    c=1
    uselist=[0 for i in range(n+1)]
    for i in range(1,n+1):
        c*=i
        c%=mod
    first=pow_cal(c,mod-2,mod)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(mod)
    return uselist
    
A=find_power(4*10**5,mod)
B=find_inv_power(4*10**5,mod)

def combi(n,r,mod):
    if n<r:
        return 0
    elif n>=r:
        return (A[n]*B[r]*B[n-r])%(mod)

    
M,N,K=map(int,input().split())
ans=M*N*(M+N)*(M*N-1)//6

print(ans*combi(M*N-2,K-2,mod)%mod)

Buggy submission (verdict: Runtime Error):

##mod,nについての制約は自分でいかに記入する

def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist
 #あるかずxのn乗をmodで割ったあまりを返す関数pow_cal(x,n,mod)
def pow_cal(x,n,mod):
    if n==0:
         return 1
    elif n==1:
         return x%mod
    elif n>=2:
        if n%2==0:
             return (pow_cal(x,n//2,mod)**2)%mod
        else:
             return (x*pow_cal(x,n//2,mod)**2)%mod

def find_inv_power(n,mod):
    #0!からn!までの逆元を素数modで割ったあまりリストを作る関数
    c=1
    uselist=[0 for i in range(n+1)]
    for i in range(1,n+1):
        c*=i
        c%=mod
    first=pow_cal(c,mod-2,mod)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(mod)
    return uselist
    
A=find_power(4*10**5,mod)
B=find_inv_power(4*10**5,mod)

def combi(n,r,mod):
    if n<r:
        return 0
    elif n>=r:
        return (A[n]*B[r]*B[n-r])%(mod)

    
M,N,K=map(int,input().split())
ans=M*N*(M+N)*(M*N-1)//6
mod=10**9+7
print(ans*combi(M*N-2,K-2,mod)%mod)