akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           (long long)1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigint        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(aint(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

template <typename T>
T ceil(T a, T b){ return (a+b-1)/b; }


template<typename T>
T binpow(T a, T b, T m) {
    a %= m;
    T res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
class Solution {
    vector<int> dp;
public:    
    Solution() {
        dp.assign(2001, -1);
    }
    int solve(int n) {
        if(n==0) {
            return 1;
        } else if(dp[n]!=-1) {
            return dp[n];
        } else {
            int ways=0;
            for(int i=3;n-i>2;i++) {
                (ways += solve(n-i))%=inf;
            }
            return dp[n] = 1+ways;
        }
    }
};

void solve(){
    int n; cin>>n;
    if(n<3) {
        cout<<0;
        return;
    }
    Solution sol;
    cout<<sol.solve(n);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);     
    int t=1;
    //cin>>t;
    FOR(i, 1, t+1){ 
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
 
}

Measured memory_bytes: 3692
def search(depth, cur)
  @n.times do |i|
    next if @used[i]
    if @sendto[i] == cur
      @used[i] = true
      puts '.' * (depth + 1) + @msg[i]
      search(depth + 1, i)
    end
  end
end

@n = gets.to_i
@msg = @n.times.map{ '' }
@sendto = [-1] * @n
@n.times do |i|
  @sendto[i] = gets.to_i - 1
  @msg[i] = gets.chomp
end

@used = [false] * @n

puts @msg[0]
@used[0] = true
search(0, 0)

Measured memory_bytes: 11616
import sys

def main():
    input = sys.stdin.readline
    N, A, B = map(int, input().split())
    X = list(map(int, input().split()))

    diff = [0 for _ in range(N-1)]
    for i in range(N-1):
        diff[i] = X[i+1] - X[i]

    ans = 0
    for d in diff:
        ans += min(A*d, B)

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 14252
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 80000+2
struct Node{
	int le;
	int ri;
};
Node jl[MAXN];
int tot=0;
int hxq[MAXN],hxz[MAXN],hxh[MAXN];
int n;
int g;
void zg(){
	for(int i=0;i<n;++i){
		int q=0;
		if(jl[i].le==-1&&jl[i].ri==-1) continue;
		for(int j=0;j<n;++j){
			if(jl[j].le==i||jl[j].ri==i) q=1;
		}
		if(q!=1){
		    g=i;
		    return;
		}
	}
}
void input(){
	cin>>n;
	int x;
	for(int i=0;i<n;++i){
		cin>>x;
		cin>>jl[x].le>>jl[x].ri;
	}
}
void syf1(int x){
	if(jl[x].le==-1&&jl[x].ri==-1) {
		hxq[tot]=x;
		tot++;
		return;
	}
	hxq[tot]=x;
	tot++;
	if(jl[x].le!=-1) syf1(jl[x].le);
	if(jl[x].ri!=-1) syf1(jl[x].ri);
	return;
}
void syf2(int x){
	if(jl[x].le==-1&&jl[x].ri==-1){
		hxz[tot]=x;
		tot++;
		return;
	}
	if(jl[x].le!=-1) syf2(jl[x].le);
	hxz[tot]=x;
	tot++;
	if(jl[x].ri!=-1) syf2(jl[x].ri);
}
void syf3(int x){
	if(jl[x].le==-1&&jl[x].ri==-1){
		hxh[tot]=x;
		tot++;
		return;
	}
	if(jl[x].le!=-1) syf3(jl[x].le);
	if(jl[x].ri!=-1) syf3(jl[x].ri);
	hxh[tot]=x;
	tot++;
}
void output(){
	cout<<"Preorder"<<endl;
	for(int i=0;i<n;++i){
		cout<<" "<<hxq[i];
	}
	cout<<endl;
	cout<<"Inorder"<<endl;
	for(int i=0;i<n;++i){
		cout<<" "<<hxz[i];
	}
	cout<<endl;
	cout<<"Postorder"<<endl;
	for(int i=0;i<n;++i){
		cout<<" "<<hxh[i];
	}
	cout<<endl;
}
int main(){
	input();
	zg();
	//cout<<g<<endl;
	syf1(g);
	tot=0;
	syf2(g);
	tot=0;
	syf3(g);
	output();
	return 0;
}

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

LL Z[51], Y[51];

LL part(int N, LL X) {
    if (N == 0) { if (X == 0) return 0; else return 1; }
    LL ans = 0;
    if (X <= 1) return ans;
    X--;
    if (X <= Z[N - 1]) return part(N - 1, X);
    ans += Y[N - 1]; X -= Z[N - 1];
    if (X <= 1) return ans + 1;
    ans++; X--;
    if (X <= Z[N - 1]) return ans + part(N - 1, X);
    ans += Y[N - 1]; X -= Z[N - 1];
    return ans;
}

int main() {
    int N; LL X; cin >> N >> X;
    Z[0] = Y[0] = 1;
    rep(i, N) Z[i + 1] = Z[i] * 2 + 3;
    rep(i, N) Y[i + 1] = Y[i] * 2 + 1;
    cout << part(N, X) << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;

template<typename T>
T in() { T x; cin >> x; return (x); }

template<typename T1,typename T2>
inline T1 gcd(T1 a, T2 b) { if (a%b == 0)return (b); return (gcd(b, a%b)); }

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

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	
  	ll a = in<ll>();
	
  	cout << lcm(2,a) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#define N_ 201000
char p[N_];
int main() {
	int i, ck=0;
	scanf("%s", p);
	for (i = 0; p[i]; i++) {
		if (i % 2 == 0 && p[i] != 'h')ck = 1;
		if (i % 2 == 1 && p[i] != 'i')ck = 1;
	}
	if (i % 2 == 1)ck = 1;
	if (ck)puts("No");
	else puts("Yes");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
int dp[N+2];
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n;cin>>n;
  dp[0]=1;
  for(int i=0;i<=n;i++)
  {
    for(int j=100;j<=105;j++)
      dp[i+j]|=dp[i];
  }
  cout<<dp[n]<<endl;
  
  return 0;
}

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

int n,m,q;
vector<int>sum,ans,a,b,c,d;

void dfs(int cnt){
    if(cnt==n-1){
        int S=0;
        for(int i=0;i<q;++i){
            if(sum[b[i]]-sum[a[i]]==c[i])S+=d[i];
        }
        ans.push_back(S);
    }
    else if(cnt<n){
        for(int i=0;i<m-sum[cnt];++i){
            sum[cnt+1]=sum[cnt]+i;
            dfs(cnt+1);
        }
    }
}

int main(){
    cin>>n>>m>>q;
    sum.resize(n,0);
    a.resize(q);b.resize(q);c.resize(q);d.resize(q);
    for(int i=0;i<q;++i){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;b[i]--;
    }
    dfs(0);
    sort(ans.begin(),ans.end());
    reverse(ans.begin(),ans.end());
    cout<<ans[0]<<endl;
}


Measured memory_bytes: 3684
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
if(a<b&&b<c&&a<c&&a<b<c){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
         return 0;
      }

Measured memory_bytes: 1156
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int cal(int N) {
    int sum = 0;
    while (N) {
          sum += N % 10;
          N /= 10;
    }
    return sum;
}

int main() {
    int N;
    while (~scanf("%d", &N)) {
          int ans = N;
          for (int i = 1; i < N; i++) {
              ans = min(ans, cal(i) + cal(N - i));
          }
          printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    double a,b,x;
    cin >> a >> b >> x;
    if(x<=a*a*b/2){
    double d=(2*x)/(a*b);
    printf("%f\n",(90.0-double(180*atan(d/b))/M_PI));
    }
    else if(x>a*a*b/2){
        double d=((2*b-(2*x/(a*a)))/a);
        printf("%f\n",double(180*atan(d))/M_PI); 
    }
    else if(x==(a*a*b)){
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile

INF = float("inf")


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in readi(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[0]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    n = readi()
    print(sum(i % 2 == 1 for i in range(1, n + 1)) / n)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int INF = 1e8;
    int N;
    int X,Y;
    cin >> N;
    cin >> X >> Y;
    vector<vector<int>> G(N, vector<int>(N, INF));

    for (int i = 0; i < N; i++) {
        G[i][i] = 0;
    }

    for (int i = 0; i < N-1; i++) {
        G[i][i+1] = min(G[i][i+1],1);
        G[i+1][i] = min(G[i+1][i],1);
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            G[i][j] = min(G[i][j], abs(j-i));
        }
    }
    G[X-1][Y-1] = min(G[X-1][Y-1],1);
    G[Y-1][X-1] = min(G[Y-1][X-1],1);

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            G[i][j] = min(G[i][j], G[i][X-1] + G[X-1][j]);
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            G[i][j] = min(G[i][j], G[i][Y-1] + G[Y-1][j]);
        }
    }

    map<int,int> m{};
    for(int i=1;i<N;++i){
        m[i] = 0;
    }
    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            m[G[i][j]]++;
        }
    }
    for(int i=1;i<N;++i){
        cout << m[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 18048
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll i;
    ll a,b;
    cin>>a>>b;
    ll c=a*4;
    ll d=a*2;
    if(b%2==0&&(d<=b&&b<=c))
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
}



Measured memory_bytes: 3608
/// [Amberjack] CUT BEGIN
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define __GET_REP_MACRO(_1,_2,_3,NAME,...) NAME
#define __REP0(i,n) for(_loop_int i=0;i<(n);++i)
#define __REP1(i,a,b) for(_loop_int i=(a);i<(b);++i)
#define __REPR0(i,n) for(_loop_int i=(n)-1;i>=0;--i)
#define __REPR1(i,a,b) for(_loop_int i=(b)-1;i>=(a);--i)
#define REP(...) __GET_REP_MACRO(__VA_ARGS__,__REP1,__REP0)(__VA_ARGS__)
#define REPR(...) __GET_REP_MACRO(__VA_ARGS__,__REPR1,__REPR0)(__VA_ARGS__)

#ifdef BURI
#define __DEBUG0() "Hello"
#define __DEBUG1(x) #x"("<<(x)<<")"
#define __DEBUG2(x,...) #x"("<<(x)<<"), " __DEBUG1(__VA_ARGS__)
#define __DEBUG3(x,...) #x"("<<(x)<<"), " __DEBUG2(__VA_ARGS__)
#define __DEBUG4(x,...) #x"("<<(x)<<"), " __DEBUG3(__VA_ARGS__)
#define __DEBUG5(x,...) #x"("<<(x)<<"), " __DEBUG4(__VA_ARGS__)
#define __GET_DEBUG_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define __DEBUG(...) __GET_DEBUG_MACRO(__VA_ARGS__,__DEBUG5,__DEBUG4,__DEBUG3,__DEBUG2,__DEBUG1,__DEBUG0)(__VA_ARGS__)
#define DEBUG(...) cerr<<__DEBUG(__VA_ARGS__)<<endl
#else
#define DEBUG(...)
#endif

inline void getll(ll &x){
  int sgn=1;x=0;
  char c=getchar();
  while(c!='-'&&(c<'0'||c>'9'))c=getchar();
  if(c=='-') sgn=-1; else x=c-'0';
  c=getchar();
  while('0'<=c&&c<='9'){
    x*=10;
    x+=c-'0';
    c=getchar();
  }
  x*=sgn;
}
inline void read(ll &x){getll(x);}
inline void read(int &x){ll y;getll(y);x=y;}
inline void read(float &x){scanf("%f",&x);}
inline void read(double &x){scanf("%lf",&x);}
inline void read(long double &x){scanf("%Lf",&x);}
inline void read(char *s){scanf("%s",s);}
inline void read(string &s){int len=s.size();char *buf=(char*)malloc(len*sizeof(char));scanf("%s",buf);s=string(buf);free(buf);}
inline void read(char &c){char *buf=(char*)malloc(5*sizeof(char));scanf("%s",buf);c=buf[0];free(buf);}
inline void read(){}
template<typename S,typename ...T>
inline void read(S& first, T&... rest){
  read(first);
  read(rest...);
}
/// [/Amberjack] CUT END

int n;
int main(){
  ll ans;
  read(n,ans);
  ans-=1;
  int ban = 2;
  int a;
  REP(i,1,n){
    read(a);
    if(a==ban)ban++;
    ans += (a-1)/ban;
  }
  printf("%lld\n",ans);
  return 0;
}


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

using namespace std;

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

    int t;
    int ans = N;
    int s;
    for (int i = 0; i <=N; i++) {
        s = 0;

        t = i;
        while (t > 0) {
            s += t % 6;
            t /= 6;
        }

        t = N-i;
        while (t > 0) {
            s += t % 9;
            t /= 9;
        }

        ans = min(ans, s);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N, K;
  scanf("%d", &N);
  scanf("%d", &K);
  long long ans = 0;
  if (K%2==0){
    int sho1 = N/K;
    int sho2 = N/(K/2)-sho1;
    ans = pow((long long)sho1, 3);
    ans += pow((long long)sho2, 3);
  } else {
    int sho = N/K;
    ans = pow((long long)sho, 3);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 504
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
#include <bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

int N,maxi=0,A,x;
bool y;

int main(){
    cin>>N;
    vector<pair<int,bool>> v[N];
    rep(i,N){
        cin>>A;
        rep(j,A){
            cin>>x>>y;
            x--;
            v[i].push_back({x,y});
        }
    }
    rep(i,(1<<N)){
        bitset<15> bs(i);
        bool ok=true;
        rep(j,N){
            for(pair<int,bool> p:v[j]){
                if(bs[j]==1){
                    if(bs[p.first]!=p.second)ok=false;
                }
            }
        }
        if(ok){
            int tmp=0;
            rep(i,15)if(bs[i]==1)tmp++;
            maxi=max(maxi,tmp);
        }
    }
    out(maxi);

    
    
}


Measured memory_bytes: 256
def main():
    import math
    K = int(input())
    value = 0
    for a in range(1 , K+1) :
        for b in range(1 , K+1) :
            gcd_ab = math.gcd(a,b)
            for c in range(1,K+1) :
                gcd_abc = math.gcd(gcd_ab,c)
                value = value + gcd_abc
    print(value)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
A[1000][1000],I[1000],u[999];i,j;d;F=2;main(N){for(scanf("%d",&N);i<N;++i)for(j=0;j<N-1;)scanf("%d",A[j++]+i);for(;F&2;i=N)for(++d,F=1;i--;u[i]<d&&j&&u[F&=2,--j]<d&A[I[j]][j]==i+1&&++I[u[i]=u[j]=d,++I[i],F=2,j])j=A[I[i]][i];printf("%d",F*d-1);}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int ub=N-1,lb=0;
    bool lM,uM,mM;
    string input;

    cout << 0 << endl;
    cin >> input;

    if(input == "Vacant"){
        return 0;
    }else if(input=="Male"){
        lM = true;
    }else{
        lM = false;
    }
 
    cout << N-1 << endl;
    cin >> input;

    if(input == "Vacant"){
        return 0;
    }else if(input=="Male"){
        uM = true;
    }else{
        uM = false;
    }

    while(ub-lb>1){
        int mid = (ub+lb)/2;

        cout << mid << endl;
        cin >> input;

        if(input == "Vacant"){
            return 0;
        }else if(input=="Male"){
            mM = true;
        }else{
            mM = false;
        }

        if(((mid-lb)%2==0 && lM!=mM) || ((mid-lb)%2==1 && lM==mM)){
            ub = mid;
            uM = mM;
        }else{
            lb = mid;
            lM = mM;
        }
    }
}


Measured memory_bytes: 852
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

bool used[200005], answered[200005];
int n, m, e, ans[200005];

int main(){
	
	cin >> n >> m;
	
	REP(i,200005){
		used[i] = false;
		answered[i] = false;
	}
	used[0] = true;
	
	REP(i,m){
		cin >> e;
		ans[m-1-i] = e;
		used[e] = true;
	}
	
	// debug(used[1]);
	
	REP(i,m){
		if (!answered[ans[i]]){
			cout << ans[i] << endl;
			answered[ans[i]] = true;
		}
	}
	
	for (int i=1; i<=n; i++){
		if (!used[i]) cout << i << endl;
	}
	
	return 0;
}



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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    string S, T;
    cin >> S >> T;
    int count = 0;
    rep(i,3){
        if(S.at(i)== T.at(i)) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, k = map(int, input().split())
a = list(map(int, input().split()))

import math

def cond():
    _max = max(a)
    if k > _max:
        return False
    _gcd = a[0]
    for i in a[1:]:
        _gcd = math.gcd(_gcd, i)
    return (k % _gcd) == 0

if cond():
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 85164
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] order = new int[5];
		order[0] = sc.nextInt();
		order[1] = sc.nextInt();
		order[2] = sc.nextInt();
		order[3] = sc.nextInt();
		order[4] = sc.nextInt();
		sc.close();
		int[] time = new int[5];
		for(int i = 0; i < 5; i++) {
			time[i] = (order[i] / 10) * 10 + (order[i] % 10 > 0 ? 10 : 0);
		}
		int max = 0;
		int answer = 0;
		for(int i = 0; i < 5; i++) {
			max = Math.abs(time[i] - order[i]) > max ? Math.abs(time[i] - order[i]) : max;
			answer += time[i];
		}
		System.out.println(answer - max);
	}
}

Measured memory_bytes: 23764
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int a=gi();
	    int b=gi();
	    String s=gs();
	    String s1=s.substring(0,a);
	    String s2=s.substring(a+1);

	    //System.out.println(c);
	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
	    	System.out.print("Yes");
	    }else {
	    	System.out.print("No");
	    }



	}

public static boolean isNumber(String val) {
	try {
		Integer.parseInt(val);
		return true;
	} catch (NumberFormatException nfex) {
		return false;
	}
}

	public static int d(int n) {
		int m=0;
		while(true) {
			if(n<1) {
				break;
			}
			int l= n%10;
			m+=l;
			n= (n-l)/10;
		}
		return m;
	}
	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35572
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>
#define REP(i,A) for(int i=0;i<A;i++)

using namespace std;
using ll = long long int;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);

