akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 9;
const double eps = 1e-6;

int n, r;
int s[N];

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        if(x < 400) s[0]++;
        else if(x < 800) s[1]++;
        else if(x < 1200) s[2]++;
        else if(x < 1600) s[3]++;
        else if(x < 2000) s[4]++;
        else if(x < 2400) s[5]++;
        else if(x < 2800) s[6]++;
        else if(x < 3200) s[7]++;
        else r++;
    }

    int cnt = 0;
    for(int i = 0; i < 8; i++)
        if(s[i]) cnt++;

    cout << max(1, cnt) << ' ' << r + cnt << endl;
    return 0;
}


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

const int MOD = 1000000007;


using namespace std;

int main(){

    int i,n;
    cin >> n;
    float ave=0.0,v[n];
    for(i=0;i<n;i++){
        cin >> v[i];
    }

    sort(v,v+n);
    for(i=1;i<n;i++){
        v[i] = (v[i]+v[i-1])/2;
    }

    cout << v[n-1] << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
X=[0]*n
u=[0]*n
for i in range(n):
  X[i],u[i]=input().split()
x=[float(i) for i in X]
ans=0
for i in range(n):
  if u[i]=='JPY':
    ans+=x[i]
  else:
    ans+=380000.0*x[i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 200001
#define B 100
#define dmp make_pair
#define dpb push_back
#define fi first
#define se second
#define se1 se.fi
#define se2 se.se
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const int inf = 1e9;
const ll INF = 1e18;
//__gcd(a,b), __builtin_popcount(a);

map<P, int> mp;
pair<int,int> g[MAX];
vector<int> G[MAX];
int used[MAX], d[MAX], ti[MAX];
int n, m, qn, ans[MAX+1];

void dijkstra(){
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, 1));
	d[1] = 0;
	while(!q.empty()){
		P p = q.top();q.pop();
		if(d[p.se] < p.fi)continue;
		for(int i = 0;i < G[p.se].size();i++){
			int from = p.se, to = G[p.se][i];
			if(d[to] > d[from]+1){
				d[to] = d[from]+1;
				q.push(P(d[to], to));
			}
		}
	}
}

void dijkstra2(){//時間,場所
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(0, 1));
	used[1] = 1;
	while(!q.empty()){
		P p = q.top();q.pop();
		if(p.fi >= ti[p.se])continue;
		ti[p.se] = p.fi;
		ans[qn-p.fi]++;
		//printf("%d %d\n",qn-p.fi, p.se);
		for(int i = 0;i < G[p.se].size();i++){
			int from = p.se, to = G[p.se][i];
			if(d[from]+1 == d[to]){
				if(mp[P(from,to)] <= p.fi)q.push(P(p.fi, to));
				else q.push(P(mp[P(from,to)], to));
			}
		}
	}
}

int main(){
	int t, t1, t2;
	scanf("%d%d%d", &n, &m, &qn);
	fill(d, d+MAX, inf);
	fill(ti, ti+MAX, inf);
	rrep(i,m){
		scanf("%d%d", &t1, &t2);
		G[t1].push_back(t2);
		G[t2].push_back(t1);
		g[i] = (P(t1, t2));
	}
	rrep(i,qn){
		scanf("%d", &t);
		t1 = g[t].fi;
		t2 = g[t].se;
		mp[P(t1, t2)] = qn-i+1;
		mp[P(t2, t1)] = qn-i+1;
	}
	
	dijkstra();
	dijkstra2();
	for(int i = 0;i < qn;i++){
		printf("%d\n", ans[i]);
		ans[i+1] += ans[i];
	}
	return 0;
}



Measured memory_bytes: 41176
import sys
sys.setrecursionlimit(1000000)


N, M = map(int, input().split())

G = {k: [] for k in range(N)}
for _ in range(M):
    x, y = map(int, input().split())

    # 有向グラフ
    G[x-1].append(y-1)  # 0-indexed

dp = [-1 for _ in range(100100)]


def rec(v):
    if dp[v] != -1:
        return dp[v]

    dp[v] = 0
    for nv in G[v]:
        dp[v] = max(dp[v], rec(nv)+1)

    return dp[v]


ans = 0
for v in range(N):
    ans = max(ans, rec(v))
print(ans)


