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

using namespace std;

void Main() {
    int X;
    cin >> X;

    int last2digits = X % 100;
    for (int x1 = 0; x1 < 100; ++x1) {
        for (int x2 = 0; x2 < 50; ++x2) {
            for (int x3 = 0; x3 < 34; ++x3) {
                for (int x4 = 0; x4 < 25; ++x4) {
                    for (int x5 = 0; x5 < 20; ++x5) {
                        int s = 101 * x1 + 102 * x2 + 103 * x3 + 104 * x4 + 105 * x5;
                        if ((X - s) % 100 == 0 && s <= X) {
                            cout << 1 << endl;
                            return;
                        }
                    }
                }
            }
        }
    }
    cout << 0 << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include <string>
#include <cstring>
#include<climits>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;
ll mod = 998244353;
ll d[200001];
ll e[200001];
ll go(ll x, ll y) {
	if (y == 0)return 1;
	else if (y == 1)return x;
	else if (y & 1) {
		return x * go(x, y - 1) % mod;
	}
	else {
		ll tmp = go(x, y / 2);
		return tmp * tmp % mod;
	}
}
ll go2(ll x, ll y) {
	ll cnt = d[x];
	ll tmp = d[x - y] * d[y] % mod;
	tmp = go(tmp, mod - 2);
	cnt *= tmp; cnt %= mod;
	return cnt;
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0); cout.tie(NULL);
	d[0] = 1;
	d[1] = 1;
	for (ll i = 2; i <= 200000; i++) {
		d[i] = d[i - 1] * i; d[i] %= mod;
	}
	ll n, m, k; cin >> n >> m >> k;
	if (m == 1) {
		if (k == n - 1) {
			cout << 1 << '\n';
		}
		else cout << 0 << '\n';
		return 0;
	}
	e[0] = 1;
	e[1] = m - 1;
	for (int i = 2; i <= 200000; i++) {
		e[i] = e[i - 1] * (ll)(m - 1); e[i] %= mod;
	}
	ll ans = 0;
	if (n - 1 <= k) {
		ans = m;
	}
	for (ll i = 1; i <= n - 1; i++) {
		if (n - i - 1 <= k) {
			ll tmp = m * e[i]; tmp %= mod;
			tmp *= go2(n - 1, i); tmp %= mod;
			ans += tmp; ans %= mod;
		}
	}
	cout << ans << '\n';

}

Measured memory_bytes: 6708
// AOJ 0596: Taxis
// 2018.1.26 bal4u

#include <stdio.h>
#include <string.h>

#define QMAX 25000
typedef struct { int t, s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x33333333

int q [5010]; int top, end, end2;
int r[5001], c[5001]; char f[5001];
int to [5001][5001], hi [5001];
int to2[5001][5001], hi2[5001];
int cost[5001];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int start, int goal)
{
	int i, s, d, d2, e;

	memset(cost, INF, sizeof(cost));
	qsize = 0;
	cost[start] = 0;
	enq(start, 0);
	while (qsize) {
		s = que[0].s, d = que[0].t, deq();
		if (s == goal) break;
		for (i = 0; i < hi2[s]; i++) {
			e = to2[s][i];
			d2 = d + c[s];
			if (d2 < cost[e]) cost[e] = d2, enq(e, d2);
		}
	}
	return d;
}