string S;
cin >> S;
int flag=0;
    if(S[0]=='0'&&S[1]!='0'){
        flag =1;
    }else if(S[0]=='1'&&S[1]<='2'){
        flag = 1;
    }else{
        flag =2;
    }
    if(S[2]=='0'&&S[3]!='0'){
        flag +=10;
    }else if(S[2]=='1'&&S[3]<='2'){
        flag +=10;
    }else{
        flag +=20;
    }
    
    
    if(flag ==11){
        cout << "AMBIGUOUS";
    }else if(flag ==12){
        cout << "YYMM";
    }else if(flag ==21){
        cout << "MMYY";
    }else{
        cout << "NA";
    }
return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int X;
  cin >> X;
  ll res = 1LL;
  REP(i,X + 2) res *= 2LL;
  res -= 2LL;
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sn = new Scanner(System.in);
        long N = sn.nextInt();
        long result = 0;

        for(int i=1; i<=N; i++){
            if(i%3 == 0 | i%5 == 0){
                continue;
            }else{
                result += i;
            }
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 35768
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:String,
    }
    let mut b=b.chars().collect_vec();
    let mut c=0;
    for i in 0..b.len(){
        if b[i]=='R'{
            c+=1
        }
    }
    println!("{}",if c>a-c{"Yes"}else{"No"})
}

