akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
#define vll vector<ll>
#define pll vector<pair<ll,ll>>



int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t;
	//cin>>t;
	t=1;
	start:
	while(t--){

     ll n;
     cin>>n;

     ll arr[n];
     for(ll i=0;i<n;i++)
        cin>>arr[i];
     ll sum=0;

     for(ll i=1;i<n;i++){
        if(arr[i]<arr[i-1]){
            sum+=(arr[i-1]-arr[i]);
            arr[i]=arr[i-1];
        }
     }
     cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 5220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<pair<int,int>>vec;
int n,w;
ll memo[100100][101];
ll solve(int weight=0,int num=0){
    if(num==n)
        return 0;
    ll &cur=memo[weight][num];
    if(cur!=-1)
        return cur;
    cur=0;
    if(weight+vec[num].first<=w) {
        cur = max(cur, vec[num].second + solve(weight + vec[num].first, num + 1));
        cur=max(cur,solve(weight,num+1));
    }
    else
        cur=max(cur,solve(weight,num+1));
    return cur;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    memset(memo,-1,sizeof(memo));
    cin>>n>>w;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        vec.push_back({a,b});
    }
    cout<<solve();
}

Measured memory_bytes: 79232
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 650055;
const int K = 700 ;
int a[N], p[N], cnt[N], b[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n, q;
    int on, oq;
    cin >> n >> q;
    if (q == 0){
        for (int i = 1; i <= n; i++){
            cout << 1 << endl;
        }
        return 0;
    }
    on = n;
    oq = q;
    for (int i = 1; i <= q; i++) cin >> a[i];
    for (int i = q; i >= 1; i--){
        if (a[i] < a[i - 1]){
            a[i - 1] = a[i];
        }
    }
    q = 0;
    for (int i = 1; i <= oq; i++){
        if (a[i] == a[i - 1]) continue;
        q++;
        b[q] = a[i];
    }
    n = min(n, b[1]);
    cnt[q] = 1;
    b[0] = n;
    for (int i = q; i >= 1; i--){
        int j = i - 1;
        int len = b[i];
        int x = cnt[i];
        while(j != 0){
            cnt[j] += len / b[j] * x;
            len %= b[j];
            int l = 0;
            int r = j;
            while(r - l > 1){
                int mid = (r + l) / 2;
                if (b[mid] <= len) l = mid; else r = mid;
            }
            j = l;
        }
        cnt[0] += len / b[0] * x;
        len %= b[0];
        p[0] += x;
        p[len + 1] -= x;
    }
    int y = cnt[0] + p[0];
    for (int i = 1; i <= n; i++){
        y += p[i];
        cout << y << endl;
    }
    for (int i = n + 1; i <= on; i++) cout << 0 << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> a(N),b(N),c(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    for(int i=0;i<N;i++){
        cin >> b[i];
    }
    for(int i=0;i<N;i++){
        cin >> c[i];
    }
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    long long ans=0;
    //中部のパーツを一個決めて二分探索
    for(int i=0;i<N;i++){
        long long ue=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        long long shita=c.end()-upper_bound(c.begin(),c.end(),b[i]);
        //cout << " ue " << ue << " shita " << shita << endl;
        ans+=ue*shita;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4576
n = $<.gets.to_i
Node = Struct.new(:id, :left, :right, :depth, :type, :sibling, :degree, :parent, :height)

nodes = n.times.map { Node.new(*$<.gets.split.map(&:to_i)) }.sort_by(&:id)
root = [*0...n] - nodes.flat_map {|n| [n.left, n.right]}.uniq
root = nodes[root.first]
h = nodes.map {|n| [n.id, n]}.to_h

build_tree = ->(node, depth) {
  node.depth = depth
  l, r = node.left, node.right
  degree = 0
  h1 = h2 = 0
  try = ->(next_node, s) {
    next_node.sibling = s
    next_node.parent = node.id
    build_tree.(next_node, depth + 1)
    degree += 1
    next_node.height + 1
  }
  h1 = try.(h[l], r) if l != -1
  h2 = try.(h[r], l) if r != -1
  node.degree = degree
  if l == -1 and r == -1
    node.height = 0
    node.type = "leaf"
  else
    node.height = [h1, h2].max
    node.type = "internal node"
  end
}
build_tree.(root, 0)

root.type = "root"
root.sibling = -1
root.parent = -1

puts nodes.map {|n| "node #{n.id}: parent = #{n.parent}, sibling = #{n.sibling}, " +
  "degree = #{n.degree}, depth = #{n.depth}, height = #{n.height}, #{n.type}"}



Measured memory_bytes: 6912
N,D = gets.split.map(&:to_i)
X = N.times.map{gets.split.map(&:to_i)}

count = 0
X.combination(2){|a,b|
  d = D.times.map{|n| (a[n] - b[n])**2}.inject(:+)
  count += 1 if (d**0.5) % 1 == 0
}

p count

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

int main() {
  long long n, k;
  cin >> n >> k;
  
  vector<long long> p(n);
  for (int i=0; i<n; i++) {
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  
  long long ans = 0;
  for (int i=0; i<k; i++) {
    ans += p[i];
  }
  cout << ans << endl;
  
  return 0;
}

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

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}

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

    int N;
    cin >> N;
    vector<vector<pii>> g(N);
    // d[i][j] は頂点 i と 頂点 j の距離.
    vector<vector<int>> d(N, vector<int>(N, INT_MAX / 2));
    REP(i, N) d[i][i] = 0;
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
        d[a][b] = d[b][a] = 1;
    }

    // Floyd-Warshall
    REP(k, N) REP(i, N) REP(j, N) {
        if (d[i][j] > d[i][k] + d[k][j])
            d[i][j] = d[i][k] + d[k][j];
    }

    int M;
    cin >> M;
    // mask[i] は 辺 i を黒く塗ったときに満たされる条件の集合を表す長さ M の bit.
    vector<ll> mask(N - 1);
    REP(i, M) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        while (u != v) {
            for (auto [w, id]: g[u]) {
                if (d[u][v] > d[w][v]) {
                    mask[id] |= 1 << i;
                    u = w;
                    break;
                }
            }
        }
    }

    // dp[i][b] は辺 i - 1 まで辺の色を塗り, 満たしている条件の集合が b のときの辺の塗り方の個数.
    vector<vector<ll>> dp(N, vector<ll>(1 << M));
    dp[0][0] = 1;
    REP(i, N - 1) {
        REP(b, 1 << M) {
            // 辺 i を白く塗る場合.
            dp[i + 1][b] += dp[i][b];
            // 辺 i を黒く塗る場合.
            dp[i + 1][b | mask[i]] += dp[i][b];
        }
    }

    cout << dp[N - 1][(1 << M) - 1] << endl;

    return 0;
}


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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0;
    int levo = 0;
    for(int i=0; i<n; i++){
        if(s[i] == '(') x--;
        else x++;
        levo = max(levo, x);
    }
    x = 0;
    int desno = 0;
    for(int i=n-1; i>=0; i--){
        if(s[i] == ')') x--;
        else x++;
        desno = max(desno, x);
    }
    while(levo--) cout << "(";
    cout << s;
    while(desno--) cout << ")";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void y(bool c) { if (c)print("Yes"); else print("No"); };


