akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 

// #define ANY 900000007
#define ANY 998244353


int main()
{
    int N, K, S; cin >>N>>K>>S;
    string s = to_string(S);
    string s2 = to_string(S==ANY?1:ANY);
    rep(i, K) {
        cout << s; 
        if (i != N-1) cout << " ";
    }
    rep(i, N-K) {
        cout << s2;
        if (i != N-1) cout << " ";
    }
    cout<<endl;
}


Measured memory_bytes: 1280
#include<stdio.h>
int main(){
  int n,m,p,i,j;
  int b[4][13];
  char suit;
   for(i=0;i<4;i++){
      for(j=0;j<13;j++){
	b[i][j]=0;
      }
   }

  scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf(" %c %d", &suit, &m);
      if(suit=='S') p=0;
      if(suit=='H') p=1; 
      if(suit=='D') p=3;
      if(suit=='C') p=2;

      // printf("%c %d",suit,m);
    b[p][m-1]++;      
    }
    for(i=0;i<4;i++){
      for(j=0;j<13;j++){
	if(i==0) suit='S';
	if(i==1) suit='H';
	if(i==3) suit='D';
	if(i==2) suit='C';	
	if(b[i][j]==0) printf("%c %d\n",suit,j+1);

      }
    }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
using namespace  std;

const int MAXSIZE = 100000;
const int END = -1;
struct StNod
{
  int m_nDept;
  int m_nParnt;
  int m_nLChd;
  int m_nRSib;

  StNod() :
    m_nDept(END), m_nParnt(END), m_nLChd(END), m_nRSib(END)
  { }
};

void fnInput(int &rnMaxSiz, vector<StNod> &rvoNod)
{
  StNod oNod;
  rvoNod.resize(MAXSIZE, oNod);

  cin >> rnMaxSiz;

  for (int i = 0; i < rnMaxSiz; i++)
  {
    int nParnt, nCCnt, nChd, nBChd = END;
    cin >> nParnt >> nCCnt;
    for (int j = 0; j < nCCnt; j++)
    {
      cin >> nChd;
      rvoNod[nChd].m_nParnt = nParnt;
      if (nBChd != END) rvoNod[nBChd].m_nRSib = nChd;
      if (!j)          rvoNod[nParnt].m_nLChd = nChd;
      nBChd = nChd;
    }
  }
}

void fnSetDepth(vector<StNod> &rvoNod, int nx, int nDept)
{
  rvoNod[nx].m_nDept = nDept;
  
  if (rvoNod[nx].m_nRSib != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nRSib, nDept);

  if (rvoNod[nx].m_nLChd != END)
    fnSetDepth(rvoNod, rvoNod[nx].m_nLChd, nDept + 1);
}

void fnRtdTree(vector<StNod> &rvoNod)
{
  int nx = 0, nDept = 0;
  while (rvoNod[nx].m_nParnt != END)
    nx = rvoNod[nx].m_nParnt;

  fnSetDepth(rvoNod, nx, nDept);
}

void fnResult(const vector<StNod> &cnrvoNod)
{
  for (int i = 0; i < cnrvoNod.size(); i++)
  {
    if (cnrvoNod[i].m_nDept == END)  break;
    cout << "node " << i << ": parent = " << cnrvoNod[i].m_nParnt << ", depth = " << cnrvoNod[i].m_nDept;

    if (!cnrvoNod[i].m_nDept)            cout << ", root, ";
    else if (cnrvoNod[i].m_nLChd == END) cout << ", leaf, ";
    else                                 cout << ", internal node, ";

    cout << "[";
    if (cnrvoNod[i].m_nLChd != END)
    {
      int nx = cnrvoNod[i].m_nLChd;
      cout << nx;
      while (cnrvoNod[nx].m_nRSib != END)
      {
        cout << ", " << cnrvoNod[nx].m_nRSib;
        nx = cnrvoNod[nx].m_nRSib;
      }
    }
    cout << "]" << endl;
  }
}

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

  int nMaxSiz;
  vector<StNod> voNod;

  fnInput(nMaxSiz, voNod);
  fnRtdTree(voNod);
  fnResult(voNod);
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll mini = numeric_limits<ll>::max();
    cin >> N;
    for(ll i = 1;i * i <= N;i++) {
        if(N % i == 0) {
            ll j = N / i;
            ll count = 0;
            while(j) j /= 10, count++;
            mini = min(mini, count);
        }
    }
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()(vi&a) {
		int n=a.size();
		int ans=0;

		sort(a.begin(), a.end());
		int a_max=a.back();
		vector<bool> f(a_max+1, true);

		for(int i=0;i<n;i++)
		{
			if(!f[a[i]]) continue;
			if(i>0 && a[i]==a[i-1])
			{
				f[a[i]]=false;
				ans--;
				continue;
			}
			ans++;
			for(int j=a[i]*2;j<=a_max;j+=a[i])
			{
				f[j]=false;
			}
		}
		return ans;
	}
};

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

	for(;;)
	{
		int n;
		cin >> n;
		if(cin.fail()) break;
		vi a(n);

		for(auto&m:a) cin >> m;

		cout << solve()(a) << "\n";
	}
	return 0;
}