Measured memory_bytes: 2128
import java.util.Scanner;
import java.util.ArrayList;
import java.lang.Integer;
import java.lang.StringBuilder;
import java.lang.Math;

class Point {
  public int x;
  public int y;
  public Point(int x, int y) {
    this.x = x;
    this.y = y;
  }
}

public class Main {
  private static int W;
  private static int H;
  private static int N;
  private static Point[] p;
  private static int[] a;

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    W = in.nextInt();
    H = in.nextInt();
    N = in.nextInt();

    int minX = 0;
    int minY = 0;
    int maxX = W;
    int maxY = H;

    p = new Point[N];
    a = new int[N];
    for (int i = 0; i < N; i++) {
      p[i] = new Point(in.nextInt(), in.nextInt());
      a[i] = in.nextInt();
      switch(a[i]) {
        case 1:
          minX = Math.max(p[i].x, minX);;
          break;
        case 2:
          maxX = Math.min(p[i].x, maxX);;
          break;
        case 3:
          minY = Math.max(p[i].y, minY);;
          break;
        case 4:
          maxY = Math.min(p[i].y, maxY);;
          break;
        default:
          System.exit(1);
      }
    }


    int width = (maxX - minX);
    int height = (maxY - minY);
    if (width >= 0 && height >= 0) {
      int area = width * height;
      System.out.println(area);
    } else {
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 10324
N, K = map(int, input().split())
p = list(map(int, input().split()))
prospect = []
for k in range(N):
  if p[k]%2 == 1:
    prospect.append((p[k]+1)>>1)
  else:
    prospect.append((p[k]+1)/2)
S = sum(prospect[:K])
ans = 0 + S
for k in range(N-K):
  S += prospect[k+K] - prospect[k]
  ans = max(ans, S)
print(ans) 

Measured memory_bytes: 32160
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N, D;
	cin >> N >> D;
	D = 2 * D + 1;
	cout << (N + D - 1) / D;
}

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

template<typename T>
class CumulativeSum{
public:
  
