akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main(){
    int A,B;cin >> A >> B;
    cout<<abs(A-B)<<endl;
}



Measured memory_bytes: 3108
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

S = list(input())
ans = 0
for i in range(1, len(S)):
    if S[i - 1] != S[i]:
        ans += 1

print (ans)

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

const long mod = 1000000007;
int x, y;

long f(long n) {
  long ret = 1;
  for (long i = 1; i <= n; ++i) {
    ret = ret * i % mod;
  }
  return ret;
}

long pow(long b, long e) {
  if (e == 0) return 1;
  if (e % 2 == 1) return pow(b, e - 1) * b % mod;
  long t = pow(b, e / 2);
  return t * t % mod;
}

long inv(long n) {
  return pow(n, mod - 2);
}

long sub(long a, long b) {
  return f(a + b) * inv(f(a) * f(b) % mod) % mod;
}

int main() {
  cin >> x >> y;
  int i = 2 * x - y;
  int j = 2 * y - x;
  if (i < 0 || j < 0 || i % 3 != 0 || j % 3 != 0) {
    cout << 0 << endl;
  } else {
    cout << sub(i / 3, j / 3) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vl p(m), y(m);
    rep(i, m) {
        cin >> p[i] >> y[i];
        p[i]--;
    }

    vvl val(n);  // val[v] : p[i] = v であるようなiについてのy[i]の値を集めたもの
    rep(i, m) {
        val[p[i]].pb(y[i]);
    }
    
    rep(v, n) {
        sort(all(val[v]));
        val[v].erase(unique(all(val[v])), val[v].end());
    }

    rep(i, m) {
        ll v = p[i];
        printf("%06d", v+1);
        ll id = lower_bound(all(val[v]), y[i]) - val[v].begin();
        printf("%06d\n", id+1);
    }
    
    re0;
}

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

int main() {
	int n,a,b;
	cin>>n>>a>>b;
	vector<long long> v(n);
	for(auto &i : v) cin>>i;
	long long ans=0;
	for(int i=1;i<n;i++){
	    if(a*(v[i]-v[i-1])>b){
	        ans+=b;
	    } else{
	        ans+=a*(v[i]-v[i-1]);
	    }
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1024
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ');
  buildMaxHeap(arr);
  console.log(arr.reduce((s, e) => s += ' ' + e, ''));
})();

function buildMaxHeap(arr) {
  const n = arr.length;
  const maxHeapify = (i) => {
    let left, right, largest = i;
    left = 2 * i + 1;
    right = 2 * i + 2;
    if (left < n && Number(arr[left]) > Number(arr[i])) largest = left;
    if (right < n && Number(arr[right]) > Number(arr[largest])) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(n / 2 - 1); i >= 0; i--) maxHeapify(i);
}



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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, a;
    map<int, int> mii;
    cin >> N;
    REP(i, N) {
        cin >> a;
        mii[a]++;
    }
    int ans = 0;
    for (auto p : mii) {
        if (p.first > p.second) ans += p.second;
        else if (p.first < p.second) ans += (p.second - p.first);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int a, b, c;
    cin >>a >>b >>c;
    bool d = false;
    if(a==b && b!=c){
        d= true;
    }else if(b==c && c!=a){
        d= true;
    }else if(c==a && a!=b){
        d= true;
    }
    if(d){
        cout << "Yes";
    } else {
        cout << "No";
    }

}


Measured memory_bytes: 256
/*
  Contest 068
  B - Break Number
  Rakesh Kumar --> 01/09/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);
    int n = 0;
    std::cin >> n;
    std::cout << (1 << static_cast<int>(std::floor(std::log2(n)))) << std::endl;

    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX (int)(pow(10,5)+ 10)




void deal(){
	string a,b;
	cin>>a>>b;
	a = "?" + a;
	b = "!" + b;
	ll n1 = a.length()-1, n2 = b.length()-1;
	vector<vector<ll> > dp(n1+1, vector<ll>(n2+1,0));
	for(ll i = 1; i<=n1; i++)
		for(ll j = 1; j<=n2; j++){
			dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			if(a[i] == b[j])
				dp[i][j] = dp[i-1][j-1] + 1;
		}
	string ans = "";
	ll id1 = n1, id2 = n2;
	while(dp[id1][id2]){
		if(a[id1] == b[id2])
			ans+=a[id1], --id1, --id2;
		else{
			if(dp[id1-1][id2] > dp[id1][id2-1])
				--id1;
			else
				--id2;
		}
	}
	reverse(ans.begin(), ans.end());
	cout<<ans;
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

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

using namespace std;

void print(const std::vector<long long>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

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

    if(S.size() < 3) {
        cout << 0 << endl;
        return 0;
    }

    reverse(S.begin(),S.end());
    
    int m = 2019;
    vector<int> count(m);
    int x = 1;
    int tot = 0;
    int ans = 0;
    for(int i = 0;i < (int)S.size(); i++){
        count[tot]++;
        tot += ((S[i] - '0') * x);
        tot = tot % m;
        ans += count[tot];
        x = x * 10 % 2019;
    }
    cout << ans << endl;
    return 0;
}

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

int gcd(int x, int y);
int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	long long int H, W;
	cin >> H >> W;
	
	// 4つのリストで答えを管理する
	vector<int> y, x, yd, xd;

	int al[H][W];
	for(int i=0; i<H; i++) {
		for(int j=0; j<W; j++) {
			int a;
			cin >> a;
			al[i][j] = a;
		}
	}

	for(int i=0; i<H; i++) {
		for(int j=0; j<W; j++) {
			if(al[i][j]%2){
				if(j+1<W) {
					al[i][j]--;
					al[i][j+1]++;
					
					y.push_back(i+1);
					x.push_back(j+1);
					yd.push_back(i+1);
					xd.push_back(j+2);
				} else if(i+1<H) {
					al[i][j]--;
					al[i+1][j]++;
					
					y.push_back(i+1);
					x.push_back(j+1);
					yd.push_back(i+2);
					xd.push_back(j+1);
				}
			}
		}
	}

	cout << y.size() << endl;
	for(int i=0; i<y.size(); i++) {
		cout << y.at(i) << " " <<  x.at(i) << " " << yd.at(i) << " " << xd.at(i);
		if(i != y.size()-1) cout << endl;
	}

	return 0;
}

Measured memory_bytes: 5220
function main() {
  var
  nq = input[0].split(' ').map(Number),
  n = nq[0], q = nq[1],
  queue = [], process,
  total;
  input.slice(1, 1+n).forEach(function (process) {
    process = process.split(' ');
    process[1] = Number(process[1]);
    queue.push(process);
  });

  total = 0;
  while(queue.length !== 0) {
    process = queue.shift();
    if (process[1] > q) {
      process[1] -= q;
      total += q;
      queue.push(process);
    } else {
      total += process[1];
      console.log(process[0] + ' ' + total);
    }
  }
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 35296
from collections import deque

n = int(input())
data = deque()

for i in range(n):
	command = input().split()
	if len(command) == 2:
		command,x = command
	else:
		command = command[0]
	if command == 'insert':
		data.appendleft(x)
	elif command == 'delete':
		if x in data:
			data.remove(x)
	elif command == 'deleteFirst':
		data.popleft()
	elif command == 'deleteLast':
		data.pop()

print(*data)

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

int main()
{
	long long N, K;
	long long  result;

	vector<long long>A;

	cin >> N >> K;

	result = 0;

	for (int a = 0; a < N; a++) {
		long long newA;
		cin >> newA;
		A.push_back(newA*2);

	}

	long long sum = 0;
	for (int a = 0; a < A.size(); a++) {
		sum += A[a];
		if (a <= K - 2) {

		}
		else {
			long long nowResult = (sum + K*2) / 2;
			if (nowResult > result)result = nowResult;
			sum -= A[a - K + 1];
		}

	}

	string resultString = "";

	if (result % 2 != 0) {
		resultString = to_string(result / 2) + ".5";
	}
	else {
		resultString = to_string(result / 2);
	}

	cout << resultString << endl;
}



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

double n, k;

int func(int a) {
	int flow = a;
	int res = 0;
	if (a >= k) return 0;
	for (int i = 0; ; i++) {
		flow *= 2;
		res++;
		if (flow >= k) break;
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	vector<double> ans(n);
	int s = k / 2;
	for (int i = 0; i < n;i++) {
		ans[i] = (1/n) * pow(0.5, func(i + 1));
	}
	double sol = 0;
	rep(i, n) sol += ans[i];
	cout << setprecision(12) << sol << endl;
}

Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    a,b,c=MI()
    if a==b:print(c)
    elif b==c:print(a)
    else:print(b)
main()

Measured memory_bytes: 3060
def main():
    inf = 10 ** 14 + 1

    n = int(input())
    *a, = map(int, input().split())

    stay = 0  # -1を乗算しない
    done = -inf  # -1を乗算した

    for x in a:
        stay, done = max(stay + x, done - x), max(stay - x, done + x)

    print(stay)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14412
#include <iostream>
    #include <algorithm>
    using namespace std;
     
    int digit(long long int num){
    	int ret = 0;
    	while(num > 0){
    		num /= 10;
    		ret++;
    	}
    	return ret;
    }
     
    int main() {
    	long long int N;
    	cin >> N;
    	int ans = digit(N);
    	for(long long int i = 1; i * i <= N; i++){
    		if(N % i == 0){
    			ans = min(ans, max(digit(i), digit(N / i)));
    		}
    		//if(i % 100 == 0)cout << i << " ";
    	}
    	cout << ans << endl;
    	return 0;
    }

Measured memory_bytes: 764
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, h, m; cin >> a >> b >> h >> m;
    double radh = 30.0 * h, radm = 6.0 * m;
    radh += 0.5 * m;
    double mid = abs(radh - radm);
    chmin(mid, 360 - mid);
    double rad = mid * M_PI / 180.0;
    double c2 = (double)(a * a) + (double)(b * b) - (double)(2 * a * b) * cos(rad);
    cout << fixed << setprecision(12) << sqrt(c2) << '\n';
    return 0;
}


Measured memory_bytes: 4240
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n, m = map(int, input().split())
from collections import defaultdict
ns = defaultdict(set)
pps = [set() for _ in range(n)]
for i in range(n-1+m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    ns[a].add(b)
    pps[b].add(a)

for i,s in enumerate(pps):
    if not s:
        r = i
        
def tps(start):
    q = [start]
    # 行きがけ順
    seen = [None] * n
    # 帰りがけ順
    done = [None] * n
    d0 = 0
    d1 = n
    seen[start] = d0
    while q:
        u = q.pop()
        if u>=0:
            q.append(~u)
            for v in ns[u]:
                if done[v] is None:
                    d0 += 1
                    seen[v] = d0
                    q.append(v)
        else:
            d1 -= 1
            done[~u] = d1
    return seen, done

done = [None]*n
seen = [False]*n
def dfs(u, val):
    for v in ns[u]:
        if seen[v]:
            continue
        seen[v] = True
        val = dfs(v, val)
    val = val - 1
    done[u] = val
    return val

dfs(r, n)
# seen, done = tps(r)
ps = [-1] * n
ps[r] = 0
for i in range(n):
    if i==r:
        continue
    val = max(pps[i], key=lambda item: done[item])
    ps[i] = val+1
write("\n".join(map(str, ps)))

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

struct Point
{
	int x;
	int y;
};

bool inPoint(Point a, Point b, Point c)
{
	if(min(a.x,c.x)<=b.x && max(a.x,c.x)>=b.x && min(a.y,c.y)<=b.y && max(a.y,c.y)>=b.y) return true;
	return false;
}

int orientation(Point a, Point b, Point c)
{
	int val = (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);
	//clockwise
	if(val<0) return -1;
	//counter
	else if(val>0) return 1;
	//collinear
	else return 0;
}

void turn(Point a, Point b, Point c)
{
	int val = orientation(a,b,c);
	if(val==-1) cout<<"CLOCKWISE"<<endl;
	else if(val==1) cout<<"COUNTER_CLOCKWISE"<<endl;
	else if(inPoint(a, c, b)) cout<<"ON_SEGMENT"<<endl;
	else if(inPoint(c, a, b)) cout<<"ONLINE_BACK"<<endl;
	else cout<<"ONLINE_FRONT"<<endl;
}

int main()
{
	int x1,y1,x2,y2;
	int q;
	cin>>x1>>y1>>x2>>y2;
	cin>>q;
	Point a = {x1,y1};
	Point b = {x2,y2};
	int x3,y3;
	for(int i=0;i<q;i++)
	{
		cin>>x3>>y3;
		Point c = {x3,y3};	
		turn(a,b,c);
	}
	return 0;
}



Measured memory_bytes: 3120
//#pragma comment(linker, "/STACK:134217728")

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;

#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair

#define MAX (1 << 18)
#define MOD (int(1e9+7))

Int F[MAX];
Int R[MAX];
Int S[MAX];

Int pwr(Int a, Int b)
{
	if (b == 0) return 1;
	Int r = pwr(a * a % MOD, b >> 1);
	if (b & 1) r = r * a % MOD;
	return r;
}

Int inverse(Int a)
{
	return pwr(a, MOD - 2);
}

int main()
{
	int n;
	cin >> n;
	VInt v(n);
	int i;
	FOR(i, 0, n) cin >> v[i];

	F[0] = 1;
	FOR(i, 1, MAX) F[i] = i * F[i - 1] % MOD;

	R[1] = 1;
	S[1] = R[1];
	FOR(i, 2, n)
	{ 
		R[i] = (R[i - 1] + inverse(i)) % MOD;
		S[i] = (S[i - 1] + R[i]) % MOD;
	}

	Int res = 0;
	FOR(i, 1, n)
		res = (res + (v[i] - v [i - 1]) * R[i]) % MOD;

	cout << (res * F[n - 1] % MOD) << endl;
	return 0;
};


Measured memory_bytes: 5504
N = 8
while True:
    A = []
    for i in range(N):
        A.append(input())

    x1 = -1
    y1 = -1
    for i in range(N):
        for j in range(N):
            if x1 == -1 and A [i] [j] == '1':
                y1 = i
                x1 = j
            elif A [i] [j] == '1':
                y2 = i
                x2 = j

    if x2 - x1 == 1 and y2 - y1 == 1:
        print('A')
    elif x2 - x1 == 0 and y2 - y1 == 3:
        print('B')
    elif x2 - x1 == 3 and y2 - y1 == 0:
        print('C')
    elif x2 - x1 == -1 and y2 - y1 == 2:
        print('D')
    elif x2 - x1 == 2 and y2 - y1 == 1:
        print('E')
    elif x2 - x1 == 1 and y2 - y1 == 2:
        print('F')
    else:
        print('G')
    try:
        input()
    except EOFError:
        break

Measured memory_bytes: 7444
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

string J(string t){
    string ret = t.substr(sz(t)-1,1);
    ret += t.substr(0,sz(t)-1);
    return ret;
}

string C(string t){
    string ret = t.substr(1,sz(t)-1);
    ret.pb(t[0]);
    return ret;
}

string E(string s){
    if(s.size()%2==0){
        int t = s.size();
        string s1 = s.substr(0,t/2);
        string s2 = s.substr(t/2,t/2);

        return s2+s1;
    }else{
        int t = s.size();
        string s1 = s.substr(0,t/2);
        string s2 = s.substr(t/2+1,t/2);
        char c = s[t/2];
        string ret = s2;
        ret.pb(c);
        ret += s1;
        return ret;
    }
}

string A(string s){
    string ret = s;
    reverse(all(ret));
    return ret;
}

string P(string s){
    for(int i=0;i<sz(s);i++){
        if('1'<=s[i] and s[i]<='9') s[i]--;
        else if(s[i]=='0') s[i]='9';
    }
    return s;
}

string M(string s){
    for(int i=0;i<sz(s);i++){
        if('0'<=s[i] and s[i]<'9'){
            s[i]++;
        }else if(s[i]=='9'){
            s[i]='0';
        }
    }
    return s;
}

void solve(){
    string s,t;
    cin >> s >> t;

    for(int i=sz(s)-1;i>=0;i--){
        string u;
        if(s[i]=='J') t = J(t);
        if(s[i]=='C') t = C(t);
        if(s[i]=='E') t = E(t);
        if(s[i]=='A') t = A(t);
        if(s[i]=='P') t = P(t);
        if(s[i]=='M') t = M(t);
    }
    cout << t << endl;
}

int main(){
//    string s;
//    cin >> s;
//    cout << P(s) << endl;
//    return 0;
    int N;
    cin >> N;
    rep(i,N) solve();
}

Measured memory_bytes: 3016
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#define MAX 100
#define INF 0x3f3f3f3f
using namespace std;
struct edge {
	int from, to, cost;
	edge(int a,int b,int c) {
		from = a;
		to = b;
		cost = c;
	}
};
typedef pair<int, int> P;
P fun(int s, int V, int E, vector<edge> es) {
	int d[MAX];
	fill(d, d + V, INF);
	d[s] = 0;
	while (true) {
		bool update = false;
		for (int i = 0; i<es.size(); i++) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to]>d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if (!update)
			break;
	}
	int sum = 0;
	for (int i = 0; i<V; i++)
		sum += d[i];
	return P(sum, s);
}
P cmp(P a, P b) {
	if (a.first == b.first)
		return a.second<b.second ? a : b;
	return a.first<b.first ? a : b;
}
int  main() {
	ios::sync_with_stdio(0);
	vector<edge> es;
	int n;
	while (cin >> n && n) {
		es.clear();
		P res = P(INF, INF);
		int a, b, c, V=0;
		for (int i = 0; i< n; i++) {
			cin >> a >> b >> c;
			es.push_back(edge(a, b, c));
			es.push_back(edge(b, a, c));
			V = max(max(a, b), V);
		}
		for (int j = 0; j<n; j++)
			res = cmp(res, fun(j, V+1, es.size(), es));
		cout << res.second << " " << res.first << endl;
	}
	return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,c;
	cin>>a>>b>>c;
	int ans = (a+b+c)-max({a,b,c});
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())
lst=[0 for f in range(N)]
for i in range(N):
 lst[i]= list(map(int,input().split()))
lst.sort(key=lambda x: x[2], reverse=True)
for i in range(101):
 for j in range(101):
  h=abs(i-lst[0][0])+abs(j-lst[0][1])+lst[0][2]
  if h==10**9 and N==1:
   ans=[lst[0][0],lst[0][1],lst[0][2]]
  else:
   t=0
   for k in range(N-1):
    if max(h-abs(i-lst[k+1][0])-abs(j-lst[k+1][1]),0)==lst[k+1][2]:
     t+=1
   if t==N-1:
    ans=[i,j,h]
print(*ans)


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

int main(){
  int n;
  std::cin >> n;
  vector<int> c(n), w(n + 1, 0);
  for (int i = 0; i < n; i++) {
    std::cin >> c[i] >> w[i + 1];
  }
  bool dp[n][n];
  memset(dp, false, sizeof(dp));
  for (int i = 0; i < n; i++) dp[i][i] = true;
  for (int i = 1; i <= n; i++) w[i] += w[i - 1];
  for (int i = 1; i < n; i++) {
    for (int j = 0; i + j < n; j++) {
      dp[j][i + j] |= (dp[j + 1][i + j] and c[j] >= w[i + j + 1] - w[j + 1]) or
        (dp[j][i + j - 1] and c[i + j] >= w[i + j] - w[j]);
    }
  }
  int ans[n + 1];
  for (int i = 0; i <= n; i++) ans[i] = 1e9;
  ans[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      if(dp[j][i] == false)continue;
      ans[i + 1] = min(ans[i + 1], ans[j] + 1);
    }
  }
  std::cout << ans[n] << std::endl;
  return 0;
}

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

int main(){
  string S, T;
  cin >> S >> T;
  
  int Slen = (int)(S.length()), Tlen = (int)(T.length());
  
  vector<string> kouho(0);
  for (int i = 0; i <= Slen - Tlen; i++){
    string ac = S;
    for (int j = 0; j < Tlen; j++){
      
      if (S.at(i + j) == '?' || S.at(i + j) == T.at(j)){
        ac.at(i + j) = T.at(j);
        
        if (j == Tlen - 1){
          for (int k = 0; k < Slen; k++){
            
            if (ac.at(k) == '?'){
              ac.at(k) = 'a';
            }
            
          }
          kouho.push_back(ac);
        }
        
        continue;
      }
      else{
        break;
      }
      
    }
  }
  
  if (kouho.size() > 0){
    sort(kouho.begin(), kouho.end());
  
    cout << kouho.at(0) << endl;
  }
  else{
    cout << "UNRESTORABLE" << endl;
  }
  
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

bool bad[100005];

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) {
    int t;
    scanf("%d", &t);
    if(i == t) bad[i] = true;
  }
  int ret = 0;
  for(int i = 1; i <= n; i++) {
    if(bad[i] && bad[i+1]) {
      ret++;
      i++;
    }
    else if(bad[i]) {
      ret++;
    }
  }
  printf("%d\n", ret);
}


Measured memory_bytes: 384
# N,M = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

co = [1,400,800,1200,1600,2000,2400,2800, 3200]

from collections import defaultdict
from bisect import bisect_right

ans = 0
gold = 0
dic = defaultdict(int)
for i in range(N):
    r = bisect_right(co, A[i])
    dic[r] += 1
    
gold = dic[9]
del dic[9]
ans = len(dic.keys())

if ans == 0:
    # print(1, min(gold, 8))
    print(1, gold)
else:
    # print( ans  , min(ans+gold, 8) )
    print( ans  , ans+gold )
# print(dic)



Measured memory_bytes: 38512
n, a, b = [int(i) for i in input().split()]
a,b=max(a,b),min(a,b)

if (a - b) % 2 == 0:
    print((a - b) // 2)
else:
    c = b + (a -1- b) // 2
    d = n - a + 1 + (n - (n - a + 1) - b) // 2
    print(min(c,d))


Measured memory_bytes: 9188
import java.util.Scanner;

public class Main {

	static int I=1, V=5, X=10, L=50, C=100, D=500, M=1000;
	static char[] s;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(cin.hasNext()){
			String str = cin.next();
			s = new char[150];
			for(int i = 0; i < str.length(); i++){
				s[i]=str.charAt(i);
			}
			int sum=0;
			for(int i = 0; i < str.length(); i++){
				int now= charToInt(s[i]);
				int next = charToInt(s[i+1]);
				if(now < next){
					sum+=next-now;
					i++;
				}
				else{
					sum+=now;
				}
			}
			System.out.println(sum);
		}
		
	}
	static int charToInt(char s){
		int now=0;
		if(s=='I'){
			now=I;
		}
		else if(s=='V'){
			now=V;
		}
		else if(s=='X'){
			now=X;
		}
		else if(s=='L'){
			now=L;
		}
		else if(s=='C'){
			now=C;
		}
		else if(s=='D'){
			now=D;
		}
		else if(s=='M'){
			now=M;
		}
		else{
			
		}		
		return now;
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<numeric>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

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

Measured memory_bytes: 4056
#include<iostream>
#include<string>
using namespace std;
int main() {
    int N, X;
    cin >> N >> X;
    int m[110];
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> m[i];
        sum += m[i]; 
    }
    int min = m[0];
    for(int i = 0; i < N; i++){
        if(min > m[i])
            min = m[i];
    }
    int R, j;
    R = X - sum;
    j = R / min;
    cout << N + j << endl;
    return 0; 
}

Measured memory_bytes: 3596
def calc_abs(n):
    return abs(n)

N = int(input())
A = [int(i) for i in input().split()]
count = len([i for i in A if i < 0])
count_zero = A.count(0)
answer = 0
if(count % 2 != 0 and count_zero == 0):
    abs_list = list(map(calc_abs,A))
    answer = sum(abs_list) - 2 * min(abs_list)
else:
    abs_list = list(map(calc_abs, A))
    answer = sum(abs_list)
print(answer)

Measured memory_bytes: 14412
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(ll i = 0; i < (ll)c; i++)
#define ll long long
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;
const int inf = 1000000000; // 10^9

int main(){
    ll n, h[110000], dp[110000], k;

    fill(dp, dp + 110000, inf);

    cin >> n >> k;

    rep(i, n) cin >> h[i];

    dp[0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < i + k + 1; j++){
            upd_min(dp[j], dp[i] + abs(h[i] - h[j]));
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

void chmax(ll &a, ll b){
    a = max(a, b);
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = -INF;
    chmax(ans, a * c);
    chmax(ans, a * d);
    chmax(ans, b * c);
    chmax(ans, b * d);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

vector<int> ms;

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

    ms.resize(M);

    for (int i = 0; i < N; i++) {
        int K;
        cin >> K;
        for (int j = 0; j < K; j++) {
            int a;
            cin >> a;
            a--;
            ms[a]++;
        }
    }

    int cnt = 0;
    for (int i = 0; i < (int) ms.size(); i++) {
        if (ms[i] == N) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      aa: [usize; n],
    }
    let mut ans = vec![];
    let mut b = vec![0; n];
    for i in (1..n+1).rev() {
        let mut sum = 0;
        let mut cur = i*2;
        while cur <= n {
            sum += b[cur-1];
            cur += i;
        }
        if sum%2 != aa[i-1] {
            b[i-1] = 1;
            ans.push(i);
        }
    }
    puts!("{}\n", ans.len());
    for a in ans {
        puts!("{}\n", a);
    }
}


Measured memory_bytes: 9212
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
 
int main()
{
   int n;
   cin>>n;
   int h[n+1];
   for(int i=1;i<=n;i++)
   {
     cin>>h[i];
   }
  int dp[n+1];
  dp[n]=0;
  dp[n-1]=abs(h[n-1]-h[n]);
  for(int i=n-2;i>=0;i--)
  {
     dp[i]=min(dp[i+1]+abs(h[i]-h[i+1]),dp[i+2]+abs(h[i]-h[i+2]));
  }
  cout<<dp[1];
  return 0;
}

Measured memory_bytes: 1024
x=int(input())
if 400<=x<=599:
  print(8)
elif 600<=x<=799:
  print(7)
elif 800<=x<=999:
  print(6)
elif 1000<=x<=1199:
  print(5)
elif 1200<=x<=1399:
  print(4)
elif 1400<=x<=1599:
  print(3)
elif 1600<=x<=1799:
  print(2)
elif 1800<=x<=1999:
  print(1)

Measured memory_bytes: 9212
N = int(input())
if [2 * ((i - 1 + N % 2) // 2) + 1 - N % 2 for i in range(1, N + 1)] == sorted([int(a) for a in input().split()]):
  print((2 ** (N // 2)) % (10 ** 9 + 7))
else:
  print(0)

Measured memory_bytes: 17844
#include<bits/stdc++.h>
using namespace std;
int minhe(int a[],int n,int k)
{
   // int ans=0;
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;++i)
    {
       int ans=INT_MAX;
      for(int j=1;j<=k&&j<=i;++j)
      {
          int min1=abs(a[i]-a[i-j])+dp[i-j];
          ans=min(ans,min1);
      }
      //int min1=abs(a[i]-a[i-1])+dp[i-1];
      //int min2=abs(a[i]-a[i-2])+dp[i-2];
      dp[i]=ans;
    }
    return dp[n-1];
}
int main()
{
    int n,k;
    cin>>n>>k;
    int *a=new int[n];
    for(int i=0;i<n;++i)
        cin>>a[i];
    cout<<minhe(a,n,k);
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
//1232
int a,b,c,n,m,l[4],o[1140010][4],k,i,d,dx[10]={0,1,-1,0,0,-1,-1,1,1},dy[10]={0,0,0,-1,1,1,-1,1,-1};
long long x,y,z;
stack<int> s;
struct P
{
    int x,y;
    long long z;
    bool operator<(const P &a)const
    {
        return y>a.y;
    }
};
 //map<int, int> p;
queue<P> q;
string r[3];
vector<P> v[1000100];
//vector<long long> ;
bool sdf(P a,P b){return a.y<b.y;}


int main()
{
    cin>>r[0];
    cin>>r[1];
    cin>>r[2];
    if(r[0][r[0].size()-1]==r[1][0]&&r[1][r[1].size()-1]==r[2][0]) puts("YES");
    else puts("NO");
    return 0;
}

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

int main ()
{
    int r ;
    scanf("%d", &r);

    double a1 = 3.14 ;
    double a2 = (3.14 * pow(r , 2));

    printf("%.0lf\n", a2 / a1);
    return 0 ;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
cost = [0 for i in range(N + 1)]
cost[0] = abs(A[0] - 0)
for i in range(1, N):
    cost[i] = abs(A[i] - A[i-1]) + cost[i-1]
cost[N] = abs(A[N-1]) + cost[N-1]

print(cost[N] - cost[1] + abs(A[1] - 0))
for i in range(1, N-1):
    print(cost[i-1] + cost[N] - cost[i+1] + abs(A[i+1] - A[i-1]))
print(cost[N-2] + abs(0 - A[N-2]))


Measured memory_bytes: 14172
#include<bits/stdc++.h>
using namespace std;
string s;
int main(int argc, char const *argv[])
{
	cin>>s;
	int i=0,j=s.length()-1,ans=0;
	bool flag=1;
	while(i<j)
	{
		if(s[i]==s[j])
		{
			i++;
			j--;
		}
		else if(s[i]=='x')
		{
			i++;
			ans++;
		}
		else if(s[j]=='x')
		{
			j--;
			ans++;
		}
		else
		{
			flag=0;
			break;
		}
	}
	if(flag)
		cout<<ans<<"\n";
	else
		cout<<"-1\n";
	return 0;
}

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

int main() {
    int x, n, mx = INT_MIN, mn = INT_MAX;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        mx = max(mx, x);
        mn = min(mn, x);
    }

    cout << mx - mn << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

const int INF = 1e9;
const long long LINF = 1e18;
const double PI=3.14159265358979323846;

typedef priority_queue<int, vector<int>, greater<int>> priority_queue_asc;

int main() {
    char c;
    cin >> c;

    if ('A' <= c && c <= 'Z') {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }

    return 0;
}


Measured memory_bytes: 3064
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int a, b;
    cin >> a >> b;
    if (a <= b) cout << a << endl;
    else cout << a-1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int h, w, n, ans;
    cin>>h>>w>>n;
    if(h>w) ans = ceil(1.0*n/h);
    else ans = ceil(1.0*n/w) ;
    cout<<ans<<endl;
    return 0;

}



Measured memory_bytes: 256
n=int(input())+1
data=[0]*n*2
def update(i,x):
    i+=n
    data[i]=x
    i//=2
    while i:
        data[i]=data[i*2]|data[i*2+1]
        i//=2
def query(l,r):
    l+=n
    r+=n
    s=0
    while l<r:
        if l&1:
            s|=data[l]
            l+=1
        if r&1:
            r-=1
            s|=data[r]
        l//=2
        r//=2
    return sum(map(int,bin(s)[2:]))
s=input()
for i,c in enumerate(s,n):
    data[i]=1<<(ord(c)-97)
for i in range(n-1,0,-1):
    data[i]=data[2*i]|data[2*i+1]
for _ in range(int(input())):
    q,a,b=input().split()
    if q=="2":
        print(query(int(a)-1,int(b)))
    else:
        update(int(a)-1,1<<(ord(b)-97))

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

ll N, A, B;
vll X;


void solve()
{
    cin >> N >> A >> B;
    X = vll(N+1); REP1(i, N) cin >> X[i];

    ll ans = 0;
    REP1(i, N-1)
    {
        ans += min(A*(X[i+1]-X[i]), B);
    }

    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 1024
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<>, rb_tree_tag,
//        tree_order_statistics_node_update>
//        indexed_set;

#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int((x.size())))
#define fi first
#define se second
#define REP(i, a, b) for (int (i)=(a);(i)<(b);(i)++)
#define PER(i, a, b) for (int (i)=(b)-1;(i)>=(a);(i)--)

typedef long double ld;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<PII> VPI;

#ifdef qwerty
#define dbb(x)        { cerr << #x << " = " << x << "\t";      }
#define db(x)        { dbb(x); cerr << endl; }
#define db2(x, y)    { dbb(x); dbb(y); cerr << endl; }
#define db3(x, y, z)    { dbb(x); dbb(y); dbb(z); cerr << endl; }
#else
#define dbb(x)	404;
#define db(x)	404;
#define db2(x,y) 404;
#define db3(x,y,z)	404;
#endif


const ll MOD = 1000000007ll;

ll powmod(ll a, ll b) {
    ll res = 1;
    a %= MOD;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
    }
    return res;
}

template<typename t1, typename t2>
inline bool upmax(t1 &a, t2 b) {
    if (a < (t1) b) {
        a = (t1) b;
        return true;
    } else return false;
}

template<typename t1, typename t2>
inline bool upmin(t1 &a, t2 b) {
    if (a > (t1) b) {
        a = (t1) b;
        return true;
    } else return false;
}

template<typename T>
inline T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<typename T>
inline T lcm(T a, T b) { return a * (b / gcd(a, b)); }

template<typename T>
inline T sqr(T a) { return a * a; }

int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int dkx[] = {-1, -1, 1, 1, -2, -2, 2, 2};
int dky[] = {-2, 2, -2, 2, -1, 1, -1, 1};

const int INF = 1000000404;
const ll LINF = 1e18 * (1ll);
const ld PI = 3.14159265358979323846;
const ld EPS = 1e-9;

const int SQ = 318;
int timer = 0;


const int a_lot_of_test = 0;
#define N 100100



void solve() {


    string a,b;
    cin >> a >> b;
    b.pop_back();

    if (a!=b) {
        cout << "No" << endl;
    } else cout <<"Yes" << endl;

}

int main() {

#ifdef qwerty
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    if (a_lot_of_test) cin >> t;
    for (int i = 1; i <= t; i++) {
        solve();
    }


    return 0;
}

Measured memory_bytes: 3616
N = 1
data = []
for i in range(N):
    data_input = list(map(int,input().split()))
    data.append(data_input)
data = data[0][0]
ans=0
for i in range(3):
    k=2-i
    ans += data // (10**k)
    data = data % (10**k)
    
print(ans)

Measured memory_bytes: 3060
from math import floor

def main():
    n = int(input())
    nsq = floor(n ** 0.5)
    r = 11
    for nsqe in range(nsq, 0, -1):
        if n % nsqe == 0:
            rt = max(len(str(nsqe)), len(str(n // nsqe)))
            r = min(r, rt)
    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 64708
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,k;
    cin>>n>>k;
    vector<int> p(n);
    
    for(int i=0;i<n;i++) cin>>p[i];
    
    sort(p.begin(),p.end());
    
    int cnt=0;
    for(int i=0;i<k;i++){
        cnt+=p[i];
    }
    
    cout<<cnt<<endl;
}


Measured memory_bytes: 3628
N, X = map(int, input().split())
a = list(map(int, input().split()))

ans = 0

for i in range(N-1):
    if a[i] + a[i+1] > X:
        
        if X - a[i] >= 0:
            ans += a[i+1] - (X - a[i])
            a[i+1] = (X - a[i])
        else:
            ans += a[i+1]
            a[i+1] = 0
            ans += a[i] - X
            a[i] = X
            
print(ans)

Measured memory_bytes: 14588
#include <bits/stdc++.h> 
using namespace std; 
  
typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
  
#define rep(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define revrep(a, b, c) for (int(a) = (c-1); (a) >= (b); --(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 

int main() 
{ 
    ll t,n,i,j,res;
    cin>>t;
    res=t/500;
    res*=1000;
    t=t%500;
    t=t/5;
    res+=(t*5);
    cout<<res<<endl;
    return 0;
} 


Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
grid = [input() for i in range(H)]

dist = [[-1]*W for _ in range(H)]

black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append((h, w))
            dist[h][w] = 0

def bfs(black_cells, dist):
    d = 0
    while black_cells:
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:  # セルが白('.')であるのと同義
                dist[new_h][new_w] = d+1
                black_cells.append((new_h, new_w))
    return d

d = bfs(black_cells, dist)
print(d)

Measured memory_bytes: 86620
A, B, C, D, E, F = map(int, input().split())

A *= 100
B *= 100
dp = [-1]*(F+1)
if A <= F:
    dp[A] = 0
if B <= F:
    dp[B] = 0
for i in range(A, F + 1):
    if A <= i:
        dp[i] = max(dp[i - A], dp[i])
    if B <= i:
        dp[i] = max(dp[i - B], dp[i])
    if C <= i and dp[i-C] >= 0:
        if dp[i-C] + C <= (i-C - dp[i-C]) * (E / 100):
            dp[i] = max(dp[i-C] + C, dp[i])
    if D <= i and dp[i-D] >= 0:
        if dp[i-D] + D <= (i - D - dp[i-D]) * (E / 100):
            dp[i] = max(dp[i-D] + D, dp[i])


x = 0
id = 0
for i in range(A, F+1):
    if x <= (dp[i] / (i)):
        x = dp[i] / (i)
        id = i
print(id, dp[id])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

 
int main() {

    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a);
    vector<ll> q(b);
    vector<ll> r(c);
    rep(i,a)    cin >> p[i];
    rep(i,b)    cin >> q[i];
    rep(i,c)    cin >> r[i];
    sort(all(p));
    sort(all(q));
    sort(all(r));

    ll ans=0;
    for(int i=a-1;i>=a-x;i--) {
        ans+=p[i];
    }
    ll akami=a-x;
    for(int i=b-1;i>=b-y;i--) {
        ans+=q[i];
    }
    ll midomi=b-y;
    for(int i=c-1;i>=0;i--) {
        if(p[akami]<q[midomi]) {
            if(r[i]>p[akami]) {
                ans+=r[i];
                ans-=p[akami];
                akami++;
                if(akami==a) {
                    akami--;
                    p[akami]=10000000000;
                } 
            }
            else    break;
        }
        else {
            if(r[i]>q[midomi]) {
                ans+=r[i];
                ans-=q[midomi];
                midomi++;
                if(midomi==b) {
                    midomi--;
                    q[midomi]=10000000000;
                }
            }
            else    break;
        }
    }

    cout<<ans<<endl;


 return 0;
}

Measured memory_bytes: 2560