Measured memory_bytes: 4236
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;

int main()
{
    int n, m;
    while(cin >> n && cin >> m && n && m) {
        int fl[500], flfl[500][500], cnt = 0; queue<int> que;

        memset(fl, 0, sizeof(fl));
        memset(flfl, 0, sizeof(flfl));

        for(int i=0;i < m;++i) {
            int a, b;
            scanf("%d\n%d", &a, &b);

            if (a == 1) fl[b-1] = 1;
            else if (b == 1) fl[a-1] = 1;
            else flfl[a-1][b-1] = 1, flfl[b-1][a-1] = 1;
        }

        int flag = 1;

        for(int i=0;i < n;++i) {
            if (fl[i]) {
                flfl[i][0] = 0;
                que.push(i);
                flag = 0;
                ++cnt;
            }
        }

        if (flag) {
            printf("%d\n", cnt);
        } else {
            while(que.size()) {
                int i = que.front();
                for(int j=0;j < n;++j) {
                    if (flfl[i][j] && fl[j] != 1) {
                        flfl[i][j] = 0;
                        flfl[j][i] = 0;
                        fl[j] = 1;
                        ++cnt;
                    }
                }
                que.pop();
            }

            printf("%d\n", cnt);
        }
    }
    return 0;
}

Measured memory_bytes: 2220
import sys
import heapq
import math
def input(): return sys.stdin.readline().rstrip()
def main():
    n, k = map(int,input().split())
    A = list(map(int,input().split()))
    def is_good(mid, key):
        kk = 0
        for a in A:
            kk += -(-a//mid)-1
        if kk <= key:
            return True
        else:
            return False
    def bi_search(bad, good, key):
        while good - bad > 1:
            mid = (bad + good)//2
            if is_good(mid, key):
                good = mid
            else:
                bad = mid
        return good
    
    print(bi_search(0, 1000000000, k))
    
    
    


if __name__=='__main__':
    main()

Measured memory_bytes: 30972
def main():
    import sys
    input = sys.stdin.readline
    X, K, D = [int(x) for x in input().strip().split()]
    ans = 0
    X = abs(X)
    if X >= K * D:
        print(abs(X-K*D))
    else:
        X, K = X - D * (X // D), K - X // D
        if K % 2:
            print(abs(X-D))
        else:
            print(X)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9140
h,w=map(int,input().split());input();a,d,MAP,w1,h1=list(map(int,input().split())),[],[[0 for i in range(w)] for j in range(h)],0,0
for i,j in enumerate(a):
  for _ in range(j):
    if w1<w:
      MAP[h1][w1]= i+1
      w1+=1
      if w1==w:
        w1=0
        h1+=1
if h>2 and w>2:
  for i in range(h):
    if i%2!=0:
      MAP[i] = MAP[i][::-1]
[print(*i,sep=' ') for i in MAP]

Measured memory_bytes: 9608
n = int(input())
x = list(map(int, input().split()))
minsumhp = 10**9
for i in range(1, 100):
    sumhp = 0
    for j in range(n):
        sumhp += (x[j] - i)**2
    minsumhp = min(sumhp, minsumhp)
print(minsumhp)

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

template<typename T>
auto print(std::vector<T> array) 
 -> void{
	auto iterator = array.begin();
	std::cout<<*iterator;
	iterator++;
	for(;iterator!=array.end();++iterator){
		std::cout<<" "<< *iterator;
	}
	std::cout<<"\n";
}

auto main()
 -> int{

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

	int n;
	std::cin>>n;

	std::vector<int> array(n);
	for(int i=0;i<n;i++)
		std::cin>>array[i];

	for(int i=1;i<n;i++){

		print(array);

		int key = array[i];
		int j = i - 1;
		while(j >= 0 && array[j]>key){
			array[j+1] = array[j];
			j--;
		}
		array[j+1] = key;

	}

	print(array);

	return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
    cin>>s;
    int k,len=s.length();
    scanf("%d",&k);
    for(int i=0;i<len;i++)
    {
    	if(s[i]=='a') continue;
    	if('z'-s[i]+1<=k)
    	{
			k-=('z'-s[i]+1);
    		s[i]='a';
		}
	}
	k%=26;
	s[len-1]+=k;
	cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 1010;
int px[N], py[N], n, t = -1, arr[N], acnt;
void doit(int tx,int ty) {
  if (t == 0) putchar('L');
  rrp (i, 30, 0) {
    if (abs(tx) > abs(ty)) {
      if (tx > 0) putchar('R'), tx -= 1 << i;
      else putchar('L'), tx += 1 << i;
    } else {
      if (ty > 0) putchar('U'), ty -= 1 << i;
      else putchar('D'), ty += 1 << i;
    }
  }
  puts("");
}
int main() {
  read(n);
  rep (i, 1, n) {
    read(px[i]), read(py[i]);
    int tmp = (px[i] + py[i]) % 2 == 0 ? 0 : 1;
    if (t == -1) t = tmp;
    else if (tmp != t) {
      puts("-1");
      return 0;
    }
  }
  if (t == 0) {
    arr[++ acnt] = 1;
    rep (i, 1, n) px[i] ++;
  }
  rep (i, 1, 31) arr[++ acnt] = 1 << (31 - i);
  printf("%d\n", acnt);
  rep (i, 1, acnt)
    printf("%d ", arr[i]);
  puts("");
  rep (i, 1, n) doit(px[i], py[i]);
  return 0;
}


Measured memory_bytes: 256
#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

using mint = modint998244353;

vector<mint> fact, ifact, double_fact;
void init(int n) {
    fact.resize(n+1);
    ifact.resize(n+1);
    double_fact.resize(n+1);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
    double_fact[1] = 1;
    for (int i = 3; i <= n; i += 2) double_fact[i] = double_fact[i-2] * i;
}
mint comb(int n, int k) { return fact[n] * ifact[k] * ifact[n-k]; }
mint perm(int n, int k) { return fact[n] * ifact[n-k]; }

template <typename T>
vector<pair<T, int>> rle(const vector<T>& a) {
    vector<pair<T, int>> res;
    if (a.empty()) return res;
    res.emplace_back(a[0], 0);
    for (size_t i = 0; i < a.size(); ++i) {
        if (res.back().first == a[i]) res.back().second++;
        else res.emplace_back(a[i], 1);
    }
    return res;
}

int main() {
    const int maxn = 100005;
    init(maxn);
    int n;
    cin >> n;
    vector<int> h(2*n);
    rep(i, 2*n) cin >> h[i];
    sort(h.begin(), h.end());
    auto res = rle(h);

    auto comp = [](const vector<mint>& a, const vector<mint>& b) {
        return a.size() > b.size();
    };
    priority_queue<vector<mint>, vector<vector<mint>>, decltype(comp)> q(comp);
    
    rep(i, res.size()) {
        int k = res[i].second;
        vector<mint> d;
        d.push_back(1);
        for (int i = 1; 2 * i <= k; ++i) {
            d.push_back(comb(k, 2*i) * double_fact[2*i - 1]);
        }
        q.push(d);
    }

    while (q.size() >= 2) {
        auto a = q.top(); q.pop();
        auto b = q.top(); q.pop();
        auto c = convolution(a, b);
        q.push(c);
    }

    auto merged = q.top();
    mint ans = 0;
    rep(i, merged.size()) {
        mint now = merged[i] * (i == n ? 1 : double_fact[2*n - 1 - 2*i]);
        if (i % 2 == 0) ans += now;
        else ans -= now;
    }
    cout << ans.val() << '\n';
}

Measured memory_bytes: 11196
n = gets.to_i
res = []
for i in 1..n
  num = gets.strip.split
  # <<は破壊的に要素を末尾に追加する。
  res << [num[0].to_s,num[1].to_i,i]
  # ここで数値と文字を区別せよ、数字は大きさ、文字は字書順整理
  # https://qiita.com/takanatsu/items/39cf827aadc7d06bf48c
end
newews = res.sort {|a, b, c| (a[0] <=> b[0]).nonzero? || (b[1] <=> a[1])}
for i in 1..n
  puts newews[i-1][2]
end

Measured memory_bytes: 14328
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
//#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
struct node{
    int t;
    ll cost;
};

const ll inf = 1LL << 62;
bool ok = true;
vector<int> vis;
vector<ll> pos;
void dfs(vector<vector<node>> &G, int cur) {
    for(node n: G[cur]) {
        if(vis[n.t]){
            if(pos[n.t] - pos[cur] != n.cost) {
                ok = false;
            }
        }
        else {
            vis[n.t] = 1;
            pos[n.t] = pos[cur] + n.cost;
            dfs(G, n.t);
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, M;
    cin >> N >> M;
    vector<vector<node>> G(N);
    rep(i, M) {
        int l, r;
        ll d;
        cin >> l >> r >> d;
        l--, r--;
        G[l].pb({r, d});
        G[r].pb({l, -d});
    }
    pos.assign(N, 0);
    vis.assign(N, 0);
    rep(i, N) {
        if(!vis[i]) {
            vis[i] = 1;
            pos[i] = 0;
            dfs(G, i);
        }
    }
    output(ok ? "Yes" : "No");
    
    
    
    
    return 0;
}


Measured memory_bytes: 16896
N = int(input())
ans = 0

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

N_list = make_divisors(N)
if len(N_list) % 2 == 1:
    odd = len(N_list) / 2 
    i = N_list[int(odd)]
    ans = (i - 1)*2
else:
    even = len(N_list) / 2
    i = N_list[int(even) - 1]
    j = N_list[int(even)]
    ans = i+j-2

print(ans)

Measured memory_bytes: 3268
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>
 
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long> da(n);
    for(int i=0;i<n;i++){
        cin >> da[i];
    }
    vector<vector<long long>> dp(n,vector<long long> (n,0)),si(n,vector<long long> (n,0));
   /* for(int i=0;i<n;i++){
        dp[i][i]=da[i];
    }*/
    for(int i=0;i<n;i++){
        long long me=0;
        for(int j=0;j<n-i;j++){
            me+=da[j+i];
            si[i][i+j]=me;
        }
    }
    for(int i=1;i<n;i++){
        for(int j=0;j<n-i;j++){
            long long ans=10e12;
            for(int k=0;k<i;k++){
                ans=min(ans,dp[j][j+k]+dp[j+k+1][j+i]);
            }
            dp[j][j+i]=ans+si[j][i+j];
        }
    }
    cout << dp[0][n-1] << endl;
    /*for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    }*/
}

Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

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

    string s;
    int cnt[30];
    for (int i=0; i < 30; ++i) cnt[i] = 0;
    cin >> s;
    for (int i = 0; i < s.length(); ++i)
    {
        ++cnt[s[i]-'a'];
        if(cnt[s[i]-'a'] == 2) 
        {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;

    return 0;
}

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

    cin>>n>>k;
    ll h[n];
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
    sort(h,h+n);
    for(i=0;i<n-k;i++)
        sum+=h[i];
    cout<<sum;


}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
struct UnionFind {
private:
    ll N;
    vector<ll> parent;
    vector<ll> num;
    vector<ll> diff_weight;

public:
    UnionFind(ll n){
        N = n;
        rep(i,0,N) parent.push_back(i);
        rep(i,0,N) num.push_back(1);
        rep(i,0,N) diff_weight.push_back(0);
    }
    ll root(ll x){
        if(x == parent[x]){
            return x;
        }else{
            ll r = root(parent[x]);
            diff_weight[x] += diff_weight[parent[x]];
            return parent[x] = r;
        }
    }
    void unite(ll a, ll b, ll w = 0){
        w += weight(a); w -= weight(b);
        a = root(a); b = root(b);
        if(a == b) return;
        parent[b] = a;
        ll sum = num[a] + num[b];
        num[a] = sum;
        num[b] = sum;
        diff_weight[b] = w;
    }

    bool same(ll a, ll b){ return root(a) == root(b);}
    ll sz(ll x){ return num[x];}

    ll weight(ll x){
        root(x);
        return diff_weight[x];
    }

    ll diff(ll a, ll b){
        return weight(b) - weight(a);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    while(cin >> N >> M){
        UnionFind uf(100010);
        while(M--){
            char c;
            cin >> c;
            if(c == '!'){
                ll a,b,c;
                cin >> a >> b >> c;
                a--; b--;
                uf.unite(a,b,c);

            }else{
                ll a,b;
                cin >> a >> b;
                a--; b--;
                if(not uf.same(a,b)){
                    print("UNKNOWN");
                }else{
                    print(uf.diff(a,b));
                }
            }

        }

    }
    
}


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

typedef long long ll;

ll INF=1e10;

int main(){

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

  int D;
  cin>>D;
  int E=min(10,D);

  vector<ll> c(27);
  for(int i=1;i<=26;++i) cin>>c[i];

  vector<vector<ll>> s(D+1,vector<ll>(27,0));
  for(int i=1;i<=D;++i){
    for(int j=1;j<=26;++j){
      cin>>s[i][j];
    }
  }

  vector<ll> t(D+1);
  vector<set<ll>> next(27);
  vector<ll> test(D+1);

  ll ans=0;
  ll val=-INF;

  for(int cnt=0;cnt<3000;++cnt){

    vector<set<ll>> nest(27);
    for(int i=1;i<=26;++i){
      nest[i].insert(0);
      nest[i].insert(D+1);
    }
    
    for(int i=1;i<=E;++i){
      test[i]=rand()%26;
      ++test[i];
      nest[test[i]].insert(i);
    }

    for(int i=E+1;i<=D;++i){
      ll ind=1;
      ll sum=-INF;
      for(int j=1;j<=26;++j){
        auto k=nest[j].lower_bound(i);
        --k;
        ll l=*k;
        ll cmp=s[i][j]+c[j]*(i-l);
        if(cmp>sum){
          sum=cmp;
          ind=j;
        }
      }
      test[i]=ind;
      nest[ind].insert(i);
    }

    ll ch=0;
    for(int i=1;i<=D;++i){
      ch += s[i][test[i]];
      for(int j=1;j<=26;++j){
        auto k=nest[j].upper_bound(i);
        --k;
        ll l=*k;
        ch -= c[j]*(i-l);
      }
    }

    if(ch>val){
      val=ch;
      ans=val;
      for(int i=1;i<=D;++i) t[i]=test[i];
    }
   }

  for(int i=1;i<=D;++i){
    next[t[i]].insert(i);
  }
  for(int i=1;i<=26;++i){
    next[i].insert(0);
    next[i].insert(D+1);
  }

  for(int i=0;i<3000000;++i){

    int d=rand()%D;
    ++d;
    int q=rand()%26;
    ++q;
    ll diff=0;

    //up
    ll l,r;
    auto j=next[q].lower_bound(d);
    r=*j;
    --j;
    l=*j;
    diff += s[d][q]+((r-d)*(d-l))*c[q];

    //down
    next[t[d]].erase(d);
    auto k=next[t[d]].lower_bound(d);
    r=*k;
    --k;
    l=*k;
    diff -= s[d][t[d]]+((r-d)*(d-l))*c[t[d]];

    //update
    if(diff>0){
      next[q].insert(d);
      t[d]=q;
      ans += diff;
    }
    else{
      next[t[d]].insert(d);
    }
  }

  for(int i=1;i<=D;++i) cout<<t[i]<<"\n";

  //cout<<ans<<"\n";

}

Measured memory_bytes: 3724
while(1):
    try:
        a,b,n = [int(i) for i in input().split()]
        num = "{float_:.{length}f}".format(float_=a/b, length=n+1)
        decimal = [int(i) for i in num.split(".")[1]]
        print(sum(decimal[:n]))
    except EOFError:
        break




Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <regex>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rFOR(i,a,b) for(int i=(b);i>=(a);i--)
#define SORT(a) sort((a).begin(),(a).end());
#define rSORT(a) sort((a).rbegin(),(a).rend());
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end());
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;

const ll MOD = 1e9+7;

//sankou
//vvi = vector<vector<int>>(20, vector<int>(10, 0));

//seiki
//#include <regex>
/*bubun*/
//regex_search("u32", regex("[0-9]"));      // true
/*kanzen*/
//regex_match("u32", regex("(i|u)\\d+"));   // true

int isP(int n) {
    if(n<=1) return 0;
    FOR(i,2,(int)sqrt(n)) {
        if(n%i==0) return 0;
    }
    return 1;
}

int main() {

    ll N;
    cin >>N;
    vll a(N);
    ll c0=0,c13=0,c2=0;
    FOR(i,0,N-1){
        cin >>a[i];
        if(a[i]%4==0) c0++;
        if(a[i]%4==1) c13++;
        if(a[i]%4==2) c2++;
        if(a[i]%4==3) c13++;
    }
    Yn(((N-c2)/2>=c13)||((c2==0)&&(c0>0)&&(c0-c13>=-1)));

    return 0;
}

Measured memory_bytes: 1024
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int N, K;
	cin >> N >> K;

	vector<int> H(N);
	for (int i = 0; i < N; i++) cin >> H[i];
	sort(H.begin(), H.end(), greater<>());

	lint ans = 0;
	for (int i = K; i < N; i++) {
		ans += H[i];
	}

	cout << ans << "\n";

	return 0;
}

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

int inf=1<<21;
int n;

int prim_souwa(int G[500][500]){
    int d[n],vstd[n];
    int u=0,sum=0;
    fill(d,d+n,inf);
    fill(vstd,vstd+n,0);
    d[0]=0;
    while(true){
        int mini=inf;
        for(int i=0; i<n; i++){
            if(mini>d[i]&&vstd[i]==0){
                mini=d[i];
                u=i;
            }
        }
        if(mini==inf)break;
        sum+=mini;
        vstd[u]=1;
        for(int i=0; i<n; i++){
            if(G[u][i]<d[i]){
                d[i]=G[u][i];
            }
        }
    }
    return sum;
}

int main(){
    int m;
    int G[500][500];
    while(cin>>n,n){
        cin>>m;
        fill(G[0],G[500],inf);
        for(int i=0; i<m; i++){
            int in1,in2,in3;
            scanf("%d,%d,%d",&in1,&in2,&in3);
            G[in1][in2]=in3;
            G[in2][in1]=in3;
        }
        cout<<prim_souwa(G)/100-(n-1)<<endl;
    }
    return 0;
}

Measured memory_bytes: 4172
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
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;
}

inline ll readll()
{
    ll x=0;int 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;
}

struct node{int to,nxt;}sq[N<<1];
int all=0,head[N];
ll dis[N];

void addedge(int u,int v)
{
    all++;sq[all].to=v;sq[all].nxt=head[u];head[u]=all;
}

void dfs(int u,int fu)
{
    go(u,i) 
        if (v!=fu) 
        {
            dis[v]=dis[u]+1;
            dfs(v,u);
        }
}

struct pnode{int id;ll dis;}p[N];
bool cmp(pnode p,pnode q) {return p.dis>q.dis;}
int n,siz[N];
map<ll,int> mp;
vector<pii> ans;

int main()
{
    n=read();
    rep(i,1,n)
    {
        p[i].dis=readll();
        p[i].id=i;siz[i]=1;
        mp[p[i].dis]=i;
    }
    sort(p+1,p+1+n,cmp);
    rep(i,1,n-1)
    {
        int u=p[i].id;
        int delta=2*siz[u]-n;
        if (delta>=0) {puts("-1");return 0;}
        ll nxt=p[i].dis+delta;
        if (!mp[nxt]) {puts("-1");return 0;}
        int v=mp[nxt];
        siz[v]+=siz[u];
        addedge(u,v);addedge(v,u);
        ans.pb(mkp(u,v));
    }
    //cout << "from " << p[1].id << endl;
    dfs(p[1].id,0);
    ll sum=0;
    //rep(i,1,n) cout << dis[i] << " ";cout << endl;
    rep(i,1,n) sum+=dis[i];
    if (sum!=p[1].dis) {puts("-1");return 0;}
    rep(i,0,n-2) printf("%d %d\n",ans[i].fir,ans[i].sec);
    return 0;
}


Measured memory_bytes: 17912
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(c<=a)cout<<0<<endl;
    else if(c<=a+b)cout<<(c-a)<<endl;
    else cout<<"NA"<<endl;
    return 0;
}



Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int mod=998244353,N=5e5+10;
int Pow(int x,int y) {
    int res=1;
    while(y) {
        if(y&1) res=res*(ll)x%mod;
        x=x*(ll)x%mod,y>>=1;
    }
    return res;
}
int fac[N],inv[N];
void getfac(int n) {
    fac[0]=1; for(int i=1;i<=n;++i) fac[i]=fac[i-1]*(ll)i%mod;
    inv[n]=Pow(fac[n],mod-2); for(int i=n;i>=1;--i) inv[i-1]=inv[i]*(ll)i%mod;
}
int C(int n,int m) { return fac[n]*(ll)inv[m]%mod*inv[n-m]%mod; }
int main() {
    int n,m; rd(n),rd(m); getfac(max(n,m));
    int ans=0;
    for(int i=0;i<=min(n,m);++i)
        ans=(ans+((i&1)?-1:1)*C(n,i)*(ll)C(m,i)%mod*fac[i]%mod*Pow(m+1,n-i)%mod*Pow(n+1,m-i)%mod)%mod;
    printf("%d",(ans+mod)%mod);
    return 0;
}

Measured memory_bytes: 4096
n = int(input())
a = list(map(int,input().split()))

o = []
ans = 0
for i in a:
    if i%2==1:
        o.append(i)
    else:
        ans += i//2

o.sort()
o.reverse()

for i in range(0,len(o)-1,2):
    b = o[i]+o[i+1]
    ans += b//2

print(ans)



Measured memory_bytes: 5600
#include <cstdio>
#include <set>
#include <algorithm>
//#pragma warning(disable:4996)


using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	int mmx = 0;
	set<int> st;
	for (int i = 0; i < n; i++)
	{
		int x;
		scanf("%d", &x);
		if (mmx < x)
			mmx = x;
		st.insert(x);
	}
	int val = mmx / 2;
	auto it = st.lower_bound(val);
	int id = 0;
	if (it != st.end() && *it != mmx)
		id = *it;
	if (it != st.begin())
	{
		--it;
		if (min(*it, mmx - *it) > min(id, mmx - id))
			id = *it;
	}
	printf("%d %d", mmx, id);
}

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

