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

Fixed submission:
N = int(input())
for k in range(N+2):
    if k * (k-1) == 2 * N:
        S = [[] for _ in range(k+1)]
        n = 1
        for i in range(2, k+1):
            for j in range(1, i):
                S[i].append(n)
                S[j].append(n)
                n += 1
        print('Yes')
        print(k)
        for i in range(1, k+1):
            ans = [len(S[i])] + S[i]
            print(' '.join(map(str, ans)))
        exit()
print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
for k in range(N+2):
    if k * (k-1) == 2 * N:
        S = [[] for _ in range(k+1)]
        n = 1
        for i in range(2, N+1):
            for j in range(1, i):
                S[i].append(n)
                S[j].append(n)
                n += 1
        print(k)
        for i in range(1, k+1):
            ans = [len(S[i])] + S[i]
            print(' '.join(map(str, ans)))
        exit()
print('No')
Problem p03394 (python)

Fixed submission:
N = int(input())
if N == 3:
    print(2, 5, 63)
    exit()
a = []
i = 2
while len(a) < N-N%2-2 and i + 2 <= 30000:
    a.append(i)
    a.append(i+2)
    i += 6
b = []
i = 3
while len(a) + len(b) < N-N%2 and i + 6 <= 30000:
    b.append(i)
    b.append(i+6)
    i += 12
c = []
i = 6
while len(a) + len(b) + len(c) < N:
    c.append(i)
    i += 6
print(' '.join(map(str, a+b+c)))

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 3：
	print(1, 2, 3)
  	exit()
a = []
i = 2
while len(a) < N-N%2-2 and i + 2 <= 30000:
	a.append(i)
    a.append(i+2)
    i += 6
b = []
i = 3
while len(a) + len(b) < N-N%2 and i + 6 <= 30000:
  	b.append(i)
    b.append(i+6)
    i += 12
c = []
i = 6
while len(a) + len(b) + len(c) < N:
  	c.append(i)
    i += 6
print(' '.join(map(str, a+b+c)))

Buggy submission (verdict: Runtime Error):
N = int(input())
if N ＝＝ 3：
	print(1, 2, 3)
  	exit()
a = []
i = 2
while len(a) < N-N%2-2 and i + 2 <= 30000:
	a.append(i)
    a.append(i+2)
    i += 6
b = []
i = 3
while len(a) + len(b) < N-N%2 and i + 6 <= 30000:
  	b.append(i)
    b.append(i+6)
    i += 12
c = []
i = 6
while len(a) + len(b) + len(c) < N:
  	c.append(i)
    i += 6
print(' '.join(map(str, a+b+c)))
Problem p03450 (python)

Fixed submission:
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    G[L].append((R, D))
    G[R].append((L, -D))

visited = [False] * N
dist = [float('inf')] * N
for i in range(N):
    if not visited[i]:
        dist[i] = 0
        stack = [i]
        while stack:
            v = stack.pop()
            visited[v] = True
            for u, d in G[v]:
                if dist[u] == float('inf'):
                    dist[u] = dist[v] + d
                elif dist[u] != dist[v] + d:
                    print('No')
                    exit()
                if not visited[u]:
                    stack.append(u)
print('Yes')

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import floyd_warshall
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
G = [[float('inf')] * N for _ in range(N)]
for i in range(N):
    G[i][i] = 0
LRD = [None] * M
for i in range(M):
    L, R, D = map(int, input().split())
    L -= 1
    R -= 1
    G[L][R] = D
    LRD[i] = (L, R, D)
dist = floyd_warshall(G)
for L, R, D in LRD:
    if dist[L][R] != D or dist[R][L] != float('inf'):
        print('No')
        exit()
print('Yes')
Problem p03488 (python)

Fixed submission:
def check(arr, x):
    pos = set([0])
    for dx in arr:
        npos = set()
        for p in pos:
            npos.add(p+dx)
            npos.add(p-dx)
        pos = npos
    return x in pos


s = input().split('T')
x, y = map(int, input().split())
d = [len(ss) for ss in s]
dx = d[2::2]
dy = d[1::2]
x -= d[0]
if check(dx, x) and check(dy, y):
    print('Yes')
else:
    print('No')

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


