akhauriyash/Code-Regression huggingface dataset:
// Contest: AtCoder Beginner Contest 146 (https://atcoder.jp/contests/abc146)
// Problem: F: Sugoroku (https://atcoder.jp/contests/abc146/tasks/abc146_f)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int n, m; string s; cin >> n >> m >> s;
    if (s[0] == '1')
        cout << "-1\n", exit(0);

    vpi dp(n + 1);
    dp[n] = {0, n};
    int n1 = n, n2 = n;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == '1')
            continue;
        if (n2 - i <= m)
            n1 = i, dp[i] = {dp[n2].first + 1, n2};
        else if (n1 - i <= m)
            dp[i] = {dp[n1].first + 1, n1}, n2 = n1, n1 = i;
        else
            cout << "-1\n", exit(0);
    }

    int i = 0;
    while (i < n) {
        cout << (dp[i].second - i) << ' ';
        i = dp[i].second;
    }
    cout << '\n';

    return 0;
}

Measured memory_bytes: 1488
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 4e18;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

// LIS　最長増加部分列(非減少)
int LIS(const vector<int> &A) {
    vector<int> lis(A.size(), INF);
    for (int i = 0; i < A.size(); i++)
    {
        lis[upper_bound(ALL(lis), A[i]) - lis.begin()] = A[i];
    }
    return lower_bound(ALL(lis), INF) - lis.begin();
}

int main() {
    int n; input(n);
    vector<int> a(n),b(n); input(a);
    REP(i, n) {
        b[n - 1 - i] = a[i];
    }
    cout << LIS(b) << endl;
    getchar(); getchar();
}

Measured memory_bytes: 1408
N,*as=$<.read.split.map(&:to_i)

arr = Array.new(8,0)
x=0

as.each do |a|
    if a < 3200
        arr[a/400] = 1
    else
        x += 1
    end
end

n = arr.inject(&:+)
min = [1,n].max
# max = [8,n+x].min
max = n+x

puts "#{min} #{max}"

Measured memory_bytes: 1788
from sys import stdin, stdout
def readLine_int_list():return list(map(int, stdin.readline().split()))

def main():
    n,k = readLine_int_list()
    d = readLine_int_list()
    i = [i for i in range(10) if not i in d]
    for ii in range(n, 10**9):
        l = [int(x) for x in list(str(ii))]
        ll =[q for q in l if q in d]
        if len(ll) == 0:
            print(ii)
            break
if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	if(a==1)a+=13;
	if(b==1)b+=13;
	if(a>b)cout<<"Alice"<<endl;
	else if(a<b)cout<<"Bob"<<endl;
	else cout<<"Draw"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, T;cin>>N>>T;
	int a, b;
	priority_queue< pair<int,int> > pq;
	while(N--){
		cin>>a>>b;
		if(b <= T) pq.push({a,b});
	}
	if(pq.size() == 0){
		cout<<"TLE";
		return 0;
	}
	while(pq.size()>1)pq.pop();
	cout<<pq.top().first;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define assign(x,val) memset(x,val,sizeof(x))
#define motherfucker  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(ll i=0;i<n;++i)
#define for1(i,n) for(ll i=1;i<=n;++i)
#define ford(i,n) for(ll i=n;i>=1;--i)
#define forg(i,a,b) for(ll i=a;i<b;++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpl;
long long mod = 1000000007;
const long double PI = (long double)(3.1415926535897932384626433832795);
 
 
void solve(){
	int n, k;cin>>n>>k;
	int r, S, p;cin>>r>>S>>p;
	map<char, int> mp;
	mp['s'] = S;
	mp['r'] = r;
	mp['p'] = p;
	string t;cin>>t;
	string s = "";
	ll ans = 0;
	for0(i,n){
		if(t[i]=='r'){
			s += 'p';
		} else if(t[i]=='s'){
			s += 'r';
		} else{
			s += 's';
		}
		ans += mp[s[i]];
	}
	for(int i = k; i < n; ++i){
		if(s[i]==s[i-k]){
			ans -= mp[s[i]];
			set<char> se = {'r', 'p', 's'};
			se.erase(s[i-k]);
			if(i+k < n){
				se.erase(s[i+k]);
			}
			s[i] = *se.begin();
		}
	}
	cout<<ans<<endl;
}
 
