akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        int N = sc.nextInt();
        System.out.println(gcd(M,N));
    }   

    public static int gcd(int M,int N){
        int x = M > N ? M : N;
        int y = M > N ? N : M;
        if (y == 1) return 1;
        if(x % y == 0){
            return y;
        }else{
            return gcd(y,x % y);
        }
    }
}


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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int N, Q;
    cin >> N >> Q;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<pair<int, int>> X(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> X[i].first;
        X[i].second = i;
    }
    sort(begin(X), end(X));
    reverse(begin(X), end(X));
    vector<long long> preA(N, 0), evenA(N, 0), oddA(N, 0);
    preA[0] = evenA[0] = A[0];
    for (int i = 1; i < N; ++i) {
        preA[i] = A[i] + preA[i - 1];
        evenA[i] = (i % 2 == 0 ? A[i] : 0) + evenA[i - 1];
        oddA[i] = (i % 2 == 0 ? 0 : A[i]) + oddA[i - 1];
    }
    vector<long long> res(Q);
    for (int q = 0, i = N - 3, j = N - 2; q < Q; ++q) {
        while (i >= 0 && j >= 0 && abs(A[i] - X[q].first) <= abs(A[j] - X[q].first)) {
            i -= 2;
            --j;
            //cout << "move" << endl;
        }
        /*cout << "for " << X[q] << endl;
        for (int k = 0; k < N; ++k) {
            if (k <= i) {
                cout << "abw " << A[k] << endl;
            } else if (k <= j) {
                cout << "aoki " << A[k] << endl;
            } else {
                cout << "taka " << A[k] << endl;
            }
        }*/
        long long cur = preA[N - 1] - (j < 0 ? 0 : preA[j]);
        if (i % 2 == 0) {
            cur += (i < 0 ? 0 : evenA[i]);
        } else {
            cur += (i < 0 ? 0 : oddA[i]);
        }
        res[X[q].second] = cur;
    }

    for (long long x : res) {
        cout << x << "\n";
    }

    return 0;
}

Measured memory_bytes: 6016
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

double x[111], y[111], z[111], r[111];
double d[111][111];
int visit[111];

int main(){
	int n;
	while(cin>>n, n){
		memset(visit, 0, sizeof(visit));
		REP(i,n)cin>>x[i]>>y[i]>>z[i]>>r[i];
		REP(i,n)FOR(j,i+1,n)d[i][j] = d[j][i] = max(sqrt(pow(x[i]-x[j], 2.0)+pow(y[i]-y[j], 2.0)+pow(z[i]-z[j], 2.0))-r[i]-r[j], 0.0);
		priority_queue<pair<double, PII>, vector<pair<double,PII> >, greater<pair<double,PII> > > q;
		visit[0]=1;
		FOR(i,1,n)q.push(MP(d[0][i], MP(0, i)));
		double ret = 0.0;
		int cnt = n-1;
		while(!q.empty()){
			pair<double, PII> tmp;
			tmp = q.top();
			q.pop();
			if(visit[tmp.second.second])continue;
			ret += tmp.first;
			if(--cnt==0)break;
			visit[tmp.second.second] = 1;
			REP(i,n)if(i!=tmp.second.second && (!visit[i]))q.push(MP(d[tmp.second.second][i], MP(tmp.second.second, i)));
		}
		printf("%.3f\n", ret);
	}
	return 0;
}

