Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a = input().split()
X = int(a[0])
N = int(a[1])
OK = []
list = []
if N ==0:
    print(X)
else:
    P = input().split()
    for i in range(100):
        OK.append(str(i + 1))
    for i in range(len(P)):
        OK.remove(P[i])
    for i in range(len(OK)):
        list.append(abs(int(OK[i]) - X))
    Y = list.index(min(list))
    print(OK[Y])

Fixed submission:
a = input().split()
X = int(a[0])
N = int(a[1])
OK = []
list = []
if N ==0:
    print(X)
else:
    P = input().split()
    for i in range(102):
        OK.append(str(i))
    for i in range(len(P)):
        OK.remove(P[i])
    for i in range(len(OK)):
        list.append(abs(int(OK[i]) - X))
    Y = list.index(min(list))
    print(OK[Y])
Buggy python submission (verdict: Runtime Error):
s = input().split()
print(s[0] * s[1])

Fixed submission:
s = input().split()
A = int(s[0])
B = int(s[1])
print(A * B)
Buggy python submission (verdict: Runtime Error):
a = list(map(int,input().split()))
A = a[0]
B = a[1]
C = a[2]
K = a[3]
if A > k :
    print(A)
elif (A + B) > K:
    print(A)
else:
    print(A-(K-A-B))

Fixed submission:
a = list(map(int,input().split()))
A = a[0]
B = a[1]
C = a[2]
K = a[3]
if A > K :
    print(K)
elif (A + B) > K:
    print(A)
else:
    print(A-(K-A-B))
Buggy python submission (verdict: Runtime Error):
A,B,C=[int(i) for i in input().split()]
if A*C <B:
  print C
else:
  print B % A

Fixed submission:
A,B,C=[int(i) for i in input().split()]
if A*C<= B:
    print (C)
else:
    print (int(B/A))
Buggy python submission (verdict: Runtime Error):

def main():
    S = input()
    T = input()
    # Sのi文字目をTの先頭として，それらの文字列の一致度を見る．

    st = {}
    for i in range(len(S)-len(T)+1):
        cnt = 0
        for s, t in zip(S[i:i+len(T)], T):
            cnt += s == t
        st.add(cnt)
    print(len(T) - max(st))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    S = input()
    T = input()
    # Sのi文字目をTの先頭として，それらの文字列の一致度を見る．

    st = set()
    for i in range(len(S)-len(T)+1):
        cnt = 0
        for s, t in zip(S[i:i+len(T)], T):
            cnt += s == t
        st.add(cnt)
    print(len(T) - max(st))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def main(H, W, M, obj_h, obj_w, obj):
    c_h = Counter(obj_h)
    c_w = Counter(obj_w)
    max_h = max(c_h.values())
    max_w = max(c_w.values())
    lst_h = [kv[0] for kv in c_h.items() if kv[1] == max_h]
    lst_w = [kv[0] for kv in c_w.items() if kv[1] == max_w]
    for h in lst_h:
        for w in lst_w:
            if [h, w] not in obj:
                print(max_h + max_w)
                exit()
    else:
        print(max_h + max_w - 1)



if __name__ == '__main__':
    H, W, M = list(map(int, input().split()))
    obj = []
    obj_h = []
    obj_w = []
    for _ in range(M):
        i = list(map(int, input().split()))
        obj.append(i)
        obj_h.append(i[0])
        obj_w.append(i[1])
    main(H, W, M, obj_h, obj_w, obj)

Fixed submission:
from collections import Counter

def main(H, W, M, obj_h, obj_w, obj):
    c_h = Counter(obj_h)
    c_w = Counter(obj_w)
    max_h = max(c_h.values())
    max_w = max(c_w.values())
    lst_h = [kv[0] for kv in c_h.items() if kv[1] == max_h]
    lst_w = [kv[0] for kv in c_w.items() if kv[1] == max_w]
    for h in lst_h:
        for w in lst_w:
            if (h, w) not in obj:
                print(max_h + max_w)
                exit()
    else:
        print(max_h + max_w - 1)