int main(){
	motherfucker
	ll t = 1;
	//cin>>t;
	for0(i, t){
		solve();
	}
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <vector>
#include <utility>
#include <cstring>
#include <algorithm>
using namespace std;
typedef pair<int,int> ii;
int n,m;
vector<ii> edges;
vector<int> al[100005];
int memo[200005];
vector<int> fw[100005],bw[100005];
inline int rev(int i){
    return i^1;
}
inline int mul(int i,int j){
    return ((long long)i*j)%m;
}
int dfs(int i){
    if (memo[i]!=-1) return memo[i];
    long long ans=1;
    for (vector<int>::iterator it=al[edges[i].second].begin();it!=al[edges[i].second].end();it++){
        if (edges[i].first==edges[*it].second) continue;
        ans=(ans*(dfs(*it)+1))%m;
    }
    return memo[i]=ans;
}
void dfs_fill(int i,int p){
    fw[i].push_back(1);
    for (vector<int>::iterator it=al[i].begin();it!=al[i].end();it++){
        fw[i].push_back(mul(fw[i].back(),dfs(*it)+1));
    }
    bw[i].push_back(1);
    for (vector<int>::reverse_iterator it=al[i].rbegin();it!=al[i].rend();it++){
        bw[i].push_back(mul(bw[i].back(),dfs(*it)+1));
    }
    reverse(bw[i].begin(),bw[i].end());

    for (int x=0;x<al[i].size();x++){
        memo[rev(al[i][x])]=mul(fw[i][x],bw[i][x+1]);
    }

    for (vector<int>::iterator it=al[i].begin();it!=al[i].end();it++){
        if (edges[*it].second==p) continue;
        dfs_fill(edges[*it].second,i);
    }
}
int main(){
    memset(memo,-1,sizeof(memo));
    scanf("%d%d",&n,&m);
    int a,b;
    int counter=0;
    for (int x=1;x<n;x++){
        scanf("%d%d",&a,&b);
        edges.push_back(ii(a,b));
        al[a].push_back(counter++);
        edges.push_back(ii(b,a));
        al[b].push_back(counter++);
    }

    for (vector<int>::iterator it=al[1].begin();it!=al[1].end();it++){
        dfs(*it);
    }

    fw[1].push_back(1);
    for (vector<int>::iterator it=al[1].begin();it!=al[1].end();it++){
        fw[1].push_back(mul(fw[1].back(),dfs(*it)+1));
    }
    bw[1].push_back(1);
    for (vector<int>::reverse_iterator it=al[1].rbegin();it!=al[1].rend();it++){
        bw[1].push_back(mul(bw[1].back(),dfs(*it)+1));
    }
    reverse(bw[1].begin(),bw[1].end());

    for (int x=0;x<al[1].size();x++){
        memo[rev(al[1][x])]=mul(fw[1][x],bw[1][x+1]);
    }

    dfs_fill(1,-1);

    for (int x=1;x<=n;x++) printf("%d\n",bw[x][0]);
}


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

long gcd(long a, long b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

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

int main() {
  long a, b;
  cin >> a >> b;
  cout << lcm(a,b) << endl;
  
}

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

struct LR{
  int W;
  int E;
};


int main(){
  int n,maxans = 1000000;
  char EW;
  LR  right,left;
  string std;
  right.W = right.E = 0;
  left.W = left.E = 0;
  cin >> n;
  cin >> std;
  for(int i = 0; i < n; i++){
    if(std[i] == 'W') right.W ++;
    else right.E ++;
  }
  for(int i = 0; i < n;i++){
    if(std[i] == 'W'){
      right.W --;
    }
    else
    {
      right.E --;
    }
    maxans = min(left.W + right.E , maxans);
    if(std[i] == 'W'){
      left.W ++;
    }
    else
    {
      left.E ++;
    }
  }

  cout << maxans << endl;
  return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  string str;
  while (cin >> str) {
    if (str == "-") break;
    
    int m; cin >> m;
    string s = str;
    for (int i = 0; i < m; i++) {
      int h; cin >> h;
      int s1 = 0, e1 = h;
      int s2 = h, e2 = s.length();
      s = s.substr(s2, e2) + s.substr(s1, e1);
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <functional>
#include <cmath>
#include <map>
using namespace std;
int n, a, b;
int main() {
	cin >> n >> a >> b;
	if ((b - a) % 2 == 1) cout << "Borys" << endl;
	else cout << "Alice" << endl;
	return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	cin >> N;
	vector<double> v(N);
	REP(i, N) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	REP(i, N - 1) {
		v[i + 1] = (v[i] + v[i + 1]) / 2;
	}
	cout << v[N - 1] << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
    ll N, M;
    cin>>N>>M;
    vector<ll> A(M);
    ll Sum=0;
    rep(i, M){
        cin>>A[i];
        Sum+=A[i];
    }
    if(N-Sum>=0){
        cout<<N-Sum<<endl;
    }
    else{
        cout<<-1<<endl;
    }

}



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


struct Point {
    int x, y;
    Point() {}
    Point(int x, int y): x(x), y(y) {}
};


int main() {
    int H, W;
    std::cin >> H >> W;
    Point start, goal;
    std::cin >> start.y >> start.x >> goal.y >> goal.x;
    start.x--; start.y--; goal.x--; goal.y--;

    std::vector<std::vector<char>> road(H, std::vector<char>(W));
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {
            std::cin >> road[y][x];
        }
    }

    auto compare = [](std::pair<int, Point> a, std::pair<int, Point> b) {
        return a.first > b.first;
    };
    std::priority_queue<std::pair<int, Point>, std::vector<std::pair<int, Point>>, decltype(compare)> que {compare};

    std::vector<std::vector<int>> map(H, std::vector<int>(W, -1));
    map[start.y][start.x] = 0;
    que.push(std::make_pair(0, start));
    while (!que.empty()) {
        auto top = que.top();
        que.pop();
        auto pos = top.second;
        if (pos.x == goal.x && pos.y == goal.y) {
            std::cout << map[pos.y][pos.x] << std::endl;
            return 0;
        }
        if (pos.y + 1 < H && road[pos.y + 1][pos.x] == '.') {
            if (map[pos.y + 1][pos.x] == -1 || top.first < map[pos.y + 1][pos.x]) {
                Point next(pos.x, pos.y + 1);
                map[next.y][next.x] = top.first;
                que.push(std::make_pair(top.first, next));
            }
        }
        if (pos.y - 1 >= 0 && road[pos.y - 1][pos.x] == '.') {
            if (map[pos.y - 1][pos.x] == -1 || top.first < map[pos.y - 1][pos.x]) {
                Point next(pos.x, pos.y - 1);
                map[next.y][next.x] = top.first;
                que.push(std::make_pair(top.first, next));
            }
        }
        if (pos.x + 1 < W && road[pos.y][pos.x + 1] == '.') {
            if (map[pos.y][pos.x + 1] == -1 || top.first < map[pos.y][pos.x + 1]) {
                Point next(pos.x + 1, pos.y);
                map[next.y][next.x] = top.first;
                que.push(std::make_pair(top.first, next));
            }
        }
        if (pos.x - 1 >= 0 && road[pos.y][pos.x - 1] == '.') {
            if (map[pos.y][pos.x - 1] == -1 ||
                top.first < map[pos.y][pos.x - 1]) {
                Point next(pos.x - 1, pos.y);
                map[next.y][next.x] = top.first;
                que.push(std::make_pair(top.first, next));
            }
        }

        for (int y = std::max(0, pos.y - 2); y < std::min(pos.y + 3, H); y++) {
            for (int x = std::max(0, pos.x - 2); x < std::min(pos.x + 3, W); x++) {
                if (map[y][x] == -1 && road[y][x] == '.') {
                    map[y][x] = top.first + 1;
                    que.push(std::make_pair(top.first + 1, Point(x, y)));
                }
            }
        }
    }
    std::cout << map[goal.y][goal.x] << std::endl;
}


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

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d", &t)
#define SCLD(t) scanf("%ld", &t)
#define SCLLD(t) scanf("%lld", &t)
#define SCC(t) scanf("%c", &t)
#define SCS(t) scanf("%s", t)
#define SCF(t) scanf("%f", &t)
#define SCLF(t) scanf("%lf", &t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i = j; i < k; i += in)
#define RFOR(i, j, k, in) for (int i = j; i >= k; i -= in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<VPII> VVPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef map<int, int> MII;
typedef unordered_map<int, int> UMII;
typedef set<int> SI;
typedef unordered_set<int> USI;
typedef multiset<int> MSI;
typedef unordered_multiset<int> UMSI;
typedef long long ll;
typedef unsigned long long ull;

/****** Template of some basic operations *****/
template <typename T, typename U>
inline void amin(T &x, U y)
{
	if (y < x)
		x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y)
{
	if (x < y)
		x = y;
}
/**********************************************/

/******* Debugging Class Template *******/
struct dummy_struct
{
	static bool a_very_long_variable_name_that_i_wont_happen_to_use_it_again;

	static void debug(string seperator)
	{
		cerr << endl;
		a_very_long_variable_name_that_i_wont_happen_to_use_it_again = true;
	}

	template <typename T, typename... Args>
	static void debug(string seperator, T &&top, Args &&... args)
	{
		if (a_very_long_variable_name_that_i_wont_happen_to_use_it_again)
		{
			a_very_long_variable_name_that_i_wont_happen_to_use_it_again = false;
		}
		else
		{
			cerr << seperator;
		}
		cerr << top;
		debug(seperator, args...);
	}
};
bool dummy_struct::a_very_long_variable_name_that_i_wont_happen_to_use_it_again = true;
template<typename... Args>
void debug(Args&&... args)
{
	dummy_struct::debug(forward<Args>(args)...);
}


int main()
{
    int n; cin >> n;
    int res=0;
    for (int i = 1; i <= n; ++i)
    {
        int t; cin >> t;
        if (t & 1 && i & 1)
            ++res;
    }
    cout << res << endl;
}

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

int main() {
  int N, M; cin >> N >> M;
  vector<int> A(M);
  for (int i = 0; i < M; i++) cin >> A[i];
  
  
  int hw = 0;
  for (int i = 0; i < M; i++) hw += A[i];
  
  int ans = N - hw;
  
  if (ans < 0) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> l(n + 1);
  vector<int> r(n);
  l[0] = 0;
  repz(i, 1, n + 1) l[i] = max(l[i - 1], a[i - 1]);
  r[n] = 0;
  for (int i = n - 2; i >= 0; i--) r[i] = max(a[i + 1], r[i + 1]);
  repz(i, 0, n) cout << max(l[i], r[i]) << endl;
  return 0;
}


Measured memory_bytes: 3968
object Main extends App{
  import scala.io.StdIn._

  var n = readLine.trim.toInt
  while (n != 0) {
    val nums = readLine.trim.split(' ').map(_.toDouble)
    val avg = nums.sum / n
    println(nums.count(_ <= avg))
    n = readLine.trim.toInt
  }
}


Measured memory_bytes: 56636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll dp[301][301][301];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,t;
    cin>>n>>t;
    ll h[n];
    map<ll,ll> mp;
    if(n==t){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        cin>>h[i];
        mp[h[i]]=1;
    }
    mp[0]=0;
    vector<ll> inv;
    int cnt=0;
    for(auto &i:mp){
        i.second = cnt;
        cnt++;
        inv.push_back(i.first);
    }
    ll INF = 1e15;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=t;j++){
            for(int k=0;k<cnt;k++){
                dp[i][j][k] = INF;
            }
        }
    }
    dp[0][0][0] = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=t;j++){
            for(int k=0;k<cnt;k++){
                // 変えない
                ll ret = dp[i][j][k];
                ll now = mp[h[i]];
                if(k < now) ret += h[i] - inv[k];
                dp[i+1][j][now] = min(dp[i+1][j][now], ret);

                // 変える
                if(j+1<=t) dp[i+1][j+1][k] = min(dp[i+1][j+1][k], dp[i][j][k]);
            }
        }
    }
    ll ans = 1e18;
    for(int i=0;i<=t;i++){
        for(int j=0;j<cnt;j++){
            ans = min(ans,dp[n][i][j]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 212992
import math

N = int(input())
coordinates = []
for i in range(N):
    x, y = map(int, input().split())
    coordinates.append([x, y])

def calc_distance(a, b):
    return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)
num = 0
d = 0
for i in range(N):
    for j in range(i+1, N):
        num += 1
        d += calc_distance(coordinates[i], coordinates[j])

print(d / N * 2)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int x,y;
	while(~getII(x,y)) printf("%d",x+y/2);
}


Measured memory_bytes: 768
import sys
input = sys.stdin.readline
import numpy as np
n = int(input()) 
num = [input() for _ in range(n)] 
num = np.array(num).astype("int64")
#ma=max(num)
#ind=num.index(ma)
sorted_num=sorted(num)
ma=sorted_num[-1]
ma2=sorted_num[-2]
for i in range(n):
    if ma != num[i]:
        print(str(ma).strip())
    else:
        print(str(ma2).strip())

Measured memory_bytes: 38356
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"strings"
)

