akhauriyash/Code-Regression huggingface dataset:
def main():
	N = int(input())
	info = []
	for i in range(N):
		x, y, h = [int(a) for a in input().split(" ")]
		info.append({"x": x, "y": y, "h": h})
	info.sort(key=lambda f: -f["h"])
	for cx in range(101):
		for cy in range(101):
			H = 0
			for i in range(len(info)):
				h = info[i]["h"] + abs(info[i]["x"] - cx) + abs(info[i]["y"] - cy)
				if i == 0:
					H = h
				else:
					if h != H:
						if (info[i]["h"] == 0 and h < H) or (info[i]["h"] > 0):
							break
			else:
				print(cx, cy, H)
				return 0
	if info[0]["x"] in [0, 100] and info[0]["y"] in [0, 100]:
		print(info[0]["x"], info[0]["y"], info[0]["h"])
		return 0

main()


Measured memory_bytes: 9140
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
	fast;
	ll h = 1;
	//cin >> h;
    while(h--){
        ll k, x;
        cin >> k >> x;
        if(k * 500 >= x){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
}
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    ll n,m;
    cin >> n >> m;
    ll ans = 0;
    if(n==1&&m==1) ans = 1;
    else if(n==1||m==1) ans = n*m-2;
    else if(n==2||m==2) ans = 0;
    else ans = (n-2)*(m-2);
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    LL sum = 0;
    REP(i,0,n) {
        if (i % 2) sum -= a[i];
        else sum += a[i];
    }
    LL last = sum;
    REP(i,0,n) {
        if (i) cout << " ";
        cout << last;
        last = (a[i] - last/2)*2;
    }
    cout << endl;
}

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

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

int main() {
	// your code goes here
    /* code */
int n;
cin>>n;
long long int a[n];
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
vector<vector<pair<long long int,long long int>>> dp(n,vector<pair<long long int,long long int>>(n,{0,0}));
for(int i=0;i<n;i++)
{
    dp[i][i].first=a[i];
    dp[i][i].second=0;
}
for(int i=0;i<n-1;i++)
{
    dp[i][i+1].first=max(a[i],a[i+1]);
    dp[i][i+1].second=min(a[i],a[i+1]);
}
for(int gap=2;gap<n;gap++)
{
    for(int i=0,j=gap;j<n;j++,i++)
    {
        if(a[i]+dp[i+1][j].second>a[j]+dp[i][j-1].second)
        {
            dp[i][j].first=a[i]+dp[i+1][j].second;
        }
        else
        {
            dp[i][j].first=a[j]+dp[i][j-1].second;
        }
        dp[i][j].second=min(dp[i+1][j].first,dp[i][j-1].first);
    }
}
cout<<dp[0][n-1].first-dp[0][n-1].second<<endl;
return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define esort(s) sort((s).begin(),(s).end())

typedef long long ll;
typedef pair<int,int> ip;
typedef vector<vector<int>> vv;

const int INF = 1000000000;
const ll LINF = 1000000000000000000;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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

    int N;
    cin >> N;
    vv G(N);
    vector<ip> inp;
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        inp.emplace_back(a,b);
    }

    int mc = 1;
    map<ip,int> edge;
    vector<bool> used(N,false);
    vector<int> parent(N,0);
    queue<int> q;
    q.emplace(0);
    used[0] = true;
    while(!q.empty()){
        int v = q.front();
        q.pop();
        if (mc < G[v].size()) mc = G[v].size();
        int col = 1;
        for(int u:G[v]){
            if(used[u]) continue;
            if(parent[v]==col) col++;
            parent[u] = edge[make_pair(u,v)] = edge[make_pair(v,u)] = col++;
            used[u] = true;
            q.emplace(u);
        }
    }

    cout << mc << "\n";
    for(ip p:inp){
        cout << edge[p] << "\n";
    }

    return 0;
}

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

