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

#define ll              long long
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             (int)(1e18)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define rep(i,j,n)      for(int i=j;i<n;i++)
#define all(p)          p.begin(),p.end()
#define ub(a,b)         upper_bound(all(a),b)
#define lb(a,b)         lower_bound(all(a),b)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void run()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
}
const double pi = 3.1415926535897;
int32_t main()
{
	run();
	int n, m;
	cin >> n >> m;
	int ans = 0;
	rep(i, 0, m)
	{
		int temp;
		cin >> temp;
		ans += temp;
	}
	ans = min(ans, n + 1);
	cout << n - ans << endl;
	return 0;
}

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

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; }

using ll = long long;

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<vector<int>> work(N,vector<int>(2));
  for(int i = 0;i<N;i++) {
    int x,y;
    cin>>x>>y;
    work[i][0]=y;
    work[i][1]=-x;
  }
  sort(work.begin(),work.end());
  reverse(work.begin(),work.end());
  vector<int> mon(M,0);
  vector<int> lim(M);
  for(int i = 0; i < M; i++) lim[i]=i;
  for(int i = 0; i < N; i++){
    int day=-work[i][1];
    int pay=work[i][0];
    auto ite = upper_bound(lim.begin(),lim.end(),M-day);
    if(ite==lim.begin()) continue;
    mon[*(ite-1)]=pay;
    lim.erase(ite-1);
  }
  ll ans = 0LL;
  for(auto x:mon) ans+=x;
  cout<<ans<<endl;
}

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

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

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

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

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

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

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

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

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

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

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

using namespace templates;

int func(){
  int n = in();
  vector<int> line(n);
  foreach(i,line)i = in();
  vector<int> dead_line_right(n,0);
  vector<int> dead_line_left(n,0);
  {
    int time = -1;
    rep(i,n){
      --time;
      if(line[i]==0){
        time = INF;
      }else if(line[i]<0){
        chmin(time,-line[i]);
      }else{
        chmax(dead_line_left[i],time);
      }
    }
  }
  {
    int time = -1;
    per(i,n){
      --time;
      if(line[i]==0){
        time = INF;
      }else if(line[i]<0){
        chmin(time,-line[i]);
      }else{
        chmax(dead_line_right[i],time);
      }
    }
  }
  int res = 0;
  rep(i,n){
    res += min(max(line[i],0),max({dead_line_left[i],dead_line_right[i],0}));
  }
  return res;
}

int main(){
  cout << func() << endl;
  return 0;
}



Measured memory_bytes: 3892
N , M =(int(a) for a in input().split())
num = []

for i in  range(M) :
    L,R =(int(a) for a in input().split())
    num.append((L , R))

a = 0
b = 10 ** 5
for i in range(M) :
    a = max(a , num[i][0])
    b = min(b , num[i][1])

x = b - a + 1
if x < 0 :
    print(0)
else : print(x)






    
    

            


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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    vector<int> a(n), b(n), c(n-1);
    rep(i, n)
    {
        cin >> a[i];
        --a[i];
    }
    rep(i, n)
    {
        cin >> b[i];
    }
    rep(i, n-1)
    {
        cin >> c[i];
    }
    
    int sum = 0;
    rep(i, n)
    {
        sum += b[a[i]];
        if (i >= 1 && a[i] - a[i-1]==1)
        {
            sum += c[a[i-1]];
        }
    }
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import sys, math

a, b, h, m = [int(x) for x in stdin.readline().rstrip().split()]

x = 30*h + 0.5*m
y = 6*m

z = abs(x-y)
if z > 180: z = 360 - z

c = a**2 + b**2 - 2*a*b*math.cos(math.radians(z))
c = math.sqrt(c)

print(c)

Measured memory_bytes: 9388
#include <iostream>
#include <algorithm>
#include <string>
#include <bitset>
using namespace std;

