akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

        int num;
        boolean approved = true;
        num = cin.nextInt();

        int temp;
        for (int i = 0; i < num; i++) {
            temp = cin.nextInt();
            if (temp % 2 == 0) {
                if (!(temp % 3 == 0 || temp % 5 == 0)) {
                    approved = false;
                }
            }
        }

        if (approved) {
            System.out.println("APPROVED");
        } else {
            System.out.println("DENIED");
        }
    }
}


Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

template<typename T>
void say(vector<T> s, string t) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << t << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T & a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T & a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T> & v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

int main() {
	makev(v, 3);
	sort(all(v));
	say(v);
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define dmp make_pair
#define fi first
#define se second
#define rep(i,n) for(int i = 0;i < n;i++)
typedef pair<int,int> P;
typedef pair<int, P> PP;

int a[2][100], dp[2][100], d[2][100];
int main(){
	int n;
	scanf("%d", &n);
	rep(i,2)rep(j,n)scanf("%d", &a[i][j]);
	
	queue<PP> q;
	q.push(dmp(0, P(0, 0)));
	while(!q.empty()){
		PP p = q.front();q.pop();
		int y = p.se.fi, x = p.se.se, cost = p.fi;
		d[y][x] = max(d[y][x], cost+a[y][x]);
		if(x < n)q.push(dmp(d[y][x], P(y, x+1)));
		if(y < 1)q.push(dmp(d[y][x], P(y+1, x)));
	}
	
	printf("%d\n", d[1][n]);
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
class pos
{
	public:
	int x;
	int y;
	pos(int,int);
};

pos::pos(int a,int b)
{
	x=a;y=b;
}

int main()
{
	int w,h;
	int g[21][21];
/*	for(int i=0;i<21;i++)
		for(int j=0;j<21;j++)
			g[i][j]=-1;
*/	while(1)
	{
		cin>>w>>h;
		if(w==0&&h==0) break;
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
				g[i][j]=-1;
		int psx,psy;
		bool visited[21][21];
		for(int i=0;i<h;i++)
			for(int j=0;j<w;j++)
			{
				char s;
				cin>>s;
				switch(s)
				{
					case '.':
						g[i][j]=0;break;
					case '#':
						g[i][j]=1;break;
					case '@':
						g[i][j]=2;psx=i;psy=j;break;
				}
				visited[i][j]=false;
			}

/*		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
				cout<<g[i][j];
			cout<<endl;
		}
*/
		int num=0;
		queue<pos> Q;
		Q.push(pos(psx,psy));
		num++;
		visited[psx][psy]=true;
		while(!Q.empty())
		{
			pos now=Q.front();
			Q.pop();
	
			for(int i=-1;i<=1;i+=2)
			{
				int newx=now.x+i;
				int newy=now.y;
				if(newx>=0&&newx<h&&newy>=0&&newy<w&&g[newx][newy]==0&&visited[newx][newy]==false)
				{
					Q.push(pos(newx,newy));		
					num++;
					visited[newx][newy]=true;
				}
			}
			for(int i=-1;i<=1;i+=2)
			{                
				int newx=now.x;
				int newy=now.y+i;
				if(newx>=0&&newx<h&&newy>=0&&newy<w&&g[newx][newy]==0&&visited[newx][newy]==false)
				{
					Q.push(pos(newx,newy));
					num++;
					visited[newx][newy]=true;
				}
			}

		}
		cout<<num<<endl;
								


	}
}

Measured memory_bytes: 3152
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>

using namespace std;
int main() {
    vector<char> a(4);
    lp(i,4)
        cin>>a[i];
    sort(a.begin(),a.end());
    if(a[0]==a[1]&&a[0]!=a[2]&&a[2]==a[3])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int n;
int s[505],t[505];
unsigned long long u[505],v[505],ans[505][505];
unsigned long long mat[505][505];
void check_all(){
	for(int i=1;i<=n;i++){
		unsigned long long cur=0;
		if(s[i]==0)cur=~cur;
		for(int j=1;j<=n;j++){
			(s[i]==0?cur&=ans[i][j]:cur|=ans[i][j]);
		}
		if(cur!=u[i]){
			puts("-1");
			exit(0);
		}
	}
	for(int j=1;j<=n;j++){
		unsigned long long cur=0;
		if(t[j]==0)cur=~cur;
		for(int i=1;i<=n;i++){
			(t[j]==0?cur&=ans[i][j]:cur|=ans[i][j]);
		}
		if(cur!=v[j]){
			puts("-1");
			exit(0);
		}
	}
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>s[i];
	for(int i=1;i<=n;i++)cin>>t[i];
	for(int i=1;i<=n;i++)cin>>u[i];
	for(int i=1;i<=n;i++)cin>>v[i];
	if(n==1){
		if(u[1]!=v[1]){
			puts("-1");
		}else{
			cout<<u[1]<<endl;
		}
		return 0;
	}
	for(int bit=0;bit<64;bit++){
		memset(mat,-1,sizeof mat);
		vector<int>r,c;
		bool z=0,o=0;
		int R=-1,C=-1;
		for(int i=1;i<=n;i++){
			int val=(u[i]>>bit)&1;
			if(s[i]==0){
				if(val==1)for(int j=1;j<=n;j++)mat[i][j]=1,o=1,R=1;
				else r.push_back(i);
			}else{
				if(val==0)for(int j=1;j<=n;j++)mat[i][j]=0,z=1,R=0;
				else r.push_back(i);
			}
		}
		for(int i=1;i<=n;i++){
			int val=(v[i]>>bit)&1;
			if(t[i]==0){
				if(val==1)for(int j=1;j<=n;j++)mat[j][i]=1,o=1,C=1;
				else c.push_back(i);
			}else{
				if(val==0)for(int j=1;j<=n;j++)mat[j][i]=0,z=1,C=0;
				else c.push_back(i);
			}
		}
		if(r.size()==1){
			int x=r[0];
			for(auto y:c){
				if(R==(v[y]>>bit)%2)mat[x][y]=(u[x]>>bit)%2;
				else mat[x][y]=(v[y]>>bit)%2;
			}
		}else if(c.size()==1){
			int y=c[0]; 
			for(auto x:r){
				if(C==(u[x]>>bit)%2)mat[x][y]=(v[y]>>bit)%2;
				else mat[x][y]=(u[x]>>bit)%2;
			}
		}else{
			int t=0,tt=0;
			for(int i=0;i<r.size();i++){
				for(int j=0;j<c.size();j++){
					mat[r[i]][c[j]]=(i+j)%2;
				}
			}
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
//				cerr<<mat[i][j]<<" ";
				ans[i][j]|=((mat[i][j]?1ull:0ull)<<bit);
			}
//			cerr<<endl;
		}
	}
	check_all();
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cout<<ans[i][j]<<" ";
		}
		cout<<endl;
	}
	return 0;
}

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

