akhauriyash/Code-Regression huggingface dataset:
n=int(input())
h=list(map(int,input().split()))
inf=float("inf")
dp=[(inf) for i in range(n)]
dp[0]=0

for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    else:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 13980
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, h;
	cin >> n >> h;
	vector<int> a(n), b(n);
	rep(i, 0, n) cin >> a[i] >> b[i];
	int ans = 0;
	sort(all(a));
	reverse(all(a));
	sort(all(b));
	reverse(all(b));
	rep(i, 0, n){
		if(b[i] >= a[0]){
			h -= b[i];
			ans++;
			if(h <= 0) break;
		}
	}
	cout << ans + (max(0LL, h) + a[0] - 1) / a[0] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  vector<int> A;
  cin >> N;
  for (int i = 0; i < N; i++)
  {
    int a;
    cin >> a;
    A.push_back(a);
  }
  double ans;
  for (int i = 0; i < N; i++)
  {
    ans += (1.0 / A.at(i));
  }
  printf("%.8lf", 1.0 / ans);
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	fmt.Scan(&n)
	pt, px, py := 0, 0, 0
	for i := 0; i < n; i++ {
		var t, x, y int
		fmt.Scan(&t, &x, &y)
		rt := (t - pt) - (Abs(x-px) + Abs(y-py))
		if rt < 0 || rt%2 != 0 {
			fmt.Println("No")
			return
		}
		pt, px, py = t, x, y
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int h, w;
	cin >> h >> w;

	vector<vector<int>> c(10, vector<int>(10));
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}

	vector<vector<int>> a(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}

	vector<vector<int>> magic = c;
	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (magic[i][k] + magic[k][j] < magic[i][j]) {
					magic[i][j] = magic[i][k] + magic[k][j];
				}
			}
		}
	}

	ll res = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == -1) {
				continue;
			}
			res += magic[a[i][j]][1];
		}
	}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template <class T>
vector<T> merge(vector<T> &A, vector<T> &B) {
    vector<T> ans;
    for (int i = 0; i < B.size(); i++) {
        ans.push_back(A[i]);
        ans.push_back(B[i]);
    }
    if (A.size() > B.size()) ans.push_back(A[B.size()]);
    return ans;
}
template <class T>
int inversion(vector<T> &A) {
    vector<T> B = A;
    int ans = 0;
    for (int i = 0; i < B.size(); i++) {
        for (int j = B.size() - 1; j - 1 >= 0; j--) {
            if (B[j - 1] > B[j]) swap(B[j - 1], B[j]), ans++;
        }
    }
    return ans;
}
int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    for (auto &a : A) cin >> a;
    for (auto &b : B) cin >> b;
    int half = (N + 1) / 2;
    int ans = 1e9;
    for (int mask = 0; mask < (1 << N); mask++) if (__builtin_popcount(mask) == half) {
        vector<pair<int, int>> C, D;
        for (int i = 0; i < N; i++) {
            if ((1 << i) & mask) {
                if (i % 2 == 0) C.emplace_back(A[i], i);
                else C.emplace_back(B[i], i);
            } else {
                if (i % 2 == 0) D.emplace_back(B[i], i);
                else D.emplace_back(A[i], i);
            }
        }
        sort(begin(C), end(C));
        sort(begin(D), end(D));
        auto E = merge(C, D);
        vector<int> F;
        for (int i = 0; i + 1 < E.size(); i++) {
            if (E[i].first > E[i + 1].first) {
                goto NEXT;
            }
        }
        for (int i = 0; i < E.size(); i++) {
            F.push_back(E[i].second);
        }
        ans = min(ans, inversion(F));
        NEXT:;
    }
    cout << (ans == 1e9 ? -1 : ans) << endl;
    return 0;
}


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

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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int N,M;
    cin>>N>>M;
    dsu tree(N);
    rep(i,M){
        int A,B;
        cin>>A>>B;
        tree.merge(A-1,B-1);
    }
    int ans = tree.groups().size();
    cout<<ans-1<<endl;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

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

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

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

    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vl a = vl(x);
    for (int i = 0; i < x; ++i) cin >> a[i];
    vl b = vl(y);
    for (int i = 0; i < y; ++i) cin >> b[i];
    vl c = vl(z);
    for (int i = 0; i < z; ++i) cin >> c[i];

    vl ab1 = vl(0);
    for (int i = 0; i < x; ++i) {
        for (int j = 0; j < y; ++j) {
            ab1.push_back(a[i] + b[j]);
        }
    }

    sort(ALL(ab1));
    reverse(ALL(ab1));

    vl ab2 = vl(0);
    for (int i = 0; i < ab1.size(); ++i) {
        if (i > k) break;

        ab2.push_back(ab1[i]);
    }

    vl abc = vl(0);
    for (int i = 0; i < ab2.size(); ++i) {
        for (int j = 0; j < z; ++j) {
            abc.push_back(ab2[i] + c[j]);
        }
    }

    sort(ALL(abc));
    reverse(ALL(abc));

    for (int i = 0; i < k; ++i) {
        cout << abc[i] << endl;
    }

    return 0;
}


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

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

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

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

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

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

