akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

class Dice
{
public:
    int f[6];
    Dice(){}
    void roll_z(){ roll(1, 2, 4, 3); }
    void roll_y(){ roll(0, 2, 5, 3); }
    void roll_x(){ roll(0, 1, 5, 4); }
    void roll(int i, int j, int k, int l){
        int t = f[i];
        f[i] = f[j];
        f[j] = f[k];
        f[k] = f[l];
        f[l] = t;
    }
    void move(char ch){
        if (ch == 'E') for (int i = 0; i < 3; i++) roll_y();
        if (ch == 'W') roll_y();
        if (ch == 'N') roll_x();
        if (ch == 'S') for (int i = 0; i < 3; i++) roll_x();
    }
};

int main()
{
    Dice dice;
    string dir;
    for (int i = 0; i < 6; i++)
        cin >> dice.f[i];
    cin >> dir;
    for (int i = 0; i < dir.size(); i++)
    {
        dice.move(dir[i]);
    }
    cout << dice.f[0] << endl;
    return 0;
}


Measured memory_bytes: 3184
#include <iostream> //üoÍ
#include <string>   //¶ñ
#include <vector>   //®Izñ
#include <sstream>  //¶ñtH[}bg
#include <cctype>
#include <cstdlib>

using namespace std;

int main(){
	string s;
	
	char c;
	int	n = 0;
	while(cin >> s){
	
		for(int i = 0; i < s.size(); i++){
			if(isdigit(s[i]) != 0){
				int j = i;
				for( i ; isdigit(s[i]) != 0; i++){
				}
				string str = "";
				for( j ; j != i ; j++){
					str += s[j];
				}
				n += atoi(str.c_str());
			}
		}

	}
	

	cout << n << endl;
	

	return 0;
	
}

Measured memory_bytes: 0
/*    Hariom_Pandey
	01-12-2019 13:19:39
*/
#include<bits/stdc++.h>
using namespace std;

#define All(a)          (a).begin(), (a).end()
#define Sort(x)         sort(All(x))
#define ll              long long int 
#define ull             unsigned ll
#define ld              long double
#define vll             vector<ll>
const ll MOD = (ll) 1e9 + 7;
inline long long int LD(long long int n) { return (n % 10);}
inline long long TT(long long int n){int digits = (int)log10(n);}
#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Unique(v)       Sort(v); (v).resize(unique(All(v)) - (v).begin())
inline ll Gcd(ll a, ll b) {ll r; while(b){ r = a % b; a = b; b = r;} return a;}
inline ll Lcm(ll a, ll b) {return a / Gcd(a, b) * b;}
inline ll Pow(ll n, ll k) {ll r = 1; for(; k; k >>= 1, n = n * n % MOD){if(k & 1) r = r * n % MOD;} return r;}
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))


signed main() {
	vector<int> v{100,101,102,103,104,105};
	ll m1,d1,m2,d2;
	cin>>m1;
	ll f=0;
	for(int i=m1;i>=1;i--)
	{
		double tmp=i*1.08;
		if(floor(tmp)==m1)
		{
			cout<<i<<endl;
			f=1;
			break;
		}
	}
	if(!f)
	{
		cout<<":("<<endl;
	}
	return 0;

}

Measured memory_bytes: 256
def modinv(x, mod):
    a, b = x, mod
    u, v = 1, 0
    while b:
        t = a // b
        a -= t * b; a, b = b, a
        u -= t * v; u, v = v, u
    return u % mod


def _garner(xs, mods):
    M = len(xs)
    coeffs = [1] * M
    constants = [0] * M
    for i in range(M - 1):
        mod_i = mods[i]
        v = (xs[i] - constants[i]) * modinv(coeffs[i], mod_i) % mod_i
        for j in range(i + 1, M):
            mod_j = mods[j]
            constants[j] = (constants[j] + coeffs[j] * v) % mod_j
            coeffs[j] = (coeffs[j] * mod_i) % mod_j

    return constants[-1]


def bit_reverse(d):
    n = len(d)
    ns = n >> 1
    nss = ns >> 1
    ns1 = ns + 1
    i = 0
    for j in range(0, ns, 2):
        if j < i:
            d[i], d[j] = d[j], d[i]
            d[i + ns1], d[j + ns1] = d[j + ns1], d[i + ns1]
        d[i + 1], d[j + ns] = d[j + ns], d[i + 1]
        k = nss
        i ^= k
        while k > i:
            k >>= 1
            i ^= k
    return d


