akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<class Val, class Cmp, Val Def>
struct RangeAddRMQ {
    int n, L, R;
    vector<Val> dat, mai;
    Cmp cmp;

    RangeAddRMQ(){}
    RangeAddRMQ(int n_) {
        n = 1;
        while (n < n_)n *= 2;
        dat.resize(n * 2);
        mai.resize(n * 2);
    }

    void add(int L_, int R_, Val x) {
        L = L_, R = R_;
        add(1, 0, n, x);
    }

    void add(int k, int l, int r, Val x) {
        if (L <= l&&r <= R) {
            mai[k] += x;
            dat[k] += x;
        } else if (L < r &&l < R) {
            int m = (l + r) >> 1, lk = k * 2, rk = lk + 1;
            Val ly, ry;
            add(lk, l, m, x);
            add(rk, m, r, x);
            ly = mai[lk];
            ry = mai[rk];
            mai[k] = dat[k] + (cmp(ly, ry) ? ly : ry);
        }
    }

    Val query(int L_, int R_) {
        L = L_, R = R_;
        return query(1, 0, n);
    }
    Val query(int k, int l, int r) {
        if (L <= l&&r <= R) {
            return mai[k];
        } else if (L < r &&l < R) {
            int m = (l + r) >> 1, lk = k * 2, rk = lk + 1;
            Val ly, ry;
            ly = query(lk, l, m);
            ry = query(rk, m, r);
            return dat[k] + (cmp(ly, ry) ? ly : ry);
        } else {
            return Def;
        }
    }
};

/**
x1,x2,..,xk,...,xn

x[k]またはi(1<=i<=n)
のどちらかから
x[k+1]へ移動

x[k]=>x[k+1]の場合
そのまま

i=>x[k+1]の場合
(x[k+1],j=x[k])を更新したい

|i-x[k+1]| + dp[k]の最小値を求める

x[i-1] => x[i]の移動 (a!=x[i-1])
dp[i][a] = dp[i-1][a] + |x[i]-x[i-1]|

a=>x[i]の移動
dp[i][x[i-1]]
= min(0<=a<=N, dp[i-1][a] + |a-x[i]|)

aとx[i]の大小関係を見る
dp-a+x[i]
or
dp+a-x[i]
// 0<=a<x
f1[i][a]=dp[i][a]-a
と
// x<a<N
f2[i][a]=dp[i][a]+a
を計算しておく
**/

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N, Q, A, B;
    cin >> N >> Q >> A >> B;
    --A; --B;

    const ll MA = LLONG_MAX / 6;
    RangeAddRMQ<ll, less<ll>, MA*2> f1(N), f2(N);

    rep(i, N) {
        f1.add(i, i + 1, MA-i);
        f2.add(i, i + 1, MA+i);
    }

    f1.add(A, A + 1, -MA);
    f2.add(A, A + 1, -MA);
    int p = B;
    while(Q--){
        int x; cin >> x;
        --x;
        // a=>x
        ll mi = min(f1.query(0, x) + x, f2.query(x, N) - x);
        
        // p=>x
        f1.add(0, N, abs(x - p));
        f2.add(0, N, abs(x - p));

        // a=>x
        ll y = f1.query(p, p + 1) + p;
        if (mi < y)f1.add(p, p + 1, mi - y);
        if (mi < y)f2.add(p, p + 1, mi - y);

        p = x;
    }

    ll ans = MA;
    rep(i, N)smin(ans, f1.query(i, i + 1) + i);
    cout << ans << endl;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;

#define INPUT freopen("input.txt", "r", stdin);

#define ll long long
#define ld long double

#define len(s) s.size()

#define fl(st, en, in) for (int i = st; i < en; i += in)
#define rfl(st, en, de) for (int i = st; i < en; i -= de)
#define fll fl(0, n, 1)

#define cy cout << "Yes" << endl;
#define cn cout << "No" << endl;
#define ci(s) cin >> s
#define co(s) cout << s << endl

