akhauriyash/Code-Regression huggingface dataset:
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, input().rstrip('\n').split()))
    d = collections.defaultdict(int)
    for v in list(map(int, input().rstrip('\n').split())):
        d[str(v)]
    for i in range(n, 10 ** 10):
        s = str(i)
        b = True
        for v in s:
            if v in d:
                b = False
                break
        if b:
            print(i)
            exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39664
#2回目以降のあまりを計算
def f(j):
    cnt = 0
    while j:
        j %= bin(j).count("1")
        cnt += 1
    return cnt

N = int(input())
S = input()

#入力を数値に変換
X = int(S, 2)

#元のbit数をカウント
pcx = S.count("1")
#bit数は-1, +1のみなので予め計算しておく
#カウントが0ならば0にしておく
pc1 = X % (pcx - 1) if pcx > 1 else 0
pc2 = X % (pcx + 1)

for i, y in enumerate(S):
    k = N - 1 - i
    if y == "0":
        print(f((pc2 + pow(2, k, pcx + 1)) % (pcx + 1)) + 1)
    elif pcx > 1:
        print(f((pc1 - pow(2, k, pcx - 1)) % (pcx - 1)) + 1)
    else:
        print(0)



Measured memory_bytes: 9388
/*
Though leaves are many, the root is one;
Through all the lying days of my youth
I swayed my leaves and flowers in the sun,
Now many I wither into the truth.
-- William Butler Yeats
µ±»ªÃÀµÄÒ¶Æ¬Âä¾¡£¬ÉúÃüµÄÂöÂç²ÅÀúÀú¿É¼û
*/ 
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
ll n;
ll d[100005];
map <ll,ll> m;
pair<ll,ll> p[100005];
ll sub[100005];
ll sz[100005];
vector <pair<ll,ll> >res;
vector <int>vec[100005];
ll dp[100005];

int dfs(int x,int p=-1)
{
	sz[x]=1;
	for(int i=0;i<vec[x].size();i++)
	{
		if(vec[x][i]==p) continue;
		sz[x]+=dfs(vec[x][i],x);
	}
	return sz[x];
}

int go(int x,int p=-1)
{
	dp[x]=sz[x]-1;
	for(int i=0;i<vec[x].size();i++)
	{
		if(vec[x][i]==p) continue;
		dp[x]+=go(vec[x][i],x);
	}
	return dp[x];
}

int main()
{
//	freopen("input.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>d[i];
		m[d[i]]=i;
		p[i].first=d[i];
		p[i].second=i;
		sz[i]=1;
	}
	sort(p,p+n);
	reverse(p,p+n);
	memset(sub,-1,sizeof(sub));
	for(ll i=0;i<n-1;i++)
	{
		ll de=p[i].first;
		ll x=p[i].second;
		sub[x]=n-sz[x]*2;
//		cout<<x+1<<'-'<<de<<'-'<<sub[x]<<'-'<<sz[i]<<endl;
		if(sub[x]==0) over("-1");
		if(m.find(de-sub[x])==m.end()) over("-1");
		ll par=m[de-sub[x]];
		sz[par]+=sz[x];
		dp[par]+=dp[x];
		res.push_back(mp(x,par));
	}
	for(int i=0;i<n-1;i++)
	{
		vec[res[i].first].push_back(res[i].second);
		vec[res[i].second].push_back(res[i].first);
	}
	dfs(p[n-1].second);
	go(p[n-1].second);