int main()
{
	int n, k, a, b, i, j;

	n = in(), k = in();
	for (i = 0; i < n; i++) c[i] = in(), r[i] = in();
	for (i = 0; i < k; i++) {
		a = in()-1, b = in()-1;
		to[a][hi[a]++] = b;
		to[b][hi[b]++] = a;
	}

	for (i = 0; i < n; i++) {
		q[0] = i, top = 0, end = end2 = 1;
		j = r[i]; while (j--) {
			while (top < end) {
				a = q[top++];
				for (k = 0; k < hi[a]; k++) {
					b = to[a][k];
					if (!f[b]) f[b] = 1, q[end2++] = b;
				}
			}
			end = end2;
		}
		for (j = 0; j < n; j++) {
			if (i != j && f[j])	to2[i][hi2[i]++] = j;
		}
		memset(f, 0, n);
	}
	printf("%d\n", dijkstra(0, n-1));
	return 0;
}



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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  if ((r*100 + g*10 + b) %4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#if __cplusplus >= 201103L
#pragma comment(linker, "/STACK:64000000")
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <cctype>
#include <numeric>
#if __cplusplus >= 201103L
#include <cwchar>
#include <cwctype>
#include <array>
#include <forward_list>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
const int MAXN=200005;
int n,a[MAXN]; 
deque<int> v;
int main(){
	cin>>n;
	for(int i=0;i<n;++i) {
		cin>>a[i];
		if(i%2==0) v.push_front(a[i]);
		else v.push_back(a[i]);
	}
	if(n%2==0) reverse(v.begin(),v.end());
	for(int i=0;i<n;++i) cout<<v[i]<<" ";
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3840
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    ll N;
    string S;
    cin>>N;
    cin>>S;
    ll numR=0;
    rep(i,0,N){
        if(S[i] == 'R')numR++;
    }
    ll ans = 0;
    rep(i,0,numR){
        if(S[i] == 'W')ans++;
    }
    cout<<ans;
    return 0;
}

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

const int dx[] = { -1,0,1,0 };
const int dy[] = { 0,-1,0,1 };
int H, W;
int f(int n, int m,vector<string> S) {
	vector<vector<int>> data(20, vector<int>(20)); 
	queue<pair<int, int>> q;
	q.emplace(n, m); 
	S[n][m] = '#';
	int ans = 0;
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		//範囲内かつ0を4セット
		for (int l = 0; l < 4; ++l) {
			int x1 = x + dx[l];
			int y1 = y + dy[l]; 
			if ((0 <= x1) && (H > x1) && (0 <= y1) && (W > y1) && ('.' == S[x1][y1])) {
				S[x1][y1] = '#';
				data[x1][y1] = data[x][y] + 1;
				ans = max(ans, data[x][y] + 1);
				q.emplace(x1, y1);
			}
		}
	}
	return ans;
}

int main() {
	cin >> H >> W;
	vector<string> S(H);
	for (int n = 0; n < H; ++n) {
		cin >> S[n];
	}
	int ans = 0;
	for (int n = 0;n< H ;++n) {
		for (int m = 0;m<W;++m) {
			if ('#' != S[n][m]) {
				ans = max(ans, f(n,m, S));
			}
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3640
<?php
fscanf(STDIN, '%d', $N);
$line = trim(fgets(STDIN));
$arr = explode(' ', $line);

$bubbleArr = BubbleSort($arr,$N);
echo(implode(' ',$bubbleArr).PHP_EOL."Stable".PHP_EOL);
$selectionArr = SelectionSort($arr,$N);
echo implode(" ",$selectionArr) . PHP_EOL;
isStable($bubbleArr, $selectionArr);

function BubbleSort($arr,$N)
{
    for ($i = 0; $i<$N; ++$i) {
        for ($j = $N-1; $j>$i; --$j) {
            if ($arr[$j][1] < $arr[$j-1][1]) {
                $tmp = $arr[$j];
                $arr[$j] = $arr[$j - 1];
                $arr[$j - 1] = $tmp;
            }
        }
    }

    return $arr;
}

function SelectionSort($arr, $N){
    for ($i=0; $i<$N; ++$i){
        $mini = $i;
        for ($j=$i; $j<$N; ++$j){
            if ($arr[$j][1] < $arr[$mini][1]){
                $mini = $j;
            }
        }
        if($mini!=$i){
            $tmp = $arr[$i];
            $arr[$i] = $arr[$mini];
            $arr[$mini] = $tmp;
        }
    }
    return $arr;
}

function isStable($bubbleArr, $selectionArr){
    $result = array_diff_assoc($bubbleArr, $selectionArr);
    if(count($result)==0){
        echo("Stable".PHP_EOL);
    } else {
        echo("Not stable".PHP_EOL);
    }
}


Measured memory_bytes: 9300
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),n.end()
#define PI acos(-1)
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n||m){
    int a[n];
    int b[m];
    rep(i,n){
      int tmp;
      cin>>tmp;
      a[i]=tmp;
    }
    rep(i,m){
      int tmp;
      cin>>tmp;
      b[i]=tmp;
    }
    int co=0;
    int num=0;
    for(int i=0;num<n-1;i++){num+=b[i];num+=a[num];co++;}
    cout<<co<<endl;
  }
}

Measured memory_bytes: 1168
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int r; cin >> r;

	cout << 3 * r*r << endl;

	return 0;
}

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