// ===

fn main() {
    let (n, k): (i32, i32) = read();
    println!("{}", min(1, n%k));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,T;
pair<int,int>p[200001];
int dp[200001][32];
bool cmp(pair<int,int>a,pair<int,int>b)
{
	return (a.first-1)*b.second>(b.first-1)*a.second;
}/*
bool cmp(pair<int,int>a,pair<int,int>b)
{
	if(a.first==b.first)
		return a.second<b.second;
	return a.first>b.first;
}*/
bool cmp2(pair<int,int>a,pair<int,int>b)
{
	return a.second<b.second;
}
vector<pair<int,int> >v,v2;
signed main()
{
	memset(dp,0x3f,sizeof(dp));
	scanf("%lld%lld",&n,&T);T++;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&p[i].first,&p[i].second),p[i].first++,p[i].second++;
		if(p[i].first>=2)
			v.push_back(p[i]);
		else
			v2.push_back(p[i]);
	}
	sort(v.begin(),v.end(),cmp);
	sort(v2.begin(),v2.end(),cmp2);
	dp[0][0]=1;
	for(int i=0;i<v.size();i++)
	{
		for(int j=0;j<31;j++)
			if(dp[i][j]<=T)
		{
			dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]*v[i].first+v[i].second);
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
		}
	}
	int ans=0;
	for(int j=0;j<31;j++)
		if(dp[v.size()][j]<=T)
		{
			int tot=0;
			for(int i=0;i<v2.size();i++)
				if(T-v2[i].second>=dp[v.size()][j])
					dp[v.size()][j]+=v2[i].second,tot++;
			ans=max(ans,j+tot);	
		}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 58224
#include "bits/stdc++.h"

using namespace std;
// jebote stupidast
int main() {
    long long a, b;
    cin >> a  >> b;
    for(long long i = 0; i < 100000; ++i){
        if((long long)(i * 0.08) == a && (long long)(i * 0.1) == b){
            cout << i;
            return 0;
        }
    }
    cout << -1;

	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, L;
	cin >> N >> L;
	vector<int>T(N);
	rep(i, N) {
		T[i] = L + i;
	}
	sort(T);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += T[i];
	}
	int m = 1000000000;
	rep(i, N) {
		if (abs(m) > abs(T[i])) {
			m = T[i];
		}
	}
	cout << ans - m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int N,Q;
  ll K;
  cin >> N >> K >> Q;
  int A[Q];
  ll B[N];
  for(int i=0;i<N;i++){
    B[i]=K;
  }
  for(int i=0;i<Q;i++){
    cin >> A[i];
    ++B[A[i]-1];
  }
  for(int i=0;i<N;i++){
    B[i]-=Q;
    if(B[i]>0){
      cout << "Yes" <<endl;
    }else cout << "No" <<endl;
  }
}



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

const int INF = 1e18;
int a[200010];

signed main(){

  int n; cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];

  int mi = INF;
  int ans = INF;
  for(int i = 0; i < n; i++){
    ans = min(ans,mi-a[i]);
    mi = min(mi,a[i]);
  }
  if(ans < 0) cout << -ans << endl;
  else cout << -ans << endl;

  return 0;
}



Measured memory_bytes: 4656
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する
ll mod = 1000000007;

ll pask[101][101];

