akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
#define MXN 200005
/*
4+4*2+3+4
*/
int main(){
    int n;
    scanf("%d",&n);
    int a[200005];
    for(int i = 1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    sort(a+1,a+n+1);
    int cnt[10005];
    for(int i = 1;i<=n;i++)
        cnt[a[i]]++;
    if(cnt[a[n]]>=2){
        for(int i=a[n];i>=(a[n]+1)/2;i--){
            if(cnt[i]==0){
                printf("Impossible\n");
                return 0;
            }
        }
        for(int  i =(a[n]-1)/2;i>=0;i--){
             if(cnt[i]){
                printf("Impossible\n");
                return 0;
            }
        }
        if(a[n]&1){
            if(cnt[a[n]/2+1]!=2){
                printf("Impossible\n");
                return 0;
            }
        }
        else{
            if(cnt[a[n]/2]!=1){
                printf("Impossible\n");
                return 0;
            }
        }
        printf("Possible\n");
        return 0;
    }
    else{
        printf("Impossible\n");
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

// range max, point assign
pii dat[1<<19];
int N;
void init(int n){
  N = 1;
  while(N<n)N<<=1;
  REP(i,2*N-1)dat[i] = pii(-1,-1);
}
void add(int l,int r,pii val,int a,int b,int k){
  if(r<=a || b<=l)return;
  if(l<=a && b<=r){
    dat[k] = max(dat[k],val);
    return;
  }
  add(l,r,val,a,(a+b)/2,2*k+1);
  add(l,r,val,(a+b)/2,b,2*k+2);
}
void add(int l,int r,pii val){
  if(r<=l)return;
  add(l,r,val,0,N,0);
}
pii get(int x,int a,int b,int k){
  pii ret = dat[k];
  if(a+1==b && a==x)return ret;
  int mid = (a+b)/2;
  if(x<mid){
    return max(ret,get(x,a,mid,2*k+1));
  }else{
    return max(ret,get(x,mid,b,2*k+2));
  }
}
pii get(int x){
  return get(x,0,N,0);
}

vi g[125252];
bool used[125252];
int lft[125252],rig[125252];
int height[125252];

void dfs(int p,int &iter,int h){
  used[p] = true;
  height[p] = h;
  lft[p] = iter;
  iter++;
  REP(i,g[p].size()){
    int to = g[p][i];
    if(used[to])continue;
    dfs(to,iter,h+1);
  }
  used[p] = false;
  rig[p] = iter;
  iter++;
}
int main(){
  while(true){
    int n,q;
    scanf("%d%d",&n,&q);
    if(n==0 && q==0)break;
    REP(i,n){
      g[i].clear();
      used[i] = false;
      lft[i] = n+1;
      rig[i] = -1;
    }
    REP(i,n-1){
      int src = i+1;
      int to;
      scanf("%d",&to);--to;
      g[src].push_back(to);
      g[to].push_back(src);
    }
    init(2*n);
    int iter = 0;
    dfs(0,iter,0);
    add(lft[0],rig[0],pii(height[0],0));
    ll ans = 0;
    while(q--){
      char s[5];
      int x;
      scanf("%s%d",s,&x);
      --x;
      if(s[0]=='M'){
        add(lft[x],rig[x],pii(height[x],x));
      }else{
        pii val = get(lft[x]);
        ans += val.second+1;
      }
    }
    printf("%lld\n",ans);
  }
  return 0;
}

Measured memory_bytes: 17948
m=input()
A=[map(int,raw_input().split()) for _ in range(input())]
X=[]
while A:
  a1,a2=map(set,zip(*A))
  for e in A:
    if e[1] in a2-a1:
      if e[1] not in X: X.append(e[1])
      A.remove(e)
X=list(set(range(1,m+1))-set(X))+X[::-1]

for e in X: print e

Measured memory_bytes: 4232
object Main{
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt()
    var ans = BigDecimal(0)

    (1 to n).foreach(_ =>{
      val x = BigDecimal(sc.next())
      val u = sc.next("JPY|BTC")
      if(u == "BTC") ans += x*BigDecimal(380000.0) else ans += x
    })

    println(ans)
  }
}

Measured memory_bytes: 25420
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    string s; cin >> s;
    int len = s.size();
    vector<int> S(len + 1);
    rep(i, len){
        S[i+1] = S[i];
        if(s[i]=='B')S[i+1]++;
    }
    ll res = 0;
    rep(i, len){
        if(s[i]=='W'){
            res += S[i];
        }
    }
    cout << res << ln;
}



Measured memory_bytes: 4460
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main() 
{
	fast;
	ll W,a,b; cin>>W>>a>>b;
	ll t1=a,t2=a+W,t3=b,t4=b+W;
	if( t3 >= t1 && t3 <= t2  || t4 >= t1 && t4 <= t2)
		cout << 0 << endl;
	else if( t1 >= t3 && t1 <= t4  || t2 >= t3 && t2 <= t4)
		cout << 0 << endl;
	else
	{
		if(t2 > t4)
		{
			cout << t1-t4 << endl;
		}
		else if(t2 < t3)
		{
			cout << t3-t2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Stone_Monument.Run();
        }
    }
    public class Stone_Monument
    {
        public Stone_Monument()
        {
        }
        public static void Run(){
            int a, b;
            string s = Console.ReadLine();
            a = int.Parse(s.Split(' ')[0]);
            b = int.Parse(s.Split(' ')[1]);
            int d = b - a;
            int sum = 0;
            for (int n = d-1; n > 0;n--){
                sum += n;
            }
            sum -= a;
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll LOG = 22;
const ll INF = 1e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll n , A[MAXN] , dp[MAXN][3][2];

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

    for(ll i = 0 ; i < MAXN ; i++){
        for(ll j = 0 ; j < 3 ; j++) dp[i][j][0] = dp[i][j][1] = -INF;
    }
    dp[0][1][0] = 0;

    cin >> n;
    for(ll i = 1 ; i <= n ; i++)    cin >> A[i];
    for(ll i = 1 ; i <= n ; i++){
        for(ll j = 0 ; j < 3 ; j++){
            ll x = (i - 1) / 2 + j - 1 , y = -1;
            if(x < 0 || x > n)  continue;
            if(x == i / 2 + 1)  y = 2;
            if(x == i / 2)  y = 1;
            if(x == i / 2 - 1)  y = 0;
            if(y == -1) continue;
            dp[i][y][0] = max(dp[i - 1][j][0] , dp[i - 1][j][1]);
            if(y != 2)  dp[i][y + 1][1] = dp[i - 1][j][0] + A[i];
            //cout << i << sep << j << sep << y << sep << dp[i][y][0] << sep << dp[i][y][1] << endl;
        }
    }
    cout << max(dp[n][1][0] , dp[n][1][1]) << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 14548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll ans = 100000,n,i;scanf("%lld",&n);
    for(i=0;i<n;i++){
        ans += ans/20;
        if(ans%1000) ans = ans/1000*1000+1000;
    }
    printf("%lld\n",ans);
}


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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int solve() {
    int n;
    map<int, int> M;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        M[a]++;
    }
    // cout << "M:  " << M << endl;
    int m = 1e6 + 1;
    int ans = 0;
    vector<int> B(m, 1);
    for (auto &p: M) {
        int a = p.first;
        if (B[a]) {
            if (p.second == 1)
                ans++;
            for (int i = a ; i < m; i += a) {
                B[i] = 0;
            }
        }
    }
    return ans;
}

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


Measured memory_bytes: 16376
N, H = map(int, input().split())
ablst = [list(map(int, input().split())) for _ in range(N)]
ablst.sort(key=lambda x: x[0])
amax = ablst[-1][0]
ablst.sort(key=lambda x: x[1], reverse=True)
blst = []
for i in range(N):
    if amax <= ablst[i][1]:
        blst.append(ablst[i][1])
    else:
        break

cnt = 0
for i in blst:
    H -= i
    cnt += 1
    if H <= 0:
        break

if H <= 0:
    print(cnt)
else:
    acnt = H // amax
    cnt += acnt
    if H - (amax * acnt) <= 0:
        print(cnt)
    else:
        print(cnt + 1)


Measured memory_bytes: 28928
#include <bits/stdc++.h>
#define fi first
#define se second
#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)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;



int main() {
  int n;
  scanf("%d",&n);
  set<int> s;
  while (1) {
    s.insert(n);
    if (n&1) n = n*3+1;
    else n /= 2;
    if (s.count(n)) {
      cout<<sz(s)+1<<endl;
      return 0;
    }
  }
  return 0;
}






















Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
const static int MAX = 1000;

void showCard(int card[], int n){
    for(int i = 0; i < n - 1; i++){
        cout << card[i] << " ";
    }
    cout << card[n-1] << endl;
}

void insertionSort(int card[], int n){
    int v,j;
    for(int i = 0; i < n ; i++){
        v = card[i];
        j = i - 1;
        while(j >= 0 && card[j] > v){
            card[j+1] = card[j];
            j--;
        }
        card[j+1] = v;
    showCard(card,n);
    }
}

int main(){
    
    int n, card[MAX];
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> card[i];
    }
    insertionSort(card,n);

    return 0;
}


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

int main() {
  vector<int64_t> v = {2, 1};
  rep(i, 85) v.push_back(v[i]+v[i+1]);
  int n;
  cin >> n;
  cout << v[n] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<time.h>
#include<math.h>
#include<stdlib.h>
#include<iostream>
#include<iomanip>
#include<utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define mp make_pair
#define rep(a,b,c) for(int a=1;a<=b;a+=c)
#define repp(a,b,c,d) for(int a=b;a<=c;a+=d)

const double PI=acos(-1);
const double EPS=1e-12;
const int MOD=1e9+7;
const int INF=1<<30;


using namespace std;

map<string,bool>m;

int main(){
	ios::sync_with_stdio(false);cin.tie(NULL);	cout.tie(NULL);
	int n,k,t,tt;
	cin>>n>>k;
	string s;
	int cnt[30];
	rep(i,26,1){
		cnt[i]=0;
	}
	rep(i,n,1){
		cin>>s;
		if(!m[s]){
			cnt[s[0]-'A'+1]++;
			m[s]=true;
		}
	}
	sort(cnt+1,cnt+27);
	reverse(cnt+1,cnt+27);
	priority_queue<int>pq;
	queue<int>q;
	rep(i,26,1){
		if(cnt[i]>0){
			pq.push(cnt[i]);
		}
	}
	t=0;
	tt=0;
	rep(j,n,1){
		while(!pq.empty()){
			int x=pq.top();
			pq.pop();
			if(x>0){
				tt++;
				x--;
				if(x>0)q.push(x);
				if(tt==k){
					t++;
					tt=0;
					break;
				}
			}
			
		}
		while(!q.empty()){
			if(q.front()!=0){
				pq.push(q.front());
			}
			q.pop();
		}
		tt=0;
	}
	cout<<t<<endl;
	return 0;
}



Measured memory_bytes: 1408
/*
      author : nishi5451
      created: 11.08.2020 01:14:46
*/

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


int main(){
    string s,t;
    cin >> s >> t;
    if(s[0]==t[2] && s[1]==t[1] && s[2]==t[0])
        cout << "YES" << endl;
    else cout << "NO" << endl;
    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 rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

void solve() {
  string s; ll k; cin >> s >> k;
  rep(i,s.size()) {
    if (s[i] != '1') {
      cout << s[i] << endl;
      return;
    }
    if (i+1 == k) {
      cout << s[i] << endl;
      return;
    }
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
//typedef pair<ll, P> T;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define revrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define f first
#define s second
#define pb push_back

ll mod = 1000000007;
const ll INF = 100000000000010000;
//const ull B = 998244353;

ll bit[200010];
//ll kai[3010];
ll Cnt[1000010];

//void pres(double A, ll x = 20) { printf("%.20f\n", x); }



/*ll sum(ll i)
{
	//i += 1;
	ll t = 0;
	while (i > 0)
	{
		t += bit[i];
		i -= i & -i;
	}
	return t;
}

void add(ll i, ll x)
{
	//i += 1;
	while (i <= 200005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

/*`ll SAIKI(ll S) {
	for (ll T = S; ; T = (T - 1) & S) {

	}
}*/



void test() {
	cout << "888888888888888888888888" << endl;
}

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll k) {
	x %= mod;
	ll res = 1;
	while (k > 0) {
		if (k % 2) {
			res *= x; res %= mod;
		}
		x *= x; x %= mod;
		k /= 2;
	}
	return res;
}

ll div_mod(ll x) {
	return pow_mod(x, mod - 2);
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXcomb; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod%i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * finv[k] % mod * finv[n - k] % mod;
}

void makePrimeList(ll x) {
	ll X = x;
	for (ll j = 2; j * j <= x; j++) {
		ll cnt = 0;
		while (X % j == 0) {
			cnt++;
			X /= j;
		}
		if (cnt) {
			Cnt[j] = max(Cnt[j], cnt);
		}
	}
	if (X != 1) Cnt[X] = max(Cnt[X], 1LL);
}

ll N, K;
ll A[200010], F[200010];
ll ans;
ll tmp[200010];

bool judge(ll tm) {
	ll k = K;
	rep(i, N) {
		tmp[i] = tm / F[i];
		//cout << tmp[i];
		if (tmp[i] < A[i]) {
			k -= A[i] - tmp[i];
		}
		if (k < 0) return false;
	}
	return true;
}

void solve() {
	cin >> N >> K;
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> F[i];
	sort(A, A + N);
	reverse(A, A + N);
	sort(F, F + N);
	
	ll lb = -1, ub = A[0] * F[N - 1];
	while (lb + 1 < ub) {
		ll mid = (lb + ub) / 2;
		if (judge(mid)) ub = mid;
		else lb = mid;
	}
	cout << ub << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	ll N;
	cin >> N;
}

Measured memory_bytes: 6400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Comparator;
import java.util.Deque;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }
  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int k = sc.nextInt();
    PriorityQueue<String> pq = new PriorityQueue<>(new Comparator<String>() {
      @Override
      public int compare(String o1, String o2) {
        if (o1.length() != o2.length()) return o1.length() - o2.length();
        long l1 = Long.parseLong(o1);
        long l2 = Long.parseLong(o2);
        if (l1 < l2) return -1;
        if (l1 > l2) return 1;
        return 0;
      }
    });
    for (int i = 0; i < 10; i++) {
      pq.add(String.valueOf(i));
    }
    while (true) {
      String val = pq.poll();
      int leftDigit = Integer.parseInt(String.valueOf(val.charAt(0)));
      if (leftDigit != 0) k--;
      if (k == 0) {
        System.out.println(val);
        return;
      }
      pq.add(leftDigit + val);
      if (leftDigit != 0) {
        pq.add(String.valueOf(leftDigit - 1) + val);
      }
      if (leftDigit != 9) {
        pq.add(String.valueOf(leftDigit + 1) + val);
      }
    }
  }
}

Measured memory_bytes: 60404
#include <iostream>

using ll=long long int;

constexpr ll mod = 1e9+7;
constexpr int MAX_K = 1e5;


int n,k;

ll g[MAX_K];

//n乗
ll pow(ll x){

    ll res=1;

    for(int i=0;i<30;++i){
        if((1<<i)&n)
            res=res*x%mod;
        x=x*x%mod;
    }

    return res;
}

int main(){

    std::cin>>n>>k;

    for(int i=k;i>=1;--i){
        g[i]=pow(k/i);
        for(int j=2;j*i<=k;++j)
            g[i]=(g[i]-g[j*i])%mod;
    }

    ll ans=0;

    for(ll i=1;i<=k;++i)
        ans=(ans+g[i]*i)%mod;

    std::cout<<ans<<std::endl;

    return 0;
}

Measured memory_bytes: 4416
N, L = [int(_) for _ in input().split()]

left = L
right = L + N - 1

sum = 0
for i in range(left, right + 1):
    sum += i

ans = sum
if left * right > 0:
    if abs(left) < abs(right):
        ans -= left
    else:
        ans -= right

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int N; cin >> N;
    vector<int> M(N);
    REP(i, N) cin >> M[i];
    whole(sort, M);

    int res = 0;

    for(int mid = N - 1; mid >= 0; mid--){
        for(int low = mid - 1; low >= 0; low--){
            auto itr = whole(lower_bound ,M, M[mid] + M[low]);
            int ng = distance(itr, M.end());
            res += (N - 1 - mid) - ng;
        }
    }

    cout << res << endl;


}

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