// Node 頂点
type Node struct {
	gid  int   // グループID
	edge []int // 隣接辺
}

// NoID グループIDなし
const NoID = -1

// NewNode 頂点の生成
func NewNode() *Node {
	return &Node{gid: NoID, edge: []int{}}
}

func parseNode(nodes []*Node, gid int, queue []int) {
	if len(queue) == 0 {
		return
	}
	var nextQ []int
	for _, id := range queue {
		node := nodes[id]
		if node.gid == NoID {
			node.gid = gid
			for _, edge := range node.edge {
				nextQ = append(nextQ, edge)
			}
		}
	}
	parseNode(nodes, gid, nextQ)
	return
}
func digNode(nodes []*Node, id, gid int) {
	node := nodes[id]
	if node.gid != NoID {
		// 探索済み
		return
	}
	node.gid = gid
	for _, edge := range node.edge {
		digNode(nodes, edge, gid)
	}
	return
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	n, m := eGetInt2(scanner)

	nodes := make([]*Node, n)
	for i := 0; i < n; i++ {
		nodes[i] = NewNode()
	}

	for i := 0; i < m; i++ {
		a, b := eGetInt2(scanner)
		nodes[a].edge = append(nodes[a].edge, b)
		nodes[b].edge = append(nodes[b].edge, a)
	}

	for i := 0; i < n; i++ {
		// 幅優先探索
		// gid := i
		// queue := []int{i}
		// parseNode(nodes, gid, queue)

		// 深さ優先探索
		digNode(nodes, i, i)
	}

	q := eGetInt(scanner)
	for i := 0; i < q; i++ {
		a, b := eGetInt2(scanner)
		if nodes[a].gid == nodes[b].gid {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
}

func eGetInt(scanner *bufio.Scanner) int {
	t := eAtoi(strings.Fields(eGetline(scanner)))
	return t[0]
}
func eGetInt2(scanner *bufio.Scanner) (int, int) {
	t := eAtoi(strings.Fields(eGetline(scanner)))
	return t[0], t[1]
}

func eGetline(p *bufio.Scanner) string {
	if !p.Scan() {
		if err := p.Err(); err != nil {
			log.Fatal(err.Error())
		}
		return ""
	}
	return p.Text()
}

func eAtoi(s []string) []int {
	ints := make([]int, len(s))
	var err error
	for i, e := range s {
		ints[i], err = strconv.Atoi(e)
		if err != nil {
			log.Fatal(err.Error())
		}
	}
	return ints
}



Measured memory_bytes: 27124
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    int a,b;
    cin>>a>>b;
    if(a<=5){
        cout<<0<<endl;
    }else if(a<=12){
        cout<<b/2<<endl;
    }else{
        cout<<b<<endl;
    }
 
    return 0;
}

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

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

  ll N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];

  ll s = 0, s2 = 0;
  ll MOD = 1e9 + 7;
  ll mod2 = 5e8 + 4;
  for (ll i = 0; i < N; i++) {
    s += A[i];
    s2 += (A[i] * A[i] % MOD);
    s %= MOD;
    s2 %= MOD;
  }

  ll ans = s * s % MOD;
  ans -= s2;
  ans = (ans + MOD) % MOD;
  ans = (ans * mod2) % MOD;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 4780
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	public static void solve() {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        if(a >= b) out.println("delicious");
        else if(x >= b - a) out.println("safe");
        else out.println("dangerous");
        out.flush();
	}
}