#define vl vector<ll>
#define pb(x) push_back(x)

#define ms(arr, x) memset(arr, x, sizeof(arr))

#define inf INT_MAX
#define mx (ll)100000009
#define mod 1e9 + 7

//DSU

ll n, m;
ll par[mx];
ll sz[mx];

void make_set(ll v)
{
    par[v] = v;
    sz[v] = 1;
}

ll find_set(ll v)
{
    if (par[v] == v)
        return v;
    return par[v] = find_set(par[v]);
}

void union_set(ll a, ll b)
{
    a = find_set(a);
    b = find_set(b);
    if (a != b)
    {
        if (sz[a] < sz[b])
        {
            swap(a, b);
        }
        par[b] = a;
        sz[a] += sz[b];
    }
}
void solve()
{
    cin >> n >> m;

    fll
    {
        make_set(i + 1);
    }
    while (m--)
    {
        ll a, b;
        cin >> a >> b;
        union_set(a, b);
    }
    ll ans = 0;
    fll
    {
        ans = max(ans, sz[i + 1]);
    }
    cout << ans << endl;
}

int main()
{
    //INPUT;
    // int t;
    // ci(t);
    // while (t--)
    solve();
}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-6;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll H,W,N;
ll sy,sx;
string S,T;

int main(){
   cin >> H >> W >> N >> sy >> sx >> S >> T;
   ll u = sy,d = sy,l = sx,r = sx;
   bool flag = 0;
   rep(i,N){
       if(S[i] == 'U') u--;
       if(S[i] == 'D') d++;
       if(S[i] == 'L') l--;
       if(S[i] == 'R') r++;
       if(u == 0 || d == H + 1 || l == 0 || r == W + 1){
           cout << "NO" << endl;
           return 0;
       }
       if(T[i] == 'U' && d > 1) d--;
       if(T[i] == 'D' && u < H) u++;
       if(T[i] == 'L' && r > 1) r--;
       if(T[i] == 'R' && l < W) l++;
   }
   cout << "YES" << endl;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N, L;
	cin >> N >> L;

	vector<string> S = vector<string>(N);
	for(int i=0;i<N;i++){
		cin >> S.at(i);
	}

	sort(S.begin(), S.end());

	for(string str : S){
		cout << str;
	}
	cout << endl;

	return 0;

}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;
//using ll = long long;


const int MOD = 1000000007;
const int INF = 1e18;

const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};

const double pi = acos(-1);



template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


using Graph = vector<vector<int>>;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int x; cin >> x;
    
    for (int ia = -1000; ia <= 1000; ia++) {
        bool isOK = false;
        for (int jb = -1000; jb <= 1000; jb++) {
            
            int xtmp = pow(ia,5) - pow(jb,5);
            if(xtmp == x){
                cout << ia << " " << jb << endl;
                isOK = true;
                break;
            }
        }
        if(isOK) break;
    }
    
    
}





signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 4128
def solve():
    s = input()
    t = input()
    dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

    for i in range(len(s)):
        for j in range(len(t)):
            if s[i] == t[j]:
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])
    
    i = len(s)
    j = len(t)
    ans = ""
    while i > 0 and j > 0:
        if dp[i][j] == dp[i][j-1]:
            j -= 1
        elif dp[i][j] == dp[i-1][j]:
            i -= 1
        else:
            ans = s[i-1] + ans
            i -= 1
            j -= 1
    
    print(ans)

            
if __name__ == '__main__':
    solve()

Measured memory_bytes: 112348
#include <bits/stdc++.h>
using namespace std;

#define int long long

bool cd(int n){
	int c = 0 ;
	while(n){
		n/=10 ;
		c++ ;
	}
	return c&1 ;
}