  int n;
  vector<T> A, S;
  
  CumulativeSum(){ assert( false && "引数がありません" ); };
  CumulativeSum(vector<T> Array) : A(Array) { n = (int)A.size(); apply(); };
  
  // 初期値からAに変更があった場合、この関数を使うまでSが更新されないことに注意
  void apply(){
    S = vector<T>( n + 1 );
    for(int i=1;i<=n;i++) S[i] = S[i-1] + A[i-1];
  }
  
  // 0 origin
  void update(int k, T v){ A[k] = v; }
  
  // 0 origin, [ begin, end )
  T get(int begin, int end){ return S[end] - S[begin]; }
  
};

signed main(){
  
  int n, k;

  while(1){
    
    vector<int> A;

    cin >> n >> k;
    
    if( !n && !k ) break;
    
    for(int i=0;i<n;i++){
      int a;
      cin >> a;
      A.push_back( a );
    }
  
    CumulativeSum<int> C( A );
    
    int ans = -1e10;
    
    for(int i=0;i<n;i++){
      if( n <= i + k ) break;
      ans = max( ans, C.get( i, i + k ) );
    }

    cout << ans << endl;
    
  }
  
  return 0;
}



Measured memory_bytes: 6020
import sys
input = sys.stdin.readline

N,K = [int(x) for x in input().rstrip().split()]
R,S,P = [int(x) for x in input().rstrip().split()]
T = input().rstrip()

ans = 0
d = ['']*N
for i in range(N):
    if(T[i] == 's'):
        if(i-K >= 0):
            if(d[i-K] != T[i]):
                ans += R
                d[i] = 's'
        else:
            ans += R
            d[i] = 's'
    elif(T[i] == 'r'):
        if(i-K >= 0):
            if(d[i-K] != T[i]):
                ans += P
                d[i] = 'r'
        else:
            ans += P
            d[i] = 'r'
    else:
        if(i-K >= 0):
            if(d[i-K] != T[i]):
                ans += S
                d[i] = 'p'
        else:
            ans += S
            d[i] = 'p'

print(ans)

Measured memory_bytes: 4084
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <sstream>
#include <string.h>
using namespace std;
int main()
{
int x,a,b;
cin>>x>>a>>b;
int cnt=x-a;
int q=cnt%b;
int o=(cnt-q)/b;
cout<<cnt-b*o;
system ("pause");
return 0;
}

Measured memory_bytes: 504
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 5005 /*rem*/
#define mod 1000000007
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
ll pw[maxn];
ll dp[maxn][maxn]; 
int main() {
	pw[0] = 1;
	for (int i = 1; i < maxn; i++)
		pw[i] = pw[i - 1] * 2 % mod;
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		ll pl = 0;
		for (int j = 1; j <= m; j++) {
			if (i == 1) dp[i][j] = pw[j];
			else {
				dp[i][j] = (j + 1) * dp[i - 1][j] % mod;
				pl *= 2;
				pl += dp[i - 1][j - 1] * (j - 1);
				pl %= mod;
				dp[i][j] = (dp[i][j] + pl) % mod;
			//	}
				/*
					dp[i][j] += dp[i - 1][j - d] * pw[d - 1] % mod * (j - d), 
					dp[i][j] %= mod;
				*/
			}
		}
	}
	cout << dp[n][m] << endl;
	return 0;
}