//	cout<<dp[p[n-1].second]<<endl;
	if(dp[p[n-1].second]!=p[n-1].first) over("-1");
	for(ll i=0;i<n-1;i++)
	{
		cout<<res[i].first+1<<' '<<res[i].second+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 23412
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 typedef pair<int,P> PP;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int r,c,n;

int getnum(int x,int y){
	if(!x) return y;
	if(y == c) return c + x;
	if(x == r) return c * 2 + r - y;
	if(!y) return c * 2 + r * 2 - x;
	return -1;
}

signed main(){
	int a[100000],b[100000];
	cin >> r >> c >> n;
	vector<PP> vec;
	for(int i = 0;i < n;i++){
		int x1,x2,y1,y2;
		cin >> x1 >> y1 >> x2 >> y2;
		a[i] = getnum(x1,y1);
		b[i] = getnum(x2,y2);
		if(a[i] > b[i]) swap(a[i],b[i]);
		if(a[i] != -1 && b[i] != -1){
			vec.push_back(mp(a[i],mp(i,0)));
			vec.push_back(mp(b[i],mp(i,1)));
		}
	}
	sort(all(vec));
	stack<int> st;
	for(int i = 0;i < vec.size();i++){
		int num = vec[i].second.first,mode = vec[i].second.second;
		if(!mode) st.push(num);
		else{
			if(st.top() != num){
				NO();
				return 0;
			}
			st.pop();
		}
	}
	if(st.empty()) YES();
	else NO();
	return 0;
}

Measured memory_bytes: 9072
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int dp[1005][1005] = { 0 };
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string x, y;
		cin >> x >> y;
		for (int j = 0; j < 1005; j++)
			for (int k = 0; k < 1005; k++) dp[j][k] = 0;
		for (int j = 1; j <= x.size(); j++) {
			for (int k = 1; k <= y.size(); k++) {
				dp[j][k] = max(dp[j][k - 1], dp[j - 1][k]);
				if (x[j - 1] == y[k - 1]) {
					dp[j][k] = max(dp[j][k], dp[j - 1][k - 1] + 1);
				}
			}
		}
		cout << dp[x.size()][y.size()] << endl;
	}
	return 0;
}



Measured memory_bytes: 7164
#include<stdio.h>
#pragma GCC optimize ("O2")
typedef long long LL;
#define rep(i,N) for(LL i=0;i<(LL)N;i++)
const LL MOD=998244353;
LL Pow(LL x,LL y){LL z=1;x%=MOD;while(y){if(y&1){z=(z*x)%MOD;}x=(x*x)%MOD;y>>=1;}return z;}
int main(void)
{
  LL A,B,C,D,ans=0,sum,dp[3000]={0};
  if(!scanf("%lld %lld %lld %lld",&A,&B,&C,&D))return 0;
  if(A==C){return printf("%lld\n",Pow(A,D-B)),0;}
  else if(B==D){return printf("%lld\n",Pow(B,C-A)),0;}
  dp[A-1]=1;
  rep(i,D-B)
  {
    sum=0;
    rep(j,C)
    {
      sum=(sum*(B+i)%MOD+dp[j])%MOD;
      dp[j]=(j*dp[j]+sum)%MOD;
    }
  }
  rep(i,C){ans=(ans+dp[i]*Pow(D,C-i-1))%MOD;}
  return printf("%lld\n",ans),0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int w, h, n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> w >> h >> n;
  int xl = 0, xr = w, yl = 0, yr = h;
  FOR(i, 0, n){
    int x, y, a;
    cin >> x >> y >> a;
    switch(a){
      case 1:
        maxs(xl, x);
        break;
      case 2:
        mins(xr, x);
        break;
      case 3:
        maxs(yl, y);
        break;
      case 4:
        mins(yr, y);
        break;
    }
  }
  cout << max(0, xr-xl) * max(0, yr-yl) << endl;
}

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

const int INF = 1001001001;

