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

Fixed submission:
import sys
import math
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
D,T,S=MAP()
if T*S>=D:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i % 2
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k
    if n > 1:return {n} 
    return set(ret)
def main():
    n=int(input())
    a=list(map(int,input().split()))
    g=a[0]
    for i in a[1:]:g=gcd(g,i)
    if g!=1:
        print("not coprime")
        exit()
    ans=0
    s=set()
    for i in a:
        p=primeFactor(i)
        ans+=len(p)
        s|=p
    if ans!=len(s):print("setwise coprime")
    else:print("pairwise coprime")
if __name__ == "__main__":
    main()
Problem p02580 (python)

Fixed submission:
import collections
import sys
import math
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
H,W,M=map(int,input().split())
A=list()
B=list()
for i in range(M):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
c = collections.Counter(A)
s=c.most_common()
k=s[0][0]
t=s[0][1]
L=list()
for i in range(M):
  if A[i]!=k:
    L.append(B[i])
c = collections.Counter(L)
s=c.most_common()
if len(s)!=0:
  ans=s[0][1]+t
else:
  ans=t
c = collections.Counter(B)
s=c.most_common()
k=s[0][0]
t=s[0][1]
L=list()
for i in range(M):
  if B[i]!=k:
    L.append(A[i])
c = collections.Counter(L)
s=c.most_common()
if len(s)!=0:
  q=s[0][1]+t
else:
  q=t
ans=max(ans,q)
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
import sys
import math
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
H,W,M=map(int,input().split())
A=list()
B=list()
for i in range(M):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
c = collections.Counter(A)
s=c.most_common()
k=s[0][0]
t=s[0][1]
L=list()
for i in range(M):
  if A[i]!=k:
    L.append(B[i])
c = collections.Counter(L)
s=c.most_common()
ans=s[0][1]+t

c = collections.Counter(B)
s=c.most_common()
k=s[0][0]
t=s[0][1]
L=list()
for i in range(M):
  if B[i]!=k:
    L.append(A[i])
c = collections.Counter(L)
s=c.most_common()
ans=max(ans,s[0][1]+t)
print(ans)
Problem p02598 (python)

