akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n), b(n);
    for(ll i=0;i<n;++i){
        cin>>a[i]>>b[i];
    }

    ll ans = 0;
    for(ll i=0;i<n;++i){
        ll shou = (a[n-i-1] + ans) / b[n-i-1];
        ll amari = (a[n-i-1] + ans) - b[n-i-1] * shou;
        if(amari == 0){
            continue;
        }
        ll fl = b[n-i-1] - amari;
        ans += fl;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(void){
  int N, X;
  cin >> N >> X;
  int s = 0, M = 1000000;
  vector<int> m(101);
  for(int i = 0; i < N; i++){
    cin >> m[i];
    s += m[i];
    if(m[i] < M){
      M = m[i];
    }
  }
  int ans = N + (X - s) / M;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<iostream>

int adjacive[100][100][2];
const int INF=1000000000;

int dijkstra(int start,int goal,int type,int num);

int main()
{
	while(1)
	{
		int n,m,k;
		
		std::cin>>n>>m;
		
		if(n==0&&m==0)break;
		
		for(int i=0;i<m;i++)
		{
			for(int j=0;j<m;j++)
			{
				for(int k=0;k<2;k++)
				{
					adjacive[i][j][k]=INF;
				}
			}
		}
		
		for(int i=0;i<n;i++)
		{
			int a,b,c,t;
			std::cin>>a>>b>>c>>t;
			adjacive[a-1][b-1][0]=c;
			adjacive[b-1][a-1][0]=c;
			adjacive[a-1][b-1][1]=t;
			adjacive[b-1][a-1][1]=t;
		}
		
		std::cin>>k;
		
		for(int i=0;i<k;i++)
		{
			int result,p,q,r;
			std::cin>>p>>q>>r;
			result=dijkstra(p,q,r,m);
			std::cout<<result<<std::endl;
		}
	}
	return 0;
}

int dijkstra(int start,int goal,int type,int num)
{
	bool visited[100];
	int cost[100];
	for(int i=0;i<num;i++)
	{
		visited[i]=false;;
		cost[i]=INF;
	}
	
	cost[start-1]=0;
	
	while(1)
	{
		int u=-1;
		for(int i=0;i<num;i++)
		{
			if(!visited[i]&&(u==-1||cost[i]<cost[u]))
			{
				u=i;
			}
		}
		if(u==-1)break;
		
		visited[u]=true;
		for(int i=0;i<num;i++)
		{
			if(!visited[i])
			{
				cost[i] = cost[i] > cost[u] + adjacive[u][i][type] ? cost[u] + adjacive[u][i][type] : cost[i];
			}
		}
	}
	return cost[goal-1];
}

Measured memory_bytes: 944
#include <iostream> 
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

long C[51][51];

int main(int argc, char *argv[]) {
	int N, A, B;
	cin >> N >> A >> B;

	vector<long> v(N);
	for (int i = 0; i < N; i++) cin >> v[i];

	sort(begin(v), end(v), greater<long>());

	for (int n = 0; n <= N; n++) C[n][0] = 1;
	for (int n = 1; n <= N; n++)
		for (int k = 1; k <= n; k++)
			C[n][k] = C[n-1][k-1] + C[n-1][k];

	long sum = 0;
	for (int i = 0; i < A; i++) sum += v[i];
	double avg = (double)sum / A;

	long cnt = 0;
	if (v[0] != v[A - 1]) {
		int n = 0, k = 0;
		for (int i = 0; i < N; i++) {
			if (v[i] != v[A - 1]) continue;
			n++;
			if (i < A) k++;
		}
		cnt = C[n][k];
	} else {
		int n = 0;
		for (int i = 0; i < N; i++)
			if (v[0] == v[i])
				n++;

		for (int k = A; k <= B && k <= n; k++)
			cnt += C[n][k];
	}

	cout << fixed << setprecision(20) << avg << endl;
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int main() {
  string s;
  cin >> s;
  vector<bool> v;
  for (int i=0; i<s.size();) {
    if (s[i] == 'e') {
      v.push_back(0);
      i += 3;
    } else {
      v.push_back(1);
      i += 7;
    }
  }
  int pre = -1;
  vector<bool> vv[1000];
  int num = 0;
  REP(i, v.size()) {
    if (i!=0 && v[i] == pre) {
      num++;
    }
    vv[num].push_back(v[i]);
    pre = v[i];
  }
  num++;
  int ma = -1;
  int id = 0;
  REP(i, num) {
    if ((int)vv[i].size() > ma ) {
      ma = vv[i].size();
      id = i;
    }
  }
  if (vv[id][vv[id].size()-1]) {
    cout << "chicken" << endl;
  } else {
    cout << "egg" << endl;
  }
}

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

using ll = long long;

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

    ll n,a,b;
    cin>>n>>a>>b;

    ll ans=0;

    if(abs(a-b)%2==0)
    {
        ans = abs(a-b)/2;
    }
    else
    {
        ans=(abs(a-b)+2*(min(min(a-1,n-a),min(b-1,n-b))+1))/2;
    }

    cout<<ans<<"\n";    

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main(){
  string a;
  cin>>a;
  if(a<="2019/04/30"){
    cout << "Heisei" <<endl;
  }else{
    cout << "TBD" <<endl;
  }
}

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

const int N = 200000 + 10;

int n, a[N];
int b[N];

int check(int m) {
  for (int i = 1; i < 2 * n; ++i) b[i] = (a[i] >= m);
  for (int i = 0; i < n - 1; ++i) {
    if (b[n - i - 1] == b[n - i]) return b[n - i];
    if (b[n + i] == b[n + i + 1]) return b[n + i];
  }
  return b[n] ^ (n & 1) ^ 1;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i < 2 * n; ++i) scanf("%d", &a[i]);
  int l = 1, r = 2 * n - 1;
  while (l < r) {
    int mid = (l + r + 1) / 2;
    if (check(mid)) l = mid; else r = mid - 1;
  }
  printf("%d\n", l);
  return 0;
}


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

int INF = 1001001001;

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() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(3));
    rep(i,n)rep(j,3) cin >> a[i][j];
    vector<vector<int>> dp(n+1, vector<int>(3));
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                chmax(dp[i][j], dp[i-1][k] + a[i-1][j]);
            }
        }
    } 
    int ans = 0;
    rep(i,3) chmax(ans, dp[n][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14272
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s, int v, vector<int>& d, whei(edge)& G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size(); i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}



int main() {
	ll s;
	cin >> s;
	const int a = 1000000000;
	ll x = (a - (s % a)) % a;
	ll y = (s + x) / a;
	cout << "0 0 1000000000 1 " << x << " " << y << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
// long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)
#define rep(i, a, n) for (long long i = a; i < (n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
long long mod = 1000000007;
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t % mod;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}
long long power(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

const ll INF = 1LL << 60;

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

ll nCkmod(ll n, ll k) {
    ll denomi = 1;
    for (int i = n; i > n - k; i--) {
        denomi *= i;
        denomi %= mod;
    }
    ll numera = 1;
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}
vector<vector<ll>> graph;
vector<ll> as;
map<P, ll> number;
ll rmemo[101][300001];
ll memo[101][300001];
int main() {
    ll n;
    cin >> n;
    vector<ll> as(n);
    ll ans = 0;
    REP(i, n) {
        cin >> as[i];
        if ((i + 1) % 2 == 1 && as[i] % 2 == 1) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
program prob4
    implicit none
    integer(16)::N, M
    integer(16)::i,j,ans,com
    integer::v(17)
    read(*,*) N

    v = 0

    if(N < 10) then
        write(*,*) N
    else
        N = N + 1
        do i = 16, 0, -1
            if(N >= 10**i) then
                v(i+1) = N/(10**i)
                N = N - N/(10**i) * 10**i
            end if
        end do

        do i = 17, 1, -1
            if(v(i) > 0)then
                j = i
                exit
            end if
        end do

        ans = v(j) - 1 + 9*(j-1)
        write(*,*) ans      
    end if

    stop
end program

Measured memory_bytes: 2832
import sys
input = sys.stdin.readline
N = int(input())
t = []
res = set()
for i in range(1, N // 2 + 1):
  if N % 2:
    t.append((i, N - i))
  else: t.append((i, N - i + 1))
for i in range(1, N):
  for x in t:
    if i in x: continue
    res.add(tuple(sorted((i, x[0]))))
    res.add(tuple(sorted((i, x[1]))))
if N % 2:
  for i in range(1, N):
    res.add((i, N))
print(len(res))
for r in res:
  print(*r)

Measured memory_bytes: 44780
/*Author: Gautam*/
 
 
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}
 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
void solve()
{
	ll a,b;
	cin>>a>>b;
	cout<<a*b/__gcd(a,b)<<endl;

}
 
int main()
{
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
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 end



int main(){
    int n; scanf("%d",&n);
    string s; cin>>s;
    rep(i,0,s.size()){
        int val=s[i]-'A';
        val=(val+n)%26;
        s[i]=(char)('A'+val);
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;


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

    deque<char> deq;
    for(int i=0; i<s.size(); ++i){
        deq.push_back(s[i]);
    }


    int Q; cin >> Q;
    int one_counter = 0;

    for(int i=0; i<Q; ++i){
        int q; cin >> q;
        if(q == 1){
            one_counter++;
        }else{
            int f; cin >> f;
            char c; cin >> c;

            if( one_counter %2 == 0 ){
                if(f == 1){
                    deq.push_front(c);
                }else{
                    deq.push_back(c);
                }
            }else{
                if(f == 1){
                    deq.push_back(c);
                }else{
                    deq.push_front(c);
                }
            }
        }
    }
    if(one_counter % 2 == 1){
        reverse(deq.begin(), deq.end());
    }

    while(!deq.empty()){
        char c = deq.front();
        deq.pop_front();

        cout << c;
    }
    cout << endl;

}

Measured memory_bytes: 3976
def fib_memo(n):
    memo = [-1]*(n+1)
    def fib(n):
        if n==0 or n==1:
            return 1
        if memo[n] != -1:
            return memo[n]
        memo[n] = fib(n-1) + fib(n-2)
        return memo[n]

    return fib(n)
n=int(input())
print(fib_memo(n))


Measured memory_bytes: 5604
#ifdef __GNUC__
#include <bits/stdc++.h>
#else
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#endif
using namespace std;
using ll = long long;

#define REPI(i, a, n)	for(int (i)=(a);(i)<(n);(i++))
#define REP(i,n) REPI(i,0,n)
#define REP1(i,n) REPI(i,1,n)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;

int vector_finder(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll fact(ll n) {
	int m;
	if (n == 0) {
		return 1;
	}
	m = fact(n - 1);
	return n * m;
}

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	long double l = a + 2 * sqrtl(a * b) + b - c;
	cout<< (l<0.0?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, R;
    cin >> N >> R;

    if(N>9) {
        cout << R << endl;
    } else {
        cout << R + (100*(10-N)) << endl;
    }
    
    return 0;
}

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

int check(int b[],int l,int r){
  int tmp[200001],a[200001];
  for(int i=0;i<=r;i++)a[i]=b[i];
    while(l!=r){
    for(int i=l+1;i<r;i++){
      int num[]={a[i],a[i-1],a[i+1]};
      sort(num,num+3);
      tmp[i]=num[1];
    }
    for(int i=l+1;i<r;i++)a[i]=tmp[i];
    l++,r--;
  }
  return a[l];
}

int A[200001];
int used[200001],flg=0,n,x,len;
void dfs(int cnt){
  if(flg)return;
  if(cnt==len){
    if(check(A,0,len-1)==x){
      flg=1;
      cout<<"Yes"<<endl;
      for(int i=0;i<len;i++)cout<<A[i]<<endl;
    }
    return;
  }

  for(int i=1;i<=len;i++){
    if(used[i])continue;
    A[cnt]=i;
    used[i]=1;
    dfs(cnt+1);
    used[i]=0;
  }
}


int main(){
  cin>>n>>x;
  len=n*2-1;
  int ans[200001]={};
  if(x==1||len==x){cout<<"No"<<endl;return 0;}
  if(x==2){
    ans[len/2]=x;
    ans[len/2-1]=1;
    int cnt=3;
    for(int i=0;i<len;i++){
      if(cnt==x)cnt++;
      if(!ans[i])ans[i]=cnt++;
    }
  }
  else if(x==len-1){
    ans[len/2]=x;
    ans[len/2+1]=len;
    int cnt=1;
    for(int i=0;i<len;i++){
      if(cnt==x)cnt++;
      if(!ans[i])ans[i]=cnt++;
    }
  }
  else{
    ans[len/2-1]=x;
    ans[len/2-2]=1;
    ans[len/2]=len;
    ans[len/2+1]=2;
    int cnt=3;
    for(int i=0;i<len;i++){
	if(cnt==x)cnt++;
	if(!ans[i])ans[i]=cnt++;
      }
  }
  cout<<"Yes"<<endl;
      for(int i=0;i<len;i++)cout<<ans[i]<<endl;
      
  return 0;
}


Measured memory_bytes: 2304
import java.util.*;
class Main{
  public static void main(String[] args){
  Scanner stdIn=new Scanner(System.in);
    int K =stdIn.nextInt();
    if(K%2==0){
		System.out.println(K/2*K/2);
    }else{
      	int n=K/2+1;
		System.out.println(n*(K/2));
    }
  }
}

Measured memory_bytes: 23120
// {{{ Headers
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <cassert>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <fstream>
#include <iostream>
#include <sstream>

using namespace std;
// }}}

typedef long long int64;
const int INF = 0x3f3f3f3f;
const int64 LINF = (int64) 1e15;
template <class T> inline int len (const T &a) { return a.size (); }
#define ALL(x) (x).begin(), (x).end()

int64 dp [100 * 1000 + 5];
int v [100 * 1000 + 5];
int w [100 * 1000 + 5];
int N, W;

int
main () {
    scanf ("%d %d", &N, &W);
    for (int i = 0; i < N; i++) scanf ("%d %d", w + i, v + i);
    for (int j = 0; j <= 100000; j++)
        dp [j] = LINF;

    dp [0] = 0;
    for (int i = 1; i <= N; i++)
        for (int j = 100000; j >= 0; j--)
            if (j >= v [i - 1])
                dp [j] = min (dp [j], dp [j - v [i - 1]] + w [i - 1]);

    int ret = 0;
    for (int j = 0; j <= 100000; j++)
        if (dp [j] <= W)
            ret = max (ret, j);

    printf ("%d\n", ret);


#ifdef LOCALHOST
	cerr << "time: " << (int64) clock () * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
    return 0;
}



Measured memory_bytes: 1024
n, m = [int(_) for _ in input().split()]
matrix = []
for i in range(n):
    matrix.append([int(_) for _ in input().split()])
vector = []
for i in range(m):
    vector.append(int(input()))

for row in matrix:
    c = 0
    for i in range(m):
        c += row[i] * vector[i]
    print(c)


Measured memory_bytes: 6016
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

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

int n,m;
map<int,int> factor;

ll facts[200010],invs[200010];
ll powll(ll base,ll power){
    ll ans = 1;
    while (power){
        if (power&1) ans = (base*ans)%mod;
        base = (base*base)%mod;
        power >>= 1;
    }
    return ans;
}

void fact(int i){
    if (i == 1) return;
    int v = sqrt(i) + 100;
    FOR(c,2,v+1){
        if(i%c == 0){
            factor[c]++;
            return fact(i/c);
        }
    }
    factor[i]++;
}

signed main(){
    I(n); I(m);
    if (n==1) {
        cout << 1 << endl;
        return 0;
    }
    n *= 2;

    //-
        ll f = 1;
        facts[0] = 1;
        FOR(i,1,n+1){
            f *= i;
            f %= mod;
            facts[i] = f;
        }
        ll inv = powll(f,mod-2);
        invs[n] = inv;
        REPNS(i,n){
            inv *= i;
            inv %= mod;
            invs[i-1] = inv;
        }
    //

    n /= 2;
    fact(m);
    int ret = 1;
    for(auto pv: factor){
        auto u = pv.first;
        auto v = pv.second;
        // cerr << u << " " << v << endl;
        ret = ret * facts[n+v-1] % mod * invs[v] % mod * invs[n-1] % mod; 
        // cerr << ret << endl;
    }
    cout << ret << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  string s1,s2,s3;
  s1=to_string(a);
  s2=to_string(b);
  s3=s1+s2;
  int c=stoi(s3);
  double p=sqrt(c);
  if(p-floor(p)==0)
  {
    cout<<"Yes"<<endl;
    
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define rep(i,l,n) for(int (i)=(l);(i)<(n);(i)++)
#define min(a,b) (a)<(b)?(a):(b)
#define max(a,b) (a)>(b)?(a):(b)

int int_cmp(const void*,const void*);

int main(){
	int K,N; scanf("%d %d",&K,&N);
	int a[N];
	rep(i,0,N) scanf("%d",&a[i]);
	int max = K+a[0]-a[N-1];
	rep(i,1,N) max = max(max,a[i]-a[i-1]);
	printf("%d",K-max);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						(int)2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int A, B;
	cin >> A >> B;
	static int ans[4];
	ans[A]++;
	ans[B]++;

	int ansone = 0;
	if (ans[1] == 0) ansone = 1;
	else if (ans[2] == 0)ansone = 2;
	else if (ans[3] == 0)ansone = 3;
	cout << ansone << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt
    val as = in.readLine().split("\\s+").map(_.toInt)

    val maxes = Array.ofDim[Long](as.length)
    var sum = 0L
    for (i <- maxes.length - 1 to 1 by -1) {
      sum += as(i)
      maxes(i - 1) = sum
    }

    var count = 1L
    var node = 1L
    for (i <- as.indices) {
      if (node < as(i)) {
        out.println(-1)
        out.flush()
        return
      }
      node = Math.min((node - as(i)) * 2, maxes(i))
      count += node
    }

    out.println(count)
    out.flush()
  }
}

Measured memory_bytes: 62516
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


N = a_int()
for en in range(1000, 10001, 1000):
    if en >= N:
        exit(en - N)


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

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

   long long ans = 0;

   vector<int> a(n+1);
   vector<int> b(n);

   for(int i = 0; i < n + 1; i++){
       cin >> a.at(i);
   }
   for(int i = 0; i < n; i++){
       cin >> b.at(i);
   }

   for(int i = 0; i < n; i++){
       int left = min(a.at(i), b.at(i));
       ans += left;
       a.at(i) -= left;
       b.at(i) -= left;

       int right = min(a.at(i + 1), b.at(i));
       ans += right;
       a.at(i + 1) -= right;
       b.at(i) -= right;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    double r,pi=3.14159265358979323;
    cin>>r;
    double ans=2*r;
    ans*=pi;
    cout<<fixed<<setprecision(12)<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define pb      push_back
#define all(v)  v.begin(),v.end()
#define see(x)  cout<<#x<<" : "<<(x)<<endl;
#define ya      cout<<"YES"<<endl;
#define no      cout<<"NO"<<endl;
#define ff      first
#define sc      second
typedef long long ll;
typedef pair<ll,ll> pii;
bool ok(string s,int n)
{
    int i;
    bool k=0;
    for(i=n-1;i>=0;i--)
    {
        if(ok && s[i]=='R')return false;
        if(s[i]=='W')k=1;
    }
    return true;
}
int main()
{

    ll n,i,j,k,ans=0;
    string s;
    cin>>n>>s;
    vector<ll>w,r;
    for(i=0;i<n;i++)
        if(s[i]=='R') r.pb(i);
    for(i=n-1;i>=0;i--)
        if(s[i]=='W')w.pb(i);

    while(1)
    {
        if(w.empty()||r.empty()){break;}
        if(w.back()>r.back()){break;}
        int x=w.back(),y=r.back();
//        see(x)
//        see(y)
        swap(s[x],s[y]);
        w.pop_back();
        r.pop_back();
    //see(s)
        ans++;
    }
//    if(!ok(s,n))
//    {
//        int c1=0,c2=0;
//        for(i=0;i<n;i++)
//        {
//            if(s[i]=='W')c1++;
//            else c2++;
//        }
//        ans+=min(c1,c2);
//    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5816
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

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

    int c1[10] = {0};
    int c2[100] = {0};
    int c3[1000] = {0};
    for (int i = 0; i < N; i++) {
        int d = S[i] - '0';
        for (int j = 0; j < 10; j++) {
            if (c1[j] == 1) {
                for (int k = 0; k < 10; k++) {
                    if (c2[10*j+k] == 1)
                        c3[100*j+10*k + d] = 1;
                }
                c2[10*j+d] = 1;
            }
        }
        c1[d] = 1;
    }
    int count = 0;
    for (int i = 0; i < 1000; i++) {
        if (c3[i] == 1) count++;
    }
    cout << count << endl;

    return 0;
}



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

using namespace std;

#define int long long

void solve() {
    int n, x, y;
    cin >> n >> x >> y;
    --x;
    --y;
    vector <vector <int> > dist(n, vector <int> (n, -1));
    vector <int> ans(n);
    for (int i = 0; i < n; ++i) {
        dist[i][i] = 0;
        queue <int> q;
        q.push(i);
        while (!q.empty()) {
            int v = q.front();
            q.pop();
            if (v + 1 < n && dist[i][v + 1] == -1) {
                dist[i][v + 1] = dist[i][v] + 1;
                q.push(v + 1);
            }
            if (v - 1 >= 0 && dist[i][v - 1] == -1) {
                dist[i][v - 1] = dist[i][v] + 1;
                q.push(v - 1);
            }
            if (v == x && dist[i][y] == -1) {
                dist[i][y] = dist[i][v] + 1;
                q.push(y);
            }
            if (v == y && dist[i][x] == -1) {
                dist[i][x] = dist[i][v] + 1;
                q.push(x);
            }
        }
        for (int j = 0; j < n; ++j) ++ans[dist[i][j]];
    }
    //for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) cout << i << ' ' << j << ' ' << dist[i][j] << '\n';
    for (int i = 1; i < n; ++i) cout << ans[i] / 2 << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii; 

#define mp make_pair
#define F first
#define S second

const ll N = 2e5;
const ll M = 20;
const ll SQ = 320;
const ll INF = 1e16;
const ll MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int a,b;
	cin >> a >> b;
	if (a>0)
		cout << "Positive";
	else if (b<0)
	{
		if ((b-a+1)%2==1)
			cout << "Negative";
		else
			cout << "Positive";
	}
	else
		cout << "Zero";
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
def ans(t,h,t_s,h_s):
    for i in t:
        for j in h:
            if t_s - i + j == h_s - j + i:
                return str(i) + " " + str(j)
    return -1
while True:
    n, m = [int(x) for x in input().split()]
    # print(n,m)
    if n == 0 and m == 0:
        break
    t = [int(input()) for i in range(n)]
    h = [int(input()) for i in range(m)]
    t_s = sum(t)
    h_s = sum(h)
    print(ans(t,h,t_s,h_s))

Measured memory_bytes: 7612
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
	string str = "CODEFESTIVAL2016";
	string str2;
	cin >> str2;

	int ans = 0;
	rep(i, str.size()) if( str2[i] != str[i] ) ++ans;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	ll N;
	cin >> N;
	map<string, ll> strs;
	REP(i, N){
		string key;
		cin >> key;
		if(strs.count(key)==0){
			strs[key]=1;
		}else{
			strs[key]++;
		}
	}
	ll max=0;
	for(auto itr=strs.begin(); itr!=strs.end(); itr++){
		if(max<itr->second){
			max=itr->second;
		}
	}
	for(auto itr=strs.begin(); itr!=strs.end(); itr++){
		if(max==itr->second){
			cout << itr->first << endl;
		}
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n), c(n), a(n);
  
  for(int i = 0; i < n; i++){
  	cin >> v.at(i);
  }
  
  for(int i = 0; i < n; i++){
  	cin >> c.at(i);
  }
  
  for(int i = 0; i < n; i++){
  	a.at(i) = v.at(i) - c.at(i);
  }
  
  int sum = 0;
  
  for(int i = 0; i < n; i++){
  	if(a.at(i) > 0){
    	sum += a.at(i);
    }
  }
  cout << sum << endl;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    int i,j;
    int n = 1e6;
    int tmpnmax = 200;
    vector<ll> sankaku(tmpnmax);
    for(i = 0;i < tmpnmax;++i){
        sankaku.at(i) = i+1;
    }
    for(i = 1;i < tmpnmax;++i){
        sankaku.at(i) += sankaku.at(i-1);
    }
    vector<ll> simen = sankaku;
    for(i = 1;i < tmpnmax;++i){
        simen.at(i) += simen.at(i-1);
    }
    vector<ll> dp1(n+1,1e9);
    vector<ll> dp2(n+1,1e9);
    dp1.at(0) = 0;
    dp2.at(0) = 0;
    for(i = 1;i <= tmpnmax;++i){
        if(simen.at(i-1) > n) break;
        for(j = 0;j + simen.at(i-1) <= n;++j){
            dp1.at(j + simen.at(i-1)) = min(dp1.at(j) + 1, dp1.at(j + simen.at(i-1)));
            if(simen.at(i-1)%2) dp2.at(j + simen.at(i-1)) = min(dp2.at(j) + 1, dp2.at(j + simen.at(i-1)));
        }
    }
    while(true){
        int nn;
        cin >> nn;
        if(nn == 0) return 0;
        cout << dp1.at(nn) << " " << dp2.at(nn) << endl;
    }

    return 0;
}


Measured memory_bytes: 18136
hw_list = list(map(int, input().split()))
h = hw_list[0]
w = hw_list[1]
row_list = ['.'*(w+2)]

def mine_check(area, x, y):
    mine = 0
    if area[y-1][x-1] == '#':
        mine += 1
    if area[y-1][x] == '#':
        mine += 1
    if area[y-1][x+1] == '#':
        mine += 1
    if area[y][x-1] == '#':
        mine += 1
    if area[y][x+1] == '#':
        mine += 1
    if area[y+1][x-1] == '#':
        mine += 1
    if area[y+1][x] == '#':
        mine += 1
    if area[y+1][x+1] == '#':
        mine += 1
    return mine

for i in range(h):
    row_list.append('.'+ input()+ '.')
row_list.append('.'*(w+2))

for y in range(1, h+1):
    temp_list = []
    for x in range(1, w+1):
        if row_list[y][x] == '#':
            temp_list.append('#')
        else:
            temp_list.append(str(mine_check(row_list, x, y)))
    print(''.join(temp_list))


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

using namespace std;

typedef long long LL;

struct Line {
    mutable LL m, b, p;
    bool operator<(const Line &o) const { return m < o.m; }
    bool operator<(const LL &x) const { return p < x; }
};

struct LineContainer : multiset<Line, less<>> { // upper convex hull.
    // (for doubles, use inf = 1/.0, div(a,b) = a/b)
    const LL inf = LLONG_MAX;
    LL div(LL a, LL b) { return a / b - ((a ^ b) < 0 && a % b); }
    bool isect(iterator x, iterator y) {
        if (y == end()) {
            x->p = inf;
            return false;
        }
        if (x->m == y->m)
            x->p = x->b > y->b ? inf : -inf;
        else
            x->p = div(y->b - x->b, x->m - y->m);
        return x->p >= y->p;
    }
    void add(LL m, LL b) {
        auto z = insert({m, b, 0}), y = z++, x = y;
        while (isect(y, z))
            z = erase(z);
        if (x != begin() && isect(--x, y))
            isect(x, y = erase(y));
        while ((y = x) != begin() && (--x)->p >= y->p)
            isect(x, erase(y));
    }
    LL query(LL x) {
        assert(!empty());
        auto l = *lower_bound(x);
        return l.m * x + l.b;
    }
};

const int N = 2e5 + 7;

LL dp[N];

int main() {
       LineContainer L; L.add(0, 0);
       LL n, c; cin >> n >> c;
       for(int i = 1; i <= n; i++) {
            LL x; cin >> x;
            if(i > 1)
                dp[i] = -L.query(x) + x * x + c;
            L.add(2 * x, -(x * x + dp[i]));
       }
       cout << dp[n] << endl;
}


Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll n, f[110][15], p[110][15], cnt = 0, ans = -1e15, num = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)for (int j = 1; j <= 10; j++)cin >> f[i][j];
	for (int i = 1; i <= n; i++)for (int j = 0; j <= 10; j++)cin >> p[i][j];
	for (int i = 1; i < 1024; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= 10; k++) {
				if ((i & 1 << (k - 1)) && f[j][k])cnt++;
			}
			num += p[j][cnt];
			cnt = 0;
		}
		ans = max(ans, num);
		num = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		// Nの入力
		int N = sc.nextInt();
		
		// Kの入力
		int K = sc.nextInt();
		
		// hiの評価
		int sum = 0;
		for (int i = 0; i < N; i++) {
			int h = sc.nextInt();
			if (h >= K) {
				sum++;
			}
		}
		
		// 結果の出力
		System.out.println(sum);
		
		sc.close();
	}
}


Measured memory_bytes: 48984
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
		
s = input()
t = input()
 
dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(len(s)):
	for j in range(len(t)):
		if s[i] == t[j]:
			dp[i+1][j+1] = dp[i][j] + 1
		else:
			dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])
            
y = len(s)
x = len(t)
ans = ""
while 1:
	#print(y, x, ans)
	if x*y == 0:
		break
	elif s[y-1] == t[x-1]:
		ans += s[y-1]
		x -= 1
		y -= 1
	else:
		if dp[y][x] == dp[y-1][x]:
			y -= 1
		elif dp[y][x] == dp[y][x-1]:
			x -= 1
            
print(ans[::-1])

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int modminus(int a, int b, int N) {
  int ret = (a - b) % N;
  return (ret >= 0) ? ret : ret + N;
}

template<typename T>
std::vector<int> MP(const std::vector<T> &S) {
  int N = (int) S.size();
  std::vector<int> ret(N + 1);

  ret[0] = -1;

  int pos = -1;
  for(int i = 0; i < N; ++i) {
    while(pos >= 0 && S[i] != S[pos]) pos = ret[pos];
    ret[i + 1] = ++pos;
  }
  return ret;
}

template<typename T>
std::vector<int> KMP(const std::vector<T> &S, const std::vector<T> &P) {
  int N = (int) S.size();
  int M = (int) P.size();
  std::vector<int> table = MP(P);

  std::vector<int> ret;
  int head = 0;
  int pos = 0;
  while(head + pos < N) {
    if(S[head + pos] == P[pos]) {
      ++pos;
      if(pos == M) {
        ret.push_back(head);
        head += pos - table[pos];
        pos = (pos > 0) ? table[pos] : pos;
      }
    } else {
      head += pos - table[pos];
      pos = (pos > 0) ? table[pos] : pos;
    }
  }

  return ret;
}

int main() {
  int N;
  std::cin >> N;
  std::vector<int> a(N), b(N);
  rep(i, N) {
    std::cin >> a[i];
  }
  rep(i, N) {
    std::cin >> b[i];
  }

  std::vector<int> c(N), d(2 * N - 1);
  rep(i, N) {
    c[i] = a[i] ^ a[(i + 1) % N];
  }
  rep(i, 2 * N - 1) {
    d[i] = b[i % N] ^ b[(i + 1) % N];
  }

  std::vector<int> ks = KMP(d, c);

  for(int &k: ks) {
    k = modminus(0, k, N);
  }
  std::sort(ks.begin(), ks.end());

  for(int k : ks) {
    std::cout << k << ' ' << (a[k] ^ b[0]) << '\n';
  }

}


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

using namespace std;
typedef unsigned long long ull;
#define DBG(v) cerr << #v << " = " << (v) << endl;

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

    int x, a;
    cin >> x >> a;
    cout << (x<a?0:10);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int fibo [] = new int[n+1];
        Arrays.fill(fibo,-1);
        fibo[0] = 1;
        fibo[1] = 1;
        int opt = fibonacchi(fibo,n);
        System.out.println(opt);
    }
    public static int fibonacchi(int [] fibo,int i) {
        if(fibo[i]==-1) return fibo[i] = fibonacchi(fibo,i-1)+fibonacchi(fibo,i-2);
        else return fibo[i];
    }
}


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

typedef long long ll;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define clr(a, b) memset(a, b, sizeof(a))
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef LOCAL
    clock_t tStart = clock();
#endif
    string s,t,u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(u == s)
        --a;
    else
        --b;
    cout << a << " " << b << "\n";
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * (clock() - tStart)/ CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256