Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(M, K):
    if K != 0:
        print(-1)
        return

    for i in range(2**(M-1)+1):
        print(i, i, '', end='')
    return


def main():
    M, K = read_int_n()
    (slv(M, K))


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(M, K):
    if M == 0:
        if K == 0:
            print(0, 0)
        else:
            print(-1)
    elif M == 1:
        if K == 0:
            print(0, 0, 1, 1)
        else:
            print(-1)
    else:
        if K < 2**M:

            for i in range(2**M):
                if i == K:
                    continue
                print(i, '', end='')
            print(K, '', end='')

            for i in range(2**M-1, -1, -1):
                if i == K:
                    continue
                print(i, '', end='')
            print(K, '', end='')

        else:
            print(-1)


def main():
    M, K = read_int_n()
    (slv(M, K))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(R, G, B, N):
    ans = 0
    r = -R
    for i in range(N//R + 1):
        r += R
        g = -G
        for j in range((N-r)//G + 1):
            g += G
            b = -B
            for k in range((N-r-g)//B + 1):
                b += B
                if r + g + b == N:
                    ans += 1

    return ans


def main():
    R, G, B, N = read_int_n()
    # A = [read_int_n() for _ in range(N)]
    print(slv(R, G, B, N))


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(R, G, B, N):
    ans = 0
    r = -R
    for i in range(N//R + 1):
        r += R
        g = -G
        for j in range((N-r)//G + 1):
            g += G
            if (N-r-g) % B == 0:
                ans += 1

    return ans


def main():
    R, G, B, N = read_int_n()
    # A = [read_int_n() for _ in range(N)]
    print(slv(R, G, B, N))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
b = input().strip()
if b == 'A':
  pirnt('T')
if b == 'T':
  print('A')
if b == 'G':
  print('C')
if b == 'C':
  print('G')

Fixed submission:
b = input().strip()
if b == 'A':
  print('T')
if b == 'T':
  print('A')
if b == 'G':
  print('C')
if b == 'C':
  print('G')
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def error_mat_print(m):
    for r in m:
        print(r, file=sys.stderr)

def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(L, A):

    dp = [[sys.maxsize] * (L+1) for _ in range(5)]
    dp[0][0] = 0

    for i, a in enumerate(A):
        t = dp[0][i]
        dp[0][i+1] = t + a
        t = min(t, dp[1][i])
        dp[1][i+1] = t+ ((a%2) if a != 0 else 2)
        t = min(t, dp[2][i])
        dp[2][i+1] = t + ((a+1)%2)
        t = min(t, dp[3][i])
        dp[3][i+1] =t + ((a%2) if a != 0 else 2)
        t = min(t, dp[4][i])
        dp[4][i+1] = t + a


    return min([dp[i][L] for i in range(5)])

def main():
    L = read_int()
    A = [read_int() for _ in range(L)]
    print(slv(L, A))


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K):
    return 'YES' if int(math.ceil(N/2)) >= K else 'NO'


def main():
    # N = read_int()
    N, K = read_int_n()
    # A = [read_int_n() for _ in range(N)]
    print(slv(N, K))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
x, y, z = map(int, intput().split())
print(x*y//2)

Fixed submission:
x, y, z = map(int, input().split())
print(x*y//2)
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]

from collections import Counter

dp = Counter()
dp[0] = 0
for w, v in WV:
  ndp = Counter()
  for k in dp:
   	ndp[k] = max(dp[k], ndp[k])
   	if k+w <= W:
   	 	ndp[k+w] = max(dp[k] + v, ndp[k+w])
  dp = ndp
print(dp.most_common()[0][1])

Fixed submission:
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]

from collections import defaultdict

dp = defaultdict(lambda : 10**100)
dp[0] = 0
for w, v in WV:
  ndp = defaultdict(lambda : 10**100)
  for k in dp:
    ndp[k] = min(dp[k], ndp[k])
    if dp[k] + w <= W:
   	  ndp[k+v] = min(dp[k] + w, ndp[k+v])
  dp = ndp
print(max(dp.keys()))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(M)]

from collections import defaultdict
from collections import deque
g = defaultdict(set)

for x, y in XY:
  g[x].add(y)

  
def bfs(u):
  s = deque([u])
  cost = {u: 0}
  done = set()
  while s:
    u = s.popleft()
    if u not in done:
      done.add(u)
    else:
      continue
    for v in g[u]:
      cost[v] = cost[u] + 1
      if v in done:
        done.remove(v)
      s.append(v)

  return cost
  
ans = 0
for i in range(1, N+1):
  d = bfs(i)
  ans = max(ans, max(d.values()))
print(ans)

Fixed submission:
N, M = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(M)]

from collections import defaultdict
from collections import deque
from collections import Counter
g = defaultdict(set)

for x, y in XY:
  g[x].add(y)
  
  
def TSort(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v))
    V = set(V)
    funin = Counter()
    
    for u in V:
        for v in g[u]:
            funin[v] += 1
    
    q = deque()
    for v in V:
        if funin[v] == 0:
            q.append(v)
    L = []
    while q:
        u = q.popleft()
        L.append(u)
        for v in g[u]:
            funin[v] -= 1
            if funin[v] == 0:
                q.append(v)
    return L

  
D = Counter()
ns = TSort(g)
for u in ns:
  for v in g[u]:
    D[v] = max(D[v], D[u] + 1)
print(D.most_common()[0][1])

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(M)]

