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

Fixed submission:
import sys
sys.setrecursionlimit(10000000)
input=lambda :sys.stdin.readline()
N,Q=map(int, input().split())
tree_dist={}
for i in range(N):
    tree_dist[i+1] = []
for i in range(N-1):
    a,b = map(int, input().split())
    tree_dist[a].append(b)
    tree_dist[b].append(a)
    
z=[0]*N
for i in range(Q):
    p,x = map(int, input().split())
    z[p-1] += x

def saiki(i,p):
    L = list(tree_dist[i])
    for l in L:
        if l != p:
            z[l-1] += z[i-1]
            saiki(l,i)
saiki(1,0)
print(" ".join(map(str,z)))

Buggy submission (verdict: Runtime Error):
N,Q=map(int, input().split())
#AB=[list(map(int, input().split())) for i in range(N)]
tree_dist={}
for i in range(N):
    tree_dist[i+1] = set()
for i in range(N-1):
    a,b = map(int, input().split())
    tree_dist[a].add(b)
    tree_dist[b].add(a)
    
PX=[list(map(int, input().split())) for i in range(Q)]
z=[0]*N
for p,x in PX:
    z[p-1] += x

def saiki(i,p):
    L = list(tree_dist[i])
    for l in L:
        if l == p:
            continue
        z[l-1] += z[i-1]
        saiki(l,i)
saiki(1,0)
print(" ".join(map(str,z)))

Buggy submission (verdict: Runtime Error):
N,Q=map(int, input().split())
tree_dist={}
for i in range(N):
    tree_dist[i+1] = set()
for i in range(N-1):
    a,b = map(int, input().split())
    tree_dist[a].add(b)
    tree_dist[b].add(a)
    
PX=[list(map(int, input().split())) for i in range(Q)]
z=[0]*N
for p,x in PX:
    z[p-1] += x

def saiki(i,p):
    print(i)
    L = list(tree_dist[i])
    for l in L:
        if l == p:
            continue
        z[l-1] += z[i-1]
        saiki(l,i)
saiki(1,0)
print(*z)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,Q = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N-1)]
AB.reverse()
T = [[i] for i in range(N+1)]
for a,b in AB:
    T[a]+=T[b]
PQ = [list(map(int,input().split())) for _ in range(Q)]
X = np.array([0]*N)
for p,q in PQ:
    X[T[p]] = X[T[p]] + q
print(*X)
Problem p02973 (python)

Fixed submission:
N=int(input())
from collections import deque
d = deque([int(input())]) 
import bisect

for i in range(N-1):
  a=int(input())
  if a>d[-1]:
    d[-1]=a
  elif d[0]>=a:
    d.appendleft(a)
  else:
    i=bisect.bisect_left(d,a)
    d[i-1]=a
print(len(d))

Buggy submission (verdict: Runtime Error):
N=int(input())
from collections import deque
d = deque([int(input())]) 
def insert_search(List,a,l,r):
  if r==l:
    List[l-1]=a
    return List
  m=(l+r)//2
  if List[m]<a:
    return insert_search(List,a,m+1,r)
  elif List[m]!=a:
    return insert_search(List,a,l,m-1)
  else:
    while List[m]==a:
      m-=1
    List[m]=a
    return List
for i in range(N-1):
  a=int(input())
  if a>d[-1]:
    d[-1]=a
  elif d[0]>=a:
    d.appendleft(a)
  else:
    d=insert_search(d,a,0,len(d)-1)
print(len(d))

Buggy submission (verdict: Runtime Error):
N=int(input())
X=[int(input())]

def insert_search(List,a,l,r):
  if r==l:
    List[l-1]=a
    return List
  m=(l+r)//2
  if List[m]<a:
    return insert_search(List,a,m+1,r)
  elif List[m]!=a:
    return insert_search(List,a,l,m-1)
  else:
    while List[m]==a:
      m-=1
    List[m]=a
    return List