Measured memory_bytes: 67552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll n, m;
    cin >> n >> m;
    if(abs(n - m) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll mx = max(n, m);
    ll my = min(n, m);
    ll ans = 1;
    constexpr ll mod = 1e9 + 7;
    rep(i, 1, mx+1){
        ans *= i;
        ans %= mod;
    }
    rep(i, 1, my+1){
        ans *= i;
        ans %= mod;
    }
    if(mx - my == 1) cout << ans << endl;
    else cout << (2 * ans) % mod << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100001

typedef struct{
  int par;
  int l_child;
  int r_sib;
}node;

node tree[N];
int depth(int);

int main(){
  
  int n,i,j,id,cnum,lef,child;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    tree[i].par=-1;
    tree[i].l_child=-1;
    tree[i].r_sib=-1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&cnum);
    for(j=0;j<cnum;j++){
      scanf("%d",&child);
      if(j==0)tree[id].l_child=child;
      else tree[lef].r_sib=child;
      tree[child].par=id;
      lef=child;
    }
  }
  
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,tree[i].par,depth(i));
    if(tree[i].par==-1)printf("root, [");
    else if(tree[i].l_child==-1)printf("leaf, [");
    else printf("internal node, [");
    lef=tree[i].l_child;
    for(j=0;j<n;j++){
      if(lef==-1)break;
      if(j!=0)printf(", ");
      printf("%d",lef);
      lef=tree[lef].r_sib;
      
    }
    printf("]\n");
  }


  return 0;
}
int depth(n){
  if(tree[n].par==-1)return 0;
  return depth(tree[n].par)+1;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


void no(){
    cout<<"No"<<endl;
}
void yes(){
    cout<<"Yes"<<endl;
}
bool comp(l_l a,l_l b){
    return a.second<b.second;
}
 
int main(){fastio
    ll n;cin>>n;
    ll a[n],b[n];
    rep(i,0,n-1)cin>>a[i];
    rep(i,0,n-1)cin>>b[i];
    ll c[n],d[n];
    rep(i,0,n-1){
        c[i]=a[i];d[i]=b[i];
    }
    sort(c,c+n);sort(d,d+n);
    rep(i,0,n-1){
        if(c[i]>d[i]){
            no();return 0;
        }
    }
    rep(i,0,n-2){
        if(c[i]==c[i+1]){
            yes();return 0;
        }
        if(d[i]==d[i+1]){
            yes();return 0;
        }
    }
    rep(i,0,n-2){
        if(d[i]>=c[i+1]){
            yes();return 0;
        }
    }
    l_l e[n];
    rep(i,0,n-1){
        e[i]=l_l(lower_bound(c,c+n,a[i])-c,lower_bound(d,d+n,b[i])-d);
    }
    sort(e,e+n,comp);
    ll used[n];memset(used,false,sizeof(used));
    ll pos=0;used[0]=true;
    while(1){
        pos=e[pos].first;
        if(used[pos])break;
        used[pos]=true;
    }
    //rep(i,0,n-1)cout<<used[i]<<" ";cout<<endl;
    rep(i,0,n-1){
        if(!used[i]){
            yes();return 0;
        }
    }
    no();
    return 0;
}




Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

int a[101][101] = { 0 };

int main()
{
	int n;
	int u, k, v;

	cin >> n;
	rep(i, n) {
		cin >> u >> k;
		rep(j, k) {
			cin >> v;
			a[u][v] = 1;
		}
	}

	repc(i, 1, n) {
		cout << a[i][1];
		repc(j, 2, n) cout << ' ' << a[i][j];
		cout << endl;
	}

	return 0;
}


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

int CalcSumOfDigit(int n){
  int sum = 0;
  while(n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  
  int total = 0;
  for(int i=1;i<=N;i++){
    if( A <= CalcSumOfDigit(i) && CalcSumOfDigit(i) <= B ){
      total += i;
//      cout << i << endl;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
    x, l = map(int, input().split())
    a.append([x+l, x-l])
a.sort()
ans = 1
bef = a[0]
for i in range(1, n):
    aft = a[i]
    if (bef[0] <= aft[1]):
        bef = aft
        ans += 1
print(ans)

Measured memory_bytes: 20104
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <limits.h>
#include <float.h>
#include <numeric>
#include <queue>
#include <deque>

using namespace std;

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


int main(){
    ll a, b;
    cin >> a >> b;
    ll res = 0;
    for(ll i = a; i < a + (4-a % 4); i++){
        res ^= i;
    }
    for(ll i = b; i >= b - b%4; i--){
        res ^= i;
    }
    cout << res << endl;



    return 0;
}


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

#define int long long 
#define dou double 
#define endl "\n"

const int MOD=1e9+7;

void solve()
{
	int n,m,k;
	cin >> n >> m >> k;
	if(n>m){
		if(n%m==0){
			int t=n/m;
			cout << t*k << endl;
		}
		else{
			int t=n/m;
			cout << (t+1)*k << endl;
		}
	}
	else{
		cout << k << endl;
	}
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }



int main() {
	IOS;
	int n;
	cin >> n;
	vector<ll> x(n), l(n);
	REP(i, n) {
		cin >> x[i] >> l[i];
	}
	vector<P> r(n);
	REP(i, n) {
		r[i].first = x[i] + l[i];
		r[i].second = i;
	}
	sort(all(r));
	int res = 0, t = INT_MIN;
	REP(i, n) {
		int tmp = r[i].first - 2*l[r[i].second];
		if (tmp >= t) {
			res++;
			chmax(t, r[i].first);
		}
	}
	put(res);
	return 0;
}


Measured memory_bytes: 3456
#include<iostream>

using namespace std;

int main(){
	int N, v[102], w[102], W, i, j, K[102][10002];

	cin>>N>>W; //getchar();
	for(i=0; i<N; i++){
		cin>>v[i]>>w[i]; //getchar();
	}
	for(i=0; i<=W; i++){
		K[0][i]=0;
	}
	for(i=1; i<=N; i++){
		K[i][0]=0;
	}
	for(i=1; i<=N; i++){
		for(j=1; j<=W; j++){
			if(w[i-1]<=j){
				if(v[i-1]+K[i-1][j-w[i-1]]>K[i-1][j]){
					K[i][j]=v[i-1]+K[i-1][j-w[i-1]];
				}else{
					K[i][j]=K[i-1][j];
				}
			}else{
				K[i][j]=K[i-1][j];
			}
		} 
	}
	cout<<K[i-1][j-1]<<endl;

	//getchar();
	return 0;
}


Measured memory_bytes: 7052
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

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

Measured memory_bytes: 256
n = int(input())
a = [i for i in map(int, input().split())]
cnt = 0
tmp = []
for i in range(n):
    b = a[i]
    t = 0
    while b % 2 == 0:
        b //= 2
        t += 1
    tmp.append(t)
print(min(tmp))


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

int main()
{
	int n;
	string s;
	cin >> n;
	int cnt = 0;
	for (int i = 0; i < n; i++)
    {
		cin >> s;
		if (s == "Y")
        {
			cnt += 1;
        }
    }
	if (cnt == 0)
    {
		cout << "Three" << endl;
    }
	else
    {
		cout << "Four" << endl;
    }
}			

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {

    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    cout << s1[0] << s2[1] << s3[2] << endl;

    return 0; 
    

}


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

using namespace std;
const int MAX = 100000;
bool alph[26][MAX];
int alphlast[26];

int main()
{

    string s;
    cin >> s;
    int length = s.length();

    for (int j = 0; j < 26; j++)
    {
        alphlast[j] = -1;
    }
    int alphnum;
    for (int i = 0; i < length; i++)
    {
        alphnum = int(s[i]) - int('a');
        if (alphlast[alphnum] == -1)
        {
        }
        else if (i - alphlast[alphnum] <= 2)
        {
            cout << alphlast[alphnum] + 1 << " " << i + 1 << endl;
            return 0;
        }
        alphlast[alphnum] = i;
    }
    cout << -1 << " " << -1 << endl;
    return 0;
    // for (int i = 0; i < length; i++)
    // {
    //     alph[int(s[i]) - int('a')][i] = true;
    //     cout << int(s[i]) - int('a') << endl;
    // }
    // for (int i = 0; i < 26;i++){

    // }
}


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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

using ll=long long;

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> as;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        as.push_back(a);
    }

    ll L = as[0] / 2;
    for (int i = 1; i < N; ++i) {
        L = lcm(L, as[i] / 2);
        if (L > M) { 
            cout << "0" << endl; 
            debug("case1");
            return 0; 
        }
    }
    debug(L);
    for (int i = 0; i < N; ++i) {
        if (L / (as[i] / 2) % 2 == 0) {
            cout << "0" << endl; 
            debug("case2");
            return 0;
        }
    }
    int n = M / L;
    cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 892
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

ans = [0 for _ in range(n)]
for i in range(n):
    stux = ab[i][0]
    stuy = ab[i][1]
    minz = 10 ** 9
    for j in range(m):
        pntx = cd[j][0]
        pnty = cd[j][1]
        if minz > abs(stux - pntx) + abs(stuy - pnty):
            ans[i] = j + 1
            minz = abs(stux - pntx) + abs(stuy - pnty)
for i in range(n):
    print(ans[i])

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

int main() {
  int N, a, i, sum, min=10000000;
  cin >> N;
  for (i=0; i<N; i++) {
    sum = 0;
    cin >> a;
    while((a%2) == 0 ) {
      a /= 2;
      sum++;
    }
    if(sum<min){
      min = sum;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
import sys
import numpy as np
import copy

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))

    # + - + - の順番
    S = 0
    cnt = 0
    for i in range(N):
        S += A[i]
        if i % 2 == 0:
            # +
            if S > 0:
                continue
            else:
                cnt += abs(S) + 1
                S += abs(S) + 1
        else:
            # -
            if S < 0:
                pass
            else:
                cnt += abs(S) + 1
                S -= abs(S) + 1
    ans = cnt

    # - + - +の順番
    S = 0
    cnt = 0
    for i in range(N):
        S += A[i]
        if i % 2 == 1:
            # +
            if S > 0:
                continue
            else:
                cnt += abs(S) + 1
                S += abs(S) + 1
        else:
            # -
            if S < 0:
                continue
            else:
                cnt += abs(S) + 1
                S -= abs(S) + 1

    if ans > cnt:
        ans = cnt
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23212
#include<bits/stdc++.h>
#include <math.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 per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#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};
int main() {
  int N;
  cin >>N;
  int K;
  cin>>K;
  vector<int>vec(N);
  rep(i,N) {
cin >>vec.at(i);
  }
int count=0;
  rep(i,N) {
if(K<=vec.at(i)) {
count++;
}
  }
  cout << count<< endl;
}

Measured memory_bytes: 640
import math
import sys
from decimal import *
import itertools

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

for i in range(N):
    if A[i] == 0:
        print(0)
        sys.exit(0)

now = 1
maxVal = 10**18
for i in range(N):
    if(now * A[i] > maxVal):
        print(-1)
        sys.exit(0)
    now *= A[i]
print(now)



Measured memory_bytes: 88836
fun main(args: Array<String>){

    val n = readLine()!!.toInt()
    val v = readLine()!!.split(" ")
    val c = readLine()!!.split(" ")
    
    val diff = mutableListOf<Int>()

    var ans = 0

    for(i in 0.. n-1){
        diff.add(v[i].toInt()-c[i].toInt())

        if(diff[i] > 0){
            ans += diff[i]
        }
    }
    println(ans)




}

Measured memory_bytes: 37872
while True:

	a, op, b = [int(i) if i.isdigit() else i for i in input().split()]

	if op == "+":
		print(a + b)

	elif op == "-":
			print(a - b)

	elif op == "*":
		print(a * b)

	elif op == "/":
		print(int(a / b))

	elif op == "?":
		break;

Measured memory_bytes: 7644
#include <stdio.h>

int search(char S[]);

int main(void){
  char S[3];
  int price;

  scanf("%s\n", S);
  price = 700 + 100*search(S);

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

  return 0;
}




int search(char str[]){
	int i;
	int num = 0;

	for(i=0;i<3;i++){
		if(str[i] == 'o'){
			num++;
		}
	}
	return num;
}



Measured memory_bytes: 128
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cini(N);
    Cins(S);
    int ans = 0;
    rep(i,S.length()-2){
        if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C')ans++;
    }
    cout << ans << nn;
    return 0;
}

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

int main(){
    string a,b;
    cin >> a >> b;
    if(a.size() > b.size()){
        cout << "GREATER" << endl;
        return 0;
    }
    else if(b.size() > a.size()){
        cout << "LESS" << endl;
        return 0;
    }
    int n = a.size();
    rep(i,n){
        if(a[i] == b[i])continue;
        if(a[i] > b[i]){cout << "GREATER" << endl;
        return 0;}
        else if(a[i] < b[i]){cout << "LESS" << endl;
        return 0;}
    }
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def main():
    a = int(stdin.readline().rstrip())
    print(a+a*a+a*a*a)
main()

Measured memory_bytes: 9904
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using namespace std;
ll power(ll a,ll n)
{
          ll result=1;
          while(n>0)
          {
               if(n&1)
                    result=result*a;
               a=a*a;
               n=n>>1;
          }
          return result;
}
ll lcm(ll a,ll b)
{
          return ((a*b)/__gcd(a,b));
}
bool ispow2(ll n)
{
          return (ceil(log2(n))==floor(log2(n)));
}
bool isprime(ll n)
{
          if(n==1)
               return false;
          else if(n==2)
               return true;
          else
          {
               for(ll i=2;i*i<=n;++i)
               {
                    if(n%i==0)
                         return false;
               }
               return true;
          }
}

ll ncr(ll n,ll r)
{
    if(r > n - r)
          r = n - r;
    ll ans = 1;
    ll i;

    for(i = 1; i <= r; i++)
     {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
int main()
{
          ios_base::sync_with_stdio(0);
          cin.tie(0);

          int t=1;
          //cin>>t;
          while(t--)
          {
                    ll x,k,d;
                    cin>>x>>k>>d;
                    if(x>0)
                    {

                              //10 4 3
                              ll mov = min(x/d,k);
                              k = k - mov;
                              x  = x - (mov*d);
                              ll ans1=1e18,ans2=1e18,ans3=1e18;

                              if(k%2==0)
                                   ans1 = (abs)(x);
                              else
                              {
                                   ans2 = (abs)(x+d);
                                   ans3 = (abs)(x-d);

                              }
                              cout<<min({ans1,ans2,ans3});

                    }
                    else
                    {
                         //-10 1 2


                              //-10 3 4
                              ll mov = ((abs)(x))/d;
                              ll mov1 = (ll)min(k,mov);
                              x = x + (mov1*d);
                              k = k - mov1;
                              ll ans1=1e18,ans2=1e18,ans3=1e18;

                              if(k%2==0)
                              {
                                   ans1 = (abs)(x);
                              }
                              else
                              {
                                   ans2 = (abs)(x+d);
                                   ans3 = (abs)(x-d);

                              }
                              cout<<min({ans1,ans2,ans3});

                    }
          }
          return 0;
}


Measured memory_bytes: 3696
def main():
    s = int(input())
    x1, y1 = 0, 0
    x2, y2 = 1, int(1e9)
    x3, y3 = 0, 0

    l, r = 1, int(1e9)
    while True:
        m = int((l + r) / 2)
        y = m * int(1e9) - s
        if y < 0:
            l = m + 1
        elif y > 1e9:
            r = m - 1
        else:
            x3, y3 = m, y
            break
    if s == int(1e18):
        x2, y2 = 0, int(1e9)
        x3, y3 = int(1e9), 0
    print(x1, y1, x2, y2, x3, y3)


main()


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

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    for (int i = 0; i < N; ++i) {
      cin >> A[i];
    }
    ll sumW = 0;
    for (int i = 0; i < N; ++i) {
        sumW += A[i];
    }
    ll sumD = 0;
    for (int i = 0; i < N; ++i) {
        if(i % 2 == 0) sumD += A[i];
    }
    
    vector<int>ans(N); // 山割る2
    ans[0] = sumD - (sumW / 2);
    for (int i = 1; i < N; ++i) {
        ans[i] = A[i-1] - ans[i-1];
    }
    for (int i = 0; i < N; ++i) {
        cout << ans[i] * 2 << " ";
    }
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
  int N;
  ll ans{};
  cin >> N;
  vector<int> L(N);
  for (int &l: L) cin >> l;
  sort(begin(L),end(L));
  for (int i = 0; i != N; ++i) {
    for (int j = i+1; j < N; ++j) {
      ans += lower_bound(begin(L)+j+1, end(L), L[i]+L[j]) - begin(L)-j-1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
struct st{
    int t;
    int x;
    int y;
};
vector<st> v;
//=============================
void input()
{
    cin>>N;
    v.resize(N);
    rep(i,N){
        cin>>v[i].t>>v[i].x>>v[i].y;
    }
}
//=============================
void func(){}
//=============================
void solve()
{
    bool ans=true;

    sort(v.begin(),v.end(), 
    [](const st &a, const st &b){
        return (a.t<b.t);
    });

    
    int nt=0;
    int nx=0;
    int ny=0;
    for (auto a : v) {
        int dt = a.t - nt;
        int dx = a.x - nx;
        int dy = a.y - ny;

        int aa = abs(dx) + abs(dy);
        if (aa%2 != dt%2 || (dt < aa)) {
            ans = false;
            break;
        }



    }

    cout<<(ans ? "Yes" : "No")<<endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
int main() {
  int n, k;
  cin >> n >> k;
  int mx = (n-1)*(n-2)/2;
  if (mx < k) {
    puts("-1");
    return 0;
  }
  vector<P> ans;
  rep(i,n-1) {
    ans.push_back(P(i+1,n));
  }
  int add = mx-k;
  vector<P> edge;
  rep(i,n-1)rep(j,i) edge.push_back(P(i+1,j+1));
  rep(i,add) ans.push_back(edge[i]);
  cout << ans.size() << endl;
  rep(i,ans.size()) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<utility>
#include<climits>
#define MAX 1000000
#define pb push_back
#define f first
#define s second

using namespace std;

typedef pair<int, int> pii;
typedef map<int, int> mapint;

int32_t main(){
	int a, b;
	cin>>a>>b;
	int first = max(a, b);
	if (first==a) a = a-1;
	else b = b - 1;
	cout<<first + max(a, b)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cmath>
#include <map>
#include <set>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, m, n) for(int i = m;i >= n;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    int n;
    ll a[200005]={},sum1=0,sum2=0,a_min=1e18;
    cin>>n;
    rep(i,0,n){
        cin>>a[i];
        sum2+=a[i];
    }
    rep(i,0,n-1){
        sum1+=a[i];
        sum2-=a[i];
        a_min=min(a_min, abs(sum1-sum2));
    }
    cout<<a_min<<endl;
}

Measured memory_bytes: 1792
#include <iostream> 
#define MAX 100000
using namespace std;

int main() 
{
    int n; cin >> n;
    int A[n+1], B[n+1], C[MAX+1];
    for (int i = 0; i < n; ++i) 
    {
        cin >> A[i];
    }
    for (int i = 0; i <= MAX; ++i) C[i] = 0;

    for (int i = 0; i < n; ++i) ++C[A[i]];

    // 累積和を計算する
    for (int i = 1; i <= MAX; ++i) C[i] += C[i-1];

    for (int i = n-1; i >= 0; --i) B[C[A[i]]--] = A[i];

    // index of B starts from 1
    for (int i = 1; i <= n; ++i) 
    {
        if (i != 1) cout << ' ';
        cout << B[i];
    }
    cout << endl;
}


Measured memory_bytes: 19072
S=input()
#ABCBCBC
N=len(S)
if N<3:
    print(0)
    exit()
S=list(S)
#abc前にaが続く数
As=0
#abcごにbc続く数
BCs=0
ans=0
flag=False
safe=-1
for i in range(N-2):
    if "".join(S[i:i+3])=="ABC":
        ans+=1
        ans+=As


        S[i]="B"
        S[i+1]="C"
        S[i+2]="A"
        safe=i+1

    elif S[i]=="A":
        As+=1
    else:
        if i!=safe:
            As=0
    #print(As)

print(ans)

Measured memory_bytes: 82820
#include <bits/stdc++.h> //M - Candies
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int maxn = 110;
const int maxm = 1e5 + 7;
const int mod = 1e9 + 7;

typedef long long int ll;

// ll dp[maxn][maxm];
ll dp[maxm],v[maxn],k;
ll pre[maxm];

int n,m;
inline ll go(int a,int b)
{
	if(a < 0) a = 0;

	if(a == 0) return pre[b]%mod;
	return (pre[b] - pre[a-1])%mod;
}

//dp[i][j] == na poss 'i' usando 'j' candies

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
		
	cin>>n>>k;
	for(int i=1;i<=n;++i) cin>>v[i];

	dp[0] = 1;
	
	for(int i=1;i<=n;++i)
	{
		
		pre[0] = dp[0];
		dp[0] = 0;

		for(int j=1;j<=k;++j)
			pre[j] = (dp[j] + pre[j-1])%mod;

		for(int j = 0; j <= k;++j)
			dp[j] = go(j-v[i],j);
	}

	
			
	// for(int j=0;j<=v[n];++j)
	// 	ans = (ans + dp[n][j])%mod;
	
	// cout<<ans<<"\n";
	if(dp[k] < 0) dp[k] += mod;
	
	cout<<dp[k]<<"\n";	
}

Measured memory_bytes: 5216
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define max 100

//qsort(d, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}

int main()
{
    int l;
    double ll, ans;
    
    scanf("%d", &l);
    
    ll=l/3.0;
    
    printf("%lf", ll*ll*ll);
    
    return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
using namespace std;
int main(){
        string s = "Yes";
        int n, i, j;
        cin >>n ;
        int a[n];
        for (i=0;i<n;i++){
                cin >> a[i];
        }
        for (i=n-1;i>0;i--){
                if (a[i]==a[i-1]-1){
                        a[i-1] = a[i-1]-1;
                }else if (a[i]<a[i-1]-1){
                        s = "No";
                        break;
                }
        }
        cout << s;
}



Measured memory_bytes: 640
import sys
input = sys.stdin.readline

def main():
    n, k = map(int, input().split())
    alst = [int(input()) for _ in range(n)]
    N = 300100
    
    ll = - 10 ** 10    
    LV = (N-1).bit_length()
    N0 = 2**LV
    data = [0]*(2*N0)
    lazy = [ll]*(2*N0)
    
    def gindex(l, r):
        L = (l + N0) >> 1; R = (r + N0) >> 1
        lc = 0 if l & 1 else (L & -L).bit_length()
        rc = 0 if r & 1 else (R & -R).bit_length()
        for i in range(LV):
            if rc <= i:
                yield R
            if L < R and lc <= i:
                yield L
            L >>= 1; R >>= 1
    
    def propagates(*ids):
        for i in reversed(ids):
            v = lazy[i-1]
            if v == ll:
                continue
            lazy[2*i-1] = data[2*i-1] = lazy[2*i] = data[2*i] = max(v, data[2*i-1], data[2*i])
            lazy[i-1] = ll
    
    def update(l, r, x):
        *ids, = gindex(l, r)
        propagates(*ids)
    
        L = N0 + l; R = N0 + r
        while L < R:
            if R & 1:
                R -= 1
                lazy[R-1] = data[R-1] = max(data[R-1], x)
            if L & 1:
                lazy[L-1] = data[L-1] = max(data[L-1], x)
                L += 1
            L >>= 1; R >>= 1
        for i in ids:
            data[i-1] = max(data[2*i-1], data[2*i])
    
    def query(l, r):
        propagates(*gindex(l, r))
        L = N0 + l; R = N0 + r
    
        s = 0
        while L < R:
            if R & 1:
                R -= 1
                s = max(s, data[R-1])
            if L & 1:
                s = max(s, data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s
    
    ans = 0
    for a in alst:
        a += 50
        l = max(0,a - k)
        r = min(a + k, 300099)
        xx = query(l, r + 1) + 1
        update(a, a + 1, xx)
        ans = max(ans, xx)
    print(ans)
    
main()


Measured memory_bytes: 105804
// ------------------------------------
// Date:2018/ 2/23
// Problem:ABC 048 AtCoder***Contest a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()

using ll = long long;

#define MOD 1000000007

int main()
{
  string S;
  REP(i,3) {
    cin >> S;
    cout << S[0];
  }
  cout << endl;
  return 0;
}


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

typedef long long  LL;
LL n,m,k,x[100010],a[100010],_[100010];

void mul(LL *a,LL *b)
{
	for (int i=1; i<=n; i++)  _[i]=a[b[i]];
	for (int i=1; i<=n; i++)  a[i]=_[i];
}

void work()
{
	scanf("%lld",&n);
	for (int i=1; i<=n; i++)  scanf("%lld",&x[i]),a[i]=i;
	for (int i=n; i; i--)  x[i]-=x[i-1];
	scanf("%lld %lld",&m,&k);
	for (int i=1,x; i<=m; i++)  scanf("%d",&x),swap(a[x],a[x+1]);
	while (k)
		{
			if (k&1)  mul(x,a);
			mul(a,a),k>>=1;
		}
	for (int i=1; i<=n; i++)  x[i]+=x[i-1],printf("%lld\n",x[i]);
}

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


Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
 int X=0;
 scanf("%d",&X);
 X=X%7;
if(X>=9)
{
 if(X==2)
 {printf("sat\n");}
  if(X==3)
 {printf("sun\n");}
  if(X==4)
 {printf("mon\n");}
  if(X==5)
 {printf("tue\n");}
  if(X==6)
 {printf("wed\n");}
  if(X==0)
 {printf("thu\n");}
  if(X==1)
 {printf("fri\n");}
}
else
{
if(X==2)
 {printf("sat\n");}
if(X==1)
 {printf("fri\n");}
if(X==0)
 {printf("thu\n");}
if(X==6)
 {printf("wed\n");}
if(X==5)
 {printf("tue\n");}
if(X==4)
 {printf("mon\n");}
if(X==3)
 {printf("sun\n");}
}


 return 0;
}


Measured memory_bytes: 3172
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val a = new Array[Long](n)
    for (i <- 0 until n) {
      a(i) = sc.nextLong
    }

    // (ai - i)を算出し、昇順に並べる
    val ab = a.zipWithIndex.map(v => v._1 - v._2 - 1).sorted
    // 中央の値が各点との距離の合計が最小になる（数直線上で負の方向にも正の方向にも動けない）
    val b = ab(n / 2)
    // 各点とbとの距離を合算=悲しさ
    val ans = ab.map(v => math.abs(v - b)).sum

    println(ans)
  }
}


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

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

    map<long long int, long long int> mp;
    for(int i=1;i<=n;++i){
        long long int m = i;
        for(long long int j=2;j*j<=m;++j){
            while(m%j == 0){
                mp[j]++;
                m /= j;
            }
        }
        if(m != 1)mp[m]++;
    }

    long long int ans = 1;
    for(auto e : mp){
        ans = ans * (e.second + 1) % 1000000007;
    }

    cout << ans << endl;

    return 0;
}


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

template<typename T>
struct BIT{
    int n;
    vector<T> f;
    BIT(int n = 500002) : n(n), f(n + 1) {}
 
    T getsum(int p){
        T ret = 0;
        for (++p; p > 0; p -= p & -p){
            ret += f[p];
        }
        return ret;
    }
    void add(int p, T x){
        for (++p; p <= n; p += p & -p){
            f[p] += x;
        }
    }
};

int main(){
    int N; cin >> N;
    string s; cin >> s;
    int Q; cin >> Q;
    vector<BIT<long long>> tmp(26);
    for(int i=0;i<N;i++){
        tmp[s[i]-'a'].add(i,1);
    }
    for(int i=0;i<Q;i++){
        int com; cin >> com;
        if(com == 1){
            int i; cin >> i; i--;
            char c; cin >> c;
            tmp[s[i]-'a'].add(i,-1);
            s[i]=c;
            tmp[s[i]-'a'].add(i,1);
            
        }
        if(com == 2){
            int l,r; cin >> l >> r; l--; r--;
            int ans=0;
            for(int i=0;i<26;i++){
                ans+=tmp[i].getsum(r)-tmp[i].getsum(l-1)>0;
            }
            cout << ans << endl;
        }
    }
}

Measured memory_bytes: 102660
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b;
    cin>>a>>b;
    if(a > 9 or b > 9)cout << -1 << endl;
    else cout << a*b<< endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  vi a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(all(a));
  print(10*a[2]+a[1]+a[0]);

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static bool Solve(int A, int B)
        {
            for (int C = 1; C <= 3; ++C)
            {
                if ((A * B * C) % 2 != 0) { return true; }
            }
            return false;
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            Console.WriteLine(Solve(V[0], V[1]) ? "Yes" : "No");
        }
    }
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A, B);
  if (A + B > N) {
    cout << " " << (A + B) - N << endl;
  }
  else {
    cout << " " << 0 << endl;
  }
}

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

int main(){
    
    ll N;
    cin >> N;
    vector<vector<ll>> A(2, vector<ll>(N));
    rep(i, 0, 2){
        rep(j, 0, N) cin >> A[i][j];
    }

    ll ans = 0;
    rep(i, 0, N){
        ll sum = 0;
        rep(j, 0, i+1) sum += A[0][j];
        rep(j, i, N) sum += A[1][j];
        ans = max(ans, sum);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			int r = stdIn.nextInt();
			if(n == 0 && r == 0)
			{
				break;
			}
			List<Integer> list = new ArrayList<Integer>();
			for(int i = 0; i < n; ++i)
			{
				list.add(n - i);
			}
			while(r-- != 0)
			{
				int p = stdIn.nextInt();
				int c = stdIn.nextInt();
				List<Integer> listBuf = new ArrayList<Integer>();
				for(int i = 0; i < n; ++i)
				{
					listBuf.add(list.get(i));
				}
				int pos = 0;
				for(int i = p - 1; i < p + c - 1; ++i)
				{
					list.set(pos, listBuf.get(i));
					++pos;
				}
				for(int i = 0; i < p - 1; ++i)
				{
					list.set(pos, listBuf.get(i));
					++pos;
				}
				for(int i = p + c - 1; i < n; ++i)
				{
					list.set(pos, listBuf.get(i));
					++pos;
				}
			}
			System.out.println(list.get(0));
		}
	}
}

Measured memory_bytes: 12000