from collections import defaultdict
from collections import deque
g = defaultdict(set)

for x, y in XY:
  g[x].add(y)

  
def bfs(u):
  s = deque([u])
  done = {u: 0}
  while s:
    u = s.popleft()
    for v in g[u]:
      done[v] = done[u] + 1
      s.append(v)
  return done
  
ans = 0
for i in range(1, N+1):
  d = bfs(i)
  ans = max(ans, max(d.values()))
print(ans)

Fixed submission:
N, M = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(M)]

from collections import defaultdict
from collections import deque
from collections import Counter
g = defaultdict(set)

for x, y in XY:
  g[x].add(y)
  
  
def TSort(g):
    V = list(g.keys())
    for v in g.values():
        V.extend(list(v))
    V = set(V)
    funin = Counter()
    
    for u in V:
        for v in g[u]:
            funin[v] += 1
    
    q = deque()
    for v in V:
        if funin[v] == 0:
            q.append(v)
    L = []
    while q:
        u = q.popleft()
        L.append(u)
        for v in g[u]:
            funin[v] -= 1
            if funin[v] == 0:
                q.append(v)
    return L

  
D = Counter()
ns = TSort(g)
for u in ns:
  for v in g[u]:
    D[v] = max(D[v], D[u] + 1)
print(D.most_common()[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
import resource
import sys
from functools import lru_cache
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.reverse()
sys.setrecursionlimit(1000000)

@lru_cache(maxsize=None)
def f(k, p):
  for a in A:
    if k >= a:
      if f(k-a, p ^ 1) == p:
        return p
  return p ^ 1

print('First' if f(K, 0) == 0 else 'Second')


Fixed submission:
import resource
import sys
from functools import lru_cache
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.reverse()
sys.setrecursionlimit(1000000)

@lru_cache(maxsize=None)
def f(k, p):
  for a in A:
    if k >= a:
      if f(k-a, p ^ 1) == p:
        return p
  return p ^ 1

print('First' if f(K, 0) == 0 else 'Second')

Buggy python submission (verdict: Time Limit Exceeded):
import resource
import sys
from functools import lru_cache
N, K = map(int, input().split())
A = list(map(int, input().split()))

sys.setrecursionlimit(1000000)

@lru_cache(maxsize=None)
def f(k, p):
  w = set()
  for a in A:
    if k >= a:
      w.add(f(k-a, p ^ 1))
  if len(w) == 0:
    return p ^ 1
  elif None in w:
    return None
  elif p in w:
    return p
  else:
    return 1 ^ p


print('First' if f(K, 0) == 0 else 'Second')


Fixed submission:
import resource
import sys
from functools import lru_cache
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.reverse()
sys.setrecursionlimit(1000000)

@lru_cache(maxsize=None)
def f(k, p):
  for a in A:
    if k >= a:
      if f(k-a, p ^ 1) == p:
        return p
  return p ^ 1

print('First' if f(K, 0) == 0 else 'Second')

Buggy python submission (verdict: Time Limit Exceeded):
import resource
import sys
from functools import lru_cache
N, K = map(int, input().split())
A = list(map(int, input().split()))

sys.setrecursionlimit(1000000)

@lru_cache(maxsize=None)
def f(k, p):
  w = set()
  for a in A:
    if k >= a:
      w.add(f(k-a, p ^ 1))
  if len(w) == 0:
    return p ^ 1
  elif None in w:
    return None
  elif p in w:
    return p
  else:
    return 1 ^ p


print('First' if f(K, 0) == 0 else 'Second')


Fixed submission:
import resource
import sys
from functools import lru_cache
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.reverse()
sys.setrecursionlimit(1000000)

@lru_cache(maxsize=None)
def f(k, p):
  for a in A:
    if k >= a:
      if f(k-a, p ^ 1) == p:
        return p
  return p ^ 1

print('First' if f(K, 0) == 0 else 'Second')
Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache
N = int(input())
A = list(map(int, input().split()))
import sys
sys.setrecursionlimit(100000)

import random
#N = 20
#A = [random.randint(1, 10**9) for _ in range(N)]


@lru_cache(maxsize=None)
def f(l, r):
  if l > r:
    return 0
  
  n = r - l
  if (N - n) % 2 == 0:
    s = -1
  else:
    s = 1
    
  lv = f(l+1, r) + s*A[l]
  rv = f(l, r-1) + s*A[r]
  
  if s*lv > s*rv:
    return lv
  else:
    return rv
    
   
print(f(0, N-1))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
#import random
#N = 3000
#A = [random.randint(1, 10**9) for _ in range(N)]


dp = [[0] * (N+1) for _ in range(N+1)]
for g in range(N):
  for l in range(N-g):
    r = l + g
    n = r - l
    s = -1 if (N-n) % 2 == 0 else 1
    lv = dp[l+1][r] + s*A[l]
    rv = dp[l][r-1] + s*A[r]
    if s*lv > s*rv:
      dp[l][r] = lv
    else:
      dp[l][r] = rv

print(dp[0][N-1])

Buggy python submission (verdict: Runtime Error):
from functools import lru_cache
N = int(input())
A = list(map(int, input().split()))

#import random
#N = 400
#A = [random.randint(1, 10**9) for _ in range(N)]
INF = 1.0e+100

@lru_cache(maxsize=None)
def f(l, r, xy):
  if l > r:
    return xy
  
  n = r - l
  if (N - n) % 2 == 0:
    s = -1
  else:
    s = 1
    
  lv = f(l+1, r, xy + s*A[l])
  rv = f(l, r-1, xy + s*A[r])
  
  if s*lv > s*rv:
    return lv
  else:
    return rv
    
   
print(f(0, N-1, 0))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
#import random
#N = 3000
#A = [random.randint(1, 10**9) for _ in range(N)]


dp = [[0] * (N+1) for _ in range(N+1)]
for g in range(N):
  for l in range(N-g):
    r = l + g
    n = r - l
    s = -1 if (N-n) % 2 == 0 else 1
    lv = dp[l+1][r] + s*A[l]
    rv = dp[l][r-1] + s*A[r]
    if s*lv > s*rv:
      dp[l][r] = lv
    else:
      dp[l][r] = rv

print(dp[0][N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

# import random
# N = 100
# K = 10**5
# A = [K] * N

if sum(A) < K:
  print(0)
  exit(0)


class SegmentTree:
    def __init__(self, array, operator, identity_element):
        _len = len(array)
        self.__op = operator
        self.__size = 1 << (_len - 1).bit_length()
        self.__tree = [identity_element] * self.__size + \
            array + [identity_element] * (self.__size - _len)
        self.__ie = identity_element

        for i in range(self.__size - 1, 0, -1):
            self.__tree[i] = operator(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def update(self, i, v):
        i += self.__size
        self.__tree[i] = v
        while i:
            i //= 2
            self.__tree[i] = self.__op(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def query(self, l, r):
        l += self.__size
        r += self.__size
        ret = self.__ie
        while l < r:
            if l & 1:
                ret = self.__op(ret, self.__tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.__op(ret, self.__tree[r])
            l //= 2
            r //= 2
        return ret


from operator import add

t0 = [0] * (K+1)
t0[0] = 1

M = 10**9 + 7
for i in range(N):
    a = A[i]
    t1 = [0] * (K+1)
    st = SegmentTree(t0, add, 0)
    for k in range(K+1):
        t1[k] = st.query(max(0, k-a), k+1) % M
    t0 = t1

print(t0[K])


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

# import random
# N = 100
# K = 10**5
# A = [K] * N

if sum(A) < K:
  print(0)
  exit(0)

t0 = [0] * (K+1)
t0[0] = 1

M = 10**9 + 7
for i in range(N):
    a = A[i]
    t1 = [0] * (K+1)
    st0 = [0]
    for t in t0:
        st0.append((t + st0[-1]) % M)
    for k in range(K+1):
        l = max(0, k-a)
        t1[k] = (st0[k+1] - st0[l]) % M
    t0 = t1

print(t0[K])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

if sum(A) < K:
  print(0)
  exit(0)

#import random
#N = 3000
#A = [random.randint(1, 10**9) for _ in range(N)]
dp = [[0] * (K+1) for _ in range(N+1)]
dp[-1][0] = 1
M = 10**9 + 7
for i in range(N):
  a = A[i]
  for j in range(a+1):
    for k in range(K-j+1):
      dp[i][k+j] += dp[i-1][k]
      dp[i][k+j] %= M

#for r in dp:
#  print(r)
print(dp[N-1][K])



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

# import random
# N = 100
# K = 10**5
# A = [K] * N

if sum(A) < K:
  print(0)
  exit(0)

t0 = [0] * (K+1)
t0[0] = 1

M = 10**9 + 7
for i in range(N):
    a = A[i]
    t1 = [0] * (K+1)
    st0 = [0]
    for t in t0:
        st0.append((t + st0[-1]) % M)
    for k in range(K+1):
        l = max(0, k-a)
        t1[k] = (st0[k+1] - st0[l]) % M
    t0 = t1

print(t0[K])
Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]


from collections import Counter

M = 10**9 + 7
cur = {0: 1}
for B in A:
    nxt = Counter()
    C = [1 << i for i, v in enumerate(B) if v == 1]
    for s, v in cur.items():
        v %= M
        for b in C:
            if (s & b) != 0:
                continue
            m = s | b
            nxt[m] += v
    cur = nxt
print(cur[(1<<N) - 1] % M)


Fixed submission:

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

from collections import Counter

M = 10**9 + 7
cur = [0] * (1<<N)
cur[0] = 1
for B in A:
    nxt = [0] * (1 << N)
    C = [1 << i for i, v in enumerate(B) if v == 1]
    for s, v in enumerate(cur):
        if v == 0:
            continue
        v %= M
        for b in C:
            if (s & b) != 0:
                continue
            nxt[s | b] += v
    cur = nxt
print(cur[(1<<N) - 1] % M)

Buggy python submission (verdict: Time Limit Exceeded):

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]


from collections import Counter

M = 10**9 + 7
cur = {0: 1}
for B in A:
    nxt = Counter()
    C = [1 << i for i, v in enumerate(B) if v == 1]
    for s, v in cur.items():
        for b in C:
            if (s & b) != 0:
                continue
            m = s | b
            nxt[m] += v
            nxt[m] %= M
    cur = nxt
print(cur[(1<<N) - 1])


Fixed submission:

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

from collections import Counter

M = 10**9 + 7
cur = [0] * (1<<N)
cur[0] = 1
for B in A:
    nxt = [0] * (1 << N)
    C = [1 << i for i, v in enumerate(B) if v == 1]
    for s, v in enumerate(cur):
        if v == 0:
            continue
        v %= M
        for b in C:
            if (s & b) != 0:
                continue
            nxt[s | b] += v
    cur = nxt
print(cur[(1<<N) - 1] % M)