for i in range(N-1):
  a=int(input())
  if a>X[-1]:
    X[-1]=a
  elif X[0]>=a:
    X.insert(0,a)
  else:
    X=insert_search(X,a,0,len(X)-1)
print(len(X))

Buggy submission (verdict: Runtime Error):
N=int(input())
X=[int(input())]

def insert_search(List,a,l,r):
  if r==l:
    List[l-1]=a
    return List
  m=(l+r)//2
  if List[m]<a:
    return insert_search(List,a,m+1,r)
  elif Lisr[m]!=a:
    return insert_search(List,a,l,m-1)
  else:
    while List[m]==a:
      m-=1
    List[m]=a
    return List
for i in range(N-1):
  a=int(input())
  if a>X[-1]:
    X[-1]=a
  elif X[0]>=a:
    X.insert(0,a)
  else:
    X=insert_search(X,a,0,len(X)-1)
print(len(X))
Problem p02985 (python)

Fixed submission:
N,K=map(int,input().split())
Tree=[[] for i in range(N)]
MOD=10**9+7
import sys
sys.setrecursionlimit(10**9)
for i in range(N-1):
  a,b=map(int,input().split())
  Tree[a-1].append(b-1)
  Tree[b-1].append(a-1)
def P(n,m):
  _=n
  for i in range(m-1):
    n-=1
    _*=n
    _%=MOD
  return _%MOD
def dfs(p,i):
  global Tree,ans
  n=len(Tree[i])-1
  if n==0:
    return
  if i==0:
    ans*=P(K-1,n)
  else:
    ans*=P(K-2,n)
    ans%=MOD
  for j in Tree[i]:
    if j==p:
      continue
    dfs(i,j)
Tree[0].append(-1)
ans=K
dfs(-1,0)
print(ans%MOD)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
Tree=[[] for i in range(N)]
MOD=10**9+7
import sys
sys.setrecursionlimit(2*N)
for i in range(N-1):
  a,b=map(int,input().split())
  Tree[a-1].append(b-1)
  Tree[b-1].append(a-1)
def P(n,m):
  _=n
  for i in range(m-1):
    n-=1
    _*=(n%MOD)
  return _%MOD
def dfs(p,i):
  global Tree,ans
  n=len(Tree[i])-1
  if n==0:
    return
  if i==0:
    ans*=P(K-1,n)
  else:
    ans*=P(K-2,n)
    ans%=MOD
  for j in Tree[i]:
    if j==p:
      continue
    dfs(i,j)
Tree[0].append(-1)
ans=K
dfs(-1,0)
print(ans%MOD)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
Tree=[[] for i in range(N)]
MOD=10**9+7
for i in range(N-1):
  a,b=map(int,input().split())
  Tree[a-1].append(b-1)
  Tree[b-1].append(a-1)
def P(n,m):
  _=n
  for i in range(m-1):
    n-=1
    _*=(n%MOD)
  return _%MOD
def dfs(p,i):
  global Tree,ans
  n=len(Tree[i])-1
  if n==0:
    return
  if i==0:
    ans*=P(K-1,n)
  else:
    ans*=P(K-2,n)
  for j in Tree[i]:
    if j==p:
      continue
    dfs(i,j)
Tree[0].append(-1)
ans=K
dfs(-1,0)
print(ans%MOD)
Problem p02993 (python)

Fixed submission:
S=input()
for i in range(3):
  if S[i]==S[i+1]:
    print('Bad')
    exit(0)
print('Good')

Buggy submission (verdict: Runtime Error):
S=input()
for i in range(3):
  if s[i]==s[i+1]:
    print('Bad')
    exit(0)
print('Good')
Problem p03000 (python)

Fixed submission:
N,X=map(int,input().split())
L=list(map(int,input().split()))
x=0
ans=1
for l in L:
  x+=l
  if x>X:
    break
  ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
x=0
ans=1
for l in L:
  x+=L
  if x>X:
    break
  ans+=1
