akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		rep(i,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m,b,c;
	cin>>n>>m;
	map<ll,ll> mp;
	vl v(n);
	rep(i,n)cin>>v[i],mp[v[i]]++;
	rep(i,m)cin>>b>>c,mp[c]+=b;
	vector<pll> ns;
	for(auto x:mp){
		ns.push_back(pll(-x.fs,x.sc));
	}
	sort(all(ns));
	ll ans=0,cnt=0;
	rep(i,ns.size()){
		ans-=min(max(0,n-cnt),ns[i].sc)*ns[i].fs;
		cnt+=min(max(0,n-cnt),ns[i].sc);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 19696
#include <bits/stdc++.h>
typedef long long int ll;
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
using namespace std;

int main() {
  ll x, a, b;
  cin >> x >> a >> b;
  cout << x - (a + (x - a) / b * b) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string s; cin >> s;
    int n = s.size();
    int start = 0, end = 0;
    for(int i=0; i<n; ++i){
        if(start == 0 and s[i]=='A') start = i+1;
        if(end == 0 and s[n-1-i]=='Z') end = n-i;
    }
    cout << end-start+1 << endl;
    return 0;
}

Measured memory_bytes: 640
use std::time::{Duration, Instant};

use proconio::input;
use rand::distributions::{Distribution, Uniform};
use rand_pcg::Mcg128Xsl64;

const V: usize = 26;

struct State {
    cc: Vec<i32>,
    ss: Vec<Vec<i32>>,
    tt: Vec<usize>,
}

impl State {
    fn new(cc: Vec<i32>, ss: Vec<Vec<i32>>, tt: Vec<usize>) -> State {
        State { cc, ss, tt }
    }

    fn find_before(&self, day: usize, target: usize) -> usize {
        for (i, &t) in self.tt[..day].iter().enumerate().rev() {
            if t == target {
                return day - i - 1;
            }
        }
        day
    }

    fn find_after(&self, day: usize, target: usize) -> usize {
        for (i, &t) in self.tt[day + 1..].iter().enumerate() {
            if t == target {
                return i + 1;
            }
        }
        self.tt.len() - day
    }

    fn diff(&self, day: usize, new: usize) -> i32 {
        let now = self.tt[day];
        if new == now {
            return 0;
        }
        let mut diff = self.ss[day][new] - self.ss[day][now];
        diff -= {
            let b = self.find_before(day, now) as i32;
            let a = self.find_after(day, now) as i32;
            self.cc[now] * (a * b + a)
        };
        diff += {
            let b = self.find_before(day, new) as i32;
            let a = self.find_after(day, new) as i32;
            self.cc[new] * (a * b + a)
        };
        diff
    }
}

fn main() {
    let now = Instant::now();

    input! {
        d: usize,
        cc: [i32; V],
        ss: [[i32; V]; d],
    }
    let mut rng = Mcg128Xsl64::new(1);
    let day_samp = Uniform::new(0, d);
    let t_samp = Uniform::new(0, V);

    let tt = {
        let mut tt = Vec::with_capacity(d);
        for _ in 0..d {
            tt.push(t_samp.sample(&mut rng));
        }
        tt
    };
    let mut state = State::new(cc, ss, tt);

    let r_samp = Uniform::new(0.0, 1.0);
    let limit = Duration::from_millis(1900);
    let mut temp = 1000.0;
    while now.elapsed() < limit {
        temp *= 0.98;
        let beta = 1.0 / temp;
        // let mut c = 0;
        for _ in 0..100000 {
            let day = day_samp.sample(&mut rng);
            let target = t_samp.sample(&mut rng);
            let diff = state.diff(day, target);
            if diff >= 0 || r_samp.sample(&mut rng) < (diff as f64 * beta).exp() {
                // if diff < 0 {
                //     c += 1;
                // }
                state.tt[day] = target;
            }
        }
        // eprintln!("{} {} {}", temp, c, (-10.0 * beta).exp());
    }
    for &t in state.tt.iter() {
        println!("{}", t + 1);
    }
}


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

int main(){
  int a,b,c,x,y,z;
  cin >>a >>b >>c;
     
     x = a+b-c;
     y = a+c-b;
     z = b+c-a;
     
     if(x == 0){
     	cout <<"Yes";
     	
     }
     if(y == 0){
     	cout <<"Yes";
     	
     }
     if(z == 0){
     	cout <<"Yes";
     
     }
     if(x != 0 && y != 0 && z != 0){
     	cout <<"No";
         
     }
}



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

int64_t ZERO=0;

int main(){
  int N;
  int64_t K;
  cin>>N>>K;
  vector<int> p(N);
  vector<int64_t> c(N);
  for(int i=0;i<N;i++){
    cin>>p[i];
    p[i]--;
  }
  for(int i=0;i<N;i++){
    cin>>c[i];
  }
  int64_t Z=c[0];
  for(int i=0;i<N;i++){
    Z=max(c[i],Z);
  }
  for(int i=0;i<N;i++){
    vector<int64_t> q;
    int a=i;
    int64_t S=c[a],L=0;
    q.push_back(c[a]);
    while(p[a]!=i){
      a=p[a];
      q.push_back(c[a]);
      S+=c[a];
    }
    int64_t M=q.size();
    for(int j=0;j<M;j++){
      L+=q[j];
      if(K>j){
        Z=max(Z,max(ZERO,((K-1-j)/M)*S)+L);
      }
    }
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 3768
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    string s, t;
    cin >> s;
    t = s;
    reverse(t.begin(), t.end());
    REP(i, t.size()){
        if(t[i] == 'b')t[i] = 'd';
        else if(t[i] == 'd')t[i] = 'b';
        else if(t[i] == 'p')t[i] = 'q';
        else if(t[i] == 'q')t[i] = 'p';
    }
    cout << ((s == t)? "Yes" : "No") << endl;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;

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

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

    if(n % 10 == 3){
        cout << "bon" << endl;
    } else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
    int a, b, c;
    cin >> a >> b >> c;
    if (b + c <= a) {
        c = 0;
    } else {
        c = c - (a - b);
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const int mod = 2019;
static const int INF = 3000;
using namespace std;

int main(){
	string s,t="";
	cin>>s;
	rep(i,s.size()){
		if(s[i]=='0')t+="0";
		else if(s[i]=='1')t+="1";
		else{
			auto itr=t.end();
			*(itr)--;
			if(t!="")t.erase(itr);
		}
	}
	cout<<t<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#define debug(x) cout << #x << "==" << x << endl;

const int INF = 1e+8;

using namespace std;

//??\???
#define MAX_N 100
#define MAX_W 10000
int N, W;
int w[MAX_N], v[MAX_N];

// memo
int memo[MAX_N + 1][MAX_W + 1];
bool checked[MAX_N + 1][MAX_W + 1];

int opt(int i, int cw) {

  if( i == -1 ) { return 0; }

  if(checked[i][cw] == true) { return memo[i][cw]; }
  checked[i][cw] = true;

  int ret;
  if (  cw < w[i] ) {
    ret = opt(i - 1, cw);
  } else {
    ret = max( opt(i - 1, cw), opt(i, cw - w[i]) + v[i] );
  }

  return memo[i][cw] = ret;

}

int main() {
  ios::sync_with_stdio(false);

  cin >> N >> W;
  for(int i = 0; i < N; i++) { cin >> v[i] >> w[i]; }

  cout << opt(N - 1, W) << endl;

  return 0;
}

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

int main(){
    // 'a' == 'A' + 0x20で表現できる
    string s;
    cin >> s;
    int cCount = 0;
    int sml = 0;
    if(s[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }
    for(int i = 2;i < s.size()-1;i++){
        if(s[i] == 'C')cCount++;
    }
    for(int i = 1;i < s.size();i++){
        if(s[i] >= 0x61 && s[i] <= ('Z'+0x20))sml++;
    }
    if(cCount == 1 && (cCount + sml) == s.size()-1){
        cout << "AC" << endl;
    }
    else cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<algorithm>
typedef long long LL;
using namespace std;
//#pragma comment(linker, "/STACK:102400000,102400000")

char s1[55],s2[55];
int main(){
    scanf("%s%s",s1,s2);
    int len1=strlen(s1);
    int len2=strlen(s2);
    for(int i=0;i<len2;i++)
        printf("%c%c",s1[i],s2[i]);
    if(len1!=len2)
        printf("%c",s1[len1-1]);
    return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var K, S int
	fmt.Scan(&K, &S)
	ans := 0
	for X := 0; X <= K; X++ {
		for Y := 0; Y <= K; Y++ {
			Z := S - X - Y
			if 0 <= Z && Z <= K && X+Y+Z == S {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String aStr = sc.next();
        String bStr = sc.next();
        String cStr = sc.next();
        char curChar = 'a';
        int i = 0, j = 0, k = 0;
        while(true) {
          if(curChar == 'a') {
            if(i == aStr.length()) {
              System.out.println("A");
              return;
            }
            curChar = aStr.charAt(i++);
          } else if(curChar == 'b'){
            if(j == bStr.length()) {
              System.out.println("B");
              return;
            }
            curChar = bStr.charAt(j++);
          } else {
            if(k == cStr.length()) {
              System.out.println("C");
              return;
            }
            curChar = cStr.charAt(k++);
          }
        }
    }
}

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

using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    string ans = "No";
    if(a==b){
        if(b!=c){
            ans = "Yes";
        }
    }
    if(a==c){
        if(b!=c){
            ans = "Yes";
        }
    }
    if(b==c){
        if(a!=b){
            ans = "Yes";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
Module Program
  Sub Main
    Dim s=Gets()
    Dim a=s(0).Substring(4)
    Dim ans="2018"+a
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

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

using namespace std;

template<class V, class E>
struct Graph
{
	int sz;
	vector<V> v;
	vector<vector<E>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};
struct Vertex{};
using vertex = Vertex;
struct Edge
{
	int to;
	Edge(int t) : to(t) {}
	Edge() {}
};

using edge = Edge;
using graph = Graph<vertex, edge>;
template<class G>
struct LCA {
	int sz;
	vector<vector<int>> dp;
	vector<int> depth;
	int log2_n;
	LCA(G& g, int root) : sz(g.size()), depth(sz) {
		log2_n = 0;
		for (int t = sz; t; t /= 2, log2_n++);
		dp.resize(sz, vector<int>(log2_n, -1));
		dfs(g, root);
		for (int i = 0; i < sz; i++) {
			for (int j = 1; j < log2_n; j++) {
				int t = dp[i][j-1];
				dp[i][j] = t == -1 ? -1 : dp[t][j-1];
			}
		}
	}
	inline int size() { return sz;}
	void dfs(G& g, int root) {
		stack<tuple<int, int, int>> s;
		s.emplace(root, -1, 0);
		while (!s.empty()) {
			int now, par, d;
			tie(now, par, d) = s.top(); s.pop();
			dp[now][0] = par;
			depth[now] = d;
			for (auto& x: g.e[now]) {
				if (x.to != par) s.emplace(x.to, now, d+1);
			}
		}
	}
	int get(int a, int b) {
		if (depth[a] > depth[b]) swap(a, b);
		for (int i = 0; i < log2_n; i++) {
			if ((depth[b] - depth[a]) & (1 << i)) b = dp[b][i];
		}
		if (a == b) return a;
		for (int i = log2_n - 1; i >= 0; i--) {
			if (dp[a][i] != dp[b][i]) {
				a = dp[a][i];
				b = dp[b][i];
			}
		}
		return dp[a][0];
	}
};
using lca = LCA<graph>;

int main() {
	int N, Q;
	cin >> N;
	graph G(N);
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		for (int j = 0; j < a; j++) {
			int t;
			cin >> t;
			G.add_edge(i, t);
			G.add_edge(t, i);
		}
	}
	lca L(G, 0);
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int a, b;
		cin >> a >> b;
		cout << L.get(a, b) << endl;
	}
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	bool flg = true;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) {
			if (a[i] % 3 != 0 && a[i] % 5 != 0) {
				flg = false;
			}
		}
	}
	if (flg) {
		cout << "APPROVED";
	}
	else {
		cout << "DENIED";
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>
#include <numeric>
#include <tuple>



typedef long long ll;


using namespace std;

typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(int)(a) ; i < (int) (b) ; ++i )
#define rep(i,n) FOR(i,0,n)
#define sz(x) int(x.size())


template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;


const int T=6300;

int main(){
    int n,t;
    cin>>n>>t;
    vector<pair<int,int>> ab;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        ab.emplace_back(a,b);
    }
    sort(ab.begin(),ab.end(),[](pair<int,int> x,pair<int,int> y){
        return x.first<y.first;
    });
    vector<vector<int>> v(n+1,vector<int>(t,-1));
    v[0][0]=0;
    //cout<<v[1][2];
    int ans=0;
    rep(i,n){
        rep(j,t){
            if (v[i][j]==-1) continue;
            
            int del=ab[i].second;
            int seni=ab[i].first;
            v[i+1][j]=max(v[i+1][j],v[i][j]);
            if (j+seni<t){
            v[i+1][j+seni]=max(v[i+1][j+seni],v[i][j]+del);
            } else{
                ans=max(ans,v[i][j]+del);
            }
        }
        
    }
    rep(i,t){
        ans=max(ans,v[n][i]);
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 35584
S = input()
T = input()
sls = {chr(_): list() for _ in range(97, 97+26)}
tls = {chr(_): list() for _ in range(97, 97+26)}
for i in range(len(S)):
    sls[S[i]].append(i)
for i in range(len(T)):
    tls[T[i]].append(i)

for i in range(97, 97+26):
    t = sls[chr(i)]
    if len(t) > 1:
        for j in range(len(t)-1):
            if T[t[j]] != T[t[j+1]]:
                print('No')
                exit(0)

for i in range(97, 97 + 26):
    t = tls[chr(i)]
    if len(t) > 1:
        for j in range(len(t) - 1):
            if S[t[j]] != S[t[j + 1]]:
                print('No')
                exit(0)

print('Yes')


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> data(H, vector<char>(W));
  
  for (int i = 0; i<H; i++) {
    for (int j = 0; j<W; j++) {
      cin >> data.at(i).at(j);
    }
  }
  
  for (int i = 0; i<H; i++) {
    bool empty = true;
    for (int j = 0; j<W; j++) {
      if (data.at(i).at(j) == '#') {
        empty = false;
        break;
      }
    }
    if (empty) {
      for (int j = 0; j<W; j++) {
        data.at(i).at(j) = 'e';
      }
    }
  }

  for (int j = 0; j<W; j++) {
    bool empty = true;
    for (int i = 0; i<H; i++) {
      if (data.at(i).at(j) == '#') {
        empty = false;
        break;
      }
    }
    if (empty) {
      for (int i = 0; i<H; i++) {
        data.at(i).at(j) = 'e';
      }
    }
  }

  for (int i = 0; i<H; i++) {
    bool empty = true;
    for (int j = 0; j<W; j++) {
      if (data.at(i).at(j) != 'e') {
        cout << data.at(i).at(j);
        empty = false;
      }
    }
    if (!empty) cout << endl;
  }
}



Measured memory_bytes: 256
def distance_p(x_values: list, y_values: list, p: int) -> float:
    return sum(map(lambda x, y: abs(x - y) ** p, x_values, y_values)) ** (1 / p)


def distance_chebyshev(x_values: list, y_values: list) -> float:
    return max(map(lambda x, y: abs(x - y), x_values, y_values))


if __name__ == "__main__":
    elem_num = int(input())
    x_values = list(map(lambda x: float(x), input().split()))
    y_values = list(map(lambda x: float(x), input().split()))
    print(f"{distance_p(x_values, y_values, 1)}")
    print(f"{distance_p(x_values, y_values, 2)}")
    print(f"{distance_p(x_values, y_values, 3)}")
    print(f"{distance_chebyshev(x_values, y_values)}")



Measured memory_bytes: 5672
import java.util.Scanner;


public class Main{

	public static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args) {
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		int[]a = new int[n];
		int oneIdx = -1;
		for(int i=0; i<n; i++) {
			a[i] = scanner.nextInt();
			if(a[i] == 1)
				oneIdx = i;
		}
		int leftCnt = oneIdx;
		int rightCnt = n - oneIdx - 1;
		
		int leftTime = leftCnt / (k - 1);
		int rightTime = rightCnt / (k - 1);
		
		int totalTime = leftTime + rightTime;
		
		int leftMode = leftCnt % (k - 1);
		int rightMode = rightCnt % (k - 1);
		
		if(leftMode + rightMode > k - 1)
			totalTime += 2;
		else if(leftMode + rightMode > 0)
			totalTime += 1;
		
		System.out.println(totalTime);
		
	}

}


Measured memory_bytes: 50288
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    int x[n];
    int sum=0;
    for(int i=0;i<n;i++)    cin>>x[i], sum +=x[i];
    int avg_ceil = int(round((double)sum/n));
    int cost=0;
    for(int i=0;i<n;i++)    cost += ((avg_ceil-x[i])*(avg_ceil-x[i]));
    
    cout<<cost<<endl;

    return 0;
}



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

class Program
{
    static void Main(string[] args)
    {
        //入力
        var s = crS();
        int count = 0;
        int len = s.Length;
        for(int i = 0; i < len / 2; i++)
        {
            if (s[i] != s[len - 1 - i]) count++;
        }
        Console.WriteLine(count);
    }

   

    //入力受け取り用
    static string crS() { return Console.ReadLine(); }
    static int crI() { return int.Parse(Console.ReadLine()); }
    static int[] arrInt(){return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();}
    static long[] arrLong(){ return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray(); }
    static string[] arrStr(){return Console.ReadLine().Split(' ').ToArray();}

}

Measured memory_bytes: 25976
import math
while True:
    n=int(input())
    if n == 0 : break
    s=list(map(int,input().split()))
    sumv = 0
    for x in s: sumv += x
    mean = sumv/n
    aa=0
    for x in s: aa+=(x-mean)*(x-mean)
    aa/=n
    a = math.sqrt(aa)
    print(f"{a:.5f}")


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

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

Measured memory_bytes: 640
// https://atcoder.jp/contests/abc165/tasks/abc165_c

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

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

//------------------------------------------------------------------------------

const int N_MAX = 10;
const int M_MAX = 10;
const int Q_MAX = 50;
const int D_I_MAX = 1e5;

struct Cond {
  int a, b, c, d;
};

int N, M, Q;
vector<vector<Cond>> qs;

int dfs(vector<int> X, int v) {
  int b = X.size();
  if (b == N) return v;
  int ret = 0;
  int xx = *X.rbegin();
  FOR(i, xx, M) {
    vector<int> Y = X;
    Y.push_back(i);
    int v2 = v;
    for (auto q : qs[b]) {
      if (q.c == Y[b] - Y[q.a]) v2 += q.d;
    }
    chmax(ret, dfs(Y, v2));
  }
  return ret;
}

int main() {
  cin >> N >> M >> Q;
  qs = vector<vector<Cond>>(N, vector<Cond>());
  REP(i, Q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--; b--;
    qs[b].push_back({a, b, c, d});
  }

  vector<int> X = { 1 };
  int ans = dfs(X, 0);
  cout << ans << endl;
}


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

using namespace std;

const int MOD = int(1e9) + 7;
int add(int x, int y)
{
    return (x + y) % MOD;
}
int sub(int x, int y)
{
    return add(x, MOD - y);
}
int mul(int x, int y)
{
    return (x * 1ll * y) % MOD;
}
int main()
{
    int n, k;
    cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    vector<int> presum(k + 1, 0);
    vector<vector<int>> dp(k + 1, vector<int>(n, 0));
    dp[0][0] = presum[0] = 1;
    for (int i = 1; i <= k; i++)
    {
        if (i <= arr[0])
            dp[i][0] = 1;
        else
            dp[i][0] = 0;
        presum[i] = add(presum[i - 1], dp[i][0]);
    }
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            dp[j][i] = presum[j];
            if (j - arr[i] - 1 >= 0)
                dp[j][i] = sub(dp[j][i], presum[j - arr[i] - 1]);
        }
        presum[0] = dp[0][i];
        for (int j = 1; j <= k; j++)
            presum[j] = add(presum[j - 1], dp[j][i]);
    }
    cout << dp[k][n - 1] << "\n";
    return 0;
}

Measured memory_bytes: 43648
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

const int MAX_N = 128000;

int P[MAX_N];
int l[MAX_N], r[MAX_N], res[MAX_N];
vector<int> graph[MAX_N], g[MAX_N];
bool visited[MAX_N];

void make_graph(int v) {
  visited[v] = true;
  for (int i: graph[v]) {
    if (visited[i]) continue;
    g[v].push_back(i);
    make_graph(i);
  }
}

bool dfs(int v) {
  for (int i: g[v]) {
    if (!dfs(i)) return false;
  }
  l[v] = -1e9; r[v] = 1e9;
  for (int i: g[v]) {
    if (l[v] > -1e8 && l[i] > -1e-8 && ((l[v] ^ l[i]) & 1) == 0) return false;
    chmax(l[v], l[i] - 1);
    chmin(r[v], r[i] + 1);
  }
  if (l[v] > r[v]) return false;
  if (P[v] >= 0) {
    if (l[v] > -1e8 && ((l[v] + P[v]) & 1)) return false;
    if (P[v] < l[v] || P[v] > r[v]) return false;
    l[v] = P[v];
    r[v] = P[v];
  }
  // cout << v << " " << l[v] << " " << r[v] << endl;
  return true;
}

void dfs2(int v, int val) {
  res[v] = val;
  for (int i: g[v]) {
    if (val + 1 <= r[i]) dfs2(i, val + 1);
    else dfs2(i, val - 1);
  }
}

void solve() {
  int N, K;
  cin >> N;
  REP(i,N-1) {
    int A, B;
    cin >> A >> B;
    graph[A-1].push_back(B-1);
    graph[B-1].push_back(A-1);
  }
  memset(P, -1, sizeof(P));
  cin >> K;
  REP(i,K) {
    int V, C;
    cin >> V >> C;
    P[V-1] = C;
  }
  make_graph(0);
  if (!dfs(0)) { cout << false << endl; return; }
  dfs2(0, l[0]);
  cout << true << endl;
  REP(i,N) cout << res[i] << endl;
  return;
}


Measured memory_bytes: 19584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
const int MAX_N = 1000000000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
const int INF = 1000000000;
typedef int64_t ll;
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; }

int N;


int main() {
	cin >> N;
	ll ans = 0;
	rep(i, N) {
		int tmp;
		cin >> tmp;
		int cnt = 0;
		while (tmp%2==0)
		{
			tmp /= 2;
			cnt++;
		}
		ans += cnt;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <tuple>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	std::cout << (a * b / 2) <<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,c,d;
    string s;
    scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
    cin>>s;
    a--;
    b--;
    c--;
    d--;
    int x=0,y=0;
    int m=max(c,d);
    for(int i=a;i<m;i++)
    {
        if(s[i]=='#' && s[i+1]=='#')
        {
           printf("No");
           return 0;
        }
    }
    m=min(c,d);
    if(d<c)
    {
        int y=0;
        for(int i=b-1;i<d;i++)
        {
            if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.')
            y++;
        }
        if(y)
        printf("Yes");
        else
        printf("No");
    }
    else printf("Yes") ;
    return 0;
}


Measured memory_bytes: 640
#define		_CRT_SECURE_NO_WARNINGS
#include	<cstdio>
#include	<cstdint>

typedef		std::uint_least32_t		ULI;		//10^9
typedef		std::int_least32_t		SLI;
typedef		std::uint_least64_t		ULLI;
typedef		std::int_least64_t		SLLI;

using namespace std;

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

	int		first;
	scanf("%d", &first);

	int		second;
	scanf("%d", &second);

	int		min;
	if (first < second)
	{
		min = first;
	}
	else
	{
		min = second;
	}

	int		delMax = second - first;

	int		Rt;
	for (int i = 2; i < n; i++)
	{
		scanf("%d", &Rt);

		int	del = Rt - min;

		if (del > delMax)
		{
			delMax = del;
		}

		if (min > Rt)
		{
			min = Rt;
		}
	}

	printf("%d\n", delMax);

	return 0;
}

Measured memory_bytes: 2740
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let x: i32 = read();
    let a: i32 = read();
    let b: i32 = read();
    println!("{}", if (x - a).abs() > (x - b).abs() { "B" } else { "A" });
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
nm = input().split()
n = int(nm[0])
m = int(nm[1])

kalist = []
for i in range(n):
    ka = input().split()
    k = int(ka[0])
    alist = [int(a) for a in ka[1:]]
    kalist.append((k, alist))


aset = None
for k, alist in kalist:
    if aset is None:
        aset = set(alist)
    else:
        aset = aset & set(alist)

print(len(aset))


Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int INF = 1e18 + 239;

int f(int b, int n) {
	if (n < b) {
		return n;
	} else {
		return n % b + f(b, n / b);
	}
}

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

	//5 3
	//12
	//11

	int n, s;
	cin >> n >> s;
	for (int i = 2; i * i <= n; i++) {
		if (f(i, n) == s) {
			cout << i << endl;
			return 0;
		}
	}
	int cb = INF;
	for (int ff = 1; ff * ff < n; ff++) {
		//ff ss
		int ss = s - ff;
		//b * ff + ss == n
		if ((n - ss) >= 2 * ff) {
			int cand = (n - ss) / ff;
			if (f(cand, n) == s) cb = min(cb, cand);
		}
	}
	if (f(n + 1, n) == s) {
		cb = min(cb, n + 1);
	}
	if (cb == INF) {
		cout << -1 << endl;
	} else {
		cout << cb << endl;
	}
}


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

const int INF = 100000;
int dp[50][410][410];

int main() {
  int n, ma, mb;
  cin >> n >> ma >> mb;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i ++) cin >> a[i] >> b[i] >> c[i];

  for (int i = 0; i <= n; i ++) {
    for (int j = 0; j < 410; j ++) {
      for (int k = 0; k < 410; k ++) dp[i][j][k] = INF;
    }
  }

  dp[0][0][0] = 0;
  for (int i = 0; i < n; i ++) {
    for (int na = 0; na <= 400; na ++) {
      for (int nb = 0; nb <= 400; nb ++) {
        if (dp[i][na][nb] == INF) continue;
        dp[i + 1][na][nb] = min(dp[i + 1][na][nb], dp[i][na][nb]);
        dp[i + 1][na + a[i]][nb + b[i]] = min(dp[i + 1][na + a[i]][nb + b[i]], dp[i][na][nb] + c[i]);
      }
    }
  }

  int ans = INF;
  for (int na = 1; na <= 400; na ++) {
    for (int nb = 1; nb <= 400; nb ++) {
      if (na * mb == nb * ma) ans = min(ans, dp[n][na][nb]);
    }
  }
  if (ans == INF) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 28928
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll H,W;
queue<pl> que;
ll GridBFS(pl start,pl goal,const vector<vector<char>> &info,vvl dist){
    que.emplace(start);
    dist[start.fi][start.se]=0;
    while(que.size()){
        ll y=que.front().fi,x=que.front().se;
        que.pop();
        rep(k,4){
            ll ny=y+dy[k],nx=x+dx[k];
            if(0<=ny and ny<H and 0<=nx and nx<W){
                if(info[ny][nx]=='#')continue;
                if(dist[ny][nx]>dist[y][x]+1){
                    dist[ny][nx]=dist[y][x]+1;
                    que.emplace(ny,nx);
                }
            }
        }
    }
    return dist[goal.fi][goal.se];
}
int main(){
    cin>>H>>W;
    vector<vector<char>> info(H,vector<char>(W));
    vvl dist(H,vl(W,inf));
    pl start,goal;
    start={0,0},goal={H-1,W-1};
    int cnt=0;
    rep(i,H)rep(j,W){
        cin>>info[i][j];
        if(info[i][j]=='.')cnt++;
    }
    ll a=GridBFS(start,goal,info,dist);
    if(a==inf)puts("-1");
    else printf("%d\n",cnt-a-1);
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define PI acos(-1.0)
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define MOD 1000000007
#define MOD1 998244353
#define ep 0.000000001
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, 1};
int dy4[] = {1, -1, 1, -1};
//#define fio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main()
{
    #ifndef ONLINE_JUDGE
    freopen ("in.txt", "r", stdin);
    freopen ("out.txt", "w", stdout);
    #endif
    string s, t;
    cin>>s>>t; int c, mx=0;
    for(int i=0;i<=(s.sz-t.sz);i++){
        c=0;
        for(int j=0,k=i;j<t.sz;j++,k++){
            if(s[k]==t[j])c++;
        }
        mx=max(mx, c);
    }
    cout<<t.sz-mx<<endl;
    return 0;
}
//https://thebestoffersintheweb.com/redirect/57a764d042bf8/


Measured memory_bytes: 3580
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>


//pair sort firstに揃う

#define int long long
#define pb(n) push_back(n)
#define Rap(n,i) for(int (i)=0;(i)<(n);(i)++)
#define Pr(n) cout<<n<<endl;
#define PairV vector<pair<int , int> >
#define F first
#define S second
#define Vector1  vector<int>
#define vector2 vector<vector<int> >
#define index(v,x) find((v).begin(), (v).end(), (x))-(v).begin()
#define ctoi(c) (int)(c-'0')
#define incin(n) int (n); cin>>(n);
#define stcin(s) string (s); cin>>(s);
#define all(v) (v).begin() , (v).end()
#define PI 3.14
#define Rad2Deg  57.29578

using namespace std;
 
signed  main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double W,H,x,y;
    cin >> W >> H >>x >> y;
    cout<<W*H/2<<' ';
    if(x==W/2 && y==H/2){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;

struct POINT {
	int x;
	int y;
};

int main(void) {
	int N, M;
	while (cin >> N, N) {
		vector< vector<bool> > gem(21, vector<bool> (21, 0) );
		for (int gi = 0; gi < N; gi++) {
			int x, y;
			cin >> x >> y;
			gem[x][y] = true;
		}

		POINT robotp = {10, 10};
		int haveGem = 0;
		cin >> M;
		for (int i = 0; i < M; i++) {
			char dir;
			int dis;
			cin >> dir >> dis;
			while (dis) {
				switch(dir) {
					case 'N':
						robotp.y++;
						break;
					case 'E':
						robotp.x++;
						break;
					case 'S':
						robotp.y--;
						break;
					case 'W':
						robotp.x--;
						break;
				}
				if (gem[robotp.x][robotp.y]) {
					gem[robotp.x][robotp.y] = false;
					haveGem++;
				}
				dis--;
			}
		}

		cout << (haveGem == N ? "Yes" : "No") << endl;
	}

	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
 
   
int main(){
   vector<ll> l(100);
   l.at(0)=2;
   l.at(1)=1;
   for(int i=2;i<=99;i++){
     l.at(i)=l.at(i-1)+l.at(i-2);
   }
   int n;
   cin >> n;
   cout << l.at(n) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

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

  ll ans = 1;
  ll MOD = 1000000007;
  int x[3] = {0,0,0};
  rep(i,N){
    int cnt = 0;
    rep(j,3) if (A[i]==x[j]) cnt++;
    // cout << x[0] << " " << x[1] << " " << x[2] << " " << cnt << endl;

    rep(j,3) {
      if (A[i]==x[j]) {
        x[j]++;
        break;
      }
    }
    (ans *= cnt) %= MOD;    
  }
  cout << ans << endl;

  




  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4004
import math

X = int(input())
yaku = []

def nibu(a):
  small = -a//2-1
  big = 10**10
  while big-small > 1:
    mid = (small+big)//2
    isx = (mid+a)**5 - mid**5
    if isx > X:
      big = mid
    elif isx < X:
      small = mid
    else:
      print(mid+a,mid)
      exit()

for i in range(1,int(X**0.5+1)):
  if X%i == 0:
    yaku.append(i)
    yaku.append(X//i)
    
for el in yaku:
  nibu(el)

Measured memory_bytes: 65708
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class E { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		var x = new long[N];
		var y = new long[N];
		for(long i = 0; i < N; i++)
		{
			x[i] = GetLong();
			y[i] = GetLong();
		}

		var f0 = x.Zip(y, (a, b) => a - b);
		var f1 = x.Zip(y, (a, b) => a + b);
		WriteLine(Max(f0.Max() - f0.Min(), f1.Max() - f1.Min()));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 44236
#include<iostream>
#include<string>
#include<map>
#include<queue>
std::map<std::string,int> mp;
std::queue< std::string > q;
int n,m,ans=0; 
int main()
{
	std::cin>>n;
	for (int i=1;i<=n;i++)
	{
		std::string st;
		std::cin>>st;
		mp[st]++;
		q.push(st); 
	}
	std::cin>>m;
	for (int i=1;i<=m;i++)
	{
		std::string st;
		std::cin>>st;
		mp[st]--;
		q.push(st); 
	}
	while (!q.empty())
	{
		std::string st=q.front();q.pop();
		ans=std::max(ans,mp[st]);
	}
	std::cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int n;
ll k;
vl a,f;

bool check(ll X){
  int ll cnt = 0LL;// 修行回数
  rep(i,n) {
    if(a[i]*f[i] > X){
      ll na = X/f[i];
      //printf("X:%lld i:%d syugyou:%lld\n", X, i, a[i] - na);
      cnt += a[i] - na;
    }
  }

  return (cnt <= k);
}

int main(){
  cin >> n >> k;
  a.resize(n), f.resize(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  
  sort(all(a));
  sort(all(f),greater<ll>());
  
  ll ok = 0LL, ng = -1LL;
  rep(i,n) chmax(ok, a[i]*f[i]);
  while (abs(ng-ok)>1){
    ll mid = (ok+ng)/2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <string.h>
using namespace std;

int main()
{
	char change[6][6] = {
		"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "
	};
	
	char str[256];
	
	while (scanf("%s", str) != EOF){
		char str2[256];
		strcpy(str2, "");
		
		int i = 0;
		while (str[i] != '\0'){
			if (
			(str[i] < '1' || str[i] > '6') || 
			(str[i + 1] < '1' || str[i + 1] > '5')
			){
				strcpy(str2, "NA");
				break;
			}
						
			strncat(str2, &change[str[i] - '0' - 1][str[i + 1] - '0' - 1], 1);
			
			i += 2;
		}
		
		printf("%s\n", str2);
	}
	
	return 0;
}

Measured memory_bytes: 960
#include<stdio.h>

int main(){
  int N,i,j,min,temp,swap=0;
  int A[100];

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

  for(i=0;i<N;i++){
    min=i;
    for(j=i+1;j<N;j++){

      if(A[j]<A[min]) {
	min=j;
      }
    }
    if(i!=min){    
    temp=A[i];
    A[i]=A[min];
    A[min]=temp;
    swap++;
    }

  }
    for(i=0;i<N-1;i++){
      printf("%d ",A[i]);
    }
    printf("%d\n%d\n",A[N-1],swap);
  
} 



Measured memory_bytes: 2144
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int H, W;
    cin >> H >> W;
    vector<string>masu(H);
    for (int i=0; i<H; i++) {
        cin >> masu.at(i);
    }

    vector<bool> gyou_assyuku(H, false);
    vector<bool> retsu_assyuku(W, false);
    for (int i=0; i<H; i++) {
        bool is_gyou_assyuku = true;
        for (int j=0; j<W; j++) {
            if (masu[i][j] == '#') {
                is_gyou_assyuku = false;
            }
        }

        if (is_gyou_assyuku) {
            gyou_assyuku[i] = true;
        }
    }

    for (int i=0; i<W; i++) {
        bool is_retsu_assyuku = true;
        for (int j=0; j<H; j++) {
            if (masu[j][i] == '#') {
                is_retsu_assyuku = false;
            }
        }

        if (is_retsu_assyuku) {
            retsu_assyuku[i] = true;
        }
    }

    for (int i=0; i<H; i++) {
        if (gyou_assyuku[i]) {
            continue;
        }

        for (int j=0; j<W; j++) {
            if (retsu_assyuku[j]) {
                continue;
            }

            cout << masu[i][j];
        }

        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <string.h>
#define N 100

int main (){
  int i,j,n,a1[N],a[N],tmp,k;
  char c0[N+1],c[N+1],c1[N+1],tmpc,A[2][11]={"Stable","Not stable"};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c %d",&c0[i],&a[i]);
    a1[i] =a[i];
  }
  strcpy(c,c0);
  strcpy(c1,c0);

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

    for(j=n-1;j>i;j--){

      if(a[j]<a[j-1]){
	tmp=a[j];
	tmpc=c[j];
	a[j]=a[j-1];
	c[j]=c[j-1];
	a[j-1]=tmp;
	c[j-1]=tmpc;
      }
    }
  }
    for(i=0;i<n;i++){
      if(i==n-1) printf("%c%d\n",c[i],a[i]);
      else printf("%c%d ",c[i],a[i]);
  }
  printf("%s\n",A[0]);

 
  for(i=0;i<n;i++){
    k=i;
    for(j=i;j<n;j++){
      if(a1[j]<a1[k])k=j;
    }
    if(k!=i){
      tmp=a1[k];
      tmpc=c1[k];
      a1[k]=a1[i];
      c1[k]=c1[i];
      a1[i]=tmp;
      c1[i]=tmpc;
    }
  }
    for(i=0;i<n;i++){
      if(i==n-1) printf("%c%d\n",c1[i],a1[i]);
      else printf("%c%d ",c1[i],a1[i]);
    }
    if(strcmp(c1,c)==0)printf("%s\n",A[0]);
    else printf("%s\n",A[1]);
    
    



  return 0;
}

Measured memory_bytes: 628