int main() {
    string s;
    cin >> s;
    long long int sum = 0;
    //+の入れ方
    for (int bit=0; bit < (1<<(s.size()-1)); bit++) {
        //cout << bitset<10>(bit) << endl;
        //和をとる
        int split = 0;
        for (int i=0;i<s.size();i++) {
            //i番目にフラグが立ってる→splitからi+1で区切る，後ろから
            if((bit & (1<<i)) || i==(s.size()-1)) {
                sum += stoll(s.substr(split,i-split+1));
                split = i+1;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
const int MOD = 1000000007;

int main(){
    int N; cin >> N;
    vector<ll> L(N);
    rep(i,N) cin >> L[i];

    int ans = 0;
    for(int i = 0; i < N; i++){
        for (int j = i+1; j < N; j++){
            if (L[i] == L[j]) continue;
            for (int k = j+1; k < N; k++){
                if (L[i] == L[k]) continue;
                if (L[j] == L[k]) continue;
                if (L[i]+L[j]+L[k] > max({L[i],L[j],L[k]})*2) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin>>n>>m;
	vector<ar<ll,3> >v;
	for(ll i=0,j,k,c; i<m; i++)
	{
		cin>>j>>k>>c, --j,--k;
		c = -c;
		v.push_back({j,k,c});
	}
	ll dist[n];
	fill(dist,dist+n,(ll)(1e18));
	dist[0]=0;
	for(int i = 0; i<n-1; i++)
	{
		for(auto it:v)
		{
			if(dist[it[0]]==(ll)1e18)
				continue;
			dist[it[1]] = min(dist[it[1]],dist[it[0]]+ it[2]);
		}
	}

	bool vis[n] = {0};
	for(auto it:v)
	{
		if(dist[it[0]]== (ll)1e18)
			continue;
		if(dist[it[0]]+it[2]<dist[it[1]])
			vis[it[1]] = 1;
		if(vis[it[0]])
			vis[it[1]]=1;
	}
	if(vis[n-1])
		cout<<"inf"<<endl;
	else
		cout<<(-dist[n-1])<<endl;
	return 0;
}

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

string str,str1,str2,str3;
int main(){
int i=0,a=0,b=0;
cin>>str>>i;
for(int i2=0;i2<i;i2++)
	{cin>>str1;
	if(str1=="replace")
		{cin>>a>>b>>str2;
		str.replace(a,b-a+1,str2);
		}
	if(str1=="reverse")
		{cin>>a>>b;
		str2=str.substr(a,b-a+1);
		str.erase(a,b-a+1);
		str3="";
		for(int i3=0;i3<=b-a;i3++)
			{
			str3+=str2[str2.size()-i3-1];
			}
		str.insert(a,str3);
	        
		}
	if(str1=="print")
		{cin>>a>>b;
		cout<<str.substr(a,b-a+1)<<endl;
		}
	}
return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	vi h(N);
	REP(i,N) cin >> h[i];
	vi dp(N + 1, numeric_limits<int>::max());
	dp[0] = 0;
	REP(i,N - 1) {
		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]));
	}
	cout << dp[N - 1] << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	ll n, m;
	cin >> n >> m;

	vector<ll> divs;
	for(ll i = 1; i * i <= m; i++){
		if(m % i == 0){
			divs.push_back(i);
			divs.push_back(m / i);
		}
	}

	ll ans = 1;
	for(ll x : divs){
		if(n <= m / x){
			ans = max(ans, x);
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    cin >> a >> b >> c;
    if( a <= c && c <= b ) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#include <assert.h>
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
using namespace std;
int n, a[200009], first[200009], b[200009], nb[200009];
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
        first[i] = -1;
    for(int i=1;i<=n;i++) {
        cin>>b[i];
        if(first[b[i]] == -1)
            first[b[i]] = i;
    }
    int shift = 0;
    for(int i=1;i<=n;i++) {
        if(first[a[i]] != -1 && (i == n || a[i] != a[i + 1])) {
            int curshift = i + 1 - first[a[i]];
            shift = max(shift, curshift);
        }
    }
    //cout<<shift<<endl;
    for(int i=1;i<=n;i++) {
        int ind = i - shift;
        if(ind < 1)
            ind += n;
        //cout<<i<<" "<<ind<<endl;
        nb[i] = b[ind];
        if(nb[i] == a[i]) {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes\n";
    for(int i=1;i<=n;i++)
        cout<<nb[i]<<" ";
}
/*
 2
 1 1
 1 0
 1 1
 1 1
 */


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

using namespace std;

#define long long long
#define INF 2e18
#define MOD (long) (1e9 + 7)
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long a, b;
        cin >> a >> b;

        set<long> s;
        s.insert({1, 2, 3});
        s.erase(a);
        s.erase(b);
        printf("%lld\n", *s.begin());
    }
}


Measured memory_bytes: 3724
#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(){
    ll K; cin >> K;
    if(K % 2 == 0 || K % 5 == 0){
        cout << -1 << endl;
        return 0;
    }

    ll ans = 1;
    ll bp;
    while(1){
        bp = (bp * 10 + 7) % K;
        if(bp == 0) break;
        ++ans;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int N;
  	cin >> N;
    bool ok = true;
    REP(i,N){
        int a;cin>>a;
        if(a%2==0 && (a%3!=0 &&a%5 !=0)){
            ok = false;
            break;
        }
    }
    if(ok){
        cout <<"APPROVED" << endl;
    }
    else{
        cout <<"DENIED" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())

txy = [list(map(int, input().split())) for _ in range(N)]

point = [0,0]
flag = "Yes"
t = 0
for i in txy:
    t_, x, y = i
    t__ = t_ - t 
    move = abs(x-point[0])+abs(y-point[1])
    if move > t__:
        flag = "No"
        break
    elif (t__ - move) % 2 == 1:
        flag = "No"
        break
    point = [x,y]
    t = t_

print(flag)

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

typedef long long ll;
typedef pair<int,int>P;
#define INF (1e9)
#define EPS (1e-7)
#define MOD ((ll)1e9+7)
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,k,n) for(int i = (k); i < (int)(n); i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define pb push_back
#define vec vector<int>


/*--------------------------------------------*/
/*ll factorial(ll);
void list_Prime(ll);
ll divisor(ll);*/
/*--------------------------------------------*/


int main(){
    int n;cin>>n;
    vec a(n);
    REP(i,n)cin>>a[i];
    sort(ALL(a));
    int ans=0;
    for(int i=0;i<n;){
        int cnt=0;
        int tmp=a[i];
        while(a[i+cnt]==tmp)cnt++;
        if(cnt>tmp)ans+=(-tmp+cnt);
        if(cnt<tmp)ans+=cnt;
        i+=cnt;
        //printf("tmp=%d cnt=%d i=%d\n",tmp,cnt,i);
    }
    cout<<ans<<endl;
}



/*--------------------------------------------*/
/*
ll factorial(ll n){
    if(n==1)return 1;
    return n*factorial(n-1);
}


void list_Prime(ll n){//n以下の素数を全て見つける
    ll Limit=(int)sqrt((double)n);
    for(ll i=2;i<=n;i++)prime[i]=1;//最初はみんな素数かも
    //素数の整数倍を消していく(ルートnまで)
    for(ll i=2;i<=Limit;i++){
        if(prime[i]){
            for(ll j=2*i;j<=n;j++){
                if(j%i==0){
                    prime[j]=0;                
                }
            }
        }
    }
}

ll divisor(ll n){
    for(ll i=2;i<=n;i++){
        ll d=1;
        ll tmp=i;
        while(tmp>0){
            d++;
            while(tmp%d==0){
                prime[i]++;
                tmp/=i;
            }
        }
    }
    ll sum=1;
    for(ll i=2;;i<=n;i++){
        sum*=(prime[i]+1)/MOD;
    }    
    cout<<"sum="<<sum<<endl;

    return sum%MOD;
}
*/


Measured memory_bytes: 640
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;


ll dp[1010][210];
ll riku[210][210], fune[210][210];



int main(){
	int n, m;
	while(cin >> n >> m && (n | m)) {
		rep(i, 1010) rep(j, 210) dp[i][j] = LINF;
		rep(i, 210) rep(j, 210) riku[i][j] = fune[i][j] = (i == j ? 0LL : LINF);
		rep(i, m) {
			int a, b;
			ll t;
			string s;
			cin >> a >> b >> t >> s;
			a--; b--;
			if(s == "L") riku[a][b] = riku[b][a] = min(riku[a][b], t);
			else fune[a][b] = fune[b][a] = min(fune[a][b], t);
		}
		rep(k, n) rep(i, n) rep(j, n) {
			riku[i][j] = min(riku[i][j], riku[i][k] + riku[k][j]);
			fune[i][j] = min(fune[i][j], fune[i][k] + fune[k][j]);
		}
		int r;
		cin >> r;
		vi v(r);
		rep(i, r) cin >> v[i], v[i]--;
		dp[0][v[0]] = 0LL;
		rep(i, r - 1) {
			rep(j, n) if(dp[i][j] != LINF) {
				dp[i+1][j] = min(dp[i+1][j], dp[i][j] + riku[v[i]][v[i+1]]);
				rep(k, n) {
					dp[i+1][k] = min(dp[i+1][k], dp[i][j] + riku[v[i]][j] + fune[j][k] + riku[k][v[i+1]]);
				}
			}
		}
		ll ans = LINF;
		for(int i = 0; i < 210; i++) ans = min(ans, dp[r-1][i]);
		cout<<ans<<endl;
 	}
	
}

Measured memory_bytes: 5424
/* ex3_3
   tamayama */

#include<stdio.h>
 int main (void){
 
 int N,K,L;
    int digit=1;
    scanf("%d %d",&N,&K);
    L = K;

    while(K <= N){
    K = L*K;
    digit++;
    }
    printf("%d\n",digit);

   return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<string> w(n);
  for (auto &e : w)
    cin >> e;

  for (int i = 1; i < n; ++i)
  {
    if (w[i - 1][w[i - 1].size() - 1] != w[i][0])
    {
      cout << "No" << endl;
      return 0;
    }
    for (int j = 0; j < i; ++j)
    {
      if (w[i] == w[j])
      {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define  LL long long
const double pi = acos(-1);
const double g = -9.8;


int main()
{
	LL l,r;
	scanf("%lld%lld",&l,&r);
	int ans=1;
	int ci=1;
	for(LL i=2;;i=i*2){
		if(l*i>r){
			break;
		}
		ans=++ci;
	}
	printf("%d\n",ans);
}



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

using namespace std;

void solve1() {
	int N;
	cin >> N;

	//calculate
	string ans = "No";
	if (N >= 21) {
		ans = "Yes";
	} else {
		if (N % 4 == 0) {
			ans = "Yes";
		} else {
			for (int i = 0; i < 2; ++i) {
				N -= 7;
				if (N < 0) {
					ans = "No";
					break;
				} else if (N % 4 == 0) {
					ans = "Yes";
					break;
				}
			}
		}
	}

	//print
	cout << ans << '\n';
}

void solve2() {
	int N;
	cin >> N;

	//calculate
	int ans = 0;

	//print
	cout << ans << '\n';
}

void solve3() {
	int N;
	cin >> N;

	//calculate
	int ans = 0;

	//print
	cout << ans << '\n';
}

void solve4() {
	int N;
	cin >> N;

	//calculate
	int ans = 0;

	//print
	cout << ans << '\n';
}

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


Measured memory_bytes: 256
def main():
    C = tuple(tuple(map(int, input().split())) for _ in [0] * 3)

    c = [[0 for _ in [0] * 4] for _ in [0] * 4]
    for i, n in enumerate(C):
        for j, m in enumerate(n):
            c[i+1][j+1] = m

    a, b = [0] * 4, [0] * 4
    for n in range(c[1][1] + 1):
        a[1] = n
        b[1] = c[1][1] - n
        a[2] = c[2][1] - b[1]
        b[2] = c[1][2] - a[1]
        a[3] = c[3][1] - b[1]
        b[3] = c[1][3] - a[1]

        flag = 0
        for i in range(1, 4):
            for j in range(1, 4):
                if c[i][j] != a[i] + b[j]:
                    flag = 1
                    break
            if flag:
                break
        else:
            print('Yes')
            break
    else:
        print('No')

main()


Measured memory_bytes: 3064
from collections import defaultdict

S = input().rstrip()

char_dict = defaultdict(int)
for char in S:
    char_dict[char] += 1

kind = len(char_dict.keys())
val_set = set(char_dict.values())

if kind == 2 and val_set == {2}:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll i,n,a,b,k,max=0;
    cin>>a>>b>>n;
    if(b-1<=n){
      i=b-1;
    }else{
      i=n;
    }
        k=(a*i/b)-a*(i/b);
        max=k;
    cout<<max;
}

Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int intLoop = scan.nextInt();
		double dbAve = 0;
		int intTemp = 0;
		double dbVariance = 0;
		double dbDeviation = 0;
		ArrayList<Integer> list = new ArrayList<Integer>();
		ArrayList<Double> devList = new ArrayList<Double>();
		while (intLoop != 0) {
			dbAve = 0;
			intTemp = 0;
			dbVariance = 0;
			dbDeviation = 0;
			list = new ArrayList<Integer>();
			for (int i = 0; i < intLoop; i++) {
				intTemp = scan.nextInt();
				list.add(intTemp);
				dbAve += intTemp;
			}
			dbAve = dbAve / intLoop;
			for (int i = 0; i < intLoop; i++) {
				dbVariance += Math.pow(list.get(i) - dbAve, 2);
			}
			dbVariance /= intLoop;
			dbDeviation = Math.sqrt(dbVariance);
			devList.add(dbDeviation);
			intLoop = scan.nextInt();
		}
		for(int i = 0; i < devList.size(); i++){
			System.out.println(devList.get(i));
		}
	}
}

Measured memory_bytes: 23772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}


ll r, c, n, x, y, z, w, i;

inline bool inside(ll x, ll y) {return x > 0 and x < r and y > 0 and y < c;}

ll cir_long(ll x, ll y){
    if(y == 0) return x;
    if(x == r) return r + y;
    if(y == c) return 2 * r + c - x;
    if(x == 0) return 2 * r + 2 * c - y;
}

typedef pair<ll,ll> P; 

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> r >> c >> n;
    V<P> cir;
    while(cin >> x >> y >> z >> w){
        if(inside(x ,y) or inside(z, w)) continue;
        cir.pb({cir_long(x, y), i});
        cir.pb({cir_long(z, w), i});
  		i++;
    }
    sort(all(cir));
    stack<ll> st;
    REP(i, SZ(cir)){
        ll now = cir[i].second;
        if(st.empty() or st.top() != now) st.push(now);
        else st.pop();
    }
    YES(st.empty());
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll H, W;
    cin >> H >> W;

    vector<vector<char>> S(H+1, vector<char>(W+1,'.'));

    for(ll i=1; i<=H; i++){
        for(ll j=1; j<=W; j++){
            cin >> S[i][j];
        }
    }

    vector<vector<ll>> dp(H+1, vector<ll>(W+1, INF));
    
    if(S[1][1] == '#') dp[1][1] = 1;
    if(S[1][1] == '.') dp[1][1] = 0;

    for(ll i=1; i<=H; i++){
        for(ll j=1; j<=W; j++){
            if(S[i][j] == '.'){
                dp[i][j] = min(dp[i][j], dp[i-1][j]);
                dp[i][j] = min(dp[i][j], dp[i][j-1]);
            }
            else{
                if(S[i-1][j] == '#'){
                    dp[i][j] = min(dp[i][j], dp[i-1][j]);
                }
                else{
                    dp[i][j] = min(dp[i][j], dp[i-1][j]+1);
                }

                if(S[i][j-1] == '#'){
                    dp[i][j] = min(dp[i][j], dp[i][j-1]);
                }
                else{
                    dp[i][j] = min(dp[i][j], dp[i][j-1]+1);
                }
            }
        }
    }
    cout << dp[H][W] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <algorithm>

struct edge
{
  short from;
  short to;
  int cost;
};

constexpr long long INF = 1e18;
long long dist[1000];

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);

  std::vector<edge> edges;
  for (int i = 0; i < m; ++i)
  {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    edges.emplace_back(edge{a - 1, b - 1, -c});
  }

  std::fill(dist + 1, dist + n, INF);
  for (int i = 0; i < n - 1; ++i)
  {
    for (edge& e : edges)
    {
      if (dist[e.from] == INF) continue;
      if (dist[e.to] > dist[e.from] + (long long)e.cost) dist[e.to] = dist[e.from] + (long long)e.cost;
    }
  }
  for (edge& e : edges)
  {
    if (dist[e.from] == INF) continue;
    if (dist[e.to] > dist[e.from] + (long long)e.cost)
    {
      if (e.to == n - 1)
      {
        puts("inf");
        return 0;
      }
      dist[e.to] = dist[e.from] + (long long)e.cost;
    }
  }
  printf("%lld\n", -dist[n - 1]);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
	int n;
	int i1,i2;
	int nn;
	int min;
	int num;
	int max;
	vector<int> v;
	
	

	max=0;

	while(1){
		cin >> n;
		if(n==0) break;
		if(max<n) max=n;
		v.push_back(n);
		
	}

	vector<int> pollock(max+1,0);
	vector<int> pollock2(max+1,0);
	vector<int> p;
	vector<int> p2;
	nn=1;
	num=(nn*(nn+1)*(nn+2))/6;

	for(i1=1;i1<=max;i1++){			

		if(i1==num) {
			if(i1%2==1){
				p.push_back(i1);
				p2.push_back(i1);
				nn++;
				num=(nn*(nn+1)*(nn+2))/6;
				pollock[i1]=1;
				pollock2[i1]=1;
			}
			else {
				nn++;
				num=(nn*(nn+1)*(nn+2))/6;
				p.push_back(i1);
				pollock[i1]=1;
				min=100000;
				for(i2=0;i2<p2.size();i2++){
					if((pollock2[i1-p2[i2]])<min){
						min=pollock2[i1-p2[i2]];
					}
				}
				pollock2[i1]=min+1;
			}
		}
		else {
			min=100000;
			for(i2=0;i2<p.size();i2++){
				if((pollock[i1-p[i2]])<min){
					min=pollock[i1-p[i2]];
				}
			}
			pollock[i1]=min+1;

			min=100000;
			for(i2=0;i2<p2.size();i2++){
				if((pollock2[i1-p2[i2]])<min){
					min=pollock2[i1-p2[i2]];
				}
			}
			pollock2[i1]=min+1;
		}
			//cout<<pollock[i1]<<" ";
	}

	for(i1=0;i1<v.size();i1++){

		cout << pollock[v[i1]] << " " << pollock2[v[i1]] << endl;
	}


	return 0;
}

Measured memory_bytes: 8524
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert
#define fh(x,v) for(auto x:v)

//{
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();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};
//template<class T>vector<T> var_vec(size_t a){return vector<T>(a);}
//template<class T, class... Ts>auto var_vec(size_t a, Ts... ts){return vector<decltype(var_vec<T>(ts...))>(a, var_vec<T>(ts...));}

//}

int mem[1000];

main(){
	int n,d;
	cin>>n>>d;
	int p[n][d];rep(i,n)rep(j,d)cin>>p[i][j];
	vint v;
	rep(i,1000)mem[i]=i*i;
	int ans=0;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			int t=0;
			for(int k=0;k<d;k++){
				t+=(p[i][k]-p[j][k])*(p[i][k]-p[j][k]);
			}
			rep(k,1000){
				ans+=(mem[k]==t);
			}
		}
	}
	dans;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    string s;
    cin >> s;
    if(s == "ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

}

Measured memory_bytes: 3624
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

n = onem()

l = l()
if n == 1:
    print("Yes")
    exit()
else:
    k = l[0]

for i in range(1,n):
    if l[i]-1 >= k:
        k = l[i]-1
    elif l[i] == k:
        k = l[i]
    else:
        print("No")
        exit()
print("Yes")









Measured memory_bytes: 63984
def main():
    n = int(input())
    ls = [input() for _ in range(n)]
    acount = 0
    bcount = 0
    abcount = 0
    bacount = 0
    for s in ls:
        abcount += s.count("AB")
        if s[0] =="B" and s[-1] =="A":bacount += 1
        elif s[0] =="B":bcount += 1
        elif s[-1] =="A":acount += 1

    if acount == 0 and bcount == 0:
        if bacount > 0:
            bacount -= 1
        print(abcount+bacount)
    elif acount == 0 or bcount == 0:
        print(abcount+bacount)
    else:
        print(abcount+bacount+min(acount,bcount))

main()

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
const int N = 50000;
const int INF = 1e8;
const int M = 20;

/*int rec(int n,int m){
    if(dp[n][m] != INF){
        return dp[n][m];
    }

    if(v[m] > n){
        return dp[n][m] = rec(n,m-1);
    }else{
        return dp[n][m] = min(rec(n,m),rec(n-n/v[m]*v[m],m-1));
    }
}*/

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

    vector<int> v(m);
    int dp[M+1][N+1];

    for(auto &t: v){
        cin >> t;
    }

    for(int i=0;i<=M;i++){
        for(int j=0;j<=N;j++){
            dp[i][j]=(j==0?0:INF);
        }
    }

    for(int i=0; i<m; i++){
        for(int j=0; j<=n; j++){
            if(j < v[i]){
                dp[i+1][j] = dp[i][j];
            }else{
                dp[i+1][j] = min(dp[i][j],dp[i+1][j-v[i]]+1);
            }
        }
    }

    cout << dp[m][n] << endl;

}

Measured memory_bytes: 5292
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll M = 128;
const ll X = 32768; // >= sqrt(N)

ll a[M][X], b[M][X];
int main(){
	int N, K; scanf("%d%d", &N, &K);
	for(int i=1; i<X; i++){
		a[1][i] = min(i, N);
		b[1][i] = N/i;
	}
	for(int m=2; m<=K; m++){
		a[m][0]=0;
		for(int i=1; i<X; i++){
			a[m][i] = ( a[m][i-1] + b[m-1][i] ) % MOD;
		}
		b[m][X-1]= a[m][N/(X-1)];
		for(int i=X-2; i>=1; i--){
			b[m][i] = ( b[m][i+1] + a[m-1][i] * (N/i - N/(i+1)) ) % MOD;
		}
	}
	printf("%lld\n", b[K][1]);
}

Measured memory_bytes: 53248
n,W=map(int,input().split())
w=[]
v=[]
for i in range(n):
  a,b=map(int,input().split())
  w.append(a)
  v.append(b)
V=sum(v)
INF=10**18
dp=[[INF for _ in range(V+1)] for _ in range(n+1)]
dp[0][0]=0
for i in range(n):
  for j in range(V+1):
    if j<v[i]:dp[i+1][j]=dp[i][j]
    else:dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i])
