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

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
result=0
flug = 0
if(len(a) == 1):
    print(1)
else:
    a.sort()
    dp = [True] * a[-1]
    flug = 1
    for j in range(n):
        if(dp[a[j]-1] == True):
            if(a[j] == a[j-1]):
                if(flug == 0):
                    result-=1
                    flug = 1
            else:
                result+=1
                flug = 0
            k = a[j] * 2
            while(k-1 < len(dp)):
                dp[k-1] = False
                k+=a[j]
                
    print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
if(len(a) == 1):
    print(1)
else:
    flug = 1
    for j in range(n):
        numl = []
        if(j >= len(a)):
            break
        else:
            flug = 1
            for i in range(len(a)):
                if(a[i] == a[j] and flug == 1):
                    numl.append(j)
                    flug = 0
                    numl.append(i)
                elif(a[i] > a[j] and a[i] % a[j]==0):
                    numl.append(i)
            for i in range(len(numl)):
                a.pop(numl[-(i+1)])
    print(len(a))
Problem p02683 (python)

Fixed submission:
n, m, x = map(int, input().split())
numlist = []
minimum = -1
for i in range(n):
    numlist.append(list(map(int, input().split())))
for i in range(1<<n):
    result = [0] * (m+1)
    for j in range(n):
        if(i>>j & 1 == 1):
            for k in range(m+1):
                result[k] += numlist[j][k]
    for k in range(m):
        if(result[k+1] < x): break
    else:
        if(minimum > result[0] or minimum == -1): minimum = result[0]
print(minimum)

Buggy submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
numlist = []
minimum = -1
for i in range(n):
    numlist.append(list(map(int, input().split())))
for i in range(1<<n):
    result = [0] * (m+1)
    for j in range(n):
        if(i>>j & 1 == 1):
            for k in range(m+1):
                result[k] += numlist[j][k]
    for k in range(m):
        if(result[k+1] < x): break
    else:
        if(min > result[0] or minimum == -1): minimum = result[0]
print(minimum)

Buggy submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
numlist = []
minimum = -1
for i in range(n):
    numlist.append(list(map(int, input().split())))
for i in range(1<<n):
    result = [0] * (m+1)
    for j in range(n):
        if(i>>j & 1 == 1):
            for k in range(m+1):
                result[k] += numlist[j][k]
    for k in range(m):
        if(result[k+1] < x): break
    else:
        if(min > result[0] or minimum == -1): minimum = result[0]
print(minimum)
Problem p02719 (python)

Fixed submission:
n, k = map(int, input().split())
n = n % k
if abs(n - k) > abs(k - n):
    if n > abs(k - n):
        print(abs (k - n))
    else:
        print(n)  
else:
    if n > abs(n - k):
        print(abs (n - k))
    else:
        print(n)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
n = n % k
if abs(n - k) > abs(k - n):
    if n > abs(k - n)
        print(abs (k - n))
    else:
        print(n)  
else:
    if n > abs(n - k)
        print(abs (n - k))
    else:
        print(n)
Problem p02628 (python)

Fixed submission:
N_syu, K_ko = map(int, input().split())
prices = list(map(int, input().split()))

prices.sort()

sum = 0
for i in range(K_ko):
    sum += prices[i]
print(sum)

Buggy submission (verdict: Runtime Error):
num, select = map(int, input())
l = list(map(int, input()))

sum = 0
l = l.sort()
for i in l:
  sum += l[i]

print(sum)
Problem p02534 (python)

Fixed submission:
k=int(input())
if k==1:
  print('ACL')
elif k==2:
  print('ACLACL')
elif k==3:
  print('ACLACLACL')
elif k==4:
  print('ACLACLACLACL')
elif k==5:
  print('ACLACLACLACLACL')

Buggy submission (verdict: Runtime Error):
k=int(input())
print(k*ACL)
Problem p03360 (python)

Fixed submission:
num = list(map(int, input().split()))
k = int(input())
print(max(num)*(2**k-1)+sum(num))

