akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch AttackSurvival | diff AttackSurvival.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address AttackSurvival.cpp && ./a.out

/*
 
 9/15/2019
 
 5:06-
 
 */

int N,Q,K;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>K>>Q;
  VI cnt(N,0);
  REP(i,Q) {
    int a; cin>>a;
    cnt[--a]++;
  }
  REP(i,N) {
    int dec=Q-cnt[i];
    int res=K-dec;
    cout<<(res>0?"Yes":"No")<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

int main(void){
	int n, m, tmp;
	cin >> n >> m;
	vector<int> a, b;
	int grid[1020][1020];
	a.resize(n); b.resize(m);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	for(int i = 0; i < m; ++i){
		cin >> b[i];
	}
	ll remain = 0;
	ll ans = 1;
	for(int k = n * m; k > 0; --k){
		//cout << remain << endl;
		int pa = -1, pb = -1;
		for(int i = 0; i < n; ++i){
			if(a[i] == k){
				pa = i;
				break;
			}
		}
		for(int i = 0; i < m; ++i){
			if(b[i] == k){
				pb = i;
				break;
			}
		}
		if(pa == -1 && pb == -1){
			// mikakutei
			if(remain > 0){
				ans *= remain;
				ans %= MOD;
				remain--;
			}else{
				cout << 0 << endl;
				return 0;

			}

		}else{
			if(pa == -1){
				// gyou kakutei
				b[pb] *= -1;
				int tmp = 0, last;
				for(int i = 0; i < n; ++i){
					if(grid[i][pb] != 1 && a[i] < 0){
						tmp++;
						last = i;
					}
				}
				if(tmp > 0){
					ans *= tmp;
					ans %= MOD;
					remain += tmp - 1;
					grid[last][pb] = 1;
				}else{
					cout << 0 << endl;
					return 0;
					//return 0;

				}
			}else if(pb == -1){
				// retu kakutei
				a[pa] *= -1;
				int tmp = 0, last;
				for(int i = 0; i < m; ++i){
					if(grid[pa][i] != 1 && b[i] < 0){
						tmp++;
						last = i;
					}
				}
				if(tmp > 0){
					ans *= tmp;
					ans %= MOD;
					remain += tmp - 1;
					grid[pa][last] = 1;
				}else{
					cout << 0 << endl;
					return 0;
					//return 0;

				}
			}else{
				// gyou retsu kakutei
				for(int i = 0; i < n; ++i){
					if(a[i] < 0){
						if(grid[i][pb] == 0){
							grid[i][pb] = 2;
							remain++;
						}
					}
				}
				for(int i = 0; i < m; ++i){
					if(grid[pa][i] == 0 && b[i] < 0){
						grid[pa][i] = 2;
						remain++;
					}
				}
				a[pa] *= -1;
				b[pb] *= -1;
				grid[pa][pb] = 1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int i,n,t;
  double j;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  sort(a,a+n);
  j=(a[0]+a[1])/2.0;
  for(i=2;i<n;i++)
  {
    j=(j+a[i])/2.0;
  }
  cout<<j;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll x,y;
  cin >> x >> y;
  if (x==1 || y==1) {
    cout << 1 << endl;
  } else if (x%2 == 0) {
    cout << y*(x/2) << endl;
  } else if (y%2 == 0) {
    cout << x*(y/2) << endl;
  } else {
    cout << (x*y-1)/2 + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int N,M;
vector<vector<int>> G;
vector<vector<ll>> dp;

ll dfs(int v,int p=-1){
    ll res = 1;
    for(int i=0; i<G[v].size(); i++){
        if(G[v][i] == p) continue;
        dp[v][i] = dfs(G[v][i],v);
        res *= (dp[v][i]+1);
        res %= M;
    }
    return res;
}

void rev(int v,int p=-1,ll add=-1){
    for(int i=0; i<G[v].size(); i++){
        if(G[v][i] == p){
            dp[v][i] = add;
            break;
        }
    }
    vector<ll> l(G[v].size()),r(G[v].size());
    for(int i=0; i<G[v].size(); i++){
        l[i] = r[i] = (dp[v][i]+1)%M;
    }
    for(int i=1; i<G[v].size(); i++){
        l[i] *= l[i-1];
        l[i] %= M;
    }
    for(int i=G[v].size()-2; i>=0; i--){
        r[i] *= r[i+1];
        r[i] %= M;
    }
    for(int i=0; i<G[v].size(); i++){
        if(G[v][i] == p) continue;
        ll add_c = 1;
        if(i != 0){
            add_c *= l[i-1];
            add_c %= M;
        }
        if(i != G[v].size()-1){
            add_c *= r[i+1];
            add_c %= M;
        }
        rev(G[v][i],v,add_c);
    }
}


int main(){
    cin >> N >> M;
    G.resize(N);
    for(int i=0; i<N-1; i++){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dp.resize(N);
    for(int i=0; i<N; i++){
        dp[i].resize(G[i].size());
    }
    // for(int i=0; i<N; i++){
    //     cout << dp[i].size() << endl;
    // }
    dfs(0);
    rev(0);
    for(int i=0; i<N; i++){
        ll ans = 1;
        for(int j=0; j<G[i].size(); j++){
            ans *= (dp[i][j]+1);
            ans %= M;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 29056
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {

			int n = sc.nextInt();
			int p = sc.nextInt();

			if((n|p)==0) {
				break;
			}

			int wan = p;
			int[] hands = new int[n];
			int idx = 0;
			ans = 0;

			while(true ) {

				if(wan > 0) {
					wan--;
					hands[idx%n]++;
				}else {
					wan+=hands[idx%n];
					hands[idx%n]=0;
				}


				if(hands[idx %n] == p) {
					ans = idx %n;
					break;
					}
				idx++;
				}
			System.out.println(ans);
		}



	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}
}



Measured memory_bytes: 26792
#include <bits/stdc++.h>
#include <unordered_set>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define fod(i, r, l) for (int i = r; i >= l; i--)
#define pii pair<int, int>
#define vec vector<int>
#define vecl vector<long long>
#define umap unordered_map<int, int>
#define ll long long
#define yes cout << "Yes" \
                 << "\n";
#define no cout << "No" \
                << "\n";
#define en cout << "\n";
#define endl "\n";
#define inf 1000000001
#define mod 1000000007
#define pb push_back
#define mid(l, r) l + (r - l) / 2
#define all(arr) arr.begin(), arr.end()
#define mem(dp) memset(dp, 0, sizeof(dp));
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
using namespace std;
const int N = 100005;

inline int gcd(int a, int b)
{
    while (a != 0 && b != 0)
    {
        if (a > b)
        {
            a %= b;
        }
        else
        {
            b %= a;
        }
    }
    return max(a, b);
}

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

void solve()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    ans+=min(a,k);
    k=k-ans;
    if(k>0){
        k=k-min(k,b);
        if(k>0){
            ans=ans-min(c,k);
    
        }
    }
    cout<<ans<<endl;
}

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

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

    return 0;
}


Measured memory_bytes: 3652
N = int(input())
D, X = map(int, input().split())
A = []
for i in range(N):
    A.append(int(input()))
ans = X
for i in range(N):
    count = 0
    while A[i] * count + 1 <= D:
        ans += 1
        count += 1
print(ans)


Measured memory_bytes: 3060
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
n = int(input())

fact = factorization(n)
cnt = 0
for f in fact:
  if f[0] == 1:
    continue
  i = 1
  while True:
    f[1] -= i
    i += 1
    if f[1] < 0:
      break
    cnt += 1
print(cnt)

Measured memory_bytes: 9492
#include<iostream>
using namespace std;
long long n,a[200000],i,memo;
int main()
{ 
  a[0]=0;
  cin >> n;
  for(i=1;i<=n;i++){
    cin >> a[i];
  }
  memo=abs(a[n]);
  for(i=0;i<n;i++){
     memo=memo+abs(a[i]-a[i+1]);
    }
  for(i=1;i<n;i++){
    printf("%lld\n",memo-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]));
  }
  printf("%lld",memo-abs(a[i]-a[i-1])-abs(a[i]-a[0])+abs(a[i-1]-a[0]));
}

Measured memory_bytes: 2048
import java.util.Scanner;

public class Main {
    private static int[] num;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        num = new int[6];

        for (int i = 0; i < 6; i++) {
            num[i] = scan.nextInt();
        }

        String direction = scan.next();
        char[] chars = direction.toCharArray();

        for (int i = 0; i < chars.length; i++) {
            roll(num, chars[i]);
        }

        System.out.println(getTop());
    }

    private static void roll(int[] num, char direction) {
        int temp = num[0];
        switch (direction) {
            case 'N':
                num[0] = num[1];
                num[1] = num[5];
                num[5] = num[4];
                num[4] = temp;
                break;
            case 'S':
                num[0] = num[4];
                num[4] = num[5];
                num[5] = num[1];
                num[1] = temp;
                break;
            case 'W':
                num[0] = num[2];
                num[2] = num[5];
                num[5] = num[3];
                num[3] = temp;
                break;
            case 'E':
                num[0] = num[3];
                num[3] = num[5];
                num[5] = num[2];
                num[2] = temp;
                break;
        }
    }

    private static int getTop() {
        return num[0];
    }
}

Measured memory_bytes: 26212
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    set<char> st;
    int n=s.size();
    rep(i,n) st.insert(s[i]);
    int ans=10000;
    for(char x:st){
        int cnt=0;
        string t=s;
        while(true){
            string u;
            bool ok=1;
            rep(i,t.size()-1){
                if(t[i]==x||t[i+1]==x) u+=x;
                else{
                    ok=0;
                    u+=t[i];
                }
            }
            
            cnt++;
            if(ok) break;
            t=u;
        }
        chmin(ans,cnt);
    }
    if(st.size()==1) ans=0;
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 256
import math


def div_with_mod(x, y, mod):
    # Fermat's little theorem
    return x*pow(y, mod - 2, mod)


def comb(n, r, mod):
    # calculates C(n,r) with mod (assuming mod is prime)
    nc = n
    for rc in range(1, r):
        nc -= 1
        n = n*nc % mod
        r = r*rc % mod

    return div_with_mod(n, r, mod)


def solve():
    N = int(input())
    # ord("a") Unicode コードポイントを返す
    codepoint = ord("a")

    # たどるグラフの深さ
    i = 1
    # 標準形文字列とその次の辞書順
    ans = [["a", 1]]
    # 一つづつ潜る
    while i < N:
        # 次の深さをtmpとする
        tmp = []
        # 各ノード
        for w, j in ans:
            # 辞書順で追加していく
            for k in range(j+1):
                if k != j:
                    tmp.append([w + chr(codepoint+k), j])
                # 辞書順のインクリメント
                else:
                    tmp.append([w + chr(codepoint+k), j+1])
        ans = tmp
        i += 1

    [print(a[0]) for a in ans]

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


Measured memory_bytes: 80220
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back

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

	int r,d,x;
	cin>>r>>d>>x;

	for(int i=1;i<=10;i++)
	{
		x=r*x-d;
		cout<<x<<"\n";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int n,m,a[1<<19];
ll s[1<<19],f[1<<19],g[1<<19],put[1<<19];
ll k[1<<19],b[1<<19];
ll calc(int p,int x){return k[p]*x+b[p];}
ll C2(ll x){return x*(x-1)/2;}
void add(ll*f,int i,int&r){
	ll k0=-i,b0=f[i]+s[i]+C2(i);
	while(r>1&&(b0-b[r])*(k[r-1]-k[r])>(b[r]-b[r-1])*(k[r]-k0))r--;
	k[++r]=k0,b[r]=b0;
}
void solve(ll*f){
	for(int i=1;i<=n;i++)s[i]=s[i-1]+a[i];
	int r=1;k[1]=b[1]=0;
	for(int i=1;i<=n;i++){
		while(r>1&&calc(r,i)<calc(r-1,i))r--;
		f[i]=max(f[i-1],calc(r,i)-s[i]+C2(i+1));
		add(f,i,r);
	}
}
void work(int l,int r){
	if(l==r)return;
	int mid=l+r>>1;work(l,mid);work(mid+1,r);
	int L=1,R=0;ll t=-1e18;
	for(int i=l-1;i<=r;i++)s[i]=i<l?0:s[i-1]+a[i];
	for(int i=l-1;i<=mid;i++)add(f,i,R);
	for(int i=r;i>mid;i--){
		while(L<R&&calc(L,i)<calc(L+1,i))L++;
		t=max(t,g[i+1]+calc(L,i)-s[i]+C2(i+1));
		put[i]=max(put[i],t+a[i]);
	}
	L=1,R=0;t=-1e18;
	reverse(a+l,a+1+r);mid=l+r-mid-1;
	for(int i=l-1;i<=r;i++)s[i]=i<l?0:s[i-1]+a[i];
	reverse(g+l-1,g+2+r);
	for(int i=l-1;i<=mid;i++)add(g,i,R);
	reverse(g+l-1,g+2+r);
	for(int i=r;i>mid;i--){
		while(L<R&&calc(L,i)<calc(L+1,i))L++;
		t=max(t,f[l+r-i-1]+calc(L,i)-s[i]+C2(i+1));
		put[l+r-i]=max(put[l+r-i],t+a[i]);
	}
	reverse(a+l,a+1+r);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	solve(f);
	reverse(a+1,a+1+n);
	solve(g);
	reverse(a+1,a+1+n);reverse(g+1,g+1+n);
	work(1,n);
	for(scanf("%d",&m);m--;){
		int p,x;scanf("%d%d",&p,&x);
		printf("%lld\n",max(f[p-1]+g[p+1],put[p]-x));
	}
	return 0;
}

Measured memory_bytes: 23040
def main():
    n, x = map(int,input().split())
    a = list(map(int,input().split()))

    ans=0

    if a[0] > x:
        tmp = a[0] -x
        a[0] -= tmp
        ans+=tmp

    for i in range(n-1):
        if a[i] + a[i+1] > x:
            tmp = (a[i]+a[i+1]) -x
            a[i+1] -= tmp
            ans += tmp

    print(ans)

if __name__ == "__main__":
        main()


Measured memory_bytes: 14132
W,N,v,w,i,m,*p;s(){scanf("%d,%d",&v,&w);}main(n){for(s();W=v;){int c[1001]={0};for(s(),n=v;s(p=c),n--;)for(m=i=W+1;i--;m-=*p++==*c)i>=w?*p=fmax(*p,p[w]+v):0;printf("Case %d:\n%d\n%d\n",++N,*c,m);}}

Measured memory_bytes: 0
#encoding utf-8

a,b,c,d = map(int, input().split())

connect = 0
if abs(a-c) <= d:
    connect = 1
elif abs(a-b) <= d and abs(b-c) <= d:
    connect = 1
else:
    connect = 0

if connect == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    set<string> st;
    while(N--) {
        string s;
        cin >> s;
        st.insert(s);
    }

    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 19124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin >> a[i];
        a[i]-=(i+1);
    }
    sort(a.begin(),a.end());
    ll mid=n/2;
    ll ans=0;
    ll b=a[mid];
    for(ll i=0;i<n;i++){
        a[i]-=b;
        if(a[i]<0) ans-=a[i];
        else ans+=a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4756
// {{{ by unolight
#include <bits/stdc++.h>
#include <unistd.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x),end(x)
#define RALL(x) rbegin(x),rend(x)
#define REP(i,n) for ( int i=0; i<int(n); i++ )
#define REP1(i,a,b) for ( int i=(a); i<=int(b); i++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

int n,m;
int A[15][15];
int main() {
    cin >> n >> m;
    int ans = 0;
    REP(i, n) REP(j, m) cin >> A[i][j];

    REP(i, n) REP1(j, i+1, n-1) {
        int r = 0;
        REP(k, m) r += (A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
        int q = sqrt(r);
        if(q*q == r) ans++;
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

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; }

int main()
{
	int n, d;
	cin >> n >> d;

	vector<vector<int>> x(n, vector<int>(d));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < d; j++)
		{
			cin >> x[i][j];
		}
	}

	int count = 0;
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			int length = 0;
			for (int k = 0; k < d; k++)
			{
				length += (x[j][k] - x[i][k]) * (x[j][k] - x[i][k]);
			}
			int s = sqrt(length) + 0.5;
			if (s * s == length)
			{
				count++;
			}
		}
	}

	cout << count << endl;
}

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

int main() {
  int r, g, b, n, cnt = 0;

  cin >> r >> g >> b >> n;

  for (int i = 0; i * r <= n; i++) {
    for (int j = 0; j * g + i * r <= n; j++) {
      if (i * r + j * g == n) {
        cnt++;
      } else if (i * r + j * g < n) {
        if ((n - (i * r + j * g)) % b == 0) {
          cnt++;
        }
      }
    }
  }

  cout << cnt;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	vector<long long> arr(n);
	for(int i=0;i<n;++i)cin>>arr[i];

	long long all = 0L;
	for(int i=0;i<n;++i)all ^= arr[i];
	//cout<<all<<endl;
  
    
	for(int i=0;i<n;++i){
		for(int bit=0;bit<60;++bit){
			if( (all & (1LL<<bit)) && ((1LL<<bit) & arr[i]) ){
				arr[i] -= (1LL<<bit);
			}
		}
	}
  
  	long long sum = 0L;
	for(int i=0;i<n;++i)sum ^= arr[i];
	//cout<<all<<endl;
  
	int index = 0;
	for(int bit=59;bit>=0;--bit){
		long long mx = -1;
		int id = index; 
		for(int i=index;i<n;++i){
			if( ((1LL<<bit)&arr[i])){
				id = i;
				mx = arr[i];
                break;
			}
		}
		if(mx==-1){continue;}
		swap(arr[index],arr[id]);

		for(int i=0;i<n;++i){
			if(i!=index && arr[i]&(1LL<<bit) ){
				arr[i] ^= arr[index];
			}
		}
		index++;
        //for(auto i:arr)cout<<i<<" ";cout<<endl;
	}
  
	
	long long curr = 0L;
	for(int i=0;i<n;++i){
		curr ^= arr[i];
	}
	
	cout<<curr + (curr^sum) + all<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int d[55];
int dfs(int n,int pos){
    if(n==0) return 1;
    else{
        if(pos==1) return 0;
        else if(pos<=d[n-1]+1){
            return dfs(n-1,pos-1);
        }
        else if(pos==d[n-1]+2){
            return dfs(n-1,d[n-1])+1;
        }
        else if(pos<d[n-1]*2+3){
            return dfs(n-1,d[n-1])+dfs(n-1,pos-d[n-1]-2)+1;
        }
        else return dfs(n-1,d[n-1])*2+1;
    }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,X; cin >> N >> X;
    rep(i,N+1){
        if(!i) d[0]=1;
        else d[i]=d[i-1]*2+3;
    }
    cout << dfs(N,X) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] dice1,dice2,dice3,dice4;
		dice1 = new int[10];
		dice2 = new int[10];
		dice3 = new int[10];
		dice4 = new int[10];
		int i,m;
		
		for(i = 0; i < 6; i++){
			dice1[i] = scan.nextInt();
			dice4[i] = dice1[i];
		}
		
		for(i = 0; i < 6; i++){
			dice2[i] = scan.nextInt();
		}
		
		for(i = 0; i < 4; i++){
			if(dice1[0] == dice2[0] && dice1[1] == dice2[1] &&
					dice1[2] == dice2[2] && dice1[3] == dice2[3] &&
					dice1[4] == dice2[4] && dice1[5] == dice2[5])
				break;
			dice3[0] = dice1[4];
			dice3[1] = dice1[0];
			dice3[2] = dice1[2];
			dice3[3] = dice1[3];
			dice3[4] = dice1[5];
			dice3[5] = dice1[1];
			dice1[0] = dice3[0];
			dice1[1] = dice3[1];
			dice1[2] = dice3[2];
			dice1[3] = dice3[3];
			dice1[4] = dice3[4];
			dice1[5] = dice3[5];
			for(m = 0; m < 4; m++){
				if(dice1[0] == dice2[0] && dice1[1] == dice2[1] &&
						dice1[2] == dice2[2] && dice1[3] == dice2[3] &&
						dice1[4] == dice2[4] && dice1[5] == dice2[5])
					break;
				dice3[0] = dice1[0];
				dice3[1] = dice1[3];
				dice3[2] = dice1[1];
				dice3[3] = dice1[4];
				dice3[4] = dice1[2];
				dice3[5] = dice1[5];
				dice1[0] = dice3[0];
				dice1[1] = dice3[1];
				dice1[2] = dice3[2];
				dice1[3] = dice3[3];
				dice1[4] = dice3[4];
				dice1[5] = dice3[5];
			}
		}
		
		if(dice1[0] == dice2[0] && dice1[1] == dice2[1] &&
				dice1[2] == dice2[2] && dice1[3] == dice2[3] &&
				dice1[4] == dice2[4] && dice1[5] == dice2[5]){}
		else{
			dice1[0] = dice4[0];
			dice1[1] = dice4[1];
			dice1[2] = dice4[2];
			dice1[3] = dice4[3];
			dice1[4] = dice4[4];
			dice1[5] = dice4[5];
		}
			
		
		for(i = 0; i < 4; i++){
			if(dice1[0] == dice2[0] && dice1[1] == dice2[1] &&
					dice1[2] == dice2[2] && dice1[3] == dice2[3] &&
					dice1[4] == dice2[4] && dice1[5] == dice2[5])
				break;
			dice3[0] = dice1[3];
			dice3[1] = dice1[1];
			dice3[2] = dice1[0];
			dice3[3] = dice1[5];
			dice3[4] = dice1[4];
			dice3[5] = dice1[2];
			dice1[0] = dice3[0];
			dice1[1] = dice3[1];
			dice1[2] = dice3[2];
			dice1[3] = dice3[3];
			dice1[4] = dice3[4];
			dice1[5] = dice3[5];
			for(m = 0; m < 4; m++){
				if(dice1[0] == dice2[0] && dice1[1] == dice2[1] &&
						dice1[2] == dice2[2] && dice1[3] == dice2[3] &&
						dice1[4] == dice2[4] && dice1[5] == dice2[5])
					break;
				dice3[0] = dice1[0];
				dice3[1] = dice1[3];
				dice3[2] = dice1[1];
				dice3[3] = dice1[4];
				dice3[4] = dice1[2];
				dice3[5] = dice1[5];
				dice1[0] = dice3[0];
				dice1[1] = dice3[1];
				dice1[2] = dice3[2];
				dice1[3] = dice3[3];
				dice1[4] = dice3[4];
				dice1[5] = dice3[5];
			}
		}
		
		if(dice1[0] == dice2[0] && dice1[1] == dice2[1] &&
				dice1[2] == dice2[2] && dice1[3] == dice2[3] &&
				dice1[4] == dice2[4] && dice1[5] == dice2[5])
			System.out.println("Yes");
			else
				System.out.println("No");
	}
}

Measured memory_bytes: 26404
import bisect
import sys
input=sys.stdin.readline
from operator import itemgetter
n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for i in range(m)]
a.sort()
bc.sort(key=itemgetter(1),reverse=True)
s=0
ans=0
for i in range(m):
  if a[s]<bc[i][1]:
    t=bisect.bisect_left(a,bc[i][1],s,n)
    cvt=min(t-s,bc[i][0])
    ans+=bc[i][1]*cvt
    s+=cvt
    if s>=n:
      break
  else:
    break