Fixed submission:
def waru(a,b):
  if a%b==0:
    return a//b
  else:
    return (a//b)+1
N,K=map(int,input().split())
A=list(map(int,input().split()))
ue=sum(A)
sita=1
for i in range(50):
  n=(ue+sita)//2
  L=[waru(i,n)-1 for i in A]
  if sum(L)>K:
    sita=n
  else:
    ue=n
  if ue==sita:
    print(ue)
    exit()
  elif ue-sita==1:
    n=sita
    L=[waru(i,n)-1 for i in A]
    if sum(L)>K:
      print(n+1)
      exit()
    else:
      print(n)
      exit()

Buggy submission (verdict: Runtime Error):
def waru(a,b):
  if a%b==0:
    return a//b
  else:
    return (a//b)+1
N,K=map(int,input().split())
A=list(map(int,input().split()))
ue=sum(A)
sita=0
for i in range(40):
  n=(ue+sita)//2
  L=[waru(i,n)-1 for i in A]
  if sum(L)>K:
    sita=n
  else:
    ue=n
  if ue==sita:
    print(ue)
    exit()
  elif ue-sita==1:
    n=sita
    L=[waru(i,n)-1 for i in A]
    if sum(L)>K:
      print(n+1)
      exit()
    else:
      print(n)
      exit()
Problem p02659 (python)

Fixed submission:
import math
a,b=input().split()
a=int(a)
L=list(b)
if "." in L and L[0]==0:
  c=L[2]+L[3]
  c=int(c)
  print(c*a//100)
elif  "." in L and L[0]!=0:
  c=L[0]+L[2]+L[3]
  c=int(c)
  print(c*a//100)

Buggy submission (verdict: Runtime Error):
A=int(A)
B=list(B)
N=B[0]+B[2]+B[3]
N=int(N)
C=int(A*N//100)
print(C)
Problem p02688 (python)

Fixed submission:
A,B=map(int,input().split())
R=list(range(1,A+1))
for i in range(2*B):
  L=list(map(int,input().split()))
  if i%2==1:
    for j in range(len(L)):
      if L[j] in R:
        R.pop(R.index(L[j]))
  if R==list():
    break
print(len(R))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
ans=list()
for i in range(K):
  D=int(input())
  L=list(map(int,input(),split()))
  ans+=L
  ans=list(set(ans))
print(N-len(ans))
Problem p02693 (python)

Fixed submission:
import sys
N=int(input())
a,b=map(int,input().split())
for i in range(a,b+1):
  if i%N==0:
    print("OK")
    sys.exit()
print("NG")

Buggy submission (verdict: Runtime Error):
M,A,B=(int(x) for x in input().split())
if B//M-A//M>=1:
  print("OK")
elif A%M=0:
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
M,A,B=(int(x) for x in input().split())
if B//M-A//M>=1:
  print("OK")
elif A%M=0:
  print("OK")
else:
  print("NO")
Problem p02729 (python)

Fixed submission:
N,M=map(int,input().split())
print((N*(N-1)+M*(M-1))//2)

Buggy submission (verdict: Runtime Error):
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N,M=map(int,input().split())
if N==0:
  a=0
else:
  a = comb(N,2)
if M==0:
  b=0
else:
  b = comb(M,2)
print(a+b)
Problem p02781 (python)

Fixed submission:
n=int(input())
k=int(input())
def main(N,K):
  ans=0
  if N<=100+10**6:
    for i in range(1,N+1):
      a=str(i)
      if len(a)-list(a).count("0")==K:
        ans+=1
    return ans
  L=list(map(int,list(str(N))))
  ans=0
  L=list(map(int,list(str(N))))
  if K==1:#おけ
    return (len(str(N))-1)*9+int(str(N)[0])
  elif K==2:#おけ
    for i in range(len(L)-1):
      ans+=(9*(int(str(N)[0])-1))
      for j in range(i+1,len(L)):
        if i==0:
          if j==1:
            ans+=int(str(N)[1])
          else:
            ans+=9
        else:
          ans+=81
    return ans
  else:
    le=len(L)
    for i in range(le-2):
      for j in range(i+1,le-1):
        for k in range(j+1,le):
          if i==0:
            ans+=81*(int(str(N)[0])-1)
            if j==1:
              ans+=9*(int(str(N)[1])-1)
              if k==2:
                ans+=int(str(N)[2])
              else:
                ans+=9
            else:
              ans+=81
          else:
            ans+=729
    return ans
ans2=0
L=list(str(n))
a=len(L)
for i in range(a):
  L=list(str(n))
  s=L[:a-i-1]
  t=L[a-i-1:]
  t=int("".join(t))
  p=s.count("0")
  p=len(s)-p
  if p>k:
    n-=t+1
  elif p==k:
    n-=t+1
    ans2+=1
  else:
    ans2+=main(t,k-p)
    n-=t+1
print(ans2)

Buggy submission (verdict: Runtime Error):
N=int(input())
K=int(input())
if N<=10**6:
  ans=0
  for i in range(1,N+1):
    a=str(i)
    if len(a)-list(a).count("0")==K:
      ans+=1
  print(ans)
  exit()
L=list(map(int,list(str(N))))
ans=0
L=list(map(int,list(str(N))))
for i in range(N,N+1001):
  L=list(map(int,list(str(i))))
  s=L[:3]
  if s[0]!=0 and s[1]!=0 and s[2]!=0:
    go=i
    break
for i in range(N+1,go+1):
  a=str(i)
  if len(a)-list(a).count("0")==K:
    ans-=1
if K==1:#おけ
  print((len(str(N))-1)*9+int(str(N)[0]))
elif K==2:#おけ
  N=go
  for i in range(len(L)-1):
    ans+=(9*(int(str(N)[0])-1))
    for j in range(i+1,len(L)):
      if i==0:
        if j==1:
          ans+=int(str(N)[1])
        else:
          ans+=9
      else:
        ans+=81
  print(ans)
else:
  N=go
  le=len(L)
  for i in range(le-2):
    for j in range(i+1,le-1):
      for k in range(j+1,le):
        if i==0:
          ans+=81*(int(str(N)[0])-1)
          if j==1:
            ans+=9*(int(str(N)[1])-1)
            if k==2:
              ans+=int(str(N)[2])
            else:
              ans+=9
          else:
            ans+=81
        else:
          ans+=729
  print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
K=int(input())
if N<=10**6:
  ans=0
  for i in range(1,N+1):
    a=str(i)
    if len(a)-list(a).count("0")==K:
      ans+=1
  print(ans)
  exit()
if K==1:#おけ
  ans=0
  print((len(str(N))-1)*9+int(str(N)[0]))
elif K==2:#おけ
  ans=0
  L=list(map(int,list(str(N))))
  for i in range(len(L)-1):
    ans+=(9*(int(str(N)[0])-1))
    for j in range(i+1,len(L)):
      if i==0:
        if j==1:
          ans+=int(str(N)[1])
        else:
          ans+=9
      else:
        ans+=81
  print(ans)
else:
  qwq
Problem p02831 (python)

Fixed submission:
import fractions
a,b=map(int,input().split())
print((a * b) // fractions.gcd(a, b))

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print((a * b) // math.gcd(a, b))

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

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
import math
print(math.gcd(a, b))
Problem p02835 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a+b+c<=21:
  print("win")
else:
  print("bust")

Buggy submission (verdict: Runtime Error):
a,b,c=int(input())
if a+b+c<=21:
  print("win")
else:
  print("bust")
Problem p02851 (python)

Fixed submission:
N,K=map(int,input().split())
L=list(map(int,input().split()))
R=list()
if K>=N:
  sums=0
  c=dict()
  for i in range(N):
    sums+=L[i]
    sums%=K
    a=(sums-i-1)%K
    if a in c:
      c[a]+=1
    else:
      c[a]=1
  ans=0
  for i in c:
    ans+=(c[i]-1)*c[i]//2
  if 0 in c:
    print(ans+c[0])
  else:
    print(ans)
else:
  ans=0
  c=[0]*K
  sums=0
  for i in range(N):
    sums+=L[i]
    sums%=K
    a=(sums-i-1)%K
    R.append(a)
  for i in range(K-1):
    c[R[i]]+=1
  ans+=c[0]
  c[R[K-1]]+=1
  for i in range(N):
    if i<N-K:
      ans+=c[R[i]]-1
      c[R[i]]-=1
      c[R[i+K]]+=1
    else:
      ans+=c[R[i]]-1
      c[R[i]]-=1
  print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
L=list(map(int,input().split()))
R=list()
if K>=N:
  sums=0
  c=[0]*K
  for i in range(N):
    sums+=L[i]
    sums%=K
    a=(sums-i-1)%K
    R.append(a)
    c[a]+=1
  ans=0
  for i in range(N):
    ans+=(c[i]-1)*c[i]//2
  print(ans+c[0])
else:
  ans=0
  c=[0]*K
  sums=0
  for i in range(N):
    sums+=L[i]
    sums%=K
    a=(sums-i-1)%K
    R.append(a)
  for i in range(K-1):
    c[R[i]]+=1
  ans+=c[0]
  c[R[K-1]]+=1
  for i in range(N):
    if i<N-K:
      ans+=c[R[i]]-1
      c[R[i]]-=1
      c[R[i+K]]+=1
    else:
      ans+=c[R[i]]-1
      c[R[i]]-=1
  print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
L=list(map(int,input().split()))
R=list()
if K>=N:
  sums=0
  c=[0]*K
  for i in range(N):
    sums+=L[i]
    sums%=K
    a=(sums-i-1)%K
    R.append(a)
    c[a]+=1
  ans=0
  for i in range(N):
    s=(K-R[i])%K
    if s!=0:
      ans+=c[s]
    else:
      ans+=c[s]-1
  print((ans//2)+c[0])
else:
  ans=0
  c=[0]*K
  sums=0
  for i in range(N):
    sums+=L[i]
    sums%=K
    a=(sums-i-1)%K
    R.append(a)
  for i in range(K-1):
    c[R[i]]+=1
  ans+=c[0]
  c[R[K-1]]+=1
  for i in range(N):
    if i<N-K:
      ans+=c[R[i]]-1
      c[R[i]]-=1
      c[R[i+K]]+=1
    else:
      ans+=c[R[i]]-1
      c[R[i]]-=1
  print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
L=list(map(int,input().split()))
R=list()
if K>=N:
  sums=0
  for i in range(N):
    sums+=L[i]
    sums%=K
    a=(sums-i-1)%K
    R.append(a)
    c[a]+=1
  ans=0
  c=[0]*K
  for i in range(N):
    s=(K-R[i])%K
    ans+=c[s]
  print(ans)
else:
  ans=0
  c=[0]*K
  sums=0
  for i in range(N):
    sums+=L[i]
    sums%=K
    a=(sums-i-1)%K
    R.append(a)
  for i in range(K-1):
    c[R[i]]+=1
  ans+=c[0]
  c[R[K-1]]+=1
  for i in range(N):
    if i<N-K:
      ans+=c[R[i]]-1
      c[R[i]]-=1
      c[R[i+K]]+=1
    else:
      ans+=c[R[i]]-1
      c[R[i]]-=1
  print(ans)
Problem p03013 (python)

Fixed submission:
N,M=map(int,input().split())
L=[0]*N
c={}
mod=1000000007
for i in range(M):
  k=int(input())
  c[k]=0
for i in range(N):
  if i==0:
    L[i]=1
  elif i==1:
    if L[0]==0:
      L[i]=1
    else:
      L[i]=2
  else:
    L[i]=(L[i-1]+L[i-2])%mod
  if i+1 in c:
    L[i]=0
print(L[N-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import math
def fibnatch(n):
  if n==0:
    return 1
  a=(pow(((1+math.sqrt(5))/2),n)-pow(((1-math.sqrt(5))/2),n))/math.sqrt(5)
  c=int(a)
  if n==1:
    return 1
  elif abs(c-a)>=abs(c-a+1):
    return (c+1)%1000000007
  else:
    return c%1000000007
L=list()
N,M=map(int,input().split())
a=1
for i in range(M):
  c=int(input())
  if i==0:
    L.append(c-a)
  else:
    L.append(c-a-1)
  a=c
if 0 in L[1:]:
  print(0)
  sys.exit()
L.append(N-c)
s=1
for i in range(len(L)):
  d=L[i]
  s=(s*fibnatch(d))%1000000007
print(s)
Problem p03107 (python)

Fixed submission:
S=input()
a=S.count("1")
b=S.count("0")
print(min(a,b)*2)

Buggy submission (verdict: Runtime Error):
import sys
i=0
L=list(input())
N=len(L)
if N==1:
  print(0)
  sys.exit()
for j in range(N):
  i=0
  while True:
    if L[i]!=L[i+1]:
      L.pop(i)
      L.pop(i)
      if L==[]:
        sys.exit()
    i+=1
    if i>len(L)-2:
      break
print(N-len(L))
Problem p03242 (python)

Fixed submission:
L=[0]*3
N=input()
for i in range(3):
  if N[i]=="1":
    L[i]=9
  else:
    L[i]=1
print((L[0]*100)+(L[1]*10)+L[2])

Buggy submission (verdict: Runtime Error):
N=input()
for i in range(3):
  if N[i]=="1":
    N[i]=9
  else:
    N[i]=1
Problem p02624 (python)

Fixed submission:
n = int(input())
print(sum(n//i * (n//i+1) // 2 * i for i in range(1, n+1)))

Buggy submission (verdict: Runtime Error):
n = int(input())
print(sum(n/i * (n/i+1) / 2 * i for i in range(1, n+1))
Problem p02836 (python)

Fixed submission:
S = input()
n = len(S)
count = 0
for i in range(n // 2):
    if S[i] != S[n - 1 - i]:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
S = intput()
n = len(S)
count = 0
for i in range(n // 2):
    if S[i] != S[n - 1 - i]:
        count += 1
print(count)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
a = [True] * (N + 1)
for _ in range(M):
    a[int(input())] = False

arr = [0] * (N + 1)
arr[1] = 1 if a[1] else 0
if 2 <= N:
    arr[2] = arr[1] + 1 if a[2] else 0
    for i in range(3, N + 1):
        arr[i] = arr[i - 2] + arr[i - 1] if a[i] else 0

print(arr[N] % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [True] * (N + 1)
for _ in range(M):
    a[int(input())] = False


arr = [0] * (N + 1)
arr[1] = 1 if a[1] else 0
arr[2] = arr[1] + 1 if a[2] else 0

for i in range(3, N + 1):
    arr[i] = arr[i - 2] + arr[i - 1] if a[i] else 0

print(arr[N] % 1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [True] * N
for _ in range(M):
    a[int(input())] = False


memo = {}

def find(n):
    if n == 0:
        return 1
    if n == 1:
        return 1
    if n in memo:
        return memo[n]
    memo[n] = (find(n - 1) if a[n - 1] else 0) + (find(n - 2) if a[n - 2] else 0)
    return memo[n]


print(find(N) % 1000000007)
Problem p03107 (python)

Fixed submission:
S = input()

xs = [S[0]]
for c in S[1:]:
    if xs and xs[-1] != c:
        xs.pop()
    else:
        xs.append(c)
print(len(S) - len(xs))

Buggy submission (verdict: Runtime Error):
import re

S = input()
xs = list(S)

i, j = 0, 1
while j < len(xs):
    if xs[i] != xs[j]:
        xs[i:j + 1] = []
        i -= 1
        j = i + 1
    else:
        i += 1
        j += 1
print(len(S) - len(xs))
Problem p03108 (python)

Fixed submission:
import io
import sys

lines = sys.stdin.read().splitlines()[::-1]


def readline():
    return lines.pop()


N, M = map(int, readline().split())
A = []
B = []
for _ in range(M):
    a, b = map(int, readline().split())
    A.append(a - 1)
    B.append(b - 1)

uf = [-1] * N
values = []
for i in range(M - 1, -1, -1):
    a = A[i]
    b = B[i]

    cur = a
    while 0 <= uf[cur]:
        cur = uf[cur]
    num_a = -uf[cur]
    root_a = cur
    cur = a
    while 0 <= uf[cur]:
        nxt = uf[cur]
        uf[cur] = root_a
        cur = nxt

    cur = b
    while 0 <= uf[cur]:
        cur = uf[cur]
    num_b = -uf[cur]
    root_b = cur
    cur = b
    while 0 <= uf[cur]:
        nxt = uf[cur]
        uf[cur] = root_b
        cur = nxt

    if root_a != root_b:
        values.append(num_a * num_b)

        if num_a < num_b:
            uf[root_b] += uf[root_a]
            cur = uf[root_a]
            uf[root_a] = root_b
            while 0 <= cur and 0 <= uf[cur]:
                nxt = uf[cur]
                uf[cur] = root_b
                cur = nxt
        else:
            uf[root_a] += uf[root_b]
            cur = uf[root_b]
            uf[root_b] = root_a
            while 0 <= cur and 0 <= uf[cur]:
                nxt = uf[cur]
                uf[cur] = root_a
                cur = nxt
    else:
        values.append(0)

total = 0
out = io.StringIO()
for v in reversed(values):
    total += v
    print(total, file=out)
print(out.getvalue())

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = []
B = []
for _ in range(M):
    a, b = map(int, input().split())
    A.append(a - 1)
    B.append(b - 1)

uf = [-1] * N
values = []
for i in range(M - 1, -1, -1):
    a = A[i]
    b = B[i]

    root_a = a if uf[a] < 0 else uf[a]
    root_b = b if uf[b] < 0 else uf[b]

    cur_a = root_a
    while 0 <= uf[cur_a]:
        cur_a = uf[cur_a]
    num_a = -uf[cur_a]

    cur_b = root_b
    while 0 <= uf[cur_b]:
        cur_b = uf[cur_b]
    num_b = -uf[cur_b]

    if root_a != root_b and 1 <= num_a and 1 <= num_b and cur_a != cur_b:
        values.append(num_a * num_b)

        uf[root_b] += uf[root_a]
        cur = uf[root_a]
        uf[root_a] = root_b
        while 0 <= cur and 0 <= uf[cur]:
            nxt = uf[cur]
            uf[cur] = root_b
            cur = nxt
    else:
        values.append(0)

total = 0
for v in reversed(values):
    total += v
    print(total)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = []
B = []
for _ in range(M):
    a, b = map(int, input().split())
    A.append(a - 1)
    B.append(b - 1)

uf = [-1] * N
values = []
for i in range(M - 1, -1, -1):
    a = A[i]
    b = B[i]

    root_a = a if uf[a] < 0 else uf[a]
    root_b = b if uf[b] < 0 else uf[b]
    num_a = -uf[root_a]
    num_b = -uf[root_b]

    if root_a != root_b:
        values.append(num_a * num_b)
    else:
        values.append(0)

    if num_a < num_b:
        uf[root_b] += uf[root_a]
        uf[root_a] = root_b
    else:
        uf[root_a] += uf[root_b]
        uf[root_b] = root_a

total = 0
for v in reversed(values):
    total += v
    print(total)
Problem p03250 (python)

Fixed submission:
A, B, C = map(int, input().split())
m = max(A, B, C)
print(m * 9 + sum((A, B, C)))

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
m = max(A, B, C)
print(m * 9 + sum(A, B, C))
Problem p02757 (python)

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

mod = p
l = 100

M = [1]  # i!のmod
m = 1
for i in range(1, l):
    m = (m * i) % mod
    M.append(m)

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

def inv(x, mod):  # x の mod での逆元を返す関数
    return pow(x, mod-2, mod)

T = [1]
for i in range(n-1):
    T.append((T[-1]*10) % p)

P = [0] * p
P[0] = 1

ans = 0
v = 0
S = [int(s[i]) for i in range(n-1,-1,-1)]

if p==2 or p==5:
    for i in range(n):
        ans += (int(s[i]) % p == 0) * (i+1)
else:
    for i in range(n):
        v = (v + T[i]*S[i]) % p
        ans += P[v]
        P[v] += 1
        # print(P)

print(ans)

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

mod = p
l = 100

M = [1]  # i!のmod
m = 1
for i in range(1, l):
    m = (m * i) % mod
    M.append(m)

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

def inv(x, mod):  # x の mod での逆元を返す関数
    return pow(x, mod-2, mod)


P = [0] * p

T = [1]
for i in range(n-1):
    T.append((T[-1] * 10) % p)

# a = 0
# for i in range(n):
#     a = (a * 10 + int(s[i]))
#     a = a%p
#     P[a] += 1

ans = 0
u = 0
v = 0
s = list(s)
for i in range(n):
    s[i] = int(s[i])
# for i in range(n):
#     print(u,P[(p-u)%p])
#     ans += P[(p-u)%p]
#     u = (u-int(s[n-1-i])) % p
#     u = u * inv(10%p, mod) % p
# print(s)
for i in range(n):
    v = (u * 10 + s[i]) % p
    P[v] += 1
    # qq = s[i-1] if i > 0 else 0
    ans += P[(p-v*s[i])%p]
    # print(ans)
    u = v
s -= 1
if s[-1] == 0:
    s += 1

print(ans)
Problem p02851 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n, k = map(int,input().split())
A = list(map(int,input().split()))

S = [A[0] % k]
for i in range(1, n):
    S.append((A[i]+S[-1]) % k)

# print(S)

D = {}
S = [0] + S
ans = 0
for i in range(len(S)):
    key = (S[i] - i) % k

    if i >= k:
        j = i-k
        key1 = (S[j] - j) % k
        D[key1] -= 1
        try:
            ans += D[key1]
            # print(i, j, D[key1])
        except:
            ans += 0

    try:
        D[key] += 1
    except:
        D[key] = 1

for j in range(max(0, len(S)-k), len(S)):
    key1 = (S[j] - j) % k
    D[key1] -= 1
    try:
        ans += D[key1]
        # print(i, j, D[key1])
    except:
        ans += 0
# print(D)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n, k = map(int,input().split())
A = list(map(int,input().split()))

S = [A[0] % k]
for i in range(1, n):
    S.append((A[i]+S[-1]) % k)

# print(S)

D = {}
S = [0] + S
ans = 0
for i in range(len(S)):
    key = (S[i] - i) % k

    
    if i >= k:
        j = i-k
        key1 = (S[j] - j) % k
        D[key1] -= 1
        try:
            ans += D[key1]
            # print(i, j, D[key1])
        except:
            ans += 0

    try:
        D[key] += 1
    except:
        D[key] = 1

for j in range(len(S)-k, len(S)):
    key1 = (S[j] - j) % k
    D[key1] -= 1
    try:
        ans += D[key1]
        # print(i, j, D[key1])
    except:
        ans += 0
# print(D)
print(ans)