Buggy submission (verdict: Runtime Error):
num = list(map(int, input().split())
k = int(input())
print(max(num)*(2**k-1)+sum(num))
Problem p03556 (python)

Fixed submission:
n = int(input())
a = 1
while a**2 <= n:
    a += 1
print((a-1)**2)

Buggy submission (verdict: Runtime Error):
n = int(input())
import fractions
print(fractions.floor(n**0.5)**2)
Problem p03760 (python)

Fixed submission:
O = input()
E = input()
for o,e in zip(O,E):
  print(o,e,end="",sep="")
if len(O)>len(E):
    print(O[-1],end="")

Buggy submission (verdict: Runtime Error):
for o,e in zip(input(),input()):
  print(o,e,end="",sep="")
if len(O)>len(E):
    print(O[-1],end="")

Buggy submission (verdict: Runtime Error):
o = list(input())
e = list(input())
ans = []
for i in range(len(o)):
  ans.append(o[i])
  ans.append(e[i])
print("".join(ans))

Buggy submission (verdict: Runtime Error):
o = list(input())
e = list(input())
ans = []
for i in range(len(o)):
  ans.append(o[i])
  ans.append(e[i])
print("".join(ans))
Problem p03796 (python)

Fixed submission:
n = int(input())
import math
print(math.factorial(n)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n = int(input())
import fractions
print(fractions.factorial(n)%(10**9+7))
Problem p02573 (python)

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

import resource,sys
#resource.setrlimit(resource.RLIMIT_STACK,(2**29,-1))
sys.setrecursionlimit(10**6)

def dfs(u):
    global graph,vis
    vis.add(u)
    for i in graph[u]:
        if i not in vis:
            dfs(i)

n,m = ip()
graph = {i:[] for i in range(1,n+1)}
for i in range(m):
    a,b = ip()
    graph[a].append(b)
    graph[b].append(a)
for i in graph:
    graph[i] = list(set(graph[i]))
vis = set()
ans = -1
prev = 0
for i in range(1,n+1):
    if i not in vis:
        dfs(i)
        t = len(vis)
        ans = max(ans,t-prev)
        prev = t
print(ans)

Buggy submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

import resource,sys
resource.setrlimit(resource.RLIMIT_STACK,(2**29,-1))
sys.setrecursionlimit(10**6)

def dfs(u):
    global graph,vis
    vis.add(u)
    for i in graph[u]:
        if i not in vis:
            dfs(i)

n,m = ip()
graph = {i:[] for i in range(1,n+1)}
for i in range(m):
    a,b = ip()
    graph[a].append(b)
    graph[b].append(a)
for i in graph:
    graph[i] = list(set(graph[i]))
vis = set()
ans = -1
prev = 0
for i in range(1,n+1):
    if i not in vis:
        dfs(i)
        t = len(vis)
        ans = max(ans,t-prev)
        prev = t
print(ans)
Problem p02681 (python)

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())


a = input()
b = input()
if a == b[:-1]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
if a == b[:-1]: print("Yes")
  else: print("No")

Buggy submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

for _ in range(int(input())):
    a = input()
    b = input()
    if a == b[:-1]: print("Yes")
    else: print("No")
Problem p02690 (python)

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

dt = {}
x = []
for i in range(300):
    dt[i**5] = i
    x.append(i**5)
num = inp()
if num in dt:
    print(dt[num],0)
    exit()
n = len(x)
for i in range(n-1):
    for j in range(i+1,n):
        if x[i] + x[j] == num:
            print(dt[x[i]],-dt[x[j]])
            exit()
        elif x[j] - x[i] == num:
            print(dt[x[j]],dt[x[i]])

Buggy submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

from bisect import bisect_left as bs
dt = {}
x = []
for i in range(200):
    dt[i**5] = i
    x.append(i**5)
n = inp()
if n in dt:
    print(dt[n],0)
    exit()
i = bs(x,n)
a = x[i]
b = a - n
if b in dt:
    print(dt[a],dt[b])
else:
    a = x[i-1]
    b = n - a
    print(dt[a],-dt[b])

Buggy submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

from bisect import bisect_left as bs
dt = {}
x = []
for i in range(120):
    dt[i**5] = i
    x.append(i**5)
n = inp()
if n in dt:
    print(dt[n],0)
    exit()
i = bs(x,n)
a = x[i]
b = a - n
if b in dt:
    print(dt[a],dt[b])
else:
    a = x[i-1]
    b = n - a
    print(dt[a],-dt[b])

Buggy submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
#dt = {k:v for k,v in sorted(x.items(), key=lambda i: i[1])}
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]
mp = lambda :map(int,input().split())

