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

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define sqrt(x) sqrt(abs(x))
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define re return
#define prev PREV
#define next NEXT
#define sz(x) ((int)x.size())

template<typename T> T sqr(T a) { re a * a; }
template<typename T> T gcd(T a, T b) { re b ? gcd(b, a % b) : a; }
template<typename T> T sgn(T a) { re a > 0 ? 1 : (a < 0 ? -1 : 0); }
template<typename T> T abs(T a) { re a > 0 ? a : -a; }

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 100000;

#define FILENAME ""


int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //  freopen(FILENAME ".in", "r", stdin);
    //  freopen(FILENAME ".out", "w", stdout);
    ll n;
    cin >> n;
    vector <ll> a(n + 1), b(n);
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] >= b[i]) {
            ans += b[i];
            a[i] -= b[i];
        }
        else {
            ans += a[i];
            b[i] -= a[i];
            if (a[i + 1] >= b[i]) {
                ans += b[i];
                a[i + 1] -= b[i];
            }
            else {
                ans += a[i + 1];
                a[i + 1] = 0;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
#include <bitset>
using namespace std;
using ll = long long;
 
int main(){
  int n;
  cin >> n;
  vector<int> v(n, 0);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  int cnt = 0;
  if(v[0] == 1 && v[n-1] == n){
    swap(v[n-2], v[n-1]);
    cnt++;
  }
  
  if(v[n-1] == n){
    for(int i = n-1; i > 0; i++){
      if(v[i] == i+1){swap(v[i], v[i-1]); cnt++;}
    }
  }
  else{
    for(int i = 0; i < n-1; i++){
      if(v[i] == i+1){swap(v[i], v[i+1]); cnt++;}
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b);
#define chmin(a, b) (a)=min(a, b);
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/




int main(void) {
  ll i, j, k;
  
  ll N;
  cin >> N;
  ll a[MAX*2];
  
  for(i=0; i<N; i++) cin >> a[i];
  
  ll f=0;
  if(a[0]) f=1;
  for(i=0; i<N-1; i++) {
    if(a[i+1]-a[i]>1) f=1;
  }
  
  if(f) {pt(-1); return 0;}
  
  ll ans=0;
  for(i=1; i<N; i++) {
    if(a[i-1]+1==a[i]) ans++;
    else ans+=a[i];
    
  }
  
  pt(ans);
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int>g[100001];
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	vector<int>col(n+1);
	queue<int>q;
	q.push(1);
	q.push(n);
	col[1]=1;
	col[n]=2;
	int f,s;
	f=s=1;
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(int i=0;i<g[x].size();i++){
			int y=g[x][i];
			if(col[y]==0){
				q.push(y);
				col[y]=col[x];
				if(col[y]==1)f++;
				else s++;
			}
		}
	}
	if(f>s)cout<<"Fennec";
	else cout<<"Snuke";
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, cnt;

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

	cin >> n;
	int x;
	for (int i = 0; i < n; i++)
	{
		cin >> x;
		cnt += (x & 1);
	}
	cout << (cnt & 1 ? "NO" : "YES") << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
int n, k;
int fruits[1000];
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++) 
		cin>>fruits[i];
	sort(fruits, fruits+n);
	int price=0;
	for(int i=0;i<k;i++) {
		price+=fruits[i];
	}
	cout<<price<<endl;
	
		
}



Measured memory_bytes: 3656
#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn = 1e4 + 5;
int n, a[maxn];

int main() {
	while (scanf("%d", &n) && n != 0) {
		int sum = 0, num = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d", &a[i]);
			sum += a[i];
		}
		sum /= n;
		for (int i = 0; i < n; i++) {
			if (a[i] <= sum)num++;
		}
		printf("%d\n", num);
	}
	return 0;
}


Measured memory_bytes: 2788
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

int main(int argc, char *argv[])
{
  int n, w, d;
  cin >> n >> w >> d;
  vector<pair<int,int>> ps;
  // mapping to the south-west corner 
  auto mapping0 = [](int x, int y) {
    return x - y;
  };
  // mapping in one of four directions
  auto mappingX = [w,d,&mapping0](int x, int y, int dir) {
    switch(dir) {
    case 0 : { // (-1, -1)-direction
      int o = mapping0(x, y);
      return o; // o >= 0 ? o : w + w + d + d + o; // normalization
    }
    case 1 : { // (1, -1)-direction
      int o = mapping0(w-x, y); // flipping in x
      return w - o; // o >= 0 ? w - o : w + (- o);
    }
    case 2 : { // (1, 1)-direction
      int o = mapping0(w-x, d-y); // flipping in x and y
      return w + d + o; // o >= 0 ? w + d + o : w + d + o;
    }
    case 3 : { // (-1, 1)-direction
      int o = mapping0(x, d-y); // flipping in y
      return w + d + w - o; // o >= 0 ? w + d + w - o : w + d + w + -o;
    }
    return -1;
    }
  };
  // mapping to a range
  auto make_range = [w,d,&mappingX](int x, int y, char c) {
    switch(c){
    case 'N': return make_pair(mappingX(x, y, 2), mappingX(x, y, 3));
    case 'E': return make_pair(mappingX(x, y, 1), mappingX(x, y, 2));
    case 'S': {
      int s = mappingX(x, y, 0);
      int e = mappingX(x, y, 1);
      if(s < 0) { // normalize to non-negative
        s += d + d + w + w;
        e += d + d + w + w;
      }
      return make_pair(s, e);
    }
    case 'W': {
      int s = mappingX(x, y, 3);
      int e = mappingX(x, y, 0) + w + w + d + d;
      return make_pair(s, e);
    }
    }
    return make_pair(-10, -10);
  };
  
  for(int i = 0; i < n; i++) {
    int x, y, d;
    char c;
    cin >> x >> y;
    cin >> c;
    ps.push_back(make_range(x, y, c));
  }
  // a desk = a range on walls
  // a lock = a point on walls
  // todo: put points so that every range contains a point

  // sort the ranges
  sort(ps.begin(), ps.end());

  // shrink the region (endpoint ee) by the range r
  auto shrink = [d,w](bool aug, const pair<int,int> &r, int *ee) {
    int s = r.first + (aug ? (d + d + w + w) : 0);
    int e = r.second + (aug ? (d + d + w + w) : 0);
    if(s <= *ee) {
      *ee = min(*ee, e);
      return true;
    }
    return false;
  };
  // locating clocks from i's view
  auto count = [&ps,n,&shrink](const int ii){
    int i = ii;
    int k = 0;
    int cnt = 0;
    while(k < n) {
      int e = ps[i].second;
      k++;
      i = (i + 1) % n;
      while(k < n && shrink(i < ii, ps[i], &e)) {
        i = (i + 1) % n;
        k++;
      }
      cnt++;
    }
    return cnt;
  };

  int cnt = n; // at most n
  // possible starting points
  for(int i = 0; i < n; i++) {
    cnt = min(cnt, count(i));
  }
  cout << cnt << endl;
  return 0;
}




Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
double n,m,d,ans;
int main(){
	cin>>n>>m>>d;
	if (d==0) ans=n; else if (d+d<=n) ans=(d+d)*1+(n-d-d)*2; else ans=n-(d+d-n);
	printf("%.15f\n",(m-1)*ans/n/n);
	return 0;
}

Measured memory_bytes: 256
# ball and box 4
MOD = pow(10,9)+7
from math import factorial
def P(n,r):
    return factorial(n)//factorial(n-r)
def C(n,r):
    return P(n,r)//factorial(r)
def H(n,r):
    return C(n+r-1,r)
n, k = map(int, input().split())

print(H(k,n)%MOD)


Measured memory_bytes: 5668
import sys, re
import math
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-

x = INT()
if x == 0:
    print(0)
else:
    a = math.floor(x / 500)
    b = math.floor((x - (a * 500)) / 5)
    print(a * 1000 + b * 5)

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


int main(){fastio
    ll k;cin>>k;
    queue<ll> q;
    rep(i,1,9){
        q.push(i);
    }
    ll x;
    vector<ll> ans;
    while(true){
        x=q.front();q.pop();
        if(x>pow(10,10))break;
        ans.pb(x);
        if(x%10==0){
            q.push(x*10);
            q.push(x*10+1);
        }else if(x%10==9){
            q.push(x*10+9);
            q.push(x*10+8);
        }else{
            q.push(x*10+(x%10));
            q.push(x*10+(x%10)+1);
            q.push(x*10+(x%10)-1);
        }
    }
    sort(ans.begin(),ans.end());
    cout<<ans[k-1]<<endl;
    
    return 0;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
// typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 998244353;
const lli e3 = 1 << 12;
const lli INF = 1ll << 63;

lli n;
lli a[e5];
unordered_map<lli,lli> cnt;
lli ans = 0;

int main(){
  cin >> n;
  for(lli i = 1;i <= n;i++) cin >> a[i];
  for(lli i = 1;i <= n;i++) a[i] += a[i-1];
  for(lli i = 0;i <= n;i++){
    cnt[a[i]]++;
  }
  for(auto x : cnt){
    ans += x.second*(x.second-1)/2;
  }
  cout << ans << endl;

}


Measured memory_bytes: 10056
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
 ll n,k;
 cin>>n>>k;
 V<V<ll>> b(2*k,V<ll>(2*k,0)),w(2*k,V<ll>(2*k,0));
 for(int i=0;i<n;i++){
     int s,t;char c;
     cin>>s>>t>>c;
     if(c=='B'){
       b[s%(2*k)][t%(2*k)]++;
     }else{
       w[s%(2*k)][t%(2*k)]++;
     }
 }
 for(int i=0;i<2*k;i++){
   for(int j=0;j<2*k-1;j++){
     b[i][j+1]+=b[i][j];
     w[i][j+1]+=w[i][j];
   }
 }
 for(int i=0;i<2*k;i++){
   for(int j=0;j<2*k-1;j++){
     b[j+1][i]+=b[j][i];
     w[j+1][i]+=w[j][i];
   }
 }
 ll ans=0;
 for(int i=0;i<k;i++){
   for(int j=0;j<k;j++){
     ll res1=0,res2=0;
       res1+=b[i][j];
       res1+=w[i][j+k]-w[i][j];
       res1+=b[i][2*k-1]-b[i][j+k];
       res1+=w[i+k][j]-w[i][j];
       res1+=b[i+k][j+k]-b[i+k][j]-b[i][j+k]+b[i][j];
       res1+=w[i+k][2*k-1]-w[i][2*k-1]-w[i+k][j+k]+w[i][j+k];
       res1+=b[2*k-1][j]-b[i+k][j];
       res1+=w[2*k-1][j+k]-w[2*k-1][j]-w[i+k][j+k]+w[i+k][j];
       res1+=b[2*k-1][2*k-1]-b[i+k][2*k-1]-b[2*k-1][j+k]+b[i+k][j+k];

       res2+=w[i][j];
       res2+=b[i][j+k]-b[i][j];
       res2+=w[i][2*k-1]-w[i][j+k];
       res2+=b[i+k][j]-b[i][j];
       res2+=w[i+k][j+k]-w[i+k][j]-w[i][j+k]+w[i][j];
       res2+=b[i+k][2*k-1]-b[i][2*k-1]-b[i+k][j+k]+b[i][j+k];
       res2+=w[2*k-1][j]-w[i+k][j];
       res2+=b[2*k-1][j+k]-b[2*k-1][j]-b[i+k][j+k]+b[i+k][j];
       res2+=w[2*k-1][2*k-1]-w[i+k][2*k-1]-w[2*k-1][j+k]+w[i+k][j+k];
       chmax(ans,max(res1,res2));
   }
 }
 cout<<ans<<"\n";
}


Measured memory_bytes: 66040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    string s;
    cin >> s;
    if (s.substr(0,4) == "YAKI") {
        Yes;
    }else{
        No;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int p[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		int t;scanf("%d",&t);t--;
		p[t]++;
	}
	int ret=0;
	int tw=0;
	for(int i=0;i<110000;i++){
		if(p[i]){
			ret++;
			if(p[i]%2==0)tw++;
		}
	}
	if(tw%2)ret--;
	printf("%d\n",ret);
}

Measured memory_bytes: 512
#include<stdio.h>
 
 int main(){
   int a[110],n,temp;
   int i,count=0; 
   int flag;

   scanf("%d",&n);
   for(i=0;i<n;i++) scanf("%d",&a[i]);
   flag = 1;
   
   while(flag){
     flag = 0;
     for(i=n-1;i>0;i--){
       if(a[i]<a[i-1]){
	 temp = a[i];
	 a[i] = a[i-1];
	 a[i-1] = temp;
	 flag=1;
	 count++;
       }
     }
   }
   for(i=0;i<n;i++){
     printf("%d",a[i]);
     if(i!=n-1) printf(" ");
     else printf("\n");
   }
   printf("%d\n",count);
   
   return 0;
 }



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

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  
  vector<long long> b(n);
  b = a;
  sort(b.begin(), b.end());
  if(b.at(0) == 0){
    cout << 0 << endl;
  }
  else{
    long long ans = 1;
    for(int i = 0; i < n; i++){
      if(a.at(i) <= 1000000000000000000 / ans){
        ans = a.at(i) * ans;
      }
      else{
        ans = -1;
        break;
      }
    }
    cout << ans << endl;
  }
}

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