for i in range(V+1):
  if dp[n][i]<=W:ans=i
print(ans)

Measured memory_bytes: 218120
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int n;cin>>n;
	vector<int> a(n),b(n),c(n);
	for(auto&& w:a)cin>>w;
	for(auto&& w:b)cin>>w;
	for(auto&& w:c)cin>>w;
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
	int ans=0;
	for(auto&& w:b){
	int x=lower_bound(a.begin(),a.end(),w)-a.begin();
	int y=c.end()-upper_bound(c.begin(),c.end(),w);
	ans+=x*y;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

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

        int N = in.nextInt();
        float tempRes = 0;
        for (int i = 0; i < N; i++) {
            int A = in.nextInt();
            tempRes += (float) 1 / A;
        }
        System.out.println(1 / tempRes);
    }
}


Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    long a[] = new long[1001];

    long n = Long.parseLong(sl[0]);

    for(int i = 0; i <= 1000; i++)
    {
      a[i] = i;
      a[i] *= i;
      a[i] *= i;
      a[i] *= i;
      a[i] *= i;
    }

    for(int i = 0; i <= 1000; i++)
    {
      for(int j = 0; j <= 1000; j++)
      {
        if(a[i] - a[j] == n)
        {
          System.out.printf("%d %d\n", i, j);
          System.exit(0);
        }
        if(a[i] + a[j] == n)
        {
          System.out.printf("%d %d\n", i, - j);
          System.exit(0);
        }
        if(- a[i] - a[j] == n)
        {
          System.out.printf("%d %d\n", - i, j);
          System.exit(0);
        }
        if(- a[i] + a[j] == n)
        {
          System.out.printf("%d %d\n", - i, - j);
          System.exit(0);
        }
      }
    }

  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}