void calcpask() {
    REP(i, 1, 101) {
        pask[i][i] = 1;
        pask[i][0] = 1;
    }
    REP(i, 1, 101) {
        REP(j, 1, i) {
            if (pask[i][j] == 0)pask[i][j] = pask[i - 1][j - 1] + pask[i - 1][j];
        }
    }
}

int main() {
    //入力
//    string s = "abcdef";
//    cout << s.substr(1,2) << endl;
//    cout << s.substr(1,3) << endl;

    int M, N;
    cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);
    REP(i, 0, N) cin >> A[i];
    REP(i, 0, M) cin >> B[i];

    REP(a, 0, N - M + 1) {
        REP(b, 0, N - M + 1) {
            bool flag = true;
            REP(i, 0, M) {
                string s1 =  A[b + i].substr(a,a+M);
                string s2 = B[i];
                if(A[b + i].substr(a,M) != B[i]){
                    flag = false;
                }
            }
            if(flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }


    cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include<string.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define Max(x,y,z) max(x,max(y,z))
    #define Min(x,y,z) min(x,min(y,z))
    #define fr(i,s,e) for(i=s;i<e;i++)
    #define rf(i,s,e) for(i=s-1;i>=e;i--)
    #define pb push_back
    #define eb emblace_back
    #define mp make_pair
    #define ff first
    #define ss second
    #define ll long long
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define vl vector<long long>
     
    #define vi vector<int> 
    #define vii vector< vector<int> >
    #define vll vector< vector<long long> >
    #define vpi vector< pair<int,int> >   
    #define vpl vector< pair<ll,ll> >   
    typedef pair<pair<int, int>,int> P;
     #define mod %1000000007
     
    bool less_vectors(const vector<int>& a,const vector<int>& b) 
    {
       return a.size() > b.size();
    }
     
    int gcd(int a,int b)
    {
    	if(a%b==0)
    		return b;
    		else
    			return gcd(b,a%b);
    }
     
    bool cmp(pair<int,pair<int,int> >  p1,pair<int,pair<int,int> > p2)
    {
    		return p1.ff>p2.ff;
    }
    
    int main()
    {
    	IOS;
    	int n;
		cin>>n;
		vl v(n);
		ll c=0;
		vl cf(n);
		for(int i=0;i<n;i++)
		{
			cin>>v[i];
			c+=v[i];
			cf[i]=c;
		}
		ll ans=1e17;
		for(int i=1;i<n;i++)
		{
			ll j=cf[i-1];
			ll k=c-cf[i-1];
			ans=min(ans,abs(j-k));
		}
		cout<<ans;
    	return 0;
    		
    } 

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <queue>
#include <string>

using namespace std;

const double PI = 3.14159265358979;

struct Item
{
	int value;
	int weight;
};

int dp[101][10001];

int main() {

	int N, W; cin >> N >> W;

	Item* items = new Item[N + 1];
	for (int i = 1; i <= N; i++) {
		int v, w; cin >> v >> w;
		items[i].value = v;
		items[i].weight = w;
	}

		
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= W; j++) {
			if (j >= items[i].weight) {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - items[i].weight] + items[i].value);
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
		//for (int k = 1; k <= W; k++)
		//{
		//	cout << dp[i][k] << " ";
		//}
		//cout << endl;
	}
	cout << dp[N][W] << endl;

	delete[] items;
	return 0;
}