long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
void solve() {
	int N, K; cin >> N >> K;
	ll ans = 0;
	FOR(k, K, N + 2) {
		int mn = k * (k - 1) / 2;
		int mx = k * (2 * N - k + 1) / 2;
		ans += (mx - mn + 1);
		ans %= MOD;
	}
	print(ans);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}




Measured memory_bytes: 3684
s = input()
a = int(s[0:2])
b = int(s[2:4])

if (a>0 and a<13) and (b>0 and b<13):
  print("AMBIGUOUS")
elif a>0 and a<13:
  print("MMYY")
elif b>0 and b<13:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3060
const input=require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);const nin=()=>{const r = input[0];input.shift();return Number(r)};const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};const sin=()=>{const r = input[0];input.shift();return String(r)};const out=(...a)=>{console.log(...a)};const floor=(a)=>{return Math.floor(a)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}};const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};const permutation=({result=[],pre=[],post,n=post.length})=>{if(n>0){post.forEach((_,i)=>{const rest=[...post];const elem=rest.splice(i, 1);permutation({result, pre: [...pre,...elem],post:rest,n:n-1})})}else{result.push(pre)}return result};const sw=(s,a:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<a.length;i+=2){if(op==='=='){if(s==a[i])return a[i+1]}else if(op==='>='){if(s>=a[i])return a[i+1]}else if(op==='<='){if(s<=a[i])return a[i+1]}else if(op==='>'){if(s>a[i])return a[i+1]}else if(op==='<'){if(s<a[i])return a[i+1]}}return a[a.length-1];};const or=(a,...b)=>{for(let i=0;i<b.length;i++)if(a==b[i])return true;return false};const maxindex=(...a)=>{return a.indexOf(Math.max.apply(null,a))};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const ceil=a=>{return Math.ceil(a)};const srin=s=>{const a:string[]=[];rep(s,()=>a.push(sin()));return a};let ssinteger=-1;const ssin=()=>{ssinteger++;return input[0][ssinteger]};
const main = ()=>{
  // let n=nin()
  out(nin()>=1000?'ABD':'ABC')
  
}
main();

