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

Fixed submission:
import sys

s = input()
t = input()

for i in range(len(s)-len(t)+1):
  if i == 0:
    sub = s[-i-len(t):]
  else:
    sub = s[-i-len(t):-i]
  for j in range(len(t)):
    if sub[j]!=t[j] and sub[j]!="?":
      break
  else:
    if i == 0:
      s = s[:-i-len(t)]+t
    else:
      s = s[:-i-len(t)]+t+s[-i:]
    s = s.replace("?","a")
    print(s)
    sys.exit()
  continue
    
print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
lenS = len(S)
lenT = len(T)
ans = ""
for i in range(lenS-lenT,-1,-1):
    for j in range(lenT):
        if S[i+j]!=T[j] and S[i+j]!="?":
            break
    else:
        ans = S[:i]+T+S[i+lenT:]
        ans = ans.replace("?","a")
        print(ans)
        sys.exit()
print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()

tLen = len(t)

"""
sの中の?を.に置換する
"""
s.replace("?",".")

print(s)

for i in range(tLen,len(s)+1):
  #[-i:(-i+tLen)]の区間の文字列が、tにマッチするかを調べる。マッチするなら置換する。
Problem p03608 (python)

Fixed submission:
N,M,r = map(int,input().split())
R = list(map(int,input().split()))
#dp[i][j][k] -> 町iまで経由地点として使える。j,kの最短移動距離
dp = [[float("INF")]*(N+1) for _ in range(N+1)]
for _ in range(M):
    a,b,c = map(int,input().split())
    dp[a][b] = c
    dp[b][a] = c

for i in range(N+1):
    dp[i][i] = 0

for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(N+1):
            dp[j][k] = min(dp[j][k],dp[j][i]+dp[i][k])

from itertools import permutations
ans = float("INF")
for pattern in permutations(R):
    cost = 0
    for i in range(r-1):
        cost += dp[pattern[i]][pattern[i+1]]
    ans = min(ans,cost)
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import permutations
N,M,R = map(int,input().split())
RList = list(map(int,input().split()))
dp = [[[float("INF")]*(N+1) for _ in range(N+1)]for _ in range(N+1)]
for i in range(N+1):
    dp[i][i] = 0
for _ in range(M):
    a,b,c = map(int,input().split())
    dp[a][b] = c
    dp[b][a] = c

for i in range(1,N+1):
    for j in range(1,N+1):
        for k in range(1,N+1):
            dp[j][k] = min(dp[j][i]+dp[i][k],dp[j][k])

ans = float("INF")
RList = list(permutations(RList))
for Rs in RList:
    tmp = 0
    for i in range(1,R):
        a = Rs[i-1]
        b = Rs[i]
        tmp += dp[a][b]
    ans = min(ans,tmp)
print(ans)
Problem p03633 (python)

Fixed submission:
"""
すべての秒数の最小公倍数を求める
Gを最大公約数として持つX,Yの最小公倍数はG*X/G*Y/G
"""
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
N = int(input())
T = [int(input()) for _ in range(N)]
tmp = T[0]
for i in range(1,N):
    t = T[i]
    g = gcd(tmp,t)
    tmp = g*(tmp//g)*(t//g)
print(tmp)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for _ in range(N)]
def gcd(a,b):
    if b:
        return gcd(b,a%b)
    else:
        return a

def lcm(a,b):
    g = gcd(a,b)
    return a*b//g

l = lcm(T[0],T[1])
for i in range(2,N):
    l = lcm(l,T[i])

print(l)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(200000)
N = int(input())
T = [int(input()) for _ in range(N)]
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)

def lcm(a,b):
    g = gcd(a,b)
    return a*b//g

l = lcm(T[0],T[1])
for i in range(2,N):
    l = lcm(l,T[i])
print(l)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for _ in range(N)]
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)

def lcm(a,b):
    g = gcd(a,b)
    return a*b//g

l = lcm(T[0],T[1])
for i in range(2,N):
    l = lcm(l,T[i])
print(l)

Buggy submission (verdict: Runtime Error):
N = int(input())
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
def lcm(a,b):
    g = gcd(a,b)
    return (a*b)//g

T = [int(input()) for _ in range(N)]
l = lcm(T[0],T[1])
for i in range(2,N):
    l = lcm(l,T[i])

print(l)
Problem p03651 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2000000)
N,K = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
if N ==1:
    g = A[0]
else:
    g = gcd(A[0],A[1])
    if N > 2:
        for i in range(2,N):
            g = gcd(g,A[i])
