akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ab = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1])

    num=1
    while num < n:
        num *= 2
    num-=1
    inf=10**9+1

    m=num+n
    segtree=[inf]*m
    for i in range(num,m):
        segtree[i] = ab[i - num][0]
    for i in range(num-1,-1,-1):
        j=2*i+1
        if j>=m:
            segtree[i]=inf
        elif j+1>=m:
            segtree[i]=segtree[j]
        else:
            segtree[i] = min(segtree[j], segtree[j + 1])

    #探す
    def search(s):
        i=0
        while i < num:
            k = 2 * i + 1
            if k+2<=m:
                if segtree[k+1] <= s:
                    i = k + 1
                    continue
            if k+1<=m:
                if segtree[k] <= s:
                    i = k
                    continue
            return - 1
        return i - num
    
    #更新
    def update_good(i, s):
        while True:
            if segtree[i] > s:
                segtree[i] = s
                i = (i - 1) // 2
                continue
            break
    
    def update_bad(i):
        while i!=0:
            k=(i - 1) // 2
            if i % 2 == 1:
                if m > i + 1:
                    temp=min(segtree[i+1],segtree[i])
                    if segtree[k]<temp:
                        segtree[k] = temp
                        i = k
                        continue
                else:
                    segtree[k] = segtree[i]
                    i = k
                    continue
            else:
                temp=min(segtree[i-1],segtree[i])
                if segtree[k]<temp:
                    segtree[k] = temp
                    i = k
                    continue
            break

    cnt = 0
    for i in range(n):
        a,b=ab[i][0],ab[i][1]
        if a > b:
            t = search(b)
            if t <= i:
                print("No")
                return 0
            update_good(num + i, a)
            segtree[num + t] = a
            update_bad(num + t)
            ab[i][0], ab[t][0] = ab[t][0], a
            cnt+=1
    if cnt <= n - 2:
        print("Yes")
    else:
        print("No")
    
main()

Measured memory_bytes: 96616
from collections import Counter

a = int(input())
a_list = []
ans_list = []

for i in range(a):
  a_list.append(input())

a_counter = Counter(a_list)

_v = 0
for k, v in a_counter.most_common():
    if _v == 0 or _v == v:
      _v = v
      ans_list.append(k)
    elif _v > v:
      break

ans = sorted(ans_list)
for i in ans:
  print(i)

Measured memory_bytes: 45164
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>

using namespace std;


int main() {
 long long int a,b[110],c,d;
  
  cin >> a;
  
  for(int i=0;i<a-1;i++)
    cin >> b[i];
  
  c=0;
  
   c+= b[0];
  
  for(int i=0;i<a-2;i++){
    
    if(b[i] <= b[i+1]){
      c += b[i];
    }
    
    else if(b[i] > b[i+1]){
      c += b[i+1];
    }
  }
  
 c += b[a-2];
  cout << c << endl;
}
  
  

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<cmath>
#include<complex>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

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

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
typedef complex<double> Complex;
const double PI=acos(-1);
const Complex I(0,1);

// Stockham algorithm
// Hint: vector<Complex> v; fft(v.data(), v.size(), false);
void fft(Complex *x, const int n, const bool idft=false) {
    static Complex *y = NULL; static int y_len = 0;
    if (y_len < n) {
	if (y) delete[] y;
	y_len = n;
	y = new Complex[y_len];
    }
    if (idft) {
	for (int p=0; p<n; p++) x[p] = conj(x[p]);
    }
    int nn = n, s = 1, eo = 0;
    for (; nn>1;) {
	const int m = nn / 2;
	const double theta = 2.0 * PI / nn;
	for (int p=0; p<m; p++) {
	    const Complex wp(cos(p * theta), -sin(p * theta));
	    for (int q=0; q<s; q++) {
		const Complex a = x[q + s * p];
		const Complex b = x[q + s * (p + m)];
		const Complex c = a - b;
		y[q + s * (p + p)] = a + b;
		y[q + s * (p + p + 1)] = Complex(
			c.real()*wp.real() - c.imag()*wp.imag(),
			c.real()*wp.imag() + c.imag()*wp.real());
		//y[q + s * (p + p + 1)] = (a - b) * wp;
	    }
	}
	nn = m; s += s; eo ^= 1;
	swap(x, y);
    }
    if (eo) {
	for (int q=0; q<s; q++) y[q] = x[q];
	swap(x, y);
    }
    if (idft) {
	double b = 1.0 / n;
	for (int p=0; p<n; p++) x[p] = conj(x[p]) * b;
    }
}


