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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double
#define debug(x) cerr << #x << " " << x << endl;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, w;
	cin>>n>>w;
	LL dp[n+1][w+1];
	for(int i=0; i<=w; i++)
		dp[0][i] = 0;
	LL ww, vv;
	for(int i=1; i<=n; i++) {
		cin>>ww>>vv;
		for(int j=0; j<=w; j++)
			dp[i][j] = dp[i-1][j];
		for(int j=ww; j<=w; j++) {
			dp[i][j] = max(dp[i][j], dp[i-1][j-ww]+vv);
		}
	}
	cout<<dp[n][w];
}


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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

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

int main() {
  cout << setprecision(18);
  u32 N, M;
  cin >> N >> M;
  vector<u32> A(N);
  ArrayInput(A);
  sort(A.begin(), A.end(), greater<u32>());
  double sum = 0;
  for (u32 i = 0; i < N; ++i) {
    sum += A[i];
  }
  double Th = (sum / (4 * M));
  u32 flag = 0;
  for (u32 i = 0; i < M; ++i) {
    if (A[i] < Th) {
      flag = 1;
      break;
    }
  }
  if (flag) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, k; cin >> n >> k;

    cout << (k == 1 ? 0 : n-k) << endl;
    
}

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

int main() {
    int A, B;
    int H;
    int M;
    cin >> A >> B >> H >> M;

    pair<double, double> hour_hand =
        make_pair(A * cos(M_PI_2 - H * M_PI / 6.0 - M * M_PI / 360.0),
                  A * sin(M_PI_2 - H * M_PI / 6.0 - M * M_PI / 360.0));
    pair<double, double> min_hand = make_pair(
        B * cos(M_PI_2 - M * M_PI / 30.0), B * sin(M_PI_2 - M * M_PI / 30.0));

    double dx = hour_hand.first - min_hand.first;
    double dy = hour_hand.second - min_hand.second;

    cout << fixed << setprecision(10) << sqrt(pow(dx, 2) + pow(dy, 2)) << endl;
}

Measured memory_bytes: 4088
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

int32_t main() {

    fast

    string s;
    cin>>s;

    int n=s.size();

    int sum=0;
    for(int i=0;i<n;i++){
        sum+=(s[i]-'0');
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }





    return 0;
}



Measured memory_bytes: 3776
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

// k<=max(3000)
ll x, y, z, k;
ll a[1010], b[1010], c[1010];

int cnt_a, cnt_b, cnt_c;

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

  cin >> x >> y >> z >> k;
  
  REP(i, x) cin >> a[i];
  REP(i, y) cin >> b[i];
  REP(i, z) cin >> c[i];

  sort(a, a+x, greater<ll>());
  sort(b, b+y, greater<ll>());
  sort(c, c+z, greater<ll>());

  vector<ll> ab, ans;
  REP(i, x) REP(j, y) ab.push_back(a[i]+b[j]);  
  sort(ab.begin(), ab.end(), greater<ll>());
  
  int tmp = min((int)k, (int)ab.size());
  
  REP(i, tmp) REP(j, z){
    ans.push_back(ab[i] + c[j]);
  }

  sort(ans.begin(), ans.end(), greater<ll>());
  
  REP(i, k) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 43364
package main

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

var sc = bufio.NewScanner(os.Stdin)

// var rdr = bufio.NewReaderSize(os.Stdin, 100000)
var rdr *bufio.Reader

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	// ABC064D
	n := nextInt()
	s := nextLine()

	cntF := 0
	cntS := 0

	for _, ch := range s {
		if ch == '(' {
			cntS++
		} else {
			if cntS > 0 {
				cntS--
			} else {
				cntF++
			}
		}
	}

	ans := make([]byte, 0, 200)
	for i := 0; i < cntF; i++ {
		ans = append(ans, '(')
	}
	for i := 0; i < n; i++ {
		ans = append(ans, s[i])
	}
	for i := 0; i < cntS; i++ {
		ans = append(ans, ')')
	}

	fmt.Println(string(ans))
}

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

