akhauriyash/Code-Regression huggingface dataset:
import sys
fin = sys.stdin.readline
from collections import defaultdict, Counter
from bisect import bisect


possible_pows = []
cur_pow = 2
for i in range(32):
    possible_pows.append(cur_pow)
    cur_pow *= 2
assert possible_pows[-1] == 2**32


N = int(fin())
A_list = [int(elem) for elem in fin().split()]
A_list.sort(reverse=True)
rest = Counter(A_list)
num_pairs = 0
for A in A_list:
    idx = bisect(possible_pows, A)
    complement = possible_pows[idx] - A
    if rest[complement] > 0:
        if complement == A and rest[A] >= 2:
            rest[complement] -= 1
            num_pairs += 1
        elif complement != A and rest[A] >= 1:
            rest[complement] -= 1
            num_pairs += 1
    rest[A] -= 1
print(num_pairs)


Measured memory_bytes: 103508
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

/*
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()
*/

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

void solve() {
    ll r;
    cin >> r;
    string s;
    if(r < 1200) s = "ABC";
    else if(r < 2800) s = "ARC";
    else s = "AGC";
    cout << s << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

n = int(input())

answer = 0.0

for i in range(1,n+1):
  
  for j in range(1,n+1):
    
    for h in range(1,n+1):
      f = gcd(i,j,h)
      answer += f
      
print(int(answer))

Measured memory_bytes: 75100
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000000
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll S;
    cin >> S;
    ll x1, y1, x2, y2;
    if (S % mod == 0) {
        x1 = mod;
        y1 = mod;
        x2 = 0;
        y2 = S / mod;
    }
    else {
        ll r = S % mod;
        y1 = 1;
        x2 = mod - r;
        x1 = mod;
        y2 = (S + mod - r) / mod;
    }
    cout << 0 << " " << 0 << " " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
from sys import stdin, stdout
s = stdin.readline()

# ans= 0
# for i, char in enumerate(s):
#     if i+1<len(s):
#         if s[i] == 'P' and s[i+1] == 'D':
#             ans += 1
    
#     if s[i] == '?' or s[i] == 'D':
#         ans += 1
# print(ans)

print(s.replace('?', 'D'))


Measured memory_bytes: 9424
#include <bits/stdc++.h>
using namespace std;
long long ans = 0;

void cnt(int n){
    int a = pow(10, n) - 1, b = pow(10, n - 1) - 1;
    if(n % 2 == 0){
        return;
    }
    ans += a - b;
    return;
}

int main(){
    int N;
    string M;
    cin >> N;
    M = to_string(N);
    int n = M.length() - 1;
    for(int i = n; i > 0; --i){
        cnt(i);
    }
    if((n + 1) % 2 == 1){
        ans += N - pow(10, n) + 1;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n;
    long long x;
    cin >> n >> x;
    long long a[n] = {};
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    long long tmp =0;
    int ans = 0;
    for(int i=0; i<n; i++){
        tmp += a[i];
        if(tmp < x && i!=n-1){
            ans++;
        }else if(tmp == x){
            ans++;
        }    
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
// Created by PRATEEK RANJAN
#include <bits/stdc++.h>
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int long long
const int mod = 1e9+7;

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,m,ans=0;
    cin>>n>>m;
    if(m<=n*2){
        ans = m/2;
    }
    else{
        m = m-(n*2);
        ans+=n;
        ans += (m/4);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

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

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

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

	cout << max(0, c - (a - b)) << '\n';



	return 0;
}

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

int main()
{
  string a, b;
  cin >> a >> b;

  if (a.size() > b.size()) cout << "GREATER" << endl;
  else if (a.size() < b.size()) cout << "LESS" << endl;
  else {
    for (int i = 0; i < (int)a.size(); i++) {
      if (a[i] > b[i]) {
        cout << "GREATER" << endl;
        break;
      }
      else if (a[i] < b[i]) {
        cout << "LESS" << endl;
        break;
      }
      else if (i + 1 == (int)a.size()) cout << "EQUAL" << endl;
    }
  }
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		int n;
		Scanner sc = new Scanner(System.in);
		Prime p = new Prime();
		
		while(sc.hasNext()){
			n = sc.nextInt();
			System.out.println(p.getBeforePrime(n)+" "+p.getAfterPrime());
		}
	}
}

class Prime{
	private ArrayList<Integer> prime;
	private int index;
	private boolean f;
	
	Prime(){
		prime = new ArrayList<Integer>();
		setPrime();
	}
	
	public int getBeforePrime(int n){
		index = 0;
		f = false;
		
		for(int i=0;i<prime.size();i++){
			index = i;
			if(n < prime.get(index)){
				break;
			}else if(n == prime.get(index)){
				f = true;
				break;
			}
		}
		
		return prime.get(index-1);
	}
	
	public int getAfterPrime(){
		if(f){
			return prime.get(index+1);
		}
		return prime.get(index);
	}
	
	private void setPrime(){
		int counter = 0;
		int index = 2;
		
		prime.add(2);
		prime.add(3);

		for (int n=5;n<=50021;n+=2) {
			boolean flag = true;
			for (int i=1;prime.get(i)*prime.get(i)<=n;i++) {
				counter +=2;
				if (0 == n%prime.get(i)) {
					flag = false;
					break;
				}
			}
			if (flag) {
				prime.add(n);
				counter++;
			}
		}
		
	}
}

Measured memory_bytes: 20460
n,k,c = map(int,input().split())
s = input()

ANS = [0] * n
A = [0] * n
B = []
NX = [10**8] * n
kk = k
for i in range(n):
    if kk == 0:
        break
    if s[i] == "o" and (len(B) == 0 or i > B[-1]+c):
        A[i] = 1
        ANS[i] = 1
        B.append(i)
        kk -= 1

nx = 10**8
for i in range(n-1,-1,-1):
    if A[i] == 1:
        nx = i
    NX[i] = nx

# print(B)
# print(NX)

bf = 10**8
nx = 10**8
for i in range(n-1,-1,-1):
    # print(i, NX[i],nx)
    if A[i] == 1:
        nx = i
    if s[i] == "o" and A[i] == 0 and nx-i > c:
        # print("ok",i)
        nx = i
        bf = min(bf, i) - 1
        # print("bf s",bf)
        while bf >= 0 and A[bf] == 0:
            bf -= 1
        # print("bf",bf)
        if bf >= 0:
            A[bf] = 0
            ANS[bf] = 0
            A[i] = 1
        # print(A)

# print(ANS)
for i in range(len(ANS)):
    if ANS[i] == 1:
        print(i+1)


Measured memory_bytes: 57952
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
      string s;
      cin>>s;
      int ans=0;
      for(int i=0;i<s.length()-1;i++)
                if(s[i]!=s[i+1])
                    ans++;
                printf("%d\n",ans);
                return 0;

}


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

int main() {
  int N, H, W;
  cin >> N >> H >> W;
  int A[N], B[N];
  int ita =0;
  
  for(int i=0; i<N; i++) {
    cin>> A[i] >> B[i];
    if(A[i] >= H && B[i] >= W) ita++;
  } 
    cout << ita << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)

using namespace std;

int main(void){
    
    int number;
    int hen[3];
    int temp;
    cin >> number;
    bool judge[1020];
    
    REP(i,number)
    {
        REP(i, 3)
        cin >> hen[i];
        REP(i, 2)
        REP(j, 2)
        {
            if(hen[j] < hen[j+1])
            {
                temp = hen[j+1];
                hen[j+1] = hen[j];
                hen[j] = temp;
            }
        }
        if(hen[0]*hen[0] == (hen[1]*hen[1] + hen[2]*hen[2]))
            judge[i] = true;
        else
            judge[i] = false;
        
    }
    REP(i, number)
    {
        if(judge[i])
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
  
    
    return 0;
}

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

int Search(int S[], int n, int key) {
    int i=0;
    S[n]=key;
    while(S[i]!=key)i++;
    return i;
}

int main() {
    int n, S[10010], q, key, sum = 0;
    cin>>n;
    for(int i=0; i<n; i++)scanf("%d", &S[i]);

    cin>>q;
    for(int i=0; i<q; i++) {
        scanf("%d", &key);
        if(Search(S, n, key)!=n)sum++;
    }
    cout<<sum<<endl;

    return 0;
}



Measured memory_bytes: 3212
#include<iostream>
using namespace std;
int main(){
    int a,b;
    while(true){
        cin>>a>>b;
        if(a==0&&b==0)
         break;
        if(a>b)
         cout<<b<<" "<<a<<endl;
         else
         cout<<a<<" "<<b<<endl;
        
    }
    return 0;
}



Measured memory_bytes: 3092
using System;
using System.Collections;
using System.Linq;


public class ABC077_sunukefes
{
	public static void Main()
	{
        int N = int.Parse(Console.ReadLine());
        int[] upper = new int[N];
        int[] mid = new int[N];
        int[] lower = new int[N];
        long ans = 0;

        string[] str = Console.ReadLine().Split(' ');
        for(int i = 0; i < N ; i++){
            upper[i] = int.Parse(str[i]);
        }
        Array.Sort(upper);

        str = Console.ReadLine().Split(' ');
        for(int i = 0; i < N ; i++){
            mid[i] = int.Parse(str[i]);
        }
        Array.Sort(mid);

        str = Console.ReadLine().Split(' ');
        for(int i = 0; i < N ; i++){
            lower[i] = int.Parse(str[i]);
        }
        Array.Sort(lower);

        long a = 0;
        long b = 0;
        int key;
        for(int i = 0 ; i < N ; i++){
            key = mid[i];
            a = upperBinarySearch(lower, key);
            b = lowerBinarySearch(upper, key);
      
            ans += a*b;
        }
        
        
        Console.WriteLine(ans);
	}
    
    
    public static int upperBinarySearch(int[] A , int key){
        int left = 0;
        int right = A.Length;

        while(left < right) {
                int mid = (left + right) / 2;
                if (key < A[mid]){
                    right = mid;
                } else {
                    left = mid +1;
                }
        }
        return A.Length - right;
    }
    
    
    public static int lowerBinarySearch(int[] A , int key){
        int left = 0;
        int right = A.Length;

        while(left < right) {
            int mid = (left + right) / 2;
            if (key <= A[mid]){
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        return left;
    }
}

Measured memory_bytes: 40272
/*
 * atcoder/abc127/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * 1 2 3
 *   2 3 4
 *     3 4 5
 *       4 5 6
 */

struct G {
  int l, r;
  bool operator<(const G& a)const{
    return l == a.l ? r < a.r : l < a.l;
  }
};

int N, M;
G gs[100001];

void solve() {
  cin >> N >> M;
  int x, y;
  loop(m,0,M) {
    cin >> x >> y;
    gs[m] = (G){ x, y };
  }

  sort(gs, gs+M);
  if (gs[0].r < gs[M-1].l) {
    cout << 0 << endl;
    return;
  }

  int max_l = 0, min_r = 1000000;
  loop(m,0,M) {
    chmax(max_l, gs[m].l);
    chmin(min_r, gs[m].r);
  }
  cout << min_r - max_l + 1 << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 1024
#include <map>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N, P;
string S;
vector<int> vec;
map < string, vector<pair<int, int> > > mmap;
int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> S >> P;
		mmap[S].push_back(make_pair(P, i));
	}
	for (auto it = mmap.begin(); it != mmap.end(); it++) {
		sort(it->second.rbegin(), it->second.rend());
	}
	for (auto it = mmap.begin(); it != mmap.end(); it++) {
		for (pair<int, int> item : it->second) {
			cout << item.second << endl;
		}
	}
	return 0;
}

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

int arr[100005][3];
ll sol[100005][3];

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

    ll n; cin >> n;
    for(ll i=0; i<n; i++){
        for(ll ii=0; ii<3; ii++){
            cin >> arr[i][ii];
        }
    }
    sol[0][0] = arr[0][0];
    sol[0][1] = arr[0][1];
    sol[0][2] = arr[0][2];

    ll maxi = max(arr[0][0],max(arr[0][1],arr[0][2]));
    for(ll i=1; i<n; i++){
        for(ll ii=0; ii<3; ii++){
            maxi = 0;
            for(ll x=0; x<3; x++){
                if(x == ii) continue;

                maxi = max(maxi,arr[i][ii] + sol[i-1][x]);
            }
            sol[i][ii] = maxi;
        }
    }




    cout << max(sol[n-1][0],max(sol[n-1][1],sol[n-1][2]));



    return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=100001 ;
int main()
{
   fast ;
   ll n,a,b ;
   cin>>n>>a>>b ;
   vector<ll>h(n) ;
   for(ll i=0;i<n;i++)
    cin>>h[i] ;

   ll lo=0,hi=1e10 ;
   ll ans=hi ;
   while(lo<=hi)
   {
       ll mi=(lo+hi)/2 ;
       ll cnt=mi ;
       for(ll i=0;i<n;i++)
       {
           ll fr=mi*b ;
           if(fr<h[i])
           {
               ll x=(h[i]-fr)/(a-b) ;
               if((h[i]-fr)%(a-b)!=0)
                x++ ;

               if(cnt>=x)
                cnt-=x ;
               else
               {
                   cnt=-1 ;
                   break ;
               }
           }
       }
       if(cnt>=0)
       {
           ans=mi ;
           hi=mi-1 ;
       }
       else
       {
           lo=mi+1 ;

       }
   }
   cout<<ans ;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  
  int count=0;
  int ans=0;
   for(int i=0;i<S.size();i++){
     if(S.at(i)=='A'||S.at(i)=='C'||S.at(i)=='G'||S.at(i)=='T'){
       count++;
       ans=max(count,ans);
     }else{
       count=0;
     }
   }
    cout << ans << endl;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

//Appropriately Changed
using W = ll;
using edge = struct {int to; W cost;};
using G = vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph, int from, int to, W cost) {
	graph[from].push_back({to, cost});
	graph[to].push_back({from, cost});
}


auto dijkstra(const G &graph, int s) {
	const W inf = 1LL << 60;
	const int n = graph.size();

	vector<W> dist(n, inf);
	using state = tuple<W, int>;

	priority_queue<state, vector<state>, greater<state>> q;
	dist[s] = 0, q.push(state(0, s));

	while (!q.empty()) {
		W c; int v;
		tie(c, v) = q.top(); q.pop();
		for (auto &e : graph[v]) {
			W nc = c + e.cost; int nv = e.to;
			if (chmin(dist[nv], nc)) q.push(state(nc, nv));
		}
	}
	return dist;
}

int main(void) {
	int n, m, s, t;
	cin >> n >> m >> s >> t, s--, t--;

	G graph(n);

	rep(i, m) {
		int a, b, c;
		ll d;
		cin >> a >> b >> c >> d;
		a--, b--, c--;
		add_edge(graph,a, b, d);
		add_edge(graph,a, c, d);
		add_edge(graph,b, c, d);
	}

	auto dist = dijkstra(graph, s);
	cout << dist[t] << endl;

	return 0;
}


Measured memory_bytes: 23644
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> x(n) ,y(n);
    cin >> x[0] >> y[0];
    int mod = abs(x[0]+y[0])%2;
    bool f = false;
    
    reps(i,1,n){
        cin >> x[i] >> y[i];
        if(abs(x[i]+y[i])%2 != mod){
            f = true;
            break;
        }
    }
    
    if(f) cout << -1 << endl;
    else{
        cout << 32 - mod << endl;
        rep(i,31) cout << (int)pow(2,i) << " ";
        if(mod == 0) cout << 1 ;
        cout << "" << endl;
        vector<bool> u(31),v(31);
        rep(i,n){
            if(mod == 0) x[i]--;
            rep(j,31)u[j] = v[j] = false;
            rep(j,31){
                if((
                        ((x[i]+y[i]-1)/2+(int)pow(2,30)) >> j
                )&1) u[j] = true;
                if((
                        ((x[i]-y[i]-1)/2+(int)pow(2,30)) >> j
                )&1) v[j] = true;
            }
            rep(j,31){
                if(u[j] && v[j]) cout << "R";
                if(u[j] && !v[j]) cout << "U";
                if(!u[j] && v[j]) cout << "D";
                if(!u[j] && !v[j]) cout << "L";
            }
            if(mod == 0) cout << "R";
            cout << endl;
        }
    }

    return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;
    int x[h+5][w+5];
    string y;
    for ( int i = 0; i < h+2; i++){
        if (i!=0 and i!=h+1){
            cin >> y;
            x[i][0] = 0;
            x[i][w+1] = 0;
        }else{
            for (int k = 0; k < w+2; k++){
                x[i][k] = 0;
            }
            continue;
        }
        for ( int k = 0; k < w+2; k++){
            if (y[k]=='#') x[i][k+1] = 1; //fill
            else x[i][k+1] = 0;
        }
    }

    bool end_flag = false;
    for ( int i = 0; i < h+2; i++){
        for ( int k = 0; k < w+2; k++){
            if (x[i][k]==1 and x[i-1][k]==0 and x[i][k-1]==0 and x[i][k+1]==0 and x[i+1][k]==0){
                cout << "No" << endl;
                end_flag = true;
            }
            if (end_flag == true) break;
        }
        if (end_flag == true) break;
    }
    if ( end_flag == false ) cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define INF 2000000000
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if((c-a-b)*(c-a-b)>4*a*b&&c>a+b)cout<<"Yes";
    else cout<<"No";
    cout<<endl;
    
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define vint vector<int>
#define vll vector<ll>
#define vstr vector<string>
#define vbl vector<bool>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}
#pragma endregion template

void solve(ll N, ll D, vector<vector<ll>> X) {
  ll cnt = 0;
  rep(i, N - 1) {
    rep2(j, i + 1, N - 1) {
        double distance = 0;
        rep(k, D) {
          distance += pow(X.at(i).at(k) - X.at(j).at(k), 2);
        }
        distance = sqrt(distance);
        cnt += (distance - floor(distance) == 0);
    }
  }

  cout << cnt << endl;
}

int main() {
  ll N;
  ignore_ret(scanf("%lld",&N));
  ll D;
  ignore_ret(scanf("%lld",&D));
  vector<vector<ll>> X(N, vector<ll>(D));
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < D ; j++){
      ignore_ret(scanf("%lld",&X[i][j]));
    }
  }
  solve(N, D, move(X));
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long[] sum = new long[n + 1];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
			sum[i + 1] = sum[i] + a[i];
		}

		long[][] dp = new long[n + 1][n + 1];
		for (int i = 0; i <= n; i++) {
			Arrays.fill(dp[i], Long.MAX_VALUE / 3);
		}

		for (int i = 0; i < n; i++) {
			dp[i][i + 1] = a[i]; // last: (n-1, n)
		}

		for (int d = 2; d <= n; d++) {
			for (int l = 0; l < n; l++) {
				int r = Math.min(l + d, n);

				for (int x = 1; (l + x) <= r; x++) {
					long cl = dp[l][l + x] + (sum[l + x] - sum[l]);
					long cr = dp[l + x][r] + (sum[r] - sum[l + x]);
					dp[l][r] = Math.min(dp[l][r], cl + cr);
				}
			}
		}

		System.out.println(dp[0][n] - sum[n]);
	}
}