if __name__ == '__main__':
    H, W, M = list(map(int, input().split()))
    obj = set()
    obj_h = []
    obj_w = []
    for _ in range(M):
        i = list(map(int, input().split()))
        obj.add(tuple(i))
        obj_h.append(i[0])
        obj_w.append(i[1])
    main(H, W, M, obj_h, obj_w, obj)
Buggy python submission (verdict: Time Limit Exceeded):
def main(N, K, A):
    for i in range(K-1, N): # 0 から数えるから K-1
        # 総積
        this = A[i-(K-1):i+1]   # 直近3学期． i+1はスライスのときその数字は入らないから．

        # print
        if i != K-1:
            if this[-1] > before[0]:
                print('Yes')
            else:
                print('No')
        before = this


if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

Fixed submission:
def main(N, K, A):
    for i in range(K, N): # 0 から数えるから K-1
        this = A[i]
        before = A[i-K]

        if this > before:
            print('Yes')
        else:
            print('No')



if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

Buggy python submission (verdict: Time Limit Exceeded):
def main(N, K, A):
    for i in range(K-1, N): # 0 から数えるから K-1
        this = 1

        # 総積
        for a in A[i-(K-1):i+1]:   # 直近3学期． i+1はスライスのときその数字は入らないから．
            this *= a

        # print
        if i != K-1:
            if this > before:
                print('Yes')
            else:
                print('No')
        before = this


if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

Fixed submission:
def main(N, K, A):
    for i in range(K, N): # 0 から数えるから K-1
        this = A[i]
        before = A[i-K]

        if this > before:
            print('Yes')
        else:
            print('No')



if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)
Buggy python submission (verdict: Runtime Error):
def main(N, K, A):
    i = 0   # 現在地
    lst_memo = []
    set_memo = set([])
    while i not in set_memo:
        lst_memo.append(i)
        set_memo.add(i)
        i = A[i] - 1    # pythonは一つずれる
    key = lst_memo.index(i)
    if K <= key:
        print(lst_memo[K - 1] + 1)
    else:
        roop = lst_memo[key:]
        print(roop[key + (K - key) % len(roop)] + 1)    # pythonは一つずれる


if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

Fixed submission:
def main(N, K, A):
    i = 0   # 現在地
    lst_memo = []
    set_memo = set([])
    while i not in set_memo:
        lst_memo.append(i)
        set_memo.add(i)
        i = A[i] - 1    # pythonは一つずれる
    key = lst_memo.index(i)
    if K < key:
        print(lst_memo[K] + 1)
    else:
        roop = lst_memo[key:]
        print(roop[(K - key) % len(roop)] + 1)    # pythonは一つずれる


if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

Buggy python submission (verdict: Runtime Error):
def main(N, K, A):
    i = 0   # 現在地
    lst_memo = []
    set_memo = {}
    while i not in set_memo:
        lst_memo.append(i)
        set_memo.append(i)
        i = A[i] - 1    # pythonは一つずれる
    key = lst_memo.index(i)
    roop = memo[key:]
    print(roop[(K - key) % len(roop)] + 1)    # pythonは一つずれる


if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)

Fixed submission:
def main(N, K, A):
    i = 0   # 現在地
    lst_memo = []
    set_memo = set([])
    while i not in set_memo:
        lst_memo.append(i)
        set_memo.add(i)
        i = A[i] - 1    # pythonは一つずれる
    key = lst_memo.index(i)
    if K < key:
        print(lst_memo[K] + 1)
    else:
        roop = lst_memo[key:]
        print(roop[(K - key) % len(roop)] + 1)    # pythonは一つずれる


if __name__ == '__main__':
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))
    main(N, K, A)
Buggy python submission (verdict: Time Limit Exceeded):
import math

def main(A, B, N):
    answer = 0
    for x in range(N + 1):
        cand = math.floor(A * x / B) - A * math.floor(x / B)
        answer = max(answer, cand)
    print(answer)



if __name__ == '__main__':
    A, B, N = list(map(int, input().split()))
    # A, B, N = 5, 7, 4
    main(A, B, N)


Fixed submission:
import math

def main(A, B, N):
    x = min(B-1, N)
    answer = math.floor(A * x / B) - A * math.floor(x / B)
    print(answer)