Measured memory_bytes: 1532
/*  
	Talkin' to myself and feelin' old
    Sometimes I'd like to quit, nothin' ever seems to fit
    Hangin' around, nothin' to do but frown
    Rainy days and Mondays always get me down
    _________________________
    _________________________
    888 Hours of Solitude
    Quarantine_Day : 37
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;
typedef pair<ll, ll>		pll;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005


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

	int n; cin>>n;
	vi v(n);

	REP(i, n) cin>>v[i];
	int k = 0;
	int ans = 0;
	while(v[k] != 2){
		k = v[k];
		k--;
		ans++;
		if(ans > n) break;
	}
	if(ans > n) cout<<-1<<"\n";
	else cout<<ans+1<<"\n";

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    int n , l;
    cin >> n >> l;
    int sum = 0;
    for(int i = 1 ; i <= n ; i++){
         sum += (l+i-1);
    }
    int ans = 99999999;
    int pr = sum;
    for(int i = 1 ; i <= n ; i++){
         if(abs(sum - sum + (l + i - 1)) < ans){
            ans = abs(sum - sum + (l + i - 1));
            pr = sum - (l + i - 1);
         }
    }
    cout << pr << endl;
    return 0; 
 	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class BEL{
	public:
	struct edge{
		Def to,cost;
	};
	vector<vector<edge> >G;
	Def n;
	vector<Def>d;//distance
	BEL(Def size){
		n=size;
		G=vector<vector<edge> >(n);
	}
	void add_edge(Def a,Def b,Def c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
//		G[b].pb(ee);
	}
	int bel(Def s){// return 1 -> negative cycle
		d=vector<Def>(n,inf);
		d[s]=0;
		rep(i,n+1){
			rep(j,n)rep(k,G[j].size()){
				edge e=G[j][k];
				if(d[j]!=inf&&d[e.to]>d[j]+e.cost){
					if(i==n)return 1;
					d[e.to]=d[j]+e.cost;
				}
			}
		}
		return 0;
	}
};
int main(){
	int n,m,r;
	cin>>n>>m>>r;
	BEL bel(n);
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		bel.add_edge(a,b,c);
	}
	int a=bel.bel(r);
	if(a)cout<<"NEGATIVE CYCLE"<<endl;
	else rep(i,n)if(bel.d[i]>inf/2)cout<<"INF"<<endl;
	else cout<<bel.d[i]<<endl;
}

Measured memory_bytes: 3140
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  os << "--------" << std::endl;
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

// DIGNUM
std::vector<ll> dignum(ll x) {
  if (x == 0) return {0};
  std::vector<ll> res;
  while (x) {
    res.push_back(x % 10);
    x /= 10;
  }
  std::reverse(res.begin(), res.end());
  return res;
}

// FAIL
void fail(){ print(-1); std::exit(0); }
//void fail(){ print("No"); std::exit(0); }

void solve()
{
  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);
  std::vector< ll > vb(N, 0LL);

  ll cnt = 0LL;
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i] >> vb[i];
  }

  std::reverse(va.begin(), va.end());
  std::reverse(vb.begin(), vb.end());

  for (ll i = 0; i < N; i++) {
    ll a = va[i];
    ll b = vb[i];

    if ((a + cnt) % b != 0) {
      cnt += b - (a + cnt) % b;
    }
  }

  print(cnt);
  return;
}

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

  solve();
  return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
 
int main()
{
  int a,b,n,i,k,x,s=0;
  scanf("%d %d %d",&n,&a,&b);
  for(i=1;i<=n;i+=1)
  {
    k = i;
    x = k%10;
    k = k/10;
    x += k%10;
    k = k/10;
    x += k%10;
    k = k/10;
    x += k%10;
    k = k/10;
    x += k%10;
    if(x>=a && x<= b)
      s += i;
  }
  printf("%d\n",s);
  return 0;
}

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

int main() {
    int n;cin>>n;
    int copy=n;
    int sum=0;
    while(1){
        if(copy==0) break;
        else{
            sum+=copy%10;
            copy/=10;
        }
    }
    if(n%sum==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
/*
	watch me go
*/

#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;*/
#define int long long
//#define d long double
#define pii pair<int,int>
#define bitcount(a) __builtin_popcountll(a)
#define pb push_back
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod1=998244353;
int const mod=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ******** Using PBDS ********
 /*typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
                os; */

int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}

signed main() 
{ 
    haha
     int h,w;
     cin>>h>>w;
     int dp[h+1][w+1];
     string s[h];
     for(int i=0;i<h;i++)
     cin>>s[i];
     char arr[h+1][w+1];
     init(dp,0);
     for(int i=0;i<=h;i++)
     {
         for(int j=0;j<=w;j++)
         {
             if(i==0 || j==0)
             arr[i][j]='.';
             else
             arr[i][j]=s[i-1][j-1];
         }
     }
     for(int i=1;i<=h;i++)
     {
         for(int j=1;j<=w;j++)
         {
             if(arr[i][j]=='.')
             {
                 if(i==1 && j==1)
                 dp[i][j]=1;
                 dp[i][j]+=dp[i-1][j];
                 dp[i][j]%=mod;
                 dp[i][j]+=dp[i][j-1];
                 dp[i][j]%=mod;
                 
             }
         }
     }
     cout<<dp[h][w];
    
    
    
   
   
} 


Measured memory_bytes: 10112
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int T = sc.nextInt();
		int S = sc.nextInt();
		solve(D, T, S);
	}

	private static void solve(int d, int t, int s) {
		// TODO Auto-generated method stub
		//formula : d = vt
		if (s == 0) {
			if (d == 0) System.out.println("Yes");
			else System.out.println("No");
			return;
		}
		int res = s * t;
		if (res >= d) System.out.println("Yes");
		else System.out.println("No");
	}

}


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