func readLine() string {
	buf := make([]byte, 0, 100000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

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

func nextI64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func maxi64(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func updateMax(a *int, b int) {
	if *a < b {
		*a = b
	}
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func mini64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func updateMin(a *int, b int) {
	if *a > b {
		*a = b
	}
}

func absi64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}

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

int main() {
    int64_t n, k, s;
    cin >> n >> k >> s;

    vector<int64_t> a(n, 0);

    for(int i = 0; i < k; i++) {
        a[i] = s;
    }

    if(s < 1e9) {
        for(int i = k; i < n; i++) {
            a[i] = s + 1;
        }
    } else {
        for(int i = k; i < n; i++) {
            a[i] = s - 1;
        }
    }

    for(int i = 0; i < n; i++) {
        cout << a[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <numeric>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	long long N,K;
	cin >> N >>K;
	long long ans = 0;
	for(long long i =K;i<N+2;i++){
		ans += (N - i + 1) * i+1;
		ans = ans % 1000000007;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}
//auto f = [&](int n)->int{return n;};
//auto a = [&](auto&&b){b(b)};



signed main(){
	int a;
	cin>>a;
	cout<<3*a*a<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b,c,x,y,z;
   cin>>a>>b>>c;
   if(a>=b&&a>=c)
   {
     x=a-b;
     y=a-c;
     if(x>=y)
     {
         cout<<"B";
     }
     else cout<<"A";
   }
   else if(a>=b&&c>=a)
   {
       x=a-b;
       y=c-a;
        if(x>=y)
     {
         cout<<"B";
     }
     else cout<<"A";
   }
   else if(a<=b&&a>=c)
   {
       x=b-a;
       y=a-c;
        if(x>=y)
     {
         cout<<"B";
     }
     else cout<<"A";
   }
   else if(a<b&&c>=a)
   {
       x=b-a;
       y=c-a;
        if(x>=y)
     {
         cout<<"B";
     }
     else cout<<"A";
   }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 123;
int n;

ll f(ll x) {
	return x * (x + 1) / 2;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	ll e = 0;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		if (x > y) swap(x, y);
		e += (ll)x * (n - y + 1);
	}
	ll res = 0;
	for (int i = 1; i <= n; i++) {
		ll cur = f(n) - f(i - 1);
		cur -= ((ll)n - i + 1) * (i - 1);
		res += cur;
	}
	res -= e;
	cout << res;
}


Measured memory_bytes: 3616
#include<stdio.h>

int main(){
  int a,b,c,k,i;
  int sum=0;
  scanf("%d %d %d %d\n",&a,&b,&c,&k);
  if(a>=k){
    sum=k;
  }else if(a+b>=k){
    sum=a;
  }else{
    sum=a-(k-(a+b));
  }
  
  printf("%d",sum);
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

bitset<110> cor;

int32_t main()
{
	int x, n;
	
	cin >> x >> n;
	for(int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		cor[a] = 1;
	}
	
	int ans = OO;
	
	for(int i = 0; i <= 105; i++)
	{
		if(cor[i]) continue;
		if(abs(i - x) < abs(x - ans))
			ans = i;
	}
	
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3640
using System;

namespace _3_C {
    class Program {
        static void Main (string[] args) {
            var max_size = 3000;
            for (var i = 0; i < max_size; ++i) {
                var input = Console.ReadLine ();
                if (input == null || input == "0 0") {
                    break;
                }
                var data = input.Split ();
                var x = Convert.ToInt32 (data[0]);
                var y = Convert.ToInt32 (data[1]);
                if (x > y) {
                    Console.WriteLine ($"{y} {x}");
                } else {
                    Console.WriteLine ($"{x} {y}");
                }
            }
        }
    }
}


Measured memory_bytes: 16044
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
int L;
void MAIN() {
	cin>>L;
	ld a=L/3.0L;
	cout<<fixed<<setprecision(10);
	cout<<a*a*a;
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 4005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
struct node {
	string s;int num;
	friend bool operator < (const node &a,const node &b) {
		return a.s < b.s;
	}
};
set<node> S;
int x,y,z;
void Solve() {
	read(x);read(y);read(z);
	if(x) S.insert((node){"a",x});
	if(y) S.insert((node){"b",y});
	if(z) S.insert((node){"c",z});
	while(1) {
		if(S.size() == 1) {
			node p = *S.begin();
			for(int i = 1 ; i <= p.num ; ++i) {
				cout << p.s;
			}
			enter;
			break;
		}
		node s0 = *S.begin(),t0 = *(--S.end());
		S.erase(S.begin());S.erase(--S.end());
		int k = min(s0.num,t0.num);
		S.insert((node){s0.s + t0.s,k});
		if(s0.num > k) S.insert((node){s0.s,s0.num - k});
		if(t0.num > k) S.insert((node){t0.s,t0.num - k});
	}
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    S=list(input())
    A,C,Q=[0]*(len(S)+1),[0]*(len(S)+1),[0]*(len(S)+1)
    l_B=[]
    l_Q=[]
    q=0
    for i in range(len(S)):
        A[i+1]=A[i]+(S[i]=='A')
        C[i+1]=C[i]+(S[i]=='C')
        Q[i+1]=Q[i]+(S[i]=='?')
        if S[i]=='?':
            q+=1
            l_Q.append(i)
        if S[i]=='B':
            l_B.append(i)
    ans=0
    pow3q=pow(3,q,MOD)
    if q-1>=0:
        pow3q_1=pow(3,q-1,MOD)
    else:
        pow3q_1=0
    if q-2>=0:
        pow3q_2=pow(3,q-2,MOD)
    else:
        pow3q_2=0
    if q-3>=0:
        pow3q_3=pow(3,q-3,MOD)
    else:
        pow3q_3=0
    
    for x in l_B:
        ans+=A[x]*(C[len(S)]-C[x+1])*pow3q
        ans+=Q[x]*(C[len(S)]-C[x+1])*pow3q_1
        ans+=A[x]*(Q[len(S)]-Q[x+1])*pow3q_1
        ans+=Q[x]*(Q[len(S)]-Q[x+1])*pow3q_2
        ans%=MOD
    for x in l_Q:
        ans+=A[x]*(C[len(S)]-C[x+1])*pow3q_1
        ans+=Q[x]*(C[len(S)]-C[x+1])*pow3q_2
        ans+=A[x]*(Q[len(S)]-Q[x+1])*pow3q_2
        ans+=Q[x]*(Q[len(S)]-Q[x+1])*pow3q_3
        ans%=MOD        
    print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 51952
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<n-1;i++)sum+=a[i];
  if(a[n-1]<sum)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}
                             

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	deque<pair<int, int>>bw;
	deque<int>cp;
	int cnt = 1;
	rep(i, n - 1) {
		if (s[i] == s[i + 1]) {
			cnt++;
		}
		else {
			if (s[i] == '#') {
				bw.push_back(make_pair(cnt, 1));
			}
			else {
				bw.push_back(make_pair(cnt, 0));
			}
			cnt = 1;
		}
	}

	if (s[n - 1] == '#') {
		bw.push_back(make_pair(cnt, 1));

	}
	else {
		bw.push_back(make_pair(cnt, 0));
	}
	int wmax = 0;
	rep(i, bw.size()) {
		if (bw[i].second == 0) {
			wmax += bw[i].F;
		}
	}
	int bsum = 0, wsum = 0;
	cp.push_back(wmax);
	rep(i, bw.size()) {
		if (bw[i].second == 1) {
			bsum += bw[i].first;
		}
		else {
			wsum += bw[i].first;
		}
		cp.push_back(bsum + wmax - wsum);
	}
	
	sort(all(cp));
	cout << cp[0]<< endl;
}


Measured memory_bytes: 2948
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        var ab = Console.ReadLine().Split().Select(int.Parse);
        int a = ab.First(), b = ab.Last();
        int d = b - a;
        int h = (1 + d) * d / 2;
        Console.WriteLine(h - b);
    }
}

Measured memory_bytes: 13396
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::*;
use proconio::{input, fastout, marker::*};

#[fastout]
fn main() {
  input!{
    n:f64,
    x:f64,
    t:f64
  }
  println!("{}",(n/x).ceil()*t)
}


Measured memory_bytes: 2744
n = gets.to_i
point = Array.new(2, 0)

n.times do
  t, h = gets.split
  case
  when t > h
    point[0] += 3
  when t == h
    point[0] += 1
    point[1] += 1
  when t < h
    point[1] += 3
  end
end

puts point.join(" ")


Measured memory_bytes: 8888
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  
  string s;
  cin >> s;
  ll k;
  cin >> k;
  ll n = s.size();
  k=min(n,k);
  int ans = 1;
  rep(i,k){
    if(s[i]!='1'){
      ans=s[i]-'0';
      break;
    }
  }
  cout << ans << endl;
    
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;

 
//int vis[N];
bool sortcol(const vector<int>& v1,
	const vector<int>& v2) {
	return v1[0] < v2[0];
}

int32_t  main() {

	IOS;
  
 
	int N, M;

	cin >> N >> M;

	vector<int> e(N + 1);

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

		cin >> e[i];
	}

	vector< vector <int> > link(N+1  );
	
	 
	for (int i = 1; i <= M; i++) {
		 
		int tmp;
		cin >> tmp;

		int tmp2;
		cin >> tmp2;

		link[tmp].push_back(tmp2);
		link[tmp2].push_back(tmp);
		
	}



	int cnt = 0;
	for (int i = 1;  i <= N; i++) {
		bool flag = true;
		//cout << link[i].size() << endl;
		if (link[i].size() == 0) {
			cnt++;
			continue;
		}
		for(auto &it: link[i]){
		//	cout << e[i] << " " << e[it] << endl;
			if (e[i] <= e[it]) {
				
				flag = false;
			}

		}
		if (flag) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 9376
n, m, d = gets.split.map(&:to_i)
expected =
  if d == 0
    1 / n.to_f
  else
    double = [n - (d * 2), 0].max
    single = n - double
    (double * 2 + single) / (n ** 2).to_f
  end
puts expected * (m - 1)


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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = int(lines[0])

    return (n, )


def solve(n):

    m = str(n)
    l = m[-1]
    result = None
    if l in ('2', '4', '5', '7', '9'):
        result = 'hon'
    elif l in ('0', '1', '6', '8'):
        result  = 'pon'
    elif l in ('3'):
        result = 'bon'
    
    return  result
    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 62072
x, n = map(int, input().split())
nums = list(map(int, input().split()))

if n == 0:
  print(x)
  exit()

dif = 0

while True:
  if (x - dif) not in nums:
    print(x - dif)
    break
  if (x + dif) not in nums:
    print(x + dif)
    break
  dif += 1

Measured memory_bytes: 9180
N,M = list(map(int,input().split()))

Qa,Qw = {}, {}
for _ in range(M):
    p, S = input().split()
    p = int(p)-1

    if p not in Qa:
        Qa[p] = 0

    if p not in Qw:
        Qw[p] = 0

    if S == 'AC':
        Qa[p] = 1
    elif S == 'WA':
        if Qa[p] <= 0:
            Qw[p] += 1

AC = sum([ac for ac in Qa.values()])
WA = sum([Qw[k] for k,v in Qa.items() if v > 0])
print( AC, WA)



Measured memory_bytes: 21476
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

const int maxN = 1e5 + 10, maxLog = 20;

#define FORU(i, l, r) for (int i = l; i <= r; ++i)
#define FORD(i, r, l) for (int i = r; i >= l; --i)
#define REPU(i, r) for (int i = 0; i < r; ++i)
#define LL long long
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define PINT pair < int, int >
#define BIT(x, i) ((x >> i) & 1)
#define NUM_SET_BIT __builtin_popcountll

LL a, b, pa, pb;
int q;

int main() {
    cin >> q;
    LL k = 1;
    FORU(i, 1, q) {
        cin >> a >> b;
        if (i > 1) {
            LL pk = k;
            k = max((pk * pa) / a, (pk * pb) / b);
            if (k * a < pk * pa || k * b < pk * pb)
                ++k;
        }
        pa = a, pb = b;
    }
    cout << k * (pa + pb);
}


Measured memory_bytes: 256
def main():
    import sys
    from collections import defaultdict
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline

    def gcd(a, b):
        if b == 0:
            return a
        return gcd(b, a % b)
    
    N, M = [int(x) for x in input().strip().split()]
    S = input().strip()
    T = input().strip()
    L = (N * M) // gcd(N, M)
    d = defaultdict(int)
    for n in range(N):
        d[L//N*n] = S[n]
    for m in range(M):
        if d[L//M*m] == 0 or d[L//M*m] == T[m]:
            continue
        else:
            print(-1)
            return
    print(L)

if __name__ == '__main__':
    main()

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

int main(){
  int64_t N;
  cin >> N;
  if(N%2!=0){
    cout << 0 << endl;
  }else{
    int64_t ans=0;
    int i=0;
    while(N>=10*pow(5,i)){
      ans+=N/(10*(int64_t)pow(5,i));
      i++;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 512
def collatz(x):
  if(x==1 or x==2 or x==4):
    return[0,0]
  ret=[]
  while(x>1):
    if(x%2):
      x=3*x+1
    else:
      x/=2
    ret.append(x)
  return ret

print(len(collatz(int(input())))+2)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A; int B; int C; int D; int K;
  cin>>A>>B>>C>>D>>K;
  int S=60*A+B; int T=60*C+D;
   if(A>C)
  T+=60*24;
  cout<<T-S-K<<endl;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
int main(void)
{
	char S[101];
	int K,a,i;
	scanf("%d", &K);
	scanf("%s", S);
	a = strlen(S);
	if (a <= K)
	{
		printf("%s\n", &S);
	}
	else
	{
		for (i = K ; i <= a; i++)
		{
			S[i] = '\0';
		}
		for (i = K ; i <= K + 2; i++)
		{
			S[i] = '.';
			
		}
		printf("%s\n", &S);

			
	}

	return 0;
}

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

typedef long long int ll;
typedef long double ld;

using namespace std;


int main()
{
    string s;
    int i,cnt=0,len;

    cin>>s;
    len = s.length();
    for(i=0;i<len;i++){
        if(s[i]=='7'){
            cnt++;
            break;
        }
    }
    if(cnt>0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    //cout<<"Case "<<cn<<": "<<"good"<<endl;
    return 0;
}


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


int main(){
  int N;
  cin >> N;
  int a;
  set<int> s;
  int ex=0;
  rep(i,N){
    cin >> a;        
    int t=a/400;
    if(t<8) s.insert(t);
    else ex++;
  }
  int amin=0;
  int amax=0;
  rep(i,8){
    if(s.count(i)==1){
      amin++;amax++;
    }
  }
  if(amin==0 && ex>0) cout << 1 << " ";
  else cout << amin << " ";
  cout << amax + ex << endl;
  
  
  return 0;

}


Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os
import sys
import itertools
import math
from collections import Counter, defaultdict

class Main(object):
    
    def __init__(self):
        pass

    def solve(self):
        '''
        insert your code
        '''
        while True:
            n, q = map(int, raw_input().split())
            if n == q == 0:
                break
            db = []
            for i in range(n):
                en, eby, wy = raw_input().split()
                eby = int(eby)
                wy = int(wy)
                db.append((en, wy - eby + 1, wy))
            db.sort(key=lambda x: x[1])
            for i in range(q):
                y = input()
                for en, s, f in db:
                    if s <= y <= f:
                        print en, y - s + 1
                        break
                else:
                    print 'Unknown'
        
        
        return None

if __name__ == '__main__':
    m = Main()
    m.solve()

Measured memory_bytes: 5128
n, m = gets.chomp.split.map(&:to_i)
l = []
r = []
m.times do |i|
  l[i], r[i] = gets.chomp.split.map(&:to_i)
end

r_min = r.min
l_max = l.max

if r_min >= l_max
  p r_min - l_max + 1
else
  p 0
end


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S;
    cin >> N;
    vector<ll> a(N);
    REP(i,N){
        cin >> a.at(i);
    }

    ll all_sum = 0;
    REP(i,N){
        all_sum += a.at(i);
    }

    vector<ll> a_sum(N);
    a_sum.at(0) = a.at(0);
    REPS(i,N-2){
        a_sum.at(i) = a_sum.at(i - 1) + a.at(i);
    }

    ll ans = LLINF;
    REP(i,N-1){
        ll tmp = abs(a_sum.at(i) - (all_sum - a_sum.at(i)));
        ans = min(tmp, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6340
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
using ll = long long;
using namespace std;
const ll mod = 1000000007;

const int bound = 2000020;
ll fact[bound], fact_inv[bound];

ll power( ll a, ll b ){
	ll res = 1;
	while( b > 0 ){
		if( b & 1 ) res = res*a % mod;
		a = a*a % mod;
		b >>= 1;
	}
	return res;
}

void init(){
	fact[0] = 1;
	int b = bound-10;
	for( int i = 0; i < b; ++i ){
		fact[i+1] = fact[i]*(i+1) % mod;
	}
	fact_inv[b] = power(fact[b], mod-2);
	for( int i = b-1; i >= 0; --i ){
		fact_inv[i] = fact_inv[i+1]*(i+1) % mod;
	}
}

ll comb( ll n, ll r ){
	if( n < r ) return 0;
	return ( fact[n]*fact_inv[r] ) % mod * fact_inv[n-r] % mod;
}

ll seq( ll x, ll y ){
	return ( comb(x+y+2, x+1)+mod-1 ) % mod;
}

int main(){
	init();
	ll a, b, c, d; cin >> a >> b >> c >> d;
	cout << ( seq(c, d) - seq(a-1, d) - seq(c, b-1) + seq(a-1, b-1) + 10*mod ) % mod << endl;
}

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

struct Edge{//辺のデータ
    int s;//一方の頂点
    int t;//他方の頂点
    int cost;//辺の重み

    //辺をコストの昇順にソートする
    bool operator<(const Edge& right) const {
        return cost < right.cost;
    }
};

class union_find{
public:
    union_find(int N){
        parent = new int[N];
        rank = new int[N];
        for(int i = 0; i < N; i++){
            parent[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x){
        if(parent[x] == x){
            return x;
        }else{
            return parent[x] = root(parent[x]);
        }
    }
    
    void unite(int x, int y);
    bool same(int x, int y){
        return root(x) == root(y);
    }
private:
    int *parent;
    int *rank;
};


void union_find::unite(int x, int y){
    x = root(x);
    y = root(y);
    
    if(x == y) return;
    
    if(rank[x] < rank[y]){
        parent[x] = y;
    }else{
        parent[y] = x;
        if(rank[x] == rank[y]){
            rank[x]++;
        }
    }
}

int main(){
    int v, e;
    cin >> v >> e;
    vector<Edge> e_data(e);
    union_find v_data(v);
    for(int i = 0; i < e; i++){
        int s, t, cost;
        cin >> s >> t >> cost;
        e_data[i].s = s;
        e_data[i].t = t;
        e_data[i].cost = cost;
    }
    
    sort(e_data.begin(), e_data.end());

    long long int res = 0;
    for(int i = 0; i < e; i++){
        if(!v_data.same(e_data[i].s, e_data[i].t)){
            res += e_data[i].cost;
            v_data.unite(e_data[i].s, e_data[i].t);
        }
    }

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


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

int main() {
  char x, y;
  cin >> x >> y;
  
  if(x == y){
    cout << "=" << endl;
  }
  else if(x < y){
    cout << "<" << endl;
  }
  else{
    cout << ">" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
 
int main(void) {
  string str, st, sr;
  cin >> str;
  for (int i = 2; i < str.length(); i += 2) {
    st = str.substr(0, (str.length() - i) / 2);
    sr = str.substr((str.length()-i )/ 2, (str.length() - i) / 2);
    if (st == sr) {
      cout <<  str.length()-i<< endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
l = inp.shift().split(' ')
x = l[0] * 1
y = l[1] * 1 
cnt = 0
if (x == y) {
    
} else if (Math.abs(x) == Math.abs(y)) {
    cnt++
} else if (x == 0 || y == 0) {
    if (y < x) {
        cnt++
    }
    cnt += Math.abs(Math.abs(x) - Math.abs(y))
} else {
    if (x > y) {
        if (x > 0 && y > 0) {
            cnt += 2
        } else if (x > 0 && y < 0) {
            cnt += 1
        } else {
            cnt += 2
        }
    } else {
        if (x < 0 && y > 0) {
            cnt += 1
        }
    }
    cnt += Math.abs(Math.abs(x) - Math.abs(y))
}
console.log(cnt)

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  long long n; scanf("%lld", &n);
  if (!n) {
    printf("0");
    return;
  }
  vector<int> ans;
  if (n > 0) {
    for (long long i = 0;; ++i) {
      if (i && i%2==0) {
	n += 1LL << (i-1);
      }
      if (n/(1LL<<i) == 0) break;
      ans.push_back((n/(1LL<<i))%2);
    }  
  } else {
    n = -n;
    for (long long i = 0;; ++i) {
      if (i%2==1) {
	n += 1LL << (i-1);
      }
      if (n/(1LL<<i) == 0) break;
      ans.push_back((n/(1LL<<i))%2);
    }
  }
  for (int i = ans.size()-1; i >= 0; --i) {
    printf("%d", ans[i]);
  }
}

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

/*
1 -2 4 -8 16
  00
-10 1010
-9  1011
-8  1000
-7  1001
-6  1110
-5  1111
-4  1100
-3  1101
-2  0010
-1    11
0     00
1      1
2    110 
3    111
4    100
5    101
6  11010
7  11011
8  11000
9  11001
10 11110

0: n%2
1: ((n+2)/2)%2
2: ((n+2)/4)%2
3: ((n+8)/8)%2
4: ((n+8)/16)%2

  0: 00000 good
  1: 00001 good
 -1: 00001 bad, just add 1 to leftmost?
  4: 00100
 -5: 1
 10:
-10:

0(-1)10

10%2 = 0
10/2 = 5
5%2 = 1
5/-2 = -2
-2%2 = 0
-2/2 = -1
-1%2 = -1
-1/2 = 0

10(-1)

-5%2 = -1
-5/2 = -2
-2%2 = 0
-2/-2 = 1
1%2 = 1
1/2 = 0

 */


Measured memory_bytes: 3788
N=int(input())
P = [0] * N
for i in range(N):
  P[i] = int(input())
  
# 差1で作れるもっとも長い部分列の長さをNから引く
# 例：1 3 2 4 -> 1,2もしくは3,4が最も長い
# 例：3 2 5 1 4 6 -> 3,4もしくは5,6
# 例：6 3 1 2 7 4 8 5 -> 6,7,8もしくは3,4,5もしくは1,2

seen=[0 for i in range(N+1)]
for i in range(N):
  # P[i]より1小さい数が今までに出てきていたら、その数に+1する。
  seen[P[i]] = seen[P[i] - 1] + 1
  
print(N - max(seen))


Measured memory_bytes: 18868
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String t = sc.next();

        String ans = "UNRESTORABLE";

        if (s.contains(t)) {
            ans = s.replace("?", "a");
        } else {
            String[] tList = t.split("");
            for (int i = 0; i <= s.length() - t.length(); i++) {
                String[] value = s.substring(i, i + t.length()).split("");
                boolean isOK = true;
                for (int j = 0; j < t.length(); j++) {
                    if (!(tList[j].equals(value[j]) || value[j].equals("?"))) {
                        isOK = false;
                        break;
                    }
                }
                if (isOK) {
                    String kouho = (s.substring(0, i) + t + s.substring(i + t.length())).replace("?", "a");
                    if (ans.equals("UNRESTORABLE") || kouho.compareTo(ans) < 0) {
                        ans = kouho;
                    }
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long a = inputLongArray[0];
            long b = inputLongArray[1];
            string result = Math.Max(Math.Max(a + b, a - b), a * b).ToString();
            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11348
#include<iostream>
using namespace std;
int main(){
int n;
  cin>>n;
  int a[n],i,ans=0;
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=2;i<n;i++){
    if((a[i-2]<a[i-1]&&a[i-1]<a[i])||(a[i-2]>a[i-1]&&a[i-1]>a[i])) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int N;
	int A[100002];
	scanf("%d",&N);
	A[0] = 0;
	for(int i=1;i<=N;i++){
		scanf("%d", &A[i]);
	}
	A[N+1] = 0;

	long long B[100002];
	B[0] = 0;
	for(int i=1;i<=N+1;i++){
		B[i] = B[i-1] + abs(A[i]-A[i-1]);
	}
	/*
	for(int i=0;i<=N+1;i++){
		printf("%lld\n", B[i]);
	}
	*/

	for(int i=1;i<=N;i++){
		long long ans = 0;
		ans += B[i-1];
		ans += abs(A[i+1]-A[i-1]);
		ans += B[N+1] - B[i+1];
		printf("%lld\n", ans);
	}

	return 0;
}


Measured memory_bytes: 2304
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  V<ll> d(n+1);
  rep(i,0,n+1)cin>>d[i];
  V<ll> und(n+1,0);
  und[n]=d[n];
  repr(i,0,n){
    und[i]=und[i+1]+d[i];
  }

  ll ans=0,now=1;
  rep(i,0,n+1){
    ans+=now;
    now-=d[i];
    if(now<0){
      cout<<-1<<ENDL;
      return 0;
    }
    if(i<n)now=min(2*now,und[i+1]);
  }
  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

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

using namespace std;

int main() {
    int n;
    cin >> n;
    for(int i = 0;i < 1000; i += 111){
        if(n <= i) {
            cout << i;
            return 0;
        }
    }
    return 0;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int ans = 0;
	for (const auto& x : s) {
		ans += (x-'0');
	}
	cout  << (ans%9?"No":"Yes") << '\n';
	return 0;
}

Measured memory_bytes: 3704
n = int(input())
l = dict()
for i in range(n):
    s = input()
    if s not in l:
        l[s]=1
    else:
        l[s]+=1
l1 = []
for i in l:
    l1.append((l[i],i))
l1.sort()
l1 = l1[::-1]
p=0
#print(l1)
l2 = []
l2.append(l1[0][1])
for i in range(len(l1)-1):
    if l1[i][0]==l1[i+1][0]:
        l2.append(l1[i+1][1])
        p=i
    else:
        break
l2.sort()

for i in l2:
    print(i)

Measured memory_bytes: 45148
#include <queue>
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <cstdio>
#define rep(i, n) for(long long i = 0;(i) < (n);(i)++)
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int N;
int a[10];

int main() {
	cin >> a[0] >> a[1] >> a[2];
	if (a[0] + a[1] + a[2] <= 21)
	{
		cout << "win" << endl;
	}
	else
	{
		cout << "bust" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math
 
X=int(input())
ans = X
 
def is_prime(n):
    if n==1:
        return False
    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False
    return True

while True:
    if is_prime(ans):
        print(ans)
        break
    ans+=1

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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

const ll MRINF = 5000000000000000;

int main() {

    int A, B; cin >> A >> B;
    int a1, a2, a3;
    a1=A+B;
    a2=A-B;
    a3=A*B;

    cout << max(a1, max(a2, a3)) << endl;


}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 3576
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
   
using namespace std;
 

 
int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int t[17][17];
        vector<int> result(1 << n, 100000000);
        result[0] = 0;
        for(int i = 1; i < n + 1; i++){
            for(int j = 0; j < n + 1; j++){
                cin >> t[i][j];
            }
        }
        for(int i = 0; i < (1 << n); i++){
            for(int j = 1; j < n + 1; j++){
                // ?????????j??????????????????????????¢??????
                if((i & (1 << (j - 1))) == 1) continue;
                // ?????§???j???????????¢??????????????§?£???°???
                int cost = t[j][0];
                for(int k = 1; k < n + 1; k++){
                    // ????????????????????????
                    if((i & (1 << (k - 1))) == 0) continue;
                    // k??????????????????????????\??£?????????????????§?£???°???
                    cost = min(cost, t[j][k]);
                }
                int now = (i | (1 << (j - 1)));
                // ????????¢?????????
                result[now] = min(result[now], result[i] + cost);
            }
        }
        cout << result[(1<<n) - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1452
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)
using ll = long long;
int n, k, p[5005], c[5005], e;
bool used[5005];
ll v[5005], sm, ans=-1e9;
void chmax(ll &a, ll b){if(a<b) a=b;}
int main(){
	scanf("%d%d", &n, &k);
	rep2(i,n) scanf("%d", p+i);
	rep2(i,n) scanf("%d", c+i);
	rep2(t,n) if(!used[t]){
		v[e=1]=c[t];
		for(int u=p[t]; u!=t; used[u]=true, u=p[u], e++) v[e+1]=v[e]+c[u];
		rep2(i,e) rep2(j,e){
			int l = j-i+(j>i?0:e);
			ll sm = v[j]-v[i]+(j>i?0:v[e]);
			if(l<=k) chmax(ans,(v[e]>0?v[e]*((k-l)/e):0)+sm);
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 3908
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    let N = parseInt(arg[0].split(" ")[0]);
    const alphabets = "abcdefghijklmnopqrstuvwxyz".split("");
    
    let answer = "";
    
    while(0 < N) {
        let m = N % 26;
        
        if(m === 0) m = 26;
        
        answer = alphabets[m-1] + answer;
        N = (N - m) / 26;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29676
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void push(int);
int pop(void);

int top, S[1000];

int main()
{
  int n, m;
  char s[100];
  top=0;

  while( scanf("%s",s) != EOF ){
    if(s[0]=='+'){
      n = pop();
      m = pop();
      push(n+m);
    }
    else if(s[0]=='-'){
      n = pop();
      m = pop();
      push(m-n);
    }
    else if(s[0]=='*'){
      n = pop();
      m = pop();
      push(n*m);
    }
    else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}

void push(int x)
{
  S[++top]=x;
}

int pop()
{
  top--;
  return S[top+1];
}

Measured memory_bytes: 548