if __name__ == '__main__':
    A, B, N = list(map(int, input().split()))
    main(A, B, N)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

def main(A):
    return collections.Counter(A)


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    # N = 7
    # A = list(map(int, "1 2 3 4 5 6".split()))
    [print(main(A)[i + 1]) for i in range(N)]


Fixed submission:
import collections

def main(N, A):
    c = collections.Counter(A)
    [print(c[i+1]) for i in range(max(c.keys()))]
    [print(0) for i in range(max(c.keys()), N)]

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    # N = 7
    # A = list(map(int, "1 2 3 4 5 6".split()))
    main(N, A)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()

counta = 0
i = 0

while i < N - 2:
    j = i + 1
    while j < N - 1:
        if S[j] != S[i]:
            k = j + 1
            rest = [l for l in ['R', 'G', 'B'] if l != S[i] and l != S[j]]
            while k < N:
                if S[k] == rest[0] and  k - j != j - i:
                    counta += 1
                k += 1
        j += 1
    i += 1

print(counta)

Fixed submission:
import math
import itertools
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

K = int(input())

ans = 0
for lst in itertools.combinations_with_replacement([i + 1 for i in range(K)], 3):
    ans += int(6 / math.factorial(4 - len(set(lst)))) * gcd(list(lst))

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

real = A[M] / sum(A)
ideal = 1 / (4 * M)

if real >= ideal:
    print("Yes")
else:
    print("No")


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

A.sort(reverse = True)
real = A[M-1] / sum(A)
ideal = 1 / (4 * M)

if real >= ideal:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import collections
import math

#****************************************************************
def comb(n):
    if n < 2:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))
#****************************************************************

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

c = collections.Counter(A)
dict_ans = {i:0 for i in c.keys()}
full_ans = sum(list(map(comb, c.values())))

for i in c.keys():
    target = c.copy()
    target[i] -= 1
    if target[i] == 0:
        dict_ans[i] = full_ans
    else:
        dict_ans[i] = sum(list(map(comb, target.values())))

for i in A:
    print(dict_ans[i])


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

ans = int((N + M) * (N + M - 1) / 2 - N * M)
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
P = np.array(input().split(' '), dtype = int)
# P = np.array(list(map(int, input().split(' '))))

counta = 0
for i in range(N):
    counta += np.all((P[:i+1] >= P[i]))
print(counta)

Fixed submission:
N, M = map(int, input().split(' '))
if N == M:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))

i = 1
j = 0

while j < N and i in set(a[j:]):
    j = a[j:].index(i) + j
    # print(i, j)
    i += 1

if 1 in set(a):
    print(N - i + 1)
else:
    print(-1)

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

i = 1
# j = 0

if 1 in set(a):
    # while j < N and i in set(a[j:]):
    #     j = a[j:].index(i) + j
    #     # print(i, j)
    #     i += 1
    for a_i in a:
        if a_i == i:
            i += 1
    print(N - i + 1)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
def cookies(A,B):
    if A%3==0 or B%3==0 or (A+B)%3==0:
        return 'Possible'
    else:
        return 'Impossible

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

if A%3==0 or B%3==0 or (A+B)%3==0:
    print('Possible')
else:
    print('Impossible')
Buggy python submission (verdict: Runtime Error):
N ,L = map(int,input().split())
lis = []
for i in range(N):
  lis.append(L+i)

mini = 100
index = ""
for i in range(N):
  if mini > abs(lis[i]):
    mini = abs(lis[i])
    index = i

print(sum(lis)-lis[index])

Fixed submission:
N ,L = map(int,input().split())
lis = []
for i in range(N):
  lis.append(L+i)

mini = 100
index = 0
for i in range(N):
  if mini > abs(lis[i]):
    mini = abs(lis[i])
    index = i

print(sum(lis)-lis[index])
Buggy python submission (verdict: Runtime Error):
N, X = map(int,input().split())

lis = list(map(int,input().split()))
i = 0
sum = 0
while  sum <= X:
  sum += lis[i]
  i += 1
print(i)

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

