Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left

import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 998244353

def main():
    n,m,k = getList()
    dp = [m]
    # dp[0] = m
    for i in range(n-1):
        tmp = [0 for _ in range(min(i+2, k+1))]
        for j, d in enumerate(dp):
            # print(tmp, j)
            # print(dp)
            tmp[j] += d * (m-1)
            if j < k:
                tmp[j+1] += d
                tmp[j+1] = tmp[j+1] % MOD
            # print("   ", tmp)
        dp = tmp
        # print(dp)

    ans = 0
    for d in dp:
        ans += d
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()



Fixed submission:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left

import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 998244353

def main():
    n,m,kk = getList()

    k = m - 1
    ans = 0
    nck = 1
    rui = m
    for itr in range(1, n+1):
        if n - itr <= kk:
            # print(nck, rui)
            ans += (rui*nck) % MOD
            ans %= MOD
            # print(nck, n, itr)
        nck *= (n - itr)
        nck *= pow(itr, MOD-2, MOD)
        nck %= MOD
        rui *= k
        rui %= MOD
        # print(nck, rui)
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

n, m = getList()
nums = getList()
sn = sum(nums)
if sn > n:
  print(-1)
else:
  print(n - sn)
  

Fixed submission:

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
n, m = getList()
nums = getList()
sn = sum(nums)
if sn > n:
  print(-1)
else:
  print(n - sn)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
INF = 10 ** 20
MOD = 10**9 + 7
def combmod(n, k, mod=MOD):
    if k == 0:
        return 1
    if k == 1:
        return n
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret

def main():
    n, k = getList()
    if k >= n-1:
        ans = combmod(n+n-1, n)
    else:
        ans = 0
        for i in range(k+1):
            tmp = combmod(n-1, i)
            tmp *= combmod(n, i)
            tmp %= MOD
            ans += tmp
            ans %= MOD
        # ans = combmod(n, k+1)
        # print(ans)
        # ans *= combmod(k+k+1, k+1)
        # # ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()



Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
INF = 10 ** 20
MOD = 10**9 + 7
def combmod(n, k, mod=MOD):
    if k == 0:
        return 1
    if k == 1:
        return n
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret

def main():
    n, k = getList()
    if k >= n-1:
        ans = combmod(n+n-1, n)
    else:
        # ans = 0
        ans = 1
        tmp = 1
        for i in range(1, k+1):
            tmp *= n-i
            tmp *= n + 1 - i
            tmp *= pow(i, MOD-2, MOD)
            tmp *= pow(i, MOD - 2, MOD)
            ans += tmp
            tmp %= MOD
            # tmp = combmod(n-1, i)
            # tmp *= combmod(n, i)
            # tmp %= MOD
            # ans += tmp
            ans %= MOD
        # ans = combmod(n, k+1)
        # print(ans)
        # ans *= combmod(k+k+1, k+1)
        # # ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def getList():
    return list(map(int, input().split()))
  
s,t = input().split()
a, b = getList()
u = input.strip()

if s == u:
  print(a-1 ,b)
else:
  print(a, b-1)
    

Fixed submission:
def getList():
    return list(map(int, input().split()))
  
s,t = input().split()
a, b = getList()
u = input().strip()
 
if s == u:
  print(a-1 ,b)
else:
  print(a, b-1)
Buggy python submission (verdict: Runtime Error):
print(x*len(input().strip()))

Fixed submission:
print("x"*len(input().strip()))
Buggy python submission (verdict: Runtime Error):
import sys
# from collections import defaultdict, deque
# import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10 ** 9 + 7
def solve():
    n, k, s = getList()
    fill = s // k
    if s > 10 ** 6:
        out = 1
    else:
        out = 10 ** 9
    ans = [out for i in range(n - k)] + [s for i in range(k)] #] + [0 for i in range(k-1)]

    print(*ans)

def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()


Fixed submission:
import sys
# from collections import defaultdict, deque
# import math
# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10 ** 9 + 7
def solve():
    n, k, s = getList()
    if s > 10 ** 6:
        out = 1
    else:
        out = 10 ** 9
    ans = [out for i in range(n - k)] + [s for i in range(k)] #] + [0 for i in range(k-1)]

    print(*ans)

def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()
Buggy python submission (verdict: Runtime Error):
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