def check(arr, x):
    s = sum(arr)
    if (s+x) % 2 == 1:
        return False
    target = (s+x) // 2
    dp = [False] * (target+1)
    dp[0] = True
    for a in arr:
        for i in range(a, target+1):
            dp[i] = dp[i-a]
    return dp[-1]


s = input().rstrip() + 'T'
x, y = map(int, input().split())
X = []
Y = []
xy = 0
f_count = 0
for c in s:
    if c == 'T':
        if xy == 0:
            X.append(f_count)
        else:
            Y.append(f_count)
        f_count = 0
        xy = 1 - xy
    else:
        f_count += 1
x -= X[0]
X.pop(0)
if check(X, x) and check(Y, y):
    print('Yes')
else:
    print('No')
Problem p03599 (python)

Fixed submission:
# 100(aA + bB) + cC + dD <= F
# cC + dD <= (aA + bB)E
# maximize 100(cD + dD) / (100(aA + bB) + cC + dD)

A, B, C, D, E, F = map(int, input().split())
concentration = -1
ans = (0, 0)
for a in range(31):
    for b in range(31):
        water = 100*(a*A + b*B)
        if water > F:
            break
        for c in range(3001):
            for d in range(3001):
                sugar = c*C + d*D
                if water + sugar == 0:
                    continue
                if water + sugar > F:
                    break
                if sugar > water // 100 * E:
                    break
                conc = 100*sugar / (water + sugar)
                if concentration < conc:
                    concentration = conc
                    ans = (water + sugar, sugar)
print(ans[0], ans[1])

Buggy submission (verdict: Runtime Error):
# 100(aA + bB) + cC + dD <= F
# cC + dD <= (aA + bB)E
# maximize 100(cD + dD) / (100(aA + bB) + cC + dD)

A, B, C, D, E, F = map(int, input().split())
concentration = 0
ans = None
for a in range(31):
    for b in range(31):
        water = 100*(a*A + b*B)
        if water > F:
            break
        for c in range(3001):
            for d in range(3001):
                sugar = c*C + d*D
                if water + sugar == 0:
                    continue
                if water + sugar > F:
                    break
                if sugar > water // 100 * E:
                    break
                conc = 100*sugar / (water + sugar)
                if concentration < conc:
                    concentration = conc
                    ans = (water + sugar, sugar)
print(ans[0], ans[1])
Problem p03660 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


N = int(input())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    G[a].append(b)
    G[b].append(a)


def dfs(v, dist):
    for u in G[v]:
        if dist[u] != -1:
            continue
        dist[u] = dist[v] + 1
        ret = dfs(u, dist)


dist_fen = [-1] * N
dist_fen[0] = 0
dfs(0, dist_fen)

dist_snu = [-1] * N
dist_snu[N-1] = 0
dfs(N-1, dist_snu)

fen = 0
for v in range(N):
    if dist_fen[v] <= dist_snu[v]:
        fen += 1
if fen > N // 2:
    print('Fennec')
else:
    print('Snuke')

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


class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))
        self.rank = [0] * size

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


N = int(input())
G = [set() for _ in range(N)]
for _ in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    G[a].add(b)
    G[b].add(a)
visited = [False] * N
visited[0] = True


def dfs(v):
    if v == N-1:
        return [N-1]
    for u in G[v]:
        if visited[u]:
            continue
        visited[u] = True
        ret = dfs(u)
        visited[u] = False
        if ret:
            return [v] + ret
    return None