if K <= max(A) and K%g==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
"""
KがAの最大公約数の倍数であれば実現可能。そうでなければ実現不可能。
"""
import sys
sys.setrecursionlimit(200000)
N,K = map(int,input().split())
A = list(map(int,input().split()))

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

g = gcd(A[0],A[1])
for i in range(2,N):
    g = gcd(g,A[2])

if K<=max(A) and K%g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
"""
KがAの最大公約数の倍数であれば実現可能。そうでなければ実現不可能。
"""
N,K = map(int,input().split())
A = list(map(int,input().split()))

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

g = gcd(A[0],A[1])
for i in range(2,N):
    g = gcd(g,A[2])

if K<=max(A) and K%g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
"""
KがAの最大公約数の倍数であれば実現可能。そうでなければ実現不可能。
"""
N,K = map(int,input().split())
A = list(map(int,input().split()))

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

g = gcd(A[0],A[1])
for i in range(2,N):
    g = gcd(g,A[2])

if K%g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000000)
N,K = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
g = gcd(A[0],A[1])
for i in range(2,N):
    g = gcd(g,A[i])
if K <= max(A) and K%g==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
g = gcd(A[0],A[1])
for i in range(2,N):
    g = gcd(g,A[i])
if K <= max(A) and K%g==0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(200000)

N,K = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
g = gcd(A[0],A[1])
for i in range(2,N):
    g = gcd(g,A[i])
if K % g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    return a if b==0 else gcd(b,a%b)
g = gcd(A[0],A[1])
for i in range(2,N):
    g = gcd(g,A[i])
if K % g == 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))

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

g = gcd(A[0],A[1])
for i in range(2,N):
    g = gcd(g,A[i])

if K%g==0 and K<=max(A):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Problem p03682 (python)

Fixed submission:
def main():
    import sys
    sys.setrecursionlimit(2000000)
    input = sys.stdin.readline

    class UnionFind():
        def __init__(self,n):
            self.n=n
            self.parents = [i for i in range(n+1)]
            self.size = [1]*(n+1)
        def find(self,x):
            if self.parents[x]==x:
                return x
            else:
                self.parents[x]=self.find(self.parents[x])
                return self.parents[x]
        def unite(self,x,y):
            xRoot = self.find(x)
            yRoot = self.find(y)
            if xRoot == yRoot:
                return
            if self.size[xRoot]>self.size[yRoot]:
                self.parents[yRoot] = xRoot
            else:
                self.parents[xRoot] = yRoot
                if self.size[xRoot] == self.size[yRoot]:
                    self.size[yRoot]+=1

    N = int(input())
    nodesX = []
    nodesY = []
    for i in range(1,N+1):
        x,y = map(int,input().split())
        nodesX.append((x,i))
        nodesY.append((y,i))
    nodesX.sort()
    nodesY.sort()
    edges = []
    for i in range(1,N):
        edges.append((nodesX[i][0]-nodesX[i-1][0],nodesX[i][1],nodesX[i-1][1]))
        edges.append((nodesY[i][0]-nodesY[i-1][0],nodesY[i][1],nodesY[i-1][1]))
    edges.sort()
    tree = UnionFind(N)
    cost = 0
    for w,s,t in edges:
        if tree.find(s)!= tree.find(t):
            tree.unite(s,t)
            cost += w
    print(cost)

main()

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.parents = [i for i in range(n+1)]
        self.size = [1]*(n+1)
    def find(self,x):
        if self.parents[x]==x:
            return x
        else:
            self.parents[x]=self.find(self.parents[x])
            return self.parents[x]
    def unite(self,x,y):
        xRoot = self.find(x)
        yRoot = self.find(y)
        if xRoot == yRoot:
            return
        if self.size[xRoot]>self.size[yRoot]:
            self.parents[yRoot] = xRoot
        else:
            self.parents[xRoot] = yRoot
            if self.size[xRoot] == self.size[yRoot]:
                self.size[yRoot]+=1

N = int(input())
nodesX = []
nodesY = []
for i in range(1,N+1):
    x,y = map(int,input().split())
    nodesX.append((x,i))
    nodexY.append((y,i))
nodesX.sort()
nodesY.sort()
edges = []
for i in range(1,N):
    edges.appednd(nodesX[i][0]-nodesX[i-1][0],nodesX[i][1],nodesX[i-1][1])
    edges.appednd(nodesY[i][0]-nodesY[i-1][0],nodesY[i][1],nodesY[i-1][1])
tree = UnionFind(N)
cost = 0
for w,s,t in edges:
    if tree.find(s)!= tree.find(t):
        tree.unite(s,t)
        cost += w