from bisect import bisect_left as bs
dt = {}
x = []
for i in range(65):
    dt[i**5] = i
    x.append(i**5)
n = inp()
if n in dt:
    print(dt[n],0)
    exit()
i = bs(x,n)
a = x[i]
b = a - n
if b in dt:
    print(dt[a],dt[b])
else:
    a = x[i-1]
    b = n - a
    print(dt[a],-dt[b])
Problem p03164 (python)

Fixed submission:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

def knapsack(wt,sm,W,n,V):
    K = [float('inf')]*(sm+1)
    K[0] = 0
    for i in range(n):
        for j in range(sm-V[i],-1,-1):
                K[j+V[i]] = min(K[j+V[i]],K[j]+W[i])
    #print(K)
    return max([i for i in range(sm+1) if K[i] <= wt])

n,wt = ip()
V,W = [0]*n,[0]*n
for i in range(n):
    w,v = ip()
    V[i] = v
    W[i] = w
ans = knapsack(wt,sum(V),W,n,V)
print(ans)

Buggy submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

def knapsack(sm,W,n,V):
    K = [0]*(sm+1)
    for i in range(1,n+1):
        for j in reversed(range(1,sm+1)):
            if j - W[i-1] >= 0:
                K[j] = max(V[i-1]+K[j-W[i-1]], K[j])
    return K[-1]

n,wt = ip()
V,W = [0]*n,[0]*n
for i in range(n):
    w,v = ip()
    V[i] = v
    W[i] = w
ans = knapsack(wt,W,n,V)
print(ans)

Buggy submission (verdict: Runtime Error):
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

def knapsack(sm,W,n,V):
    K = [[0]*(sm+1) for i in range(n+1)]
    for i in range(1,n+1):
        for j in range(1,sm+1):
            K[i][j] = K[i-1][j]
            if W[i-1] <= j:
                K[i][j] = max(V[i-1]+K[i-1][j-W[i-1]], K[i-1][j])
    return K[n][sm]

n,wt = ip()
V,W = [0]*n,[0]*n
for i in range(n):
    w,v = ip()
    V[i] = v
    W[i] = w

ans = knapsack(wt,W,n,V)
print(ans)
Problem p02553 (python)

Fixed submission:
a, b, c, d = list(map(int, input().split()))

maxn = a*c

x = a*d
y = b*c
z = b*d

if maxn < x :
    maxn = x
if maxn < y :
    maxn = y
if maxn < z :
    maxn = z

print(maxn)

Buggy submission (verdict: Runtime Error):
a, b, c, d = list(map(int, input().split()))

a += 1
c += 1

max = a*c

a*d = x
b*c = y
b*d = z

if max < x :
    max = x
if max < y :
    max = y
if max < z :
    max = z

print(max)
Problem p02630 (python)

Fixed submission:
#Replacing
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
Q = int(input())
u, count = np.unique(A,return_counts=True)
L = np.zeros(10**5,int)
for i in range(len(u)):
    L[u[i]-1] = count[i]
asum = A.sum()
for i in range(Q):
    B, C = list(map(int, input().split()))
    asum += L[B-1] * (C-B)
    L[C-1] += L[B-1]
    L[B-1] = 0
    print(asum)

