<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts on Code Now</title><link>https://blog.0xnullpath.cc/en/posts/</link><description>Recent content in Posts on Code Now</description><generator>Hugo</generator><language>en</language><lastBuildDate>Thu, 01 Oct 2026 20:30:00 +0800</lastBuildDate><atom:link href="https://blog.0xnullpath.cc/en/posts/index.xml" rel="self" type="application/rss+xml"/><item><title>DeepSeek's Attention Evolution - [DSA, CSA, CSA2]</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-21-deepseeks-attention-evolution-dsa-csa-csa2/</link><pubDate>Thu, 01 Oct 2026 20:30:00 +0800</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-21-deepseeks-attention-evolution-dsa-csa-csa2/</guid><description>&lt;div class="markdown-alert markdown-alert-note">
 &lt;p class="markdown-alert-title">
 &lt;span class="markdown-alert-kind">Note&lt;/span>
 &lt;span class="markdown-alert-num">&lt;/span>
 &lt;span class="markdown-alert-sep">|&lt;/span>
 &lt;span class="markdown-alert-text">Preface&lt;/span>
 &lt;/p>
 &lt;div class="markdown-alert-body">
 &lt;p>This is the second post in the DeepSeek Attention evolution series. The previous one, &lt;a href="https://blog.0xnullpath.cc/posts/note-snippet-20-deepseek-%E7%9A%84-attention%E6%BC%94%E8%BF%9B-mla/">DeepSeek&amp;rsquo;s Attention Evolution -【MLA】&lt;/a>, covered the evolution from MHA to MLA; this post picks up with DSA, CSA and CSA2. MLA solved the storage form of the KVCache, but its compute complexity is still $O(N^2)$ and the KVCache is still $O(N)$, so it still struggles with 256K/1M long contexts. This post follows the DeepSeek V3.2-exp → V4 → V4.1-Flash line to see how it pushes the algorithmic and engineering tradeoffs to the limit, step by step, across sparse attention, KV compression and cross-layer sharing.&lt;/p></description></item><item><title>DeepSeek's attention evolution - [MLA]</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-20-deepseeks-attention-evolution-mla/</link><pubDate>Tue, 15 Sep 2026 23:30:00 +0800</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-20-deepseeks-attention-evolution-mla/</guid><description>&lt;blockquote>
 &lt;p>Foreword: After reading the DeepSeekV4.1 paper and seeing that DeepSeek had once again made major changes to the model architecture, I was quite excited. So I looked back at DeepSeek&amp;rsquo;s incremental improvements to the model architecture and wrote this series of articles in the gaps while waiting for agents to finish running and slacking off at work — a summary of what I&amp;rsquo;ve learned about model architectures over the year since I moved into AI Infra.&lt;/p></description></item><item><title>[Model Inference] A Brief Look at CUDA Graph</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-15-model-inference-a-brief-look-at-cuda-graph/</link><pubDate>Mon, 20 Apr 2026 04:27:43 +0000</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-15-model-inference-a-brief-look-at-cuda-graph/</guid><description>&lt;p>CUDA Graph is probably one of the most frequently mentioned features in inference optimization. The principle isn&amp;rsquo;t complicated: package the kernels that were originally launched one at a time into a static graph, hand the whole thing to the GPU in one shot, and skip the scheduling overhead in between.&lt;/p>
&lt;p>But how exactly does this &amp;ldquo;packaging&amp;rdquo; work? How do you use it in PyTorch? And most importantly — how much faster is it actually on an H200?&lt;/p></description></item><item><title>How to make Hugo support infographic</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-13-how-to-make-hugo-support-infographic/</link><pubDate>Tue, 06 Jan 2026 03:33:16 +0000</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-13-how-to-make-hugo-support-infographic/</guid><description>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>&lt;code>infographic&lt;/code> is a new component from Ant Group&amp;rsquo;s AntV team. Its goal is to provide easier-to-use visualization tools for AI, positioned similarly to mermaid. It offers a DSL that is easy for developers and AI to use: by quickly writing DSL, you can rapidly visualize all kinds of charts, such as line charts and pie charts, and you can also visualize tools like grid diagrams and SWOT diagrams that are typically needed in PPTs. It is very easy to use. So I wanted to bring it into my Hugo blog, and be able to quickly visualize my ideas through &lt;code>infographic&lt;/code> in a markdown code block.&lt;/p></description></item><item><title>LLM Life from Scratch: How to Write an Agent</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-9-llm-life-from-scratch-how-to-write-an-agent/</link><pubDate>Tue, 27 May 2025 16:04:10 +0000</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-9-llm-life-from-scratch-how-to-write-an-agent/</guid><description>&lt;blockquote>
 &lt;p>This article aims to explain what an LLM Agent is in plain language and to implement a simple Agent in Python.&lt;/p>