lis = list(map(int,input().split()))
count = 1
sm = 0
for l in lis:
  sm += l
  if sm > X:
    break
  count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())

list_a = []
list_b = []
list_dist = []

for i in range(N):
  list_a.append(list(map(int, input().split())))

for j in range(Q):
  list_b.append(int(input()))

list_a.sort(key=lambda x:x[2])


for b in list_b:
  dist = 0
  time = b
  stop_flag = 0
  for a in list_a:
    time = time + a[2] - dist
    dist = a[2]
    if time > a[0]-0.5 and time < a[1]-0.5:
      stop_flag = 1
      break
  if stop_flag == 0:
    list_dist.append(-1)
  else:
    list_dist.append(dist)

for dist in list_dist:
  print(dist)

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

P = A * 3 + P
print(int(P / 2))
Buggy python submission (verdict: Runtime Error):
r, D, x = map(int, input(),split())

def calc(r, D, x):
  return (r * x) - D

for _ in range(10):
  x = calc(r, D, x)
  print(x)

Fixed submission:
r, D, x = map(int, input().split())

def calc(r, D, x):
  return (r * x) - D

for _ in range(10):
  x = calc(r, D, x)
  print(x)
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(n):
  d = map(int, input().split())


answer = 'No'

count = 0
for i in range(n):
    if d[i][0] != d[i][1]:
        count = 0
    else:
        count += 1

    if count == 3:
        answer = 'Yes'
        break

print(answer)


Fixed submission:
def judge():
    cnt = 0  
    for _ in range(N):
        x, y = map(int, input().split())
        if x == y:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            return True
    return False

N = int(input())

if judge():  
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
a_li = list(map(int,input().split()))
 
for i in range(k,n):
    if a_li[i-k] < a_li[i]:
        print("Yes")
    else:
        print("No")
n,k = map(int,input().split())
a_li = list(map(int,input().split()))

for i in range(k,n):
    if a_li[i-k] < a_li[i]:
        print("Yes")
    else:
        print("No")


Fixed submission:
n,k = map(int,input().split())
a_li = list(map(int,input().split()))
 
