akhauriyash/Code-Regression huggingface dataset:
// SeeAlso: https://atcoder.jp/contests/abc056/tasks/abc056_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 50
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

ll W, a, b;

int main() {
    cin >> W >> a >> b;
    ll ans;
    if(a<b) {
        if((a+W)<b) {
            ans = abs(b-a-W);
        } else {
            ans = 0;
        }
    } else {
        if((b+W)<a) {
            ans = abs(a-b-W); 
        } else {
            ans = 0;
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N,A,B,i;
	cin>>N>>A>>B;
	int maxV=min(A,B);
	vector<int> x(N,0);
	for (i=0;i<A;i++){
		x[i]=1;
	}
	for (i=0;i<B;i++){
		x[i]+=1;
	}
	int minV=0;
	int minAB=min(A,B);
	for (i=0;i<minAB;i++){
		x[N-1-i]+=1;
		if (x[N-1-i]>1){
			minV++;
		}
	}


	cout<<maxV<<" "<<minV<<endl;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define SZ(x) ((int)(x).size())
#define TC(tc) while (tc--)
#define VI vector<int>
#define PII pair<int, int>
#define trav(a,x) for (auto& a : x)
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;


int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int a, b, n; cin >> a >> b >> n;
    int c = 0;
    int tmp = n;
    while (n <= b)
    {
        if (n >= a) c++;
        n += tmp;
    }
    cout << c;

    return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
 
typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;
 
#define for01(k,n)  for (ll i=k; i<n; i++)
#define for02(k,n)  for (ll j=k; j<n; j++)
#define for03(k,n)  for (ll k=k; k<n; k++)
#define for11(k,n)  for (ll i=k; i<=n; i++)
#define for12(k,n)  for (ll j=k; j<=n; j++)
#define for13(k,n)  for (ll k=k; k<=n; k++)

#define pb push_back
#define mp make_pair
#define pf push_front
#define popf pop_front
#define popb pop_back
#define vll vector<ll>
#define F first
#define S second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)

#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"


#define MAX LLONG_MAX

#define MIN LLONG_MIN

using namespace std;
ll ans = 0;
int findCombinations(string str, int index, 
                      ll out) 
{ 
    if (index == str.length()) 
        ans+=out; 
  
    for (int i = index; i < str.length(); i++) 
        findCombinations(str, i + 1, out + stoll(str.substr(index, i+1-index))); 
} 


int main()
{
  ll n;
  cin >> n;
  
  string s = to_string(n);
  findCombinations(s, 0 ,0);
  
  p1(ans);
  
  return 0;
}

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

class Program {
    static void Main(string[] args) {

        string s = Console.ReadLine();

        int result = 0;


        for(int a=0;a< s.Length / 2; a++) {
            int b = s.Length - 1 - a;

            if (s.Substring(a, 1) != s.Substring(b, 1)) result++;
        }

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 11092
#include<iostream>

int n,h,max=0,res=0;

int main(){

    std::cin>>n;

    for(int i=0;i<n;i++){
        std::cin>>h;
        if(max<=h){
            max=h;
            res++;
        }
    }

    std::cout<<res<<std::endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
/*
struct S{
    string St;
    int ten;
    int Num;
};
bool cmp(const S &a, const S &b){
    if(a.St != b.St){
        return a.St < b.St;
    }else if(a.ten != b.ten){
        return a.ten > b.ten;
    }else
        return a.Num < b.Num;
}
 */
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N,M;
    int k;
    int tmp;
    int sw[10];
    vector <int> s[10];
    vector <int> p;
    cin >> N >> M;
    FOR(i,0,M){
        cin >> k;
        FOR(j,0,k){
            cin >> tmp;
            s[i].push_back(tmp);
        }
    }
    FOR(i,0,M){
        cin >> tmp;
        p.push_back(tmp);
    }
    int summ =0;
    FOR(i,0,pow(2,N)){
        tmp = i;
        FOR(j,0,N){
            sw[j] = tmp % 2; tmp /=2;
        }
        FOR(j,0,M){
            int sum =0;
            FOR(l,0,N){
                if(sw[l] ==1){
                    FOR(m,0,s[j].size()){
                        if(s[j][m] == l+1)
                            sum++;
                    }
                }
            }
            if(sum%2 != p[j])
                break;
            if(j ==M-1)
                summ++;
        }
    }
    cout << summ;
    return 0;
}

Measured memory_bytes: 384
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    cin >> N;

    //本文
    ll num = to_string(N).size();
    ll ans = 0;
    if(num==6){
      ans = 9 + 900 + 90000;
    }
    if(num==5){
      ans = 9 + 900 + N-9999;
    }
    if(num==4){
      ans = 9 + 900;
    }
    if(num==3){
      ans = 9 + N-99;
    }
    if(num==2){
      ans =9;
    }
    if(num==1){
      ans = N;
    }
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3784
#include "bits/stdc++.h"
using namespace std;

#define ub upper_bound
#define sum(a) accumulate(all(a),0ll)
#define lb lower_bound
#define all(v) begin(v),end(v)
#define allr(v) rbegin(v),rend(v)
#define sort_dec(v) sort(all(v),[](auto e1,auto e2){return e1>e2;})
#define For(n) for(ll i=0;i<n;i++)
#define Forj(n) for(ll j=0;j<n;j++)
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define Mp 1e9+7
#define vpll vector< pair<ll,ll> >
#define bug(n) {cout<<n;return;}
#define cont(n) {cout<<n<<endl;continue;}
#define pb push_back
 
void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	For(n)cin>>a[i];
	ll dp[n];
	dp[0]=0;dp[1]=abs(a[0]-a[1]);
	rep(i,2,n)dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	// For(n)cout<<dp[i]<<" ";cout<<endl;
	cout<<dp[n-1];
}
 
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	 
	// freopen("error.txt", "w", stderr);
	 
	int t=1;
	 
	while(t--)
	{
		solve();
	}

	cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	 
	return 0;
}

Measured memory_bytes: 5336
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();

        System.out.printf("%d %d %.5f%n",a / b, a % b, (double)a / (double)b);
    }

}

Measured memory_bytes: 17340
#include<bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
#define ll long long

using namespace std;

inline int read()
{
    char ch=getchar(); int f=1,x=0;
    while (ch<'0' || ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
    while (ch>='0' && ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
    return f*x;
}

int n,r;
vector <pii> v;

signed main()
{
    n=read();
    int r=n&1 ? n-1 : n;
    for (int i=1;i<=n;i++)
    {
        for (int j=i+1;j<=n;j++)
        {
            if (j==r) continue;
            v.emplace_back(mp(i,j));
        }
        r--;
    }
    printf("%lu\n",v.size());
    for (auto i:v) printf("%d %d\n",i.first,i.second);
    return 0;
}

Measured memory_bytes: 384
use proconio::input;

const A: usize = 1000_000;

fn main() {
    input! { n: usize }
    let mut a = vec![0; n];
    let mut ac = vec![0; A + 1];
    for i in 0..n {
        input! { ai: usize }
        a[i] = ai;
        ac[ai] += 1;
    }

    let mut pc = true;
    for i in 2..=A {
        let mut c = 0;
        for j in (0..=A).skip(i).step_by(i) {
            c += ac[j];
        }
        if c > 1 {
            pc = false;
            break;
        }
    }

    println!("{} coprime", if pc {
        "pairwise"
    } else {
        let mut v = a[0];
        for i in 1..n {
            v = num_integer::gcd(a[i], v);
        }
        if v == 1 {
            "setwise"
        } else {
            "not"
        }
    });
}


Measured memory_bytes: 20452
#include <iostream>
#include <vector>
typedef long long ll;
using namespace std;

int main()
{
    ll n, m;
    cin >> n >> m;
    
    ll ans = 1;
    
    for (ll i = 1; i * i <= m; i++)
    { 
        if (m % i != 0) continue;
        
        ll f = m / i;
        if (i * n <= m)
        {
            ans = max(ans, i);
        }
        
        if (f * n <= m)
        {
            ans = max(ans, f);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

long int M = 1e+9+7;
int main(void){
    string n;
    cin >> n;
    vvi dp(n.size()+1, vi(2));
    int nsize = n.size();
    dp[0][0] = 0;
    dp[0][1] = 1;
    rep(i,nsize){
        int ai = n[i]-'0';
        dp[i+1][0] = min(dp[i][0]+ai, dp[i][1]+10-ai);
        dp[i+1][1] = min(dp[i][0]+ai+1, dp[i][1]+9-ai);
    }
    cout << dp[nsize][0] << endl;
    return 0;
}

Measured memory_bytes: 55940
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, a[100001];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n + 1; i++) cin >> a[i];
	long long cnt = 0;
	for(int i = 0; i < n; i++){
		int b, left;
		cin >> b;
		left = b;
		left = max(0, left - a[i]);
		cnt += b - left;
		if(a[i + 1] >= left) cnt += left;
		else cnt += a[i + 1];
		a[i + 1] = max(0, a[i + 1] - left);
	}
	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
typedef pair<int,P> PP;

void Main() {
  int n,m,m1,m2,s,t;
  while(cin >> n >> m >> m1 >> m2 >> s >> t && n) {
    set<int> se;
    rep(i,m1) {
      int x;
      R x;
      se.in(x);
    }
    vector<P> v[n];
    rep(i,m2) {
      int x,y,z;
      cin >> x >> y >> z;
      v[x].pb(P(y,z));
      v[y].pb(P(x,z));
    }
    int d[n][m+1];
    rep(i,n)rep(j,m+1) d[i][j]=MAX;
    d[s][m]=0;
    priority_queue<PP,vector<PP>,greater<PP> > que;
    que.push(PP(0,P(s,m)));
    while(!que.empty()) {
      PP p=que.top();que.pop();
      int x=p.S.F,k=p.S.S,cc=p.F;
      if(d[x][k]<cc) continue;
      rep(i,v[x].size()) {
        int y=v[x][i].F,c=v[x][i].S;
        rep(j,m+1) {
          if(j&&!se.count(x)||j+k>m) break;
          if(j+k-c>=0&&d[y][j+k-c]>d[x][k]+c+j) {
            d[y][j+k-c]=d[x][k]+c+j;
            que.push(PP(d[y][j+k-c],P(y,j+k-c)));
          }
        }
      }
    }
    int ans=MAX;
    rep(i,m+1) ans=min(ans,d[t][i]);
    if(ans==MAX) pr("Help!");
    else pr(ans);
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3448
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let m: usize = sc.read();
    let dc = (0..m)
        .map(|_| (sc.read::<u64>(), sc.read::<usize>()))
        .collect::<Vec<_>>();

    let mut res = vec![];
    for (d, c) in dc.into_iter() {
        let r = reduce(d, c);
        res.push(r);
    }
    let (_, ans) = reduce_v(res);
    println!("{:?}", ans - 1);
}

fn reduce(d: u64, mut c: usize) -> (u64, usize) {
    let mut res = vec![];
    let mut cur = d;
    let mut count = 1;
    while c > 0 {
        if c & 1 == 1 {
            res.push((cur, count));
        }
        cur = cur * 2;
        c >>= 1;
        count *= 2;
        if cur >= 10 {
            assert!(cur <= 18);
            cur = cur % 10 + cur / 10;
            count += 1;
        }
    }
    reduce_v(res)
}

fn reduce_v(res: Vec<(u64, usize)>) -> (u64, usize) {
    let mut cur = 0;
    let mut ans = 0;
    for (r, count) in res.into_iter() {
        cur += r;
        ans += count;
        if cur >= 10 {
            assert!(cur <= 18);
            cur = cur % 10 + cur / 10;
            ans += 1;
        }
    }
    (cur, ans)
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write(&mut self, s: String) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const set<T> &v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T,S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T,S> &v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "TRACE ON! (Line: " << __LINE__ << ")\n"; auto _stream = istringstream{string{#args}}; d_f(_stream, args); } while(0)
	void d_f(__attribute__((unused)) istringstream& _stream) {}
	template<typename Head, typename... Tails> void d_f(istringstream& _stream, Head H, Tails... T) { string _name; _stream >> _name; if(_name.back() == ',') _name.pop_back(); cerr << "\t" << _name << " <=> [" << H << "]\n"; d_f(_stream, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	string s, t;
	cin >> s >> t;

	int changes = 0;
	for(int i = 0; i < s.size(); ++i)
		changes += s[i] != t[i];

	cout << changes << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3800
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
class trie
{
public:
	int nxt[100000][11];
	int cst[100000];
	int fail[100000];//failure link
	int fc[100000];//failure linkの合計コスト
	int pt;
	void init()
	{
		pt = 1;
		fill(nxt[0], nxt[0] + 11, -1);
	}
	void add(string s, int t)
	{
		int now = 0;
		for (int i = 0; i < s.size(); i++)
		{
			if (nxt[now][s[i] - '0'] == -1)
			{
				fill(nxt[pt], nxt[pt] + 11, -1);
				nxt[now][s[i] - '0'] = pt++;
			}
			now = nxt[now][s[i] - '0'];
		}
		cst[now] += t;
	}
	void makefail(string s)
	{
		int zz = 0;
		for (int i = 0; i < s.size(); i++)zz = nxt[zz][s[i] - '0'];
		int c = 0;
		for (int i = 0; i < s.size(); i++)
		{
			bool f = true;
			int now = 0;
			for (int j = i + 1; j < s.size(); j++)
			{
				if (nxt[now][s[j] - '0'] == -1)
				{
					f = false;
					break;
				}
				now = nxt[now][s[j] - '0'];
				c += cst[now];
			}
			if (f)
			{
				fail[zz] = now;
				fc[zz] = c;
				break;
			}
		}
	}
	void dfs(int node, string s)//addをやったあとこれを(0,"")で呼べばfailure linkができる
	{
		for (int i = 0; i < 11; i++)
		{
			if (nxt[node][i] != -1)
			{
				s.push_back('0' + i);
				makefail(s);
				dfs(nxt[node][i], s);
				s.pop_back();
			}
		}
	}
};
trie tr;
ll dp[41][100000];
ll mod = 1000000007;
vector<string>zv;
void dfs(int g, string s)
{
	if (g == 0)zv.push_back(s);
	for (int i = 1; i <= g; i++)
	{
		s.push_back(i + '0');
		dfs(g - i, s);
		s.pop_back();
	}
}
int main()
{
	int num;
	int g[3];
	scanf("%d%d%d%d", &num, &g[0], &g[1], &g[2]);
	vector<string>now;
	now.push_back("");
	for (int i = 0; i < 3; i++)
	{
		zv.clear();
		dfs(g[i], "");
		vector<string>z;
		for (int j = 0; j < now.size(); j++)for (int k = 0; k < zv.size(); k++)z.push_back(now[j] + zv[k]);
		now = z;
	}
	tr.init();
	for (int i = 0; i < now.size(); i++)tr.add(now[i], 1);
	tr.dfs(0, "");
	dp[0][0] = 1;
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < tr.pt; j++)
		{
			for (int k = 1; k <= 10; k++)
			{
				if (tr.nxt[j][k] == -1)
				{
					bool f = true;
					int n = j;
					int x = 0;
					for (;;)
					{
						if (tr.fc[n] != 0)
						{
							f = false;
							break;
						}
						n = tr.fail[n];
						if (tr.nxt[n][k] != -1)
						{
							x = tr.nxt[n][k];
							if (tr.cst[x] != 0)
							{
								f = false;
							}
							break;
						}
						if (n == 0)break;
					}
					if (!f)continue;
					dp[i + 1][x] += dp[i][j];
					dp[i + 1][x] %= mod;
				}
				else
				{
					int x = tr.nxt[j][k];
					if (tr.cst[x] != 0)continue;
					dp[i + 1][x] += dp[i][j];
					dp[i + 1][x] %= mod;
				}
			}
		}
	}
	ll ans = 1;
	for (int i = 0; i < num; i++)ans = (ans * 10) % mod;
	for (int i = 0; i < tr.pt; i++)
	{
		int c = 0;
		int now = i;
		for (;;)
		{
			if (now == 0)break;
			c += tr.fc[now];
			now = tr.fail[now];
		}
		if (c == 0)
		{
			ans += mod - dp[num][i];
			ans %= mod;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 13948
#include <iostream>
#include <stack>
#include <vector>

#define FLAT 0
#define DOWN 1
#define FILL 2

using namespace std;

struct Token {
  int type;
  int width;
  int size;
};

int main() {
  stack<Token> S;
  char ch;
  int ndown = 0;
  Token token, v;

  while (cin >> ch) {
    switch (ch) {
    case '/':
      if (ndown == 0)
        break;
      token = Token{FILL, 1, 0};
      while (1) {
        v = S.top();
        S.pop();
        token.width += v.width;
        token.size += v.size;
        if (v.type == DOWN) {
          ndown--;
          break;
        }
        if (v.type == FILL) {
          token.size += v.width;
        }
      }
      S.push(token);
      break;
    case '\\':
      S.push(Token{DOWN, 1, 1});
      ndown++;
      break;
    case '_':
      S.push(Token{FLAT, 1, 1});
      break;
    }
  }

  vector<int> result;
  int sum = 0;
  while (!S.empty()) {
    token = S.top();
    if (token.type == FILL) {
      result.push_back(token.size);
      sum += token.size;
    }
    S.pop();
  }

  cout << sum << endl;
  cout << result.size();
  for (int i = result.size() - 1; i >= 0; i--) {
    cout << " " << result[i];
  }
  cout << endl;
}

Measured memory_bytes: 3236
import numpy as np
import sys
input = sys.stdin.readline

N, M, Q = map(int, input().split())
city = np.zeros((N + 2, N + 1), dtype=np.int)

for _ in range(M):
    L, R = map(int, input().split())
    city[L][R] += 1

np.cumsum(city, axis=0, out=city)
np.cumsum(city, axis=1, out=city)

for _ in range(Q):
    p, q = map(int, input().split())
    print(city[q][q] - city[q][p - 1] - city[p - 1][q] + city[p - 1][p - 1])

Measured memory_bytes: 16976
#include<stdio.h>
int A[100];

//Output function
void printSequence(int length, int num){
    int i;
    for(i=0; i<length; i++){
        if(i!=0)printf(" ");
        printf("%d",A[i]);
    }

    printf("\n");
    printf("%d\n",num);

}

int main(){
    int key=0, num=0, length, i, j;

    scanf("%d", &length);
    for(i=0; i<length; i++){
        scanf("%d",&A[i]);
    }


    //Bubble Sort Algo
    for(i=0; i<=length-1; i++){
        for(j=length-1; j>=i+1; j--){
            if(A[j] < A[j-1]){
                key = A[j];
                A[j] = A[j-1];
                A[j-1] = key;
                num++;
            }
        }
    }

    printSequence(length, num);

    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 200005;

ll N, A, ans = 0;
vector<int> a;
int add[MX];

void solve() {
    cin >> N; a.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (i - (a[i] - 1) >= 0) add[i - (a[i] - 1)]++;
    }
    
    for (int i = 0; i < N; i++) {
        if (i + a[i] + 1 < N) ans += add[i + a[i] + 1];
    }
    cout << ans;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
int tag[100000+5]={0};
int main(){
	int n,k;
	cin>>n>>k;
	int p ,s, r;
	cin>>r>>s>>p;
	int ans=0;
	string ss;
	cin>>ss;
	for(int i=0;i<ss.size();i++){
		if(ss[i]=='p') ss[i]='s';
		else if(ss[i]=='r') ss[i]='p';
		else if(ss[i]=='s') ss[i]='r';
	}
//	cout<<ss<<endl;
	ans=0;
	for(int i=0;i<ss.size();i++){
		if(i<k){
			if(ss[i]=='p') ans+=p;
			else if(ss[i]=='s') ans+=s;
			else if(ss[i]=='r') ans+=r;	
			tag[i]=1;	
		}
		else{
			if(ss[i]!=ss[i-k] || tag[i-k]==0){
				if(ss[i]=='p') ans+=p;
				else if(ss[i]=='s') ans+=s;
				else if(ss[i]=='r') ans+=r;
				tag[i]=1;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;
using ll = long long;

int main() {
  ll N;
  cin >> N;

  stack<char> s;
  while (0 < N) {
    bool is_z = N % 26 == 0;
    int p = N % 26 - 1;
    if (is_z) p = 25;
    char c = p + 'a';
    s.push(c);
    N = N / 26;
    if (is_z) N--;
  }

  while (!s.empty()) {
    cout << s.top(); s.pop();
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3636
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    let mut xs: Vec<i64> = sc.vec(n);
    xs.sort();
    let mut queries: Vec<_> = (0..m).map(|_| {
        let b: usize = sc.cin();
        let c: i64 = sc.cin();
        (c, b)
    }).collect();
    queries.sort();
    queries.reverse();

    let mut i = 0;
    for &(c, b) in queries.iter() {
        if i >= n { break }
        for _ in 0..b {
            if xs[i] >= c { break }
            xs[i] = c;
            i += 1;
            if i >= n { break }
        }
    }

    put!(xs.iter().sum::<i64>());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 12532
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef pair<int,int> P;



int main() {
    long int x, k, d;
    cin >> x >> k >> d;
    
    x = abs(x);
    long int cnt = x / d;
    long int pu = x - d * cnt;
    long int mi = x - d * (cnt+1);
    
    if(k < cnt)
        cout << x - d * k << endl;
    else if((k - cnt) % 2 == 1)
        cout << abs(mi) << endl;
    else
        cout << pu << endl;
    
    return 0;
}




Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {
  int N, L; std::cin >> N >> L;

  int ideal = 0;
  int bite = std::numeric_limits<int>::max();
  for(int i=1; i<=N; i++) {
    ideal += (L+i-1);
    if ( std::abs(bite) > std::abs(L+i-1) ) bite = (L+i-1);
  }

  std::cout << ideal - bite << std::endl;

  return 0;
}


Measured memory_bytes: 256
MOD = 10 ** 9 + 7
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
res = 0
for i in range(N - 1):
    cnt = 0
    _cnt = 0
    for j in range(i + 1, N):
        if A[i] < A[j]:
            cnt += 1
        elif A[i] > A[j]:
            _cnt += 1
    res += (cnt * (K - 1) * K // 2 + _cnt * K * (K + 1) // 2) % MOD
print(res % MOD)


Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define fs first
#define sc second
#define P pair<int, int>
#define mk_p make_pair
int n, a[200010];
map<int, int> mp;
char s[1111111];
int main(){
	string a, b, c;
	int x, y;
	cin>>a>>b;
	cin>>x>>y;
	cin>>c;
	if(a == c)x--;
	else y--;
	printf("%d %d\n", x, y);
	return 0;
}

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

const int Maxn = 100005;
struct node {
  long long l, r, x, d;
  node(long long l, long long r, long long x, long long d) : 
    l(l), r(r), x(x), d(d) { }
  node() { l = r = x = d = 0; }
  bool operator<(const node &b) const {
    return l < b.l;
  }
};
int n, b[Maxn];
long long k, ans;
long long a[Maxn];
set <node> st;
int main() {
  scanf("%d %lld", &n, &k), ans = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%lld %d", a + i, b + i);
    ans += (a[i] <<= 1);
    if (a[i] > k && b[i] == 1) 
      return puts("-1") & 0;
    if (b[i] == 2) a[i] %= k;
  } st.insert({0, k, 0, 0});
  long long cur = 0;
  for (int i = 0; i < n; ++i) {
    long long d = a[i];
    long long nx = cur + d;
    (nx > k) && (nx -= k);
    if (b[i] == 1) {
      if (cur < nx) {
        auto it = st.lower_bound({cur, 0, 0, 0});
        while (it -> r < nx) st.erase(it ++);
        node x1 = *it, x2 = *it;
        st.erase(it), x2.l = nx;
        long long now = x2.x + x2.d * (x2.r - nx);
        x1 = node(cur, nx, now, 1);
        st.insert(x1);
        if (x2.l ^ x2.r) st.insert(x2);
      } else {
        auto it = st.lower_bound({cur, 0, 0, 0});
        while (it != st.end()) st.erase(it ++);
        it = st.begin();
        while (it -> r < nx) st.erase(it ++);
        node x1 = *it, x2 = *it;
        st.erase(it), x2.l = nx;
        long long now = x2.x + x2.d * (x2.r - nx);
        x1 = node(0, nx, now, 1);
        st.insert(x1);
        if (x2.l != x2.r) st.insert(x2);
        now = x1.x + x1.d * x1.r;
        x2 = node(cur, k, now, 1);
        st.insert(x2);
      } cur = (cur + a[i]) % k;
    } else {
      (cur += a[i]) %= k;
      auto it = st.lower_bound({cur, 0, 0, 0});
      if (it == st.begin()) continue;
      if ((-- it) -> r <= cur) continue;
      node x1 = *it, x2 = *it;
      st.erase(it), x2.l = cur;
      x1.x = x2.x + x2.d * (x2.r - cur);
      x1.r = cur;
      st.insert(x1), st.insert(x2);
    }
  }
  long long mn = st.begin() -> x;
  for (auto x: st)
    mn = min(mn, x.x);
  printf("%lld\n", ans + mn);
  return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

#define INF 100000000

LL mod = 1000000007;

LL N;
string S;

LL mpow(LL a, LL b)
{
	LL ret = 1;
	for (LL i = 0; i < b; i++)
		ret = (ret*a) % mod;
	return ret;
}

int main()
{
	cin >> S;
	N = S.size();

	LL m = 1, a = 0, b = 0, c = 0;
	for (int n = 0; n < N; n++)
	{
		if (S[n] == 'A')
			a += m;
		if (S[n] == 'B')
			b += a;
		if (S[n] == 'C')
			c += b;
		if (S[n] == '?')
		{
			c = 3*c + b;
			b = 3*b + a;
			a = 3*a + m;
			m *= 3;
		}
		a %= mod, b %= mod, c %= mod, m %= mod;
	}
	cout << (c % mod) << endl;
}



Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int h,w;
  cin >> h >> w;
  char s[h][w];
  int dx[8]={1,1,0,-1,-1,-1,0,1};
  int dy[8]={0,1,1,1,0,-1,-1,-1};
  rep(i,h){
    rep(j,w){
      cin >> s[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      char cnt='0';
      if(s[i][j]=='.'){
        rep(k,8){
          int x=j+dx[k];
          int y=i+dy[k];
          if(x>=0&& x<w && y>=0 && y<h && s[i+dy[k]][j+dx[k]]=='#'){
            cnt++;
          }
        }
         s[i][j]=cnt;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      cout<<s[i][j];
    }
    cout << endl;
  }
}
   
      

Measured memory_bytes: 256
n,c=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(c)]
board=[list(map(int,input().split())) for _ in range(n)]
cnt=[[0]*c for _ in range(3)]
for i in range(n):
  for j in range(n):
    cnt[(i+j)%3][board[i][j]-1]+=1
ans=10**10
for i in range(c):
  for j in range(c):
    if i==j:
      continue
    for k in range(c):
      if i==k or j==k:
        continue
      tmp=0
      for l in range(c):
        tmp+=d[l][i]*cnt[0][l]
        tmp+=d[l][j]*cnt[1][l]
        tmp+=d[l][k]*cnt[2][l]
      ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 5620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		int ans = 0;
		int i;
		int length;
		for(i = 1; i <= n; i++) {
			length = String.valueOf(i).length();
			if(!(length % 2 == 0))
				ans++;
		}
		System.out.println(ans);
	}
}


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

using namespace std;
int MAXV = 0;
auto M = 2147483647 /2;
int main()
{
	int N, W;
	cin >> N >> W;
	vector<int>w(N + 1), v(N + 1);
	
	for (int k = 0; k < N; k++)
	{

		cin >> w[k] >> v[k];
		MAXV += v[k];
	}
	vector<vector<int>> dp(N + 1, vector<int>(MAXV+1));
	for (int k = 0; k <= MAXV; k++)
	{
		dp[0][k] = M;
	}

	dp[0][0] = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j <= MAXV; j++)
		{
			if (j < v[i])
				dp[i + 1][j] = dp[i][j];
			else dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
		}
	}
	int res = 0;
	for (int i = 0; i <= MAXV; i++)
	{
		if (dp[N][i] <= W)
		{
			res = i;
		}
	}
	cout << res;
}




Measured memory_bytes: 40192
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

namespace mine
{
    const int MAXN=110000;

    int n;

    int tr[2*MAXN];
    int lowbit(int x) {return x&-x;}
    void change(int d)
    {
        d+=MAXN;
        while(d<2*MAXN) tr[d]++,d+=lowbit(d);
    }
    int sum(int d)
    {
        d+=MAXN;
        int ans=0;
        while(d>=1) ans+=tr[d],d-=lowbit(d);
        return ans;
    }

    int a[MAXN],b[MAXN];
    int c[MAXN];

    typedef long long ll;//debug 爆int 
    bool check(int now)
    {
        for(int i=1;i<=n;i++) c[i]=c[i-1]+(a[i]<=now?1:-1);//1小于等于,-1大于

        memset(tr,0,sizeof tr);//debug
        change(c[0]);//debug 

        ll tot=0;//<=now的数，产生的贡献 
        for(int r=1;r<=n;r++)
        {
            //c[r]-c[l-1]>0 => c[l-1]<c[r] (l-1<r)
            tot+=sum(c[r]-1);
            change(c[r]);
        }
        return tot>=ll(n+1)*n/4+1;
    }
    void main()
    {
        scanf("%d",&n);
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);

        int l=1,r=1e9,ans=-1;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(check(mid)) ans=mid,r=mid-1;
            else l=mid+1;
        }
        printf("%d",ans);
    }
};

int main()
{
    mine::main();
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <ctime>

#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
#define TT int test_cases; cin >> test_cases; while(test_cases--)
#define TT1 int test_cases=1; while(test_cases--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
using namespace std;
typedef long long int ll;

 
int main() {
    
    FAST;
    TT1{
        
        int n;cin>>n;
        vector<ll> a(n);
        ll s=0;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            s=s^a[i];
        }
        
        for(int i=0;i<n;i++)
        {
            ll d=s^a[i];
            cout<<d<<" ";
        }
        cout<<"\n";
        
        
    }
}

Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Teleporter | diff Teleporter.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Teleporter.cpp && ./a.out

/*
 
 5/10/2020
 
 5:12-
 
 */

const int MAX_N=1e6+1;
int A[MAX_N];
int N;
LL K;

int nex[MAX_N][64];
void solve_() {
  REP(i,N) nex[i][0]=A[i];
  REP(x,63)REP(i,N) nex[i][x+1]=nex[nex[i][x]][x];
  
  int res=0;
  REP(i,61)if((K>>i)&1) res=nex[res][i];
  cout<<res+1<<endl;
}

void solve() {
  int i=0,step=0;
  VI viz(N,-1);
  while(viz[i]==-1) {
    viz[i]=step;
    i=A[i],++step;
//    dump(i,step);
    if(step==K) {
      cout<<i+1<<endl;
      return;
    }
  }
  LL c=step-viz[i];
  LL rem=(K-viz[i])%c;
  dump(K,c,rem);
  
  while(rem--) i=A[i];
  cout<<i+1<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>K;
  REP(i,N) cin>>A[i],A[i]--;
  solve();
  
  return 0;
}


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

using namespace std;

class nck {
    vector<long long> inv;
    vector<long long> frac;
    vector<long long> frac_inv;
    int mod;

public:
    nck(int n, int m) {
        inv = vector<long long>(n + 1, 0);
        frac = vector<long long>(n + 1, 0);
        frac_inv = vector<long long>(n + 1, 0);
        mod = m;

        inv[1] = 1;
        frac[0] = frac[1] = 1;
        frac_inv[0] = frac_inv[1] = 1;
        for (int i = 2; i <= n; i++) {
            inv[i] = mod - (inv[mod % i] * (mod / i)) % mod;
            frac[i] = (frac[i - 1] * i) % mod;
            frac_inv[i] = (frac_inv[i - 1] * inv[i]) % mod;
        }
    }

    int calc(int n, int k) {
        return (frac[n] * frac_inv[k] % mod) * frac_inv[n - k] % mod;
    }
};

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

    int mod = 1000000007;
    nck nck(n, mod);

    long long res = 0;
    for (int i = 0; i <= min(k, n - 1); i++) {
        res += static_cast<long long>(nck.calc(n, i)) * nck.calc(n - 1, n - i - 1);
        res %= mod;
    }

    cout << res << endl;
}


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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vi vis(100001,0);
vi adj[100001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    int n;
    cin>>n;
    int a[n+1],b[n+1],c[n+1];
    a[0]=-50;
    for(int i=1; i<=n; ++i)
    	cin>>a[i];
    for(int i=1; i<=n; ++i)
    	cin>>b[i];
    for(int i=1; i<n; ++i)
    	cin>>c[i];
    int sum=0;
    for(int i=1; i<=n; ++i)
    {
    	if(a[i]-a[i-1]==1)
    		sum+=c[a[i-1]];
    	sum+=b[a[i]];
    }
    cout<<sum<<"\n";


}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	register int x=0;
	register bool f=0;
	register char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+c-48;
		c=getchar();
	}
	return f?-x:x;
}
char cr[200];int tt;
inline void print(register int x,register char k='\n') {
    if(!x) putchar('0');
    if(x < 0) putchar('-'),x=-x;
    while(x) cr[++tt]=x%10+'0',x/=10;
    while(tt) putchar(cr[tt--]);
    putchar(k);
}
const int maxn=100005;
struct node{
    int a, b;
    friend bool operator <(node x,node y){
    	return x.a-x.b>y.a-y.b;
	}
}f[maxn];
int ll[maxn],rr[maxn],x,y,z,ans,n;
priority_queue<int> q;
signed main() {
    x=read(),y=read(),z=read();
    n=x+y+z;
    for(int i=1;i<=n;i++) {
        int v=read();
        ans+=v;
        f[i].a=read()-v;
        f[i].b=read()-v;
    }
    sort(f+1,f+n+1);
    for(int i=1;i<=n;i++) {
        ll[i]=ll[i-1]+f[i].a;
        q.push(-f[i].a);
        if(q.size()>y) {
            ll[i]+=q.top();
            q.pop();
        }
    }
    while(!q.empty()) q.pop();
    for(int i=n;i;i--) {
        rr[i]=rr[i+1]+f[i].b;
        q.push(-f[i].b);
        if(q.size()>z) {
            rr[i]+=q.top();
            q.pop();
        }
    }
    int res=-1000000000000000000ll;
    for(int k=y;k<=n-z;k++)
        res=max(res,ll[k]+rr[k + 1]);
    print(ans+res);
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define pi 3.1415926536
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define INF 2147483647
#define _INF -2147483647
#define MM multimap
#define PB push_back
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    int r, D, x;
    cin >> r >> D >> x;
    rep(i, 0, 10) {
        int ans = r * x - D;
        cout << ans << endl;
        x = ans;
    }
    return 0;
}

Measured memory_bytes: 256