&lt;/blockquote>&lt;h2 id="1-introduction-to-agents">1. Introduction to Agents&lt;/h2>
&lt;h3 id="11-what-is-an-agent">1.1 What Is an Agent?&lt;/h3>
&lt;p>There is no precise definition of an LLM Agent, but one core characteristic stands out:&lt;/p>
&lt;blockquote>
 &lt;p>An LLM serves as the main controller or &amp;ldquo;brain&amp;rdquo; that controls a flow of operations needed to complete a task or user request. &amp;mdash;《Prompt Engineering Guide》&lt;/p></description></item><item><title>LLM Agent Programming from Scratch: The MCP Edition</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-5-llm-agent-programming-from-scratch-the-mcp-edition/</link><pubDate>Mon, 21 Apr 2025 08:23:57 +0000</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-5-llm-agent-programming-from-scratch-the-mcp-edition/</guid><description>&lt;h2 id="1-what-is-mcp-model-context-protocol">1. What Is MCP (Model Context Protocol)&lt;/h2>
&lt;p>MCP (Model Context Protocol) is a communication protocol launched and open-sourced by Anthropic in 2024, designed to solve the connection problem between large language models (LLMs) and external data sources and tools. It defines the protocol for communication between the Model and external interfaces/data/Prompts. Tool/resource providers only need to implement the MCP protocol to connect with an LLM APP that implements an MCP client. During runtime, the LLM APP automatically retrieves the tool list/Prompt/resource list returned by the protocol from the MCP server via JsonRpc.&lt;/p></description></item><item><title>Data System Design Explained to My Wife: ACID Transactions</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-3-data-system-design-explained-to-my-wife-acid-transactions/</link><pubDate>Sun, 09 Mar 2025 16:16:44 +0000</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-3-data-system-design-explained-to-my-wife-acid-transactions/</guid><description>&lt;h2 id="why-transactions-exist">Why transactions exist&lt;/h2>
&lt;blockquote>
 &lt;p>&amp;ldquo;In the harsh reality of data systems, many things can go wrong:&lt;/p>
&lt;ol>
&lt;li>The database software or hardware may fail at any moment (including in the middle of a write operation).&lt;/li>
&lt;li>The application may crash at any moment (including in the middle of a series of operations).&lt;/li>
&lt;li>Network interruptions may unexpectedly cut the connection between the database and the application, or between databases.&lt;/li>
&lt;li>Multiple clients may write to the database at the same time, overwriting each other&amp;rsquo;s changes.&lt;/li>
&lt;li>A client may read nonsensical data because the data was only partially updated.&lt;/li>
&lt;li>Race conditions between clients may cause surprising errors.&amp;rdquo;
&amp;mdash; &lt;em>Designing Data-Intensive Applications&lt;/em>&lt;/li>
&lt;/ol>
&lt;/blockquote>&lt;p>In concurrent programming, we often care about the correctness of multiple threads/processes/coroutines modifying the same block of memory, and we solve this with atomic variables and locks to implement critical sections. In real life and in development, however, it&amp;rsquo;s more often the case that an actor completes a task through a series of operations, and here too we want something like an atomic variable to protect that series of operations, preventing unexpected situations when multiple actors operate at once.&lt;/p></description></item><item><title>EM Algorithm Notes</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-16-em-algorithm-notes/</link><pubDate>Tue, 14 Apr 2020 17:57:00 +0000</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-16-em-algorithm-notes/</guid><description>&lt;blockquote>
 &lt;p>I recently ran into the EM algorithm again. Too often I just use something without knowing why, so this time, before using it, I went back and read up on it some more.&lt;/p>
