akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    vector<int> a{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << a[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
def merge(a, left, mid, right)
  n1 = mid - left
  n2 = right - mid
  l = [] * n1
  r = [] * n2
  n1.times do |i|
    l << a[left + i]
  end
  n2.times do |i|
    r << a[mid + i]
  end
  li = 0
  ri = 0
  l << 0xffffffff
  r << 0xffffffff
  left.upto(right - 1) do |i|
    @cnt += 1
    if l[li] <= r[ri]
      a[i] = l[li]
      li += 1
    else
      a[i] = r[ri]
      ri += 1
    end
  end
end

def _merge_sort(a, left, right)
  if left + 1 < right
    mid = (left + right) / 2
    _merge_sort(a, left, mid)
    _merge_sort(a, mid, right)
    merge(a, left, mid, right)
  end
  a
end

def merge_sort(a)
  _merge_sort(a, 0, a.size)
end

n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

@cnt = 0
puts merge_sort(a).map(&:to_s).join(' ')
puts @cnt


Measured memory_bytes: 67420
h1,m1,h2,m2,k=gets.split.map &:to_i
t2=(h2*60+m2)
t1=(h1*60+m1)
if t2>=t1
  puts t2 - t1 - k
elsif t2<t1
  puts t2 + 60*24 - t1 -k
end

Measured memory_bytes: 14412
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        StringBuilder output = new StringBuilder();

        while (true) {
            int amount = scan.nextInt();
            if (amount == 0)
                break;
            int[] scores = new int[amount];
            for (int i = 0; i < amount; i++) {
                scores[i] = scan.nextInt();
            }

            double average = 0.0;
            for (int i = 0; i < amount; i++) {
                average += scores[i];
            }
            average = average / (double)amount;

            double sq_sum = 0.0;
            for (int i = 0; i < amount; i++) {
                sq_sum += Math.pow(scores[i] - average, 2);
            }

            output.append(Math.sqrt(sq_sum / amount)).append('\n');
        }

        System.out.print(output);
    }
}