Measured memory_bytes: 24788
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
  ll x, y; cin >> x >> y;
  int cnt=0;
  while(x <= y){
    x = x*2;
    cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,d,x[15][15],i,k,j,a,b,c=0;
	cin>>n>>d;
	for(i=0;i<n;i++)
	{
		for(j=0;j<d;j++)
		{
			cin>>x[i][j];
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
		{
			a=0;
			for(k=0;k<d;k++)
			{
				a+=pow(x[j][k]-x[i][k],2);
			}
			if(sqrt(a)==floor(sqrt(a)))
			{
				c++;
			}
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

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

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    int n; cin >> n;
    std::vector<ll> left(n); REP(i,n) cin >> left[i];
    std::vector<ll> right(n); REP(i,n) cin >> right[i];

    std::vector<ll> l(n,0); l[0] = left[0];
    std::vector<ll> r(n,0); r[n-1] = right[n-1];
    for(int i=1; i<n;++i){
        if(left[i] != left[i-1]) l[i] = left[i];
        if(right[n-i] != right[n-i-1]) r[n-i-1] = right[n-i-1];
    }

    int ans = 1;

    // REP(i,n) cout << l[i] << " ";
    // cout << '\n';
    //
    // REP(i,n) cout << r[i] << " ";
    // cout << '\n';

    REP(i,n){
        if(l[i]!=r[i] && r[i]!=0 && l[i]!=0){
            cout << 0 << endl; return 0;
        }

        if(r[i]!=0 && left[i]<r[i]){
            cout << 0 << endl; return 0;
        }

        if(l[i]!=0 && right[i]<l[i]){
            cout << 0 << endl; return 0;
        }
    }

    REP(i,n){
        if(l[i]==0LL && r[i]==0LL){
            ans = ans * min(left[i], right[i]) % MOD;
        }
    }

    cout << ans << endl;





    return 0;
}


Measured memory_bytes: 3456
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int N,D;
vi A;
int sum;
int res;

signed main(){

    in(N,D);
    A.resize(N);
    in(A);
    for(auto e:A){
        // show(e,(e-1)%(D+1));
        sum+=e;
        res^=(e-1)%(D+1);
    }

    // if(D==1){
    //     puts(sum&1?"Second":"First");
    //     return 0;
    // }

    puts(res==0?"Second":"First");

    return 0;
}



Measured memory_bytes: 4756
#include<iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    unsigned long long int n;
    cin>>n;
    char index;
    for(int i=0;i<s.size()&&n>0;i++)
    {
        if(s[i]=='1'){
            index=s[i];
            n--;
            continue;
        }
        else
        {
            index=s[i];
            break;
        }
    }
    cout<<index;
}

Measured memory_bytes: 3596
// Problem : C - Peaks
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>

using namespace std;

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	
	int mx[n + 10], h[n + 10];
	
	fill(mx, mx + n + 1, 0);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &h[i]);
		// mx[i] = 0;
	}
	h[0] = 0;
	
	for(int i = 0; i < m ;i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		mx[a] = max(mx[a], h[b]);
		mx[b] = max(mx[b], h[a]);
		// mx[b] = max(mx[b], h[b]);
	}
	int cnt = 0;
	for(int i = 1 ; i <= n; i++) {
		cnt += h[i] > mx[i];
	}
	printf("%d", cnt);
	return 0;
}