int32_t main() {
	int n ;
	cin >> n ;
	int a[n] ;
	for(int i = 0 ; i < n ; i++){
		cin >> a[i] ;
	}
	a[0]--;
	for(int i = 1 ; i < n ; i++){
		if(a[i] == a[i-1]) continue ;
		else if(a[i]-a[i-1] > 0) a[i]-- ;
		else{
			cout << "No" ;
			return 0 ;
		}
	}
	cout << "Yes" ;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
struct Corr {
    ll y;
    ll x;
    ll depth;
};
int h,w;
ll s_y, s_x, g_y, g_x;  // スタート，ゴールの座標
ll y, x, depth;  // キューから取り出した座標
//vector<string> vec;  // 座標を受け取る配列
char s[50][50]={};
queue<Corr> q;

int y_vec[] = {0, 0, -1, +1};  // 進む方向の簡便化，テクニックとして覚えておく．
int x_vec[] = {-1, +1, 0, 0};  // ループで回すことで上下左右に移動できるようになっている

ll bfs() {
    while (!q.empty()) {
        Corr now = q.front(); q.pop();  // キューの先頭を取り出す
        y = now.y, x = now.x, depth = now.depth;  // 行，列が y, x になっているので注意

        // 停止条件：現在の座標がゴールなら深さを返す
        if (y == g_y && x == g_x) return depth;

        // 上下左右 4 方向を探索．進むことができればキューに格納する．
        for (ll i = 0; i < 4; ++i) {
            Corr next = {y + y_vec[i], x + x_vec[i], depth + 1};
            if (0 <= next.y && next.y <= h-1 && 0 <= next.x && next.x <= w-1 && s[next.y][next.x] == '.') {
                s[next.y][next.x] = 'x';  // 同じ場所を探索しないようにする
                q.push(next);
            }
        }
    }
    return 0;
}
int main(){
    cin >> h >> w;
    int count = 0;
    REP(i,h){
        REP(j,w){
            cin >> s[i][j];
            if(s[i][j] == '.')count++;
        }
    }
    s_y = 0;s_x = 0;g_y = h-1; g_x = w-1;
    Corr start = {s_y, s_x, 0};  // 初期位置の深さ(depth)は 0
    q.push(start);
    ll dist = bfs();
    if(dist == 0){
        cout << "-1" << endl;
    }else{
        cout << count - dist -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b == c+d) {
    cout << "Balanced" << endl;
  }
  else if (a+b > c+d) {
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int a,b,c,d=0,x;
  scanf("%d %d %d",&a,&b,&c);
  for(1;a<=b;a++){
    x=c%a;
    if(x == 0){
    d++;
  }
}
  printf("%d\n",d);
  return 0;
}

Measured memory_bytes: 1776
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	x -= a;
	x = (x % b);
	dump(x);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<(ll)n;i++)
#define repf(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define repr(i,a,b) for(ll i=(ll)a-1;i>=(ll)b;i--)
#define Fi first
#define Se second
typedef pair<ll, ll> pll;
const ll MAX = 1000000000000000000;
const char END = '\n';


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	double R, Ans;
	cin >> R;
	
	Ans = 2 * 3.1415*R;

	cout << Ans << END;

	return 0;
}



Measured memory_bytes: 3764
use std::io::Read;
 
fn main() {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    stdin.lock().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n = iter.next().unwrap().parse::<usize>().unwrap();
    let m = iter.next().unwrap().parse::<usize>().unwrap();

    let mut ac_ed_arr = vec![false; n+1];
    let mut n_ac: usize = 0;
    let mut penalties = vec![0_usize; n+1];
    let mut n_pn: usize = 0;

    for _ in 0..m {
        let p: usize = iter.next().unwrap().parse().unwrap();
        let s = iter.next().unwrap();
        if s == "AC" && !ac_ed_arr[p] {
            n_ac += 1;
            n_pn += penalties[p];
            ac_ed_arr[p] = true;
        } else {
            penalties[p] += 1;
        }
    }

    println!("{} {}", n_ac, n_pn);
}


