akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {

    while(true){

        double r;
        int n;

        cin >> r >> n;

        if(r == 0.0 && n == 0){
            break;
        }

        int x[41] = {0};

        for(int i=0; i<n; i++){
            int lx,ly,h;

            cin >> lx >> ly >> h;

            for(int i=20+lx; i<20+ly; i++){
                x[i] = max(x[i],h);
            }
        }

        double ans = 0.0000;

        while(true){

            double survey = ans + 0.0001;

            bool flag = true;

            for(int i=-20; i<=20; i++){
                double d_x = static_cast<double>(i);
                if(r*r > d_x*d_x){
                    double h = sqrt(r*r - d_x*d_x) + survey - r;
                    if(h > x[i+20] || h > x[i+20 -1]){
                        flag = false;
                        break;
                    }
                }
            }

            if(!flag){
                break;
            }

            ans += 0.0001;

        }

        cout << fixed << setprecision(4) << ans << endl;

    }

    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
vector < int > DP(N, 2e9), v(N);
int main() {
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
      cin >> v[i];
    }
    DP[1] = 0;
    for (int i = 2; i <= n; i++) {
      for (int j = 1; j <= k; j++) {
        if (i - j < 1) break;
        DP[i] = min(DP[i], DP[i - j] + abs(v[i] - v[i - j]));
      }
    }
    cout << DP[n] << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
typedef long long LL;
using namespace std;
int main(){
   int a,b,c,d;
   cin>>a>>b>>c>>d;
    LL res=-1e18-1;
    res=max(res,(LL)a*d);
    res=max(res,(LL)a*c);
    res=max(res,(LL)b*c);
    res=max(res,(LL)b*d);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

constexpr auto INF = INT_MAX/2;
constexpr auto MOD = 1000000007;


int main() {

	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];

	ll ans = a[0] / 2;
	a[0] -= (a[0] / 2) * 2;

	rep(i, n - 1) {
	
		if (a[i]&&a[i+1]) { a[i]--; a[i + 1]--; ans++; }
		ans += a[i + 1] / 2;
		a[i + 1] -= (a[i + 1] / 2) * 2;

	}

	cout << ans << endl;

}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int N, K, x;
    while(scanf("%d %d", &N, &K) != EOF)
	{
		x = 1;
		for(int i = 1; i <=	N; i++)
		{
			if(x < K)
			{
				x = 2 * x;
			}
			else
			{
				x = x + K;
			}
		}
		printf("%d\n", x);
	}
	return 0;
}


Measured memory_bytes: 256
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=2e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=(xx<<3)+(xx<<1)+ch-'0';ch=getchar();}
    return xx*ff;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	fastio;

	int a,b,c; cin>>a>>b>>c;
	
	int two[10];
	two[0] = 1;
	
	forsn(i,1,10) two[i] = two[i-1] * 2;
	int k; cin>>k;
	bool y = 0;

	forn(i,k+1){
		forn(j,k+1){
			forn(l,k+1){
				if(i+j+l != k) continue;
				ll na = a * two[i];
				ll nb = b * two[j];
				ll nc = c * two[l];
				if(nb > na && nc > nb) y = 1;
			}
		}
	}

	if(y) cout<<"Yes"<<ln;
	else cout<<"No"<<ln;

	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  int x , a , b;
  cin >> x >> a >> b;
  if(b <= a)cout << "delicious" << endl;
  else if(b - a <= x)cout << "safe" << endl;
  else cout << "dangerous" << endl;
}


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

