akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
template<int mod>
struct ModInt {
    using ll = long long; ll x;
    ModInt() : x(0) {}
    ModInt(int y) : x(y >= 0 ? ll(y % mod) : (ll)((mod - (-y) % mod))) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) { if((x += rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &rhs) { if((x += mod - rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &rhs) { x = x * rhs.x % mod; return *this; }
    ModInt &operator/=(const ModInt &rhs) { *this *= rhs.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.x; }
    friend istream &operator>>(istream &is, ModInt &rhs) { ll t; is >> t; rhs = ModInt<mod> (t); return (is); }
private:
    ModInt inverse() const { ll a = x, u = 1LL, v = 0LL, t, b = (ll)mod; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return  ModInt(u); }
};
using mint = ModInt<MOD>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    unordered_map<ll, int> count;
    vector<ll> A(N);
    rep(i, N){
        cin >> A[i];
        count[A[i]]++;
    }
    int ans = 0;
    for(auto &p : count){
        if(p.second & 1) ans++;
    }    
    cout << ans << endl;

    return 0;
}

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = (ll) 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 300005;


int main() {
    FAST
    ll n,k,dif;
    cin>>n>>k>>dif;
    n=abs(n);
    ll num=n/dif;
    if(n%dif==0){
       if(num>=k){
           cout<<n-(ll)(k*dif)<<endl;
       }
       else{
           if((k-num)%2==0){
               cout<<0<<endl;
           }
           else{
               cout<<dif<<endl;
           }
       }
    }
    else{
        if(num>=k){
            cout<<n-(ll)(k*dif)<<endl;
        }
        else {
            ll mod = n % dif;
            k -= num;
           if(mod<llabs(mod-dif)){
               if(k%2==0){
                   cout<<mod<<endl;
               }
               else{
                   cout<<min(llabs(mod-dif),mod+dif)<<endl;
               }
           }
           else{
               k--;
               if(k%2==0){
                   cout<<llabs(mod-dif)<<endl;
               }
               else{
                   cout<<min(llabs((mod-dif)-dif),mod)<<endl;
               }
           }
        }

    }
    return 0;
}


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }

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

    int N;
    std::cin >> N;
    if(N % 2 == 0) {
        std::cout << (N / 2) / (double)N << std::endl;
    }
    else {
        std::cout << (N / 2 + 1) / (double)N << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <limits>
#include <tuple>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

float inf = std::numeric_limits<float>::infinity();
ll mod = 1e9+7;

/* 二次元配列の宣言
  vector<vector<int>> tb;
  tb.resize(H);
  for (size_t i = 0; i < H; i++) {
    tb[i].resize(W);
  }
*/
/*
  A.resize(N);
  for (int i = 0; i < N; i++) {scanf("%d",&A[i]);}
*/

int max(int &a,int &b){if(a>b){return a;}else{return b;}}
int min(int &a,int &b){if(a>b){return b;}else{return a;}}

int ar_max(vector<int> &v){
  int max_val = v[0];
  for (size_t i = 1; i < v.size(); i++) {
    if (v[i]>max_val){max_val=v[i];}
  }
  return max_val;
}

int ar_min(vector<int> &v){
  int min_val = v[0];
  for (size_t i = 1; i < v.size(); i++) {
    if (v[i]<min_val){min_val=v[i];}
  }
  return min_val;
}


/* バイナリーサーチ(v,N,flag)
  flag = true -> return ind(int) 挿入index
  flag = false -> return in(0or1) 入ってるかどうか*/
int b_search(vector<int> &v, int &N, bool flag=true){
  sort(v.begin(),v.end());
  int left=0,right=v.size()-1,ind;
  if (N < v[left]){return 0;}
  if (N > v[right]){return right+1;}
  while(true){
    ind = (left+right)/2;
    if (v[ind]>N){right = ind;}
    else if(v[ind]<N){left = ind;}
    else if(v[ind]==N){
      if(flag){return ind;}
      else{return 1;}
    }

    /* 終了判定*/
    if (right-left<=1){
      if(flag){
        if(v[left]==N){
          return left;
        }else{
          return right;
        }
      }else{
        if(v[left]==N || v[right]==N){return 1;}
        else{return 0;}
      }
    }
  }
}


vector<int> prime_tb;
vector<vector<int>> ans_tb;
int max_pr=0;

/*素因数分解(N) ex:N=90(=2*3^2*5)
prime_tb = [2,3,5]
ans_tb = [[2,1][3,2][5,1]]*/
vector<vector<int>> prime_factor(int &N){
  int prime=2,ind;
  while (N>=2){
    if (N%prime==0){
      if(max_pr>=prime){/*既に出た素因数*/
        ind = b_search(prime_tb,prime);
        ans_tb[ind][1]++;
      }else if(max_pr<N){/*初めて素因数*/
        ind = prime_tb.size();
        ans_tb.push_back({prime,1});
        prime_tb.push_back(prime);
        max_pr = prime;
      }
      N /= prime;
      prime = 2;
    }else{
      prime ++;
    }
  }
  return ans_tb;
}

/*約数の数*/
int divsor_num(int &N){
  vector<vector<int>> pf_tb;
  int ans=1;
  pf_tb = prime_factor(N);
  for (size_t i = 0; i < pf_tb.size(); i++) {
    ans *= pf_tb[i][1]+1;
  }
  return ans;
}

int main(void) {
  int N;
  ll ans=1;
  vector<vector<int>> arr;
  cin >> N;
  FOR(i,2,N+1){
    int ii = i;
    ans_tb = prime_factor(ii);
  }
  REP(i,ans_tb.size()){
    ans *= ans_tb[i][1]+1;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,a[3][SZ];
struct bcj
{
int ff[SZ];
int gf(int x) {return ff[x]?ff[x]=gf(ff[x]):x;}
bool uni(int a,int b)
{
	int ga=gf(a),gb=gf(b);
	if(ga^gb) ff[ga]=gb;
	else return 0;
	return 1;
}
}b[2];
int main()
{
	scanf("%d",&n);
	for(int j=0;j<3;++j)
		for(int i=1;i<=n;++i)
			scanf("%d",&a[j][i]);
	int c[2][2];
	memset(c,0,sizeof c);
	for(int i=1;i<=n;++i)
	{
		int t=0;
		if(a[0][i]+1==a[1][i]&&a[1][i]+1==a[2][i])
			t=0;
		else
		if(a[0][i]-1==a[1][i]&&a[1][i]-1==a[2][i])
			t=1;
		else
		{
			puts("No");
			return 0;
		}
		int r=min(a[0][i],min(a[1][i],a[2][i]))/3+1;
		if((i-r)&1)
		{
			puts("No");
			return 0;
		}
		if(b[i&1].uni(i,r)) c[i&1][0]+=r-i-1;
		if(t) ++c[i&1][1];
	}
	c[0][0]&=1; c[1][1]&=1; c[1][0]&=1; c[0][1]&=1;
	if(c[0][0]!=c[1][1]||c[1][0]!=c[0][1])
		puts("No");
	else puts("Yes");
}


Measured memory_bytes: 10880
c=[10*[0]for _ in range(10)]
n=int(input())
for i in range(1,n+1):
  a=int(str(i)[0])
  b=int(str(i)[-1])
  c[a][b]+=1
ans=0
for i in range(1,10):
  for j in range(1,10):
    ans+=c[i][j]*c[j][i]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+10;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char ch=0; x=0;
	bool sign=false;
	while(ch<'0'||'9'<ch) sign|=ch=='-',ch=getchar();
	while('0'<=ch&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	x=sign?-x:x;
}
struct Segment_Tree{
	struct Node{
		ll val; 
		int stdl,stdr;
		Node *lson,*rson;
	};
	Node* root;
	Segment_Tree(){ root=new Node; }
	inline void build_tree(Node* now,int l,int r){
		now->val=0;
		now->stdl=l;
		now->stdr=r;
		if(l==r) return;
		build_tree(now->lson=new Node,l,(l+r)>>1);
		build_tree(now->rson=new Node,(l+r+2)>>1,r);
	}
	inline ll query(Node* now,int l,int r){
		ll ret=0;
		if(l<=now->stdl&&now->stdr<=r){
			ret=max(ret,now->val);
		} else {
			if(l<=(now->stdl+now->stdr)>>1){
				ret=max(ret,query(now->lson,l,r));
			}
			if(r>(now->stdl+now->stdr)>>1){
				ret=max(ret,query(now->rson,l,r));
			}
		}
		return ret;
	}
	inline void update(Node* now,int v,ll k){
		if(now->stdl==now->stdr){
			now->val=max(k,now->val);
		} else {
			if(v<=(now->stdl+now->stdr)>>1){
				update(now->lson,v,k);
			} else {
				update(now->rson,v,k);
			}
			now->val=max(now->lson->val,now->rson->val);
		}
	}
};
int hig[MAXN],val[MAXN];
int main(){
	int n;
	read(n);
	Segment_Tree St;
	St.build_tree(St.root,1,n);
	for(int i=0;i<n;++i){
		read(hig[i]);
	}
	for(int i=0;i<n;++i){
		read(val[i]);
	}
	ll ans(0);
	for(int i=0;i<n;++i){
		ll vvv=St.query(St.root,1,hig[i])+val[i];
		St.update(St.root,hig[i],vvv),ans=max(ans,vvv);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 20608
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
#from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,v = readInts()
b,w = readInts()
t = I()
ab = abs(a-b)
sa = abs(w - v)
if sa == 0:
    print('NO')
    exit()
if a == b:
    print('YES')
elif a < b and v <= w:
    print('NO')
elif a > b and v <= w:
    print('NO')
elif ab/sa <= t:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 10372
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>

using namespace std;

#define int_ int64_t
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=200010;

int n;
ll a[N];

int main()
{
    scanf("%d",&n);
    ll sum1=0,sum2=0;
    for (int i=1;i<=n;i++) {
        scanf("%lld",a+i);
        sum2+=a[i];
    }
    sum2-=a[1];
    sum1=a[1];
    int p1=1,p2=3;
    ll l1=a[1],l2=a[2]+a[3];
    ll ans=1e18;
    for (int i=2;i+2<=n;i++) {
        sum1+=a[i];
        sum2-=a[i];
        l2-=a[i];
        while (p1<i) {
            if (abs(2*l1-sum1)>abs(2*(l1+a[p1+1])-sum1)) {
                l1+=a[p1+1];
                p1++;
            } else {
                break;
            }
        }
        while (p2<n) {
            if (abs(2*l2-sum2)>abs(2*(l2+a[p2+1])-sum2)) {
                l2+=a[p2+1];
                p2++;
            } else {
                break;
            }
        }
        vector<ll> vec;
        vec.pb(l1);vec.pb(sum1-l1);vec.pb(l2);vec.pb(sum2-l2);
        sort(vec.begin(),vec.end());
        ans=min(ans,vec.back()-vec.front());
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1792
d = { "N" => [0, 1],
      "E" => [1, 0],
      "W" => [-1, 0],
      "S" => [0, -1] }

while true do
  n = gets.to_i
  break if n == 0

  field = Array.new(21, 0).map{ Array.new(21, 0) }
  gems = []
  n.times do
    gems << gets.split.map(&:to_i)
  end

  x, y = 10, 10
  field[x][y] = 1
  gets.to_i.times do
    dir, dis = gets.split
    dis.to_i.times do
      x += d[dir][0]
      y += d[dir][1]
      field[x][y] = 1
    end
  end

  count = 0
  gems.each do |gem|
    if field[gem[0]][gem[1]] == 1
      count += 1
    else
      break
    end
  end

  puts count == n ? "Yes" : "No"
end

Measured memory_bytes: 6132
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 100001
#define int long long
#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;
int n,x[N],m,k,d[N],p[N],tmp[N],w[N];
void mul(int a[],int b[])
{
	for(int i=1;i<n;++i)
		tmp[i]=a[b[i]];
	memcpy(a,tmp,sizeof tmp);
}
main()
{
	re(n);
	for(int i=1;i<=n;++i)re(x[i]);
	re(m),re(k);
	for(int i=1;i<n;++i)d[i]=p[i]=i;
	for(int x;m--;)
		re(x),swap(d[x],d[x-1]);
	while(k)
	{
		if(k&1)mul(p,d);
		mul(d,d);
		k>>=1;
	}
	for(int i=1;i<n;++i)
		w[i]=x[i+1]-x[i];
	mul(w,p);
	int now=x[1];
	for(int i=1;i<=n;++i)
	{
		printf("%lld\n",now);
		now+=w[i];
	}	
}

Measured memory_bytes: 5120
n = int(input())
t = [[0] * 10 for _ in range(10)]

for i in range(1, n+1):
    si = str(i)
    t[int(si[0])][int(si[-1])] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += t[i][j] * t[j][i]

print(ans)


Measured memory_bytes: 9160
#include <stdio.h>
#include <stdlib.h>
int a[999999];
int main(){
	int R,S,Q;
	scanf("%d%d%d",&R,&S,&Q);
	for(int i=0;i<Q;i++){
		int x,y;
		scanf("%d%d",&y,&x);x--;y--;
		if(x>=S)x=x-S+1;
		else x=S-x;
		a[i]=x+R-y;
	}
	qsort(a,Q,4,"\x8b\7+\6\xc3");
	for(int i=1;i<Q;i++)if(a[i]<a[i-1]+1)a[i]=a[i-1]+1;
	printf("%d\n",a[Q-1]);
}


Measured memory_bytes: 5424
function main(_stdin) {
    const stdin = _stdin.trim().split('\n');
    const n = Number(stdin.shift());
    const T = [];
    for (let i = 0; i < n; i++) {
        T[i] = {parent: null, left: null, right: null};
    }
    for (let i = 0; i < n; i++) {
        const [id, left, right] = stdin[i].split(' ').map(Number);
        T[id].left = left;
        T[id].right = right;
        if(left > -1) {
            T[left].parent = id;
        }
        if(right > -1) {
            T[right].parent = id;
        }
    }

    const rootid = getRootId(T);

    console.log('Preorder');
    const preids = [];
    preorder(rootid, T, preids);
    console.log('', preids.join(' '));

    console.log('Inorder');
    const inids = [];
    inorder(rootid, T, inids);
    console.log('', inids.join(' '));

    console.log('Postorder');
    const postids = [];
    postorder(rootid, T, postids);
    console.log('', postids.join(' '));
}

function getRootId(T) {
    for (let i = 0, l = T.length; i < l; i++) {
        if(T[i].parent === null) return i;
    }
}

function preorder(id, T, ids) {
    if(id === -1) {
        return;
    }
    ids.push(id);
    preorder(T[id].left, T, ids);
    preorder(T[id].right, T, ids);
}

function inorder(id, T, ids) {
    if(id === -1) {
        return;
    }
    inorder(T[id].left, T, ids);
    ids.push(id);
    inorder(T[id].right, T, ids);
}


function postorder(id, T, ids) {
    if(id === -1) {
        return;
    }
    postorder(T[id].left, T, ids);
    postorder(T[id].right, T, ids);
    ids.push(id);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 15168
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int a;
    cin>>a;
    int sum=0;
    int res=a;
    bool flag=true;
    while(flag){
        sum+=a%10;
        a=a/10;
        if(a==0){
            flag=false;
        }
    }
    if(res%sum==0){
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}

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


public class Contest
{
	public static void Main()
	{

/*
		int n = a[0];
		int[][] e = new int[n][];
		for(int i=0; i<n; i++) MyIO.ReadArray(out e[i]);

		int[] a;
		MyIO.ReadArray(out a);

        long a,b,c,d,e,f;
        MyIO.ReadMulti(out a, out b, out c, out d, out e, out f);

		MyIO.WriteArray(ans);
*/

        int k,x;
		MyIO.ReadMulti(out k, out x);

        List<int> ans = new List<int>();
		for(int i=Math.Max(-1000000,x-k+1);i<=Math.Min(1000000,x+k-1); i++) ans.Add(i);
		

		MyIO.WriteArray(ans.ToArray());
	}


}

public static class MyIO
{
	private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
	private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
	private static T cv<T>(string s) => eq<T, int>()    ? ct<T, int>(int.Parse(s))
	                                  : eq<T, long>()   ? ct<T, long>(long.Parse(s))
	                                  : eq<T, double>() ? ct<T, double>(double.Parse(s))
	                                  : eq<T, char>()   ? ct<T, char>(s[0])
	                                                    : ct<T, string>(s);
	public static string[] ReadArray<T>(out T[] a) {		
		var ar = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); 												
		a = System.Array.ConvertAll(ar, new Converter<string,T>(cv<T>));
		return ar;
	}										
	public static string[] ReadMulti<T>(out T a) {
		var ar = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); 
		a = cv<T>(ar[0]);
		return ar;
	}
	public static string[] ReadMulti<T, U>(out T a, out U b) {
		var ar = ReadMulti<T>(out a); 
        b = cv<U>(ar[1]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V>(out T a, out U b, out V c) {
		var ar = ReadMulti<T, U>(out a, out b); 
        c = cv<V>(ar[2]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W>(out T a, out U b, out V c, out W d) {
		var ar = ReadMulti<T, U, V>(out a, out b, out c); 
        d = cv<W>(ar[3]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
		var ar = ReadMulti<T, U, V, W>(out a, out b, out c, out d); 
        e = cv<X>(ar[4]);
		return ar;
	}
	public static string[] ReadMulti<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) {
		var ar = ReadMulti<T, U, V, W, X>(out a, out b, out c, out d, out e); 
        f = cv<Y>(ar[5]);
		return ar;
	}

	public static void WriteArray<T>(T[] a) {
		Console.WriteLine(string.Join(" ", Array.ConvertAll(a, x => x.ToString())));
	}


}




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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    double a,b;
    t = 1;
    while(t--) {
     cin >> a >> b;
     cout << ceil((a + b) / 2) << endl;
    }
    return 0;
}


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

long long int gcd(int a,int b){
	if(a<b){
		int c=a;
		a=b;
		b=c;
	}
	int r = a%b;
	while(r!=0){
		a = b;
		b = r;
		r = a%b;
	}
	return b;
}

int main(){
	const int MAX_N = 114514;
	int N;
	int M[MAX_N];
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%d",&M[i]);
	}
	int ans = M[0];
	for(int i=1;i<N;i++){
		ans = gcd(ans,M[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
using llong = long long;

llong a, v;
llong b, w;
llong t;

int main() {
    cin >> a >> v;
    cin >> b >> w;
    cin >> t;

    if (llabs(a - b) <= v * t - w * t) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }


    return 0;
}

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

int main()
{	
	int n;
	int a[100] = {0};
	cin >> n;
	for ( int i = 0; i < n; i++)
	{ 
		cin >> a[i];
	}
	
	int temp = 0;
	int sum = 0;

	for (int i= 0; i < n-1; i++ )
	{
		for ( int j = 0; j < n-1-i; j++ )
		{
			if ( a[j] > a[j+1] )
			{
				temp = a[j];
				a[j] = a[j+1];
				a[j+1] = temp;
				sum++;
			}
		}
	}

	for ( int i= 0; i < n; i++ )
	{
	cout << a[i];
	if ( i < n-1 )
	{
		cout << " ";
	}
	}

	cout << "\n" << sum << endl;

	return 0;
}


Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
int main(void){
	int n, k;
	int d;
	int *a;
	int sum = 0;
	scanf("%d", &n);
	scanf("%d", &k);
	a = (int *)malloc(sizeof(int) * n);
	for(int p=0; p<n; p++){
		a[p] = 0;
	}
	int tmp;
	for(int i=0; i<k; i++){
		scanf("%d", &d);
		for(int j=0; j<d; j++){
			scanf("%d", &tmp);
			a[tmp-1] = 1;
		}
	}
	for(int k=0; k<n; k++){
		if(a[k] == 0){
			sum++;
		}
	}
	printf("%d\n", sum);
	return 0;
}

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

int main(){
	int n;
	cin>>n;
	int res=0;
	int cnt=0;
	bool flag=false;
	bool flag2=false;
	res=res+n%10+(n/10%10)*10;
	cnt=cnt+n/100%10+n/1000*10;
	if(cnt>0&&cnt<=12)flag=true;
	if(res>0&&res<=12)flag2=true;
	if(flag&&flag2)cout<<"AMBIGUOUS"<<endl;
	else if(!flag&&!flag2)cout<<"NA"<<endl;
	else if(flag&&!flag2)cout<<"MMYY"<<endl;
	else if(!flag&&flag2)cout<<"YYMM"<<endl;
	return 0;
}

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

using namespace std;

#define int long long
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cint int t;cin>>t;while(t--)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back

int mod=1e9+7;

int32_t main() {
    string s;
    cin>>s;
    int n=s.length();
    int tmp=(n-1)/2;

    string t=s.substr(0,tmp);
    string z=t;
    reverse(z.begin(),z.end());

    if(z==t){
        reverse(s.begin(),s.end());
        string t1=s.substr(0,tmp);
        string z1=t;
        reverse(z1.begin(),z1.end());

        if(z1==t1){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int  A,B, C,D;
	int  start = 0, end = 0;
	int an = 0;
	scanf("%d%d%d%d", &A, &B, &C, &D);
	if ((A<=C && B>=C)||(C<=A&&D>=A)) {
		start = (A > C) ? A : C;
		end = (B < D) ? B : D;
		an = end - start;
		printf("%d", an);
	}
	else {
		an = 0;
		printf("%d",an);
	}
	return 0;
}

Measured memory_bytes: 128
h,w = map(int,input().split())
a = [input() for _ in range(h)]

hl=[]
wl=[]

for i in range(h):
    if a[i]=="."*w:
        hl +=[i]
for i in range(w):
    if all([a[j][i]=="." for j in range(h)]):
        wl += [i]


for i in range(h):
    if i not in hl:
        for j in range(w):
            if j not in wl:
                print(a[i][j],end="")
        else:
            print("")

Measured memory_bytes: 9164
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
#include <stdio.h>
using namespace std;
 
int main()
{
    std::string s;
    cin >> s;
    int ans = 0;
    for(int i=0; i<s.length(); i++){
        ans += s[i] - '0';
    }

    if(ans%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3720
import re
s = input()
cnt = 0
if (s[2:-1].count('C') != 1):
    print('WA')
    exit(0)
for i in range(len(s)):
    if (s[i] >= 'A' and s[i] <= 'Z'):
        cnt += 1
        if (cnt >= 3):
            print('WA')
            exit(0)
print('AC') if s[0]=='A' else print('WA')


Measured memory_bytes: 3188
#include<iostream>
int main()
{
    using namespace std;

    int a[3],b[3];
    for(int i=0;i<3;i++)cin >> a[i] >> b[i];

    int one=0,two=0,three=0,four=0;
    for(int i=0;i<3;i++){
        if(a[i] == 1 || b[i] == 1)one++;
        if(a[i] == 2 || b[i] == 2)two++;
        if(a[i] == 3 || b[i] == 3)three++;
        if(a[i] == 4 || b[i] == 4)four++;
    }

    if(one>=3||two>=3||three>=3||four>=3){
        cout << "NO" << endl;
        return 0;
    }

    else{
        cout << "YES" << endl;
        return 0;
    }
}

Measured memory_bytes: 256
import sys
from itertools import accumulate
n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
aa = list(accumulate(a))
MOD = 10**9+7
ans = 0
for i in range(n):
    ans += a[i]*(aa[n-1] - aa[i])
print(ans%MOD)


Measured memory_bytes: 29120
#include <bits/stdc++.h>
using namespace std;
#define MAX 100010

vector<int>adj[MAX], edgeCost[MAX];
bool visited[MAX], exists;
int dist[MAX];

void dfs(int s){
    visited[s] = true;

    for(int i=0; i<adj[s].size(); i++){
        int d = adj[s][i];
        int c = edgeCost[s][i];

        if(!visited[d]){
            dist[d] = dist[s] + c;
            dfs(d);
        }

        else if(dist[d] - dist[s] != c){
            exists = false;
            return;
        }
    }

    return;
}

void reset(int n){
    exists = true;

    for(int i=0; i<n; i++){
        adj[i].clear();
        edgeCost[i].clear();
        dist[i] = -1;
        visited[i] = false;
    }
}

int main(){
    int n,m;

    while(scanf("%d%d",&n,&m)==2){
        reset(n);

        while(m--){
            int u, v, c;
            scanf("%d%d%d",&u, &v, &c);
            adj[u].push_back(v);
            edgeCost[u].push_back(c);

            adj[v].push_back(u);
            edgeCost[v].push_back(-c);
        }

        for(int i=0; i<n && exists; i++){
            if(!visited[i]){
                dist[i] = 0;
                dfs(i);
            }
        }

        if(exists)
            puts("Yes");
        else
            puts("No");
    }

    return 0;
}


Measured memory_bytes: 16512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextInt();


            Console.WriteLine((n+1)/2);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, count = 0, idx=1;
    in >> n;
    vector<ll> a(n);
    REP(i, n) in >> a[i];
    REP(i, n){
        count += 1;
        idx = a[idx - 1];
        if(idx == 2){
            break;
        }
        if(i == n-1){
            count = -1;
        }
    }
    out << count << endl;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll x,k,d;
  cin>>x>>k>>d;

  x=abs(x);
  ll mx=x%d;
  ll r=x/d;

  if(mx>abs(mx-d)){
    mx=abs(mx-d);
    r++;
  }

  ll ans;
  if(k<r)
    ans=x-d*k;
  else{
    ll rem=k-r;
    if(rem%2==0)
      ans=mx;
    else
      ans=abs(mx-d);
  }


  cout<<ans<<endl;
}



Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();
            long res = 0;
            long sofar = 0;
            for (int i = 0; i < s.length(); ++i) {
                if (s.charAt(i) == 'W') {
                    res += sofar;
                } else {
                    sofar += 1;
                }
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 26708
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	_, M := sc.NextInt(), sc.NextInt()
	A := sc.NextIntArray()

	cnt := 0
	sum := 0
	for _, v := range A {
		sum += v
	}

	for _, v := range A {
		if v*4*M >= sum {
			cnt++
		}
	}

	if cnt >= M {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static Switch switches[];
	static Light lights[];

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		switches = new Switch[n];
		lights = new Light[m];

		for(int i = 0; i < n; i++){
			switches[i] = new Switch();
		}

		for(int i = 0; i < m; i++){
			int k = sc.nextInt();

			lights[i] = new Light();

			for(int j = 0; j < k; j++){
				lights[i].connected.add(switches[sc.nextInt() - 1]);
			}
		}

		for(int i = 0; i < m; i++){
			lights[i].p = sc.nextInt();
		}

		solve(0);

		System.out.println(result);
	}

	static int result = 0;
	static void solve(int depth){
		if(depth == switches.length){
			for(int i = 0; i < lights.length ; i++){
				if(!lights[i].on()){
					return;
				}
			}
			result++;
			return;
		}

		switches[depth].on = false;
		solve(depth + 1);
		switches[depth].on = true;
		solve(depth + 1);
	}

}

class Light {
	ArrayList<Switch> connected;
	int p;

	Light(){
		this.p = 0;
		connected = new ArrayList<Switch>();
	}

	boolean on(){
		int count = 0;

		for(int i = 0; i < connected.size(); i++){
			if(connected.get(i).on){
				count++;
			}
		}

		return count%2 == p;
	}
}

class Switch {
	boolean on = false;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> s(N);
  for(int i=0;i<N;i++){
      cin >> s.at(i);
  }
  int AB=0;
  int A=0;
  int B=0;
  int same=0;
  int flag=0;
  for(int i=0;i<N;i++){
      for(int j=0;j<s.at(i).size()-1;j++){
          if(s.at(i).at(j)=='A' && s.at(i).at(j+1) == 'B'){
              AB ++;
          }
      }
      if(s.at(i).at(0) == 'B'){
          B ++;
      }
      if(s.at(i).at(s.at(i).size()-1) == 'A'){
          A ++;
      }
      if(s.at(i).at(0) == 'B' && s.at(i).at(s.at(i).size()-1) == 'A'){
          same ++;
      }
  }
  if(A == B && A == same && same >0){
      flag = 1;
  }
  cout << AB + min(A,B) - flag << endl;
}


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

int main() {
  int b,c;
  int n=0;
  int sum = 0;
  set<int> bo;
  
  cin >> n;
  
  vector<int> a(n);
  
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    if(i > 0 && a.at(i) == a.at(i-1) + 1){
      bo.insert(a.at(i-1)-1);
    }
  }
  
  for(int i=0;i<n;i++){
    cin >> b;
    sum += b;
  }
  
  for(int i=0;i<n-1;i++){
    cin >> c;
    if(bo.count(i)) sum += c;
  }
  
  cout << sum << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll n; cin >> n;
  string s, t; cin >> s >> t;
  ll res;
  if (s.at(0) == t.at(0)) {
    res = 3;
    bool flag = 1;
    for (ll i = 1; i < n; i++) {
      if (s.at(i) == t.at(i)) {
        if (flag) res *= 2;
        else res *= 1;
        flag = 1;
        res %= mod;
      } else {
        if (flag) res *= 2;
        else res *= 3;
        flag = 0;
        i++;
        res %= mod;
      }
    }
  } else {
    res = 6;
    bool flag = 0;
    for (ll i = 2; i < n; i++) {
      if (s.at(i) == t.at(i)) {
        if (flag) res *= 2;
        else res *= 1;
        flag = 1;
        res %= mod;
      } else {
        if (flag) res *= 2;
        else res *= 3;
        flag = 0;
        i++;
        res %= mod;
      }
    }
  }
  cout << res << endl;
}

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

int main()
{
    string S, T;
    cin >> S >> T;
    T.pop_back();
    if (S == T)
    {
        cout << "Yes" << "\n";
    }
    else
    {
        cout << "No" << "\n";
    }
    return 0;
}

Measured memory_bytes: 3584
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
using p = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    vi data(0);
    int size = 0;
    while(1) {
        int a,b;
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        if(a > b) {
            data.push_back(b);
            data.push_back(a);
        }
        else {
            data.push_back(a);
            data.push_back(b);
        }
    }
    size = data.size();
    for(int i = 0; i < size; i += 2) {
        cout << data[i] << " " << data[i + 1] << endl;
    }
}


Measured memory_bytes: 3156
#include <iostream>

int main()
{
    int rightw, righth, n;
    std::cin >> rightw >> righth >> n;
    int x[n],y[n],a[n];
    for(int i = 0; i < n; i++){
        std::cin >> x[i] >> y[i] >> a[i];
    }
    int leftw = 0, lefth = 0;
    for(int j = 0; j < n; j++){
        switch(a[j]){
            case 1:
                if(leftw < x[j]) 
                    leftw = x[j];
                break;
            case 2:
                if(rightw > x[j])
                    rightw = x[j];
                break;
            case 3:
                if(lefth < y[j])
                    lefth = y[j];
                break;
            case 4:
                if(righth > y[j])
                    righth = y[j];
                break;
        }
    }
    if(rightw > leftw && righth > lefth)
        std::cout << (rightw - leftw) * (righth - lefth);
    else
        std::cout << "0" << std::endl;
    return 0;
}



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

int main()
{
	int N;
	cin >> N;
	int count = 0;
	int l[1000], r[1000];
	for (int i = 0; i < N; i++) {
		cin >> l[i] >> r[i];
		count += r[i] + 1 - l[i];
	}
	cout << count << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

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

int main(){
    int N;
    cin>>N;
    double v[N];
    rep(i,N)cin>>v[i];
    sort(v,v+N,greater<double>());
    double sum=0;
    rep(i,N-1){
        sum+=v[i]/double(pow(2,i+1));
    }
    sum+=v[N-1]/double(pow(2,N-1));
    cout<<setprecision(16)<<sum<<endl;
    return 0;
}

Measured memory_bytes: 512
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: usize = read().unwrap();
    let a: usize = read().unwrap();
    let b: usize = read().unwrap();

    let total = a + b;
    let quotient = n / total;
    let reminder = n % total;
    if reminder < a {
        println!("{}", quotient * a + reminder);
    } else {
        println!("{}", (quotient + 1) * a);
    }
}

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


int main()
{
	string s, x, t;
	int q, a, b;
	cin >> s >> q;
	for(; q > 0; q--)
	{
		cin >> x;
		if (x == "print")
		{
			cin >> a >> b;
			cout << s.substr(a, b-a+1) << endl;
		}
		else if (x == "replace")
		{
			cin >> a >> b >> t;
			s = s.replace(a, b-a+1, t);
		}
		else
		{
			cin >> a >> b;
			string r = s.substr(0, a);
			for (int i = b; i >= a; i--)
				r += s[i];
			r += s.substr(b+1);
			s = r;
		}
	}
	return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;


int main(){
    vector<int> antena(5);
    for(int i = 0;i<5;i++){
        cin >> antena.at(i);
    }
    int k;
    cin >> k;
    sort(antena.begin(),antena.end());
    if(antena.at(4)-antena.at(0)<=k){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
}

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

int main() {
  int a, b;
  cin >> a >> b;

  int o = 1;
  int ans = 0;
  while(o < b){
    o += a - 1;
    ans++;
  }

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,a;
  cin>>n;
  vector<int>p(10000);
  for(int i=0;i<10000;i++){
    p.at(i)=0;
  }
  for(int x=1;x<101;x++){
    for(int y=x;y<101;y++){
      for(int z=y;z<101;z++){
        a=((x+y)*(x+z))+y*y+z*z;
        if(a>10000){
          continue;
        }
        else if(x<y&&y<z){
          p.at(a-1)+=6;
        }
        else if(x==y&&y==z){
          p.at(a-1)+=1;
        }
        else{
          p.at(a-1)+=3;
        }

        
      }
    }
  }
 for(int i=0;i<n;i++){
 cout<<p.at(i)<<endl;;
  }
}

Measured memory_bytes: 3536
x, y, z, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

d = []

a.each do |x|
  b.each do |y|
    d << x + y
  end
end

e = []

d.sort.reverse[0,3000].each do |x|
  c.each do |y|
    e << x + y
  end
end

puts e.sort.reverse[0,k]

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

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

	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 640