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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll a,b;cin>>a>>b;
  ll ret=0;
  ll ax=a,bx=b;
  while(ax%4!=0)ax++;
  while(bx%4!=0)bx--;
  rep(i,a,ax)ret^=i;
  rep(i,bx,b+1)ret^=i;
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vl vector<ll>
#define el '\n'
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vpll vector<pll>
#define vvll vector<vector<ll> >
#define vvpll vector< vector<pll> >
#define ff first
#define ss second
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
typedef long long ll;

int main() 
{
    fastio();
    
    ll n,k;
    cin>>n>>k;
    ll a[n];
        for(ll i=0 ; i<n ; i++)
            cin>>a[i];
            
    if(k >= n)
        cout<<abs(a[0] - a[n-1]);
    else
    {
        ll dp[n];
        dp[0] = 0;
        for(ll i=1 ; i<k ; i++)
        {
            ll mini = LLONG_MAX;
            for(ll j=i-1 ; j>=0 ; j--)
                mini = min(mini, dp[j] + abs(a[j] - a[i]));
            dp[i] = mini;
        }
    	
    	for(ll i=k ; i<n ; i++)
        {
            ll mini = LLONG_MAX;
            for(ll j=1 ; j<=k ; j++)
                mini = min(mini, dp[i-j] + abs(a[i-j] - a[i]));
            dp[i] = mini;
        }
        
        cout<<dp[n-1];
    }
	return 0;
}

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

int x(int n){
  int sum=0;
  while(n>0){
    sum+=n%10;
    n=n/10;
  }
  return sum;
}