def main():
    s = input().strip()
    # tmp = 0
    # mx = 0
    # for ch in s:
    #     if ch == ">"
    #         tmp -= 1
    #     else:
    #         tmp += 1
    #
    #     if abs(tmp) > mx:
    #         mx = abs(tmp)
    #
    fwd = [0]
    rev = [0]
    tmp = 0
    mn = 0
    for ch in s:
        # print(ch)
        if ch == "<":
            tmp += 1
        else:
            tmp = 0
        fwd.append(tmp)

    for ch in s[::-1]:
        # print(ch)
        if ch == ">":
            tmp += 1
        else:
            tmp = 0
        rev.append(tmp)
    rev.reverse()
    # print(fwd, rev)
    print(sum([max(i, j) for i, j in zip(fwd, rev)]))

    #     if mn > tmp:
    #         mn = tmp
    #     print(tmp)
    #
    # ans = 0
    # print(mn)
    # ttmp = max(0, -mn)
    # for ch in s:
    #     ans += ttmp
    #     if ch == ">":
    #         ttmp -= 1
    #     else:
    #         ttmp += 1
    #
    # print(ans)
    return

if __name__ == "__main__":
    main()

Fixed submission:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
 
def main():
    s = input().strip()
    # tmp = 0
    # mx = 0
    # for ch in s:
    #     if ch == ">"
    #         tmp -= 1
    #     else:
    #         tmp += 1
    #
    #     if abs(tmp) > mx:
    #         mx = abs(tmp)
    #
    fwd = [0]
    rev = [0]
    tmp = 0
    mn = 0
    for ch in s:
        # print(ch)
        if ch == "<":
            tmp += 1
        else:
            tmp = 0
        fwd.append(tmp)
 
    for ch in s[::-1]:
        # print(ch)
        if ch == ">":
            tmp += 1
        else:
            tmp = 0
        rev.append(tmp)
    rev.reverse()
    # print(fwd, rev)
    print(sum([max(i, j) for i, j in zip(fwd, rev)]))
 
    #     if mn > tmp:
    #         mn = tmp
    #     print(tmp)
    #
    # ans = 0
    # print(mn)
    # ttmp = max(0, -mn)
    # for ch in s:
    #     ans += ttmp
    #     if ch == ">":
    #         ttmp -= 1
    #     else:
    #         ttmp += 1
    #
    # print(ans)
    return
 
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict, deque
import math

# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7

def divide(k):
    return pow(k, MOD-2, MOD)


def make_nck(n):
    ret = [1]
    for i in range(1, n+1):
        ret.append((ret[-1] * (n + 1 - i) * divide(i)) % MOD)

    # print(ret)
    return ret

def make_nigojyo(n):
    ret = [1]

    for i in range(1, n+1):
        ret.append((ret[-1] * 25) % MOD)

    # print(ret)
    return ret


def solve():
    n = getN()
    a = getList()
    ans = 0
    for i, j in zip(a, a[1:]):
        ans += min(i, j)
    ans += a[0] + a[-1]

    print(ans)



def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()import sys
from collections import defaultdict, deque
import math

# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7

def divide(k):
    return pow(k, MOD-2, MOD)


def make_nck(n):
    ret = [1]
    for i in range(1, n+1):
        ret.append((ret[-1] * (n + 1 - i) * divide(i)) % MOD)

    # print(ret)
    return ret

def make_nigojyo(n):
    ret = [1]

    for i in range(1, n+1):
        ret.append((ret[-1] * 25) % MOD)

    # print(ret)
    return ret


def solve():
    n = getN()
    a = getList()
    ans = 0
    for i, j in zip(a, a[1:]):
        ans += min(i, j)
    ans += a[0] + a[-1]

    print(ans)



def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()
INF = 100000000000
nums = [INF] + getList() + [INF]
ans = 0
for i, j in zip(nums, nums[1:]):
    ans += min(i, j)

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict, deque, Counter
import math
 
# import copy
from bisect import bisect_left, bisect_right
# import heapq
 
# sys.setrecursionlimit(1000000)
 
# input aliases
input = sys.stdin.readline
 
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)
 