int a[222222];
int main() {
    int n, b;
    cin >> n;
    for(int i = 1; i < n; i++)
        cin >> b, a[b]++;
    for(int i = 0; i < n; i++)
        cout << a[i + 1] << '\n';
    cout << flush;
    return 0;
}


Measured memory_bytes: 4368
S = input()
words = ['dream', 'dreamer', 'erase', 'eraser']
while len(S) > 0:
  judge = [S.endswith(w) for w in words]
  # 逆から考えることで単語の重複をなくすのがポイント！
  if any(judge):
    hit_word = words[judge.index(True)]
    S = S[:-len(hit_word)]
    if len(S) == 0:
      print('YES')
      break
  else:
    print('NO')
    break


Measured memory_bytes: 3188
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B, C, D] = input[0].map(Number);

  return Math.max(A * B, C * D);
};

console.log(main(read()));


Measured memory_bytes: 29496
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x1 = in.nextInt();
        int x2 = in.nextInt();
        int x3 = in.nextInt();
        int x4 = in.nextInt();
        int x5 = in.nextInt();

        int ans = 0;
        if (x1 == 0) {
            ans = 1;
        } else if (x2 == 0) {
            ans = 2;
        } else if (x3 == 0) {
            ans = 3;
        } else if (x4 == 0) {
            ans = 4;
        } else if (x5 == 0) {
            ans = 5;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35556
n = int(input())
l = list(map(int, input().split()))

INF = 10 ** 16

dp = [-INF] * (n + 1)
dp[0] = 0

import heapq
q = []
for i in range(n):
    heapq.heappush(q, (-l[i], i))

for itera in range(n):
    _, ind = heapq.heappop(q)
    val = l[ind]
    dpnew = [-INF] * (n + 1)

    for i in range(n):
        left = dp[i] + abs(i - ind) * val
        right = dp[i] + abs(n - 1 - itera + i - ind) * val
        if dpnew[i] < right:
            dpnew[i] = right
        if dpnew[i+1] < left:
            dpnew[i+1] = left
    dp = dpnew
print(max(dp))
    


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

LL calc(vector<LL> &A, bool larger)
{
    deque<LL> dq;
    if (larger)
    {
        sort(A.begin(), A.end());
    }
    else
    {
        sort(A.begin(), A.end(), [](LL a, LL b) { return a > b; });
    }
    dq.push_back(A[0]);

    int l = 0;
    int r = A.size();
    bool turn_large = true;
    while (true)
    {
        if (turn_large)
        {
            if (l < r - 2)
            {
                dq.push_front(A[r - 1]);
                dq.push_back(A[r - 2]);
                r -= 2;
            }
            else
            {
                if (l < r - 1)
                    dq.push_front(A[r - 1]);

                break;
            }
        }
        else
        {
            if (l + 2 < r)
            {
                dq.push_front(A[l + 1]);
                dq.push_back(A[l + 2]);
                l += 2;
            }
            else
            {
                if (l + 1 < r)
                    dq.push_front(A[l + 1]);

                break;
            }
        }
        turn_large = !turn_large;
    }

    LL prev_a = dq.front();
    dq.pop_front();
    LL ans = 0;
    for (auto a : dq)
    {
        ans += abs(prev_a - a);
        prev_a = a;
    }
    return ans;
};

void solve()
{
    int N;
    cin >> N;
    LL ans_g = 0;
    vector<LL> A(N);

    REP0 (i, N)
    {
        cin >> A[i];
    }

    ans_g = calc(A, false);
    ans_g = max(ans_g, calc(A, true));

    std::cout << ans_g << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 1920
import sys
sys.setrecursionlimit(10**7)
P=10**9+7
N=int(input())
edges = [[] for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  edges[a-1].append((b-1, i))
  edges[b-1].append((a-1, i))
L=[0]*N
def dfs(cur, x):
  res = 1
  for i in edges[cur]:
    if i[1]!=x:
      res += dfs(i[0], i[1])
  L[x]=res
  return res
dfs(0,-1)
L2=[1]
i2=pow(2,P-2,P)
for i in range(N):
  L2.append(L2[-1]*i2%P)
cnt = 0
for i in L:
  cnt+=(1-L2[i])* (1-L2[N-i])
print((-N*i2-L2[-1]+cnt+1)%P)

Measured memory_bytes: 202336
#include <stdio.h>

int x[1001], y[1001];
int main() {
    int a, n, j = 0;
	scanf("%d", &n);
    for (int i=0; i<n; i++) {
        scanf("%d", &a);
        if (a > 0) {
            if (y[a] == 1) {
                printf("%d\n", i+1);
                return 0;
            }
            x[j++] = a;
            y[a] = 1;
        } else {
            if (-a != x[--j]) {
                printf("%d\n", i+1);
                return 0;
            }
            y[-a] = 0;
        }
    }
    puts("OK");
}



Measured memory_bytes: 2080
from collections import deque
N,M=map(int,input().split())
to=[[] for _ in range(N)]
for _ in range(M):
  a,b=map(int,input().split())
  to[a-1].append(b-1)
  to[b-1].append(a-1)
q=deque([0])
r=[-1]*N
r[0]=0
while q:
  x=q.popleft()
  for i in to[x]:
    if r[i]==-1:
      q.append(i)
      r[i]=x+1
print("Yes",*r[1:],sep="\n")

Measured memory_bytes: 38940
s = input()
s_len = len(s)
s_ary = list(s)

#print(s_ary)
sowa = 0

for i in range(2**(s_len-1)):
    x="{:0" + str(s_len-1) + "b}"
    keisan = list(str(x.format(i)))
    #print(keisan)
    zentai = 0
    flag = 0
    for j in range(s_len-1):
        #print(int(s_ary[s_len-1-j])*10**flag)
        zentai += int(s_ary[s_len-1-j])*10**flag
        if(keisan[j]=="0"):
            flag = 0
        else:
            flag += 1
    
    #print(int(s_ary[0])*10**flag)
    zentai += int(s_ary[0])*10**flag
    sowa += zentai

print(sowa)

Measured memory_bytes: 3188
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }
    sort(ALL(A));

    // 累積和
    vector<ll> B(N);
    B[0] = A[0];
    FOR(i, 1, N){
        B[i] = B[i-1] + A[i];
    }

    ll t = -1;
    FOR(i, 0, N-1){
        // 左から全員食っても勝てないものがいるか
        if(2 * B[i] < A[i+1]){
            t = i;
        }
    }

    p(N-t-1);

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<math.h>
using namespace std;
typedef long long int ll;

int main(void){
    ll n,k;
    cin>>n>>k;
    ll h[n],dp[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    dp[0]=0;
    for(int i=1;i<n;i++){
        dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        for(int j=2;i-j>-1&&j<k+1;j++){
            dp[i]=fmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
    }

    cout<<dp[n-1]<<endl;

}

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

int main()
{
	int n;
	cin >> n;
	int k = 0;

	for (int i = 1; i <= n; i=i+2) {
		int count = 0;
		for (int k=1; k <= i; k++) {
			if (i%k == 0) {
				count++;
			}
		}
		if (count == 8) k++;
	}

	cout << k << endl;

		return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n);
  for(int i = 0; i < n; i++){
    a[i] = i;
  }
  if(n % 2 != 0){
    for(int i = 0; i < n / 2; i++) {
      b[i * 2] = i;
      b[i * 2 + 1] = n - i - 2;
    }
  }else{
    for(int i = 0; i < n / 4; i++){
      b[i * 2] = n / 2 - i;
      b[i * 2 + 1] = n / 2 + i + 1;
    }
    for(int i = n / 4; i < n / 2; i++) {
      b[i * 2] = n / 2 - i - 1;
      b[i * 2 + 1] = n / 2 + i + 1;
    }
  }
  for(int i = 0; i < m; i++){
    cout << b[i * 2] + 1 << " " << b[i * 2 + 1] + 1 << '\n';
  }
  /*
  for(int i = 0; i < n; i++){
    for(int j = 0; j < m; j++){
      cout << a[(b[j * 2] - i + n) % n] + 1 << " " << a[(b[j * 2 + 1] - i + n) % n]  + 1 << "  ";
    }
    cout << '\n';
  }
  */

    return 0;
}

Measured memory_bytes: 4560
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
ll INF = 1e18;

using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

int N;
Graph G;

vector<int> res;

void dfs(int v, int p, int c){
    res[v] = c;
    for(auto e : G[v]){
        if(e.first == p) continue;  // e.first is parent node number. prevent back
        if(e.second & 1){          // e.second is distance
            dfs(e.first, v, 1-c);
        }else{
            dfs(e.first, v, c);
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N;
    G.assign(N, vector<Edge>());
    for( int i = 0; i < N-1; i++){
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        // making tree
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }
    res.assign(N, 0);
    dfs(0, -1, 1);
    for(auto v: res){
        cout << v << endl;
    }
    return 0;
}


Measured memory_bytes: 8960
N = int(input())
As = list(map(int, input().split()))

dp = [[0 for _ in range(N)] for _ in range(2)]

dp[0][0] = 1
dp[1][0] = 1
for i in range(1, N):
    if As[i - 1] < As[i]:
        dp[0][i] = min(dp[0][i - 1], dp[1][i - 1] + 1)
        dp[1][i] = min(dp[0][i - 1] + 1, dp[1][i - 1] + 1)
    elif As[i - 1] > As[i]:
        dp[0][i] = min(dp[0][i - 1] + 1, dp[1][i - 1] + 1)
        dp[1][i] = min(dp[0][i - 1] + 1, dp[1][i - 1])
    else:
        dp[0][i] = min(dp[0][i - 1], dp[1][i - 1] + 1)
        dp[1][i] = min(dp[0][i - 1] + 1, dp[1][i - 1])

ans = min(dp[0][N - 1], dp[1][N - 1])
print(ans)

Measured memory_bytes: 14100
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,sum=0;
    cin>>n;
    long long a[n];
    f(i,0,n){
        cin>>a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    f(i,0,n){
        if(i%2==0){
            sum+=a[i];
        }
        else{
            sum-=a[i];
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int left = sc.nextInt() + sc.nextInt();
        int right = sc.nextInt() + sc.nextInt();
        
        if(left > right){
            System.out.println("Left");
        }else if(left < right){
            System.out.println("Right");
        }else{
            System.out.println("Balanced");
        }
        
    }
}


Measured memory_bytes: 21332
package main

import "fmt"

func main() {
	// Code for B - OddString
	var s string
	fmt.Scanf("%s", &s)

	for i := 0; i < len(s); i++ {
		if (i+1)%2 != 0 {
			fmt.Printf("%c", s[i])
		}
	}

	fmt.Printf("\n")
}


Measured memory_bytes: 2568
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	vector<vector<LL>> d(n, vector<LL>(n));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> d[i][j];
		}
	}

	//a+b<cとなってると、cが矛盾する
	for (int m = 0; m < n; m++) {
		for (int s = 0; s < n; s++) {
			for (int t = 0; t < n; t++) {

				if (d[s][m] + d[m][t] < d[s][t]) {
					cout << "-1" << endl;
					return 0;
				}

			}
		}
	}
	

	//a+b==cとなってるcは渡れないことにする
	for (int m = 0; m < n; m++) {
		for (int s = 0; s < n; s++) {
			for (int t = 0; t < n; t++) {
				if (s == t || t == m || s == m)continue;

				if (d[s][m] + d[m][t] == d[s][t]) {
					d[s][t] = INF2;
				}
			}
		}
	}
	

	LL ans = 0;

	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			if (d[i][j] != INF2)ans += d[i][j];
		}
	}

	cout << ans << endl;

	return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

int main(){

	lli n;
	cin>>n;

	vector<pair<lli,lli>> v;
	REP(i,0,n){
		lli a,b;
		cin>>a>>b;
		v.push_back({a,b});
	}

	REP(i,0,n-2){
		if(v[i].first==v[i].second && v[i+1].first==v[i+1].second && v[i+2].first==v[i+2].second){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;


	
    return 0;
}


Measured memory_bytes: 3616
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)
C = gets.split.map(&:to_i)

sum = 0
N.times do |i|
  sum += B[A[i] - 1]
  if i > 0 && A[i - 1] + 1 == A[i]
    sum += C[A[i -1] - 1]
  end
end
print sum

Measured memory_bytes: 1788
import sys
s=input()
len_s=len(s)
if(len_s==1):
    print(1)
    sys.exit()


if(len_s%2==1):
    l=len_s//2
    r=l
else:
    r=len_s//2
    l=r-1

saisyo=s[l]
if(s[l]==s[r]):
    while(0<l and saisyo==s[l-1] and saisyo==s[r+1]):
        l-=1
        r+=1

else:
    r=l

print( (len_s + r-l +1)//2)

Measured memory_bytes: 3316
#include <stdio.h>

int root[1000][1000];
bool right[1000][1000];

int main()
{
	int h, w, n, tmp, ax, ay;

	while(true) {
		scanf("%d%d%d", &h, &w, &n);
		if(h == 0 && w == 0 && n == 0) break;
		for(int y = 0; y < h; ++y) {
			for(int x = 0; x < w; ++x) {
				scanf("%d", &tmp);
				right[x][y] = tmp;
				root[x][y] = 0;
				if(x == 0 && y == 0)
					root[x][y] = n - 1;
				if(x != 0) {
					if(right[x - 1][y])
						root[x][y] += (root[x - 1][y] + 1) / 2;
					else
						root[x][y] += (root[x - 1][y]) / 2;
				}
				if(y != 0) {
					if(right[x][y - 1])
						root[x][y] += (root[x][y - 1]) / 2;
					else
						root[x][y] += (root[x][y - 1] + 1) / 2;
				}
			}
		}
		
		ax = 0;
		ay = 0;
		while(ax < w && ay < h) {
			if((right[ax][ay] + root[ax][ay]) % 2 == 1)
				++ax;
			else
				++ay;
		}

		printf("%d %d\n", ay + 1, ax + 1);
	}

	return 0;
}

Measured memory_bytes: 5648
while True:
    a, op, b = input().split()
    if op == '?': exit()
    num = list(map(int, [a, b]))
    a, b = num[0], num[1]
    if op == '+' : result = a + b
    if op == '-' : result = a - b
    if op == '*' : result = a * b
    if op == '/' : result = a // b
    print(result)



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll X;
    cin >> X;

    vector<bool> beki(1010, false);
    beki[1] = true;
    for(int i=2;i<=X;i++){
    	ll now = i*i;
    	while(now<=X){
    		beki[now] = true;
    		now *= i;
    	}
    }

    //cout << beki << endl;

    ll res = 0;
    for(int i=1;i<=X;i++){
    	if(beki[i]) res = i;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val S = Array(3) { readLine()!!.toCharArray().toMutableList() }
    var turn = 0
    while (S[turn].isNotEmpty()) {
        turn = S[turn].removeAt(0).toInt() - 'a'.toInt()
    }
    println('A' + turn)
}



Measured memory_bytes: 32228
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n,m;
    cin >> n >> m;
    vector<int> denkyu[m];

    REP(i,m){
        int k;
        cin >> k;
        int tmp;
        REP(j,k){
            cin >> tmp;
            denkyu[i].push_back(tmp-1); 
        }
    }
    int P[m];
    REP(i,m){
        cin >> P[i];
    }
    int res = 0;
    int mask = 0;
    int check = 1;
    REP(i,n){
        check *= 2;
    }


    while(1){
        
        bool flagg = true;
        REP(j,m){
            int ko = 0;
            itrfor(itr,denkyu[j]){
                if( mask & (1 <<  (*itr) ) ) ko ++;
            }
            if(ko %2 != P[j]){
                flagg = false; 
                // cout << mask << " " << j << " " << ko << endl;
            }
        }
       
        if(flagg) res ++;
        mask ++;
        if(check == mask) break;
    }

    cout << res << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define MAX INT_MAX
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
void solve() {
 	int n, k, s;
 	cin >> n >> k >> s;
 	vector <int> v;
 	if(s == 1000000000) {
	 	//vector <int> v;
	 	for(int i=0;i<k;i++) {
	 		v.pb(s);
	 	}  
	 	n -= k;
	 	if(n > 0) {
	 		for(int i=0;i<n;i++)
	 			v.pb(1);
	 	}
 	}
 	else {
 		//vector <int> v;
	 	for(int i=0;i<k;i++) {
	 		v.pb(s);
	 	}  
	 	n -= k;
	 	if(n > 0) {
	 		for(int i=0;i<n;i++)
	 			v.pb(s+1);
	 	}
 	}
 	for(int x : v)
 		cout << x << " ";
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}


Measured memory_bytes: 2292
#include<iostream>
#include<utility>

using namespace std;

long long len_burger[51];
long long len_patty[51];
// バン 1 枚、レベル L−1 バーガー、パティ 1 枚、レベル L−1 バーガー、バン 1 枚
long long count_len_burger(int n) {
  if(len_burger[n] != -1) {
    return len_burger[n];
  }
  if(n == 0) {
    return len_burger[n] = 1;
  }
  long long len = count_len_burger(n-1);
  return len_burger[n] = 1 + len + 1 + len + 1;
}
long long count_patty(int n) {
  if(len_patty[n] != -1) {
    return len_patty[n];
  }
  if(n == 0) {
    return len_patty[n] = 1;
  }
  return len_patty[n] = 2 * count_patty(n-1) + 1;
}

/*
 * patty, consumed_budget
 */
pair<long long, long long> p_burg(int n, long long x) {
  if(n==0) {
    if(x >= 1) {
      return make_pair(1, 1);
    }
    return make_pair(0, 0);
  }
  if(x <= 1) {
    return make_pair(0, 1);
  }
  long long remain = x-1;
  long long smaller_burger = count_len_burger(n-1);
  if(remain <= smaller_burger) {
    pair<long long, long long> p = p_burg(n-1, remain);
    return make_pair(p.first, 1 + p.second);
  }
  remain -= smaller_burger + 1;
  long long num_patty = count_patty(n-1) + 1;
  if(remain == 0) {
    return make_pair(num_patty, x);
  }
  if(remain <= smaller_burger) {
    pair<long long, long long> p = p_burg(n-1, remain);
    return make_pair(num_patty + p.first, 1 + smaller_burger + 1 + p.second);
  }
  return make_pair(num_patty + count_patty(n-1), 3 + count_len_burger(n-1)*2);
}

long long christmas(int n, long long x) {
  for(int i=0;i<51;i++) {
    len_burger[i] = len_patty[i] = -1;
  }
  return p_burg(n, x).first;
}

int main() {
  int n;
  long long x;
  cin >> n;
  cin >> x;
  cout << christmas(n, x);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265

#define MAX 501


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

    int arr[5] = {105 , 135 , 165 , 189 , 195};

    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < 5; i++) {
        if (arr[i] >= 1 && arr[i] <= n) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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


class Program
{
    static void Main(string[] args)
    {
        ulong X = ulong.Parse(Console.ReadLine());
        ulong year = 0;
        ulong money = 100;

        while(money < X) {
            money = (ulong)(money * 1.01);
            year += 1;
        }
        
        Console.WriteLine(year);
    }
}

Measured memory_bytes: 27536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n;
    cin>>n;
    
    vector <ll> a(n);
    for (ll i = 0; i < n; i++){
        cin>>a[i];
    }
    vector <ll> b(n);
    for (ll i =0;  i < n; i++){
        cin>>b[i];
    }
    vector <ll> c(n-1);
    for (ll i = 0; i<n-1; i++){
        cin>>c[i];
    }
    for (ll i = 0; i<n; i++){
        a[i]--;
    }
    
    ll ans = 0;
    
    for (ll i = 0; i<n; i++){
        ans += b[a[i]];
    }
    for (ll i = 0; i < n-1; i++){
        if(a[i]+1 ==  a[i+1]){
            ans += c[a[i]];
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import math

rcvr = [0, 0, 0, 0, 0]
i = 0
while (i < 5):
    rcvr[i] = int(input())
    i += 1

i = 0
ceiled = [0, 0, 0, 0, 0]
dif =  [0, 0, 0, 0, 0]
while (i < 5):
    ceiled[i] = math.ceil(rcvr[i] / 10)*10
    dif[i] = rcvr[i] - ceiled[i]
    i += 1


diff = min(dif)
ans = 0
for d in ceiled:
    ans +=  d

ans += diff
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

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

	double ans = 0.0;
	for(int i = 1; i <= n; i++){
		int cnt = 0;
		int ret = 1;
		while(i*ret < k){
			cnt++;
			ret*=2;
		}
		ans += pow(0.5,cnt);
	}
	printf("%.15f\n", ans/n);


	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final String next = sc.next();
        if (next.equals("A")) {
            System.out.println("T");
        } else if (next.equals("T")) {
            System.out.println("A");
        } else if (next.equals("C")) {
            System.out.println("G");
        } else if (next.equals("G")) {
            System.out.println("C");
        }
    }
}


Measured memory_bytes: 21716
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class Task {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int a = in.nextInt() + in.nextInt();
            int h = in.nextInt() / 2;
            out.printLine(a * h);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tokenizer = null;

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 8148
import itertools
n = int(input())
points = [ list(map(int,input().split())) for _ in range(n)]
routes = list(itertools.permutations(points))
ans = 0
for route in routes:
    for i in range(len(route)-1):
        x,y = route[i][0],route[i][1]
        a,b = route[i+1][0],route[i+1][1]
        ans += ((x-a)**2+(y-b)**2 )**(0.5)
ans /= len(routes)        
print(ans)

Measured memory_bytes: 13920
fun main(args: Array<String>) {
    val a = IntArray(5) { readLine()!!.toInt() }
    var t = a.map { if (it % 10 == 0) it else (it / 10 + 1) * 10 }.sum()
    val l = a.filter { it % 10 != 0 }.minBy { it % 10 }
    if (l != null) {
        t -= 10 - l % 10
    }
    println(t)
}


Measured memory_bytes: 33720
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i > 0; i--)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
template <typename Iter> std::string join(Iter begin, Iter end, std::string const& separator){ std::ostringstream result; if (begin != end){ result << *begin++; }; while (begin != end){ result << separator << *begin++; }; return result.str(); }
using namespace std;
typedef long long ll;
void solve() {
  ll k, x;
  cin >> k >> x;
  vector<ll> a;
  FOR(i, x - k + 1, x + k) {
    if (-1000000 <= i && i <= 1000000) {
      a.push_back(i);
    }
  }
  cout << join(ALL(a), " ") << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

struct unionfind{
    vector<int> parent;
    vector<int> rank;
    vector<int> sizeb;
    vector<int> sizew;

    unionfind (int N) {
        parent = vector<int>(N);
        iota(parent.begin(), parent.end(), 0);
        rank = vector<int>(N, 0);
        sizeb = vector<int>(N, 0);
        sizew = vector<int>(N, 0);
        
    }
    int root(int x) {
        if (parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            sizeb[x] += sizeb[y];
            sizew[x] += sizew[y];
        }
        else {
            parent[x] = y;
            sizeb[y] += sizeb[x];
            sizew[y] += sizew[x];
            if (rank[x] == rank[y]) rank[y] += 1;
        }
    }

    int getsizeb(int x) {
        return sizeb[root(x)];
    }
    int getsizew(int x) {
        return sizew[root(x)];
    }
};

ll modpower(ll a, ll r, ll mod){ //a^r
    ll x = 1;
    a %= mod;
    while (r > 0) {
        if (r & 1) x = x * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return x;
}

ll modinv(ll a, ll mod){
    return modpower(a, mod-2, mod);
}

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    unionfind uf(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
        if (P[i] > 0) {
            P[i]--;
            uf.sizeb[i] = 1;
        }else {
            uf.sizew[i] = 1;
        }
    }
    ll K = count(P.begin(), P.end(), -1);
    
    for (int i = 0; i < N; i++) {
        if (P[i] >= 0) uf.unite(i, P[i]);
    }
    
    vector<ll> node;
    ll cycle = 0;
    for (int i = 0; i < N; i++) {
        if (uf.root(i) != i) continue;
        if (uf.getsizew(i) == 0) cycle++;
        else node.push_back(uf.getsizeb(i) + uf.getsizew(i));
    }
    
    ll mod = 1e9+7;
    ll cc = 0;
    cc += cycle * modpower(N-1, K, mod) % mod;
    
    vector<ll> dp(N+2, 0);
    dp[0] = 1;
    for (ll n : node) {
        for (int i = N; i >= 0; i--) {
            dp[i+1] += dp[i]*n%mod;
            dp[i+1] %= mod;
        }
    }
    
    vector<ll> fact(N+1, 1);
    for (int i = 2; i <= N; i++) fact[i] = fact[i-1]*i%mod;
    
    cc += (dp[1] - K) * modpower(N-1, K-1, mod) % mod;
    for (int i = 2; i <= K; i++) {
        cc += dp[i] * modpower(N-1, K-i, mod) % mod * fact[i-1] % mod;
        cc %= mod;
    }
    ll ans = N * modpower(N-1, K, mod) - cc;
    cout << (ans%mod+mod)%mod << endl;
    
    return 0;
}


Measured memory_bytes: 3868
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
  int n,s=0,ss=0,k=0,t=0,u=0;
   cin>>n;
   vector<int> w(n);
   rep(i,n)cin>>w.at(i);
   rep(i,n)s+=w.at(i);
   rep(i,n){
   k++;
     ss+=w.at(i);
     if(ss>s/2)break;
   }
   rep(i,k-1)t+=w.at(i);
   t=s-2*t;
   rep(i,k)u+=w.at(i);
   u=2*u-s;
   cout<<min(t,u)<<endl;
}


Measured memory_bytes: 256
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o B.exe B.cpp 
Execute: ./B
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

bool check_if_success(int red, int green, int blue) {
	return (green > red && blue > green); 
}

bool check_branches(int red, int green, int blue, int k) {
	// Base case: if you're out of operations, check if r/g/b meet the criterion. 
	if(k == 0) {
		return(check_if_success(red, green, blue)); 
	} 
	
	// Check if r/g/b meet criterion. If not, check all three options. 
	if(check_if_success(red, green, blue)) {
		return true; 
	}
	return(
		check_branches(2*red, green, blue, k-1) || 
		check_branches(red, 2*green, blue, k-1) || 
		check_branches(red, green, 2*blue, k-1) 
	); 
}

int main() { 	
	int red, green, blue, k; 
	cin >> red >> green >> blue >> k; 
	
	if(check_branches(red, green, blue, k))
		cout << "Yes" << endl; 
	else 
		cout << "No" << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3632
#include<cstdio>
#include<set> 
using namespace std;
int main()
{
	int N,t;
	scanf("%d",&N);
	set<int> a;
	for(int i=0;i<N;i++)
	{
		scanf("%d",&t);
		a.insert(t);
	}
	if(N==a.size())	printf("YES\n");
	else	printf("NO\n");
}


Measured memory_bytes: 9600
def slove():
    import sys
    input = sys.stdin.readline
    n, q = list(map(int, input().rstrip('\n').split()))
    s = str(input().rstrip('\n'))
    sc = [0] * n
    cnt = 0
    for i in range(1, n):
        if s[i] == "C" and s[i-1] == "A":
            cnt += 1
        sc[i] = cnt
    for i in range(q):
        l, r = list(map(int, input().rstrip('\n').split()))
        print(sc[r-1] - sc[l-1])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 53848
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;
typedef string tring;

lint N, arr[200001];
lint dp[200001], accu[200001];

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, N) {
		cin >> arr[i + 1]; arr[i + 1]--;
	}
	REP(i, 200001) accu[i] = -1;
	dp[0] = 1;
	FOR(i, 1, N + 1) {
		dp[i] = dp[i - 1];
		if (i != N && arr[i] == arr[i + 1]) continue;
		if (accu[arr[i]] != -1) {
			dp[i] += dp[accu[arr[i]]];
		}
		dp[i] %= MOD;
		accu[arr[i]] = i;
	}
	cout << dp[N];
}

Measured memory_bytes: 4992
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main(args: Array<String>) {
    val (k, t) = intList()
    val a = intList().toMutableList()
    val max = a.max()!!
    a.removeAt(a.indexOf(max))
    val total = a.sum()
    val d = max - total
    if (d <= 0) {
        println("0")
    } else {
        println("${d - 1}")
    }
}


Measured memory_bytes: 37684