Measured memory_bytes: 199196
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll INF=1e18;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll ans=1;
    rep(i,n){
        cin >> a[i];
        
        if(a[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    rep(i,n){
        if(INF/ans<a[i]){
            cout << -1 << endl;
            return 0;
        }
        ans*=a[i];
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 3964
n, m, c = map(int, input().split())
b = list(map(int , input().split()))
ans = 0
for _ in range(n):
    a = list(map(int , input().split()))
    tmp = c
    for i, ai in enumerate(a):
        tmp += ai * b[i]
    if tmp > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
N = int(input())
words = [input() for i in range(N)]
count=0
if len(words)==len(set(words)):
  for j in range(0,N-1):
    if words[j][-1]==words[j+1][0]:
      count+=1
  if count==N-1:
    print("Yes")
  else:
    print("No")
else:
  print("No")

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N, Q;
    cin >> N;
    string S;
    cin >> S;
    cin >> Q;


    REP(i, Q){
        int k;
        cin >> k;

        long long ans = 0;
        long long num_D = 0, num_M = 0, num_DM = 0;
        REP(i, N){
            if(i >= k){
                if(S[i-k] == 'D'){
                    --num_D;
                    num_DM -= num_M;
                }
                if(S[i-k] == 'M') --num_M;
            }
            if(S[i] == 'D') ++num_D;
            if(S[i] == 'M'){
                ++num_M;
                num_DM += num_D;
            }
            if(S[i] == 'C') ans += num_DM;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1412
N,A,B=map(int,input().split())
S=list(input())
cnt1=0
cnt2=0

for i in range(N):
    if S[i]=='c':
        print('No')
    elif S[i]=='a':
        if cnt1<A+B:
            print('Yes')
            cnt1+=1
        else:
            print('No')
    else:
        if cnt1<A+B and cnt2<B:
            print('Yes')
            cnt1+=1
            cnt2+=1
        else:
            print('No')



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

using namespace std;

typedef long long lint;

template<int mod> class modint {
public:
  int x;
  modint(): x(0) {}
  modint(int a) { x = a % mod; if (x < 0) x += mod; }
  modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; }
  modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; }
  modint &operator*=(modint that) { x = lint(x) * that.x % mod; return *this; }
  modint &operator/=(modint that) { return *this *= that.inverse(); }
  modint operator-() { return modint(-this->x); }
  friend ostream& operator<<(ostream &out, modint m) { return out << m.x; }
  modint inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return modint(u);
  }
#define op(o, p) modint operator o(modint that) { return modint(*this) p that; }
  op(+, +=) op(-, -=) op(*, *=) op(/, /=)
#undef op
#define op(o) bool operator o(modint that) { return x o that.x; }
  op(==) op(!=) op(<) op(<=) op(>) op(>=)
#undef op
};

typedef modint<1000000007> mint;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  vector<mint> f(h + w + 1, 1);
  for (int i = 1; i <= h + w; i++) {
    f[i] = f[i - 1] * i;
  }
  mint ans = 0;
  for (int d = 0; d < w - b; d++) {
    int y1 = h - a - 1;
    int x1 = b + d;
    int y2 = a - 1;
    int x2 = w - (b + d) - 1;
    ans += (f[x1 + y1] / (f[x1] * f[y1])) * (f[x2 + y2] / (f[x2] * f[y2]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<memory.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }
 
   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

int main(){
  int n,k,l;
  cin >> n >> k >> l;
  UnionFind uf(n),uf2(n);
  rep(i,k){
    int x,y;
    cin >> x >> y;
    x--,y--;
    uf.unite(x,y);
  }
  rep(i,l){
    int x,y;
    cin >> x >> y;
    x--,y--;
    uf2.unite(x,y);
  }
  map<pint,int> mp;
  rep(i,n)mp[{uf.find(i),uf2.find(i)}]++;
  rep(i,n){
    cout << mp[{uf.find(i),uf2.find(i)}] << ' ';
  }
  cout << endl;
return 0;}

Measured memory_bytes: 13568
#include<stdio.h>
#include<iostream>
#include<stack>
#include<cstdio>
using namespace std;
int main(){
	stack<int> s;
	int n;
	while((scanf("%d",&n))!=EOF){
		if(n!=0){
			s.push(n);
		}else{
			printf("%d\n",s.top());
			s.pop();
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 1000000001
#define EPS 1.0e-6

using namespace std;

typedef long long ll;

int main()
{
	int n;
	while (cin >> n) {
		int s = 0;
		for (int i = 1; i < 600 / n; i++) {
			s += (i*n)*(i*n)*n;
		}
		cout << s << endl;
	}

	return 0;
}

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

// #include<cstdio>

int main(){
  int n;
  int a[1000];

  cin >> n;
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  for (int i=n-1; i>=0; i--){
    cout << a[i];
    if (i>0) cout << ' ';
  }
  cout << "\n";

  return 0;
}

Measured memory_bytes: 3112
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let a: Vec<i64> = (0..n).map(|_| input()).collect();

    let sum: Vec<i64> = a
        .iter()
        .scan(0, |acc, &a| {
            *acc += a;
            Some(*acc)
        })
        .collect();

    let mut x = 0;
    let mut y = 0;
    let mut ans1 = 0;
    let mut ans2 = 0;
    for i in 0..n {
        if i % 2 == 0 {
            if sum[i] + x <= 0 {
                ans1 += -sum[i] - x + 1;
                x += -sum[i] - x + 1;
            }
            if sum[i] + y >= 0 {
                ans2 += sum[i] + y + 1;
                y -= sum[i] + y + 1;
            }
        } else if i % 2 == 1 {
            if sum[i] + x >= 0 {
                ans1 += sum[i] + x + 1;
                x -= sum[i] + x + 1;
            }
            if sum[i] + y <= 0 {
                ans2 += -sum[i] - y + 1;
                y += -sum[i] - y + 1;
            }
        }
    }

    println!("{}", std::cmp::min(ans1, ans2));
}


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

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


if __name__ == '__main__':
    k = int(input())
    s = input()

    if len(s) <= k:
        print(s)
    else:
        s = s[:k]
        print(s + "...")



    #print('\33[32m' + 'end' + '\033[0m') # debug

    

Measured memory_bytes: 68504
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
#define coa cout << ans << endl
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

void op(vector<pair<bool, int>> &balls, int x, int y){
    balls[x].second--;
    balls[y].second++;
    if(balls[x].first){
        balls[y].first = true;
    }
    if(balls[x].second == 0){
        balls[x].first = false;
    }
    return;
}

int main(){
    int n, m;
    cin >> n >> m;

    vector<pair<bool, int>> balls(n, make_pair(0, 1));  //red, num
    balls[0] = make_pair(1, 1);

    rep(i, m){
        int x, y;
        cin >> x >> y;
        x--; y--;
        op(balls, x, y);
    }

    int ans = 0;
    rep(i, n){
        if(balls[i].first) ans++;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4016
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			if(n==0) {
				break;
			}
			int[] wx = new int[n];
			int[] wy = new int[n];
			int[] r = new int[n];
			for(int i=0;i<n;i++) {
				wx[i] = sc.nextInt();
				wy[i] = sc.nextInt();
				r[i] = sc.nextInt();
			}
			int m = sc.nextInt();
			int[] tx = new int[m];
			int[] ty = new int[m];
			int[] sx = new int[m];
			int[] sy = new int[m];
			for(int i=0;i<m;i++) {
				tx[i] = sc.nextInt();
				ty[i] = sc.nextInt();
				sx[i] = sc.nextInt();
				sy[i] = sc.nextInt();
			}
			for(int i=0;i<m;i++) {
				boolean safe = false;
				for(int j=0;j<n;j++) {
					int ax = wx[j]-tx[i];
					int ay = wy[j]-ty[i];
					int bx = wx[j]-sx[i];
					int by = wy[j]-sy[i];
					int al = ax*ax+ay*ay;
					int bl = bx*bx+by*by;
					if(al>r[j]*r[j] && bl>r[j]*r[j]) { //両方外側のとき
						int cx = bx-ax;
						int cy = by-ay;
						int cl = cx*cx+cy*cy;
						int d = (ax*cy-ay*cx)*(ax*cy-ay*cx)/cl;
						if (d<=r[j]*r[j]) { //直線が円と交差
							if((ax*cx+ay*cy)*(bx*cx+by*cy)<0) { //鋭角三角形の形
								safe = true;
								break;
							}
						}
					}else{
						if(al>r[j]*r[j] || bl>r[j]*r[j]) { //内側と外側
							safe = true;
							break;
						}
					}
				}
				System.out.println(safe ? "Safe" : "Danger");
			}
		}
	}
}

Measured memory_bytes: 26164
#include<iostream>
#include<cmath>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    int H[N];
    rep(i,N) cin >> H[i];

    int dp[N];
    rep(i,N) dp[i] = INT_MAX;
    dp[0] = 0;

    // dp[i] = カエルが足場H[i]に辿り着くまでに支払うコストの総和の最小値
    rep(i,N) {
        if (i+1 < N) dp[i+1] = min(dp[i+1], dp[i] + abs(H[i+1] - H[i]));
        if (i+2 < N) dp[i+2] = min(dp[i+2], dp[i] + abs(H[i+2] - H[i]));
    }

    cout << dp[N-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    long long n, k, ans = 0;
    cin >> n >> k;
    for(int i = k + 1; i <= n; i++){
            ans += (n / i) * (i - k) + max(0ll, n % i - k + 1);
    }
    if(k == 0){
        ans -= n;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,raw_input().split())
rw=[1]*n
rball=[True]+[False]*(n-1)
for i in xrange(m):
    x,y=map(int,raw_input().split())
    x-=1;y-=1
    if rw[x]==1:
        if rball[x]:
            rball[x]=False
            rw[x]-=1
            rw[y]+=1
            rball[y]=True
        else:
            rw[x]-=1
            rw[y]+=1
    else:
        rw[x]-=1
        rw[y]+=1
        if rball[x]:
            rball[y]=True
ans=0
for i in xrange(n):
    if rball[i]:
        ans+=1
print(ans)


Measured memory_bytes: 4996
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<map>



using namespace std;

long long int n,ans,y;
int cnt[20];
int x;
int main(){
    cin >> n;
    n = n;
    long long int nori=n;
    char str[20];
    int i=0;
    if (n == 0){
        cout << "a" << endl;
        return 0;
    }
    while(n != 0){
        n--;
        str[i] = 'a' + n%26;
        // cout << n%26 << endl;
        n = n/26;
        i++;
    }
    int x = i-1;
    // cout << (char)('a' + 0) << endl;
    for(int i=x;i>=0;i--){
        // char a = 'a' + cnt[i]  ;
        // if(a == '`' && c>1) {
        //     b[c-2] = 'z';
        //     b[c-1] = 'z';
        //     c++; 
        // }
        // else if(a == '`' ) continue;
        // else {
        //     b[c] = a;
        //     c++;
        // }
        cout << str[i];
    }
    // for(int i=0;i<c;i++) cout << b[i] ;
    cout << endl;



return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

int main() 
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];

  int max = 0;
  int count = 0;
  for (int i = 0; i < n - 1; i++){
    if (h[i] >= h[i+1]){
      count++;
      if (count > max) max = count;
    }else{
      count = 0;
    }
  }
  cout << max << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int n;
	cin >> n;
	cout << (n+1)/2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<string> s(n);
        for (int i = 0; i < n; i++) {
            string str;
            cin >> str;
            s[i].push_back(str[0]);
            for (int j = 0; j < str.size() - 1; j++) {
                if (str[j] == 'a' or str[j] == 'i' or str[j] == 'u' or str[j] == 'e' or str[j] == 'o') {
                    s[i].push_back(str[j + 1]);
                }
            }
        }
        for (int k = 1;; k++) {
            set<string> st;
            bool ok = true;
            for (int i = 0; i < n; i++) {
                const string sub = s[i].substr(0, k);
                if (st.find(sub) == st.end()) {
                    st.insert(sub);
                } else {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                cout << k << endl;
                break;
            } else if (k == 50) {
                cout << -1 << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    string s; cin >> s;
    
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
 
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! { t: usize }

    let mut ans = vec![];
    for _ in 0..t {
        input! { n: u64, m: u64, a: u64, b: u64 }
        ans.push(floor_sum(n, m, a, b).to_string());
    }
    println!("{}", ans.join("\n"));
}

fn floor_sum(n: u64, m: u64, mut a: u64, mut b: u64) -> u64 {
    let mut r = 0;
    if a >= m {
        r += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if b >= m {
        r += n * (b / m);
        b %= m;
    }

    let y = (a * n + b) / m;
    if y > 0 {
        let x = y * m - b;
        r += (n - (x + a - 1) / a) * y;
        r += floor_sum(y, a, m, (a - x % a) % a);
    }
    r
}


Measured memory_bytes: 9544
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		for (int j = 1; j <= m; j++) {
			if (j % 3 == 0) {
				System.out.print(" "+j );
				continue;
			}

			for (int i = j; i > 0; i /= 10) {
				if (i % 10 == 3) {
					System.out.print(" "+j );
					break;
				}
			}

		}
		System.out.println();
		sc.close();
	}
}

Measured memory_bytes: 22468
N=int(input())
if 400<=N<600:
  print(8)
elif 600<=N<800:
  print(7)
elif 800<=N<1000:
  print(6)
elif 1000<=N<1200:
  print(5)
elif 1200<=N<1400:
  print(4)
elif 1400<=N<1600:
  print(3)
elif 1600<=N<1800:
  print(2)
else:
  print(1)

Measured memory_bytes: 61612
def action(A, N):
  B = [0] * N
  for i, bright in enumerate(A):
    s = max(0, i - bright)
    B[s] += 1
    e = min(N, i + bright)
    if e < N - 1:
      B[e + 1] -= 1
  
  for i in range(N - 1):
    B[i + 1] += B[i]
  return B

def main():
  N, K = map(int, input().split())
  A = list(map(int, input().split()))

  for i in range(K):
    A = action(A, N)
    if (A[0] == N) & all(A):
      break
      
  print(*A, sep=" ")

if __name__ == '__main__':
  main()

Measured memory_bytes: 128992
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <math.h>
int minimum(int a, int b) { return a < b ? a : b; }
int maximum(int a, int b) { return a > b ? a : b; }
const long long mod = 1000000007;
//const long long mod = 998244353;

using std::vector;
using std::map;
using std::pair;

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	int N, M, K;
	scanf("%d %d %d", &N, &M, &K);
	auto fr = new vector<int>[N];
	auto bl = new vector<int>[N];
	UnionFind un(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		fr[a].push_back(b);
		fr[b].push_back(a);
		un.unite(a, b);
	}
	for (int i = 0; i < K; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		bl[a].push_back(b);
		bl[b].push_back(a);
	}
	auto cnt = new int[N] {};
	for (int i = 0; i < N; i++)cnt[un.root(i)]++;
	for (int i = 0; i < N; i++) {
		int res = cnt[un.root(i)] - 1;
		for (int j = 0; j < fr[i].size(); j++) {
			if (un.same(i, fr[i][j]))res--;
		}
		for (int j = 0; j < bl[i].size(); j++) {
			if (un.same(i, bl[i][j]))res--;
		}
		printf("%d ", res);
	}

	return 0;
}

Measured memory_bytes: 12920