akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <iomanip>

using namespace std;

#define rad first
#define pnt second
typedef long double ld;
typedef complex<ld> P;
typedef pair<ld,P> C;

const ld eps = 1e-10;
ld cross(const P& a, const P& b) { return a.real()*b.imag() - a.imag()*b.real(); }

C smallest_enclosing_disc(vector<P> ps) {
    auto c3 = [](const P &a, const P &b, const P &c) {
        ld A = norm(b - c);
        ld B = norm(c - a);
        ld C = norm(a - b);
        ld S = abs(cross(b - a, c - a));
        P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / (4 * S * S);
        ld r = abs(p - a);
        return make_pair(r, p);
    };

    auto c2 = [](const P &a, const P &b) {
        P c = (a + b) / (ld) 2;
        ld r = abs(a - c);
        return make_pair(r, c);
    };

    auto in_circle = [](const P &a, const C &c) {
        return norm(a - c.pnt) <= c.rad * c.rad + eps;
    };

    int n = ps.size();
    random_shuffle(ps.begin(), ps.end());
    C c = c2(ps[0], ps[1]);
    for (int i = 2; i < n; ++i) {
        if (!in_circle(ps[i], c)) {
            c = c2(ps[0], ps[i]);
            for (int j = 1; j < i; ++j) {
                if (!in_circle(ps[j], c)) {
                    c = c2(ps[j], ps[i]);
                    for (int k = 0; k < j; ++k) {
                        if (!in_circle(ps[k], c)) {
                            c = c3(ps[i], ps[j], ps[k]);
                        }
                    }
                }
            }
        }
    }
    return c;
}

int main() {
    int n;
    cin >> n;
    vector<P> points(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        points[i] = P(x, y);
    }
    cout << fixed << setprecision(15) << smallest_enclosing_disc(points).first << endl;
    return 0;
}

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

using namespace std;