int isSquare(string map[], int x, int y, int size) {
  for(int i = 0; i < size; i++) {
    for(int j = 0; j < size; j++) {
      int nx = x+j, ny = y+i;
      if(nx >= map[0].length() || ny >= map[0].length()) return 0;
      if(map[ny][nx] == '*') return 0;
    }
  }
  return 1;
}

int main() {
  int n;

  while(1) {
    cin >> n;
    if(n == 0) break;
    string map[n];
    getchar();
    for(int i = 0; i < n; i++) {
      getline(cin, map[i]);
    }
    int max = 0;

    for(int s = 1; s <= n; s++) {
      bool flag = false;
      for(int i = 0; !flag && i <= n-s; i++) {
	for(int j = 0; !flag && j <= n-s; j++) {
	  if(isSquare(map, j, i, s)) {
	    max = s;
	    flag = true;
	  }
	}
      }
      if(!flag) break;
    }
    cout << max << endl;
  }
  return 0;
}

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

using namespace std;

#define pb push_back
const int inf = 1e9+10;
const int maxi = 1e6+10;
const int sz = 1<<18;
vector<int> v[maxi];
int a[maxi];
string s;
int n,k;
long long tree[2][maxi];
int d[maxi];
int ma[maxi], mi[maxi];
int p[maxi];