Buggy submission (verdict: Runtime Error):
#Replacing
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
Q = int(input())
u, count = np.unique(A,return_counts=True)
asum = A.sum()
for i in range(Q):
    B, C = list(map(int, input().split()))
    posB = np.where(u==B)
    posC = np.where(u==C)
    asum += int(count[posB]) * (C-B)
    if posC==[]:
        u[posB] = B
    else :
        count[posC] += count[posB]
        u = np.delete(u,posB)
        count = np.delete(count,posB)
    print(asum)
    # print(u)
    # print(count)
Problem p02621 (python)

Fixed submission:
n = int(input())
s = 0
for i in range(1,4):
  s += n**i
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = 0
for i in range(1,4):
  s += a**i
Problem p02628 (python)

Fixed submission:
n,k= map(int,input().split())
s = map(int,input().split())
li = list(s)
li.sort()
print(sum(li[:k]))

Buggy submission (verdict: Runtime Error):
n,k= map(int,input().split())
s = map(int,input().split())
s.sort()
print(sum(s[:k]))
Problem p02603 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

memo = {}
s = set()

ans = 0
def dfs(idx, money, stocks):
    global ans
    if idx==N:
        ans = max(ans, money)
        return
    a = As[idx]
    if (idx, stocks) in s:
        if money<=memo[(idx, stocks)]:
            return
    s.add((idx, stocks))
    memo[(idx, stocks)] = money
    dfs(idx+1, money+stocks*a, 0)
    dfs(idx+1, money, stocks)
    cnt = money//a
    dfs(idx+1, money-cnt*a, stocks+cnt)

dfs(0, 1000, 0)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

memo = {}
s = set()

ans = 0
def dfs(idx, money, stocks):
    global ans
    if idx==N:
        ans = max(ans, money)
        return
    a = As[idx]
    if (idx, stocks) in s:
        if money<=memo[(idx, stocks)]:
            return
    s.add((idx, stocks))
    for num in range(1, stocks+1):
        dfs(idx+1, money+a*num, stocks-num)
    cnt = 0
    while money>=0:
        dfs(idx+1, money, stocks+cnt)
        cnt += 1
        money -= a

dfs(0, 1000, 0)
print(ans)
Problem p02609 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Xs = list(map(int, list(input())))
rXs = Xs[::-1]

num = sum(Xs)
pos = 0
neg = 0

pow_pos = [0]*N
pow_neg = [0]*N
dic = {0: 0, 1: 1, 2: 1, 3: 2, 4: 1, 5: 2, 6: 1, 7: 2, 8: 1}

for m in range(1, num+2):
    c = bin(m)[2:].count('1')
    dic[m] = dic[m%c]+1
    
for i in range(N):
    pow_pos[i] = pow(2, i, num+1)
    if not num==1:
        pow_neg[i] = pow(2, i, num-1)

for i, x in enumerate(rXs):
    if x==0:
        continue
    pos += pow_pos[i]
    if not num==1:
        neg += pow_neg[i]

anss = []
for i, x in enumerate(rXs):
    if num==1 and x==1:
        anss.append(0)
        continue
    if x==0:
        mod = num+1
        tmp = (pos+pow_pos[i])%mod
    else:
        mod = num-1
        tmp = (neg-pow_neg[i])%mod
    ans = dic[tmp]+1
    anss.append(ans)

for ans in anss[::-1]:
    print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Xs = list(map(int, list(input())))
rXs = Xs[::-1]

num = sum(Xs)
pos = 0
neg = 0

pow_pos = [0]*N
pow_neg = [0]*N
dic = {0: 0, 1: 1, 2: 1, 3: 2, 4: 1, 5: 2, 6: 1, 7: 2, 8: 1}

for m in range(1, num+2):
    c = bin(m)[2:].count('1')
    dic[m] = dic[m%c]+1
    
for i in range(N):
    pow_pos[i] = pow(2, i, num+1)
    if not num==1:
        pow_neg[i] = pow(2, i, num-1)

