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

Fixed submission:
'''
Accepted    　:No
difficult   　: 
ペナルティ　  　:5分
実際の回答時間  :分
WAの回数　     :回
合計時間　　  　:分
'''
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def myAnswer(A:int,B:int,C:int,D:int) -> int:
   divC = B//C - (A - 1)//C 
   divD = B//D - (A - 1)//D
   divCD = B//lcm(C,D) - (A - 1)//lcm(C,D) 
   # print(divC,divD,divCD)
   return (B - A + 1) - (divC + divD - divCD)

def modelAnswer():
   return
def main():
   A,B,C,D = map(int,input().split())
   print(myAnswer(A,B,C,D))

if __name__ == '__main__':
   main()

Buggy submission (verdict: Runtime Error):
'''
Accepted    　:No
difficult   　: 
ペナルティ　  　:5分
実際の回答時間  :分
WAの回数　     :回
合計時間　　  　:分
'''
from math import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)

def myAnswer(A:int,B:int,C:int,D:int) -> int:
   divC = B//C - (A - 1)//C 
   divD = B//D - (A - 1)//D
   divCD = B//lcm(C,D) - (A - 1)//lcm(C,D) 
   # print(divC,divD,divCD)
   return (B - A + 1) - (divC + divD - divCD)

def modelAnswer():
   return
def main():
   A,B,C,D = map(int,input().split())
   print(myAnswer(A,B,C,D))

if __name__ == '__main__':
   main()
Problem p03150 (python)

Fixed submission:
def myAnswer(S:str) -> str:
   if(S == "keyence"):return "YES"
   for i in range(len(S)-1):
      for j in range(i+1,len(S)):
         if(S[:i]+S[j:] == "keyence"):
            return "YES"
   return "NO"

def modelAnswer():
   return
def main():
   S = (input())
   print(myAnswer(S))
if __name__ == '__main__':
   main()

Buggy submission (verdict: Runtime Error):
import sys
S=(input())

key=['k','e','y','e','n','c','e']
ans=''
i=0
number=[]

if(S=="keyence"):
    print("YES")
    sys.exit()

for n,s in enumerate(S):
    if(s==key[i]):
        ans+=s
        i+=1
    else:
        number.append(n)

pre=number.pop(0)
a=pre
for n in number:
    if(pre!=(n-1)):
        print("NO")
        sys.exit()
    pre=n
if(ans!="keyence"):
    print('NO')
else:
    print('YES')
Problem p03231 (python)

Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
def myAnswer(N:int,M:int,S:str,T:str) -> int:
   a = N//fractions.gcd(N,M)
   b =M // fractions.gcd(N,M)
   # print(a,b)
   for i in range(fractions.gcd(N,M)):
      # print(S[a * i],T[b * i])
      if(S [a * i] != T[b * i]):
         return -1
   else:
      return lcm(N,M)

def modelAnswer():
   return
def main():
   N,M = map(int,input().split())
   S = input()
   T = input()
   print(myAnswer(N,M,S,T))