Measured memory_bytes: 4512
Q,H,S,D=map(int,input().split())
N=4*int(input())
digs=[(1,Q)]
if H<2*Q:
    digs.append((2,H))
if S<4*Q and S<2*H:
    digs.append((4,S))
if D<8*Q and D<4*H and D<2*S:
    digs.append((8,D))
ans=0
for d,p in reversed(digs):
    ans+=p*(N//d)
    N=N%d
print(ans)

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

using v1 = vector<int>;
using v2 = vector<vector<int>>;
using ll = long long;

int main(){
	string s;
	cin >> s;
	ll size_s = s.size();
	for(int i = 0; i<size_s; i++){
		if(s.at(i) == '?'){
			s.at(i) += 5;
		}
	}
	cout << s << endl;
}


Measured memory_bytes: 3724
N = int(input())
A = list(map(int,input().split()))
mini = 1000000001
zero = 0
wa = 0
for n in range(N):
	a = abs(A[n])
	mini = min(mini, a)
	wa += a
	if A[n] < 0:
		zero += 1
if zero % 2 == 1:
	print(wa - mini * 2)
else:
	print(wa)

Measured memory_bytes: 14228
#include <math.h>
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <iostream>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;


int main()
{
    int N, M;
    cin >> N >> M;
    map<int, set<pair<int, int>>> OUT;
    map<int, set<int>> IN;
    set<int> start;
    FOR (i,0,N){
        start.insert(i);
    }
    FOR(i,0,N+M-1){
        int a, b;
        cin >> a >> b;
        start.erase(b - 1);
        OUT[a - 1].insert(make_pair(i, b - 1));
        IN[b - 1].insert(i);
    }
    vector<int> P(N, 0);
    while (start.size()>0){
        int now = *start.begin();
        start.erase(now);
        for (auto x:OUT[now]){
            int b = x.first;
            int nex = x.second;
            IN[nex].erase(b);
            if (IN[nex].size()==0){
                start.insert(nex);
                P[nex] = now + 1;
            }
        }
    }
    FOR(i,0,N){
        cout << P[i] << endl;
    }
}


Measured memory_bytes: 29312
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int K;
int X;
int ress;
int res[200];
int main(){
  int i;
  rd(K);
  rd(X);
  for(i=(X-K+1);i<(X+K);i++){
    res[ress++] = i;
  }
  {
    int Lj4PdHRW;
    if(ress==0){
      putchar_unlocked('\n');
    }
    else{
      for(Lj4PdHRW=0;Lj4PdHRW<(ress-1);Lj4PdHRW++){
        wt_L(res[Lj4PdHRW]);
        wt_L(' ');
      }
      wt_L(res[Lj4PdHRW]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190820-1

// --- original code ---
// int K, X;
// int ress, res[200];
// {
//   rd(K,X);
//   rep(i,X-K+1,X+K) res[ress++] = i;
//   wt(res(ress));
// }


Measured memory_bytes: 256
# coding:utf-8
import numpy as np
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
dp = [[0 for i in range(3)] for j in range(n+1)]

#後者が前者よりも大きい時に更新→DPテーブルを-infに初期化
def chmax(a,b):
    if(a< b):
        return b
    else:
        return a

def main():
    #参照するdpテーブルの番号
    for i in range(n):
        #過去にどの手を出しているか
        for j in range(3):
            #次の遷移先
            for k in range(3):
                if (j == k):
                    continue
                else:
                    dp[i+1][k] = chmax(dp[i+1][k], dp[i][j]+ a[i][k])

    res = 0
    for i in range(3):
        res = chmax(res, dp[n][i])

    print(res)

if __name__ == '__main__' :
    main()


Measured memory_bytes: 56468
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
   
using namespace std;
   
static const double PI = acos(-1.0);
   
class Vec2
{
public:
    Vec2( double _x, double _y ) : x(_x), y(_y) {}
   
    double length() const { return sqrt(x*x + y*y); }
    double arg() const {
        if ( length() == 0 ) return 0.0;
        return atan2(y, x);
    }
    Vec2 normalize() const {
        if ( length() == 0 ) return *this;
        return Vec2(x/length(), y/length());
    }
   
    Vec2 operator+( const Vec2& rhs ) const { return Vec2(x+rhs.x, y+rhs.y); }
    Vec2 operator-( const Vec2& rhs ) const { return Vec2(x-rhs.x, y-rhs.y); }
    Vec2 operator*( double s ) const { return Vec2(x*s, y*s); }
    double dot( const Vec2& rhs ) const { return x*rhs.x + y*rhs.y; }
    double cross( const Vec2& rhs ) const { return x*rhs.y - y*rhs.x; }
   
private:
    double x;
    double y;
};
   
double DiffAngle( const Vec2& A, const Vec2& B )
{
    double d = fabs(A.arg()-B.arg());
    if ( d > PI ) d = 2*PI-d;
    return d;
}
   
vector<Vec2> IntSegCircle( const Vec2& A, const Vec2& B, double r )
{
    vector<Vec2> IntPoint;
    Vec2 D = B - A;
    Vec2 DU = D.normalize();
    Vec2 H = A - DU*(A.dot(DU));
    double h = H.length();
    if ( h >= r )
        return vector<Vec2>();
   
    double l = sqrt(r*r - h*h);
    double pa = (A-H).dot(DU), pb = (B-H).dot(DU);
    if ( pa < -l && -l < pb ) {
        IntPoint.push_back(H - DU*l);
    }
    if ( pa < l && l < pb ) {
        IntPoint.push_back(H + DU*l);
    }
    return IntPoint;
}
   
double IntTriCircle( const Vec2& A, const Vec2& B, double r )
{
    vector<Vec2> Int = IntSegCircle( A, B, r );
    if ( Int.empty() ) {
        return min( 0.5*r*r*DiffAngle(A,B), 0.5*A.length()*B.length()*sin(DiffAngle(A,B)) );
    } else if ( Int.size() == 1 ) {
        double area = 0.0;
        if ( A.length() > r ) {
            area += 0.5*r*r*DiffAngle(A,Int[0]);
        } else {
            area += 0.5*A.length()*r*sin(DiffAngle(A,Int[0]));
        }
        if ( B.length() > r ) {
            area += 0.5*r*r*DiffAngle(B,Int[0]);
        } else {
            area += 0.5*B.length()*r*sin(DiffAngle(B,Int[0]));
        }
        return area;
    } else {
        return 0.5*r*r*(sin(DiffAngle(Int[0],Int[1])) + DiffAngle(A,B) - DiffAngle(Int[0],Int[1]));
    }
}
   
double solve( int R, const vector<Vec2>& Poly )
{
    double area = 0.0;
    for ( size_t i = 0; i < Poly.size()-1; i++ ) {
        double coef = Poly[i].cross(Poly[i+1]) > 0 ? 1.0 : -1.0;
        area += coef * fabs(IntTriCircle(Poly[i], Poly[i+1], R));
    }
    return area;
}
   
int main()
{
    int N, R;
    cin >> N >> R;
   
    vector<Vec2> Poly;
    for ( int i = 0; i < N; i++ ) {
        double x, y;
        cin >> x >> y;
        Poly.push_back( Vec2(x,y) );
    }
    Poly.push_back( Poly.front() );
   
    printf( "%.10f\n", solve( R, Poly ) );
    return 0;
}


Measured memory_bytes: 3652
#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<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;

int main(){
  int n,m; cin >> n >> m;
  int left = 1, right = n;
  for(int i = 0; i < m; i++){
    int a,b; cin >> a >> b;
    left = max(left, a);
    right = min(right, b);
  }
  int ans = right - left + 1;
  if(ans < 0) ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <set>

using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)
typedef vector<DT> vec;
typedef list<DT> li;



int main() {
	ifstream fin("Text.txt");
	int i, j, k, t;
	DT n, x;
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1)
		cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		k = 2 * n - 1;
		forc(i, 1, k) {
			t= (i-((k+1)/2-x) <=0 ? i - ((k + 1) / 2 - x) +k : i - ((k + 1) / 2 - x));
			if (t > k)
				t -= k;
			cout << t << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n,k;
	cin>>n>>k;
	long double ans=0.0;
	for(int i=1;i<=n;i++){
			long double a=1.0/n;
			ll num=i;
			while(num<k){
				num*=2;
				a*=0.5;
			}
			ans+=a;
	}
	cout<<fixed<<setprecision(20)<<ans<<endl;
	return 0;
}

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

using namespace std;


int main() {

    long long int n;
    long long int ans = 0;

    cin >> n;

    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) {

        } else {
            ans += i;
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
template <typename T>
vector<T> divisor(T n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}
template <typename T>
map<T, int> prime_factor(T n) {
    map<T, int> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if (n != 1) {
        res[n]++;
    }
    return res;
}
template <typename T>
T gcd(T a, T b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    auto d = divisor(accumulate(a.begin(),a.end(),0LL));
    reverse(d.begin(), d.end());
    for(ll x : d){
        vector<ll>b(n);
        rep(i,n)b[i] = a[i] % x;
        ll sum = accumulate(b.begin(), b.end(), 0LL);
        if(sum % x)continue;
        ll num = 1LL<<60;
        ll s = 0;
        sort(b.begin(),b.end());
        rep(i,n){
            s += b[i];
            if(s == (n-1-i)*x-(sum - s)){
                num = min(num, s);
            }
        }
        if(num <= k){
            cout << x << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
from itertools import permutations
n = int(input())
plots = [0] * n
for i in range(n):
    x, y = map(int, input().split())
    plots[i] = (x, y)

roots = list(permutations(range(n)))
tmp = 0
for root in roots:
    for i in range(n-1):
        tmp += ((plots[root[i]][0] - plots[root[i + 1]][0]) ** 2 + (plots[root[i]][1] - plots[root[i + 1]][1]) ** 2) ** 0.5

print(tmp / len(roots))

Measured memory_bytes: 10100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef set<ll> sl;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int n;
	cin >> n;
	if(n == 3) {
		cout << "2 5 63" << endl;
		return 0;
	}
	int even[8] = {2, 10, 3, 9, 4, 8, 6, 12};
	int odd[8] = {6, 2, 10, 3, 9, 4, 8, 12};
	if(n%2) {
		rep(i,0,n) {
			cout << i/8 * 12 + odd[i%8] << ' ';
		}
	} else {
		rep(i,0,n) {
			cout << i/8 * 12 + even[i%8] << ' ';
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, t;
    cin >> a >> b >> t;
    cout << t / a * b << endl;
    return 0;
}



Measured memory_bytes: 256