akhauriyash/Code-Regression huggingface dataset:
ans = 0
N = int(input())
x = 2
while not N % x:
    ans += 1
    N //= x
    x *= 2
    
while not N % 2:
    N //= 2
    
i = 3

while i*i <= N:
    x = i
    while not N % x:
        ans += 1
        N //= x
        x *= i
        
    while not N % i:
        N //= i
        
    i += 2
    
if N > 1: ans += 1
print(ans)

Measured memory_bytes: 9152
N, K = map(int, input().split())
A = []
for i, a in enumerate(list(map(int, input().split()))):
  if i < K:
    A.append(a)
    continue
  else:
    A.append(a)
    x = A.pop(0)
    if x < a:
      print('Yes')
    else:
      print('No')

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

int main(){
    double r;
    cin >> r;
    cout << fixed << setprecision(5) << r*2*3.14159 << endl;
}

Measured memory_bytes: 3784
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<int> N,M;
  invec<ll> A(N);
  
  int sumA = bst::accumulate(A, 0);
  int sumr = 0;
  
  for (auto i : A) {
    if (i * 4 * M >= sumA)
      sumr++;
  }


  return (sumr >= M ? "Yes" : "No");
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}




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

/*
提出前に確認!
- setとmultisetを間違えない
*/

/*
制約が小さい
n <= 50
s.size() <= 20

一個で回文は別で計算
まず左端と右端に使う文字列を選ぶ -> 2500通り
だめそう

できる回文は全部試さないといけない？
その回文が分割できる二つ以上の回文を含んでいない限りは見ないといけなそう
つまりできる回文の個数は高々10^5とか10^6とかで抑えれるはず

真ん中の文字を決める -> 1000通り * 2(偶数と奇数パターン)
それに合うように文字列を選んでいく?
多分一通りにはならないけど、コスト最小っていう条件をつければ一通り


*/

long long INF = 4e18;

int	main(void)
{
	int n;
	cin >> n;
	vector<string> s(n);
	vector<int> c(n);
	for (int i = 0; i < n; i++) cin >> s[i] >> c[i];
	for (int i = 0; i < n; i++)
	{
		string tmp_s = s[i];
		reverse(tmp_s.begin(), tmp_s.end());
		s.push_back(tmp_s);
	}
	for (int i = 0; i < n; i++) c.push_back(c[i]);
	int id = 0;
	vector<vector<int>> node_id(n * 2);
	for (int i = 0; i < n * 2; i++)
	{
		for (int j = 0; j <= s[i].size(); j++) node_id[i].push_back(id++);
	}
	vector<vector<pair<int, int>>> edge(id);
	for (int i = 0; i < n * 2; i++)
	{
		for (int ni = 0; ni < n * 2; ni++)
		{
			if (i / n == ni / n) continue ;
			//reverseされた文字列を足していく
			for (int j = 0; j < s[i].size(); j++)
			{
				int size = min(s[i].size() - j, s[ni].size());
				//s[i]のsuffixとs[ni]のprefixが一致すればいい
				//s[ni]はreverseされているのでどちらも先頭から見ていけばいい
				bool flag = true;
				for (int k = 0; k < size; k++) 
				{
					if (s[i][j + k] != s[ni][k]) flag = false;
				}
				if (flag == false) continue ;
				//辺をはる
				if (size != s[ni].size()) edge[node_id[i][j]].push_back({node_id[ni][size], c[ni]});
				else edge[node_id[i][j]].push_back({node_id[i][j + size], c[ni]});
			}
		}
	}
	//あとはダイクストラ
	priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> q;
	vector<long long> dist(id, INF);
	vector<bool> is_visited(id, false);
	for (int i = 0; i < 2 * n; i++) q.push({c[i], node_id[i][0]});
	while (q.size())
	{
		long long cost;
		int node;
		tie(cost, node) = q.top(); q.pop();
		if (is_visited[node]) continue;
		is_visited[node] = true;
		dist[node] = cost;
		for (int i = 0; i < edge[node].size(); i++)
		{
			if (is_visited[edge[node][i].first]) continue ;
			q.push({cost + edge[node][i].second, edge[node][i].first});
		}
	}
	long long ans = INF;
	for (int i = 0; i < 2 * n; i++)
	{
		for (int j = 0; j <= s[i].size(); j++)
		{
			if (dist[node_id[i][j]] == INF) continue ;
			string tmp_str = s[i].substr(j);
			reverse(tmp_str.begin(), tmp_str.end());
			if (s[i].substr(j) == tmp_str) ans = min(ans, dist[node_id[i][j]]);
		}
	}
	if (ans == INF) cout << -1 << endl;
	else cout << ans << endl;
	return (0);
}