const LL MOD = 200003;
const int LEN = 1 << 19;

int N;
int C[MOD+11];

LL A[MOD];
Complex X[LEN];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) {
	scanf("%lld", A+i);
    }

    sort(A, A+N);

    REP (i, N) C[A[i]]++;

    {
	LL x = 1;
	int e = 0;
	// 2^e == x;
	do {
	    X[e].real(C[x]);
	    x = x * 2 % MOD;
	    e++;
	} while (x != 1);
    }

    fft(X, LEN);
    REP (i, LEN) X[i] *= X[i];
    fft(X, LEN, true);

    LL ans = 0;
    for (LL x=1, e=0; e<LEN; e++, x=x*2%MOD) {
	ans += llround(X[e].real()) * x;
    }

    REP (i, N) ans -= A[i] * A[i] % MOD;
    assert(ans % 2 == 0);
    ans /= 2;
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main(void) {
    int x, y, gx, gy;
    cin >> x >> y;
    if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) gx == 1;
    else if (x == 4 || x == 6 || x == 9 || x == 11) gx = 2;
    else if (x == 2) gx = 3;
    if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) gy == 1;
    else if (y == 4 || y == 6 || y == 9 || y == 11) gy = 2;
    else if (y == 2) gy = 3;
    cout << (gx == gy ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
temp = input()
temp2 = temp.split(" ")
temp = []
for i in temp2:
    temp.append(int(i))

for i in range(1,100000000):
    ans1 = temp[0]*i
    if ans1 % temp[1] != 0:
        break
    if ans1 >= 10^18:
        ans1 = -1
        break
print(ans1)

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
using namespace std;
static const int INFTY=(1<<21);
static const int N=100;
int n,M[N][N],d[N];

void bfs(int s){
  queue<int> q;
  int i,u,v;
  q.push(s);
  for(i=0;i<n;i++)d[i]=INFTY;
  d[s]=0;
  while(!q.empty()){
    u=q.front();
    q.pop();
    for(v=0;v<n;v++){
      if(M[u][v]==0)continue;
      if(d[v]!=INFTY)continue;
      d[v]=d[u]+1;
      q.push(v);
    }
  }
  for(i=0;i<n;i++){
    cout<< i+1<<" "<<( (d[i]==INFTY)?(-1):d[i])<<endl;
  }
}

int main(){
  int u,k,v,i,j;
  
  cin>>n;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }

  for(i=0;i<n;i++){
    cin>>u>>k;
    u--;
    for(j=0;j<k;j++){
      cin>>v;
      v--;
      M[u][v]=1;
    }
  }
  bfs(0);

  return 0;
}

Measured memory_bytes: 3132
fun main() {
    // 文字列
    var k = readLine()!!.toInt()
//    val x: String = readLine()!!
    // 数値
//    val int =readLine()!!.toInt()
    // 行
//    val list = readLine()!!.split(" ").map (String::toInt )
//    val (n,d) = readLine()!!.split(" ").map(String::toInt)
//    val xys = List(n) {
//        readLine()!!.split(" ").map(String::toLong)
//    }

    var x =7%k
    var i=1
    var list= mutableListOf<Int>()
    while (i<=k){
        if (x==0){
            print(i)
            return
        }
        list.add(x)
        x=(x*10+7) %k
        i++
    }
    print(-1)
    return

//    var k = readLine()!!.toInt()
}


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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

int n;
map < LL, int > mp;

int main()
{
    _upgrade
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int x; cin >> x;
        mp[x]++;
    }
    LL ans = 0;
    for(auto x: mp)
    {
        if(x.second >= 4)
        {
            ans = max(ans, x.first * x.first);
        }
    }
    LL mx = 0;
    for(auto x: mp)
    {
        if(x.second >= 2)
        {
            mx = max(mx, x.first);
        }
    }
    for(auto x: mp)
    {
        if(x.second >= 2 && x.first != mx)
            ans = max(ans, mx * x.first);
    }
    cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int D = sc.nextInt();
    int X = sc.nextInt();
    int[]A= new int[N];
 
    int all = 0;
    for(int i=0; i<N; i++){
        A[i] = sc.nextInt();
        for(int j=0; j<D; j++) {
        	if(j*A[i]+1<=D) {
        		all++;
        	}
    } 
}
	System.out.println(all+X);
    }
}



Measured memory_bytes: 36008
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;


void main() {
    auto s = readln.split.map!(to!int);
    auto V = s[0];
    auto E = s[1];
    auto F = s[2];

    auto mcf = new MinCostFlow(V);

    foreach (_; 0..E) {
        s = readln.split.map!(to!int);
        mcf.add_edge(s[0], s[1], s[2], s[3]);
    }

    mcf.run(0, V-1, F).writeln;
}