if __name__ == '__main__':
   main()

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
def myAnswer(N:int,M:int,S:str,T:str) -> int:
   L = lcm(N,M)
   setS = [1]
   for n in range(1,N):
      setS.append(n * L//N + 1)
   setT = [1]
   for m in range(1,M):
      setT.append(m * L//M + 1)
   # print(setS,setT,L)
   for n,i in enumerate(setS):
      for m,j in enumerate(setT):
         if(i == j and S[n] != T[m]):
            # print(i,j,S[n],T[m],n,m)
            return -1
   else:
      return L

def modelAnswer():
   return
def main():
   N,M = map(int,input().split())
   S = input()
   T = input()
   print(myAnswer(N,M,S,T))
if __name__ == '__main__':
   main()
Problem p03324 (python)

Fixed submission:
def myAnswer(D:int, N:int) -> int:
   if(N == 100):
      return 100**D * (N + 1 )
   else:
      return 100**D * N


def modelAnswer():
   tmp=1
def main():
   D,N =map(int,input().split())
   print(myAnswer(D,N))
if __name__ == '__main__':
   main()

Buggy submission (verdict: Runtime Error):
def myAnswer(D:int, N:int) -> int:
   return 100**D * (N - (N - 1)//99)


def modelAnswer():
   tmp=1
def main():
   D,N =map(int,input().split())
   print(myAnswer(D,N))
if __name__ == '__main__':
   main()

   return ans
Problem p03427 (python)

Fixed submission:

def myAnswer(N:int)->int:
   K = len(str(N)) #桁数
   if(K == 1):return N
   c = N // 10**(K-1) #最上位の桁の数
   if((c*10**(K-1) + int("9"*(K-1)))<= N):
      return c + 9 *(K - 1)
   else:
      return c + 9 *(K - 1) -1 


def modelAnswer():
   tmp=1
def main():
   N = int(input())
   print(myAnswer(N))

if __name__ == '__main__':
   main()

Buggy submission (verdict: Runtime Error):
def myAnswer(N:int)->int:
   K = len(str(N)) #桁数
   c = N // 10**(K-1) #最上位の桁の数
   if((c*10**(K-1) + int("9"*(K-1)))<= N):
      return c + 9 *(K - 1)
   else:
      return c + 9 *(K - 1) -1 


def modelAnswer():
   tmp=1
def main():
   N = int(input())
   print(myAnswer(N))

if __name__ == '__main__':
   main()
Problem p03607 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N=int(input())
ans=dict()
cnt=0

for _ in range(N):
    A=int(input())
    if((A in ans)==False):
        ans[A]=1
    else:
        ans[A]+=1

for value in ans.values():
    if(value%2==1):
        cnt+=1

print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

# 自分の解答
def myAnswer(N:int,dic:dict) -> int: # pythonはlist操作が重いので辞書で処理する
   ans = 0
   for a in dic.values():
      if(a % 2 == 1):
         ans += 1
   return ans
def modelAnswer(N:int,A:list) -> int:
   ans = []
   A.sort()
   for a in A:
      if(a in ans):
         ans.remove(a)
      else:
         ans.append(a)
   return len(ans)

def main():
   N = int(input())
   dic = {}
   for _ in range(N):
      a = int(input())
      if(a in dic.keys()):
         dic[a]+=1
      else:
         dic[a]=1
   print(modelAnswer(N,dic))
if __name__ ==
Problem p03611 (python)

Fixed submission:
def myAnswer(N:int,A:list) -> int:
   if(N == 1): return 1
   dic ={}
   for a in A:
      if(a == 0):
         for i in range(2):
            if(i in dic.keys()):
               dic[i]+=1
            else:
               dic[i]=1
      else:
         for i in range(a-1,a+2):
            if(i in dic.keys()):
               dic[i]+=1
            else:
               dic[i] = 1
   return max(list(dic.values()))

def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ == '__main__':
   main()

Buggy submission (verdict: Runtime Error):
def myAnswer(N:int,A:list) -> int:
   if(N == 1): return 1
   dic ={}
   for a in A:
      if(a == 0):
         for i in range(2):
            if(i in dic.keys()):
               dic[i]+=1
            else:
               dic[i]=1
      else:
         for i in range(a-1,a+2):
            if(i in dic.keys()):
               dic[i]+=1
            else:
               dic[i] = 1
   return max(list(dic.values()))

def modelAnswer():
   return
def main():
   N = int(input())
   A = list(map(int,input().split()))
   print(myAnswer(N,A[:]))
if __name__ =
Problem p03612 (python)

Fixed submission:

def myAnswer(N:int,P:list) -> int:
   ans = 0
   counter = 0
   for i in range(1,N+1):
      if(i == P[i - 1]):
         counter += 1
      elif(counter != 0):
         ans += counter//2 + counter % 2 if(counter > 1) else 1
         counter = 0
   if(counter != 0):
      ans += counter//2 + counter % 2 if(counter > 1) else 1
   return ans

def modelAnswer():
   return
def main():
   N = int(input())
   P = list(map(int,input().split()))
   print(myAnswer(N,P[:]))
if __name__ == '__main__':
   main()

Buggy submission (verdict: Runtime Error):
def myAnswer(N:int,P:list) -> int:
   ans = 0
   counter = 0
   for i in range(1,N+1):
      if(i == P[i - 1]):
         counter += 1
      elif(counter != 0):
         ans += sum(divmod(counter,2))
         counter = 0
   if(counter != 0):
      ans += sum(divmod(counter,2))
   return ans

def modelAnswer(N:int,P:list) -> int:
   ans = 0
   for i in range(1,N+1):
      if(i == P[i - 1]):
         ans += 1
         P[i - 1],P[i] = P[i],P[i - 1]
   return ans

def main():
   N = int(input())
   P = list(map(int,input().split()))
   print(modelAnswer(N,P[:]))
if __name__ == '__main__':
   main()
Problem p02741 (python)

Fixed submission:
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(arr[k - 1])

Buggy submission (verdict: Runtime Error):
from math import sqrt

eps = 1e-8

def eq(a, b):
    return a + eps > b and a - eps < b

a, b, c = list(map(int, input().split()))
elif 2 * sqrt(a * b) < c - a - b - eps:
    print("Yes")
else:
    print("No")
Problem p02684 (python)

Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))
A = [-1] + A
memo = []
loop = []
visit = [0]*n
town = 1
while visit[town-1] < 2:
    if visit[town-1] == 0:
        memo.append(town)
    else:
        loop.append(town)
    visit[town-1] += 1
    town = A[town]
outlier = len(memo) - len(loop) 
T = len(loop)
if k <= outlier:
    print(memo[k])
else:
    print(loop[(k-outlier) % T])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))
