akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " [" << x.fi << " " << x.se << "]"<<endl;
#define debug_v(x) {cerr << #x << " "; for (auto ioi : x) cerr << ioi << " "; cerr << endl;}
#define debug_vp(x) {cerr << #x << " "; for (auto ioi : x) cerr << '[' << ioi.fi << " " << ioi.se << ']'; cerr << endl;}
#define debug_v_v(x) {cerr << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cerr << ioi2 << " "; cerr << '\n';} cerr << "*/" << #x << endl;}
#define gen_clock(x) ll x = clock(); cerr << "Clock " << #x << " created" << endl;
#define check_clock(x) cerr << "Time spent in " << #x << ": " << (double)(clock() - x)/CLOCKS_PER_SEC << endl; x = clock();
#define reset_clock(x) x = clock()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

vi pre(65);
bool prime[1000009];
vi primes;

void sieve()
{
	ll i,j;
	for(i=2;i<=1000000;i++)
	if(!prime[i])
	{
		primes.pb(i);
		for(j=i*i;j<=1000000;j+=i)
		prime[j]=1;
	}
}

void solve()
{
	ll i;
	pre[0]=0;
	for(i=1;i<=64;i++)
	pre[i]=pre[i-1]+i;
	sieve();
	ll n;
	cin>>n;
	vi pows;
	for(auto u:primes)
	{
		if(1LL*u*u > n) break;
		if(n%u) continue;
		int cnt=0;
		while(n%u==0)
		{
			n/=u;
			cnt++;
		}
		pows.pb(cnt);
	}
	if(n!=1) pows.pb(1);
	
	ll ans=0;
	//debug_v(pows)
	for(auto u:pows)
	ans += upper_bound(all(pre),u)-pre.begin()-1;
	
	cout<<ans<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 4796
#include<bits/stdc++.h>
using namespace std;
int main(){
int _t4;int _t2;int _t7;int _t5;int _t11;int _t10;int _t9;string _t8;string _t1;int A;int H;scanf("%d",&_t4);_t2=H=_t4;scanf("%d",&_t7);_t5=A=_t7;_t11=H+A;_t10=_t11-1;_t9=_t10/A;_t8=to_string(_t9);printf("%s\n",_t8.c_str());
}



Measured memory_bytes: 256
n,k = map(int, input().split())
x = list(map(int, input().split()))
left = []
right = []
for i in x:
    if i < 0:
        left.append(-i)
    elif i > 0:
        right.append(i)
    else:
        k -= 1
if k <= 0:
    print(0)
else:
    left = [0] + left[::-1]
    right = [0] + right
    ans = float("Inf")
    for i in range(k+1):
        # 左にi 右にk-i
        if len(left) > i and len(right) > k-i:
            tmp = left[i]+right[k-i] + min(left[i], right[k-i])
            ans = min(ans, tmp)
    print(ans)

Measured memory_bytes: 64664
<?php
// Structured Program I - Print a Rectangle
while(true){
    $data = explode(" ",trim(fgets(STDIN)));
    $H = $data[0];
    $W = $data[1];
    if($H == 0 && $W == 0) break;// ??\????????????
    for($i = 0; $i < $H; $i++){
        for($j = 0; $j < $W; $j++){
            echo "#";
        }
        echo "\n";
    }
    echo "\n";
}

Measured memory_bytes: 15392
#include <cstdio>
#include <iostream>

using namespace std;

typedef long long ll;
const int MAXN = 51;
const int MOD = 1e9+7;

int n;
ll k;

struct matrix{
	int a[MAXN][MAXN];
	matrix(){
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				a[i][j] = 0;
	}
	matrix(int TP = 0){
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				a[i][j] = 0;
		if(TP)
			for(int i=1;i<=n;i++)
				a[i][i] = 1;
	}
	matrix operator*(const matrix &y)
	{
		matrix res(0);
		for(int k=1;k<=n;k++)
			for(int i=1;i<=n;i++)
				for(int j=1;j<=n;j++)
					res.a[i][j] = (res.a[i][j] + 1ll * a[i][k] * y.a[k][j] % MOD) % MOD;
		return res;
	}
};

inline matrix pw(matrix x, ll p)
{
	matrix res(1);
	for(;p;p>>=1,x=x*x)
		if(p&1) res=res*x;
	return res;
}

matrix x(0);

int main()
{
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			scanf("%d",&x.a[i][j]);
	matrix z = pw(x, k);
	int ans = 0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			ans = (ans + z.a[i][j]) % MOD;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<cmath>
#define INF 10000000000000
using namespace std;
typedef long long ll;
typedef pair<double,ll> P;
struct edge{
  ll to;
  double cost;
};
signed main(){
  double sx,sy,tx,ty;
  ll n;
  cin >> sx >> sy >> tx >> ty >> n;
  vector<edge> G[1100];
  double d[1100],dis;
  priority_queue<P,vector<P>,greater<P>> que;
  double x[n+2],y[n+2],r[n+2];
  x[0] = sx;
  y[0] = sy;
  x[n+1] = tx;
  y[n+1] = ty;
  for(int i=1;i<=n;i++){
    cin >> x[i] >> y[i] >> r[i];
  }
  for(int i=0;i<n+2;i++){
    for(int j=0;j<n+2;j++){
      if(i==j) continue;
      dis = max(0.0,sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2))-r[i]-r[j]);
      G[i].push_back({j,dis});
    }
  }
  fill(d,d+1100,INF);
  que.push(P(0,0));
  while(!que.empty()){
    P tmp = que.top();
    que.pop();
    ll nv = tmp.second;
    double dis = tmp.first;
    if(d[nv]<=dis){
      continue;
    }
    d[nv] = dis;
    for(auto v:G[nv]){
      que.push(P(v.cost+dis,v.to));
    }
  }
  printf("%.12lf\n",d[n+1]);
}


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