int main(void)
{
	int score[100];
	vector<int> answer;
	int n, ans;
	
	while (scanf("%d,%d", &n, &ans) * n != 0){
		score[n - 1] = ans;
		answer.push_back(ans);
	}
	sort(answer.begin(), answer.end());
	answer.erase(unique(answer.begin(), answer.end()), answer.end());
	reverse(answer.begin(), answer.end());
	
	while (scanf("%d", &n) != EOF){
		ans = score[n - 1];
		for (int i = 0; i < answer.size(); i++){
			if (answer[i] == ans){
				printf("%d\n", i + 1);
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int main(){
    ll a,b; cin>>a>>b;
    if((a+b)%2==0) cout<<(a+b)/2<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fname "E"
#define cerr if(false)cerr
#define bug(x) cerr << (#x) << " = " << (x) << endl
#define ll long long
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define ARR0(a, n) {cerr <<(#a)<< ": ["; REP0(i, n) cerr<< ' ' << a[i] <<','; cerr<<']'<<endl;}
#define ARR1(a, n) {cerr <<(#a)<< ": ["; REP1(i, n) cerr<< ' ' << a[i] <<','; cerr<<']'<<endl;}
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define LB lower_bound
#define UB upper_bound
#define X first
#define Y second

using namespace std;
template<typename T, typename V>
inline void bugp(const pair<T, V> &x) {cerr << '{' << x.X << ", " << x.Y << '}' << endl;}
template<typename T, typename U, typename V>
inline void bugpp(const pair<T, pair<U, V> > &x) {cerr << '{' << x.X << ", {" << x.Y.X << ", " << x.Y.Y << "}}" << endl;}
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ll, int> li;
typedef pair<ll, ii> lii;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int N = 3003;
int C[N][N];
ll dp[N][N][4];

int main()
{
    //freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(false); cin.tie(0);
    int r, c, k;
    cin >> r >> c >> k;
    while(k--) {
        int x, y, v;
        cin >> x >> y >> v;
        C[x][y] = v;
    }
    REP1(i, r) {
        bug(i);
        REP1(j, c) {
            bug(j);
            REP1(v, 3) {
                bug(v);
                dp[i][j][v] = max(dp[i - 1][j][3], dp[i][j - 1][v]);
                if(C[i][j]) dp[i][j][v] = max(dp[i][j][v], max(dp[i - 1][j][3], dp[i][j - 1][v - 1]) + C[i][j]);
                bug(dp[i][j][v]);
            }
        }
    }
    cout << dp[r][c][3];
	return 0;
}


Measured memory_bytes: 320280
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];

inline ll take_mod(ll a) { return (a % mod + mod) % mod; }

inline ll add(ll a, ll b) { return take_mod(a + b); }

inline ll sub(ll a, ll b) { return take_mod(a - b); }

inline ll mul(ll a, ll b) { return take_mod(a * b); }

inline ll pow(ll x, ll n) {
  ll res = 1LL;
  while (n > 0) {
    if (n & 1) res = mul(res, x);
    x = mul(x, x);
    n >>= 1;
  }
  return res;
}

ll mod_inv(ll x) { return pow(x, mod - 2); }

void make_fact(ll n) {
  fact[0] = 1;
  ll res = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = res;
    res = mul(res, i + 1);
  }
}

void make_invfact(ll n) {
  invfact[0] = 1;
  invfact[n] = mod_inv(fact[n]);
  for (int i = n - 1; i >= 1; i--) {
    invfact[i] = mul(invfact[i + 1], i + 1);
  }
}

ll perm(ll n, ll k) { return mul(fact[n], invfact[n - k]); }

ll comb(ll n, ll k) { return mul(mul(fact[n], invfact[n - k]), invfact[k]); }

int main() {
  ll n;
  cin >> n;
  map<ll, ll> lcm;
  ll ans = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    ans = add(ans, mod_inv(a));
    for (ll d = 2; d * d <= a; d++) {
      ll cd = 0;
      while (a % d == 0) {
        cd++;
        a /= d;
      }
      chmax(lcm[d], cd);
    }  // d
    if (a != 1) {
      chmax(lcm[a], 1LL);
    }
  }  // i

  ll L = 1;
  for (auto& kv : lcm) {
    ll p, cp;
    tie(p, cp) = kv;
    L = mul(L, pow(p, cp));
  }
  ans = mul(ans, L);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
//char a[55][55];
int dx[] = {1,0,-1,0,1,1,-1,-1};
int dy[] = {0,1,0,-1,1,-1,-1,1};
ll a[100];
int main()
{
	dhoom;
	string s;
	cin >> s;
	int cnt = 0;
	for(int i = 0 ; i < (int)s.size() ; i++)
	{
		if(s[i] == '1')
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int w,a,b;
	cin>>w>>a>>b;
	if(a<=b){
		if(a+w>=b){
			cout<<0<<endl;
		}
		
		else if(a+w<=b){
			cout<<b-a-w<<endl;
		}
	}
	
	else if(a>=b){
		if(b+w>=a){
			cout<<0<<endl;
		}
		
		else if(b+w<=a){
			cout<<a-b-w<<endl;
		}
	}
	
}

Measured memory_bytes: 256
#include<iostream>

int main(){
    int N;
    std::cin >> N;
    int maxCake = N / 4;
    int maxDonuts = N / 7;
    for(int i = 0; i <= maxCake; i++){
        for(int j = 0; j <= maxDonuts; j++){
            if(4 * i + 7 * j == N){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "No" << std::endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt int

// x文字目の時に，あまりiである数をカウント
var dp = [13]int{}

func main() {
	input := bufio.NewReader(os.Stdin)
	var S string
	fmt.Fscanf(input, "%s\n", &S)

	// 1234 % mod = ((1000%mod) + (200%mod) + (30%mod) + (4%mod))%mod

	dp[0] = 1
	for i := 0; i < len(S); i++ {
		var nextdp = [13]int{}
		num, _ := strconv.Atoi(string(S[i]))

		for k := 0; k < 10; k++ {
			if string(S[i]) == "?" || num == k {
				for j := 0; j < 13; j++ {
					nextdp[((j*10)+k)%13] += dp[j]
					nextdp[((j*10)+k)%13] %= mod
				}
			}
		}
		dp = nextdp
	}
	fmt.Println(dp[5])
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; i++ {
		fac[i] = fac[i-1] * i % mod
		inv[i] = mod - inv[mod%i]*(mod/i)%mod
		finv[i] = finv[i-1] * inv[i] % mod
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i][0] < a[j][0] }

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int s[3];
 for(int i= 0;i<3;i++){
   cin >> s[i];
 }
 for(int i= 0;i<1;i++){
   if((s[i]==5&&s[i+1]==5)||(s[i]==5&&s[i+2]==5)||(s[i+1]==5&&s[i+2]==5)){
     cout << "YES" << endl;
     return 0;
   }else{
     cout << "NO" << endl;
     return 0;
   }
 }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    vector<vector<int>> dp(100100,vector<int>(14,0));
    dp[0][0] = 1;
    for(int i = 0;i < s.size(); i++){
        for(int j = 0;j < 13; j++){
            if(s[i] == '?'){
                for(int k= 0; k < 10; k++){
                    dp[i+1][(j*10 + k) % 13] += dp[i][j];
                    dp[i+1][(j*10 + k) % 13] %= mod;
                }
            }else{
                int k = s[i] - '0';
                dp[i+1][(j*10 + k) % 13] += dp[i][j];
                dp[i+1][(j*10 + k) % 13] %= mod;
            }
        }
    }
    cout << dp[s.size()][5] << endl;
    return 0;
}

Measured memory_bytes: 11928
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int 
const LL MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.
string solve(LL n,LL l){
  string s;
  while(n>0){
    s.pb(n%2+'0');
    n/=2;
  }
  LL i,x=s.length();
  fo(i,0,l-x) s.pb('0');
  reverse(s.begin(), s.end());
  return s;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LL h,w,k,i,j,r,m,tot=0;cin>>h>>w>>k;
      string a[h];
      fo(i,0,h) cin>>a[i];
      fo(r,0,h){
        fo(m,0,w){
          if(a[r][m]=='#') tot++;
        }
      }
      LL wy=0;
      fo(i,0,(1<<h)-1){
        fo(j,0,(1<<w)-1){
          string s=solve(i,h),s1=solve(j,w);
          LL num=0;
          fo(r,0,h){
            fo(m,0,w){
              if(a[r][m]=='#'&&(s[r]=='1'||s1[m]=='1')) num++;
            }
          }
          if(tot-num==k) wy++;
        }
      }
      cout<<wy;
    }
    return 0;
}

Measured memory_bytes: 3636
import math

N = 100001   # N is max number
prime = [True]*(N+1)
prime[0] = False
prime[1] = False

R = int(math.sqrt(N))

for i in range(2, R+1):
    if prime[i]:
        cnt = 2
        while i * cnt <= N:
            prime[i * cnt] = False
            cnt += 1
# if prime[i] = True, i is prime number

def check(n):
    return prime[n] and prime[(n+1)//2]

imos = [0]*(N+2)
for i in range(1, N+1):
    if i % 2 == 1:
        if check(i):
            imos[i] += 1
for i in range(1, N+2):
    imos[i] = imos[i] + imos[i-1]

Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    ans = imos[r] - imos[l-1]
    print(ans)



Measured memory_bytes: 54232
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

# エラトステネスの篩の篩みたいに約数の個数をどんどん作っていくのは？


def ret_eratos(N: int):
    '''エラトステネスの篩'''
    '''is_primeは約数の個数'''
    is_prime = [0] * (N + 1)
    is_prime[0] = -2  # 0と1は素数ではない
    is_prime[1] = -1
    for i in range(2, N // 2 + 1):
        for j in range(i * 2, N + 1, i):  # iの倍数は素数でない
            is_prime[j] += 1
    for i in range(N + 1):
        is_prime[i] += 2
    return is_prime


N = a_int()
eratos = ret_eratos(N)
# print(eratos)
ans = 0
for k in range(1, N + 1):
    ans += k * eratos[k]
print(ans)

# でも多分TLEだなぁ


Measured memory_bytes: 147012
#include <stdio.h>

int main (void) 
{

    int n;
    int i;

    scanf("%d", &n);

    long A[n];
    long X = 0;
    int max = 0;

    for (i = 0; i < n; i++) {
        scanf ("%ld", &A[i]);
        
    }

    for (i = 0; i < n; i++) {
        if (max < A[i]) {
            max = A[i];
        }
        X += max - A[i];
    }

    printf("%ld", X);

    return 0;
}

Measured memory_bytes: 3276
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
//#define fi first
//#define se second
//#define P pair<int,int>
//#define PP pair<int,pair<int,int> >
//#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;

inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 105; 
char c[N][N];
int f[2][N][N][N], sum[N][N];  
inline void Max(int &x,int v) { if( v > x ) x = v; }
inline int Q(int x1,int x2,int y1,int y2) { 
	if( x1 > x2 || y1 > y2 ) return 0;
//	cout<<"Q "<<x1<<" "<<x2<<" "<<y1<<" "<<y2<<" "<<sum[x2][y2] + sum[x1-1][y1-1] - sum[x1-1][y2] - sum[x2][y1-1]<<endl;
	return sum[x2][y2] + sum[x1-1][y1-1] - sum[x1-1][y2] - sum[x2][y1-1];
}

int main() {
	int n = read(), m = read(), x, y;
	rep(i,1,n) scanf("%s",c[i]+1);
	rep(i,1,n) { 
		rep(j,1,m) { 
			if( c[i][j] == 'o' ) sum[i][j] = sum[i][j-1] + 1; 
			else sum[i][j] = sum[i][j-1];
			
			if( c[i][j] == 'E' ) x = i, y = j;
		}
	}
	rep(i,1,n) rep(j,1,m) sum[i][j] += sum[i-1][j];
	int now = 0, pre = 1;
	rep(i,0,y-1) { 
		swap(now,pre);
		rep(j,0,m-y) { 
			rep(k,0,x-1) { 
				rep(l,0,n-x) { 
					if( i < y - 1 ) { 
						if( j < y-i-1 ) Max(f[now][j][k][l],f[pre][j][k][l]+Q(max(x-k,l+1),min(x+l,n-k),y-i-1,y-i-1));
						else Max(f[now][j][k][l],f[pre][j][k][l]); 
					}
					if( j < m - y ) { 
						if( y+j+1 < m+1-i ) Max(f[pre][j+1][k][l],f[pre][j][k][l]+Q(max(x-k,l+1),min(x+l,n-k),y+j+1,y+j+1));
						else Max(f[pre][j+1][k][l],f[pre][j][k][l]);
					}
					if( k < x - 1 ) { 
						if( l < x-k-1 ) Max(f[pre][j][k+1][l],f[pre][j][k][l]+Q(x-k-1,x-k-1,max(y-i,j+1),min(y+j,m-i)));
						else Max(f[pre][j][k+1][l],f[pre][j][k][l]);
					}
					if( l < n - x ) { 
						if( x+l+1 < n+1-k ) Max(f[pre][j][k][l+1],f[pre][j][k][l]+Q(x+l+1,x+l+1,max(y-i,j+1),min(y+j,m-i)));
						else Max(f[pre][j][k][l+1],f[pre][j][k][l]);
					}
				}
			}
		}
	}
	cout<<f[pre][m-y][x-1][n-x]<<endl;
	return 0; 
}

Measured memory_bytes: 8960
import java.io.*
import java.util.*

fun solve(N: Int, M: Int, x: LongArray, y: LongArray, z: LongArray){
    val xyz = (0 until N).map { Triple(x[it], y[it], z[it]) }
    // +++ ++- +-- ... の場合全てを試す
    val signs = listOf(1, -1)
    val patterns = product(signs, signs, signs)
    var ans = 0L
    for (pattern in patterns){
        val ret = xyz.map{
            pattern[0]*it.first + pattern[1]*it.second + pattern[2]*it.third
        }.sortedDescending()
        ans = Math.max(ans, ret.slice(0 until M).sum())
    }
    println(ans)
    return
}


fun <T> product(vararg lists: List<T>): List<List<T>> {
    fun <T> oneDimTimesOne(left: List<T>, right: List<T>): List<List<T>> =
            left.flatMap { lelem -> right.map { relem -> listOf(lelem, relem) } }

    fun <T> twoDimTimesOne(left: List<List<T>>, right: List<T>): List<List<T>> {
        val product = mutableListOf<List<T>>()
        for (list in left) {
            for (element in right) {
                product.add(list + listOf(element))
            }
        }
        return product
    }
    require(lists.size >= 2)
    return lists
            .drop(2)
            .fold(oneDimTimesOne(lists[0], lists[1])) { acc, suc -> twoDimTimesOne(acc, suc) }
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toLong()
    val M = sc.next().toLong()
    val x = LongArray(N.toInt())
    val y = LongArray(N.toInt())
    val z = LongArray(N.toInt())
    for (i in 0 until N.toInt()) {
        x[i] = sc.next().toLong()
        y[i] = sc.next().toLong()
        z[i] = sc.next().toLong()
    }
    solve(N.toInt(), M.toInt(), x, y, z)
}



Measured memory_bytes: 36412
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n = 5;
    vi a(n); for(auto& e : a) cin >> e;
    int K; cin >> K;

    bool ok = true;
    rep(i, n){
        rep(j, n){
            ok &= (abs(a[i] - a[j]) <= K);
        }
    }

    cout << (ok ? "Yay!":":(") << endl;

    return 0;
}


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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    int X,N; cin >> X >> N;
    vi p(N); rep(i,N) cin >> p[i];
    vector<bool> bitmap(105,false);
    rep(i,N) bitmap[p[i]] = true;
    if(!bitmap[X]){
        cout << X << endl;
        return 0;
    }

    int ans;
    rep(i,51){
        int left = X-i-1;
        int right = X+i+1;
        if(left >= 0 && !bitmap[left]) {
            ans = left;
            break;
        }
        if(right <= 101 && !bitmap[right]) {
            ans = right;
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,c=0;
  double n;
  cin>>n;
  for(i=1;i<=n;i++)
  {
    if(i%2==1)
      c++;
  }
  cout<<((double)c/n)<<endl;
}


Measured memory_bytes: 256
// INCLUDE LIST
#include <cstdio>
#include <bitset>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min(c, b) << " " << max(0, (b + c) - a) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll n, k;
ll a[109];
ll dp[100009];
ll f(ll x){
    if(dp[x] != -1)
        return dp[x];
    dp[x] = 0;
    for(int i = 0; i < n; ++i)
        if(x-a[i] >= 0 && f(x-a[i]) == 0){
            dp[x] = 1;
            break;
        }
    return dp[x];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n >> k;
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    for(ll i = 0; i <= k; ++i)
        dp[i] = -1;
    if(f(k))
        cout << "First\n";
    else
        cout << "Second\n";
}

Measured memory_bytes: 4224
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 k;
    cin >> k;
    i64 x = min(i64(50), k / i64(1e16) + 1);
    if (x == 1)
    {
        cout << 2 << endl;
        if (k & 1)
        {
            cout << k / 2 << ' ' << k / 2 + 3 << endl;
        }
        else
        {
            cout << k / 2 + 1 << ' ' << k / 2 + 1 << endl;
        }
        return;
    }
    i64 lo = 0, hi = 1e16 + 1;
    while (lo + 1 < hi)
    {
        i64 m = (hi + lo) / 2;
        (m * x <= k ? lo : hi) = m;
    }
    i64 a = lo, off = 0;
    int up = x;
    cout << x << endl;
    akari<i64> ans(x);
    for (int i = 0; i < x; i++)
    {
        ans[i] = a + x - 1 + off;
        if (a * i + (a - 1) * (x - i) == k)
        {
            off = 1;
            up = i;
        }
    }
    sort(ans.rbegin(), ans.rend());
    for (i64 i = 0; i < k - a * x; i++)
    {
        ans[i % up] += x;
        for (int j = 0; j < x; j++)
        {
            if (j == i % up)
            {
                continue;
            }
            ans[j]--;
        }
    }
    for (int i = 0; i < x; i++)
    {
        cout << ans[i] << ' ';
    }
    cout << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
loop do
  x, y  = gets.split.map(&:to_i)

  if x == 0 && y == 0
    break
  else
    case x <=> y
    when -1, 0
      a, b = x, y
    when 1
      a, b = y, x
    end
    puts "#{a} #{b}"
  end
end

Measured memory_bytes: 6104
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct UnionFind{
  vector<int> data;
  int siz;
  UnionFind(int size){
    siz=size;
    data=vi(size,-1);
  }
  bool Union(int x,int y){
    x=root(x);y=root(y);
    if(x==y)return 0;
    siz--;
    if(data[y]<data[x])swap(x,y);
    data[x]+=data[y],data[y]=x;
    return 1;
  }
  bool Find(int x,int y){
    return root(x)==root(y);
  }
  int root(int x){
    return data[x]<0 ? x : data[x]=root(data[x]);
  }
  int size(int x){
    return -data[root(x)];
  }
};
int main(){
  int n,x,y;
  cin>>n>>x>>y;
  vp A(n),B(n);
  int h=0;
  rep(i,n){
    int a,b;
    cin>>a>>b;
    if(a==1||b==1||a==x||b==y)h=1;
    A[i]={a,i};
    B[i]={b,i};
  }
  UnionFind uf(n);
  sort(all(A));sort(all(B));
  rep(i,n-1)if(A[i].first==A[i+1].first)uf.Union(A[i].second,A[i+1].second);
  rep(i,n-1)if(B[i].first==B[i+1].first)uf.Union(B[i].second,B[i+1].second);
  if(uf.siz==1)h=1;
  int out=n+uf.siz-1-h;
  cout<<out<<endl;
}

Measured memory_bytes: 3872
//Be Name Khoda, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stweight++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <fstream>


using namespace std;

const int N = 5000 + 5;

int n;
int a[4];
int b[4];
int dp1[N];
long long dp2[N * N];
long long ans = 0;


int main() 
{
    cin >> n;
    for (int i = 1; i < 4; i++) 
    {
        cin >> a[i];
    }
    for (int i = 1; i < 4; i++) 
    {
        cin >> b[i];
    }
    a[0] = 1;
    b[0] = 1;
    for (int i = 0; i < 4; i++) 
    {
        for (int j = a[i]; j < N; j++) 
        {
            dp1[j] = max(dp1[j], dp1[j - a[i]] + b[i]);
        }
    }
    ans = dp1[n];
    for (int i = 0; i < 4; i++) 
    {
        for (int j = b[i]; j < N * N; j++) 
        {
            dp2[j] = max(dp2[j], dp2[j - b[i]] + a[i]);
        }
    }
    ans = dp2[ans];
    cout << ans << endl;
}




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

typedef long long int ll;
typedef vector<int> vi;            typedef vector<ll> vl;
typedef vector<vi> vvi;         typedef vector<vl> vvl;
typedef pair<int, int>     pii;    typedef pair<ll, ll> pll;
typedef vector<pii> vii;         typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define rforne(i,n) for(int i=n;i>=1;i--)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
const double pi = 3.14159265358979323846; 
#ifdef KARAN
    #include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
    while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}

void solve(){
    int n, m; cin>>n>>m;
    vvi adj(n);
    graph(adj, m);

    queue<int> q;
    vi p(n, -1);
    q.push(0);
    p[0] = 0;
    while (!q.empty()){
        int v = q.front();
        q.pop();
        for (int u : adj[v]){
            if(p[u]==-1){
                q.push(u);
                p[u] = v;
            }
        }
    }
    forn(i, n)
        if(p[i]==-1)
            { cout<<"No"<<endl; return;}
    cout<<"Yes"<<endl;
    forne(i, n-1)
        cout<<p[i]+1<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef KARAN
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        freopen("err.txt", "w", stderr);
    #endif
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 10160
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int a,b,t;
  cin >> a >> b >> t;
  cout << t/a*b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=2e5+10;

int main()
{
	int N,pre[maxn];
	scanf("%d",&N);
	for(int i=0;i<N;i++)
		scanf("%d",&pre[i]);
	sort(pre,pre+N);
	for(int i=0;i<N-1;i++)
	{
		if(pre[i]==pre[i+1])
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 4544
S = input()

s_i = 0
flag = True
while s_i < len(S) and flag:
    
    if S[s_i:s_i+7] == 'dreamer' and S[s_i:s_i+10]  != 'dreamerase':
        s_i += 7
    elif S[s_i:s_i+5] == 'dream':
        s_i += 5
    elif S[s_i:s_i+6] == 'eraser':
        s_i += 6
    elif S[s_i:s_i+5] == 'erase':
        s_i += 5
    else:
        flag = False
if flag:
    print('YES')
else:
    print('NO')

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

typedef long long LL;


int main(){
	LL n, m;
	cin>>n;
	m=n;
	LL w=0;
	while(n){
		w+=n%10;
		n/=10;
	}
	
	cout<<(m%w?"No":"Yes")<<"\n";
	return 0;
}


Measured memory_bytes: 256
n, x, y = map(int, input().split())
li = [0] * (n - 1)
num = 0

for i in range(1, n):
    for j in range(i + 1, n + 1):
        num = min(j-i, abs(i-x)+abs(j-y)+1)
        li[num - 1] += 1

for i in li:
    print(i)

Measured memory_bytes: 9340
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
int N;
int G[1000][1000];
bool used[1000];
void dfs(int u) {
    if(used[u]) return;
    used[u] = true;
    REP(i, N) if(G[u][i] && !used[i]) dfs(i);
}

char memo[1010][1010][2][2];
int rec(int odd, int even, int t, int p) {
    if(odd + even == 2) {
        return p == 0;
    } else {
        char& res = memo[odd][even][t][p];
        if(res != -1) return res;

        if(odd - 2 >= 0 && !rec(odd - 2, even + 1, t ^ 1, p ^ 1)) return res = true;
        if(even - 2 >= 0 && !rec(odd, even - 1, t ^ 1, p)) return res = true;
        if(odd - 1 >= 0 && even - 1 >= 0 && !rec(odd, even - 1, t ^ 1, p)) return res = true;
        return res = false;
    }
}


int main(){
    while(cin >> N) {
        REP(i, N) {
            string s;
            cin >> s;
            REP(j, N) G[i][j] = s[j] == 'Y';
        }
        int odd = 0, even = 0;
        int E = 0;
        bool fill[1010] = {};
        REP(i, N) if(!fill[i]) {
            memset(used, 0, sizeof(used));
            dfs(i);
            vector<int> vs;
            REP(j, N) if(used[j]) {
                fill[j] = true;
                vs.push_back(j);
            }
            for(int u : vs) for(int v : vs) if(u < v && !G[u][v]) {
                E++;
            }
            if(vs.size() % 2 == 0) {
                even ++;
            } else {
                odd ++;
            }
        }

        E += (odd + even) - 1;

        //printf("odd = %d even = %d E = %d\n", odd, even, E);

        memset(memo, -1, sizeof(memo));
        if(rec(odd, even, 0, E % 2)) {
            cout << "Taro" << endl;
        } else {
            cout << "Hanako" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 9192
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5;
ll a[N];
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    int cnt = 1;
    int ans = 0;
    int x;
    for(int i = 1; i <= n; i++){
        cin >> x;
        if(x == cnt){
            cnt++;
        }
        else{
            ans++;
        }
    }
    cout << (ans == n ? -1 : ans);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}





int main() {
    int N; 
    long long K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i], --A[i];

    deque<int> a; // 繰り返しの部分
    vector<bool> seen(N, false); // 一度見たかどうか
    int cur = 0;
    while (true) {
        // 一度通った頂点を見つけたときの処理
        if (seen[cur]) {
            while (a[0] != cur) {
                // 最初の余計な数手分を除去する
                --K;
                a.pop_front();

                // 繰り返す前に K が限界になったらリターン
                if (K == 0) {
                    cout << a[0]+1 << endl;
                    return 0;
                }
            }
            break;
        }
        // 最初は愚直にシミュレーションしつつ、履歴をメモしていく
        a.push_back(cur);
        seen[cur] = true;
        cur = A[cur];
    }
    cout << a[K % a.size()]+1 << endl;
}


Measured memory_bytes: 4848
#include <stdio.h>
int main(void){
    int i,j,n,m;
    scanf("%d%d\n",&n,&m);
    int a[31]={0};
    for (i=0;i<n;i++){
	int k;
	scanf("%d",&k);
	for (j=0;j<k;j++){
	    int l;
	    scanf("%d",&l);
	    a[l]++;
	    }
	}
    int x=0;
    for (i=1;i<=m;i++){
	if(a[i]==n)x++;
	}
    printf("%d\n",x);
    return 0;
    }



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

int main()
{
	int A, B, X;
    scanf("%d %d %d", &A, &B, &X);
    if(X <= A + B && A <= X)
        printf("YES\n");
    else
        printf("NO\n");
}



Measured memory_bytes: 128
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = [INT() for _ in range(N)]

def gcd(a ,b):
	while b:
		a, b = b, a%b
	return a

def lcm(a, b):
	return a * b // gcd(a, b)

ans = A[0]
for i in range(1, N):
	ans = ans * A[i] // gcd(ans, A[i])

print(ans)

Measured memory_bytes: 38424
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        StringBuffer n = new StringBuffer(scanner.next());
        for(int i = 0; i < n.length(); i++){
            switch (n.charAt(i)){
                case '1':
                    n.setCharAt(i, '9');
                    break;
                case '9':
                    n.setCharAt(i, '1');
                    break;
            }
        }
        System.out.println(n);
    }
}

Measured memory_bytes: 21460
import numpy as np

n, a, b = map(int, raw_input().split())
l = []

for i in range(n):
	l.append(input())
ll = np.array(l)
ll.sort()
ll = ll[::-1]

# print count
def solve(count):
	q = ll - b * count
	t = q > 0

	if a > b:
		p = (q - 1) / (a - b) + 1
	else:
		p = q
	p = p[p > 0]
	if p.sum() <= count:
		return True
	else:
		return False

l = 1
r = ll[0] / b + 1
while r - l > 1:
	m = (l + r) / 2
	if solve(m):
		r = m
	else:
		l = m

if r == 2:
	if solve(1):
		r = 1

print r

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

using namespace std;

#define loop(i, init, val) for(i = init; i < val; i++)
#define srt(v) sort(v.begin(), v.end())

int main(){
	int i;
	int n,k;
	cin >> n >> k;

	vector<int> h(n);
	loop(i, 0, n)	cin >> h[i];

	srt(h);
	long long sum = 0;
	loop(i, 0, int(h.size() - k)){
		sum += h[i];
	}

	cout << sum << endl;
}

Measured memory_bytes: 1024