def _ntt(a, sign, mod, g):
        n = len(a)
        tmp = (mod - 1) * modinv(n, mod) % mod  # -1/n
        h = pow(g, tmp, mod)  # ^n√g
        if sign < 0:
            h = modinv(h, mod)

        a = bit_reverse(a)

        m = 1
        while m < n:
            m2 = m << 1
            _base = pow(h, n // m2, mod)
            _w = 1
            for x in range(m):
                for s in range(x, n, m2):
                    u = a[s]
                    d = a[s + m] * _w % mod
                    a[s] = (u + d) % mod
                    a[s + m] = (u - d) % mod
                _w = _w * _base % mod
            m <<= 1
        return a

def ntt(a, mod, g):
        return _ntt(a, 1, mod, g)
  
def intt(a, mod, g):
        n = len(a)
        n_inv = modinv(n, mod)
        a = _ntt(a, -1, mod, g)
        for i in range(n):
            a[i] = a[i] * n_inv % mod
        return a
      
def convolution(a, b, mod, g):
        ret_size = len(a) + len(b) - 1
        n = 1 << (ret_size - 1).bit_length()
        _a = a + [0] * (n - len(a))
        _b = b + [0] * (n - len(b))
        _a = ntt(_a, mod, g)
        _b = ntt(_b, mod, g)
        _a = [x * y % mod for x, y in zip(_a, _b)]
        _a = intt(_a, mod, g)
        _a = _a[:ret_size]
        return _a


def convolution_ntt(a, b, mod):
    a = [x % mod for x in a]
    b = [x % mod for x in b]

    mods = (167772161, 469762049, 1224736769, mod)

    ntt1 = NTT(mods[0], 3)
    ntt2 = NTT(mods[1], 3)
    ntt3 = NTT(mods[2], 3)

    x1 = ntt1.convolution(a, b)
    x2 = ntt2.convolution(a, b)
    x3 = ntt3.convolution(a, b)

    n = len(x1)
    ret = [0] * n
    for i in range(n):
        xs = [x1[i], x2[i], x3[i], 0]
        ret[i] = _garner(xs, mods)

    return ret

N = 100000
A = []
B = []
s = 0
for i in range(N):
    s = (s * 3 + i * 7) % 100
    a = s
    b = (s * 3 + a * 11) % 100
    A.append(a)
    B.append(b)

AB = convolution(A, B, 998244353, 5)


#####
A, B, C, K = map(int, input().split())
if K <= A + B:
    print(min(A, K))
else:
    print(A - (K - A - B))


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


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

    if (isupper(s)){
        cout << "A" << endl;
    }
    else{
        cout << "a" << endl;
    }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    int n;
    cin>>k>>n;
    int a[200000];
    int i;
    int j;
    int minimum;
    if(k>=2&&k<=1000000&&n>=2&&n<=200000)
    {
        for(i=0;i<n;i++)
            cin>>a[i];
    }

    j=0;
    while(j<n)
    {
        if(j==0)
            minimum=min(a[n-1]-a[0],k-(a[1]-a[0]));
        else
        {
            minimum=min(minimum,k-(a[j]-a[j-1]));
            minimum=min(minimum,k-(a[j+1]-a[j]));
        }
        j++;
    }
    cout<<minimum<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
long long chiyo(long long x){
    if(x%4==0) return x;
    if(x%4==1) return 1;
    if(x%4==2) return x+1;
    if(x%4==3) return 0;
}
int main(){
    long long n,m,a=0,b=0,A[200000]={0},B[200000]={0},ans=0;
    cin>>n>>m;
    n=chiyo(n-1),m=chiyo(m);
    while(n>0) A[a]=n%2,n=n/2,a++;
    while(m>0) B[b]=m%2,m=m/2,b++;
    long long p=max(a,b);
    rep(i,p) ans+=((A[i]+B[i])%2)*pow(2,i);
    cout<<ans;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int test(const char *num, char *tr){
	char *last = tr;
	for(int i = 0; i < 3; ++i){
		last = strchr(last, num[i]);
		if(last == NULL) return 0;
		last++;
	}
	return 1;
}
int main(){
	int sum = 0, d;
	char num[4] = {0, 0, 0, '\0'}, str[30004];
	cin >> d >> str;
	for(int x0 = '0'; x0 <= '9'; ++x0){
		num[0] = x0;
		for (int x1 = '0'; x1 <= '9'; ++x1){
			num[1] = x1;
			for (int x2 = '0'; x2 <= '9'; ++x2){
				num[2] = x2;
				sum += test(num, str);
			}
		}
	}
	cout << sum << '\n';
}

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


int main() {
  vector<bool> vec(10, true);
  int n, k;
  cin >> n >> k;
  rep(i,k){
    int x; cin >> x;
    vec[x] = false;
  }
  for(int i=n; i<100000; i++){
    int x = i;
    bool flag = true;
    while(x>0){
      int d = x%10;
      if(vec[d] == false){
        flag = false;
        break;
      }
      x /= 10;
    }
    if(flag){
      if(n<=i){
        cout << i << endl;
        return 0;
      }
    }
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<pii> v(n);
    REP(i,n) cin >> v[i].first >> v[i].second;
    vector<int> p(n);
    iota(ALL(p),0);

    double ans = 0;
    int count = 0;
    do {
        double tmp = 0;
        REP(i,n-1) {
            tmp += sqrt(pow(v[p[i]].first - v[p[i+1]].first,2) +
                        pow(v[p[i]].second - v[p[i+1]].second,2));
        }
        ans += tmp;
        count++;
    } while(next_permutation(ALL(p)));

    ans /= count;

    cout << fixed << setprecision(10) << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long
#define ull unsigned long long
#define IO(x,y) freopen(x,"r",stdin);freopen(y,"w",stdout)
#define fo(x) while(x-->0)
#define nl '\n'
#define pb push_back

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// IO("in.txt", "out.txt");
	int i, n, in;
	cin >> n;
	int h[n], c[n];
	for(i=0; i<n; i++){
		cin >> h[i];
	}
	c[n-1]=0;
	c[n-2]=abs(h[n-1]-h[n-2]);
	for(i=n-3; i>=0; i--){
		c[i]=min(c[i+1]+abs(h[i]-h[i+1]),c[i+2]+abs(h[i]-h[i+2]));
	}
	cout << c[0];
}


Measured memory_bytes: 1024
#include<stdio.h>

void sort(int *a, int N) {
  int i, tmp, flag, k;
  k = 0;
  do {
    flag = 0;
    for (i = 0; i < N-1-k;i++) {
      if(a[i] > a[i+1]) {
	flag = 1;
	tmp = a[i];
	a[i] = a[i+1];
	a[i+1] = tmp;
      }
    }
    k++;
  } while(flag == 1);
}

int main(void) {
  int a[12], i;
  for (i = 0; i < 12; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, 12);

  if(a[0]==a[3]&&a[4]==a[7]&&a[8]==a[11]) printf("yes\n");
  else printf("no\n");

  return 0;
}

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

ll patty(ll n,ll x){
    if(n==0) return 1ll;
    if(x==1) return 0ll;
    if(x==((1ll<<(n+2))-3ll)) return (1ll<<(n+1))-1ll;
    if(x<((1ll<<(n+1))-1ll)) return patty(n-1,x-1);
    if(x==((1ll<<(n+1))-1ll)) return 1ll<<n;
    if(x>((1ll<<(n+1))-1ll)) return (1ll<<n)+patty(n-1,x-((1ll<<(n+1))-1ll));
}
int main(){
    ll n,x;
    cin >> n >> x;
    cout << patty(n,x) << endl;
    return 0;
}

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

int main() {
    long long X, Y;
    cin >> X >> Y;

    int ans = 0;
    while (X <= Y) {
        ans++;
        X *= 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;

public class Main {
	/**
	* @param args
	*/

	static class SH {
		public	int	n;
		public	int	d;
		public	int	b;
		public SH(int n, int d, int b) {
			this.n = n;
			this.d = d;
			this.b = b;
		}
	}

	public	static	SH[]		t = null;
	public	static	double[][]	d = null;
	public	static	int[][][]	p = null;

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int		n   = parseNum();
		int[]	tmp = new int[2];
		double	min = Double.MAX_VALUE;
		String	out = "";

		t = new SH[n];
		d = new double[n][1<<n];
		p = new int[n][1<<n][2];

		for (int i = 0; i < n; i++) {
			t[i] = new SH(parseNum(), parseNum(), parseNum());
			Arrays.fill(d[i], Double.MAX_VALUE);
		}

		solve(0, 0, 0, 1);

		for (int i = 0; i < n; i++) {
			if (d[i][1<<i] < min) {
				min    = d[i][1<<i];
				tmp[0] = 1<<i;
				tmp[1] = i;
			}
		}

		while (tmp[0] != -1) {
			if (out.isEmpty()) {
				out += ""+t[tmp[1]].n;
			} else {
				out += " "+t[tmp[1]].n;
			}
			tmp = p[tmp[1]][tmp[0]];
		}

		System.out.println(out);
	}

	private	static double solve(int state, int j, int w, int dp) {
		double min = Double.MAX_VALUE;

		if (state == (1<<t.length)-1) {
			p[j][state] = new int[]{-1, -1};
			return 0.0;
		}

		if (d[j][state] != Double.MAX_VALUE) {
			return d[j][state];
		}

		for (int i = 0; i < t.length; i++) {
			double tmp = (dp == 1)?0.0:Math.abs(t[j].d-t[i].d)/(2000.0/(70+w));
			if ((state&(1<<i))!=0) continue;

			tmp += solve(state+(1<<i), i, w+20*t[i].b, dp+1);
			if(tmp < min){
				if (dp > 1) {
					p[j][state] = new int[]{state+(1<<i), i};
				}
				min = tmp;
			}
		}

		if (dp > 1) d[j][state] = min;
		return min;
	}
	private static int parseNum() {
		try {
			int	buf = 0;
			int	num = 0;
			int	mns = 0;
			int	skp = 1;

			// -,0〜9以外は読み飛ばす
			while (true) {
				buf = System.in.read();
				if (buf == '-') {
					mns = 1;
					skp = 0;
				} else if (buf >= '0' && buf <= '9') {
					num = num * 10 + (buf - '0');
					skp = 0;
				} else if (skp == 0) {
					return (mns == 0)?num:num*(-1);
				}
			}
		} catch (IOException e) {}
		return -1;
	}
}

Measured memory_bytes: 54292
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n, m; cin >> n >> m;
    vll a(n); for(auto& e : a) cin >> e;
    vll lcnt(2 * m), rcnt(2 * m), rval(2 * m);
    ll sum = 0;
    rep(i, n - 1){
        int s = a[i], t = a[i + 1];
        if(s > t) t += m;
        lcnt[s]++;
        rcnt[t]++;
        rval[t] += (t - s);
        sum += t - s;
    }

    vll res(m, sum);
    ll cur = 0;
    ll num = 0;
    rep(i, 2 * m){
        // cerr << i << ": cur = " << cur << ", num = " << num << endl;
        res[i % m] -= cur;
        cur += num;
        cur -= rval[i];
        num += lcnt[i] - rcnt[i];
    }

    cout << *min_element(_all(res)) << endl;

    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int a;
	cin >> a;

	int b = a % 10;
	string ans = "";
	if (b == 3)
	{
		ans = "bon";
	}
	else if(b == 0 || b == 1 || b == 6 || b == 8)
	{
		ans = "pon";
	}
	else{
		ans = "hon";
	}
	cout << ans << endl;
}

int main()
{
	fastio;
	solve();

	return 0;
}

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

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

    vector<int> W(N);
    for (int i = 0; i < N; i++)
    {
        cin >> W[i];
    }

    vector<int> sum(N);
    sum[0] = W[0];
    for (int i = 1; i < N; i++)
    {
        sum[i] = sum[i - 1] + W[i];
    }

    vector<int> ans(N);
    for (int i = 0; i < N; i++)
    {
        ans[i] = abs(sum[N - 1] - sum[i] * 2);
    }

    cout << *min_element(ans.begin(), ans.end()) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int N = 100;

int main() {
    int M[N][N];
    int n, u, k, v; cin >> n;
    
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) M[i][j] = 0;
    }
    
    for(int i=0; i<n; i++) {
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++) {
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    for(int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            if(j) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
object Main extends App {
	override def main(args: Array[String]){
		val sc = new java.util.Scanner(System.in)
		
		val n = sc.nextInt
		val m = sc.nextInt
		val l = sc.nextInt
		
		val m1 = new Matrix(n,m);
		for(i <- (0 until n) ; j <- (0 until m)){
			m1(i,j) = sc.nextInt
		}

		val m2 = new Matrix(m,l);
		for(i <- (0 until m) ; j <- (0 until l)){
			m2(i,j) = sc.nextInt
		}
		
		val res = m1.product(m2)
		
		for(i <- (0 until n); j<- (0 until l)){
			print(res(i,j))
			j match{
				case x:Int if x == l-1 => println
				case _ => print(" ")
			}
		}
		
	}
	
}

class Matrix(val h: Int , val w :Int){
	val matrix = Array.ofDim[Long](h,w)
	
	def update(i:Int , j:Int , newValue:Long):Unit = {
		matrix(i)(j) = newValue
	}
	def apply(i:Int,j:Int): Long = matrix(i)(j)
	
	def product(right:Matrix):Matrix = {
		val ret = new Matrix(h , right.w)
		for(i <- (0 until h) ; j <- (0 until w) ; k <- (0 until right.w)){
			ret(i,k) = ret(i,k) + apply(i,j) * right(j,k)
		}
		
		ret
	}
}

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

int main(){
  int n[4] = {0};
  int a[4] = {1, 4, 7, 9};
  int ans = 0;
  cin >> n[0] >> n[1] >> n[2] >> n[3];
  
  sort(n, n + 4);
  
  for(int i = 0; i < 4; ++i){
    if(n[i] != a[i]){
      ans = 1;
      break;
    }
  }
  if(ans == 1){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
S = str(input())

ans = S[1:].count('E')
tmp = S[1:].count('E')
for i in range(N-1):
  if S[i] == 'W':
    tmp += 1
  if S[i+1] == 'E':
    tmp -= 1
  ans = min(ans, tmp)
    
print(ans)

Measured memory_bytes: 9732
class WeightedUnionFind:
    def __init__(self, size):
        """
        :param collections.Iterable nodes:
        """
        self._parents = [i for i in range(size)]
        self._ranks = [0 for _ in range(size)]
        self._sizes = [1 for _ in range(size)]
        # 直近の親からの重み。root なら 0
        self._weights = [0 for _ in range(size)]
 
    def unite(self, x, y, w):
        """
        x が属する木と y が属する木を併合
        :param x:
        :param y:
        :param w: x と y の重みの差; (重み y) - (重み x)
        :return:
        """
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return
 
        # rank が小さい方が下
        if self._ranks[rx] > self._ranks[ry]:
            # x が root
            self._parents[ry] = rx
            self._sizes[rx] += self._sizes[ry]
            # root 間の重みに変換
            self._weights[ry] = w + self._weights[x] - self._weights[y]
        else:
            # y が root
            self._parents[rx] = ry
            self._sizes[ry] += self._sizes[rx]
            # root 間の重みに変換
            self._weights[rx] = -w + self._weights[y] - self._weights[x]
            if self._ranks[rx] == self._ranks[ry]:
                self._ranks[ry] += 1
 
    def find(self, x):
        """
        x が属する木の root
        :param x:
        :return:
        """
        if self._parents[x] == x:
            return x
        root = self.find(self._parents[x])
        self._weights[x] += self._weights[self._parents[x]]
        self._parents[x] = root
        return root
 
    def size(self, x):
        """
        x が属する木のノード数
        :param x:
        :return:
        """
        return self._sizes[self.find(x)]
 
    def weight(self, x):
        """
        :param x:
        :return:
        """
        # 経路圧縮
        self.find(x)
        return self._weights[x]
 
    def diff(self, x, y):
        """
        (y の重み) - (x の重み)
        :param x:
        :param y:
        :return:
        """
        if self.find(x) == self.find(y):
            return self._weights[y] - self._weights[x]
        return float('inf')
n=int(input())
uf=WeightedUnionFind(n)
for i in range(n-1):
    u,v,w=map(int, input().split())
    uf.unite(u-1,v-1,w)
C=[0]*n
for i in range(1,n):
    if uf.diff(i,0)%2==0:
        C[i]=0
    else:
        C[i]=1
for i in range(n):
    print(C[i])


Measured memory_bytes: 13588
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
int a[210000];

int main() {
  while (cin >> N) {
    for (int i = 0; i < N; ++i) cin >> a[i];
    int num[210000] = {0};
    for (int i = 0; i < N; ++i) {
      num[a[i]]++;
    }

    int res = 0;
    for (int i = 1; i <= 100000; ++i) {
      int tmp = num[i] + num[i-1] + num[i+1];
      chmax(res, tmp);
    }
    cout << res << endl;
  }
}













Measured memory_bytes: 1408
<?php

while($line = fgets(STDIN)){
    $line = trim($line);
    
    $x = array();
    for($i = 0; $i < strlen($line); $i++){
    	$x[] = intval($line[$i]);
    }
    
    while(count($x) > 1){
    	$x = calcBottom($x);
    }
    
    echo $x[0]."\n";
}


function calcBottom($arr){
	$ret = array();
	for($i = 0; $i < count($arr) - 1; $i++){
		$ret[] = ($arr[$i] + $arr[$i + 1]) % 10;
    }
	return $ret;
}

Measured memory_bytes: 15112
x, k, d = io.read("*n","*n","*n")

x = math.abs(x)

if math.abs(x) // d >= k then
  print(math.abs(x) - k*d)
else
  k = k - x // d
  x = x - x // d * d
  if (k % 2 == 1) then x = math.abs(x - d) end
  print(x)
end


Measured memory_bytes: 2792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int main()
{
	int n,m;
	cin>>n>>m;
	cout<<(n-1)*(m-1);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;


int main() { 
    ll N, M, C, x, sum, n=0;
    cin >> N >> M >> C ;
    vector<ll> B;
    for(int i=0; i<M; i++){
        cin >> x;
        B.emplace_back(x);
    }

    for(int j=0; j<N; j++){
        sum=C;
        for(int i=0; i<M; i++){
            cin >> x;
            sum += x*B[i];
        }
        if(sum > 0) n++;
    }
    cout << n << endl;
}

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

cnt = [0]*(10**6+1)

for elem in a:
    cnt[elem] += 1

unique = []
for i in range(10**6+1):
    if cnt[i] == 1:
        unique.append(i)

cnt = [0]*(10**6+1)
a = list(set(a))

for elem in a:
    for m in range(elem*2,10**6+1,elem):
        cnt[m] = 1

ans = 0
for elem in unique:
    if cnt[elem] == 0:
        ans += 1

print(ans)

Measured memory_bytes: 48140
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[3];
		Arrays.fill(a, -1);

		for (int i = 0; i < M; i++) {
			int s = sc.nextInt() - 1;
			int c = sc.nextInt();
			if (a[s] != -1 && a[s] != c) {
				System.out.println(-1);
				return;
			}

			if (s + 1 > N) {
				System.out.println(-1);
				return;
			}

			a[s] = c;
		}

		if (N == 1) {
			System.out.println((a[0] != -1) ? a[0] : 0);
			return;
		}

		if (N >= 2 && a[0] == 0) {
			System.out.println(-1);
			return;
		}

		if (a[0] == -1) {
			a[0] = 1;
		}

		for (int i = 1; i < N; i++) {
			if (a[i] == -1) a[i] = 0;
		}

		for (int i = 0; i < N; i++) {
			System.out.print(a[i]);
		}

		System.out.println();
	}
}


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

using namespace std;

int main() {
	int r, g, b;
	scanf( "%d%d%d", &r, &g, &b );
	int x = r*100 + g*10 + b;
	puts( x % 4 == 0 ? "YES" : "NO" );
	return 0;
}


Measured memory_bytes: 256
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007
#define PI acos(-1)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>

using namespace std;

// clang-format on

main {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a <= c && c <= b ? "Yes" : "No") << endl;
  bye;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////


int main(){
  inl(N);
  for(ll h = 1; h <= 3500 ; h++){
    for(ll n = 1; n <= 3500; n++){
      if( (4LL * h * n) % N != 0) continue;
      ll x = 4 * h * n / N - h - n;
      if(x <= 0) continue;
      if(h * n % x != 0) continue;
      ll w = h * n / x;
      out(h , n , w); exit(0);
    }
  }

}

Measured memory_bytes: 256
(defun princ-list (lst)
  (princ (car lst))
  (if (cdr lst) (progn (princ " ") (princ-list (cdr lst)))))
(let* ((n (read))
       (lst (loop :repeat n :collect (read)))
       (ans nil))
  (if (cdr lst)
      (progn
        (setf ans (concatenate 'list
                               (reverse (loop :for k :in (cdr lst) :by #'cddr :collect k))
                               (loop :for k :in lst :by #'cddr :collect k)))
        (if (evenp n)
            (princ-list ans)
            (princ-list (reverse ans))))
      (princ (car lst))))


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

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

  int ans = 1000;
  for (int i = 0; i < S.size() - 2; i++) {
    int X = (S[i] - '0') * 100 + (S[i + 1] - '0') * 10 + S[i + 2] - '0';
    ans = min(ans, abs(753 - X));
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
const ld pi = acos(-1);
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    set<int> s;
    FOR(i, 0, n) {
        int a; cin >> a;
        s.insert(a);
    }
    cout << s.size() << "\n";
}



Measured memory_bytes: 7772
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int p, f = 0, a;
  a = s.size();
  char k = s[0];
  char r = s[2];
  for(int i = 1; i < a; i++){
    if(k == s[i]){
      break;
    }
    if(k != s[i]){
      r = s[i];
    }
    if(i == 3){
      cout << "No\n";
      return 0;
    }
  }
  if(k == r){
    cout << "No\n";
    return 0;
  }
  for(int i = 1; i < a; i++){
    if(r == s[i]){
      f++;
    }
    if(f == 2){
      break;
    }
    if(i == 3){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
}
  

Measured memory_bytes: 3592
#include <stdio.h>

int main(void)
{
	int N,flg=0;
	int cake[27] = {'\0'};
	int donut[16] = {'\0'};

	scanf("%d", &N);

	for (int i = 0; 4*i <= N; i++) {
		cake[i] = 4 * i;
		for (int j = 0; 7 * j <= N; j++) {
			donut[j] = 7 * j;
			if (cake[i] + donut[j] == N) {			
				flg = 1;
				break;
			}
		}
		if (flg == 1) {
			break;

		}
	}

	if (flg == 0) {
		printf("No\n");
	}
	else {
		printf("Yes\n");
	}

	return 0;
}

Measured memory_bytes: 128
// SPDX-License-Identifier: X11
// 2020-08-02 (Live)

#include <stdio.h>

int main() {
  long N,D;
  scanf("%ld %ld", &N, &D);
  long X,Y,n = 0;
  for (long i = 0; i < N; i++) {
    scanf("%ld %ld", &X, &Y);
    if (D*D >= X*X + Y*Y)
      n++;
  }
  printf("%ld\n", n);
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

char toLowerCase(char c){
  if(isLowerCase(c)){
    return c;
  }else{
    return c+'a'-'A';
  }
}
char toUpperCase(char c){
  if(isLowerCase(c)){
    return c-('a'-'A');
  }else{
    return c;
  }
}
ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int ans=0;
  for(int i=0;i<n;i+=2){
    if(a[i]%2!=0){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


int main(){
	int N; cin >> N;
	set<int> d;
	for (int i = 0; i < N; i++) {
		int p; cin >> p;
		d.insert(p);
	}

	print(d.size());

	return 0;
}

Measured memory_bytes: 256
import math
from itertools import permutations
menu = 5
times = [int(input()) for _ in  range(menu)]
orders = list(permutations(times, menu))
minimum = sum(math.ceil(time / 10) * 10 for time in times)

for order in orders:
    total = order[0]
    for i in range(1, menu):
        total += math.ceil(order[i]/10)*10
    minimum = min(total, minimum)
print(minimum)

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

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if (a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3672
import math
n, aa = int(input()), list(map(int, input().split()))
l = max(aa)
r = 99999999999999
ar = sorted(aa)
for a in aa:
    if a == l:
        continue
    if abs(a - l/2) < abs(r - l/2):
        r = a
print(l, r)


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    long long d,n;
    cin>>n>>d;
    int ans = 0;
    for(int i=0; i<n; i++){
        long long p,q;
        cin>>p>>q;
        if(p*p+q*q<=d*d) ans++;
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	string s;
	ll k, ans= 0, d = 0;
	cin >> s >> k;
	int i = 1;
	bool same = true;
	REP(i, 1, (int)s.size()){
		if(s[i] != s[0]){
			same = false;
			break;
		}
	}
	
	if(same){
		cout << (int)s.size()*k/2;
		return 0;
	}
	
	while(i < (int)s.size()){
		if(s[i] == s[i-1]){
			++d;
			++i;
		}
		++i;
	}
	ans = d*k;
	int ss = s.size()-1;
	if(s[0] == s[ss]){
		int a = 0;
		int b = 0;
		while(a <= ss && s[a] == s[0]) ++a;
		while(ss- b >= 0 && s[ss-b] == s[0]) ++b;
		ans -= ((a/2 +b/2 - (a+b)/2) * (k-1));
	}
		
	
	
	cout << ans;
	
}


Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	count := 0
	mp := map[int]bool{}
	sN := N
	for i := 2; i*i <= sN; i++ {
		b := i
		for N%i == 0 {
			//fmt.Println(N, i, b, count)
			N /= i

			if _, ok := mp[b]; !ok {
				//fmt.Printf("%+v\n", mp)
				count++
				mp[b] = true
				b = 1
			}
			b *= i

		}
		//fmt.Println(i)
	}
	//fmt.Println(N)
	if _, ok := mp[N]; N > 1 && !ok {
		//fmt.Println(N)
		count++
	}
	fmt.Println(count)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1776
#include <stdio.h>

int sortplus(int x[],int y[],int l){
	int h,i,j,k;
	for(i=1;i<=l;i++){
		for(j=l;j>=i+1;j--){
			if(x[j-1]>x[j]){
				k=x[j];
				h=y[j];
				x[j]=x[j-1];
				y[j]=y[j-1];
				x[j-1]=k;
				y[j-1]=h;
			}
		}
	}
	return 0;
}

int main(void) {
	int d[16384],xy[16384],h,w,s,k,i,no=0;
	for(h = 1;h <= 150;h++){
		for(w = h+1;w <= 150;w++){
			no++;
			d[no] = h*h+w*w;
			xy[no] = 1000*h+w;
		}
	}
	sortplus(d,xy,no);
	while(scanf("%d%d",&h,&w) , h != 0){
		s = h*h+w*w;
		k = 1000*h+w;
		for(i = 1;i <= no;i++){
			if(xy[i] == k){
				printf("%d %d\n",xy[i+1] / 1000,xy[i+1] % 1000);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 692
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

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

int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        vector<int>x(n),y(n);
        x[0]=0,y[0]=0;
        for(int i=1;i<n;i++){
            int index,d;
            cin>>index>>d;
            x[i]=x[index]+dx[d];
            y[i]=y[index]+dy[d];
        }
        int xmax = x[0],xmin = x[0];
        int ymax = y[0],ymin = y[0];
        for(int i=0;i<n;i++){
            xmax = max(xmax,x[i]);
            xmin = min(xmin,x[i]);
            ymax = max(ymax,y[i]);
            ymin = min(ymin,y[i]);
        }
        cout<<(xmax-xmin+1)<<" "<<(ymax-ymin+1)<<endl;
    }
    return 0;
}


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

using namespace std;

//奇数があるかな？
bool odd_check(vector<long> a){
    int n = a.size();
    for (int i = 0; i < n; i++){
        if (a[i] % 2 != 0){
            return false;
        } 
    }
    return true;
}


int main()
{
    int N;  cin >> N;
    vector<long> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    int ans = 0;
    while (odd_check(A)){
        for (int i = 0; i < N; i++){
                A[i] /= 2;
        }
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    cout.setf(ios::fixed);
    double L;
    cin>>L;
    cout<<fixed<<setprecision(12)<<(L*1.0/3)*(L*1.0/3)*(L*1.0/3);

    return 0;
}



Measured memory_bytes: 256
n=int(input())
h=list(map(lambda x: int(x), input().split()))
INF=10**10
dp=[INF]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2, n):
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]))
print(dp[n-1])

Measured memory_bytes: 13976
#include <algorithm>
#include <iostream>

using namespace std;

template <typename T, T MOD_>
class ModInt {
public:
	ModInt() = default;
	ModInt(T num)
		: num_(num)
	{ }

	const ModInt &operator=(T num) {
		num_ = num % MOD_;
		return *this;
	}
	ModInt operator+(T num) {
		return ModInt((num_ + num) % MOD_);
	}
	ModInt operator-(T num) {
		return ModInt((num_ + MOD_ - num) % MOD_);
	}
	ModInt operator*(T num) {
		return ModInt((num_ * (num % MOD_)) % MOD_);
	}
	ModInt operator/(T num) {
		const auto inv = inverse(num);
		return ModInt((num_ * inv) % MOD_);
	}
	const ModInt &operator+=(T num) {
		num_ = (*this + num).num_;
		return *this;
	}
	const ModInt &operator-=(T num) {
		num_ = (*this - num).num_;
		return *this;
	}
	const ModInt &operator*=(T num) {
		num_ = (*this * num).num_;
		return *this;
	}
	const ModInt &operator/=(T num) {
		num_ = (*this / num).num_;
		return *this;
	}
	bool operator==(T num) {
		return num_ == num;
	}

	friend std::ostream &operator<<(std::ostream &os, const ModInt &modint) {
		os << modint.num_;
		return os;
	}

	T num() const {
		return num_;
	}

private:
	T inverse(T num) const {
		return modpow(num, MOD_ - 2);
	}
	T modpow(T num, T n) const {
		T result = 1;
		while(n > 0) {
			if(n & 1) {
				result = result * num % MOD_;
			}
			num = num * num % MOD_;
			n >>= 1;
		}
		return result;
	}


	T num_;
};

const int MOD = 1'000'000'007;
using Mod = ModInt<long long, MOD>;

int main() {
	int X, Y;
	cin >> X >> Y;

	if((X + Y) % 3 != 0
		|| X * 2 < Y
		|| Y * 2 < X) {
		cout << 0 << endl;
		return 0;
	}

	// 移動回数
	const int n = (X + Y) / 3;
	// 右の方に跳ぶ回数
	const int right = X - n;

	Mod result = 1;
	const int t = max(right, n - right);
	for(int i = 0; i < t; i++) {
		result *= (n - i);
	}
	for(int i = 0; i < t; i++) {
		result /= (i + 1);
	}

	cout << result << endl;

	return 0;
}


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

int main(void){
  long long H, temp;
  cin >> H;
  long long count = 0;
  long long sum = 0;
  temp = H;
  while(temp / 2 >= 1){
    temp = temp / 2;
    count++;
  }
  for(long long i = 0; i <= count; i++){
   sum += pow(2, i); 
  }
  cout << sum;
 return 0; 
}

Measured memory_bytes: 256