print(ans+sum(a[s:]))


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

#define fst first
#define snd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const ll _INF = 1e18+7;
const int mxn = 1e3+7;

string s[mxn];
bool vst[mxn][mxn];

struct ds{int r, c, val;};

int main(){
	setIO();
	int r, c, cr, cw, dr, dw, ans = INF;
	cin >> r >> c >> cr >> cw >> dr >> dw;
	for (int i = 0; i < r; i++){
		cin >> s[i];
	}
	auto comp = [](ds a, ds b){return a.val > b.val;};
	priority_queue<ds, vector<ds>, decltype(comp)>pq(comp);
	pq.push({cr, cw, 0});
	while (!pq.empty()){
		ds v = pq.top();
		pq.pop();
		if (!vst[v.r][v.c] && s[v.r-1][v.c-1] == '.'){
			vst[v.r][v.c] = 1;
			if (v.r == dr && v.c == dw){
				ans = min(ans, v.val);
				continue;
			}
			for (int j = -2; j <= 2; j++){
				for (int k = -2; k <= 2; k++){
					if (v.r+j > 0 && v.r+j <= r && v.c+k > 0 && v.c+k <= c && !vst[v.r+j][v.c+k] && s[v.r+j-1][v.c+k-1] == '.'){
						if (!j && !k) continue;
						if (abs(j)+abs(k) == 1) pq.push({v.r+j, v.c+k, v.val});
						else pq.push({v.r+j, v.c+k, v.val+1});
					}
				}
			}
		}
	}
	if (ans == INF) cout << "-1\n";
	else cout << ans << endl;
}

