akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int N, W;
int w[110], v[110];
int dp[110][110][310];

signed main() {
    cin >> N >> W;
    repq(i,1,N) cin >> w[i] >> v[i];
    int flr = w[1];
    int sum = 0;
    repq(i,1,N) {
        w[i] -= flr;
        sum += w[i];
    }
    memset(dp, 0, sizeof(dp));
    int ans = 0;
    repq(i,1,N) repq(j,1,i) repq(k,0,sum) {
        dp[i][j][k] = dp[i-1][j][k];
        // printf("i = %lld, j = %lld, k = %lld, flr = %lld\n", i, j, k, flr);
        if(k-w[i] >= 0 && k + j * flr <= W)
            dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-1][k-w[i]] + v[i]);
        if(i == N) ans = max(ans, dp[i][j][k]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 29568
#include <iostream>
 #include <vector>
 #include <algorithm>
 #include <cmath>
 
 using namespace std;
 
 int main(){
   int h,w,d;cin>>h>>w>>d;
   int mp[h][w];
   vector<pair<int,pair<int,int> > > a[d];
   for(int i = 0; h > i; i++){
     for(int j = 0; w > j; j++){
       cin>>mp[i][j];
       a[mp[i][j]%d].push_back(make_pair(mp[i][j],make_pair(i,j)));
     }
   }
   vector<long long> b[d];
   for(int i = 0; d > i; i++){
     sort(a[i].begin(),a[i].end());
     b[i].push_back(0);
     b[i].push_back(a[i][1].second.first+a[i][1].second.second);
     for(int j = 1; a[i].size() >= j; j++){
       b[i].push_back(b[i][j]+abs(a[i][j].second.first-a[i][j-1].second.first)+abs(a[i][j].second.second-a[i][j-1].second.second));
     }
   }
   int q;cin>>q;
   for(int _ = 0; q > _; _++){
     int x,y;cin>>x>>y;
     int ans = b[x%d][(y-1)/d+1]-b[x%d][(x-1)/d+1];
     cout << ans << endl;
   }
 }    

Measured memory_bytes: 12032
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <ctime>
#include <fstream>
#include <stdarg.h>
using namespace std;
const bool debug=false;
const bool INJUDGE=false;
#define FASTERCIN cin.tie(0);ios_base::sync_with_stdio(false)
typedef long long ll;
/*Time:
Status:
Type:
Author:*/
int a[100005],n,k;
int main(){
	scanf("%d%d",&n,&k);
	cout<<(n-1+k-2)/(k-1)<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
readline=sys.stdin.readline
n=int(input())
a=[list(map(int, readline().split())) for _ in range(n)]
a.sort(key=lambda x: x[1])
t=0
for i in range(n):
  t+=a[i][0]
  if t>a[i][1]:
    print("No")
    break
  elif i==n-1:
    print("Yes")

Measured memory_bytes: 53616
//g++ test.cpp -o test.out
//入出力：http://kaitei.net/cpp/iostream/
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
using namespace std;

int N;
char str[10000];

char rot(char c){
	return ((c-0x41)+N)%26 + 0x41;
}

int main(){
	cin >> N;
	cin >>str;
	for(int i=0;i<10000;i++){
		if(str[i]>0x41+26 || str[i]<0x41){
			break;
		}
		str[i] = rot(str[i]);
	}
	cout << str;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int n;
long long x=1,y=1;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		long long w=max(1ll*(x+a-1)/a,1ll*(y+b-1)/b);
		x=1ll*a*w,y=1ll*b*w;
		//printf(" * %lld %lld\n",x,y);
	}
	printf("%lld\n",x+y);
}

Measured memory_bytes: 128
import sys
from io import StringIO
import unittest
import heapq


def resolve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A = list(map(lambda x: x*(-1), A))
    heapq.heapify(A)

    for i in range(M):
        m = -1 * heapq.heappop(A)
        heapq.heappush(A, -1 * (m//2))

    print(-1 * int(sum(A)))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3
2 13 8"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 4
1 9 3 5"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1 100000
1000000000"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000"""
        output = """9500000000"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 84840
#!/mnt/c/Users/moiki/bash/env/bin/python
from collections import Counter
# N,M = map(int, input().split())
a = [ [int(a) for a in input().split()] for _ in range(3)]
b = sum(a, [])

# print(b)
b = Counter(b)

if b.most_common()[0][1] >= 3:
    print("NO")
else:
    print("YES")






Measured memory_bytes: 38384
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

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

int a, b, c, res = (int)1e18+10;

signed main()
{
    init_ios();
    cin >> a >> b >> c;
    if (a%2 == 0 || b%2 == 0 || c%2 == 0) {
    	cout<<"0\n";
    	return 0;
    }
    res = min(res, a*b);
    res = min(res, a*c);
    res = min(res, b*c);
    cout<<res<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////

int happy(int A[][3],int t, int dp[][3],int n)
{
    int s1,s2;
    s1 = (t+1)%3;
    s2 = (t+2)%3;
    if (n == 0)
    return dp[0][t];
    if (dp[n][t]!=(-1))
    return dp[n][t];
    dp[n][t] = max(happy(A,s1,dp,n-1)+A[n][s1],happy(A,s2,dp,n-1)+A[n][s2]);
    return dp[n][t];
       
}

int main()
{
    int n,i,j,A[100000][3],maxi1,maxi2,maxi3,dp[100000][3];
    cin >> n;
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < 3; j++)
        {
            cin >> A[i][j];
            dp[i][j] = -1;
        }
    }
    dp[0][0] = max(A[0][1],A[0][2]);
    dp[0][1] = max(A[0][0],A[0][2]);
    dp[0][2] = max(A[0][1],A[0][0]);
    maxi1 = happy(A,0,dp,n-1);
    maxi2 = happy(A,1,dp,n-1);
    maxi3 = happy(A,2,dp,n-1);
    if (maxi2 > maxi1)
    maxi1 = maxi2;
    if (maxi3 > maxi1)
    maxi1 = maxi3;
    cout << maxi1;
    return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#define MP make_pair
#define PB push_back
#define SZ size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define S second
#define ld long double
#define eps 0.00000000001
#define MAX 1000000007
#define vll vector <ll> 
#define pll pair <ll,ll> 

using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ll powc(ll a, ll b){
    if(b<0){
        return -1;
    }
    ll res=1;
    while(b>0){
        if(b&1){
            res*=a;
        }
        a*=a;
        //res%=m9, a%=m9;
        b>>=1;
    }
    return res;
}



///target expert

int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n; cin>>n;
    vector <ll> v(n), suf(n-1);
    REP(i,0,n){
        cin>>v[i];
    }
    ll ans=0;
    suf[n-2]=v[n-1]%MAX;
    RED(i,n-3,0){
        suf[i]=suf[i+1];
        suf[i]+=v[i+1];
        suf[i]%=MAX;
    }
    REP(i,0,n-1){
        //cout<<v[i]<<" "<<suf[i]<<endl;
        ans+=((v[i]%MAX)*(suf[i]%MAX))%MAX;
        ans%=MAX;
    }
    cout<<ans;
}



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

int main(){
  ll n,t;
  cin>>n>>t;
  vector<ll> v(n);
  rep(i,n) cin>>v.at(i);
  ll sum = 0;
  rep(i,n-1){
    if (v.at(i+1)-v.at(i) >= t){
      sum+=t;
    }
    else {
      sum = sum+(v.at(i+1)-v.at(i));
    }
  }
  sum+=t;
  cout << sum << endl;
}

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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			var array = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
			long a = array[0];
			long b = array[1];
			string sign = "";
			if (a > b) {
				sign = ">";
			} else if(a < b){
				sign = "<";
			} else {
				sign = "==";
			}

			Console.WriteLine($"a {sign} b");
			Console.Out.Flush();
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 18400
#include <iostream>
#include <vector>
#include <algorithm>

auto main() -> int
{
    int num = 0;
    std::cin >> num;

    int tmp = 0, max = 0, min = 0;
    bool flag = false;
    while (std::cin >> tmp, max = tmp > max ? tmp : max, tmp + 1 < max ? flag = true : 0, --num);

    if (flag)
        std::cout << "No";
    else
        std::cout << "Yes";
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 100005;

int main(){
	fastio;
	int a,b,c;
	cin >> a >> b >> c;
	cout << c*(int)ceil((double)a/(double)b) << '\n';
	return 0;
}


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

int main(){
       string s;
       cin >> s;
       int a = 0;
       for(int i = 0; i < s.size(); ++i){
           if(s.at(i) == 'A'){
               a = i;
               break;
           }
        }
       // cout << a << endl;
        int z = 0;
        for(int i = s.size()-1; i > 0; --i){
           if(s.at(i) == 'Z'){
               z = i+1;
               break;
           }
        }
       // cout << z << endl;
        cout << z - a << endl;
}

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

int main()
{
  string S;
  cin >> S;
  if (S.at(0) == S.at(1) || S.at(1) == S.at(2) || S.at(2) == S.at(3)) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;


template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  Int n;
  F f;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(F f,T ti):f(f),ti(ti){}
  void init(Int n_){
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }
  void build(const vector<T> &v){
    Int n_=v.size();
    init(n_);
    for(Int i=0;i<n_;i++) dat[n+i]=v[i];
    for(Int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }
  void set_val(Int k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
  }
  T query(Int a,Int b){
    T vl=ti,vr=ti;
    for(Int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }
  template<typename C>
  Int find(Int st,C &check,T &acc,Int k,Int l,Int r){
    if(l+1==r){
      acc=f(acc,dat[k]);
      return check(acc)?k-n:-1;
    }
    Int m=(l+r)>>1;
    if(m<=st) return find(st,check,acc,(k<<1)|1,m,r);
    if(st<=l&&!check(f(acc,dat[k]))){
      acc=f(acc,dat[k]);
      return -1;
    }
    Int vl=find(st,check,acc,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(st,check,acc,(k<<1)|1,m,r);
  }
  template<typename C>
  Int find(Int st,C &check){
    T acc=ti;
    return find(st,check,acc,1,0,n);
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,q;
  cin>>n>>q;
  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  const Int INF = 1e15;
  using T = tuple<Int,Int,Int,Int,Int>;
  T ti(-INF,-INF,-INF,-INF,-INF);

  auto f=[&](T a,T b){
           if(a==ti) return b;
           if(b==ti) return a;
           Int as,ava,avi,avl,avr;
           tie(as,ava,avi,avl,avr)=a;
           Int bs,bva,bvi,bvl,bvr;
           tie(bs,bva,bvi,bvl,bvr)=b;
           Int cs=as+bs;
           Int cva=ava+bva,cvi=max(avi,bvi),cvl=avl,cvr=bvr;
           cvi=max(cvi,avr+bvl);
           cvl=max(cvl,ava+bvl);
           cvr=max(cvr,avr+bva);
           return T(cs,cva,cvi,cvl,cvr);
         };
  SegmentTree<T> seg(f,ti);

  vector<T> vt;
  for(Int i=0;i<n;i++) vt.emplace_back(as[i],as[i],as[i],as[i],as[i]);
  seg.build(vt);

  auto print=
    [&](){
      auto res=seg.query(0,n);
      Int ans=max({get<0>(res),get<1>(res),get<2>(res),get<3>(res),get<4>(res)});
      chmax(ans,0);
      cout<<ans<<endl;
    };

    print();
  for(Int i=0;i<q;i++){
    Int k,x;
    cin>>k>>x;
    k--;
    seg.set_val(k,T(x,x,x,x,x));
    print();
  }
  return 0;
}



Measured memory_bytes: 17824
#include <iostream>
#include <stdlib.h>
//#include "lib/argsort.hpp"
using namespace std;

struct Data{
    int index;
    int value;
};

int compare_struct(const void *a, const void *b){
    struct Data *A = (struct Data *)a;
    struct Data *B = (struct Data *)b;
    return A->value - B->value;
}

int main(){
    
    int N;

    cin >> N;
    Data d[N];

    for(int i=0; i<N; i++){
        cin >> d[i].value;
    }

    for(int i=0; i<N; i++){
        d[i].index = i+1;
    }

    qsort(d, N, sizeof(struct Data), compare_struct);

    for(int i=0; i<N-1; i++){
        cout << d[i].index << " ";
    }
    cout << d[N-1].index << endl;
    return 0;
}

Measured memory_bytes: 1788
n, c, k = map(int, input().split())
t = [int(input()) for _ in range(n)]
t.sort()

num = t[0]
count = 1
ans = 0
for i in range(1, n):
    if t[i] <= num + k and count + 1 <= c:
        count += 1
    else:
        count = 1
        num = t[i]
        ans += 1

ans += 1
print(ans)

Measured memory_bytes: 7384
fn dfs(
    n: usize,
    lb: usize,
    ub: usize,
    target: &mut Vec<usize>,
    abcds: &Vec<(usize, usize, usize, usize)>,
) -> usize {
    // 集計
    if n == 0 {
        let mut res = 0;
        for e in abcds {
            if target[e.1] - target[e.0] == e.2 {
                res += e.3;
            }
        }
        return res;
    } else {
        let mut res = 0;
        for z in lb..ub + 1 {
            target.push(z);
            res = max(dfs(n - 1, z, ub, target, abcds), res);
            target.pop();
        }
        return res;
    }
}

fn solve() {
    let (n, m, q): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
    let mut abcds = vec![];
    for _ in 0..q {
        let (a, b, c): (usize, usize, usize) =
            (read::<usize>() - 1, read::<usize>() - 1, read::<usize>());
        let d: usize = read();
        abcds.push((a, b, c, d));
    }
    let mut target = Vec::with_capacity(n);
    println!("{}", dfs(n, 1, m, &mut target, &abcds));
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2200
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    string s;
    cin >> s;
    int N = s.size();
    if(s[0] == '0' || s[N-1] == '1'){
        cout << -1 << endl;
        return 0;
    }
    for(int i=0; i<N-1; i++){
        if(s[i] != s[N-2-i]){
            cout << -1 << endl;
            return 0;
        }
    }
    vector<pair<int, int>> edges;
    queue<int> pars;
    s[N-1] = '1';
    pars.push(0);
    for(int i=1; i<N; i++){
        if(s[i] == '1'){
            while(!pars.empty()){
                int x = pars.front();
                pars.pop();
                edges.push_back(make_pair(i, x));
            }
        }
        pars.push(i);
    }
    for(auto edge : edges)
        cout << edge.first+1 << " " << edge.second+1 << endl;
    return 0;
}

Measured memory_bytes: 2808
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
vector<char> pf(1000000, 1);
vector<int> prime;
int list[10000];
int main() {
	pf[0] = pf[1] = 0;
	for (int i = 2; i < 10000; i++) {
		if (!pf[i])continue;
		for (int j = 2 * i; j < 1000000; j += i)pf[j] = 0;
	}
	for (int i = 2; i < 1000000; i++) {
		if (pf[i])prime.push_back(i);
	}
	int n, p;
	while (cin >> n >> p, n!=-1) {
		auto ptr = lower_bound(prime.begin(), prime.end(),n+1);
		int cnt = 0;
		for (int i = 0; i < p; i++) {
			for (int j = i; j < p; j++) {
				list[cnt] = ptr[i] + ptr[j];
				cnt++;
			}
		}
		sort(list, list + cnt);
		cout << list[p - 1] << endl;
	}

}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

const int MAXN = 100000;
const ll MOD = 998244353;

int n, m;
char str[110][110];
int D[110][110];

int main(){
	scanf("%d%d",&n,&m);
	for (int i=0;i<n;i++) {
		scanf("%s",str[i]);
	}
	for (int i=0;i<n;i++) {
		for (int j=0;j<m;j++) {
			if (i==0&&j==0) {
				D[i][j] = (str[i][j]=='#');
				continue;
			}
			if (i==0) {
				D[i][j] = D[i][j-1]+(str[i][j]=='#'&&str[i][j-1]=='.');
				continue;
			}
			if (j==0) {
				D[i][j] = D[i-1][j]+(str[i][j]=='#'&&str[i-1][j]=='.');
				continue;
			}
			D[i][j] = min(D[i-1][j]+(str[i][j]=='#'&&str[i-1][j]=='.'),D[i][j-1]+(str[i][j]=='#'&&str[i][j-1]=='.'));
		}
	}
	printf("%d\n",D[n-1][m-1]);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << #x << ": " << x << '\n';
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  double a, b, x;
  cin >> a >> b >> x;
  double s = x / a;
  double rad, ans, h;
  if (s >= a * b / 2) {
    h = (a*b-s) * 2 / a;
    ans = atan2(h, a);
  } else {
    h = (2 * s) / b;
    ans = atan2(b, h);
  }
  double pi = acos(-1) * 2;
  double deg = ans/(pi) * 360;
  cout << deg << '\n';
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a[5];
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	int b=10,c,d=0;
	for(int i=0;i<5;i++){
		if(a[i]%10<b&&a[i]%10!=0){
			b=a[i]%10;
			c=a[i];
		}
		a[i]=((a[i]+9)/10)*10;
		d+=a[i];
	}
	cout<<d-((c+9)/10)*10+c<<endl;
	return 0;
}

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

struct UnionFind{
    vector<int> par;
    vector<int> sizes;

    UnionFind(){}
    UnionFind(int n):par(n),sizes(n,1){ rep(i,n)par[i]=i; }

    //find root of x
    int find(int x){
        if(x!=par[x]) par[x] = find(par[x]);
        return par[x];
    }

    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(int x,int y){ return find(x) == find(y); }
    int size(int x){ return sizes[find(x)]; }
};


typedef priority_queue<ll, vector<ll>, greater<ll> > PQ;
// typedef  PQP;
vector<ll> a;
vector<PQ> pq;
priority_queue<pair<int,int>> choose;
UnionFind uf;


// pqのサイズのどちらかが0ならimpossible
void merge(int x,int y){
    assert(!uf.same(x,y));
    x = uf.find(x);
    y = uf.find(y);
    if(pq[x].size() < pq[y].size()){
        swap(x,y);
    }

    while(pq[y].size()){
        pq[x].push(pq[y].top());
        pq[y].pop();
    }

    uf.unite(x,y);
    int z = uf.find(x);
    // ufのルートに合わせる
    if(z != x){
        assert(pq[z].size()==0);
        pq[z].swap(pq[x]);
    }
}

int main(void){
    int n,m;
    cin>>n>>m;
    a.resize(n);
    uf = UnionFind(n);
    pq.resize(n);
    rep(i,n) {
        cin>>a[i];
        pq[i].push(a[i]);
    }
    rep(_,m){
        int x,y;
        cin>>x>>y;
        merge(x,y);
    }

    rep(i,n){
        if(pq[i].size()){
            choose.push({pq[i].size(), i});
        }
    }

    ll res = 0;
    while(choose.size()>=2){
        int x = choose.top().second; choose.pop();
        int y = choose.top().second; choose.pop();
        if(pq[x].size()==0 || pq[y].size()==0){
            cout<<"Impossible"<<endl;
            return 0;   
        }
        res += pq[x].top() + pq[y].top();
        pq[x].pop(); pq[y].pop();
        merge(x,y);
        int z = uf.find(x);
        // if(pq[z].size()==0){
        //     if(uf.size(z) != n){
        //         cout<<"Impossible"<<endl;
        //         return 0;
        //     }
        //     break;
        // }
        choose.push({pq[z].size(), z});
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 10744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
ll N, A, B, C;
std::vector<long long> l(N+100);
bool graph[nmax][nmax];
ll ans = LONG_MAX;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll calc(vector<ll> v)
{
    ll cost = 0;
    ll a = 0, b = 0, c = 0;
    for (auto &&i : v)
    {
        switch (i)
        {
        case 1:
            if (a != 0)
                cost += 10;
            a += i;
            break;
        case 2:
            if (b != 0)
                cost += 10;
            b += i;
            break;
        case 3:
            if (c != 0)
                cost += 10;
            c += i;
            break;
        default:
            break;
        }
    }
    cost += abs(A - a);
    cost += abs(B - b);
    cost += abs(C - c);
    return cost;
}

int dfs(int n, int na, int a, int nb, int b, int nc, int c)
{
    if (n == N)
    {
        if (na == 0 || nb == 0 || nc == 0)
            return 1000000000;

        return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (na + nb + nc - 3);
    }

    int tmp1, tmp2, tmp3, tmp4;
    tmp1 = dfs(n + 1, na + 1, a + l[n], nb, b, nc, c);
    tmp2 = dfs(n + 1, na, a, nb + 1, b + l[n], nc, c);
    tmp3 = dfs(n + 1, na, a, nb, b, nc + 1, c + l[n]);
    tmp4 = dfs(n + 1, na, a, nb, b, nc, c);
    int ans;
    ans = min(min(min(tmp1,tmp2),tmp3),tmp4);
    return ans;
}

int main()
{
    scanf("%lld", &N);
    scanf("%lld", &A);
    scanf("%lld", &B);
    scanf("%lld", &C);

    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &l[i]);
    }
    cout << dfs(0, 0, 0, 0, 0, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100005];

bool cmp(int x,int y)
{
    return x>y;
}
int main()
{
    int i,j,m,n;
    ll b[5];
    ios::sync_with_stdio(false);
    while(cin>>m)
    {
        for(i=0;i<m;i++)
            cin>>a[i];
        sort(a,a+m,cmp);
        int count=0;
        for(i=0;i<m-1;i++)
        {
            if(a[i]==a[i+1]) b[count++]=a[i],i++;
            if(count==2) break;
        }
        if(count<2) cout<<0<<endl;
        else cout<<b[0]*b[1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> pii;
#define INF 0x3f3f3f3f
const int N = 300050;
int mod = 1000000007;
 
int main()
{
	//freopen("in.txt", "r", stdin);
	string s;
	while (cin >> s)
	{
		s[3] = '8';
		cout<<s<<endl;
	}
   	return 0;
}

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

#define int long long
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) otp(v[i]) cte
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n,l;
string s[100];

main() {
    cin >> n >> l;
    rep(i,n) cin >> s[i];
    sort(s,s+n);
    rep(i,n) otp(s[i])
    cte
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
int n, m;
vector<lint> x;
lint MOD = 1000000007;

lint calc(vector<lint> &vec)
{
    lint ans = 0;
    lint N = vec.size();
    for (lint i = 1; i < N; i++)
    {
        lint diff = (vec[i] - vec[i - 1]) % MOD;
        ans += diff * i * (N - i);
        ans %= MOD;
    }
    return ans;
}
int main()
{
    cin >> n >> m;
    x.resize(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    lint ans = calc(x);
    x.resize(m);
    for (int i = 0; i < m; i++) cin >> x[i];
    ans *= calc(x);
    cout << ans % MOD << endl;
}

Measured memory_bytes: 1792
###==================================================
### import
#import bisect
#from collections import Counter, deque, defaultdict
#from copy import deepcopy
#from functools import reduce, lru_cache
#from heapq import heappush, heappop
#import itertools
#import math
#import string
import sys
### stdin
def input(): return sys.stdin.readline().rstrip()
def iIn(): return int(input())
def iInM(): return map(int, input().split())
def iInM1(): return map(int1, input().split())
def iInLH(): return list(map(int, input().split()))
def iInLH1(): return list(map(int1, input().split()))
def iInLV(n): return [iIn() for _ in range(n)]
def iInLV1(n): return [iIn()-1 for _ in range(n)]
def iInLD(n): return [iInLH() for _ in range(n)]
def iInLD1(n): return [iInLH1() for _ in range(n)]
def sInLH(): return list(input().split())
def sInLV(n): return [input().rstrip('\n') for _ in range(n)]
def sInLD(n): return [sInLH() for _ in range(n)]
### stdout
def OutH(lst, deli=' '): print(deli.join(map(str, lst)))
def OutV(lst): print('\n'.join(map(str, lst)))
### setting
sys.setrecursionlimit(10 ** 6)
### utils
int1 = lambda x: int(x) - 1
### constants
INF = int(1e9)
MOD = 1000000007
dx = (-1, 0, 1, 0)
dy = (0, -1, 0, 1)
###---------------------------------------------------

N, A, B = iInM()

ans = 0
for n in range(1, N+1):
    var = sum(list(map(int, list(str(n)))))
    if var >= A and var <= B:
        ans += n

print(ans)


Measured memory_bytes: 74096
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int main(){
  long long A;
  long long V;
  long long B;
  long long W;
  long long T;
  rd(A);
  rd(V);
  rd(B);
  rd(W);
  rd(T);
  A =max_L(A-B, B-A);
  V -= W;
  if(A <= V*T){
    wt_L("YES");
    wt_L('\n');
  }
  else{
    wt_L("NO");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// {
//   ll A, V, B, W, T;
//   rd(A, V, B, W, T);
//   A = max(A-B, B-A);
//   V -= W;
//   wt(if[A <= V*T, "YES", "NO"]);
// }


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    int n;
    cin>>n;
    int dp[3];
    cin>>dp[0];
    cin>>dp[1];
    cin>>dp[2];
    for(int i=1;i<n;i++){
        int temp[3];
        cin>>temp[0];
        cin>>temp[1];
        cin>>temp[2];
        temp[0] = temp[0]+max(dp[1],dp[2]);
        temp[1] = temp[1]+max(dp[0],dp[2]);
        temp[2] = temp[2]+max(dp[1],dp[0]);
        dp[0]= temp[0];
        dp[1]= temp[1];
        dp[2]= temp[2]; 
    }
    cout<<max(dp[0],max(dp[1],dp[2]));
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>

using namespace std;

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;


int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);
	string s; cin >> s;
	sort(s.begin(), s.end());
	if(s == "abc") cout << "Yes\n";
	else cout << "No\n";
}





Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    string S;
    cin >> S;
    int ans = 0, N = S.size();
    for (int i = 1; i < N; i++) {
        if (S[i] != S[i - 1]) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3764
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;
double EPS = 1e-11;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.12lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

ll N, K;
vector<ll> E[100010];

ll dfs(ll now, ll from){
  ll res;
  if(from == -1){
    res = comb(K, E[now].size() + 1) * kai(E[now].size() + 1) % MOD;
  }else{
    res = comb(K-2, E[now].size() - 1) * kai(E[now].size() - 1) % MOD;
  }
  for(ll to: E[now])if(to != from){
    res *= dfs(to, now);
    res %= MOD;
  }
  return res;
}

void solve(){
  COMinit();
  cin >> N >> K;
  rep(i, N-1){
    ll a, b;
    cin >> a >> b;
    a--, b--;
    E[a].pb(b);
    E[b].pb(a);
  }
  ll ans = dfs(0, -1);
  cout << ans << endl;
}



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


Measured memory_bytes: 57728
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    int N;
    cin >> N;

    for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
            if (N == i*j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
a=input().strip()
b=input().strip()

if a==b:
  print("EQUAL")
elif len(a)>len(b):
  print("GREATER")
elif len(b)>len(a):
  print("LESS")
else: #same len
  for i in range(len(a)):
    if int(a[i])>int(b[i]):
      print("GREATER")
      sys.exit()
    elif int(a[i])<int(b[i]):
      print("LESS")
      sys.exit()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

// #define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


const int MAX_N = 110;
int d[MAX_N][MAX_N];

struct Edge {
    int x, y, z;
};

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, n) rep(j, n) d[i][j] = INF;
    rep(i, n) d[i][i] = 0;

    vector<Edge> es(m);
    rep(i, m) {
        int a, b, c;
        cin >> a>> b >> c;
        --a;
        --b;
        d[a][b] = d[b][a] = min(d[a][b], c);

        es[i] = {a, b, c};
    }



    rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    #ifdef DEBUG_MODE
    //DEBUG_2D
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) printf("%2d ",d[i][j] == INF ? -1 : d[i][j]);
        printf("\n");
    }
    #endif

    int ans = m;
    rep(k, m) {
        bool f = false;
        int x = es[k].x;
        int y = es[k].y;
        int z = es[k].z;
        // cout << x << " " << y << " " << z << endl;
        rep(i, n) rep(j, i) {
            f |= (d[i][j] == min(d[i][x] + d[y][j], d[i][y] + d[x][j]) + z);
        }
        if(f) --ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
      long long n,max=0,min=0,sum=0;
      cin >> n ;
      long long a[n];
      for(int i=0;i<n;i++){
            cin>>a[i];
            sum+=a[i];
            if(i==0){
                        max=a[i];
                        min=a[i];
            }
            if(a[i]>max)max=a[i];
            if(a[i]<min)min=a[i];
      }
      cout << min << " " << max << " " << sum << endl;
      return 0;
}
      




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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int a;
    string s;
    cin>>a>>s;
    cout<<(a>=3200?s:"red")<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{

        int H, W;

        while(1) {
                scanf("%d %d", &H, &W);

                if (H == 0 && W == 0) {
                        break;
                }

                for (int i = 0; i < H; i++) {
                        for (int j = 0; j < W; j++) {
                                printf("#");
                        }
                        printf("\n");
                }
                printf("\n");
        }
        return 0;
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  string s;
  cin >> s;
  int n = sz(s);
  char c = s[0];
  int ans = 0;
  REP(i,n) {
    if(s[i] != c) {
      ans++;
      c = s[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

int		main(void)
{
	string S;
	ll k;
	cin >> S >> k;

	ll o = 0;
	while (S[o] == '1')
		o++;
	if (k <= o)
		cout << S[0] << endl;
	else
	{
		if (S[0] != '1')
			cout << S[0] << endl;
		else
		{
			int i = 0;
			while (S[i] == '1')
				i++;
			if (i != (int)S.size())
				cout << S[i] << endl;
			else
				cout << 1 << endl;
		}
	}
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}



const int n_max = 200500;
vector<bool> visited(n_max, false);
vector<int> a;

void loop_search(int v, vector<int>& root, int &back){
    visited[v] = true;
    root.push_back(v);
    if (visited[a[v]] == true){
        back = a[v];
        return;
    } else {
        loop_search(a[v], root, back);
    }
    return;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    rep(i, n){ int tmp; cin >> tmp; a.push_back(tmp-1);}

    vector<int> root; //開始位置
    int back; //visitedで戻ったnode
    loop_search(0, root, back);

    // show(root);
    // cout << back << endl;

    ll back_no = 0;
    rep(i, root.size()){
        if (back == root[i]){
            back_no = i;            
        }
    }
    back_no++;

    int ans = 0;
    int len = root.size();
    ll loop_num = root.size()-back_no+1;

    // cout << endl;
    // cout << len << endl; //5
    // cout << back_no << endl; //3
    // cout << loop_num << endl; //2

    if (k >= (ll)root.size()){
        ll plus_loop = (k+1-back_no)%loop_num;
        // cout << plus_loop << endl;
        // cout << back_no+plus_loop-1 << "g"<< root[back_no+plus_loop-1]<< endl;
        ans = root[back_no+plus_loop-1];
    } else {
        ans = root[k];
    }

    if (a[0] == 0){
        cout << "1"<< endl;
        return 0;
    }

    cout << ans+1 << endl;

}



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

typedef long long ll;
const int MAX_N = 200030;    // Change as necessary
const ll  MODD = 1000000009; //

int A[MAX_N];
/*
int med(int a,int b,int c){
  vector<int> A = {a,b,c};
  sort(A.begin(),A.end());
  return A[1];
}

int simulate(vector<int> v){
  while(true){
    vector<int> next(v.size()-2);
    for(int i=0;i<next.size();i++)
      next[i] = med(last[i],last[i+1],last[i+2]);
    for(int i=0;i<next.size();i++)
      cout << next[i] << endl;
    if(next.size() == 1)
        return next[0];
    v = next;
  }
}*/

bool used[MAX_N];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int N,x; cin >> N >> x;
  if(x == 1 || x == 2*N-1){ cout << "No" << endl; return 0; }
  cout << "Yes" << endl;
  
  used[1] = used[2*N-1] = used[x] = true;
  
  vector<int> v(2*N-1);
  
  v[N-1] = x;
  v[N-2] = 1;
  v[N] = 2*N-1;
  
  int idx = 1;
  for(int i=0;i<2*N-1;i++)
    if(v[i] == 0){
      while(used[idx]) idx++;
      v[i] = idx;
      used[idx] = true;
    }
  
  for(int i=0;i<2*N-1;i++)
    cout << v[i] << "\n";
  return 0;
}


Measured memory_bytes: 2560