&lt;/blockquote>&lt;p>Where the EM algorithm applies: maximum likelihood estimation of the parameters of a probabilistic model that has hidden variables.&lt;/p>
&lt;p>First question: what is a hidden variable?&lt;/p>
&lt;h2 id="latent-variables">Latent Variables&lt;/h2>
&lt;blockquote>
 &lt;p>Something that cannot be directly observed, but that influences the state of the system and the outputs that can be observed. It refers to an unobservable random variable. Latent variables can be inferred from observed data by using a mathematical model.&lt;/p></description></item><item><title>Python Basics: Decorators</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-17-python-basics-decorators/</link><pubDate>Fri, 20 Mar 2020 16:54:00 +0000</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-17-python-basics-decorators/</guid><description>&lt;p>A decorator is a callable object whose argument is another function (the decorated function). The decorator may process the decorated function and then return it, or replace it with another function or callable object.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-python" data-lang="python">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1&lt;/span>&lt;span>&lt;span style="color:#a6e22e">@test&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2&lt;/span>&lt;span>&lt;span style="color:#66d9ef">def&lt;/span> &lt;span style="color:#a6e22e">target&lt;/span>():
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3&lt;/span>&lt;span> print(&lt;span style="color:#e6db74">&amp;#34;run target function!&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>It works the same as the following code&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-python" data-lang="python">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1&lt;/span>&lt;span>&lt;span style="color:#66d9ef">def&lt;/span> &lt;span style="color:#a6e22e">target&lt;/span>():
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2&lt;/span>&lt;span> print(&lt;span style="color:#e6db74">&amp;#34;run target function!&amp;#34;&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3&lt;/span>&lt;span>target &lt;span style="color:#f92672">=&lt;/span> test(target) &lt;span style="color:#75715e"># In the test function, the function will be enhanced or replaced&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Function decorators run at import time, while the decorated function only runs when it is explicitly called.&lt;/p></description></item><item><title>[Python Basics] Namespaces, Scope, and Closures</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-18-python-basics-namespaces-scope-and-closures/</link><pubDate>Fri, 20 Mar 2020 16:53:00 +0000</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-18-python-basics-namespaces-scope-and-closures/</guid><description>&lt;blockquote>
 &lt;p>A namespace is a &lt;strong>mapping&lt;/strong> from names to objects. Most namespaces are currently implemented as Python dictionaries, but that&amp;rsquo;s normally not noticeable in any way (except for performance), and it may change in the future.&lt;/p>
&lt;/blockquote>&lt;p>Namespaces are an important structure for avoiding name collisions. Namespaces are dynamic: they come into being as the interpreter executes, and they are maintained throughout the life of the program.&lt;/p>
&lt;p>Namespaces:&lt;/p>
&lt;ul>
&lt;li>Built-in namespace: the namespace that comes with the Python interpreter as soon as it starts, and stops when the Python interpreter ends.&lt;/li>
&lt;li>Global namespace: the set of global names of a Python module — names defined directly in the module, such as classes, functions, other imported modules, and so on. Destroyed when the interpreter exits.&lt;/li>
&lt;li>Local namespace: the namespace inside a function or a class. It is created when a function is called, and deleted when the function returns or raises an error that is not handled inside the function.&lt;/li>
&lt;li>The attribute namespace of an object&lt;/li>
&lt;li>Class namespace&lt;/li>
&lt;/ul>
&lt;h1 id="scope">Scope&lt;/h1>
&lt;p>A &lt;em>scope&lt;/em> is a &lt;strong>textual region&lt;/strong> of a Python program where a namespace is directly accessible. &amp;ldquo;Directly accessible&amp;rdquo; here means that an unqualified reference to a name attempts to find the name in the namespace.&lt;/p></description></item><item><title>Inversions in an array</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-19-inversions-in-an-array/</link><pubDate>Tue, 10 Mar 2020 18:11:00 +0000</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-19-inversions-in-an-array/</guid><description>&lt;blockquote>
 &lt;p>Interview Question 51. Inversions in an Array
Given two numbers in an array, if the earlier number is greater than the later one, the two numbers form an inversion. Given an array, find the total number of inversions in it.&lt;/p>
&lt;/blockquote>&lt;p>Example 1:&lt;/p>
&lt;pre tabindex="0">&lt;code>Input: [7,5,6,4]
Output: 5
&lt;/code>&lt;/pre>&lt;p>Constraints:
0 &amp;lt;= array length &amp;lt;= 50000&lt;/p>
&lt;h1 id="approach">Approach&lt;/h1>
&lt;h2 id="brute-force-solution">Brute-force solution&lt;/h2>
&lt;p>Just scan it mindlessly&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-cpp" data-lang="cpp">&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1&lt;/span>&lt;span>&lt;span style="color:#66d9ef">class&lt;/span> &lt;span style="color:#a6e22e">Solution&lt;/span> {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2&lt;/span>&lt;span>&lt;span style="color:#66d9ef">public&lt;/span>&lt;span style="color:#f92672">:&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3&lt;/span>&lt;span> &lt;span style="color:#66d9ef">int&lt;/span> reversePairs(vector&lt;span style="color:#f92672">&amp;lt;&lt;/span>&lt;span style="color:#66d9ef">int&lt;/span>&lt;span style="color:#f92672">&amp;gt;&amp;amp;&lt;/span> nums) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4&lt;/span>&lt;span> &lt;span style="color:#66d9ef">if&lt;/span> (nums.size() &lt;span style="color:#f92672">==&lt;/span> &lt;span style="color:#ae81ff">0&lt;/span>)
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5&lt;/span>&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> &lt;span style="color:#ae81ff">0&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6&lt;/span>&lt;span> &lt;span style="color:#66d9ef">int&lt;/span> sum &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#ae81ff">0&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7&lt;/span>&lt;span> &lt;span style="color:#66d9ef">for&lt;/span> (&lt;span style="color:#66d9ef">int&lt;/span> i &lt;span style="color:#f92672">=&lt;/span> &lt;span style="color:#ae81ff">0&lt;/span>; i &lt;span style="color:#f92672">&amp;lt;&lt;/span> nums.size() &lt;span style="color:#f92672">-&lt;/span> &lt;span style="color:#ae81ff">1&lt;/span>; &lt;span style="color:#f92672">++&lt;/span>i) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8&lt;/span>&lt;span> &lt;span style="color:#66d9ef">for&lt;/span> (&lt;span style="color:#66d9ef">int&lt;/span> j &lt;span style="color:#f92672">=&lt;/span> i&lt;span style="color:#f92672">+&lt;/span>&lt;span style="color:#ae81ff">1&lt;/span>; j &lt;span style="color:#f92672">&amp;lt;&lt;/span> nums.size(); &lt;span style="color:#f92672">++&lt;/span>j) {
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9&lt;/span>&lt;span> &lt;span style="color:#66d9ef">if&lt;/span> (nums[i] &lt;span style="color:#f92672">&amp;gt;&lt;/span> nums[j])
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10&lt;/span>&lt;span> sum&lt;span style="color:#f92672">++&lt;/span>;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11&lt;/span>&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12&lt;/span>&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13&lt;/span>&lt;span> &lt;span style="color:#66d9ef">return&lt;/span> sum;
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14&lt;/span>&lt;span> }
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15&lt;/span>&lt;span>};
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Time complexity $O(n^2)$, space complexity $O(1)$&lt;/p></description></item><item><title>Fenwick Tree (Binary Indexed)</title><link>https://blog.0xnullpath.cc/en/posts/note-snippet-12-fenwick-tree-binary-indexed/</link><pubDate>Tue, 10 Mar 2020 17:30:00 +0000</pubDate><guid>https://blog.0xnullpath.cc/en/posts/note-snippet-12-fenwick-tree-binary-indexed/</guid><description>&lt;blockquote>
 &lt;p>First, many thanks to the Bilibili creator 鹤翔万里 for the video; I recommend watching &lt;a href="https://www.bilibili.com/video/av69667943?from=search&amp;amp;seid=10916758362943551299">https://www.bilibili.com/video/av69667943?from=search&amp;seid=10916758362943551299&lt;/a>. This article is a summary I wrote for the 算法笔记 collection accompanying that video.&lt;/p>