/*
3
aab 3
ab 1
baaba 100
*/

Measured memory_bytes: 3676
//(・ω・)
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#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 <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
using namespace std;

int main(){
    string s,ans;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

int main() {
    string s;
    cin >> s;

    vi num(s.size());
    bool soo = true;
    rep(i, s.size()) {
        num[i] = s[i]-'a';
        if(num[i] != num[0]) {
            soo = false;
        }
    }


    int ans = 101;
    rep(i, 26) {
        vi num_;
        rep(j, s.size()) {
            num_.push_back(num[j]);
        }

        while(!num_.empty()) {
            bool check = true;
            rep(j, num_.size()-1) {
                if(num_[j] == i || num_[j+1] == i) {
                    num_[j] = i;
                } else {
                    num_[j] = 30;
                    check = false;
                }
            }
            num_.pop_back();
            int le = s.size()-num_.size();
            if(check) {
                ans = min(ans, le);
            }
        }
    }

    if(soo) {
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
}

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

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)6e5 + 7;
const int lmaxn = (int)6e6 + 7;
const ll linf = (ll)1e16 + 7;

const ld eps = ld(1e-11);

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

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}

string a;

bool ok(string x){
    vector < ll > cnt(27, 0);
    for(ll i : x)
        cnt[i - 'a']++;
    for(ll i : x){
        if(cnt[i - 'a'] > (ll)x.size() / 2)
            return 1;
    }
    return 0;
}