Measured memory_bytes: 23756
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int a,b,c,aa = 0;
  cin >> a >> b >> c;
  aa = a;
  bool can = false;
  REP(i,b*2){
    if(aa % b == c) can = true;
    aa += a;
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define fora(i,a,b) for(int i=a,Wub=b;i<Wub;++i)
#define ford(i,a,b) for(int i=a,Wub=b;i>=Wub;--i)
#define SPEEDIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 1000000
#define MOD 1073741824
using namespace std;
typedef long long ll;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(b - a == c - b)cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define mx 100005
#define ll long long
#define mod 1000000007

int ar[mx];
char ch[mx];

int n,m;

void solve()
{
    ll xx;
    scanf("%lld",&xx);
     for(ll i=-1000;i<=1000;i++)
     {
         for(ll j=i;j<=1000;j++)
         {
             ll x=i*i*i*i*i;
             ll y=j*j*j*j*j;
             if(y-x==xx)
             {
                 printf("%lld %lld\n",j,i);
                 return;
             }
         }
     }
}

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


Measured memory_bytes: 3812
s = input()
count = 0
a, c, q = 0, 0, 0
n = len(s)
for i in range(n):
    if s[i] == 'C':
        c += 1
    elif s[i] == '?':
        q += 1
    else:
        continue
c = 3 * c + q
p = pow(3, q-3)
for i in range(n):
    if s[i] == 'A':
        a += 3
    elif s[i] == 'C':
        c -= 3
    elif s[i] == 'B':
        count += 3*a*c
    else:
        c -= 1
        count += a*c
        a += 1
print(int(count*p) % 1000000007)

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

int main() {
	map<char, int> mp;
	bool ans = true;
	for (int i = 0; i < 4; i++) {
		char c;
		cin >> c;
		mp[c]++;
	}
	if (mp.size() != 2) ans = false;
	for (auto m : mp) {
		if (m.second != 2) ans = false;
	}
	if (ans) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int n,ls,lt;
char s[105],t[105];

int pan(int i)
{
	for(int j=i;j<=ls;j++)
		if(s[j] != t[j-i+1])
			return -1;
	return i-1+lt;
}

int main()
{
	int ans;
	scanf("%d %s %s",&n,s+1,t+1);
	ls=strlen(s+1); lt=strlen(t+1);
	ans=max(n,ls+lt);
	for(int i=1;i<=ls;i++)
		if(s[i] == t[1])
		{
			int k=pan(i);
			if(k == -1) continue;
			if(k >= n)
			{
				ans=k;
				break;
			}
		}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Harshad
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <climits>

class TaskB {
public:
    void solve(std::istream &in, std::ostream &out) {
        long long int n, maxi = 0, mini = LLONG_MAX;
        in >> n;
        long long int a, b;
        for (int i = 0; i < n; ++i) {
            in >> a >> b;
            if (a > maxi) maxi = a;
            if (b < mini) mini = b;
        }
        out << maxi + mini;
    }
};


int main() {
    TaskB solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ra = 101, rb = -1;
		while(n--!=0){
			int a = sc.nextInt(), b = sc.nextInt();
			if(rb < b || rb==b && a < ra){
				ra = a;
				rb = b;
			}
		}
		System.out.println(ra+" "+rb);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17248
#include<iostream>
#include<cstring>

using namespace std;

int jj[1001][1001],oo[1001][1001],ii[1001][1001];
char map[1001][1001];

int main(void){
	int a,b,c,m,n,k;
	cin >> m >> n;
	cin >> k;
	for(a=0;a<m;a++){
		cin >> map[a];
	}
	memset(jj,0,sizeof(jj));
	memset(jj,0,sizeof(oo));
	memset(jj,0,sizeof(ii));
	for(a=0;a<m;a++){
		for(b=0;b<n;b++){
			jj[b+1][a+1]=jj[b+1][a]+jj[b][a+1]-jj[b][a];
			oo[b+1][a+1]=oo[b+1][a]+oo[b][a+1]-oo[b][a];
			ii[b+1][a+1]=ii[b+1][a]+ii[b][a+1]-ii[b][a];
			if(map[a][b]=='J')jj[b+1][a+1]++;
			if(map[a][b]=='O')oo[b+1][a+1]++;
			if(map[a][b]=='I')ii[b+1][a+1]++;
		}
	}
	for(c=0;c<k;c++){
		int ax,ay,bx,by;
		int ja=0,oa=0,ia=0;
		cin >> ay >> ax >> by >> bx;
		ja=jj[bx][by]-jj[ax-1][by]-jj[bx][ay-1]+jj[ax-1][ay-1];
		oa=oo[bx][by]-oo[ax-1][by]-oo[bx][ay-1]+oo[ax-1][ay-1];
		ia=ii[bx][by]-ii[ax-1][by]-ii[bx][ay-1]+ii[ax-1][ay-1];
		cout << ja << " " << oa << " " << ia << endl;
	}
	return 0;
}

Measured memory_bytes: 13000
'use strict'

function main(input) {
  input = input
    .trim()
    .split(' ')
    .map(Number)

  const x1 = input[0]
  const y1 = input[1]
  const x2 = input[2]
  const y2 = input[3]

  const x3 = x2 - (y2 - y1)
  const y3 = y2 + (x2 - x1)
  const x4 = x1 + (y1 - y2)
  const y4 = y1 - (x1 - x2)

  console.log([x3, y3, x4, y4].join(' '))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

#define pb push_back
#define rep(i, a, n) for(int (i)=a; (i)<(n); (i)++)
#define FOR(i, n) rep(i, 0, n)
#define F(n) FOR(i, n)
#define FF(n) FOR(j, n)
#define repi(i, a, n) for(int (i)=a; (i)<=(n); (i)++)
#define FORI(i, n) repi(i, 1, n)
#define FI(n) FORI(i, n)
#define FFI(n) FORI(j, n)
#define IN(x) int x; cin>>(x);
#define INN(x, y) int x, y; cin>>(x)>>(y);
#define INFO(a) cout<<"info "<<a<<endl
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define vpii vector<pair<int, int> >
#define sortv(x) sort((x).begin(), (x).end())
#define sortvd(x) sort((x).begin(), (x).end(), greater<int>())
#define lboundv(x,v) lower_bound((x).begin(),(x).end(),(v))-(x).begin();
#define uboundv(x,v) upper_bound((x).begin(),(x).end(),(v))-(x).begin();
#define ite iterator
#define fi first
#define se second
#define mems(a, v) memset((a), (v), sizeof((a)))
#define lmid(l, r) ((l)+(r)-1)/2
#define rmid(l, r) ((l)+(r))/2+1
#define mp make_pair

typedef long long ll;
typedef long double LD;

using namespace std;

#define N 100005
int main() {
	ios::sync_with_stdio(0);
	ll n, K;
	cin>>n>>K;
	vll a(n), b(n);
	F(n) cin>>a[i]>>b[i];
	ll to=0;
	F(n) {
		if(!(~K&a[i])) to+=b[i];
	}
	ll ans=0, ma=0;
	for(int i=K; i; i-=i&-i) {
		//int j = i-(i&-i);
		//cout<<i<<' '<<j<<endl;
		int j = i-1;
		ans = 0;
		FOR(k, n) {
			//if(!(~j&a[k])) {ans += b[k]; continue;}
			//if(!((~j)&a[k])||(j<=a[k]&&a[k]<i)||a[k]<(i&-i)) ans+=b[k];
			if(!(~j&a[k])) ans+=b[k];
		}
		ma = max(ans, ma);
		//cout<<ans<<endl;
	}
	/*ans = 0;
	FOR(k, n) {
		if(a[k]==K) ans+=b[k];
	}*/
	ma = max(ans, ma);
	cout<<max(ma,to)<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main() {
  int D;
  cin >> D;

  if (D == 22) cout << "Christmas Eve Eve Eve" << endl;
  if (D == 23) cout << "Christmas Eve Eve" << endl;
  if (D == 24) cout << "Christmas Eve" << endl;
  if (D == 25) cout << "Christmas" << endl;


  return 0;
}

Measured memory_bytes: 256
def find(A):
    stack=[]
    while A:
        #print(stack)
        index=-1
        for i in range(len(A)):
            if A[i]==i+1:
                index=i
        
        if index!=-1:
            
            stack+=[index+1]
            A=A[:index]+A[index+1:]
        else:
            return -1
    return stack   
        
        
N=int(input())
A=list(map(int,input().strip().split(' ')))

temp=find(A)

if temp==-1:
    print(temp)
    
else:
    while temp:
        print(temp.pop())

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<string>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = LONG_MAX;
// const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;



ll A, B, N;

ll check(ll mid) {
	ll cur = (A * mid) / B - A * (mid / B);
	return cur;
}

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;

	while (tc--) {

		ll n, m, k, i, j;
		ll x, y;


		cin >> A >> B >> N;

		ll l = 1, r = N;

		ll mid;
		ll cur = 0;

		while (l <= r) {
			mid = l + (r - l) / 2;

			ll cmp = check(mid);
			// cout << mid << endl;
			// cout << cmp << endl;

			if (cmp >= cur) {
				cur = max(cur, cmp);
				l = mid + 1;
			}
			else
				r = mid - 1;
		}

		cout << cur << endl;

	}

}

Measured memory_bytes: 3600
#include<stdio.h>
#include<string.h>
#define N 1001

char X[N], Y[N];

int LCS(void){
  int m = strlen(X), n = strlen(Y), i, j, c[m+1][n+1];
  for(i = 1;i < m+1;i++) c[i][0] = 0;
  for(i = 0;i < n+1;i++) c[0][i] = 0;
  for(i = 1;i < m+1;i++){
    for(j = 1;j < n+1;j++){
      if(i > 0 && j > 0 && X[i-1] == Y[j-1]) c[i][j] = c[i-1][j-1] + 1;
      else if(i > 0 && j > 0 && X[i-1] !=  Y[j-1]) c[i][j] = max(c[i][j-1], c[i-1][j]);
    }
  }
  return c[m][n];
}
int max(int a, int b){
  if(a <= b) return b;
  else return a;
}

int main(){
  int i, n;
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%s%s", X, Y);
    printf("%d\n", LCS());
  }
  return 0;
}

Measured memory_bytes: 4512
#include <stdio.h>
int main()
{
    char a[100],b[100];
    int i=0,j=0,count=0,x,count1=0;
    gets(a);
    strcpy(b,a);
    
    x=strlen(a);
   
     while(a[i]!='\0')
    {
        if(i%2!=0&&(a[i]=='L'||a[i]=='U'||a[i]=='D'))
            {
                count++;

            }
        i++;
    }
    
     while(b[j]!='\0')
    {
     if(j%2==0&&(b[j]=='R'||b[j]=='U'||b[j]=='D'))
            {
                count1++;
            }
            j++;
    }
   
    if(count+count1==x)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int D;
  cin>>D;
  vector<int> c(26+1);
  for(int i(1);i<27;i++){
    cin>>c[i];
  }
  vector<vector<int>> s(D+1,vector<int>(26+1));
  for(int i(1);i<=D;i++){
    for(int j(1);j<=26;j++){
      cin>>s[i][j];
    }
  }
  vector<int> t(D+1);
  for(int i(1);i<=D;i++){
    cin>>t[i];
  }
  int nowp(0);
  vector<int> l(D,0);
  for(int i(1);i<=D;i++){
    nowp += s[i][t[i]];
    l[t[i]] = i;
    for(int j(1);j<=26;j++){
      nowp -= c[j]*(i-l[j]);
    }
    cout << nowp << endl;
  }
  return 0;
}



Measured memory_bytes: 3688
#include <stdio.h>

int main() {
	int n;
	int cnt = 0;
	int x[100];

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d"
			, &x[i]);
	}


	for (int i = 0; i < n - 1; i++) {
		if (x[i] == x[i + 1]) {
			x[i + 1] = 0;
			cnt++;
		}
	}
	
	printf("%d\n",cnt);
	return 0;
}

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

int main()
{
    ll n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    string s;
    cin>>s;

    bool canA = true;
    for(int i=a-1;i<c-1;i++)
    {
        if( s[i] =='#' && s[i+1] == '#')
            canA = false;
    }
    bool canB = true;
    for(int i=b-1;i<d-1;i++)
    {
        if( s[i] =='#' && s[i+1] == '#')
            canB = false;
    }
    if( !(canB && canA)  )
    {
        cout<<"No";
        return 0;
    }
    if( c== d )
    {
        cout<<"No";
        return 0;
    }
    if( c < d )
    {
        cout<<"Yes";
    } else
    {
        bool ans = false;
        for(int i=b-2;i<d-1 ;i++)
        {
            if( s[i] =='.' && s[i+1] =='.' &&  s[i+2] =='.' ) {
                ans = true;
                break;
            }
        }
        if( ans)
            cout<<"Yes";
        else cout<<"No";
    }
}

Measured memory_bytes: 3712
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int R, C, N;
int Ri[101010], Ci[101010], Ai[101010];

int uf[201010];
i64 ofs[201010];
i64 mn[201010];

pair<int, i64> root(int p)
{
	if (uf[p] < 0) return{ p, 0LL };
	auto tmp = root(uf[p]);
	tmp.second += ofs[p];
	uf[p] = tmp.first;
	ofs[p] = tmp.second;
	return tmp;
}

bool join(int p, int q, i64 d)
{
	// v[p] = v[q] + d
	auto r1 = root(p), r2 = root(q);
	if (r1.first == r2.first) {
		if (r1.second != r2.second - d) return true;
		return false;
	}
	d += r1.second - r2.second;
	p = r1.first;
	q = r2.first;
	if (0 && uf[p] < uf[q]) {
		swap(p, q);
		d *= -1;
	}
	uf[p] += uf[q];
	uf[q] = p;
	ofs[q] = d;
	return false;
}

vector<pair<int, int> > vals[101010];

int main()
{
	scanf("%d%d", &R, &C);
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%d%d%d", Ri + i, Ci + i, Ai + i);
		--Ri[i]; --Ci[i];
	}

	bool ans = true;
	for (int t = 0; t < 2; ++t) {
		int ppp = (t == 1 ? 100000 : 0);
		for (int i = 0; i < R; ++i) {
			uf[i + ppp] = -1;
			ofs[i + ppp] = 0;
		}
		for (int i = 0; i < C; ++i) vals[i].clear();
		for (int i = 0; i < N; ++i) {
			vals[Ci[i]].push_back({ Ri[i], Ai[i] });
		}
		for (int i = 0; i < C; ++i) if (vals[i].size() >= 2) {
			for (int j = 1; j < vals[i].size(); ++j) {
				if (join(vals[i][0].first + ppp, vals[i][j].first + ppp, -vals[i][j].second + vals[i][0].second)) {
	//				printf("%d %d %d\n", t, vals[i][0].first, vals[i][1].first);
					ans = false;
				}
			}
		}
		swap(R, C);
		for (int i = 0; i < N; ++i) swap(Ri[i], Ci[i]);
	}
	const int waf = 100000;
	for (int i = 0; i < 200000; ++i) {
		mn[i] = -(1LL << 60LL);
	}
	for (int i = 0; i < R; ++i) {
		auto t = root(i);
		mn[t.first] = max(mn[t.first], t.second);
	}
	for (int i = 0; i < C; ++i) {
		auto t = root(i + waf);
		mn[t.first] = max(mn[t.first], t.second);
	}
	for (int i = 0; i < N; ++i) {
		i64 mnr = mn[root(Ri[i]).first];
		i64 mnc = mn[root(Ci[i] + waf).first];
		i64 v = Ai[i] + root(Ri[i]).second + root(Ci[i] + waf).second;
//		printf("%d: %lld %lld %lld\n", i, mnr, mnc, v);
		if (v - mnr - mnc < 0) ans = false;
	}

	puts(ans ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 10880
r, D, saitama2000 = map(int, input().split())

kechadon2000 = saitama2000 * r - D
koibumi2000 = kechadon2000 * r - D
yokuderu2000 = koibumi2000 * r - D
taberuna2000 = yokuderu2000 * r - D
kitasaitama2000 = taberuna2000 * r - D
toroban2000 = kitasaitama2000 * r - D
tendiku2000 = toroban2000 * r - D
EkiBEN2000 = tendiku2000 * r - D
X_DAY2000 = EkiBEN2000 * r - D
hayasaitama2000 = X_DAY2000 * r - D

print(kechadon2000)
print(koibumi2000)
print(yokuderu2000)
print(taberuna2000)
print(kitasaitama2000)
print(toroban2000)
print(tendiku2000)
print(EkiBEN2000)
print(X_DAY2000)
print(hayasaitama2000)


Measured memory_bytes: 3064
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n = int(input())
	al = list(IN())
	for i in al:
		if i % 2 == 0 and i%3!=0 and i%5!=0:
			print('DENIED')
			return 
	print('APPROVED')
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    cout << max({a1, a2, a3}) - min({a1, a2, a3}) << endl;
    return 0;
}


Measured memory_bytes: 256
/*
Template for vjudge.net

	Author: Iqbal Hossain Rasel
	CodeForces: The_Silent_Man
	AtCoder   : IHR57
	TopCoder  : IHR57

*/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define EPS 1e-8
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

ll cs[MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
    int val, n;

    cin>>n;

    for(int i = 1; i <= n; i++){
        cin>>val;
        cs[i] = cs[i-1] + val;
    }

    int l = 1, r = 3;
    ll ans = 1e16;
    ll d[4];
    for(int i = 2; i <= n - 2; i++){
        while(l < i && abs(cs[l] - (cs[i] - cs[l])) >= abs(cs[l+1] - (cs[i] - cs[l+1]))){
            l++;
        }
        while(r < n && abs(cs[r] - cs[i] - (cs[n] - cs[r])) >= abs(cs[r+1] - cs[i] - (cs[n] - cs[r+1]))){
            r++;
        }
        d[0] = cs[l], d[1] = cs[i] - cs[l], d[2] = cs[r] - cs[i], d[3] = cs[n] - cs[r];
        //cout<<d[0]<<" "<<d[1]<<" "<<d[2]<<" "<<d[3]<<endl;
        sort(d, d + 4);
        ans = min(ans, d[3] - d[0]); 
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) x.rbegin(),x.rend()
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define            bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
vi a , dp , ans;

void dfs(int i = 0 , int p = -1)
{
     int len = upper_bound( all(dp) , a[i]) - begin(dp);
     int now = dp[len];
     if( dp[len-1] < a[i] and dp[len] > a[i] )
     {
          dp[len] = a[i];
     }

     ans[i] = lower_bound( all(dp) , INF) - begin(dp) - 1;

     for( auto j : adj[i] )
     {
          if( j != p ) dfs( j , i );
     }

     dp[len] = now;

}

void go()
{
     cin >> n;
     a.resize(n);
     dp.assign(n + 1,INF);
     dp[0] = -INF;
     ans.assign(n , 1);

     fo(i,0,n) cin >> a[i];

     fo(i,0,n-1)
     {
          int u , v;
          cin >> u >> v;
          --u, --v;

          adj[u].pb(v);
          adj[v].pb(u);
     }

     dfs();

     fo(i,0,n) cout << ans[i] << endl;
}

int32_t main()
{
     FAST;     
     int t=1; 
     // cin>>t;
     test(t) go();
}

 

Measured memory_bytes: 30244
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  string s;
  cin >> s;
  if(s.length() >= 4) {
    if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

using namespace std;

using ll = long long int;

void print(int A, int B) { printf("%d %d\n", A, B); }

int main() {
    // Input
    int X;
    cin >> X;

    // Process and Output
    // B = 0
    int A = int(pow(X, 0.2));
    ll a = (ll)pow(A, 5);
    if (a == X) {
        print(A, 0);
        return 0;
    }

    // 0 <= B^5 < X
    ll a0 = a;
    A++;
    a = (ll)pow(A, 5);
    int B = 0;
    ll b = 0;
    while (a0 + b < a) {
        B++;
        b = (ll)pow(B, 5);
        if (a0 + b == a) {
            print(A, B);
            return 0;
        }
    }

    // B < 0
    A = int(pow(X / 2, 0.2));
    B = -(A + 1);
    a = (ll)pow(A, 5);
    b = (ll)pow(B, 5);
    while (a - b != X) {
        if (a - b < X) {
            A++;
            a = pow(A, 5);
        } else {
            B++;
            b = pow(B, 5);
        }
    }
    print(A, B);

    return 0;
}


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

int main(){
    string s;
    cin >> s;
    if(s=="SUN") cout << 7 << endl;
    if(s=="MON") cout << 6 << endl;
    if(s=="TUE") cout << 5 << endl;
    if(s=="WED") cout << 4 << endl;
    if(s=="THU") cout << 3 << endl;
    if(s=="FRI") cout << 2 << endl;
    if(s=="SAT") cout << 1 << endl;
    return 0;
}


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

int main()
{
    string s;  cin >> s;
    int count = 0;

    for (int i = 0; i < s.length(); i++) {
        if ((i + 1) % 2 == 0) {
            if (s[i] == 'R') {
                break;
            }
        } else {
            if (s[i] == 'L') {
                break;
            }
        }
        ++count;
    }
    if (count == s.length())  cout << "Yes" << endl;
    else  cout << "No" << endl;
}

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

using namespace std;

#define INF 0x7fffffff

int main() {
  string S;
  int ans = INF;
  
  cin >> S;
  
  for (int i = 0; i < S.length() - 2; i++) {
    ans = min(ans, abs(753 - stoi(S.substr(i, 3))));
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func main() {
	n, _ := strconv.Atoi(input())
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(input())
	}
	oddNum := 0
	for i := 0; i < n; i++ {
		if a[i]%2 == 1 {
			oddNum++
		}
	}
	if oddNum%2 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 2944
n = int(input())
s = list(input())

num = s[1:].count('E')
ans = num

for k in range(1, n):
    now = s[k-1]
    next = s[k]
    num += 1 if now == 'W' else 0
    num -= 1 if next == 'E' else 0
    ans = min(ans, num)

print(ans)


Measured memory_bytes: 8012
N,K,S = list(map(int,input().split()))
inf = 10**9
if K < N and S != inf:
    for i in range(K):
        print(S,end=" ")
    for i in range(N-K-1):
        print(inf,end=" ")
    print(inf)
elif K < N and S == inf:
    for i in range(K):
        print(inf,end=" ")
    for i in range(N-K-1):
        print(1,end=" ")
    print(1)
elif K == N:
    for i in range(K-1):
        print(S,end=" ")
    print(S)

Measured memory_bytes: 4340
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<array>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

static const int N=100;
static const int white=0;
static const int gray=1;
static const int black=2;
int color[N],nt[N];
int mp[N][N];
int n,d[N],f[N],tt;
int next(int r){
    
    for(int i=nt[r];i<n;i++){
        nt[r]=i+1;
        if(mp[r][i]&&color[i]==white)return i;
        
    }
    return -1;
    
}

void dfs_visit(int r){
    rep(i,n){nt[i]=0;}
    stack<int> s;
    s.push(r);
    d[r]=++tt;
    color[r]=gray;
    
    while(!s.empty()){
        int u=s.top();
        int v=next(u);
        if(v!=-1){
            
            d[v]=++tt;
            color[v]=gray;
            s.push(v);
            
        }else{
            f[u]=++tt;
            color[u]=black;
            s.pop();
        }
    }
}



void dfs(){
    tt=0;
    rep(i,n){
        color[i]=white;nt[i]=0;
    }
    rep(i,n){
        if(color[i]==white){
            dfs_visit(i);
            
        }
    }
    rep(i,n){
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
}


int main(){
    cin>>n;
    rep(i,N){
        rep(j,N){
            mp[i][j]=0;
        }
    }
    rep(i,n){
        int a,b;
        cin>>a>>b;
        a--;
        rep(i,b){
            int c;
            cin>>c;
            c--;
            mp[a][c]=1;
        }
    }
    dfs();
    return 0;
}



Measured memory_bytes: 3144
def solve():
    from collections import namedtuple
    from heapq import heappush, heappop
    from operator import attrgetter
    import sys

    input = sys.stdin.readline
    Sushi = namedtuple('Sushi', 'taste kind')

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

    e = []
    for _ in range(n):
        t, d = map(int, input().split())
        e.append(Sushi(taste=d, kind=t - 1))

    e.sort(key=attrgetter('taste'), reverse=True)

    b = e[:k]  # 美味しさ降順k個

    ret = 0
    used = [False] * n  # 選択されている種類
    h = []  # 選択から外す候補
    x = 0  # 暫定選択の種類数
    for s in b:
        if used[s.kind]:
            heappush(h, s)
        else:
            used[s.kind] = True
            x += 1
        ret += s.taste

    ret += pow(x, 2)  # 種類ボーナス

    t = ret
    r = iter(e[k:])  # 交換で入れる候補
    while h:
        rem = heappop(h)  # 選択から外す
        t -= rem.taste

        for s in r:
            if used[s.kind]:
                continue
            used[s.kind] = True
            t += s.taste + x * 2 + 1
            x += 1
            ret = max(ret, t)
            break
        else:
            break

    return ret


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


Measured memory_bytes: 19464
#include <bits/stdc++.h>
#define ll long long
#define foru(i,a,n) for(int i=(a); i<=(n); ++i)
#define ford(i,n,a) for(int i=(n); i>=(a); --i)
using namespace std;
const ll inf = 1e15;
const int N = 3030;
ll n, a[N], s[N], dp[N][N];

ll sol(int L, int R){
	if(L == R) return a[L];
	if(dp[L][R] != inf) return dp[L][R];
	return dp[L][R] = max(a[L] - sol(L+1,R), a[R] - sol(L,R-1));
}

int main() {
	//freopen("a.in","r",stdin);
	ios::sync_with_stdio(0);
	cin >>n;
	foru(i,1,n) cin >>a[i];
	
	foru(i,0,N-1) foru(j,0,N-1) dp[i][j] = inf;
	cout <<sol(1,n) <<"\n";
	
	//cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
	return 0;
}

Measured memory_bytes: 72192
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int a,b,k,ans[200],j;
int main(){
cin>>a>>b>>k;
for(int i=a;i-a<k&&i<=b;i++)
{ans[j]=i;
j++;}
for(int i=b;b-i<k&&i>=a;i--)
{bool ok=true;
for(int s=0;s<j;s++)
if(i==ans[s])
ok=0;
if(ok){ans[j]=i;
j++;}
}
sort(ans,ans+200);
for(int i=0;i<200;i++)
if(ans[i]!=0)
cout<<ans[i]<<endl;
system("pause");
return 0;
}

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

int main() {
    int n;
    cin >> n;
    int R[n], i;

    for(i=0; i<n; i++) {
        cin >> R[i];
    }

    int buy = R[0], min = R[0], sell = 0;
    for(i=1; i<n; i++) {
        if(R[i] > sell) sell = R[i];
        if(R[i] - min > sell - buy) {
            sell = R[i];
            buy = min;
        }
        if(R[i] < min) min = R[i];
    }
    cout << sell - buy << endl;

    return 0;
}

Measured memory_bytes: 3840
# ????????????
n,m,l = list(map(int,input().split()))
matrixA,matrixB = [],[]
for i in range(n):
	matrixA.append(list(map(int,input().split())))
for j in range(m):
	matrixB.append(list(map(int,input().split())))

matrix = []
for i in range(l):
	mtr = []
	for j in range(m):
		mtr.append(matrixB[j][i])
	matrix.append(mtr)

matrixC = []
for i in range(l):
	mtr = []
	for j in range(n):
		num_sum = 0
		# print(matrixA[j],matrix[i])
		for a,b in zip(matrixA[j],matrix[i]):
			num_sum += a*b
		mtr.append(num_sum)
	matrixC.append(mtr)

matrix = []
for i in range(n):
	out = ''
	for j in range(l):
		out += str(matrixC[j][i]) + ' '
	print(out[:-1])

Measured memory_bytes: 8964
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n;i++)
using namespace std;
int main(){
    int n;
    while(cin>>n){
        vector<int>v(n);
        rep(i,n)cin>>v[i];
        sort(v.begin(),v.end());
        rep(i,n-1)v[i+1]+=v[i];
        int ans=0;rep(i,n)ans+=v[i];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3012
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<algorithm>
#include<bits/stdc++.h>
#include<string>
#include<cmath>
using namespace std;

int main(){
  int N;
  cin>>N;
  
  
  vector<pair<string,int>> WWW;
  for(int i=0; i<N; ++i){
    string S;
    int a;
    cin>>S>>a;
    WWW.push_back(make_pair(S,a));
  }
  
  int AA[N-1];
  
  
  for(int i=0; i<N; ++i){
    int t=0;
    for(int j=0; j<N; ++j){
      if((WWW[t].first==WWW[j].first && WWW[t].second<WWW[j].second) 
         || WWW[t].first>WWW[j].first){
        t=j;
      }
    }
    WWW[t].first="zzzzzzzzzzzzzzzzZZZZZZZZZZz";
    AA[i]=t+1;
  }
  
  for(int i=0; i<N; ++i) cout<<AA[i]<<endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	ll N;
	cin>>N;
	map<ll,ll>mp;
	set<ll>odd;
	set<ll>even;
	int no_even=0;
	rep(i,0,N){
		ll A;
		cin>>A;
		mp[A]++;
		if(A%2){
			DBG("odd!","A=",A,"");
			odd.insert(A);
		}
		else{
			DBG("even!","A=",A,"");
			even.insert(A);
		}
		if(A==2) no_even=1;
	}
	if(mp[1]>1){
		cout<<0<<endl;
		return 0;
	}
	if(mp[1]>0){
		cout<<1<<endl;
		return 0;
	}
	if(no_even==0){
		for(auto u : even){
			DBG("even!",u,"","");
			rep(j,2,500001){
				ll num=u*j;
				if(num>1000000) break;
				if(even.count(num)){
					even.erase(num);
				}
			}
	    }
	}
	DBG("2","","","");
	for(auto u : odd){
		DBG("odd!",u,"","");
		rep(j,2,333335){
			ll num=u*j;
			if(num>1000000) break;
			if(num%2){
				if(odd.count(num)){
					odd.erase(num);
				}
			}
			else{
				if(even.count(num)){
					even.erase(num);
				}
			}
		}
    }
	DBG("3","","","");
	ll ans=0;
	if(no_even==0){
		for(auto u:even){
			if(mp[u]>=2) continue;
			ans+=mp[u];
		}
	}
	else{
		ans++;
	}
	DBG("4","","","");
	for(auto u:odd){
		if(mp[u]>=2) continue;
		ans+=mp[u];
	}
	DBG("5","","","");
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 25536
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
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;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string s,t;
    cin>>s>>t;
    ll res=0;
    rep(i,s.size()){
        if(s[i]!=t[i]){
            res++;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3752
#include<iostream>

using namespace std;

int main(){
  char a;
  cin>>a;
  
  if(a=='A'){
    cout<<'T'<<endl;
  }else if(a=='T'){
    cout<<'A'<<endl;
  }else if(a=='G'){
    cout<<'C'<<endl;
  }else if(a=='C'){
    cout<<'G'<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	char s[15]; char ans[15];
	scanf("%s", s);
	int n = 0; // current string length
	for(int i = 0; s[i] != '\0'; i++)
	{
		if(s[i] == '1') ans[n++] = '1';
		else if (s[i] == '0') ans[n++] = '0';
		else if (s[i] == 'B' && n > 0) n--;
	}
	for(int i = 0; i < n; i++) printf("%c", ans[i]); puts("");
	return 0;
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

//#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define vvii vector<vii>
#define pb push_back
#define endl "\n"
#define f first
#define s second

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n;
    cin >> n;
    string s;
    set<string> st;
    REP(i, 0, n) {
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}


Measured memory_bytes: 19096
n=int(input())
s=input().split()
l=[None]*n
for i in range(n):
    l[i]=int(s[i])
res=0
i=1
while True:
    if i>=n:
        break
    if l[i-1]==l[i]:
        res+=1
        i+=1
    i+=1
print(res)

Measured memory_bytes: 3064
#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;

int main() {
  int n;
  cin >> n;
  int h[n];
  rep(i,n)
  cin >> h[i];
  int dp[n];
  dp[0]=0,dp[1]=abs(h[0]-h[1]);
  for(int i=2;i<n;i++)
  dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]));
  cout << dp[n-1] << endl;
}

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

using namespace std;

int main(void)
{
	string s; cin>>s;
	int len = s.size();
	int ans = 0;
	if(s[0] == s[len-1]) ans++;
	if(len%2 == 0) ans++;
	if(ans == 0 || ans == 2) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
int main() 
{
	string s;
	//scanf("%s",&s);
	cin>>s;
	int len=s.size();
	for(int i=0;i<len;i++)
		if(s[i]=='C')
			for(int j=i+1;j<len;j++)
				if(s[j]=='F')
				{
					printf("Yes\n");
					return 0;
				}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
s = list(map(str, input().split()))
l = []
for i in range(len(s)):
    n = s[i]
    if n == "-":
        t = l.pop(-2) - l.pop(-1)
        l.append(t)
    elif n == "+":
        t = l.pop(-2) + l.pop(-1)
        l.append(t)
    elif n == "*":
        t = l.pop(-2) * l.pop(-1)
        l.append(t)
    else:
        l.append(int(n))

print(*l)



Measured memory_bytes: 5600
#include <cstdio>
int main(){
	int a,b,c;
	scanf("%d %d %d" ,&a,&b,&c);
	if(a == 5 && b == 7 && c == 5)
		printf("YES\n");
	else if(a == 5 && b == 5 && c == 7)
				printf("YES\n");
    else if(a == 7 && b == 5 && c == 5)
				printf("YES\n");
				else printf("NO\n");
					return 0;
}



Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,m,x,y;

int main(){
  ll ans=0;
  cin >> n >> m;
  vi s(m),c(m);
  vi ke(3,-1);
  REP(i,m){
    cin>>s[i]>>c[i];
    //s[i]--;
    if (ke[n-s[i]]==-1){
      ke[n-s[i]]=c[i];
    }else{
      if (ke[n-s[i]]!=c[i]){
        cout<<-1<<endl;
        return 0;
      }
    }
  }



  REP(i,3){
    if (ke[i]==-1){
      if (n==i+1){
        if (n==1){
          ke[i]=0;
        }else{
          ke[i]=1;
        }
      }else{
        ke[i]=0;
      }
    }

    if (ke[i]==0){
      if (n==i+1){
        if (n==1){
          cout<<0<<endl;
          return 0;
        }
        cout<<-1<<endl;
        return 0;
      }
    }

  }

  ans=ke[0]+ke[1]*10+ke[2]*100;

  int nn=1;
  if (n==1)nn=0;
  if (n==2)nn=10;
  if (n==3)nn=100;
  if (ans>=nn){
  cout<<ans<<endl;
  }else{
  cout<<-1<<endl;
  }
  




  return 0;
}

Measured memory_bytes: 256
//g++  7.4.0

#include <iostream>
#include<vector>
typedef long long ll ;
using namespace std;
ll minstep(ll i,vector <ll> &arr,ll prev,vector <ll> &dp)
{
    if(i<=-1)
       return 999999999;  
    else if(i==0)
        return 0;
    else if(dp[i]!=-1)
        return dp[i];
    else
        if(i>=2)
            dp[i]=ll(min(abs(arr[i]-arr[i-1])+minstep(i-1,arr,arr[i],dp),abs(arr[i-2]-arr[i])+minstep(i-2,arr,arr[i],dp)));
        else
            dp[i]=ll(abs(arr[i]-arr[i-1])+minstep(i-1,arr,arr[i],dp));
        //cout<<i<<" "<<dp[i]<<endl;
        return dp[i];
}

int main()
{
    int t;
    t=1;
    while(t--)
    {
        ll n;
        cin>>n;
        vector <ll> arr (n);
        vector <ll> dp (n,-1);
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }

        cout<<minstep(n-1,arr,arr[n-1],dp);
    }
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;}
ll f(ll X, ll C, ll D){
    ll result = X;
    //1-Xのうち、C で割り切れる
    result -=  X/C;
    //1-Xのうち、Dで割り切れる
    result -=  X/D;
    //1-Xのうち、CorDで割り切れる(CorD's LCM)
    result += X/lcm(C,D);

    return result;
}
int main() {
    ll A = 0;
    ll B = 0;
    ll C = 0;
    ll D = 0;
    cin >> A  >> B >> C >> D;
    ll ans = f(B,C,D) -f(A-1, C, D);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = [0] * 9
for i in a:
  x = min(i // 400, 8)
  if x >= 8:
    ans[8] += 1
  else:
    ans[x] = 1

if sum(ans[:8]) == 0:
  l = 1
  r = ans[8]
else:
  l = sum(ans[:8])
  r = l+ans[8]
print(l,r)


Measured memory_bytes: 8992
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int64_t a, b, n; cin >> a >> b >> n;
	int64_t x = min(n, b - 1);

	cout << (a * x) / b - a * (x / b) << endl;

	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

/*
bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
*/


//3111111111111111111111111111111






	void solve(){
		int a[5000];
		a[0] = 100;
		FOR(i,1,5000){
			a[i] =a[i-1]*1.01;
		}
		ini(x);
		FOR(i,0,5000){
		//	out(a[i]);
			if(a[i]>=x){out(i);return;}
		}
		out(a[4999]);

	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 3005;

double dp[MAX_N][MAX_N];
double p[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        cin >> p[i];
    }
    dp[0][0] = 1.0;
    rep(i,n){
        rep(j,i+1){
            dp[j][i-j+1] += dp[j][i-j]*(1.0-p[i]);
            dp[j+1][i-j] += dp[j][i-j]*p[i];
        }
    }
    double ans = 0;
    rep(j,(n+1)/2){
        ans += dp[n-j][j];
    }
    printf("%.12lf\n", ans);
    return 0;
}

Measured memory_bytes: 70016