int main() {
  string s;
  cin >> s;
  int start,end=0;
  bool start_flag=true;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A' && start_flag){
      start=i;
      start_flag=false;
    }
    if(s[i]=='Z'){
      end=i;
    }
  }
  cout << end-start+1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include <limits.h>
using namespace std;
int main()
{
    // 全何種類で何種類買うか取得
    int n=1,k;
    cin >> n >> k;
    // 値段を格納する配列を作成
  	int *p = (int *)malloc(sizeof(int)*n);
  	if (!p) {
    	cout << "malloc failed";
  	}
  	//値段の格納
    for(int i=0;i<n;i++){
    	cin >> p[i];
    }
  	//k個の最安値を抽出
  	int num=0,min;
  	for(int i=0;i<k;i++){
      min = INT_MAX;
      for(int j=i;j<n;j++){
        if(min>p[j]){
          min = p[j];
          num = j;
        }
      }
      p[num] = p[i];
      p[i] = min;
    }
  	//cout << p[0] << p[1] << p[2] << p[3] << p[4] << endl;
    // 出力
  	int sum=0;
  	for(int i=0;i<k;i++){
      sum += p[i];
    }
    cout << sum << endl;
  	free(p);
    return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  ll N, X;
  string S;
  cin >> N >> X;
  cout << 6 - N - X << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
int main(int argc, char const *argv[]) {
    ll N, T;
    std::cin >> N >> T;
    ll c[N];
    ll t[N];
    for (size_t i = 0; i < N; i++) {
        std::cin >> c[i] >> t[i];
    }

    ll ans = 100000;
    for (size_t i = 0; i < N; i++) {
        if (t[i] <= T && c[i] < ans) {
            ans = c[i];
        }
    }
    if (ans == 100000) {
        std::cout << "TLE" << '\n';
    } else {
        std::cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 384
a,b,c=map(int,input().split())
if a==b and a==c and a%2==0:
    print(-1)
else:
    ans=0
    while a%2==0 and b%2==0 and c%2==0:
        x=a
        y=b
        z=c
        a=(y+z)//2
        b=(x+z)//2
        c=(x+y)//2
        ans+=1
    print(ans)


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m, K;
    cin >> m >> K;
    if (K >= (1 << m)) {
        cout << -1 << endl;
        return 0;
    }

    if (m == 0) {
        cout << "0 0" << endl;
        return 0;
    } else if (m == 1) {
        if (K == 1) {
            cout << -1 << endl;
        } else {
            cout << "0 0 1 1" << endl;
        }
        return 0;
    }

    vector<int> ans;
    ans.push_back(K);
    for (int i = 0; i < (1 << m); i++) {
        if (i == K) continue;
        ans.push_back(i);
    }
    ans.push_back(K);
    for (int i = (1 << m) - 1; i >= 0; i--) {
        if (i == K) continue;
        ans.push_back(i);
    }

    cout << ans[0];
    for (int i = 1; i < ans.size(); i++) {
        cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}

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

#define int ll
#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define pb push_back
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
constexpr int inf = 1ll<<61;

struct node {
  ll v, d;
  node(ll _a, ll _b):v(_a),d(_b){}
  bool operator<(const node &n) const { return d > n.d; }
};
struct edge {
  ll to, d;
  edge(ll _to, ll _d):to(_to),d(_d){}
};
class dijkstra{
public:
  ll ans;

  dijkstra(ll s,ll t,vector<vector<edge>> &g,vector<vector<edge>> &f){ // sからtへの最短経路
    vector<vector<vector<edge>>> G(2);
    G[0] = move(g);
    G[1] = move(f);
    vvi dist(2,vi(G[0].size(),inf));
    vector<vector<bool>> visit(2,vector<bool>(G[0].size(),false));
  
    vector<priority_queue<node>> que(2);
    que[0].push(node(s,0));
    que[1].push(node(t,0));
    dist[0][s] = 0;
    dist[1][t] = 0;
    ll mu = inf;

    while(!que[0].empty() and !que[1].empty()){
      if(que[0].top().d + que[1].top().d >= mu) break;
      ll k = (que[0].top().d > que[1].top().d)?0:1;      
      ll v = que[k].top().v, d = que[k].top().d;
      que[k].pop();

      if(visit[k^1][v]) goto L;
      visit[k][v] = true;

      rep(i, G[k][v].size()){
	auto n = G[k][v][i];
	ll tmp = d + n.d;
	if(dist[k][n.to] > tmp){
	  mu = min(mu, dist[k][v] + n.d + dist[k^1][n.to]);
	  dist[k][n.to] = tmp;
	  que[k].push(node(n.to, tmp));
	}
      }
    }
  L:
    g = move(G[0]);
    f = move(G[1]);

    ans = inf;
    rep(i,g.size()) ans = min(ans, dist[0][i]+dist[1][i]);
  }
};

main(){
  int k; cin >> k;
  vector<vector<edge>> g(k),f(k);
  rep(i,k){
    g[i].pb(edge((i+1)%k,1));
    g[i].pb(edge((i*10)%k,0));
    
    f[(i+1)%k].pb(edge(i,1));
    f[(i*10)%k].pb(edge(i,0));
  }
  dijkstra d(1,0,g,f);
  cout << d.ans+1 << endl;
}

Measured memory_bytes: 18416
#include<bits/stdc++.h>
using namespace std;
#define max1 1000005
#define siz 100000
#define mod 998244353
#define inf 1e18+5
#define ll long long int
#define debug(x) cout<<#x<<" "<<x<<endl
#define jam(x) cout<<"Case #"<<x<<": "
typedef pair<ll,ll> pr;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/
  ll n;
  cin>>n;
  vector<ll> a(n);
  for(ll i=0;i<n;i++)
  {
    cin>>a[i];
  }
  vector<ll> dp(n,0);
  for(ll i=1;i<n;i++)
  {
    if(i==1)
    {
      dp[i]=abs(a[i]-a[i-1]);
    }
    else
    {
      dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    }
  }
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <cmath>

using ll = long long;

//各種nil
template <class T>
constexpr T nil = static_cast<T>(-1);

constexpr int nil_i = nil<int>;
constexpr int nil_ll = nil<ll>;
constexpr double nil_d = nil<double>;

//vector
template <class T>
using vec = std::vector<T>;

void solve()
{
    using namespace std;
    int x;
    cin >> x;

    int ma {};

    int sq = static_cast<int>(sqrt(x));

    for (int i = 1; i <= x; ++i)
        for (int j = 2; j <= 10; ++j)
        {
            int tmp = pow(i, j);
            if (tmp <= x)
            {
                ma = max(ma, tmp);
            }
            else
                break;
        }

    cout << ma << endl;

}

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

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

struct Range{
  long long int l,r;
  Range(const long long int ll,const long long int rr){
    l=ll,r=rr;
    return;
  }
  bool operator <(const Range&ra)const{
    return r<ra.r;
  }
};

signed main() {

  long long int N,M;
  cin>>N>>M;
  vector<Range>range;
  map<long long int,int>m;
  for(int i=0;i<N;i++){
    long long int a,b;
    cin>>a>>b;
    m[a]=0;
    m[b]=0;
    range.push_back(Range(a,b));
  }
  int cnt=0;
  for(auto &i:m){
    i.second=cnt++;
  }
  for(auto &i:range){
    i.l=m[i.l];
    i.r=m[i.r];
   // cout<<"range "<<i.l<<" "<<i.r<<endl;
  }
  vector<vector<Range>>vr(m.size());
  for(auto i:range){
    vr[i.l].push_back(i);
  }
  sort(range.begin(),range.end());
  priority_queue<Range>PQ;
  cnt=0;
  int ans=0;
  for(auto i:vr[0]){
    PQ.push(i);
  }
  M=m[M];
  while(!PQ.empty()){
    auto box=PQ.top();
    PQ.pop();
    for(int i=cnt+1;i<=box.r;i++){
      for(auto j:vr[i]){
        PQ.push(j);
      }
    }
    ans++;
    cnt=box.r;
    if(cnt==M)break;
  }
  cout<<ans<<" ";
  vector<int>sum(m.size());
  for(auto i:range){
    sum[i.l]++;
    sum[i.r]--;
  }
  for(int i=1;i<m.size();i++){
    sum[i]+=sum[i-1];
  }
  sum.pop_back();
 // for(auto i:sum)cout<<i<<endl;
  cout<<N+1-(*min_element(sum.begin(),sum.end()))<<endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;
using Graph = vector<vector<int>>;
int main(){

int h,n;
cin>>h>>n;
int x=0;
for(int i=0;i<n;i++){
    int y;
    cin>>y;
    x+=y;
}
if(x>=h){
    cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}


}

Measured memory_bytes: 3648
// #include <bits/stdc++.h>
#include <iostream> // cin, cout, string
#include <algorithm> // sort, min, max
#include <vector>
#include <utility> // pair, swap
#include <functional>

using namespace std;

// #define int long long

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

using vi = vector<int>;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
// const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i, a, b) for(int i = (a);i < (b);++i)
#define rfor_(i, a, b) for(int i = (b)-1;i >= (a);--i)

#define rep(i, n) for_(i, 0, n)
#define rrep(i, n) rfor_(i, 0, n)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

string S;
int p, s;

bool ym, my;

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

  cin >> S;

  p = (S[0]-'0') * 10 + (S[1]-'0');
  s = (S[2]-'0') * 10 + (S[3]-'0');

  if(1 <= s && s <= 12) {
    ym = (s >= 10 || S[2] == '0');
  }

  if(1 <= p && p <= 12) {
    my = (s >= 10 || S[0] == '0');
  }

  if(ym && !my) cout << "YYMM" << endl;
  else if(!ym && my) cout << "MMYY" << endl;
  else if(ym && my) cout << "AMBIGUOUS" << endl;
  else cout << "NA" << endl;

  return 0;
}


Measured memory_bytes: 256
import collections as c
ip = lambda : map(int, input().split())

#################
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

ans = 0
ans += (N+A-1)//A
bt = ans
# print('------------')
# print(ans)

b = A
for i in [B,C,D,E]:
    if b <= i:
        ans += 1
    else:
        b = i
        ans += (N+i-1)//i - bt +1
        bt = (N+i-1)//i
print(ans)

Measured memory_bytes: 3316
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{
    fastt;

    ll n, m, k, i, j, x, y, p=0, s=0, h=inf, f=0;
    cin>>n;
    ll a[n];
    for(i=0; i<n; i++){
        cin>>a[i];
    }
    sort(a, a+n);
    x=a[0];
    y=a[n-1];
    for(k=1; k<=100; k++){
        s=0;
        for(i=0; i<n; i++){
            s+=(a[i]-k)*(a[i]-k);
        }

        h=min(h, s);

    }
    cout<<h<<endl;
    return 0;
}



Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;

vector<long long int> sum;

bool hantei(int index, long long int key,int left,int right) {
	if (sum[index] - sum[left] >= sum[right] - sum[index])return true;
	else return false;
}

int nibutan(long long int key, int left, int right) {
	int ng = left;
	int ok = right-1;

	while (abs(ok - ng) > 1) {

		int mid = (ng + ok) / 2;

		if (hantei(mid, key, left, right))ok = mid;
		else ng = mid;

	}
	if (ok!=left+1&&abs(sum[right] + sum[left] - 2 * sum[ok]) > abs(sum[right] + sum[left] - 2 * sum[ok - 1]))ok--;
	return ok;
}


int main() {
	//cout << fixed << setprecision(10);
	
	
	long long int n, m=1, a[200006] = {}, b[100005],tmp, in=11451419198109314;
	string str;
	cin >> n;
	sum.push_back(0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum.push_back(a[i] + sum[i - 1]);
	}

	for (int i = 3; i <= n-1; i++) {
		
		tmp = max(sum[i - 1] - sum[nibutan(0, 0, i - 1)], max(sum[n] - sum[nibutan(0, i - 1, n)], max(sum[nibutan(0, 0, i - 1)] - sum[0], sum[nibutan(0, i - 1, n)] - sum[i-1])));
		tmp -= min(sum[i - 1] - sum[nibutan(0, 0, i - 1)], min(sum[n] - sum[nibutan(0, i - 1, n)], min(sum[nibutan(0, 0, i - 1)] - sum[0], sum[nibutan(0, i - 1, n)] - sum[i-1])));
		if (tmp < in) {
			in = tmp;
		}
	}
	cout << in;
}

Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

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

	int a, b, c;
	bool flag = false;
	REP(i, 0, n + 1) {
		REP(j, 0, n - i + 1) {
			int k = n - (i + j);
			if (k < 0) continue;

			int sum = 10000 * i + 5000 * j + 1000 * k;
			if (sum == y) {
				flag = true;
				a = i;
				b = j;
				c = k;
				break;
			}
		}
		if (flag) break;
	}

	if (flag) cout << a << " " << b << " " << c << endl;
	else cout << -1 << " " << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
if a[0] > x:
    ans += a[0]-x
    a[0] = x
for i in range(N-1):
    ac = a[i]+a[i+1]
    if ac > x:
        ans += ac-x
        a[i+1] -= ac-x
print(ans)

Measured memory_bytes: 14060
#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
int comp(const void *a, const void *b){//昇順
    int c = *(int *)a;
    int d = *(int *)b;
    if(c<d) return -1;
    else return 1;
}
int comp2(const void *a, const void *b){//降順
    int c = *(int *)a;
    int d = *(int *)b;
    if(c<d) return 1;
    else return -1;
}
int arraytonum(int x[], int L){
    int ans=0;
    for(int i=0; i<L; i++){
        ans+=x[i];
        ans*=10;
    }
    return ans/10;
}
void cal(int a0, int L){
    int work[L];
    int array[21];
    int count=0;
    while(1){
        array[count]=a0;
        for(int i=L-1; i>=0; i--){
            work[i]=a0%10;
            a0/=10;
        }
        //rep(i,L) printf("%d",work[i]); puts("");
        qsort(work,L,sizeof(int),comp2);
        //rep(i,L) printf("%d",work[i]); puts("");
        int ai=arraytonum(work,L);
        qsort(work,L,sizeof(int),comp);
        int aj=arraytonum(work,L);
        a0=ai-aj;
        //printf("a0=%d\n",a0);
        for(int j=0;j<count;j++){
            if(array[count]==array[j]){
                printf("%d %d %d\n",j,array[count],count-j);
                return;
            }
        }
        count++;
    }
    return;
}
int main(void){
    int a0, L;
    while(1){
        scanf("%d%d", &a0, &L);
        if(a0==0 && L==0) break;
        cal(a0,L);
    }
}


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

int main()
{
    int N;
    std::cin >> N;

    std::vector<double> v(N);
    for (int i=0; i<N; ++i)
        std::cin >> v[i];

    std::sort(v.begin(), v.end()); // 昇順にソート
    double lhs = v[0];
    for (int i=1; i<N; ++i) {
        lhs = (lhs + v[i]) / 2;
    }
    std::cout << lhs << std::endl;
    return 0;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())
W2 = W-1
c = [0] * (W2+1)
cnt = 0
MOD = 10**9 + 7
for bit in range(1 << W2):
    s0 = bit&1
    flg=True
    for i in range(1, W2):
        if (bit>>i)&1 and s0 == 1:
            flg = False
            break
        s0 = (bit>>i)&1
    if flg:
        cnt += 1
        for i in range(W2):
            if (bit >> i)&1:
                c[i] += 1
dp = [[0]*W for _ in range(H+1)]
dp[0][0] = 1
for h in range(H):
    for i in range(W):
        if i != 0:
            dp[h+1][i-1] += dp[h][i]*c[i-1]
            dp[h+1][i-1] %= MOD
        if i != W-1:
            dp[h+1][i+1] += dp[h][i]*c[i]
            dp[h+1][i+1] %= MOD
        dp[h+1][i] += dp[h][i]*(cnt-c[i-1]-c[i])
        dp[h+1][i] %= MOD
print(dp[H][K-1])

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

int n, m, a, b;
int heights[200001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    vector<priority_queue<int>> pqvec(n + 1);

    for (int i = 1; i <= n; i++)
    {
        cin >> heights[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        pqvec[a].push(heights[b]);
        pqvec[b].push(heights[a]);
    }
    int c = 0;
    for (int i = 1; i <= n; i++)
    {
        if (pqvec[i].size() == 0)
        {
            c++;
        }
        else if (heights[i] > pqvec[i].top())
        {
            c++;
        }
    }
    cout << c;
}

Measured memory_bytes: 9540
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int>L(M);
  vector<int>R(M);
  for(int i=0;i<M;i++){
    cin>>L.at(i)>>R.at(i);
  }
  sort(L.begin(),L.end());
  sort(R.begin(),R.end());
  int K;
  K=R.at(0)-L.at(M-1)+1;
  if(K<0){
    K=0;
  }
  else{
  }
  cout<<K<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#define INF 100000000
#define _INF -100000000
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> P;
 
int main() {
	string s; cin >> s;
	s.insert(4, " ");
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

int main(void){
  bool frag = true;
 int n;cin >> n;
 int ab = 0;int a_last = 0;int b_first=0;
 for(int i = 0;i<n;i++){
   string s;cin >> s;
   if(s.at(s.size()-1) == 'A'){
     a_last += 1;
   }
   if(s.at(0) == 'B'){
     b_first += 1;
   }
   if(s.at(s.size()-1)== 'A' and s.at(0) != 'B'){
     frag = false;
   }
   if( s.at(s.size()-1) != 'A' and s.at(0) == 'B'){
     frag = false;
   }
   for(int j = 1;j<s.size()-1;j++){
     if(s.at(j-1) == 'A' and s.at(j) == 'B') ab += 1;
   }
 }
 if(frag == false){
   cout << ab+min(a_last,b_first) << endl;
 }else if(a_last == 0 and b_first == 0){
   cout << ab << endl;
 }else{
   cout << ab+min(a_last,b_first)-1 << endl;
 }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    vector<int> foo(3);
    cin >> n >> foo[0] >> foo[1] >> foo[2];
    vector<int> l(n);
    for(int i = 0; i < n; ++i)  cin >> l[i];

    int limit = 1;
    for(int i = 0; i < n; ++i)  limit *= 4;
    ll ans = 1e+15;
    for(int bit = 0; bit < limit; ++bit){
        vector<vector<int>> use(4);
        int hoge = bit;
        for(int i = 0; i < n; ++i){
            int id = hoge % 4;
            use[id].push_back(i);
            hoge /= 4;
        }
        if(use[0].size() == 0 || use[1].size() == 0 || use[2].size() == 0)  continue;
        
        ll cost = 0;
        for(int i = 0; i < 3; ++i){
            int sz = use[i].size();
            cost += 10 * (sz - 1);
            int LenSum = 0;
            for(int j = 0; j < sz; ++j) LenSum += l[use[i][j]];
            cost += abs(LenSum - foo[i]);
        }
        chmin(ans, cost);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int a,b,c;cin>>a>>b>>c;
  cout << max({a,b,c})*10 + a+b+c-max({a,b,c}) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MAXN 55
#define mod 998244353
#define INF 0x3f3f3f3f
#define ld long double
using namespace std;
ll dp[3][200005];
ll a[200005];
int main(){
    ios::sync_with_stdio(false);
    #define int ll
    int n;
    cin>>n;
     for(int i=1;i<=n;i++){
        cin>>a[i];
     }
    if(n%2==0){

        dp[0][1]=a[1];
        dp[0][2]=a[2];
        dp[0][3]=a[3]+a[1];

       for(int i=4;i<=n;i++){
            if(i%2==0){
                dp[0][i]=a[i]+max(dp[0][i-2],dp[0][i-3]);
            }
            else{
                dp[0][i]=a[i]+dp[0][i-2];
            }
       }
       int ans=max(dp[0][n],dp[0][n-1]);
       cout<<ans<<endl;
    }
    else{
        dp[0][1]=a[1];
        dp[0][2]=a[2];
        dp[1][3]=a[3]+a[1];
        dp[0][3]=a[3];
        dp[0][4]=a[4]+max(a[1],a[2]);


        for(int i=5;i<=n;i++){
            if(i%2==0)dp[0][i]=a[i]+max(dp[0][i-2],dp[1][i-3]);
            else dp[0][i]=a[i]+max(dp[0][i-2],dp[0][i-3]);
           // cout<<dp[0][i]<<' ';
            if(i%2==1&&i!=n){
                dp[1][i]=a[i]+dp[1][i-2];
              //  ans=max(ans,dp[1][i]);
           //     cout<<dp[1][i];
            }
          //  cout<<endl;
            //ans=max(ans,dp[0][i]);
        }
        int ans=max(dp[1][n-2],max(dp[0][n-1],dp[0][n]));
        cout<<ans<<endl;
    }

    return 0;
}


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

int main(void){
    int A, B;
    cin >> A >> B;
    string s;
    cin >> s;
    int check = 0;

    for(int i = 0; i < A+B+1; i++){
        if(s[i] >= '0' && s[i] <= '9')
            check++;
    }

    if(s[A] != '-' || check < A+B)
    cout << "No" << endl;
    else
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
var
	N,K,ans,i,A:Longint;
	cnt:Array[1..200000]of Longint;
	bck:Array[0..200000]of Longint;
begin
	read(N,K);
	for i:=1 to N do begin
		read(A);
		inc(cnt[A]);
	end;
	for i:=1 to N do inc(bck[cnt[i]]);
	for i:=N downto 1 do begin
		while bck[i]>0 do begin
			dec(bck[i]);
			if K>0 then dec(K) else inc(ans,i);
		end;
	end;
	writeln(ans);
end.


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

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

	int est = h[0];
	int ans = 1;
	for(int i=1; i<n; i++){
		if(est <= h[i]){
			est = h[i];
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

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

#define int long long

int N, L[200];

signed main()
{
	cin >> N;
	for (int i = 0; i < N*2; i++) cin >> L[i];
	sort(L, L + N*2);
	int ans = 0;
	for (int i = 0; i < N*2; i += 2) ans += L[i];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
    if(a<b){
	cout<<"a < b"<<endl;
    }else if (a>b){
	cout<<"a > b"<<endl;
    }else{
	cout<<"a == b"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
#include<math.h>
int n;
void koch(double p1x, double p1y, double p2x, double p2y, int c){
  double s_x, s_y, t_x, t_y, u_x, u_y;
  if(c != 0){
    s_x = (2 * p1x + p2x) / 3;
    s_y = (2 * p1y + p2y) / 3;
    t_x = (p1x + 2 * p2x) / 3;
    t_y = (p1y + 2 * p2y) / 3;
    u_x = s_x + (t_x - s_x) * cos(M_PI/3) - (t_y - s_y) * sin(M_PI/3);
    u_y = s_y + (t_x - s_x) * sin(M_PI/3) + (t_y - s_y) * cos(M_PI/3);
 
    koch(p1x, p1y, s_x, s_y, c - 1);
    printf("%f %f\n", s_x, s_y);
    koch(s_x, s_y, u_x, u_y, c - 1);
    printf("%f %f\n", u_x, u_y);
    koch(u_x, u_y, t_x, t_y, c - 1);
    printf("%f %f\n", t_x, t_y);
    koch(t_x, t_y, p2x, p2y, c - 1);
  }
}
 
int main(){
  scanf("%d", &n);
  printf("%f %f\n", 0.0, 0.0);
  koch(0.0, 0.0, 100.0, 0.0, n);
  printf("%f %f\n", 100.0, 0.0);
  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout(n) cout << fixed << setprecision(n)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acosl(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N, M;
int k[20];
int s[20][20];
int p[20];


signed main(){
    cin >> N >> M;
    rep(i, 0, M){
        cin >> k[i];
        rep(j, 0, k[i]) cin >> s[i][j], s[i][j]--;
    }
    rep(i, 0, M) cin >> p[i];

    int ans = 0;
    rep(bit, 0, 1<<N){
        bool f = true;
        rep(i, 0, M){
            int x = 0;
            rep(j, 0, k[i]) if((bit>>s[i][j])&1) x++;
            if((x&1) != p[i]) f = false;
        }
        if(f) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::io::Read;
use std::cmp::Ordering;

fn main(){
	let mut input = String::new();
    io::stdin().read_to_string(&mut input);
    let xs: Vec<u8> = input.split_whitespace().take(4).map(str::parse).map(Result::unwrap).collect();
    println!("{}", match (xs[0] + xs[1]).cmp(&(xs[2] + xs[3])) {
    	Ordering::Less => "Right",
        Ordering::Equal => "Balanced",
        Ordering::Greater => "Left",
    });
}

Measured memory_bytes: 4352
N, X, Y = map(int, input().split())

X -= 1
Y -= 1

def calc(s):
	queue = [s]
	distance = [N + 1] * N
	distance[s] = 0
	while queue:
		cur = queue.pop()
		dist = distance[cur] + 1
		if cur > 0 and distance[cur - 1] > dist:
			queue.append(cur - 1)
			distance[cur - 1] = dist
		
		if cur < N - 1 and distance[cur + 1] > dist:
			queue.append(cur + 1)
			distance[cur + 1] = dist
		
		if cur == X and distance[Y] > dist:
			queue.append(Y)
			distance[Y] = dist
		
		if cur == Y and distance[X] > dist:
			queue.append(X)
			distance[X] = dist
	
	return distance

d_list = [calc(i) for i in range(N)]

#print(d_list)

d_table = [0] * N

for l in d_list:
	for d in l:
		d_table[d] += 1

for k in range(1, N):
	print(d_table[k] // 2)


Measured memory_bytes: 77916
import java.io.*;
import java.util.*;

public class Main {


    private void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        out.println(convertToNegBinary(n));
    }

    private static String convertToNegBinary(long num) {
        if (num == 0) {
            return "0";
        } else {
            StringBuilder result = new StringBuilder();
            while (num != 0) {
                if ((num < 0) && (num % 2 != 0)) {
                    result.insert(0, String.valueOf(Math.abs(num % -2)));
                    num /= -2;
                    num++;
                } else {
                    result.insert(0, String.valueOf(Math.abs(num % -2)));
                    num /= -2;
                }
            }
            return result.toString();
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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


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

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

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

        @Override
        public void close() {

        }
    }


}


Measured memory_bytes: 22228
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		int c = parseInt(sc.next());
		sc.close();
		int ans = c-(a-b);
		if(ans<0)ans=0;
		out.println(ans);
	}
}


Measured memory_bytes: 21588
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,p[maxn],x[maxn][10],ans;
char s[maxn];

int main()
{
	n=read(); scanf("%s",s+1);
	for(int i=n;i>=1;i--)
	{
		rep(j,1,3) x[i][j]=x[i+1][j];
		if(s[i]=='R') p[i]=1,x[i][1]++;
		if(s[i]=='G') p[i]=2,x[i][2]++;
		if(s[i]=='B') p[i]=3,x[i][3]++;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(s[i]==s[j]) continue;
			int t=j+(j-i),q=6-p[i]-p[j];
			if(p[t]==q) ans+=x[j+1][q]-1;
			else ans+=x[j+1][q];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4124