Measured memory_bytes: 34652
#include <iostream>
#include <vector>
#include <algorithm>
#define vi vector<int>
using namespace std;

vi solutions, heights;
vector<bool> sol_ready;
int minimum_cost_to(int position)
{
	if (sol_ready[position])
		return solutions[position];
	int cost1 = minimum_cost_to(position - 1);
	int cost2 = minimum_cost_to(position - 2);
	int height1 = heights[position - 1];
	int height2 = heights[position - 2];
	int min_cost = min(cost1 + abs(heights[position] - height1),
					   cost2 + abs(heights[position] - height2));
	solutions[position] = min_cost;
	sol_ready[position] = true;
	return min_cost;
}
int main()
{
	ios::sync_with_stdio(false);
	int n; cin >> n;
	solutions = vi(n);
	sol_ready = vector<bool>(n);
	heights = vi(n);
	for (size_t i = 0; i < n; i++)
		cin >> heights[i];
	sol_ready[0] = true; sol_ready[1] = true;
	solutions[1] = abs(heights[0] - heights[1]);
	cout << minimum_cost_to(n - 1);
	return 0;
}

Measured memory_bytes: 5760
(function(input) {
  'use strict';

  var n = null
  var words = []
  var wordHash = {}
  input.split("\n").forEach(function(line) {
    if (n == -1) return
    if (line == '') return
    if (n == null) {
      n = parseInt(line, 10)
      return
    }
    words.push(line)
    if (wordHash[line]) {
      n = -1
      return
    }
    wordHash[line] = true
  })
  // console.log('words')
  // console.log(words)
  // console.log('words hash')
  // console.log(wordHash)

  if (n == -1) {
    // すでにあった
    console.log('No')
    return
  }
  if (words.length <= 1) return

  // 処理開始
  var lastChar = null
  var fail = false
  words.forEach((word) => {
    if (fail) return

    if (lastChar == null) {
      // 最初の一回目
      lastChar = word[word.length - 1]
      return
    }

    // 二回目いこう
    if (word[0] != lastChar) {
      fail = true
      return
    }
    lastChar = word[word.length - 1]
  })

  if (fail) {
    console.log('No')
    return
  }
  console.log('Yes')
})(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
N , K = map(int,input().split())
deme = [int(i) for i in input().split() ]

cusum = [0.0] * ( N + 1 )

for x in range( len(deme) ):
    cusum[x+1] = cusum[x] + float(( deme[x] + 1 ) / 2)

ans = 0.0
for i in range( K, len(cusum)):
    if i > 0:
        pre = i - K
        kukan = cusum[i] - cusum[i-K]
        ans = max(ans, kukan)

print(ans)


Measured memory_bytes: 25188
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cstring>
#define N 60000
using namespace std;

int main() {
  int a[N];
  int n,v,j;
//  cin >> n;
  for(int i = 0;i < 4;i++)
    cin >> a[i];

  n = min(a[0],a[1]);
  v = min(a[2],a[3]);
  j = n + v;
  cout << j << endl;


  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;
  cin >> n;
  vector<string> s(n);
  rep(i, n) {
    cin >> s[i];
  }
  vector<ll> list(5, 0);
  rep(i, n) {
    string ss = s[i];
    switch (ss[0]) {
      case 'M':
        list[0]++;
        break;
      case 'A':
        list[1]++;
        break;
      case 'R':
        list[2]++;
        break;
      case 'C':
        list[3]++;
        break;
      case 'H':
        list[4]++;
        break;
      default:
        // 処理なし
        break;
    }
  }
  ll res = 0;
  for (int bit = 0; bit < (1 << list.size()); ++bit) {
    vector<int> S;
    for (int i = 0; i < list.size(); ++i) {
      if (bit & (1 << i)) {
        S.push_back(i);
      }
    }
    if (S.size() != 3) {
      continue;
    }
    res += list[S[0]] * list[S[1]] * list[S[2]];
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 6144
# -*- coding: utf-8 -*-

n = int(input())
s = input()

culmR = []
culmG = []
culmB = []
cR = 0
cG = 0
cB = 0
for i in range(n):
    if s[i] == "R":
        cR += 1
    elif s[i] == "G":
        cG += 1
    else:
        cB += 1
    culmR.append(cR)
    culmG.append(cG)
    culmB.append(cB)
#print(culmR, culmG, culmB)

ans = 0
for i in range(n):
    for j in range(i+1, n):
        #print(i,j)
        if i == j:
            pass
        else:
            count = 0
            #異なる2色を選択したら
            if s[i] != s[j]:
                #差を計算
                diff = j-i
                if "R" not in [s[i], s[j]]:
                    required = "R"
                    #print("R未決定")
                    #累積和の最後とj番目の差
                    count = culmR[-1] - culmR[j]
                    #ただし、diff番目がRの時は除く
                    if (j+diff < n):
                        if s[j+diff] == "R":
                            count -= 1
                    #print("count: ", count)
                elif "G" not in [s[i], s[j]]:
                    required = "G"
                    #print("G未決定")
                    #累積和の最後とj番目の差
                    count = culmG[-1] - culmG[j]
                    #ただし、diff番目がRの時は除く
                    if (j+diff < n):
                        if s[j+diff] == "G":
                            count -= 1
                    #print("count: ", count)
                else:
                    required = "B"
                    #print("B未決定")
                    #累積和の最後とj番目の差
                    count = culmB[-1] - culmB[j]
                    #ただし、diff番目がRの時は除く
                    if (j+diff < n):
                        if s[j+diff] == "B":
                            count -= 1
                    #print("count: ", count)
                ans += count
            #同色ならスキップ
            else:
                pass
print(ans)

Measured memory_bytes: 68640
#include<bits/stdc++.h>
#define reg register
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
string s;
ll ans=inf;
int main(){
    getline(cin,s);
    for(reg int i=0;i<=s.length()-1;i++) 
    if(s[i]!=s[i-1])
    ans=min(ans,max((ll)i,(ll)s.length()-i));
	printf("%lld",min(ans,(ll)s.length()));
    return 0;
}

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

using namespace std;

const int DIM = 1e5 + 7;

int v[DIM];
int pos[DIM];

multiset <int> s;

main()
{
	int n;
	cin >> n;
	
	for(int i = 1; i <= n; i++)
	{
		cin >> v[i];
		
		pos[v[i]] = i;
	}
	
	long long ans = 0;
	
	s.insert(0);
	s.insert(0);
	s.insert(n + 1);
	s.insert(n + 1);
	
	for(int i = n; i >= 1; i--)
	{
		s.insert(pos[i]);
		
		set <int> ::iterator st = s.find(pos[i]);
		set <int> ::iterator dr = st; 
		
		
		int l1, l2, r1, r2;
		
		st--;
		dr++;
		
		l1 = *st;
		r1 = *dr;
		
		st--;
		dr++;
		
		l2 = *st;
		r2 = *dr;
		
		ans += 1LL * i * (r2 - r1) * (pos[i] - l1);
		ans += 1LL * i * (l1 - l2) * (r1 - pos[i]);
	}
	
	cout << ans;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main()
{
  int a,b,i,j;
  scanf("%d%d",&a,&b);
  if(a<b)
  {
    for(i=0;i<b;i++)
    {
      printf("%d",a);
    }

  }
  else
  {
     for(j=0;j<a;j++)
    {
      printf("%d",b);
    }
  }
}
 
             

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

# define s(n)           scanf("%d",&n)
# define sl(n)          scanf("%lld",&n)
# define sc(n)          scanf("%c",&n)
# define forall(i,a,b)  for(i=a;i<b;i++)
# define all(a)         a.begin(),a.end()
# define gcd            __gcd
# define pb             push_back
# define ll             long long int
# define vl             vector<long long int> 

int main(){
ll n,t,i,j,k,p,sum;
vl vec;
array<ll,100005> dp;
cin>>n;
forall(i,0,n){
    cin>>p;
    vec.pb(p);
}
dp.fill(INT_MAX);
dp[1]=0;
sum=0;
dp[2]=abs(vec[0]-vec[1]);
for(i=3;i<=n;i++){
    dp[i]=min(dp[i-1]+abs(vec[i-1]-vec[i-2]),dp[i-2]+abs(vec[i-1]-vec[i-3]));
}
cout<<dp[n];
}

Measured memory_bytes: 4824