for i, x in enumerate(rXs):
    if x==0:
        continue
    pos += pow_pos[i]
    if not num==1:
        neg += pow_neg[i]

anss = []
for i, x in enumerate(rXs):
    if num==1 and x==1:
        ans.append(0)
        continue
    if x==0:
        mod = num+1
        tmp = (pos+pow_pos[i])%mod
    else:
        mod = num-1
        tmp = (neg-pow_neg[i])%mod
    ans = dic[tmp]+1
    anss.append(ans)

for ans in anss[::-1]:
    print(ans)
Problem p02632 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

K = int(input())
S = str(input())
mod = 10**9+7
lens = len(S)
length = lens+K

L = 1
pow_dic = [0]*(10**6*2+1)
pow_dic[0] = 1
for i in range(1, 10**6*2+1):
    L = L*i%mod
    pow_dic[i] = L%mod
ans = 0
for rest in range(K+1):
    lenall = length-rest-1
    nlens = lens-1
    l = pow_dic[lenall]*pow(pow_dic[lenall-nlens], mod-2, mod)%mod
    r = pow_dic[nlens]
    comb = l*pow(r, mod-2, mod)%mod
    ans += pow(25, K-rest, mod)*pow(26, rest, mod)*comb%mod
    ans %= mod
print(ans%mod)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

K = int(input())
S = str(input())
mod = 10**9+7
lens = len(S)
length = lens+K

L = 1
pow_dic = {}
pow_dic[0] = 1
for i in range(1, 10**6+1000):
    L = L*i%mod
    pow_dic[i] = L
ans = 0
for rest in range(K+1):
    lenall = length-rest-1
    nlens = lens-1
    l = pow_dic[lenall]*pow(pow_dic[lenall-nlens], mod-2, mod)%mod
    r = pow_dic[nlens]
    comb = l*pow(r, mod-2, mod)%mod
    ans += pow(25, K-rest, mod)*pow(26, rest, mod)*comb%mod
    ans %= mod
print(ans%mod)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

K = int(input())
S = str(input())
mod = 10**9+7
lens = len(S)
length = lens+K

L = 1
pow_dic = {}
pow_dic[0] = 1
for i in range(1, 10**6+2):
    L = L*i%mod
    pow_dic[i] = L
ans = 0
for rest in range(K+1):
    lenall = length-rest-1
    nlens = lens-1
    l = pow_dic[lenall]*pow(pow_dic[lenall-nlens], mod-2, mod)%mod
    r = pow_dic[nlens]
    comb = l*pow(r, mod-2, mod)%mod
    ans += pow(25, K-rest, mod)*pow(26, rest, mod)*comb%mod
    ans %= mod
print(ans%mod)
Problem p02642 (python)

Fixed submission:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

from math import sqrt
from collections import Counter, deque
N = int(input())
As = list(mapint())
As.sort()
C = Counter(As)
S = set()

MAX = As[-1]
cnt = 0
for n in range(N):
    p = As[n]
    if p in S:
        continue
    i = 1
    while MAX>=p*i:
        S.add(p*i)
        i += 1
    if C[p]>=2:
        continue
    cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

from math import sqrt
from collections import Counter, deque
N = int(input())
As = list(mapint())
As.sort()
C = Counter(As)

MAX = As[-1]
Ps = deque(As)
cnt = 0
for _ in range(N):
    p = Ps.popleft()
    if C[p]>=2:
        continue
    Ps = deque([i for i in Ps if i%p!=0])
    cnt += 1
    if p>=sqrt(MAX):
        break
print(len(Ps)+cnt)
Problem p02662 (python)