A = [-1] + A
memo = [1]
def func(i, town=1):
    global memo
    arrival = A[town]
    memo.append(arrival)
    if memo.count(arrival) == 2:
        return memo
    return func(i+1, A[town])

table = func(0, 1)
index = table.index(table[-1])
r = (k - index) % (len(table)-1 - index)
print(table[index+r])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))
A = [-1] + A
if A[1] != 1:
    memo = [1]
    def dfs(i, town=1):
        global memo
        arrival = A[town]
        if arrival in memo:
            memo.append(arrival)
            return memo
        memo.append(arrival)
        return dfs(i+1, A[town])

    table = dfs(0, 1)
    indexes = [i for i, x in enumerate(table) if x == table[-1]]
    q = indexes[0]
    r = (k - q) % (indexes[1] - q)
    print(table[q+r])
else:
    print(1)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int, input().split()))
A = [-1] + A
memo = [1]
def dfs(i, town=1):
    global memo
    arrival = A[town]
    if arrival in memo:
        memo.append(arrival)
        return memo
    memo.append(arrival)
    return dfs(i+1, A[town])

table = dfs(0, 1)
indexes = [i for i, x in enumerate(table) if x == table[-1]]
q = indexes[0]
r = (k - q) % (indexes[1] - q)
print(table[q+r])
Problem p02714 (python)

Fixed submission:
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n-2):
    for j in range(i+1, n-1):
        if 2*j - i >= n:
            break
        elif s[i] != s[j] and s[j] != s[(2*j-i)] and s[(2*j-i)] != s[i]:
            ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
r = []
g = []
b = []
for i in range(n):
    if s[i] == 'R':
        r.append(i)
    elif s[i] == 'G':
        g.append(i)
    else:
        b.append(i)
ans = len(r)*len(g)*len(b)
def func(a,b,c):
    ans = 0
    for i in a:
        for k in [num1 for num1 in b if num1 > i+1]:
            if (k + i) // 2 in j:
                    ans -= 1
    return ans
print(ans + func(r,g,b) + func(r,b,g) + func(g,r,b) + func(g,b,r) + func(b,g,r) + func(b,r,g))
Problem p02802 (python)

Fixed submission:
n, m = map(int, input().split())
lis = [list(input().split()) for _ in range(m)]
d = {}
ac, wa = 0, 0
for i in lis:
    if i[0] not in d:
        if i[1] == 'AC':
            ac += 1
            d[i[0]] = 'AC'
        else:
            d[i[0]] = 1
    else:
        if i[1] == 'AC':
            if d[i[0]] != 'AC':
                ac += 1
                wa += d[i[0]]
                d[i[0]] = 'AC'
        else:
            if d[i[0]] != 'AC':
                d[i[0]] += 1
print(ac, wa)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
lis = [list(input().split()) for _ in range(m)]
d = {}
ac, wa = 0, 0
for i in lis:
    if i[0] not in d:
        if i[1] == 'AC':
            ac += 1
            d[i[0]] = 'AC'
        else:
            d[i[0]] = 1
    else:
        if i[1] == 'AC':
            if d[i[0]] != 'AC':
                ac += 1
                wa += d[i[0]]
                d[i[0]] = 'AC'
        else:
            d[i[0]] += 1
print(ac, wa)
Problem p02813 (python)

Fixed submission:
import itertools
n = int(input())
plis = list(map(int, input().split()))
qlis = list(map(int, input().split()))
lis = list(itertools.permutations(range(1, n+1)))
n = 1
for i in lis:
    if list(i) == plis:
        a = n
    if list(i) == qlis:
        b = n
    n += 1
print(abs(a-b))