class Segtree_op():
     def __init__(self, n):
         self.size = 1
         while(n >= 1):
             self.size = self.size << 1
             n = n//2
 
         self.arr = [self.unit() for i in range(self.size*2)]
 
     def op(self, lch, rch):
         # update min with holding index
         return lch + rch
 
     def unit(self):
         return 0
 
     def update(self, k, val):
         k += self.size - 1
         self.arr[k] = val
         while(k):
             k = (k - 1) // 2
             self.arr[k] = self.op(self.arr[k*2 + 1], self.arr[k*2 + 2])
 
     def query(self, l, r):
         L = l + self.size
         R = r + self.size
         s = self.unit()
         while L < R:
             if R & 1:
                 R -= 1
                 s = self.op(s, self.arr[R - 1])
 
             if L & 1:
                 s = self.op(s, self.arr[L - 1])
                 L += 1
             L >>= 1
             R >>= 1
         return s
 
 
     def show(self):
         idx = 1
         while(idx <= self.size):
             print(self.arr[idx - 1:idx * 2 - 1])
             idx *= 2
def tento(nums):
    n = len(nums)
    st = Segtree_op(n)
    ret = 0
    for i, num in enumerate(nums):
        st.update(num, st.query(num, num+1)+1)
        # st.show()
        ret += i - st.query(0, num+1) + 1

    return ret