print(cost)
Problem p02555 (python)

Fixed submission:
MOD = 10**9+7

s = int(input())
a = [0 for i in range(s+1)]
a[0] = 1
for i in range(3, s+1):
    a[i] = sum(a[:i-2]) % MOD
print(a[s])

Buggy submission (verdict: Runtime Error):
MOD = 10**9+7

s = int(input())
a = [0]*range(s+1)
a[0] = 1
for i in range(3, s+1):
    a[i] = sum(a[:i-2]) % MOD
print(a[s])
Problem p02642 (python)

Fixed submission:
from sys import stdin
n = int(input())
a = list(map(int, stdin.readline().split()))
a.sort()
amax = max(a)+1
e = [0]*amax
ans = 0

for i in range(n):
    e[a[i]] += 1
    if e[a[i]] == 1:
        for j in range(2*a[i], amax, a[i]):
            e[j] += 2

print(e.count(1))

Buggy submission (verdict: Runtime Error):
from sys import stdin
n = int(input())
a = list(map(int, stdin.readline().split()))
amax = max(a)
e = [0]*(amax+1)
ans = 0

for i in range(n):
    e[a[i]] += 1
    if e[a[i]] == 1:
        for j in range(2*a[i], amax, a[i]):
            e[i] += 2

print(e.count(i))
Problem p02647 (python)

Fixed submission:
import numpy as np
from numba import jit
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
@jit
def imos(a):
    tmp = np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        tmp[max(0, i - a[i])] += 1
        tmp[min(i + a[i] + 1, n)] -= 1
    tmp = np.cumsum(tmp)
    return tmp[:n]

for j in range(1, min(k+1, 50)):
    a = imos(a)
print(*a)

Buggy submission (verdict: Runtime Error):
import numpy as np
from numba import jit
n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
@jit
for j in range(1, min(k+1, 50)):
    tmp = np.zeros(n+1, dtype=np.int64)
    for i in range(n):
        tmp[max(0, i - a[i])] += 1
        tmp[min(i + a[i] + 1, n)] -= 1
    tmp = np.cumsum(tmp)
    a = tmp[:n]
print(*a)
Problem p02664 (python)

Fixed submission:
print(input().replace("?", "D"))

Buggy submission (verdict: Runtime Error):
print(input.replace("?", "D"))
Problem p02702 (python)

Fixed submission:
import sys

s = sys.stdin.buffer.readline().rstrip().decode()
MOD = 2019
ans = [1] + [0 for i in range(MOD)]
t = 1
r = 0
for i in reversed(s):
    r = (r + int(i)*t) % MOD
    t = t*10%2019
    ans[r] += 1