Buggy submission (verdict: Runtime Error):
import itertools
n = int(input())
plis = list(map(int, input().split()))
qlis = list(map(int, input().split()))
lis = list(itertools.permutations(range(1, n+1)))
n = 1
for i in lis:
    if list(i) == plis:
        a = n
        n += 1
    elif list(i) == qlis:
        b = n
        n += 1
    else:
        n += 1
print(abs(a-b))
Problem p03262 (python)

Fixed submission:
n, x = map(int, input().split())
xlis = list(map(int, input().split()))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
if n > 1:
    d = gcd(abs(xlis[0]-x), abs(xlis[1]-x))
    for i in range(2, n):
        d = gcd(d, abs(xlis[i]-x))
    print(d)
else:
    print(abs(xlis[0] - x))

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
xlis = list(map(int, input().split()))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

d = gcd(abs(xlis[0]-x), abs(xlis[1]-x))
for i in range(2, n):
    d = gcd(d, abs(xlis[i]-x))
print(d)
Problem p03328 (python)

Fixed submission:
a, b = map(int, input().split())
ans = 0
for i in range(1, b-a):
  ans += i
print(ans - a)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
def func(n):
  if n == 0:
    return 0
  else:
    return func(n-1) + n
print(func(b-a-1) - a)
Problem p02675 (python)

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()

    one = n % 10

    a = set([2, 4, 5, 7, 9])
    b = set([0, 1, 6, 8])
    if one in a:
        print('hon')
    elif one in b:
        print('pon')
    else:
        print('bon')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()

    one = n % 10

    a = set(2, 4, 5, 7, 9)
    b = set(0, 1, 6, 8)
    if one in a:
        print('hon')
    elif one in b:
        print('pon')
    else:
        print('bon')


if __name__ == '__main__':
    main()
Problem p02700 (python)

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c, d = nm()
    while True:
        c -= b
        if c <= 0:
            print('Yes')
            exit()
        a -= d
        if a <= 0:
            print('No')
            exit()


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c, d = nm()
    while True:
        c -= d
        if c <= 0:
            print('Yes')
            exit()
        a -= d:
        if a <= 0:
            print('No')
            exit()


if __name__ == '__main__':
    main()
Problem p02719 (python)

Fixed submission:
import sys

input = sys.stdin.readline

N, K = map(int, input().split())

if N < K:
    print(min(N, K - N))
    exit()

if N % K == 0:
    print(0)
else:
    print(min(K - N%K, N%K))

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline

N, K = map(int, input().split())
diff = abs(K - N)

if N < K:
    print(N)
    exit()

if N % K == 0:
    print(0)
else:
    print(min(K - N%K), N%K)
Problem p02642 (python)

Fixed submission:
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def BinarySearch(num, List):
    if len(List) == 0:
        print("Erorr : list has no element")
        return
    left,right = 0,len(List)
    while left < right:
        mid  = (left+right)//2
        if num < List[mid]:#
            right = mid
        else:
            left = mid + 1
    return right


def main():
    n = ni()
    a = sorted(na())
    asub = [i for i in a]

    for i in range(n):
        ai = a[i]
        right = BinarySearch(ai, a)
        if right-1 != i:
            asub[right-1] = -1
            asub[i] = -1
            continue
        cnt = 2
        while right != n:
            right = BinarySearch(ai*cnt, a)
            if asub[right-1] == ai*cnt:
                asub[right-1] = -1
            cnt += 1
    
    ans = 0
    for i in range(n):
        if asub[i] != -1:
            ans += 1
    print(ans)
    return


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))


def BinarySearch(num, List):
    if len(List) == 0:
        print("Erorr : list has no element")
        return
    left,right = 0,len(List)
    while left < right:
        mid  = (left+right)//2
        if num < List[mid]:#
            right = mid
        else:
            left = mid + 1
    return right


def main():
    nn = ni()
    atmp = sorted(na())
    a = []
    if atmp[0] != atmp[1]:
        a = [atmp[0]]
    pre = atmp[0]
    for i in range(1, nn):
        if pre != atmp[i]:
            a += [atmp[i]]
    n = len(a)
    if n == 0:
        print(0)
        return
    asub = [i for i in a]
    ans = 0
    for i in range(n):
        ai = a[i]
        if ai != -1:
            ans += 1
            cnt = 2
            right = i
            while right != n:
                right = BinarySearch(ai*cnt, asub)
                if a[right-1] == ai*cnt:
                    a[right-1] = -1
                cnt += 1
    print(ans)
    return


if __name__ == '__main__':
    main()