Measured memory_bytes: 6396
#include <iostream>
using namespace std;
int main(){
    long long n;
    cin >> n;
    long long sum = 0;
    for(long long i = 1; i <= n; i++){
        if(i % 3 != 0 && i % 5 != 0) sum += i;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3588
from sys import stdin
def ip(): return [int(i) for i in stdin.readline().split()]
def sp(): return [str(i) for i in stdin.readline().split()]


s = str(input())
t = str(input())

ans = len(t)
for i in range(len(s) - len(t) + 1):
    # print(f'{i=} | {ans=}')
    curr = len(t)
    for j in range(i, len(t) + i):
        # print(f'{curr=} | {s[j]=} | {t[j-i]=}')
        if s[j] == t[j-i]:
            curr -= 1
    ans = min(ans, curr)
print(ans)


Measured memory_bytes: 9116
using System;
using System.Linq;

class program
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        int[] ai = new int[n];
        long ct = 0;
        for(int i = 0; i < n; i++)
        {
            int pai = i + a[i];
            int paj = i - a[i];           
            if (paj >= 0) ct += (long)ai[paj];
            if (pai < n) ai[pai]++;
        }
        Console.Write(ct);
                
    }
}

Measured memory_bytes: 44420
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;
  
  int ans = 0;
  for(int i = 0; i < 3; i++){
    if(s.at(i) == 'R') ans++;
  }
  if(s.at(1) == 'S' && ans == 2) ans--;
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int minx = (1 << 30);