path = dfs(0)
l = len(path)
u, v = 0, 0
if l % 2 == 0:
    u = path[l//2-1]
    v = path[l//2]
else:
    u = path[l//2]
    v = path[l//2+1]
G[u].remove(v)
G[v].remove(u)

uf = UnionFind(N)
for u in range(N):
    for v in G[u]:
        uf.unite(u, v)
fen = 0
snu = 0
for v in range(N):
    if uf.same(v, 0):
        fen += 1
    else:
        snu += 1
if fen > snu:
    print('Fennec')
else:
    print('Snuke')
Problem p03689 (python)

Fixed submission:
H, W, h, w = map(int, input().split())
rem = H * W - (H - H % h) * (W - W % w)
if rem == 0:
    print('No')
    exit()
x = (H // h * W // w + rem) // rem
if abs(x) > 10**9 or abs(-(h * w - 1) * x - 1) > 10**9:
    print('No')
    exit()
print('Yes')
a = [[x] * W for _ in range(H)]
for i in range(h-1, H, h):
    for j in range(w-1, W, w):
        a[i][j] = -(h * w - 1) * x - 1
for row in a:
    print(*row)

Buggy submission (verdict: Runtime Error):
H, W, h, w = map(int, input().split())
if H % h == 0 and W % h == 0:
    print('No')
    exit()
rem = H * W - (H - H % h) * (W - W % w)
x = (H // h * W // w) // rem + 1
a = [[x] * W for _ in range(H)]
for i in range(h-1, H, h):
    for j in range(w-1, W, w):
        a[i][j] = -(h * w - 1) * x - 1
print('Yes')
for row in a:
    print(*row)
Problem p03952 (python)

Fixed submission:
N, x = map(int, input().split())
if x == 1 or x == 2*N-1:
    print('No')
    exit()
print('Yes')
ans = None
if N == 2:
    ans = [1, 2, 3]
elif x+2 <= 2*N-1:
    ans = list(range(1, x-1)) + list(range(x+3, 2*N))
    ans = ans[:N-3] + [x+2, x-1, x, x+1] + ans[N-3:]
else:
    ans = list(range(1, x-2)) + list(range(x+2, 2*N))
    ans = ans[:N-3] + [x-2, x+1, x, x-1] + ans[N-3:]
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
N, x = map(int, input().split())
if x == 1 or x == 2*N-1:
    print('No')
    exit()
print('Yes')
ans = None
if x+2 <= 2*N-1:
    ans = list(range(1, x-1)) + list(range(x+3, 2*N))
    ans = ans[:N-3] + [x+2, x-1, x, x+1] + ans[N-3:]
elif x-2 >= 1:
    ans = list(range(1, x-2)) + list(range(x+2, 2*N))
    ans = ans[:N-3] + [x-2, x+1, x, x-1] + ans[N-3:]
for i in ans:
    print(i)
Problem p04013 (python)

Fixed submission:
N, A = map(int, input().split())
x = list(map(int, input().split()))
MAX_J = sum(x)
dp = [[0] * (MAX_J+1) for i in range(N+1)]
dp[0][0] = 1
for n in range(N):
    for i in range(N)[::-1]:
        for j in range(MAX_J-x[n]+1)[::-1]:
            dp[i+1][j+x[n]] += dp[i][j]
ans = 0
for i in range(1, N+1):
    if A * i <= MAX_J:
        ans += dp[i][A * i]
print(ans)

Buggy submission (verdict: Runtime Error):
N, A = map(int, input().split())
x = list(map(int, input().split()))
MAX_J = sum(x)
dp = [[0] * (MAX_J+1) for i in range(N+1)]
dp[0][0] = 1
for n in range(N):
    for i in range(N)[::-1]:
        for j in range(MAX_J-x[n]+1)[::-1]:
            dp[i+1][j+x[n]] += dp[i][j]
ans = 0
for i in range(1, N+1):
    ans += dp[i][A * i]
print(ans)
Problem p02582 (python)

Fixed submission:
s = input()
if "RRR" in s:
  print(3)
elif "RR" in s:
  print(2)
elif "R" in s:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n,K=map(int,input().split())
p=list(map(lambda x:int(x)-1,input().split()))
c=list(map(int,input().split()))
if K == 1:
    print(max(c));exit()
ans = -10**10
def cycle(k):
    mo=k
    clen=0
    cscore=0
    flg = True
    cmax=[-10**10]
    while (mo != k or flg):
        clen+=1
        cscore+=c[mo]
        mo = p[mo]
        cmax.append(max(cmax[-1],cscore))
        if mo == k:
            flg = False
    if cscore<0:
        return cmax[min(K-1,clen-1)]
    return cscore*((K-1)//clen)+cmax[(K-1)%clen+1]
for i in range(n):
    a=cycle(i)
    if a>ans:
        ans = a
print(ans)
Problem p02612 (python)

Fixed submission:
n = int(input())
for i in range(11):
  if 1000*i >= n:
    print(1000*i - n)
    exit()

Buggy submission (verdict: Runtime Error):
n = input()
for i in range(11):
  if 1000*i >= n:
    print(n - 1000*i)
    exit()
Problem p02640 (python)

Fixed submission:
x,y = map(int,input().split())
for i in range(x+1):
  if 2*i + 4*(x-i) == y:
    print("Yes")
    exit()
print("No")

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())
for i in range(x+1):
  2*i + 4*(x-i) == y:
    print("Yes")
    exit()
print("No")
Problem p02684 (python)

Fixed submission:
N,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(N):
    a[i]-=1
if a[0]==0:print(1);exit()
c=dict()
visited=[False]*N
visited[0]=True
c[0]=0
cnt=0
dap=0
n=0
b=[0]
while True:
    n=a[n]
    if visited[n]:
        dap=c[n] 
        break
    visited[n]=True
    b.append(n)
    cnt+=1
    c[n]=cnt
l=len(c)
if k<dap:
    print(b[k]+1)
else:
    print(b[(k-dap)%(l-dap)+dap]+1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=1
b=[0]
c=dict()
visited=[False]*n
visited[0]=True
c[0]=0
cnt=0
dap=0
while True:
    n=b[-1]
    if visited[a[n]]:
        dap=c[a[n]] 
        break
    visited[a[n]]=True
    b.append(a[n])
    c[n]=cnt
    cnt+=1
l=len(b)
print(b[(k-dap)%(l-dap)+dap]+1)
Problem p02713 (python)

Fixed submission:
import math
n=int(input())
ans=0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      ans+=math.gcd(i,math.gcd(j,k))
print(ans)

Buggy submission (verdict: Runtime Error):
import math
k= int(input())
ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      g = math.gcd(a,b,c)
      ans = ans + g
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      ans+=math.gcd(i,math.gcd(j,k))
print(ans)
Problem p02787 (python)

Fixed submission:
h,n=map(int,input().split())
mahou=[list(map(int,input().split())) for i in range(n)]
INF=10**10
dp=[INF]*(h+1)#そのHPを与えるのに必要な最小MP
dp[0]=0
for hp in range(h+1):
  for use in mahou:
    dp[hp]=min(dp[max(0,hp-use[0])]+use[1],dp[hp])
print(dp[h])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline()
H,N = map(int,input().split())
spells = [list(map(int,input().split())) for i in range(N)]
INF = 10**10
dp = [INF]*(H+1)
dp[0] = 0
for use in spells:
    damage = use[0]
    mp = use[1]
    for i in range(1,H+1):
        dp[i] = min(dp[max(0,i-damage)] + mp, dp[i])
print(dp[-1])
Problem p02830 (python)

Fixed submission:
n=int(input())
s,t=input().split()
a=""
for i in range(n):
  a+=s[i]
  a+=t[i]
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
s,t=input().split()
a=""
for i , j in (s,t):
  a+=i
  a+=j
print(a)
Problem p02885 (python)

Fixed submission:
a,b=map(int,input().split())
print(max(0,a-2*b))

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
n,m,l=map(int,input().split())
INF=10**10
graph=[[INF for i in range(n)] for j in range(n)]
fuel=[[INF for i in range(n)] for j in range(n)]
for i in range(n):
    graph[i][i]=0
for i in range(m):
    a,b,c=map(int,input().split())
    a-=1;b-=1
    if c>l:continue
    graph[a][b],graph[b][a]=c,c
for i in range(n):
  for j in range(n):
    for k in range(n):
      graph[j][k]=min(graph[j][k],graph[j][i]+graph[i][k])
for i in range(n):
    for j in range(n):
        if graph[i][j]<=l:
            fuel[i][j]=1
for i in range(n):
  for j in range(n):
    for k in range(n):
      fuel[j][k]=min(fuel[j][k],fuel[j][i]+fuel[i][k])
q=int(input())
for i in range(q):
    s,t=map(int,input().split())
    s-=1;t-=1
    if fuel[s][t]==INF:print(-1)
    else:print(fuel[s][t]-1)
Problem p02910 (python)

Fixed submission:
s=input()
a=s[1::2]
b=s[::2]
if ("L" not in b) and ("R" not in a):print("Yes")
else:print("No")

Buggy submission (verdict: Runtime Error):
s=input()
a=s[1::2]
b=[::2]
if "L" not in b and "R" not in a:print("Yes")
else:print("No")
Problem p02928 (python)

Fixed submission:
import bisect
n,k=map(int,input().split())
mod=10**9+7
a=list(map(int,input().split()))
c=sorted(a)
d=[0]*n
e=[0]*n
for i in range(n):
  d[i]=bisect.bisect_left(c,a[i])
for i in range(n):
  cnt=0
  for j in range(i,n):
    if a[i]>a[j]:
      cnt+=1
  e[i]=cnt
st=sum(e)*k%mod
ad=sum(d)%mod
print((st+(ad*(k-1)*k//2)%mod)%mod)

Buggy submission (verdict: Runtime Error):
import bisect
n,k=map(int,input().split())
mod=10**9+7;ans=0
a=list(map(int,input().split()))
c=sorted(a)
d=[0]*n
e=[0]*n
for i in range(n):
  d[i]=bisect.bisectleft(c,a[i])
for i in range(n):
  cnt=0
  for j in range(i,n):
    if a[i]>a[j]:
      cnt+=1
  e[i]=cnt
st=sum(e)*k%mod
ad=sum(d)%mod
print((st+(ad*(k-1)*k//2)%mod)%mod)

Buggy submission (verdict: Runtime Error):
import bisect
n,k=map(int,input().split())
mod=10**9+7;ans=0
a=list(map(int,input().split()))
c=sorted(a)
d=[0]*n
e=[0]*n
for i in range(n):
  d[i]=bisect.bisectleft(c,a[i])
for i in range(n):
  cnt=0
  for j in range(i,n):
    if a[i]>a[j]:
      cnt+=1
  e[i]=cnt
st=sum(e)*k%mod
ad=sum(d)%mod
print((st+(ad*(k-1)*k//2)%mod)%mod)
Problem p02936 (python)

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(500000)
n,q=map(int,input().split())
edge=[[] for i in range(n)]
cost=[0]*n
for i in range(n-1):
  p,s=map(int,input().split())
  p-=1;s-=1
  edge[p].append(s)
  edge[s].append(p)
for i in range(q):
  x,c=map(int,input().split())
  x-=1
  cost[x]+=c
visited=[False]*n
queue=deque([0])
visited[0]=True
while len(queue)!=0:
  a=queue.popleft()
  for i in edge[a]:
    if visited[i]==True:continue
    queue.append(i)
    visited[i]=True
    cost[i]+=cost[a]
for i in range(n):
  cost[i]=str(cost[i])
print(" ".join(cost))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(500000)
n,q=map(int,input().split())
edge=[[] for i in range(n)]
cost=[0]*n
for i in range(n):
  p,s=map(int,input().split())
  p-=1;s-=1
  edge[p].append(s)
for i in range(q):
  x,c=map(int,input().split())
  x-=1
  cost[x]+=c
for i in range(n):
  for j in edge[i]:
    cost[j]+=cost[i]
for i in cost:
  i=str(i)
print(" ".join(cost))

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
edge=[[] for i in range(n)]
cost=[0]*n
for i in range(n):
  p,s=map(int,input().split())
  p-=1;s-=1
  edge[p].append(s)
for i in range(q):
  x,c=map(int,input().split())
  x-=1
  cost[x]+=c
for i in range(n):
  for j in edge[i]:
    cost[j]+=cost[i]
for i in cost:
  i=str(i)
print(" ".join(cost))
Problem p02946 (python)

Fixed submission:
k,x=map(int,input().split())
ans=[str(x+i) for i in range(-k+1,k)]
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
k,x=map(int,input().split())
ans=[x+i for i in range(-k+1,k)]
print(" ".join(ans))
Problem p02947 (python)

Fixed submission:
n=int(input())
l=[None for i in range(n)]
for i in range(n):
  l[i]=sorted(input())
l.sort()
l+="l"
cnt=1
ans=0
for i in range(n):
  if l[i]!=l[i+1]:
    ans+=(cnt-1)*cnt//2
    cnt=1
    continue
  cnt+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[None for i in range(n)]
for i in range(n):
  l[i]=sorted(input())
print(len(set(l)))
Problem p02957 (python)

Fixed submission:
a,b=map(int,input().split())
c=max(a,b);d=min(a,b)
if (d-c)%2==1:print("IMPOSSIBLE")
else:
  print((d+c)//2)

Buggy submission (verdict: Runtime Error):
s=input()
l=len(s);mod=10**9+7
dp=[[0]*13 for i in range(l)]
rem=[1,10,9,12,3,4]
for i in range(l)[::-1]:
  dig=i%6
  if s[i]=="?":
    if i==l-1:
      for j in range(10):
        dp[-1][(j*rem[dig])%13]=1
    else:
      for j in range(10):
        for h in range(13):
          dp[i][(h+j*rem[dig])%13]+=dp[i+1][h]
          dp[i][(h+j*rem[dig])%13]%=mod
  else:
    a=int(s[i])
    if i==l-1:
      dp[i][(a*rem[dig])%13]=1
    else:
      for j in range(13):
        dp[i][(j+a*rem[dig])%13]+=dp[i+1][j]
        dp[i][(j+a*rem[dig])%13]%=mod
print(dp[0][5])
Problem p02960 (python)

Fixed submission:
s=input()
l=len(s);mod=10**9+7
dp=[[0]*13 for i in range(l)]
rem=[1,10,9,12,3,4]
for i in range(l)[::-1]:
  dig=(l-i-1)%6
  if s[i]=="?":
    if i==l-1:
      for j in range(10):
        dp[-1][(j*rem[dig])%13]=1
    else:
      for j in range(10):
        for h in range(13):
          dp[i][(h+j*rem[dig])%13]+=dp[i+1][h]
          dp[i][(h+j*rem[dig])%13]%=mod
  else:
    a=int(s[i])
    if i==l-1:
      dp[i][(a*rem[dig])%13]=1
    else:
      for j in range(13):
        dp[i][(j+a*rem[dig])%13]+=dp[i+1][j]
        dp[i][(j+a*rem[dig])%13]%=mod
print(dp[0][5])

Buggy submission (verdict: Runtime Error):
s=input()
l=len(s);mod=10**9+7
dp=[[0]*13 for i in range(n)]
rem=[1,10,9,12,3,4]
for i in range(n)[::-1]:
  dig=i%6
  if s[i]=="?":
    if i==n-1:
      for j in range(10):
        dp[-1][(j*rem[dig])%13]=1
    else:
      for j in range(10):
        for h in range(13):
          dp[i][(h+j*rem[dig])%13]+=dp[i+1][h]
          dp[i][(h+j*rem[dig])%13]%=mod
print(dp[0][5])
Problem p02969 (python)

Fixed submission:
a=int(input())
print(3*a*a)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
b=[]
emp=[0]*n
ans=0
for i in range(n)[::-1]:
  c=n//(i+1)
  s=0
  while (c+1)*(i+1)<=n:
    s+=emp[(c+1)*(i+1)-1]
    c+=1
    s%=2
  if l[i]!=s:
    b.append(str(i+1))
    ans+=1
    emp[i]=1
print(ans)
print(" ".join(b))
Problem p02972 (python)

Fixed submission:
n=int(input())
balls=list(map(int,input().split()))
ans=[0]*n;m=0;al=[]
for i in range(n)[::-1]:
  d=i+1
  c=n//d
  mal=2
  check=0
  while d*mal<=n:
    check+=ans[d*mal-1]
    mal+=1
  check%=2
  if check!=balls[i]:
    ans[i]=1
    al.append(str(d))
    m+=1
print(m)
print(" ".join(al))

Buggy submission (verdict: Runtime Error):
n=int(input())
balls=list(map(int,input().split()))
ans=[0]*n;m=0
for i in range(n)[::-1]:
  d=i+1
  c=n//d
  check=0
  while d*(c+1)<=n:
    check+=ans[d*(c+1)-1]
    c+=1
  if check!=balls[i]:
    ans[i]=1
    m+=1
print(m)
print(" ".join(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
b=[]
ans=0
for i in range(n)[::-1]:
  c=n//(i+1)
  s=0
  while (c+1)*(i+1)<=n:
    s+=l[(c+1)*(i+1)]
    c+=1
    s%=2
  if l[i]!=s:
    b.append(i+1)
    ans+=1
print(ans)
print(" ".join(b))
Problem p02973 (python)

Fixed submission:
import bisect as b
from collections import deque
n=int(input())
ans=1
clist=deque([int(input())])
for i in range(n-1):
    next=int(input())
    pos=b.bisect_left(clist,next)
    if pos==0:
        clist.appendleft(next)
        ans+=1
    else:
        clist[pos-1]=next
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
import bisect as b
n=int(input())
ans=1
clist=[int(input())]
for i in range(n-1):
    next=int(input())
    pos=b.bisect_left(clist,next)
    if pos==0:
        clist=[next]+clist
        ans+=1
    else:
        clist[pos-1]=next
print(ans)