int s;

int main () {
  cin >> s;
  int flag = 1;
  int before = s;

  if (s == 1  || s == 2 || s == 4) {
    cout << 4 << endl;
    return 0;
  }
  
  while (true) {
    if (s%2 == 0) {
      s /= 2;
    } else {
      s = before*3+1;
    }

    before = s;
    flag++;
    if (s == 4) {
      flag += 3;
      break;
    }
  }
  cout << flag << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, a;
  cin >> N >> M;
  vector<int> vec(2 * M);
  for (int i = 0; i < 2 * M; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < N; i++) {
    a = 0;
    for (int j = 0; j < 2 * M; j++) {
      if (vec.at(j) == i + 1) {
        a++;
      }
    }
    cout << a << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int W,H,x,y,r;
cin >> W >> H >> x >> y >> r;
if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.io.*; 
 
class Main { 
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
      	//int x = sc.nextInt();
      	//int t = sc.nextInt();
      	PrintWriter out = new PrintWriter(System.out);
        out.println(Math.max(sc.nextInt() - sc.nextInt(), 0));
      	out.flush();
    }

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
 
    public int nextInt() {
        int n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}


}



Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_D 100000005
#define MAX_N 200005


vector<pair<ll,P>> v;
ll l[MAX_N], r[MAX_N];


int main() {
    ll n, x_, d;
    cin >> n >> x_ >> d;

    ll ans = 0;

    if(d == 0){
        if(x_ == 0){
            cout << '1' << endl;
        }else{
            cout << n + 1 << endl;
        }
        return 0;
    }

    if(d < 0){
        d = -d;
        x_ = -x_;
    }



    rep(i,n+1){
        ll ii = i;
        ll xx = x_ * ii % d;
        ll l_ = x_ * ii + ii * (ii - 1) / 2 * d;
        ll r_ = x_ * ii + (n - 1) * n / 2 * d - (n - 1 - ii) * (n - ii) / 2 * d;
        pair<ll,P> p;
        p.first = xx;
        p.second.first = l_;
        p.second.second = r_;
        v.push_back(p);
    }

    sort(v.begin(), v.end());
    
    int m = 0;
    rep(i,n+1){
        ll xx = v[i].first;
        ll l_ = v[i].second.first;
        ll r_ = v[i].second.second;
        if(i == 0){
            l[m] = l_;
            r[m] = r_;
            m++;
        }else if(xx == v[i-1].first){
            l[m] = l_;
            r[m] = r_;
            m++;
        }else{
            sort(l,l+m);
            sort(r,r+m);
            ll now = 0;
            ll s = 0;
            int x = 0, y = 0;
            while(y <m){
                if(x == m){
                    y++;
                    now--;
                }else if(l[x] <= r[y]){
                    if(now == 0)s = l[x];
                    x++;
                    now++;
                }else{
                    now--;
                    y++;
                }
                if(now == 0){
                    ans += (r[y-1] - s) / d + 1;
                }
            }
            m = 0;
            l[m] = l_;
            r[m] = r_;
            m++;
        }
        if(i == n){
            sort(l,l+m);
            sort(r,r+m);
            ll now = 0;
            ll s = 0;
            int x = 0, y = 0;
            while(y <m){
                if(x == m){
                    y++;
                    now--;
                }else if(l[x] <= r[y]){
                    if(now == 0)s = l[x];
                    x++;
                    now++;
                }else{
                    now--;
                    y++;
                }
                if(now == 0){
                    ans += (r[y-1] - s) / d + 1;
                }
            }
        }
    }


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



Measured memory_bytes: 9324
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}

const int INF = 1 << 20;
const int MOD = 1e9 + 7;

int main() {
   int x, y;
   cin >> x >> y;
   int ans = x + y / 2;
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

K=II()
S=input()
L=len(S)
FACT=FLIST(K+L)
def NCR(n, r):
    res = FACT[n-r]
    res *= FACT[r]
    res %= DVSR
    res = INV(res)
    res *= FACT[n]
    res %= DVSR
    return res

ans = 0
for i in range(K+1):
    v = NCR(L+K-i-1, L-1)
    v *= POW(25, K-i)
    v %= DVSR
    v *= POW(26, i)
    v %= DVSR
    ans += v

print(ans % DVSR)


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

int main(){
  int N;
  cin >> N;
  
  int H[N];
  
  for(int i=0;i<N;i++){
  cin >> H[i];
  }
  
  int biggest = 0;
  
  for(int i = 0;i < N-1;i++){
    int counter = 0;
    int t = i;
    if(biggest >= N -1){break;}
    
    while(t<N-1){
      if(H[t] >= H[t+1]){
        counter++;
        t++;
      }
      else{
        break;
      }
    }
    biggest = max(counter,biggest);
    //cout << i << ' ' << biggest << endl;
  }
  
  
  cout << biggest;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll mod=998244353;

vector<ll> fac(100000000);
 
ll modinv(ll a){
    ll b=mod,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b; swap(a,b);
        u-=t*v; swap(u,v);
        }
        u%=mod;
        if(u<0) u+=mod;
    return u;
}
 
void modfac(int n){
    fac[0]=1;
    for(ll i=1;i<n;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
}
 
ll modperm(ll n,ll k){
    if(n<0||k<0||n<k) return 0;
    else return (fac[n]*modinv(fac[n-k]))%mod;
}
 
ll modcomb(ll n,ll k){
    if(n<0||k<0||n<k) return 0;
    else return ((fac[n]*modinv(fac[k]))%mod*modinv(fac[n-k]))%mod;
}
 
ll modpow(ll a,ll b){
  ll ans=1;
  a%=mod;
  while(b){
    if(b&1) ans=ans*a%mod;
    a=a*a%mod;
    b>>=1;
  }
  return ans;
}

int main(){
  ll n;
  cin >> n;
  modfac(10000010);
  ll ans=modpow(3,n);
  ll cnt=modpow(2,n-n/2-1);
  ll inv2=modinv(2);
  for(ll i=n/2+1;i<=n;i++){
    ans-=cnt*modcomb(n,i)*2%mod;
    ans+=mod; ans%=mod;
    cnt*=inv2; cnt%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 781568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I=ll(A);I<ll(B);++I)

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

	int n,ta=0,ha=0;
	string s,t;
	cin >> n;
	FOR(i,0,n){
		cin >> s >> t;
		if(s>t){
			ta+=3;
		}else if(s<t){
			ha+=3;
		}else{
			ta++;ha++;
		}
	}
	cout << ta << " " << ha << endl;
}


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

int main(){
  int N,M;
  cin >>N >>M;
  vector<int> a(M);
  vector<int> b(M);
  for(int i=0;i<M;i++)
    cin >>a.at(i) >>b.at(i);
  for(int i=1;i<=N;i++){
    int answer=0;
    for(int j=0;j<M;j++){
      if(i==a.at(j)||i==b.at(j))
        answer++;
    }
    cout <<answer <<endl;
  }
}


Measured memory_bytes: 256
Rooms = [[[0 for i in range(10)] for ii in range(3)] for iii in range (4)]
num = int(input())
for i in range(num):
    b, f, r, v = map(int, input().split())
    Rooms[b-1][f-1][r-1] += v
    
for i in range(15):
    if i % 4 == 3: 
        print("####################")
    else:
        b = i // 4
        f = i % 4
        print(" " + " ".join(map(str, Rooms[b][f])))


Measured memory_bytes: 5608
#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=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

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

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

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    int X; cin >> X;

    int ans = 360 / gcd(X, 360);
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3648
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let s = buf.trim();
    let n = s.len();
    let mut g = vec![Vec::new(); n];
    let mut reach = vec![0; n+1];
    reach[0] = 1;
    for &t in &["dream", "dreamer", "erase", "eraser"] {
        for p in s.match_indices(t) {
            g[p.0].push(p.0 + t.len());
        }
    }
    for i in 0..n {
        if reach[i] == 0 { continue }
        for &t in &g[i] { reach[t] = 1; }
    }
    println!("{}", if reach[n] == 1 { "YES" } else { "NO" });
}


Measured memory_bytes: 8444
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

int len(ll x){
    int l = 0;
    while(x){
        ++l;
        x /= 10;
    }
    return l;
}

int sum(ll x){
    int s = 0;
    while(x){
        s += x%10;
        x /= 10;
    }
    return s;
}

ll ext(ll x){
    ll ans = 0;
    ll div = 10;
    while(div <= x){
        ans += x/div;
        div *= 10;
    }
    return ans;
}

ll f(ll x){
    if(x <= 9) return 0;
    
    ll l = len(x), s = sum(x);
    ll ans = l-len(s) + ext(s) + f(s);
    return ans;
}

void solve(){
    int m;
    cin >> m;
    ll l = 0, s = 0;
    for(int i = 0; i < m; ++i){
        int d;
        ll c;
        cin >> d >> c;
        l += c;
        s += c*d;
    }

    ll ans = l-len(s) + ext(s) + f(s);
    cout << ans << '\n';
}

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

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return [f = std::forward<F>(f)](auto&&... args) {
    return f(f, std::forward<decltype(args)>(args)...);
  };
}
template<typename T>
static inline T fin() { T t; cin >> t; return std::move(t); }

int main() {
  i64 n;
  cin >> n;
  map<string , i64> mp;
  for(int i = 0;i < n;i++) {
    string s;
    cin >> s;
    sort(all(s));
    mp[s]++;
  }
  i64 ans = 0;
  for(auto p: mp) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <atcoder/all>

#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define REP(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using namespace atcoder;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int k;
	cin >> k;
	string a = "ACL";
	rep(i, k)cout << a;
	cout << endl;
	return 0;
}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define X first
#define Y second
#define LL long long
#define MP make_pair
#define PB push_back
#define SZ(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 47;
using namespace std;

int main() 
{
	int n , m;
	cin >> n >> m;
	int cnt = 1;
	int x = 0;
	while(cnt < m)
	{
		cnt += n - 1;
		x++;
	}
	cout << x;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

print('Yay!' if max(b-a, c-a, d-a, e-a, c-b, d-b, e-b, d-c, e-c, e-d) <= k else ':(')

Measured memory_bytes: 8988
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  int x = in();
  int ans = 1;
  rep(i,2,x){
    for(int j=i*i;j<=x;j*=i){
      chmax(ans,j);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
     if(a==0||b==0)
        printf("-1\n");
    else if(((9<a)||(a<1))||((9<b)||(b<1)))
        printf("-1\n");
    else if((9>=a>=1)&&(9>=b>=1))
        printf("%d\n",a*b);
     //if(a==0||b==0)
        //printf("-1\n");
    return 0;
}


Measured memory_bytes: 128
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Data.Ord

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    [n,m] <- r'
    print $ (n*(n-1)+m*(m-1)) `div` 2



Measured memory_bytes: 380
#include <stdio.h>

void printLine(int *A, int N)
{
    int i;

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

void insertionSort(int *A, int N)
{
    int i, j, v;
    
    for (i = 1; i < N; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        
        printLine(A, N);
    }
}

int main()
{
    int N;
    int A[1000] = {0};
    int i;

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

    printLine(A, N);
    insertionSort(A, N);

    return 0;
}


Measured memory_bytes: 2040
N=int(input())
H=list(map(int,input().split()))
min=H[0]
count=[0 for _ in range(N)]
cnt=0
t=0
for i in range(1,N):
    if H[i]<=min:
        min=H[i]
        cnt+=1
    else:
        count[t]=cnt
        cnt=0
        t+=1
        min=H[i]
count[t]=cnt
print(max(count))

Measured memory_bytes: 64228
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}
int main(){
  int m,f,b;
  cin>>m>>f>>b;
  if(m>=b) cout<<"0"<<endl;
  else if(m+f<b) cout<<"NA"<<endl;
  else cout<<b-m<<endl;
    
  return 0;
}



Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
static const int N=101;

int n;
vi d(N,-1),color(N,WHITE);
vii M(N,vi(N,0));

void bfs();
void bfs_visit(int);

int main(){
	int i,j;
	cin>>n;
	int u,k,v;
	loop(i,0,n){
		cin>>u>>k;
		loop(j,0,k){
			cin>>v;
			M[u][v]=1;
		}
	}
	
	bfs();
}

void bfs(){
	int u;
	bfs_visit(1);
	loop(u,1,n+1){
		cout<<u<<" "<<d[u]<<endl;
	}
}

void bfs_visit(int r){
	queue<int> q;
	int v;
	q.push(r);
	d[r]=0;
	while(!q.empty()){
		int u=q.front();
		loop(v,1,n+1){
			if(M[u][v] && color[v]==WHITE){
				q.push(v);
				color[v]=GRAY;
				d[v]=d[u]+1;
			}
		}
		color[u]=BLACK;
		q.pop();
	}
}

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

int N, K;

int main() {
    cin >> N >> K;
    deque<int> jewel;
    for (int i=0; i < N; i++) {
        int v;
        cin >> v;
        jewel.push_back(v);
    }

    int ans = 0;
    for(int i = 0; i <= K; i++) {
        for(int j = 0; i + j <= K; j++) {
            for (int l = 0; i + j + l <= K; l++) {
                deque<int> tmp_jewel = jewel;
                priority_queue<int> minus_v;
                int sum = 0;

                for(int a = 0; a < i; a++) {
                    if (tmp_jewel.empty()) break;
                    else {
                        sum += tmp_jewel.front();
                        if (tmp_jewel.front() < 0) {
                            minus_v.push(-tmp_jewel.front());
                        }
                        tmp_jewel.pop_front();
                    }
                }

                for(int b = 0; b < j; b++) {
                    if (tmp_jewel.empty()) break;
                    else {
                        sum += tmp_jewel.back();
                        if (tmp_jewel.back() < 0) {
                            minus_v.push(-tmp_jewel.back());
                        }
                        tmp_jewel.pop_back();
                    }
                }

                for(int c = 0; c < l; c++) {
                    if (minus_v.empty()) break;
                    else {
                        sum += minus_v.top();
                        minus_v.pop();
                    }
                }
                ans = max(ans, sum);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 1e5 + 5;

void debug_out() {
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
set<ll>v[MAXN];
int main() {
    FAST
ll n,m;
    cin>>n>>m;
    map<ll,ll> hi;
    for(int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        hi[i+1]=a;
    }
    for(int i=0;i<m;i++)
    {
        ll a,b;
        cin>>a>>b;
        v[a].insert(hi[b]);
        v[b].insert(hi[a]);
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        if(v[i].size()==0|| hi[i]>*v[i].rbegin() )
            ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 23980
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        400005
#define mod         1000000007 
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k,i,j,count=0,l,mx=0,x,sum=0;
    vector<ll> vi0;
    cin>>n>>k;
    string s;
    cin>>s;
    ll a[MAXN];
    memset(a,0,sizeof(a));
    j=1;
    l=0;
    bool flag=true;
    for(i=0;i<n;i++){
        if(s[i]=='0'){
            count++;
            flag=false;
        }
        else{
            if(flag==false){
                vi0.pb(count);
                a[j]=count;
                j+=2;
                count=0;
                flag=true;
            }
        }
    }
    if(count>0){
        a[j]=count;
        vi0.pb(count);
    }
    count=0;
    flag=false;
    for(i=0;i<n;i++){
        if(s[i]=='1'){
            count++;
            flag=false;
        }
        else{
            if(flag==false){
                a[l]=count;
                l+=2;
                count=0;
                flag=true;
            }
        }
    }
    a[l]=count;
    l++;
    a[l]=0;
    if(k>=vi0.size()){
        cout<<n;
    }
    else{
        x=max(l,j);
        //for(i=0;i<=x;i++){
       //     cout<<a[i]<<" ";
       // }
        //cout<<endl;
            for(i=0;i<=2*k;i++){
                sum+=a[i];
            }
          //  cout<<sum<<" ";
            mx=sum;
            j=2*k;
            for(i=2;i<x-2;i+=2){
               // cout<<a[i-1]<<" "<<a[i-2]<<" "<<a[i-1]+a[i-2]<<" ";
                sum=sum-(a[i-1]+a[i-2]);
               // cout<<sum<<" ";
                j++;
                sum+=a[j];
                j++;
                sum+=a[j];
               // cout<<sum<<" ";
                mx=max(mx,sum);
            }
        cout<<mx;
    }
}

Measured memory_bytes: 4172
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18+5;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin >> s >> t;
  for(int i=0; i<s.size(); i++) {
    if(s[i]!=t[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 
*/
//================== INPUT ========================
int N, K;
vector<int> P;
//=================================================
//=================================================
void input()
{
    cin >> N;
    P.resize(N);

    rep(i, N)
    {
        cin >> P[i];
    }
}
//=================================================
void solve()
{
    bool ans = false;
    for (int i = 0; i < N; ++i)
    {
        if (ans)
            break;
        for (int j = i + 1; j < N; ++j)
        {
            vector<int> newp(N);
            int tmpi, tmpj;
            tmpi = P[i];
            tmpj = P[j];
            rep(l, N)
            {
                if (l == i)
                {

                    //cout<<"l="<<l<<", tmpj="<<tmpj<<endl;
                    newp[l] = tmpj;
                }
                else if (l == j)
                {
                    //cout<<"l="<<l<<", tmpi="<<tmpi<<endl;
                    newp[l] = tmpi;
                }
                else
                    newp[l] = P[l];
            }
            // cout<<i<<","<<j<<endl;
            // for (auto x : newp){
            //     cout<<x << " ";
            // }
            // cout<<endl;

            // check
            bool isOK = true;
            for (int k = 0; k < N - 1; ++k)
            {
                if (newp[k] > newp[k + 1])
                {
                    isOK = false;
                    break;
                }
            }
            if (isOK)
            {
                ans = true;
                break;
            }
        }
    }

    bool isOK = true;
    for (int k = 0; k < N - 1; ++k)
    {
        if (P[k] > P[k + 1])
        {
            isOK = false;
            break;
        }
    }
    if (isOK)
    {
        ans = true;
    }

    cout << (ans ? "YES" : "NO") << endl;
}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void solve() {
        int n; cin >> n;
        double wh= n/ 3.0;
        cout<< setprecision(10);
        cout << wh* wh* (wh)<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) solve();
return 0;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
    cin>>arr[i];
int ans=0;
for(int i=0;i<n;i++)
{
    if(i%2==0&&arr[i]&1)
        ans++;
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <map>
#include <stack>
#include <unordered_set>
using namespace std;

typedef long long ll;
const int M = 1e9 + 7;
const int N = 3e5 + 10;
const int MAX = 1e9 + 1;
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

int n, m;

int main() {
    int i, j;
    string s;
    cin >> s;
    int len = s.size();
    int ans = len;
    for (i = 0; i < len - 1; ++i) {
        if (s[i] != s[i + 1])
            ans = min(ans, max(i + 1, len - i - 1));
    }
    cout << ans << endl;
    return 0;
}


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

const int P = 1000000007;
int n, dp[55][55], binom[55][55];

void upd(int &x, long long y) {
	x = (x + y) % P;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i <= n; ++i)
		for (int j = binom[i][0] = 1; j <= i; ++j)
			binom[i][j] = (binom[i - 1][j] + binom[i - 1][j - 1]) % P;
	dp[1][0] = dp[1][1] = n;
	for (int i = 1; i < n; ++i)
		for (int j = 0; j <= i; ++j)
			if (dp[i][j]) for (int k = j == 0 ? 2 : j; k <= n - i; k += 2)
				for (int x = 0; x <= k; ++x)
					upd(dp[i + k][abs((k - j) / 2 - x)], 1ll * dp[i][j] * binom[k][x] % P * binom[n - i][k]);
	printf("%d\n", dp[n][0]);
	return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	X = LI()
	X = np.array(X, dtype="int32")
	m = round(np.sum(X) / N)
	print(int(np.sum((X-m)**2)))

if __name__ == '__main__':
	main()

Measured memory_bytes: 22124
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
string a[101];
int main(){
	int n,i,l;
	cin>>n>>l;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
    sort(a,a+n);
	for(i=0;i<n;i++)
	cout<<a[i];	
	cout<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
g = [[] for i in range(n)]
for i in range(n-1):
  a,b,c = map(int,input().split())
  a-=1;b-=1
  g[a].append([b,c])
  g[b].append([a,c])
q,k = map(int,input().split())
k -= 1
con = [-1] * n
con[k] = 0
stack = [k]
while stack:
  cur = stack.pop()
  for i,j in g[cur]:
    if con[i] == -1:
      con[i] = con[cur] + j
      stack.append(i)
for i in range(q):
  x,y = map(int,input().split())
  x-=1;y-=1
  print(con[x]+con[y])

Measured memory_bytes: 81476
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 159, task d, 2020/09/08
//ms,
/*
*/

int main(void){
  int N;
  vector<int64_t> rec(200001);//インデックスはボールに書かれた数字、要素は個数
  vector<int64_t> a;
  int64_t cases=0;

  for(int i=0;i<200000;i++) rec[i]=0;

  cin >>N;
  for(int i=0;i<N;i++){
    int tmp_a;
    cin >>tmp_a;
    rec[tmp_a]++;
    a.push_back(tmp_a);
  }

  for(int i=1;i<200000;i++) cases+=rec[i]*(rec[i]-1)/2;

  for(int i=0;i<N;i++){
    int same_balls =rec[a[i]];
    int64_t ans=cases - same_balls*(same_balls-1)/2;
    ans += (same_balls-1)*(same_balls-2)/2;
    cout <<ans <<endl;

  }


  return 0;
}
/*
*/


Measured memory_bytes: 6852
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << " #x = " << x << endl;
#define show(x) {for( auto ii : x) cout << ii << en; cout << endl;}
#define shop(n,x) {for(int i = 0; i < n; i++) cout << x << en; cout << endl;}
#define ff first
#define ss second
#define sq(x) (x*x)
#define endl '\n'
#define en " "
#define pb push_back
#define mpair make_pair
ll mod=1000000007;
double pi=3.1415926536;
ll n;
ll dp[200003];
ll cost(ll a[], ll idx)
{
	if(dp[idx] != -1)
		return dp[idx];

	if(idx >= n-2)
		return abs(a[n-1] - a[idx]);

	return dp[idx] = min(abs(a[idx + 1] - a[idx]) + cost(a, idx + 1),
				 	abs(a[idx + 2] - a[idx]) + cost(a, idx + 2));
}
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// go fast 		check		//		CHECK -> if()   else if()
		
		ll x=0, m=0, y=0, d=1, k=mod;
		cin >> n;
		ll a[n];
		memset( dp, -1, sizeof(dp) );
		for(int i = 0; i < n; i++)
			cin >> a[i];

		cout << cost(a, 0) << endl;
	}
}

Measured memory_bytes: 5760
# https://atcoder.jp/contests/abc117/tasks/abc117_c

import numpy as np

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

x = np.array(sorted(Xs))
if N == 1:
    print(np.sum(np.sort(np.diff(x))))
else:
    print(np.sum(np.sort(np.diff(x))[:-N+1]))

Measured memory_bytes: 38600
#include <stdio.h>
#include <stdlib.h>
#define ms_valtype data

typedef struct {
	int num;
	int x;
	int y;
}data;

//比較関数
int compare_ms_num(ms_valtype a, ms_valtype b){
	return a.num - b.num;
}

int compare_ms_x(ms_valtype a, ms_valtype b){
	return a.x - b.x;
}

int compare_ms_y(ms_valtype a, ms_valtype b){
	return a.y - b.y;
}

//昇順
void sort_sub(ms_valtype *origin, int left, int right, ms_valtype *tmp, int (*compare_ms)(ms_valtype a, ms_valtype b)){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp, compare_ms);
		sort_sub(origin, half, right, tmp, compare_ms);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare_ms(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(ms_valtype *origin, int N, int (*compare_ms)(ms_valtype a, ms_valtype b)){
	ms_valtype *tmp = (ms_valtype *)malloc(sizeof(ms_valtype) * N);
	sort_sub(origin, 0, N, tmp, compare_ms);
	free(tmp);
}

typedef struct {
	int N;
	int *u;
	int *u_rank;
}union_find;

union_find *make_union_find(int N){
	int i;
	union_find *uf = (union_find *)malloc(sizeof(union_find));
	uf->N = N;
	uf->u = (int *)malloc(sizeof(int) * N);
	uf->u_rank = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		(uf->u)[i] = i;
		(uf->u_rank)[i] = 1;
	}
	return uf;
}

int root_uf(int x, union_find *uf){
	int *u = uf->u;
	if(u[x] == x){
		return x;
	}
	else{
		u[x] = root_uf(u[x], uf);
		return u[x];
	}
}

void combine_uf(int x, int y, union_find *uf){
	int x_root = root_uf(x, uf);
	int y_root = root_uf(y, uf);
	int *u = uf->u;
	int *u_rank = uf->u_rank;
	if(x_root == y_root){
		return;
	}
	else if(u_rank[x_root] < u_rank[y_root]){
		u[x_root] = y_root;
		u_rank[y_root] += u_rank[x_root];
		u_rank[x_root] = 0;
	}
	else{
		u[y_root] = x_root;
		u_rank[x_root] += u_rank[y_root];
		u_rank[y_root] = 0;
	}
}

//xとyが同じ集合に属していれば1を,そうでなければ0を返す
int is_same_union_uf(int x, int y, union_find *uf){
	if(root_uf(x, uf) == root_uf(y, uf)){
		return 1;
	}
	else{
		return 0;
	}
}

//xが属する集合の要素数を返す
int rank_uf(int x, union_find *uf){
	return (uf->u_rank)[root_uf(x, uf)];
}

int main(){
	int N, i, ans = 0;
	scanf("%d", &N);
	data *v = (data *)malloc(sizeof(data) * N);
	for(i = 0; i < N; i++){
		v[i].num = i;
		scanf("%d%d", &v[i].x, &v[i].y);
	}
	data *e = (data *)malloc(sizeof(data) * 2 * (N - 1));
	sort(v, N, compare_ms_x);
	for(i = 0; i < N - 1; i++){
		e[i].num = v[i + 1].x - v[i].x;
		e[i].x = v[i].num;
		e[i].y = v[i + 1].num;
	}
	sort(v, N, compare_ms_y);
	for(i = 0; i < N - 1; i++){
		e[N - 1 + i].num = v[i + 1].y - v[i].y;
		e[N - 1 + i].x = v[i].num;
		e[N - 1 + i].y = v[i + 1].num;
	}
	sort(e, 2 * (N - 1), compare_ms_num);
	union_find *uf = make_union_find(N);
	for(i = 0; i < 2 * (N - 1); i++){
		if(root_uf(e[i].x, uf) != root_uf(e[i].y, uf)){
			combine_uf(e[i].x, e[i].y, uf);
			ans += e[i].num;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 7148
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 999999999
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;

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


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



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

int main() {
  int N;
  cin >> N;
  int ans=0;
  string S;
  cin >> S;
  for(int i=0; i<N; i++ ){
    if( S.at(i) == 'R'){
      ans++;
    }
    if( S.at(i) == 'B'){
      ans--;
    }
  }
  if (ans>0){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
    
}



Measured memory_bytes: 256
x,n=map(int,input().split())
if n==0:
    print(x)
    exit()
p=list(map(int,input().split()))
p.sort()
if p[0]>x or p[-1]<x:
    print(x)
else:
    now=x
    ans1=p[-1]+1
    ans2=p[0]-1
    while now<=p[-1]:
        if now in p:
            now+=1
        else:
            ans1=now
            break
    now=x
    while now>=p[0]:
        if now in p:
            now-=1
        else:
            ans2=now
            break
if abs(x-ans1)>=abs(x-ans2):
    print(ans2)
else:
    print(ans1)

Measured memory_bytes: 9224