print(ans)
Problem p03078 (python)

Fixed submission:
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
ans=[]
for i in range(X):
  if i+1>K:
    break
  for j in range(Y):
    if (i+1)*(j+1)>K:
      break
    for k in range(Z):
      if (i+1)*(j+1)*(k+1)>K:
        break
      ans.append(A[i]+B[j]+C[k])
ans=sorted(ans,reverse=True)
for a in ans[:K]:
  print(a)

Buggy submission (verdict: Runtime Error):
X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
import heapq
h=[]
chk=[0]*(X*Y*Z)
heapq.heappush(h,(-(A[0]+B[0]+C[0]),0,0,0))
for _ in range(K):
  ans,i,j,k=heapq.heappop(h)
  print(-ans)
  if i+1<X and chk[(i+1)*(Y*Z)+j*Z+k]==0:
    chk[(i+1)*(Y*Z)+j*Z+k]=1
    heapq.heappush(h,(-(A[i+1]+B[j]+C[k]),i+1,j,k))
  if j+1<Y and chk[i*(Y*Z)+(j+1)*Z+k]==0:
    chk[i*(Y*Z)+(j+1)*Z+k]=1
    heapq.heappush(h,(-(A[i]+B[j+1]+C[k]),i,j+1,k))
  if k+1<Z and chk[i*(Y*Z)+j*Z+k+1]==0:
    chk[i*(Y*Z)+j*Z+k+1]=1
    heapq.heappush(h,(-(A[i]+B[j]+C[k+1]),i,j,k+1))
  #print(h,chk)

Buggy submission (verdict: Runtime Error):
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
if X>Y and X>Z:
  X,Z=Z,X
  A,C=C,A
elif Y>X and Y>Z:
  Y,Z=Z,Y
  B,C=C,Y
C=sorted(C,,reverse=True)
k=min(K,X*Y)
AB=sorted([a+b for a in A for b in B],reverse=True)[:k]
ABC=sorted([ab+c for ab in AB for c in C[:K]],reverse=True)[:K]
for x in ABC:
  print(x)
Problem p03136 (python)

Fixed submission:
N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
if sum(L[:-1])>L[-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N=int(input())
L=list(map(int,input().split()))
L=sorted(L)
if sum(L[:-1])>L:
  print('Yes')
else:
  print('No')
Problem p03206 (python)

Fixed submission:
D=int(input())
if D==25:
  a='Christmas'
elif D==24:
  a='Christmas Eve'
elif D==23:
  a='Christmas Eve Eve'
else:
  a='Christmas Eve Eve Eve'
print(a)

Buggy submission (verdict: Runtime Error):
D=int(input())
if D=25:
  a='Christmas'
elif D=24:
  a='Christmas Eve'
elif D=23:
  a='Christmas Eve Eve'
else:
  a='Christmas Eve Eve Eve'
print(a)
Problem p03456 (python)

Fixed submission:
a,b=input().split()
a=int(a+b)
for i in range(1,320):
  if i**2==a:
    print('Yes')
    exit(0)
print('No')

Buggy submission (verdict: Runtime Error):
a,b=imput().split()
a=int(a+b)
for i in range(1,320):
  if i**2==a:
    print('Yes')
    exit(0)
print('No')
Problem p02555 (python)

Fixed submission:
from math import comb
MOD = 10**9+7
n = int(input())
mdiv = n // 3

ans = 0
for i in range(mdiv):
    ans += comb(n - 3 * (i + 1) + i, i)

print(ans % MOD)

Buggy submission (verdict: Runtime Error):
from math import comb
MOD = 10**9+7
n = int(input())
mdiv = n // 3

ans = 0
for i in range(mdiv):
    ans += comb(n - 3 * (i + 1) + i, i)

print(ans % MOD)
Problem p02619 (python)

Fixed submission:
(d,), cc, *sstt = [list(map(int, s.split())) for s in open(0)]

ss = sstt[:d]

tt = list(map(lambda x: x-1, sum(sstt[d:], [])))

comp = [0]*len(cc)

ans = 0

for i in range(d):
    comp = [sum(x) for x in zip(comp, cc)]
    t = tt[i]
    ans += ss[i][t]
    comp[t] = 0
    ans -= sum(comp)
    print(ans)

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

(d,), cc, *sstt = [list(map(int, s.split())) for s in open(0)]

ss = sstt[:d]

tt = sum(sstt[d:], [])

print(sum(ss[i][t] for (i, t) in enumerate(tt)))
Problem p02642 (python)

Fixed submission:
n = int(input())
aa = list(map(int, input().split()))

c = [0]*(10**6+1)

for a in aa:
    c[a] += 1

d = [False]*(10**6+1)

count = 0

for i in range(1, 10**6+1):
    if not c[i]:
        continue
    if d[i]:
        continue
    if c[i] == 1:
        count += 1
    for j in range(i, 10**6+1, i):
        d[j] = True

print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())