int main(){
    int n;
    while(cin >> n, n){
        n++;
        int h[n];
        for(int i = 0; i < n; i++)  cin >> h[i];
        
        for(int i = 0; i < n; i++){
            vector<int> now;
            int j;
            for(j = 0; j < n; j++)  if(i != j)  now.push_back(h[j]);
            
            int diff = now[1] - now[0];
            for(j = 2; j < n-1; j++){
                if(now[j]-now[j-1] != diff) break;
            }
            
            if(j == n-1){
                cout << h[i] << endl;
                break;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3116
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sat Jan 19 09:21:18 2019
//
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

type intHeap []int

func (h intHeap) sum() int {
	s := 0
	for i := range h {
		s += h[i]
	}
	return s
}

func (h intHeap) Len() int {
	return len(h)
}

func (h intHeap) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}

func (h intHeap) Less(i, j int) bool {
	return h[i] < h[j]
}

func (h *intHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *intHeap) Pop() interface{} {
	old, n := *h, len(*h)
	v := old[n-1]
	*h = (*h)[:n-1]
	return v
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()

	arr := make([]int, 3*N)
	for i := range arr {
		arr[i] = nextInt()
	}

	leftHeap := make(intHeap, N)
	copy(leftHeap, arr[:N])

	sumLefts := make([]int, N+1)
	heap.Init(&leftHeap)
	for k := N - 1; k < 2*N; k++ {
		if k == N-1 {
			sumLefts[0] = leftHeap.sum()
			continue
		}
		heap.Push(&leftHeap, arr[k])
		n := heap.Pop(&leftHeap).(int)
		sumLefts[k-N+1] = sumLefts[k-N] + arr[k] - n
	}

	rightHeap := make(intHeap, N)
	for i := range rightHeap {
		rightHeap[i] = -arr[2*N+i]
	}

	sumRights := make([]int, N+1)
	heap.Init(&rightHeap)
	for k := 2 * N; k >= N; k-- {
		if k == 2*N {
			sumRights[len(sumRights)-1] = -rightHeap.sum()
			continue
		}
		heap.Push(&rightHeap, -arr[k])
		n := -heap.Pop(&rightHeap).(int)
		sumRights[k-N] = sumRights[k-N+1] + arr[k] - n
	}

	max := -1 << 60
	for i := range sumRights {
		d := sumLefts[i] - sumRights[i]
		if max < d {
			max = d
		}
	}

	fmt.Println(max)
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if (n & 1) cout << "No\n";
  else {
    bool repeated = true;
    int i = 0;
    int j = n / 2;
    while (i < n / 2) {
      if (s[i] != s[j]) { repeated = false; break; }
      ++i;
      ++j;
    }
    if (repeated) cout << "Yes\n";
    else cout << "No\n";
  }
  return 0;
}

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

int main(){
   int N;
   cin >> N;
   vector<int> A(N);
   for (int i=0; i<N; i++)
      cin >> A.at(i);

   bool flag = true;
   for (int x : A)
      if (x%2 == 0)
         if (!(x%3 == 0 || x%5 == 0))
            flag = false;

   if (flag)
      cout << "APPROVED" << endl;
   else
      cout << "DENIED" << endl;
}



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

struct S{
    double l, r, m, p;
    int c;
};
int k;
double r, l, p, e, t;    
const double EPS = 1e-10;

bool cross(double al, double ar){
    double left = t - e;
    double right = t + e;
    if(ar < left || right < al) return false;
    return true;
}
bool inside(double al, double ar){
    double left = t - e;
    double right = t + e;
    if(left - EPS <= al && ar - EPS <= right) return true;
    return false;
}

signed main(){
    cin >> k >> l >> r >> p >> e >> t;
    S init = {l, r, (l + r) / 2.0, 1.0, 0};
    queue<S> q;
    q.push(init);
    double ans = 0.0;
    while(!q.empty()){
        S s = q.front(); q.pop();
        // cout << s.l << ' ' << s.r << ' ' << s.m << ' ' << s.p << ' ' << s.c << endl;
        if(cross(s.l, s.r) == false) continue;
        if((s.c == k && inside(s.m, s.m)) || inside(s.l, s.r)){
            ans += s.p;
            // cout << "o" << endl;
            continue;
        }
        if(s.c == k) continue;
        S left, right;
        left.l = s.l;
        left.r = s.m;
        left.m = (left.l + left.r) / 2.0;
        left.p = s.p * p;
        if(s.m > t) left.p = s.p * (1.0 - p);
        left.c = s.c + 1;
        right.l = s.m;
        right.r = s.r;
        right.m = (right.l + right.r) / 2.0;
        right.p = s.p * (1.0 - p);
        if(s.m > t) right.p = s.p * p;
        right.c = s.c + 1;
        q.push(left);
        q.push(right);
    }
    printf("%.10f\n", ans);
}


Measured memory_bytes: 3308
N,X = map(int,input().split())
Data = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    a1 = Data[i]
    a2 = Data[i+1]

    diff = a1+a2-X
    if diff > 0:
        ans += diff
        if a2 >= diff:
            Data[i+1] -= diff
        else:
            Data[i+1] = 0
            Data[i] -= (a2-diff)
print(ans)

Measured memory_bytes: 14540
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    string S, T;
    cin >> S >> T;

    int ret = INF;
    int diff = S.size() - T.size();
    for (int d = 0; d <= diff; d++) {
        int cnt = 0;
        for (int i = 0; i < T.size(); i++) {
            if (S[i+d] != T[i]) cnt++;
        }
        ret = min(ret, cnt);
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const ll INF = 1ll << 60;
const double EPS = 1e-8;
const int MOD = 1000000007;

int T, n, m;
ll C;

ll solve(const vector<pll> &v) {
    map<ll, ll> memo;
    ll sum = 0;
    ll ans = 0;
    memo[0] = 0;
    for(auto it : v) {
        ll x, w; tie(x, w) = it;
        sum += w;
        if(memo.rbegin()->second < sum - x) {
            memo[x] = sum - x;
        }
        ans = max(ans, sum - x);
    }
    sum = 0;
    RREP(i, v.size()) {
        ll x, w; tie(x, w) = v[i];
        ll xx = C - x;
        sum += w;
        ans = max(ans, sum - xx);
        ll t = prev(memo.lower_bound(x))->second;
        ans = max(ans, sum - 2 * xx + t);
    }
    return ans;
}

int main(int argc, char *argv[]) {
    ios::sync_with_stdio(false);
    cin >> n >> C;
    vector<pll> v;
    REP(i, n) {
        ll x, y;
        cin >> x >> y;
        v.emplace_back(x, y);
    }
    ll ans = solve(v);
    for(pll &it : v) {
        it.first = C - it.first;
    }
    sort(ALL(v));
    ans = max(ans, solve(v));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8048
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;

function main(input) {
  var o = new I(input);

  var n = o.a();

  var m = Math.sqrt(n);

  var half = [];
  for (var i = 1; i <= m; i++) {
    if (n % i === 0) {
      half.push(i);
    }
  }

  var div = [];
  half.forEach(x => {
    div.push(x);
    if (x !== n / x) div.push(n / x);
  });
  div.sort((a,b) => a - b);

  var sum = 0;
  div.forEach(a => {
    var x = n / a - 1;
    if ( x > a ) {
      sum += x;
    }
  });

  console.log(sum);
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9404
n=gets.to_i
maxExponentiation=1
(2..n).each do |number|
  count=2
  loop do
    tempExponentiation = number ** count
    break tempExponentiation if tempExponentiation > n
    maxExponentiation = tempExponentiation if tempExponentiation > maxExponentiation  
    count += 1
  end
end
puts maxExponentiation

Measured memory_bytes: 1788
n, t = map(int, input().split())
span = list(map(int, input().split()))
sum_t = 0
for i in range(n-1):
    if span[i+1] - span[i] >= t:
        sum_t += t
    else:
        sum_t += span[i+1] - span[i]
sum_t += t
print(sum_t)

Measured memory_bytes: 26832
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c,s,t;
    scanf("%d%d%d",&a,&b,&c);
    t=max(a,b);
    t=max(t,c);
    s=t*3-a-b-c;
    if(s%2==0)
        printf("%d\n",s/2);
    else
        printf("%d\n",(s+3)/2);
    return 0;
}

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

typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int h,w,n;

bool finish(vs const& g){
    rep(i,h)rep(j,w)if(g[i][j]!='.')return false;
    return true;
}

int erase(vs &g){
    vvb exist(h,vb(w));
    rep(i,h)rep(j,w)exist[i][j]=g[i][j]!='.';
    rep(i,h)rep(j,w){
        int ni;
        for(ni=i; ni<h && g[i][j]==g[ni][j]; ni++);
        if(ni-i >= n){
            for(int ii=i;ii<ni;ii++)exist[ii][j]=false;
        }
        int nj;
        for(nj=j; nj<w && g[i][j]==g[i][nj]; nj++);
        if(nj-j >= n){
            for(int jj=j;jj<nj;jj++)exist[i][jj]=false;
        }
    }

    int res=0;
    rep(i,h)rep(j,w){
        if(!exist[i][j] && g[i][j]!='.'){
            g[i][j]='.';
            res++;
        }
    }
    return res;
}

void drop(vs &g){
    rep(j,w){
        int top=h-1;
        for(int i=h-1;i>=0;i--){
            if(g[i][j]!='.'){
                g[top--][j] = g[i][j];
            }
        }
        while(top>=0)g[top--][j]='.';
    }
}

void view(vs g){
    // rep(i,g.size())cout<<g[i]<<endl;
}

bool solve(vs const& g){
    rep(i,h){
        rep(j,w-1){
            vs ng=g;
            swap(ng[i][j],ng[i][j+1]);
            view(ng);
            drop(ng);
            while(erase(ng))drop(ng);
            view(ng);
            if(finish(ng))return true;
        }
    }
    return false;
}

int main(){
    cin>>h>>w>>n;
    vs g(h);
    rep(i,h)cin>>g[i];
    puts(solve(g) ? "YES" : "NO");
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0);
using namespace std;

const long long INF = 1e6;
const long long N = 1e3 + 7;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;

ll T = 1, n, m, b, ans, y, x, c, a, used[INF], u[1001], cnt, mn = 1e18;
string s;
vector < ll > v, v1;
set< ll > st;
int main(){
    TIME
    cin >> n >> m >> x;
    cout << max( 0ll, x - abs( n - m ) );
}


Measured memory_bytes: 256
N=int(input())
s=input()

sa=s[:N]
sb=s[N:]

import itertools
ALLIST=itertools.product((0,1),repeat=N)

from collections import defaultdict
STRA = defaultdict(int)
STRB = defaultdict(int)

for i in ALLIST:
    red_a=""
    blue_a=""
    red_b=""
    blue_b=""
    for j in range(N):
        if i[j]==0:
            red_a+=sa[j]
            red_b+=sb[j]
        else:
            blue_a+=sa[j]
            blue_b+=sb[j]

    STRA[(red_a[::-1],blue_a[::-1])]+=1
    STRB[(red_b,blue_b)]+=1

ANS=0
for key in STRA:
    ANS+=STRA[key]*STRB[key]

print(ANS)

Measured memory_bytes: 150656
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

typedef struct idexedval{
  int a;
  int index;
} node;

int cmp(const node *a,const node *b){
  return a->a<=b->a;
}

node *seg=NULL;
int size=0;
const int inf=1000000000;
void rmq_init(int *array,int n){
  int t=1;
  while(t<n) t*=2;
  seg=(node *)malloc(sizeof(node)*2*t);
  size=t;
  int i;
  for(i=0;i<n;i++){
    seg[i+size].a=array[i];
    seg[i+size].index=i;
  }
  for(;i<size;i++) seg[i+size].a=inf;
  for(i=size-1;i>=1;i--) seg[i]=cmp(seg+2*i,seg+2*i+1)?seg[2*i]:seg[2*i+1];
  return;
}

//[l,r)
void calc(int l,int r,node *res){
  for(l+=size,r+=size;l<r;l>>=1,r>>=1){
    if(r&0x01){
      --r;
      *res=cmp(res,seg+r)?*res:seg[r];
    }
    if(l&0x01){
      *res=cmp(res,seg+l)?*res:seg[l];
      l++;
    }
  }
  return;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *array=(int *)malloc(sizeof(int)*n);
  int i;
  for(i=0;i<n;i++) scanf("%d",array+i);
  rmq_init(array,n);
  int64 sum=0;
  int *sl=(int *)malloc(sizeof(int)*n);
  int *sr=(int *)malloc(sizeof(int)*n);
  sl[0]=0;
  sr[0]=n;
  int top=1;
  while(top>0){
    top--;
    int l=sl[top];
    int r=sr[top];
    if(l>=r) continue;
    node t;
    t.a=inf;
    calc(l,r,&t);
    int min=t.a;
    int m=t.index;
    sum+=(int64)min*(m+1-l)*(r-m);
    sl[top]=l;sr[top]=m;top++;
    sl[top]=m+1;sr[top]=r;top++;
  }
  printf("%lld\n",sum);
  return;
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 6656
#include <iostream>
#include <cmath>

using namespace std;

unsigned GetDigit(int num){
   return log10(num)+1;
}

int main()
{
   int N;
   cin >> N;
   int digit;
   digit = GetDigit(N);


   int answer = 0;
   int i=0;
   if(digit%2==0){
      for(int i=0;i<digit;i+=2){
         answer += pow(10,i+1) - pow(10,i);
      }
   } else {
      for(int i=0;i<digit-1;i+=2){
         answer += pow(10,i+1) - pow(10,i);
      }
      answer += N - pow(10,digit-1)+1;
   }

   cout << answer << endl;

   return 0;

}


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

#define rep(i,a,b) for(auto (i)=a;i<b;i++)
#define list(i,N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
#define mp make_pair
#define pb push_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

int32_t main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int K, X; cin >> K >> X;
	if(500*K >= X) cout << "Yes\n";
	else cout << "No\n";



	return 0;
}


Measured memory_bytes: 256
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define sz size()
#define mk make_pair
#define clr clear()
#define B begin()
#define E end()
#define EM empty()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define all(cont) cont.begin(),cont.end()
#define pb push_back
string en="\n";
string t="hello";
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
     while(cin>>n)
     {
         vi a,b;
         m=n-1;
         a.pb(0);
         rep(i,m)
         {
             vp(a,x);
         }
         s=0;
         rep(i,m)
         {
             if(i==0) s+=a[1];
             else    s+=min(a[i],a[i+1]);
         }
         s+=a[m];
         if(n==2)
         {
             s=2*a[1];
         }
         cout<<s<<en;
     }
}



Measured memory_bytes: 256
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll n; cin >> n;
  set<string> S;
  loop(i,0,n) {
    string s;
    cin >> s;
    S.insert(s);
  }
  cout << S.size() << endl;
  return 0;
}


Measured memory_bytes: 19092
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    while a[-2] > 0:
        x = 0
        for i in range(n):
            if x==0:
                x = a[i]
            else:
                a[i] %= x
        a.sort()
    print(a[-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 14636
#include<bits/stdc++.h>
using namespace std;
vector<int> *dp,arr;
int n;

void initialize(int n)
{
  ::n=n;
  dp=new vector<int>[n];
  for(int i=0;i<n;i++)dp[i].resize(2,INT_MAX);
  arr.resize(n);
}

int minimum_cost(int i)
{
  if(i+1>=n)return 0;
  if(i+1<n and dp[i][0]==INT_MAX)
  {
    dp[i][0]=abs(arr[i]-arr[i+1])+minimum_cost(i+1);
  }
  if(i+2<n and dp[i][1]==INT_MAX)
  {
    dp[i][1]=abs(arr[i]-arr[i+2])+minimum_cost(i+2);
  }
  return min(dp[i][0],dp[i][1]);
}

int main()
{
  int n;
  cin>>n;
  initialize(n);
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  cout<<minimum_cost(0);
}


Measured memory_bytes: 10752
import java.util.ArrayList;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		@SuppressWarnings("unchecked") ArrayList<Integer>[] jobs = new ArrayList[m + 1]; // 遅延日数ごとに仕事をグルーピングする
		for ( int i = 0; i <= m; i++ ) {
			ArrayList<Integer> a = new ArrayList<>();
			a.add(0); // ダミー要素
			jobs[i] = a;
		}

		for ( int i = 0; i < n; i++ ) {
			int d = in.nextInt();
			int f = in.nextInt();
			if ( d > m ) continue; // 遅延日数的に候補になりえない仕事は除外
			jobs[d].add(f);
		}

		long total = 0;
		PriorityQueue<Integer> pool = new PriorityQueue<Integer>(Collections.reverseOrder()); // job候補のプール
		pool.add(0); // ダミー

		// m日目をゼロとして考え後退していく days:残り日数
		for ( int today = 0; today <= m; today++ ) {
			pool.addAll(jobs[today]);
			// int daypay = pool.poll();
			total += (long)pool.poll();
		}

		System.out.println(total);
		in.close();
	}
}


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

int main()
{
  string s,t;
  cin >> s >> t;
  int count = 0;
  for(int i = 0; i< s.length();++i){
    if(s[i]!=t[i]) count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3836
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<iostream>
#define ll long long
using namespace std;
#define max(a,b)    (a)>(b)?(a):(b)
#define min(a,b)    (a)<(b)?(a):(b)
#define s(i)        scanf("%d",&(i))
#define ss(i)       scanf("%s",(i))
#define p(i)        printf("%d",i)
#define ps(i)       printf("%s",(i))
#define pc(i)       printf("%c",(i))
#define end         printf("\n")
#define f(i,n)      for(i=1;i<=n;i++)
#define w(i)        while(i--)
#define m(vis)      memset(vis,0,sizeof vis);
int a[200001];
int b[200001];
int main()
{
	int i,n,j;
	scanf("%d",&n);
	f(i,n)
	{
		scanf("%d",&a[i]);
	}
	int m=1;
	sort(a+1,a+1+n);
	int x;
	if(a[n]%2==1)
	{
		x=a[n]/2;
		for(i=2;i<=n-1;i++)
		{
			if(abs(a[i]-x)<abs(a[m]-x)||abs(a[i]-(x+1))<abs(a[m]-(x+1))) 
				m=i;
		}
	} 
	else
	{ 
		x=a[n]/2;
		for(i=2;i<=n-1;i++)
		{
			if(abs(a[i]-x)<abs(a[m]-x))
				m=i;
		}
	} 
	p(a[n]);ps(" ");p(a[m]);end;
    return 0;
}

Measured memory_bytes: 640
n, x, y = map(int, input().split())
ans = [0] * (n - 1)
for i in range(n - 1):
  for j in range(i + 1, n):
    idx = min(j - i, abs(x - i - 1) + 1 + abs(y - j - 1))
    ans[idx-1] += 1
for i in range(n - 1):
  print(ans[i])

Measured memory_bytes: 3444
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  LL N, A, B; std::cin >> N >> A >> B;
  if ((B-A) % 2 == 0) {
    std::cout << (B-A)/2 << std::endl;
    return 0;
  }

  LL cost1 = (B-1LL-A)/2LL + A;
  LL cost2 = (B-1LL-A)/2LL + N - B + 1LL;
  std::cout << std::min(cost1, cost2) << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define f(i,a,n) for(i=a;i<n;i++)
#define rf(i,a,n) for(i=a;i>=n;i--)
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vi vector<int>
#define vll vector<long long>
#define umii unordered_map<int,int>
#define umci unordered_map<char,int>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define all(v) begin(v),end(v)
#define mkp make_pair
#define M 1000000007
#define TakeInput freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);


using namespace std;
int main()
{
	#ifndef ONLINE_JUDGE
	//TakeInput
	#endif
	fast;
	int n,m;
	cin >> n >> m;
	if (n == m)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;

int main(){
    int x,y;
    while(1){
        cin >> x >> y;
        if(x==0 && y==0) break;
        if(x<y) cout << x << ' ' << y << endl;
        else cout << y << ' ' << x << endl;
    }
	}



Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int N = 1000001;

main(){
  int n, a, b;
  while(true){
    cin >> n >> a >> b;
    if( n==0 && a==0 && b==0) break;
    vector<int> A, B;
    int cnt = n;
    bool used[N];
    fill(used, used+n+1, false);
    used[0] = true;
    for(int i=0;i<n;i++){
      if(used[i]){
	int next = i + a;
	if(next <= n){
	  if(!used[next]) cnt--;
	  used[next] = true;
	}
	next = i + b;
	if(next <= n){
	  if(!used[next]) cnt--;
	  used[next] = true;
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  char a[n][n];
  char b[m][m];
  for (int i=0;i<n;i++){
    for (int j=0;j<n;j++){
      cin >> a[i][j];
    }
  }
  for (int i=0;i<m;i++){
    for (int j=0;j<m;j++){
      cin >> b[i][j];
    }
  }
  int chk;
  for (int i=0;i<n-m+1;i++){
    for (int j=0;j<n-m+1;j++){
      chk=0;
      for (int k=0;k<m;k++){
        for (int l=0;l<m;l++){
          if (a[i+k][j+l] != b[k][l])chk++;
        }
      }
      if (chk == 0){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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


#define FOR(i,n) for(int i=0;i<n;i++)
#define SORT(v,n) sort(v[0],v[n-1])
#define INF 999999999

using namespace std;

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

	int leng=S.size();
	int x=0;
	int max=x;
	FOR(i,leng){
		if(S.at(i)=='I'){
			x++;
		}else{
			x--;
		}
		if(max<x){
			max=x;
		}
	}
	cout << max << endl;

}


Measured memory_bytes: 256
import math
money, = list(map(int,input().split()))

max_number = math.ceil(money/4 + 1)

ans = 'No'

for i in range(max_number):
    for j in range(max_number):
        if  money == i*4 + 7*j:
            ans = 'Yes'
            
print(ans)

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

using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    int v[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>v[i][j];
        }
    }
    int fa=0,fb=0,a[2]={v[1][0]-v[0][0],v[1][0]-v[2][0]},b[2]={v[0][1]-v[0][0],v[0][1]-v[0][2]};
    for(int j=1;j<3;j++){
        int tmp0=v[1][j]-v[0][j],tmp1=v[1][j]-v[2][j];
        if(tmp0==a[0] && tmp1==a[1]){
            a[0]=tmp0;a[1]=tmp1;
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    for(int j=1;j<3;j++){
        int tmp0=v[j][1]-v[j][0],tmp1=v[j][1]-v[j][2];
        if(tmp0==b[0] && tmp1==b[1]){
            b[0]=tmp0;b[1]=tmp1;
        }else{
            cout<<"No"<<endl;
            return 0;
        }
    }
     
    cout<<"Yes"<<endl;
    
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int k;
    cin >> k;
    vector<string> sub;
    for(int i=0;i<s.size();i++){
        int max = min(k,((int)s.size()-i));
        for(int j=1;j<=max ;j++){
            sub.push_back(s.substr(i,j));
        }
    }
    sort(sub.begin(),sub.end());
    sub.erase(unique(sub.begin(),sub.end()),sub.end());
    cout << sub[k-1] << endl;
    return 0;
}

Measured memory_bytes: 1660
#include<stdio.h>

int main( void ){
   int i , temp ;
   int dice[ 7 ] ;
   char command[ 105 ] ;
   for( i=1 ; i<7 ; i++){
      scanf( "%d" , &dice[i] ) ;
   }
   scanf( "%s" , command ) ;

   i = 0;
   while( command[ i ]!='\0' ){
      if( command[ i ] == 'N' ){
         temp    = dice[1] ;
         dice[1] = dice[2] ;
         dice[2] = dice[6] ;
         dice[6] = dice[5] ;
         dice[5] = temp ; }
      else if( command[ i ] == 'E' ){
         temp    = dice[1] ;
         dice[1] = dice[4] ;
         dice[4] = dice[6] ;
         dice[6] = dice[3] ;
         dice[3] = temp ; }
      else if( command[ i ] == 'W' ){
         temp    = dice[1] ;
         dice[1] = dice[3] ;
         dice[3] = dice[6] ;
         dice[6] = dice[4] ;
         dice[4] = temp ; }
      else if( command[ i ] == 'S' ){
         temp    = dice[1] ;
         dice[1] = dice[5] ;
         dice[5] = dice[6] ;
         dice[6] = dice[2] ;
         dice[2] = temp ; }
      i++;
   }
   printf( "%d\n", dice[1] );
   return 0;
}



Measured memory_bytes: 2104
stack = Array.new(1000)
top = 0

s = gets.split
for x in s do
  if x == "+"
    stack[top - 1] = stack[top - 1] + stack[top]
    top -= 1
  elsif x == "-"
    stack[top - 1] = stack[top - 1] - stack[top]
    top -= 1
  elsif x == "*"
    stack[top - 1] = stack[top - 1] * stack[top]
    top -= 1
  else
    stack[top + 1] = x.to_i
    top += 1
  end
end

puts stack[1]



Measured memory_bytes: 6876
from bisect import bisect, bisect_left
from sys import stdin

def dfs(n):
    l = [0] * n
    ret = []
    def dfs_(n):
        if not n:
            ret.append(l[:])
            return
        for i in ('a', 'b', 'c', '_'):
            l[n-1] = i
            dfs_(n-1)
    dfs_(n)
    return ret

def main():
    N, A, B, C = map(int, input().split())
    L = [int(input()) for _ in [0] * N]

    ans = float('inf')
    for s in dfs(N):
        banboo = {'a': 0, 'b': 0, 'c':0, '_': 0}
        for i, t in enumerate(s):
            banboo[t] += L[i]
        if all((banboo['a'] > 0,
                banboo['b'] > 0,
                banboo['c'] > 0)):
            mp = (s.count('a') + s.count('b') + s.count('c') - 3) * 10
            mp += (abs(banboo['a'] - A) +
                   abs(banboo['b'] - B) +
                   abs(banboo['c'] - C))
            ans = min(ans, mp)
    print(ans)

input = lambda: stdin.readline()
main()


Measured memory_bytes: 12788
#include <iostream>
#include <string>

int main(){
  int N;
  std::cin>>N;
  int a[N+1];
  for(int i=1; i<N+1; i++) std::cin>>a[i];
  int sum=0;
  for(int i=1; i<N+1; i++)
    sum+=a[i]-1;
  
  std::cout<<sum<<std::endl;
  
  return 0;
}


Measured memory_bytes: 256
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>k;
		if(n==k)
		cout<<"Yes";
		else cout<<"No";

		
		cout<<"\n";
	}
	return 0;
}

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


using namespace std;
int main()
{

int a,b,c;

cin>>a>>b>>c;

if(a>=b&&a>=c){
    a=a*10;
}
else if(b>=a&&b>=c){
    b=b*10;
}
else c=c*10;

cout<<a+b+c<<endl;



    return 0;
}

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

//+=を=+と打っても動作するが意味が違う

const int INF = 1001000000;

int main(){
  int n,d[200],res=0;
  cin >> n ;
  for(int i=0;i<n;i++){
    cin >> d[i];
  }
  sort(d,d+n);
  for(int j=1;j<n;j++){
    if(d[j]!=d[j-1]){
      res++;
    }
  }
  cout << res+1 << endl;//最初の一枚をたす
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

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

	if (N % K == 0) { cout << 0 << endl; }
	else { cout << 1 << endl; }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
template<typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac;
    Comb(){fac.resize(FAC_MAX,1);ifac.resize(FAC_MAX,1);rep(i,1,FAC_MAX)fac[i]=fac[i-1]*i;
        ifac[FAC_MAX-1]=T(1)/fac[FAC_MAX-1];rrep(i,FAC_MAX-2,1)ifac[i]=ifac[i+1]*T(i+1);}
    T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; }
    T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; }
    T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0;
        return aCb(n + k - 1, k); }}; // nHk = (n+k-1)Ck : n is separator
typedef ModInt<1000000007> mint;
//------------------------------------------------------------------------------
void _main()
{
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


char buf[2];

int main(){

	scanf("%s",buf);

	if(buf[0] != 'z'){

		printf("%c\n",'a'+(buf[0]-'a')+1);
	}else{

		printf("a\n");
	}

	return 0;
}


Measured memory_bytes: 256