int main() {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  int ans = 0;
  while (a != b || b != c) {
    if (b < a) swap(a, b);
    if (c < a) swap(a, c);
    if (c < b) swap(b, c);
    int d = c - a;
    if (d >= 2)
      a += 2;
    else {
      ++a;
      ++b;
    }
    ++ans;
  } 
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int H, W, K;
int MAP[1000][1000];
int x, y, vis[1000][1000];
int ans = 2147483647;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
struct PR {
    int x, y, now;
    PR() {x = y = now = 0;}
    PR(int _x, int _y, int _now) {x = _x, y = _y, now = _now;}
};
bool check(int x, int y) {
    if (x < 0 || x > H) return 0;
    if (y < 0 || y > W) return 0;
    if (MAP[x][y]) return 0;
    return 1;
}
int main() {
    cin >> H >> W >> K;
    for (int i = 1; i <= H; i ++) {
        string s;
        cin >> s;
        for (int j = 1; j <= W; j ++) {
            if (s[j - 1] == '#') MAP[i][j] = 1;
            else {
                MAP[i][j] = 0;
                if (s[j - 1] == 'S') x = i, y = j; 
            }
        }
    }
    queue<PR> Q; Q.push((PR){x, y, 0});
    while (!Q.empty()) {
        PR tmp = Q.front(); Q.pop();
        if (tmp.now > K) continue;
        if (vis[tmp.x][tmp.y] <= tmp.now && vis[tmp.x][tmp.y] != 0) continue;
        vis[tmp.x][tmp.y] = tmp.now;
		int num = min(min(H - tmp.x, W - tmp.y), min(tmp.x - 1, tmp.y - 1));
		num = (num + K - 1) / K;
		if (num + 1 > ans) continue;
		ans = min(ans, num + 1);
        for (int i = 0; i < 4; i ++) {
            if (check(tmp.x + dx[i], tmp.y + dy[i])) Q.push((PR){tmp.x + dx[i], tmp.y + dy[i], tmp.now + 1});
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

unsigned long long int c[2001][2001];

int main()
{
    int n, k;
    cin >> n >> k;

    c[0][0] = 1;

    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            if (j == 0 || j == i)
            {
                c[i][j] = 1;
            }
            else
            {
                c[i][j] = (c[i - 1][j - 1] % MOD) + (c[i - 1][j] % MOD);
                c[i][j] = c[i][j] % MOD;
            }
        }
    }

    for (int i = 1; i <= k; i++)
    {
        cout << c[k - 1][i - 1] * c[n - k + 1][i] % MOD << endl;
    }
}

Measured memory_bytes: 30080
#include <stdio.h>
#include <math.h>
//prototype
int main(void);
double SDcalc(int* _point, int _n);

int main(void){
  while(1){
    int n;   scanf("%d", &n);
    if(n == 0)  break;

    int test_point[n+1];
    for (int i = 0; i < n; i++) {
      scanf("%d", &test_point[i]);
    }

    double SD = SDcalc(test_point, n);

    printf("%lf\n", SD);
  }
  return 0;
}

double SDcalc(int* _point, int _n){
  double ave = 0.0;
  double s2  = 0.0;
  double sd  = 0.0;
  
  //Average
  for (int i = 0; i < _n; i++) {
    ave += (double)_point[i];
  }
  ave /= (double)_n;

  //Dispersion
  for (int i = 0; i < _n; i++) {
    s2 += pow(((double)_point[i] - ave), 2.0);
  }
  s2 /= (double)_n;

  //Standard Deviation
  sd = sqrt(s2);
  return sd;
}



Measured memory_bytes: 2100
import numpy as np


def getInput():
    separator = ' '
    ret_array = []
    while True:
        try:
            row = input().split(sep=separator)
            ret_array.append(row)
        except EOFError:
            break
    return ret_array


g = getInput()
N = g[0][0]
A = np.array(g[1], dtype=np.int32)
A = np.sort(A, kind='mergesort')
A = A[::-1]

idx = 0
ph = np.empty((2,), dtype=np.int32)
try:
    for c in range(0, 2):
        while True:
            if A[idx] == A[idx + 1]:
                ph[c] = A[idx]
                idx += 2
                break
            else:
                idx += 1
except IndexError:
    print(0)
    exit()

print(np.prod(ph))

Measured memory_bytes: 26856
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<class Graph>
pair<bool, vector<int>> toposort(const Graph &adj){
	int n = int(adj.size());
	vector<int> indeg(n), res;
	for(int u = 0; u < n; ++ u) for(auto v: adj[u]) ++ indeg[v];
	deque<int> q;
	for(int u = 0; u < n; ++ u) if (!indeg[u]) q.push_back(u);
	while(q.size() > 0){
		int u = q.front();
		q.pop_front();
		res.push_back(u);
		for(auto v: adj[u]) if (!(-- indeg[v])) q.push_back(v);
	}
	return {int(res.size()) == n, res};
}

int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> adj(n);
	for(int i = 0; i < m; ++ i){
		int u, v;
		cin >> u >> v, -- u, -- v;
		adj[u].push_back(v);
	}
	auto ts = toposort(adj).second;
	vector<int> pos(n);
	for(auto i = 0; i < n; ++ i){
		pos[ts[i]] = i;
	}
	vector<int> dp(n);
	for(auto i = 0; i < n; ++ i){
		int u = ts[i];
		for(auto v: adj[u]){
			ctmax(dp[pos[v]], dp[pos[u]] + 1);
		}
	}
	cout << *max_element(dp.begin(), dp.end());
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 7032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,K,mod;
inline int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
inline int sub(int a,int b){a-=b;return a<0?a+mod:a;}
inline int mul(int a,int b){return 1ll*a*b%mod;}
inline int qpow(int a,int b){int ret=1;for(;b;b>>=1,a=mul(a,a))if(b&1)ret=mul(ret,a);return ret;}
/* math */
const int N = 110;
int bin[N][N];
int c=0,f[2][N][N],cst[N][N];
int fac[N], ifac[N], pw[N][N*N];
int main()
{
	cin >> n >> m >> K >> mod;
	for(int i=0;i<=K;i++){
		pw[i][0]=1;for(int j=1;j<=n*m;j++)pw[i][j]=mul(pw[i][j-1],i);
	}
	fac[0]=ifac[0]=1;for(int i=1;i<=max(n,m);i++)fac[i] = mul(fac[i-1],i);
	ifac[max(n,m)]=qpow(fac[max(n,m)],mod-2);for(int j=max(n,m)-1;j;j--)ifac[j]=mul(ifac[j+1],j+1);
	f[c][0][0]=1;
	for(int D = 1;D<=K;D++){
		c^=1;memset(f[c],0,sizeof(f[c]));
		for(int j=0;j<=n;j++)
		for(int k=0;k<=m;k++){
			cst[j][k] = mul(mul(ifac[j],pw[D-1][j*(m-k)]), mul(pw[K-D+1][j*k], j%2?mod-1:1));
		}
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
			for(int k=0;k<=i;k++){
				f[c][i][j]=add(f[c][i][j], mul(f[c^1][i-k][j], cst[k][j]));
			}
		}
		// cout << f[c][0][0] << " " << f[c][0][1] << " " << f[c][1][0] << " " << f[c][1][1] << endl;
		c^=1;memset(f[c],0,sizeof(f[c]));
		for(int j=0;j<=m;j++)
		for(int k=0;k<=n;k++){
			cst[j][k] = mul(mul(ifac[j],pw[D-1][j*(n-k)]), mul(pw[K-D+1][j*k], j%2?mod-1:1));
		}
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
			for(int k=0;k<=j;k++){
				f[c][i][j]=add(f[c][i][j], mul(f[c^1][i][j-k], cst[k][i]));
			}
		}
		// cout << f[c][0][0] << " " << f[c][0][1] << " " << f[c][1][0] << " " << f[c][1][1] << endl;
		c^=1;memset(f[c],0,sizeof(f[c]));
		for(int j=0;j<=n;j++)
		for(int k=0;k<=m;k++){
			cst[j][k] = mul(mul(ifac[j],pw[D][j*(m-k)]), mul(pw[K-D+1][j*k], 1));
		}
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
			for(int k=0;k<=i;k++){
				f[c][i][j]=add(f[c][i][j], mul(f[c^1][i-k][j], cst[k][j]));
			}
		}
		
		//  cout << f[c][0][0] << " " << f[c][0][1] << " " << f[c][1][0] << " " << f[c][1][1] << endl;
		c^=1;memset(f[c],0,sizeof(f[c]));
		for(int j=0;j<=m;j++)
		for(int k=0;k<=n;k++){
			cst[j][k] = mul(mul(ifac[j],pw[D][j*(n-k)]), mul(pw[K-D+1][j*k], 1));
		}
		for(int i=0;i<=n;i++)for(int j=0;j<=m;j++){
			for(int k=0;k<=j;k++){
				f[c][i][j]=add(f[c][i][j], mul(f[c^1][i][j-k], cst[k][i]));
			}
		}
		
		//  cout << f[c][0][0] << " " << f[c][0][1] << " " << f[c][1][0] << " " << f[c][1][1] << endl;
	}
	cout << mul(f[c][n][m], mul(fac[n],fac[m])) << endl;
}

