akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;

int main() {
	int nnu, sum;
	string nst;
	cin >> nnu;
	nst=to_string(nnu);
	if(nst.length()%2==0){ //偶数桁
		sum = ( std::pow(100, nst.length()/2) -1)/11 ;
	}else {
		sum = ( std::pow(100, (nst.length()-1)/2) -1)/11 ;
		sum += nnu - std::pow(10, nst.length()-1)+1;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 384
/*
 * Author : Sadi
 * Fri 03/07/2020
 * 16:36:22.84
 */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> queries;
    vector<int> est[n + 1];
//    map<int, set<pair<int, int>>> est;
    for(int i = 0; i < m; ++i) {
        int p, y;
        cin >> p >> y;
        queries.push_back({p, y});
        est[p].push_back(y);
    }
    for(int i = 1; i <= n; ++i) {
        sort(all(est[i]));
    }
    map<int, int> my_map;
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j < (int) est[i].size(); ++j) {
            my_map.insert({est[i][j], j + 1});
        }
    }
    for(int i = 0; i < (int) queries.size(); ++i) {
        int year = queries[i].se;
        auto it = my_map.find(year);
        cout << setfill('0') << setw(6) << queries[i].fi;
        cout << setfill('0') << setw(6) << it->se;
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 13888
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <deque>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i=0;i<n;++i) {
        cin >> p[i];
    }

    int cnt=0;
    for (int i = 1; i<n-1;++i) {
        if (p[i-1] < p[i] && p[i] < p[i+1]) cnt++;
        else if (p[i+1] < p[i] && p[i] < p[i-1]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include <vector>
using namespace std;
int main() 
{
  int N = 0;

  cin >> N;

  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      if (N == i * j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    string S;
    cin >>S;
    int ans=7;
    if(S[0]=='M'&&S[1]=='O')ans=6;
    else if(S[0]=='T'&&S[1]=='U')ans=5;
    else if(S[0]=='W'&&S[1]=='E')ans=4;
    else if(S[0]=='T'&&S[1]=='H')ans=3;
    else if(S[0]=='F'&&S[1]=='R')ans=2;
    else if(S[0]=='S'&&S[1]=='A')ans=1;
    //-----------------------------------
    cout << ans <<endl;
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/segtree>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int max_a = 300005;
int op(int a,int b){
	return max(a,b);
}
int e(){
	return 0;
}
int main(){
	int n,k;cin>>n>>k;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];	
	}

	atcoder::segtree<int,op,e> dp(max_a);
	for(int i = 0; i < n; i++) {
		int x = a[i];
		int l = max(0,x - k),r = min(x + k + 1,max_a);
		int now = dp.prod(l,r) + 1;
		dp.set(x,now);
	}
	int ans = dp.prod(0,max_a);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9572
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

void rec(vector<vector<pair<P,short>>>&v,vector<bool>&vis,int i=0){
    vis[i]=true;
    for(auto&ps:v[i]){
        if(vis[ps.first.first]) continue;
        ps.second=v[ps.first.first][ps.first.second].second=2;
        rec(v,vis,ps.first.first);
    }
}

bool rec2(vector<vector<pair<P,short>>>&v,vector<bool>&vis,vector<int>&o,int i=0){
    vis[i]=true;
    for(auto&ps:v[i]){
        if(ps.second<2||vis[ps.first.first]) continue;
        bool f=rec2(v,vis,o,ps.first.first);
        if(f) ps.second=0,v[ps.first.first][ps.first.second].second=1;
        else ps.second=1,v[ps.first.first][ps.first.second].second=0,++o[i];

    }
    return o[i]&1;
}

class BEvenDegrees {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        int n,m,a,b;
        in>>n>>m;
        if(m&1){
            out<<-1<<endl;
            return;
        }
        vector<vector<pair<P,short>>> v(n);
        fr(i,m){
            in>>a>>b;--a,--b;
            v[a].emplace_back(P(b,v[b].size()),-1);
            v[b].emplace_back(P(a,v[a].size()-1),-1);
        }
        vector<bool> vis(n);
        rec(v,vis);
        vector<int> o(n);
        fr(i,n) for(auto&ps:v[i]) if(ps.second<0) ++o[i],ps.second=1,v[ps.first.first][ps.first.second].second=0;
        vis.assign(n,false);
        rec2(v,vis,o);
        fr(i,n) for(auto&ps:v[i]) if(ps.second) out<<i+1<<" "<<ps.first.first+1<<endl;
    }
};

int main() {
    BEvenDegrees solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

const int maxn = 1e6 + 10, inf = 1e9;
int dp[maxn][2];
string s;

int main()
{
        cin >> s;
        for (char& c : s)
                c -= '0';

        dp[0][1] = inf;
        for (int i = 1; i <= s.size(); i++) {
                dp[i][1] = min(dp[i - 1][0] + 11 - s[i - 1], dp[i - 1][1] + 9 - s[i - 1]);
                dp[i][0] = min(dp[i - 1][0] + s[i - 1], dp[i][1]);
        }

        cout << dp[s.size()][0];

        return 0;
}

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

const int INF = 1e9;
int h,w;
vector<vector<char>> v(100);

int main(){
    cin >> h >> w;
    
    rep(i,h){
        vector<char> r(w);
        rep(j,w){
            cin >> r.at(j);
        }
        v.at(i) = r;
    }

    // rep(i,h)
    // {
    //     rep(j,w){
    //         cout << v.at(i).at(j);
    //     }
    //     cout << endl;
    // }
    
    vector<vector<int>> dp(h);
    rep(i,h)
    {
        vector<int> r(w);
        dp.at(i) = r;
    }

    rep(i,h)
    {
        rep(j,w){
            char cur = v.at(i).at(j);
            int ra = INF,rb = INF;
            if(i==0 && j == 0){
                if(v.at(0).at(0) == '#') ra = 1;
                else ra = 0;
            }
            if(j > 0){
                ra = dp.at(i).at(j-1);
                if(cur == '#' && v.at(i).at(j-1) == '.'){
                    ra++;
                }
            }
            if(i > 0){
                rb = dp.at(i-1).at(j);
                if(cur == '#' && v.at(i-1).at(j) == '.'){
                    rb++;
                }
            }
            dp.at(i).at(j) = min(ra,rb);
        }
    }

    cout << dp.at(h-1).at(w-1) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*

enum class Suit {
    S, H, C, D
}

data class Cards(val suit: Suit, val num: Int)

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val list = mutableListOf<Cards>()
    (1..n).forEach {
        list.add(Cards(Suit.valueOf(scanner.next()), scanner.nextInt()))
    }
    list.reverse()
    Suit.values().forEach { suit -> (1..13).forEach {num ->
        if (!list.contains(Cards(suit, num))) {
            println("${suit} ${num}")
        }
    } }
}


Measured memory_bytes: 28408
n = gets.to_i
array = gets.split(' ').map(&:to_i)

if n == 1
  puts 0
else
  sum = 0
  (0..n - 2).each do |i|
    if array[i] - array[i + 1] > 0
      sum += array[i] - array[i + 1]
      array[i + 1] = array[i]
    end
  end
  puts sum
end

Measured memory_bytes: 28104
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main argv =
    let [|a;b|] = reads int
    if a = b
    then a + b
    else
        let x = max a b
        x + (x - 1)
    |> printfn "%i"
    0

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

int main()
{
  string s,t;
  cin >> s >> t;
  t += s;
  cout << t << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int main(){

	int D,L;
	scanf("%d %d",&D,&L);

	printf("%d\n",(D/L)+(D%L));

	return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
typedef  long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];
 
ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
#define yo 100001
//------------------変数-----------------------//
//-------------------関数----------------------//
 
ll ketawa(ll b, ll nn) {
	if (nn < b) {
		return nn;
	}
	return ketawa(b, nn / b) + nn%b;
}
int main() {
vector<ll> vec;
vec.push_back(INF);
ll n;cin>>n;
vector<ll>::iterator itr;
REP(i,n){
ll hoge;cin>>hoge;
itr=lower_bound(vec.begin(),vec.end(),hoge);

if(*itr==hoge){vec.erase(itr);
}
else{
vec.insert(itr,hoge);
}
}
cout<<vec.size()-1<<endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

const int edge = 1;
const int no_edge = 0;
const int no_time = -1;
const int no_label = -1;


// return finished time
int depth_search(
  int started_label,
  int current_time,
  vector<vector<int>> matrices_graph,
  vector<int>& discovered_times,
  vector<int>& finished_times
) {
  stack<int> visited_stack;
  int vertex_num = matrices_graph.size();
  visited_stack.push(started_label);
  discovered_times[started_label -1] = ++current_time;

  while(!visited_stack.empty()) {
    int current_label = visited_stack.top();

    // find no visited vertex
    int no_visited_label = no_label;
    for(int i = 0; i < vertex_num; i++) {
      if(matrices_graph[current_label - 1][i] != edge) {
        continue;
      }
      if(discovered_times[i] != no_time) {
        continue;
      }
      no_visited_label = i + 1;
      break;
    }

    if(no_visited_label != no_label) {
      visited_stack.push(no_visited_label);
      discovered_times[no_visited_label - 1] = ++current_time;
    } else {
      int finished_label = visited_stack.top();
      visited_stack.pop();

      finished_times[finished_label - 1] = ++current_time;
    }
  }

  return current_time;
}

int main() {
  int vertex_num;
  cin >> vertex_num;
  vector<vector<int>> matrices_graph(
    vertex_num,
    vector<int>(vertex_num, 0)
  );


  // set adjacency matrices graph
  for(int i = 0; i < vertex_num; i++) {
    int vertex_label;
    int adjacency_num;
    cin >> vertex_label >> adjacency_num;

    for(int j = 0; j < adjacency_num; j++) {
      int adjacency_label;
      cin >> adjacency_label;
      matrices_graph[vertex_label -1][adjacency_label - 1] = edge;
    }
  }

  vector<int> discovered_times(vertex_num, no_time);
  vector<int> finished_times(vertex_num, no_time);

  int current_time = 0;
  for(int i = 0; i <vertex_num; i++) {
    if(discovered_times[i] == no_time) {
      int started_label = i + 1;
      current_time = depth_search(
        started_label,
        current_time,
        matrices_graph,
        discovered_times,
        finished_times
      );
    }
  }

  for(int i = 0; i < vertex_num; i++) {
    cout << i + 1 << ' ' <<  discovered_times[i] << ' ' << finished_times[i] << endl;
  }
}



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

typedef long long ll;

const int MN = 200010;

int N;
int A[MN];
ll psum1[MN], psum2[MN];

int main() {
    scanf("%d", &N);

    for(int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    for(int i = 0; i < N; i++) {
        psum1[i] = A[i];
        psum2[i] = A[i];
        if(i) {
            psum1[i] += psum1[i - 1];
            psum2[i] ^= psum2[i - 1];
        }
    }

    ll ans = 0;
    ll a = 0;
    ll b = 0;
    for(int i = 0; i < N; i++) {
        int s = i, e = N - 1, p = -1;
        while(s <= e) {
            int m = (s + e)>>1;

            if(psum1[m] - a == (psum2[m] ^ b)) {
                p = m;
                s = m + 1;
            }
            else e = m - 1;
        }
        ans += (p - i + 1);
        a += A[i];
        b ^= A[i];
    }
    printf("%lld", ans);
}


Measured memory_bytes: 4096
s = list(input())
ans = 0
for i in range(len(s)-1):
  if s[i]==s[i+1]=="0":
    s[i+1] ="1"
    ans+=1
  elif s[i]==s[i+1]=="1":
    s[i+1] ="0"
    ans+=1
print(ans)

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int m, d;
	cin >> m >> d;
	int answer = 0;
	for(int i = 1; i <= m; ++i){
		for(int j = 1; j <= d; ++j){
			const int a = j / 10, b = j % 10;
			if(a > 1 && b > 1 && a * b == i){
				++answer;
			}
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<cstdio>
#include<cstring>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
struct edge{ ll to, cost; };//　一つ目は結んでいるノード,二つ目はその辺の重みを指す
//#define sort(a) sort(a.begin(),a.end())
using Graph = vector<vector<edge>>;  //隣接リスト
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
const int MOD = 1e9+7;
const ll INF =1e18;

int main(){
  S s;cin>>s;
  int ans = 700;
  fr(i,3){
    if(s[i]=='o')ans+=100;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)




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

	int a[n];
	
	int whole = 0;
	rep(i, n) {
		cin >> a[i];
		whole ^= a[i];
	}

	rep(i,n) {
		cout << (whole ^ a[i]) << endl;
	}

	return 0;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std; 
  
typedef long long int ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
typedef priority_queue <ll> pqb;
typedef priority_queue <ll, vector<ll>, greater<ll>> pqs;
double EPS = 1e-9; 
long long INF = 1000000000000000005ll; 
double PI = acos(-1); 
#define M 1000000007ll
#define D 998244353ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound  
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a))
#define GCD(a,b) __gcd(a,b)
#define setbits(x)   __builtin_popcountll(x)
#define zerobits(x)  __builtin_ctzll(x) 
#define ps(x,y)  fixed<<setprecision(y)<<x
#define endl '\n'
#define ff first 
#define ss second 
#define mp make_pair  
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
  
inline string IntToString(ll a) 
{ 
    char x[100]; 
    sprintf(x, "%lld", a); 
    string s = x; 
    return s; 
} 
  
inline ll StringToInt(string a) 
{ 
    char x[100]; 
    ll res; 
    strcpy(x, a.c_str()); 
    sscanf(x, "%lld", &res); 
    return res; 
} 
  
 
inline string uppercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'a' && s[i] <= 'z') 
        s[i] = s[i] - 'a' + 'A'; 
    return s; 
} 
  
inline string lowercase(string s) 
{ 
    int n = SIZE(s); 
    for(ll i=0;i<n;i++) 
    if (s[i] >= 'A' && s[i] <= 'Z') 
        s[i] = s[i] - 'A' + 'a'; 
    return s; 
}

bool cmp(pll a,pll b)
{
  ll as=a.ff-a.ss;
  ll bs=b.ff-b.ss;
    return (as>bs);
}

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

vl v[100005];
bool vis[100005];

int main() {
    FAST
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll n,k;
    cin>>n>>k;
    ll a[n+1]={0};
    for(ll i=1;i<=n;i++){
    	cin>>a[i];
    }
    ll dp[n+1]={0};
    dp[2]=abs(a[2]-a[1]);
    for(ll i=3;i<=n;i++){
    	dp[i]=INF;
    	for(ll j=i-1;j>=max(1ll,i-k);j--){
    		dp[i]=min(dp[j]+abs(a[i]-a[j]),dp[i]);
    	}
    	//cout<<dp[i]<<endl;
    }
    cout<<dp[n]<<endl;
    return 0; 
}

Measured memory_bytes: 7508
#include<iostream>
#include<algorithm>
#include<cstring>
#define lowbit(x) (x)&(-x)
#define ll long long 
using namespace std;

const int maxn = 1e5 + 100;
ll c[maxn * 10]; int a[maxn]; ll N; ll sum[maxn * 10];

void add(int x)
{
	while (x <= N * 2)
	{
		c[x] += 1; x += lowbit(x);
	}
}

ll getsum(int x)
{
	ll sum = 0;
	while (x >= 1)
	{
		sum += c[x]; x -= lowbit(x);
	}
	return sum;
}

bool check(int mid)
{
	for (int i = 0; i <= 2 * N; i++) c[i] = 0;
	sum[0] = 0;
	for (int i = 1; i <= N; i++)
	{
		sum[i] = (a[i] >= mid) ? 1 : -1;
		sum[i] += sum[i - 1];
	}
	ll SUM = 0;
	for (int i = 0; i <= N; i++)
	{
		SUM += getsum(N + sum[i]);
		add(N + sum[i]);
	}
	return SUM >= ((N + 1) * N / (ll)4);
}
int main()
{
	cin >> N;
	int L; int R; L = 0; R = 0;
	for (int i = 1; i <= N; i++)
	{
		cin >> a[i]; R = max(R, a[i]);
	}

	while (L <= R)
	{
		int mid = (L + R) >> 1;
		if (check(mid) == true) L = mid + 1;
		else R = mid - 1;
	}
	cout << R << endl;
	return 0;
}

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

// template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
// template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 998244353
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

//更新順序が非自明
int dp[100100];
int rec(int now,Graph const & G){
    if(dp[now]!=-1) return dp[now];
    int res = 0;
    for(auto nv:G[now]){
        res = max(res,rec(nv,G)+1);
    }
    return dp[now] = res;
}

int main(){
    int N,M; cin>>N>>M;
    Graph G(N);
    rep(i,M){
        int x,y; cin>>x>>y;
        x--;
        y--;
        G[x].push_back(y);
    }
    rep(i,100100)dp[i] = -1;

    int res = 0;
    rep(i,N)res = max(res,rec(i,G));
    cout<<res<<endl;
}

Measured memory_bytes: 11096
'''

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

'''
s = str(input(""))
    
if s == "SUN":
    print("7")
elif s == "MON":
    print("6")
elif s == "TUE":
    print("5")
elif s == "WED":
    print("4")
elif s == "THU":
    print("3")
elif s == "FRI":
    print("2")
elif s == "SAT":
    print("1")

Measured memory_bytes: 2940
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;


ll pat[52];
ll len[52];

ll solve(ll k, ll x) {
    if(len[k] == x) return pat[k];
    ll ans = 0;
    x--;
    if(x > 0) {
        ll L = min(x, len[k-1]);
        ans += solve(k-1, L);
        x-=L;
    }
    if(x > 0) {
        ans++;
        x--;
    }
    if(x > 0) {
        ll L = min(x, len[k-1]);
        ans += solve(k-1, L);
        x -= L;
    }
    return ans;
}

int main(int argc, char const *argv[]) {
    ll n, x;
    cin >> n >> x;
    len[0] = pat[0] = 1;
    for(int i = 0; i < 51; ++i){
        len[i+1] = 2*len[i]+3;
        pat[i+1] = 2*pat[i]+1;
    }
    ll ans = solve(n, x);
    cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

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

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

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

	if (b == 0) {

		return 1;

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

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

	}
	else {

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

	}

}
//pは素数,aのb乗をpで割った余り

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

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

		a *= i;
		a = a%p;

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

		b *= i;
		b = b%p;

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

		c *= i;
		c = c%p;

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

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

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

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

}
//最大公約数

ll lcm(ll a, ll b) {

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

}
//最小公倍数

ll MAX(ll a, ll b) {

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

}
//MAX

ll MIN(ll a, ll b) {

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

}
//MIN

bool func(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

int main() {

	string S, T;
	cin >> S >> T;

	sort(S.begin(), S.end());
	sort(T.begin(), T.end());
	reverse(T.begin(), T.end());

	if (S < T)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

const AMAX = 100000

func main() {
	sc.Split(bufio.ScanWords)

	n, k := nextInt(), nextInt()
	a := make([]int, n)
	b := make([]int, n)

	for i := 0; i < n; i++ {
		a[i], b[i] = nextInt(), nextInt()
	}

	cnt := make([]int, AMAX+10)
	for i := 0; i < n; i++ {
		cnt[a[i]] += b[i]
	}

	for i, v := range cnt {
		if k <= v {
			fmt.Println(i)
			break
		}
		k -= v
	}

	// k++
	// left := 0
	// right := 0
	// sum := make([]int, n+1)
	// for i := 1; i < n+1; i++ {
	// 	sum[i] = sum[i-1] + b[i-1]

	// }
	// fmt.Println(sum)

	// for i := 0; i < n; i++ {
	// 	if sum[i] < k && k <= sum[i+1] {
	// 		fmt.Println(a[sum[i+1]])
	// 		return
	// 	}
	// }
}


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




int main(){
  int num[100000]={};
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>num[i];
    }
    int b=0;
    int count=0;
    for(int i=0; i<n; i++){
       count++;
        if(num[b]==2)break;
        else b=num[b]-1;
      
    }
    if(count==n)cout<<-1<<endl;
    else cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main()
{
    int n, i, sum=0, max;
    scanf("%d", &n);
    int arr[n+5];
    
    scanf("%d", &arr[1]);
    max = arr[1];
    sum = arr[1];
    for(i=2; i<=n; i++)
    {
        scanf("%d", &arr[i]);
        sum = sum + arr[i];
        if(arr[i]>max)
        max = arr[i];
    }
    printf("%d", sum-max/2);
    return 0;
}


Measured memory_bytes: 1708
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  x /= 50;
  int count = 0;
  for (int i = 0; i <= a; i++)
  {
    for (int j = 0; j <= b; j++)
    {
      for (int k = 0; k <= c; k++)
      {
        if ((10 * i + 2 * j + k) == x)
        {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


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

using namespace std;
const int N=1e5+55;
ll sum[N];
ll dp[155][N];
ll mod=1e9+7;
int a[155];
int n,K;
	

int main()
{
	cin>>n>>K;
	for(int i=0;i<n;i++)
		cin>>a[i];
	dp[n][0]=1;
	for(int i=n-1;i>=0;i--)
	{
		sum[0]=dp[i+1][0];
		for(int k=1;k<=K;k++)
		{
			sum[k]=sum[k-1]+dp[i+1][k];
			sum[k]%=mod;
		}
		for(int k=0;k<=K;k++)
		{
			dp[i][k]=sum[k];
			if(a[i]<k)
			{
				dp[i][k]-=sum[k-a[i]-1];
				dp[i][k]+=mod;
				dp[i][k]%=mod;
			}
		}
	}
	cout<<dp[0][K]<<endl;
	
	return 0;
}


Measured memory_bytes: 80896
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
using namespace std;
const int  INF=100000000;
int main(){
  int h,w;
  cin>>h>>w;
  char a[h][w];
  rep(i,h)rep(j,w){
    cin>>a[i][j];
  }

  rep(i,h){
    rep(j,w)cout<<a[i][j];
    cout<<endl;
    rep(j,w)cout<<a[i][j];
    cout<<endl;
  }

  return 0;
}



Measured memory_bytes: 256
// https://atcoder.jp/contests/abc103/tasks/abc103_c

#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, sum = 0;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> m;
        sum += (m - 1);
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

ll A[200010];
int main()
{
	int N;
	cin >> N;
	ll sum = 0;
	for (int i = 0; i < N; i++) cin >> A[i];
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans = (ans + (sum % mod) * A[i]) % mod;
		sum += A[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 5176
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <cctype>
#include <bits/stdc++.h>
#include <queue>

using namespace std;
// for loop
#define F(i, L, R) for(long i = L; i < R; i++)
#define FE(i, L, R) for(long i = L; i <= R; i++)
// for (reversed)
#define FR(i, L, R) for(long i = L; i > R; i--)
#define FRE(i, L, R) for(long i = L; i >= R; i--)

// data types
#define Int long
#define ul unsigned long
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned shoft

// vectors
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
#define ALL(c) (c).begin(),(c).end()
#define last(vec) vec.size()-1
#define lastEle(vec) vec[last(vec)]
#define pb push_back
#define InputV(a, n) F(i,0,n){long l; cin >> l; a.pb(l);}

// debug
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
#define printA(a, L, R) FE(i, L, R) cout << a[i] << (i==R?'\n':' ')
#define printAF(a, L) printA(a, 0, L-1)
#define printV(a) printA(a, 0, a.size()-1)

// utils
#define char2int(c) (c-'0')
#define bit(x, i) (x&(1<<i))
#define space ' '
#define PI 3.14159265358979323

void printM(vector<vector<long> > &vec, long height, long width){
    F(i, 0, height){
        F(j, 0, width){
            cout << vec[i][j] << space;
        }
        cout << endl;
    }
}

#define TST 0
int main() {
#if TST==1
    ifstream in ("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int k,a,b;
    cin >> k >> a >> b;
    int i = 1;
    while(k * i < a){
        i++;
    }
    if(k*i <= b){
        cout << "OK" <<endl;
    }else{
        cout << "NG" << endl;
    }

#if TST==1

#endif
}


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

const int N = 2e5 + 10, mod = 1e9 + 7;



int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    //scanf("%d", &tc);
    while(tc--) {
        int n; cin >> n;
        long long res = 0;
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                for(int k = 1; k <= n; k++) {
                    res += __gcd(__gcd(i, j), k);
                }
            }
        }
        cout << res;
    }    
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second

typedef long long LL;

int h,w;
int n;
int a[12345];
int b[123][123];

int main() {
   // freopen("test.txt","r",stdin);
    cin >> h >> w;
    cin >> n ;
    for (int i =1 ; i <= n ; i++) cin >> a[i];
    int cnt = 1;
    for (int i = 1 ; i  <= h ; i++) {
        if ( i % 2 == 1) {
        for (int j = 1; j <= w ; j++) {
            if ( a[cnt] != 0 ) {
                b[i][j] = cnt;
                a[cnt]--;
            } else {
                while ( a[cnt] == 0) {
                    cnt++;
                }
                b[i][j] = cnt;
                a[cnt]--;
            }
        }
        } else {
         for (int j = w; j >= 1 ; j--) {
            if ( a[cnt] != 0 ) {
                b[i][j] = cnt;
                a[cnt]--;
            } else {
                while ( a[cnt] == 0) {
                    cnt++;
                }
                b[i][j] = cnt;
                a[cnt]--;
            }
        }
        }
    }
    for (int i =1 ; i <= h ; i ++) {
        for (int j = 1; j <= w; j++) {
            cout << b[i][j] << " ";
        }
        cout << endl;
    }
}


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

int main()
{
    long a,b,c,d;
    cin >> a >> b >> c >> d;
    long x[5] ={0};
    x[0] = a * c;
    x[1] = a * d;
    x[2] = b * c;
    x[3] = b * d;
    sort(x, x+4);
    cout << x[3];
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

bitset<4000005> dp;

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


  int sum = 0;
  rep(i,N) sum += v[i];
  if(sum%2==0) sum /= 2;
  else sum = sum/2 + 1;

  dp[0] = 1;
  rep(i,N){
    dp |= dp << v[i];
  }

  int ret = 0;
  REP(i,sum,dp.size()){
    if(dp[i] == 1){
      ret = i;
      break;
    }
  }
  
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int n;
    string s;
    cin >> n >> s;

    int res = 0;
    rep(i, s.size()-2) {
        string t = "";
        t += s[i];
        t += s[i+1];
        t += s[i+2];

        if(t == "ABC") res++;

    }

    cout << res << endl;
    
    return 0;
}

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

int main(){
    int n; cin>>n;
    vector<int> j(n);
    int ans=0;
    for(int i=0;i<n;i++){
        cin>>j.at(i);
        }
    for(int i=1;i<n-1;i++){
        if(j.at(i-1)<j.at(i)&&j.at(i)<j.at(i+1)){
            ans++;
            }
        if(j.at(i-1)>j.at(i)&&j.at(i)>j.at(i+1)){
            ans++;
            }
        }
        cout<<ans<<endl;
}


Measured memory_bytes: 256
def main():
    import numpy as np
    import scipy.sparse.csgraph as sp
    n = int(input())
    gg = [input() for _ in [0]*n]
    graph = [[] for _ in [0]*n]

    inf = float('inf')

    dist = np.full((n, n), inf)

    for i in range(n):
        dist[i, i] = 0
        for j in range(n):
            if gg[i][j] == "1":
                graph[i].append(j)
                dist[i, j] = 1
                dist[j, i] = 1
    q = [0]
    dp = [0]*n
    dp[0] = 1

    flag = True
    while q:
        i = q.pop()
        for j in graph[i]:
            if dp[j] == 0:
                dp[j] = dp[i]*(-1)
                q.append(j)
            elif dp[j] == dp[i]:
                flag = False
                break
        if flag is False:
            break

    dist = np.array(dist)

    if flag is False:
        print(-1)
    else:
        dist = sp.shortest_path(dist)
        print(int(max([max([i for i in j]) for j in dist])+1))


main()

Measured memory_bytes: 18728
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x,n;
  cin>>x>>n;
  
  int p;
  vector<int> A;
  rep(i,n){
    cin>>p;
    A.push_back(p);
  }
  
  set<int> s;
  for(int i=-200;i<=200;i++){
    s.insert(i);
  }
  
  rep(i,A.size()){
    s.erase(A[i]);
  }
  
  int ans;
  int min=100000;
  for(auto u:s){
    if(min>abs(u-x)){
      min=abs(u-x);
      ans=u;
    }
  }
  
  cout<<ans<<endl;

  return 0;
}

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

H = input().split()

H_int = []
for i in H:
    H_int.append(int(i))

view_capable = 0

max_height = H_int[0]

for j in H_int:
    if j >= max_height:
        view_capable += 1
        max_height = j

print(view_capable)

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

int main() {
  int tHp,tAtk,aHp,aAtk;
  string kekka;
  cin >> tHp >> tAtk >> aHp >> aAtk;
  
  while(true){
    tHp -= aAtk;
    aHp -= tAtk;
    
    if(aHp <= 0){
      cout << "Yes";
      break;
    }
    
    if(tHp <= 0){
      cout << "No";
      break;
    }
  }
}


Measured memory_bytes: 3628
using System;

class A
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
		long n = h[0], a = h[1], b = h[2], d = b - a;
		Console.WriteLine(d % 2 == 0 ? d / 2 : Math.Min(a, n - b + 1) + (d - 1) / 2);
	}
}


Measured memory_bytes: 13140
fun main (args : Array<String>) {
    val line1 = readLine()!!.split(" ")
    val line2 = readLine()!!.split(" ")
    val line3 = readLine()!!.split(" ")

    val n = readLine()!!.toInt()
    var bList : MutableList<Int> = mutableListOf()
    for (i in 0..n - 1) {
        val b = readLine()!!.toInt()
        bList.add(b)
    }

    var aMap : MutableMap<Int, Boolean> = mutableMapOf()
    var aList : MutableList<Int> = mutableListOf()

    for (i in line1) {
        aMap.put(i.toInt(), false)
        aList.add(i.toInt())
    }
    for (i in line2) {
        aMap.put(i.toInt(), false)
        aList.add(i.toInt())
    }
    for (i in line3) {
        aMap.put(i.toInt(), false)
        aList.add(i.toInt())
    }

    for (i in 0..bList.size - 1) {
        if (aMap.containsKey(bList[i])) {
            aMap.put(bList[i], true)
        } else {
            continue
        }
    }

    if ( (aMap[aList[0]]!! && aMap[aList[3]]!! && aMap[aList[6]]!!) || (aMap[aList[1]]!! && aMap[aList[4]]!! && aMap[aList[7]]!!) || 
        (aMap[aList[2]]!! && aMap[aList[5]]!! && aMap[aList[8]]!!) || (aMap[aList[0]]!! && aMap[aList[1]]!! && aMap[aList[2]]!!) || 
        (aMap[aList[3]]!! && aMap[aList[4]]!! && aMap[aList[5]]!!) || (aMap[aList[6]]!! && aMap[aList[7]]!! && aMap[aList[8]]!!) || 
        (aMap[aList[0]]!! && aMap[aList[4]]!! && aMap[aList[8]]!!) || (aMap[aList[2]]!! && aMap[aList[4]]!! && aMap[aList[6]]!!) ) {
        println("Yes")
    } else {
        println("No")
    }

}

Measured memory_bytes: 37864
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const int INFI = 1000000000;
 const ll INFL = (1LL << 60);

 const int MAX = 100005;

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

 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }

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

 int main() {
   ll N, K; cin >> N >> K;
   vector<ll> A(N);
   rep(i, 0, N) cin >> A.at(i);

   sort(A.begin(), A.end());

   ll ans = 0;

   COMinit();

   rep(i, K - 1, N) {
     ans += A.at(i) * COM(i, K - 1) % MOD;
     ans %= MOD;
   }

   rep(i, 0, N - K + 1) {
     ans -= A.at(i) * COM(N - i - 1, K - 1) % MOD;
     if (ans < 0) ans += MOD;
     ans %= MOD;
   }

   cout << ans << endl;
 }


Measured memory_bytes: 3328
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		int result = 0;
		result = max(a+b, max(a-b, a*b));
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 22996
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int a, int b, int c) {
    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) return 0;
    if (a == b && b == c) return -1;

    return calc((b + c) / 2, (a + c) / 2, (a + b) / 2) + 1;
}

void main() {
    auto abc = readints;
    int a = abc[0], b = abc[1], c = abc[2];
    writeln(calc(a, b, c));
}


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

int main()
{
    int x,n;
    cin>>x>>n;
    vector<int> p(n);
    vector<int> s={x};
    for (int i=0;i<n;++i)
    {
        cin>>p.at(i);
    }
    for (int i=1;i<=101;++i)
    {
        s.push_back(x-i);
        s.push_back(x+i);
    }
    for (int i=0;i<s.size();++i)
    {
        int tmp=0;
        for (int j=0;j<n;++j)
        {
            if(p.at(j)==s.at(i)){
                tmp++;
                break;
            }
        }
        if(tmp==0)
        {
            cout<<s.at(i)<<endl;
            break;
        }
    }
}

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

void print(const vector<int> &past,int n){
	for(int i = 0; i < past.size(); i++){
		printf("%d ",past[i]);
	}
	printf("%d\n",n);
}

int solve(int n, int mx, vector<int> &past){
	if(n == 1){
		print(past,1);
		return 0;
	}

	if(n <= mx){
		print(past,n);
	}

	for(int i = min(mx,n-1); i > 0; i--){
		vector<int> v = past;
		v.push_back(i);
		solve(n-i,i,v);
	}
	return 0;
}

int main(){
	int n;
	while(scanf("%d\n",&n), n != 0){	
		vector<int> v = vector<int>();
		solve(n,n,v);
	}
	return 0;
}



Measured memory_bytes: 3180
#include<iostream>

using namespace std;

int main(void){

	int h;
	int i;
	int best[3]={0,0,0};

	for(i=0;i<10;i++){

		cin>>h;

		if(best[0] < h ){
			best[2] = best[1];
			best[1] = best[0];
			best[0] = h;
		}
		else if(best[1] < h){
			best[2] = best[1];
			best[1] = h;
		}else if(best[2] < h){
			best[2] =h;
		}
	}

	cout << best[0] << endl << best[1] << endl << best[2] << endl;

	return 0;
}

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

int main() {
	string S, P, Q;
	int N, A, B;
	cin >> S >> N;
	for (int i = 0; i < N; i++) {
		cin >> Q >> A >> B;
		if (Q == "print") {
			cout << S.substr(A, B - A + 1) << endl;
		}
		if (Q == "reverse") {
			reverse(S.begin() + A, S.begin() + B + 1);
		}
		if (Q == "replace") {
			cin >> P;
			S.replace(A, B - A + 1, P);
		}
	}
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<n+1;i++)
typedef long long ll;
typedef vector<int> vec;
int main(){
  int n,x,ans=0;
  while(1){
    ans=0;
    cin>>n>>x;
    if(n==0&&x==0)break;
    for(int i=1;i<n+1;i++)for(int j=i+1;j<n+1;j++)for(int k=j+1;k<n+1;k++){
      if(i+j+k==x)ans++;
    }
    cout<<ans<<endl;
  }

}



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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  int n;
  while (cin >> n) {
    int a[n];
    int b[n];
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      b[i] = a[i];
    }
    sort(b, b + n);
    map<int, int> no;
    for (int i = 0; i < n; ++i) {
      no[b[i]] = i;
    }
    vector<int> v;
    for (int i = 0; i < n; ++i) {
      v.push_back(no[a[i]]);
    }

    int odd = 0;
    int even = 0;
    for (int i = 0; i < v.size(); ++i) {
      if (i % 2 != v[i] % 2) {
        int& o = odd;
        int& e = even;
        (i % 2 ? o : e) += 1;
      }
    }
    assert(odd == even);
    cout << odd << endl;
  }
  return 0;
}


Measured memory_bytes: 6396
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var xyxy = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var x1 = xyxy[0];
        var y1 = xyxy[1];
        var x2 = xyxy[2];
        var y2 = xyxy[3];
        int dirx = x2 - x1;
        int diry = y2 - y1;
        Console.WriteLine($"{x2 - diry} {y2 + dirx} {x2 - dirx - diry} {y2 + dirx - diry}");
    }
}


Measured memory_bytes: 13396