akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
ll x, y, z, k;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> x >> y >> z >> k;
    ll a[x], b[y], c[z];
    priority_queue<pair<ll, ll>>pq;
    for(int i = 0;i < x;++i)
        cin >> a[i];
    for(int i = 0;i < y;++i)
        cin >> b[i];
    for(int i = 0;i < z;++i)
        cin >> c[i];
    sort(c, c + z);
    reverse(c, c + z);
    for(int i = 0;i < x;++i)
        for(int j = 0;j < y;++j)
            pq.push({a[i] + b[j] + c[0], 1});
    vector<ll>ans;
    while(k--)
    {
        pair<ll, ll>tp = pq.top();
        pq.pop();
        ans.push_back(tp.F);
        if(tp.S < z)
        {
            tp.F -= c[tp.S - 1];
            tp.F += c[tp.S];
            pq.push({tp.F, tp.S + 1});
        }
    }
    for(auto it : ans)
        cout << it << '\n';
    return 0;
}


Measured memory_bytes: 18792
#include<iostream>
using namespace std;
#include<vector>
int main(){
  int n,m,c;
  cin>>n>>m>>c;
  vector<int> b(m);
  for(int i=0;i<m;i++) cin>>b[i];

  int cnt=0;
  for(int i=0;i<n;i++){
    int res=c;
    for(int j=0;j<m;j++){
      int a;
      cin>>a;
      res+=a*b[j];
    }
    if(res>0) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

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

ll nCr(ll n,ll r){
  if(r == 1) return n;
  else if(r == 0) return 1;
  else return nCr(n-1,r-1)*n/r;
}

int main(){
  ll h1,m1,h2,m2,k; cin >> h1 >> m1 >> h2 >> m2 >> k;
  
  cout << 60*h2+m2 - 60*h1-m1 - k << endl;
  
}

Measured memory_bytes: 3632
/**
 * Created by hiramekun at 21:09 on 2020-04-02.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    vl a(n);
    cin >> a;

    map<ll, ll> mp;
    rep(i, n) {
        mp[a[i]]++;
    }
    ll ans = 0;
    each(e, mp) {
        if (e.S < e.F) ans += e.S;
        else ans += e.S - e.F;
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 7040
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    a, b = map(int, input().split())

    base = b * 10
    for i in range(10):
        r = int((base + i) * 0.08)
        if r == a:
            print(base + i)
            return
    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<tuple<string, int, int>> restaurant(N);
	for (int i = 0; i < N; i++) {
		string s;
		int p;
		cin >> s >> p;
		restaurant.at(i) = make_tuple(s, -p, i + 1);
	}
	sort(restaurant.begin(), restaurant.end());
	for (int i = 0; i < N; i++) {
		int ans;
		tie(ignore, ignore, ans) = restaurant.at(i);
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
    int main()
    {
        ios;
        ll n ;
        cin >> n ;
        if(n==25){
            cout <<"Christmas\n";
        }
        else if(n==24){
            cout <<"Christmas Eve\n";
        }
        else if(n==23){
            cout <<"Christmas Eve Eve";
        }
        else if(n==22){
            cout <<"Christmas Eve Eve Eve";
        }
    }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <boost/math/common_factor_rt.hpp>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long

int main(){
  string S, T;
  cin >> S >> T;
  
  int Sl[26], Tl[26];
  rep(i, 26){
    Sl[i] = 0;
    Tl[i] = 0;
  }
  int len = S.length();
  
  rep(i, len){
    Sl[S[i]-97]++;
    Tl[T[i]-97]++;
  }
  
  sort(Sl, Sl+26);
  sort(Tl, Tl+26);
  
  //rep(i, 26) cout << Sl[i] << Tl[i] << endl;
  
  rep(i, 26){
    if(Sl[i] != Tl[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
  
}

Measured memory_bytes: 776
#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()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  ll n, a, b;
  cin >> n >> a >> b;
  if (a > b) {
    cout << 0 << endl;
    return;
  }
  if (n < 2) {
    if (a == b) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
    return;
  }
  ll r = a + b + (n - 2) * b;
  ll l = a + b + (n - 2) * a;
  cout << r - l + 1 << endl;
}

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

Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int a, b, c;
    bool flag = false;

    cin >> a >> b >> c;
    const int tmp = a;

    vector<int> num;
    while(1){
        if(a % b == c){
            flag = true;
            break;
        }
        else{
            auto result = find(num.begin(), num.end(), (a % b));
            if(result == num.end()){
                num.push_back(a % b);
            }
            else{
                break;
            }
        }
        a += tmp;
    }

    if(flag){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

int main() {
	ios::sync_with_stdio(false);
	int n, a, b, c;
	cin >> a >> b >> c >> n;
	int cnt = 0;
	for(int i = 0; i * a <= n; ++i)
		for(int j = 0; i * a + j * b <= n; ++j) {
			cnt += (n - i * a - j * b) % c == 0;
		}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
const int maxn=5e5+10;
ll a[maxn];

int main()
{
	string s;cin>>s;
	int ans=0,i=0;
	while(i<3){
		int c=0;
		while(i<3&&s[i]=='S') i++;
		while(i<3&&s[i]=='R') i++,c++;
		ans=max(ans,c);
	}
	cout<<ans;
	return 0;	
} 

Measured memory_bytes: 3184
<?php
list($n,$m)=explode(" ",trim(fgets(STDIN)));
if($m==0){
  if($n==1){
    echo 0;
    exit;
  }
  echo 1;
  echo str_repeat(0,$n-1);
  exit;
}
$ans=array_fill(1,$n,0);
$check=array_fill(1,$n,0);
$i=0;
while($i<$m){
  list($s,$c)=explode(" ",trim(fgets(STDIN)));
  if($s==1 and $c==0){
    if($n==1){
      if($ans[1]!=0){
      echo -1;
      exit;
      }
    }else{
    echo -1;
    exit;
      }
  }
  if($check[$s]==0){
    $ans[$s]=$c;
    $check[$s]=1;
  }else{
    if($ans[$s]!=$c){
      echo -1;
      exit;
    }
  }
  ++$i;
}

if($ans[1]==0 and $n!=1){
  $ans[1]=1;
}
echo join("",$ans);

Measured memory_bytes: 4728
let area =
  [| [1; 4]
   ; [0; 2; 5]
   ; [1; 3; 6]
   ; [2; 7]
   ; [0; 5; 8]
   ; [1; 4; 6; 9]
   ; [2; 5; 7; 10]
   ; [3; 6; 11]
   ; [4; 9; 12]
   ; [5; 8; 10; 13]
   ; [6; 9; 11; 14]
   ; [7; 10; 15]
   ; [8; 13]
   ; [9; 12; 14]
   ; [10; 13; 15]
   ; [11; 14] |]

let m_d =
  [| [|0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0|]
   ; [|0; 1; 2; 3; 1; 2; 3; 4; 2; 3; 4; 5; 3; 4; 5; 6|]
   ; [|1; 0; 1; 2; 2; 1; 2; 3; 3; 2; 3; 4; 4; 3; 4; 5|]
   ; [|2; 1; 0; 1; 3; 2; 1; 2; 4; 3; 2; 3; 5; 4; 3; 4|]
   ; [|3; 2; 1; 0; 4; 3; 2; 1; 5; 4; 3; 2; 6; 5; 4; 3|]
   ; [|1; 2; 3; 4; 0; 1; 2; 3; 1; 2; 3; 4; 2; 3; 4; 5|]
   ; [|2; 1; 2; 3; 1; 0; 1; 2; 2; 1; 2; 3; 3; 2; 3; 4|]
   ; [|3; 2; 1; 2; 2; 1; 0; 1; 3; 2; 1; 2; 4; 3; 2; 3|]
   ; [|4; 3; 2; 1; 3; 2; 1; 0; 4; 3; 2; 1; 5; 4; 3; 2|]
   ; [|2; 3; 4; 5; 1; 2; 3; 4; 0; 1; 2; 3; 1; 2; 3; 4|]
   ; [|3; 2; 3; 4; 2; 1; 2; 3; 1; 0; 1; 2; 2; 1; 2; 3|]
   ; [|4; 3; 2; 3; 3; 2; 1; 2; 2; 1; 0; 1; 3; 2; 1; 2|]
   ; [|5; 4; 3; 2; 4; 3; 2; 1; 3; 2; 1; 0; 4; 3; 2; 1|]
   ; [|3; 4; 5; 6; 2; 3; 4; 5; 1; 2; 3; 4; 0; 1; 2; 3|]
   ; [|4; 3; 4; 5; 3; 2; 3; 4; 2; 1; 2; 3; 1; 0; 1; 2|]
   ; [|5; 4; 3; 4; 4; 3; 2; 3; 3; 2; 1; 2; 2; 1; 0; 1|] |]

let h a =
  let rec doit i acc =
    if i = 16 then acc
    else doit (i + 1) (acc + m_d.(a.(i)).(i))
  in doit 0 0

let idx_by_val x (a : int array) =
  let n = Array.length a in
  let rec doit i =
    if i = n then raise Not_found
    else if x = a.(i) then i
    else doit (i + 1)
  in doit 0

let solve a =
  let goal = [|1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 0|] in
  let rec idastar i limit space_i moved lower =
    if i = limit then begin
      if a = goal then (Printf.printf "%d\n" (List.length moved - 1); exit 0)
    end else
      let move j =
        let x = a.(j) in
        if x <> List.hd moved then
          let new_lower = lower - m_d.(x).(j) + m_d.(x).(space_i) in
          if new_lower + i <= limit then begin
            a.(j) <- 0;
            a.(space_i) <- x;
            idastar (i + 1) limit j (x :: moved) new_lower;
            a.(j) <- x;
            a.(space_i) <- 0;
          end in
      List.iter move area.(space_i)
  in
  let lower = h a in
  let rec doit limit =
    if limit <= 45 then begin
      idastar 0 limit (idx_by_val 0 a) [-1] lower;
      doit (limit + 1)
    end in
  doit lower

let () =
  solve (Array.init 16 (fun _ -> Scanf.scanf "%d " (fun i -> i)))

Measured memory_bytes: 4512
// 22
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << left << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef DEBUG
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}
// 3
void _main(int tc) {
  int n;
  cin >> n;
  vector<vector<int>> can(n + 1, vector<int>(n + 1));
  rep(n) {
    rep(j, n) cin >> can[i][j];
  }
  int const mod = 1e9 + 7;
  auto addSelf = [](int &a, int b) -> void {
    a += b;
    if (a >= mod) a -= mod;
  };

  /************* Recursive *************
  vector<vector<int>> mem(n, vector<int>(1 << n, -1));
  function<int(int, int)> f = [&](int i, int mask) -> int {
    if (mask == (1 << n) - 1) return 1;
    if (i == n) return 0;
    if (mem[i][mask] != -1) return mem[i][mask];
    mem[i][mask] = 0;
    rep(j, n) {
      if (can[i][j] && ((mask >> j) & 1) == 0)
        addSelf(mem[i][mask], f(i + 1, mask | (1 << j)));
    }
    return mem[i][mask];
  };
  cout << f(0, 0) << endl;
  *********** End Recursive ***********/

  vector<vector<int>> mem(n + 1, vector<int>((1 << n)));

  rep(n + 1) { mem[i][(1 << n) - 1] = 1; }

  // rep(i, n - 1, -1) {
    rep(mask, (1 << n) - 1, -1) {
      int i = __builtin_popcount(mask);
      rep(j, n) {
        if (can[i][j] && ((mask >> j) & 1) == 0) {
          addSelf(mem[i][mask], mem[i + 1][mask | (1 << j)]);
        }
      }
    }
  // }
  cout << mem[0][0] << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

// 000 111

Measured memory_bytes: 188800
#include "bits/stdc++.h"
using namespace std;

int main() {
    string S;
    cin >> S;
    
    int num[26] = {0};
    for (int i = 0; i < S.size(); i++) {
        num[S.at(i) - 'a']++;
    }

    bool flag = true;
    for (int i = 0; i < 26; i++) {
        if (num[i] == 0) {
            cout << char(i + 'a') << endl;
            flag = false;
            break;
        }
    }

    if (flag) {
        cout << "None" << endl;
    }
}

Measured memory_bytes: 512
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  string S;
  cin >> S;
  vector<int> ans;
  ans.reserve(N);
  int index = N;
  while (index > 0) {
    int m = min(M, index);
    for (; index > m && S[index - m] == '1'; --m);
    if (m == 0) {
      cout << -1 << endl;
      return 0;
    }
    index -= m;
    ans.push_back(m);
  }
  reverse(begin(ans), end(ans));
  for (auto& e : ans)cout << e << " ";
  cout << endl;
}


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

bool isPrime(long long int x){
    if(x < 2)	return false;
    else if(x == 2)	return true;
    else{
        if(x%2 == 0)	return false;
        for(long long int i = 3;i <= sqrt(x);i += 2)
            if(x%i == 0)	return false;
    }
    return true;
}
int main()
{
    ll int x;
    cin >> x;

    for (ll int i = x; i <= 2*x; i++)
    {
        if(isPrime(i) == true){
            cout << i << endl;
            break;
        }
    }
    
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const long long INF = 2e18;
const long long MOD = 1e9+7;

#define sx(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(a) begin(a),end(a)

int main(void) {
    int m,nmin,nmax;
    while (cin >> m >> nmin >> nmax, m) {
        vector<int> P(m);
        REP(i,m) cin >> P[i];
        int gap = 0;
        int ans = 0;

        for (int i=nmin; i<=nmax; i++) {
            if (i == 0) continue;
            int gokaku = P[i-1];
            int hugokaku = P[i];
            if (gokaku - hugokaku >= gap) {
                gap = gokaku - hugokaku;
                ans = i;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007LL
#define all(x) x.begin() , x.end()
#define ld long double
void solve();
vector<vector<ll>>adj;
vector<bool>used;
vector<ll>comp;
void dfs(ll v)
{
	used[v] = 1;
	comp.push_back(v);
	for (auto u : adj[v])
	{
		if (!used[u]) dfs(u);
	}
}
int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}
void solve()
{
	ll n, m; cin >> n >> m;
	adj.resize(n); used.assign(n , 0);
	for (int i = 0; i < m; i++)
	{
		ll u, v; cin >> u >> v; u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	ll res = 0;
	for (int i = 0; i < n; i++)
	{
		if (!used[i])
		{
			comp.clear();
			dfs(i);
			res = max(res , (ll)comp.size());
		}
	}
	cout << res;
	cout << "\n";
	return ;
}

Measured memory_bytes: 28320
#87 C - Exam and Wizard
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
diff = [a-b for a,b in zip(A,B)]
diff = sorted(diff,reverse = True)
negative_v = [i for i in diff if i < 0]
tot = sum(negative_v)

if sum(A) < sum(B):
    print(-1)
else:
    if tot >= 0:
        print(0)
    else:
        cnt = 0
        for d in diff:
            tot += d
            # tot が正になったら終了
            if tot < 0:
                cnt += 1
            else:
                cnt += 1
                break
        ans = cnt + len(negative_v)
        print(ans)

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

int a[222222],b[1111111];
int main(){
int n,c=0;
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
for(int i=0;i<n;i++){
    if(b[a[i]]>1) c--,b[a[i]]--;
    if(b[a[i]]) continue;
    for(int j=a[i];j<1111111;j+=a[i])
    b[j]=1;
    b[a[i]]++;
    c++;
}
cout<<c<<endl;
return 0;
}


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

int main(){
    int num;
    cin >> num;
    bool A[num+1][num+1];
    
    for(int i=1; i<=num; i++){
        for(int j=1; j<=num; j++){
            A[j][i] = false;
        }
    }
    
    for(int i=1; i<=num; i++){
        int node;
        int n;
        cin >> node >> n;
        for(int j=1; j<=n; j++){
            int a;
            //cin >> A[i][j];
            cin >> a;
            A[node][a] = true;
            }
    }
    
    for (int i=1; i<=num; i++){
        for(int j=1; j<=num; j++){
            if(j-1!=0) {
            cout << ' ';
            }
            if(A[i][j]){
            cout << '1' ;
            }
            else{
            cout << '0';
            }
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3044
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
        Integer nam[] = new Integer[N];
        int max1 = 0;int max2 = 0;
      
      for(int i = 0;i < N ; i++){nam[i] =  in.nextInt();}
      
      Integer[] nam2 = nam.clone();
      Arrays.sort(nam, Collections.reverseOrder());
      max1 = nam[0];max2 = nam[1];
      
      for(int i = 0;i < N ; i++){
        if(nam2[i]!=max1){System.out.println(max1);}
        else{System.out.println(max2);}
        
      }
	}
}

Measured memory_bytes: 94136
N = int(input())

minimum = 1e+9999
for a in range(1,N):
  b = N - a
  a_str = str(a)
  b_str = str(b)
  sum = 0
  for i in range(len(a_str)):
    sum += int(a_str[i])
  for i in range(len(b_str)):
    sum += int(b_str[i])
  if sum < minimum:
    minimum = sum
print(minimum)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int i,x,y,z;
	for(i=1;;i++){
		z=0;
		scanf("%d%d",&x,&y);
		if(x==0&&y==0)break;
		if(x>y){
			z=x;
			x=y;
			y=z;
			}
		printf("%d %d\n",x,y);
	}
	return 0;
}


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

int main()
{
    int h,n;    cin>>h>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    cout << ((accumulate(a.begin(), a.end(), 0) >= h) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int q = Integer.parseInt(reader.readLine());
        System.out.println((int)(q+1)/2);
}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

int N;
vector<int> R,G,B;
string S;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N>>S;
    for(int i=0;i<N;i++)
    	if(S[i]=='R') R.push_back(i);
    	else if(S[i]=='G') G.push_back(i);
    	else if(S[i]=='B') B.push_back(i);
    ll ans=0;
    for(int i=0;i<N;i++) for(int j=i+1;j<N;j++){
    	if(S[i]==S[j]) continue;
    	char target='R'^'G'^'B'^S[i]^S[j];
    	if(target=='R'){
    		ans+=R.end()-lower_bound(all(R),j+1);
    		if(2*j-i<N&&S[2*j-i]=='R') ans--;
    	}
    	if(target=='G'){
    		ans+=G.end()-lower_bound(all(G),j+1);
    		if(2*j-i<N&&S[2*j-i]=='G') ans--;
    	}
    	if(target=='B'){
    		ans+=B.end()-lower_bound(all(B),j+1);
    		if(2*j-i<N&&S[2*j-i]=='B') ans--;
    	}
    }
    cout<<ans;
    return 0;
}

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

using Lint=long long;

template<int mod> class ModInt
{
 private:
    Lint val;
 public:
    Lint value(){ return val; }
    ModInt(Lint x=0){ val=x%mod; }
    ModInt pow(int n){
        ModInt res(1),x(val);
        while(n>0){ if(n&1) res*=x; x*=x; n>>=1; }
        return res;
    }
    ModInt inv(){ return pow(mod-2); }
    ModInt& operator+=(ModInt rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator-=(ModInt rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; }
    ModInt& operator*=(ModInt rhs){ val=val*rhs.val%mod; return *this; }
    ModInt& operator/=(ModInt rhs){ *this*=rhs.inv(); return *this; }
    ModInt operator+(ModInt rhs){ return ModInt(val)+=rhs; }
    ModInt operator-(ModInt rhs){ return ModInt(val)-=rhs; }
    ModInt operator*(ModInt rhs){ return ModInt(val)*=rhs; }
    ModInt operator/(ModInt rhs){ return ModInt(val)/=rhs; }
};
using mint=ModInt<1000000007>;

using Graph=vector<vector<int>>;

int main()
{
   int N; cin>>N;
   Graph G(N);
   for(int i=0;i<N-1;i++){
      int a,b; cin>>a>>b;
      a--; b--;
      G[a].push_back(b);
      G[b].push_back(a);
   }

   vector<vector<mint>> dp(N,vector<mint>(2));
   function<mint(int,int,int)> dfs=[&](int v,int p,int c)
   {
      if(dp[v][c].value()>0) return dp[v][c];
      mint res=1;
      for(int u:G[v]) if(u!=p){
         if(c==1) res*=dfs(u,v,0);
         else res*=(dfs(u,v,0)+dfs(u,v,1));
      }
      return dp[v][c]=res;
   };
   mint ans=dfs(0,-1,0)+dfs(0,-1,1);
   cout<<ans.value()<<endl;
   return 0;
}


Measured memory_bytes: 23680
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(T) (T).begin(), (T).end()
 
using namespace std;
 
typedef vector<int> vi;
 
int main(void){
    int d; cin >> d;
    vi dp(d + 1);
    fill(ALL(dp), -1);
    dp[0] = 0;
 
    int x; cin >> x;
    rep(i, x){
        string ans;
        int s;
        cin >> ans >> s;
 
        if(ans != "D") continue;
 
        for(int j = d - 1; j >= 0; j--){
            if(!~dp[j]) continue;
            dp[j + 1] = max(dp[j + 1], dp[j] + s);
        }
    }
 
    int y; cin >> y;
    rep(i, y){
        string ans;
        int s;
        cin >> ans >> s;
 
        if(ans != "DD") continue;
          
        for(int j = d - 2; j >= 0; j--){
            if(!~dp[j]) continue;
            dp[j + 2] = max(dp[j + 2], dp[j] + s);
        }
    }
 
    cout << *max_element(ALL(dp)) << endl;
 
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x >= y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x <= y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  string s;
  cin >> s;
  rep(i, s.size() - 1) {
    if (s.substr(i, 2) == "AC") yes();
  }
  no();
}


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

int main(){
    int n; cin >> n;
    int arr[n][3];
    for (int i = 0; i < n; i++){
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }

    int dp[n][3];
    // init
    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];

    for (int i = 1; i < n; i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + arr[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + arr[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + arr[i][2];
    }

    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}

Measured memory_bytes: 2560
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,k = iim()
H = []
for _ in range(n):
    H.append(ii())
H.sort()

ans = 1000000000
for i in range(n-k+1):
    ans = min(H[i+k-1]-H[i],ans)
print(ans)

Measured memory_bytes: 7488
package main

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

func main() {
	S := oneStr()
	r := ""
	for index := 0; index < len(S); index++ {
		r += "x"
	}
	fmt.Print(r)
}

func searchAbove(slice []int, target int, index int) int {
	for i := index + 1; i < len(slice); i++ {
		v := slice[i]
		if v >= target {
			return i
		}
	}
	return -1
}

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}


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

int main()
{
int A,B;
scanf("%d %d",&A,&B);
if(A==B)
{
    printf("Draw");
}
if((A==1&&B!=1)||(A!=1&&B==1))
{
    if(A==1)
        printf("Alice");
    if(B==1)
        printf("Bob");
}
else if(A>B)
{
    if(A<=13)
    {
        printf("Alice");
    }}
    else if(B>A)
    {
        if(B<=13)
        {
            printf("Bob");
        }
    }
}


Measured memory_bytes: 256
let () =
  let swap arr n =
    let tmp = arr.(n) in
    arr.(n) <- arr.(n-1); arr.(n-1) <- tmp in
  let rec bubbleSort arr n flag counter =
    if n = 0 then (flag, counter)
    else if arr.(n) < arr.(n-1) then (swap arr n; bubbleSort arr (n-1) true (counter+1))
    else bubbleSort arr (n-1) flag counter in
  Scanf.scanf "%d\n" @@ fun n ->
  let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let flag = ref true in
  let counter = ref 0 in
  while !flag do
    let (f, c) = bubbleSort arr (n-1) false 0 in
    counter := !counter + c; flag := f
  done;
  for i = 0 to n - 2 do
    Printf.printf "%d " arr.(i)
  done;
  Printf.printf "%d\n" arr.(n-1);
  Printf.printf "%d\n" !counter


Measured memory_bytes: 2436
#include <bits/stdc++.h>
#define int long long int
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL);
#define fr(i,a,b)  for(int i=a;i<=b;i++)
#define rf(j,b,a)  for(int j=b;j>=a;j--)
#define frr(k,a,b) for(int k=a;k<=b;k++)
#define mp make_pair
#define pb push_back
#define MOD 1000000007
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;

signed main()
{   
	IOS
  /*  #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif*/
 int N,t;
 cin>>N;
 std::vector<int> h;
 for(int i=0;i<N;i++)
 {
 cin>>t;
 h.pb(t);
 }
 int dp[N+1];
 memset(dp,0,sizeof(dp));
 dp[1]=0;
 dp[2]=abs(h[1]-h[0]);
 for(int i=3;i<=N;i++)
 {
  dp[i]=min(abs(h[i-1]-h[i-3])+dp[i-2],abs(h[i-1]-h[i-2])+dp[i-1]);
 }
 cout<<dp[N]<<endl; 
 return 0;
}

Measured memory_bytes: 1908
def make_ps(n):
    nums = [True for i in range(n)]
    nums[0] = nums[1] = False
    p = 2
    sqrt = n ** 0.5
    while p < sqrt:
        for i in range(2 * p, n, p):
            nums[i] = False
        while True:
            p += 1
            if nums[p]:
                break
    return [i for i in range(n) if nums[i]]
ps = make_ps(250)
def is_p(x):
    i = 0
    s = x ** 0.5
    while True:
        if ps[i] > s:
            break
        if not x % ps[i]:
            return False
        i += 1
    return True
while True:
    try:
        n = int(input())
    except:
        break
    for i in range(n - 1, 0, -1):
        if is_p(i):
            print(i, end=' ')
            break
    for i in range(n + 1, 50100):
        if is_p(i):
            print(i)
            break

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

using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

typedef long double Real;
#define EPS 1e-13
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

#define MP make_pair<int,int>

int main(){
  while(true){
    int n;
    cin>>n;
    if(!n)break;
    int mnval = 1145141919;
    for(int a=0;a*200<=n;++a){
      for(int b=0;a*200+b*300<=n;++b){
        int _c = n - (a*200+b*300);
        if(_c%500!=0)continue;
        int c = _c/500;
        int val = 0;
        val += 380*5*4/5*(a/5);
        val += 380*(a%5);
        val += 550*4*17/20*(b/4);
        val += 550*(b%4);
        val += 850*3*22/25*(c/3);
        val += 850*(c%3);
        mnval = min(mnval,val);
      }
    }
    cout<<mnval<<endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;
vector<int> A;

void init()
{
	cin >> N;
	CINV(A, N);
}

int X;

bool add(int x, map<int, int>& m)
{
        if (x == 0) return false;
	m[x]++;
	if (m[x] == X) {
		m.erase(x);
		return add(x-1, m);
	}
        return true;
}

inline bool isok(int x)
{
	X = x;
	int pre = 0;
	map<int, int> m;
	rep(i, N) {
		if (pre < A[i]) {
			pre = A[i];
			continue;
		}
		pre = A[i];
		if (!add(A[i], m)) return false;
		while (1) {
			auto itr = m.end();
			itr--;
			int x = (*itr).first;
			if (x > A[i]) m.erase(itr);
			else break;
		}
	}
	return true;
}

void solve()
{
	bool f = true;
	rep(i, N-1) {
		f &= A[i] < A[i+1];
	}
	if (f) {
		cout << 1 << endl;
		return;
	}
	int ok = 1000000000;
	int ng = 1;
	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;
		if (isok(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}



Measured memory_bytes: 1024
n,m=map(int,input().split())
ng=[set() for _ in range(n)]

for i in range(m):
    A,B=map(int,input().split())
    ng[A].add(B)
    
now=[]
danger=set()
cu=0
for i in range(1,n):
    now.append(i)
    for j in ng[i]:
        danger.add(j)
    if(i+1 in danger):
        cu+=1
        danger.clear()
            
print(cu)

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;
ll mod = 1000000007;


int main(){
    st s;
    cin >> s;
    if(s.size() % 2 == 1) cout << "No"<< endl;
    else{
        ll ans = 0;
        for(ll i = 0; i < s.size() / 2; i++){
            if(s.at(i * 2) == 'h' && s.at(i * 2 + 1) == 'i') ans++;
        }
        if(ans == s.size() / 2) cout << "Yes" << endl;
        else cout << "No" << endl;
    } 
}

Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                while(true){
                        int N = sc.nextInt();
                        if(N==0){
                                break;
                        }
                        for (int i = 0; i < 9; i++) {
                                N -= sc.nextInt();
                        }
                        System.out.println(N);
                }
        }
}

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

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++) // repマクロ
#define all(v) v.begin(), v.end() // sort等の関数呼び出しを簡潔にする

using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

int main() {
    int N;
    cin >> N;
    
    int ans = 0;
    if(N % 2 == 0){
        cout << N / 2 << endl;
    }else{
        cout << N / 2 + 1 << endl;
    }
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long x;cin>>x;
  for(long long i=-200;i<=200;i++){
    for(long long j=-200;j<=200;j++){
      if(i*i*i*i*i-j*j*j*j*j==x){
        cout<<i<<" "<<j;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3624
#include <cstdio>
#include <set>
using namespace std;
int n, a, s;
set<int> st;
int main() {
	scanf("%d", &n);
	while(n--) {
		scanf("%d", &a);
		if(st.count(a)) st.erase(a);
		else st.insert(a);
	}
	printf("%d", st.size());
	return 0;
}

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

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


void solve(long long N, std::vector<long long> W){
    ll s1=0,s2=0,m=100000;
    rep(i,N)s2+=W[i];
    rep(i,N){
        m=min(m,abs(s1-s2));
        s1+=W[i];s2-=W[i];
    }
    cout<<m<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> W(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&W[i]);
    }
    solve(N, std::move(W));
    return 0;
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  ll m1 = 0;
  ll m2 = 0;
  ll m3 = 0;
  ll m4 = 0;
  ll x1=0, y1=0;
  ll x2=0, y2=0;
  ll x3=0, y3=0;
  ll x4=0, y4=0;
  ll x, y;
  rep(i, N) {
    cin >> x >> y;
    if (x+y>m1) {
      m1 = x+y;
      x1 = x;
      y1 = y;
    }
    if ((ll)INF-x+y>m2) {
      m2 = (ll)INF-x+y;
      x2 = x;
      y2 = y;
    }
    if (2*(ll)INF-x-y>m3) {
      m3 = 2*(ll)INF-x-y;
      x3 = x;
      y3 = y;
    }
    if ((ll)INF-y+x>m4) {
      m4 = (ll)INF+x-y;
      x4 = x;
      y4 = y;
    }
  }
  // cout << x1 << y1 << x3 << y3 << endl;
  cout << max(m1+m3-(ll)INF*2, m2+m4-(ll)INF*2) << endl;
}


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

using namespace std;

int main() {
  int s;cin>>s;
  vector<int> vec(1100000);
  int cnt=0;
  while(1){
    cnt++;
      vec[s-1]++;
    if(vec[s-1]==2)break;
    if(s%2==0)s=s/2;
    else s=3*s+1;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 7464
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[305][305];
long long ans = 0;
 
int main()
{
	int a,b;
	cin>>a>>b;
	long long k=1,s=1;
	while(s<=a){
		s*=b;
		k++;
	}
	cout<<k-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    string S,T;
    cin>>S>>T;
    int ans=0;
    for (int i=0;i<S.size();i++){
        if (S[i]==T[i]) ans++;
    }

    cout<<S.size()-ans<<endl;

    return 0;
}

Measured memory_bytes: 3920
using System;
using System.Collections;
using System.Text;
class Program {
    static void Main(string[] args) {
#if LOCAL_ENVIRONMENT
        var stdin = new System.IO.StreamReader("stdin.txt");
        System.Console.SetIn(stdin);
#endif
        SimpleScanner sc = new SimpleScanner();
        int A = sc.NextInt();
        int B = sc.NextInt(); 
        int C = sc.NextInt();
        int D = sc.NextInt();

        int ans = Math.Min(A,B)+Math.Min(C,D);
        Console.WriteLine(ans);
    } //Main

    public class SimpleScanner {
        private int cnt;
        private string[] items;
        public SimpleScanner() {
            this.cnt = 0;
            var sb = new StringBuilder();
            var s = Console.ReadLine();
            while (s != null) {
                sb.Append(s + " ");
                s = Console.ReadLine();
            }
            this.items = sb.ToString().Split(' ');
#if LOCAL_ENVIRONMENT
    Console.Error.WriteLine("SimpleScanner.items: {0}" , this.items.ToStringA());
#endif
        }
        public void SetCnt(int n) { this.cnt = n; }
        public int NextInt() {
            return int.Parse(this.items[this.cnt++]);
        }
        public long NextLong() {
            return long.Parse(this.items[this.cnt++]);
        }
        public string NextString() {
            return this.items[this.cnt++];
        }
        public int[] NextIntArray(int n) {
            if (n < 1) throw new IndexOutOfRangeException("引数は1以上であること！");
            var result = new int[n];
            for (var i = 0; i < n; i++) result[i] = this.NextInt();
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("{0}", result.ToStringA());
#endif
            return result;
        }
        public long[] NextLongArray(int n) {
            if (n < 1) throw new IndexOutOfRangeException("引数は1以上であること！");
            var result = new long[n];
            for (var i = 0; i < n; i++) result[i] = this.NextLong();
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("{0}", result.ToStringA());
#endif
            return result;
        }
        public string[] NextStringArray(int n) {
            if (n < 1) throw new IndexOutOfRangeException("引数は1以上であること！");
            var result = new string[n];
            for (var i = 0; i < n; i++) result[i] = this.NextString();
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("{0}", result.ToStringA());
#endif
            return result;
        }
        public int[][] NextInt2Col(int n) {
            const int M = 2;
            if (n < 1) throw new IndexOutOfRangeException("引数は1以上であること！");
            int[][] result = new int[M][] {
                new int[n],
                new int[n],
            };
            for (var i = 0; i < n; i++) {
                result[0][i] = this.NextInt();
                result[1][i] = this.NextInt();
            }
#if LOCAL_ENVIRONMENT
            Console.Error.WriteLine("NextInt2Col: [");
            for (var i = 0; i < M; i++)
                Console.Error.WriteLine("  {0},", result[i].ToStringA());
            Console.Error.WriteLine("]");
#endif
            return result;
        }
    }
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  each(x,vec) is >> x;
  return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
  rep(i,vec.size()) {
    if (i) os << " ";
    os << vec[i];
  }
  return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
  rep(i,vec.size()) {
    if (i) os << endl;
    os << vec[i];
  }
  return os;
}

vector<ll> factors(ll n) {
  vector<ll> res;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      n /= i;
      res.pb(i);
    }
  }
  if (n > 1 || res.size() == 0) res.pb(n);
  return res;
}

ll last_id = 0;
vector<vector<P>> G;
ll fresh_node() {
  assert(last_id < 20);
  G.resize(last_id+1);
  return last_id++;
}
vector<ll> xx;
void dfs(const vector<vector<P>>& G, ll v, ll sum) {
  if (v == G.size()-1) {
    xx.pb(sum);
  }
  each(p, G[v]) {
    ll to, cost; tie(to, cost) = p;
    dfs(G, to, sum + cost);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll L; cin >> L;
  ll k = 0;
  rrep(i, 20) {
    if (L>>i & 1) {
      k = i;
      break;
    }
  }
  ll edges = 0;
  auto add_edge = [&](ll a, ll b, ll c) {
    G[a].eb(b, c);
    ++edges;
  };
  vector<ll> ids;
  rep(i, k+1) ids.pb(fresh_node());
  reverse(all(ids));
  rrep(i, k) {
    add_edge(ids[i+1], ids[i], 0);
    add_edge(ids[i+1], ids[i], 1LL<<i);
  }
  ll sum = 1LL<<k;
  rrep(i, k) {
    if (L>>i & 1) {
      add_edge(0, ids[i], sum);
      sum += 1LL<<i;
    }
  }
  // dfs(G, 0, 0);
  // if (xx.size() != L) {
  //   cout << xx.size() << endl;
  //   cout << xx << endl;
  //   cout << endl;
  // }
  // sort(all(xx));
  // xx.erase(unique(all(xx)), xx.end());
  // if (xx.size() != L) {
  //   cout << xx.size() << endl;
  //   cout << xx << endl;
  //   cout << endl;
  // }
  // if (*max_element(all(xx)) != L-1) {
  //   cout << xx.size() << endl;
  //   cout << xx << endl;
  //   cout << endl;
  // }
  assert(edges <= 60);
  assert(last_id <= 20);
  cout << last_id << " " << edges << endl;
  rep(v, G.size()) each(p, G[v]) {
    cout << v+1 << " " << p.first+1 << " " << p.second << endl;
  }
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int cnt[] = new int[26];
        int len = str.length();
        for (int i = 0; i < len; i++) {
            cnt[str.charAt(i) - 'a']++;
        }
        long ans = len * 1L * (len + 1) / 2;
        for(int i = 0;i < len;i++){
            ans -= cnt[str.charAt(i) - 'a'];
            cnt[str.charAt(i) - 'a']--;
        }
        System.out.print(++ans);
    }
}


Measured memory_bytes: 25704
n = int(input())

l = [list(map(str,input().split()))for i in range(n)]

name = []
rate = []

for i in range(n):
    name.append(l[i][0])

for i in range(n):
    rate.append(int(l[i][1]))
    


for i in range(n):
    l[i][1] = int(l[i][1])

for i in range(n):
    l[i][1] = 100 - l[i][1]
    
sorted_l = sorted(l)


for i in sorted_l:
    print(l.index(i)+1)

Measured memory_bytes: 3064