Measured memory_bytes: 7372
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

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 (a > b) { a = b; return 1; }return 0; }



#define rep(n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
const int MOD = 1000000007;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;

int main() {
	
	int N, W;
	cin >> N >> W;
	vl w(N), v(N);
	rep(N) { cin >> w[i] >> v[i]; }
	vll dp(N + 1, vl(W+1,0));

	rep(N) {
		for (int j = 0; j <= W; j++) {
			dp[i + 1][j] = dp[i][j];
			if (j - w[i] >= 0)chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}

Measured memory_bytes: 80256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        string inNum = Reader.ReadLine();
        long target = long.Parse(Reader.ReadLine());

        long idx = 0;
        long ans = 0;
        for (int i = 0; i < inNum.Length; i++) {
            long num = inNum[i] - '0';


            if(num >= 2) {
                ans = num;
                break;
            }
            idx++;
            if(idx >= target) {
                ans = num;
                break;
            }
        }

        Console.WriteLine(ans);



    }




    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"

299792458
9460730472580800


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;

int main() {

int m,f,r;

while(true){

cin >> m >> f >> r;

if(m==-1 && f==-1 && r==-1){break;}

if(m==-1 || f==-1){
cout << "F" << endl;
}else{
if(m+f>=80){cout << "A" << endl;}
if(m+f>=65 && m+f <80){cout << "B" << endl;}
if(m+f>=50 && m+f <65){cout << "C" << endl;}
if(m+f>=30 && m+f <50){
if(r>=50){
cout << "C" << endl;
}else{
cout << "D" << endl;
}
}
if(m+f <30){cout << "F" << endl;}
}


}

}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;

struct edge { int to,cost; };

int main() {
  ll x;cin>>x;
  // 656565656..

  if (x<=6) {
    OUT(1);
    return 0;
  }

  ll ans = x/11*2;
  if (x%11!=0) ans++;
  if (x%11>=7) ans++;
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <cmath>
#include <vector>
using namespace std;
#define ll long long
int fight(ll m, ll n){
	if(m == n){
		return m;
	}
	else if(m > n){
		return m-n;
	}
	else{
		return n-m;
	}
}
int main(){
	ll N;
	cin >> N;
	vector<ll> A(pow(2,N));
	for(ll i = 0; i < pow(2.0,N); i++){
		cin >> A[i];
	}
	for(ll i=0;i<N;i++){
		for(ll j=0;j<pow(2,N);j+=(pow(2,i)*2)){
			A[j]=fight(A[j],A[j+pow(2,i)]);
		}
	}
	cout <<A[0] << endl;
}

Measured memory_bytes: 2304
#include<iostream>
using namespace std;
 
int main(){
    int a,b,W,H,x,y,r;
    a = 0;
    b = 0;
    cin >> W >> H >> x >> y >> r;
    if( x+r<=W && y+r<=H && x-r>=a && y-r>=b ){cout << "Yes" << endl;}
    else{cout << "No" << endl;}
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int n,pos;
vector<int> pre, in, post;

void rec(int l, int r){
  if(l >= r)
    return;
  int root = pre[pos++];
  int m = distance(in.begin(),find(in.begin(),in.end(),root));
  rec(l,m);
  rec(m+1, r);
  post.push_back(root);
}

void solve(){
  pos = 0;
  rec(0,pre.size());
  for(int i = 0; i < n; i++){
    if(i)
      cout << " ";
    cout << post[i];
  }
  cout << endl;
}

int main(){
  int k;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> k;
    pre.push_back(k);
  }
  for(int i = 0; i < n; i++){
    cin >> k;
    in.push_back(k);
  }
  solve();
  return 0;
}
		      

Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	string S;
	int ANS=0;
	int count0=0;
	int count1=0;

	cin >> S;

	for(int i=0;i<S.size();i++)
	{
		if(S[i]=='1')
		{
			count1++;
		}
		if(S[i]=='0')
		{
			count0++;
		}
			
	}
	cout << min(count1,count0)*2 << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        long n=scanner.nextLong();
        long ans=(n/(long)500);
        ans=(long)((long)ans*(long)1000);
        long ss=((n%(long)500)/(long)5);
        ss=(long)((long)ss*(long)5);
        ans+=ss;
        System.out.println(ans);

    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++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(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

bool is_palind(int n) {
    string s = to_string(n);
    REP(i, 2)if(s[i] != s[4 - i]) return false;
    return true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    int ans = 0;
    FOR(i, a, b) {
        if(is_palind(i)) ans++;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),(OUT(YES),1),(OUT(NO),0))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p998 = 998244353;
const LL p107 = 1000000007;
const LL p = p107;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
#define endl "\n"
ut N, M,K,  Q, D, H, W;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
LL A[SIZE],B[SIZE],C[SIZE];
LL solve(){
	LL S;
	cin >> N  >> K >> S;
	REP(i,K){
		cout << S << " ";
	}
	LL ie9=1000000000;
	FOR(i,K,N){
		if(S==ie9) cout <<ie9-1 <<" " ;
		else cout << ie9 << " ";
	}
	cout <<endl;
	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	LL T=1;

	REP(i,T){
		DEFAULT;

	}
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}


Measured memory_bytes: 14464
object Main extends App {
	val pw = new java.io.PrintWriter(System.out)

	@scala.annotation.tailrec
	def loop(start: Int, end: Int)(f: Int => Unit): Unit =
		if (start < end) {
			f(start)
			loop(start + 1, end)(f)
		}

	val a, b, x = Scanner.nextDouble

	val v = a * a * b

	val ans = if (x <= v / 2.0)
		scala.math.atan2(b, 2.0 * x / (a * b)) / scala.math.Pi * 180
	else
		scala.math.atan2(2.0 * (v - x) / (a * a), a) / scala.math.Pi * 180

	pw.println(ans)
	pw.flush()
}

object Scanner {
	private val buf = new Array[Byte](1024); private var ptr = 0; private var len = 0

	@inline private def isPrintableChar(c: Int): Boolean = 33 <= c && c <= 126
	@inline private def hasNextByte(): Boolean = if (ptr >= len) { ptr = 0; len = System.in.read(buf); len > 0 } else true
	@inline private def hasNext(): Boolean = {
		while (hasNextByte() && !isPrintableChar(buf(ptr))) ptr += 1
		hasNextByte()
	}
	@inline private def readByte(): Byte = if (hasNextByte()) { val res = buf(ptr); ptr += 1; res } else -1

	def next(): String = {
		if(!hasNext()) ???
		val sb = new StringBuilder; var b = readByte()
		while (isPrintableChar(b)) { sb.append(b.toChar); b = readByte() }
		sb.toString
	}

	def nextInt(): Int = {
		val n = nextLong()
		if (n < Int.MinValue || Int.MaxValue < n) ???
		n.toInt
	}

	def nextLong(): Long = {
		if(!hasNext()) ???
		var minus = false; var b = readByte()
		if (b == '-') { minus = true; b = readByte() }

		@scala.annotation.tailrec
		def go (b: Byte, n: Long = 0): Long = if ('0' <= b && b <= '9') go(readByte(), n * 10 + b - '0') else if (minus) -n else n

		go(b)
	}

	def nextDouble(): Double = next().toDouble
}


Measured memory_bytes: 54772
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int main(){
    int N,time=0;
    cin>>N;
    pair<int,int> p[200010];
    for(int i=0;i<N;++i)
        cin>>p[i].second>>p[i].first;
    sort(p,p+N);
    for(int i=0;i<N;++i){
        time+=p[i].second;
        if(time>p[i].first){
            cout<<"No"<<endl;
            goto lol;
        }

    }

    cout<<"Yes"<<endl;
    lol:
    return 0;

}

Measured memory_bytes: 1920
using System;
using System.Collections.Generic;

namespace CompetitiveProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            switch (n)
            {
                case "1":
                    Console.WriteLine("Hello World");
                    break;
                case "2":
                    int a = int.Parse(Console.ReadLine());
                    int b = int.Parse(Console.ReadLine());
                    int sum = a + b;
                    Console.Write(sum);
                    break;
            }
        }
    }
}


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

