akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <set>

using namespace std;
#define MAXN 100000
#define ll long long
#define rint register int
#define gc() getchar()
inline ll read(ll ans = 0, rint sgn = ' ', rint ch = gc())
{
	for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
	for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
	return sgn-'-'?ans:-ans;
}
int N, Q, tmp; ll X[MAXN+5], D[MAXN+5], R[MAXN+5], x;
void DFS(ll T, ll V){if(T <= X[1]){R[T] += V; return;} tmp = lower_bound(X+1,X+Q+1,T)-X-1, D[tmp] += T/X[tmp]*V, DFS(T%X[tmp],V);}
int main()
{
	N = read(); X[Q=1] = N; for(int i = read(); i--; X[++Q] = x) for(x = read(); Q && x <= X[Q]; Q--);
	D[Q] = 1; for(rint i = Q; i > 1; D[i-1] += X[i]/X[i-1]*D[i], DFS(X[i]%X[i-1],D[i]), i--); R[X[1]] += D[1];
	for(rint i = N; i; R[i-1] += R[i], i--); for(rint i = 1; i <= N; printf("%lld\n",R[i]), i++); return 0;
}

Measured memory_bytes: 4096
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;
const double PI = 3.14159265358979323846;
int main() {
    double a;
    cin >> a;
     cout << setprecision(16) <<  2.0 * a * PI  << endl;

}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  string S;
  cin >> S;
  bitset<10> d1;
  bitset<100> d2;
  set<int> ans;
  REP(i, N) {
    int d = S[i] - '0';
    REP(j, 100) {
      if (d2[j]) {
        ans.insert(j * 10 + d);
      }
    }
    REP(j, 10) {
      if (d1[j]) {
        d2.set(10 * j + d, true);
      }
    }
    d1.set(d, true);
  }
  cout << ans.size() << endl;
}


Measured memory_bytes: 3724
# FOLLOW ANSWER
N,C = map(int,input().split())

x = [0]
v = [0]

acc = [0]
rev = [0]
s = 0
res = 0
for i in range(N):
    a,b = map(int,input().split())
    x.append(a)
    v.append(b)
    s += b
    acc.append(s)


#OB < OA
#O->B->A = 2*OB + OA
F =  []

for i in range(N+1):
    F.append(acc[i]-x[i])
for i in range(1,N+1):
    F[i] = max(F[i],F[i-1])
for B in range(N+1):
    if B == 0:
        A = N
        costB = 0
    else:
        A = B - 1
        costB = (s-acc[B]+v[B]-2*(C-x[B]))
    
    res = max(res,F[A] + costB)

#OA < OB
#O->A->B = 2*OA + OB
F[0] = 0
for i in range(N,0,-1):
    F[i] = (s-acc[i]+v[i]-(C-x[i]))
    F[i] = max(F[i],F[(i+1)%(N+1)])
for A in range(N+1):
    if A == N:
        B = 0
    else:
        B = A + 1
    
    res = max(res,F[B] + acc[A]-2*x[A])
print(res) 


Measured memory_bytes: 19768
program atcoder
implicit none
character(len=10) :: s
character :: c
integer(16) :: i, bin, j, ans, val, sum
integer(16), allocatable :: plus(:)

read(*,*) s

allocate(plus(len_trim(s)-1))

ans = 0
do i = 0, 2**(len_trim(s)-1)-1
  c = s(1:1)
  read(c,*) sum
  plus = 0
  bin = i
  do j = 1, len_trim(s)-1
    plus(j) = mod(bin,2)
    bin = bin/2
  end do
  do j = 2, len_trim(s)
    c = s(j:j)
    read(c,*) val
    if (plus(j-1) == 0) then
      sum = sum*10 + val
    else
      ans = ans + sum
      sum = val
    end if
  end do
  ans = ans + sum
end do

write(*,'(i0)') ans

end program atcoder

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
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; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    // 入力
    int N;cin >> N;
    vector<int> A(N),B(N);
    rep(i,N)cin >> A[i];        //見やすさのため上段と下段でわける。
    rep(i,N)cin >> B[i];

    vector<int> sum_A(N),sum_B(N);
    rep(i,N){                   //左累積和
        if(i == 0)sum_A[0] = A[0];
        else sum_A[i] = sum_A[i-1] + A[i];
    }                           //右累積和
    for(int i = N-1;i>=0;i--){
        if(i == N-1)sum_B[N-1] = B[N-1];
        else sum_B[i] = sum_B[i+1] + B[i];
    }

    int ans = 0;
    rep(i,N) ans = max(ans,sum_A[i]+sum_B[i]);      //答え
    cout << ans << endl;
}

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

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

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

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    ll n;
    std::cin >> n;

    ll ans = 1e9;
    for (ll i = 1; i * i <= n; i++) if (n % i == 0) {
        ll a = std::to_string(i).length();
        ll b = std::to_string(n / i).length();
        chmin(std::max(a, b), ans);
    }

    std::cout << ans << '\n';
}