Measured memory_bytes: 6884
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N, T;
  while(cin >> N >> T && N){
    vector<int> v[100];
    REP(i, N){
      int t; 
      while(cin >> t && t) v[i].push_back(t);
    }
    vector<int> cur(N);
    vector<int> rest(N);
    REP(i, N) rest[i] = v[i][0];
    int now_use = -1;
    queue<int> que;
    int ans = 0;
    REP(t, T){
      if(now_use == -1 && !que.empty()){
        now_use = que.front();
        que.pop();
      }
      ans += que.size();
      REP(i, N){
        if(now_use == i || cur[i] % 2 == 0){
          rest[i]--;
          if(rest[i] == 0){
            cur[i] = (cur[i] + 1) % v[i].size();
            rest[i] = v[i][cur[i]];
            if(now_use == i) now_use = -1;
            if(cur[i] % 2 == 1){
              que.push(i);
            }
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;

int S[100],R[100];
main(){
	int N,i=0,a,b,c,d;
	vector<pair<int,int> >v;
	scanf("%d",&N);
	for(;i<N*(N-1)/2;i++){scanf("%d%d%d%d",&a,&b,&c,&d);if(c==d)c=d=1;else if(c>d)c=3,d=0;else c=0,d=3;S[a-1]+=c,S[b-1]+=d;}
	for(i=0;i<N;i++)v.push_back(make_pair(S[i],i));
	sort(v.begin(),v.end(),greater<pair<int,int> >());
	for(R[v[0].second]=1,a=0,i=1;i<N;i++){if(v[i].first<v[a].first)a=i;R[v[i].second]=a+1;}
	for(i=0;i<N;i++)printf("%d\n",R[i]);
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){
  int n;
  int a,b;
  int ans;
  scanf("%d",&n);
  if(n==1){
    printf("Hello World");
  }else if(n==2){
    scanf("%d%d",&a,&b);
    ans=a+b;
    printf("%d",ans);
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int,int> P;

int main(){
	int W,N,cou=0;
	int tr[1001],we[1001];
	while(cin >> W , W){
		cou++;
		cin >> N;
		for(int i=0;i<N;i++){
			scanf("%d,%d",&tr[i],&we[i]);
		}

		int dp[1010];
		for(int i=0;i<=W;i++){
			dp[i]= 0;
		}
		for(int i=0;i<N;i++){
			for(int j=W;j>=we[i];j--){
				dp[j] = max(dp[j],dp[j-we[i]]+tr[i]);
			}
		}
		int ret = 0;
		for(int i=0;i<=W;i++){
			if(dp[i] > dp[ret]) ret = i;
		}
		cout << "Case " << cou << ":" << endl;
		cout << dp[ret] << endl;
		cout << ret << endl;
	}
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

int main() {
  // https://atcoder.jp/contests/soundhound2018-summer-qual/tasks/soundhound2018_summer_qual_c
  double n,m,d; cin >> n >> m >> d;
  double p = 0;
  if(d==0) p = 1.0 / n;
  else p = (n-2*d)/ n * 2 / n + (d*2) /n / n;
  cerr << p << endl;
  double ans = (m-1) * p;
  printf("%.10lf\n", ans);
}


Measured memory_bytes: 3756
n, k, q = gets.chomp.split(' ').map(&:to_i)
arr = Array.new(n, 0)

q.times do |i|
  a = gets.chomp.to_i - 1
  arr[a] += 1
end

arr.each do |i|
  q - i < k ? puts('Yes') : puts('No')
end


Measured memory_bytes: 4220
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long answer = 0;
        if (n % (a + b) == 0) {
            if (n < a+b) {
                if (n < a) {
                    answer = n;
                } else {
                    answer = a;
                }
            } else {
                answer = a * (n / (a + b));
            }
        } else if (n % (a + b) > a) {
            answer = a * (n / (a + b)) + a;
        } else {
            answer = a * (n / (a + b)) + (n % (a + b));
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 22612
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }


int main() {
    rep(i, 5) {
        int x;
        cin >> x;
        if (x == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

signed main() {
  int m, k;
  cin >> m >> k;
  if (m == 1) {
    if (k == 0) {
      cout << "0 0 1 1" << endl;
    } else {
      cout << -1;
    }
  } else {
    if (k < (1 << m)) {
      RREP(i, 1 << m) {
        if (i != k) {
          cout << i;
          cout << " ";
        }
      }
      cout << k << " ";
      REP(i, 1 << m) {
        if (i != k) {
          cout << i;
          cout << " ";
        }
      }
      cout << k << endl;
    } else {
      cout << -1 << endl;
    }
  }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h> 
    using namespace std; 
     
    #define ll long long  
     
    int main()
    {
        ll int n, ans; 
        cin >> n; 
        ans = n - 1; 
     
        for (int i = 1; i < sqrt(n) + 1; ++i){
            if (n % i == 0)
            {
                ans = min(ans, i + n / i - 2); 
            }
        }
        cout << ans << endl; 
        return 0; 
    }

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
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

H, W, K = MAP()

dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1

for i in range(H):
    for j in range(W):
        for S in range(1<<(W-1)):
            for k in range(W-2):
                if (S>>k)&1==1 and (S>>(k+1))&1==1:
                    break
            else:
                if j >= 1 and (S>>(j-1))&1:
                    dp[i+1][j-1] += dp[i][j]
                    dp[i+1][j-1] %= mod
                elif j <= W-2 and (S>>j)&1:
                    dp[i+1][j+1] += dp[i][j]
                    dp[i+1][j+1] %= mod
                else:
                    dp[i+1][j] += dp[i][j]
                    dp[i+1][j] %= mod

print(dp[H][K-1])


Measured memory_bytes: 75840
#include <bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
bool isPrime(int i)
{
	if(i==1)return false;
	if(i==2) return true;
	if(i%2==0) return false;
	for(int j=3;j*j<=i;j++)
	{
		if(i%j==0) return false;
	}
	return true;
}
long long n,ans=1;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=2;i<=n;i++)
	{
		if(isPrime(i))
		{
			long long t=i;
			long long sum=0;
			while(n/t!=0)
			{
				sum+=n/t;
				t*=i;
				sum%=mod;
			}
			ans*=((sum+1)%mod);
			ans%=mod;
		}
	}
	cout<<ans<<endl;
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  char a;
  cin>>a;
  cout<<('a'<=a && a<='z' ? 'a' : 'A')<<'\n';
  return 0;
}


Measured memory_bytes: 3648
// https://beta.atcoder.jp/contests/abc068

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;

void print_yes_no(bool cond, string yes = "POSSIBLE", string no = "IMPOSSIBLE") { cout << (cond ? yes : no) << endl; }

const int MAX_N = 200000;
int N, M;
set<int> adj[MAX_N + 1];

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    stringstream stream(R"(5 5
1 3
4 5
2 3
2 4
1 4
)");
#endif
    int N, M;
    stream >> N >> M;
    int a, b;
    for (int i = 0; i < M; ++i) {
        stream >> a >> b;
        adj[a].insert(b);
        adj[b].insert(a);
    }

    bool possible = false;
    set<int> reachable_nodes;
    for (auto u : adj[1]) reachable_nodes.insert(u);
    for (auto r : reachable_nodes) {
        if (adj[r].find(N) != adj[r].end()) {
            possible = true;
            break;
        }
    }

    print_yes_no(possible);
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,k; cin>>n>>k;
    ll ans=k;
    rep(i,n-1) ans*=(k-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
#include <stdlib.h>
#include <vector>
#include <climits>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <iomanip>
using namespace std; 
#define Endl '\n'
int main()
{
    int a,b;
    cin>>a>>b;
    if (a>b)
    {
        cout<<"safe";
    }
    else
        cout<<"unsafe";
}

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

int n;

int main()
{
    cin>>n;

    int maxa = n/4;
    int maxb = n/7;

    bool exists = false;
    for (int i = 0; i <= maxa; i++)
    {
        for (int j = 0; j <= maxb; j++)
        {
            if(4*i + 7*j == n) exists = true;
        }
    }
    
    if(exists) cout << "Yes" << endl;
    else cout << "No" << endl;
        
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
ll k, n, a[N];
ll pre[N], suf[N];
int main()
{
	cin >> k >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	a[n + 1] = k + a[1];
	ll ma = 0;
	for (int i = 1; i <= n; i++)
	ma = max(ma, a[i + 1] - a[i]);
	cout << k - ma << endl;
}

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

int main()
{
	int n, q;
	cin >> n >> q;
	vector<pair<string, int>> A( n );
	int num = 0;
	for( int i = 0; i < n; i++ ) {
		cin >> A[i].first >> A[i].second;
	}

	vector<pair<string, int>> ans;
	queue<int> que;
	for( int i = 0; i < n; i++ ) {
		que.push( i );
	}
	int time = 0;
	while( !que.empty() ) {
		int i = que.front();
		que.pop();
		if( A[i].second > q ) {
			A[i].second -= q;
			que.push( i );
			time += q;
		}
		else {
			time += A[i].second;
			ans.push_back( make_pair( A[i].first, time ) );
		}
	}

	for( int i = 0; i < ans.size(); i++ ) {
		cout << ans[i].first << " " << ans[i].second << endl;
	}
}



Measured memory_bytes: 7292
def linearSearch(key, list):
    for e in list:
        if key == e:
            return 1
    return 0


N1 = int(input())
arr1 = [int(n) for n in input().split()]
N2 = int(input())
arr2 = [int(n) for n in input().split()]

print(sum([linearSearch(key, arr1) for key in arr2]))



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

using namespace std;

const int INF = 2e9 + 9;
const long long MOD = 998244353;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(), a.end());
    vector<pair<int, long long>> st = {{INF, 1}};
    for (int i = n-1; i >= 0; i--) {
        auto cur = st.back().second;
        auto to = a[i].first + a[i].second;
        while (st.back().first < to) {
            st.pop_back();
        }
        cur = (cur + st.back().second) % MOD;
        st.push_back({a[i].first, cur});
    }
    cout << st.back().second << endl;
}



Measured memory_bytes: 3956
#include <cstdio>
#include <algorithm>
using namespace std;

int a,b;

int main(void){
	scanf("%d %d",&a,&b);
	if(a>12){
		printf("%d",b);
		return 0;
	}
	if(a>=6&&a<=12){
		printf("%d",b/2);
		return 0;
	}
	printf("0");
} 

Measured memory_bytes: 128
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include<map>
#include <vector>
#include <cassert>
#include<cmath>
using namespace std;



int main() {
	int N, M;
	cin >> N >> M;
	cout << (N*(N - 1)) / 2 + (M*(M - 1)) / 2;
}

Measured memory_bytes: 256