vector<vector<int> > ans;

int main(){
    int H, W;
    int a[501][501] = {};
    cin >> H >> W;
    for(int h = 1; h <= H; h++){
        for(int w = 1; w <= W; w++){
            cin >> a[h][w];
        }
    }

    int h = 1, w = 1;
    while(h <= H){
        if(h % 2 == 1){
            while(w < W){
                if(a[h][w] % 2 != 0){
                    vector<int> p{h, w, h, w+1};
                    ans.push_back(p);
                    a[h][w+1]++;
                }
                w++;
            }
            if(a[h][W] % 2 != 0 && h < H){
                a[h+1][W]++;
                vector<int> p {h, w, h+1, w};
                ans.push_back(p);
            }
        }
        if(h % 2 == 0){
            while(w > 1){
                if(a[h][w] % 2 != 0){
                    vector<int> p{h, w, h, w-1};
                    ans.push_back(p);
                    a[h][w-1]++;
                }
                w--;
            }
            if(a[h][1] % 2 != 0 && h < H){
                a[h+1][1]++;
                vector<int> p {h, w, h+1, w};
                ans.push_back(p);
            }
        }
        h++;
    }
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << " " << ans[i][3] << endl;
    }
}


Measured memory_bytes: 9904
#include <bits/stdc++.h>
#define int long long

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

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