class MinCostFlow {
    alias Tuple!(int, "to", int, "cap", int, "cost", int, "rev") Edge;
    immutable int INF = 1 << 29;

    int V;
    Edge[][] G;
    int[] h;
    int[] dist;
    int[] prevv;
    int[] preve;

    this(int v) {
        V = v;
        G = new Edge[][](v);
        h = new int[](v);
        dist = new int[](v);
        prevv = new int[](v);
        preve = new int[](v);
    }

    void add_edge(int from, int to, int cap, int cost) {
        G[from] ~= Edge(to, cap, cost, G[to].length.to!int);
        G[to] ~= Edge(from, 0, -cost, G[from].length.to!int - 1);
    }

    int run(int s, int t, int f) { // source, sink, flow
        int res = 0;
        h.fill(0);
        while (f > 0) {
            auto pq = new BinaryHeap!(Array!(Tuple!(int, int)), "a[0] < b[0]");
            dist.fill(INF);
            dist[s] = 0;
            pq.insert(tuple(0, s));
            while (!pq.empty) {
                auto p = pq.front;
                pq.removeFront;
                int v = p[1];
                if (dist[v] < p[0]) continue;
                foreach (i; 0..G[v].length.to!int) {
                    auto e = G[v][i];
                    if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
                        dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                        prevv[e.to] = v;
                        preve[e.to] = i;
                        pq.insert(tuple(dist[e.to], e.to));
                    }
                }
            }
            if (dist[t] == INF) {
                return -1;
            }
            foreach (v; 0..V) {
                h[v] += dist[v];
            }

            int d = f;
            for (int v = t; v != s; v = prevv[v]) {
                d = min(d, G[prevv[v]][preve[v]].cap);
            }
            f -= d;
            res += d * h[t];
            for (int v = t; v != s; v = prevv[v]) {
                G[prevv[v]][preve[v]].cap -= d;
                G[v][G[prevv[v]][preve[v]].rev].cap += d;
            }
        }

        return res;
    }
}

Measured memory_bytes: 2788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define pq priority_queue
#define bcnt(n) __builtin_popcountll(n)

using ll = long long;  // long longをllだけにした
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using mll = map<long long, long long>;
using pll = pair<long long, long long>;
using sll = set<long long>;
using vpll = vector<pair<long long, long long>>;
using mlv = map<long long, vector<long long>>;