int main() {
	string S; cin >> S;
	for (int i = 0; i < S.size() - 2; i++) {
		int c1 = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + (S[i + 2] - '0');
		minx = min(minx, abs(753 - c1));
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int N, M;
int x[110], a[15], b[15], c[15];
int dp[15][110][110];

int solve(int idx, int l, int r) {
  assert(r - l > 0);

  int val = dp[idx][l][r];
  if(val >= 0) return val;

  val = 0;
  if(r - l == 1) {
    val = (x[l] == a[idx]);
    return dp[idx][l][r] = val;
  }
  else {
    // split
    for(int k=l+1; k<r; k++) {
      int vl = solve(b[idx], l, k);
      int vr = solve(c[idx], k, r);
      val |= (vl && vr);
    }
  }
  return dp[idx][l][r] = val;
}

int main() {
  cin >> N;
  for(int i=0; i<N; i++) {
    cin >> x[i];
  }

  cin >> M;
  for(int i=0; i<M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    b[i]--; c[i]--;
  }
  
  memset(dp, -1, sizeof(dp));
  cout << (solve(0, 0, N) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  ll now = a[0];
  ll ans = 0;
  rep(i,n-1) {
    if (a[i+1] < now){
      ans += now - a[i+1];
    }else{
      now = a[i+1];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4768
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
s = str(N)
x = 0
for i in s:
    x += int(i)
if N % x == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 73768
n,s=map(int,input().split())
A=[int(i) for i in input().split()]
mod=998244353


dp=[0 for i in range(s+1)]
ans=0
for i in range(n):
    now=A[i]
    for q in range(s-now,-1,-1):
        dp[q+now]+=dp[q]%mod
    if A[i]<=s:
        dp[A[i]]+=i+1
    ans+=dp[s] #*(n-i)
    ans=ans%mod
    #print(dp[s],n-i)
print(ans)

Measured memory_bytes: 71296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class91
    {
        static void Main()
        {
            var NAB = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = NAB[0], A = NAB[1], B = NAB[2];
            long C = A + B;
            long D = N / C;
            long E = N % C;
            E = Math.Min(E, A);

            Console.WriteLine(D * A + E);
        }
    }
}


Measured memory_bytes: 13396
N = int(input())
A = list(map(int, input().split()))
 
# print(max(A) - min(A))

min = A[0]
max = A[0]
for i in range(N):
  if A[i] > max:
    max = A[i]
  if A[i] < min:
    min = A[i]
print(max - min)

Measured memory_bytes: 3060
#include <bits/stdc++.h>

#include <atcoder/all>

using namespace std;
using namespace atcoder;

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

constexpr int INF = TEN(9);

int op(int x, int y) { return max(x, y); }

int e() { return -1; }

int bd;
bool f(int x) { return x < bd; }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    V<int> A(N);
    rep(i, N) cin >> A[i];

    segtree<int, op, e> seg(A);
    while (Q--) {
        int t;
        cin >> t;
        if (t == 1) {
            int x, v;
            cin >> x >> v;
            --x;
            seg.set(x, v);
        } else if (t == 2) {
            int l, r;
            cin >> l >> r;
            --l;
            cout << seg.prod(l, r) << '\n';
        } else {
            int x, v;
            cin >> x >> v;
            --x;
            bd = v;
            int p = seg.max_right<f>(x);
            cout << p + 1 << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 6100
N, K = map(int, input().split())

ans = 0
for b in range(K+1, N+1):
    tmp = 0
    q, r = divmod(N+1, b)
    tmp += q * (b-K)
    if r > K:
        tmp += r - K
    if K == 0:
        tmp -= 1
    ans += tmp
print(ans)


Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if((s[0]=='B' && s[1]=='B' && s[2]=='B') ||(s[0]=='A' && s[1]=='A' && s[2]=='A'))
    {
        cout<<"No"<<endl;
    }
    else
        {
            cout<<"Yes"<<endl;
        }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <map>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <set>
#include <stack>
#include <stack>
#include <list>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
// using ll = long long;
// using P = pair<int, int>;

int main(){
    
    int n, x;
    int a, b, c;
    int sum[10000] = {};
    int X = 0;
    
    rep(i, 10000){
        cin >> n >> x;
        if(n==0 && x==0) break;
        for(int j = 1; j < n; j++){
            a = j;
            for(int k = j+1; k < n; k++){
                b = k;
                for(int l = k+1; l <= n; l++){
                    c = l;
                    if(a+b+c == x) sum[i] += 1;
                }
            }
        }
        X++;
    }
    
    rep(i, X){
        cout << sum[i] << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3104
//https://atcoder.jp/contests/agc033/tasks/agc033_a

#include <bits/stdc++.h>

using namespace std;

const int N = 1003;
int h, w;
char grid[N][N];
int level[N][N];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int mx = 0;
queue<pair<int, int>> q;

void bfs()
{
    while (!q.empty())
    {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();

        for (int i = 0; i < 4; i++)
        {
            int cx = x + dx[i];
            int cy = y + dy[i];

            if (cx >= 0 && cx < h && cy >= 0 && cy < w && level[cx][cy] == -1)
            {
                q.push({cx, cy});
                level[cx][cy] = level[x][y] + 1;
                mx = max(mx, level[cx][cy]);
            }
        }
    }
}

int main()
{
    int ans = 0;
    cin >> h >> w;
    memset(level, -1, sizeof level);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> grid[i][j];
            if (grid[i][j] == '#')
            {
                q.push({i, j});
                level[i][j] = 0;
            }
        }
    }
    bfs();

    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 13328
a,b,k=map(int,input().split())
t=set()
for i in range(a,min(a+k,b+1)):
    t.add(i)
for i in range(max(a,b-k+1),b+1):
    t.add(i)
a=list(t)
a.sort()
for i in a:
    print(i)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		System.out.println(solve());
	}

	public static long solve() {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long sum = 0;
		
		int i = 0;
		while (N != 0) {
			sum += Math.pow(2, i);
			N /= 2;
			i++;
		}
		return sum;
	}
}


Measured memory_bytes: 23764
package main

import (
       "fmt"
)

func main(){
     var n, k int
     var s []byte
     fmt.Scan(&n, &s, &k)
     for i := 0; i < n; i++{
     if s[k-1] != s[i]{
     s[i] = '*'
     }
     }
     fmt.Println(string(s))
}

Measured memory_bytes: 1772
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    cout << pow(n, 3);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int a,b,c;
    Scd3(a,b,c);

    printf ("%d\n", a+b+c-max(a,max(b,c)));

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>

#define      sf           scanf
#define      pf           printf
#define      pb           push_back
#define      sz           200005
#define      read         freopen("in.txt", "r", stdin);
#define      write        freopen("out.txt", "w", stdout);
#define      optimize     ios::sync_with_stdio(0); cin.tie(0);

using namespace std;

typedef      long long int      ll;

int main()
{
	// read
	// write

	int n;

	ll ans = 0;

	sf("%d", &n);

	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			for(int k = 1; k <= n; k++)
			{
				ans += ll(__gcd(i, __gcd(j, k)));
			}
		}
	}
	
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, k;

int main() {
	cin >> n >> k;
	
	int x = (n - 1) * (n - 2) / 2;
	if(x < k) { cout << -1 << endl; return 0; }
	
	vector<pair<int, int>> ans;
	inc(i, n - 1) { ans.EB(i + 1, n); }
	
	inc(i, n - 1) {
	inc(j, i) {
		if(k < x) { ans.EB(i + 1, j + 1); x--; }
	}
	}
	
	cout << SI(ans) << "\n";
	RF(e, ans) { cout << e.FI << " " << e.SE << "\n"; }
	
	return 0;
}


Measured memory_bytes: 384
void main() {
	auto N = readAs!long;
	auto A = readAs!(long[]);
	auto B = readAs!(long[]);

	long res;

	foreach(i, v; B) {
		debug A.writeln;
		if(v >= A[i]) {
			auto tmp = v - A[i];
			res += A[i];
			A[i] = 0;
			debug tmp.writeln;
			auto m = max(0, A[i+1] - tmp);
			res += A[i+1] - m;
			A[i+1] = m;
			
		} else {
			res += v;
			A[i] -= v;
		}
	}
	debug A.writeln;
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 9580
#[allow(unused_imports)]
use std::{
    i64,
    f64,
    cmp,
};

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };

    (stream = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };

    ($($r:tt)*) => {
        use std::io::*;
        let mut stream = stdin();
        let stream = &mut stream;
        input_inner!{stream, $($r)*}
    };
}

macro_rules! input_inner {
    ($stream:expr) => {};
    ($stream:expr, ) => {};

    ($stream:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($stream, $t);
        input_inner!{$stream $($r)*}
    };
}

macro_rules! read_value {
    ($stream:expr, ( $($t:tt),* )) => {
        ( $(read_value!($stream, $t)),* )
    };

    ($stream:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($stream, $t)).collect::<Vec<_>>()
    };

    ($stream:expr, chars) => {
        read_value!($stream, String).chars().collect::<Vec<char>>()
    };

    ($stream:expr, usize1) => {
        read_value!($stream, usize) - 1
    };

    ($stream:expr, $t:ty) => {
        $stream.by_ref().bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<$t>()
            .expect("Parse error")
    };
}

fn calc_min_cost(mask: usize, key_value: &Vec<i64>, key_mask: &Vec<usize>, memo: &mut Vec<Option<Option<i64>>>) -> Option<i64> {
    if let Some(v) = memo[mask] {
        v
    } else {
        memo[mask] = Some(None);
        for (i, m) in key_mask.iter().enumerate() {
            if (mask & m) == 0 {
                continue;
            }
            if let Some(cost) = calc_min_cost(mask & !m, key_value, key_mask, memo) {
                memo[mask] = Some(Some(if let Some(Some(old_cost)) = memo[mask] {
                    cmp::min(cost + key_value[i], old_cost)
                } else {
                    cost + key_value[i]
                }));
            }
        }
        memo[mask].unwrap()
    }
}

fn main() {
    input!{n: i64, m: i64}
    let mut key_value: Vec<i64> = Vec::new();
    let mut key_mask: Vec<usize> = Vec::new();

    for _ in 0 .. m {
        input!{
            a: i64,
            b: i64,
            c: [usize1; b]
        };

        key_value.push(a);
        let mask = c.iter().fold(0, |acc, i| {acc | (1 << i) as usize});
        key_mask.push(mask);
    }

    let mut memo: Vec<Option<Option<i64>>> = vec![None; 1 << n];
    memo[0] = Some(Some(0));

    println!("{}", if let Some(c) = calc_min_cost((1 << n) - 1, &key_value, &key_mask, &mut memo) {c} else {-1});
}

Measured memory_bytes: 4352
s = input()
count = 0
for i in range(1,len(s)):
    if s[i-1] == "0" and s[i] == s[i-1]:
        s = s[:i] + "1" + s[i+1:]
        count += 1
    elif s[i-1] == "1" and s[i] == s[i-1]:
        s = s[:i] + "0" + s[i+1:]
        count += 1
print(count)

Measured memory_bytes: 3436
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();

		for (int i = 0; i < s.length(); i+=2) {
			System.out.print(s.charAt(i));
		}
		System.out.println();
	}

}

Measured memory_bytes: 29160
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int a[1000005];
int main()
{
    int n,k;
	cin>>n>>k;
	for (int i = 0; i < n; i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	ll ans=0;
	for (int i = 0; i < k; i++)
	{
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3636
import collections

N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
c = collections.Counter(A)
b = sorted(c,reverse = True)
tmp  = []
for i in b:
    if c[i] >= 4:
        tmp += [i]
        break
    elif c[i] >= 2:
        tmp += [i]
    if len(tmp) == 2:
        break
    
if len(tmp) == 2:
    print(tmp[0]*tmp[1])
elif len(tmp) == 1:
    print(tmp[0]*tmp[0])
else:
    print(0)
        



Measured memory_bytes: 18600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int n; cin >> n;
    string s;
    while (n) {
        int r = n%2;
        if (r<0) r+= 2;
        s += r+'0';
        
        n = (n-r)/(-2);
    }
    reverse(all(s));
    if (s.empty()) s += '0';
    cout << s << endl;
}

Measured memory_bytes: 256
def main():
    N, K, Q = map(int, input().split())
    ans = [K-Q] * N

    for i in range(Q):
        ans[int(input())-1] += 1 

    for i in ans:
        if i > 0:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 6580
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <complex>
using namespace std;
typedef long long LL;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(b, a*n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <time.h>
using namespace std;
typedef long long ll;


int main()
{
	int N, M; cin >> N >> M;
	vector<pair<int, int>> I(M);
	for (int i = 0; i < M; ++i) {
		cin >> I[i].first >> I[i].second;
	}
	auto cmpr = [](pair<int, int> a, pair<int, int> b) {
		if (a.second != b.second) return a.second < b.second;
		return a.first > b.first;
	};
	sort(I.begin(), I.end(), cmpr);
	int cur = 1 << 30; cur *= -1;
	int ans = 0;
	for (int i = 0; i < M; ++i) {
		if (cur > I[i].first) continue;
		cur = I[i].second;
		++ans;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;

using LL = long long;

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b) for (int(i) = (a); (i) > (b); --(i))
#define SORT(x) sort(ALL((x)))
#define RSORT(x) sort(RALL((x)))
#define SZ(x) (int)(x).size()
#define debug(x) cerr << #x << " : " << x << '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const LL LINF = 1e18;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  LL ans = 0;
  int N, D, X;
  cin >> N >> D >> X;

  vector<int> A(N);
  FOR(i, 0, N) { cin >> A[i]; }

  FOR(i, 0, N) {
    for (int j = 0; j * A[i] + 1 <= D; ++j) {
      ans++;
    }
  }

  cout << ans + X << '\n';

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using std::string;
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))
#define FORR(i,l,r) for(int (i)=l;(i)<(r);++(i))
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ins insert
#define mp make_pair
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int>
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define EPSILON 1e-9
#define MAX 100002
#define PI 3.1415926535897932384626433832795028841971693993751
typedef long long  ll;
typedef unsigned long long llu;
typedef long double  ldb;
typedef double  db ;
int dp[100002],h[100002],inf=1000000002;
int main()
{
   // freopen("in.txt","r",stdin);
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>h[i];
        dp[i]=inf;
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout<<dp[n-1];
}








Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
 
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
 
using namespace std;
 
typedef pair<long long int, long long int> P;
long long int INF = 1e18;

#define MAX_V 110000

int N;

struct edge{
	int to;
	long long int cost;
};

vector<edge> G[MAX_V];
long long int d[MAX_V];

// 速さはO(|E|log|V|)

void shortest_path(int s, int V){ // Vは頂点数
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		} // 頂点への最小コストを更新
	}
}

long long int cnt1[310000] = {}, cnt2[310000] = {};

int main(){
	
	long long int N, M, s, t;
	cin >> N >> M >> s >> t;
	s--;
	t--;
	
	for(int i = 0; i < M; i++){
		edge e;
		e.cost = 1;
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		e.to = v;
		G[u].push_back(e);
		e.to = u;
		G[v].push_back(e);
	}
	
	shortest_path(s, N);
	
	for(int i = 0; i < N; i++){
		if(d[i] < M){
			cnt1[d[i]]++;
		}
	}
	
	int dist = d[t];
	
	shortest_path(t, N);
	
	for(int i = 0; i < N; i++){
		if(d[i] < M){
			cnt2[d[i]]++;
		}
	}
	
	long long int ans = 0;
	
	for(int i = 0; i <= dist - 2; i++){
		ans += cnt1[i] * cnt2[dist - i - 2];
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 16476
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <stdio.h>
#include <unistd.h>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define itrep(itr, base) for (auto itr = base.begin(); itr != base.end(); itr++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
#define PI 3.14159265359

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  int f[n][10];
  rep (i, n) rep (j, 10) cin >> f[i][j];
  int p[n][11];
  rep (i, n) rep (j, 11) cin >> p[i][j];

  int loop = pow(2, 10);
  ll ans = INF * -1;
  for (int i = 1; i < loop; i++) {
    ll tmpAns = 0;
    rep (mise, n) {
      int count = 0;
      rep (open, 10) {
        if (i & (1 << open) && f[mise][open] == 1) count++;
      }
      tmpAns += p[mise][count];
    }
    ans = max(ans, tmpAns);
  }
  P(ans);
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    cout << ((s[2] == s[3] && s[4] == s[5])?"Yes":"No")  << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void solve(long long N, long long C, std::vector<std::vector<long long>> D, std::vector<std::vector<long long>> c){
    vector<vll> diag(2*N-1, vll(C, 0));
    REP(r, 2*N-1){ //* diagonal r
        for(ll i = 0; i <= r; i++){
            ll j = r-i;
            if(0 > i || i >= N || 0 > j || j >= N) continue;
            ll color = c[i][j];
            REP(k, C){
                //* color --> k
                diag[r][k] += D[color][k];
            }
        }
    }
    ll ans = INF;
    REP(i, C){
        REP(j, C){
            if(i == j) continue;
            REP(k, C){
                if(k == i || k == j) continue;
                ll tmp = 0;
                REP(r, 2*N-1){
                    if(r % 3 == 0) tmp += diag[r][i];
                    if(r % 3 == 1) tmp += diag[r][j];
                    if(r % 3 == 2) tmp += diag[r][k];
                }
                chmin(ans, tmp);
            }
        }
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long C;
    scanf("%lld",&C);
    std::vector<std::vector<long long>> D(C, std::vector<long long>(C));
    for(int i = 0 ; i < C ; i++){
        for(int j = 0 ; j < C ; j++){
            scanf("%lld",&D[i][j]);
        }
    }
    std::vector<std::vector<long long>> c(N, std::vector<long long>(N));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
            scanf("%lld",&c[i][j]);
            c[i][j] --;
        }
    }
    solve(N, C, std::move(D), std::move(c));
    return 0;
}


Measured memory_bytes: 3064