Measured memory_bytes: 21716
#include<stdio.h>
int main(){
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-(h*3600+m*60);
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
#define maxn 400010
#define ll long long
#define ull unsigned long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define pii pair<int, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define IL inline
#define ss system
using namespace std;

ll fac[maxn], ifac[maxn];
const ll p = 1e9 + 7;
template <class T> void read (T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch))
    fl |= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
ll pw(ll a, ll b) {
  ll ret = 1;
  while (b) {
    if (b & 1)
      ret = ret * a % p;
    a = a * a % p, b >>= 1;
  }
  return ret;
}
ll C(int a, int b) {
  return a < b || b < 0 ? 0 : fac[a] * ifac[b] % p * ifac[a - b] % p;
}
void init() {
  fac[0] = 1;
  for (int i = 1; i < maxn; i++) {
    fac[i] = fac[i - 1] * i % p;
  }
  ifac[maxn - 1] = pw(fac[maxn - 1], p - 2);
  for (int i = maxn - 2; ~i; i--) {
    ifac[i] = ifac[i + 1] * (i + 1) % p;
  }
}
int main() {
  int n, a, b, c;
  cin >> n >> a >> b, c = a + b, a = 1LL * a * pw(c, p - 2) % p, b = 1LL * b * pw(c, p - 2) % p, init();
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans = (ans + C(n - 1 + i, n - 1) * pw(a, n) % p * pw(b, i) % p * (n + i)) % p;
    ans = (ans + C(n - 1 + i, n - 1) * pw(b, n) % p * pw(a, i) % p * (n + i)) % p;
  }
  printf("%lld\n", ans * 100 % p * pw(c, p - 2) % p);
  return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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 = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll n;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sort(all(v));
    reverse(all(v));
    ll ans = v[0];
    for(ll i=1; i<=(n-2)/2;i++){
        ans += v[i]*2;
    }
    if((n-1)%2 == 0){
        ans += v[(n-2)/2 + 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
    vector<int> par, rank;

    UnionFind(int n) : par(n , -1), rank(n, 0) { }
    void init(int n) { par.assign(n, -1), rank.assign(n, 0); }

    int root(int x) {
        if (par[x] == -1) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

int main(){
    string s;
  	cin >> s;
	string ans = "";
  	rep(i,s.size()){
      string temp = "";
      if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
        while(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
          temp += s[i];
          ++i;
        }
      }
      if(temp.size() > ans.size()) ans = temp;
    }
  cout << ans.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, k, i, a[200005];
int main()
{
    scanf("%d%d", &n, &k);
    for (i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for (i = k + 1; i <= n; ++i)
        puts(a[i] > a[i - k] ? "Yes" : "No");
}

Measured memory_bytes: 4544
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <type_traits>
#include <limits>
#include <tuple>

template <class Tp>
class lines {
  // based on Li Chao tree
  std::map<Tp, size_t> enc;
  std::vector<Tp> dec;
  std::vector<std::pair<Tp, Tp>> c;
  size_t m = 1;
  Tp inf = std::numeric_limits<Tp>::max() / 8;

private:
  void init_resize(size_t n) {
    while (m < n+n) m <<= 1;
    c.assign(m, {0, inf});
  }

  void inspect() const {
    for (size_t i = 1; i < m; ++i) {
      std::string s = (c[i].first < inf? std::to_string(c[i].first) : "inf");
      std::string t = (c[i].second < inf? std::to_string(c[i].second) : "inf");
      fprintf(stderr, "(%s, %s)%c", s.c_str(), t.c_str(), (i&(i+1))? ' ':'\n');
    }
  }

public:
  template <class ForwardIt>
  lines(ForwardIt first, ForwardIt last): dec(first, last) {
    static_assert(std::is_same<typename ForwardIt::value_type, Tp>::value, "Type mismatch");
    std::sort(dec.begin(), dec.end());
    size_t n = dec.size();
    init_resize(n);
    // while (dec.size() < m/2) dec.push_back(dec.back()+1);
    dec.resize(m/2, dec.back());
    for (size_t i = 0; i < m/2; ++i) enc.emplace(dec[i], i);
  }

  void append(Tp a, Tp b) {
    size_t l = 0;
    size_t j = 1;
    size_t h = 1;
    size_t w = m/2;
    while (w > 0 && l+w-1 < dec.size()) {
      Tp xl = dec[l];
      Tp xm = dec[l+w/2];
      Tp xr = dec[l+w-1];

      Tp a0, b0;
      std::tie(a0, b0) = c[j];

      Tp yl0 = a0*xl + b0;
      Tp ym0 = a0*xm + b0;
      Tp yr0 = a0*xr + b0;

      Tp yl = a*xl + b;
      Tp ym = a*xm + b;
      Tp yr = a*xr + b;

      if (yl0 <= yl && yr0 <= yr) break;
      if (yl0 >= yl && yr0 >= yr) {
        c[j] = {a, b};
        break;
      }

      h <<= 1;
      w >>= 1;

      if (ym0 >= ym) {
        c[j] = {a, b};
        a = a0;
        b = b0;
        j <<= 1;
        if (yr0 < yr) {
          j |= 1;
          l += w;
        }
      } else {
        j <<= 1;
        if (yr0 >= yr) {
          j |= 1;
          l += w;
        }
      }
    }
  }

  Tp min_at(Tp x) const {
    size_t i = enc.at(x) + m/2;
    Tp y = inf;
    while (i > 0) {
      Tp a, b;
      std::tie(a, b) = c[i];
      y = std::min(y, a*x+b);
      i >>= 1;
    }
    return y;
  }
};

int main() {
  size_t N;
  intmax_t C;
  scanf("%zu %jd", &N, &C);

  std::vector<intmax_t> h(N);
  for (auto& hi: h) scanf("%jd", &hi);

  lines<intmax_t> cht(h.begin(), h.end());

  std::vector<intmax_t> dp(N);
  for (size_t i = 0; i+1 < N; ++i) {
    cht.append(-2*h[i], h[i]*h[i]+dp[i]);
    dp[i+1] = cht.min_at(h[i+1]) + h[i+1]*h[i+1] + C;
  }

  printf("%jd\n", dp[N-1]);
}


Measured memory_bytes: 27108
#include <iostream>
#include <vector>

using namespace std;

static const int INF=1000000007;

int main(void){
   int N,M;
   cin >> N >> M;
   
   vector<bool> broken(N,false);
   
   for(int i=0;i<M;i++){
       int crt;
       cin >> crt;
       broken.at(crt)=true;
   }
   
   vector<long long> pattern(N+1,0);
   pattern.at(0)=1;
   if(!pattern.at(1)){
        pattern.at(1)=1;
   }else{
       pattern.at(1)=0;
   }
   
   for(int i=2;i<N+1;i++){
       long long ans=0;
       if(!broken.at(i-2)){
           ans+=pattern.at(i-2);
       }
       if(!broken.at(i-1)){
           ans+=pattern.at(i-1);
       }
       ans%=INF;
       pattern.at(i)=ans;
   }
   
   cout << pattern.at(N) << endl;
    
}


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

using namespace std;

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

    vector<int> edge[n];
    int a, b;
    for(int i=0; i<m; i++) {
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    vector<int> cost(n, INT_MAX), dir(n, -1);
    cost[0] = 0;
    dir[0] = 0;

    queue<int> q;
    q.push(0);
    while(!q.empty()) {
        int r = q.front(); q.pop();
        for(auto s: edge[r]) {
            if(dir[s] != -1) continue;
            dir[s] = r;
            cost[s] = cost[r] + 1;
            q.push(s);
        }
    }

    cout << "Yes" << endl;
    for(int i=1; i<n; i++) cout << dir[i]+1 << endl;

    return 0;
}


Measured memory_bytes: 10740
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
const int MOD = 1000000007;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

int i, j, k, m, n, l;

int main() {
    // freopen("x.in", "r", stdin);

    ll a[4], n;
    F0(i, 4) cin >> a[i];
    F0(i, 3) a[i + 1] = min(a[i + 1], 2 * a[i]);
    cin >> n;
    
    cout << (n / 2) * a[3] + (n % 2) * a[2] << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
nMAP = [["" for i in range(N)] for j in range(N)]
tMAP = [["" for i in range(N)] for j in range(N)]
c = 0
flag = 0
for i in range(N):
    s = list(str(input()))
    if "#" in s:
        flag = 1
    nMAP[i] = s
        
for i in range(N):
    for j in range(N):
        tMAP[i][j] = nMAP[j][i]
        
for i in range(N):
    if "." in tMAP[i]:
        c+=1
        
MIN = N
for i in range(N):
    x = nMAP[i].count(".")
    if "#" in tMAP[i]:
        MIN = min(MIN,x)
    else:
        MIN = min(MIN,x+1)
    
if flag == 0:
    print(-1)
else:
    print(MIN+c)
    

Measured memory_bytes: 7412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;

int a[N];
ll sum[N];

int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	sum[0] = 0;
	for(int i = 1;i <= n;++i) scanf("%d",&a[i]),sum[i] = sum[i-1]+a[i];
    
	double ans = 0;
	for(int i = 1;i+k-1 <= n;++i){
		double t = (double)(sum[i+k-1]-sum[i-1]+k)/2.0;
		ans = max(ans,t);
	}
	printf("%.12lf\n",ans);
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	cin>>n;
	long long a[n+1];
	rep(i,n)cin>>a[i];
	a[n]=0;
	long long sum=0;
	rep(i,n){
		sum+=a[i]/2;
		if(a[i]%2){
			if(a[i+1]!=0){
				sum++;
				a[i]--;
				a[i+1]--;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Vector;

public class Main {
	static int a[][];
	static long dp[];
	static int n;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		dp = new long [1<<n];
		for (int i=0;i<1<<n;i++)
			dp[i] = -1;
		a = new int[n][n];
		for (int i=0;i<n;i++)
			for (int j=0;j<n;j++) 
				a[i][j]=sc.nextInt();
		
		long ans = f((1<<n)-1);
		System.out.println(ans);
	}
	private static long f(int bit) {
		if (bit==0) return 1;
		if (dp[bit]>=0) 
			return dp[bit];
		int fb = Integer.bitCount(bit)-1;

		long ans = 0;
		for (int i=0;i<n;i++) {
			if ((bit>>i)%2==0) continue;
			if (a[fb][i]==0) continue;
			long l = f(bit^(1<<i));
			ans = (ans + l)%1000000007;
		}
		dp[bit] = ans;
		return ans;
	}
}


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

int main () {
  int N;	cin >> N;
  int a[110000];
  for (int i=0; i<N; i++)
    cin >>a[i] ;
  
  int odd=0;
  for (int i=0; i<N; i++) {
    if (a[i] %2 != 0)
      odd += a[i];
  }
    
    if (odd%2 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a >= b){
          int tmp = a;
          a = b;
          b = tmp;
        }
        String ans="";
        for (int i = 0; i < b; i++) {
            ans = ans + a;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
 using namespace std;
 
 int main()
 {
     int H, N;

     cin >> H >> N;

     for(int i = 0; i < N; i++)
     {

         int A;
         cin >> A;
         H= H-A;

    } 
         if(H <= 0)
            puts("Yes");
         else
            puts("No");
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

journey = [1]

for i in range(n):
    journey.append(a[journey[i]])

if k <= n:
    print(journey[k])
    exit()

cycle_end = n
cycle_start = n - 1

while journey[cycle_start] != journey[cycle_end]:
    cycle_start -= 1

cycle_range = cycle_end - cycle_start

cycle_cnt = (k - n) // cycle_range
extra = (k - n) - (cycle_range * cycle_cnt)

for i in range(extra):
    journey.append(a[journey[i + n]])    

print(journey[-1])

Measured memory_bytes: 113332
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int S, W;
	cin >> S >> W;

	if (W >= S) {
		cout << "unsafe" << endl;
	}
	else {
		cout << "safe" << endl;
	}


}






Measured memory_bytes: 3596
#include <iostream>
#include <vector>

using namespace std;



int main() {
    char t[256];
#define P(x, y) {t[x]=y; t[y]=x;}
    P('A', 'T')
    P('G', 'C')
    string s;
    cin >> s;
    for(auto&& c : s) cout << t[c];
    cout << endl;
}


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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 998244353;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}

//__builtin_popcount ();
int n, m, k;
vector<int> v1[MAXN];
vector<int> v2[MAXN];
bool vis[MAXN];
int leader = 1;
int cnt = 0;
set<int> s[MAXN];
int arrS[MAXN];
int cc[MAXN];



void dfs(int x) {
    vis[x] = 1;
    cnt++;
    cc[x]=leader;
    s[leader].insert(x);
    for (int i = 0; i < v1[x].size(); i++)
        if (!vis[v1[x][i]])
            dfs(v1[x][i]);
}

int main() {
    FAST
    cin >> n >> m >> k;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        v1[a].push_back(b);
        v1[b].push_back(a);
    }
    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        v2[a].push_back(b);
        v2[b].push_back(a);
    }
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            cnt=0;
            dfs(i);
            arrS[leader] = cnt;
            leader++;

        }
        int k=0;
        for(int pt=0;pt<v2[i].size();pt++)
        {
            if(s[cc[i]].find(v2[i][pt])!=s[cc[i]].end())
            {
                k++;
            }
        }
        cout<<arrS[cc[i]]-v1[i].size()-k-1<<" ";
    }
    return 0;
}

Measured memory_bytes: 21760
#include<bits/stdc++.h>
using namespace std;
string n;
int main()
{
    int i,a;
    cin>>n;
    a=n.size()-1;
    for(i=0;i<=a;i++)
    if(n[i]=='A'&&n[i+1]=='C')
    {
    	cout<<"Yes"<<endl;
    	return 0;
    }
	cout<<"No"<<endl; 
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long a[100001];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	int zero=0;
	for(int i=0;i<n;i++){
		if(a[i]==0) zero++;
	}
	if(zero>0){
		cout<<0<<endl;
		return 0;
	}
	
	long long prod=1;
	for(int i=0;i<n;i++){
		if(a[i]<=1000000000000000000/prod){
			prod*=a[i];
		}
		else{
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<prod<<endl;
}


Measured memory_bytes: 4408
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll n;
  std::cin>>n;

  ll a=0,w=0,t=0,r=0;

  while(n--){
    std::string s;
    std::cin>>s;
    if(s=="AC")a++;
    if(s=="WA")w++;
    if(s=="TLE")t++;
    if(s=="RE")r++;
  }

  std::cout<<"AC x "<<a<<"\n";
  std::cout<<"WA x "<<w<<"\n";
  std::cout<<"TLE x "<<t<<"\n";
  std::cout<<"RE x "<<r<<"\n";

  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  int q;
  cin >> q;
  map<string, int> mp;
  rep(qi, q)
  {
    int type;
    cin >> type;
    if (type == 0)
    {
      string key;
      int x;
      cin >> key >> x;
      mp[key] = x;
    }
    else
    {
      string key;
      cin >> key;
      cout << mp[key] << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 25780