Problem p02717 (python)

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

print(c,a,b)

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

print(c,a,b)
Problem p02727 (python)

Fixed submission:
x,y,a,b,c = map(int,input().split())
p_a = list(map(int,input().split()))
p_b = list(map(int,input().split()))
p_c = list(map(int,input().split()))
p_a.sort(reverse=True)
p_b.sort(reverse=True)
#p_c.sort(reverse=True)

ans = p_a[:x] + p_b[:y] + p_c
ans.sort(reverse=True)
print(sum(ans[:x+y]))

Buggy submission (verdict: Runtime Error):
x,y,a,b,c = map(int,input().split())
p_a = list(map(int,input().split()))
p_b = list(map(int,input().split()))
p_c = list(map(int,input().split()))
p_a.sort(reverse=True)
p_b.sort(reverse=True)
p_c.sort(reverse=True)
p_c += [0]

ans = p_a[:x] + p_b[:y]
ans.sort(reverse=True)
i = -1
p_c_sum = 0
while True:
    if ans[i] > p_c[0]:
        break
    else:
        ans[i] = 0
        i -= 1
        p_c_sum += p_c[0]
        p_c.pop(0)
print(sum(ans) + p_c_sum )
Problem p02761 (python)

Fixed submission:
# coding: utf-8
# Your code here!

n,m = map(int,input().split())
a = [-1 for i in range(n)]
flag = 1
for i in range(m):
    b,c = map(int,input().split())
    b -= 1
    if a[b] != -1 and a[b] != c:
        flag = 0
        print("-1")
        break
    else:
        a[b] = c

if flag == 1:
    if a[0] == 0:
        if n == 1:
            print(0)
        else:
            print(-1)
    else:
        if a[0] == -1:
            if n == 1:
                a[0] = 0
            else:
                a[0] = 1
        ans = 0
        for i in range(n):
            if a[i] != -1:
                ans += a[i] * (10**(n-1-i))
        print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!

n,m = map(int,input().split())
a = [-1 for i in range(n)]
flag = 1
for i in range(m):
    b,c = map(int,input().split())
    b -= 1
    if a[b] != -1 and a[b] != c:
        flag = 0
        print("-1")
        break
    else:
        a[b] = c

if flag == 1:
    if a[0] == 0:
        if n == 1:
            print(0)
        else:
            print(-1)
    else:
        if a[0] == -1:
            a[0] = 1:
        ans = 0
        for i in range(n):
            if a[i] != -1:
                ans += a[i] * (10**(n-1-i))
        print(ans)
Problem p03039 (python)

Fixed submission:
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n,m,k = map(int,input().split())
nm = n*m%(10**9+7)
k = k%(10**9+7)
a = (cmb(nm-2,k-2,mod)%(10**9+7))*(nm*(m*(n**2-1)+n*(m**2-1)))//6
print(a%(10**9+7))

Buggy submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n,m,k = map(int,input().split())
nm = n*m%(10**9+7)
k = k%(10**9+7)
a = (cmb(nm-2,k-2,mod)%(10**9+7))*(nm*(m*(n**2-1)+n*(m**2-1)))//6
print(a%(10**9+7))
Problem p03043 (python)

Fixed submission:
import math
n,k = map(int,input().split())

def f(i,k,n):
     if i<k:
          m = math.ceil(math.log2(k/i))
          return ((1/2)**m)/n
     else:
          return 1/n

ans = 0
for i in range(1,n+1):
     ans += f(i,k,n)

print(ans)

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

def f(i,k,n):
     if i<k:
          m = math.ceil(math.log2(k/i))
          return ((1/2)**m)/n
     else:
          return 1/n

ans = 0
for i in range(1,n+1):
     ans += f(i,k,n)

print(ans)
Problem p03061 (python)

Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

n = int(input())
a = list(map(int,input().split()))

b = [a[0]]
c = [a[-1]]

for i in range(1,n):
     j = n-1-i
     b.append(gcd(b[-1],a[i]))
     c.append(gcd(c[-1],a[j]))
     
ans = max(b[-2],c[-2])
for i in range(n):
     ans = max(ans,gcd(b[i],c[n-3-i]))
print(ans)

Buggy submission (verdict: Runtime Error):
import functools
import math

n = int(input())
a = list(map(int,input().split()))
ans = 1

def f(a,ans):
     ans = max(functools.reduce(math.gcd, a),ans)
     return ans
     
for i in range(n):
     ans = f(a[:i]+a[i+1:],ans)
print(ans)