int main() {
    int n, l;
    cin >> n >> l;
    P p;
    int tot = 0;
    rep(i, n) {
        tot += l + i;
    }
    int samin = INF;
    int ans = 0;
    rep(i, n) {
        int aji = tot - (l+i);
        int sa = abs(l+i);
        if (sa < samin) {
            ans = aji;
            samin = sa;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef signed long long ll;
typedef vector<ll> vec;
const int TP = 26;

ll compute_score(ll& D, vec& C, vector<vector<ll>>& S, vec& sol) {
    vec last(TP, 0);
    ll score = 0;
    for (int i = 0; i < D; i++) {
        int j = sol[i] - 1;
        last[j] = i + 1;
        for (int k = 0; k < TP; k++)
            score -= C[k] * (i + 1 - last[k]);
        score += S[i][j];
    }
    return score;
}

void compute_greedy(ll& D, vector<vector<ll>>& S, vec* sol) {
    for (int i = 0; i < D; i++) {
        auto itp = std::max_element(S[i].begin(), S[i].end());
        int di = itp - S[i].begin();
        int maxsdi = *itp;
        // cout << i << " " << di << " " << maxsdi << endl;
        (*sol)[i] = di;
    }
}

int main() {
    ll D; cin >> D;
    vector<ll> C(TP, 0);
    for (int i = 0; i < TP; i++) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(TP, 0));
    for (int i = 0; i < D; i++)
        for (int j = 0; j < TP; j++)
            cin >> S[i][j];

    // greedy解
    vector<ll> sol(D, 0);
    compute_greedy(D, S, &sol);

    for (auto v : sol) {
        cout << (v + 1) << endl;
    }

}

Measured memory_bytes: 3716
def main():
    n = int(input())
    d = list(map(int,input().split()))
    mod = 998244353
    if d[0]!=0:
        print(0)
        return
    D = {0:1}
    for i in range(1,n):
        if d[i]==0:
            print(0)
            return
        if D.get(d[i]) == None:
            D[d[i]] = 1
        else:
            D[d[i]] += 1
    ans = 1
    if sorted(D.keys())[-1]!=len(D.keys())-1:
        print(0)
        return
    for k in range(1,len(D.keys())):
        ans *= pow(D[k-1],D[k],mod)
        ans = ans % mod
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 23292
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;

const LL M=998244353;
const int U=4000+1;
LL C[U][U];
LL P[U];
int main() {
	for(int i=0;i<U;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++){
			C[i][j]=C[i-1][j-1]+C[i-1][j];
			C[i][j]%=M;
		}
	}
	P[0]=1;
	for(int i=1;i<U;i++){
		P[i]=P[i-1]*2%M;
	}
	int K,N;
	cin >> K >> N;
	for(int i=2;i<=2*K;i++){
		LL s=0;
		if(i%2==1){
			LL p=i/2-max(0,i-K-1);
			LL a=0;
			if(K>=2*p){
				a=K-2*p;
			}
			for(int j=0;j<=p;j++){
				if(a+j-1>=0){
					s+=P[j]*C[p][j]%M*C[N+a-1][a+j-1]%M;
					s%=M;
				}
			}
		}
		else{
			LL p=i/2-1-max(0,i-K-1);
			LL a=0;
			if(K>=2*p){
				a=K-2*p-1;
			}
			for(int j=0;j<=p;j++){
				if(a+j-1>=0){
					s+=P[j]*C[p][j]%M*C[N+a-1][a+j-1]%M;
					s%=M;
				}
			}
			for(int j=0;j<=p;j++){
				if(a+j-1>=0){
					s+=P[j]*C[p][j]%M*C[N-1+a-1][a+j-1]%M;
					s%=M;
				}
			}
		}
		cout << s << endl;
	}

	return 0;
}



Measured memory_bytes: 123648
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   //IOS;
   string s;
   cin >> s;
   if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes";
   else cout<<"No";
}


Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n,d;
	cin>>n>>d;
	int cnt=0;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		int x=a*a+b*b;
		if(sqrt(x)<=d){
			cnt+=1;
		}
	}
	cout<<cnt<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}







Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using P = pair<int, int>;
using ll = long long;