Measured memory_bytes: 7008
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main() {
    lli h,w,c,a,sum=0;
    vector<vector<lli>> dp(10,vector<lli>(10,0));
    lli i,j,k;
    cin>>h>>w;
    rep(i,0,10){
        rep(j,0,10){
            cin>>c;
            dp[i][j]=c;
        }
    }
    rep(i,0,10){
        rep(j,0,10){
            rep(k,0,10){
                dp[j][k]=min(dp[j][k],dp[j][i]+dp[i][k]);
            }
        }
    }
    rep(i,0,h){
        rep(j,0,w){
            cin>>a;
            if(a!=-1){
                sum+=dp[a][1];
            }
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s);
    let s = &s.trim();
    let l = s.len() - 2;
    let mut s = s.chars();
    let e = s.clone().last().unwrap();
    let f = (&mut s).next().unwrap();
    
    println!("{}{}{}", f, l, e);
}


Measured memory_bytes: 4352
#include<stdio.h>
void gcd(int x, int y);
void output(int x);

int main(void){
  int x=0;
  int y=0;

  scanf("%d",&x);
  scanf("%d",&y);

 
  gcd(x,y);

  return 0;
}


void gcd(int x, int y){
 
  int t=0;
  if(y==0)
    output(x);
  else{
    t = x%y;
    gcd(y,t);
  }
}

void output(int x){
  printf("%d",x);
  putchar('\n');
}




  



Measured memory_bytes: 2732
using System;

namespace ITP_8_B{
    public class Program{
        public static void Main(string[] args){
            while(true){
                string test = Console.ReadLine();
                int sum = 0;
                if(test.Equals("0")) break;

                for(int i=0; i<test.Length; i++){
                    //char??§?????°???1???int???49???????§????????????§48??????????????¨??§?¨?????????????
                    sum += test[i] -48;
                }
                Console.WriteLine(sum);
            }
        }
    }
}

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

using namespace std;

#define Fast  ios::sync_with_stdio(false); cin.tie(0)
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define S second
#define F first
typedef long long ll;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 5;
ll inf = 1e18;

ll a[N];
ll sm[N];

int main(){

    Fast;

    ll n;
    cin >> n;

    for(int i = 0  ;i < n ;i ++)cin >> a[i];

    sm[n-1] = a[n-1];

    for(int i = n-2; i >= 0 ; i --){
        sm[i] = a[i] + sm[i+1];
        sm[i] %= mod;
    }

    ll ans = 0;

    for(int i = 0 ; i < n-1 ;i ++){
        ans += a[i] * sm[i+1];
        ans %= mod;
    }

    cout << ans ;



    return 0;
}


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

int main(){
    int n,k,d,t;
    int sum = 0;
    cin >> n >> k;
    vector<int> p(n,0);
    for(int i = 0; i < k; i++){
        cin >> d;
        for(int j = 0; j < d; j++){
            cin >> t;
            if(p[t-1] == 0){
                p[t-1] = 1;
                sum++;
            }
        }
    }
    cout << n-sum << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll H, W;
  cin >> H >> W;
  
  if(H==1 || W==1){
    cout << 1 << endl;
    return 0;
  }
  
  if((H*W)%2==0){
	cout << H*W/2 << endl;
  }else{
    cout << (H*W/2)+1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =1;

int main(){
    int n;  cin >> n;
    ll all=0;
    int w[n];
    rep(i,n){
        
        cin >> w[i];
        all += w[i];
    }

    ll sum1[n],sum2[n],minimam=INF;
    sum1[0]=w[0];
    sum2[0]=all - sum1[0];
    

    for(int i=1;i<n;i++){
        sum1[i] = w[i]+sum1[i-1];
        sum2[i] = all - sum1[i]; 
        
        minimam = min(minimam,abs(sum1[i]-sum2[i]));
    }
    cout << minimam << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define FOR0(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)

int abs(int n)
{
    if (n >= 0)
        return n;
    else
        return -n;
}

int main()
{
    bool safe = true;
    int N;
    cin >> N;
    int b[N + 1];
    FOR(i, 1, N)
    {
        cin >> b[i];
    }
    int d[N + 1];
    FOR(i, 1, N)
    {
        d[i] = i - b[i];
        if (d[i] < 0)
        {
            safe = false;
            break;
        }
    }
    int ans[N + 1];
    FOR(i, 1, N)
    {
        if (!safe)
        {
            break;
        }
        int max_0 = 0;
        FOR(j, 1, N - i + 1)
        {
            if (d[j] == 0)
            {
                max_0 = j;
            }
        }
        if (max_0 == 0)
        {
            safe = false;
            break;
        }
        ans[N - i + 1] = b[max_0];
        FOR(j, max_0, N - i)
        {
            b[j] = b[j + 1];
            d[j] = d[j + 1] - 1;
        }
    }
    if (!safe)
    {
        cout << -1 << endl;
    }
    else
    {
        FOR(i, 1, N)
        {
            cout << ans[i] << endl;
        }
    }
}

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


int main(){

	int m, h, len, i;
	char str[201], tmp[201];


	while(1){

		scanf( "%s", str );	
		if( strcmp(str, "-" ) == 0) break;

		len = strlen(str);

		scanf( "%d", &m );

		for( i=0; i<m; i++ ){
	
			scanf( "%d", &h );
	
			strncpy( tmp, &str[h], len-h);
			strncpy( &tmp[len-h], str, h);
			tmp[len] = '\0';
			

			strncpy( str, tmp, len );

		}
	
		printf( "%s\n", str );

	}	

	return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void ChMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void ChMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  DivUp(T a, T b)   {return ((a+b-1)/b);}

int main(){
    int n;
    string str;
    cin >> n >> str;

    str.erase(unique(str.begin(), str.end()), str.end());
    cout << str.size() << endl;
    return 0;
}
/*

*/


Measured memory_bytes: 3692
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    ans = 0
    for a in range(1, N+1):
        for b in range(1, N//a + 1):
            c = N - a*b
            if c > 0:
                ans += 1

    return ans


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 78660
K = int(input())

lunlun = []
for i in range(10):
    lunlun.append([0, i])

count, itr = 9, 1
while count < K:
    if lunlun[itr][1] == 0:
        lunlun.append([itr, 0])
        lunlun.append([itr, 1])
        count += 2
    elif lunlun[itr][1] == 9:
        lunlun.append([itr, 8])
        lunlun.append([itr, 9])
        count += 2
    else:
        lunlun.append([itr, lunlun[itr][1] - 1])
        lunlun.append([itr, lunlun[itr][1]])
        lunlun.append([itr, lunlun[itr][1] + 1])
        count += 3
    itr += 1

ans = ""
itr = K
while True:
    ans = str(lunlun[itr][1]) + ans
    if lunlun[itr][0] != 0:
        itr = lunlun[itr][0]
    else:
        break

print(ans)


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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
uf = UnionFind(N)      
V = [[] for _ in range(N)]

for _ in range(M):
  a,b = map(int, input().split())
  a,b = a-1, b-1
  V[a].append(b)
  V[b].append(a)
  uf.union(a,b)
  
for _ in range(K):
  a,b = map(int, input().split())
  a,b = a-1, b-1
  if uf.same(a,b):
    V[a].append(b)
    V[b].append(a)

ans = [-1] * N
for i in range(N):
  ans[i] = uf.size(i) - len(V[i]) - 1
  
print(" ".join(list(map(str, ans))))



Measured memory_bytes: 109564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x;
  cin >> x;
  vl dp(x + 1, 0);
  dp[0] = 1;
  rep(i, 6) rep(j, x) {
    ll nj = j + 100 + i;
    if(nj <= x) dp[nj] += dp[j];
  }
  cout << (dp[x] > 0 ? 1 : 0) << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin >> s;
  REP(i,s.size()){
      if (s[i]!='B')t+=s[i];
      else{
          if(t.size()!=0){
              t.erase(t.size()-1);
          }
      }
  }
  cout << t << endl;
}


Measured memory_bytes: 256
import sys
import numpy as np
from math import ceil as C, floor as F, sqrt
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
 
ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

_, k = Is()
towns = [i-1 for i in Is()]

now = 0
seen = [0]
seenx = {0: 0}

while k > 0:
  k -= 1
  now = towns[now]
  
  if now not in seenx:
    seenx[now] = len(seen)
    seen.append(now)
  else:
    seen = seen[seenx[now]:]
    break

if k == 0:
  print(1 + now)
else:
  print(1 + (seen[k % len(seen)]))

Measured memory_bytes: 50452
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define VS vector<string>
#define VI vector<int>
#define ll long long
#define ull unsigned long long
#define FST first
#define SEC second
int main(){
  int a,b;
  cin>>a>>b;
  cout<<(a+b)%24<<endl;
  return 0;
}


Measured memory_bytes: 256
MAX = 10**6 * 3
MOD = 10**9+7
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX
#前処理 逆元テーブルを作る
def COMinit():
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD//i)%MOD
        finv[i] = finv[i-1] * inv[i] % MOD
#実行
def COM(n, k):
    if n  < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
k = int(input())
s = input()
n = len(s)
COMinit()
ans = 0
for i in range(k+1):
    pls = pow(25, i, MOD)
    pls *= pow(26,k-i, MOD)
    pls %= MOD
    pls *= COM(i+n-1, i)
    ans += pls
    ans %= MOD
print(ans%MOD)

Measured memory_bytes: 143260
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>

using namespace std;
string s;
int main() {
G:
	while (getline(cin, s) && s != ".") {
		stack<char> p;
		for (int i = 0;i < s.length();i++) {
			if (s[i] == '(' || s[i] == '[')p.push(s[i]);
			if (s[i] == ')') { if (p.empty() || p.top() != '(') { cout << "no" << endl;goto G; }p.pop(); }
			if (s[i] == ']') { if (p.empty() || p.top() != '[') { cout << "no" << endl;goto G; }p.pop(); }
		}
		cout << (p.empty() ? "yes" : "no") << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include"bits/stdc++.h"
using namespace std;

void Main() {
  long long K;
  cin >> K;
  int N = 50;
  long long ans[N];
  long long offset = K / N;
  for (int i = 0; i < N; i++) {
    ans[i] = i + offset;
  }

  long long loop = K % N;
  for (int i = 0; i < loop; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) ans[j] += N;
      else ans[j]--;
    }
  }
  cout << N << endl;
  for (int i = 0; i < N; i++) {
    cout << ans[i];
    if (i < N - 1) cout << " ";
  }
  cout << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	nums := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	flag := true
	count := 0

	for flag {
		for i := 0; i < len(nums); i++ {
			if nums[i]%2 == 0 {
				nums[i] = nums[i] / 2
			} else {
				flag = false
				break
			}
		}
		if flag {
			count++
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 512
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-02 10:10:29
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=310;
i64 n,m,mod,f[N][N],F[N][N],ans,C[N][N];
int main()
{
	n=read()+1; m=read()+1; mod=read();
	fr(i,1,m) F[1][i]=F[1][i-1]+(f[1][i]=1);
	fr(i,0,n) C[i][0]=C[i][i]=1;
	fr(i,1,n) fr(j,1,i-1) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	fr(i,2,n)
	{
		fr(j,1,i-1) fr(k,1,m) if(f[i-j][k])
			f[i][k]=(f[i][k]+f[i-j][k]*F[j][k-1]%mod*C[i-2][j-1])%mod;
		fr(j,1,m) F[i][j]=(F[i][j-1]+f[i][j])%mod;
	}
//	fr(i,1,n) fr(j,1,m) printf("%d%c",int(f[i][j]),j==m?'\n':' ');
	printf("%d\n",int(f[n][m]));
	return 0;
}
// 3 2 1234567     15

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int k,s;
	cin >> k >> s;
	int ans = 0;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			int z = s - x - y;
			if (z >= 0 and z <= k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin>>S;
  int count0=0,count1=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='0')count0++;
    else count1++;
  }
  cout<<min(count0,count1)*2<<endl;
}

Measured memory_bytes: 512
import random
from typing import TypeVar, Callable, List, Tuple, Union
T = TypeVar('T')
Num = Union[int, float]




import random
from typing import TypeVar, Callable, List, Tuple, Union
T = TypeVar('T')
Num = Union[int, float]



def nth_element(L: List[Num], begin: int=-1, end: int=-1, key=lambda x: x) -> int:
    """
    pivot = L[pivot_ind] とする。 'pivot 未満の要素 ... pivot ... pivot 以上の要素' となるよう L を破壊的に並び替える。(O(n))
    最後に基準値の pivot がおさまった場所のインデックスを返す。
    begin <= pivot_ind < end の要請はあるが、begin, end の指定により L[begin:end] に対象を絞り L[pivot_ind] 未満 / 以上に並べ替えることもできる。

    Args:
        L (list)
        pivot_ind (int)
        begin, end (int): L の [begin, end) 半開区間を考える。デフォルトでは L[0:n] となる

    Returns:
        int: 最後に基準値の pivot がおさまった場所のインデックス

    Examples:
        >>> seq = [1, 9, 2, 7, 5, 6, 4, 8, 3, 0]
        >>> nth_element(seq, 4)
        5
        >>> seq
        [1, 2, 0, 4, 3, 5, 7, 8, 9, 6]
        >>> nth_element(seq, 3, begin=3, end=9)
        4
        >>> seq
        [1, 2, 0, 3, 4, 5, 7, 8, 9, 6]
    """
    if begin == -1 and end == -1:
        begin, end = 0, len(L)
    pivot_ind = end-1

    # [begin]...[end] が対象範囲である
    end -= 1

    pivot = L[pivot_ind]
    L[pivot_ind], L[end] = L[end], L[pivot_ind]
    # i: 確定済みのバッファ先頭。ループ開始時点で pivot 未満であると判明しているところの先端を指す。
    i = begin - 1
    # j: 斥候。ループ開始時にここより前は検査済となっている。
    # begin ... end - 1 を動けば良い。(end は最初の swap の結果 pivot 自身がいるため探索しなくて良い)
    for j in range(begin, end):
        if key(L[j]) <= key(pivot):
            i += 1
            L[j], L[i] = L[i], L[j]
    L[i+1], L[end] = L[end], L[i+1]
    return i+1


if __name__ == "__main__":
    n = int(input())
    L = list(map(int, input().split()))
    ind = nth_element(L, 0, n)
    if L[:ind]:
        print(*L[:ind], sep=' ', end=' ')
    print('[{}]'.format(L[ind]), end='')
    if L[ind+1:]:
        print(' ', end='')
    print(*L[ind+1:], sep=' ')



Measured memory_bytes: 19748
N = int(input())

def dfs(s):
    global N
    n = int(s)
    if n>N:
        return 0
    ans = 0
    if n>=357 and all(s.count(c) for c in "753"):
        ans = 1
    ans = ans + dfs(s+"7")+dfs(s+"5")+dfs(s+"3")
    return ans

print(dfs("0"))

Measured memory_bytes: 3060
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [a, b, c] <- getIntList
    putStrLn $ if  c - a - b > 0 && 4 * a * b < (c - a - b) ^ 2 then "Yes" else "No"

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

int main(){
  int N,W;
  cin >> N >> W;
  char S[N+2][W+2]={};
  int cnt[N+2][W+2]={};
  for(int i=1; i<=N; i++){
    for(int j=1; j<=W; j++){
      cin >> S[i][j];
      if(S[i][j] == '#'){
          cnt[i+1][j]++;
          cnt[i+1][j+1]++;
          cnt[i+1][j-1]++;
          cnt[i-1][j]++;
          cnt[i-1][j+1]++;
          cnt[i-1][j-1]++;
          cnt[i][j+1]++;
          cnt[i][j-1]++;
      }
    }
  }
  for(int i=1; i<=N; i++){
    for(int j=1; j<=W; j++){
      if(S[i][j] == '.') cout << cnt[i][j];
      else cout << '#';
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;

vector<vector<long long>> dp;
vector<long long> a;

long long solve(int l, int r){
    if(dp[l][r] != 1ll<<62)return dp[l][r];
    if(l == r)return 0;
    dp[l][r] = max(a[l] - solve(l+1,r), a[r-1] - solve(l,r-1));
    return dp[l][r];
}

int main(int argc, char const *argv[]) {
    long long n;cin>>n;
    a = vector<long long>(n);
    dp = vector<vector<long long>>(n+1,vector<long long>(n+1,1ll<<62));
    for(int i=0;i<n;++i)cin>>a[i];
    cout<<solve(0,n)<<endl;
    return 0;
}

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

#define FORi( a , b ) for( int i = a ; i <= b ; i++ )
#define REPj( a , b ) for( int j = a ; j <= b ; j++ )
#define FORd( a , b ) for( int i = a ; i >= b ; i -- )
#define vi vector < int >
#define vll vector < long long int >
#define ll long long int
#define pb push_back

const int size = 1002 ;
int ar[ size ] ;
int i , j , k , l , sum ;
int n , m , p , q , maximum , minimum ;
string a , b , c , res ;
stringstream ss , ss1 , ss2 ;
bool checker ;

int main( )
{
    cin >> n ;
    cout << n / 3 << endl ;

    return 0 ;
}



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

struct Node {
  int parent;
  int left;
  int right;
};

const int NIL = -1;
const int MAX = 30;
Node T[MAX];

void preParse(int u) {
  if (u == NIL) return;
  cout << " " << u;
  preParse(T[u].left);
  preParse(T[u].right);
}

void inParse(int u) {
  if (u == NIL) return;
  inParse(T[u].left);
  cout << " " << u;
  inParse(T[u].right);
}

void postParse(int u) {
  if (u == NIL) return;
  postParse(T[u].left);
  postParse(T[u].right);
  cout << " " << u;
}

int main() {
  int n, v, r;
  cin >> n;

  // initialize the node with NIL
  for (int i = 0; i < n; i++) {
    T[i].parent = NIL;
    T[i].left = NIL;
    T[i].right = NIL;
  }

  for (int i = 0; i < n; i++) {
    cin >> v;
    cin >> T[v].left >> T[v].right;
    if (T[v].left != NIL) {
      T[T[v].left].parent = v;
    }
    if (T[v].right != NIL) {
      T[T[v].right].parent = v;
    }
  }

  // find the root noce
  for (int i = 0; i < n; i++) {
    if (T[i].parent == NIL) {
      r = i;
    }
  }

  cout << "Preorder" << endl;
  preParse(r);
  cout << endl << "Inorder" << endl;
  inParse(r);
  cout << endl << "Postorder" << endl;
  postParse(r);
  cout << endl;
  return 0;
}



Measured memory_bytes: 3112
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    double[] a, b;
    int i;

    a = new double[4]; b = new double[4];
    for(;sc.hasNext();){
      for(i = 0;i < 4;i++)a[i] = sc.nextDouble();
      for(i = 0;i < 4;i++)b[i] = sc.nextDouble();
      if(judge(a, b))out.println("YES");
      else out.println("NO");
    }
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static boolean judge(double[] a, double[] b){
    int i, j;
    for(i = 0;i < 2;i++)for(j = 0;j < 2;j++)
      if(isin(a, b[i * 2], b[1 + j * 2]))return true;
    for(i = 0;i < 2;i++)for(j = 0;j < 2;j++)
      if(isin(b, a[i * 2], a[1 + j * 2]))return true;
    if(iscross(a, b) || iscross(b, a))return true;
    return false;
  }
  private static boolean isin(double[] a, double x, double y){
    if(a[0] <= x && x <= a[2] && a[1] <= y && y <= a[3])return true;
    return false;
  }
  private static boolean iscross(double[] a, double[] b){
    if(a[0] < b[0] && b[2] < a[2] && b[1] < a[1] && a[3] < b[3])return true;
    return false;
  }
}

Measured memory_bytes: 20780
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
#include <map>
#include <cstring>
#include <cassert>
#include <random>
 
using namespace std;
 
int main(void){

    long long n,k;
    cin>>n>>k;

    long long a=0,b=0;
    for(int i=1;i<=n;i++){
        if(i%k==0) a++;
        if(k%2==0 && (i%k==k/2)) b++;
    }

    cout<<a*a*a+b*b*b<<endl;

    return 0;
}

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


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[]	tbl = new int[100+1];
		int		num = 0;

		while((num = parseNum()) != 0) {
			for (int i = 0; i <= num; i++) {
				tbl[i] = parseNum();
			}
			solve(tbl, num);
		}
	}

	private static void solve(int[] tbl, int num) {
		int	key = tbl[num];
		int	cmp = 0;
		int	l   = 0;
		int	r   = num-1;

		while (l <= r) {
			int	m = (l+r)/2;
			cmp++;
			if (key == tbl[m]) {
				break;
			} else if (key > tbl[m]) {
				l = m+1;
			} else {
				r = m-1;
			}
		}

		System.out.println(cmp);
	}

	private static int parseNum() {
		int		param = 0;
		String	strin = null;

		if ((strin = parseStdin()) != null) {
			param = Integer.parseInt(strin);
		}
 
		return param;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 15028
#include<iostream>
#include<cmath>
#include<vector>
#include<utility>
#include<string>
using namespace std;

int main(){
    int memo[1001];
    int X , i , j , N;
    cin>>X;

    for(i = 0; i < 1001; i++){
        memo[i] = 0;
    }

    memo[1] = 1;
    for(i = 2;i < 1001; i++){
        for(N = i*i;N < 1001;N *= i){
            memo[N] = 1;
            //printf("i = %d , N = %d\n" , i , N);
        }
    }

    for(i = X; i >= 0; i--){
        if(memo[i] == 1){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  long long int N, ans = 0, high = 0 ;
  cin >> N ;
  long long int A[N] ;
  for(int i=0;i<N;i++){
    cin >> A[i] ;
    if(high < A[i]){
      high = A[i] ;
    }
    else{
      ans += (high - A[i]) ;
    }
  }
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 5128