int main(){
  int x;
  cin >> x;
  
  //while (1)とかwhile (true)は無限ループのこと
  while (1){
    bool ok=true;//ここでのokは「xは素数だ」ということ
    for (int i=2;i<x;++i){
      if (x%i==0) {
        ok=false;
        break;
      }
    }
    if (ok) break;
      ++x;
  }
      cout << x << endl;
      return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream> 
#include <cmath>
#include <map>
#include <queue>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
const ll MOD=ll(1e9+7);
 
//repetition
#define REP(i,n)  for(ll i=0;i<n;i++)
 
ll P_POW(ll i, ll n) {
  if(n==0) return 1;
 
  n--;
  ll rep = i;
 
  while(n) {
    rep = rep * i;
    n--;
  }
  return rep;
} 
 
unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
unsigned binarySearch(ll target, ll max, ll min) {
  while((max - min) > 1) {
      if((max + min)/2 > target) {
        max = (max + min)/2;
        min = min;
      } else {
        max = max;
        min = (max + min)/2;
      }
    }
}
 
ll n;
 
 
long long solve2(long long N) {
    if (N % 2 == 1) return 0;
 
    long long res = 0;
    N /= 2;
    while (N) {
        res += N / 5;
        cout << "N/5: " << N/5 <<  endl;
        cout << "res1: " << res <<  endl;
        N /= 5;
    }
    return res;
}
 
 
ll solve(ll n) {
    if (n % 2 == 1) return 0;
 
    ll res = 0;
    n /= 2;
    int c = 1;
 
    while ((ll) n/((ll)pow(5,c))) {
      res += n/P_POW(5,c);
      c++;
    }
    return res;
}
 
void f(int rest, string s) {
  char abc[] = "abc";
  if(rest == 0) {
    cout << s << endl;
  } else {
    for(int i=0; i < 3; i++) {
      f(rest - 1, s+abc[i]);
    }
  }
} 
 
int main() {
  ll a, n;
  cin >> n;
  // vector<vector<ll>> a(n ,vector<ll>{2,0});
  // vector
  // vector<ll> s(n,0);
  // vector<vector<ll>> v;
  // map<ll,ll> m;
  // priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
  // vector<pair<ll, ll>> epv(n, {0, 0});
  
  /* iterator
  for(auto&& m: em) {
    epv.push_back({ m.second, m.first });
  }
  */
 
  vector<ll> ev;
  vector<ll> ov;
 
  map<ll, ll> em;
  map<ll, ll> om;
 
  vector<pair<ll, ll>> epv(n, {0, 0});
  vector<pair<ll, ll>> opv(n, {0, 0});
 
  REP(i, n) {
    cin >> a;
    if(i%2 == 0) {
      ev.push_back(a);
    } else {
      ov.push_back(a);
    }
  }
  
  REP(i, ev.size()) {
    em[ev[i]]++;
  }
 
  REP(i, ov.size()) {
    om[ov[i]]++;
  }

  for(auto&& m: em) {
    epv.push_back({ m.second, m.first });
  }

  for(auto&& m: om) {
    opv.push_back({ m.second, m.first });
  }

  sort(epv.rbegin(), epv.rend());
  sort(opv.rbegin(), opv.rend());

  if(epv[0].second == opv[0].second) {
    cout << n - max((epv[0].first + opv[1].first), (epv[1].first + opv[0].first)) << endl;
  } else {
    cout << n - (epv[0].first+opv[0].first) << endl;
  }
 
}



Measured memory_bytes: 14180
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

template <typename T>
void chmin(T& x, T y) {
    x = min(x, y);
}

template <typename T>
void chmax(T& x, T y) {
    x = max(x, y);
}

ll csum(ll x, ll y) {
    if (x > 0 && y > 0 && x > LL_MAX - y) {
        return LL_MAX;
    }
    if (x < 0 && y < 0 && x < LL_MIN - y) {
        return LL_MIN;
    }
    return x + y;
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
	ll N, M, K;
	cin >> N >> M >> K;
	vector<ll> A(N);
	vector<ll> B(M);
	rep(i,0,N) {
		cin >> A[i];
	}
	rep(i,0,M) {
		cin >> B[i];
	}
	ll ans = LL_MIN;
	ll a_end = 0;
	ll b_end = 0;
	ll time = 0;
	while (true) {
		if (a_end >= N) {
			break;
		} 
		if (time + A[a_end] > K) {
			break;
		}
		time += A[a_end];
		a_end++;
	}
	while (true) {
		while (true) {
			if (b_end >= M) {
				break;
			}
			if (time + B[b_end] > K) {
				break;
			}
			time += B[b_end];
			b_end++;
		}
		chmax(ans, a_end + b_end);
		if (a_end == 0) {
			break;
		}
		a_end--;
		time -= A[a_end];
	}
	cout << ans << endl;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N; cin >> N;
  vector<int> A(N); REP(i, N) cin >> A[i];
  vector<int> c(N, 0); c[0] = 3;
  ll ans = 1; const ll MOD = pow(10, 9) + 7;
  REP(i, N) {
    ans = ans * c[A[i]] % MOD;
    c[A[i]]--;
    c[A[i] + 1]++;
  } 
  cout << ans << endl;
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
const int N = 1e6+5;
int main()
{
	sync;
	ll n, d, ans= 0;
	cin >> n >> d;
	d *= d;
	for(ll i = 0 ; i < n ; i++)
	{
		ll x,y;
		cin >> x >> y;
		if(x * x  + y * y <= d)
			ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 3656
#include <cmath>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		h -= a;
		if (h <= 0)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    int ans=0;
    rep(i,n)ans+=max(0,a[i]-b[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
use strict;
use warnings;
use utf8;

my @variables = ();

while(<STDIN>){
    chomp($_);
    push(@variables, $_);
}

my $N = $variables[0];
shift(@variables);
my @sorted = ();

@sorted = sort {$b <=> $a} @variables;

my $max1 = $sorted[0];
my $max2 = $sorted[1];
#print($max1, $max2);

for(my $i=0; $i < $N; $i++){
  my $subtract = $variables[$i];
  if($subtract==$max1){
    print($max2,"\n");
  }
  else{
    print($max1,"\n");
  }
}
#print @sorted;


Measured memory_bytes: 44668
use input::{Input, ReadMode};
type Book = Vec<(u32, Vec<u32>)>;

const INF: u32 = 1_000_000_000;

fn main() {
    let mut input = Input::new(ReadMode::Line);

    let n: usize = input.parse();
    let m: usize = input.parse();
    let x: u32 = input.parse();

    let c: Book = (0..n)
        .map(|_| {
            (
                input.parse(),
                (0..m).map(|_| input.parse()).collect::<Vec<_>>(),
            )
        })
        .collect();

    let mut ans = INF;
    for k in 0..1 << n {
        let mut v = vec![0u32; m];
        let mut tmp = 0;
        for i in 0..n {
            if k >> i & 1 == 1 {
                let (cost, point) = &c[i];
                tmp += cost;
                for j in 0..m {
                    v[j] += point[j];
                }
            }
        }
        if v.iter().all(|&a| a >= x) {
            ans = ans.min(tmp);
        }
    }

    if ans < INF {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}

#[allow(dead_code)]
pub mod input {
    use std::io::{BufRead, Read};

    pub enum ReadMode {
        Full,
        Line,
    }

    pub struct Input<'a> {
        lock: std::io::StdinLock<'static>,
        iter: Option<std::str::SplitAsciiWhitespace<'a>>,
        mode: ReadMode,
    }

    impl<'a> Input<'a> {
        fn naive_read(&mut self) -> Option<std::str::SplitAsciiWhitespace<'a>> {
            let mut s = Box::leak(Box::new(String::new()));
            let res = match self.mode {
                ReadMode::Full => self.lock.read_to_string(&mut s),
                ReadMode::Line => self.lock.read_line(&mut s),
            };
            res.ok().expect("failed to read");
            Some(s.split_ascii_whitespace())
        }
        pub fn new(mode: ReadMode) -> Self {
            let lock = Box::leak(Box::new(std::io::stdin())).lock();
            let iter = None;
            Self { lock, iter, mode }
        }
        pub fn read_line(&mut self) -> String {
            let mut s = String::new();
            self.lock.read_line(&mut s).ok().expect("failed to read");
            s
        }
        pub fn parse<T: std::str::FromStr>(&mut self) -> T {
            match &mut self.iter {
                Some(iter) => {
                    let x = if let Some(x) = iter.next() {
                        x
                    } else {
                        self.iter = self.naive_read();
                        self.iter.as_mut().unwrap().next().expect("reached EOF")
                    };
                    x.parse().ok().expect("failed to parse")
                }
                None => {
                    self.iter = self.naive_read();
                    self.parse()
                }
            }
        }
    }
}


Measured memory_bytes: 2120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;

public class Main {

	public static int solve (char[][] map) {
		int ret = 0;
		int[] moveX = {0,0,-1,1};
		int[] moveY = {-1,1,0,0};
		boolean[][] check = new boolean[map.length][map[0].length];
		Queue<Integer> queueX = new LinkedList<Integer>();
		Queue<Integer> queueY = new LinkedList<Integer>();

		for (int i = 0; i < map.length; i++) {
			for (int j = 0; j < map[i].length; j++) {
				if (map[i][j] == '1' && !check[i][j]) {
					ret++;
					check[i][j] = true;

					queueX.add(j);
					queueY.add(i);

					while (!queueX.isEmpty()) {
						int x = queueX.poll();
						int y = queueY.poll();
						for (int k = 0; k < moveX.length; k++) {
							int nx = x + moveX[k];
							int ny = y + moveY[k];
							if (nx < 0 || nx >= map.length ||
									ny < 0 || ny >= map.length ||
									check[ny][nx]  == true) continue;
							if (map[ny][nx] == '0') continue;
							check[ny][nx] = true;
							queueX.add(nx);
							queueY.add(ny);
						}
					}

				}
			}
		}

		return ret;
	}

	public static void main(String[] args) throws IOException {

		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));

		main:while (true) {
			char[][] map = new char[12][12];
			for (int i = 0; i < map.length; i++) {
				String line = br.readLine();
				if (line == null)
					break main;
				else if (line.isEmpty()) continue main;
				char[] c = line.toCharArray();
				for (int j = 0; j < c.length; j++)
					map[i][j] = c[j];
			}
			System.out.println(solve(map));
		}

	}

}

Measured memory_bytes: 16904
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long DP[51][51][5000];
void Calc(){
	int N = rei();
	int K = rei();
	DP[0][0][2500] = 1;
	for(int i=0;i<N;i++){
		for(int j=0;j<=i;j++){
			for(int k=0;k<5000;k++){
				if(DP[i][j][k] != 0){
					DP[i][j][k] %= mod;
					DP[i+1][j][k] += DP[i][j][k]*(2*j+1) % mod;	
					if(j > 0){
						DP[i+1][j-1][k+2*i] += DP[i][j][k]*j*j%mod;
					}
					DP[i+1][j+1][k-2*i] += DP[i][j][k];
				}
			}
		}
	}
	cout << DP[N][0][2500+K] % mod << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 98944
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

/*Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}
*/
Node treeSearch(Node u, int k){

  // 現在のノードがNULLもしくは対象のキーである場合ノードを返す
  if(u == NIL || k == u->key){
    return u;
  }

  if(k < u->key){
    return treeSearch(u->left, k);
  }
  else{
    return treeSearch(u->right, k);
  }
  
}
/*
Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
*/
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    } 
    else {
      x = x->right;
    }
  }
  z->parent = y;
  
  if( y == NIL ){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else {
    y->right = z;
  }
  

}

void inorder(Node u){
  
  // 左のノードがある場合左のノードへ
  if(u->left != NIL){ 
    inorder(u->left);
    
  }
  
  // 左のノードがない、もしくは左側を踏破したとき現在のノードのキーを表示
  printf(" %d",u->key);


  // 右のノードがある場合右のノードへ
  if(u->right != NIL){
    inorder(u->right);
    
  }


}
void preorder(Node u){
  
  
  // 現在のノードのキーを表示
  printf(" %d",u->key);
  
  // 左のノードがある場合左のノードへ
  if(u->left != NIL){ 
    preorder(u->left);
    
  }
  
  // 右のノードがある場合右のノードへ
  if(u->right != NIL){
    preorder(u->right);
    
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }

  return 0;
}

Measured memory_bytes: 19364
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7

ll max(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
double max(double a, double b) {

	if (a > b)return a;
	else return b;

}
//a??¨b?????§?????????

ll min(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//a??¨b????°??????????

ll avd_i(ll a, ll b) {

	if (a > b)return a - b;
	else return b - a;

}
double avd_d(double a, double b) {

	double re;
	if (a > b)re = a - b;
	else re = b - a;
	return re;

}
//a??¨b???????????¶??????

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//p????´???°,a???b??????p??§?????£?????????

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//p????´???°,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//?????§??¬?´???°

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//????°???¬?????°

int main() {
	
	int a, b;

	cin >> a >> b;

	cout << a*b << " " << a * 2 + b * 2 << endl;

	return 0;
}

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

int main(){
    int i;
    int a;
    int ans=0;
    cin>>i;
    if(i/100==9)ans+=100;
    else ans+=900;
    if(i%100/10==9)ans+=10;
    else ans+=90;
    if(i%10==9)ans+=1;
    else ans+=9;

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


//ABC107_b
int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char> > table(H, vector<char>(W));
	rep(i, H) {
		rep(j, W) {
			cin >> table.at(i).at(j);
		}
	}

	bool h[110], w[110];
	rep(i, H) {
		bool flg = true;
		rep(j, W) {
			if (table.at(i).at(j) == '#') {
				flg = false;
				break;
			}
		}
		h[i] = flg;
	}
	rep(i, W) {
		bool flg = true;
		rep(j, H) {
			if (table.at(j).at(i) == '#') {
				flg = false;
				break;
			}
		}
		w[i] = flg;
	}

	rep(i, H) {
		if (h[i]) {
			continue;
		}
		else {
			rep(j, W) {
				if (!w[j]) {
					cout << table.at(i).at(j);
				}
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
	int n; cin>>n;
	vvi aList(n+1);
	rep(i,n-1){
		int a,b; cin>>a>>b;
		aList[a].push_back(b);
		aList[b].push_back(a);
	}
	vvi ans(2,vi(n+1,-1));
	rep(p,2){
		queue<int> q;
		q.push(p?n:1);
		ans[p][p?n:1]=0;
		while(!q.empty()){
			int t=q.front(); q.pop();
			for(auto adj:aList[t]){
				if(ans[p][adj]==-1){
					ans[p][adj]=ans[p][t]+1;
					q.push(adj);
				}
			}
		}
	}
	int res=0;
	rep(i,n) if(ans[0][i+1]<=ans[1][i+1]) res++;
	if(res>n-res)cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;
	return 0;
}


Measured memory_bytes: 6912
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int N;
int T,A;
vector<int> H;
int main(){
  cin >> N;
  cin >> T >> A;
  H.resize(N);
  for(int i = 0;i<N;i++){
    cin >> H[i];
  }
  double mindiff = 100000000.0;
  double diff = 0.0;
  int idx = 0;

  for(int n=0;n<N;n++){
    diff = abs((double)T - (double)H[n] * 0.006 - (double)A);
    if(diff < mindiff){
      mindiff = diff;
      idx = n;
    }
  }


  cout << (idx+1) << endl;

  return 0;
}



Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 105;

#define ll long long

int n, K;
char s[N];
vector<int> len;

void work() {
	for (int i = 1, j = 1; i <= n; i = j) {
		while (j <= n && s[i] == s[j])
			j++;
		len.push_back(j - i);
	}
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	scanf("%d", &K);
	work();
	ll ans = 0;
	if ((signed) len.size() == 1) {
		ans = (1ll * n * K) >> 1;
	} else if (s[1] == s[n]) {
		for (int i = 1; i < (signed) len.size() - 1; i++) {
			ans += 1ll * (len[i] >> 1) * K;	
		}
		ans += ((len[0] + len.back()) >> 1) * 1ll * (K - 1);
		ans += len[0] >> 1;
		ans += len.back() >> 1;
	} else {
		for (auto l : len)
			ans += l >> 1;
		ans = ans * K;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 256
x = 1
y = 1
while x != 0 or y != 0:
    l = list(map(int,input().split()))

    x = l[0]
    y = l[1]

    if x == 0 and y == 0:
        break

    if x < y:
        print(str(x) + ' ' + str(y))
    else:
        print(str(y) + ' ' + str(x))


Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++) cin >> d.at(i);

	int answer = 1;
	sort(d.begin(), d.end());
	int temp = d.at(0);

	for (int i = 1; i < N; i++)
	{
		if (temp == d.at(i)) continue;
		temp = d.at(i);
		answer++;
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

X = int(input())

c = int(X // 500)
a = c * 1000
X -= c * 500
b = int(X // 5) * 5
print(a + b)

Measured memory_bytes: 3956
n = int(input())
a = list(map(int, input().split()))

a.sort()

def answer():
    p = sum(1 for i in a if i < 0)
    q = sum(1 for i in a if i >= 0)

    if p == 0:
        p += 1
        q -= 1
    if q == 0:
        p -= 1
        q += 1

    list_xy = []
    for i in range(q - 1):
        list_xy.append((a[0], a[p + i]))
        a[0] -= a[p + i]
    for i in range(p):
        list_xy.append((a[-1], a[i]))
        a[-1] -= a[i]
    return a[-1], list_xy


m, list_xy = answer()

print(m)
for x, y in list_xy:
    print(x, y)


Measured memory_bytes: 23680
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var p = new int[N];
        var max = 0;
        var sum = 0;
        for(int i = 0; i < N; i++)
        {
            p[i] = int.Parse(Console.ReadLine());
            max = Math.Max(max, p[i]);
            sum += p[i];
        }

        sum -= max;
        sum += max / 2;
        Console.WriteLine(sum);

    }


}



Measured memory_bytes: 11092
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

bool is_prime(int X) {
  if(X<=1)
    return false;
  if(X==2)
    return true; 
  if(X%2==0)
    return false;
  for(int i=3; i<sqrt(X); i+=2) {
    if(X%i==0)
      return false;
  }
  return true;
}

int main() {
  int X;
  cin >> X;
  while(!is_prime(X)) {
    ++X;
  }
  cout << X << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x,y,a;
int res_x[2]={0,100};
int res_y[2]={0,100};
int main(){
  scanf("%d%d%d", &res_x[1], &res_y[1], &n);
  for(int i=0;i<n;i++){
    scanf("%d%d%d", &x, &y, &a);
    if(a==1)res_x[0]=max(res_x[0], x);
    if(a==2)res_x[1]=min(res_x[1], x);
    if(a==3)res_y[0]=max(res_y[0], y);
    if(a==4)res_y[1]=min(res_y[1], y);
    if((res_x[1]-res_x[0])<1 || (res_y[1]-res_y[0])<1){
      puts("0\n");
      return 0;
    }
  }
  printf("%d\n", (res_x[1]-res_x[0])*(res_y[1]-res_y[0]));
  return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();
    let n = iter.next().unwrap().parse::<usize>().unwrap();
    let x = iter.next().unwrap().parse::<i64>().unwrap();
    let mut t = 0;
    let mut num = 0;
    let mut min = 1001;
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let a = buf.trim().parse::<i64>().unwrap();
        t += a;
        num += 1;
        if min > a {
            min = a;
        }
    }
    let mut x = x - t;
    println!("{}", x / min + num);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m1=0,m2=0,c=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]>m1)
    {
      m2=m1;
      m1=a[i];
    }
    else if(a[i]>m2 && a[i]!=m1)
      m2=a[i];
  }
  if(m2==0)
    m2=m1;
  for(int i=0;i<n;i++)
  {
      if(a[i]==m1)
        c++;
  }
  for(int i=0;i<n;i++)
  {
    if(a[i]==m1 && c==1)
      cout<<m2<<endl;
    else
      cout<<m1<<endl;
  }
  return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int n;
    std::cin >> n;

    std::vector<int> A(n);
    for (int i = 0; i < n; i++) {
        std::cin >> A[i];
    }

    int q;
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        int b, e;
        std::cin >> b >> e;
        std::reverse(A.begin() + b, A.begin() + e);
    }

    for (int i = 0; i < A.size(); i++) {
        std::cout << A[i];
        if (i < A.size() - 1) {
            std::cout << " ";
        }
    }
    std::cout << std::endl;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//---------------------------------------------------------------------------------------------------
ll MOD = 1000000007;
ll f[201010], rf[201010];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < 201010; i++) f[i] = (f[i - 1] * i) % MOD;
    for(int i = 0; i < 201010; i++) rf[i] = inv(f[i]);
}
ll C(int n, int k) {
    if(n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % MOD;

    return (a * bc) % MOD;
}
//---------------------------------------------------------------------------------------------------

int main()
{
    init();
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<ll> sum(n+1);
    sum[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        sum[i] = sum[i-1] + a[i-1];
    }
    multiset<ll> ms;
    for(int i = 0; i <= n; i++)
    {
        ms.insert(sum[i]);
    }
    ll ans = 0;
    for(ll cand : ms)
    {
        ll count = ms.count(cand);
        ans += count * (count-1) / 2;
        ms.erase(cand);
    }
    cout << ans << endl;
}


Measured memory_bytes: 15872
#include<stdio.h>

int main(){
    	
	int p,l,luas,kll;
	scanf("%d %d",&p,&l);
	luas=p*l;
	kll=p*2+l*2;
	printf("%d %d\n",luas,kll);
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 1932
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n), b;
    rep(i,n) cin >> a[i];
    rep(j,k) {
        b = vector<int>(n);
        rep(i,n) {
            int l = max(0, i - a[i]);
            int r = min(n-1, i + a[i]);
            b[l]++;
            if (r+1<n) b[r+1] --;
        }
        repSE(i,1,n) b[i] += b[i-1];
        rep(i,n) a[i] = b[i];
        bool flag = true;
        rep(i,n) {
            if (a[i] != n) {flag = false; break; }
        }
        if (flag) break;
    }
    rep(i,n) cout << a[i] << " ";
    cout << "\n";
    return 0;
}


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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair
#define ll long long

using namespace std;

const int N = 5e3 + 2;

int n,m;
int a[N],b[N][201];
ll p[N],rs,mx;
int t[N * 4][201],cur;

inline int max(int a, int b)
{
        return a > b ? a : b;
}
inline int min(int a, int b)
{
        return a > b ? b : a;
}

void build (int v = 1,int tl = 1,int tr = n) {
        if (tl == tr) {
                for (int i = 1; i <= m; i ++) {
                        t[v][i] = b[tl][i];
                }
        }
        else {
                int tm = (tl + tr) >> 1;
                build (v * 2,tl,tm);
                build (v * 2 + 1,tm + 1,tr);
                for (int i = 1; i <= m; i ++) {
                        t[v][i] = max(t[v * 2][i],t[v * 2 + 1][i]);
                }
        }
}
int get (int l,int r,int x,int v = 1,int tl = 1,int tr = n) {
        if (l > r || l > tr || tl > r)
                return -1;

        if (l <= tl && tr <= r)
                return t[v][x];

        int tm = (tl + tr) >> 1;
        return max(get(l,r,x,v + v,tl,tm),get(l,r,x,v + v + 1,tm + 1,tr));
}
ll calc (int  l,int  r) {
        ll res = 0;

        for (int  k = 1; k <= m; k ++) {
                res += get(l,r,k);
        }
        return res;
}
void compute(int l,int r,int L,int R) {

        if (l > r) return;


        int md = (l + r) >> 1;

        ll cur = -1;
        int opt = L;

        for (ll i = L; i <= min(md,R); i ++) {
                ll now = calc(i,md) - (p[md] - p[i]);
                if (now > cur)
                        cur = now,opt = i;
        }
        mx = max(mx,cur);
        compute(l,md - 1,L,opt);
        compute(md + 1,r,opt,R);
}
main () {
        cin >> n >> m;

        for (int i = 1; i < n; i ++) {
                scanf("%d", &a[i]);
                p[i + 1] = p[i] + a[i];
        }

        for (int i = 1; i <= n; i ++) {
                for (int j = 1; j <= m; j ++) {
                        scanf("%d", &b[i][j]);
                }
        }
        build();
        compute(1,n,1,n);
        cout << mx << endl;
}


Measured memory_bytes: 19968
o = input()
e = input()
a = len(o)
b = len(e)
if a==b:
    for i in range(a):
        print(o[i],end = '')
        print(e[i],end = '')
else:
    for i in range(b):
        print(o[i],end = '')
        print(e[i],end = '')
    print(o[-1],end = '')

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

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i, n)
  {
    cin >> a.at(i);
    b.at(i) = a.at(i);
  }
    sort(b.begin(), b.end());
    ll max = b.at(n - 1);
    ll sec_max = b.at(n - 2);
  
  rep(i,n){
    if(a.at(i)!=max){
      cout << max  << "\n";
    }
    else{
      cout << sec_max << "\n";
    }
  }
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll N,A,B,C,D,E;
  cin >> N >> A >> B >> C >> D >> E;
  ll minmove=min({A,B,C,D,E});
  ll ans=(N+minmove-1)/minmove+4;
  cout << ans << endl;
}


Measured memory_bytes: 256
S,M,L,B=map(int,input().split())

N=int(input())

if min(8*S,4*M,2*L,B)==8*S:
    print(4*S*N)
elif min(8*S,4*M,2*L,B)==4*M:
    print(2*M*N)
elif min(8*S,4*M,2*L,B)==2*L:
    print(L*N)
elif min(8*S,4*M,2*L,B)==B:
    if N%2==0:
        print(B*N//2)
    else:
        if min(8*S,4*M,2*L)==8*S:
            print(B*(N//2)+4*S)
        elif min(8*S,4*M,2*L)==4*M:
            print(B*(N//2)+2*M)
        elif min(8*S,4*M,2*L)==2*L:
            print(B*(N//2)+L)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {
    
    long long H;
    cin >> H;
    long long ans = 1;
    long long max = 2;
    for(int i=0;i<41;i++){
        if(H < max){
            break;
        }else{
        ans += max;
        max *= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'
function Main(input) {
    let Nums = input.trim().split('\n');
	let Info = Nums[0].split(' ');
  	let Border = Info[1];
  	let Row = Nums[1].split(' ').sort((a,b) => {return a - b});
  	let FilterRow = Row.filter((x)=> {return x*1 >= Border});
  	console.log(FilterRow.length);
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 28024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i =(b)-1;i>=(a);--i)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef vector<int> vi;
const int mod = 998244353;
const int maxn = 2e6 + 10;
ll f[maxn];
ll b[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,s;
	cin >> n >> s;
	b[s] = 1;
	rep(i,0,n)cin >> f[i];
	rep(i,0,n){
		rep(j,0,s+1){
			b[j] = (b[j]*2 + b[j+f[i]])%mod;
		}
	}
	cout << b[0];
	return 0;
}


Measured memory_bytes: 3696
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

int main(void) {

    char cards[201];
    int N;
    while (true) {
        cin >> cards;
        if (cards[0] == '-') { break; }
        cin >> N;

        int total = 0;
        for (int _ = 0, n; _ < N; ++_) {
            cin >> n;
            total += n;
        }
        size_t len = strlen(cards);
        rotate(cards, cards + total % len, cards + len);

        printf("%s\n", cards);
    }

    return 0;
}

Measured memory_bytes: 1140
#include<stdio.h>
#include<stdlib.h>

int main(int argc,char** argv)
{
	int L, R , A, B, C, D;
	scanf("%d%d%d%d",&A, &B, &C, &D);
	L = A + B;
	R = C + D;
	if(L > R){
		printf("Left\n");
	}
	else if(L < R){
		printf("Right\n");
	}
	else{
		printf("Balanced\n");
	}
	return(0);
}

Measured memory_bytes: 128
import sys
from collections import defaultdict
from string import ascii_lowercase

n, *s = sys.stdin.read().split()
n = int(n)

def main():
    cnt = [defaultdict(int) for _ in range(n)]
    for i in range(n):
        for c in s[i]:
            cnt[i][c] += 1
    
    for i in range(n - 1):
        for c in ascii_lowercase:
            cnt[i+1][c] = min(cnt[i+1][c], cnt[i][c])
    res = ''
    for v, c in sorted(cnt[-1].items()):
        res += v * c
    print(res)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
int main()

{
    char c;
    cin>>c;

    for(int i=0;i<25;i++)
    {
        if(i+c<'z')
        {
            printf("%c",i+1+c);
            return 0;
        }
    }
}


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

const int N = 100000;

int n;
int a[N + 5], b[N + 5];
vector<pair<int, int> > val;
long long ans = LLONG_MAX, sa, sb;

int main() {

    scanf("%d", &n);
    for(int i = 1; i <= n; ++i) {
        scanf("%d%d", a+i, b+i), sa += a[i], sb += b[i];
        val.emplace_back(a[i], i);
        val.emplace_back(b[i], i);
    }
    ans = min(sa, sb);

    std::sort(val.begin(), val.end());

    long long s0 = 0, s1 = 0, s2 = 0;
    for(int i = 0; i < n-2; ++i) {
        s0 += val[i].first; 
    }
    s1 = s0 + val[n-2].first;
    s2 = s1 + val[n-1].first;

    static int vis[N + 5];
    memset(vis, -1, sizeof vis);

    for(int i = 0; i < 2*n; ++i) {
        if(vis[val[i].second] >= 0) {
            int j = vis[val[i].second];
            if(i < n) ans = min(ans, s2);
            else if(j < n - 1) ans = min(ans, val[i].first + s1);
            else ans = min(ans, val[i].first + val[vis[val[i].second]].first + s0);
        } else vis[val[i].second] = i;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3184
N, A, B, C = map(int, input().split())
L = [int(input()) for i in range(N)]

ans = 0
initial_ans = True
for i in range(4**N):
    uses = [0] * (4)
    use_count = 0
    before_div = i
    for j in range(N):
        uses[before_div%4] += L[j]
        if before_div%4 != 0:
            use_count += 1
        before_div = before_div//4
    if uses[1] == 0 or uses[2] == 0 or uses[3] == 0:
        continue
    else:
        sum_mp = abs(A-uses[1]) + abs(B-uses[2]) + abs(C-uses[3]) + 10 * (use_count-3)
        if initial_ans:
            ans = sum_mp
            initial_ans = False
        else:
            ans = min(ans, sum_mp)
print(ans)
    

Measured memory_bytes: 3064
#include <stdio.h>          // printf(), scanf()
#include <string.h>         // memcpy()

#define MAX_N 200000
#define SENTINEL 2000000000

int l[MAX_N / 2 + 2], r[MAX_N / 2 + 2];

long
merge(int a[], int left, int mid, int right)
{
	int i, j, k;
	const int n1 = mid - left;
	const int n2 = right - mid;

	memcpy(l, &a[left], sizeof(int) * n1);
	memcpy(r, &a[mid], sizeof(int) * n2);
	l[n1] = SENTINEL, r[n2] = SENTINEL;
	i = 0, j = 0;

	long count = 0;
	for (k = left; k < right; ++k)
	{
		if (l[i] <= r[j])
			a[k] = l[i++];
		else
		{
			a[k] = r[j++];
			count += n1 - i;
		}
	}

	return count;
}

long
mergesort(int a[], int left, int right)
{
	long count = 0;
	if (left + 1 < right)
	{
		const int mid = (left + right) / 2;
		count = mergesort(a, left, mid);
		count += mergesort(a, mid, right);
		count += merge(a, left, mid, right);
		return count;
	}

	return 0;
}

int
main(int argc, char** argv)
{
	int a[MAX_N];
	int n, i;

	scanf("%d", &n);
	for (i = 0; i < n; ++i)
		scanf("%d", &a[i]);

	printf("%ld\n", mergesort(a, 0, n));
	return 0;
}

Measured memory_bytes: 2172
n=int(input())
l1=list(input())
l2=list(input())
if l1[0]==l2[0]:
  ans=3
  i=1
else:
  ans=6
  i=2
while i<n:
  if l1[i-1]==l2[i-1]:
    if l1[i]==l2[i]:
      ans*=2
      i+=1
    else:
      ans*=2
      i+=2
  else:
    if l1[i]==l2[i]:
      i+=1
    else:
      ans*=3
      i+=2
  ans=ans%1000000007
print(ans)

Measured memory_bytes: 3188