template <typename T>
vector<T> make_v(size_t a)
{
    return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }

template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;
    vector<int> t(n), d(n);
    REP(i, n) cin >> t[i] >> d[i];

    vector<P> p(n);
    REP(i, n) p[i] = make_pair(d[i], t[i]);

    sort(all(p), greater<P>());

    vector<int> a, b;
    map<int, bool> mp;
    REP(i, n)
    {
        if(mp[p[i].second])
        {
            b.pb(p[i].first);
        }
        else
        {
            a.pb(p[i].first);
            mp[p[i].second] = true;
        }
    }
    sort(all(a), greater<int>());
    sort(all(b), greater<int>());

    vector<int> ruiseki1(a.size()+1, 0);
    vector<int> ruiseki2(b.size()+1, 0);
    REP(i, a.size()) ruiseki1[i+1] += ruiseki1[i] + a[i];
    REP(i, b.size()) ruiseki2[i+1] += ruiseki2[i] + b[i];

    LL ans = 0;
    REP(i, min((int)a.size(), k))
    {
        LL sum = 0;
        sum += ruiseki1[i+1];
        sum += ruiseki2[min(k-i-1, (int)b.size())];
        sum += (i+1LL) * (i+1LL);
        ans = max(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 11252
//Heaplax
#include<bits/stdc++.h>
#define N 1000005
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
const int mod=998244353;
int n,m,ans,fac[N],ifac[N],inv[N];
int C(int n,int m)
{
	if(n<m)return 0;
	else return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int mi(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=1ll*res*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return res;
}
int equal(int n,int a,int b)
{
	return 1ll*C(a,n/2)*C(b,n/2)%mod*mi(C(a+b,n),mod-2)%mod;
}
int main()
{
	re(n),re(m);
	fac[0]=ifac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<N;++i)
	{
		fac[i]=1ll*fac[i-1]*i%mod;
		if(i>1)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
	}
	ans=max(n,m);
	for(int i=0;i<n+m;++i)
		if((n+m-i)%2==0)
			ans=(ans+1ll*inv[2]*equal(n+m-i,n,m))%mod;
	printf("%d\n",ans);
}

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

using namespace std;

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int h,w;
   cin >> h >> w;
   string s[h];
   rep(i,h)cin >> s[i];
   h += 2;w += 2;

   for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
         if(i == 0 || j == 0 || i == h-1 || j == w-1){
            cout << '#';
         }else{
            cout << s[i-1][j-1];
         }
      }
      cout << endl;
   }
   
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/range/algorithm.hpp>
#define rep(i,n) for (int i=0; i< (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  map<char,int> counter;
  for(auto& c : s){
    counter[c]++;
  }
  string ans = "Yes";
  for(auto& p : counter){
    if (p.second != 2) ans = "No";
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)//初期値a,i<bの範囲でループ
#define REP(i,n) FOR(i,0,n)//初期値0,i<nの範囲でループ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int n;
int w[110];
int v[110];
int W;
int dp[110][10010];