int main(){
  int N,A,B;
  cin >> N >> A >> B;
  int s=0;
  for(int i=1; i <= N; i++){
    int sum = x(i);
    if(A<=sum && sum<=B){
      s=s+i;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <sstream>
#include <map>

using namespace std;

map<string, bool> visited;
void merge(const string &grp, map<string, vector<string> > &m, set<string> &members) {
    if(visited[grp]) return;

    const vector<string> &v = m[grp];
    for(int i = 0; i < v.size(); ++i) {
        string name = v[i];
        if(m.count(name) > 0) {
            merge(name, m, members);
        }
        else {
            members.insert(name);
        }
    }
    visited[grp] = true;
}

int main() {
    ios::sync_with_stdio(0);
    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        map<string, vector<string> > m;
        string first;
        for(int i = 0; i < N; ++i) {
            string s;
            cin >> s;
            int colon = s.find(":");
            string group = s.substr(0, colon);
            string members = s.substr(colon+1);
            members.erase(members.size()-1);
            for(int j = 0; j < members.size(); ++j) {
                if(members[j] == ',') members[j] = ' ';
            }

            istringstream is(members);
            string name;
            vector<string> &v = m[group];
            while(is >> name) {
                v.push_back(name);
            }
            if(i == 0) first = group;
        }

        visited.clear();
        set<string> members;
        merge(first, m, members);
        cout << members.size() << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

void bomb(char f[],int x,int y){
    int i;
    
    if(f[y*8+x]=='1'){
        f[y*8+x]='0';
        for(i=1;i<=3;i++){
            if(y-i>=0)bomb(f,x,y-i);
            if(x-i>=0)bomb(f,x-i,y);
            if(x+i<8)bomb(f,x+i,y);
            if(y+i<8)bomb(f,x,y+i);
        }
    }
}
int main(void){
    int N;
    scanf("%d",&N);
    
    char f[64];
    int x,y;
    
    int n,i,j;
    for(n=1;n<=N;n++){
        for(i=0;i<8;i++){
            for(j=0;j<8;j++){
                scanf(" %c\n",&f[i*8+j]);
            }
        }
        scanf("%d\n%d\n",&x,&y);
        
        bomb(f,x-1,y-1);
        
        printf("Data %d:\n",n);
        for(i=0;i<8;i++){
            for(j=0;j<8;j++){
                printf("%c",f[i*8+j]);
            }
            printf("\n");
        }
    }
    
    return 0;
}



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

public class Main {

	public static void main(String[] args) throws Exception, IOException {
		
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in), 1);
		
		int shakkin=100000;
		
		int n=Integer.parseInt(br.readLine());
		
		for(int i=0; i<n; i++) {
			shakkin*=1.05;
			if(shakkin%1000!=0)
				shakkin=(shakkin/1000+1)*1000;
		}
		
		System.out.println(shakkin);
	}
}

Measured memory_bytes: 15008
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;

signed main()
{
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    std::ios::sync_with_stdio(false);
    int t = 1;
    // cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<vector<int>> arr(n, vector<int>(2));
        for (int i = 0; i < n; i++) {
            cin >> arr[i][0];
            arr[i][1] = i + 1;
        }
        sort(arr.begin(), arr.end());
        for (int i = 0; i < n; i++) {
            cout << arr[i][1] << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 8660
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

ll mod = 1'000'000'007;

int		main(void)
{
	ll n;
	cin >> n;

	ll sum = 0;
	vector<ll> A(n);
	for (int i = 0; i < n; i++)
	{
		ll a;
		cin >> a;
		sum += a;
		A[i] = a;
	}
	ll ans = 0;
	for (int i = 0; i < n-1; i++)
	{
		sum -= A[i];
		ans += A[i] * (sum % mod);
		ans %= mod;
	}
	cout << ans << endl;
}



Measured memory_bytes: 4744
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e5+10;
const int E = 1e5+10;  
ll n;
ll h[3];
string t;
string s[maxn];
string ans;

int main(){
	cin>>n>>h[0]>>h[1]>>h[2];
	if(h[0]+h[1]+h[2]==0){
		F(i,1,n) cin>>t;
		printf("No\n");
		return 0;
	} 
	else if(h[0]+h[1]+h[2]>2||h[0]+h[1]+h[2]==1){
		bool flg = 1;
		F(i,1,n){
			cin>>t;
			int u = t[0]-'A';
			int v = t[1]-'A';
			if(h[u]==h[v]&&h[u]==0) flg = 0;
			if(h[u]>h[v]){
				h[u]--;
				h[v]++;
				ans+=t[1];
			}
			else{
				h[u]++;
				h[v]--;
				ans+=t[0];
			}
		}
		if(!flg){
			printf("No\n");
			return 0;
		}
		else{
			printf("Yes\n");
			F(i,0,ans.size()-1){
				cout<<ans[i]<<endl;
			}
		}
	}
	else if(h[0]+h[1]+h[2]==2){
		bool flg = 1;
		F(i,1,n){
			cin>>s[i];
		}
		F(i,1,n){
			int u = s[i][0]-'A';
			int v = s[i][1]-'A';
			if(h[u]==h[v]&&h[u]==0){
				flg = 0;
				printf("No\n");
				return 0;
			}
			if(h[u]>h[v]){
				h[u]--;
				h[v]++;
				ans+=s[i][1];
			}
			else if(h[u]<h[v]){
				h[u]++;
				h[v]--;
				ans+=s[i][0];
			}
			else{
				if(i<n){
					int p = s[i+1][0]-'A';
					int q = s[i+1][1]-'A';
					if(p==u&&q==v){
						h[u]--;
						h[v]++;
						ans+=s[i][1];
					}
					else if(p==u&&q!=v){
						h[u]++;
						h[v]--;
						ans+=s[i][0];
					}
					else if(p!=u&&q==v){
						h[u]--;
						h[v]++;
						ans+=s[i][1];
					}
					else if(p==v&&q!=u){
						h[v]++;
						h[u]--;
						ans+=s[i][1];
					}
					else if(q==u&&p!=v){
						h[u]++;
						h[v]--;
						ans+=s[i][0];
					}
				}
				else{
					ans+=s[i][0];
				}
			}
		}
		printf("Yes\n");
		F(i,0,ans.size()-1){
			cout<<ans[i]<<endl;
		}
	}
}


Measured memory_bytes: 6896
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BS
import           Data.List             (sort)
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  as <- map readInt . BS.words <$> BS.getLine
  print $ solve as

solve :: [Int] -> Int
solve as = sum . map (uncurry (-)) $ zip (tail as') as' where
  as' = sort as

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt


Measured memory_bytes: 380
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s: Chars
    };
    match s
        .iter()
        .position(|&s_i| s_i == 'C')
        .and_then(|i_c| s.iter().skip(i_c + 1).position(|&s_i| s_i == 'F'))
    {
        None => println!("No"),
        Some(_) => println!("Yes"),
    };
}


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

int main(){
  int N, A=0, B=0;
  cin >> N;
  vector<int> cards(N);
  rep(i, N){
    cin >> cards.at(i);
  }
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  rep(i, (N/2+ N%2)){
    A += cards.at(2*i);
    if (i == N/2) break;
    B += cards.at(2*i+1);
  }
  cout << A-B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}


int main() {
    ll a,b;
    cin>>a>>b;
    auto c = b-a;
    ll t =0;
    while(c>0) t+=(c--);
    pr(t-b);
}



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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int k, x;
	cin >> k >> x;
	for(int i = x - k + 1; i <= x + k - 1; ++i) cout << i << ' ';
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll t;
ll h[100005];

int main(void){
	scanf("%d%lld",&n,&t);
	ll maxi=0;
	ll all=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&h[i]);
		maxi=max(maxi,h[i]);
		ll l=0,r=INF;
		all+=h[i];
		while(l+1LL<r){
			ll mid=(l+r)/2LL;
			if((mid-1LL)*maxi+all<=t)l=mid;
			else r=mid;
		}
		printf("%lld\n",l+1LL);
	}
	return 0;
}

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

int main(void){
    int p = 0, w = 0, g = 0, y = 0, N;
    cin >> N;
    for(int i = 0; i < N; i++){
        string iro;
        cin >> iro;
        if(iro == "P"){
            p++;
        }else if(iro == "W"){
            w++;
        }else if(iro == "G"){
            g++;
        }else{
            y++;
        }
    }
    if(p * w * g * y != 0){
        cout << "Four" << endl;
    }else{
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
package main

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

func solve() {
	n := getInt()
	ps := getIntSlice(n)

	lowest := ps[0]
	ans := 0
	for _, p := range ps {
		if p > lowest {
			continue
		}

		ans++
		lowest = p
	}

	fmt.Fprintln(wr, ans)
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 3584
using System;

namespace tst
{
    class Program
    {
        public static void Main()
        {

            int n = int.Parse(Console.ReadLine());
            int i = 0;
            int j = 0;
            int[,] K = new int[10, 10];
            for(int k=1; k<=n; k++)
            {
                int val = k;
                j = val % 10;
                bool flag = true;
                while (flag)
                {
                    if(0<=val && val <= 9)
                    {
                        i = val;
                        flag = false;
                    }
                    else
                    {
                        val /= 10;
                    }
                }
                //Console.WriteLine("k={2},i ={0},j={1}", i, j,k);
                K[i,j]++;
            }
            int cnt = 0;
            for(int l=1; l<=9; l++)
            {
                for(int m=1; m<=9; m++)
                {
                    cnt += K[l,m] * K[m,l];
                }
            }
            Console.WriteLine(cnt);
        }

    }
}

Measured memory_bytes: 11092
n = int(input())
#桁数
def keta(x):
    count = 0
    while x != 0:
        count += 1
        x //= 10
    return count

#素数判定
ans = 1
ch = 0
for i in range(2,int(n**0.5)+1):
    if n%i == 0: #素数でない
        ans = max(ans,i)
        ch += 1
if ch == 0:
    print(keta(n))
    exit()

a = ans
b = n//a
ans = max(keta(a),keta(b))
print(min(ans, keta(n)))

Measured memory_bytes: 9444
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
void dfs(ll n,ll cu,string s,ll k){
  if(cu==n){
    cout<<s<<endl;
    return ;
  }
  for(ll i=0;i<=min(cu,k);i++){
    string h=s+(char)(i+'a');
    dfs(n,cu+1,h,max(k,i+1));
  }
  return ;
}
int main(){
  ll n;
  cin>>n;
  string s="";
  dfs(n,0,s,0);
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
const int MAXN=43;
const int MAXT=406;
const int INF=1e9+7;
int MA,N,MB,a[MAXN],b[MAXN],c[MAXN],dp[MAXN][MAXT][MAXT];

int main(){
	cin>>N>>MA>>MB;
	for(int i=1;i<=N;i++)	cin>>a[i]>>b[i]>>c[i];
	for(int i=0;i<MAXN;i++)for(int j=0;j<MAXT;j++)for(int k=0;k<MAXT;k++)	dp[i][j][k]=INF;
	dp[0][0][0]=0;
	for(int i=1;i<=N;i++){
		for(int j=0;j<=400;j++){
			for(int k=0;k<=400;k++){
				dp[i][j][k]=dp[i-1][j][k];
				if(j>=a[i]&&k>=b[i])
					dp[i][j][k]=min(dp[i][j][k],dp[i-1][j-a[i]][k-b[i]]+c[i]);
			}
		}
	}
	int mn=INF;
	for(int j=0;j<=400;j++)for(int i=0;i<=400;i++){
      int aa=i/MA,bb=j/MB;
      if(aa==bb&&aa>=1&&i%MA==0&&j%MB==0&&dp[N][i][j]!=INF){
	//cout<<i<<' '<<j<<' '<<aa<<' '<<bb<<' '<<dp[n][i][j]<<endl;
	mn=min(mn,dp[N][i][j]);
      }
    }
  if(mn==INF)cout<<-1<<endl;
  else
    cout<<mn<<endl;
}

Measured memory_bytes: 27904
//file_name:ABC89_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int h,w,d;
    scanf("%d%d%d",&h,&w,&d);
    int a[h][w];
    int num[h*w+1][2];
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
            num[a[i][j]][0]=i;
            num[a[i][j]][1]=j;
        }
    }
    int score[h*w+1] = {};
    srep(i,1,d+1){
        score[i] = 0;
    }
    srep(i,d+1,h*w+1){
        score[i] = score[i-d] + abs(num[i][0]-num[i-d][0]) + abs(num[i][1] - num[i-d][1]);
    }



    int ans = 0;
    int q;
    cin >> q;
    rep(i,q){
        int l,r;
        cin >> l >> r;
        cout << score[r] - score[l] << endl;
    }

    return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <cassert>
#include <map>

using ll = long long;
std::map<ll,int> frec;

int main() {
  int n;
  std::cin >> n;
  ll sum = 0;
  frec[sum]++;
  ll result = 0;
  for(int i = 1;i <= n; i++) {
    int val;
    std::cin >> val;
    sum += val;
    frec[sum]++;
    result += frec[sum] - 1;
  }
  std::cout << result;
  return 0;
}


Measured memory_bytes: 16056
#include <iostream>

using namespace std;

int main()
{
  int n;
  int i,j,k;
  while(1){
	cin >> n;
	if(n == 0) break;
	int m[200];
	int p[200][200];

	for (i = 0; i < n; i++) {
	  cin >> m[i];
	  for (j = 0; j < m[i]; j++) {
		cin >> p[i][j];
	  }
	}
	cin >> k;
	int hoge;
	int l[200];
	for(hoge = 0;hoge < k; hoge++){
	  cin >> l[hoge];
	}

	int ans = 0;
	int c = 0;

	for(i = 0; i < n; i++){
	  for(j = 0; j < m[i]; j++){
		for(int a = 0; a < k; a++){
		  if(l[a] == p[i][j]){
			c++;
			break;
		  }// else if(l[a] > p[i][j]){
		  // 	break;
		  // }
		}
		if(c == k){
		  if(ans == 0) {
			ans = (i+1);
			// cout << i << endl;
			break;
		  }
		  else {
			ans = -1;
			break;
		  }
		}
	  }
	  c = 0;
	}

	if(ans == 0) ans = -1;


	cout << ans << endl;

  }
  return 0;
}

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

int main(){
int n;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  
  int count=1;
  for(int i=1;i<n;i++){
    if(vec.at(i)<vec.at(i-1)){
      count++;
    }
  }
  cout<<count<<endl;
}
    
    

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long N;
cin>>N;
long long tmp=0;
long long last=10000000000;
long long ans=0;
long long h;
cin>>h;
last=h;
for(int i=1;i<N;++i){
  cin>>h;
  if(h<=last){
    tmp+=1;
    last=h;
  }
  else{
    if(ans<tmp){
      ans=tmp;
    }
    tmp=0;
    last=h;
  }
}
if(ans<tmp){
  ans=tmp;
}

cout<<ans<<"\n";

return 0;
}

Measured memory_bytes: 384
n,k = map(int,input().split())
ls = list(map(lambda x:int(x)-1,input().split()))

ved = [-1]*n
ved[0] = 0
cur = 0
i = k
while i > 0:
  cur = ls[cur]
  i -= 1  
  if ved[cur] >= 0:
    i= i % ((k-i)-ved[cur])
  else:
    ved[cur] = k-i
print(cur+1)
    

Measured memory_bytes: 32372
//
//  Created by Henry Cafaro
//  Copyright © 2020 Henry Cafaro. All rights reserved.
//

# include <iostream>
# include <string>
# include <vector>
# include <algorithm>
# include <bitset>
# include <queue>
# include <cstring>


#define ll long long

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        
        
    int n;
    cin >> n;
    
    ll int sum = 0;
    ll int arr[200000];
    
    ll int t;
    for(int i = 0; i < n; i++){
        cin >> t;
        arr[i] = t;
    }
    
    sort(arr, arr+n);
    int ct = n-1;
    if(ct>  0){
    sum += arr[n-1];
        n--;
    ct--;
    }
    
    while(ct>0){
        if(ct >=2){
            sum+=2*arr[n-1];
            ct -= 2;
            n--;
        }
        else if(ct == 1){
            sum += arr[n-1];
            ct--;
        }
        
    }
    
    cout << sum << endl;
    
   
    
    
    
    
    
    
    
    
    
    
}


Measured memory_bytes: 5208
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
//<< setprecision(5)
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
const int mod=1000000007;
const llint big=1e9+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	string str;cin>>str;
	if(str.size()>=4&&str[0]=='Y'&&str[1]=='A'&&str[2]=='K'&&str[3]=='I'){cout<<"Yes"<<endl;}
	else{cout<<"No"<<endl;}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 1123456789012345
using namespace std;

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

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

int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    
   if((b-a)==(c-b))
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>

typedef long long ll;
using namespace std;
int main(){
    string s,pre,be;
    cin>>s;
    int q; cin>>q;
    int f = 1, x, op;
    char c;
    while(q--){
        cin>>op;
        if(op==1){
            f = 1 - f;
        }
        else{
            cin>>x>>c;
            if(x == 1){
                if(f == 1) pre.push_back(c);
                else be.push_back(c);
            }
            else{
                if(f == 1) be.push_back(c);
                else pre.push_back(c);
            }
        }
    }
    if(f == 1) reverse(pre.begin(), pre.end());
    else reverse(be.begin(),be.end());
    if(f == 1){
        cout<<pre<<s<<be; 
    }
    else{
        reverse(s.begin(),s.end());
        cout<<be<<s<<pre;
    }
    // system("pause");
}

Measured memory_bytes: 1088
n = input()
a = len(n) % 2

b = []
c = []

res = 0
if a == 0:
  s = n[0:len(n) // 2]
  for i in range(len(n) // 2):
    b.append(n[len(n) - i - 1])
    c.append(n[i])
elif a == 1:
  s = n[0:len(n) // 2 ]
  for i in range(len(n) // 2 ):
    b.append(n[len(n) - i - 1])
    c.append(n[i])

for i, j in zip(b, c):
  if i != j:
    res += 1
print(res)

Measured memory_bytes: 3064
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]

INF = int(pow(10, 10))

a = [INF] * n
a[0] = 0

for i in range(1, n):
	for j in range(1, k+1):
		if i-j >= 0:
			b = a[i-j] + abs(h[i-j]-h[i])
			if b < a[i]:
				a[i] = b

print(a[n-1])

Measured memory_bytes: 52448
row = int(input())
colmun = int(input())
top = int(input())
low, high = 0,0
if row <= colmun:
  low, high = row, colmun
else:
  low, high = colmun, row
for n in range(low):
  if (n + 1) * high >= top:
    print(n + 1)
    break

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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

i64 fact[200005] , invFact[200005] ;
i64 pos[200005] , a[maxn] ;


typedef pair<i64, i64> pii;
#define x first
#define y second

pii extendedEuclid(i64 a, i64 b) { // returns x, y | ax + by = gcd(a,b)
  if(b == 0) return pii(1LL, 0LL);
  else {
    pii d = extendedEuclid(b, a % b);
    return pii(d.y, d.x - d.y * (a / b));
  }
}

i64 modularInverse(i64 a, i64 n) {
  pii ret = extendedEuclid(a, n);
  return ((ret.x % n) + n) % n;
}

i64 C(i64 n, i64 r)
{
    if( n<0 || r<0 || n<r  ) return 0 ;
    else return (((invFact[r]*invFact[n-r])%mod)*fact[n])%mod ;
}

i64 ans[maxn] ;

int main()
{
    i64 i , j , k , l , m , n ;

    i64 cancel ;

    scanf("%lld",&n) ;

    for(i=1 ; i<=n+1 ; i++){
        scanf("%lld",&a[i]) ;
        if(pos[a[i]]!=0) cancel = i-pos[a[i] ] + 1 ;
        else pos[a[i] ]  = i ;
    }

    fact[0] = 1 ; invFact[0] = 1 ;

    for(i=1 ; i<=n+1 ; i++)
    {
        fact[i] = (fact[i-1]*i)%mod ;
        invFact[i] = modularInverse(fact[i],mod) ;
    }

    for(i=1 ; i<=n+1 ; i++)
    {
        ans[i] = ( (C(n+1,i) - C(n+1-cancel,i-1))%mod + mod )%mod ;
        printf("%lld\n",ans[i]) ;
    }

    return 0 ;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    COMinit();
    int n,blue,red;
    long long int ans;
    cin >> n >> blue;
    red = n-blue;
    long long int sum =0;
    FOR(i,1,blue+1){
        cout << (COM(red+1,i)*COM(blue-1,i-1))%MOD<< endl;
    }
    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#define MAX 250
using namespace std;

int nodes[MAX];
int n;

void print(int i){
  printf("node %d: key = %d, ",i,nodes[i]);
  if(i != 1){
    printf("parent key = %d, ",nodes[i/2]); 
  }
  if(i * 2 <= n){
    printf("left key = %d, ",nodes[i*2]);
  }
  if(i * 2 + 1 <= n){
    printf("right key = %d, ",nodes[i*2+1]);
  }
  printf("\n");
}

int main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>nodes[i];
  }

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

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  int x = 1;
  int now;
  for (int i=1; i<=5; i++) {
    cin>>now;
    if (now == 0)
      x = i;
  }

  cout<<x<<endl;
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#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 Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

int main(){
    string s, t;
    cin >> s >> t;
    int slen = s.length();
    int tlen = t.length();
    vvi dp(slen+1, vi(tlen+1, 0));
    rep(i, slen){
        rep(j, tlen){
            if(s.at(i) == t.at(j)){
                chmax(dp.at(i+1).at(j+1), dp.at(i).at(j)+1);
                continue;
            }
            chmax(dp.at(i+1).at(j+1), dp.at(i+1).at(j));
            chmax(dp.at(i+1).at(j+1), dp.at(i).at(j+1));
        }
    }
    string ans = "";
    while(dp.at(slen).at(tlen) > 0){
        if(s.at(slen-1) == t.at(tlen-1)){
            ans += s.at(slen-1);
            slen--;
            tlen--;
        }
        else if(dp.at(slen).at(tlen) == dp.at(slen-1).at(tlen)){
            slen--;
        }
        else {
            tlen--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

typedef long long ll;
ll n, m, cnt, a[N], b[N], s[N], ans[N], bu[N];
ll f(ll p) {
	if (bu[p] == p) return p;
	else return bu[p] = f(bu[p]);
}
int main()
{
	ll i, t1, t2;
	cin >> n >> m;
	for (i = 1; i <= n; i++) {
		bu[i] = i;
		s[i] = 1;
	}
	for (i = 0; i < m; i++) {
		scanf ("%lld %lld", &a[i], &b[i]);
	}
	cnt = n * (n - 1) / 2;
	for (i = m - 1; i >= 0; i--) {
		ans[i] = cnt;
		t1 = f(a[i]);
		t2 = f(b[i]);
		if (t1 != t2) {
			cnt -= s[t1] * s[t2];
			s[t1] += s[t2];
			bu[t2] = t1;
		}
	}
	for (i =0; i < m; i++) printf("%lld\n", ans[i]);
    return 0;
}


Measured memory_bytes: 5376
#include <iostream> // cout, endl, cin
#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
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    vector<int> sorted;
    sorted = A;
    sort(sorted.begin(),sorted.end());
    int ans = inf;
    for(int _=0; _<N; _++){
        int mn = sorted[_];
        vector<int> check;
        vector<int> now;
        for(int i=0; i<N; i++){
            if(mn <= A[i]){
                now.emplace_back(A[i]);
            }else{
                sort(now.rbegin(),now.rend());
                for(int j=K-1; j<now.size(); j++){
                    check.emplace_back(now[j]);
                }
                now.clear();
            }
        }
        sort(now.rbegin(),now.rend());
        for(int j=K-1; j<now.size(); j++){
            check.emplace_back(now[j]);
        }
        sort(check.begin(),check.end());
        if(check.size() >= Q){
            chmin(ans,check[Q-1]-mn);
        }
    }
    cout << ans << "\n";
    return 0;
}

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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  int pre = -1;
  rep(i,n) {
    if (pre <= h[i]-1) {
      pre = h[i]-1;
    } else if (pre <= h[i]) {
      pre = h[i];
    } else {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}


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

string kata;
int len;
int prefixsum[100005];
int tmp;

int main(){
	cin>>kata;
	int r = kata.length();
	len = r;
	int l = 1;
	while(l<r){
		int mid = (l+r+1)>>1;
		
		memset(prefixsum, 0, sizeof(prefixsum));
		tmp =0;
		for(int i=0; i+mid <= len; i++){
			tmp += prefixsum[i];
			int nilpos = (kata[i] - '0') ^ (tmp & 1);
			if(nilpos){
				prefixsum[i+1] ++;
				prefixsum[i+mid] --;
			}
		}
		int sisa  = len - mid;
		for(int i=len-mid+1;i<len;i++){
			tmp += prefixsum[i];
			int nilpos = (kata[i] - '0') ^ (tmp & 1);
			if(nilpos == 0) sisa = i;else break;
		}
		if(sisa+1 >= mid){
			l = mid;
		}else{
			r = mid -1;
		}
	}	
	cout<<l<<"\n";
}

Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  int c=1, out=A;
  if(B==1){
    c=0;
  }else{
    while(out<B){
      out+=A-1;
      c++;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    string S;
    cin >> S;
    cout << "2018/01/" << S.substr(8,2) << "\n";
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut ans = vec![0; n];
    for i in 0..n {
        let k: usize = read();
        ans[k - 1] = i + 1;
    }
    println!("{}", ans.iter().map(|i| i.to_string()).collect::<Vec<_>>().join(" "))
}


Measured memory_bytes: 11004
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n = int(input())
a_list = np.array(list(map(int, input().split())))

a_mx = np.maximum.accumulate(a_list)

ans = (a_mx - a_list).sum()

print(ans)

Measured memory_bytes: 51976
#include<iostream>
#include<cstdio>
#include<cstring>
#define REP(i,e,s) for(register int i=e; i<=s; i++)
#define DREP(i,e,s) for(register int i=e; i>=s; i--)
#define DE(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG(a) DE("DEBUG: %d\n",a)
#define file(a)	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
using namespace std;
 
int read() {
	int x=0,f=1,ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
 
int main() {
	int r=read();
	printf("%.8lf\n",2*r*3.1415926);
	return 0;
}

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

    signed main() {
        int s;
        cin>>s;int ans=1;
        while(true){
            if(s==4||s==2||s==1){
                cout<<ans+3;
                return 0;
            }
            if(s%2)s=3*s+1;
            else s/=2;
            ans++;
        }
    }


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
even_cnt = []
for i in range(n):
    if a[i]%2==0:
        even_cnt.append(1)
        a[i] = 2
    else:
        even_cnt.append(2)
        a[i] = 1
x = 3 ** n
ans = 0
for i in range(n):
    x //= 3
    ans += even_cnt[i]*x
    x *= a[i]
print(ans)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    *t++;
    while(t != V.end()) {
        cout << " " << *t++;
        // if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    vector<int> v(0);
    cin >> n;
    rep(i, n) {
        cin >> a;
        if(a < 2) {
            cin >> b;
            if(a)
                cout << v.at(b) << "\n";
            else
                v.push_back(b);
        } else {
            v.pop_back();
        }
    }
}



Measured memory_bytes: 3956
#include <stdio.h>

void swap(int *x, int *y)
{
  int temp;
  temp = *x;
  *x = *y;
  *y = temp;
  
}

int main(void)
{

  int a,b,c;
  scanf("%d%d%d", &a, &b, &c);
  
  if( a > b ){
 
    if( b > c ){
      swap( &a, &c );
      }
    else{
 
      if( a > c ){
        swap( &a, &c );
        swap( &a, &b );
        }
      else{
        swap( &a, &b );
        }
      }
    }
    
  else{
    
    if( b > c ){
      
      if( a > c ){
        swap( &a, &c );
        swap( &b, &c );
      }
      else{
        swap( &b, &c );
      }
    }
  }
  
  printf("%d %d %d\n", a, b, c);
       
  return 0;

}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <algorithm>
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, LL> pil;

const int MAXN = 3500;

template<typename T> inline T read() {
	T res = 0, flag = 1; char in = getchar();
	while(!isdigit(in)) { if(in == '-') flag = -1; in = getchar(); }
	while(isdigit(in)) { res = (res << 1) + (res << 3) + in - '0'; in = getchar(); }
	return res * flag;
}

template<typename T> inline void chkmax(T &a, T b) { if(a < b) a = b; }
template<typename T> inline void chkmin(T &a, T b) { if(a > b) a = b; }

double dp[MAXN][MAXN];
double p[MAXN], ans;
int n;

inline void solve() {
	n = read<int>();
	for(int i = 1; i <= n; ++i) scanf("%lf", &p[i]);
	dp[0][0] = 1;
	for(int i = 1; i <= n; ++i)
		for(int j = 0; j <= i; ++j) {
			dp[i][j] += dp[i - 1][j] * (1 - p[i]);
			if(j) dp[i][j] += dp[i - 1][j - 1] * p[i];
		}
	for(int i = 1; i <= n; ++i)
		if(i > n - i) ans += dp[n][i];
	printf("%.10lf", ans);
}

int main() {

	solve();

	return 0;
}



Measured memory_bytes: 82560
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
LL mod = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(n); sll(m);
	LL cns[m];
	rep(i, 0, m)	cns[i] = scanLong();
	sort(cns, cns+m);
	VLL diffs;
	rep(i, 1, m)	diffs.push_back(cns[i]-cns[i-1]);
	sort(diffs.begin(), diffs.end());
	LL ans = cns[m-1] - cns[0];
	LL cnt = 0;
	rep(i, (LL)diffs.size(), 0ll) {
		if(cnt + 1 == n)	break;
		ans -= diffs[i];
		cnt++;
	}
	pll(ans); nl;
}

Measured memory_bytes: 2168