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

int NILL = -1;
int a = 0;

struct node{
    int parent, left, right, depth, height;
    node(){
        parent = NILL;
        left = NILL;
        right = NILL;
        depth = NILL;
        height = NILL;
    }
};

std::vector<node> tree;

std::vector<int> ve;

void print(std::vector<int> a){
    for(int i = 0; i < a.size(); i++){
        std::cout << " ";

        std::cout << a[i];
    }
    std::cout << std::endl;
}

int perParse(int u){
    if(u == NILL){
        return 0;
    }
    ve.push_back(u);
    perParse(tree[u].left);
    perParse(tree[u].right);
}

int inOrder(int u){
    if(u == NILL){
        return 0;
    }
    inOrder(tree[u].left);

    ve.push_back(u);
    inOrder(tree[u].right);
}

int postOrder(int u){
    if(u == NILL){
        return 0;
    }
    
    postOrder(tree[u].left);
    postOrder(tree[u].right);
    ve.push_back(u);

}

int main(void){
    int n;
    std::cin >> n;
    tree.resize(n);
    int id, left, right;
    for(int i = 0; i < n; i++){
        std::cin >> id >> left >> right;
        tree[id].left = left;
        tree[id].right = right;
        tree[left].parent = tree[right].parent = id;
    }

    int root;
    for(int i = 0; i < n; i++){
        if(tree[i].parent == -1){
            root = i;
            break;
        }
    }

    std::cout << "Preorder" << std::endl;
    perParse(root);
    print(ve);
    ve.clear();
    
    std::cout << "Inorder" << std::endl;
    inOrder(root);
    print(ve);
    ve.clear();

    std::cout << "Postorder" << std::endl;
    postOrder(root);
    print(ve);
    ve.clear();

    
    return 0;
}


Measured memory_bytes: 3164
#include<stdio.h>

int a,b;

int main(void){
while(scanf("%d %d",&a,&b) != EOF){
if (a == 0 && b == 0){
break;
}

if(a >= b){
printf("%d %d\n",b,a);
}
else{
printf("%d %d\n",a,b);
}
}
return 0;
}



Measured memory_bytes: 2056
INF = float("inf")

N, M = map(int, input().split())

dp = [INF] * (2 ** N)
dp[0] = 0

for _ in range(M):
    a, b = map(int, input().split())
    C = [int(i) for i in input().split()]
    mask = sum(1 << (c - 1) for c in C)
    for i, dpi in enumerate(dp):
        if dp[i | mask] > dpi + a:
            dp[i | mask] = dpi + a

ans = dp[-1]
print(-1 if ans == INF else ans)


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << " " << max(0, A + B - N) << endl;

    return 0;
}


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

namespace ConsoleApp15
{
    class Class163
    {
        static void Main()
        {
            double L = double.Parse(Console.ReadLine());
            Console.WriteLine(Math.Pow(L / 3, 3));
        }
    }
}


Measured memory_bytes: 11092
#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 pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#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;

