akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class CoinChangeInfinite {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] a = new int[m];

            for (int i = 0; i < m; i++) {
                a[i] = in.nextInt();
            }

            out.printf("%d\n", minCoins(n, a, m));
        }

        private int minCoins(int a, int[] c, int n) {
            int[] dp = new int[a + 1];

            for (int i = 1; i < a + 1; i++) {
                dp[i] = Integer.MAX_VALUE;
                for (int j = 0; j < n; j++) {
                    if (i >= c[j]) {
                        dp[i] = Math.min(dp[i], 1 + dp[i - c[j]]);
                    }
                }
            }

            return dp[a];
        }

    }
}




Measured memory_bytes: 27048
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
 
int32_t main(){
    IOS;
    string s,t;
    ll n,m;
    cin >> s >> t;
    n = s.size();
    m = t.size();
    ll mn = 1e18;
    fori(n-m+1){
        ll sum = 0;
        for(ll j=i;j<i+m;j++){
            if(s[j]!=t[j-i]) sum ++;
        }
        mn = min(mn,sum);
    }
    cout << mn <<"\n";
} 

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

int main() {
    string s;
    getline(cin, s);
    s.erase(remove(s.begin(), s.end(), ' '), s.end());
    int x = stoi(s);
    cout << (x % 4 == 0 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readstr()
    if N[-1] == '3':
        print('bon')
    elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
        print('pon')
    else:
        print('hon')


if __name__ == "__main__":
    main()


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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
#ifdef VC
#define scanf scanf_s
#endif
#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const int mod = 1000000007;

int n, m;


int main(){
	ll a[100010];
	cin >> n;
	forn(i)cin >> a[i];
	sort(a, a + n);
	ll res1, res2;
	res1 = a[n - 1];
	res2 = 0LL;
	forn(i) {
		if (abs(2LL * a[i] - res1) < abs(res2 * 2LL - res1) ) {
			res2 = a[i];
		}
	}
	cout << res1 << " " << res2 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long> data(N + 1), ans(N + 1);
  for(int i = 1; i <= N; i++)cin >> data.at(i);
  long count, a;
  for(int i = N; i >= 1; i--){
    count = 0;
    a = 1;
    while(i * a <= N){
      count += ans.at(i * a);
      a++;
    }
    if(count % 2 == data.at(i))ans.at(i) = 0;
    else ans.at(i) = 1;
  }
  count = 0;
  for(int i = 1; i <= N; i++){
    if(ans.at(i) == 1){
      count++;
    }
  }
  cout << count << endl;
  for(int i = 1; i <= N; i++){
    if(ans.at(i) == 1)cout << i << ' ';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3968
var input = require('fs').readFileSync('/dev/stdin', 'utf8');

var arr = input.trim().split("\n");
while(true){
   var [n,q]=arr.shift().split(" ").map(Number);
   if(n==0 && q==0)break;
   var g=[];
   for(var i=0;i<n;i++){
      var [e,ey,wy]=arr.shift().split(" ");
      [ey,wy]=[ey-0,wy-0];
      g.push([e,wy-ey,wy]);
   }
   for(var i=0;i<q;i++){
      var n = arr.shift() - 0;
      var ans="Unknown";
      for(var j=0;j<g.length;j++){
         var a = g[j][1];
         var b = g[j][2];
         if(a<n && n<=b){
            ans=[g[j][0],n-a].join(" ");
         }
      }
      console.log(ans);
   }
}



Measured memory_bytes: 33628
#include<iostream>
using namespace std;
#define yes(n) cout << ((n) ? "Yes" : "No") << endl
int main()
{
    int n,m;
    cin >> n >> m;
    if(n + m == 3)
        cout << 3;
    else if(n + m ==4)
        cout << 2;
    else
    {
        cout << 1;
    }
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
	int n;
	scanf("%d",&n);
	char w[100][11];
	int i,j;
	for(i=0;i<n;i++){
		scanf("%s",w[i]);
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(strcmp(w[i],w[j])==0){
				printf("No");
				return 0;
			}
		}
	}
	for(i=0;i<n-1;i++){
		if(w[i][strlen(w[i])-1] != w[i+1][0]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

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

const int MAXN = 10;

int ncase;
bool used[MAXN];
int mins[MAXN+1];
int maxs[MAXN+1];

void sum(int n,int m,int s,int t)
{
    if(m==n){
        if(s==t) ncase+=1;
        return;
    }
    if(t>s) return;
    if(m==n-1 && (s-t)%(m+1)!=0) return;
    if(used[0] && (s-t)<(m+1)) return;
    if(s-t<mins[n-m] || maxs[n-m]<s-t) return;
    REP(i,MAXN){
        if(!used[i]){
            used[i] = true;
            sum(n,m+1,s,t+i*(m+1));
            used[i] = false;
        }
    }
}

int minsum(int n)
{
    int s=0;
    REP(i,n) s+=i*(n-i);
    return s;
}

int maxsum(int n)
{
    int s=0;
    REP(i,n) s+=(MAXN-1-i)*(MAXN-i);
    return s;
}


void solve(int n,int s)
{
    ncase=0;
    REP(i,MAXN) used[i]=false;
    sum(n,0,s,0);
    cout<<ncase<<endl;
}
int main(void)
{
    REP(i,MAXN){
        mins[i+1]=minsum(i+1);
        maxs[i+1]=maxsum(i+1);
    }
    int n,s;
    while((cin>>n>>s)){
        solve(n,s);
    }
    return 0;
}

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

int main(){
    ll N;
    cin >> N;
    vector<vector<ll> > vec_group(10,vector<ll>(10));
    for (ll i = 1; i <= N; i++){
        int start;
        int goal;
        goal = i % 10;
        if (i < 10) start = i;
        else if (i < 100) start = i / 10;
        else if (i < 1000) start = i / 100;
        else if (i < 10000) start = i / 1000;
        else if (i < 100000) start = i / 10000;
        else start = i / 100000;
        
        if (goal != 0){
            vec_group[start][goal]++;
        }
    }
    ll ans = 0;
    for (ll i = 1; i <= 9; i++){
        for (ll j = 1; j <= 9; j++){
            ans += vec_group[i][j] * vec_group[j][i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def fact(n):
    l=set()
    x=1
    while(x*x<=n):
        if(n%x==0):
            l.add(x)
            l.add(n//x)
        x+=1
    l=list(l)
    l.sort()
    return l
n=int(input())
l=fact(n)
#print(l)
ans=10**12
i=0
j=len(l)-1
while(i<j):
    ans=min(ans,l[i]-1+l[j]-1)
    i+=1
    j-=1
if(len(l)%2==1):
    ans=min(ans,l[len(l)//2]-1+l[len(l)//2]-1)
print(ans)

Measured memory_bytes: 3832
n,m=map(int,input().split())
if n%2==1:
  ab=[]
  a=n//2
  b=n//2+1
  ab.append([str(a),str(b)])
  for _ in range(m-1):
    a-=1
    b+=1
    ab.append([str(a),str(b)])
  for a,b in ab:
    print(a,b)
else:
  l=m
  ab=[]
  cnt=0
  for i in range(m):
    if i%2==0:
      a=i//2+1
      b=a+l
    else:
      a=n-(i//2+1)
      b=a-l
    ab.append([str(a),str(b)])
    l-=1
  for a,b in ab:
    print(a,b)

Measured memory_bytes: 28056
#include<iostream>
#include<string>
#include<map>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define cout(x) cout << x << endl;
// for (int i = 0; i < N; ++i) cin >> A[i];
typedef vector<int> vint;
typedef vector<long> vl;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef map<string, int> mapstri;
typedef map<string, int> mapii;

int main () {
    double n;
    cin >> n;
    double a,b,c;
    double ans;
    a = n / 3;
    b = n / 3;
    c = n - a -b;
    ans = a * b * c;
    printf("%f", ans);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#define mod 998244353
#define MN 1000000

int f[MN + 5], g[MN + 5];
int F[MN + 5];
int inv[MN + 5];
int cnt[MN + 5];
int mu[MN + 5];
bool ok[MN]; int pri[MN], tot = 0;

void init()
{
	mu[1] = 1;
	for(int i = 2; i <= MN; i++)
	{
		if(!ok[i]) pri[++tot] = i, mu[i] = -1;
		for(int j = 1; j <= tot && i * pri[j] <= MN; j++)
		{
			ok[i * pri[j]] = 1;
			if(i % pri[j] == 0) {mu[i * pri[j]] = 0; break;}
			mu[i * pri[j]] = -mu[i];
		}
	}
}

int main()
{
	inv[0] = inv[1] = 1;
	for(int i = 2; i <= MN; i++) inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod; 
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		int a; scanf("%d", &a);
		cnt[a]++;
	}
	for(int i = 1; i <= MN; i++)
	{
		for(int j = i; j <= MN; j += i)
		{
			f[i] = (f[i] + 1ll * j * cnt[j]) % mod;
			F[i] = (F[i] + 1ll * j * j % mod * cnt[j]) % mod; 
		}
		f[i] = (1ll * f[i] * f[i] % mod - F[i] + mod) % mod * inv[2] % mod;
	}
	init();
	int ans = 0;
	for(int i = 1; i <= MN; i++)
	{
		for(int j = i; j <= MN; j += i)
		{
			g[i] = (g[i] + 1ll * (mu[j / i] + mod) * f[j]) % mod;
		}
		ans = (ans + 1ll * g[i] * inv[i]) % mod;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 26880
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
    
    string s;
    cin>>s;
    int sum = 0;

    for (auto it:s)
        sum+=(it-'0');
    if (sum%9==0)
        cout<<"Yes"<<endl;
        else
        cout<<"No"<<endl;  
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
typedef long long ll;

static const int MAX = 10000;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int,int>> Adj_vec[MAX];

void dijkstra(){
  priority_queue<pair<int,int>> pq;
  int color[MAX], d[MAX];
  rep(i,n){
    color[i] = WHITE;
    d[i] = INF;
  }
  d[0] = 0;
  pq.push(make_pair(0,0));
  color[0] = GRAY;

  while(!pq.empty()){
    pair<int,int> f = pq.top();
    pq.pop();
    int u = f.second;
    color[u] = BLACK;
    if(d[u] < f.first * (-1)) continue;

    for(int j=0; j < Adj_vec[u].size(); j++){
      int v = Adj_vec[u][j].first;
      if(color[v] == BLACK) continue;
      if(d[v] > d[u] + Adj_vec[u][j].second){
        d[v] = d[u] + Adj_vec[u][j].second;
        pq.push(make_pair(d[v] * -1, v));
        color[v] = GRAY;
      }
    }
  }
  rep(i,n){
    cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
  }
}

int main(){
  int k, c, u, v;
  cin >> n;
  rep(i,n){
    cin >> u >> k;
    rep(j,k){
      cin >> v >> c;
      Adj_vec[u].push_back(make_pair(v, c));
    }
  }

  dijkstra();

  return 0;
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  string s;
  cin >> s;
  int n = s.size();

  VI v1(n), v2(n);
  v1[0] = s[0]=='A'?1:0;
  v2[0] = s[0]=='?'?1:0;
  FOR(i, 1, n) {
    v1[i] += v1[i-1] + (s[i]=='A'?1:0);
    v2[i] += v2[i-1] + (s[i]=='?'?1:0);
  }

  VI v3(n), v4(n);
  v3[n-1] = (s[n-1]=='C'?1:0);
  v4[n-1] = (s[n-1]=='?'?1:0);
  for(int i=n-2; i>=0; --i) {
    v3[i] += v3[i+1] + (s[i]=='C'?1:0);
    v4[i] += v4[i+1] + (s[i]=='?'?1:0);
  }

  int q = v2[n-1];
  VI x(4, 1);
  REP(i, q-3) (x[0] *= 3) %= MOD;
  REP(i, q-2) (x[1] *= 3) %= MOD;
  REP(i, q-1) (x[2] *= 3) %= MOD;
  REP(i, q) (x[3] *= 3) %= MOD;

  int ret = 0;
  FOR(i, 1, n-1) {
    if(s[i]=='B') {
      (ret += v1[i-1] * v3[i+1] % MOD * x[3] % MOD) %= MOD;
      (ret += v1[i-1] * v4[i+1] % MOD * x[2] % MOD) %= MOD;
      (ret += v2[i-1] * v3[i+1] % MOD * x[2] % MOD) %= MOD;
      (ret += v2[i-1] * v4[i+1] % MOD * x[1] % MOD) %= MOD;
    }
    if(s[i]=='?') {
      (ret += v1[i-1] * v3[i+1] % MOD * x[2] % MOD) %= MOD;
      (ret += v1[i-1] * v4[i+1] % MOD * x[1] % MOD) %= MOD;
      (ret += v2[i-1] * v3[i+1] % MOD * x[1] % MOD) %= MOD;
      (ret += v2[i-1] * v4[i+1] % MOD * x[0] % MOD) %= MOD;
    }
  }
  cout << ret << endl;

  return 0;
}


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

int main(){
  int N,M;
  cin >>N>>M;
  vector<int> H(N);
  vector<int> A(M);
  vector<int> B(M);
  vector<vector<int>> Tc(N); 
  for(int i=0;i<N;i++){
    cin>>H.at(i);
  }
  for(int i=0;i<M;i++){
    cin>>A.at(i)>>B.at(i);
  }
  
  for(int i=0;i<M;i++){
        Tc.at(A.at(i)-1).push_back(B.at(i)-1);
        Tc.at(B.at(i)-1).push_back(A.at(i)-1);
  }
  int max,count=0;
  for(int i=0;i<N;i++){
    if(Tc.at(i).size()==0){
        count++;
        continue;
    }
    max=H.at(Tc.at(i).at(0));
    for(int j=1;j<Tc.at(i).size();j++){
      if(H.at(Tc.at(i).at(j))>max)
        max=H.at(Tc.at(i).at(j));
    }
    if(H.at(i)>max){
      count++;
    }
  }
  cout << count <<endl;
}


Measured memory_bytes: 9568
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    cin >> n;
    vector<int>a(n),b(n),c(n);
    int pre = -100;
    int ans = 0;
    rep(i,n)cin >> a[i], a[i]--;
    rep(i,n)cin >> b[i];
    rep(i,n-1)cin >> c[i];
    rep(i,n){
        ans += b[a[i]];
        if(pre + 1 == a[i])ans += c[pre];
        pre = a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
P dp[105][50005];
int p[100];
void Max(P &a,P b){a=max(a,b);}

int main(){
  int n;
  while(cin>>n && n){
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<n;i++)cin>>p[i];
    dp[0][0] = P(0,0);
    for(int i=0;i<n;i++){
      for(int j=0;j<50000;j++){
        if(dp[i][j]==P(-1,-1)) continue;
        int nf=dp[i][j].first,ns=dp[i][j].second-p[i];
        Max(dp[i+1][j],dp[i][j]);
        if(p[i]%1000==0)
          {if(j>=500) Max(dp[i+1][j-500],P(nf+1,ns));}
        else if(p[i]%1000<500) Max(dp[i+1][j+500-p[i]%500],P(nf+1,ns));
        else if(p[i]%500<=j) Max(dp[i+1][j-p[i]%500],P(nf+1,ns));
        else Max(dp[i+1][j+500-p[i]%500],P(nf,ns)); 
      }
    }
    P ans(0,0);
    for(int i=0;i<50000;i++) Max(ans,dp[n][i]);
    cout<<ans.first<<" "<<-ans.second<<endl;
  }  
  return 0;
}

Measured memory_bytes: 44056
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a!=b && a!=c)cout<<a;
    if(b!=a && b!=c)cout<<b;
    if(c!=a && c!=b)cout<<c;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		String b = sc.nextLine();

		System.out.println(b.equals("A") ? "T" : b.equals("G") ? "C" : b.equals("C") ? "G" : "A");
	}

}

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

typedef long double ld;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

#define FOR(i, b, e) for (int i = b; i <= e; i++)
#define FORD(i, b, e) for (int i = b; i >= e; i--)
#define SIZE(x) ((int)(x).size())
#define pb push_back
#define st first
#define nd second
#define all(a) begin(a), end(a)
#define watch(x) cerr << (#x) << " is " << (x) << '\n';

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

    int a, b;
    cin >> a >> b;

    int res = (b - 1) / (a - 1);
    if ((b - 1) % (a - 1)) res++;

    cout << res;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>



char hex[ 256 ][ 5 ] ;



int main()
{
	char p = '0' ;
	sprintf( hex[ p++ ] ,"0000" ) ;
	sprintf( hex[ p++ ] ,"0001" ) ;
	sprintf( hex[ p++ ] ,"0010" ) ;
	sprintf( hex[ p++ ] ,"0011" ) ;
	sprintf( hex[ p++ ] ,"0100" ) ;
	sprintf( hex[ p++ ] ,"0101" ) ;
	sprintf( hex[ p++ ] ,"0110" ) ;
	sprintf( hex[ p++ ] ,"0111" ) ;
	sprintf( hex[ p++ ] ,"1000" ) ;
	sprintf( hex[ p   ] ,"1001" ) ;	

	p = 'a' ;
	sprintf( hex[ p++ ] ,"1010" ) ;
	sprintf( hex[ p++ ] ,"1011" ) ;
	sprintf( hex[ p++ ] ,"1100" ) ;
	sprintf( hex[ p++ ] ,"1101" ) ;
	sprintf( hex[ p++ ] ,"1110" ) ;
	sprintf( hex[ p   ] ,"1111" ) ;


	double n ;

	while( 1 )
	{
		scanf( "%lf" ,&n ) ;

		if( n < 0 )
		{
			return 0 ;
		}


		int seisuu = ( int )n ;


		if( ( double )( n * 16 - ( int )( n * 16 ) ) > 0 )
		{
			puts( "NA" ) ;
		}

		else
		{
			int str_p = 0 ;

			int shousuu = ( int )( ( n * 16 ) - ( seisuu * 16 ) ) ;


			char str[ 20 ] ;
			sprintf( str ,"%x%x" ,seisuu ,shousuu ) ;


			if( str[ 2 ] == '\0' )
			{
				printf( "0000" ) ;
			}

			else
			{
				printf( "%s" ,hex[ str[ 0 ] ] ) ;

				++str_p ;
			}

			printf( "%s.%s\n" ,hex[ str[ str_p ] ] ,hex[ str[ str_p + 1 ] ] ) ;
		}
	}
}

Measured memory_bytes: 2672
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long k,a,b,c=0;
    cin>>k>>a>>b;
    if(a>=k)
    {
        cout<<1<<endl;
        return 0;
    }
    else if(b>=a)
    {
        cout<<-1<<endl;
        return 0;
    }
    else if((k-a)%(a-b)>=1)
        c=1;
    cout<<((k-a)/(a-b)+c)*2+1<<endl;
}

Measured memory_bytes: 256
#include <math.h>
#include <iostream>
#include<string>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#include <stdlib.h>
using namespace std;

int main()
{
int n,q,ans=0,right,left,mid;scanf("%d", &n);
vector<int> S(n);
for(int i=0;i<n;i++)scanf("%d", &S[i]);
scanf("%d", &q);
vector<int> T(q);
for(int i=0;i<q;i++)scanf("%d", &T[i]);
for(int i=0;i<q;i++)
{
right=n;left=0;
while(right>=left)
{
mid=left+(right-left)/2;
if(S[mid]==T[i]){ans++;break;}
else if(S[mid]>T[i])right=mid-1;
else if(S[mid]<T[i])left=mid+1;
}
}
printf("%d\n", ans);
}



Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int main(){
  int n,k;
  cin>>n>>k;
  int a[100000];
  int x,y,z=0,count=0;
  cin>>x;
  count-=x;
  lp(i,n-1){
    cin>>y;
    a[i]=y-(x+1);
    if(a[i]<0){
      z+=a[i];
    }
    x=y;
  }
  count+=x;
  sort(a,a+n-1);
  reverse(a,a+n-1);
  int ans;
  ans=count-z+1;
  lp(i,k-1){
    if(a[i]>0)
    ans-=a[i];
  }
  cout<<ans<<endl;
  
  return 0;
}



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

int main() {
	long long int N, M,ans;
	cin >> N >> M;
	if (N*M==1)
	{
		cout << 1;
	}
	else if(N==1){
		cout <<M - 2;
	}
	else if (M==1)
	{
		cout << N - 2;
	}
	else
	{
		ans = N * M - ((N - 1) * 2 + (M - 1) * 2);
		cout << ans;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef pair < int , int > Pi;
typedef pair < int , Pi > Pii;
#define fr first
#define sc second

int m, n, s;
int min_cost[100][100];
bool used[100][100];
int dy[] = {-1,0,1,-1,0,1};
int dx[][6] = {{ -1,-1,-1,0,1,0}, {0,-1,0,1,1,1}};

bool isover(int y, int x){
  return y < 0 || y >= n || x < 0 || x >= m;
}

void bfs(int y, int x){
  queue< Pii > que;
  que.push(Pii( 0, Pi( y, x)));
  min_cost[y][x] = 0;
  while(!que.empty()){
    Pii p = que.front();
    que.pop();
    for(int i = 0 ; i < 6 ; i++ ){
      int ny = p.sc.fr + dy[i], nx = p.sc.sc + dx[p.sc.fr % 2][i];
      if(isover( ny, nx) || min_cost[ny][nx] <= p.fr + 1) continue;
      que.push(Pii( p.fr + 1, Pi( ny, nx)));
      min_cost[ny][nx] = p.fr + 1;
    }
  }
}

int prebfs(int y, int x){
  if(!min_cost[y][x]) return 0;

  int ret = 1;
  fill_n( *used, 10000, false);
  queue< Pii > que;
  que.push(Pii( 0, Pi( y, x)));
  used[y][x] = true;


  while(!que.empty()){
    Pii p = que.front();
    que.pop();
    for(int i = 0 ; i < 6 ; i++ ){
      int ny = p.sc.fr + dy[i], nx = p.sc.sc + dx[p.sc.fr % 2][i];
      if(isover( ny, nx) || used[ny][nx] || min_cost[ny][nx] <= p.fr + 1) continue;
      que.push(Pii( p.fr + 1, Pi( ny, nx)));
      used[ny][nx] = true;
      ret++;
    }
  }
  return ret;
}

int main(){
  while(cin >> m, m){
    fill_n( *min_cost, 10000, 1 << 30);

    cin >> n >> s;

    for(int i = 0 ; i < s ; i++ ){
      int x, y;
      cin >> x >> y;
      bfs( y - 1, x - 1);
    }

    int t, ret = 0;
    cin >> t;
    while(t--){
      int p, q;
      cin >> p >> q;
      ret = max( ret,prebfs( q - 1, p - 1));
    }
    cout << ret << endl;
  }
}

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

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

    static class TaskD {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.next();
            int k = in.nextInt();

            int[][][] dp = new int[s.length()][s.length()][k + 1];

            for (int i = s.length() - 1; i >= 0; i--) {
                for (int j = i; j < s.length(); j++) {
                    if (i == j) {
                        dp[i][j][0] = 1;
                    } else {
                        for (int t = 0; t <= k; t++) {
                            dp[i][j][t] = Math.max(dp[i + 1][j][t], dp[i][j - 1][t]);
                            int cost = s.charAt(i) == s.charAt(j) ? 0 : 1;
                            if (t - cost >= 0) {
                                dp[i][j][t] = Math.max(dp[i][j][t], dp[i + 1][j - 1][t - cost] + 2);
                            }
                        }
                    }
                }
            }

            int max = 0;
            for (int t = 0; t <= k; t++) {
                max = Math.max(max, dp[0][s.length() - 1][t]);
            }
            out.println(max);
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

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

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 167508
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
int keta(int x) {
	int ans = 0;
	while (x) {
		x /= 10;
		ans++;
	}
	return ans;
}
int kk[100], test[100][100];
signed main() {
	int n, k, a, b, ans = 0; string s; cin >> s;
	for (int i = 0; i <= (1 << s.size() - 1); i++) {
		vector<int> sep = {  }; int mae = -1;
		for (int j = 0; j <= s.size() - 1; j++) {
			if ((i & (1 << j)) > 0) {
				sep.push_back(j);
			}
		}
		if (sep.size() == 0) { continue; }
		sep.push_back(s.size() - 1);
		for (int j = 0; j < sep.size(); j++) {
			int c = 1;
			for (int k = sep[j]; k > mae; k--) {
				ans += (s[k] - '0') * c; c *= 10;
			}
			mae = sep[j];
		}
	}
	cout << ans << endl;
	cin >> n;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int n = scanner.nextInt();
        int x = scanner.nextInt(); 
        while(n != 0 || x !=0){
            int cnt = 0;
            int i, j, k;
            for(i=1; i<=n; i++){
                for(j=i+1; j<=n; j++){
                    for(k=j+1; k<=n; k++){
                        if(i + j + k == x){
                            cnt++;
                        }
                    }
                }
            }
            System.out.println(cnt);
                    
            n = scanner.nextInt();
            x = scanner.nextInt();
        }
        

    }
}


Measured memory_bytes: 26584
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int count(string s, int n) {
  int res = 0;
  for (int i = 0; i < n-1; ++i)
    if (s[i] == s[i+1]) ++res;
  return res;
}

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  int ans = min(count(s, n) + k * 2, n-1);
  cout << ans << endl;
  return 0;
}

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

	int n,tmp,minj,c=0;
	cin>>n;
	int A[n];
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	for(int i=0;i<n;i++){
		minj=i;
		for(int j=i;j<n;j++){
			if(A[j]<A[minj]){
				minj=j;
			}
		}
		tmp=A[i];
		A[i]=A[minj];
		A[minj]=tmp;
		if(i!=minj)c++;
	}
	for(int i=0;i<n-1;i++){
		cout<<A[i]<<" ";
	}
	cout<<A[n-1]<<endl<<c<<endl;

	return 0;
}

Measured memory_bytes: 1164
// https://atcoder.jp/contests/cf17-final/tasks/cf17_final_b
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    string S;
    cin >> S;

    // 'a', 'b', 'c' の文字が現れる回数を求める
    map<char, int> cnts;
    REP(i, S.size())
    {
        ++cnts[S[i]];
    }

    /*
        偶数文字の回文は中心に2文字の回文が含まれる. "aa" 等
        奇数文字の回文は中心に3文字の回文が含まれる. "a?a" 等
        したがって2文字or3文字の回文が含まれない文字が作成可能か考えればよい
        各回文の構成より、同じ文字が2文字以上離れていればよい
     */

    int d0 = abs(cnts['a'] - cnts['b']);
    int d1 = abs(cnts['b'] - cnts['c']);
    int d2 = abs(cnts['c'] - cnts['a']);

    /*
        使用する文字が3種類のみなので、
        それぞれの文字が使用される回数の差が1以下であれば、
        同じ文字が2文字以上離れる文字列を作ることができる
     */
    if (d0 <= 1 && d1 <= 1 && d2 <= 1)
    {
        cout << "YES\n";
        return 0;
    }

    cout << "NO\n";
    return 0;

}


Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define INF 2000000000

int h[MAXN];
int dp[MAXN];
int n,k;

int main() {
	int i,j;
	scanf("%d %d",&n, &k);
	for (i=0; i<n;i++) {
		scanf("%d",&h[i]);
	}
	dp[n-1]=0;
	dp[n-2]=abs(h[n-1]-h[n-2]);
	for (i=n-3; i>=0; i--) {
		dp[i]=INF;
		for (j=1; j<=k && i+j<n; j++) {
			dp[i]=min(dp[i],abs(h[i]-h[i+j])+dp[i+j]);
		}
	}
	
	printf("%d\n",dp[0]);
	return 0;
}

Measured memory_bytes: 4492
use std::io::stdin;
use std::io::BufRead;

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    /*for i in 1.. {
        let mut buf = String::new();

        stdin.read_line(&mut buf).unwrap();

        let int = buf.trim().parse::<i32>().unwrap();
        if int == 0 {
            break;
        }
        println!("Case {}: {}", i, int);
    }*/

    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();

    let mut buf = buf.trim().split(" ");

    let a = buf.next().unwrap().parse::<i64>().unwrap();
    let b = buf.next().unwrap().parse::<i64>().unwrap();

    print!("{} {} {}", a / b, a % b, a as f64 / b as f64);
}


Measured memory_bytes: 5056
package main

import (
	"fmt"
)

func main() {
	var N, X int
	fmt.Scan(&N, &X)

	L := make([]int, N)
	for i := range L {
		fmt.Scan(&L[i])
	}

	d := 0
	ans := 1

	for i := range L {
		d += L[i]

		if d > X {
			break
		}

		ans += 1
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n, k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(ALL(h));
    int ans = 1001001001;
    for(int i = 0; i < n-k+1; i++){
        ans = min(ans, h[i+k-1] - h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>


using namespace std;

int main() {
    string s;
    cin >> s;
    long a=0, cnt=0;
    bool b=false;
    for (auto si:s) {
        if (si == 'A') {
            a++;
            if (b) {
                a = 1;
            }
            b = false;
        } else if (a > 0 && si == 'B') {
            if (b) {
                a = 0;
            } else b = true;
        } else if (a > 0 && si == 'C') {
            if (b) {
                cnt += a;
                b = false;
            } else {
                a = 0;
            }
        }
    }
    cout << cnt << '\n';
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int count = 0;
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    if (K <= x){
      count += 2*(x-K);
    }else if ((K-x) < x){
      count += 2*(K-x);
    }else{
      count += 2*x;
    }
  }
  cout << count << endl;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n;
  cin >> n;
  cout << (((n / 10) % 111 == 0) || ((n % 1000) % 111 == 0) ? "Yes" : "No");
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define testcase(t) int t;cin>>t;for(int testcnt=1;testcnt<=t;testcnt++)
#define int long long
#define double long double
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define eb emplace_back
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
int nod(int n)
{
	string s = to_string(n);
	return (int)s.length();
}
int sod(int n)
{
	int ans = 0;
	while(n)
	ans+=(n%10),n/=10;
	return ans;
}
int modexpo(int x,int y,int p)
{
	int res=1;
	x%=p;
	while(y){
		if(y&1)
		res*=x,res%=p;
		x*=x,x%=p;
		y>>=1;
	}
	return res;
}
int h[100005];
int dp[100005];
int32_t main()
{
	IOS
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>h[i];
	for(int i=1;i<=k;i++)
		dp[i]=abs(h[i]-h[0]);
	for(int i=k+1;i<n;i++){
		dp[i]=1e9;
		for(int j=i-1;j>=i-k;j--)
		dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1792
N, X = gets.chomp.split.map(&:to_i)

# aを厚さ　pをパティの数とする
@a = []
@p = []

0.upto(N) do |i|
  @a << 2**(i+2) - 3
  @p << 2**(i+1) - 1
end

# レベルnバーガーの左からx番目までのパティの数を出す
def f(n,x)
  # nが0までいったときに返す値を用意する
  if n == 0
    if x <= 0
      0
    else
      1
    end
  elsif x == @a[n-1] + 2
    # どっちでも良い
    # f(n-1,n-1) + 1
    @p[n-1] + 1
  elsif x < @a[n-1] + 2
    f(n-1,x-1)
  else
    @p[n-1] + 1 + f(n-1, x-2-@a[n-1])
  end
end

puts f(N,X)


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

using namespace std;

const int maxn=1000005;

vector<int>mark(maxn);

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int n;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        ++mark[a[i]];
    }
    if(mark[1]>0){
    if(mark[1]>1)cout<<"0"<<endl;
    else if(mark[1]==1)cout<<"1"<<endl;
    return 0;
    }
    for(int i=n-1;i>=0;i--){
        int e=a[i];
        if(mark[e]>1)mark[e]=-1;
        for(int j=e+e;j<maxn;j+=e){
            if(mark[j]==-1)continue;
            if(mark[j]>0) mark[j]=-1;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(mark[a[i]]!=-1)++ans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7948
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    x = S()
    s = 0
    ans = len(x)
    for i in x:
        if i == "S":
            s += 1
        else:
            if s > 0:
                s -= 1
                ans -= 2
    print(ans)
    return

#B
def B():
    n = I()
    a = LI()
    f = [0 for i in range(n+1)]
    for i in range(n):
        f[a[i]] = i
    l = [i for i in range(n+1)]
    r = [i for i in range(n+1)]
    ans = 0
    for i in range(1,n+1)[::-1]:
        j = f[i]
        ans += (j-l[j]+1)*(r[j]-j+1)*i
        l[r[j]+1] = l[j]
        r[l[j]-1] = r[j]
    print(ans)
    return

#C
def C():
    n,x = LI()
    if x == 1 or x == 2*n-1:
        print("No")
        quit()
    else:
        ans = [i+1 for i in range(2*n-1)]
        k = x-n
        if k < 0:
            ans = ans[2*n-1+k:]+ans[:2*n-1+k]
        if k > 0:
            ans = ans[k:]+ans[:k]
        print("Yes")
        for i in ans:
            print(i)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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


Measured memory_bytes: 57584
#include <iostream>
#include <algorithm>

using namespace std;

int main() {

  unsigned long long n, ans = 1, temp = 1;
  cin >> n;
  while(n > 1){
    temp = temp * 2;
    ans += temp;
    n /= 2;
    //cerr << ans << '\n';
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  string s;
  cin >> s;
  int n = s.size() / 2;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s.at(i) != s.at(s.size() - 1 - i)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc141/tasks/abc141_b

S = input()

ans = "No"
# 文字
for i in range(len(S)):
    # 奇数
    if i % 2 == 0 and (S[i] == "R"  or S[i] == "U"  or S[i] == "D" ):
       ans = "Yes"
    # 偶数
    elif i % 2 != 0 and (S[i] == "L"  or S[i] == "U"  or S[i] == "D" ):
       ans = "Yes"
    else:
       ans = "No"
       break

print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
	int n, x;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		x = i;
		if (x % 3 == 0)
		{
			cout << " " << i;
		}
		else
		{
			while (x)
			{
				if (x % 10 == 3)
				{
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
	}
	cout << endl;
        //system("pause");
	return 0;
}

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(int (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(int (i) = (ceiling); (i) >= (bottom); --(i))
#define pub push_back
#define pob pop_back
#define prf printf
#define scf scanf
#define mkp make_pair
#define fir first
#define sec second
#define clr(a) memset((a),0,sizeof(a))
#define all(a)  begin((a)),end((a))

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const vector<pair<int,int>> DIR = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF = -1 + (1<<30);
const int MOD = (int)1e9 + 7;

template<typename T> inline T gcd(T a,T b){ if(a % b){ return gcd(b,a % b); }else{ return b; } }

template<typename T> inline T lcm(T a,T b){ return a / gcd(a,b) * b; }

inline long long Pow(const long long n,long long m,const int mod = MOD){
	long long res = 1,pow = n;
	while(m) {
		if(m & 1) res = (res * pow) % mod;
		pow = (pow * pow) % mod;
		m >>= 1;
	}
	return res;
}

inline vector<long long> Frac(const int range,const int mod = MOD){
	vector<long long> frac;
	frac.push_back(1);
	for(int i = 1; i <= range; ++i) frac.push_back((long long)frac.back() * i % mod);
	return frac;
}

inline long long Comb(const int n,const int m,const int mod = MOD){
	if(n < m || m < 0) return 0;
	vector<long long> frac(Frac(n,mod));
	long long rev = Pow((long long)frac[m] * frac[n-m] % mod,mod-2,mod);
	return rev * frac[n] % mod;
}

template<typename T> inline bool v_find(const vector<T> v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) { return true; }
	return false; 
}

template<typename T> inline bool v_erase(vector<T> &v,const T obj){
	auto itr = find(v.begin(), v.end(), obj);
	size_t index = distance(v.begin(),itr);
	if (index != v.size()) {
		v.erase(itr);
		return true;
	}
	return false;	
}

template<class T,class U> inline auto LB(const T v,const U in){ return lower_bound(v.begin(),v.end(),in); }

template<class T,class U> inline auto UB(const T v,const U in){ return upper_bound(v.begin(),v.end(),in); }

inline unsigned long long next_subset(unsigned long long subset){
	unsigned long long tem = subset + (subset & -subset);
	unsigned long long btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

ll n,ans=-1,a[200001],s[200001];

inline void solve(){
	cin>>n;
	rep(i,n){ cin>>a[i]; a[i]-=i+1; }
	sort(a,a+n);
	s[0]=0;
	rep1(i,n) s[i]=s[i-1]+a[i-1];
	if(n&1) cout<<s[n]-s[(n+1)/2]-s[n/2];
	else cout<<s[n]-s[n/2]*2;

	return;
}

inline void input(){
	

	return;
}

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





Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
int main()
{
    int k,len,i;
    char str[110];
    scanf("%d",&k);
    scanf("%s",&str);
    len=strlen(str);
    if(len<=k) printf("%s\n",str);
    else{
        for(i=0;i<k;i++){
            printf("%c",str[i]);
        }
        printf("...\n");
    }
    return 0;
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i, H) cin >> S[i];

    vv<int> ans = vvec(H, W, -1);

    int k = 1;
    int hpre = 0;
    rep(i, H) {
        int wpre = 0;
        int tmp = -1;
        rep(j, W) {
            if (S[i][j] == '#') {
                rep(y, hpre, i + 1) rep(x, wpre, j + 1) ans[y][x] = k;
                k++;
                wpre = j + 1;
                tmp = i + 1;
            }
        }
        if (tmp != -1) {
            hpre = tmp;
        }
    }

    rep(i, H) {
        if (ans[i][W - 1] == -1) {
            int a = -1;
            for (int j = W - 1; j >= 0; --j) {
                if (ans[i][j] != -1) {
                    a = ans[i][j];
                    break;
                }
            }
            if (a != -1) {
                for (int j = W - 1; j >= 0; --j) {
                    if (ans[i][j] == -1) ans[i][j] = a;
                    else break;
                }
            }
        }
    }
    rep(j, W) {
        if (ans[0][j] == -1) {
            int a = -1;
            rep(i, H) {
                if (ans[i][j] != -1) {
                    a = ans[i][j];
                    break;
                }
            }
            if (a != -1) {
                rep(i, H) {
                    if (ans[i][j] == -1) ans[i][j] = a;
                    else break;
                }
            }
        }
        if (ans[H - 1][j] == -1) {
            int a = -1;
            for (int i = H - 1; i >= 0; --i) {
                if (ans[i][j] != -1) {
                    a = ans[i][j];
                    break;
                }
            }
            if (a != -1) {
                for (int i = H - 1; i >= 0; --i) {
                    if (ans[i][j] == -1) ans[i][j] = a;
                    else break;
                }
            }
        }
    }

    rep(i, H) rep(j, W) {
        cout << ans[i][j] << (j == W - 1 ? '\n' : ' ');
    }
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <math.h>
unsigned short v[5120][120],a[10],i,j,n,s;
unsigned short summing(unsigned short n,unsigned short s){
    unsigned short ans=0,i,max=0,min=0,m,k;
    if(n==1){if(s<10 && a[s]==1)return 1; else return 0;}
    else{
        k=(a[0]+a[1]*2+a[2]*4+a[3]*8+a[4]*16+a[5]*32+a[6]*64+a[7]*128+a[8]*256+a[9]*512)*5+(n-1);
        if(n<6 && s<120 && v[k][s]<60000)return v[k][s];
        for(i=0,m=n;m>0 && i<10;i++){if(a[i]==1){min+=m*i;m--;if(s<min)goto answer;}}
        for(i=9,m=n;m>0 && i>=0;i--){if(a[i]==1){max+=m*i;m--;if(s<=max)break;}}if(s>max)goto answer;
        for(i=0;i<10;i++){
            if(a[i]==1 && n*i<=s){
                a[i]=0;
                ans+=summing(n-1,s-n*i);
                a[i]=1;
            }
        }
        answer:
        if(n<6)v[k][s]=ans;
        return ans;
    }
}
int main(void){
    for(i=0;i<10;i++)a[i]=1;
    for(i=0;i<5120;i++){{for(j=0;j<120;j++)v[i][j]=60000;}}
    while(scanf("%hu %hu",&n,&s)!=EOF){printf("%hu\n",summing(n,s));}
    return 0;
}

Measured memory_bytes: 1808