akhauriyash/Code-Regression huggingface dataset:
import fractions

def lcm(a,b):
    return fractions.gcd(a,b)

N, X = map(int, input().split())
map_list = [int(i) for i in input().split()]

map_len = []
for i in range(N):
    map_len.append(abs(X - map_list[i]))

ans = map_len[0]
for i in range(1, len(map_len)):
    ans = fractions.gcd(ans, map_len[i])
    i += 1

print(ans)


Measured memory_bytes: 16276
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let a: u64 = input();
    println!("{}", a + a * a + a * a * a);
}

Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e9;

int main(){
    ll N;
    cin >> N;
    vector<ll> V(N+1);
    for(int i=0;i<N;i++){
        cin >> V[i];
    }

    ll ans = 0;
    for(int i=0;i<N;i++){
        if(i+1 != N){
            if(i+1 == V[i]){
                ans++;
                if(i+2 == V[i+1])i++;
            }
        }else if(i+1 == V[i])ans++;
    }

    cout << ans << endl;
}

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

int main()
{
ll n ;
cin >> n ;
vector<ll> a(n);
rep(i, n){
  cin >> a[i];
}
rep(i,n-1){
  if(a[i]%2&&a[i+1]>0){
    ans++;
    a[i+1]--;
  }
  ans+=a[i]/2;
}
ans+=a[n-1]/2;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mn = 100005;
char s[mn];
int a[mn][30], b[mn][30];
int main()
{
	int n, i;
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(i = 1; i <= n; i++)
		if(s[i] == s[i - 1])
		{
			printf("%d %d\n", i - 1, i);
			return 0;
		}
		else if(s[i] == s[i - 2])
		{
			printf("%d %d\n", i - 2, i);
			return 0;
		}
	printf("-1 -1\n");
}


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

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

int main() {
    int H, i, A[MAX + 1];
    
    cin >> H;
    for (i = 1; i <= H; i++) cin >> A[i];
    
    for (i = 1; i <= H; i++) {
        cout << "node " << i << ": key = " << A[i] << ", ";
        if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
        if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
        if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3112
# include<bits/stdc++.h>
# define ll long long
# define lli long long int
using namespace std;
int main(){
 lli n,m,ans=0;
  cin>>n>>m;
  ans=n*m;
  if(n==1 ||m==1)
    ans=1;
 else if(ans%2)
    ans=(ans+1)/2;
  else
    ans=ans/2;
  cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

int r, c, k;
int grid[3005][3005];
int dp[3005][3005][4]; //row col left
int32_t main() {

    fast
    cin >> r >> c >> k;
    int x, y, value;

    for(int i = 0; i < k; i++) {
        cin >> x >> y >> value;
        grid[x][y] = value;
    }
    for(int i = 1; i <= r; i++) {
        for(int j = 1; j <= c; j++) {
            for(int k=0;k<=3;k++){
                dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
                dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+grid[i][j]);
                dp[i][j][2]=max(dp[i][j][2],dp[i-1][j][k]+grid[i][j]);
                dp[i][j][3]=max(dp[i][j][3],dp[i-1][j][k]+grid[i][j]);

                if(k>0){
                    dp[i][j][k]=max({dp[i][j][k],dp[i][j-1][k-1]+grid[i][j],dp[i-1][j][k],dp[i][j-1][k]});
                }
            }
        }
    }

    int ans=0;
    for(int i=0;i<4;i++)ans=max(ans,dp[r][c][i]);
    cout << ans<< endl;




    return 0;
}



Measured memory_bytes: 355780
// @prefix atcoder
// @description atcoder template

#include <bits/stdc++.h>
using namespace std;
#define int long long

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

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'
#define DEBUGP(x) cerr << #x << ": " << x.first << " \t" << x.second << '\n'
#define INF (1ll << 60)

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
const int MOD = 1e9 + 7;

int n, m;
VVI mp(100010);
vector<bool> visited(100000);
VI mark(100000);

signed main() {
  cin >> n >> m;
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    mp[a].push_back(b);
    mp[b].push_back(a);
  }

  queue<int> q;
  q.push(0);
  visited[0] = true;

  while (q.empty() != true) {
    int v = q.front();
    q.pop();
    for (auto next_v : mp[v]) {
      if (visited[next_v] == false) {
        DEBUGP(make_pair(v, next_v));
        mark[next_v] = v;
        visited[next_v] = true;
        q.push(next_v);
      }
    }
  }

  bool flag = true;
  REP(i, n) {
    if (visited[i])
      continue;
    flag = false;
  }
  if (flag) {
    cout << "Yes" << endl;
    FOR(i, 1, n) { cout << mark[i] + 1 << endl; }
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); 
	cout.tie(NULL);
int x;
cin>>x;
if(x<600)
cout<<8;
else if(x<800)
cout<<7;
else if(x<1000)
cout<<6;
else if(x<1200)
cout<<5;
else if(x<1400)
cout<<4;
else if(x<1600)
cout<<3;
else if(x<1800)
cout<<2;
else if(x<2000)
cout<<1;
	return 0;
}


Measured memory_bytes: 3648
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		boolean flag = false;
		while(true){
			int n = stdIn.nextInt();
			if(n==0){
				return;
			}
			if(flag){
				System.out.println();
			}
			flag = true;
			String[] country = new String[n];
			int[] point = new int[n];
			int[] copy = new int[n];
			for(int i=0;i<n;i++){
				country[i] = stdIn.next();
				point[i] += stdIn.nextInt()*3;
				stdIn.nextInt();
				point[i] += stdIn.nextInt();
				copy[i] = point[i];
			}
			Arrays.sort(copy);
			int cnt = 0;
			for(int i=0;i<n;i+=cnt){
				cnt = 0;
				for(int j=0;j<n;j++){
					if(copy[n-i-1]==point[j]){
						System.out.println(country[j]+","+point[j]);
						cnt++;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
int main(void)
{
	int n,i,j,k,x[101],cum;
	int a[5000],b[5000],c[5000],d[5000],s[5000];
	scanf("%d",&n);
	for(i=1;i<=n*(n-1)/2;i++){
		scanf("%d",&a[i]);
		scanf("%d",&b[i]);
		scanf("%d",&c[i]);
		scanf("%d",&d[i]);
	}
	for(i=1;i<=n*(n-1)/2;i++){
		s[i]=0;
	}
	for(i=1;i<=n*(n-1)/2;i++){
		if(c[i]<d[i]){
			s[b[i]]+=3;
		}
		else if(c[i]>d[i]){
			s[a[i]]+=3;
		}
		else{
			s[b[i]]++;
			s[a[i]]++;
		}
	}
	for(i=1;i<=n;i++){
		x[i]=1;
	}
	for(i=1;i<=n-1;i++){
		for(j=i+1;j<=n;j++){
			if(s[i]<s[j]){
				x[i]++;
			}
			if(s[i]>s[j]){
				x[j]++;
			}
		}
	}
	for(i=1;i<=n;i++){
		printf("%d\n",x[i]);
	}
	return 0;
}


Measured memory_bytes: 2140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {
	int N, M;
	Set<Integer>[] conns;
	boolean[] done;
	int result;

	Main(int N, int M, List<String> lines) {
		this.N = N;
		this.M = M;
		this.conns = new Set[N];
		this.done = new boolean[N];
		Arrays.fill(this.done, false);
		for (int i = 0; i < N; ++i) {
			this.conns[i] = new HashSet<>();
		}
		for (String line : lines) {
			String[] tokens = line.split(" ");
			int X = Integer.parseInt(tokens[0]);
			int Y = Integer.parseInt(tokens[1]);
			int Z = Integer.parseInt(tokens[2]);
			this.conns[X - 1].add(Y - 1);
			this.conns[Y - 1].add(X - 1);
		}
		result = calc2();
	}

	int calc2() {
		int result = 0;
		for (int i = 0; i < N; ++i) {
			if (!this.done[i]) {
				++result;
				this.calc(i);
			}
		}
		return result;
	}

	void calc(int nodeIndex) {
		this.done[nodeIndex] = true;
		for (Integer key : conns[nodeIndex]) {
			this.conns[key].remove(nodeIndex);
		}
		for(Integer key: conns[nodeIndex]) {
			calc(key);
		}
		this.conns[nodeIndex].clear();
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int N = Integer.parseInt(tokens[0]);
		int M = Integer.parseInt(tokens[1]);
		List<String> lines = new ArrayList<>(M);
		for (int i = 0; i < M; ++i) {
			lines.add(in.readLine());
		}
		in.close();
		Main ins = new Main(N, M, lines);
		System.out.println(ins.result);
	}
}

Measured memory_bytes: 120188
#![allow(non_snake_case)]
use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let _: usize = read();
    let S: String = read();
    let mut before_char = '-';
    let mut ans = 0;
    for c in S.chars() {
        if c != before_char {
            ans += 1;
            before_char = c;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4476
"""
group1 = [1,3,5,7,8,10,12]
group2 = [4,6,9,11]
group3 = [2]
x,y = map(int,input().split())
if (x in group1 and y in group1) or (x in group2 and y in group2) or (x in group3 and y in group3):
    print("Yes")
else:
    print("No")
"""
x,y = map(int,input().split())
grouplist = [0,1,3,1,2,1,2,1,1,2,1,2,1]
if grouplist[x]==grouplist[y]:
    print("Yes")
else:
    print("No")


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    int mini = 1e9;
    for (int i = 0; i < 110; i++) {
        int tmp = 0;
        for (int j = 0; j < n; j++) {
            tmp += (x[j] - i) * (x[j] - i);
        }
        mini = min(mini, tmp);
    }
    cout << mini << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC147 D - Xor Sum 4
// 2020.06.19

ll MOD = 1e9+7;
ll fastpow(ll a, ll n){  // a^n mod MOD
  if(n==0) return 1;
  if(n%2==0){
    ll t = fastpow(a, n/2) % MOD;
    return t*t % MOD;
  }
  return a * fastpow(a, n-1) % MOD;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
  }
  vector<ll> B(60, 0);
  REP(i, N){
    REP(j, 60){
      if((A[i] >> j) & 1) B[j]++; 
    }
  }
  
  vector<ll> P(60);
  REP(i, 60){
    P[i] = fastpow(2, i)%MOD;
  }

  ll ans = 0;
  REP(i, N-1){
    REP(j, 60){
      if((A[i] >> j) & 1){
        B[j]--;
        ans = (ans + P[j]*(N-1-i-B[j]))%MOD;
      }else{
        ans = (ans + P[j]*B[j])%MOD;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5572
import heapq
N=int(input())
alist=list(map(int,input().split()))

alist.sort(reverse=True)
answer=0
hq=[]
heapq.heappush(hq,-alist[0])
for a in alist[1:]:
  r=heapq.heappop(hq)
  answer+=-r
  heapq.heappush(hq,-a)
  heapq.heappush(hq,-a)
  
print(answer)

Measured memory_bytes: 100412
#include <unistd.h>

#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)>(y)?(x):(y))

int n;
long long int B[60];

char ibuf[4000000];
char *ibufe = ibuf-1;

void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

long long int read_uintll(){
  long long int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

char buf[100];
char *bufe = buf;

void write_uintll(long long int x){
  int i;
  static char tmp[14];
  if(x==0){
    *bufe++ = '0';
    *bufe++ = '\n';
    return;
  }

  for(i=0; x; i++){
    tmp[i] = '0' + x % 10;
    x /= 10;
  }
  for(i--; i >= 0; i--){
    *bufe++ = tmp[i];
  }
  *bufe++ = '\n';
}

void writeall(){
  int k, t = 0;
  while((k=write(STDOUT_FILENO, buf+t, bufe-buf-t))>0) t += k;
}



int main(){
  int i, j;
  long long int a=0, z=0;
  readall();
  n = read_uintll();
  for(i=0;i<n;i++){
    long long int x = read_uintll();
    if(!x) continue;
    a ^= x;
    for(j=59;j>=0;j--){
      x = MIN(x, x^B[j]);
    }
    if(x) B[63-__builtin_clzll(x)] = x;
  }
  for(j=0;j<60;j++){
    B[j] &= ~a;
    if(!B[j]) continue;
    if(a&(1LL<<j)){
      int k = 63-__builtin_clzll(B[j]);
      for(;k>=0;k--) B[j] = MIN(B[j], B[j]^B[k]);
      if(B[j]) B[63-__builtin_clzll(B[j])] = B[j];
      B[j] = 0;
    }
  }
  for(j=59;j>=0;j--) z = MAX(z, z^B[j]);

  write_uintll(2*z + a);
  writeall();

  return 0;
}


Measured memory_bytes: 2048
H, W = map(int, input().split())

grid = []
cols = [True for _ in range(W)]
rows = [True for _ in range(H)]

for _ in range(H):
    tmp = input()
    grid.append(tmp);
    
for i in range(H):
    if grid[i].count('.') == W:
        rows[i] = False        


for i in range(W):
    count = 0
    for j in range(H):
        if grid[j][i] == '.':
            count += 1
    if count == H:
        cols[i] = False

for i in range(H):
    if rows[i]:
        for j in range(W):
            if cols[j]:
                print(grid[i][j], end="")
        print()

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string ans="Yes";
  int N;
  cin >> N;
  int H1=0,H2;
  for(int i=0; i<N; i++){
    cin >> H2;
    if(H1>H2)ans="No";
    if(H1!=H2)H1=H2-1;
  }
  cout << ans << endl;
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							     \
			cout.tie(0);
#define sz(arr) ll(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }
ll kCn(ll k, ll n, ll f[]) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	int n, m, x;
	cin >> n >> m >> x;
	vector<vector<int>> c(n, vector<int>(m + 1));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m + 1; ++j)
			cin >> c[i][j];
	}
	int ans = 1e9;
	for (int i = 0; i < (1 << n); ++i) {
		vector<int> skill(m);
		int total = 0;
		for (int j = 0; j < 32; ++j) {
			if (1 & (i >> j)) {
				for (int k = 1; k <= m; ++k)
					skill[k-1] += c[j][k];
				total += c[j][0];
			}
		}
		bool ok = true;
		for (auto s : skill) {
			if (s < x) {
				ok = false;
				break;
			}
		}
		if (ok)
			ans = min(ans, total);
	}
	cout << (ans == 1e9 ? -1 : ans);
	return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define inf 1e17
using namespace std;

long long n, c, ans = 0;
vector<long long> v, x, memo;

void solve();
void calc();

int main() {
  cin >> n >> c;
  v.assign(n, 0);
  x.assign(n, 0);
  memo.assign(n, 0);
  for(int i = 0; i < n; ++i) cin >> x[i] >> v[i];
  calc();
  solve();
  reverse(x.begin(), x.end());
  reverse(v.begin(), v.end());
  for(int i = 0; i < n; ++i) x[i] = c - x[i];
  calc();
  solve();
  cout << ans << endl;
  return 0;
}

void solve() {
  long long sum = 0;
  ans = max(ans, memo[n - 1]);
  for(int i = 0; i < n - 1; ++i) {
    long long now = 0;
    now = memo[n - 2 - i];
    sum += v[n - 1 - i];
    now += sum;
    now -= 2 * (c - x[n - 1 - i]);
    ans = max(ans, now);
  }
}

void calc() {
  long long sum = v[0] - x[0];
  for(int i = 0; i < n; ++i) {
    if(i == 0) {
      memo[i] = max(0LL, sum);
      continue;
    }
    sum += v[i] - x[i] + x[i - 1];
    memo[i] = max(memo[i - 1], sum);
  }
}

Measured memory_bytes: 2560
n,m = map(int,input().split())
A = [input() for i in range(n)]
B = [input() for i in range(m)]
for i in range(n-m+1):
    for j in range(n-m+1):
        s = [a[j:j+m] for a in A[i:i+m]]
        if s == B:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int h[100002];
int n,a,b;
bool ok(int t){
	long long q=0;
	for(int i=1;i<=n;++i){
		if(1ll*a*t<h[i]) return false;
		long long x=h[i]-1ll*b*t;
		if(x>0)q+=(x-1)/(a-b)+1;
		if(q>t) return false; 
	}
	return true;
}
int main(){
	cin>>n>>a>>b;
	for(int i=1;i<=n; ++i) cin>>h[i];
	int l=1,r=1e9;
	while (l<=r){
		int md=(l + r)>>1;
		if(ok(md)) r=md-1;
		else l=md+1;
	}
	cout<<l;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
using namespace std;
typedef long long ll;

int main(void) {
	string s;
	cin >> s;
	if (s[0] == '9') s[0] = '1';
	else s[0] = '9';
	if (s[1] == '9')s[1] = '1';
	else s[1] = '9';
	if (s[2] == '9')s[2] = '1';
	else s[2] = '9';
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a[500005];
int b[500005];
int res=0;
void merge(int l,int r){
	int m=(l+r)/2;
	// l,m    m+1,r
	int p1=l,p2=m+1;
	for(int i=l;i<=r;i++){
		res++;
		if(p2>r||(p1<=m&&a[p1]<a[p2])){
			b[i]=a[p1];
			p1++;
		}else{
			b[i]=a[p2];
			p2++;
		}
	}
	for(int i=l;i<=r;i++)a[i]=b[i];
}
void ms(int l,int r){
	if(l>=r)return;
	ms(l,(l+r)/2);
	ms((l+r)/2+1,r);
	merge(l,r);
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	ms(1,n);
	for(int i=1;i<n;i++)cout<<a[i]<<" ";
	cout<<a[n]<<endl<<res<<endl;
	return 0;
}


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

#define N 2000000

int Heap[N+1];

void maxHeapify(int H, int i){
  int largest, tmp;
  int l = 2 * i;
  int r = 2 * i + 1;

  if(l <= H && Heap[l] > Heap[i]){
    largest = l;
  }
  else{
    largest = i;
  }

  if(r <= H && Heap[r] > Heap[largest]){
    largest = r;
  }

  if(largest != i){
    tmp = Heap[i];
    Heap[i] = Heap[largest];
    Heap[largest] = tmp;
  
    maxHeapify(H, largest);
  }
}

int main(){
  int H;

  cin >> H;

  for(int i = 1 ; i <= H ; i++){
    cin >> Heap[i];
  }

  for(int i = H ; i >= 1 ; i--){
    maxHeapify(H, i);
  }

  for(int i = 1 ; i <= H ; i++){
    cout << " " << Heap[i];
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 3112
#include <iostream>

using namespace std;

constexpr int kMod = 1e9 + 7;

int Factorial(int n)
{
    auto res = 1;
    for (auto i = 2; i <= n; i += 1) {
        res = (1LL * res * i) % kMod;
    }
    return res;
}

int Solve(int dogs, int monkeys)
{
    if (abs(dogs - monkeys) > 1) {
        return 0;
    }

    auto fact_dogs = Factorial(dogs);
    auto fact_monkeys = Factorial(monkeys);

    auto res = (1LL * fact_dogs * fact_monkeys) % kMod;
    if (dogs == monkeys) {
        res = (1LL * res * 2) % kMod;
    }

    return res;
}

int main()
{
    int dogs, monkeys;
    cin >> dogs >> monkeys;

    auto res = Solve(dogs, monkeys);
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll modinv(ll a, ll mod) {
    return modpow(a, mod-2, mod);
}
ll modsub (ll a, ll b, ll mod) {
    return (a < b) ? mod + a - b : (a - b) % mod;
}
ll C(ll n, ll k) {
    ll ue = 1;
    ll shita = 1;
    rep(i, k) {
        ue *= (n - i);
        shita *= (i + 1);
        ue = ue % MOD;
        shita = shita % MOD;
    }
    return ue % MOD * modinv(shita, MOD) % MOD;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    if (n <= 2) cout << 0 << endl;
    else {
        ll ans = modpow(2, n, MOD) - 1;
        ans = modsub(ans, C(n, a), MOD);
        ans = modsub(ans, C(n, b), MOD);

        cout << ans << endl;
    }


	return 0;
}


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

namespace ABC061A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);

            if (a <= c && c <= b  && -100 <= a && c <= 100)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))
result = sum(b_list)
dif_list = []
for i in range(n -1):
  if a_list[i + 1] == a_list[i] + 1:
    dif_list.append(1)
  else:
    dif_list.append(0)
for m in range(len(dif_list)):
   if dif_list[m] == 1:
    result += c_list[a_list[m] -1]
print(result)


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
int n = sc.nextInt();
if (n == 0) {
break;
}
int[] values = new int[n];
for (int i = 0; i < n; i++) {
values[i] = sc.nextInt();
}
int min = 1000, max = 0;
for (int i = 0; i < n; i++) {
if (values[i] >= max) {
max = values[i];
}
if (values[i] <= min) {
min = values[i];
}
}
double tot = 0;
for (int i = 0; i < n; i++) {
tot += values[i];
}
tot -= (max + min);
double ave =tot/( n - 2);
System.out.println((int) ave);
}
}
}

Measured memory_bytes: 28356
N = int(input())
c = [0, 0, 0, 0]
for i in range(N):
    s = str(input())
    if s == 'AC':
        c[0] += 1
    elif s == 'WA':
        c[1] += 1
    elif s == 'TLE':
        c[2] += 1
    else:
        c[3] += 1

print('AC x ', c[0])
print('WA x ', c[1])
print('TLE x ', c[2])
print('RE x ', c[3])


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

  if(N==2||N==4||N==5||N==7||N==9){
    cout << "hon" << endl;
  }else if(N==0||N==1||N==6||N==8){
    cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }
}

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

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

using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<int> s(1),t(1);
  rep(i,n){
    int tmp;
    cin>>tmp;
    if(tmp%10==0)t.push_back(tmp);
    
    else s.push_back(tmp);
  }
  //cout<<s.size()<<"s"<<f.size()<<"f"<<t.size()<<endl;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  
  int ans = 0;

  int ssum = 0;
  //cout<<s.size()<<endl;
  rep(i,s.size()){
    ssum+=s.at(i);
  }
  //if(ssum%10==0&&ssum!=0)ssum-=s.at(1);//!5

  int tsum = 0;
  rep(i,t.size())tsum+=t.at(i);//10


  if(ssum%10==0&&ssum!=0)ssum-=s.at(1);

  ans=ssum+tsum;
  if(ans%10==0)cout<<0<<endl;
  else cout<<ans<<endl;
 
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


#define MAX_V 10

struct edge {
    int to;
    int cost;
};



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

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
  int h, w;
  cin >> h >> w;
    V=10;
    for (int i=0; i<10; ++i) {
      rep(j, 10){
        int c;
        cin >> c;
        edge e = {i, c};
        G[j].push_back(e);
      }
    }
    dijkstra(1);
    int a;
    ll ans=0;
    rep(i, h){
      rep(j, w){
        cin >> a;
        if(a!=-1){
          ans+=d[a];
        }
      }
    }
    cout << ans << endl;
}


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

int a, b, c, x;
int ans = 0;
int total;

int main() {
    cin >> a >> b >> c >> x;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                total = 500 * i + 100 * j + 50 * k;
                if (total == x) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    long a[] = new long[n];
    long dp[] = new long[81];
    for (int i = 0; i < n; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    dp[0] = 1000;
    for (int i = 1; i < n; i++) {
      long min = Integer.MAX_VALUE;
      for (int j = i - 1; j >= 0; j--) {
        min = Math.min(min, a[j]);
        dp[i] = Math.max(dp[j] / min * a[i] + dp[j] % min, dp[i]);
      }
    }
    long ans = 0;
    for (int i = 0; i < n; i++) {
      ans = Math.max(dp[i], ans);
    }
    pw.println(ans);
  }
}


Measured memory_bytes: 35724
import java.util.Scanner;

public class Main {
    static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        int n = in.nextInt(), m = in.nextInt();
        if (Math.abs(n - m) > 1) {
            System.out.println(0);
            return;
        }
        long ans = 1;

        for(int i = Math.min(n, m); i > 0; i--){
            ans = (ans % 1000000007) * i;
        }
        ans = (ans % 1000000007) * (ans % 1000000007);
        if(n == m){
            ans *= 2;
        }else{
            ans = (ans % 1000000007) * Math.max(n, m);
        }
        System.out.println(ans % 1000000007);
    }
}


Measured memory_bytes: 22868
#include<stdio.h>

int main(){
  int n,k,a,i;
  scanf("%d%d",&n,&k);
  a=(n-2)*(n-1)/2;
  if(k>a) {
    printf("-1");
    return 0;
  }// a>=k
  a=a-k;
  printf("%d\n",n-1+a);
  for(i=1;i<n;i++){
    printf("%d %d\n",n,i);
  }
  i=1;
  int j=2;
  while(a>0){
    printf("%d %d\n",i,j);
    a--;
    j++;
    if(j==n){
      i++;
      j=i+1;
    }
  }

}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
long N,M;
long A[1010],B[1010];

int main(){
  cin >> N >> M;
  for (long i=1;i<=N;i++)cin >> A[i];
  for (long i=1;i<=M;i++)cin >> B[i];
  long ans=1;
  sort(A+1,A+N+1);
  sort(B+1,B+M+1);
  long p=0,q=0;

  for (long num=N*M;num>=1;num--){
    int p_same=0,q_same=0;
    while(1){
      if (N-p==0)break;
      if (num>A[N-p])break;
      if (num==A[N-p]){p++;p_same++;}
    }
    while(1){
      if (M-q==0)break;
      if (num>B[M-q])break;
      if (num==B[M-q]){q++;q_same++;}
    }

    if (p_same>1 || q_same>1){cout << 0 << endl;return 0;}

    if (p_same==1 && q_same==1){
      /*-----*/
    }
    if (p_same==1 && q_same==0){
      ans = ans*q%1000000007;
    }
    if (p_same==0 && q_same==1){
      ans = ans*p%1000000007;
    }
    if (p_same==0 && q_same==0){
      long x=p*q-(M*N-num);
      if (x<=0){
        cout << 0 << endl;return 0;
      }
      ans = ans*x%1000000007;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    map<int, int> cnt;
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        ++ cnt[a];
    }

    int ans = 0;
    for(const auto& p : cnt){
        if(p.first < p.second)
            ans += p.second - p.first;
        else if(p.second < p.first)
            ans += p.second;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4736
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]
c = list(map(int, input().split()))

table = [[] for _ in range(N)]

for ai, bi in ab:
    table[ai - 1].append(bi - 1)
    table[bi - 1].append(ai - 1)


for i_root, row in enumerate(table):
    # print("##", row)
    if len(row) > 1: break

from collections import deque

c.sort(key=lambda x: -x)

# print("#", i_root)
nodes = [None] * N

q = deque([(i_root, 0)])
nodes[i_root] = c[0]
idx_c = 1
while len(q) > 0:
    src, d = q.popleft()
    for dst in table[src]:
        if nodes[dst] == None:
            q.append((dst, d + 1))
            nodes[dst] = c[idx_c]
            idx_c += 1

# print("#", nodes)
print(sum(c) - c[0])
print(' '.join(map(str, nodes)))

Measured memory_bytes: 9544
def main(argv)
  n = gets.chomp.to_i
  p = gets.chomp.split(' ').map(&:to_i)
  q = gets.chomp.split(' ').map(&:to_i)

  a = -1
  b = -1
  c = 0
  (1..n).to_a.permutation do |x|
    a = c if x == p
    b = c if x == q
    c += 1
  end

  puts (a - b).abs.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 2172
#157c
def solve(n,s,c):
	#print('h')
	num=str(n)
	end=len(s)
	flg=False
	for i in range(end):
		#print(num)
		#print('num[si]-1:',num[s[i]-1])
		#print('c[i]:',c[i])
		if int(num[s[i]-1])!=c[i]:
			return False
	return True


def test(n,m,ss,cc):
	tmp=str(n)
	for i in range(m):
		for j in range(i+1,m):
			#print("s:",ss[i])
			if ss[i]==ss[j] and cc[i]!=cc[j]:
				return False
			elif ss[i]==1 and cc[i]==0:
				return False
	return True

n,m=map(int,input().split())
ss=[]
cc=[]
ans=-1
cnt=0
end=10
if n==2:
	cnt,end=10,100
elif n==3:
	cnt,end=100,1000
for _ in range(m):
	s,c=map(int,input().split())
	ss.append(s)
	cc.append(c)
#print(ss)
#print(cc)
for i in range(cnt,end):
	if test(i,m,ss,cc):
		if solve(i,ss,cc):
			ans=i
			break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>V(n);
  vector<int>C(n);
  int sum=0;
  for (int i=0; i<n; i++) cin>>V[i];
  for (int i=0; i<n; i++) cin>>C[i];
  for (int i=0; i<n; i++){
    if (V[i]>C[i]){
      sum += V[i]-C[i];
    }
  }
  cout<<sum;
}

Measured memory_bytes: 3608
#D問題
N,M = map(int,input().split())
D = [int(input()) for i in range(N)]
C = [int(input()) for j in range(M)]

inf = float("inf")

dp = [[inf for i in range(N+1)] for j in range(M+1)]
dp[0][0] = 0
for j in range(M):
    dp[j+1] = dp[j][0:N+1]
    for i in range(N):
        if dp[j][i] != inf:
            dp[j+1][i+1] = min(dp[j+1][i+1],dp[j][i]+D[i]*C[j])
    #print(dp)
print(dp[M][N])


Measured memory_bytes: 19176
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意



n = int(input())
v = [int(i) for i in readline().split()]

v.sort()

ans = v[0]
for i in v:
    ans = (ans + i)/2

print(ans)

















Measured memory_bytes: 2940
#include <stdio.h>
int main(void)
{
	int i,j,n,point,outcount,runner;
	char judge[10];
	
	scanf("%d",&n);
	
	outcount=0;
	runner=0;
	point=0;
	while(scanf("%s",judge)!=EOF){
		if(judge[1]=='I'){
			if(runner==3){
				point++;
			}else{
				runner++;
			}
		}else if(judge[1]=='O'){
			point+=runner+1;
			runner=0;
		}else if(judge[1]=='U'){
			outcount++;
			if(outcount==3){
				printf("%d\n",point);
				outcount=0;
				runner=0;
				point=0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;



int main(){
int n; cin >>n;
int c[600],s[600],f[600];

for(int i=0;i<n-1;i++)
cin>>c[i]>>s[i]>>f[i];



for(int i=0;i<n;i++)
{
int time=0;
  for(int j=i;j<n-1;j++)
  {
  //iさんが駅jについたときに最初の列車が到着する時刻s[j]より前であれば
  if(time<=s[j]) time=s[j]+c[j];
  //そうでなければ、
  else{
  int next = ((time-s[j])+f[j]-1)/f[j];
  time =s[j]+ next*f[j]+c[j];
}

  }
  cout<<time<<endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int log2(int n){
  int ans=0, x=1;
  while(x < n){
    x *= 2;
    ans++;
  }
  return ans;
}

int main(){
  int n,k;
  cin >> n >> k;
  
  double ans;
  rep(i,n){
    int m = log2((k+i)/(i+1));
    ans += pow(0.5, m);
  }
  
  ans /= n;
  
  cout << setprecision(12) << ans << endl;
  
  return 0;
}

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

using namespace std;

int main(){
    int h,n,d=0;
    cin>>h>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
       d+=a[i]; 
    }
    if(d>=h)cout<<"Yes";
    if(d<h)cout<<"No";

}


Measured memory_bytes: 640
import sys
import math
import bisect
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


# A
def A():
    a, b, c = LI()
    if a + b + c >= 22:
        print("bust")
    else:
        print("win")
    return


# B
def B():
    return


# C
def C():
    return


# D
def D():
    return


# E
def E():
    return


# F
def F():
    return


# Unittest
def resolve():
    A()
    return


# Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 38256
#include<stdio.h>
int main(){
  int z;
  int i,j;
  int k,s;
  int ans=0;
  scanf("%d %d",&k,&s);
  for(i=0;i<=k;i++){
    for(j=0;j<=k;j++){
      z=s-i-j;
      if(z>=0&&z<=k)ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
using iii = pair <int , ii>;
using iiii = pair <ii , ii>;
void in(int &x);
const int N = 1e5 + 10;
const int inf = 1e9;
#define singleCase
// #define multipleCase
int n,m,dp[N][15],qryOrder[N][15];
vector <int> adj[N];
vector <iii> query;

int f(int u , int d) {
   if (d > 10) return inf;
   int &sol = dp[u][d];
   if (sol != -1) return sol;
   sol = inf;
   for (int i = d ; i <= 10 ; i++) {
      if (qryOrder[u][i] == -1) continue;
      sol = min(qryOrder[u][i] , sol);
   }
   for (int v : adj[u]) {
      sol = min(sol , f(v , d + 1));
   }
   return sol;
}

void inputAndInit() {
   memset (dp , -1 , sizeof dp);
   memset (qryOrder , -1 , sizeof qryOrder);
   in(n); in(m);
   for (int i = 0, u, v ; i < m ; i++) {
      in(u); in(v);
      adj[u].pb(v);
      adj[v].pb(u);
   }
   int q; in(q);
   query.resize(q);
   for (int i = 0, u, d , c ; i < q ; i++) {
      in(u); in(d); in(c);
      query[i] = {u , {d , c}};
   }
   reverse(all(query));
   for (int i = 0 ; i < query.size() ; i++) {
      int u = query[i].fi, d = query[i].se.fi, c = query[i].se.se;
      for (int j = 0 ; j <= d ; j++) {
         if (qryOrder[u][j] == -1) qryOrder[u][j] = i;
      }
   }
   return;
}

void work() {
   inputAndInit();
   for (int i = 1 ; i <= n ; i++) {
      int DP = f(i , 0);
      if (DP == inf) {
         puts("0");
      } else {
         printf("%d\n" , query[DP].se.se);
      }
   }
   return;
}

int main() {
   #ifdef multipleCase
      int nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(int &x) {
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 22032
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {
  long long int a,b,k;
  cin>>a>>b>>k;
  if(b-a<=k){
    for(int i=a;i<=b;i++){
      cout<<i<<endl;
    }
  }else{
    vector<long long int> v;
    for(int i=0;i<k;i++){
      v.push_back(a+i);
      v.push_back(b-i);
    }
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
    for(int i=0;i<v.size();i++){
      cout<<v[i]<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n, k;
    cin>>n>>k;
    vector<ll> v(n);
    for(auto& ele: v) cin>>ele;
    vector<ll> dp(n, INF);
    dp[0]=0;
    for(ll i =1; i<n; i++){
        for(ll j=i-1; j>=0&&j>=(i-k); j--){
            dp[i] = min(dp[i], dp[j]+(llabs(v[j]-v[i])));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}






Measured memory_bytes: 4800
#include <stdio.h>

int main() {
	long long int test, result = 1;
	scanf("%lld", &test);
	long long x[test];
	
	for(int i = 0; i < test; i++) {
		scanf("%lld", &x[i]);
	}
	for(int i = 0; i < test; i++) {
		if(x[i] == 0) {
			printf("0");
			return 0;
		}
	}
	for(int i = 0; i < test; i++) {
		if(x[i] <= (1000000000000000000 / result)){
			result *= x[i];
		} else {
			result = -1;
			break;
		}
	}
	printf("%lld", result);
	
	return 0;
}

Measured memory_bytes: 2460
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;
int sx,sy,gx,gy;

bool range(int x,int y){
  if(min(sx,gx)<=x && x<=max(sx,gx) && 
     min(sy,gy)<=y && y<=max(sy,gy))
    return true;
  return false;
}

int main(void) {
  int i,j;
  int x1,x2,y1,y2,n;
  cin>>x1>>y1>>x2>>y2;
  sx=min(x1,x2);
  gx=max(x1,x2);
  sy=min(y1,y2);
  gy=max(y1,y2);
  cin>>n;
  pii p[200000];
  rep(i,n){
    cin>>p[i].first>>p[i].second;
    if(!range(p[i].first,p[i].second))i--,n--;
  }
  if(x1>x2)rep(i,n)p[i].first*=-1;
  if(y1>y2)rep(i,n)p[i].second*=-1;
  int num=0;
  if(n){
    sort(p,p+n);
    vi v(n);
    rep(i,n)v[i]=p[i].second;
    int dp[100000]; 
    fill(dp,dp+n,INF);
    rep(i,n) *lower_bound(dp,dp+n,v[i])=v[i];
    num=lower_bound(dp,dp+n,INF)-dp;
  }
  ld ans=(ll)(abs(sx-gx)+abs(sy-gy))*100;
  if(abs(num-abs(sx-gx)-1)<EPS || abs(num-abs(sy-gy)-1)<EPS)
    ans+=5*3.141592653589793238;
  cout<<shosu(13)<<ans-20*num+num*5*3.141592653589793238<<endl;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
#include <stdlib.h>
#include <functional>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define in cin >>
#define out cout <<
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define all(v) v.begin(),v.end()
typedef long long ll;
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll modpow(ll a,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1)res=a*res%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}
void comb(vector<vector <long long int> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}
 
 
int main(){
    int n;
    cin >> n;
    ll ans=0;
    rep(i,n){
        rep(j,n){
            rep(l,n){
                ans=ans+gcd(i,gcd(j,l));
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n,a,b; cin>>n>>a>>b;
  if(n*a<b)
  cout<<n*a<<endl;
  else
  cout<<b<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

// p[i]が二番目に大きいとなる区間がいくつあるかを数えたい
//

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> p(n), id(n + 1);
    for (ll i = 0; i < n; i++)
    {
        cin >> p[i];
        id[p[i]] = i;
    }
    multiset<ll> s;
    s.insert(-1);
    s.insert(-1);
    s.insert(n);
    s.insert(n);
    ll ans = 0;
    // 大きい順から入れることで、常に自分より大きい値しか入っていない
    for (ll i = n; i >= 1; i--)
    {
        auto itr = s.lower_bound(id[i]);
        ll R1 = *itr;
        itr++;
        ll R2 = *itr;
        itr--;
        itr--;
        ll L1 = *itr;
        itr--;
        ll L2 = *itr;
        ans += i * ((R2 - R1) * (id[i] - L1) + (L1 - L2) * (R1 - id[i]));
        s.insert(id[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
using ll = long long;



int main() {
	int s;
	cin >> s;
	if (s / 100 < 13 && s % 100 < 13 &&s%100>0&&s/100>0) {
		cout << "AMBIGUOUS" << endl;
		return 0;
	}
	else if (s / 100 < 13 && s/100>0) {
		cout << "MMYY" << endl;
		return 0;
	}
	else if (s % 100 < 13 && s % 100 > 0) {
		cout << "YYMM" << endl;
		return 0;
	}
	else  cout << "NA" << endl;

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector <int> v(n),c(n);
    rep(i,n){
        cin >> v[i];
    }
    rep(i,n){
        cin >> c[i];
    }
    int ans=0;
    rep(i,n){
        if(v[i]>c[i]){
            ans+=(v[i]-c[i]);
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3600
#include <cstdio>

int main()
{
  char s[5];
  scanf("%s", s);
  puts(
    (s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) ||
    (s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) ||
    (s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) ? "Yes" : "No"
  );
  return 0;
}

Measured memory_bytes: 128
import Control.Applicative
import Data.Map.Strict (Map, (!))
import qualified Data.Map.Strict as M

main :: IO ()
main = solve <$> getLine >>= putStrLn

solve :: String -> String
solve = f
  where
    cm = M.fromList [('2', 'k'), ('3', 's'), ('4', 't'), ('5', 'n'),
                     ('6', 'h'), ('7', 'm'), ('8', 'y'), ('9', 'r'), ('0', 'w')]
    vm = M.fromList [('T', 'a'), ('L', 'i'), ('U', 'u'), ('R', 'e'), ('D', 'o')]
    f [] = []
    f (x:y:ys)
      | x == '0' && y == 'U' = 'n' : 'n' : f ys
      | x == '1' = vm ! y : f ys
      | otherwise = cm ! x : vm ! y : f ys



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

typedef long long ll;
typedef long double ld;

#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

int main(){

    ll A, P;

    cin >> A >> P;

    cout << (A * 3 + P) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
require "prime"

n=gets.to_i

aa=Prime.each.take(55555)

arr=[]

count=0
i=0
loop{
    
   if aa[i]%5==1
       arr<<aa[i]
       count+=1
   end
   
   i+=1
   
   if  count==n
       break
       
   end
    
}


puts  arr.join(" ")

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

int main(){
	while(true){
		int n,m;
		int ans = 0;
		cin >> n >> m;
		if(n == 0 && m == 0) return 0;
		int a[1005] = {0};
		for(int i = 0; i < n; i++) cin >> a[i];
		for(int i = 0; i < n; i++){
			for(int j = i + 1; j < n; j++){
				int sum = a[i] + a[j];
				if(sum <= m) ans = max(ans, sum);
			}
		}
		if(ans) cout<<ans<<endl;
		else cout<<"NONE"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3108