akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>

using namespace std;
int main(){
    int N,K;
    cin >>N >>K;
    char s[N+1];
    for(int i=1;i<=N;i++){
        cin >> s[i];
    }
    int x='A'-'a';
    s[K]-=x;
    for(int i=1;i<=N;i++){
        cout <<s[i];
    }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(i,n) rep2(i,0,n)
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int> p(n+1),inv_p(n+1);
    rep2(i,1,n+1)cin >> p[i];
    rep2(i,1,n+1)inv_p[p[i]]=i;
    multiset<int> s;
    s.emplace(0);
    s.emplace(n+1);
    s.emplace(0);
    s.emplace(n+1);
    ll sum=0;
    for(int i=n;i>0;--i){
        //...p[a]...p[b]...p[i]...p[c]...p[d]...
        auto itr=s.lower_bound(inv_p[i]);
        ll c=*itr;
        ++itr;
        ll d=*itr;
        --itr;
        --itr;
        ll b=*itr;
        --itr;
        ll a=*itr;
        sum+=((b-a)*(c-inv_p[i])+(inv_p[i]-b)*(d-c))*i;
        s.emplace(inv_p[i]);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 5760
H=int(input())+1
A=[0]+list(map(int,input().split()))
def h(i):
 l=2*i;r=l+1
 g=l if l<H and A[i]<A[l]else i
 if r<H and A[g]<A[r]:g=r
 if g>i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


Measured memory_bytes: 64812
<?php
  $num = fscanf(STDIN, "%d", $a);
  $str =  explode(" ", fgets(STDIN));

$count = 0;
$flag = 0;
while(!$flag){
	foreach($str as $key => $val){
		if($val % 2 == 1){
    		$flag++;
        	break;
        }else{
        	$str[$key] = $str[$key] / 2;
        }
	}
  	if($flag){break;}
  	$count++;
}

echo $count . "\n";
?>

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;;

const ll INF = 5e15;
const P impossible = P(-1, -1);
vector<vector<ll>> edge;
vector<ll> X;

P dfs(ll now, ll pre){
    vector<P> ret;
    for(ll next : edge[now]) if(next != pre) ret.push_back(dfs(next, now));
    if(!ret.size()) return P(0, X[now]);
    vector<ll> dp(5001, INF);
    dp[0] = 0;
    for(P r : ret){
        if(r == impossible) return impossible;
        vector<ll> nextdp(5001, INF);
        for(ll i = 0; i <= 5000; i++){
            if(i + r.first > 5000) break;
            if(dp[i] == INF) continue;
            if(dp[i] != INF) nextdp[i + r.first] = min(nextdp[i + r.first], dp[i] + r.second);
            if(i + r.second <= 5000) nextdp[i + r.second] = min(nextdp[i + r.second], dp[i] + r.first);
        }
        dp = nextdp;
    }
    vector<P> tmp;
    for(ll i = 0; i <= 5000; i++){
        if(dp[i] != INF){
            if(i <= X[now] && dp[i] <= X[now]) tmp.push_back(P(min(i, dp[i]), X[now]));
            else if(i > X[now] && dp[i] > X[now]) continue;
            else tmp.push_back(P(X[now], max(i, dp[i])));
        }
    }
    if(!tmp.size()) return impossible;
    sort(tmp.begin(), tmp.end());
    return tmp[0];
}

int main(){
    ll N;
    cin >> N;
    edge.resize(N);
    X.resize(N);
    for(ll i = 1; i < N; i++){
        ll p;
        cin >> p;
        edge[i].push_back(--p);
        edge[p].push_back(i);
    }
    for(ll &x : X) cin >> x;
    P ans = dfs(0, -1);
    if(ans == impossible) cout << "IM";
    cout << "POSSIBLE\n";
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<LL, int>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define a first
#define b second
#define pb push_back
#define all(x) x.begin(), x.end()

int main(){
    
    // 1. 入力情報.
    int X, Y, A, B, C;
    scanf("%d %d %d %d %d", &X, &Y, &A, &B, &C);
    LL x;
    priority_queue<LL> pPQ, qPQ, r, apple;
    rep(i, A){
        scanf("%lld", &x);
        pPQ.push(x);
    }
    rep(i, B){
        scanf("%lld", &x);
        qPQ.push(x);
    }
    rep(i, C){
        scanf("%lld", &x);
        r.push(x);
    }
    
    // 2. X個 の 赤色リンゴ, Y個 の 緑色リンゴ を 保存.
    priority_queue<P, vector<P>, greater<P>> pq;
    int c1 = 0, c2 = 0;
    while(++c1 <= X){
        LL p = pPQ.top();
        pPQ.pop();
        pq.push({p, 1});
    }
    while(++c2 <= Y){
        LL q = qPQ.top();
        qPQ.pop();
        pq.push({q, 2});
    }
    // while(!pq.empty()){
    //     P p = pq.top();
    //     pq.pop();
    //     printf("%lld %d\n", p.a, p.b);
    // }
    
    // 2. 組み換え.
    // pq の 最小の美味しさのリンゴ と r の 最大の美味しさのリンゴ を 
    // 比較して, 組み換え.
    while(!pq.empty()){
        // pq から 取得.
        P a1 = pq.top();
        
        if(!r.empty()){
            // r から 取得.
            LL a2 = r.top();
            
            // リンゴ a1 が 赤色 の 場合, リンゴ a2 の 美味しさ が 大きい場合, 入れ替え.
            if(a1.b == 1 && X > 0 && a1.a < a2){
                pq.pop();
                pq.push({a2, 3});
                r.pop();
                X--;
                continue;
            }
            
            // リンゴ a1 が 緑色 の 場合, リンゴ a2 の 美味しさ が 大きい場合, 入れ替え.
            if(a1.b == 2 && Y > 0 && a1.a < a2){
                pq.pop();
                pq.push({a2, 3});
                r.pop();
                Y--;
                continue;
            }
        }
        
        // 組み替え出来なかった場合.
        pq.pop();
        apple.push(a1.a);
    }
    
    // 4. 美味しさの集計.
    LL ans = 0;
    while(!apple.empty()){
        LL a = apple.top();
        apple.pop();
        ans += a;
        // printf("%lld\n", a);
    }
    
    // 5. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 10092
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  ll a,b,x; cin >> a >> b >> x;
  if(a != 0) cout << b/x+1-((a-1)/x+1);
  else cout << b/x+1;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>

using namespace std;
int a;
int main()
{
    cin >> a;
    if(a < 1200){
        cout << "ABC";
    }else if(1200 <= a && a < 2800){
        cout << "ARC";
    }else{
        cout << "AGC";
    }
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 057 B / Link: http://abc057.contest.atcoder.jp/tasks/abc057_b  ----- */


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

	LL N, M; cin >> N >> M;
	vector<LL> a(N), b(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i] >> b[i];
	}
	vector<LL> c(M), d(M);
	for (int i = 0; i < M; ++i) {
		cin >> c[i] >> d[i];
	}
	FOR(i, 0, N) {

		int ansid = 0;
		int dist = INF;
		FOR(j, 0, M) {
			int dd = abs(a[i]-c[j])+abs(b[i]-d[j]);
			if (dist > dd) {
				dist = dd;
				ansid = j + 1;
			}
		}
		cout << ansid << endl;
	}

	return 0;
}


Measured memory_bytes: 256
// インクルード
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>

// 名前空間省略
using namespace std;

// メイン
int main()
{
	// 入出力の高速化
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// 表示精度変更
	cout << fixed << setprecision(16);

    int a,b,h;
    cin >> a >> b >> h;

	cout << (a+b)*h/2 << endl;
	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const long mod=1e9+7;
int N,K;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
long dp[1<<17];
main()
{
	cin>>N>>K;
	long ans=0;
	for(int k=K;k>=1;k--)
	{
		dp[k]=power(K/k,N);
		for(int j=k+k;j<=K;j+=k)dp[k]-=dp[j];
		ans+=k*dp[k]%mod;
	}
	cout<<ans%mod<<endl;
}


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

int main(){
 int N;
 cin >> N;
 vector<int>a(N);
 vector<int>b(N);
 int ans=N;
 int j=1;
 for (int i = 0; i < N; i++){
    cin >> a.at(i);
 }
 for (int i = 0; i < N; i++){
    if(a.at(i)==j){
     b.at(i)=j;
     j++;
    }
    
 }
 for (int i = 0; i < N; i++){
     if(b.at(i)>0){
         ans--;
     }
 }
 if(j==1){
  ans=-1;
 }
 cout << ans << endl;
 
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int n = cin.nextInt();
        int m = cin.nextInt();

        int[] h = cin.ArrayInt(n);

        List<int>[] roads = new List<int>[n];
        for (int i = 0; i < n; ++i)
        {
            roads[i] = new List<int>();
        }

        for (int i = 0; i < m; ++i)
        {
            int a = cin.nextInt();
            int b = cin.nextInt();


            roads[a - 1].Add(b-1);
            roads[b - 1].Add(a-1);
        }

        int ans = 0;

        for (int i = 0; i < n; ++i)
        {
            bool good = true;
            foreach(var road in roads[i])
            {
                if (h[i] <= h[road])
                {
                    good = false;
                    break;
                }
            }

            if (good) ++ans;
        }

        WriteLine(ans);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 60308
def lmi(): return list(map(int, input().split()))

n, m = lmi()
s = [lmi() for i in range(m)]
p = lmi()
on = [0] * n
ans = 0
for i in range(1 << n):
    for j in range(n):
        on[j] = i%2
        i = i >> 1

    c = 0
    for j in range(m):
        wa = sum([on[x] for x in range(n) if x+1 in s[j][1:]])
        if wa%2 == p[j]:
            c += 1

    if c == m:
        ans += 1

print(ans)


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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template< int mod >
struct Combination
{
  vector< int64_t > mfact, rfact;

  Combination(int sz) : mfact(sz + 1), rfact(sz + 1)
  {
    mfact[0] = 1;
    for(int i = 1; i < (int)mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }

  int64_t fact(int k) const
  {
    return (mfact[k]);
  }

  int64_t pow(int64_t x, int64_t n) const
  {
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int64_t inv(int64_t x) const
  {
    return (pow(x, mod - 2));
  }

  int64_t P(int n, int r) const
  {
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }

  int64_t C(int p, int q) const
  {
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }

  int64_t H(int n, int r) const
  {
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);
  
  int n, k; cin >> n >> k;

  cout << n-k+1 << endl;
}


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

int main() {
  int n, i, j, elm, m;
  int range = pow(10, 6);
  cin >> n;

  vector<int> A(n);
  for (i = 0; i < n; i++) {
    cin >> A.at(i);
  }

  vector<int> cnt(range + 1, 0);

  for (i = 0; i < A.size(); i++) {
    cnt[A[i]] += 1;
  }

  vector<int> uni;

  for (i = 0; i < range + 1; i++) {
    if (cnt[i] == 1) {
      uni.push_back(i);
    }
  }

  cnt = vector<int>(range + 1, 0);
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());

  for (i = 0; i < A.size(); i++) {
    for (m = A[i] * 2; m < range + 1; m += A[i]) {
      cnt[m] = 1;
    }
  }

  int ans = 0;

  for (i = 0; i < uni.size(); i++) {
    if (cnt[uni[i]] == 0) {
      ans += 1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 12616
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
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;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}

using namespace std;

void solve()
{
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  map<ll, ll> mp;
  rep(i,n){
    mp[-a[i] + i]++;
  }
  ll ans = 0;
  rep(i, n){
    ans += mp[a[i] + i];
    //mp[a[i] + i]--;
  }
  cout << ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    solve();
    return 0;
}



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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  

double eps = .000000001;

int n, m;
int lowest = 1000000000;
int dists[1001];
int myvis[1001];
bool vis[1001];
vector<int> graph[1001];
int choose = 0;
void func(int node, int dist){
    //cout << node << endl;
   for (int i=0; i<graph[node].size(); i++){
       int cur = graph[node][i];
       if (myvis[cur]){
           if (dist-dists[cur] < lowest){
               lowest = dist-dists[cur];
               choose = node;
           }
       }
       if (vis[cur]){
           continue;
       }
       vis[cur] = true;
       myvis[cur] = true;
       dists[cur] = dist+1;
       func(cur, dist+1);
       myvis[cur] = false;
   }
}
int main ()
{
  prep();
  
  cin >> n >> m;
  
  for (int i=0; i<m; i++){
      int a, b;
      cin >> a >> b;
      graph[a].push_back(b);
  }
  
  memset(dists, -1, sizeof(int)*(n+1));
  // see node where loop can be
  
  for (int i=1; i<=n; i++){
      if (vis[i]){
          continue;
      }
      vis[i] = true;
      myvis[i] = true;
      func(i, 0);
      myvis[i] = false;
  }
  if (choose == 0){
      cout << -1;
      return 0;
  }
  // from node find cycle
  memset(vis, false, sizeof(bool)*(n+1));
  
  queue<int> q;
  q.push(choose);
  vis[choose] = true;
  int pars[n+1] = {0};
  int end = 0;
  bool found  = false;
  bool start = true;
  while (!q.empty() && !found){
      int front = q.front();
      q.pop();
   
      for (int i=0; i<graph[front].size(); i++){
          if (graph[front][i] == choose && !start){
              found = true;
              end = front;
              break;
          }
          int cur = graph[front][i];
          start = false;
          if (vis[cur]){
              continue;
          }
          
          pars[cur] = front;
          //cout << graph[front][i] << " " << front << endl;
          vis[cur] = true;
          q.push(cur);
      }
  }

  vector<int> res;
  while (true){
      if (end == 0){
          break;
      }
      res.push_back(end);
      end = pars[end];
  }
  cout << res.size() << '\n';
  for (int i : res){
      cout << i << '\n';
  }
  return 0; 
}


Measured memory_bytes: 384
class SegmentTree
	def initialize(arr, l = 0, r = arr.size - 1)
		@l = l
		@r = r
		if l == r
			@max = arr[l]
		else
			c = (l + r) / 2
			@left_child = self.class.new(arr, l, c)
			@right_child = self.class.new(arr, c+1, r)
			lm = @left_child.max
			rm = @right_child.max
			@max = (lm > rm ? lm : rm)
		end
	end

	def query(r)
		return @max if r == @r
		if r <= @left_child.r
			return @left_child.query(r)
		else
			lm = @left_child.max
			rm = @right_child.query(r)
			return lm > rm ? lm : rm
		end
	end

	def update(i, x)
		if @l == @r
			@max = x	
		elsif i <= @left_child.r 
			@left_child.update(i, x)
			@max = @left_child.max if @left_child.max > @max
		else
			@right_child.update(i, x)
			@max = @right_child.max if @right_child.max > @max
		end
	end

	attr_reader :max, :l, :r
end

n = gets.to_i
t = SegmentTree.new([0] * (n+1))
gets.split.map(&:to_i).each do |x|
	t.update(x, t.query(x - 1) + x)
end
p n * (n + 1) / 2 - t.max

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

const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;

int n;
double a[110];

int main() {
  cin >> n;

  double d[110];
  double sum = 0.0;
  rep(i,n) {
    cin >> a[i];
    d[i] = 1.0 / a[i];
    sum += d[i];
  }
  

  double ans = 1.0 / sum;
  cout << fixed;
  cout << setprecision(20) << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 

using namespace __gnu_pbds;
using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

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

#define FOR(i, n) for (ll i = 0; i < n; i++)
#define FORN(i, a, b) for (ll i = a; i < b; i++)
#define FORE(i, l) for (auto i : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) n.begin(), n.end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n, m;
    cin >> n >> m;
    vll nums(n);
    ll tot = 0;
    FOR(i, n) 
    {
        cin >> nums[i];
        tot += nums[i];
    }
    sort(all(nums));
    ll check = (tot + m * 4 - 1) / (4 * m);
    auto index = lower_bound(all(nums), check);
    cout << (nums.end() - index >= m ? "Yes\n" : "No\n");

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	const int n = 3;
	array<int, n> arr = {a, b, c};
	int max = arr.at(0);
	for( int i = 1; i < n; ++i ){
		if( max < arr.at(i) ){
			max = arr.at(i);
		}
	}
	int ans = accumulate(arr.begin(), arr.end(), 0) + max*(1<<k) - max;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	Ln := make([]int, N)
	for i := range Ln {
		Ln[i] = nextInt()
	}
	sort.Ints(Ln)
	var ans int
	for i := 0; i < N-2; i++ {
		for j := i + 1; j < N-1; j++ {
			for k := j + 1; k < N; k++ {
				a, b, c := Ln[i], Ln[j], Ln[k]
				if c-b < a {
					ans++
				}
				// if a+c > b && a+b > c {
				// 	fmt.Println(a, b, c)
				// 	ans++
				// }
				if a+b < c {
					break
				}
			}
		}
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1856
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
ps = LI()
sps = list(sorted(ps))

diff = 0
for i, j in zip(ps,sps):
    diff += i != j

if diff == 2 or diff == 0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
//#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

struct UnionFind {
    vector<int> par;
    vector<int> si;
    UnionFind(int N) : par(N), si(N) {
        for(int i = 0; i < N; ++i) par[i] = i;
        for(int i = 0; i < N; ++i) si[i] = 1;
    }

    int root(int x) {
        if(par[x] == x)return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        si[ry] += si[rx];
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return si[root(x)];
    }
};
int N, C;
const int MAX_T = 1e5 + 1;



int main() {
    cin >> N >> C;
    vector<vector<int>>S(C, vector<int>(MAX_T, 0));
    int ans = 0;
    rep(i, N){
        int s, t, c;
        cin >> s >> t >> c;
        S[c - 1][s - 1] += 1;
        S[c - 1][t - 1] += -1;
    }

    rep(i, 1e5) {
        int tmp = 0;
        rep(j, C) {
            S[j][i + 1] += S[j][i];
            if(S[j][i + 1] == 1)S[j][i] = 1;
            tmp += S[j][i];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 14072
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    bool f; char ch; f=0; x=0; 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();}
    if(f) x=-x;
}

template< typename T > inline void Max(T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min(T &a, T b) {if(b<a) a=b;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double pi=(double) acos(-1.0);
const int MOD=(int) 1e9+7;
const int INF=(int) 0x3f3f3f3f;
const LL  LINF=(LL) INF<<32|INF;
const int SINF=(uint) ~0>>1;
const LL  SLINF=(ULL) (-1)>>1;
const double DINF=(double) 1e50;
const double eps=(double) 1e-8;
const int maxn=(int) 200000+20;
const int maxm=(int) 1e5+20;
const int maxk=(int) 5e2+20;

inline int sig(double x) {return x<-eps?-1:x>eps;}

//--------------start------------------

void work()
{
    LL n,m;
    read(n), read(m);
    LL ans=(n-m)*100+m*1900;
    for(int i=0;i<m;i++) ans*=2;
    cout <<ans <<endl;
}

//--------------end--------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[110000],b[110000]={0};
	int n,i;
	cin >> n;
	for(i=0;i<n;i++) cin >> a[i];
	for(i=0;i<n;i++){
		b[a[i]+1]++;
		b[a[i]]++;
		b[a[i]-1]++;
	}
	sort(b,b+110000);
//	for(i=0;i<110000;i++)
//	{
//		if(b[i]!=0)
//		printf("    %d %d     ",b[i],i);
//	}
	cout << b[109999];
	return 0;	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/
const int MAX_V = 100010;

int V;
//vector<pll> G[MAX_V];
vector<vector<pll>> G;
int used[MAX_V];

ll prim()
{
    priority_queue<pll, vector<pll>, greater<pll>> que;
    memset(used, 0, sizeof(used));
    que.push(pll(0, 0));
    ll ret = 0;
    while (!que.empty()) {
        int cst = que.top().first, v = que.top().second;
        que.pop();
        if (used[v])
            continue;
        used[v] = 1;
        ret += cst;
        for (int i = 0; i < G[v].size(); i++)
            que.push(pll(G[v][i].first, G[v][i].second));
    }
    return ret;
}

int main()
{
    cin >> V;

    G.resize(V);


    vector<pll> x(V), y(V), z(V);

    rep(i, V)
    {
        ll a, b;
        cin >> a >> b;
        x[i].first = a;
        x[i].second = i;
        y[i].first = b;
        y[i].second = i;
        z[i].first = a;
        z[i].second = b;
    }
    sort(ALL(x));
    sort(ALL(y));

    for (int i = 0; i < V - 1; i++) {
        ll p = x[i].second;
        ll n = x[i + 1].second;
        G[p].PB(MP(min(abs(z[p].first - z[n].first), abs(z[p].second - z[n].second)), n));
        G[n].PB(MP(min(abs(z[p].first - z[n].first), abs(z[p].second - z[n].second)), p));
    }


    for (int i = 0; i < V - 1; i++) {
        ll p = y[i].second;
        ll n = y[i + 1].second;
        G[p].PB(MP(min(abs(z[p].first - z[n].first), abs(z[p].second - z[n].second)), n));
        G[n].PB(MP(min(abs(z[p].first - z[n].first), abs(z[p].second - z[n].second)), p));
    }

    cout << prim() << endl;
}


Measured memory_bytes: 22768
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
vector<int>v[100001];
int main(){
    string A;
    cin>>A;
    LL sum[26]={0};
    LL ans=(LL)A.size()*(A.size()-1)/2;
    for(int i=0;i<A.size();i++)sum[A[i]-'a']++;
    for(int i=0;i<26;i++){
        ans-=(LL)sum[i]*(sum[i]-1)/2;
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
int main(){
	int r;
	string s;
	cin >> r;
	cin >> s;
	if(r%2!=0)
	{
		printf("No");
	}else{
		if(s.substr(0,r/2)==(s.substr(r/2,r))){
			printf("Yes");
		}else printf("No");
	}
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define S(x) x*x
using namespace std;
int a,b,c,d;
bool flag=true;
int main(void){
  int x[3];
  while(cin>>x[0]>>x[1]>>x[2]){
    sort(x,x+3);
    if(x[0]+x[1]<=x[2])flag=false;
    if(flag){
      a++;
      if(S(x[0])+S(x[1])==S(x[2]))b++;
      if(S(x[0])+S(x[1])>S(x[2]))c++;
      if(S(x[0])+S(x[1])<S(x[2]))d++;
    }
  }
  printf("%d %d %d %d\n",a,b,c,d);
  return 0;
}

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

const int N = 1005;

int h, w, k;
char s[11][N];

int solve() {
  scanf("%d %d %d", &h, &w, &k);
  for (int i = 0; i < h; ++i) {
    scanf("%s", s[i]);
  }

  int ans = N * N;

  for (int mask = 0; mask < 1 << (h-1); ++mask) {
    int popcount = __builtin_popcount(mask);
    int cut = popcount;

    vector<int> whites(popcount + 1);
    bool justCut = true;

    bool possible = true;
    for (int j = 0; j < w; ++j) {
      vector<int> addWhite;
      int white = 0;
      for (int i = 0; i < h; ++i) {
        if (s[i][j] == '1') {
          ++white;
        }

        if (mask >> i & 1) {
          addWhite.push_back(white);
          white = 0;
        }
      }
      addWhite.push_back(white);

      bool needCut = false;
      for (int i = 0; i < addWhite.size(); ++i) {
        if (addWhite[i] > k) {
          possible = false;
          break;
        }
        if (whites[i] + addWhite[i] > k) {
          needCut = true;
          break;
        }
      }
      if (!possible) break;

      if (needCut) {
        ++cut;
        whites = addWhite;
      } else {
        for (int i = 0; i < addWhite.size(); ++i) {
          whites[i] += addWhite[i];
        }
      }
    }

    if (possible) ans = min(ans, cut);
  }

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

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;

struct edge{ll from,to,cost;};
vector<edge> es;

ll d[1000];
ll V,E;

// 頂点sからの最大距離
bool BellmanFord(ll s){
    for(int i = 0;i < V;i ++) d[i] = -INF;
    d[s] = 0;
    for(int i = 0;i < V-1;i ++) {
        for(int j = 0;j < E;j ++){
            edge e = es[j];
            if(d[e.from] != -INF && d[e.to] < d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    ll dv = d[V-1];
    for(int i = 0;i < V;i ++) {
        for(int j = 0;j < E;j ++){
            edge e = es[j];
            if(d[e.from] != -INF && d[e.to] < d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    if(d[V-1]>dv) return 0;
    else return 1;
}

int main(){
    cin >> V >> E;
    for(int i = 0;i < E;i ++){
        ll f,t,c;
        cin >> f >> t >> c;
        f --,t --;
        es.push_back({f,t,c});
    }
    if(BellmanFord(0)) cout << d[V-1] << endl;
    else cout << "inf" << endl; 
    return 0;
}

Measured memory_bytes: 384
from collections import deque


def main():
    n = int(input())
    As = list(map(int, input().split()))
    left = deque([])
    right = deque([])
    if n % 2 == 0:
        for i in range(n):
            if i % 2 == 0:
                right.append(As[i])
            else:
                left.appendleft(As[i])
    else:
        for i in range(n):
            if i % 2 == 0:
                left.appendleft(As[i])
            else:
                right.append(As[i])

    left.extend(right)
    print(*left)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32516
#include<cstdio>
#include<cstring>
#include<iostream>
const int M=120000;
using namespace std;
int a[M],ans;char s[M];
int main(){
    
    scanf("%s",s+1);
    int n=strlen(s+1);
    ans=n;
    for(int i=2;i<=n;i++)
    if(s[i]!=s[i-1])
    ans=min(ans,max(i-1,n-i+1));
    printf("%d",ans);
}


Measured memory_bytes: 384
n,a,b,c,d = gets.split.map(&:to_i)
s = gets.chomp
ans = true
if c < d
    x = 0
    ((a-1)..(d-1)).each do |i|
        if s[i] == "#"
            x += 1
        else
            x = 0
        end
        if x > 1
            ans = false
            break
        end
    end
else
    x = 0
    ((a-1)..(c-1)).each do |i|
        if s[i] == "#"
            x += 1
        else
            x = 0
        end
        if x > 1
            ans = false
            break
        end
    end
    y = false
    y = true if s[b] == "." && s[b-2] == "."
    z = 0
    ((b-1)..d).each do |i|
        if s[i] == "#"
            z = 0
        else
            z += 1
        end
        if z > 2
            y = true
            break
        end
    end
    ans = false if !y
end
puts (ans ? "Yes" : "No")

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

using namespace std;


int main(){
    int a,b,w;
    int ans;
    cin >> w >> a >> b;
    if(b > a + w){
        ans = b - a - w;
    }else if(b < a - w){
        ans = a - b - w;
    }else{
        ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
int main()
{
	cin>>n>>a>>b;
	if(n==1&&a==b||n>1&&b>=a)
		cout<<(b-a)*(n-2)+1<<endl;
	else
		cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define sorted(a_1) sort(a_1.begin(),a_1.end())
#define rsorted(a_1) sort(a_1.rbegin(),a_1.rend())
#define t1(a_1) cout<<a_1<<endl;
#define t2(a_1) for(auto it_test : a_1) cout<<it_test<<" ";
#define MOD 1000000007

long double dp[3001][3001];
long double probability(vector<double>&arr, int index, int tail){
	if(index<0 || tail<0){ return 1.0;}
	if(dp[tail][index]>0.0) return dp[tail][index];
	if(tail==0){
		dp[tail][index]=arr[index]*probability(arr,index-1,tail);
		return dp[tail][index];
	}
	else{
		dp[tail][index]=(1-arr[index])*probability(arr,index-1,tail-1)+arr[index]*probability(arr,index-1,tail);
		return dp[tail][index];
	}
}
void solve(){
    int n;
    cin>>n;
    vector<double>arr(n);
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }
    memset(dp,0,sizeof(dp));
  	// long double ans = probability(arr,n-1,(n%2==0)?n/2-1:n/2);
  	dp[0][0] = arr[0];
  	for(int i=0;i<=((n%2==0)?n/2-1:n/2) + 1;i++){
  		for(int j=0;j<=n;j++){
  			if(i==0 || j==0) dp[i][j]=1.0;
  			else if(i==1){
  				dp[i][j] = arr[j-1]*dp[i][j-1];
  			}
  			else{
  				dp[i][j] = (1-arr[j-1])*dp[i-1][j-1] + arr[j-1]*dp[i][j-1];
  			}
  		}
  	}
  	cout<<fixed<<setprecision(10)<<dp[((n%2==0)?n/2-1:n/2) + 1][n];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    while(t--){
        solve();
    }

return 0;
}

Measured memory_bytes: 144540
n = int(input())
h = list(map(int, input().split()))
h.reverse()
k = [0]
s = 0
for i in range(n-1):
  if h[i] <= h[i+1]:
    s += 1
    k.append(s)
  else:
    s = 0
    k.append(s)    
ans = max(k)
print(ans)


Measured memory_bytes: 15020
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <limits>
using namespace std;
typedef long long ll;

enum Face {
	C1, C2, C3, C4, C5, C6, FACE_SIZE
};

struct Dice {
	char face[FACE_SIZE];

	Dice(){}
	Dice(const string &init){
		for(int i=0;i<FACE_SIZE;i++)face[i] = init[i];
	}

	void roll_y(){
		roll(C2, C3, C5, C4);
	}

	void roll_x(){
		roll(C2, C6, C5, C1);
	}

	void roll_z(){
		roll(C1, C3, C6, C4);
	}

	void roll(Face a, Face b, Face c, Face d){
		char tmp = face[d];
		face[d] = face[c];
		face[c] = face[b];
		face[b] = face[a];
		face[a] = tmp;
	}

	char at(Face a) const {
		return face[a];
	}
};


int dx[] =  {0, 0,  1, -1, 0, 0};
int dy[] =  {1, -1, 0,  0, 0, 0};
int dz[] =  {0, 0,  0,  0, 1, -1};
Face from[] = {C6, C1, C3, C4, C5, C2};
Face to[] =   {C1, C6, C4, C3, C2, C5};


bool valid[300][300];


Dice rolls[8][24];

bool used[2][2][2];
Dice cube[2][2][2];

bool dfs(int n, int mask){
	if(n >= 8)return true;

	int m = n;
	int x = m % 2; m /= 2;
	int y = m % 2; m /= 2;
	int z = m;

	for(int i=0;i<8;i++){
		if((mask >> i) & 1)continue;

		for(int r=0;r<24;r++){
			Dice dice = rolls[i][r];
			bool ok = true;

			for(int k=0;k<6;k++){
				int nz = z + dz[k];
				int ny = y + dy[k];
				int nx = x + dx[k];

				if(nz < 0 || nz >= 2 || ny < 0 || ny >= 2 || nx < 0 || nx >= 2)continue;
				if(!used[nz][ny][nx])continue;

				if(!valid[ dice.at(from[k]) ][ cube[nz][ny][nx].at(to[k]) ]){
					ok = false;
					break;
				}
			}

			if(!ok)continue;

			used[z][y][x] = true;
			cube[z][y][x] = dice;


			if(dfs(n + 1, mask | (1 << i)))return true;

			used[z][y][x] = false;

		}
	}

	return false;
}

inline string solve(const vector<Dice> &dice_vec){
	for(int i=0;i<dice_vec.size();i++){
		Dice dice = dice_vec[i];

		int id = 0;
		for(int k=0;k<6;(k&1?dice.roll_y():dice.roll_x()),k++){
			for(int j=0;j<4;dice.roll_z(),j++){
				rolls[i][id] = dice;

				++id;
			}
		}
	}

	memset(used, false, sizeof(used));
	return dfs(0, 0) ? "YES" : "NO";
}

int main(){
	memset(valid, false, sizeof(valid));
	for(int i=0;i<26;i++){
		char a = 'a' + i;
		char b = 'A' + i;
		valid[a][b] = true;
		valid[b][a] = true;
	}

	string init;
	while(cin >> init){
		if(init == "0")break;

		vector<Dice> dices;
		dices.push_back(Dice(init));

		for(int t=0;t<7;t++){
			cin >> init;
			dices.push_back(Dice(init));
		}

		cout << solve(dices) << endl;
	}

	return 0;
}

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

string to_string(string s) {
    return '"' + s + '"';
}
string to_string(char ch) {
    string s(1, ch);
    return '\'' + s + '\'';
}
string to_string(const char *s) {
    return to_string((string)s);
}
string to_string(bool b) {
    return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
 
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long int ll;
#define int ll
#define pb          push_back
#define pll         pair<int,int>
#define mll	        map<int,int>
#define F           first
#define S           second
#define lbnd(v,val) lower_bound(v.begin(),v.end(),val)
#define ubnd(v,val) upper_bound(v.begin(),v.end(),val)
#define bs(v,val)   binary_search(v.begin(),v.end(),val)
#define mp          make_pair
#define f(i,x,n)    for(int i=x;i<n;i++)
#define isup		isupper
#define islow 		islower
#define max3(a,b,c)	max(a,max(b,c))
#define endl        "\n"
#define countbits(n)	 __builtin_popcountll(n)
#define all(ar) ar.begin(), ar.end()
#define rall(ar) (ar).rbegin(), (ar).rend()
const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 2e5 + 10;

typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;


void solve(){
	int n,k;
	cin>>n>>k;
	vll v(n);
	f(i,0,n){
		cin>>v[i];
	}
	vll dp(n,INT_MAX);
	dp[0]=0;
	f(i,0,n){
		f(j,i+1,i+k+1){
			if(j<n){
				dp[j] = min(dp[j],dp[i]+abs(v[i]-v[j]));
			}
		}
	}
	// debug(dp);
	cout<<dp[n-1]<<endl;
}

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

 //    #ifndef ONLINE_JUDGE
	// freopen("in.txt","r",stdin);
	// freopen("out.txt","w",stdout);
 //    #endif

    int t=1;
    // cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}


Measured memory_bytes: 1792
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=0
li=[]

for i in range(N):
    li.append(V[i]-C[i])

for j in range(N):
    if li[j]>0:
        ans+=li[j]
print(ans)


Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll a, b;
  cin >> a >> b;
  ll ans = 0;
  for(int i = a; i <= b; i++){
    string s = to_string(i);
    string t = s;
    reverse(t.begin(), t.end());
    if(s == t) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

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

    string S;
    cin >> S;
    REP(i, S.size()) {
        if (S[i] == '1') {
            S[i] = '9';
        } else if (S[i] == '9') {
            S[i] = '1';
        }
    }
    cout << S << endl;
    return 0;
}


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

vector<string> split(string s, char sp){
  vector<string> res;
  int prev_split_point = 0;
  for (int i = 0; i < s.length(); i++) {
    while(s[i] != sp && i < s.length())i++;
    res.push_back(s.substr(prev_split_point, i - prev_split_point));
    prev_split_point = i + 1;
  }
  return res;
}


int main(int argc, char *argv[]){
  string s;
  while(cin >> s){
    if(s == "#")break;
    bool ans = false;
    vector<string> clous = split(s, '|');
    for (int i = 0; i < clous.size(); i++) {
      clous[i] = clous[i].substr(1, clous[i].length() - 2);
      for (int j = 0; j < clous[i].length() - 1; j++) {
        if(clous[i][j + 1] == '~' &&
           clous[i][j] == '~') {
          clous[i].erase(clous[i].begin() + j);
          clous[i].erase(clous[i].begin() + j);
          j--;
        }
      }
    }
    for (int i = 0; i < clous.size() && ans == false; i++) {
      bool flag = true;
      vector<string> litral = split(clous[i], '&');
      for (int j = 0; j < litral.size(); j++) {
        for (int k = 0; k < litral.size(); k++) {
          if(litral[j] == '~' + litral[k]){
            flag = false;
            j = litral.size(), k = litral.size();
          }
        }
      }
      if(flag)ans = true;
    }
    if(ans) std::cout << "yes" << std::endl;
    else std::cout << "no" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
int a[26][N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s, t;
	cin >> s >> t;
	int slen = s.size();
	for (int i = 1; i <= slen; ++i)
	{
		int tmp = s[i - 1] - 'a';
		a[tmp][++a[tmp][0]] = i;
	}
	ll ans = 0;
	int cur = 0;
	for (auto i : t)
	{
		int I = i - 'a';
		if (!a[I][0])
		{
			cout << -1;	
			return 0;
		}
		int p = upper_bound(a[I] + 1, a[I] + a[I][0] + 1, cur) - a[I];
		if (p > a[I][0])
		{
			ans += slen - cur + a[I][1];
			cur = a[I][1];
		}
		else
		{
			ans += a[I][p] - cur;
			cur = a[I][p];
		}
	}
	cout << ans;
}

Measured memory_bytes: 17232