Fixed submission:
N, S = map(int, input().split())
As = list(map(int, input().split()))
mod = 998244353
dp = [[0]*(S+1) for i in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    a = As[i-1]
    for s in range(S+1):
        if s-a>=0:
            dp[i][s] += dp[i-1][s-a] + dp[i-1][s]*2
        else:
            dp[i][s] += dp[i-1][s]*2
        dp[i][s] %= mod
print(dp[-1][-1]%mod)

Buggy submission (verdict: Runtime Error):
N, S = map(int, input().split())
As = list(map(int, input().split()))
mod = 998244353
import numpy as np
dp = np.array([[0]*(S+1) for i in range(N+1)])
dp[0][0] = 1
for i in range(1, N+1):
    a = As[i-1]
    for s in range(S+1):
        if s-a>=0:
            dp[i][s] += (dp[i-1][s-a] + dp[i-1][s]*2)
        else:
            dp[i][s] += (dp[i-1][s]*2)
    dp[i] %= mod
print(dp[-1][-1]%mod)
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
As = list(map(lambda x: int(x)-1, input().split()))

cnt = 1
v = 0
checked = [-1]*N
checked[0] = 0
while True:
    v = As[v]
    if checked[v]!=-1:
        loop = cnt-checked[v]
        road = checked[v]
        break
    cnt += 1
    checked[v] = cnt-1

ite = K if K<=road else road+((K-road)%loop)

v = 0
for i in range(ite):
    v = As[v]

print(v+1)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
import numpy as np
As = list(map(lambda x: int(x)-1, input().split()))

cnt = 1
v = 0
checked = [-1]*N
checked[0] = 0
while True:
    v = As[v]
    if checked[v]!=-1:
        loop = cnt-checked[v]
        road = checked[v]
        break
    cnt += 1
    checked[v] = cnt-1

ite = K if K<=road else road+((K-road)%loop)

v = 0
for i in range(ite):
    v = As[v]

print(v+1)
Problem p02691 (python)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
L = [A[i]+i for i in range(N)]
R = [i-A[i] for i in range(N)]
c = Counter(R)

ans = 0
for l in L:
    ans += c[l]

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
Hs = np.array(list(map(int, input().split())))
As = np.tile(Hs, (N, 1))
h = As.T.copy()
L = np.array([i for i in range(N)])
idxs = np.tile(L, (N, 1))
tidxs = idxs.T.copy()
try:
    co = As + h - np.abs(idxs-tidxs)
except:
    co = As
ans = N**2-np.count_nonzero(co)
print(ans//2)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
Hs = np.array(list(map(int, input().split())), dtype='int64')
As = np.tile(Hs, (N, 1))
h = As.T.copy()
L = np.array([i for i in range(N)], dtype='int64')
idxs = np.tile(L, (N, 1))
tidxs = idxs.T.copy()
co = As + h - np.abs(idxs-tidxs)
ans = N**2-np.count_nonzero(co)
print(ans//2)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
Hs = np.array(list(map(int, input().split())), dtype='int64').reshape(-1, 1)
As = Hs.repeat(N, axis=1)
h = As.T.copy()
L = np.array([i for i in range(N)], dtype='int64').reshape(-1, 1)
idxs = L.repeat(N, axis=1)
tidxs = idxs.T.copy()
co = As + h - np.abs(idxs-tidxs)
ans = N**2-np.count_nonzero(co)
print(ans//2)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
Hs = np.array(list(map(int, input().split()))).reshape(-1, 1)
As = Hs.repeat(N, axis=1)
h = As.T.copy()
L = np.array([i for i in range(N)]).reshape(-1, 1)
idxs = L.repeat(N, axis=1)
tidxs = idxs.T.copy()
co = As + h - np.abs(idxs-tidxs)
ans = N**2-np.count_nonzero(co)
print(ans//2)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
Hs = list(map(int, input().split()))
nHs = np.array(Hs)
h = np.tile(nHs, (N, 1))
co = h - np.array([[abs(n-i)-Hs[n] for i in range(N)] for n in range(N)])
ans = np.sum(co==0)
print(ans//2)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
Hs = list(map(int, input().split()))
nHs = np.array(Hs)
h = np.tile(nHs, (N, 1))
co = h - np.array([[abs(n-i)-Hs[n] for i in range(N)] for n in range(N)])
ans = N**2-np.count_nonzero(co)
print(ans//2)