Measured memory_bytes: 3792
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N, M;
    cin >> N >> M;

    vector<int> A(N+1);
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }
    vector<LL> S(N+1);
    S[0] = 0;
    for (int i = 1; i <= N; ++i) {
        S[i] = (S[i-1] + A[i]) % M;
    }

    LL ans = 0;
    map<int, int> rHist;
    for (int i = 1; i <= N; ++i) {
        if (!S[i]) {
            ++ans;
        }
        ans += rHist[S[i]];
        ++rHist[S[i]];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int tmp = 0;
        int count = 0;
        for(int i=a; i<=b; i++) {
            tmp = i;
            String num = new String();
            while(tmp > 0) {
                num += Integer.toString(tmp%10);
                tmp /= 10;
            }
            if(num.charAt(0) == num.charAt(4)) {
                if(num.charAt(1) == num.charAt(3)) {
                    count += 1;
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 44520
// by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>

// DELETE the debugging information!
#define debug(x) std::cerr << #x << " = " << (x) << std::endl

const int N_MAX = 100003;
int a[N_MAX];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n * 2; ++i)
    scanf("%d", a + i);
  std::sort(a + 1, a + n * 2 + 1);
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    ans += std::min(a[i * 2 - 1], a[i * 2]);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;


const long long int mod = 1000000007, INF = 100000000000000;

//階乗先に計算
long long int kaizyou[200005] = { 1 };
long long int kai(long long int a, long long int b, long long int mod) {
	long long int tmp = 1;
	for (long long int i = a; i <= b; i++) {
		tmp *= i;
		tmp %= mod;

		kaizyou[i] = tmp;
	}
	return tmp;
}


//累乗(繰り返し2乗法)　aのb乗(mod)を求める。
long long int rui(long long int a, long long int b, long long mod) {
	int memo[65] = {};
	long long int A[65] = {};
	long long int tmp = 1;
	for (int i = 0; i < 65; i++) {
		memo[i] = b % 2;
		b /= 2;
	}

	A[0] = a;
	A[0] %= mod;

	for (int i = 1; i < 65; i++) {
		A[i] = A[i - 1] * A[i - 1];
		A[i] %= mod;
	}
	for (int i = 0; i < 65; i++) {
		if (memo[i] == 1) {
			tmp *= A[i];
			tmp %= mod;
		}
	}
	tmp %= mod;
	return tmp;
}

//コンビネーション計算
long long int comb(long long int n, long long int r, long long int mod) {
	long long int tmp;

	tmp = (kaizyou[n] * rui(kaizyou[r], mod - 2, mod)) % mod;
	tmp *= rui(kaizyou[n - r], mod - 2, mod);
	tmp %= mod;
	if (tmp < 0) { tmp = (mod - tmp) % mod; }
	return tmp;
}


long long int M[200005] = {},res=-9999999999;
long long int N, K, Q, a[200005], R[200005] = {}, L[100005] = {}, q[100005], num[700][700] = {}, num2[700][700] = {};
int main() {
	cout << fixed << setprecision(10);
	kai(1, 200000, mod);
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= N; i++) {
		L[i] = L[i - 1] + max(0LL, a[i]);
		R[i] = R[i - 1] + max(0LL, a[N - i + 1]);
		M[i] += M[i - 1]+a[i];
	}
	for (int i = 0; i <= N-K; i++) {
		res = max(res, L[i] + R[N - K - i] + max(M[i + K] - M[i ],0LL));
	}
	cout << res;
}


Measured memory_bytes: 8320
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;


int main()
{
    long X;
    cin >> X;
    
    long ans = 0;
    while (X / 5) {
        if (X / 500) {
            X -= 500;
            ans += 1000;
        }else if (X / 5) {
            X -= 5;
            ans += 5;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

int S[1000], top;

void push(int x){
	S[++top] = x;
}

int pop(){
	top--;
	return S[top + 1];
}

int main(){
	char s[100];
	int a, b;
	top = 0;
	while (scanf("%s", s) != EOF){
		if (s[0] == '+'){
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-'){
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*'){
			a = pop();
			b = pop();
			push(a*b);
		}
		else{
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	return 0;
}

Measured memory_bytes: 3228
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;

int main(){
    int n, m, x, y;  cin>>n>>m>>x>>y;
    int xt = x, yt = y;
    for(int i = 1; i <= n; i++){
        int t; cin>>t;
        xt = max(xt, t);
    }
    for(int i = 1; i <= m; i++){
        int t; cin>>t;
        yt = min(yt, t);
    }
    if(xt<yt) cout<<"No War";
    else cout<<"War";
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x): #親を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y): #和集合の生成
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x): #所属する集合の大きさ
        return -self.parents[self.find(x)]

    def same(self, x, y): #同じ集合に属しているか判定
        return self.find(x) == self.find(y)

    def members(self, x): #同じ集合に属する要素全列挙
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self): #集合のリーダー全列挙
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self): #集合の数
        return len(self.roots())

    def all_group_members(self): #辞書型,{(リーダーの番号):(その集合の要素全列挙)}
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m=map(int,input().split())
uf=UnionFind(n)
for i in range(m):
    a,b=map(int,input().split())
    uf.unite(a-1,b-1)
print(uf.group_count()-1)

Measured memory_bytes: 75316
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector< pair<int, int> > xy;
  vector< pair< pair<int, int>, int > > pq;
  for(int i = 0 ; i < n; i++){
    int x, y;
    cin >> x >> y;
    for(int j = 0; j < xy.size() ;j++){
      int xyjf = xy[j].first;
      int xyjs = xy[j].second;
      int flag = 0;
      for(int k = 0; k < pq.size(); k++){
        int pqkff = pq[k].first.first;
        int pqkfs = pq[k].first.second;
        if( (pqkff == x-xyjf && pqkfs == y-xyjs) || (pqkff == xyjf - x && pqkfs == xyjs - y) ){
          pq[k].second++;
          flag = 1;
        }
      }
      if( !flag ){
        pq.push_back(make_pair(make_pair(x-xyjf,y-xyjs), 1));
        pq.push_back(make_pair(make_pair(xyjf-x,xyjs-y), 1));
      }
    }
    xy.push_back(make_pair(x,y));
  }
  int maxi = 0;
  for(int i = 0; i < pq.size(); i++){
    maxi = max(maxi, pq[i].second);
  }
  cout << n - maxi << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  string s;
  cin >> s;
  
  if(s[0]!=s[1] && s[0]!=s[2] && s[1]!=s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
 
}

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

using namespace std;

int main()
{
    int n;

    cin >> n;

    vector <int> a(n+1, 0);
    map <int, int> counts;

    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        counts[a[i]+i]++;
    }

    long long int ans = 0;

    for (int i = 1; i <= n; i++)
    {
        ans += counts[i - a[i]];
    }

    cout << ans << "\n";

    return 0;
}

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

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  rep(i,3)if(s.at(i) == '1')cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 3624
mod = 998244353
N, K = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(K)]
dp = [0] * (N+1)
dpsum = [0] * (N+1)
dp[1] = 1
dpsum[1] = 1
for i in range(2, N+1):
    for l, r in LR:
        li = i-r
        ri = i-l
        if ri < 0: continue
        li = max(1, li)
        dp[i] += dpsum[ri] - dpsum[li-1]
        dp[i] = dp[i] % mod
    
    dpsum[i] = dpsum[i-1] + dp[i] 
    dpsum[i] = dpsum[i] % mod

print(dp[N])

Measured memory_bytes: 24568
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int judge(int n, int x) {//x進数
	int ans = 0;
	while (n > 0) {
		ans += n % x;//1回目はxの0乗、つまり1が何回必要とされるか,それ以降はｘの0乗が何回必要になるか
		n /= x;
	}
	return ans;
}


int main() {
	int n;
	cin >> n;
	int minv = n;
	for (int i = 0; i <= n; ++i) {
		minv = min(judge(i, 6) + judge(n - i, 9), minv);
	}
	cout << minv << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int a, b;
    string s;
    cin >> a >> b >> s;

    for(int i=0; i<a+b+1; ++i){
        if((s[i] == '-') ^ (i == a)){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


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

int main(){
  string s; cin >> s;
  int l = s.size();
  bool ans = true;
  for(int i=0; i<=(l-3)/2; i++){
    if(!(s[i]==s[((l-3)/2)-i]&&s[(l-1)-i]==s[((l+1)/2)+i]&&s[i]==s[(l-1)-i])){
      ans = false;
      break;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n, a;
map<int, int> m;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  int ans = 0;
  FOR(i, 0, n){
    cin >> a;
    if(m.find(a) == m.end()) m[a] = 0;
    if(m[a] == a){
      ans++;
    }else{
      m[a]++;
    }
  }
  each(itr, m) if(itr->fi > itr->se) ans += itr->se;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
multiset<int>val;
map<int,int>mp;
int main(){
	int h,w,l,r;scanf("%d%d",&h,&w);
	for(int i=1;i<=w;i++)val.insert(0),mp[i]=0;
	for(int i=1;i<=h;i++){
		scanf("%d%d",&l,&r);
		if(r!=w){
			auto x=mp.lower_bound(r+1);
			if(x->first!=r+1&&x!=mp.begin()){
				x--;
				int v=x->second+(r+1-x->first);
				mp[r+1]=v,val.insert(v);
			}
		}
		auto x=mp.lower_bound(l);
		while(x!=mp.end()&&x->first<=r)val.erase(val.find(x->second)),x=mp.erase(x);
		if(!val.empty())printf("%d\n",i+*val.begin());
		else puts("-1");
	}
	return 0;
}

Measured memory_bytes: 22516
def chmin(a, b): return b if a > b else a


def chmax(a, b): return a if a > b else b


"""もらうDP"""
import math

N = int(input())
h = list(map(int, input().split()))

dp = list([math.inf for i in range(N)])  # dpテーブル
dp[0] = 0
for i in range(N):
    dp[i] = chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[N-1])


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



int main(){
  ll n, k;
  cin >> n >> k;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];

  

  set<vector<ll>> st;
  rep(l, k+1){
    rep(r, k+1){
      if(k < l+r) break;
      if(n < l+r) break;

      vector<ll> w;
      rep(i, l) w.push_back(v[i]);
      rep(i, r) w.push_back(v[n-1-i]);
      st.insert(w);
    }
  }

  ll maxx = -1e10;  
  for(auto w : st){
    ll len = w.size();
    ll del = k - len;
    vector<ll> t = w;
    sort(all(t));
    ll sum = 0;
    rep(i, len){
      if(t[i] < 0 && 0 < del) del--;
      else                    sum += t[i];
    }
    maxx = max(maxx, sum);
  }
  
  cout << maxx << endl;



  return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;
 
#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c)
#define rsort(a,n) sort(a,a+n,greater<>())
 
const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100;
 
int main(void){
    ll n;
    ll a[MAX_N];
    ll answer = 0;
    
    in1(n);
    rin1(i,n,a);
    rsort(a,n);
    rep(i,n) if(i%2==0) answer += a[i]; else answer -= a[i];
    prl(answer);
 
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <random>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n+1) << setfill(x)
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 

constexpr int dy[] = {1,0,-1,0,1,-1,-1,1};
constexpr int dx[] = {0,1,0,-1,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;

inline int gcd(int a, int b){ return b ? gcd(b,a % b) : a;}
inline int lcm(int a, int b){ return a / gcd(a,b) * b;}
inline int updiv(int a, int b){ return (a + b - 1) / b; }

signed main(void){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n,h;
    cin >> n >> h;

    int maxv = 0,res = 0;
    vector<int> v(n);

    rep(i,n){
        int a;
        cin >> a >> v[i];
        chmax(maxv,a);
    }

    sort(all(v),greater<int>());
    for(int i = 0; i < n && h > 0 && v[i] > maxv; ++i){
        h -= v[i];
        ++res;
    }
    
    chmax(h,0);
    cout << res + updiv(h,maxv) << '\n';

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef pair<int,int> P;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int N;
int A[100000];

int main(){
    cin>>N;
    rep(i,N) cin>>A[i];

    vector<int> v;
    rep(i,N){
        if(v.empty()){
            v.push_back(A[i]);
            continue;
        }
        int l=-1, r=v.size();
        while(r-l>1){
            int mid=(l+r)/2;
            if(v[mid]<A[i]) r=mid;
            else l=mid;
        }
        if(r==v.size()) v.push_back(A[i]);
        else v[r]=A[i];
    }

    int ans=v.size();
    cout<<ans<<endl;
}

Measured memory_bytes: 4296
#include "bits/stdc++.h"
using namespace std;
const int N=1e5+20;
int n,x,f[N];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&x),f[x]++;
	for(int i=1;i<N;i++) f[i]+=f[i-1];
	cout<<count(f,f+N,n/2);
}

Measured memory_bytes: 640
n = int(input())
a = [int(i) for i in input().split()]

cnt = 0
sgn = 1
s = 0
for _a in a:
    if (s + _a) * sgn <= 0:
        cnt += abs(_a + s - sgn)
        s = sgn
    else:
        s += _a
    sgn = -sgn

ans = cnt

cnt = 0
sgn = -1
s = 0
for _a in a:
    if (s + _a) * sgn <= 0:
        cnt += abs(_a + s - sgn)
        s = sgn
    else:
        s += _a
    sgn = -sgn

ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 14468
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long n,k,kk,i;
  cin>>n>>k;
  i=1;
  kk=k;
  while(i>0){
    if(n<kk){
      break;
    }
    i=i+1;
    kk=kk*k;
  }
  cout<<i;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int n, m;
  cin >> n >> m;
  cout << (n - 1) * (m - 1) << endl;
}



Measured memory_bytes: 256
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)

hash = {}
a_arr.each do |a|
  hash[a] ||= 0
  hash[a] += 1
end

count = 0
even_num = 0
hash.each do |k, v|
  count += 1
  even_num += 1 if v % 2 == 0
end

if even_num % 2 == 1
  count -= 1
end

puts count


Measured memory_bytes: 25720
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
struct S
{
    //double a;
    int x,y;
};
vector<S> v[1010];

int a,b,c,i,k,d,n,m,e,dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};
int l[13011];
int o[1211];
//int dx[10]={1,0,1,-1,-1,0},dy[10]={0,1,1,1,-1,-1};

long long x,y,z[1554];
P u[1222];
int j[5][112111];
priority_queue<long long, vector<long long>,greater<long long> > q,q1;
stack<int> s,s1;


//deque<int> de;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int, int > p;
string r,r1;
//char r[10010];

bool as(P a,P b)
{

    return a.y>b.y;
}




int main()
{
    scanf("%d",&a);
    m=-987654321;
    d=987654321;
    printf("%d\n",a*2-2);
    for(int t=1;t<=a;t++)
    {
        scanf("%d",&o[t]);
        if(o[t]>m) m=o[t],n=t;
        if(o[t]<d) d=o[t],c=t;
    }
    if(max(m,-m)>max(d,-d)) c=n,d=m;
    for(int t=1;t<=a;t++)
        if(t!=c)
        printf("%d %d\n",c,t);
    if(d>0)
        for(int t=1;t<a;t++)
        printf("%d %d\n",t,t+1);
    else for(int t=a;t>1;t--)
        printf("%d %d\n",t,t-1);
}


Measured memory_bytes: 256
n, k = map(int, input().split())
x = [int(i) for i in input().split()]

ans = 10**9+7
if x[0] >= 0:
  ans = x[k-1]
elif x[-1] <= 0:
  ans = -x[-k]
else:
  for i in range(n-k+1):
    if (x[i+k-1] < 0 and i+k != n and x[i+k] < 0) or (x[i] > 0 and i != 0 and x[i-1] > 0):
      continue
    elif x[i+k-1] < 0:
      ans = min([ans, -x[i]])
    elif x[i] > 0:
      ans = min([ans, x[i+k-1]])
    else:
      ans = min([ans, -2*x[i]+x[i+k-1], -x[i]+2*x[i+k-1]])
print(ans)

Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,s,n) for(i=s;i<n;i++)
#define ff first
#define ss second
#define pb push_back
ll i,j;

int main() {
   ll n;
   cin>>n;
   if(n%1000==0)
   cout<<0<<endl;
   else
   cout<<1000-(n%1000)<<endl;
	return 0;
}


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

int main(){
	int x[2];
	while (cin >> x[0] >> x[1])
	{
		if (x[0] == 0 && x[1] == 0) break;
		sort(x, x + 2);
		cout << x[0] << " " << x[1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>

using namespace std;

int main(){
    int n,x;
    int i,j,k;
    int count;
    int l = 0;
    
    while(1){
        count = 0;
        cin >> n >> x;
        
        if(n == 0 && x == 0){
            break;
        }
        
        for(i = 1;i <= n - 2;i++){
            for(j = i + 1;j <= n -1;j++){
                for(k = j + 1;k <= n;k++){
                    if(x == i + j + k){
                        count++;
                        l++;
                    }
                }
            }
        }
        
        cout << count << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int a[3][3];
  cin >> a[0][0] >> a[0][1] >> a[1][1];
  a[2][0] = a[0][0] + a[0][1] - a[1][1];
  a[1][2] = a[0][0] + a[2][0] - a[1][1];
  a[2][2] = a[0][0] + a[0][1] - a[1][2];
  a[1][0] = a[0][0] + a[2][2] - a[1][2];
  a[0][2] = a[1][1] + a[2][2] - a[0][1];
  a[2][1] = a[0][0] + a[2][2] - a[0][1];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
}

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

int main() {
    int n, m; cin >>n >>m;
    map<int, int> ab{};
    for (int i = 0; i < n; i++) {
        int k, v;
        cin >>k >>v;
        auto it = ab.find(k);
        if (it != ab.end()) {
            v += it->second;
            ab.erase(k);
        }
        ab.insert(make_pair(k,v));
    }
    long long ret = 0;
    for (auto const& i : ab) {
        if (m>i.second) {
            ret += (long long) i.first * i.second;
            m -= i.second;
        }
        else {
            ret += (long long) i.first * m;
            m = 0;
        }
        if (m == 0) break;
    }
    cout << ret << endl;
    return 0;
}

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

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            //SolveA(args);
            SolveB(args);
            //SolveC(args);
            //SolveD(args);
        }
        
        static void SolveA(string[] args)
        {
            string sz = (Console.ReadLine());
            long n = long.Parse(sz);
            if(n %  2 == 0)
            {
                Console.WriteLine(n);
            }
            else
            {
                Console.WriteLine(n * 2);
            }
        }
        static void SolveB(string[] args)
        {
            string sz = (Console.ReadLine());
            long n = long.Parse(sz);
            long[] a = new long[n];
            string[] szArr = Console.ReadLine().Split(' ');

            long max = long.MinValue;
            long min = long.MaxValue;

            for (int i=0;i<szArr.Length;++i)
            {
                long tmp  = long.Parse(szArr[i]);
                a[i] = tmp;
                max = Math.Max(tmp, max);
                min = Math.Min(tmp, min);
            }

            long val = Math.Abs(max - min);
            Console.WriteLine(val);
        }
    }

}


Measured memory_bytes: 13140
/*
            ██        ██              ██        ██████
                    ██████                    ██    ██
        ████████    ██████    ████████      ████████
    ████        ██████████████        ████
  ██        ██████    ██    ██████        ██
██████████  ██████        ████████  ██████████
    ████████    ██████  ██████    ████████
        ████  ██    ██  ██    ██  ████
          ██  ██  ████  ████  ██  ██        ████████
          ██  ██    ██████    ██  ██          ██    ██
        ██      ██████  ██████      ██          ██████
  ██    ██          ██████          ██
        ██      ████████████████    ██
        ██    ██              ██      ██
          ██  ██    ██████    ██      ██      ████
      ██  ██  ██████      ██████        ██    ██  ██
    ████    ██                          ██    ██  ██████████
  ██  ██      ██            ██            ██  ██  ██
  ██  ██        ████      ██              ██  ██  ██
  ████            ████  ██        ██      ██████  ██████████
                ████████        ██        ████    ████
              ██    ████    ████          ████  ██  ██
              ██    ██████████            ████  ██  ██
                ██████████                  ██  ██  ██
        ██████  ██████████████████████████████████  ██
        ██  ████████  ██                    ██  ██  ████
        ██████████      ██████████████████████████    ██
          ██████        ██                  ██        ██████
                          ██                ██
*/
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

bool used[100010];
int main(){
    long long n,k; cin>>n>>k;
    pair<long long,long long> sushi[n];
    rep(i,n){
        int t,d; cin>>t>>d;
        sushi[i]={d,t};
    }
    sort(sushi,sushi+n);
    reverse(sushi,sushi+n);
    priority_queue<long long,vector<long long>,greater<long long>> pq;
    long long ans=0,sum=0,cnt=0;
    rep(i,k){
        sum+=sushi[i].first;
        if(used[sushi[i].second]){
            cnt--;
            pq.push(sushi[i].first);
        }
        cnt++;
        used[sushi[i].second]=1;
    }
    ans=sum+cnt*cnt;
    for(int i=k;i<n;i++){
        if(!used[sushi[i].second]){
            used[sushi[i].second]=1;
            if(pq.size()){
                auto x=pq.top(); pq.pop();
                sum+=sushi[i].first-x;
                cnt++;
                ans=max(ans,sum+cnt*cnt);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2556
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>
#include<chrono>

#ifdef ONLINE_JUDGE
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
#define int128 __int128
#else
#define int128 long long
#endif

#define all(x) x.begin(), x.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(nullptr));

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll mod = 1e9 + 7;

namespace {
    ll mul(ll a, ll b) {
        ll val = a * b - (ll)((ld)a * b / mod) * mod;
        if (val < 0) val += mod;
        if (val >= mod) val -= mod;
        return val;
    }
    ll poww(ll a, ll b) {
        ll val = 1;
        a %= mod;
        while (b > 0) {
            if (b % 2) val = mul(a, val);
            a = mul(a, a);
            b >>= 1;
        }
        return val % mod;
    }
    ll inv(ll a) {
        return poww(a, mod - 2);
    }
    ll gcd(ll a, ll b) {
        return (a == 0 ? b : gcd(b % a, a));
    }
    ll gcdex(ll a, ll b, ll& x, ll& y) {
        if (a == 0) {
            x = 0; y = 1;
            return b;
        }
        ll x1, y1;
        ll d = gcdex(b % a, a, x1, y1);
        x = y1 - (b / a) * x1;
        y = x1;
        return d;
    }

    ll inv_eu(ll a, ll m) {
        ll x, y;
        ll g = gcdex(a, m, x, y);
        if (g != 1)
            assert(0);
        else {
            x = (x % m + m) % m;
            return x;
        }
    }
}

ll const maxn = 3e5 + 5;

ll dp[2005];

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll a, b, c, d; cin >> a >> b >> c >> d;
    cout << max({ a * c, b * d, a * d, b * c }) << endl;

    return 0;
}

/*

*/


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll K;
  string S;

  cin >> S >> K;

  int last1pos = -1;
  int first_not1_digit = 2;
  for (size_t i = 0; i < S.length(); i++) {
    if (S[i] == '1')
      last1pos++;
    else {
      first_not1_digit = S[i] - '0';
      break;
    }
  }

  int ans = 1;
  if (K - 1 <= last1pos)
    ans = 1;
  else
    ans = first_not1_digit;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
ary = list(map(int,input().split()))
ary_sort = sorted(ary)
a = len(ary)//2-1
for i in range(n):
    if ary_sort[a] < ary[i]:
        print(ary_sort[a])
    elif ary_sort[a] >= ary[i]:
        print(ary_sort[a+1])

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

int main()
{
  int a[2];
  cin>>a[0]>>a[1];
  sort(a, a+2);
  if(a[0]<=8 && a[1]<=8)
    cout<<"Yay!"<<endl;
  else
    cout<<":("<<endl;
  return 0;
}

Measured memory_bytes: 256
s=input()
S=s[::-1]
i=0
j=0
k=len(S)
while(1):
    if(i==k):
        print("YES")
        break
    if(S[i:i+5]=="maerd" or S[i:i+5]=="esare"):
        i+=5
    if(S[i:i+6]=="resare"):
        i+=6
    if(S[i:i+7]=="remaerd"):
        i+=7
    if(i==j):
        print("NO")
        break
    j=i

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
using Graph = vector<vector<pair<int, int>>>;

int N;
vector<int> color;
Graph g;

void dfs(const Graph &g,int v,int color_) {
	for (auto nx_v : g[v]) {
		if (color[nx_v.first] != -1) continue;
		if (nx_v.second) color[nx_v.first] = abs(color_ - 1);
		else color[nx_v.first] = color_;
		dfs(g, nx_v.first, color[nx_v.first]);
	}
}

int main() {
	int u, v, w;
	cin >> N;
	color.assign(N + 1, -1);
	g.resize(N + 1);
	for (int i = 0; i < N - 1; ++i) {
		cin >> u >> v >> w;
		g[u].push_back(make_pair(v, w % 2));
		g[v].push_back(make_pair(u, w % 2));
	}
	color[1] = 0;
	dfs(g, 1, color[1]);
	for (int i = 1; i <= N; ++i) cout << color[i] << endl;
	return 0;
}

Measured memory_bytes: 8960
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;

int main(){

  map < string , int > a;
  map < string , int > b;
  string str[100];
  int n,m,x;

  for(int i=0;i<9;i++){
    cin >> str[i] >> n >> m;
    a[str[i]] = n*200 + m*300;
    b[str[i]] = n + m;
  }

  for(int i=0;i<9;i++) cout << str[i] << " " <<  b[str[i]] << " " << a[str[i]] << endl;
}

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

using namespace std;

template<int mod>
struct ModComb {
	using ll = long long;
	vector<ll> fact;
	vector<ll> facti;
	ModComb(int n) {
		init(n);
	}
	void init(int n) {
		fact.resize(n);
		facti.resize(n);
		fact[0] = 1;
		for (int i = 1; i < n; i++) {
			fact[i] = fact[i-1] * i % mod;
		}
		facti[n-1] = po(fact[n-1], mod - 2);
		for (int i = n-2; i >= 0; i--) {
			facti[i] = facti[i+1] * (i + 1) % mod;
		}
	}
	ll nCr(int a, int b) {
		return (fact[a] * facti[b] % mod) * facti[a-b] % mod;
	}
	ll po(ll next, int cnt) {
		ll res = 1;
		if (cnt == 0) return 1;
		if (cnt & 1) res = res * next % mod;
		return res * po(next * next % mod, cnt >> 1) % mod;
	}
};
using modcomb = ModComb<1000000007>;
//using modcomb = ModComb<998244353>;

int main()
{
	int H, W, A, B;
	cin >> H >> W >> A >> B;
	modcomb m(312345);
	const int mod = 1000000007;
	long long res = 0;
	for (int i = 0; ; i++) {
		int r = H - 1 - A - i;
		int c = B + i;
		if (r < 0 || c >= W) break;
		res += m.nCr(r + c, r) * m.nCr(H + W - r - c - 2, H - r - 1);
		res %= mod;
	}
	cout << res << endl;
}






Measured memory_bytes: 5120
#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,a=0,w=0,t=0,r=0;
    char ara[4];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s",&ara);
        if(ara[0]=='A')
            a++;
        else if(ara[0]=='W')
            w++;
        else if(ara[0]=='T')
            t++;
        else
            r++;
    }
    printf("AC x %d\n",a);
    printf("WA x %d\n",w);
    printf("TLE x %d\n",t);
    printf("RE x %d\n",r);
    return 0;
}


Measured memory_bytes: 1736
#include<math.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
int A[110],sw=0,n;
void swap(int x,int y)
{
	int t;
	t=A[x];
	A[x]=A[y];
	A[y]=t;
	sw++;
	return;
}
void selectionsort()
{
	int i,j,min;
	for(i=1;i<=n;i++)
	{
		min=i;
		for(j=i;j<=n;j++)
			if(A[j]<A[min])
				min=j;
		if(i!=min)
			swap(i,min);
	}
	return;
}
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&A[i]);
	selectionsort();
	for(i=1;i<=n-1;i++)
		printf("%d ",A[i]);
	printf("%d\n%d\n",A[n],sw);
	return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const int N = 1e3 + 3;

ll powmod(ll a, ll b) {
  ll res = 1;
  for (; b; b >>= 1, (a *= a) %= MOD) {
    if (b & 1) (res *= a) %= MOD;
  }
  return res;
}

ll inversemod(ll a) {
  return powmod(a, MOD - 2);
}

int n, A, B, C, D;
ll fact[N], f[N][N];

ll P(int n, int k) {
  return (fact[n] * inversemod(fact[n - k])) % MOD;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n >> A >> B >> C >> D;
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) fact[i] = (fact[i - 1] * i) % MOD;
  for (int j = 0; j <= n; ++j) f[0][j] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      f[i][j] = f[i][j - 1];
      if (A <= j && j <= B) {
        for (int k = C; k <= D; ++k) {
          if (i - j * k < 0) break;
          (f[i][j] += (((((f[i - j * k][j - 1] * P(n - i + j * k, j * k)) % MOD) * inversemod(fact[k])) % MOD) * inversemod(powmod(fact[j], k))) % MOD) %= MOD;
        }
      }
    }
  }
  cout << f[n][n];
  return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cmath>
using namespace std;
#define MAXH 1000000001
#define MAXW 101
#define INF 1000
#define MAXN 100001
#define MOD 1000000007
typedef long long ll;
typedef pair<ll, ll> P;


template<typename T>
T pow(T i, T n){
    T re;
    if(n == 0) return 1;
    re = pow(i, n / 2);
    if(n % 2 == 0){
        return re * re;
    }else{
        return i * re * re;
    }
}

int N, K;

int main(){
    cin >> N >> K;
    ll ans = 0;
    ans = K * pow<ll>(K - 1, N - 1);
    printf("%lld\n", ans);

    return 0;
}


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

int main() {
	int h, w;
	
	cin >> h >> w;
	for(int j = 0 ; j < w + 2 ; j++) cout << "#";
	cout << "\n";
	for(int i = 0 ; i < h ; i++){
		string s;
		cin >> s;
		cout << "#" << s << "#" << endl;
	}
	for(int j = 0 ; j < w + 2 ; j++) cout << "#";
	cout << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int a; cin >> a;
	cout << a + a*a + a*a*a;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 3640
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}
	min := 1000000
	max := -1000000
	sum := 0
	for i := range a {
		if min > a[i] {
			min = a[i]
		}
		if max < a[i] {
			max = a[i]
		}
		sum += a[i]
	}
	fmt.Println(min, max, sum)
}



Measured memory_bytes: 1796