// 20200415
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while(n > 0) {
		if(n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
// modとaが互いに素のときのみ有効(数学的に逆元が一意に定まるのがそのときのみ)

int main() {
	ll const mod = 1e9 + 7;
	string l;
	cin >> l;
	ll n = l.size();
	vll v(n);
	rep(i, n) v[i] = l[i] - '0';
	ll res = 0;
	ll k = 0;
	rep(i, n) {
		if(v[i] == 0) continue;
		res += modpow(2, k, mod) * modpow(3, n - 1 - i, mod);
		res %= mod;
		k++;
	}
	res += modpow(2, k, mod);
	res %= mod;
	cout << res << endl;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
    using namespace std;
    #define int long long int
    #define pb push_back
    #define vi vector<int>
    #define loop(i,a,b) for(int i=a;i<b;i++)
    int32_t main()
    {
       
        #ifndef ONLINE_JUDGE
  freopen("input.txt" , "r" , stdin);
  freopen("output.txt" , "w" , stdout);
  #endif
           int n,k,s=0;
           cin>>n>>k;
           int arr[n];
           loop(i,0,n)
           cin>>arr[i];
           sort(arr,arr+n);
           loop(i,0,k)
           s=s+arr[i];
           cout<<s<<endl;
    return 0;
}

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

int main(){
	long long N,M;
	cin>>N>>M;
	long long ans=0;
	if(M >= 2*N){
		long long P = M-2*N;
		long long CanMake =  P/4;
		ans = N + CanMake;
	}else if(M < 2*N){
		ans =  M / 2;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 3624
// Winners don't quit and Quitters don't win
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mod 998244353
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,t;
    int i,f=1;
    cin>>s;
    cin>>t;
    for(i=0;i<s.size();++i){
    	if(s[i]!=t[i]){
    		f=0;
    		break;
		}
	}
	if(f){
		cout<<"Yes"<<'\n';
	}
	else{
		cout<<"No"<<'\n';
	}
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     pll         pair<ll,ll>
#define     mp          make_pair
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;


int main() {
    
    ios
    ll a;
    cin >> a;
    cout << a + a*a + a*a*a << "\n";
    return 0;
}



Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

sunuke = 0
kuma = sum(a)
ans = pow(10, 100)
for i in range(n - 1):
    sunuke += a[i]
    kuma -= a[i]
    #print(sunuke, kuma)
    if abs(kuma - sunuke) < ans:
        ans = abs(kuma - sunuke)
print(ans)


Measured memory_bytes: 23800
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int a, b;

    cin >> a >> b;

    cout << (b % a == 0 ? a + b : b - a) << endl;

    return 0;
}



Measured memory_bytes: 892
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

int main(){

	char head = 'd', tail = 'x';
	set<string> check;
	string out, in, mid = "opqrstuv";
	
	do{
		out = mid;
		out += tail;
		out.insert(out.begin(), head);

		printf("?%s\n", out.c_str());
		fflush(stdout);

		cin>>in;
		
		if(check.count(in) || in[0]!=tail){
			printf("!OUT\n");
			break;
		}

		check.insert(in);
		head = in[in.size()-1];

	}while(next_permutation(mid.begin(), mid.end()));
	
	return 0;
}

Measured memory_bytes: 1256
import java.util.Scanner;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {

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

        int N = scanner.nextInt();
        int K = scanner.nextInt();
        long ans = K;

        for(int i = 1; i < N; i++){
            ans *= K - 1;
        }

        System.out.println(ans);
    }



}


Measured memory_bytes: 9680
n = int(input())
H = list(map(int,input().split()))
for i in range(n-1):
    if H[i] > H[i+1]:
        if H[i] <= H[i+1] + 1:
            H[i+1] += 1
        else:
            print('No')
            break
else:
    print('Yes')
    

Measured memory_bytes: 85352
#include<bits/stdc++.h> 
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;

int n,k,a[100003],ans;
int main(){
  cin>>n>>k;
  REP(i,n)cin>>a[i];
  n--;
  while(n>0){
    ans++;n-=(k-1);
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 640
/*
 *
 * Author: r3gz3n
 * 
 * 3b 13 12 9 56 4e
 * 6 56 a a 5f f
 * 6 56 47 18 56 d
 * 13 46 14 1f 13 27
 * 52 52 a 5a 47 1
 * 1d 13 b 1b 49 17
 *
 */


#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;


#define ll long long


#define rep(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define repi(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)


#define endl '\n'


class Solution {
public:
    const static int MOD = 998244353;
    const static int MAX = 3005;
    int a[MAX];
    ll dp[MAX];
    void solve(std::istream& in, std::ostream& out) {
        int n, s;
        ll ans = 0;
        in >> n >> s;
        rep(i, 0, n ,1) in >> a[i];
        memset(dp, 0, sizeof(dp));
        rep(i, 0, n, 1) {
            (dp[0] += 1) %= MOD;
            repi(j, s, a[i]-1, 1) {
                (dp[j] += dp[j-a[i]]) %= MOD;
            }
            (ans += dp[s]) %= MOD;
        }
        out << ans << endl;
    }
};

void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


    istream& in = cin;


    ostream& out = cout;

    solve(in, out);
    return 0;
}



Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n : usize,
        m : usize,
        c : i32,
        b : [i32; m],
        a : [[i32; m]; n]
    }
    let mut answer = 0;
    for vec_a in a {
        let mut num = c;
        for s in 0..m {
            num += b[s] * vec_a[s];
        }
        if num > 0 {answer += 1};
    }
    println!("{}", answer);
}



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

using namespace std;

int main()
{

   vector<int >a(3);
   for(int i=0;i<3;i++)
   {
       cin>>a[i];
   }
   sort(a.begin(),a.end());
   int d;
   cin>>d;

  cout<<a.at(0)+a.at(1)+a.at(2)*pow(2,d)<<endl;
    return 0;
}

Measured memory_bytes: 384
#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(){
    int X;
    cin >> X;
    for (int i = 1; i <= 360; i++){
        if ((i * X) % 360 == 0){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

const int maxn = 1e5 + 10;
int n , a[maxn];
map < int , int > mp;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(NULL);
	cin >> n;
	pair < int , int > mx = make_pair(-1 , -1);
	for(int i=0;i<n;i++){ cin >> a[i]; mp[a[i]]++; }
	sort(a , a + n);
	for(int i=n-1;i>=0;i--)
	{
		if(mp[a[i]] > 1)
		{
			if(mx.first == -1) mx.first = a[i];
			else if(mx.second == -1) mx.second = a[i];
			mp[a[i]] -= 2;
		}
		if(mp[a[i]] > 1)
		{
			if(mx.first == -1) mx.first = a[i];
			else if(mx.second == -1) mx.second = a[i];	
		}
	}
	if(mx.second == -1){ cout << 0; return 0; }
	ll ans = mx.first * 1ll * mx.second;
	cout << ans;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect

const int N = 2e5 + 7;

int a[N], calc[N];

void solve() {
    int n; cin >> n;
    loop(i, n) {
        cin >> a[i];
        ++calc[a[i]];
    }
    int ans = 0;
    loop(i, N)
        ans += calc[i] * (calc[i] - 1) >> 1;
    loop(i, n)
        cout << ans - (calc[a[i]] * (calc[a[i]] - 1) >> 1) + ((calc[a[i]] - 1) * (calc[a[i]] - 2) >> 1) << "\n";
}
 
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>
using namespace std;

int main()
{
    unsigned int n,q,k,all;
    bitset<18> a(0),b(1);
    cin>>n;
    all=1<<n;
    cin>>q;
    for(int i=0;i<all;i++){
        a=i;
        if(a.count()==q){
            cout<<i<<":";
            for(int i=0;i<18;i++){
                if(a.test(i)){
                    cout<<" "<<i;
                }
            }
            cout<<"\n";
        }
    }

}





Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long ans = 0;
		for(long i=1;i*i<n;i++) {
			if(n%i==0 && n/i-i>=2) ans += n/i - 1;
		}
		System.out.println(ans);
		in.close();
	}

}


Measured memory_bytes: 23764
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

use std::cmp::Ordering;

#[derive(Eq)]
struct Work {
    day: u32,
    reward: u32,
}

impl Ord for Work {
    fn cmp(&self, other: &Self) -> Ordering {
        self.reward.cmp(&other.reward)
    }
}

impl PartialOrd for Work {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl PartialEq for Work {
    fn eq(&self, other: &Self) -> bool {
        self.reward == other.reward
    }
}

use std::collections::BinaryHeap;

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {

    let (n, m) = input!(usize, usize);

    let mut works = Vec::with_capacity(n);
    let mut pq = BinaryHeap::new();

    for i in 0..n {
        let (a, b) = input!(u32, u32);
        works.push( Work { day: a, reward: b } );
    }

    works.sort_by(|a, b| b.day.cmp(&a.day));

    let mut total_reward = 0;

    for day in 1..(m+1) {
        while works.len() > 0 && works[works.len() - 1].day <= day as u32 {
            if let Some(work) = works.pop() {
                pq.push(work);
            }
        }

        if let Some(work) = pq.pop() {
            total_reward += work.reward;
        }
    }
    
    println!("{}", total_reward);
}

fn main() {
    solve();
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int calc(int x) {
    int y = 0;
    while (x) {
        y += x % 10;
        x /= 10;
    }
    return y;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int ans = 1000000;
    for (int i = 1; i <= n - 1; i++) {
        int b = n - i;
        ans = min(ans, calc(i) + calc(b));

    }
    cout << ans << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>

#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cctype>

#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    os << "{ ";
    for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
        os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", ");
    os << " }";
    return os;
}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define vv(type,w,h,init) vector<vector<type>>(h,vector<type>(w,init))
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair

string const resstr[] = {"Impossible","Possible","No","Yes"};

bool p[1000100];

void erato(){
	fill(p, p+1000100, true);
	p[0] = p[1] = false;
	
	for(int i=0; i < 1000100; i++){
		if(!p[i]) continue;
		for(int j=i+i; j < 1000100; j+=i){
			p[j] = false;
		}
	}
}

int main(){
	int n;
	erato();
	while(cin >> n){
		int count = 0;
		for(int i=0; i <= n; i++){
			if(p[i]) count++;
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 2176
#include <iostream>
using namespace std;
#include <cstdio>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
   int i,j,k,l;
   int a,b,c,d;
   int memory[2];
   int height[10];
   int n;

   for(i=0;i<10;i++) cin >> height[i];
   
   for(i=0;i<9;i++) {
      for(j=9;j>i;j--) {
         if(height[j] > height[j-1]) {
            int tmp = height[j];
            height[j] = height[j-1];
            height[j-1] = tmp;
         }
      }
   }

   for(i=0;i<3;i++) cout << height[i] << "\n";
   return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<math.h>
int a[1000001]={0};
int main(void){
    int n,i,j,ans,input;
    for(i=2;i<=1000000;i++){
        if(a[i]==0){
            for(j=2;i*j<=1000000;j++){
                a[i*j]=1;
            }
        }
    }
    while(scanf("%d",&input)!=EOF){
        ans=0;
        for(i=2;i<=input;i++){
            if(a[i]==0)ans++;
        }
    printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 4500
#include<bits/stdc++.h>
#define ll long long
#define lld long long double
#define pb push_back
#define mp make_pair
#define M 1000000007
using namespace std;

ll f(ll n, ll w, ll a[], ll b[]) {
	ll dp[n + 1][w + 1];
	memset(dp, 0, sizeof(dp));
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= w; j++) {
			if (j - a[i - 1] >= 0) {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - a[i - 1]] + b[i - 1]);
			}
			else dp[i][j] = dp[i - 1][j];
		}
	}
	return dp[n][w];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	ll n, w;
	cin >> n >> w;
	ll a[n], b[n];
	for (ll i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	cout << f(n, w, a, b);
	return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    double a, b;
    double pi = acos(-1);
    cin >> a >> b >> h >> m;

    double deg_long = 30.0 * h + 0.5 * m;
    double deg_short = 6.0 * m;
    double deg_diff = abs(deg_long - deg_short);
    if (deg_diff >= 180.0) deg_diff = 360.0 - deg_diff;

    MSG(fixed << setprecision(32) << sqrt(a * a + b * b - 2 * a * b * cos(deg_diff / 360.0 * 2 * pi)))
}


Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;

int main()
{
	int n;
	int f=0;
	cin>>n;
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		if(a==b)
		cnt++;
		else
		cnt=0;
		if(cnt>=3)
		f=1;
	}
	if(f==1)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
string s, S;
int main () {
	ios::sync_with_stdio(false);
	cin >> s;
	for (auto t: s)
		if (t != 'x')
			S.push_back(t);
	int l = S.length();
	if (!l) {
		cout << 0 << endl;
		exit(0);
	}
	for (int i = 0; i < l; i++)
		if (S[i] != S[l - i - 1]) {
			cout << -1 << endl;
			exit(0);
		}
	int pl = s.length(), cnt = 0, mid1, mid2;
	for (int i = 0; i < pl; i++) {
		if (s[i] != 'x') cnt++;
		else continue;
		if (cnt == l / 2)
			mid1 = i;
		if (cnt == l / 2 + 1) {
			mid2 = i;
			if (l & 1)
				mid1 = i;
			break;
		}
	}
	int ans = 0;
	for (int i = 0; i < (l - 1) / 2; i++) {
		int cnt1 = 0, cnt2 = 0;
		mid1--; mid2++;
		while (mid1 >= 0 && s[mid1] == 'x')
			cnt1++, mid1--;
		while (mid2 < pl && s[mid2] == 'x')
			cnt2++, mid2++;
		ans += abs(cnt1 - cnt2);
	}
	cout << ans + abs(mid1 + mid2 + 1 - pl) << endl;
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int a[3];
 cin >> a[0] >> a[1] >> a[2];
 sort(a,a+3);
 if(a[0]==5 && a[1]==5 && a[2]==7)
 cout << "YES";
 else
 cout << "NO";
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/
ll x[8],y[8];

int main()
{
  ll n;cin>>n;
  for(ll i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }
  double ans=0;
  for(ll i=0;i<n;i++){
    for(ll j=i+1;j<n;j++){
      ans+=1.*sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }
  ans=2*ans/n;
  printf("%.10lf\n",ans);
  return 0;
}


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

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());
            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long max = 0;
            long min = 1000000000;
            for (int i = 0; i < n; i++)
            {
                if (inputLongArray[i] < min)
                {
                    min = inputLongArray[i];
                }
                if (inputLongArray[i] > max)
                {
                    max = inputLongArray[i];
                }
            }

            Console.WriteLine(max-min);

            Console.Out.Flush();
        }
    }
}


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

#pragma region template


// -type-
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;


// -const-
const ll MOD = 1000000007;


const ll MAX = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define F first
#define S second

#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep(i, n) reps(i, 0, n)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(x) cerr << x << " (L:" << __LINE__ << ")" << '\n';


// -functions-

inline bool in(string s, string c) {
    return (s.find(c) != string::npos);
}
inline bool in(string s, char c) {
    return (s.find(c) != string::npos);
}

template <class T>
void print(T& x) {
    cout << x << '\n';
}

struct setup_main {
    setup_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(15);
    }
} setup_main_;

#pragma endregion

ll ans = 0;

void solve(long long N, std::vector<long long> A, std::vector<long long> B,
           std::vector<long long> C) {
    for (auto&& i : B) {
        ans += i;
    }
    rep(i, N - 1) {
        if (A[i] + 1 == A[i + 1]) {
            ans += C[A[i]];
        }
    }
    print(ans);
}

signed main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    std::vector<long long> B(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &B[i]);
    }
    std::vector<long long> C(N);
    for (int i = 1; i < N; i++) {
        scanf("%lld", &C[i]);
    }
    solve(N, std::move(A), std::move(B), std::move(C));

    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    S = list(input())
    K = int(input())
    l = []
    cnt = 0
    if len(S)==1:
        print(K//2)
    else:
        gr = groupby(S)
        for key, group in gr:
            l.append(list(group))
        if len(l)==1:
            print(len(S)*K//2)
        else:
            for i in range(len(l)):
                cnt += len(l[i]) // 2
                
            if l[0][0] == l[-1][0]:
                dev = len(l[0]) // 2 + len(l[-1]) // 2 - (len(l[-1]) + len(l[0])) // 2
            else:
                dev = 0
            print(cnt * K - dev * (K - 1))


resolve()

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; print(tail...); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; ll k; read(n, k);
	vector<int> v(n), v2(2 * n);
	rep(i, 0, n) read(v[i]), v2[i] = v2[n + i] = v[i];

	ll ans0 = 0, ans1 = 0, ans = 0;

	rep(i, 0, n) rep(j, i + 1, n) if (v[i] > v[j]) ans0++;
	rep(i, 0, n) rep(j, n, 2 * n) if (v2[i] > v2[j]) ans1++;

	const ll mod = 1000000007;

	ans += ans0 * k % mod;
	ans += ans1 * (k * (k - 1) / 2 % mod) % mod;

	cout << ans%mod << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

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

  int N,D; cin >> N >> D;
  vector<vector<ll>> X(N, vector<ll>(D));
  rep(i, N) {
    rep(j, D) {
      cin >> X[i][j];
    }
  }

  int ans = 0;
  rep(i, N) {
    rep(j, N) {
      if(i >= j) continue;
      ll val = 0;
      rep(k, D) {
        val += (X[j][k] - X[i][k]) * (X[j][k] - X[i][k]);
      }

      bool add = false;
      for(ll k = 0; k * k <= val; ++k) {
        if(k * k == val) {
          add = true;
          break;
        }
      }
      ans += add;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

int  main(){
    int a,b;
    int tmp;
    cin >> a >> b;
    if(b < 10){
        tmp = a * 10 + b;
    }else if(b < 100){
        tmp = a * 100 + b;
    }else{
        tmp = a * 1000 + b;
    }
    for(int i = 1; i < 1000; i++){
        if(tmp == i * i){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
from math import ceil
N, A, B = map(int, raw_input().split())
h = [0] * N
for i in range(N):
  h[i], = map(int, raw_input().split())
h.sort()

l = 0
r = int(ceil(1.0*h[-1]/B))
while True:
  m = (l+r)//2
  if m==l:
    break
  c = 0
  for i in range(N):
    ai = int(ceil(1.0*max(0,h[i]-B*m)/(A-B)))
    c += ai
  if c>m:
    l = m
  else:
    r = m
print r

Measured memory_bytes: 34536
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std;
int N, X;

int main(){
    ios_base::sync_with_stdio(false);
    cin >> N >> X;

    if(X == 1 || X == 2*N-1){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
        for(int i=0; i<2*N-1; i++){
            cout << (X+N+i-1)%(2*N-1)+1 << endl;
        }
    }

    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin() x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin() x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	ll slot[75];
	memset(slot, 0, sizeof(slot));
	//素数の乗数をカウント
	for(ll i=2; i<=n; i++){
		bool ng = false;
		for(ll j=2; j<=sqrt(i); j++){
			if (i%j==0){
				ng=true;
				break;
			}
		}
		if (ng) continue;
		ll k = 1, cnt=0;
		while(k*=i, k<=n){
			cnt += n/k;
		}
		if (cnt>=2) slot[2]++;
		if (cnt>=4) slot[4]++;
		if (cnt>=14) slot[14]++;
		if (cnt>=24) slot[24]++;
		if (cnt>=74) slot[74]++;
	}
	ll ans=0;
	ans += slot[74];
	ans += slot[24]*(slot[2]-1);
	ans += slot[14]*(slot[4]-1);
	ans += slot[4]*(slot[4]-1)/2*(slot[2]-2);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

		int n = scanner.nextInt();
		V V[] = new V[n];
		for (int i = 0; i < n; i ++) {
			V[i] = new V();
		}
		
		for (int i = 0; i < n; i ++) {
			int u = scanner.nextInt();
			int k = scanner.nextInt();
			for (int j = 0; j < k; j ++) {
				E e = new E();
				e.v = V[scanner.nextInt()];
				e.c = scanner.nextInt();
				V[u].e.add(e);
			}
			V[u].d = Integer.MAX_VALUE;
		}
		
		PriorityQueue<V> heep = new PriorityQueue<>();
		
		for (int i = 0; i < n; i ++) {
			heep.add(V[i]);
		}
		
		scanner.close();
		
		V[0].d = 0;
		
		for(int i = 0; i < n; i ++) {
			V u = heep.remove();
			
			u.fixed = true;
			for (E j: u.e) {
				if (j.v.fixed == false && u.d + j.c < j.v.d) {
					j.v.d = u.d + j.c;
					heep.remove(j.v);
					heep.add(j.v);
				}
			}
		}
		
		for (int i = 0; i < n; i ++) {
			System.out.println(i + " " + V[i].d);
		}
	}
	
	private static class E {
		V v;
		int c;
	}
	
	private static class V implements Comparable {
		List<E> e = new LinkedList<>();
		int d;
		boolean fixed;

		public int compareTo(Object p1)
		{
			return d - ((V) p1).d;
		}
	}
} 



Measured memory_bytes: 289984
# https://atcoder.jp/contests/abc129/tasks/abc129_c
# 典型的なDP

MOD = 10**9 + 7

# dp[i]をi段目までの通りの数とする。
N, M = list(map(int, input().split()))
to_zero = [False] * (N + 1)
for _ in range(M):
    to_zero[int(input())] = True  # 床が抜けているところ

# dpテーブルの用意
dp = [-1] * (N + 1)
dp[0] = 1
dp[1] = 0 if to_zero[1] else 1
for i in range(2, N + 1):
    dp[i] = dp[i - 1] + dp[i - 2]
    if to_zero[i]:
        dp[i] = 0

    if dp[i] > MOD:
        dp[i] %= MOD

print(dp[-1])


Measured memory_bytes: 7668
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		//int n = scan.nextInt();
		String s = scan.next();
		int n = s.length();
		scan.close();
		Deque<Integer> y1 = new ArrayDeque<Integer>();
		Deque<Integer> y2 = new ArrayDeque<Integer>();
		Deque<Integer> x = new ArrayDeque<Integer>();
//		ArrayList<Integer> h1 = new ArrayList<Integer>();
//		int h = 0;
		int sum = 0;
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(c == '\\') {
				y1.addFirst(i);
			}else if(c == '/' && y1.size() > 0) {
				int j = y1.pollFirst();
				int a = i - j;
				sum += i - j;
				while(x.size() > 0 && y2.getFirst() > j) {
					a += x.poll();
					y2.poll();
				}
				x.addFirst(a);
				y2.addFirst(j);
			}
		}
		System.out.println(sum);
		if(sum == 0) {
			System.out.println(0);
			System.exit(0);
		}
		System.out.print(x.size() + " ");
		int k = x.size();

		for(int i = 0; i < k - 1; i++) {
			System.out.print(x.pollLast() + " ");
		}
		System.out.println(x.poll());
	}
}


Measured memory_bytes: 28888
s = input().split("T")
x,y = map(int,input().split())
x-=len(s[0])
XY = [[],[]]

for n in range(1,len(s)):
  XY[n%2].append(len(s[n]))

X,Y = XY
X = sorted(X)[::-1]
Y = sorted(Y)[::-1]

for n in X:
  if 0<x:
    x-=n
  else:
    x+=n

for n in Y:
  if 0<y:
    y-=n
  else:
    y+=n

if (x,y)==(0,0):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9164
s, c = list(map(int, input().split()))
use_s = 0
hoge = int(c / 2)
if(hoge < s):
  use_s = hoge
else:
  use_s = s
remain = c - (2 * use_s)
remain_c = int(remain / 4)
amount = use_s + remain_c
use_c_only = int(c / 4)
if(amount > use_c_only):
	print(amount)
else:
	print(use_c_only)


Measured memory_bytes: 3060
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
# from math import gcd
# from fractions import gcd
from functools import reduce
from pprint import pprint

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

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

n,x = myinput()

def mycalc(a,b):
    if b==0:
        return 0
    else:
        return ( (a//b) * 3 * b ) + mycalc(b,a%b)

ans = mycalc(n-x,x)
print(ans)

Measured memory_bytes: 38384