Measured memory_bytes: 4864
#include <iostream>
#define rep(S, L) for (int i = S; i < L; ++i)
using namespace std;

int main() {
  int n;
  double x;
  string u;
  double y = 0.0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x >> u;
    if (u == "JPY") {
      y += x;
    } else {
      y += x * 380000;
    }
  }
  cout << y << endl;
  return 0;
}


Measured memory_bytes: 3288
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: kundaikwangwari
 *
 * Created on July 27, 2019, 8:28 PM
 */

#include <stdio.h>
#include <limits.h>
#define NIL -1
#define N 150
#define White 0
#define Grey 1
#define Black 2
/*
 * 
 */

int n;
int distance[N];
int color[N],table[N][N];

void Initialize(){
 
  for(int i=0; i < n; i++){
    distance[i] = INT_MAX;
    color[i]=White;
  }
  distance[0] = 0;
  color[0] = Grey;
}

void Prim(int x){
   int MWT,u; 
  Initialize();

while(1){
    MWT = INT_MAX;
    for(int i = 0; i < n; i++){
        if(MWT > distance[i] && color[i] != Black ){
            MWT = distance[i];
            u = i; 
        }
} 
    if(MWT == INT_MAX)break;
  color[u] = Black;
  for(int v = 0; v < n; v++){
    if(color[v] != Black && (distance[u] + table[u][v]) < 
            distance[v] && table[u][v] != INT_MAX){
        color[v]=Grey;
	distance[v] = distance[u] + table[u][v];
       
      }  
  }
}
}

int main(int argc, char** argv) {

    
    int initialised;
    scanf("%d",&n);
    
    int  node, Edges,degree,vector;
    //printf("\n");
    for(int a = 0; a < n; a++){
        scanf("%d %d",&node, &degree);
        

        for(int b = 0; b < N; b++)table[node][b] = INT_MAX;
        for(int b = 0; b < degree; b++){   
        scanf("%d",&vector);
        scanf("%d",&table[node][vector]);
        //printf("(%d %d),%d  ",node, vector,table[node][vector]);
        }
        //printf("\n");
    }
    
/*
    for(int a = 0; a < n; a++){
        for(int b = 0; b < n; b++ )printf("(%d %d),%d  ",a, b,table[a][b]);
    }
*/
    Prim(0);
    for(int i=0; i < n; i++){
    printf("%d %d\n",i,distance[i]);
  }
    return (0);
}




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

using namespace std;
#define ll long long
#define r(i, n) for(int i=0;i<n;i++)

int main() {
    int m, n, x;
    cin >> m;
    vector<int> v1, v2;
    r(i, m) {
        cin >> x;
        v1.push_back(x);
    }
    cin >> n;
    r(i, n) {
        cin >> x;
        v2.push_back(x);
    }
    if (includes(v1.begin(), v1.end(), v2.begin(), v2.end())) {
        cout << 1 << endl;
    } else cout << 0 << endl;
    return 0;
}


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

int search(int y, int x, int h, int w, char** field) {
    field[y][x] = '0';
    int res = 1, ny[] = {y - 1, y, y, y + 1, }, nx[] = {x, x - 1, x + 1, x, };
    for (int i = 0; i < 4; i++) {
        if (0 <= ny[i] && ny[i] < h && 0 <= nx[i] && nx[i] < w && field[ny[i]][nx[i]] == '.') {
            res += search(ny[i], nx[i], h, w, field);
        }
    }
    return res;
}

int main() {
    while (true) {
        int w, h;
        cin >> w >> h;
        if ((w | h) == 0) {
            break;
        }
        char** field = new char* [h];
        for (int i = 0; i < h; i++) {
            field[i] = new char [w + 1];
        }
        for (int i = 0; i < h; i++) {
            cin >> field[i];
        }
        int output;
        for (int y = 0; y < h; y++) {
            for (int x = 0; x < w; x++) {
                if (field[y][x] == '@') {
                    output = search(y, x, h, w, field);
                }
            }
        }
        cout << output << endl;
        for (int i = 0; i < h; i++) {
            delete[] field[i];
        }
        delete[] field;
    }
}

