akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
int main() {
	int x, h;
	while (scanf("%d%d", &x, &h)) {
		if (x == 0 && h == 0) break;
		double temp1 = sqrt(pow((double)h, 2) + pow((double)x*sqrt(2)/2, 2));
		double temp2 = sqrt(pow(temp1, 2) - pow((double)x/2, 2));
		double S = pow((double)x, 2) + 2.0 * temp2 * (double)x;
		printf("%.6f\n", S);
	}
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
	int n,m,work=0;
	cin>>n>>m;
	int a[n]={0};
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int j=2;j<=m;j++){
		for(int i=0;i<n-1;i++){
			if(a[i]%j>a[i+1]%j){
				work=a[i];
				a[i]=a[i+1];
				a[i+1]=work;
			}
		}
	}
	for(int i=0;i<n;i++){
		cout<<a[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int INF = 1000;
int main(){
  int N;
  cin >> N;
  vector<vector<int>> d(N, vector<int>(N, INF));
  for (int i = 0; i < N; i++){
    d[i][i] = 0;
  }
  vector<int> a(N - 1), b(N - 1);
  for (int i = 0; i < N - 1; i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = 1;
    d[b[i]][a[i]] = 1;
  }
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      for (int k = 0; k < N; k++){
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
      }
    }
  }
  int M;
  cin >> M;
  vector<long long> c(M, 0);
  for (int i = 0; i < M; i++){
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    for (int j = 0; j < N - 1; j++){
      bool ok = false;
      if (d[u][a[j]] + 1 + d[b[j]][v] == d[u][v]){
        ok = true;
      }
      if (d[u][b[j]] + 1 + d[a[j]][v] == d[u][v]){
        ok = true;
      }
      if (ok){
        c[i] += (long long) 1 << j;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < (1 << M); i++){
    long long v = 0;
    for (int j = 0; j < M; j++){
      if (i >> j & 1){
        v |= c[j];
      }
    }
    int cnt = __builtin_popcountll(v);
    long long cnt2 = (long long) 1 << (N - 1 - cnt);
    if (__builtin_parityll(i)){
      ans -= cnt2;
    } else {
      ans += cnt2;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	auto T = S.idup;
	long ans = 1;
	auto last = [S[0]];
	S.popFront;
	while (!S.empty)
	{
		if (last.length == 2)
		{
			last = [S[0]]; S.popFront;
			++ans;
		}
		else if (S[0] == last[0])
		{
			if (S.length == 1)
			{
				break;
			}
			last = S[0..2];
			S    = S[2..$];
			++ans;
		}
		else
		{
			last = [S[0]]; S.popFront;
			++ans;
		}
	}

	long ans2 = 1;
	last = [T[0], T[1]];
	T = T[2..$];
	while (!T.empty)
	{
		if (last.length == 2)
		{
			last = [T[0]]; T.popFront;
			++ans2;
		}
		else if (T[0] == last[0])
		{
			if (T.length == 1)
			{
				break;
			}
			last = T[0..2];
			T    = T[2..$];
			++ans2;
		}
		else
		{
			last = [T[0]]; T.popFront;
			++ans2;
		}
	}

	writeln(max(ans, ans2));
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 3640
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    string S;cin>>S;
    int N=S.size();
    int X=0;
    for(int i=0;i<N-1;i++){
        if(S[i]!=S[i+1])X++;
    }
    cout<<X<<endl;
    return 0;
}

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

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    if (C - A/2 - B/2 > 0){
        cout << A * X + B * Y << endl;
    }
    else {
        int num = min(X, Y) * 2 * C;
        if (max(X, Y) == X){
            num += min(A, 2 * C) * (X - Y);
        }
        else{
            num += min(B, 2 * C) * (Y - X);
        }
        cout << num << endl;
    }
}

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

int main()
{
    int N;
    cin >> N;
    int a = 0;
    int b = 0;
    bool answer = false;
    while (true)
    {
        if (4 * a > N)
        {
            break;
        }
        while (true)
        {
            if (4 * a + 7 * b > N)
            {
                b = 0;
                break;
            }
            if (4 * a + 7 * b == N)
            {
                b = 0;
                answer = true;
                break;
            }
            ++b;
        }
        ++a;
    }
    if (answer == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3628
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int n; cin >> n;
        vi a(n);
        rep(i,n) cin >> a[i];
        sort(all(a));
        int mid = n/2;
        cout<<a[mid]-a[mid-1]<<endl;

return 0;
}




Measured memory_bytes: 640
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n;
    cin >> n;
    vector<int> b(n);
    REP(i, n-1)
        cin >> b[i];

    vector<int> a(n);
    a[0] = b[0];
    FOR(i, 1, n-1){
        a[i] = min(b[i-1], b[i]);
    }
    a[n-1] = b[n-2];
    cout << accumulate(a.begin(), a.end(), 0) << endl;
    return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <functional>
#include <iostream>
#include <memory>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	auto price = min(x, y) * min(a + b, c * 2);
	if (x > y) {
		price += (x - y) * min(a, c * 2);
	}
	else {
		price += (y - x) * min(b, c * 2);
	}
	cout << price << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int mod=1000000007;

long dp[101][4][4][4];

int main(){
	int n;
	cin >> n;
	dp[0][3][3][3]=1;
	for(int i=0;i<n;i++){
		for(int x=0;x<4;x++)
		for(int y=0;y<4;y++)
		for(int z=0;z<4;z++)
		for(int j=0;j<4;j++){
			if(y==0 && z==1 && j==2) continue;
			if(y==0 && z==2 && j==1) continue;
			if(y==1 && z==0 && j==2) continue;
			if(x==0 && y==1 && j==2) continue;
			if(x==0 && z==1 && j==2) continue;
			dp[i+1][y][z][j]+=dp[i][x][y][z];
			dp[i+1][y][z][j]%=mod;
		}
	}
	long ans=0;
	for(int x=0;x<4;x++)
	for(int y=0;y<4;y++)
	for(int z=0;z<4;z++){
		ans+=dp[n][x][y][z];
		ans%=mod;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    ll n, x;
    cin >> n >> x;
    vector<ll> s(n);
    for (int i = 0; i < n; i++)
        cin >> s[i];
    sort(s.rbegin(), s.rend());
    // dp[i][j] = i個(1-indexed)見て, j が書かれているような場合の数
    vector<vector<ll>> dp(n + 1, vector<ll>(x + 1, 0));
    dp[0][x] = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= x; j++)
        {
            dp[i + 1][j % s[i]] += dp[i][j];
            dp[i + 1][j % s[i]] %= MOD;

            dp[i + 1][j] += dp[i][j] * (n - i - 1) % MOD;
            dp[i + 1][j] %= MOD;
        }
    }
    ll ret = 0;
    for (int i = 1; i <= x; i++)
    {
        ret += dp[n][i] * i % MOD;
        ret %= MOD;
    }
    cout << ret << endl;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template <typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

vector<string> split(string &s, char deli) {
    vector<string> res;
    string str = "";
    for (auto c : s) {
        if (c == deli) {
            if (res.size() % 2 == 0) {
                res.push_back(str);
            } else {
                str = '"' + str + '"';
                res.push_back(str);
            }

            str.clear();
        } else {
            str.push_back(c);
        }
    }

    if (!str.empty()) res.push_back(str);
    return res;
}

void solve(string s1, string s2) {
    int n = s1.size(), m = s2.size();
    vector<string> vars1, var2, syns1, syns2;
    vector<string> res1 = split(s1, '"'), res2 = split(s2, '"');
    bool isVars = res1[0][0] == '"' ? true : false;
    int diff = 0;
    if (res1.size() != res2.size()) {
        cout << "DIFFERENT" << endl;
        return;
    }

    for (int i = 0; i < res1.size(); i++) {
        if (isVars == true) {
            if (i % 2 == 0) {
                if (res1[i] == res2[i]) continue;
                diff += 1;
            } else {
                if (res1[i] != res2[i]) {
                    cout << "DIFFERENT" << endl;
                    return;
                }
            }
        } else {
            if (i % 2 == 1) {
                if (res1[i] == res2[i]) continue;
                diff += 1;
            } else {
                if (res1[i] != res2[i]) {
                    cout << "DIFFERENT" << endl;
                    return;
                }
            }
        }
    }

    if (diff == 0) {
        cout << "IDENTICAL" << endl;
    } else {
        cout << (diff == 1 ? "CLOSE" : "DIFFERENT") << endl;
    }
}

int main() {
    string s1, s2;
    while (cin >> s1 && s1 != ".") {
        cin >> s2;
        solve(s1, s2);
    }
    return 0;
}


Measured memory_bytes: 3188
// abc105_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N; cin >> N;

    REP(i, 30){
        int r = N - 4 * i;
        if (r < 0) {
            print("No");
            break;
        }
        if (r % 7 == 0){
            print("Yes");
            break;
        }
    }

    return 0;
}


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

struct edge{
  int to, cost;
};

int main(int argc, char *argv[]){
    int n, m, r;
  cin >> n >> m >> r;
  vector<vector<edge> > g(n);
  int from;
  for (int i = 0; i < m; i++) {
    edge e;
    cin >> from >> e.to >> e.cost;
    g[from].push_back(e);
  }
  int dp[n];
  for (int i = 0; i < n; i++) {
    dp[i] = 1e9;
  }
  dp[r] = 0;
  //???????????§?????????
  bool update = true;
  while(update){
    update = false;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < g[i].size(); j++) {
        edge e = g[i][j];
        if(dp[e.to] > dp[i] + e.cost){
          dp[e.to] = dp[i] + e.cost;
          update = true;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if(dp[i] == 1e9)std::cout << "INF" << std::endl;
    else std::cout << dp[i] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 10176
n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(n):
  A[i]=(1+A[i])/2
S=[0 for i in range(n+1)]
for i in range(n):
  S[i+1]=S[i]+A[i]
ans=0
for i in range(n-k+1):
  ans=max(ans,S[i+k]-S[i])
  
print(ans)


Measured memory_bytes: 25060
N,M,*A = `dd`.split.map &:to_i
Matches = [ 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 ]
ah = {}
B = A.sort.reverse.map{ |a| ah[Matches[a]] ? nil : a.tap{ |a| ah[Matches[a]] = 1 } }.compact
C = B + [0]

def compare(xh,yh)
  if xh[0] != yh[0]
    return xh[0] > yh[0]
  end
  i = B.index{ |a| xh[a] != yh[a] }
  i ? xh[B[i]] > yh[B[i]] : false
end

dp = (0..N).map{ Hash[C.map{ |a| [a,0] }] }
(0...N).each{ |i|
  next if i > 0 && dp[i][0] == 0
  B.each{ |a|
    n = Matches[a]
    next if i+n > N
    d = dp[i].clone
    d[a] += 1
    d[0] += 1
    if compare(d, dp[i+n])
      dp[i+n] = d
    end
  }
  #p [i, dp[i]]
}
puts B.map{ |a| a.to_s * (dp[N][a] || 0) }.join


Measured memory_bytes: 16128
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int mod = 1e9+7;
const int maxn = 1010;
const int dx[] = { 1,0 };
const int dy[] = { 0,1 };
char G[maxn][maxn]; int h,w, dp[maxn][maxn];

int dfs(const int i, const int j)
{
    if (i == h && j == w)
        return 1;
    int& ans = dp[i][j];
    if (-1 == ans) {
        ans = 0;
        FOR(d,0,2) {
            const int x = i+dx[d];
            const int y = j+dy[d];
            if (0 < x && x <= h && 0 < y && y <= w && G[x][y] == '.') {
                ans += dfs(x,y);
                ans %= mod;
            }
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> h >> w) {
        memset(dp,-1,sizeof(dp));
        FOR(i,1,h+1) FOR(j,1,w+1)
            cin >> G[i][j];
        const int ans = dfs(1,1);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 5376
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

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

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

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

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,t) = get!(usize,usize);
    let a = get!([usize]);

    let mut mn = std::usize::MAX; 
    let mut mx = 0;
    let mut mxnum = 0;
    for e in a {
        if mn > e {
            mn = e;
        } else {
            if mx < e-mn {
                mx = e-mn;
                mxnum = 1;
            } else if mx == e-mn {
                mxnum += 1;
            }
        }
    }
    println!("{}", mxnum);
}


Measured memory_bytes: 10492
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf

bool isPrime(int x) {
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

const int MAXN = 105;

int n;
int pn;
int p[MAXN];
int cnt[MAXN];
int dp[MAXN][MAXN];

int main() { 

  scanf("%d", &n);
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 2; i <= n; i++) {
    if (isPrime(i)) {
      pn++;
      p[pn - 1] = i;
      for (int j = 2; j <= n; j++) {
        int x = j;
        while (x % i == 0) {
          cnt[pn - 1]++;
          x /= i;
        }
      }
    }
  }

  dp[0][1] = 1;
  for (int i = 1; i <= pn; i++) {
    int cur = p[i - 1];
    for (int j = 1; j <= 75; j++) {
      for (int k = 0; k <= cnt[i - 1]; k++) {
        if (j * (k + 1) > 75) {
          continue;
        }
        dp[i][j * (k + 1)] += dp[i - 1][j];
      }
    }
  }

  cout << dp[pn][75] << endl;

  return 0;
}


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

int abc[26];

int main() {
	string str;
	while(cin >> str) {
		int len = str.length();
		for(int i = 0; i < len; i++) if(isalpha(str[i])) abc[tolower(str[i]) - 'a']++;
	}
	for(int i = 0; i < 26; i++) {
		cout << (char)('a' + i) << " : " << abc[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 3172
N = int(input())
A = []
xy = []

for i in range(N):
    a = int(input())
    tmp = []
    for j in range(a):
        x,y = map(int, input().split())
        tmp.append([x-1,y])
    A.append(a)
    xy.append(tmp)

res = 0
for i in range(2**N):
    cnt = 0
    contra = False
    for j in range(N):
        if (i >> j) & 1 and contra == False: #正直者の時
            cnt += 1
            temp = xy[j]
            for x, y in temp:
                if (i >> x) & 1 != y:
                    contra = True
                    break
    if contra == False:
        res = max(res,cnt)
print(res)

Measured memory_bytes: 43628
using System;

namespace AtCoderSucks
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int sum = 0;
            int big = 0;

            for (int i = 0; i < n; i++)
            {
                int p = int.Parse(Console.ReadLine());
                sum += p;
                if (p >= big)
                    big = p;
            }
            sum -= big;
            big /= 2;
            sum += big;
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin >> k;
    int ans = 0;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            int gc = __gcd(i, j);
            for (int x = 1; x <= k; x++)
            {
                ans += __gcd(gc, x);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n;
int sum[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int tmp;scanf("%d",&tmp);tmp++;
		sum[tmp]++;sum[tmp+1]++;sum[tmp-1]++;
	}
	int ans=0;
	for(int i=0;i<=100003;i++)
	{
		ans=max(ans,sum[i]);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
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; }
const ll INF = 1LL << 60;
int main(){
    string s,t; cin >> s >> t ;
    int a,b; cin >> a >> b;
    string u; cin >>u;
    if (u==s){
        a-=1;
    }else{
        b-=1;
    }
    
    cout << a << ' ' << b << endl;
    return 0;
}

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

int main(){
    ll n;
    cin >> n;
  ll a=1;
  for(long i=1;i<n+1;i++){
  a=a*i;
  a%=1000000007;
  }
cout << a <<endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);i <= (e);(i)++)

string s;

int main(){
  cin >> s;
  string t;
  t = s;
  sort(t.begin(),t.end());
  s = t;
  t.erase(unique(t.begin(),t.end()),t.end());

  if(s == t){
    cout << "yes" << endl;
  }
  else{
    cout << "no" << endl;
  }
}


Measured memory_bytes: 256
open Printf
open Scanf

let (++) = Int64.add
let (--) = Int64.sub
let ( ** ) = Int64.mul
let (//) = Int64.div
let (%%) = Int64.rem
let landl = Int64.logand
let lorl = Int64.logor
let lnotl = Int64.lognot
let lxorl = Int64.logxor
let lsll = Int64.shift_left
let lsrl = Int64.shift_right_logical
let long = Int64.of_int
let succl = Int64.succ
let predl = Int64.pred

let read_int _ = scanf " %d " (fun x -> x)
let read_long _ = scanf " %Ld " (fun x -> x)
let read_str _ = scanf " %s " (fun x -> x)
let read_double _ = scanf " %f " (fun x -> x)

let m = 1_000_000_007L

let rec gcd a b = if b = 0L then a else gcd b (a %% b)

let rec mod_pow a = function
  | 0L -> 1L
  | b -> (if b %% 2L = 0L then 1L else a) ** mod_pow (a ** a %% m) (b//2L) %% m


let () =
  let d = read_int () in
  let c = "Christmas" in
  let e = "Eve" in
  let mes = match d with
    | 22 -> sprintf "%s %s %s %s" c e e e
    | 23 -> sprintf "%s %s %s" c e e
    | 24 -> sprintf "%s %s" c e
    | 25 -> c
    | _ -> assert false
  in
  printf "%s\n" mes


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;

signed main()
{
    fast;
    int h,n;
    cin>>h>>n;

    vector<int> a(n);
    int sum = 0;
    for ( int i = 0 ; i < a.size() ; i++ )
    {
        cin>>a[i];
        sum += a[i];
    }

    if ( h <= sum )
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }


    return 0;
}

Measured memory_bytes: 1024
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5+1;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll t=1;
  //cin>>t;
    while(t--){
            ll a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    ll ans1;
    ll ans=1e18;
    ll am=2*x;
    ll rb=y-am/2;
    ans1=am*c;
    if(rb>=0)
        ans1+=rb*c*2;
  //  cout<<am<<" "<<rb<<" "<<ans1<<" ";
    ll ans2=a*x+b*y;
    ans=min(ans,ans1);
    ans=min(ans,ans2);
    am=2*x;
    rb=y-am/2;
    ans1=c*am;
    if(rb>=0)
        ans1+=b*rb;
      //  cout<<ans1<<" ";
    ans=min(ans,ans1);
    am=2*y;
    rb=x-am/2;
    //cout<<am<<" "<<rb<<" ";
    ans1=c*am;
    if(rb>=0)
        ans1+=a*rb;
       // cout<<ans1<<" ";
    ans=min(ans,ans1);
    cout<<ans;

    }
  return 0;
  }



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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int nowA = A, nowB = B, nowC = C;
  int time = 0;

  if((A == B) && (B == C)){
    if((A % 2 != 0) || (B % 2 != 0) || (C % 2 != 0)){
      goto Next;
    }
    time = -1;
  }

  else{
    while((nowA % 2 == 0) && (nowB % 2 == 0) && (nowC % 2 == 0)){
      time++;
      nowA = (B / 2) + (C / 2);
      nowB = (A / 2) + (C / 2);
      nowC = (A / 2) + (B / 2);
      A = nowA, B = nowB, C = nowC;
    }
  }
  Next:
  cout << time << endl;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
  i64 N, D;
  cin >> N >> D;
  i64 a = 2 * D + 1;
  cout << N / a + (N % a > 0) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	int n, m; cin >> n >> m;
	int sum = 0;
	rep(i, m){
		int a; cin >> a;
		sum += a;
	}
	if(sum <= n) cout << n - sum << endl;
	else cout << -1 << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  string s;
  cin >> s;
  int d[2] = {0, inf};
  for (char c : s) {
    int v1 = c - '0';
    int v2 = '9' - c + 2;
    int x = min(d[0] + v1, d[1] + v1);
    int y = min(d[0] + v2, d[1] + v2 - 2);
    d[0] = x;
    d[1] = y;
  }
  cout << min(d[0], d[1]) << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 1948
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

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

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


//////////////////////////////////////////////////



int main() {
    ll n; cin >> n;
    ll p; cin >> p;

    map<ll, ll> m;
    auto prime_factrize = [&](ll a) -> void {
        for (ll i = 2; i*i <= a; i++)
        {
            if (a%i != 0) continue;
            ll cnt = 0;
            while (a%i == 0) {
                cnt++;
                a /= i;
            }
            m[i] += cnt;
        }
        if (a > 1) m[a]++;
    };

    prime_factrize(p);

    ll ans = 1;
    for (auto v : m) {
        ll num = v.first;
        ll cnt = v.second;
        // cout << num << ' ' << cnt << endl;
        for (int i = cnt; i >= n; i-=n)
        {
            ans *= num;
        }
        
    }

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

Measured memory_bytes: 256
n, m = Array.new(2).map{gets.to_i}
target = gets.split(' ').map{|i| i.to_i-1}
score = Array.new(n){0}

m.times{ |i|
  game = gets.split(' ').map{|k| k.to_i-1}
  n.times{ |j|
    game[j] == target[i] ? score[j] += 1 : score[target[i]] += 1
  }
}

n.times { |i|
  puts score[i]
}

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

int main() {
	string s; cin>>s;
	int sum=0, len; len=s.length();
	for(int i=0;i<len;i++){
		if(s[i]=='+') sum+=1;
		else sum-=1;
	}
	cout<<sum;
	return 0;
}

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

using ll = long long;

const int N = 5005;
const ll M = ll(1e9) + 7;

int n, s[N], m;
ll a[N], d[N][N], p[N][N], r;
vector<int> e[N];

ll pw(ll n, ll k){
    if(!k) return 1;
    return pw(n * n % M, k / 2) * (k % 2 ? n : 1) % M;
}

int g(int x, int p){
    s[x] = 1;
    for(int i : e[x]) if(i != p) s[x] += g(i, x);
    return s[x];
}

int f(int x, int p, int t){
    for(int i : e[x])
        if(i != p && s[i] > t / 2) return f(i, x, t);
    return x;
}

int main(){
    scanf("%d", &n);
    for(int i = 0, x, y; i < n - 1; i++){
        scanf("%d%d", &x, &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    int c = f(1, 0, g(1, 0));
    for(int i : e[c]) a[++m] = g(i, c);
    d[0][0] = 1;
    n--;
    for(int i = 1; i <= m; i++){
        ll t = 1, u = 1;
        for(int k = 0; k <= a[i]; k++){
            for(int j = k; j <= n; j++){
                d[i][j] = (d[i][j] + d[i - 1][j - k] * t) % M;
                p[i][j] = (p[i][j] + p[i - 1][j - k] * t) % M;
                if(k < a[i]) p[i][j] =
                    (p[i][j] + a[i] * a[i] * d[i - 1][j - k] % M * u) % M;
            }
            t = t * (a[i] - k) * (a[i] - k) % M * pw(k + 1, M - 2) % M;
            u = u * (a[i] - 1 - k) * (a[i] - 1 - k) % M * pw(k + 1, M - 2) % M;
        }
    }
    for(int i = 0, v = 1; i <= n; i++, v *= -1){
        ll q = 1;
        for(int j = 1; j <= n - i; j++) q = q * j % M;
        r = (r + M + v * (n + 1) * d[m][i] % M * q % M) % M;
        if(i) r = (r + M - v * p[m][i - 1] * q % M) % M;
    }
    printf("%lld\n", r);
}

Measured memory_bytes: 391808
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



signed main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N;
	cin >> N;
	string S;
	cin >> S;
	int cnt[26] = { 0 };
	
	REP(i, N) {
		int a = S[i] - 'a';
		if (cnt[a] == 0)
			cnt[a]++;

		cnt[a]++;
	}
	int ans = 1;
	REP(i, 26) {
		if (cnt[i] > 0)
			ans *= cnt[i];

		ans %= mod;
	}

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



Measured memory_bytes: 512
// #[warn(dead_code)]
// const TOP: u64 = 1000000007;

fn main() {
	let text = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};

	let mut iter = text.split_whitespace();
	let num: usize = iter.next().unwrap().parse().unwrap();

	use std::collections::HashMap;

	let mut map: HashMap<u64, HashMap<u64, u32>> = HashMap::new();

	for _ in 1..num {
		let u: u64 = iter.next().unwrap().parse().unwrap();
		let v: u64 = iter.next().unwrap().parse().unwrap();
		let w: u32 = iter.next().unwrap().parse().unwrap();
		// let u = u - 1;
		// let v = v - 1;
		map.entry(u).or_insert(HashMap::new());
		map.entry(v).or_insert(HashMap::new());
		if let Some(tmp) = map.get_mut(&u) {
			tmp.insert(v, w);
		}
		if let Some(tmp) = map.get_mut(&v) {
			tmp.insert(u, w);
		}
	}

	let mut colors: HashMap<u64, u32> = HashMap::new();
	colors.insert(1, 0);

	fn set_color(u: u64, map: &HashMap<u64, HashMap<u64, u32>>, colors: &mut HashMap<u64, u32>) {
		if let Some(tmp) = map.get(&u) {
			for (&v, &w) in tmp.iter() {
				let f: u64;
				let nc: u32;
				if let Some(&c) = colors.get(&u) {
					f = v;
					nc = if w % 2 == 1 { c ^ 1 } else { c };
				} else if let Some(&c) = colors.get(&v) {
					f = u;
					nc = if w % 2 == 1 { c ^ 1 } else { c };
				} else {
					continue;
				}
				if let None = colors.get(&f) {
					// println!("{} {}", f, nc);
					colors.insert(f, nc);
					set_color(f, map, colors);
				}
			}
		}
	}

	set_color(1, &map, &mut colors);

	for i in 1..(num + 1) {
		let i = i as u64;
		if let Some(c) = colors.get(&i) {
			println!("{}", c);
		} else {
			continue;
		}
	}
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

int main(void) {
  // Here your code !

  cin >> s;

  int l = 0;
  int r = s.size() - 1;

  int ans = 0;

  while (l <= r) {
    if (s[l] == s[r]) {
      l += 1;
      r -= 1;
    } else if (s[l] == 'x') {  // append 'x' on tail
      l += 1;
      ans += 1;
    } else if (s[r] == 'x') {  // append 'x' on head
      r -= 1;
      ans += 1;
    } else {
      printf("%d\n", -1);
      return 0;
    }
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#define M 2000000000

using namespace std;
int main(void)
{
	int n,i,j,s,a[5000],b[5000],m;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	m=M;
	for(i=0;i<=a[0];i++){
		for(j=0;j<n;j++) b[j]=a[j];
		b[0]-=i; s=i;
		for(j=0;j<n-1;j++){
			if(b[j]>0){
				b[j+1]-=b[j];
				s+=b[j]*2;
				b[j]=0;
			}
		}
		if(b[n-1]>0) s+=b[n-1];
		m=min(m,s);
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 2784
n = int(input())
s = input()
rev_counter = []
rev_num = s.count("E")
if s[0] == "E":
    rev_num -= 1
rev_counter.append(rev_num)
for i in range(1, n):
    if s[i] == "E" and s[i-1] == "E":
        rev_num -= 1
    elif s[i] == "W" and s[i-1] == "W":
         rev_num += 1
    rev_counter.append(rev_num)
print(min(rev_counter))


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

using namespace std;

using ll = long long;

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

    vector<int> dp(n);

    for (int day = 0; day < n; day++)
    {
        vector<int> new_dp(3, 0), c(3);

        for (int i = 0; i < 3; i++)
            scanf("%d", &c[i]);

        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
                if (i != j)
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
        }

        dp = new_dp;
    }

    printf("%d", max({dp[0], dp[1], dp[2]}));
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func splitStr(str string) []int {
	strList := strings.Split(str, " ")
	res := make([]int, len(strList))
	for i := 0; i < len(strList); i++ {
		res[i], _ = strconv.Atoi(strList[i])
	}
	return res
}

func main() {
	var n int
	fmt.Scan(&n)
	numList := splitStr(nextLine())
	looksHotel := 0
	max := 0
	for _, num := range numList {
		if max <= num {
			looksHotel++
			max = num
		}
	}
	fmt.Println(looksHotel)
}


Measured memory_bytes: 640
N,K = map(int,input().split())
xy = [list(map(int,input().split())) for i in range(N)]
xy.sort()
ans = 10**20
for l in range(N):
    for r in range(l,N,1):
        tmp=[]
        for i in range(l,r+1,1):
            tmp.append(xy[i][1])
        tmp.sort()
        for d in range(0,len(tmp)-K+1,1):
            ans = min(ans,(tmp[d+K-1]-tmp[d])*(xy[r][0]-xy[l][0]))

print(ans)

Measured memory_bytes: 71940
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;
int main() {
    int n = 0;
    int k = 0;
    map<long long,long long >price;
    long long ans = 0;
    cin >> n >> k;
    vector<int> a(n),b(n);
    for (int l = 0; l <n ; ++l) {
        cin >> a[l] >> b[l];
    }
    for (int i = 0; i < n; ++i) {
        price[a[i]] += b[i];
    }

    for (auto shop:price) {
        long long buy = min((long long)k,shop.second);
        ans += buy * shop.first;
        k -= (int)buy;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 7296
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var count = 0;
        for (int i = 0; i < n; i++)
        {
            var minj = i;
            for (int j = i; j < n; j++)
                if (a[j] < a[minj]) { minj = j; }
            if (i != minj) { count++; swap(a, i, minj); }
        }
        for (int i = 0; i < n; i++)
            if (i != n - 1) Console.Write("{0} ", a[i]);
            else Console.WriteLine(a[i]);
        Console.WriteLine(count);
    }
    public static void swap(int[] a, int i, int j)
    {
        var t = a[i];
        a[i] = a[j];
        a[j] = t;
    }
}



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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 1e6+5;
string s;
vector<int> v[N];
ll n,m;
ll a,b,x;

template <typename T> bool is_prime(T n) {
  for (int i = 2; i*i <= n; i++) {
    if( n % i == 0) return false;
  }
  return n != 1;
}

int main () {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin >> n;
  while(!is_prime(n++)){}
  
  cout << n-1 << endl;
}


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

int main(){
  ll A,B,N;
  cin>>A>>B>>N;
  ll ans=0;
  ll kou;
  kou=min(B-1,N);
    ans=(A*kou)/B-A*(kou/B);
  cout<<ans;
}


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

string S;

int main() {
	cin >> S;
	if (S[0] == 'R' && S[1] == 'R' && S[2] == 'R') cout << 3;
	else if ((S[0] == 'R' && S[1] == 'R') || (S[1] == 'R' && S[2] == 'R')) cout << 2;
	else if (S[0] == 'R' || S[1] == 'R' || S[2] == 'R') cout << 1;
	else cout << 0;
	return 0;
}

Measured memory_bytes: 3608
package main

import "fmt"

func main() {
	var a, b, c, d, total int
	fmt.Scan(&a, &b, &c, &d)
	if a < b {
		total += a
	} else {
		total += b
	}
	if c < d {
		total += c
	} else {
		total += d
	}

	fmt.Println(total)
}


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

typedef long long ll;
typedef long double ld;
// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// use merge(all(vec1), all(vec2), vec3.begin()) to merge 2 vectors, use vec3.resize(vec1.size() + vec2.size()) first
// ll pos = partition_point(all(vec), pred) - vec.begin(); bool pred(ll a){return a<3};
// print number in binary -> cout << bitset<20>(n);

int main(){
	ll a;cin>>a;
	cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3592