const ll mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(ll n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (ll i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (ll i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(ll n, ll k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(ll n, ll k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    mint val=1;
    rep(i,n){
        val*=2;
    }
    mint sum=0;
    rep(i,n){
        cin >> a[i];
    }
    sort(a.rbegin(),a.rend());
    vector<mint> mul(n);
    mint u=val/2;
    mint v=u/2;
    rep(i,n){
        if(i==0) mul[i]=u;
        else{
            mul[i]=mul[i-1]+v;
        }
    }
    rep(i,n){
        mint num=a[i];
        sum+=num*mul[i];
    }
    sum*=val;
    cout << sum << endl;
    return 0;
}

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

typedef complex<double> P;

double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}

int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if (cross(b, c) > 0)		return +1;		// counter clockwise
	if (cross(b, c) < 0)		return -1;		// clockwise
	if (dot(b, c) < 0)		return +2;		// c--a--b on line
	if (norm(b) < norm(c))	return -2;		// a--b--c on line
	return 0;
}

int main(){
	P p[3],t;
	while(cin >> p[0].real() >> p[0].imag() >> p[1].real() >> p[1].imag() >> p[2].real() >> p[2].imag() >> t.real()>> t.imag()){
		int x=0;
		for(int i=0;i<3;i++) x += ccw(p[i],p[(i+1)%3],t);
		if(x==3||x==-3) cout<<"YES"<<endl;
		else cout<< "NO" <<endl;
		}
	return 0;
}

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

int a[4][4], b[4][4];
int n;
bool stat = false;
int main(){
	for(int i=1;i<=3;i++){
		for(int j=1;j<=3;j++) scanf("%d",&a[i][j]), b[i][j] = 0;
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int t;
		scanf("%d",&t);
		for(int i=1;i<=3;i++) for(int j=1;j<=3;j++) if(a[i][j] == t) b[i][j] = 1;
	}
	for(int i=1;i<=3;i++) if(b[i][1] && b[i][2] && b[i][3]) stat = true;
	for(int i=1;i<=3;i++) if(b[1][i] && b[2][i] && b[3][i]) stat = true;
	if(b[1][1] && b[2][2] && b[3][3]) stat = true;
	if(b[1][3] && b[2][2] && b[3][1]) stat = true;
	if(stat) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

using namespace std;

int main (){

    int a, b, c, k;

    cin >> a >> b >> c >>k;

    if(k <= a){
        cout << k;
    } else if ( k <= a+b){
        cout << a;
    } else{
        cout << a - (k - a - b);
    }


    return 0;   
}

Measured memory_bytes: 3636
using System;

namespace test2 {

    public class Program {

        public static void Main(string[] args) {

            var input = Console.ReadLine().Split(' ');

            var n = input[0];
            var m = input[1];

            if(n == m) {

                Console.WriteLine("Yes");

            } else {

                Console.WriteLine("No");

            }

        }

    }

}


Measured memory_bytes: 25692
#include <iostream>
#include <cstdio>
#include <utility>
#include <cstring>

#define SIZE 100000

typedef struct {
    char name[16];
    int time;
} process;

class Queue {
private:
    process queue[SIZE];
    int head;
    int tail;
    int flag;
public:
    Queue()
    {
        head = 0;
        tail = 0;
        flag = 0;
    }

    void enqueue(process x)
    {
        if(!isFull())
        {
            flag = 1;
            queue[tail] = x;
            tail = (tail + 1) % SIZE;
        }
    }

    process dequeue()
    {
        if(!isEmpty())
        {
            flag = -1;
            process x = queue[head];
            head = (head + 1) % SIZE;
            return x;
        }
    }

    bool isEmpty()
    {
        if (flag == -1 && head == tail)
            return true;
        else
            return false;
    }

    bool isFull()
    {
        if (flag == 1 && head == tail)
            return true;
        else
            return false;
    }
};

int main()
{
    Queue queue;
    int n;
    scanf("%d", &n);
    int quantum;
    scanf("%d", &quantum);
    for (int i = 0; i < n; i++)
    {
        char name[16];
        int time;
        scanf("%s %d", name, &time);
        process p;
        strcpy(p.name, name);
        p.time = time;
        queue.enqueue(p);
    }

    int nowtime = 0;
    while (!queue.isEmpty())
    {
        process p = queue.dequeue();
        if (p.time > quantum)
        {
            process p_updated;
            strcpy(p_updated.name, p.name);
            p_updated.time = p.time - quantum;
            queue.enqueue(p_updated);
            nowtime += quantum;
        } else
        {
            nowtime += p.time;
            printf("%s %d\n", p.name, nowtime);
        }
    }
}


Measured memory_bytes: 5084
import java.util.*;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		long S = sc.nextLong();
		long x1 =0;
		int x2 =1000000000;
		long x3 =(x2-S%x2)%x2;
		long y1 =0;
		long y2 =1;
		long y3 =((S-y2)/x2+y2);
		System.out.println(x1 + " " + y1 + " " + x2 + " " + (int)y2 + " " + x3 + " " + y3);

	}
}

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

int N;
vector<string> S;

long long C2(long long suc) {
  return suc*(suc-1)/2;
}

int main() {
  cin >> N;
  string s;
  rep(i, N) {
    cin >> s;
    sort(s.begin(), s.end());
    S.push_back(s);
  }
  sort(S.begin(), S.end());
  long long cnt = 0;
  int suc=1;
  rep(i, N-1) {
    if(S[i] == S[i+1]) {
      suc++;
    } else {
      if(suc!=1) {
        cnt += C2(suc);
      }
      suc=1;
    }
  }
  if(suc!=1) {
    cnt += C2(suc);
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 5748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

struct edge{
    int to;
    ll cost;
};

vector<ll> dijkstra(vector<edge> g[], int s, int V) {

    vector<ll> dist(V, LINF);

    priority_queue<pll, vector<pll>, greater<pll>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    while(!que.empty()) {
        ll cost;
        int idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e: g[idx]) {
            auto next_cost = cost + e.cost;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

void solve() {
    int n, x, y;
    cin >> n >> x >> y;
    vector<edge> G[n];
    x--; y--;
    rep(i, n - 1) {
        G[i + 1].push_back({i, 1});
        G[i].push_back({i + 1, 1});
    }
    int cnt[2020] = {0};
    G[x].push_back({y, 1});
    G[y].push_back({x, 1});
    rep(i, n) {
        auto dist = dijkstra(G, i, n);
        REP(j, i + 1, n) cnt[dist[j]]++;
    }
    REP(i, 1, n) cout << cnt[i] << endl;
}

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


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


int main() {
    int n,ans=0;
    cin>>n;
    int a;
    rep(i,n){
        cin>>a;
        if(a!=i+1)ans++;
    }
    cout << (ans==2 or ans==0 ? "YES":"NO") <<endl;
}


Measured memory_bytes: 256
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class Combination(object):
	def __init__(self, N, con):
		self.fac = [0] * (N + 1)
		self.inv = [0] * (N + 1)
		self.finv = [0] * (N + 1)
		self.fac[0], self.fac[1] = 1, 1
		self.inv[1] = 1
		self.finv[0], self.finv[1] = 1, 1

		# 前計算
		for i in range(2, N + 1):
			self.fac[i] = self.fac[i - 1] * i % con
			self.inv[i] = self.inv[con % i] * (con - (con // i)) % con
			self.finv[i] = self.finv[i - 1] * self.inv[i] % con

	def com(self, N, k):
		return (self.fac[N] * self.finv[k] * self.finv[N - k]) % con


#処理内容
def main():
	K = int(input())
	S = list(input())
	N = len(S)
	C = Combination(N + K, con)
	ans = pow(26, K + N, con)
	for i in range(N):
		ans -= C.com(N + K, i) * pow(25, K + N - i, con)
		ans %= con

	print(ans)



if __name__ == '__main__':
	main()

Measured memory_bytes: 164668
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<queue>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W ;
	vector<string> map(H);
	for (int i = 0; i < H; i++) {
		cin >> map[i];
	}
	int str = 1;
	int dx[4] = { 1,0,-1,0 };
	int dy[4] = { 0,1,0,-1 }; 
	int count = 0;
	queue<int> quex;
	queue<int> quey;
	vector<vector<int>>dict(H, vector<int>(W, -1));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (map[i][j] == '#') {
				quex.push(j);
				quey.push(i);
				dict[i][j] = 0;
			}
		}
	}
	
	while (!quex.empty() && !quey.empty()) {
		bool flag = false;
		int x = quex.front();
		int y = quey.front();
		quex.pop();
		quey.pop();
		for (int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i]; 
			if (nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
			if (map[ny][nx]=='.') {
				dict[ny][nx] = dict[y][x] + 1;
				quex.push(nx);
				quey.push(ny);
				map[ny][nx] = '#';
				flag = true;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (count < dict[i][j]) {
				count = dict[i][j];
			}
		}
	}
	std::cout << count << endl;
}

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

#define lli long long int
#define Sort(n) sort(n.begin(), n.end())
#define Reve(n) reverse(n.begin(), n.end())
#define YES puts("YES")
#define NO puts("NO")

//素数
bool IsPrime(lli num)
{
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)return false;
  }
  return true;
}
//各桁の和
lli sum(lli n)
{
  lli sum=0;
  if (n<0) return 0;
  while (n>0)
  {
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(void)
{
  vector<int> a(3);
  int ans=0;
  for(int i = 0;i < 3;i++) {
    cin >> a.at(i);
  }
  Sort(a);
    if(a.at(0) == a.at(1)) {
      if(a.at(1) != a.at(2)) {
        puts("Yes");
        return 0;

      }
    }
    if(a.at(0) != a.at(1)) {
      if(a.at(1) == a.at(2)) {
        puts("Yes");
        return 0;
      }
    }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = -1; i < (n); i++)
#define PI 3.141592653589793

using namespace std;
using ll = unsigned long long;


int main() {

	int n, k;

	cin >> k >> n;

	vector<int> a(n + 1);

	rep(i, n) cin >> a[i + 1];

	a[0] = a[n] - k;

	vector<int> d(n);

	rep(i, n) {
		d[i] =k - (a[i + 1] - a[i]);
	}

	sort(d.begin(), d.end());

	cout << d[0] << endl;

	return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, a[100005];
vector< ll > adj[100005];
#define ari for( int i = 0 ; i < n ; i++ ) cin >> a[i];
#define ginp for( int i = 0 ; i < m ; i++ ){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);}
#define pb push_back
#define ss second
#define ff first
#define fs first.second
#define fff first.first
#define sss second.second
#define sf second.first
#define mp make_pair
void printar(vector< ll > ar, ll l, ll r){
	for(int i = l ; i < r ; i++)
		cout << ar[i] << " ";
	cout << endl;
}
	
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> t >> m;
    if( m * t >= n )
    	cout << "Yes\n";
    else
    	cout << "No\n";
	return(0);
}

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

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,i,a,b,min=100000000000000;
    cin>>n;
    a=1;b=n;
    for(i=1;i*i<=n;i++)
    {
    	if(n%i==0)
    	{
    		if(i+(n/i)-2<min)
    		min=i+n/i-2;
		}
	}

	cout<<min;
}

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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  vector<char> Goal1(N), Goal2(N);
  for(int i = 0; i < N; i++){
    if(i % 2 == 0){
      Goal1.at(i) = '1';
      Goal2.at(i) = '0';
    }else{
      Goal1.at(i) = '0';
      Goal2.at(i) = '1';
    }
  }
  
  int count1 = 0, count2 = 0;
  for(int i = 0; i < N; i++){
    if(S.at(i) != Goal1.at(i)) count1++;
    if(S.at(i) != Goal2.at(i)) count2++;
  }
  cout << min(count1, count2) << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
 #define ll long long
int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/
	
	ll n ,m,sum=0,c=0,d=0,e=0;
	ll x,y;
	cin>>n>>m;
	vector<int> a(n);
	vector<pair<int,int>>p;
	for(ll i=0;i<n;i++)
	{	
		cin>>a[i];
		//sum=sum+a[i];
	}
	sort(a.begin(),a.end());
	for(ll i=0;i<m;i++)
	{
		cin>>x>>y;
		p.push_back(make_pair(y,x));
	}
	sort(p.rbegin(),p.rend());
	d=p[c].second;
	ll z;
	z=d;
	for (ll i = 0; i <n;i++)
	{ 
		if(d==0)
		{
			c++;
			d=p[c].second;
			if(c==m)
				break;
		}
        if(a[e]>=p[c].first)
			{
				break;
			}
		else 
		{
			if(a[e]<p[c].first)

		    a[e]=p[c].first;
		    e++;
		    d--;
		}
		//cout<<d<<" ";
	}
		
		for (ll i = 0; i < n; ++i)
		{
			//cout<<a[i]<<endl;
			sum=sum+a[i];
		}
		cout<<sum;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  int p = 10*B;
  for (int i=0; i<10; i++) {
    if ((int)((p+i)*0.08) == A) {
      cout << p+i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

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

class Dice{
public:
	int l1,l2,l3,l4,l5,l6;
	
	void East(){
		int t = l1;
		l1 = l4;
		l4 = l6;
		l6 = l3;
		l3 = t;
	}
	void West(){
		int t = l1;
		l1 = l3;
		l3 = l6;
		l6 = l4;
		l4 = t;
	}
	void South(){
		int t=l1;
		l1 = l5;
		l5 = l6;
		l6 = l2;
		l2 = t;
	}
	void North(){
		int t=l1;
		l1 = l2;
		l2 = l6;
		l6 = l5;
		l5 = t;
	}
};

int main() {
	
	Dice dice;
	int l1,l2,l3,l4,l5,l6;
	char d;
	
	cin>>l1>>l2>>l3>>l4>>l5>>l6;
	dice.l1 = l1;
	dice.l2 = l2;
	dice.l3 = l3;
	dice.l4 = l4;
	dice.l5 = l5;
	dice.l6 = l6;
	
	while(cin>>d){
		if(d=='E')dice.East();
		else if(d=='W')dice.West();
		else if(d=='S')dice.South();
		else dice.North();
	}
	
	cout<<dice.l1<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::vector<long long> vll;

#define pub push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define umap unordered_map
#define uset unordered_set

#define forn(i, n)     for(ll i = 0; i< (ll)n; i++)
#define forf(i, x, y)  for(ll i=(x); i<=(ll)y; i++)
#define forb(i, x, y)  for(ll i=(x); i>=(ll)y; i--)
#define lpt() 		   ll T; std::cin>>T; while(T--)

#define nl "\n"
#define newl std::cout<<"\n";
#define bug(x) std::cerr<<"debug "<<#x<<" : "<<x<<"\n";
#define all(x) x.begin(),x.end()
#define fastio() ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);

template<typename X> std::ostream& operator<< (std::ostream& out, std::vector<X> v)
{ for(auto &i : v) out<<i<<" "; return out; }
template<typename X, typename Y> std::ostream& operator<< (std::ostream& out, std::pair<X,Y> p)
{ out<<p.first<<" "<<p.second; return out; }

static const long long mod = 1000000007;

using namespace std;

ll n;
vll a;
ll dp[3005][3005];

ll x(ll i,ll j)
{
	ll &k = dp[i][j];
	if(j-i<0)
		return 0;
	if(k!=-1)
		return k;
	if(j==i)
		return k=a[i];
	return k = max(a[i]-x(i+1,j) , a[j]-x(i,j-1));
}

int main()
{fastio()
	
	cin>>n;
	a.resize(n);
	forn(i,n)
		cin>>a[i];
	memset(dp,-1,sizeof dp);
	cout<<x(0,n-1)<<nl;

return 0;}


Measured memory_bytes: 71040
#include <stdio.h>
#include <string.h>
 
#define MAX 20050
#define INF 1e9
 
void push(char);
char pop(void);
 
int pos,len;
char st[MAX];
 
int main(){
  double sum = 0;
  int depth[MAX],Min[MAX],mini;
  int i,S[MAX],pool = 0,ans = 0;
  char str[MAX],ch;
 
  scanf("%s" ,str);
  len = (int)strlen(str); pos = 0;
 
  for(i = 0 ; i < len ; i++){
    if(str[i] == '\\'){
      depth[i] = ++pool;
    }else if(str[i] == '/'){
      depth[i] = --pool;
    }else{
      depth[i] = pool;
    }
  }
   
  mini = INF;
  for(i = len-1 ; i >= 0 ; i--){
    if(depth[i] < mini){
      mini = depth[i];
    }
    Min[i] = mini;
  }
 
  pool = 0;
  for(i = 0 ; i < len ; i++){
    if(str[i] == '\\'){
      if(i != len-1 && depth[i] == Min[i]) continue;
      push(str[i]);
    }else if(str[i] == '/'){
      ch = pop();
      if(ch != '#'){
    sum += ((pos+1) - 0.5)*2;
      }
    }else{
      sum += pos; 
    }
 
    if(sum > 0 && (pos == 0)){
      S[pool++] = sum;
      ans += sum;
      sum = 0;
    }
  }
 
  printf("%d\n%d" ,ans ,pool);
  for(i = 0 ; i < pool ; i++){
    printf(" %d" ,S[i]);
  } 
  printf("\n");
 
  return 0;
}
 
void push(char ch){
  st[pos++] = ch;
}
 
char pop(){
  if(pos == 0){
    return '#';
  }
  return st[--pos];
}


Measured memory_bytes: 2112
using System;
class _0032
{
    public static void Main()
    {
        string str;
        string[] data;
        int rectangles = 0, rhombuses = 0;
        while ((str = Console.ReadLine()) != null)
        {
            data = str.Split(',');
            if (Judge.Rectangle(int.Parse(data[0]), int.Parse(data[1]), int.Parse(data[2]))) rectangles++;
            else if (Judge.Rhombus(int.Parse(data[0]), int.Parse(data[1]), int.Parse(data[2]))) rhombuses++;
        }
        Console.WriteLine(rectangles);
        Console.WriteLine(rhombuses);
    }
}
static class Judge
{
    public static bool Rectangle(int a, int b, int c)
    {
        return (c * c == a * a + b * b) ? true : false;
    }
    public static bool Rhombus(int a, int b, int c)
    {
        return (a * a - (c / 2) * (c / 2) == b * b - (c / 2) * (c / 2)) ? true : false;
    }
}

Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

int T[101];
int dp[101][100001];
int pref[101][100002];
const int MOD = 1e9 + 7;

int main()
{
    turbo

    int n, k; cin >> n >> k;

    for(int i = 1; i <= n; i++)
        cin >> T[i];
    
    for(int i = 0; i <= n; i++)
    {
        dp[i][0] = 1;
        pref[i][0] = 1;
    }

    for(int i = 0; i <= k; i++)
        pref[0][i] = 1;

    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= k; j++)
            if(j - T[i] <= 0) dp[i][j] = pref[i - 1][j];
            else dp[i][j] = (pref[i - 1][j] - pref[i - 1][j - T[i] - 1] + MOD) % MOD;
        for(int j = 1; j <= k; j++)
            pref[i][j] = (pref[i][j - 1] + dp[i][j]) % MOD;    
    }

    return cout << dp[n][k], 0;
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;

int main() {
    char c;
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = 0
right, suma = 0, 0
for left in range(N):
    while right < N and (suma ^ A[right]) == (suma + A[right]):
        suma += A[right]
        right += 1
    ans += right - left
    if right == left:
        right += 1
    else:
        suma -= A[left]
print(ans)


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

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000
#define MOD 1000000009

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return r;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}


void solve(void){
    string s;
    cin >> s;
    bool aflag = false,zflag = false;
    int anum,znum;
    rep(i,0,s.size()){
        if(s[i] == 'A' && !aflag){ aflag = true; anum = i;}
        if(s[s.size()-i-1] == 'Z' && !zflag){zflag = true;znum = s.size()-i-1;}
        if(aflag && zflag) break;
        
    }
    cout << znum-anum+1 <<  endl;
  
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#define int long long
#define uint unsigned long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
using namespace std;

signed main()
{
	int map[50][26] = { 0 };
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		for (int j = 0; j < s.length(); j++)
		{
			int c = s.at(j) - 'a';
			map[i][c]++;
		}
	}

	int ans[26] = { 0 };

	for (int c = 0; c < 26; c++)
	{
		int min = INT_MAX;
		for (int i = 0; i < n; i++)
		{
			min = MIN(map[i][c], min);
		}
		ans[c] = min;
	}
	
	string s = "";
	for (int c = 0; c < 26; c++)
	{
		for (int i = 0; i < ans[c]; i++)
		{
			s += ('a' + c);
		}
	}

	cout << s << endl;
}


Measured memory_bytes: 256
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=1e3+10;
	ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=1e5+10;
	//------------------FIXED------------------
	char str[N];
	void main()
	{
		scanf("%s",str+1);int n=strlen(str+1);
		fd(i,n,2) str[i]='0'+(str[i]!=str[i-1]);
		reverse(str+1,str+n+1);
		int fl=1,fr=n,ans=-1;
		while(fl<=fr)
		{
			int K=(fl+fr)/2;
			int mx=0;fo(i,1,K-1) if(str[i]=='1') chmax(mx,i);
			//int mx=0;fo(i,K,n) if(str[i]=='1') chmax(mx,i);
			if(mx==0 or K<=n-mx) ans=K,fl=K+1; else fr=K-1;
		}write(ans);
	}
};//����������
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();//����Ԥ����ģ����
	mine::main();
	debug("\n---------------------Zory---------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}

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

#define f first
#define s second
#define pb push_back
#define all(x) x.begin(), x.end()

using LL   =  long long;
using pii  =  pair <int, int>;
using vii  =  vector <pii>;

const int INF = INT_MAX;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

    int n, a;
    cin>>n>>a;

    if(a >= n % 500) {
        cout<<"Yes\n";
    }
    else {
        cout<<"No\n";
    }

    return 0;
}

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

int main(){
    long long a,b,x,high=0,low=0;
    cin >> a >> b >> x;
    high = b / x;
    if(a%x==0)low = a / x;
    else low = a/x + 1;
    cout << high - low + 1 << endl;
    return 0;
}

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

int main() {
	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	for (int n = 0;n< N - 2;++n) {
		if ((S[n] == 'A')&&(S[n+1] =='B')&&(S[n+2] == 'C')) {
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>

#define ll long long
#define PI 3.1415926535

int main()
{
    long double R;
    std::cin >> R;

    long double ans = 2.0 * R * PI;
    std::cout << ans << std::endl;
}

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

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    vector<int> in(n);
    for(auto &i:in)
        scanf("%d",&i);
    sort(in.begin(),in.end());
    vector<int> x={0};
    x.reserve(n+1);
    const int inf=1e9;
    int res=inf;
    for(int i=0;i<n;++i)
    {
        int r=in[i];
        int s=24-r,p=inf,q=p;
        for(auto &j:x)
        {
            p=min(p,min(abs(j-r),24-abs(j-r)));
            q=min(q,min(abs(j-s),24-abs(j-s)));
        }
        if(p>q)
            x.push_back(r);
        else
            x.push_back(s);
        res=min(res,max(p,q));
    }
    printf("%d\n",res);
}


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

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

  string S;
  cin >> S;
  vector<int> west(N+1, 0);
  vector<int> east(N+1, 0);
  for(int i=0; i<N; i++){
    if (S[i] == 'W'){
      west[i+1] = west[i] + 1;
      east[i+1] = east[i];
    }else{
      west[i+1] = west[i];
      east[i+1] = east[i] + 1;
    }
  }

  int minVal = 10000000;
  for(int i=0; i<N; i++){
    minVal = min(minVal, (west[i]-west[0] + east[N] - east[i+1]));
  }
  cout << minVal;
  return 0;
}

Measured memory_bytes: 2948
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
const int MAXN = 2e5 + 2;

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K; cin >> N >> K;
    LL A[MAXN];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        --A[i];
    }
    if (K == 1) {
        cout << 0 << endl;
        return 0;
    }
    map<LL, int> m;
    LL acc = 0;
    LL ans = 0;
    queue<LL> q;
    m[0] = 1;
    q.push(0);
    for (int i = 0; i < N; ++i) {
        acc += A[i];
        ans += m[acc%K];
        // cout << "ans " << ans << endl;
        ++m[acc%K];
        q.push(acc%K);
        // for (auto x : m) {
        //     cout << x.first << ' ' << x.second << endl;
        // }
        if (q.size() == K) {
            --m[q.front()];
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19344
n = int(input())
a = list(map(int, input().split()))

def check(TF):
    wa = 0
    flag = TF
    count = 0
    for i in a:
        if flag: #正にしたい時  
            if wa + i> 0:
                wa += i
            else:
                count += abs(wa) + 1 - i
                wa = 1
            flag = False
        else: #負にしたい場合
            if wa + i < 0:
                wa += i
            else:
                count += abs(wa) + 1  + i
                wa = -1
            flag = True
    return count

# print (check(True))
# print (check(False))
            
print (min(check(True), check(False)))


Measured memory_bytes: 14332
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		 Scanner sc = new Scanner(System.in);
	        int x = sc.nextInt();
	        int t = sc.nextInt();
	        int a;
	        
	        if(x>t) {
	        a = x - t;
	        }else {
	        a = 0;	
	        }
	        System.out.println(a);
	}

}

Measured memory_bytes: 21588
#include <iostream>
#include <string>
using namespace std;
int main(){
  int N;
  cin >> N;
  string S_1, S_2;
  cin >> S_1 >> S_2;
  long long int mod = 1000000007LL, ans = 1LL;
  int i = 0, l = -1, r = -1;
  if(S_1[i] == S_2[i]){
    ans *= 3LL;
    ans %= mod;
    ++i;
    l = 0;
  }else{
    ans *= 6LL;
    i += 2;
    l = 1;
  }
  for(; i < N; ++i){
    if(S_1[i] == S_2[i]){
      r = 0;
    }else{
      r = 1;
      ++i;
    }
    if(l == 1 && r == 1){
      ans *= 3LL;
      ans %= mod;
    }else if(l == 0 || r == 1){
      ans *= 2LL;
      ans %= mod;
    }
    l = r;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
h = gets.to_i
ten = 1
plus = 2
max = 1
ans = []
ans[0] = 1
while(ten < h)
  ten += plus 
  ans[max] = plus
  max += 1
  plus += 1
end
ans[ten - h - 1]  = nil unless(ten == h)
max.times {|i|
  puts ans[i] if (ans[i] != nil)
}

Measured memory_bytes: 1788
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  string S;
  cin >> S;
  int ans = 0;

  bool flag = true;
  if(S[0] == '0') flag = false;
  else flag = true;

  for (int i = 1; i < S.size(); i++) {
    if(flag == false){
      if(S[i] == '0'){
        S[i] = '1';
        ans++;
      }
      flag = true;
    } else {
      if(S[i] == '1'){
        S[i] = '0';
        ans++;
      }
      flag = false;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3708
from collections import deque
import sys
h,w = map(lambda x: int(x),input().split())
map = []
white_count = 0
map_count = [[float('inf') for i in range(w)] for j in range(h) ]
seen = [[False for i in range(w)] for j in range(h) ]
for _ in range(h) :
    a = list(input())
    white_count += a.count('.')
    map.append(a)

map_count[0][0] = 1

q = deque()
q.append([0,0,0,0])
while q :
    v = q.popleft()
    x = v[0]
    y = v[1]
    pre_x = v[2]
    pre_y = v[3]


    if x < 0 or x >= h or y < 0 or y >= w :
        continue
    if seen[x][y] :
        continue
    if map[x][y] == '#' :
        continue
    if map_count[x][y] > map_count[pre_x][pre_y] + 1 :
        map_count[x][y] = map_count[pre_x][pre_y] + 1

    if x == h-1 and y == w-1 :
        print(white_count - map_count[x][y])
        sys.exit()

    pre_x = x
    pre_y = y
    seen[x][y] = True
    q.append([x+1,y,pre_x,pre_y])
    q.append([x-1,y,pre_x,pre_y])
    q.append([x,y+1,pre_x,pre_y])
    q.append([x,y-1,pre_x,pre_y])




print(-1)


Measured memory_bytes: 3436
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    string s;cin>>s;
    int ans=100000;
    REP(i,s.size()-2){
        int d = stoi(s.substr(i,3));
        ans = min(ans, abs(753-d));
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define REP(i,a,b) for(ll i = a; i < b; i++)
#define DB( x ) cout << #x << " = " << x << endl;
#define sz(s) ((int)((s).size()))
#define endl '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef pair<int, pii> tri;
typedef vector <vector <ll>> matrix;
typedef pair<string, string> pss;

const ll mod = (ll)1e9 + 7;
const int MAX = (int)1e5 + 100;

const ll oo = 0x3f3f3f3f3f3f3f3f;

ll dp[MAX], a[MAX];

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

    memset(dp, oo, sizeof(dp));

    int n, k = 2; cin >> n;

    dp[1] = 0;

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

    for(int i = 2;i <= n;++i){
        for(int j = 1;j <= k;++j){
            if(i - j >= 1)
                dp[i] = min(dp[i - j] + abs(a[i] - a[i - j]), dp[i]);
        }
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
ll ans[10001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	int s=sqrt(n);
	forn(i,1,s+1){
		forn(j,1,s+1)
		forn(k,1,s+1){
			if(i*i+j*j+k*k+i*j+i*k+j*k<=n){
				ans[i*i+j*j+k*k+i*j+i*k+j*k]++;
			}
		}
	}
	forn(i,1,n+1){
		cout<<ans[i]<<"\n";
	}
	re 0;
}

Measured memory_bytes: 3588
#define MOD 1000000007;
#define input ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll long long

#include <bits/stdc++.h>

using namespace std;
const int N = 3e5 + 5;
set<int> st[N+1];
int main() {

    int n;
    cin>>n;
    set<int> st;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(st.find(x)!=st.end())
            st.erase(st.find(x));
        else
            st.insert(x);
    }
    cout<<st.size();
}

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

const int maxn = 2e5+10;

int f[maxn];


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = 0;
	int m = 0;
	cin >> n >> m;
	for(int i =0 ; i < m ; i++) {
		int l , r;
		cin >> l >> r;
		f[l]++;
		f[r+1]--;
	}
	int t = 0;
	int res = 0;
	for(int i=0;i<maxn;i++) {
		t += f[i];
		res += (t == m);
	}

	cout << res;
	return 0;
}


Measured memory_bytes: 640
import bisect

S = input()
N = [0] * len(S)
RL = [0] * len(S)
ID = []

for i in range(len(S) - 1):
  if S[i] == "R" and S[i + 1] == "L":
    RL[i] += 1
    RL[i + 1] += 1
    ID.append(i)
    ID.append(i + 1)
    
for i in range(len(S)):
  if RL[i] == 0:
    if S[i] == "R":
      n = bisect.bisect_left(ID,i)
      r = ID[n]

      if (r - i) % 2 == 0:
        RL[r] += 1
      else:
        RL[r + 1] += 1
    elif S[i] == "L":
      n = bisect.bisect(ID,i)
      l = ID[n - 1]

      if (i - l) % 2 == 0:
        RL[l] += 1
      else:
        RL[l - 1] += 1

print(*RL)

Measured memory_bytes: 11128
#include<bits/stdc++.h>
using namespace std;
string s,ans="";
int main()
{
	cin>>s;
	for(int i=0;i<(int)s.size();i++)
	{
		if(s[i]=='B')
		{
			if(ans.size())
				ans=ans.substr(0,ans.size()-1);
		}
		else
			ans+=s[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define puba push_back
#define pufro push_front
#define poba pop_back
#define pofro pop_front

using namespace std;
typedef long long ll;
const ll M=1e9+7;
const double PI=acos(-1);
const double EPS=1e-12;
const ll arrSize=2000005;
ll arr[arrSize];
int main(){
	int tc=1,kasus=1;
	//scanf("%d",&tc);
	while(tc--){
		int n;
		scanf("%d",&n);
		string str,prev;
		bool flag=true;
		map<string,bool>mapp;
		cin>>prev;
		n--;
		mapp[prev]=1;
		while(n--){
			cin>>str;
			if(mapp[str]==1 || str[0]!=prev[(int)prev.size()-1]){
				flag=false;
			}
			mapp[str]=1;
			prev=str;
		}
		
		if(flag){
			printf("Yes\n");
		}
		
		else{
			printf("No\n");
		}
		
	}
}


Measured memory_bytes: 256
import java.io.*;
import java.lang.*;
import java.util.*;
public class Main{  
    public static void main(String[] args) throws IOException{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String str[]=br.readLine().split(" ");
        int N=Integer.parseInt(str[0]);
        int M=Integer.parseInt(str[1]);
        int[] arr=new int[M];
        int sum=0;
        StringTokenizer st=new StringTokenizer(br.readLine()," ");
        for(int i=0;i<M;i++) {
            arr[i]=Integer.parseInt(st.nextToken());
            sum+=arr[i];
        }
        N-=sum;
        if(N<0) N=-1;
        System.out.println(N);
    }
}


Measured memory_bytes: 33960
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	cin >> a >> b;
	if (a <= 5) {
		cout << 0;
	} else if (a <= 12) {
		cout << b / 2;
	} else cout << b;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int n,startend[10][10];
long long ans;
int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++){
    int j=i;
    while(j>=10){
      j/=10;
    }
    startend[j][i%10]++;
  }
  for(int i=0;i<10;i++)for(int j=0;j<10;j++){
    ans+=startend[i][j]*startend[j][i];
  }
  printf("%d",ans);
  return 0;
}

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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false);
    long long ans=0;
    long a,b,c;
    cin>>a>>b>>c;
    
    while(a%2==0 && b%2==0 && c%2==0){
        if(a==b && b==c && c==a && a%2!=1 && b%2!=1 && c%2!=1){
            ans=-1;
            break;
        }
        long x,y,z;
        x=(b+c)/2;
        y=(a+c)/2;
        z=(a+b)/2;
        a=x;
        b=y;
        c=z;
        ans+=1;
    }
    cout<<ans;
    return 0;
}

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

using namespace std;
using ll = long long;


//constructor : SegTree(vector<T> arr, int def)
const ll INF = 1e17;
template<class T>
class SegTree{
    public:
        ll n;
        T g;
        vector<T> data;
 
        SegTree(vector<T> a, T _g){
            g = _g;
            for (n = 1; n < (T)a.size(); n *= 2);
            data.resize(n * 2, g);
        }
 
        T rec(int l, int r, int node, int node_l, int node_r, T val) {
            if (node_r <= l || node_l >= r) return g;
            if (node_l >= l && node_r <= r) return data[node] = min(data[node], val);
            ll mid = (node_l + node_r) / 2;
            return min( rec(l, r, node * 2, node_l, mid, val), rec(l, r, node * 2 + 1, mid, node_r,val));
        }
 
        void query(int l,int r, T val){
            rec(l,r,1,0,n,val);
        }
 
        T get(ll index){
            T res = data[index += n];
            for(;index /= 2;)
                res = min(res, data[index]);
            return res;
        }
};



int main()
{
    int n, m; cin >> n >> m;
    vector<tuple<int,int,ll>> q(m);
    for(int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        q[i] = tie(a, b, c);
    }

    sort(q.begin(), q.end());
    SegTree<ll> tree(vector<ll>(n, INF), INF);
    tree.query(0, 1, 0);

    for(int i = 0; i < m; i++) {
        ll a, b, c;tie(a, b, c) = q[i];
        tree.query(a + 1, b + 1, tree.get(a) + c);
    }
    cout << (tree.get(n - 1) == INF ? -1 : tree.get(n - 1))<< endl; 
}

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

num = list(map(int,input().split()))
num.sort()
dif1 = num[2] - num[1]
dif2 = num[2] - num[0]

if (dif2 - dif1) % 2 == 0:
    ans = dif1 + (dif2-dif1)//2
else:
    ans = dif1 + (dif2-dif1+1)//2 + 1

print(ans)


Measured memory_bytes: 61888
N, Y = map(int, input().split())

i_t = j_t = k_t = -1
for i in range(N+1):
    for j in range(N+1-i):
        k = N - i - j
        if 10000*i+5000*j+1000*k == Y:
            i_t = i
            j_t = j
            k_t = k
print(str(i_t), str(j_t), str(k_t))

Measured memory_bytes: 3060
k = int(input())

ans = [i for i in range(50)]
cnt = k//50

for i in range(50):
  ans[i]+=cnt

amari = k%50
for i in range(50)[::-1]:
  if amari ==0:
    break
  ans[i]+=1
  amari -= 1
print(50)
print(str(ans).replace("[","").replace("]","").replace(",",""))

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

int main(){
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (s == u) a--;
    if (t == u) b--;
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256