Measured memory_bytes: 0
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;
const long long Mod=924844033;
long long n,pw5[800010],pwinv5[800010];
long long pw(long long x,long long y)
{
	long long res=1;
	while (y)
	{
		if (y&1)
		{
			res=res*x%Mod;
		}
		x=x*x%Mod;
		y>>=1;
	}
	return res;
}
void pre()
{
	long long inv5=pw(5,Mod-2);
	for (int i=1;i<=n;i<<=1)
	{
		pw5[i]=pw(5,(Mod-1)/i);
		pwinv5[i]=pw(inv5,(Mod-1)/i);
	}
}
void rader(long long *a)
{
	for (int i=0,j=0;i<n;i++)
	{
		if (i>j)
		{
			swap(a[i],a[j]);
		}
		int k=n;
		do
		{
			k>>=1;
			j^=k;
		}while (j<k);
	}
}
void ntt(long long *a,long long f)
{
	rader(a);
	for (int i=2;i<=n;i<<=1)
	{
		int m=i>>1;
		for (int j=0;j<n;j+=i)
		{
			long long w=1,wn=pw5[i];
			if (f==-1)
			{
				wn=pwinv5[i];
			}
			for (int k=0;k<m;k++)
			{
				long long x=a[j+k+m]*w%Mod;
				a[j+k+m]=(a[j+k]-x+Mod)%Mod;
				a[j+k]=(a[j+k]+x)%Mod;
				w=w*wn%Mod;
			}
		}
	}
	if (f==-1)
	{
		long long inv=pw(n,Mod-2);
		for (int i=0;i<n;i++)
		{
			a[i]=a[i]*inv%Mod;
		}
	}
}
void conv(long long *a,long long *b)
{
	ntt(a,1);
	ntt(b,1);
	for (int i=0;i<n;i++)
	{
		a[i]=a[i]*b[i]%Mod;
	}
	ntt(a,-1);
}
int N,size[200010];
long long fac[200010],inv[200010],a[800010],b[800010];
int cnt,head[200010],to[400010],nxt[400010];
void add(int x,int y)
{
	cnt++;
	to[cnt]=y;
	nxt[cnt]=head[x];
	head[x]=cnt;
}
void dfs(int x,int fa)
{
	size[x]=1;
	for (int i=head[x];i;i=nxt[i])
	{
		int y=to[i];
		if (y==fa)
		{
			continue;
		}
		dfs(y,x);
		size[x]+=size[y];
		a[size[y]]--;
	}
	a[N-size[x]]--;
}
int main()
{
	scanf("%d",&N);
	fac[0]=1;
	for (int i=1;i<=N;i++)
	{
		fac[i]=fac[i-1]*i%Mod;
	}
	inv[N]=pw(fac[N],Mod-2);
	for (int i=N-1;i>=0;i--)
	{
		inv[i]=inv[i+1]*(i+1)%Mod;
	}
	for (int i=1;i<N;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	dfs(1,0);
	a[N]=N;
	for (int i=1;i<=N;i++)
	{
		a[i]=(a[i]+Mod)%Mod;
		a[i]=a[i]*fac[i]%Mod;
		a[i-1]=a[i]; 
	}
	for (int i=0,j=N-1;i<j;i++,j--)
	{
		swap(a[i],a[j]);
	}
	a[N]=0;
	for (int i=0;i<=N;i++)
	{
		b[i]=inv[i];
	}
	n=1;
	while (n<=N+N)
	{
		n<<=1;
	}
	pre();
	conv(a,b);
	for (int i=1;i<=N;i++)
	{
		long long x=a[N-i];
		x=x*inv[i]%Mod;
		printf("%lld\n",x);
	}
    return 0;
}
//闻君有二意，故来相决绝。
//——卓文君《白头吟》

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

#undef false
#undef true

using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

int a[100];

int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    ll mn = 98765321987654ll;
    for (int i = 0; i <= 100; i++) {
        ll sum = 0;
        for (int j = 0; j < n; j++) {
            sum += (i - a[j]) * (i - a[j]);
        }
        mn = min(mn, sum);
    }

    cout << mn;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	long long a,b,c,d,e,f;
	while(~scanf("%lld%lld%lld%lld",&a,&b,&c,&d))
	{
	e=a*b;
	f=c*d;
	printf("%lld\n",e>=f?e:f);
    }
} 

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input!(n: i64);
    let mut tot: i64 = 0;
    for i in 1..n + 1 {
        let q = n / i;
        tot += q * (q + 1) / 2 * i;
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 2256
#include<bits/stdc++.h>
using namespace std;
#define mx 10000010
typedef long long ll;
ll dv[mx];
void divisors()
{
    ll i,j,c;
    for(i=1;i<=mx;i++)
    {
        for(j=i;j<=mx;j+=i)dv[j]++;
    }
}
int main()
{
    ll n,sum=0;
    divisors();
    cin>>n;
    for(ll i=1;i<=n;i++)sum+=i*dv[i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 81744
#include <stdio.h>
 
int main()
{
  long H,W;
  scanf("%ld %ld",&H,&W);
  if (H == 1 || W == 1)
  {
    printf("1");
    return (0);
  }
  if (H * W % 2 == 0)
  {
    printf("%ld",H * W / 2);
    return (0);
  }
  else
  {
    printf("%ld",H * W / 2 + 1);
    return (0);
  }
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

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

	int n;
	cin >> n;
	vector<vector<int>> f(n, vector<int>(10));
	vector<vector<int>> p(n, vector<int>(11));
	rep (i, 0, n)
		rep (j, 0, 10)
		cin >> f[i][j];

	rep (i, 0, n)
		rep (j, 0, 11)
		cin >> p[i][j];

	int res = INT_MIN;
	for (int i = 1; i < (1<<10); i++) { // 最低１回は営業
		int tmp = 0;
		for (int j = 0; j < n; j++) {
			int id = 0;
			for (int k = 0; k < 10; k++) {
				if (i & (f[j][k] << k))
					id++;
			}
			tmp += p[j][id];
		}
		res = max(res, tmp);
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// g++ -std=c++1z
// int to string : string s = to_string(n);
// string to int : int n = stoi(s);
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main() {

    int n, m;
    cin >> n >> m;
    int p[m];
    vector <string> s(m);
    rep(i,m) cin >> p[i] >> s[i];

    bool flag[n+1];
    rep(i,n+1) flag[i] = false;
    int pt_cnt[n+1];
    rep(i,n+1) pt_cnt[i] = 0;
    int ac = 0;
    int pt = 0;
    rep(i,m) {
        if (flag[p[i]]) {
            ;
        }
        else {
            if (s[i] == "WA") ++pt_cnt[p[i]];
            else {
                ++ac;
                flag[p[i]] = true;
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (flag[i]) {
            pt += pt_cnt[i];
        }
    }

    cout << ac << " " << pt << endl;

    return 0;
}








Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");

        int n = Integer.valueOf(arr01[0]);
        int k = Integer.valueOf(arr01[1]);

        List<String> list01 = Arrays.asList(arr02);
        List<Integer> list02 = list01.stream().map(Integer::valueOf).collect(Collectors.toList());

        //昇順でソート
        Collections.sort(list02);

        long mysum = 0;
        if (n > k) {
            n -= k;

            List<Integer> sub01 = list02.subList(0, n);

            mysum = sub01.stream()
                    .mapToLong(x -> x)
                    .sum();

        }

        System.out.println(mysum);

    }

}


Measured memory_bytes: 69420
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <locale>
#include <iomanip>
#include <math.h>

#define nl '\n'

using namespace std;

int a, b, c, d, t;

int main(){

    cin >> a >> b >> c >> d;

    if(a < b){
        t = t + a;
    } else{
        t = t + b;
    }

    if(c < d){
        t = t + c;
    } else{
        t = t + d;
    }

    cout << t;



}

//g++ -std=c++14 comp.cpp -o b; ./b.exe

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()

using namespace std;

typedef long long ll;

int N,M;
char A[55][55], B[55][55];

int main() {
  scanf("%d %d", &N, &M);
  rep(i, 0, N) scanf("%s", A[i]);
  rep(i, 0, M) scanf("%s", B[i]);
   
  rep (i, 0, N-M+1) {
    rep (j, 0, N-M+1) {
      bool f = true;
      rep(k, 0, M) {
        rep(l, 0, M) {
          if (A[i+k][j+l] != B[k][l]) {
            f = false;
            break;
          }
        }
      }
      if (f) {
        puts("Yes");
        return 0;
      }
    
    }
  }
  
  puts("No");
  return 0;

}

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

int main(){
    char ch;
    int cnt[26]={};
    
    while(cin >> ch){
        ch = tolower(ch);
        if (isalpha(ch)){
            cnt[ch-'a']++;
        }
    }
    for(int i=0;i<26;i++){
        printf("%c : %d\n",i+'a',cnt[i]);
    }
    return 0;
}


Measured memory_bytes: 3156
import itertools, heapq, bisect
from collections import defaultdict as ddic, deque, Counter

rr = raw_input
rri = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())
MOD = 10 ** 9 + 7

###

def shake(n, p):
    x = n
    ans = 0
    while x:
        ans += x // p
        x //= p
    return ans

def solve(N):
    if N%2: return 0
    K = N // 2
    # K! 2^K
    a = shake(K, 2) + K
    b = shake(K, 5)
    return min(a,b )

print solve(rri())


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

int main()
{
    int n, m;
    cin >> n >> m;
    
    for (int i = 0; i < m; i++)
    {
        int temp;
        cin >> temp;
        n -= temp;
    }
    
    cout << max(n, -1) << endl;
}

Measured memory_bytes: 3592
package main

import (
	"fmt"
	"math"
	"strings"
)

func main() {
	var N int
	fmt.Scan(&N)

	var str string
	fmt.Scan(&str)
	chars := strings.Split(str, "")

	ws := make([]int, N)
	es := make([]int, N)

	wcnt := 0
	for i := 1; i < N; i++ {
		if chars[i-1] == "W" {
			wcnt++
		}
		ws[i] = wcnt
	}

	ecnt := 0
	for i := N - 2; i >= 0; i-- {
		if chars[i+1] == "E" {
			ecnt++
		}
		es[i] = ecnt
	}

	//	fmt.Println(ws)
	//  fmt.Println(es)

	ans := math.MaxInt64
	for i := 0; i < N; i++ {
		ans = min(ans, es[i]+ws[i])
	}
	fmt.Println(ans)
}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<pii, int> mp;
	vi x(n), y(n);
	REP(i, n) {
		int z;
		cin >> x[i] >> y[i] >> z;
		mp[{x[i], y[i]}] += z;
	}
	int ans = -1;
	REP(i, n) {
		REP(j, 4) {
			ans = max(ans, mp[{x[i], y[i]}] + mp[{x[i] + dx[j * 2], y[i] + dy[j * 2]}] + mp[{x[i] + dx[j * 2 + 1], y[i] + dy[j * 2 + 1]}] + mp[{x[i] + dx[(j + 1) * 2 % 8], y[i] + dy[(j + 1) * 2 % 8]}]);
		}
	}
	cout << ans <<" / 1"<< endl;
}

Measured memory_bytes: 59852
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int H, W; 
	cin >> H >> W; 
	bool A[910][910] = {}; 
	for(int i = 300; i < 300 + H; i++){
		for(int j = 300; j < 300 + W; j++){
			char c; 
			cin >> c; 
			if(c == '#'){A[i][j] = 1;}
		}
        }
	long long int B[910][1810] = {};
        for(int i = 300; i < 600; i++){
	         for(int j = 600 - i; j <= 600; j++){
			if(A[i][j] == 1){B[i][i+j] = B[i-1][i+j] + 1;}
			else{B[i][i+j] = B[i-1][i+j];}
	        }
        }
        for(int i = 600; i < 910; i++){
                 for(int j = 0; j < 1810; j++){
                        B[i][j] = B[i-1][j]; 
                 }
        }
	long long int count1 = 0; 
	for(int K = 600; K <= 1198; K++){
		for(int i = 300; i < 600; i++){
			for(int j = i + 1; j < 600; j++){
				if(A[i][K - i] == 1 && A[j][K - j] == 1){
					count1 += B[2 * j - i][K + 2 * j - 2 * i] - B[j - 1][K + 2 * j - 2 * i];
					count1 += B[i][K + 2 * i - 2 * j] - B[2 * i - j - 1][K + 2 * i - 2 * j]; 
				}
			}
		}
	}
	bool D[910][910] = {}; 
	for(int i = 300; i < 300+H; i++){
		for(int j = 0; j < 910; j++){
			D[i][j] = A[599 + H - i][j]; 
		}
        }
	long long int E[910][1810] = {};
        for(int i = 300; i < 600; i++){
	         for(int j = 600 - i; j <= 600; j++){
			if(D[i][j] == 1){E[i][i+j] = E[i-1][i+j] + 1;}
			else{E[i][i+j] = E[i-1][i+j];}
	        }
        }
        for(int i = 600; i < 910; i++){
                 for(int j = 0; j < 1810; j++){
                        E[i][j] = E[i-1][j]; 
                 }
        }
	long long int count2 = 0; 
	for(int K = 600; K <= 1198; K++){
		for(int i = 300; i < 600; i++){
			for(int j = i + 1; j < 600; j++){
				if(D[i][K - i] == 1 && D[j][K - j] == 1){
					count2 += E[2 * j - i - 1][K + 2 * j - 2 * i] - E[j][K + 2 * j - 2 * i];
					count2 += E[i - 1][K + 2 * i - 2 * j] - E[2 * i - j][K + 2 * i - 2 * j]; 
				}
			}
		}
	}
	cout << count1 + count2 << endl; 
}

Measured memory_bytes: 27648
#include <stdio.h>

int main(void)
{
    char x[1001];
    int sum;
    int i;
    
    while(1){
        scanf("%s", x);
        sum=0;
        for(i=0; x[i]!='\0'; i++){
            sum += x[i]-'0';
        }
        if(sum==0){
            break;
        }
        printf("%d\n", sum);
    }
    
    return 0;
}

Measured memory_bytes: 536
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    S, W = MI()

    if W >= S:
        print('unsafe')
    else:
        print('safe')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9180
//In the name of Allah :)
#include <bits/stdc++.h>
using namespace std;
string to_string(char c) { return string(1,c); }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(const char* s) { return (string)s; }
string to_string(string s) { return s; }
template<class A> string to_string(complex<A> c) { 
	stringstream ss; ss << c; return ss.str(); }
string to_string(vector<bool> v) { 
	string res = "{"; for(int i = 0; i < (int)v.size(); i++) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> string to_string(bitset<SZ> b) {
	string res = ""; for(size_t i = 0; i < SZ; i++) res += char('0'+b[i]);
	return res; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) { // containers with begin(), end()
	bool fst = 1; string res = "{";
	for (const auto& x: v) {
		if (!fst) res += ", ";
		fst = 0; res += to_string(x);
	}
	res += "}"; return res;
}
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	DBG(t...); }
#ifdef LOCAL // compile with -DLOCAL
#define wis(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
#else
#define wis(...) 0
#endif
typedef long long ll;
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9 + 7, INF = 1e9 + 5;
const ll LONG_INF = 1e18 + 10;
inline ll powmod(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)res=res*a%MOD;return res;}
inline ll power(ll a, ll b){ll res=1;for(;b;b>>=1,a=a*a)if(b&1)res=res*a;return res;}

const int MAXN = 2e5 + 10;
vector <int> adj[MAXN];
bitset <MAXN> mark;

int dfs(int v){
    if(mark[v]){
        return 0;
    }
    mark[v] = 1;
    int ans = 1;
    for(int i : adj[v]){
        ans += dfs(i);
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans = max(ans, dfs(i));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 20784
n, a, b, c, d = map(int, input().split())
s = input()
j = 0
flag = False
fflag = False

if '#' not in s:
  flag = True

for i, k in enumerate(s):
  if k == '.':
    j += 1
  else:
    if j >= 3 and i - j + 1 < d and b < i:
      flag = True
    if s[i-1] == '#' and i-1 < max(c, d) and i+1 > min(a, b):
      fflag = True
    j = 0

if j >= 3 and len(s) - j + 1 < d:
  flag = True
    
if fflag:
  print('No')
else:
  if c > d and flag:
    print('Yes')
  elif c < d:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 3572
from itertools import permutations

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

abs = [list(map(int,input().split())) for _ in range(1, M+1)]
          
p_paths = list(permutations(list(range(2,N+1)), N-1))


cnt=0

for p_path in p_paths:
    p_path = list(p_path)
    p_path.insert(0, 1)
    c=0
    for i in range(len(p_path)-1):
        for ab in abs:

            if ab == list([p_path[i], p_path[i+1]]) or ab == list([p_path[i+1], p_path[i]]):
                c+=1
                break
        if c==len(p_path)-1:
            cnt=cnt+1
print(cnt)
                   


Measured memory_bytes: 3572
#include<iostream>
using namespace std;
int main(){
  char n[4];
  cin >> n;
  if ((n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3])){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T,class Size=typename vector<T>::size_type>inline auto vector_2d(Size h,Size w,T v){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator,class Pair=typename iterator_traits<RandomAccessIterator>::value_type>inline void sort_pairs_by_second(RandomAccessIterator first,RandomAccessIterator last){sort(first,last,[](const Pair&p1,const Pair&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll h=in(),w=in();
    ll ch=in()-1,cw=in()-1;
    ll dh=in()-1,dw=in()-1;
    vector<string>s(h);for(ll i=0;i<h;++i)cin>>s[i];
    auto num=vector_2d(h,w,-1ll);
    ll now=0;
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            if(s[i][j]=='.'){
                if(num[i][j]==-1){
                    queue<pair<ll,ll>>q;
                    q.emplace(i,j);
                    ll dy[]={-1,0,1,0},dx[]={0,-1,0,1};
                    while(!q.empty()){
                        auto[y,x]=q.front();q.pop();
                        num[y][x]=now;
                        for(ll k=0;k<4;++k){
                            ll yy=y+dy[k],xx=x+dx[k];
                            if(0<=yy&&yy<h&&0<=xx&&xx<w){
                                if(num[yy][xx]==-1&&s[yy][xx]=='.'){
                                    num[yy][xx]=now;
                                    q.emplace(yy,xx);
                                }
                            }
                        }
                    }
                    ++now;
                }
            }
        }
    }
    vector<set<ll>>edge(now);
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            if(s[i][j]=='.'){
                for(ll k=-2;k<=2;++k){
                    for(ll l=-2;l<=2;++l){
                        ll y=i+k,x=j+l;
                        if(0<=y&&y<h&&0<=x&&x<w){
                            if(s[y][x]=='.'&&num[y][x]!=num[i][j]){
                                edge[num[i][j]].insert(num[y][x]);
                            }
                        }
                    }
                }
            }
        }
    }
    /*for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            cout<<num[i][j]<<' ';
        }
        cout<<endl;
    }*/
    /*for(auto e:edge){
        for(auto ee:e){
            cout<<ee<<' ';
        }
        cout<<endl;
    }*/
    ll inf=1e8;
    vector<ll>dist(now,inf);
    dist[num[ch][cw]]=0;
    queue<ll>q;
    q.push(num[ch][cw]);
    while(!q.empty()){
        ll n=q.front();q.pop();
        for(auto e:edge[n]){
            if(dist[e]>dist[n]+1){
                dist[e]=dist[n]+1;
                q.push(e);
            }
        }
    }
    /*cout<<dh<<' '<<dw<<endl;
    cout<<num.size()<<' '<<num.front().size()<<endl;
    cout<<num[dh][dw]<<endl;*/
    if(dist[num[dh][dw]]!=inf){
        cout<<dist[num[dh][dw]]<<endl;
    }else{
        cout<<-1<<endl;
    }
}


Measured memory_bytes: 38360
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String s = sc.next();
			if (s.equals("#"))
				break;
			char[] c = s.toCharArray();
			int[] n = new int[s.length()];
			for (int i = 0; i < n.length; i++)
				n[i] = (c[i] - '0' - 1) % 3;
			int lf = 0, rf = 2;
			int result = 0;
			boolean foot = true;
			for (int i = 0; i < n.length; i++) {
				if (foot) {
					lf = n[i];
					if (i != 0 && lf > rf) {
						result++;
						rf = lf;
						lf = 0;
						continue;
					}
					foot = false;
					continue;
				}
				rf = n[i];
				if (i != 0 && lf > rf) {
					result++;
					lf = rf;
					rf = 2;
					continue;
				}
				foot = true;
			}
			lf = 0;
			rf = 2;
			foot = false;
			int tresult = 0;
			for (int i = 0; i < n.length; i++) {
				if (foot) {
					lf = n[i];
					if (i != 0 && lf > rf) {
						tresult++;
						rf = lf;
						lf = 0;
						continue;
					}
					foot = false;
					continue;
				}
				rf = n[i];
				if (i != 0 && lf > rf) {
					tresult++;
					lf = rf;
					rf = 2;
					continue;
				}
				foot = true;
			}
			result = Math.min(result, tresult);
			System.out.println(result);
		}
		sc.close();
	}
}

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

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