int main(){
    cin >> a;
    for(ll len = 2; len <= min((ll)a.size(), 5ll); ++len){
        for(ll i = 0; i + len - 1 < (ll)a.size(); ++i){
            if(ok(a.substr(i, len))){
                cout << i + 1 << " " << i + len;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1;
    return 0;
}



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

int main() {
  int M, N;
  while(cin >> M >> N && M) {
    vector<int> books(N);
    for(int i=0; i<N; i++) {
      cin >> books[i];
    }
    
    int l = 1, r = 1500001;
    while(r - l > 1) {
      int m = (l+r)/2;
      int bpos = 0;
      for(int i=0; i<M; i++) {
	int size = m;
	for(;;) {
	  if(bpos == N) break;
	  if(size - books[bpos] < 0) break;
	  size -= books[bpos++];
	}
	if(bpos == N) break;
      }
      if(bpos == N) {
	r = m;
      } else l = m;
    }
    
    cout << l+1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include<stdio.h>
#include<string>
using namespace std;

int main() {
	int k, n;
	int kukan[200007];
	int housedis;
	int a[200007];
	int max=0;
	cin >> k >> n;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	housedis = a[n-1] - a[0];

	for (int i = 0;i < n-1;i++) {
		kukan[i] = a[i + 1] - a[i];
	}
	kukan[n - 1] = k-housedis;
	for (int i = 0;i < n;i++) {
		if (kukan[i] > max) {
			max = kukan[i];
		}
	}

	cout << k-max << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
vector<P> ret;

void until_plus(multiset<ll> &st) {
    while (st.size() > 2) {
        auto litr = st.begin(); auto ritr = st.end();
        --ritr;
        ll l = *litr; ll r = *ritr;
        if (r >= 0 && *prev(ritr) < 0) break;
        st.erase(litr); st.erase(ritr);
        ret.push_back({l,r});
        st.insert(l-r);
    }
}

void only_plus(multiset<ll> &st) {
    while (st.size() > 2) {
        auto litr = st.begin(); auto ritr = st.end();
        --ritr;
        ll l = *litr; ll r = *ritr;
        st.erase(litr); st.erase(ritr);
        ret.push_back({r,l});
        st.insert(r-l);
    }
}

void predeal(multiset<ll> &st) {
    while (st.size() > 2) {
        auto litr = st.begin(); auto ritr = st.end();
        --ritr;
        ll l = *litr; ll r = *ritr;
        st.erase(litr); st.erase(ritr);
        ret.push_back({r,l});
        st.insert(r-l);
    }
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    multiset<ll> st;
    bool min = true;
    rep(i,n) {
        ll a; cin>>a;
        if (a>0) min = false;
        st.insert(a);
    }

    if (min) predeal(st);
    until_plus(st);
    only_plus(st);

    auto litr = st.begin(); auto ritr = st.end();
    --ritr;
    ll l = *litr; ll r = *ritr;
    ret.push_back({r,l});
    ll ans = r-l;

    cout << ans << endl;
    for (auto &&e: ret) {
        cout << e.first << " " << e.second << endl;
    }
    return 0;
}

/*



*/

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


int main(){
    int n, m; cin >> n >> m;
    int ac = 0, pena = 0;
    vector<int> cnt(n+10);
    rep(i, m){
        int p; string s; cin >> p >> s;
        if(s=="WA"){
            if(cnt[p] != -1) cnt[p]++;
        }else{
            if(cnt[p] != -1){
                ac++;
                pena += cnt[p];
                cnt[p] = -1;
            }
        }
    }
    cout << ac << " " << pena << ln;
}

Measured memory_bytes: 3704
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define UMap        std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    template<class A, class B>inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B>inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        double n, m;
        read n >> m;
        echo ( n / m ) fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


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

int main (){

  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i =0; i<n; i++){
  	cin >> vec.at(i);
  }
  
  int count = 0;
  bool flg = 1;
  while(flg){
   for(int i =0; i<n; i++){
  	if((vec.at(i) % 2) != 0){
      	flg = 0;
    	break;
    }
     else {
       vec.at(i) /= 2;
       	if(i == n-1){
        	count++;
          
        }
     }
 	}
    
  }

  cout << count << endl;

}

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

int main(void)
{
    int N,tmp = 0,ans = 0;
    map<int,int> mp;
    
    cin >> N;
    
    vector<int> a(N);

    for(int i = -1;i <= 100001;i++)
        mp[i] = 0;

    rep(i, N){
        cin >> tmp;
        mp[tmp]++;
    }


    for(int i = 0;i < 100001;i++){
        tmp = mp[i-1]+mp[i]+mp[i+1];

        ans = max(ans,tmp);
    }
    

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 8300
# -*- coding: utf-8 -*-
k, n = map(int, input().split())
a = list(map(int, input().split()))

sum_dist = 0
dist = [0] * n

for i in range(n-1):
    dist[i] = a[i+1] - a[i]
    sum_dist += dist[i]

dist[n-1] = a[0] + k - a[n-1]
sum_dist += dist[n-1]

result = sum_dist - max(dist)

print(result)


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

int main(){
    int n;
    cin >> n;
    bool color[8];
    int ra = 0;
    for(int i=0;i<8;i++){
        color[i] = false;
    }
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(a< 3200){
            color[a/400] = true;
        }
        else{
            ra ++;
        }
    }
    int Min,Max;
    int c = 0;
    for(int i=0;i<8;i++){
        if(color[i]){
            c ++;
        }
    }
    Min = max(c,1);
    Max = c+ra;
    cout << Min << " " <<  Max << endl;
    return 0;
}

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

#define ll long long

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

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

const ll INF = 1LL << 60;
const ll MAX = 100100;
const ll MAX_N = 100100;
const ll MAX_M = 100100;

void aprint(vector<int> &a, int N) {
    for(int i = 0; i < N; i++) {
        if(i)
            cout << " ";
        cout << a[i];
    }
    cout << endl;
}

void MergeCompare(vector<int> &a, int left, int mid, int right) {
    vector<int> buf;

    for(int i = left; i < mid; i++) {
        buf.push_back(a[i]);
    }
    for(int i = right - 1; i >= mid; i--) {
        buf.push_back(a[i]);
    }

    int iterator_left = 0;
    int iterator_right = (int)buf.size() - 1;
    for(int i = left; i < right; i++) {
        if(buf[iterator_left] <= buf[iterator_right]) {
            a[i] = buf[iterator_left];
            iterator_left++;
        } else {
            a[i] = buf[iterator_right];
            iterator_right--;
        }
    }
}

void MergeSort(vector<int> &a, int left, int right) {
    int N = a.size();
    if(right - left == 1) {
        return;
    }
    int mid = left + (right - left) / 2;
    // cout << "left: " << left << endl;
    // cout << "mid: " << mid << endl;
    // cout << "right: " << right << endl;
    MergeSort(a, left, mid);
    MergeSort(a, mid, right);

    MergeCompare(a, left, mid, right);
    aprint(a, N);
}

int main() {

    int n;
    string s;
    cin >> n >> s;
    for(int i = 0; i < s.size(); i++) {
        cout << char((s[i] + n - 'A') % 26 + 'A');
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <utility>
#include <iostream>
#include <cmath>
#include <deque>
#include <string>
#include <time.h>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>
#include <bitset>

#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair

typedef long long ll;
using namespace std;
#define MAXN 10000007
#define MOD 998244353
#define N 1048576
ll n, x, k, z, m, pos, q, ans_v, y;
ll x1, p1, x2;
ll d[100500];
ll c[100500];
vector<ll> rem[100500];
vector<pii> g[100500];
multiset<ll> f;

int main() {
    cin >> n >> k;
    if (n < k * 2 - 1) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 0; i < n; i++) {
        cout << i / 2 + k + (i % 2) * n << " " << (i + n) / 2 + k + ((i+1) % 2) * n << " " << k + 2 * n + i << "\n";
    }
    return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
int n;
string st[200004];
string ss[200004];
map<string,int>q;
int maxn=0;
int cnt=0;
int qr()
{
    int s=0,f=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=(s<<3)+(s<<1)+(ch^48);ch=getchar();}
    return s*f;
}

int main()
{
    cin>>n;
    for(register int i=1;i<=n;i++)
    {
        cin>>st[i];
        q[st[i]]++;
        if(q[st[i]]>maxn)
            maxn=q[st[i]];
    }
    for(register int i=1;i<=n;i++)
    {
        if(q[st[i]]==maxn)
        {
            q[st[i]]=0;
            ss[++cnt]=st[i];
        }
    }
    sort(ss+1,ss+cnt+1);
    for(int i=1;i<=cnt;i++)
        cout<<ss[i]<<endl;
    return 0;
}

Measured memory_bytes: 28288
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    
    for(int i = 0; i < 3; i++){
      if(N%10 == 7){
        System.out.println("Yes");
        return;
      }
      N /= 10;
    }
    System.out.println("No");
    return;
  }
}

Measured memory_bytes: 27068
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll n; cin >> n;
    rep(i,15){
        rep(j,30){
            if(n == i*7 + j*4){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
}


Measured memory_bytes: 256
s=list(input())
def kaubun(s):
    f=1
    for i in range(len(s)//2):
        if s[i]!=s[-i]:
            f=0
    if f:
        return True
    else:
        return False

def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True
f1=1 if is_kaibun(s) else 0
f2=1 if is_kaibun(s[:(len(s)-1)//2]) else 0
f3=1 if is_kaibun(s[(len(s)+3)//2-1:]) else 0
if f1 and f2 and f3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
//#define _GLIBCXX_DEBUG
//#include <atcoder/all>
#include <bits/stdc++.h>


using namespace std;
//using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll D; cin>>D;
  vector<ll> C(26); rep(i,26) cin>>C[i];
  vector<vector<ll>> S(D,vector<ll>(26)); rep(i,D) rep(j,26) cin>>S[i][j];
  vector<int> T(D); rep(i,D) {cin>>T[i]; T[i]--;}
  
  vector<int> last(26,-1);
  ll ans=0;
  
  auto calc=[&](int d,int type){
    ll ret=0;
    ret+=S[d][type];
    last[type]=d;
    rep(i,26){
      ret-=C[i]*(d-last[i]);
    }
    
    return ret;
  };
  
  rep(i,D){
    ans+=calc(i,T[i]);
    cout<<ans<<'\n';
  }
  
  return 0;
}


Measured memory_bytes: 3716
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
visited = [[False for i in range(3)] for j in range(3)]
for i in b:
    for j in range(3):
        for k in range(3):
            if i==a[j][k]:
                visited[j][k] = True

ans = "No"
for i in visited:
    if i==[True,True,True]:
        ans = "Yes"

for i in range(3):
    flag = True
    for j in range(3):
        if visited[j][i]==False:
            flag = False
            break
    if flag:
        ans = "Yes"

if visited[0][0] and visited[1][1] and visited[2][2]:
    ans = "Yes"
if visited[2][0] and visited[1][1] and visited[0][2]:
    ans = "Yes"
print(ans)

Measured memory_bytes: 9208
#pragma GCC optimize (3)
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<bits/stdc++.h>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>*/
#define PII pair<int,int>
#define ll long long
#define ull unsigned long long
#define INFI 2147483647
#define INFL 9223372036854775807
#define INFU 18446744073709551615
using namespace std;
//using namespace __gnu_pbds;
const double PI=acos(-1.0);
const double eps=1e-6;
inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0' || ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
	//ios_base::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
	int a=read(),b=read(),h=read(),m=read();
	double rad=30.0*h+0.5*m-6.0*m;
	if(rad-180.0>eps) rad=360-rad;
	cout<<fixed<<setprecision(10)<<sqrt(a*a*1.0+b*1.0*b-2.0*b*a*cos(PI*rad/180))<<endl;
	return 0;
}


Measured memory_bytes: 4288
#include <stdio.h>
#include <string.h>

#define MAX 20
#define MAX2 1000
int main(void)
{
	char tango[MAX]	= {'\0'};
	char word[MAX2]	= {'\0'};
	int cnt			= 0;
	bool flg		= false;
	int i 			= 0;
	char c;

	scanf("%s", tango);

	while((c = getchar()) != EOF) {
		if ((c == ' ') || (c == '\n')) {
			word[i] = '\0';
			i = 0;
			if (strcmp(tango,word) == 0) {
				cnt++;
			}
		}
		else {
			if ((c >= 'A') && (c <= 'Z')) {
				c += ' ';
			}
			word[i] = c;
			i++;
		}
	}

	printf("%d\n",cnt);

	return 0;
}



Measured memory_bytes: 2824
from collections import deque

n, q = map(int, input().split())
A = [deque() for _ in range(n)]

for _ in range(q):
    query = list(map(int, input().split()))
    if query[0] == 0:
        A[query[1]].append(query[2])
    elif query[0] == 1:
        print(*A[query[1]])
    elif query[0] == 2:
        A[query[1]] = deque()


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int n;
    cin>>n;
    if(n%10==9||n/10==9)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input('').split(' '))
a=input('')
a=a.split(' ')
for i in range(m):
    a[i]=int(a[i])

s=0
for i in range(m):
    s=s+a[i]

if n-s>=0:
    print(n-s)
else:
    print(-1)

Measured memory_bytes: 9548
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, a: [i64; n]);
    let mut d = std::collections::HashMap::<i64, usize>::new();
    let mut ret = 0;
    for i in 0..n {
        let x = i as i64 - a[i];
        match d.get(&x) {
            Some(c) => ret += c,
            _ => (),
        };
        let y = a[i] + (i as i64);
        let e = d.entry(y).or_default();
        *e += 1;
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

int  main()
{
	int n; cin >> n;
	string s[n];
	rep(i, n)
		cin >> s[i];
	set<string> st;
	char e = s[0].back();
	st.insert(s[0]);
	rep1(i, n)
	{
		if (e != s[i].front())
		{
			cout << "No"; return 0;
		}
		if (st.count(s[i]))
		{
			cout << "No"; return 0;
		}
		e = s[i].back();
		st.insert(s[i]);
	}
	cout << "Yes\n";
	return (0);
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main() {

	int a;
	cin >> a;
	int i = 0;
	int ans = 1;
	if (a >= 2) {
		ans = 2;
	}
	if(a >=4){
		ans = 4;
	}
	if (a >= 8) {
		ans = 8;
	}
	if (a >= 16) {
		ans = 16;
	}
	if (a >= 32) {
		ans = 32;
	}
	if (a >= 64) {
		ans = 64;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

a_index = INF
b_index = 0
for i, s in enumerate(S):
    if a_index == INF and s == "A":
        a_index = i
    if s == "Z":
        b_index = i

ans = b_index - a_index + 1
print(ans)


Measured memory_bytes: 9184
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let mut sum: i32 = 0;
    for i in 0..n {
        let (l, r): (i32, i32) = read();
        sum += r - l + 1;
    }
    println!("{}", sum);
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n, m;
vector<int> g[maxn];

int res;

set<int> act;

void dfs(int at) {
    act.insert(at);
    if (int(act.size())==n) res++;
    for (int to: g[at]) {
	if (act.count(to)) continue;
	dfs(to);
	act.erase(to);
    }
}

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

    cin>>n>>m;
    for (int i=0; i<m; i++) {
	int u,v; cin>>u>>v;
	--u; --v;
	g[u].push_back(v);
	g[v].push_back(u);
    }


    dfs(0);

    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct edge{ll to;};
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<bool> used;

    graph(ll n){
        N = n;
        G.resize(N);
        used.resize(N);
        rep(i,N){used[i] = false;}
    }
    void add_edge(ll s, ll t){
        G[s].emplace_back((edge){t});
        G[t].emplace_back((edge){s}); //無向ならON
    }

    ll dfs(ll v=0){
        used[v]=true;
        ll depth=0;
        ll doudep=0;
        map<ll,ll> mp;
        ll ct=0;
        for(auto E : G[v]){ // 4,4,4,5,5
            if(!used[E.to]){
                ll what=dfs(E.to)+1;
                ++mp[what];
                ++ct;
            }
        }
        ll res=0;
        ll mpsize=ct;
        for(auto r:mp){
            maxi(res,r.first+mpsize-1);
            mpsize-=r.second;
        }
        return res;
    }
};

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    graph g(N);
    rep(i,N-1){
        int x; cin>>x; --x;
        g.add_edge(i+1,x);
    }
    cout<< g.dfs() <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 15104
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

typedef long long lli;
typedef pair<int, int> pii;

string s;

void read_input()
{
    cin >> s;
}

void solve()
{
    int ans = 0;
    int i = 0;
    while(i < sz(s))
    {
        if(s[i] == 'S')
            ++i;
        else
        {
            int j = i + 1;
            while(j < sz(s) && s[j] == 'R')
                ++j;
            ans = max(j - i, ans);
            i = j;
        }
    }
    cout << ans << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	while(cin>>n && n){
		int mod2=0, mod5=0;
		for(int i=1;i<=n;i++){
			int tmp, tmp2;
			tmp = i;
			while(1){
				if(tmp % 2==0){
					mod2++;
					tmp /= 2;
				}else{
					break;
				}
			}
			tmp2 = i;
			while(1){
				if(tmp2 % 5==0){
					mod5++;
					tmp2 /= 5;
				}else{
					break;
				}
			}
		}
		cout<<min( mod2, mod5 )<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 100005
#define lint long long
#define trace(x) cout << #x << " = " << x << '\n'
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, x, y, z;
lint mod(lint n) { return (n%MOD + MOD)%MOD; }
lint kali(lint a, lint b, lint c = 1, lint d = 1) { return mod(mod(a*b)*mod(c*d)); }

lint ans;
lint A[MAXN], B[MAXN];

lint up(lint n, lint m) { return (n%m == 0? n: n-n%m+m); }

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%lld%lld", &A[i], &B[i]);
	ans = 0;
	for (int i = N-1; i >= 0; i--) {
		ans += up(A[i]+ans, B[i])-(A[i]+ans);
	}
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
pair<int,int> second_max(pair<int,int> a,pair<int,int> b){
  vector<int> v(0);
  v.push_back(a.first);
  v.push_back(a.second);
  v.push_back(b.first);
  v.push_back(b.second);
  sort(v.begin(), v.end());
  
  return make_pair(v[3],v[2]);
  
}
int main()
{
  int n;
  cin >> n;
  int m = (1<<n);
  vector<int> a(m);
  rep(i,m) cin >> a[i];

  vector<vector<pair<int,int>>> dp(m);
  rep(i,m) dp[i].resize(n+1);
  rep(i,m) dp[i][0] = make_pair(a[i],0);

  rep(j,n){
    rep(i,m){
      if(i&(1<<j)){
	dp[i][j+1] = second_max(dp[i][j],dp[i&~(1<<j)][j]);
      }
      else{
	dp[i][j+1] = dp[i][j];
      }
    }
  }

  vector<int> arr(m);
  rep1(i,m-1){
    arr[i] = dp[i][n].first + dp[i][n].second;
  }

  int res = 0;
  rep1(i,m-1){
    res = max(res,arr[i]);
    cout << res << "\n";
  }
  return 0;
}


Measured memory_bytes: 52224
#!/usr/bin/python3

import os
import sys


def main():
    N = read_int()
    A = read_ints()
    print(solve(N, A))


MOD = 1000000007


def solve(N, A):
    c = 1
    nums = [0, 0, 0]

    for a in A:
        z = nums.count(a)
        if z == 0:
            return 0
        c *= z
        c %= MOD
        nums[nums.index(a)] = a + 1

    return c


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()


Measured memory_bytes: 52932
#include <bits/stdc++.h>  // ver2.2.9
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int scomb(int n, int r){  //  nCr (小さい場合)
int a=1;for(int i=n;i>n-r;--i){a=a*i;}for(int i=1;i<r+1;++i){a=a/i;}return a;}
int comb(int n, int r){  //  nCr (%MOD)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}
int stpow(int n){  //  階乗(%MOD)
if(n==0)return 1;int a=1;rep(i,1,n+1)a=a*i%MOD;return a;}
Vi stpowV(){Vi a(100001);  //  階乗配列(%MOD)
a[0]=1;repeq(i,1,100000)a[i]=a[i-1]*i%MOD;return a;}
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int n,k;
  cin >> n >> k;
  Vi a(n);
  Vin(a);
  
  Vi cost(n);
  cost[0] = 0;
  //  cost[1] = abs(a[0]-a[1]);
  int qw = 0;
  
  rep(i,1,n){
    qw = INF;
    repeq(j,1,k){
      if(i-j < 0) break;
      qw = min(qw,cost[i-j]+abs(a[i]-a[i-j]));
    }
    cost[i] = qw;
    //  cost[i] = min(cost[i-1]+abs(a[i]-a[i-1]),cost[i-2]+abs(a[i]-a[i-2]));
  }
  //Verr(cost);
  cout << cost[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int M=2*100000+5;
int s[M],n,x,i;

int main(){
	cin>>n;
	
	for(i=2;i<=n;i++){
		cin>>x;
		s[x]++;
	}
	
	for(i=1;i<=n;i++)
	cout<<s[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 4372
#include <stdio.h>

#define TRUE 1
#define FALSE -1

void push(int *,int);
int pop(int *);
int isEmpty(int *);

int s_top=0;

int main(){
  char word[7];
  int stack[100];
  int number=0;
  int number_1=0;
  int number_2=0;
  while((scanf("%s",word))!=EOF)
    {
      switch(word[0]){
      case '+':
	number_1=pop(stack);
	number_2=pop(stack);
	push(stack,number_1+number_2);
	break;
	
	case '-':
	  number_1=pop(stack);
	  number_2=pop(stack);
	  push(stack,number_2-number_1);
	  break;
	  
	case'*':
	  number_1=pop(stack);
	  number_2=pop(stack);
	  push(stack,number_1*number_2);
	  break;

      default:
	number=atoi(word);
	push(stack,number);
      }
    }
	
  printf("%d",pop(stack));
  printf("\n");
  return 0;
}

void push(int *S, int x){
  s_top=s_top+1;
  S[s_top]=x;
}

int pop(int *S){
  if(isEmpty(S)==1){
    printf("error\n");
    return 0;
  }
  else s_top=s_top-1;
  return S[s_top+1];
}

int isEmpty(int *S){
  if(s_top==0)return TRUE;
  else return FALSE;
}



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

int main() {
    int n, k;
    cin >> n >> k;
    if(k > (n-1) * (n-2) / 2){
        cout << -1;
        return 0;
    }
    k = ((n-1) * (n-2) / 2) - k;
    vector<pair<int, int> > v;
    for(int i = 2; i < n && k > 0; i++){
        for(int j = i + 1; j <= n && k > 0; j++){
            v.push_back({i, j});
            k--;
        }
    }
    int m = n - 1 + v.size();
    cout << m << endl;
    for(int i = 2; i <= n; i++)
    cout << 1 << " " << i << endl;
    for(int i = 0; i < v.size(); i++)
    cout << v[i].first << " " << v[i].second << endl;
    return 0;
}

Measured memory_bytes: 384
n = gets.to_i
ids = {}
n.times{ ids[gets.chomp] = 1 }
m = gets.to_i
open = false
m.times{
    id = gets.chomp
    if ids[id]
        puts "#{open ? 'Closed' : 'Opened'} by #{id}"
        open = !open
    else
        puts "Unknown #{id}"
    end
}

Measured memory_bytes: 6096
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;

	int st[26];
	int gl[26];
	for (int i = 0; i < 26; i++) {
		st[i] = -1;
		gl[i] = -1;
	}

	for (int i = 0; i < s.length(); i++) {
		int a = s[i] - 'a';
		int b = t[i] - 'a';

		if (st[a] != -1 || gl[b] != -1) {
			if (st[a] != b || gl[b] != a) {
				cout << "No" << endl;
				return 0;
			}
		} else {
			st[a] = b;
			gl[b] = a;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long int h;
cin >> h;
long int x=0;
while (h>0)
{
 x++;
 if(h==1)
 {h=0;}
 h/=2;
 
}
long int atk=0;
for (size_t i = 0 ;i < x; i++)
{
    atk+=pow(2, i);
}

cout << atk << endl;
 

}

Measured memory_bytes: 256
// ~/Remember,remember the 6th of March
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <unordered_map>
#include<unordered_set>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
const double PI = acos(-1.0);
const double  EPS = 1e-11;
typedef long long ll;
const ll MOD = 1000000007;
const int N = 100000 + 7;
typedef unsigned long long ull;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#endif*/
	int x;
	scanf("%d", &x);
	if (x == 3 || x == 5 || x == 7)
		puts("YES");
	else
		puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int t;
	cin >> t;
	cout << (t - 2) * 180 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll n;
  cin >> n;
  vll z(n), w(n);
  rep(i,n) {
    ll x, y;
    cin >> x >> y;
    z[i] = x+y;
    w[i] = x-y;
  }
  ll zmax = -2000000000LL;
  ll zmin = 2000000000LL;
  ll wmax = -2000000000LL;
  ll wmin = 2000000000LL;
  rep(i,n) {
    zmax = max(zmax,z[i]);
    zmin = min(zmin,z[i]);
    wmax = max(wmax,w[i]);
    wmin = min(wmin,w[i]);
  }
  cout << max(zmax-zmin,wmax-wmin) << endl;
  return 0;
}

Measured memory_bytes: 6424
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int ans = 0;
            if (N < 10) {
                ans = N;
            } else if (N < 100) {
                ans = 9;
            } else if (N < 1000) {
                ans = 9 + N % 100 + 1 + 100 * (int) Math.floor((N - 100) / 100.0);
            } else if (N < 10000) {
                ans = 909;
            } else if (N < 100000) {
                ans = 909 + N % 10000 + 1 + 10000 * (int) Math.floor((N - 10000) / 10000.0);
            } else {
                ans = 90909;
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    string s;
    cin >> s;
    cout << s[0] + to_string(s.size() - 2) + s[s.size()-1];
    return 0;
}

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


int main(int argc, char const *argv[])
{
    int N;
    std::cin >> N;
    
    int l = N / 100;
    if (N >= l*100 && N <= l*105) {
        std::cout << 1 << std::endl;
    } else {
        std::cout << 0 << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}




int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

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

    ll ans = min(n, m/2);
    n -= ans;
    m -= 2*ans;

    ans += m/4;
    cout<<ans;
    return 0;
}





Measured memory_bytes: 256