int main(){
    cin>>n>>W;
    REP(i,n)cin>>v[i]>>w[i];

    REP(i,n){
        REP(j,W+1){
            if(j>=w[i])dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
            else dp[i+1][j]=dp[i][j];
            
        }
    }

    cout<<dp[n][W]<<endl;
    

    return 0;
}


Measured memory_bytes: 7008
x, n = map(int, input().split(" "))
v = [i for i in range(102)]
min_val = 100
ans_val = 0

if n != 0:
    p = list(map(int, input().split(" ")))    
    for index in p:
        v[index] = 101


for v_val in v:
    if(min_val > abs(v_val - x)):
        ans_val = v_val
        min_val = min(min_val, abs(v_val - x))
    #print(abs(v_val - x), end=" ")


#print("")
print(ans_val)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll X;
    cin >> X;
    ll money = 100;
    ll ans = 0;
    while(true){
        if (money >= X){
            break;
        }
        else{
            money += money / 100;
            ans += 1;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;


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;
}




int main() {
    int num_patrons;
    cin >> num_patrons;
    vector<string> units(num_patrons);
    vector<double> values(num_patrons);
    REP(itr, num_patrons) {
        cin >> values[itr] >> units[itr];
    }
    double ans;
    REP(itr, num_patrons) {
        if(units[itr] == "JPY") {
            ans += values[itr];
        }
        else {
            ans += values[itr] * 380000;
        }
    }
    cout << fixed <<ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int a, b;
	vi v(3);
	cin >> a >> b;
	v[0] = a + b;
	v[1] = a - b;
	v[2] = a * b;
	sort(v.begin(), v.end());

	cout << v[2] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
#define ALL(x) begin(x), end(x)
using namespace std;

int main() {
    // input
    int n; scanf("%d", &n);
    vector<int> a(n), b(n);
    REP (i, n) scanf("%d%d", &a[i], &b[i]);
    // solve
    vector<int> order(n);
    iota(ALL(order), 0);
    sort(ALL(order), [&](int i, int j) { return b[i] < b[j]; });
    priority_queue<int> que;
    int sum_que = 0;
    for (int i : order) {
        sum_que += a[i];
        que.push(a[i]);
        if (sum_que > b[i]) {
            sum_que -= que.top();
            que.pop();
        }
    }
    // output
    printf("%d\n", int(que.size()));
    return 0;
}

Measured memory_bytes: 3264
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define mp make_pair
#define endl "\n"
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lb lower_bound
#define forn(i,n) for(ll i=0 ; i<n ; i++)
#define arr(a,n) for(ll i=0;i<n;i++){ cin>>a[i]; }
#define ub upper_bound
#define pb push_back
#define pi pair<int,int>
#define mod 1000000007
#define vectormax *max_element
#define vectormin *min_element
#define arraysize 1000000
#define setbit _builtin_popcountll
using namespace std;

ll ipow(ll x, ll n)
{
    ll result = 1;
    while (n) {
        if (n & 1)
            result = result * x ;
        n = n / 2;
        x = x * x;
    }
    return result;
}

int main() {
	int n;
	cin>>n;
	vector<pair<int,int>>v;
	while(n--){
		int a,b;
		cin>>a>>b;
		v.pb(mp(a,b));
		
	}
	int flag=0;
	for(int i=0;i<v.size()-2;i++){
		for(int j=i+1;j<v.size()-1;j++){
			for(int k=j+1;k<v.size();k++){
				if(v[i].first==v[i].second and v[j].first==v[j].second and v[k].first==v[k].second and j==i+1 and k==j+1){
					flag=1;
					break;
				}
			}
			if(flag==1) break;
		}
		if(flag==1) break;
	}
	if(flag==1) cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	
return 0;
}


Measured memory_bytes: 3604
K = int(input())
a,b = map(int,input().split())
 
k = 1000//K
ans = "NG"

if K == 1:
  ans = "OK"
  
for i in range(1,k+1):
  k_bai = K*i
  if a<= k_bai and k_bai<=b:
    ans = "OK"
    break


print(ans)
    

Measured memory_bytes: 9012
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;

string ans;

int main(){
	int n;
	cin >> n;

	char buff;

	REP(i, n){
		string chain;

		cin >> chain;

		auto it = chain.begin();

		ans = *(it++);

		while (it != chain.end()){
			string tmp(it, it + 2);
			it += 2;

			buff = *(it++);

			if (tmp == "->"){
				if (ans.find(buff) == string::npos)
					ans = ans + buff;
			}
			if (tmp == "<-"){
				if (ans.find(buff) == string::npos)
					ans = buff + ans;

			}

		}
		cout << ans << endl;
	}

	return 0;
}

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n, k;
    cin >> n >> k;
    long long a[n + 1], dp[n + 1];
    for(long long i = 1; i <= n; i++) {
        cin >> a[i];
        dp[i] = INT_MAX;
    }
    if(n == 1) {
        cout << 0 << endl;
    }
    else {
        dp[1] = 0;
        dp[2] = abs(a[1] - a[2]);
        for(long long i = 3; i <= min(n, k); i++) {
            for(long long j = 1; j < i; j++) {
                dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
            }
        }
        for(long long i = k + 1; i <= n; i++) {
            for(long long j = i - k; j < i; j++) {
                dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
            }
        }
        cout << dp[n] << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin >> a[i];

  ll sum = 0;
  for(int i=0;i<n;i++) sum += a[i];

  ll x = a[0];
  ll ans = abs(sum-x-x);
  for(int i=1;i<n-1;i++){
    x += a[i];
    ll y = sum - x;
    ans = min(ans,abs(x-y));
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
import sys
import math
from collections import deque
from decimal import Decimal

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(float, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


#隣接リスト 1-order
def make_adjlist_d(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
        res[edge[1]].append(edge[0])
    return res


def make_adjlist_nond(n, edges):
    res = [[] for _ in range(n + 1)]
    for edge in edges:
        res[edge[0]].append(edge[1])
    return res


#nCr
def cmb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)


def main():
    A, B = input().split()
    print(int(Decimal(A) * Decimal(B)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 10088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define show(ans)  cout << ans << endl;


int main() {long L;
cin >> L;
vector<long> ans1, ans2, ans3;
long r = 1;
while(pow(2, r) <= L) r++;
r--;
erep(i, r){
    ans1.push_back(i); ans2.push_back(i+1); ans3.push_back(0);
    ans1.push_back(i); ans2.push_back(i+1); ans3.push_back(pow(2, i-1));

    // cout << i << ' ' << i+1 << ' ' << 0 << endl;
    // cout << i << ' ' << i+1 << ' ' << pow(2, i-1) << endl;
}
long X = L - (pow(2, r));
long tmp = pow(2, r);
for(long i = r-1; i >= 0; i--){
    if((1 << i) & X){
        // cout << i+1 << ' ' << r+1 << ' ' << tmp << endl;
    ans1.push_back(i+1); ans2.push_back(r+1); ans3.push_back(tmp);
        tmp += pow(2, i);
    }
}
cout << r+1 << ' ' << ans1.size() << endl;
rep(i, ans1.size()){
    cout << ans1[i] << ' ' << ans2[i] << ' ' << ans3[i] << endl;
}

// show(ans);
  return 0;
 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	int n; ll a, b;
	cin >> n >> a >> b;
	vector<ll> x(n);
	rep(i, n) cin >> x[i];
	ll cnt = 0;
	rep(i, n - 1){
		cnt += min((x[i + 1] - x[i]) * a, b);
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void dfs(const vector<vector<int>> &v, vector<int> &counter, vector<int> &visited, int depth)
{
    visited[depth] = 1;
    for(int i = 0; i < v[depth].size(); i++)
    {
        int u = v[depth][i];
        if(visited[u]) continue;
        counter[u] += counter[depth];
        dfs(v, counter, visited, u);
    }
}

void solve()
{
    int n, q; cin >> n >> q;
    vector<vector<int>> v(n);
    vector<int> counter(n, 0);
    vector<int> visited(n, 0);
    for(int i = 0; i < n - 1; i++)
    {
        int a, b; cin >> a >> b;
        a--, b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i = 0; i < q; i++)
    {
        int p, x; cin >> p >> x;
        p--;
        counter[p] += x;
    }

    dfs(v, counter, visited, 0);

    cout << counter << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 27392
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
	int N,i,a;
	a=(int)pow(10,9)+7;
	scanf("%d",&N);
	long long int I=10,J=9,K=8,M;
	for (i=1;i<N;i++){
		I=(I*10) % a;
	}
	for (i=1;i<N;i++){
		J=(J*9) % a;
	}
	for (i=1;i<N;i++){
		K=(K*8) % a;
	}
	M = I-(2*J-K);
	while (M<0)
	{
		M=M+a;
	}
	
	printf("%lld",M);
	return 0;
}


Measured memory_bytes: 1720
#include <iostream>
#include <string>

int main() {
    bool s[100];
    for (int i = 0; i < 100; i++) s[i] = false;
    std::string str;
    std::cin >> str;
    for (auto c: str) {
        int i = c - 'a';
        if (s[i]) {
            std::cout << "no" << std::endl;
            return 0;
        }
        s[i] = true;
    }
    std::cout << "yes" << std::endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int s = scanner.nextInt();
        int h=s/3600;
        s=s%3600;
        int m=s/60;
        s=s%60;
        System.out.println(h+":"+m+":"+s);
    }
}



Measured memory_bytes: 26356
n, m = map(int, input().split())
sub_ls = []
for i in range(m):
    p, s = list(map(str, input().split()))
    p = int(p)-1
    sub_ls.append([p,s])
ac_cnt = []
wa_cnt = []
for i in range(n):
    ac_cnt.append(0)
    wa_cnt.append(0)
#print(ac_cnt, wa_cnt)
for i in range(m):
    if ac_cnt[sub_ls[i][0]] == 0:
        #print(sub_ls[i][1], ac_cnt[i])
        if sub_ls[i][1] == "AC":
            ac_cnt[sub_ls[i][0]] = 1
        else:
            wa_cnt[sub_ls[i][0]]+=1
ac_sum = 0
wa_sum = 0
for i in range(n):
    #print(ac_cnt[i], wa_cnt[i])
    ac_sum+=ac_cnt[i]
    if ac_cnt[i] == 1:
        wa_sum+=wa_cnt[i]
print(ac_sum, wa_sum)


Measured memory_bytes: 24076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int main() {
  int n;
  cin>>n;
  vector<long>a(n);
  vector<long>t(n);
  long to=0;
  rep(i,n){
    cin>>a.at(i);
    to+=a.at(i);
    t.at(i)=to;
  }
  map<long,long>memo;
  memo[0]=1;
  rep(i,n){
    memo[t.at(i)]++;
  }
  long ans=0;
  for(auto p:memo){
    auto k=p.second;
    ans+=k*(k-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="SUN")cout<<"7\n";
	else if(s=="MON")cout<<"6\n";
	else if(s=="TUE")cout<<"5\n";
	else if(s=="WED")cout<<"4\n";
	else if(s=="THU")cout<<"3\n";
	else if(s=="FRI")cout<<"2\n";
	else if(s=="SAT")cout<<"1\n";
	return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll mod_pow(ll x, ll n) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % MOD, n / 2);
  if (n & 1) res = res * x % MOD;
  return res;
}

int main() {
  int n, k;
  cin >> n >> k;
  ll ans = mod_pow(k, n);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3104
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    };
    println!("{}", n + n * n + n * n * n);
}


Measured memory_bytes: 2164
from collections import defaultdict

x, n = map(int, input().split())
p = list(map(int, input().split()))
h = defaultdict(lambda: False)
for i in p:
    h[i] = True
i = 0
while True:
    if not h[x - i]:
        print(x - i)
        break
    if not h[x + i]:
        print(x + i)
        break
    i += 1


Measured memory_bytes: 9472