def main():
    n, kk = getList()
    nums = getList()
    ten = tento(nums)
    oneset = 0
    for k, v in Counter(nums).items():
        oneset += n - v
    # print(ten, oneset)
    print((kk * ten + kk * (kk-1) * oneset // 4)% MOD)

if __name__ == "__main__":
    main()
   

Fixed submission:
import sys

input = sys.stdin.readline
sys.setrecursionlimit(1000000)


def getN():
    return int(input())


def getList():
    return list(map(int, input().split()))


import math
MOD = 10 ** 9 + 7

n, k = getList()
anums = getList()

space = [[] for i in range(2002)]
remain = [1 for j in range(n)]
yet = n

for i, x in enumerate(anums):
    space[x].append(i)


ans = 0
for s in space:
    if s:
        jump = 0
        ls = len(s)
        yet -= ls
        for num in s:
            jump += sum(remain[:num])
            remain[num] = 0
            # print(jump)
        ans += ls * (yet * (k * (k-1))) // 2
        ans += jump * k
        # print(ans, jump, yet)
        # remain[num] = 0

        ans %= MOD
        # yet -= len(s)
        # yet -= 1
print(ans)
# print((43 * (998244353*998244354) // 2) % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline
sys.setrecursionlimit(1000000)


def getN():
    return int(input())


def getList():
    return list(map(int, input().split()))


import math
MOD = 10**9 + 7

def factorial(n):
    ans = 1
    for i in range(1, n+1):
        ans *= i

    return ans

n = getN()
s = input().strip()

ans = 1
cur = 0
open = 0
for c in s:
    # print(c, ans, open, cur)
    if c == "B":
        if open%2 == 0:
            open += 1
            cur = 1
        else:
            if open == 0:
                print(0)
                sys.exit()
            ans *= open
            ans %= MOD
            open -= 1
            cur = 0

    else:
        if open%2 == 1:
            open += 1
            cur = 0
        else:
            if open == 0:
                print(0)
                sys.exit()
            ans *= open
            ans %= MOD
            open -= 1
            cur = 0

if open != 0:
    print(0)
    sys.exit()
print((ans * factorial(n)) % MOD)

Fixed submission:
import sys

input = sys.stdin.readline
sys.setrecursionlimit(1000000)


def getN():
    return int(input())


def getList():
    return list(map(int, input().split()))


import math
MOD = 10**9 + 7

def factorial(n):
    ans = 1
    for i in range(1, n+1):
        ans *= i
        ans %= MOD

    return ans % MOD

n = getN()
s = input().strip()

ans = 1

open = 0
for c in s:
    # print(c, ans, open, cur)
    if c == "B":
        if open%2 == 0:
            open += 1

        else:
            if open == 0:
                print(0)
                sys.exit()
            ans *= open
            ans %= MOD
            open -= 1


    else:
        if open%2 == 1:
            open += 1

        else:
            if open == 0:
                print(0)
                sys.exit()
            ans *= open
            ans %= MOD
            open -= 1


if open != 0:
    print(0)
    sys.exit()
print((ans * factorial(n)) % MOD)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n, q = getList()

vtxs = [[] for i in range(n)]
already = [0 for i in range(n)]

for i in range(n - 1):
    a, b = getList()
    vtxs[a-1].append(b -1)
    vtxs[b-1].append(a - 1)

count = [0 for i in range(n)]
for i in range(q):
    x, v = getList()
    count[x-1] += v

ans = [0 for i in range(n)]

def rep(vx, val):
    # print(vx,val)
    tgt = vtxs[vx]
    already[vx] = 1
    for tg in tgt:
        if already[tg] == 0:
            app = count[tg]
            ans[tg] = val+app
            rep(tg, val+app)

rep(0, count[0])
# print(vtxs)
ans[0] = count[0]
print(*ans)


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n, q = getList()

vtxs = [[] for i in range(n)]
already = [0 for i in range(n)]

for i in range(n - 1):
    a, b = getList()
    vtxs[a-1].append(b -1)
    vtxs[b-1].append(a - 1)

count = [0 for i in range(n)]
for i in range(q):
    x, v = getList()
    count[x-1] += v

ans = [0 for i in range(n)]

def rep(vx, val):
    # print(vx,val)
    tgt = vtxs[vx]
    already[vx] = 1
    for tg in tgt:
        if already[tg] == 0:
            app = count[tg]
            ans[tg] = val+app
            rep(tg, val+app)

rep(0, count[0])
# print(vtxs)
ans[0] = count[0]
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n, q = getList()

vtxs = [[] for i in range(n)]
already = [0 for i in range(n)]

for i in range(n - 1):
    a, b = getList()
    vtxs[a-1].append(b -1)
    vtxs[b-1].append(a - 1)

count = [0 for i in range(n)]
for i in range(q):
    x, v = getList()
    count[x-1] += v

ans = [0 for i in range(n)]

def rep(vx, val):
    # print(vx,val)
    tgt = vtxs[vx]
    already[vx] = 1
    for tg in tgt:
        if already[tg] == 0:
            app = count[tg]
            ans[tg] = val+app
            rep(tg, val+app)

rep(0, count[0])
# print(vtxs)
ans[0] = count[0]
print(*ans)


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n, q = getList()

vtxs = [[] for i in range(n)]
already = [0 for i in range(n)]

for i in range(n - 1):
    a, b = getList()
    vtxs[a-1].append(b -1)
    vtxs[b-1].append(a - 1)

count = [0 for i in range(n)]
for i in range(q):
    x, v = getList()
    count[x-1] += v

ans = [0 for i in range(n)]

def rep(vx, val):
    # print(vx,val)
    tgt = vtxs[vx]
    already[vx] = 1
    for tg in tgt:
        if already[tg] == 0:
            app = count[tg]
            ans[tg] = val+app
            rep(tg, val+app)

rep(0, count[0])
# print(vtxs)
ans[0] = count[0]
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()

anums = getList()
bnums = getList()
ans = 0

update = True
while(update):
    update = False
    for i in range(n):
        if i == n - 1:
            j = 0
        else:
            j = i + 1
        h = i - 1
        a,b,c = bnums[h], bnums[i], bnums[j]
        # print(a,b,c)
        if b > max(a, c):
            if anums[i] > bnums[i]:
                print(-1)
                sys.exit()
            if anums[i] != bnums[i]:
                dec = math.ceil((b - (max(a, c, anums[i])) ) / (a+c))
                bnums[i] -= dec * (a+c)
                ans += dec
                update = True
    # print(coll, anums, bnums)

print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()

anums = getList()
bnums = getList()
ans = 0
okay = [0 for i in range(n)]
update = True
while(update):
    update = False
    for i in range(n):
        if not okay[i]:
            if i == n - 1:
                j = 0
            else:
                j = i + 1
            h = i - 1
            a,b,c, tgt = bnums[h], bnums[i], bnums[j], anums[i]
            # print(a,b,c)
            if b > max(a, c):
                if tgt > b:
                    print(-1)
                    sys.exit()
                if tgt != b:
                    dec = math.ceil((b - (max(a, c, tgt)) ) / (a+c))
                    bnums[i] -= dec * (a+c)
                    ans += dec
                    update = True
                    if anums[i] == bnums[i]:
                        okay[i] = 1
    # print(coll, anums, bnums)

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
# from collections import defaultdict, deque
# import math
# import copy
# from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve():
    a,b = getList()
    print(max([a+b, a - b. a * b]))
    return
def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    # main()
    solve()


Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

a, b = getList()

print(max([a+b, a-b, a*b]))

# print(ans)