int getMin(int node, int tl, int tr, int l, int r, int t)
{
    if(tr<l || tl>r)
        return inf;
    if (l<=tl && r>=tr)
        return tree[t][node];

    int val1 = getMin(2*node, tl, (tl+tr)/2, l, r, t);
    int val2 = getMin(2*node+1, (tl+tr)/2+1, tr, l, r, t);

    return min(val1, val2);
}

int getMax(int node, int tl, int tr, int l, int r, int t)
{
    if(tr<l || tl>r)
        return 0;
    if (l<=tl && r>=tr)
        return tree[t][node];

    int val1 = getMax(2*node, tl, (tl+tr)/2, l, r, t);
    int val2 = getMax(2*node+1, (tl+tr)/2+1, tr, l, r, t);

    return max(val1, val2);
}

bool check(int s, int len)
{
    if (s+len+k-1>n)
        return 0;
    if (d[s]<s+len-1)
        return 0;

    int first = s+k;
    if (d[first]<first+len-1)
        return 0;

    if (mi[s+len]> a[s+len-1] && ma[s+len]<a[s+len+k])
        return 1;
    return 0;

}
int main()
{
    cin>>n>>k;

    for (int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
        a[i]++;
    }


    d[n] = n;

    for (int i=n-1; i>0; i--)
        if (a[i]<a[i+1])
            d[i] =d[i+1];
        else
            d[i] = i;


    for (int i=1; i<=n; i++)
        tree[0][sz+i -1 ] = a[i];

    for (int i=sz+n; i<2*sz; i++)
        tree[0][i] = inf;

    for (int i=sz-1; i>0; i--)
        tree[0][i] = min(tree[0][2*i], tree[0][2*i+1]);

    for (int i=1; i<=n; i++)
        tree[1][sz+i - 1] = a[i];

    for (int i=sz-1; i>0; i--)
        tree[1][i] = max(tree[1][2*i], tree[1][2*i+1]);


    for (int i=1; i<=n-k+1; i++)
    {
        ma[i] = getMax(1, 1, sz, i, i+k-1, 1);
        mi[i] = getMin(1, 1, sz, i, i+k-1, 0);
    }

    int ans = 0;
    int cur = 1;


    while(cur<=n-k+1)
    {
        if (cur == n-k+1)
        {
            ans++;
            cur++;
        }
        else if (a[cur]==mi[cur] && a[cur+k]>ma[cur])
            cur++;
        else
        {
            ans++;
            cur++;
        }
    }

    int nasao = 0;
    int pre = -1;

    for (int i=1; i<=n-k+1; i++)
    {
        if (d[i] - i>=k-1)
        {
            if (pre!=i-1){
                ans--;
            }
            pre = i;
        }
    }

    if (pre>-1)
        ans++;
    cout<<ans<<endl;

    return 0;
}
//sanjao sam ruke njene
//da je sada pored mene