int main() {
 long long N,X,Ans=0,now=0;
  cin>>N;
  rep(i,N){cin>>X;
          if(X<now){Ans+=now-X;}else{now=X;}
          }
  cout<<Ans<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

struct mint {
	ll x;
	mint(ll x = 0) :x(x% mod) {}
	mint& operator+=(const mint a) {
		(x += a.x) %= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		(x += mod - a.x) %= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
};

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	vector<ll> color(3, 0);
	vector<ll> dp(n + 1, 0);
	dp[0] = 1;
	color[0]++;
	if (a[0] != 0) {
		dunk(0);
		return 0;
	}
	rrep(i, n) {
		bool elf = false;
		ll cnt = 0;
		rep(j, 3) {
			if (a[i] == color[j]) {
				cnt++;
				if (elf) continue;
				color[j]++;
				elf = true;
			}
		}
		dp[i] = (dp[i - 1] * cnt) % mod;
	}
	dp[n - 1] = (dp[n - 1] * 3) % mod;
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	int a[n];
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	int cnt=0;
	double x=sum/(double)(4*m);
	for(int i=0;i<n;i++){
		if(a[i]>=x){
			cnt++;
		}
	}
	if(cnt>=m){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
n,k,c = map(int,input().split())
s = "x" + input()

l = []
i = 1 
# 前から貪欲
while len(l) < k:
    if s[i] == "o":
        l.append(i)
        i += c+1
    else:
        i += 1

# 後ろから貪欲
r = []
i = n

while len(r) < k:
    if s[i] == "o":
        r.append(i)
        i -= (c+1)
    else:
        i -= 1

r = r[::-1]
for i in range(len(l)):
    if l[i] == r[i]:
        print(l[i])

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

bool noPrime[1111111];
void makeIsp(){
    noPrime[0] = noPrime[1] = true;
    for(int i = 2;i < 1111111;i++){
        if(noPrime[i])continue;
        for(int j = 2 * i;j < 1111111;j += i){
            noPrime[j] = true;
        }
    }
}

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

    ll n;cin >> n;
    ll ans = 0;
    vector<ll> v(n);
    REP(i, n){
        cin >> v[i];
        if(v[i] > 1)ans = max(ans, v[i]);
    }

    REP(i, 1111111){
        if(noPrime[i])continue;
        ll now = 0;
        REP(j, n){
            if(v[j] % i == 0)now += v[j];
        }
        ans = max(ans, now);
    }

    REP(i, n){
        ll now = 0;
        if(v[i] == 1)continue;
        REP(j, n){
            if(v[j] % v[i] == 0)now += v[j];
        }
        ans = max(ans, now);
    }

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



Measured memory_bytes: 4300
#include <iostream>
#include <vector>
#include <sstream>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;


int main()
{
	const string src = "Hoshino";
	const string des = "Hoshina";

	int n;
	string in;
	getline (cin, in );
	stringstream ss (in );
	ss >> n;
	vector <string> str (n );
	rep (i, n ){
		getline (cin, str[i] );
	} // end rep
	rep (i, n ){
		while (str[i].find (src ) != string::npos ){
			 str[i] = str[i].replace (str[i].find (src ), des.length(), des );
		} // end while
	} // end 
	rep (i, n ){
		cout << str[i] << endl;
	} // end rep
		
	return 0;
}

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

using namespace std;

int n,m,fa[605],sz[605],in[605],out[605];
bool fl[605];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void link(int u,int v){sz[v]++;if(u==v)return;fa[u]=v,sz[v]+=sz[u];}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<=2*m;i++)fa[i]=i;
	for(int i=1,a,b,c,d,l,r;i<=n;i++){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		l=c?-c:a,r=d?d:-b;
		in[r+m]++,out[l+m]++;
		link(find(l+m),find(r+m));
	}
	for(int i=0;i<=2*m;i++){
		if(i<m&&in[i]<out[i])puts("NO"),exit(0);
		if(i>m&&in[i]>out[i])puts("NO"),exit(0);
		if(in[i]!=out[i])fl[find(i)]=true;
	}
	for(int i=0;i<=2*m;i++)if(sz[i]&&!fl[find(i)])puts("NO"),exit(0);
	puts("YES");
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int A[N];
  int B[N];
  for (int i=0;i<N;i++){
    cin >> A[i] >> B[i];
  }
  sort(A,A+N);
  sort(B,B+N,greater<>());
  long long ans=A[0];
  for (int i=1;i<N;i++){
    ans+=min(A[i]-A[i-1] , B[i-1]-B[i]);
  }
  ans+=B[N-1];
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

int main(){
    int n;
    cin >> n;
    int m=0;
    bool flg=false;
    
    for(int i=0;i<100;i++){
        for(int j=0;j<100;j++){
            m=i*4+j*7;
            if(n==m) {
                flg=true;
                break;
            }
        }
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
main(){
  int m,f,r,d=0,e=0;
  while(1){  
  cin >> m >> f >> r ;
  d=m+f;


  if(m==-1 && f==-1 && r==-1)break;
  else if(m==-1 || f==-1){
    cout <<"F\n";
  }
  else if(d>=80 ){
      cout<<"A\n";
    }
  else if(d>=65 && d<80){
      cout<<"B\n";
    }
  else if(d>=50 && d<65){
      cout<<"C\n";
    }
  else if(d>=30 && d<50){
      if(r>=50){
	cout<< "C\n";
      }

      else cout<< "D\n";
    }
  else if(d<30){
 cout << "F\n";
  }
 d=0;
  }
    
  
}

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

int main(){
  int N;
  cin >> N;
  vector<string> blue(N);
  for (int i = 0; i < N; i++){
    cin >> blue.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> red(M);
  for (int i = 0; i < M; i++){
    cin >> red.at(i);
  }
  
  vector<int> counter(N);
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      if (blue.at(i) == blue.at(j)){
        counter.at(i)++;
      }
    }
    for (int j = 0; j < M; j++){
      if (blue.at(i) == red.at(j)){
        counter.at(i) -= 1;
      }
    }
  }
  
  int answer = 0;
  for (int i = 0; i < N; i++){
    if (counter.at(i) > answer){
      answer = counter.at(i);
    }
  }
  
  cout << answer << endl;
   
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

vi g[MAXN];

int v[MAXN];

int used[MAXN];

set<int> st1, st2;

void dfs(int s){
	used[s] = 1;
	st1.insert(s);
	st2.insert(v[s]);
	REP(i, 0, SZ(g[s])){
		int to = g[s][i];
		if (!used[to]){
			dfs(to);
		}
	}
}

void solve(){
	int n, m;
	scanf("%d%d", &n, &m);
	REPN(i, 1, n){
		scanf("%d", &v[i]);
	}
	REP(i, 0, m){
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].pb(b);
		g[b].pb(a);
	}
	int ans = 0;
	REPN(i, 1, n){
		if (used[i]){
			continue;
		}
		if (SZ(g[i]) == 0){
			ans += (v[i] == i);
			used[i] = 1;
		} else if (SZ(g[i]) == 1 && SZ(g[g[i][0]]) == 1){
			int a = i, b = g[i][0];
			if (v[a] == a && v[b] == b || v[b] == a && v[a] == b){
				ans += 2;
			} else if (v[a] == a || v[a] == b || v[b] == a || v[b] == b){
				ans += 1;
			}
			used[a] = used[b] = 1;
		} else {
			st1.clear();
			st2.clear();
			dfs(i);
			FA(it, st1){
				if (st2.find(*it) != st2.end()){
					ans++;
				}
			}
		}
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 18944
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string S;
    cin >> S;

    vector<string> day = {"", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
    auto it = find(day.begin(), day.end(), S);
    cout << distance(day.begin(), it) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
 long long int a,b,N,M,t;
long long int gcd,lcm;
  while (scanf("%lld %lld",&N,&M)!=EOF)
  {
  a=N;
  b=M;
 while(b!=0){
    t=b;
    b=a%b;
    a=t;
  }
  gcd=a;
  lcm=(N*M)/gcd;
printf("%lld %lld\n",gcd,lcm);
  }
  return 0;
}

Measured memory_bytes: 596
def dict_order(l): # l=list(1,...,nの順列)
    import math 
    n = len(l)
    order = 0 # lの辞書式順序の番号
    used = [0]*n
    for i in range(n):
        order += (l[i]-1-sum(used[:l[i]]))*math.factorial(N-1-i)
        used[l[i]-1] += 1
    return order # lの辞書式順序の番号
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
p = dict_order(P)
q = dict_order(Q)
print(abs(p-q))


Measured memory_bytes: 38256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i, s, n) for(int i=(s); i<=(n); ++i)
#define outl(x) cout<< (x) << '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef const int let;

int V, E;
vector <int> G[10005];
bool vis[10005];
vector <int> out;

void bfs(let s, int *indeg)
{
   queue <int> que; que.emplace(s);
   ++indeg[s];
   while (!que.empty()) {
      int u = que.front(); que.pop();
      out.emplace_back(u);
      for(let x : G[u])
         if( --indeg[x] == 0 && !vis[x]++ ) que.emplace(x);
   }
}

void topologial_sort()
{
   static int indeg[10005] = {};
   rep(i, V)
      for(let x: G[i]) ++indeg[x];
   rep(i, V)
      if (indeg[i] == 0 && !vis[i]) bfs(i, indeg);

   for_each(out.cbegin(), out.cend(), [](let x) { outl( x ); });
}

signed main()
{
   cin.tie(0), ios::sync_with_stdio(false);
   cin >> V >> E;

   while(E--) {
      int s, t;
      cin >> s >> t;
      G[s].emplace_back(t);
   }

   topologial_sort();
}





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

int main(){
  int N,K;
  vector<long> h;
  long num;
  long long cnt = 0;
  cin >> N >> K;
  
  for(int i = 0;i < N;i ++){
    cin >> num;
    h.push_back(num);
  }
  sort(h.begin(),h.end());
  for(int j = 0;j < N-K;j ++)cnt += h[j];
  
  cout << cnt;
  
}

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

#define getNum(i) scanf("%d", &(i))
#define MODULO 1000000007l
#define INF 100000000
#define FOR(i,j,k) for(int (i)=(j);(i)<=(k);(i)++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
typedef long long ll;

const int maxn = 1e5 + 10;

int main() {

#ifdef CONTEST
    freopen("input.in", "r", stdin);
#endif
    IOS
    int n;
    cin >> n;
    vector<int> a(n);
    FOR(i,0,n-1) cin >> a[i];
    sort(a.begin(), a.end());
    int cnt = 1;
    FOR(i,0,1e5+10) {
        vector<int>::iterator st = lower_bound(a.begin(), a.end(), i-1);
        vector<int>::iterator nd = prev(upper_bound(a.begin(), a.end(), i+1));
        if (nd > st) {
            cnt = max(cnt, static_cast<const int &>(nd - st + 1));
        }
    }
    cout << cnt << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
  	for(i=0;i<5;i++)
    {
     	cin>>j;
      if(j==0)
      {
       cout<<i+1;
        return;
      }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
   	t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[(int)2e5 + 100];
int main(){
	ll n;
	cin>>n;
	ll arr[(int)2e5 + 100];
	for(int i = 1;i<=n;i++)cin>>arr[i];
	for(int i = 1;i<=n + 5;i++)dp[i] = (long long)1e9;
	dp[1] = 0;
	for(int i = 1;i<=n;i++){
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(arr[i] - arr[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(arr[i] - arr[i + 2]));
	}
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1792
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

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

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> xy(N, vector<int>(2));
  for (int i = 0; i < N; i++) {
    cin >> xy[i][0] >> xy[i][1];
  }
  long double ans = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      long double d =
          sqrtl(powl(xy[i][0] - xy[j][0], 2) + powl(xy[i][1] - xy[j][1], 2));
      ans += d;
      // cout << i << " " << j << " " << d << endl;
    }
  }
  cout << setprecision(15) << ans * 2 / N << endl;

  return 0;
}

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


void solve(long long N, std::vector<long long> P, std::vector<long long> Q){
    vector<ll> v;
    for(int i = 0;i < N;i++)v.push_back(i+1);
    int a;
    int b;
    int cnt = 1;
    do {
        if(v == P){
            a = cnt;
        }
        if(v == Q){
            b = cnt;
        }
        cnt++;
    }while(next_permutation(v.begin(), v.end()));
    cout<<abs(a-b)<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> P(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&P[i]);
    }
    std::vector<long long> Q(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&Q[i]);
    }
    solve(N, std::move(P), std::move(Q));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimization_level 3
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main(){
	int n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2;
}


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

#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++)

int main(){
  string s;
  cin>>s;
  if(s.size()>=4 && s.substr(0,4)=="YAKI")cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main()
{
	int V, E;
	cin >> V >> E;
	vector<vector<int>> G(V, vector<int>(V, 100000));
	for (int i = 0; i < V; i++) {
		G[i][i] = 0;
	}
	for (int i = 0, s, t; i < E; i++) {
		cin >> s >> t;
		G[s][t] = -1;
	}
	for (int k = 0; k < V; k++) {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) {
				G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
			}
		}
	}
	int flag = 0;
	for (int i = 0; i < V; i++) {
		if (G[i][i] < 0) {
			flag = 1;
		}
	}
	cout << flag << endl;
	return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int A;
int dmin = 100;
  for (int i = 0; i < N; i++) {
    cin >> A;
    int count = 0;
    while (A % 2 == 0) {
      A /= 2;
      count++;
    }
    dmin = min(dmin, count);
  }
  cout << dmin << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;
using ll = long long int;

ll C(ll n) {
    if (n == 0 || n == 1) return 0;
    return (n * (n - 1)) / 2;
}

int main(void) {
    int n; cin >> n;
    vector<vector<char>> str(n, vector<char>(10));
    rep(i, n) {
        rep(j, 10) cin >> str[i][j];
    }
    rep(i, n) sort(str[i].begin(), str[i].end());
    sort(str.begin(), str.end());
    ll sum = 0;
    ll chain = 1;
    rep(i, n - 1) {
        bool t = true;
        rep(j, 10) {
            if (str[i][j] != str[i + 1][j]) t = false;
        }
        if (t) {
            chain++;
        }
        else {
            sum += C(chain);
            chain = 1;
        }
        if (i == n - 2) sum += C(chain);
    }
    cout << sum << endl;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    char[] nums = s.toCharArray();

    int sum = 0;
    for (char num : nums) {
      sum += Integer.parseInt(String.valueOf(num));
    }

    if (sum % 9 == 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

#define LL long long
#define PP std::pair<int,int>
int N;
LL K;
std::vector<PP> H;

int main() {
	std::cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int a, b;
		std::cin >> a >> b;
		H.push_back(std::make_pair(a, b));
	}
	std::sort(H.begin(), H.end());
	for (int i = 0; i < N; i++) {
		if (K <= H[i].second) {
			std::cout << H[i].first << std::endl;
			return 0;
		}
		else {
			K -= (LL)H[i].second;
		}
	}
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    char a;
    cin >> a;

    if ('a' <= a && a <= 'z') puts("a");
    else puts("A");
}

Measured memory_bytes: 3628
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;文字列 -> 整数
(defn Int [s] (Integer/parseInt s))
;文字列 -> 文字列
(defn Str [s] s)

;scanf的なノリで1行をいい感じに読み取る
;定数が重いので注意
(defn input [varTypes]
    (mapv 
        (fn [f s] (f s)) ;文字列sに関数fを適用する
        varTypes         ;適用する関数
        (clojure.string/split 
            (read-line)  ;1行を読み込み
            #" "         ;区切り文字
        )
    )
)

;スペース区切りの整数を受け取る
;速い
(defn inputFast [varType]
    (map
        varType
        (clojure.string/split 
            (read-line)  ;1行を読み込み
            #" "         ;区切り文字
        )
    )
)

(defn floor [a b] (quot a b))
(defn ceil [a b] (floor (- (+ a b) 1) b))
(defn abs [a] (if (> 0 a) (- 0 a) a))


;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


;---main---
(dosync
    (def l1 (input [Str]))
    (def l2 (input [Int]))
    (let [[A] l1] (let [[K] l2]
        (def B (ref (list)))
        (def len (count A))
        (doseq [i (range 0 len)]
            (doseq [j (range 1 6)]
                (if (<= (+ i j) len)
                    (alter B conj (subs A i (+ i j)))
                )
            )
        )
        (alter B distinct)
        (alter B sort)
        (println (nth (deref B) (- K 1)))
    ))
)





Measured memory_bytes: 72348
w = gets.to_i
gets

d = []

for i in 0 ... w
  d[i] = i+1
end

while gets
  a = $_.split(",").map(&:to_i)
  a[0] += -1
  a[1] += -1
  d[a[0]],d[a[1]] = d[a[1]],d[a[0]]
end

puts d



Measured memory_bytes: 6872
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = list(map(int, input()))

    s = 0
    for num in n:
        s += num
        s %= 9

    print("Yes" if s == 0 else "No")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10784
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000007
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;


int main()
{

  int a ,b;
  cin>>a>>b;

  cout<<2*b-a<<endl;
 return 0;
}


Measured memory_bytes: 3592