using namespace std;

int main(void) {

    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<int> res;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        for (int j = 0, size = res.size(); j < size; ++j) {
            res.push_back(a + res[j]);
        }
        res.push_back(a);
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        vector<int>::iterator it = find(res.begin(), res.end(), t);
        cout << (it != res.end() ? "yes" : "no") << "\n";
    }

    return 0;
}

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

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	double a = 0.;
	for(int i = 1; i <= N; ++i) if(i%2) a += 1.0;
	printf("%.10f",a/N);


	return 0;
}


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

int main() {
  int n, k; cin >> n >> k;
  vector<int> ans(n);
  rep(i, k) {
    int d; cin >> d;
    rep(j, d) {
      int a; cin >> a; a--;
      ans[a]++;
    }
  }
  int cnt = 0;
  rep(i, n) if (!ans[i]) cnt++; 
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int N,t,sum=0;
    cin>>N;
    if(2<=N&&N<=9){
        cout<<N<<endl;
    }
    else {
        while(N!=0){
           t=N%10;
            sum=t+sum;
            N=N/10;
        }
        if(sum==1){
            sum=sum*10;
        }
        cout<<sum<<endl;
    }
    return 0;
}


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

int main()
{
  int n;

  cin >> n;

  ll sum = 1;

  ll waru = 1e9 + 7;

  for (int i = 1; i <= n; i++)
  {
    sum *= i % waru;
    sum %= waru;
  }

  cout << sum;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<queue>
#include<climits>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stack>
#include<map>
#include<string>
using namespace std;
const int INF=0x3f3f3f3f;
typedef long long ll;
#define me(a,b) memset(a,b,sizeof a)
const int maxn=1e5+100;
//ll a[maxn];
//ll sum[maxn];
struct node{
    ll s,e;
    bool operator < (const node &a)const{
        if(s==a.s)
            return e<a.e;
        return s<a.s;
    }
}num[maxn];
int main()
{

   ll n,c,k;
   scanf("%lld%lld%lld",&n,&c,&k);
   for(int i=0;i<n;i++){
    scanf("%lld",&num[i].s);
    num[i].e+=k+num[i].s;
   }
   ll ans=0;
   sort(num,num+n);
   ll t=num[0].e;
   ll sum=0;
   for(int i=0;i<n;i++){
    if((sum>=c&&num[i].s<=t)||sum==0){
        sum=1;
        ans++;
        t=num[i].e;
    }
    else if(num[i].s<=t){
        sum++;
    }
    else
    {
        t=num[i].e;
        ans++;
        sum=1;
    }
   }
   printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;


int main(){
   int A,B;
   cin >> A >> B;
   if(B<0){
       cout << max(A-B,A*B);
   }else{
       cout << max(A+B,A*B);
   }
}

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

int main() {
  int a[1000000];
  cin >> a[0];
  int s;
  for(int i = 0; i < 1000000; ++i){
    if(a[i] % 2 == 0)
      a[i+1] = a[i] / 2;
    else
      a[i+1] = 3*a[i] + 1;
    bool b = 0;
    for(int j = 0; j < i; ++j){
      if(a[j] == a[i+1]){
        s = i + 2;
        b = 1;
        break;
      }
    }
    if(b)
      break;
  }
  cout << s << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 2000001
#define M 10001
int n,A[N],B[N],C[M];
void countingSort(void);
int main(){
  int i;
  int count=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  countingSort();
  for(i=1;i<=n;i++){
    if( (i-1)!=0 ){
      printf(" ");
    }
    printf("%d",B[i]);
    count++;
  }
  printf("\n");
  return 0;
}
void countingSort(void){
  int i;
  for(i=0;i<M;i++){
    C[i] = 0;
  }
  for(i=1;i<=n;i++){
    C[A[i]]++;
  }
  for(i=1;i<M;i++){
    C[i] += C[i-1];
  }
  for(i=1;i<=n;i++){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
  return;
}


Measured memory_bytes: 17408
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
// const double PI = acos(-1);
const double PI = 3.14159;

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

namespace Comb{
const int N = 10 + 5;
inline void exgcd(ll a, ll b, ll &g, ll &x, ll &y) {
    if (!b) g = a, x = 1, y = 0;
    else exgcd(b, a % b, g, y, x), y -= x * (a / b);
}
 
inline ll inv(ll a) {
    ll g, res, tmp;
    exgcd(a, MOD, g, res, tmp);
    return ((res % MOD) + MOD) % MOD;
}
 
ll f[N], invFact[N];
 
inline void prepare() {
    f[0] = 1;
    int n = 200000;
    for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % MOD;
    invFact[n] = inv(f[n]);
    for (int i = n - 1; i >= 1; i--) invFact[i] = invFact[i + 1] * (i + 1) % MOD;
}
 
inline ll C(int n, int m) {
    if (!m) return 1;
    if (n == m) return 1;
    if (m > n) return 0;
    if (m < 0) return 0;
    return f[n] * invFact[m] % MOD * invFact[n - m] % MOD;
}
}

int main() {
    int n, a, ans;
    cin >> n >> a;
    ans = n / a;
    if (n % a) ans++;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
def q4():
    n = int(input())
    line = input()
    if 'WR' in line:
        r = line.count('R')
        safe = line[0:r].count('R')
    else:
        r = 0
        safe = 0
    print(r-safe)



if __name__ == "__main__":
    q4()


Measured memory_bytes: 9476
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];

		for(int i=0; i<n; i++) {
			x[i] = sc.nextInt();
		}

		for(int i=0; i<n; i++) {
			y[i] = sc.nextInt();
		}

		// マンハッタン距離
		double manhattan = 0;
		for(int i=0; i<n; i++) {
			manhattan += Math.abs(x[i] - y[i]);
		}


		// ユークリッド距離
		double euclid = 0;
		for(int i=0; i<n; i++) {
			euclid += Math.pow(x[i] - y[i], 2);
		}
		euclid = Math.sqrt(euclid);

		// チェビシェフ距離
		ArrayList<Double> distances = new ArrayList<>();
		for(int i=0; i<n; i++) {
			Double d = Math.abs(x[i] - y[i] - 0.0);
			distances.add(d);
		}
		Collections.sort(distances);
		Collections.reverse(distances);
		double chebyshev = distances.get(0);

		// 	ミンコフスキー距離
		double minkowski = 0;
		double p = 3.0;
		for(int i=0; i<n; i++) {
			minkowski += Math.pow(Math.abs(x[i] - y[i]), p);
		}
		minkowski = Math.pow(minkowski, 1/p);


		System.out.println(manhattan);
		System.out.println(euclid);
		System.out.println(minkowski);
		System.out.println(chebyshev);

		sc.close();

	}

}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> sum(n, 0);
    for (int i = 0; i < q; ++i) {
        int a;
        cin >> a;
        a--;
        sum[a]++;
    }

    for (int i = 0; i < n; ++i) {
        cout << (k - q + sum[i] <= 0 ? "No" : "Yes") << endl;
    }
}

Measured memory_bytes: 3716
import sys

sys.setrecursionlimit(10 ** 9)

t = int(input())

for _ in range(t):
    n, a, b, c, d = map(int, input().split())

    di = {0:0, 1:d}
    def _f(_n):
        if _n in di:
            return di[_n]
        nn = _n * d
        n5 = (_n % 5) * d + c + _f(_n // 5)
        if _n % 5 != 0:
            n5 = min(n5, (-_n % 5) * d + c + _f((_n // 5) + 1))
        n3 = (_n % 3) * d + b + _f(_n // 3)
        if _n % 3 != 0:
            n3 = min(n3, (-_n % 3) * d + b + _f((_n // 3) + 1))
        n2 = (_n % 2) * d + a + _f(_n // 2)
        if _n % 2 != 0:
            n2 = min(n2, (_n % 2) * d + a + _f((_n // 2) + 1))

        ret = min(nn, n2, n3, n5)
        di[_n] = ret
        return ret


    print(_f(n))


Measured memory_bytes: 10804
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>

int* UF(int N){
	int* res = (int*)malloc(sizeof(int) * N);
	for(int i=0; i<N; i++)res[i] = -1;
	return res;
}
int find(int *arr, int x){
	if(arr[x] < 0) return x;
	return arr[x] = find(arr, arr[x]);
}
bool unite(int *arr, int x, int y){
	x = find(arr, x); y = find(arr, y);
	if(x == y) return false;
	if(arr[x] > arr[y]){
		int tmp = x;
		x = y;
		y = tmp;
	}
	arr[x] += arr[y];
	arr[y] = x;
	return true;
}
bool same(int *arr, int x, int y){return find(arr, x) == find(arr, y);}
int size(int *arr, int x){return -arr[find(arr, x)];}

int main(){
	int N, Q;
	scanf("%d%d", &N, &Q);
	int *d = UF(N);
	while(Q--){
		int t, x, y;
		scanf("%d%d%d", &t, &x, &y);
		if(t == 1) printf("%d\n", same(d, x, y));
		else unite(d, x, y);
	}
	return 0;
}

Measured memory_bytes: 2388
import scala.io.StdIn._

object Main extends App {


  val n = readInt()
  val A = readLine().split(" ").map(_.toInt)

  def solve() = {
    val isValid = A.map { num =>
      if(num % 2 == 0) {
        if(num % 5 == 0 || num % 3 == 0 ) true else false
      } else true
    }.forall(identity)
    if(isValid) "APPROVED" else "DENIED"
  }

  println(solve())

}



Measured memory_bytes: 54784
import numpy as np
N,K = map(int, input().split())
ab = [tuple(map(int, input().split())) for i in range(N)]
ab.sort()
num = 0
for i in range(N):
	num += ab[i][1]
	if num >= K:
		ans = ab[i][0]
		break

print(ans)


Measured memory_bytes: 28264
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
  int i,ans=9999,N,T,c[1000],t[1000];
  scanf("%d%d",&N,&T );
  for(i=0;i<N;i++){
    scanf("%d%d",&c[i],&t[i]);
    if(t[i]<=T){
      if(c[i]<ans)
      ans=c[i];
    }
  }
  if(ans==9999)
    printf("TLE\n");
  else
    printf("%d\n",ans );
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int cnt1[100003],cnt2[100003],n,x,mx1,mx2,x1,x2;
int main() {
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> x;
		if(i % 2 == 0) {
			cnt1[x]++;
			if(mx1 < cnt1[x]) {
				mx1=cnt1[x];
				x1=x;
            }
		} else {
			cnt2[x]++;
			if(mx2 < cnt2[x]) {
				mx2 = cnt2[x];
				x2 = x;
            }
		}
	}

	sort(cnt1,cnt1+100003);
	sort(cnt2,cnt2+100003);

	if(x1 != x2) {
		cout << n-mx1-mx2;
    } else {
		cout << n - max(mx1+cnt2[100001], mx2+cnt1[100001]);
    }
    return 0;
}

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

int main() {
  int r,g,b;
  cin >> r >> g >> b;

  int S = 100 * r + 10 *g + b;
  if(S % 4 == 0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3612
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N, S, B;
        cin >> N >> S >> B;
        cout << min(N * S, B) << endl;

        return 0;
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
char s[SIZE],t[SIZE];
int main(){
    int N,M;R(N,M);
    RS(s);
    RS(t);
    LL ans=(LL)N/__gcd(N,M)*M;
    LL gg=__gcd(N,M);
    REP(i,gg){
        if(s[i*N/gg]!=t[i*M/gg]){
            W(-1);
            return 0;
        }
    }
    W(ans);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define MOD 1000000007

int main(void){
	long i, j, n, m;
	scanf("%ld %ld", &n, &m);
	long x[n], y[m];
	for(i = 0; i < n; i++) scanf("%ld", &x[i]);
	for(i = 0; i < m; i++) scanf("%ld", &y[i]);

	long sumx = 0;
	for(i = 0; i < n; i++){
		sumx += x[i]*(i*2-(n-1));
	}
	sumx %= MOD;
	long sumy = 0;
	for(i = 0; i < m; i++){
		sumy += y[i]*(i*2-(m-1));
	}
	sumy %= MOD;
	printf("%ld\n", sumx*sumy%MOD);

	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	int num1=0,num2=0,num3=0,num4=0;
	
	cin>>num1>>num2;
	if(num1>num2){
		num3=num1-num2;
		num4=num3%2;
	}
	if(num1<num2){
		num3=num2-num1;
		num4=num3%2;
	}
	if((num1>0&&num2>0)||(num1<0&&num2<0&&num4==1)){
		cout<<"Positive\n";
	}
	if((num1>0&&num2<0)||(num1<0&&num2>0)){
		cout<<"Zero\n";
	}
	if(num1<0&&num2<0&&num4==0){
		cout<<"Negative\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  cin >> N;
  ;
}
void solve() {
  // double k = N;
  // k /= 1.08;

  // int j = round(k);
  // cout << j << endl;
  // ;
  rep(i, 0, N) {
    double k = i;
    k *= 1.08;
    if (floor(k) == N) {
      cout << i << endl;
      return;
    }
  }
  cout << ":(" << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int m=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(10*i+2*j+k==d/50){
                    m++;
                }
            }
        }
    }
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{ return firstElof.second < secondElof.second; }
//**Snippetリスト**//
//rep, vin, all//
//gcdlcm, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; 
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 1;
vl flag, color; vll path; vl D; ll S, T;
//***********//
int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
		A[i] *= -1;
	}
	multiset<ll> C;
	C.insert(A[0]);
	for (i = 1; i < N; i++) {
		if (A[i] >= *C.rbegin()) {
			C.insert(A[i]);
		}
		else {
			C.erase(C.upper_bound(A[i]));
			C.insert(A[i]);
		}
		//cout << C.size() << endl;
	}
	cout << C.size();
}


Measured memory_bytes: 5760
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

INF = 10 ** 20
n = int(input())
h = [INF] + list(map(int, input().split())) + [INF]

dp = [INF] + [INF] * n + [INF]
dp[1] = 0

def chmin(dp, i, value):
    dp[i] = min(dp[i], value)

for i in range(1, n):
    chmin(dp, i+1, dp[i] + abs(h[i+1] - h[i]))
    chmin(dp, i+2, dp[i] + abs(h[i+2] - h[i]))
    #dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    #dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))

print(dp[n])


Measured memory_bytes: 55500
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;

int main() {
	int N, A, B, C;
	cin >> N;
	A = 0;
	B = 0;
	C = 0;
	for (int i = 0;i < N;i++) {
		cin >> A;
		B += A;
		if (C < A) {
			C = A;
		}
	}
	if (C < B - C) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

void solve(){
    ll ans=0;
    ll a,b;cin>>a>>b;
    repe(i,a,b){
        string s=to_string(i);
        string t=s;
        reverse(all(t));
        if(s==t)++ans;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    s += s[0];
    bool ok=false;
    string ans;
    for(int j=0;j<4;j++){
        if(j==0) ans="SS";
        if(j==1) ans="SW";
        if(j==2) ans="WS";
        if(j==3) ans="WW";
        for(int i=1;i<=n;i++){
            if(s[i]=='o'&&ans[i]=='S'){
                ans += ans[i-1];
            }
            else if(s[i]=='o' && ans[i]=='W'){//嘘つき->左右が違う
                if(ans[i-1]=='W'){
                    ans += 'S';
                }
                else{
                    ans += 'W';
                }
            }
            else if(s[i]=='x' && ans[i]=='S'){
                if(ans[i-1]=='W'){
                    ans += 'S';
                }
                else{
                    ans += 'W';
                }
            }
            else{
                ans += ans[i-1];
            }
        }
        if(ans[0]==ans[n] && ans[1]==ans[n+1]) {
            ok = true;
            //cout<<ans<<endl;
            break;
        }
    }
    if(ok) {
        rep(i,n){
            cout<<ans[i];
        }
        cout<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}

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

int main(){
  int h, w;
  cin >> h >> w;
  
  vector<char> a(h*w,0), b((h+2) * (w+2),'#');
  
  //入力
  for(int i = 0; i < h*w; i++){
    cin >> a.at(i);
    //cout << a.at(i);
  }
  for(int i = 0;i<h;i++){
    for(int j = 0; j < w; j++){
      b.at((i+1)*(w+2)+j+1) = a.at(i*w+j) ;
    }
  }
  
  //表示
  for(int i = 0; i < h+2; i++){
    for(int j = 0; j < w+2; j++){
      cout << b.at(j + i*(w+2));
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <sstream>
#include <cstdlib>
typedef long long  ll;
using namespace std;

int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

template <typename T> std::string to_bin_str(T n, std::size_t digit_num) {
    std::string str;
    while (n > 0) {
        str.push_back('0' + (n & 1));
        n >>= 1;
    }
    str.resize(digit_num, '0');
    std::reverse(str.begin(), str.end());
    return str;
}

int main(){
	string N;
	cin >> N;
	int k=N.length();
	ll result =0;
	string str;
	ll num=0;
	int count=0;
	result=stoll(N.c_str());
	/*for (int i=0; i<k;i++){
		result=result+N[i]-'0';
	}*/
	for(int i =1; i<1<<(k-1); i++){
		num=binary(i);
		str = to_bin_str(num,k-1);
		count=0;
		for (int j=0; j<k-2;j++){
			if(str[j]=='1'){
				result=result+stoll(N.substr(j-count,count+1).c_str());
				count=0;
			}else{
				count++;
			}
		}
		if(str[k-2]=='1'){
			result=result+stoll(N.substr(k-2-count,count+1).c_str())+stoll(N.substr(k-1).c_str());
		}else{
			result=result+stoll(N.substr(k-2-count).c_str());
		}
	}
	cout << result << endl;
}

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


int main() {
	long long int x,y,s,res=0;
	while(1){
		res=0;
		cin>>x>>y>>s;
		if(x==0){return 0;}
	for(int i=1;i<s;i++){
		
		long long int tmp1=(i*100-1)/(100+x)+1;
		long long int tmp2=((s-i)*100-1)/(100+x)+1;
		if(tmp1*(100+x)/100!=i||tmp2*(100+x)/100!=s-i){continue;}
		
		tmp1=tmp1*(100+y)/100;
		tmp2=tmp2*(100+y)/100;
		
		if(res<=tmp1+tmp2){
			res=tmp1+tmp2;
		}
		
	}
	cout<<res<<endl;
	}
}



Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define trace1(a) cout << a << 'n';
#define trace2(a, b) cout << a << ' ' << b << 'n';
#define trace3(a, b, c) cout << a << ' ' << b << ' ' << c << 'n';
#define trace4(a, b, c, d) cout << a << ' ' << b << ' ' << c << ' ' << d << 'n';
#define trace5(a, b, c, d, e) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << 'n';
#define trace6(a, b, c, d, e, f) cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << ' ' << f << 'n';
#define range(n) for(int i = 0; i < n; i++)
#define printArr(harry, tam) range(tam) cout << harry[i] << " n"[i == tam -1];
#define maxn -2000000 //negative value to break code and force you to put right constraint
#define mod 1000000007
#define md(x) (x) % mod;
#define sc scanf
#define pr printf
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ps push
#define prt(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define INF 1000000000
#define INFd 1e9
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<double> vd;

int main(){
  ll n;
  cin>>n;
  vector<ll> v1(n+1),v2(n+1),v3(n+1);
    for(ll i=1;i<=n;i++)
      cin>>v1[i];
    for(ll i=1;i<=n;i++)
      cin>>v2[i];
    for(ll i=1;i<n;i++)
      cin>>v3[i];
      ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        ans+=v2[v1[i]];
        if(i<n&&v1[i+1]==v1[i]+1)
          ans+=v3[v1[i]];

    }
    cout<<ans;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
using namespace std;

vector<pair<string,int> > decode(string str) {
	vector<pair<string, int> > res;
    int num = 0;
	string tmp = "";
    for (auto c : str) {
		if (c >= '0' && c <= '9') {
			num *= 10, num += c - '0';
		}
		else {
			if (num != 0) {
				res.push_back({ tmp, num });
				tmp = "";
				num = 0;
			}
			tmp += c;
		}
    }
	if (tmp != "" || num != 0) res.push_back({ tmp, num });
	return res;
}

int main() {
    int N; cin >> N;
    string S0; cin >> S0;
    auto p0 = decode(S0);
    for (int i = 0; i < N; ++i) {
        string S; cin >> S;
        auto p = decode(S);
        if (p >= p0) puts("+");
        else puts("-");
    }
}


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

int main()
{
    int N, M;
    int ACsum = 0, WAsum = 0;
    cin >> N >> M;
    vector<bool> ACsita(N, false);
    vector<int> p(M, 0), WA(N, 0);
    vector<string> S(M);
    for (int i = 0; i < M; i++)
    {
        cin >> p.at(i) >> S.at(i);
    }

    for (int i = 0; i < M; i++)
    {
        if (S.at(i) == "WA" && ACsita.at(p.at(i)-1) == false)
        {
            WAsum++;
            WA.at(p.at(i)-1)++;
        }
        if (S.at(i) == "AC" && ACsita.at(p.at(i)-1) == false)
        {
            ACsum++;
            ACsita.at(p.at(i)-1) = true;
        }
    }

    for (int i = 0; i < N; i++)
    {
        if (ACsita.at(i) == false && WA.at(i) >= 1)
        {
            WAsum = WAsum - WA.at(i);
        }
    }
    cout << ACsum << endl
         << WAsum << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int A, B;
	cin >> A >> B;
	cout << A * B - A - B + 1 << endl;
}

Measured memory_bytes: 256