for i in range(k,n):
    if a_li[i-k] < a_li[i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(0,n+1,2):
  if a[i]%2==1:
    count+=1
  else:
    continue
print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(0,n,2):
  if a[i]%2==1:
    count+=1
  else:
    continue
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = (n//1000) + 1
if n%1000=0:
  print(0)
else:
  print(x*1000-n)

Fixed submission:
n = int(input())
x = (n//1000) + 1
if n%1000==0:
  print(0)
else:
  print(x*1000-n)
Buggy python submission (verdict: Runtime Error):
s = input()
if s.issupper == True:
  print("A")
else:
  print("a")

Fixed submission:
s = str(input())
if s.isupper():
  print("A")
else:
  print("a")
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
crain = (4 * x - y) / 2
if y>=2x and y<=4x and y%2==0:
    print("Yes")
else:
    print("No")

Fixed submission:
x,y = map(int,input().split())
if y>=2*x and y<=4*x and y%2==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce
n = int(input())
a = map(int,input().split())
s = list(a)
p = reduce(mul, s)
if p>10**18:
  print(-1)
else:
  print(p)

Fixed submission:
def solve(N, A):
    ret = 1
    upper = 10**18
    if 0 in A:
      return 0
    for i in A:
        ret *= i
        if upper < ret:
          return -1
    return ret
 
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(N, A))
Buggy python submission (verdict: Runtime Error):
r = int(input())
print(2*r*pi)

Fixed submission:
import math
r = int(input())
print(2*r*math.pi)
Buggy python submission (verdict: Runtime Error):
K, N = map(int,input().split())　
A = list(map(int, input().split()))
li = []
for i in range(N - 1):
  li.append(A[i + 1] - A[i]) 

li.append(abs(A[0] + (K - A[-1]))) 
print(sum(li) - max(li))

Fixed submission:
K, N = map(int,input().split())
A = list(map(int, input().split()))
li = []
for i in range(N - 1):
  li.append(A[i + 1] - A[i]) 
li.append(abs(A[0] + (K - A[-1]))) 
print(sum(li) - max(li))
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n%2=0:
  print(n//2)
else:
  print(n//2+1)

Fixed submission:
n = int(input())
if n%2==0:
  print(n//2)
else:
  print(n//2+1)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ex=[0]*1000001
for a in A:ex[a]+=1
cnt=0
for a in A:
    ex[a]-=1
    i=1
    while i*i<=a:
        if a%i==0 and(ex[i]>0 or ex[a//i]>0):
            break
        i+=1
    else:
        cnt+=1
    ex[a]+=1
print(cnt)


Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ex=[0]*1000001
for a in A:ex[a]+=1
cnt=0
for i in range(1,1000001):
    if ex[i]>0:
        for j in range(i+i,1000001,i):ex[j]=0
        if ex[i]==1:
            cnt+=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
cnt=0
for i in range(N):
    for j in range(N):
        if i!=j and A[i]%A[j]==0:
            break
    else:
        cnt+=1
print(cnt)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ex=[0]*1000001
for a in A:ex[a]+=1
cnt=0
for i in range(1,1000001):
    if ex[i]>0:
        for j in range(i+i,1000001,i):ex[j]=0
        if ex[i]==1:
            cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n,*l=map(int,open(0).read().split())
p=0,0
d=p
i=0
for l in l:d+=max(l+d[-2],[d,p][i&1][-1]),;p+=l+p[-2],;i+=1
print(d[-1])

Fixed submission:
n,*l=map(int,open(0).read().split());p=[0]*n;d=p[:]
for i,l in enumerate(l):p[i]+=l+p[i-2];d[i]=max(l+d[i-2],[d,p][i&1][i-1])
print(d[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,*l=map(int,open(0).read().split())
p=0,0
d=p
for l in l:d+=max(l+d[-2],[d,p][len(d)&1][-1]),;p+=l+p[-2],
print(d[-1])

Fixed submission:
n,*l=map(int,open(0).read().split());p=[0]*n;d=p[:]
for i,l in enumerate(l):p[i]+=l+p[i-2];d[i]=max(l+d[i-2],[d,p][i&1][i-1])
print(d[-1])
Buggy python submission (verdict: Time Limit Exceeded):
m=10**9+7
def f(r,c,s=1):
 for i in range(c):s=s*(r+c-i)*pow(i+1,m-2,m)%m
 return s
a,b,c,d=map(int,input().split())
print((f(a,b)-f(c+1,b)-f(a,d+1)+f(c+1,d+1))%m)

Fixed submission:
m=10**9+7
def f(r,c):
 s=t=1
 for i in range(c):s=s*(r+c-i)%m;t=t*-~i%m
 return s*pow(t,m-2,m)%m
a,b,c,d=map(int,input().split())
print((f(a,b)-f(c+1,b)-f(a,d+1)+f(c+1,d+1))%m)
Buggy python submission (verdict: Runtime Error):
from heapq import*
N,M,*t=map(int,open(0).read().split())
v=[[]for _ in'_'*M]
for i in range(N):
	if M<t[2*i]:v[t[2*i]-1]+=[t[2*i+1]]
z=0
q=[]
for i in v:
	for j in i:heappush(q,-j)
	z-=len(q)and heappop(q)
print(z)

Fixed submission:
from heapq import*
(N,M),*t=[map(int,s.split())for s in open(0)]
v=[[]for _ in'_'*M]
z=0
for a,b in t:
	if a<=M:v[a-1]+=[b]
q=[0]*M
for i in v:
	for j in i:heappush(q,-j)
	z-=heappop(q)
print(z)

Buggy python submission (verdict: Runtime Error):
from heapq import*
N,M,*t=map(int,open(0).read().split())
v=[[]for _ in'_'*M]
for i in range(N):M<t[2*i]or v[t[2*i]-1].append(t[2*i+1])
z=0
q=[]
for i in v:
	for j in i:heappush(q,-j)
	z-=q[0]and heappop(q)
print(z)

Fixed submission:
from heapq import*
(N,M),*t=[map(int,s.split())for s in open(0)]
v=[[]for _ in'_'*M]
z=0
for a,b in t:
	if a<=M:v[a-1]+=[b]
q=[0]*M
for i in v:
	for j in i:heappush(q,-j)
	z-=heappop(q)
print(z)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int,input().split())
O,S,T=10**9+7,N+M,6
for i in range(K):S=S*(N*M-i)%O;T*=i+1
print(S*K*~-K*pow(T,O-2,O)%O)

Fixed submission:
N,M,K=map(int,input().split())
O,S,T=10**9+7,N+M,6
for i in range(K):S=S*(N*M-i)%O;T=T*-~i%O
print(S*K*~-K*pow(T,O-2,O)%O)

Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int,input().split())
O,S,T=10**9+7,N+M,6
for i in range(K):S*=N*M-i;T*=i+1
print(S*K*~-K*pow(T,O-2,O)%O)

Fixed submission:
N,M,K=map(int,input().split())
O,S,T=10**9+7,N+M,6
for i in range(K):S=S*(N*M-i)%O;T=T*-~i%O
print(S*K*~-K*pow(T,O-2,O)%O)

Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int,input().split())
O,S,T=10**9+7,N+M,6
for i in range(K):S*=N*M-i;T*=i+1
print(S*K*~-K*pow(T,O-2,O)%O)

Fixed submission:
N,M,K=map(int,input().split())
O,S,T=10**9+7,N+M,6
for i in range(K):S=S*(N*M-i)%O;T=T*-~i%O
print(S*K*~-K*pow(T,O-2,O)%O)

Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int,input().split())
O=10**9+7
S=N+M
for i in range(K):S=S*(N*M-i)*pow(i+1,O-2,O)
print(S*K*~-K*-~O//6%O)

Fixed submission:
N,M,K=map(int,input().split())
O,S,T=10**9+7,N+M,6
for i in range(K):S=S*(N*M-i)%O;T=T*-~i%O
print(S*K*~-K*pow(T,O-2,O)%O)

Buggy python submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
O=10**9+7
f=lambda n:1if n<1else n*f(n-1)%O;
print(f(N*M-2)*pow(6*f(N*M-K)*f(K-2),O-2,O)*N*M*(N*M-1)*(N+M)%O)

Fixed submission:
N,M,K=map(int,input().split())
O,S,T=10**9+7,N+M,6
for i in range(K):S=S*(N*M-i)%O;T=T*-~i%O
print(S*K*~-K*pow(T,O-2,O)%O)

Buggy python submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
O=10**9+7
f=lambda n:1if n<1else n*f(n-1)%O;
print(f(N*M-2)*pow(6*f(N*M-K)*f(K-2),O-2,O)*N*M*(N*M-1)*(N+M)%O)

Fixed submission:
N,M,K=map(int,input().split())
O,S,T=10**9+7,N+M,6
for i in range(K):S=S*(N*M-i)%O;T=T*-~i%O
print(S*K*~-K*pow(T,O-2,O)%O)
Buggy python submission (verdict: Runtime Error):
from heapq import*
L,R=[]*2
B=t=0
Q,*E=open(0)
for e in E:
	if' 'in e:_,a,b=map(int,e.split());t=1-t;a*=2*t-1;c=heappushpop([L,R][t],a);heappush([R,L][t],-c);B+=b+a-c-c
	else:print(-L[0],B-L[0]*t)

Fixed submission:
from heapq import*
L,R=[],[]
B=0
Q,*E=open(0)
for e in E:
    if e[0]>'1':
        w=-L[0]
        print(w,B+w*(len(L)>len(R)))
    else:
        _,a,b=map(int,e.split())
        B+=b
        if len(L)>len(R):
            B-=a
            a=-heappushpop(L,-a)
            B+=a+a
            heappush(R,a)
        else:
            B+=a
            a=heappushpop(R,a)
            B-=a+a
            heappush(L,-a)
Buggy python submission (verdict: Runtime Error):
n,k=input().split()
s=input()
k=int(k)-1
s[k]=chr(ord(s[k])+32)
print(s)

Fixed submission:
n,k=input().split()
s=input()
k=int(k)-1
for i,c in enumerate(s):
	if i==k:c=chr(ord(c)+32)
	print(c,end='')