int main()
{
    int n;
    cin >> n;
    vector<int> l(n+5);
    for(int i=1; i<=n; i++){
        for(int j=i; j<=n; j+=i) l[j]++;
    }

    ll ans = 0;
    for(int i=1; i<=n; i++){
        ans += (ll)l[i] * i;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll X;
    cin >> X;
    ll ans = (X / 500) * 1000;
    ans += ((X % 500) / 5) * 5;
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main()
{
	int a,b;char s[20];
	scanf("%d%d",&a,&b);scanf("%s",s);
	int flag=1;
	if(s[a]!='-') flag=0;
	for(int i=0;i<=a+b&&flag;i++)
	if(i!=a&&(s[i]<'0'||s[i]>'9')) flag=0;
	if(flag) printf("Yes\n");else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, K := sc.nextInt(), sc.nextInt()
	P := sc.nextIntSlice(N)
	r := 0
	var ans float64
	var sum float64
	for l := 0; l < N-K+1; l++ {
		nextr := l + K
		for r < nextr {
			sum += f(P[r])
			r++
		}
		if ans < sum {
			ans = sum
		}
		sum -= f(P[l])
	}

	fmt.Fprintln(wtr, ans)
}

func f(n int) float64 {
	sum := n * (n + 1) / 2
	return float64(sum) / float64(n)
}


Measured memory_bytes: 3072
#include<iostream>
#include<iomanip>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

double k, r, l;
double p, e, t;

double bs(int tk, double r, double l){
    tk += 1;
    double h = (r+l) / 2;

    if(tk<=k){
        if(r>=t-e && l<=t+e){
            return 1;
        } else if (r>t+e || l<t-e){
            return 0;
        } else if (h<t){
            return (1-p)*bs(tk,h,l) + p*bs(tk,r,h);
        } else {
            return p*bs(tk,h,l) + (1-p)*bs(tk,r,h);
        }
    } else {
        if(h<=t+e && h>=t-e){
            return 1;
        } else {
            return 0;
        }
    }
}

int main(){
    cin >> k >> r >> l;
    cin >> p >> e >> t;

    double output = bs(0, r, l);
    cout << fixed << setprecision(6) << output << endl;
}

Measured memory_bytes: 3276
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
  lli n,m,k,i,j,MAX=0;
  cin>>n>>m>>k;
  lli a[n+1],b[m+1];
  a[0]=b[0]=0;
  for(i=1;i<n+1;i++)
  {
      cin>>a[i];
      a[i]+=a[i-1];
  }
  for(j=1;j<m+1;j++)
  {
      cin>>b[j];
      b[j]+=b[j-1];
  }
  j=m;
  for(i=0;i<n+1;i++)
  {
      if(a[i]>k)break;
      while(b[j]>k-a[i])
        j--;
      if((i+j)>MAX)MAX=i+j;
  }
  cout<<MAX<<endl;
}

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

int N, K;
vector<int> a;
int main()
{
	cin >> N >> K;
	rep(i, N)
	{
		int p;
		cin >> p;
		a.push_back(p);
	}
	sort(a.begin(), a.end());
	int ans=0;
	rep(i, K) ans += a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
//https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/5/GRL_5_A
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

template< typename T >
struct edge {
	int src, to;
	T cost;
	edge(int _to, T _cost) : src(-1), to(_to), cost(_cost) {}
	edge(int _src, int _to, T _cost) : src(_src), to(_to), cost(_cost) {}
	edge &operator=(const int &x) {
		to = x;
		return *this;
	}
	operator int() const { return to; }
};

template< typename T>
struct node {
	vector<edge<T>> edges;
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< node< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
//木の直径,aoj_grl_5_a
template< typename T >
pair< T, int > tree_dfs(const WeightedGraph< T > &g, int idx, int par) {
    pair< T, int > ret(0, idx);
    for(auto &e : g[idx].edges) {
        if(e.to == par) continue;
        auto cost = tree_dfs(g, e.to, idx);
        cost.first += e.cost;
        ret = max(ret, cost);
    } 
    return ret;
}

//st_idx探索開始のidx
template< typename T >
T tree_diameter(const WeightedGraph< T > &g, int st_idx) {
    auto p = tree_dfs(g, st_idx, -1); //st_idxから最遠頂点
    auto q = tree_dfs(g, p.second, -1); //上記の最遠頂点からの最遠頂点
    return (q.first);
}


int main() {
    ll n; cin>>n;
    WeightedGraph<ll> graph(n);
    REP(i,n-1){
        ll s,t,w; cin>>s>>t>>w;
        graph.at(s).edges.emplace_back(s,t,w);
        graph.at(t).edges.emplace_back(t,s,w);
    }
    auto dm = tree_diameter(graph,0);
    cout<<dm<<endl;
    return 0;
}


Measured memory_bytes: 17492
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
using namespace std;
int main()
{
	int n,m,l,a,b,s;
	while(~scanf("%d%d",&n,&m))
	{
		 s=n/(2*m+1);
		 if(n!=(2*m+1)*s)
            s++;
		 printf("%d\n",s);
	}
	
	 
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int main() {
    long long n, m, f = 1;
    cin >> n >> m;
    if (abs(n - m) > 1) cout << '0';
    else
    {
        if (m == n)
        {
            for (int i = 2; i <= n; i++)
                f = (f * i) % mod;
            f = (f * f) % mod;    
            f = f * 2;
        }
        else
        {
            for (int i = 2; i <= min(m, n); i++)
                f = (f * i) % mod;
            f = (f * f) % mod;
            f = (f * max(m, n)) % mod;
        }
        cout << (f + mod) % mod;
    }
}

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

bool f(int x){
  int k=0;
  while(x>0){
    k++;
    x/=10;
  }
  return k%2 ==1;
}

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

  int ans =0;

  for(int i=1;i<=n;i++){
    if(f(i))ans++;
  }

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

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

int main()
{
    ll MAXV = 10000000001;
    ll N, M, K; cin >> N >> M >> K;
    vector<ll> A(N, 0);
    vector<ll> B(M, 0);
    vector<ll> AS(N+1, 0);
    vector<ll> BS(M+1, 0);
    ll sum = 0;
    rep(i,N) {
        cin >> A[i]; sum += A[i]; AS[i+1] = sum;
    }
    sum = 0;
    rep(i,M) {
        cin >> B[i]; sum += B[i]; BS[i+1] = sum;
    }

    ll num = 0;
    ll maxnum = 0;
    rep(i, N+1) {
        ll time = AS[i];
        ll left = 0;
        ll right = M;
        num = i;
 //       cout << "AS= " << time << endl;
        while (1) {
            if (left > right) break;
            ll mid = left + (right - left) / 2;
 //           cout << "mid= " << mid << endl;
            if (time + BS[mid] <= K) {
                if (maxnum < (i+mid)) maxnum = i+mid;
                left = mid+1;                
            }
            else {
                right = mid - 1;
            }
        }
    }
    cout << maxnum << endl;

}


Measured memory_bytes: 9560
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    double r;
    cin >> r;
    double ans = r * 2 * acos(-1);
    cout << fixed << setprecision(10) << ans << '\n';
    return 0;
}

Measured memory_bytes: 3788
def main():
    n=int(input())
    a=[]
    s=[]
    t=0
    for k in range(3,55556):
        b=k
        for j in s:
            if k%j==0:
                b=0
        if b==k:
            s.append(k)
            if k % 5 == 1:
                if t < n:
                    a.append(k)
                    t += 1
                else:
                    break
     
    print(*a)
    
    
    
main()

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    interface Output
    {
        void Write(object str);
        void WriteLine(object str);
    }

    interface Input
    {
        int NextInt();
        string NextString();
    }

    class Console_ : Input, Output
    {
        Queue<string> param = new Queue<string>();
        int Input.NextInt()
        {
            if (param.Count == 0)
            {
                foreach (var item in Console.ReadLine().Split(' '))
                {
                    param.Enqueue(item);
                }
            }
            return int.Parse(param.Dequeue());
        }
        string Input.NextString()
        {
            if (param.Count == 0)
            {
                foreach (var item in Console.ReadLine().Split(' '))
                {
                    param.Enqueue(item);
                }
            }
            return param.Dequeue();
        }
        void Output.Write(object str)
        {
            System.Console.Write(str.ToString());
        }
        void Output.WriteLine(object str)
        {
            System.Console.WriteLine(str.ToString());
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            new Solver(new Console_(), new Console_()).Run();
        }
    }

    class Debug_ : Input
    {
        int i = 0;
        int Input.NextInt()
        {
            return (int)data[i++];
        }
        string Input.NextString()
        {
            return (string)data[i++];
        }
        object[] data =
        {
            "abcdefghijklmnopqrstuvwxyz",
            "abcdefghijklmnopqrstuavwxyz",
            "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
        };
    }

    class Solver
    {
        Input input;
        Output output;
        public Solver(Input input, Output output)
        {
            this.input = input;
            this.output = output;
        }

        public void Run()
        {
            var N = input.NextInt();
            var S = input.NextString().ToArray();
            var K = input.NextInt();
            for (int i = 0; i < S.Length; ++i)
            {
                S[i] = S[i] != S[K - 1] ? '*' : S[i];
            }
            output.WriteLine(new string(S));
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
const int MAXN = 100000+10;
typedef long long LL;
char s[MAXN];
int ans;
int main(){
    //freopen("t.in", "r", stdin);
    scanf("%s", s+1);
    int l = strlen(s+1);
    for(int i=1; i<=l; ++i){
        if(s[i]!=s[i-1]) ans++;
    }
    printf("%d\n", ans-1);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<cstring>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define up(a,b) (((a)%(b)==0)?((a)/(b)):((a)/(b))+1)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) (a>b)?(a>c)?a:c:(b>c)?b:c
#define min3(a,b,c) (a<b)?(a<c)?a:c:(b<c)?b:c
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;

ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b, a%b);
}
bool prime[3001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=3000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=3000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[20];
void power()
{
	powe[0]=1;
	REP(i,1,20)
	{
		powe[i]=(powe[i-1]*10)%num;
        if(powe[i]<0)
        powe[i]+=num;
	}
}
struct vertex
{
	vll adj;
};
void dfs(ll i,vertex V[], bool vis[], ll dist[])
{
	vis[i]=true;
	//cout<<i<<" ke liye\n";
	for(auto x : V[i].adj)
	{
		if(!vis[x])
		{
			dfs(x,V,vis,dist);
		}
		dist[i]=max(dist[i],1+dist[x]);
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
	cin>>n;
	double A[n];
	REP(i,0,n)
	{
		cin>>A[i];
	}
	double dp[2][n][n+1];   // dp[current_toss][number_of_coin][number_of_heads_till_now];
	REP(i,0,n)
	{
		REP(j,0,n+1)
		{
			dp[0][i][j]=0;
			dp[1][i][j]=0;
		}
	}
	dp[0][0][0]=1-A[0];
	dp[1][0][1]=A[0];
	REP(i,1,n)
	{
		REP(j,0,n)
		{
			dp[0][i][j]=(dp[0][i-1][j]+dp[1][i-1][j])*(1-A[i]);
		}
		REP(j,1,n+1)
		{
			dp[1][i][j]=(dp[0][i-1][j-1] + dp[1][i-1][j-1])*(A[i]);
		}
	}
	double ans=0;
	REP(i,(n+1)/2,n+1)
	{
		ans+=dp[0][n-1][i];
		ans+=dp[1][n-1][i];
	}

	cout<<fix(ans,12)<<"\n";
	return 0;
}

Measured memory_bytes: 140928
#include<stdio.h>

int main(){
	int a[5];
	int i, j;
	int answer = 0;

	for (i = 0; i < 5; i++){
		scanf("%d", &a[i]);
	}

	int min_mod10 = 9;
	int min_i = 0;

	for (i = 0; i < 5; i++){
		if (min_mod10 > a[i] % 10 && a[i] % 10 != 0){
			min_mod10 = a[i] % 10;
			min_i = i;
		}
	}

	for (i = 0; i < 5; i++){
		if (i != min_i){
			answer += 10 * (a[i] / 10);
			if (a[i] % 10 != 0){
				answer += 10;
			}
		}
		else{
			answer += 10 * (a[i] / 10) + a[i] % 10;
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n;
  cin >> n;

  ll f[n][10], p[n][11];

  REP(i, n){
    REP(j, 10){
      cin >> f[i][j];
    }
  }

  REP(i, n){
    REP(j, 11){
      cin >> p[i][j];
    }
  }

  ll ans = -1e10;

  for(ll i = 1; i <= 1023; i++){
    ll rec = 0;
    ll ei[10] = {};
    ll tmp = i, cnt = 0, bi = 1;
    while(tmp){
      if(tmp % 2) ei[cnt] = 1;
      tmp /= 2;
      cnt++;
    }
    REP(j, n){
      ll db = 0;
      REP(k, 10){
        if(ei[k] && f[j][k]) db++;
      }
      rec += p[j][db];
    }
    ans = max(ans, rec);
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

//		W = in.readLine();
//		String[] Ws = W.split(" ");

		int N = Integer.parseInt(W);
		String ans = "No";
		if(N >81){
			ans="No";
		}else{
			for(int a=1;a<10;a++){
				for(int b=1;b<10;b++){
					if(a*b==N){
						ans = "Yes";
						break;
					}
					if(ans.equals("Yes")){
						break;
					}
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21204
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

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

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

//#define getchar getchar_unlocked
//#define putchar putchar_unlocked

int inp() {
	int x = 0, f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}

ll inp_ll() {
	ll x = 0; int f = 0; char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = 1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return f ? -x : x;
}

template<class T>
bool read(T &x)
{
	x = 0;
	char ch = getchar();
	if (ch == EOF) return 0;
	for(; !isdigit(ch); )
	{
		ch = getchar();
		if (ch == EOF) return 0;
	}
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return 1;
}

template<class T>
void write(T x)
{
	static char s[22];
	static char *it = s+20;
	static char *end = s+20;
	if (!x)
		*-- it = '0';
	while (x)
	{
		*-- it = x%10+'0';
		x /= 10;
	}
	for (; it < end; ++ it)
		putchar(*it);
}

template<class T>
void writeln(T x)
{
	write(x);
	putchar('\n');
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 100010;

int n;
int a[MAXN], b[MAXN], f[MAXN];

int v[MAXN];

void add(int x, int p)
{
	for (; x <= n; x += x&-x)
		freshmax(v[x], p);
}

int get(int x)
{
	int p = 0;
	for (; x; x ^= x&-x)
		freshmax(p, v[x]);
	return p;
}

int main()
{
	
	n = inp();
	for (int i = 1; i <= n; ++ i)
		b[i] = a[i] = inp();
	sort(b+1, b+n+1);
	for (int i = 1; i <= n; ++ i)
		a[i] = lower_bound(b+1, b+n+1, a[i])-b;
	reverse(a+1, a+n+1);
	int ans = 1;
	for (int i = 1; i <= n; ++ i)
	{
		f[i] = get(a[i])+1;
		add(a[i], f[i]);
		freshmax(ans, f[i]);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi a(n), b;

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

		b=a;
		sort(b.rbegin(), b.rend());

		for(int i=0;i<n;i++)
		{
			int ans=b[0];
			if(ans==a[i]) ans=b[1];
			printf("%d\n", ans);
		}
	}
	return 0;
}


Measured memory_bytes: 3200
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::cmp::max;
use std::cmp::min;


fn main() {
    input! {
        A: i32,
        S: String,
    }

    if A >= 3200 {
        println!("{}", S);
    } else {
        println!("red");
    }
}


Measured memory_bytes: 2124
var input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
var sizes = input[1].split(' ').map(v => +v);
var count = 0, startIndex, endIndex;
while(true){
    startIndex = sizes.findIndex(v => v > 0);
	if (startIndex < 0) {
      break;
    }
	endIndex = sizes.findIndex((v, index) => v == 0 && index > startIndex)
    if (endIndex < 0) {
      endIndex = sizes.length
    }
	for (;startIndex < endIndex; ++startIndex) {
      --sizes[startIndex];
    }
  	++count;
}
console.log(count);

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define pb push_back
#define mp make_pair

int n;
string s;

bool solve(string &t){
    for(int i = 1; i < n - 1; i++){
        if(s[i] == 'o'){
            if(t[i] == 'W'){
                if(t[i - 1] == 'S') t.pb('W');
                else t.pb('S');
            }
            else{
                if(t[i - 1] == 'S') t.pb('S');
                else t.pb('W');
            }
        }
        else{
            if(t[i] == 'W'){
                if(t[i - 1] == 'S') t.pb('S');
                else t.pb('W');
            }
            else{
                if(t[i - 1] == 'S') t.pb('W');
                else t.pb('S');
            }
        }
    }
    bool ok = false;
    for(int i = 0; i < n; i++){
        int l = i - 1, r = i + 1;
        if(l < 0) l += n;
        if(r >= n) r -= n;
        if(s[i] == 'o'){
            if(t[i] == 'W'){
                if(t[l] == t[r]) ok = true;
            }
            else{
                if(t[l] != t[r]) ok = true;
            }
        }
        else{
            if(t[i] == 'W'){
                if(t[l] != t[r]) ok = true;
            }
            else{
                if(t[l] == t[r]) ok = true;
            }
        }
    }
    return !ok;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> s;

    string tmp = "SW";
    if(solve(tmp)){
        cout << tmp << endl;
        exit(0);
    }

    tmp = "SS";
    if(solve(tmp)){
        cout << tmp << endl;
        exit(0);
    }

    tmp = "WS";
    if(solve(tmp)){
        cout << tmp << endl;
        exit(0);
    }

    tmp = "WW";
    if(solve(tmp)){
        cout << tmp << endl;
        exit(0);
    }

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


Measured memory_bytes: 720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0197
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int[] items = RIntAr();
                if (items.Sum() == 0) break;

                int cnt = 0;
                long res = Gcd(items[0], items[1], ref cnt);

                Console.WriteLine("{0} {1}", res, cnt);
            }
        }


        /// <summary>
        ///最大公約数
        /// </summary>
        public static long Gcd(long a, long b, ref int cnt)
        {
            if (a < b) return Gcd(b, a, ref cnt);  // 引数を入替えて自分を呼び出す
            if (b == 0) return a; //一方が0の場合は、もう片方の数自身がGCD

            long d = 0;
            do
            {
                cnt++;
                d = a % b;
                a = b;
                b = d;
            } while (d != 0);
            return a;
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



Measured memory_bytes: 16252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;

const ll mod=1e9+7;
int main(){
      int h,w;
      cin>>h>>w;
      char s[h+2][w+2];
      rep1(i,h)rep1(j,w) cin>>s[i][j];
      rep0(i,h+2) s[i][0]=s[i][w+1]='#';
      rep0(j,w+2) s[0][j]=s[h+1][j]='#';
      int ans[h+2][w+2];
      rep0(i,h+2)rep0(j,w+2) ans[i][j]=0;
      rep0(i,h+2){
            ll first=0;
            ll pos=0;
            while(pos<=w+1){
                  while(s[i][pos]!='#'){
                        pos++;
                  }
                  for(int j=first;j<pos;j++){
                        ll ad=pos-first;
                        ans[i][j]+=ad;
                  }
                  first=pos+1;
                  pos=pos+1;
            }
      }
      rep0(j,w+2){
            ll first=0;
            ll pos=0;
            while(pos<=h+1){
                  while(s[pos][j]!='#'){
                        pos++;
                  }
                  for(int i=first;i<pos;i++){
                        ll ad=pos-first;
                        ans[i][j]+=ad;
                  }
                  first=pos+1;
                  pos=pos+1;
            }
      }
      int ret=0;
      rep0(i,h+2)rep0(j,w+2){
            ret=max(ret,ans[i][j]);
      }
      cout<<ret-1<<endl;
      return 0;
}

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

int main()
{
    int N;
    string str;
    map<string, int> map;
    map.insert(make_pair("AC", 0));
    map.insert(make_pair("WA", 0));
    map.insert(make_pair("TLE", 0));
    map.insert(make_pair("RE", 0));


    cin >> N;

    for (int i = 1; i <= N; i++)
    {
        cin >> str;
        map[str]++;
    }

    cout << "AC x "  << map.at("AC")  << endl;
    cout << "WA x "  << map.at("WA")  << endl;
    cout << "TLE x " << map.at("TLE") << endl;
    cout << "RE x "  << map.at("RE")  << endl;
}


Measured memory_bytes: 3632
MAX=2500
n,a=map(int,input().split())
x=list(map(int,input().split()))
# dp[i][j][k] := x[0:i]のカードからj枚とって合計がkとなる取り方の数
dp = [[[0] * (MAX+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1

for i in range(n):
  for j in range(0,n+1):
    for k in range(0, MAX+1):
      dp[i+1][j][k] += dp[i][j][k] # i番目のカードを取らない
  for j in range(0,n):
    for k in range(0, MAX+1-x[i]):
      dp[i+1][j+1][k+x[i]] += dp[i][j][k] # i番目のカードを取る

ans = 0
for i in range(1,n+1):
  ans += dp[n][i][a*i]
print(ans)


Measured memory_bytes: 119556
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(vector<T> & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(vector<T>& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(vector<T>& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(vector<T>& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>T Sum(vector<T> a, T init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define In(T,...) T __VA_ARGS__; CINPUT(VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn(T,name,n) vector<T> name(n); rep(i,n)cin>>name[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	in(n);
	out(800 * n - n / 15 * 200);
}

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

int main() {
	list<char> S;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		S.push_back(s[i]);

	int Q;
	bool rev = false;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int T;
		cin >> T;
		if (T == 1) {
			rev = !rev;
		} else if (T == 2) {
			int F;
			char C;
			cin >> F >> C;
			if ((F == 1 && rev == false) || (F == 2 && rev == true)) {
				S.push_front(C);
			} else if ((F == 1 && rev == true) || (F == 2 && rev == false)) {
				S.push_back(C);
			}
		}
	}

	if (rev == false) {
		int size = S.size();
		for (int i = 0; i < size; i++) {
			cout << S.front();
			S.pop_front();
		}
	} else if (rev == true) {
		int size = S.size();
		for (int i = 0; i < size; i++) {
			cout << S.back();
			S.pop_back();
		}
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 13024
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A = sc.next();
		String B = A.replace("1", "2");
		String C = B.replace("9", "3");
		String D = C.replace("2", "9");
		String E = D.replace("3", "1");
		System.out.println(E);
	}
}


Measured memory_bytes: 23888
#include <algorithm>
#include <iostream>
#include <map>
#include<string>
using namespace std;
#define int long long
const int inf = 10e9 + 7;
#define rep(i,n) for(int i=0;i<=n;i++)
signed main() {
	int a, b, c,x;
	cin >> a >> b >> c>>x;
	int ans = 0;
	rep(i, a) {
		rep(j, b) {
			rep(k, c) {
				if (500 * i + 100 * j + 50 * k == x)ans++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256