void main() {
    int s, w;
    scan(s, w);
    auto safe = s > w;
    yes(safe, "safe", "unsafe");
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";
 
 
int main(){
    ll N,ans = 0;cin >> N;
    vector<string> strList(N);
    std::unordered_map<string, int> mp;
    REP(i,N){
        cin >> strList[i];
        sort(strList[i].begin(),strList[i].end());
        if(mp[strList[i]] > 0) ans += mp[strList[i]];
        mp[strList[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 17700
def check(nums):
    #print(nums)
    #5回以上出てこないか判別
    for i in range(9):
        if(nums[i]>4):
            return False


    for head in range(9):
        #作業用の配列を作る
        anums=nums[:]
        #頭ができているか確認
        if(anums[head]<2):
            continue
        anums[head]-=2

        for i in range(9):
            #三つ同じものがある場合はそれをひとまとめにする
            if(anums[i]>=3):
                anums[i]-=3
            while(anums[i]>0):
                #8以上が1になってても成立しないからFalse
                if i>=7:
                    break
                ok=True
                for j in range(i,i+3):
                    if anums[j]<=0:
                        ok=False
                #okがFalseなら順番になってない
                if not ok:
                    break
                #okがTrueなら順番になっているので一ずつ減らす。
                for j in range(i,i+3):
                    anums[j]-=1
        #全て0になっていればTrue
        if not any(anums):
            return True
    return False

while True:
    st=""
    try:
        st=input()
    except:
        break
        #9個の配列を作り0を入れる
    nums=[0 for i in range(9)]
    #各数字の数を数える
    for c in st:
        nums[int(c)-1]+=1
    #答えの配列を作る
    anss=[]
    #与えられたものに1~9を一つずつ加えてそれぞれで判定
    for n in range(0,9):
        nums[n]+=1
        if(check(nums[:])):
            anss.append(n+1)
        nums[n]-=1

    if(len(anss)==0):
        anss.append(0)
    print(" ".join(map(str,anss)))



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

int main() {
string a,b,c="";
cin >> a>>b;
bool flg = false;
for(int i = 0; i < a.length();i++){
	if(i < 0){
		c = a.substr(i,a.length());
	}else{
		c = a.substr(i,a.length()) + a.substr(0,i);
	}
	if(c == b){
		flg = true;
		break;
	}
	}

if(flg)
	cout << "Yes";
else
	cout << "No";

	return 0;
}



Measured memory_bytes: 256
import * as fs from 'fs'

//in
// 7
// beat
// vet
// beet
// bed
// vet
// bet
// beet
//out
// beet
// vet

let input: string[] = fs.readFileSync('/dev/stdin', 'utf8').split('\n');
const n: number = parseInt(input[0]);
input.shift();
let s:string[] = input.sort();

const counts: any = {};
let maxCnt: number = 0;
for (let i: number = 0; i < s.length; i++) {
    let key = s[i];
    counts[key] = (counts[key]) ? counts[key] + 1 : 1;
    if (maxCnt < counts[key]) {
        maxCnt = counts[key];
    }
}

// console.log(counts)

// for (let i: number = 0; i < Object.keys(counts).length; i++) {
//     if (parseInt(counts[i]) === maxCnt) {
//
//     }
// }
const key = Object.keys(counts);
const result = key.filter(key =>counts[key]===maxCnt)

console.log(result.join('\n'))

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
long long g[2], s[2], b[2];

int main() {
	int n = ri();
	for (int i = 0; i < 2; i++) {
		g[i] = ri();
		s[i] = ri();
		b[i] = ri();
	}
	long long res = n;
	{
		long long dp[res + 1];
		dp[res] = 0;
		for (int i = 0; i < res; i++) dp[i] = -10000000000000000LL;
		for (int i = res; i >= 0; i--) {
			if (i >= g[0]) dp[i - g[0]] = std::max(dp[i - g[0]], dp[i] + g[1]);
			if (i >= s[0]) dp[i - s[0]] = std::max(dp[i - s[0]], dp[i] + s[1]);
			if (i >= b[0]) dp[i - b[0]] = std::max(dp[i - b[0]], dp[i] + b[1]);
		}
		long long next = res;
		for (int i = 0; i <= res; i++) next = std::max(next, i + dp[i]);
		res = next;
	}
	{
		long long dp[res + 1];
		dp[res] = 0;
		for (int i = 0; i < res; i++) dp[i] = -10000000000000000LL;
		for (int i = res; i >= 0; i--) {
			if (i >= g[1]) dp[i - g[1]] = std::max(dp[i - g[1]], dp[i] + g[0]);
			if (i >= s[1]) dp[i - s[1]] = std::max(dp[i - s[1]], dp[i] + s[0]);
			if (i >= b[1]) dp[i - b[1]] = std::max(dp[i - b[1]], dp[i] + b[0]);
		}
		long long next = res;
		for (int i = 0; i <= res; i++) next = std::max(next, i + dp[i]);
		res = next;
	}
	std::cout << res << std::endl;
	return 0;
}


Measured memory_bytes: 195584
#include<stdio.h>
int main(){
int x,i,y;
while(1 == 1){
scanf("%d %d\n",&x,&y);
if(x == 0 && y == 0) break;
if(x > y){
	printf("%d %d\n", y ,x);
}else{
	printf("%d %d\n", x ,y);
}
}
return 0;
}

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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;
const int MX = 1e9 + 7;
const LL INF = 1LL * MX * MX;

int n;
PII Intrv[N];
int pref[N], suf[N];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d %d", &Intrv[i].st, &Intrv[i].nd);
	sort(Intrv + 1, Intrv + n + 1);
	
	pref[0] = MX;
	for(int i = 1; i <= n; ++i)
		pref[i] = min(pref[i - 1], Intrv[i].nd);
	
	suf[n + 1] = MX;
	for(int i = n; i >= 1; --i)
		suf[i] = min(suf[i + 1], Intrv[i].nd);
	
	int ans = 0;
	for(int i = 1; i <= n; ++i){
		int Left = i == n ? Intrv[n - 1].st : Intrv[n].st;
		ans = max(ans, Intrv[i].nd - Intrv[i].st + 1 + max(0, min(suf[i + 1], pref[i - 1]) - Left + 1));
	}
	
	for(int i = 1; i < n; ++i)
		ans = max(ans, max(0, pref[i] - Intrv[i].st + 1) + max(0, suf[i + 1] - Intrv[n].st + 1));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 8832