from collections import defaultdict

a = list(map(int, input().split()))

d = defaultdict(int)

for el in a:
    d[el] += 1

count = 0

d = sorted(d.items(), reverse=True)

m = max(d, key=lambda x: x[0])

while len(d):
    a, c = d.pop()
    if c == 1:
        count += 1
    if a == 1:
        break
    if a * a <= m:
        d = [elm for elm in d if elm[0] % a]

print(count)
Problem p02669 (python)

Fixed submission:
t = int(input())

import sys
sys.setrecursionlimit(10 ** 6)

def calc(x):
    if x in dp:
        return dp[x]
    
    divs = [5, 3, 2]
    costs = [c, b, a]
    res = d * x
    for div, cost in zip(divs, costs):
        dived = x//div
        res = min(res, calc(dived) + cost + abs(x-dived*div) * d)
        if x > div:
            dived = x//div+1
            res = min(res, calc(dived) + cost + abs(x-dived*div) * d)
    dp[x] = res
    return res

for _ in range(t):
    n, a, b, c, d = list(map(int, input().split()))
    dp = {}
    dp[0] = 0
    dp[1] = d
    print(calc(n))

Buggy submission (verdict: Runtime Error):
def calc(x):
    if x not in dp:
        divs = [5, 3, 2]
        costs = [c, b, a]
        values = lambda div, cost: [calc(x // div) + cost + x % div * d, calc((x + div - 1) // div) + cost + (-x) % div * d]
        dp[x] = min(x * d, *[value for div, cost in zip(divs, costs) for value in values(div, cost)])
    return dp[x]

for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    dp = {0: 0, 1: d}
    print(calc(n))

Buggy submission (verdict: Runtime Error):
import heapq
import numpy as np

t = int(input())

for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    # x to lowest coin
    cheapest = dict()
    # (coin, x)
    search = [(d, 1)]
    first = True

    while 1:
        coin, x = heapq.heappop(search)

        if (x > 1 or first) and x not in cheapest:
            first = False
            if x == n:
                print(coin)
                break
            cheapest[x] = coin

            heapq.heappush(search, (coin + a, 2 * x))
            heapq.heappush(search, (coin + b, 3 * x))
            heapq.heappush(search, (coin + c, 5 * x))
            heapq.heappush(search, (coin + d, x + 1))
            if x - 1 > 1:
                heapq.heappush(search, (coin + d, x - 1))
Problem p02683 (python)

Fixed submission:
*o, = open(0)

import numpy as np

(n, m, x), *ca = map(lambda x: np.array(list(map(int, x.split()))), o)

INF = 1 << 31

ans = INF

for i in range(2**n):
    tmp = np.zeros(m+1, int)
    sel = []
    for j, dig in enumerate(bin(i)[2:][::-1]):
        if int(dig):
            tmp += ca[j]
            sel.append(j)
    if min(tmp[1:]) >= x:
        ans = min(ans, tmp[0])
        

if ans == INF:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

n, m, x = map(int, input().split())



caa = [np.array(list(map(int, input().split()))) for _ in range(n)]



ans = 1 << 31

for i in range(2**n):
    tmp = np.zeros(4)
    for j in range(n):
        if i % (2**j):
            tmp += caa[j]
        if min(tmp[1:]) >= x:
            ans = min(ans, tmp[0])

if ans != 1<<31:
    print(int(ans))
else:
    print(-1)
Problem p02702 (python)

Fixed submission:
s = input().rstrip()
tmp = 0
pw = 1
from collections import Counter
c = Counter()
c[0] += 1

for d in s[::-1]:
    tmp += int(d) * pw
    tmp %= 2019
    pw *= 10
    pw %= 2019
    c[tmp] += 1

print(sum([v*(v-1)//2 for v in c.values() if v > 1]))

Buggy submission (verdict: Runtime Error):
cnt = 0
base = 0
MOD = 2019
s = open(0).read().rstrip()

for d in s:
    base *= 10
    base += int(d)
    tmp = base
    while tmp:
        if tmp % MOD == 0:
            cnt += 1
        tmp //= 10
print(ans)

Buggy submission (verdict: Runtime Error):
cnt = 0
base = 0
MOD = 2019
s = input()

for d in s:
    base *= 10
    base += int(d)
    tmp = base
    while tmp:
        if tmp % MOD == 0:
            cnt += 1
        tmp //= 10
print(ans)

Buggy submission (verdict: Runtime Error):
cnt = 0
base = 0
MOD = 2019

for d in input().rstrip():
    base *= 10
    base += int(d)
    tmp = base
    while tmp:
        if tmp % MOD == 0:
            cnt += 1
        tmp //= 10
print(ans)

Buggy submission (verdict: Runtime Error):
cnt = 0
base = 0
MOD = 2019

for d in input():
    base *= 10
    base += int(d)
    tmp = base
    while tmp:
        if tmp % MOD == 0:
            cnt += 1
        tmp //= 10
print(ans)

Buggy submission (verdict: Runtime Error):
cnt = 0
base = 0
MOD = 2019
# inv = pow(10,-1,MOD)

for d in input():
    base *= 10
    base += int(d)
    tmp = base
    while tmp:
        if tmp % MOD == 0:
            cnt += 1
        tmp //= 10
print(ans)
Problem p02706 (python)

Fixed submission:
m,n,*aa = map(int, open(0).read().split())
ans = m-sum(aa)
if ans<0:
  print(-1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
m,n,*aa = open(0).read().split()
ans = m-sum(aa)
if ans<0:
  print(-1)
else:
  print(ans)
Problem p02760 (python)

Fixed submission:
import numpy as np

card = np.array([list(map(int, input().split())) for i in range(3)])

n = int(input())

number = [int(input()) for i in range(n)]

hit = np.vectorize(lambda x: x in number)(card)

row = hit.all(axis=0).any()
col = hit.all(axis=1).any()

diag1 = hit[0][0] and hit[1][1] and hit[2][2]
diag2 = hit[0][2] and hit[1][1] and hit[2][0]

print('Yes' if row or col or diag1 or diag2 else 'No')

Buggy submission (verdict: Runtime Error):
import numpy as np

card = np.array([list(map(int, input().split())) for i in range(3)])

n = int(input())

number = [int(input()) for i in range(n)]

hit = np.isin(card, number)

row = hit.all(axis=0).any()
col = hit.all(axis=1).any()

diag1 = hit[0][0] and hit[1][1] and hit[2][2]
diag2 = hit[0][2] and hit[1][1] and hit[2][0]

print('yes' if row or col or diag1 or diag2 else 'no')
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())

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

def solve():
    global n, m, sc
    for i in range(1000):
        tmp = str(i)
        if len(tmp) != n:
            continue
        check = True
        for s, c in sc:
            if int(tmp[s-1]) != c:
                check = False
        if check:
            return tmp
    return -1
print(solve())

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

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



def solve():
    global n, m, sc
    ans = [None] * n
    for s, c in sc:
        if s > n:
            return -1
        if ans[s-1] is None:
            ans[s-1] = c
            continue
        if ans[s-1] != c:
            return -1
        if s+1 == n and c == 0:
            return -1
    ans = [x or 0 for x in ans]
    ans = list(map(str, ans))
    return ''.join(ans)

print(solve())

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split(' ')))
sc = [list(map(int, input().split(' '))) for i in range(M)]


ans_l = [False for i in range(N)]


dup = False
for s, c in sc:
    if (not ans_l[s-1]) or ans_l[s-1] == str(c):
        if s > N or s < 1:
            out = True
            break
        ans_l[s-1] = str(c)
    else:
        dup = True
        break

# ans_l

for ix, x in enumerate(ans_l):
    if x:
        break
    ans_l[ix] = '1'

for ix, x in enumerate(ans_l):
    if x:
        pass
    else:
        ans_l[ix] = '0'

ans_n = int(''.join(ans_l))

ans_final = ans_n
if dup or out:
    ans_final = -1
if len(str(ans_n)) != N:
    ans_final = -1

print(str(ans_final))

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split(' ')))
sc = [list(map(int, input().split(' '))) for i in range(M)]


ans_l = [0 for i in range(N)]

ans_final = 0

for s, c in sc:
    if (not ans_l[s-1]) or ans_l[s-1] == str(c):
        ans_l[s-1] = str(c)
    else:
        ans_final = -1
        break

ans_l = list(map(str, ans_l))

ans_n = 0

if not ans_final:
    ans_n = int(''.join(ans_l))

ans_final = ans_n
if len(str(ans_n)) != n:
    ans_final = -1

print(str(ans_final))
Problem p02784 (python)

Fixed submission:
a,b,*cc = map(int, open(0).read().split())

if sum(cc) >= a:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
if sum(cc) >= a:
    print('Yes')
else:
    print('No')
Problem p02814 (python)

Fixed submission:
from fractions import gcd

def lcm(*args):
    ans = 1
    for x in args:
        ans = ans * x // gcd(ans, x)
    return ans

n, m = map(int, input().split())
a = [int(x) for x in input().split()]

def log(x):
    ans = 0
    while x % 2 == 0:
        ans += 1
        x //= 2
    return ans

def solve(a):
    tmp = None
    for ta in a:
        if tmp is None:
            tmp = log(ta)
        else:
            if tmp == log(ta):
                continue
            else:
                print(0)
                return
    l = lcm(*a)
    print(m // (l//2) - m // l)

solve(a)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

def lcm(*args):
    ans = 1
    for x in args:
        ans = ans * x // gcd(ans, x)
    return ans

n, m = map(int, input().split())
a = [int(x) for x in input().split()]

def solve(a):
    tmp = None
    for ta in a:
        if tmp is None:
            tmp = log(ta)
        else:
            if tmp == log(ta):
                continue
            else:
                print(0)
                return
    l = lcm(*a)
    print(m // l - m // (2*l))

solve(a)

Buggy submission (verdict: Runtime Error):
from math import gcd

def lcm(*args):
    ans = 1
    for x in args:
        ans = ans * x // gcd(ans, x)
    return ans

n, m = map(int, input().split())

l = lcm(*(int(x) // 2 for x in input().split()))

print(m // l - m // (2*l))

Buggy submission (verdict: Runtime Error):
from math import gcd

def lcm(*args):
    ans = 1
    for x in args:
        ans = ans * x // gcd(ans, x)
    return ans

n, m = map(int, input().split())

l = lcm(*map(int, input().split()))

print(m // (l//2) - m // l)

Buggy submission (verdict: Runtime Error):
from math import gcd

def lcm(*args):
    ans = 1
    for x in args:
        ans = ans * x // gcd(ans, x)
    return ans

n, m = map(int, input().split())

l = lcm(*map(int, input().split()))

print(m // (l//2) - m // l)
Problem p02841 (python)

Fixed submission:
m1,_ = input().split()
m2,_ = input().split()

if m1==m2:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
n = int(input())

from decimal import Decimal

import sys

for i in range(60000):
    if int(Decimal(i) * Decimal('1.08')) == n:
        print(i)
        sys.exit()

print(':(')
Problem p02911 (python)

Fixed submission:
n,k,q, *aa = map(int, open(0).read().split())

scores = [k-q]*n

for a in aa:
    scores[a-1] += 1

for s in scores:
    if s<=0:
        print('No')
    else:
        print('Yes')

Buggy submission (verdict: Runtime Error):
n,k,q, *aa = map(int, open(0).read().split())

scores = [k-q]*n

for a in aa:
    scores[a] += 1

for s in scores:
    if s<=0:
        print('No')
    else:
        print('Yes')
Problem p02921 (python)

Fixed submission:
ss = input()
tt = input()

print(sum([s==t for s, t in zip(ss,tt)]))

Buggy submission (verdict: Runtime Error):
ss = input()
tt = input()

print(sum([s==t for s, t in zip(s,t)]))
Problem p02936 (python)

Fixed submission:
(n,q),*abpx = [list(map(int, s.split())) for s in open(0)]
ab,px = abpx[:n-1],abpx[n-1:]

from collections import defaultdict, deque
add = defaultdict(int)

for p,x in px:
    add[p] += x

links = defaultdict(set)

for a,b in ab:
    links[a].add(b)
    links[b].add(a)

passed = set()

dq = deque()
dq.append((0,1))

ans = {}

while dq:
    to_add, cur = dq.popleft()
    tmp = to_add + add[cur]
    ans[cur] = tmp
    for nx in links[cur]:
        links[nx].remove(cur)
        dq.append((tmp, nx))

print(*(ans[i] for i in range(1,n+1)))

Buggy submission (verdict: Runtime Error):
class Node:
    def __init__(self):
        self.num = None
        self.parent = None
        self.children = list()
        self.added = 0
        self.count = None
    def __repr__(self):
        return f'Node({self.num})'
    def calc_count(self):
        if self.num==1:
            self.count = self.added
            return
        if self.parent.count is None:
            self.parent.calc_count()
        self.count = self.parent.count + self.added

(n,q),*abpx = [list(map(int, s.split())) for s in open(0)]

ab,px = abpx[:n-1],abpx[n-1:]

from collections import defaultdict,deque
d = defaultdict(Node)

for a,b in ab:
    d[a].num = a
    d[b].num = b
    d[b].parent = d[a]
    d[a].children.append(d[b])

for p,x in px:
    d[p].added += x

dq = deque([d[1]])

while dq:
    cur = dq.popleft()
    if cur.children:
        dq.extend(cur.children)
    cur.calc_count()

print(*list(d[i].count for i in range(1,n+1)))
Problem p03006 (python)

Fixed submission:
(n,),*xy = [list(map(int, s.split())) for s in open(0)]

from collections import Counter
from itertools import combinations
from sys import exit

if n == 1:
    print(1)
    exit()

c = Counter()

for (xa,ya),(xb,yb) in combinations(xy,2):
    c[(xa-xb, ya-yb)] += 1
    c[(xb-xa, yb-ya)] += 1

print(n - max(c.values()))

Buggy submission (verdict: Runtime Error):
(n,),*xy = [list(map(int, s.split())) for s in open(0)]

from collections import Counter
from itertools import combinations
c = Counter()
for (xa,ya),(xb,yb) in combinations(xy,2):
    c[(xa-xb, ya-yb)] += 1
    c[(xb-xa, yb-ya)] += 1

print(n - max(c.values()))