&lt;/blockquote>&lt;p>Problem setup: given an array of length &lt;code>n&lt;/code>, support the following two operations&lt;/p>
&lt;ol>
&lt;li>Output the sum of every number in the interval &lt;code>[x, y]&lt;/code>&lt;/li>
&lt;li>Add &lt;code>k&lt;/code> to the &lt;code>x&lt;/code>-th number&lt;/li>
&lt;/ol>
&lt;p>The most basic algorithm:&lt;/p>
&lt;ol>
&lt;li>Maintain an array &lt;code>sum&lt;/code>, where &lt;code>sum[i]&lt;/code> stores the sum from 0 to i. Its recurrence relation is &lt;code>sum[i] = sum[i-1] + nums[i]&lt;/code>, where &lt;code>sum[0] = nums[0]&lt;/code>.&lt;/li>
&lt;li>The interval sum can then be computed using &lt;code>sum_xy = sum[y] - sum[x-1]&lt;/code>.&lt;/li>
&lt;li>To add &lt;code>v&lt;/code> to the &lt;code>x&lt;/code>-th number, since all values of &lt;code>sum[x]...sum[n]&lt;/code> must be updated, the time complexity is $O(n)$&lt;/li>
&lt;li>If &lt;code>k&lt;/code> operations are performed, &lt;code>add&lt;/code>, then the time complexity is $O(kn)$, and the time complexity of &lt;code>k&lt;/code> interval-sum queries is $O(k)$&lt;/li>
&lt;/ol>
&lt;p>In many scenarios with frequent updates, the $O(kn)$ time complexity is unacceptable.&lt;/p></description></item></channel></rss>