Measured memory_bytes: 50688
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int *servants_cnt = new int[N+1];
  for (int i = 0; i <= N; i++) servants_cnt[i] = 0;
  for (int i = 2; i <= N; i++) {
    int A;
    cin >> A;
    servants_cnt[A]++;
  }
  for (int i = 1; i <= N; i++) {
    cout << servants_cnt[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4408
let get_2_ints () = Scanf.scanf "%d %d " (fun u v -> u,v)

let () =
  let (x,y) = get_2_ints ()
  in let rec f0 i k =
    if i>y then k else f0 (i*2) (k+1)
  in f0 x 0 |> string_of_int |> print_endline

Measured memory_bytes: 384
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
map<int,int> m;
int main(){
	fastio;
	int n;
	cin>>n;
	rb(i,1,n)
	{
		int a;
		cin>>a;
		m[a]++;
		if(m[a]>1){
			cout<<"NO";
			return 0;
		}
	}
	cout<<"YES";
	return 0;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
typedef long long lli;
int n;

void ReadInput()
{
    cin >> n;
}

void Solve()
{
    int ans = 0;
    for(int i = 1; i * 2 < n; ++i)
    {
        int t = n - i;
        if(i != t) ++ans;
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define fi first
#define se second
const int inf = 1e15;
int mod = 1e9+7;

//最小値取得
class SegmentTree{
public:
	int n = 1;
	vector<int> seg[2];
	//m要素のセグメントツリー作成
	void init(int m){
		while(n < m)n *= 2;
		rep(i,2)seg[i].resize(2*n);
		rep(i,2)fill(all(seg[i]), inf);
	}
	//kの値をxに変更
	void update(int t, int k, int x){
		k += n-1;
		seg[t][k] = x;
		while(k > 0){
			k = (k-1)/2;
			seg[t][k] = min(seg[t][k*2+1], seg[t][k*2+2]);
		}
	}
	int calc(int t, int a, int b, int k, int l, int r){
		if(b <= l || r <= a)return inf;
		if(a <= l && r <= b)return seg[t][k];
		int vl = calc(t, a, b, k*2+1, l, (l+r)/2);
		int vr = calc(t, a, b, k*2+2, (l+r)/2, r);
		return min(vl, vr);
	}
	//[a,b)の最小値を求める
	int get(int t, int a, int b){return calc(t, a, b, 0, 0, n);}
};

int a[200004], dp[2][200004];
int n, q, x, y;
SegmentTree seg;
int solve(){
	int ans = inf, mem = 0;
	rrep(i,q){
		int vl = seg.get(0, 0, a[i])+a[i];
		int vr = seg.get(1, a[i], n)-a[i];
		int res = min(vl, vr)-llabs(a[i]-a[i-1]);
		seg.update(0, a[i-1], res-a[i-1]);
		seg.update(1, a[i-1], res+a[i-1]);
		mem += llabs(a[i]-a[i-1]);
	}
	rep(i,n)chmin(ans, seg.get(0, i, i+1)+i);
	return ans+mem;
}

signed main(){
	scanf("%lld%lld%lld%lld", &n, &q, &x, &y);
	rrep(i,q)scanf("%lld", &a[i]), a[i]--;
	x--;y--;
	
	int ans = inf;
	a[0] = y;
	seg.init(n+1);
	seg.update(0, x, -x);
	seg.update(1, x, x);
	chmin(ans, solve());
	
	a[0] = x;
	seg.init(n+1);
	seg.update(0, y, -y);
	seg.update(1, y, y);
	chmin(ans, solve());
	
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 11136
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll N;
    cin >> N;
    rep(i, 3500) {
        rep(j, 3500) {
            ll h = i+1;
            ll n = j+1;
            ll Nhn = N * h * n;
            ll bunbo = 4*h*n - N * n - N * h;
            if (bunbo == 0) continue;
            ll w = Nhn / bunbo;
            if (w <= 0 || 3500 < w) continue;
            if (4*h*n*w == N * (n*w + h*w + h*n)) {
                print(h << " " << n << " " << w);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
l = input()

n = [0  for i in range(len(l)+1)]
c = 1
i=1
for x in l:
    if x == '<':
        n[i] = c
        c+=1
    else:
        c=1
    i+=1
c=1
i=1
n_=[0 for i in range(len(l)+1)]
for x in reversed(l):
    if x == '>':
        n_[i] = c
        c+=1
    else:
        c=1
    i+=1

n_=list(reversed(n_))

ans = [max(n[i],n_[i]) for i in range(len(l)+1)]
print(sum(ans))


Measured memory_bytes: 33496
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define reprev(i,n) for(ll i=n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

const int mod = 1e9+7;
const long double pi = acos(-1);

ll power(ll x, ll y){
	x %= mod;
	if(y == 0) return 1;
	if(y == 1) return x;
	ll num = power(x,y/2) % mod;
	if(y%2 == 0) return (num*num)%mod;
	else return (((num*num)%mod)*x)%mod;
}

void solve(){

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

	return;
}

int main(){

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

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int N;
    cin >> N;
    OREP(i,9){
        if(N<=111*i){
            cout << 111*i << endl;
            return 0;
        }
    }
    
    return 0;
}   


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int X;
  int Y;
  int Z;

  int tmp;

  scanf("%d", &X);
  scanf("%d", &Y);
  scanf("%d", &Z);
  tmp = X;
  X = Y;
  Y = tmp;

  tmp = X;
  X = Z;
  Z = tmp;

  printf("%d %d %d\n", X, Y, Z);
  return 0;
}

Measured memory_bytes: 1732
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  int x,a,b;
  cin>>x>>a>>b;
  if(abs(x-a)<abs(x-b)) cout<<"A"<<endl;
  else cout<<"B"<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long longconst 
#define MAXN  100005
int arr[MAXN]; 
int main(){    
	ios::sync_with_stdio(0);    
	int n, flag = 0;    
	cin>>n;    
	arr[0] = 0;    
	for(int i = 1; i <= n; i++)    
	{        
		cin>>arr[i];    
	}    
	for(int i = 1; i <= n; i++)    
	{        
		if(arr[i-1] - arr[i] == 1)            
			arr[i-1]--;        
		else if(arr[i] == arr[i-1] && arr[i] > arr[i-2])           
			arr[i-1]--;        
		else if(arr[i] < arr[i-1] && arr[i-1] - arr[i] > 1)        
		{            
			flag = 1;            
			break;        }    
	}    
	for(int i = 1; i <= n; i++)    
	{        
		if(arr[i] < arr[i-1])        
		{            
			flag = 1;            
			break;        
		}    
	}    
	if(flag) 
		cout<<"No"<<endl;    
	else cout<<"Yes"<<endl;    
	return 0;
} 


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

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

	int sum = 0;
	
	for (int i = 0; i < N.size(); i++)
	{
		sum += N[i] - '0';
	}


	if (sum % 9 == 0)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	
}


Measured memory_bytes: 3724
#include<iostream>
#include<list>
using namespace std;
int q;
main()
{
	cin>>q;
	list<int>a;
	auto it=a.end();
	for(int i=0;i<q;i++)
	{
		int c;cin>>c;
		if(c==0)
		{
			int x;cin>>x;
			it=a.insert(it,x);
		}
		else if(c==1)
		{
			int p;cin>>p;
			advance(it,p);
		}
		else
		{
			it=a.erase(it);
		}
	}
	for(int i:a)cout<<i<<endl;
}


Measured memory_bytes: 18620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    while(true){
        ll H, W;
        cin >> H >> W;
        if(H == 0 && W == 0){ break; }

        REP(i, H){
            REP(j, W){
                if(i == 0 || i == H - 1 || j == 0 || j == W - 1){
                    cout << '#';
                }else{
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3084