print(sum([m*(m-1)//2 for m in ans]))

Buggy submission (verdict: Runtime Error):
import re
import sys

s = sys.stdin.buffer.readline().rstrip().decode()
ans = 0

for i in range(len(s) - 3):
    for j in range(i, len(s)):
        if int(s[i: j+i])%2019 == 0:
            ans += 1
print(ans)
Problem p02713 (python)

Fixed submission:
from math import gcd

k=int(input())
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            ans += gcd(i, gcd(j,m))
print(ans)

Buggy submission (verdict: Runtime Error):
from functools import reduce

def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def mgcd(*a)
    return reduce(gcd, a)

k = int(input())
ans = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    for l in range(1, k+1):
      tmp = mgcd(i, j, l)
      if i == j== k:
        ans += tmp
      else:
        ans += tmp*3
print(ans)
Problem p02720 (python)

Fixed submission:
import collections

k = int(input())
Q = collections.deque([int(i) for i in range(1, 10)])
for _ in range(k):
    x = Q.popleft()
    if x%10:
        Q.append(10*x + x%10 - 1)
    Q.append(10*x + x%10)
    if x%10 != 9:
        Q.append(10*x + x%10 + 1)
print(x)

Buggy submission (verdict: Runtime Error):
import collections

def main():
    k = int(input())
    Q = collections.deque([int(i) for i in range(1, 10)])
    for i in range(k):
        x = Q.popleft()
        if i + len(Q) < k:
            if x%10:
                Q.append(10*x + x%10 - 1)
            Q.append(10*x + x%10)
            if x%10 != 9:
                Q.append(10*x + x%10 + 1)
        print(Q)
    print(x)

if __name__ == "__main__":
    main()
Problem p02756 (python)

Fixed submission:
import sys
from collections import deque

s = deque([sys.stdin.readline().rstrip()])
q = int(input())
cnt = 0
for i in range(q):
    query = sys.stdin.readline().split()
    if query[0] == '1':
        cnt = (cnt + 1)%2
    else:
        if (int(query[1]) + cnt)%2 == 1:
            s.appendleft(query[2])
        else:
            s.append(query[2])
s = "".join(s)
if cnt:
    s = s[::-1]
print(s)

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque

s = deque([sys.stdin.readline().rstrip()])
q = int(input())
cnt = 0
for i in range(q):
    query = sys.stdin.readline().split()
    if query[0] == '1':
        cnt = (cnt + 1)%2
    else:
        if (int(query[1]) + cnt)%2 == 1:
            s.appendleft(query[2])
        else:
            s.append(query[2])

if cnt:
    s = "".join(s)
print(s[::-1])

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque

s = deque([sys.stdin.readline().rstrip()])
q = int(input())
cnt = 0
for i in range(q):
    query = sys.stdin.readline().split()
    if query[0] == '1':
        cnt = (cnt + 1)%2
    else:
        if (int(query[1]) + cnt)%2 == 1:
            s.appendleft(query[2])
        else:
            s.append(query[2])

if cnt:
    s = "".join(s)
print(s.reverse())

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque

s = deque([sys.stdin.readline().rstrip()])
q = int(input())
cnt = 0
for i in range(q):
    query = sys.stdin.readline().split()
    if query[0] == '1':
        cnt = (cnt + 1)%2
    else:
        if (int(query[1]) + cnt)%2 == 1:
            s.appendleft(query[2])
        else:
            s.append(query[2])

if cnt:
    s = s[::-1]
print("".join(s))
Problem p02765 (python)

Fixed submission:
n, r = map(int, input().split())
if n >= 10:
    print(r)
else:
    print(r + 100*(10-n))

Buggy submission (verdict: Runtime Error):
n, r = map(int, input().split())
if n >= 10:
    print(r)
else:
    print(r + 100(10-n))
Problem p02795 (python)

Fixed submission:
h = int(input())
w = int(input())
n = int(input())
print(-(-n//max(h,w)))

Buggy submission (verdict: Runtime Error):
n = int(input())
data = [[]]*(n+2)
data[0] = [-10**10, -10**10]
for i in range(1, n+1):
    x, l = map(int, input().split())
    data[i] = [x-l, x+l]
data[n+1] = [10**10, 10**10]
data.sort()
ans = n
if n == 2:
  if data[1][1] > data[2][0]:
    ans -= 1
else:
  for i in range(1, n):
    if data[i][1] > data[i+1][0] and data[i-1][1] > data[i][0]:
        ans -= 1
        data[i][0] = 0
        data[i][1] = 0
    
print(ans)

Buggy submission (verdict: Runtime Error):
h = int(input())
w = int(input())
n = int(input())
ans(-(-n//max(h,w)))
Problem p02813 (python)

Fixed submission:
import itertools
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

l=list(itertools.permutations(list(range(1,n+1))))
print(abs(l.index(p) - l.index(q)))

Buggy submission (verdict: Runtime Error):
from itertools
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

l=list(itertools.permutations(list(range(1,n+1))))
print(abs(l.index(p)-L.index(q)))
Problem p02841 (python)

Fixed submission:
m_1, d_1 = map(int, input().split())
m_2, d_2 = map(int, input().split())

if m_1 != m_2:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n= int(input())
s = input()
ans = 0
for i in range(10):
  ii = s.find(str(i))
  if -1 == ii:
    continue
  for j in range(10):
    ij = s.find(str(j), ii+1)
    if -1 == ij:
      continue
    for k in range(10):
      ik = s.find(str(k), ij+1)
      if ik != -1:
        ans += 1
      
print(ans)
Problem p02899 (python)

Fixed submission:
n = int(input())
h = tuple(map(int, input().split()))
ans = [0]*n
for i in range(n):
  ans[h[i]-1] = i+1
print(*ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = tuple(map(int, input().split()))
ans = [0]*n
for i in range(1, n+1):
  ans[h[i]-1] = i+1
print(*ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
cnt = h.sort()
for i in range(n):
  for j int range(j):
    if cnt[i] == h[j]:
      print(h[j], end = "")
Problem p02909 (python)

Fixed submission:
s = input()
if s == "Sunny" :
  print("Cloudy")
elif s == "Cloudy" :
  print("Rainy")
else :
  print("Sunny")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
for j in range(m):
  a[0] //= 2
  a.sort(reverse=True)
print(sum(a))
Problem p02921 (python)

Fixed submission:
S = input()
T = input()

count = 0
for i in range(0, 3):
  if S[i] == T[i]:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

best = 0
for i in range(N-1):
  a=0
  for j in range(i+1,N):
    if H[i] < H[j]: break
    else : 
      a += 1
  if a > best :
    best = a
print(best)
Problem p02923 (python)

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

best = []
a = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    a += 1
  else : 
    best.append(a)
    a = 0
best.append(a)
print(max(best))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

best = []
a = 0
for i in range(N):
  if H[i] >= H[i+1]:
    a += 1
  else : 
    best.append(a)
    a = 0
best.append(a)
print(max[best])

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

best = []
a = 0
for i in range(N):
  if H[i] >= H[i+1]:
    a += 1
  else : 
    best.append(a)
    a = 0
best.append(a)
print(max(best))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

best = 0
for i, j in range(N-1):
  a=0
  if H[i] >= H[j]:
      a += 1
  else : break
  if a > best :
    best = a
print(best)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

best = 0
for i in range(N):
  for j in range(i+1,N):
    if H[i] < H[j]: break
  if j - i > best :
    best = j - i
print(best)
Problem p02957 (python)

Fixed submission:
a, b = map(int ,input().split())
if (a + b)%2 == 0:
  print(int((a + b)/2))
else :
  print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
cnt = 0
check = 0
tmp = 0
for i in range(n-1):
  if p[i+1] - p[i] == 1:
    cnt += 1
  else:
    if check == 0:
      tmp = i + 2
      check += 1
    else :
      if tmp == p[i+1]:
        check += 1
      else :
        cnt += 1

if cnt == n-1 or check == 2 :
  print("YES")
else:
  print("NO")
Problem p02971 (python)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
b = a[:]
b.sort(reverse=True)
for i in range(n):
  if a[i] == b[0]:
    print(b[1])
  else:
    print(b[0])

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

if a<=0 and 0<=b:
  print("Zero")  
elif a < 0 and min(b-a,-a)%2 == 0:
  print("Negative")
else:
  print("Positive")
Problem p02982 (python)

Fixed submission:
from sys import stdin

n, d = map(int, input().split())
x = []
for i in range(n):
        x.append(list(map(int,input().split())))

ans = 0
for i in range(n):
  for k in range(i+1, n):
    tmp = 0
    for j in range(d):
        tmp += (x[i][j] - x[k][j])**2
    if tmp**(1/2)%1 == 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, d = map(int, input().split())
from sys import stdin

n, d = map(int, input().split())
x = []
for i in range(n):
        x.append(list(map(int,input().split())))

ans = 0
for i in range(n):
    tmp = 0
    for j in range(d):
        tmp += (x[i][j] - x[(i+1)%n][j])**2
    if tmp**(1/2)%1 == 0:
        ans += 1
print(ans)
Problem p02988 (python)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n-1):
    if (p[i-1] < p[i] and p[i+1] > p[i]) or (p[i-1] > p[i] and p[i+1] < p[i]):
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int. input().split()))
ans = 0
for i in range(1, n-1):
    if p[i-1] < p[i] and p[i] < p[i+1]:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input)
p = list(map(int. input().split()))
ans = 0
for i in range(1, n-1):
    if p[i-1] < p[i] and p[i] < p[i+1]:
        ans += 1
print(ans)
Problem p03031 (python)

Fixed submission:
def dfs(A):
    global cnt

    if len(A) == n:
        ans = [0 for i in range(m)]
        for i, a in enumerate(A):
            if a:
                for j in range(m):
                    if i+1 in s[j]:
                        ans[j] += 1
        for x, y in zip(p, ans):
            if x != y%2:
                break
        else:
            cnt += 1
        return
    for v in range(2):
        A.append(v)
        dfs(A)
        A.pop()

n, m = map(int, input().split())
s = [list(map(int, input().split()))[1:]  for _ in range(m)]
p = list(map(int, input().split()))
cnt = 0
dfs([])
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
def dfs(A):
    global cnt

    if len(A) == n:
        ans = [0 for i in range(m)]
        print(A)
        for i, a in enumerate(A):
            if a:
                for j in range(m):
                    if i+1 in s[j]:
                        ans[j] += 1
        print(ans)
        for x, y in zip(p, ans):
            if x != y%2:
                break
        else:
            cnt += 1
        return
    for v in range(2):
        A.append(v)
        dfs(A)
        A.pop()

n, m = map(int, input().split())
s = [list(map(int, x.split()))[1:]  for x in sys.stdin.readlines()]
p = list(map(int, input().split()))
cnt = 0
dfs([])
print(cnt)