akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <iostream>

#include <string.h>

using namespace std;

bool prime_check(int n)
{
	if (n == 1) { return false; }

	if (n % 2 == 0)
	{
		if (n == 2) { return true; }

		else { return false; }
	}

	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n % i == 0) { return false; }
	}

	return true;
}

int main()
{
	const int DATA_SETS = 10000;
	const int MAX_PRIME = 1000000;

	int N[DATA_SETS], P[DATA_SETS], C = 0;

	bool I[MAX_PRIME + 1];

	memset(N, 0, sizeof(N));
	memset(P, 0, sizeof(P));
	memset(I, 0, sizeof(I));

	for (int i = 1; i <= MAX_PRIME; i++)
	{
		if (prime_check(i) == true)
		{
			I[i] = true;
		}
		else
		{
			I[i] = false;
		}
	}

	while (true)
	{
		cin >> N[C];

		if (N[C] == 0) { goto Exit; }

		C++;
	}

Exit:;

	for (int i = 0; i < C; i++)
	{
		for (int j = 2; j <= N[i] / 2; j++)
		{
			if (I[j] == true && I[N[i] - j] == true) { P[i]++; }
		}

		cout << P[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 2220
#include <stdio.h>
using namespace std;

long long  a[51];
long long b[51];
long long A[51];
long long B[51];
long long fun(long long _a,long long _b)
{
   long long c;
   while(_b!=0)  /* 余数不?0，??相除，直到余数?0 */
   {
       c=_a%_b;
       _a=_b;
       _b=c;
    }
   return _a;
}
int main()
{
    int i=1;
    while(~scanf("%lld%lld",&a[i],&b[i]))
    {
       A[i]=fun(a[i],b[i]);//最大
       B[i]=a[i]*b[i]/fun(a[i],b[i]);
       i++;
    }
    for(int j=1;j<i;j++)
    {
       printf("%d ",A[j]);
       printf("%d\n",B[j]);
    }
    return 0;
}

Measured memory_bytes: 2712
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    T = list(input().strip())
    p = 'P'
    for i, t in enumerate(T):
        if t == '?':
            T[i] = 'D'
    print(''.join(T))

if __name__ == '__main__':
    main()

Measured memory_bytes: 10820
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;

const int mod = 1e9+7;
const int N = 1e3+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n,m;
bool vis[N];
int pre[N];
vi e[N];
vi gao(int s) {
    //de(s);
    vi ret; ret.clear();
    mt(vis, 0); mt(pre, -1);
    queue<int> q;
    q.push(s);
    while(sz(q)) {
        int u = q.front(); q.pop();
        for(auto v: e[u]) {
            //dd(u);dd(v);de(vis[v]);
            if(vis[v]) continue;
            vis[v] = 1;
            q.push(v);
            pre[v] = u;
            //de(pre[v]);
        }
        if(vis[s]) break;
    }
    //rep(i, 1, n + 1) dd(i),de(pre[i]);
    //de(1);
    if(!vis[s]) return ret;
    ret.pb(s);
    int p = pre[s];
    while(p!=s) {
        //de(p);
        ret.pb(p);
        p = pre[p];
    }
    //de(2);
    return ret;
}
int main() {
    vi ans;
    scanf("%d%d",&n,&m);
    rep(i, 0, m) {
        int u, v; scanf("%d%d",&u,&v);
        e[u].pb(v);
    }
    rep(i, 1, n + 1) {
        vi tmp = gao(i);
        if(sz(tmp)&&(sz(tmp)<sz(ans)||!sz(ans))) ans = tmp;
    }
    if(!sz(ans)) return printf("-1\n"),0;
    printf("%d\n", sz(ans));
    rep(i, 0, sz(ans)) printf("%d\n", ans[i]);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int v,j,a,n,k;
int gcd(int A,int B){return B==0?A:gcd(B,A%B);}
int main(){
	scanf("%d%d",&n,&k);
	scanf("%d",&a);
	v=a;
	int F=1;
	if(a>=k)F=0;
	for(int i=2;i<=n;i++){
		scanf("%d",&j);
		if(j>=k)F=0;
		v=gcd(v,j);
	}
	if(k%v==0&&!F)puts("POSSIBLE");
	else puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int a,b,c;
   cin>>a>>b>>c;
   int count = 0;
   for(int i = a;i<=b; i++){
       if(c%i==0){
           if(a<=i&&b>=i){
               count++;
           }
       }
   }
   cout<<count<<endl;
   
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
int main(){
    int a,b,c; cin >> a >> b >> c;
    if (a+b==c || a+c==b || b+c==a) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long v,n,a;
double d[]={0.25,0.5,1,2};
vector<pair<long long,double> >V;
main(){
  for(int i=0;i<4;++i)cin>>v,V.push_back(make_pair(v,d[i]));
  cin>>n;
  for(int i=0;i<4;++i)for(int j=3;j>i;--j)if(V[j-1].first/V[j-1].second>V[j].first/V[j].second)swap(V[j-1],V[j]);
  for(int i=0;i<4&&n;++i){
    int x=n/V[i].second;
    a+=x*V[i].first;
    n-=int(x*V[i].second);
  }
  cout<<a<<endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

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

    int n, k;
    cin >> n >> k;

    double ans = 0;
    for( int i = 1 ; i <= n ; i++ ){
        int curr_num = i;
        int multi_cnt = 0;
        while(1){
            if( curr_num >= k ){
                break;
            }
            curr_num*=2;
            multi_cnt+=1;
        }
        double prob = 1.0/pow(2,multi_cnt);
        ans += prob;
    }
    ans /= n;
    printf("%.12f",ans);
}

Measured memory_bytes: 4012
#include <stdio.h>

int main() {
    char s[100000];
    int count=0,ans=0,deff_count_a=0,deff_count_b=0;
    scanf("%s",s);
    for (int i=0; s[i]!='\0'; i++) {
        count++;
    }
    char a[count],b[count];
    //aをつくる 01010...
    for (int i=0; i<count; i++) {
        if (i%2==0) {
            a[i]='0';
        }else{
            a[i]='1';
        }
    }
    //bをつくる 1010...
    for (int i=0; i<count; i++) {
        if (i%2==0) {
            b[i]='1';
        }else{
            b[i]='0';
        }
    }
    /*
    for (int i=1; i<count; i++) {
        if (!((s[i-1]==0&&s[i+1]==1)||(s[i-1]==1&&s[i+1]==0))) {
            ans++;
        }
    }*/
    //aのカウント
    for (int i=0; i<count; i++) {
        if (a[i]!=s[i]) {
            deff_count_a++;
        }
    }
    //bのカウント
    for (int i=0; i<count; i++) {
        if (b[i]!=s[i]) {
            deff_count_b++;
        }
    }
    if (deff_count_a<deff_count_b) {
        printf("%d\n",deff_count_a);
    }else{
        printf("%d\n",deff_count_b);
    }
    
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
char a[15];
double s;
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
  	double x;
  	cin>>x;
  	cin>>a;
  	if(a[0]=='J')
  	 s+=x;
  	else
  	 s+=x*380000;
  }
  printf("%f",s);
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
#define MN 800
char s[MN+5][MN+5];
int qx[MN*MN+5],qy[MN*MN+5],qn,d[MN+5][MN+5];
const int o[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int main()
{
	int n,m,k,i,j,x,y,ans=MN;
	scanf("%d%d%d",&n,&m,&k);
	for(i=1;i<=n;++i)
	{
		scanf("%s",s[i]+1);
		for(j=1;j<=m;++j)if(s[i][j]=='S')d[qx[0]=i][qy[0]=j]=1;
	}
	for(i=0;i<=qn;++i)
	{
		ans=min(ans,(min(min(qx[i]-1,n-qx[i]),min(qy[i]-1,m-qy[i]))+k-1)/k);
		if(d[qx[i]][qy[i]]<=k)for(j=0;j<4;++j)
		{
			x=qx[i]+o[j][0];y=qy[i]+o[j][1];
			if(s[x][y]=='.'&&!d[x][y])d[x][y]=d[qx[i]][qy[i]]+1,qx[++qn]=x,qy[qn]=y;
		}
	}
	printf("%d",ans+1);
}

Measured memory_bytes: 8320
#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>;

int main() {
    int N, M;
    cin >> N >> M;
    ll A;
    priority_queue<ll, vector<ll>, less<int>> price;
    rep(i,N) {
        cin >> A;
        price.push(A);
    }
    ll ans = 0;
    rep(i,M) {
        ll discount = price.top() / 2;
        price.pop();
        price.push(discount);
    }
    rep(i,N) {
        ans += price.top();
        price.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 4216
n = int(input())
S=[]


for i in range(n):
  S.append(list(input()))

S[0].sort()
#文字列ごとにカウントする辞書
D ={}

for i in range(len(S)):
  #Sの最初の文字列を使って辞書を作る
  if i==0:
    for j in range(len(S[i])):
      #辞書にその文字列を追加
      if S[i][j] not in D:
        D[S[i][j]] =1
      #被りがあったら数を増やす
      else:
        D[S[i][j]] +=1
  else:

  #辞書の文字の中と他の文字列を照合
    for k in D:
      #その文字がなければカウントを0にする
      if k not in S[i]:
        D[k] = 0
      #その文字があればその文字列にあるその文字の中身を入れる（最小の文字の大きさに更新していく）
      else:
        D[k] = min(D[k], S[i].count(k))

D = sorted(D.items(),key=lambda x:x[0])
ans=[]

for i in range(len(D)):
  ans.append(D[i][0]*D[i][1])
ans = "".join(ans)
print(ans)



Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {
    int N;
    string answer;
    vector<int> t,x,y;
    cin >> N;

    for(int i=0; i<N; i++){
        int ti,xi,yi;
        cin >> ti >> xi >> yi;
        t.push_back(ti);
        x.push_back(xi);
        y.push_back(yi);
    }

    int start_x = 0;
    int start_y = 0;
    int time_now = 0;
    answer = "Yes";
    for(int i =0; i <N; i++){
        if (answer == "No") {
            continue;
        }
        int distance = (x[i] - start_x) + (y[i] - start_y);
        if (distance <= t[i]){
            int distance_remaining = t[i] - time_now - distance;
            if(distance_remaining%2 == 0){
                answer = "Yes";
                start_x = x[i];
                start_y = y[i];
                time_now = t[i];

            }else{
                answer = "No";
            }
        }else{
            answer = "No";
        }
    }

    cout << answer;
    return 0;
}

Measured memory_bytes: 1644
# YYMM or MMYY or AMBIGUOUS or NA
s = input()

def year_chack(s):
    return True

def manth_check(s):
    if ( s == '01' or
            s == '02' or
            s == '03' or
            s == '04' or
            s == '05' or
            s == '06' or
            s == '07' or
            s == '08' or
            s == '09' or
            s == '10' or
            s == '11' or
            s == '12'):
        return True
    else :
        return False

frond = s[0] + s[1]
back = s[2] + s[3]


status = ""

#YYMM
if (year_chack(frond) and manth_check(back)):
    status = status + "1"
else :
    status = status + "0"

#MMYY
if (manth_check(frond) and year_chack(back)):
    status = status + "1"
else :
    status = status + "0"

if (status == "11"):
    print("AMBIGUOUS")
elif (status == "00"):
    print("NA")
elif (status == "01"):
    print("MMYY")
elif (status == "10"):
    print("YYMM")






Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653589793;
int main(){
    double a, b, c; cin >> a >> b >> c;
    double s, l, h;
    s = a * b * sin(c / 180.0 * pi) / 2;
    l = a + b + sqrt(a * a + b * b  - 2 * a * b * cos(c / 180.0 * pi));
    h = s * 2 / a;
    printf("%.10f\n", s);
    printf("%.10f\n", l);
    printf("%.10f\n", h);

}


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

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const int INF = 1000000;
const int mod = 1e9 + 7;



const int MAX_E = 300100;
const int MAX_V = 100100;
 
int par_uft[MAX_V];
int rank_uft[MAX_V];
 
void init_uft(int n) {
	int i;
	for (i = 0; i < n; i++) {
		par_uft[i] = i;
		rank_uft[i] = 0;
	}
}
 
int find_uft(int x) {
	if (par_uft[x] == x) {
		return x;
	}
	else {
		return par_uft[x] = find_uft(par_uft[x]);
	}
}
 
void unite_uft(int x, int y) {
	x = find_uft(x);
	y = find_uft(y);
	if (x == y)return;
 
	if (rank_uft[x] < rank_uft[y]) {
		par_uft[x] = y;
	}
	else {
		par_uft[y] = x;
		if (rank_uft[x] == rank_uft[y]) {
			rank_uft[x]++;
		}
	}
}
 
bool same_uft(int x, int y) {
	return find_uft(x) == find_uft(y);
}
 
 
 
struct edge { 
	int u, v, cost;
	edge(){}
	edge(int u,int v,int cost):u(u),v(v),cost(cost){}
};
 
bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
 
edge es[MAX_E];
int V, E;
 
ll kruskal() {
	sort(es, es + E, comp);
	init_uft(V);
	ll res = 0LL;
	for (int i = 0; i < E; i++) {
		edge e = es[i];
		if (!same_uft(e.u, e.v)) {
			unite_uft(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}



int main(){
	int n,m;
	while(cin>>n>>m && n>0 ) {
		V=n; E=m*2;
		int a,b,c;
		for(int i=0; i<m; i++){
			cin>>a>>b>>c;
			es[i*2] =edge(a,b,c);
			es[i*2+1] = edge(b,a,c);
		}
		cout<<kruskal()<<endl;
	}
}

Measured memory_bytes: 3212
def ch(s,t):
    list1=[]
    for i in range(len(s)-len(t)+1):
        w=s[i:i+len(t)]
        ct=0
        for j in range(len(t)):
            if w[j]==t[j]:
                ct+=1
        list1.append(ct)
    return(max(list1))
s=input()
t=input()
flag=0
ans=ch(s,t)
print(len(t)-ans)

Measured memory_bytes: 67708
def main():
    n, x = list(map(int, input().split()))
    A = list(map(int, input().split()))
    B = [min(A[0], x), ]
    for i in range(n - 1):
        if B[i] + A[i + 1] > x:
            B.append(x - B[i])
        else:
            B.append(A[i + 1])
    ans = sum([a - b for a, b in zip(A, B)])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 65252
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

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

#define N 100005
ll n,m;
vector<ll>v[N];
ll dp[N];

ll dfs(ll id){
    if(dp[id]!=-1)return dp[id];
    dp[id]=1;
    for(auto x:v[id]){
        Max(dp[id],1+dfs(x));
    }
    return dp[id];
}

int main(){fastio
    cin>>n>>m;
    memset(dp,-1,sizeof(dp));
    while(m--){
        ll a,b;cin>>a>>b;
        v[a].pb(b);
    }
    rep(i,1,n){
        if(dp[i]==-1)dfs(i);
    }
    //rep(i,1,n)cout<<dp[i]<<" ";cout<<endl;
    
    ll ans=0;rep(i,1,n)Max(ans,dp[i]);
    cout<<ans-1<<endl;
    
    return 0;
}



Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N;
	while(1){
		cin >> N;
		if(N==0)break;
		vector<ll> A(N);
		ll w = 0,ans = 0;
		FOR(i,0,N){
			cin>>A[i];
			w += A[i];
		}
		FOR(i,0,N){
			if(w>=A[i]*N)ans++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3324
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
#include <deque>
#include <cstdint>
using namespace std;

int main () {
  int n, m, x;
  cin >> n >> m >> x;
  int cost = 0;
  for (int i = 0; i < m; i++){
    int a;
    cin >> a;
    if (a < x){
      cost++;
    }else{
      break;
    }
  }
  if (cost >= m-cost){
    cost = m- cost;
  }
  cout << cost;
  return 0;
}

Measured memory_bytes: 256
use std::collections::{ HashMap, VecDeque };

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

struct CharsInfo {
    chars: VecDeque<char>,
    east_num: i32,
    west_num: i32,
}

fn char_nums(chars: &VecDeque<char>) -> HashMap<char, i32> {
    let mut counter = HashMap::new();
    for c in chars {
        let mut count = counter.entry(*c).or_insert(0);
        *count += 1;
    }
    counter
}

fn main() {
    let n: i32       = read();
    let vectored_str = read::<String>().chars().collect::<Vec<char>>();
    let mut right = CharsInfo {
        chars: VecDeque::new(),
        east_num: 0,
        west_num: 0,
    };
    let mut left = {
        let chars: VecDeque<char> = (1 .. n).map(|i| vectored_str[i as usize]).collect();
        let counter = char_nums(&chars);
        CharsInfo {
            chars: chars,
            east_num: *counter.get(&'E').unwrap_or(&0),
            west_num: *counter.get(&'W').unwrap_or(&0),
        }
    };

    let change_nums: Vec<i32> = (0 .. n).map(|leader_index| {
        let right_change_num = right.west_num;
        let left_change_num  = left.east_num;

        let c = vectored_str[leader_index as usize];
        right.chars.push_back(c);
        if c == 'E' { right.east_num += 1 }
        if c == 'W' { right.west_num += 1 }

        let remove_char = left.chars.pop_front().unwrap_or('\0');
        if remove_char == 'E'  { left.east_num -= 1 }
        if remove_char == 'W'  { left.west_num -= 1 }

        right_change_num + left_change_num
    }).collect();
    println!("{}", change_nums.iter().min().unwrap());
}


Measured memory_bytes: 12540
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;

int main() {
  int n;
  cin >> n;
  static int ans[100000];
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ans[x - 1] = i + 1;
  }

  for (int i = 0; i < n; i++) {
    if (i != 0) {
      cout << " ";
    }
    cout << ans[i];
  }
  cout << endl;
}


Measured memory_bytes: 1152
sx, sy, tx, ty = map(int, input().split())
ans = ''
for _ in range(ty - sy):
    ans += 'U'
for _ in range(tx - sx):
    ans += 'R'
for _ in range(ty - sy):
    ans += 'D'
for _ in range(tx - sx):
    ans += 'L'
ans += 'L'
for _ in range(ty - sy + 1):
    ans += 'U'
for _ in range(tx - sx + 1):
    ans += 'R'
ans += 'DR'
for _ in range(ty - sy + 1):
    ans += 'D'
for _ in range(tx - sx + 1):
    ans += 'L'
ans += 'U'
print(ans)

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

int main(){
  int A,B;
  cin>>A>>B;
  bool flag=false;
  int X=0;
  while(!flag){
    if (X*8/100==A&&X*10/100==B){
      flag=true;
      break;
    }
    X++;
    if (X==1251){
      break;
    }
  }
  if (flag){
    cout<<X<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 3604
#pragma GCC optimize ("O3")
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
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 n;
      cin>>n;
      cout<<n*n*n<<endl;
      return 0;
}


Measured memory_bytes: 256
N = int(input())
if N%10 == 1 or N%10 ==0 or N%10 ==6 or N%10 ==8:
    print("pon")
elif N%10 == 2 or N%10 == 5 or N%10 == 7 or N%10 ==9 or N%10 ==4:
    print("hon")
else:
    print("bon")


Measured memory_bytes: 9092
import java.util.*

fun main() {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

class UnionFind(size: Int) {
    private val par: IntArray = IntArray(size) { -1 }
    private val rank = IntArray(size) { 0 }

    private fun root(x: Int): Int =
        if (par[x] < 0) {
            x
        } else {
            par[x] = root(par[x])
            par[x]
        }

    fun count(x: Int): Int = -par[root(x)]

    fun isSame(x: Int, y: Int) = root(x) == root(y)

    fun unite(x: Int, y: Int) {
        val rootOfX = root(x)
        val rootOfY = root(y)
        if (rootOfX == rootOfY) return
        if (rank[rootOfX] < rank[rootOfY]) {
            par[rootOfY] += par[rootOfX]
            par[rootOfX] = rootOfY
        } else {
            par[rootOfX] += par[rootOfY]
            par[rootOfY] = rootOfX
        }
        if (rank[rootOfX] == rank[rootOfY]) rank[x]++
    }
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val Q = sc.next().toInt()
        val uf = UnionFind(N)
        repeat(Q) {
            val t = sc.next().toInt()
            val u = sc.next().toInt()
            val v = sc.next().toInt()
            if (t == 0) {
                uf.unite(u, v)
            } else {
                pw.println(if (uf.isSame(u, v)) 1 else 0)
            }
        }
    }
}


Measured memory_bytes: 65716
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
ll frac[MAX_N];

ll modpow(ll a, ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%MOD;
        a=a*a%MOD;
        n/=2;
    }
    return res;
}

ll comb(ll n, ll r){
    ll res=1;
    res*=frac[n];
    res*=modpow(frac[r],MOD-2);
    res%=MOD;
    res*=modpow(frac[n-r],MOD-2);
    res%=MOD;
    return res;
}

ll perm(ll n, ll r){
    ll res=1;
    res*=frac[n];
    res=res*modpow(frac[n-r],MOD-2)%MOD;
    return res; 
}

int main(){
    ll n,m,ans=0;
    cin>>n>>m;
    frac[0]=1;
    for(ll i=1;i<=m;i++) frac[i]=frac[i-1]*i%MOD;
    for(ll i=0;i<=n;i++){
        ll buf=comb(n,i);          //一致する場所の選び方（i箇所）
        buf=buf*perm(m-i,n-i)%MOD; //それ以外の場所の通り数
        //包除原理
        if(i%2){
            ans=(ans-buf+MOD)%MOD;
        }else{
            ans=(ans+buf)%MOD;
        }
    }
    ans=ans*perm(m,n)%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 7544
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define ALL(x) (x).begin(),(x).end()

inline cpp_int between(cpp_int n, cpp_int x) {
  if(n >= 0)
    return (n/x)+1;
  else
    return 0;
}

int main () {
  int w, h, k;
  cin >> w >> h >> k;

  REP(i, h+1) {
    REP(j, w+1) {
      if((i * (w-j)) + ((h-i) * j) == k) {
        cout << "Yes" << endl;
        return 0;
      }

    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
 
int main()
{
  int n, m;
  cin >> n >> m;
  int height[n+1];
  bool isGood[n+1];
  
  REP(i, n)
  {
    int h;
    cin >> h;
    height[i+1] = h;
    isGood[i+1] = true;
  }
  
  REP(i, m)
  {
    int a, b;
    cin >> a >> b;
    isGood[a] = isGood[a] & (height[a] > height[b]);
    isGood[b] = isGood[b] & (height[b] > height[a]);
  }
    
  int ans = 0;
  REP(i, n)
  {
    if(isGood[i+1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4080
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();

    int max = Math.max(Math.max(a, b), c);

    System.out.println(((a + b + c) - max) + (max * (int) Math.pow(2, k)));

  }
}

Measured memory_bytes: 35792
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 = list(map(int, LS()))
    S = S[::-1]
    ln = len(S)
    mod = 2019

    times = 1
    for i in range(ln):
        S[i] = S[i] * times
        times = times * 10 % mod

    R = [0] * (ln+1)
    memo = {0: 1}
    ans = 0
    for i in range(1, ln+1):
        tmp = (R[i-1] + S[i-1]) % mod
        R[i] = tmp
        cnt = memo.get(tmp, 0)
        ans = ans + cnt
        memo[tmp] = cnt + 1
    print(ans)

if __name__ == '__main__':
    solve()


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

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 998244353

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define part(v, s, e) v.begin() + s, v.begin() + e
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast;
    ll n;
    cin >> n;
    vi arr(n);
    REP(i, 0, n)
        cin >> arr[i];
    vi dp(n);
    dp[0] = arr[0];
    REP(i, 1, n)
        dp[i] = dp[i-1] + arr[i];
    ll m = abs(dp[n-1] - 2 * dp[0]);
    REP(i, 1, n)
        m = min(m, abs(dp[n-1] - 2 * dp[i]));
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 256
N, H = map(int, input().split())
nage = []
a_max = 0
for i in range(N):
	a, b = map(int, input().split())
	a_max = max(a_max, a)
	nage.append(b)
nage.sort(reverse=True)
cnt = 0
for i in (i for i in nage if i > a_max):
	cnt += 1
	H -= i
	if H <= 0:
		print(cnt)
		exit()
cnt += -(-H//a_max)
print(cnt)

Measured memory_bytes: 7428
import math

(A,B,H,M) = map(int,input().split())
A_deg = 30*H+M*0.5
B_deg = M*6
deg = max(A_deg - B_deg,B_deg -A_deg)
cosdeg = math.cos(math.radians(deg))
ans = math.sqrt(A**2+B**2-2*A*B*cosdeg)
print(ans)

Measured memory_bytes: 9440
#!/usr/bin/env python3
def ispalindrome(str): return 1 if str == str[::-1] else 0
S = input()
N = len(S)
S_2 = S[0:(N-1)//2]
S_3 = S[(N+3)//2-1:]
jdg = 0

jdg += ispalindrome(S)
jdg += ispalindrome(S_2)
jdg += ispalindrome(S_3)

if jdg == 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
const int N=5003;
int n,y,A[N],w[N],B[N],b[N],dpw[N][N],dpb[N][N],dp[N][N];
char x;
int main(){
    cin>>n;
    for (int i=1; i<=2*n; i++){
    	cin>>x>>y;
    	if(x=='W')A[i]=y,w[y]=i;
    	if(x=='B')B[i]=y,b[y]=i;
	}
    for (int i=1; i<=2*n; i++)
    	for (int j=0; j<=n; j++){
    		dpw[i][j]=dpw[i-1][j];
    		dpb[i][j]=dpb[i-1][j];
    		if(A[i]>j)dpw[i][j]++;
    		if(B[i]>j)dpb[i][j]++;
    	}
    for (int i=0; i<=n; i++)
    	for (int j=0; j<=n; j++){
    		if(!i&&!j)continue;
    		if(!i){dp[i][j]=dp[i][j-1]+dpw[b[j]][i]+dpb[b[j]][j];continue;}
    		if(!j){dp[i][j]=dp[i-1][j]+dpw[w[i]][i]+dpb[w[i]][j];continue;}
    		dp[i][j]=min (  dp[i-1][j]+dpw[w[i]][i]+dpb[w[i]][j], 
						    dp[i][j-1]+dpw[b[j]][i]+dpb[b[j]][j]);
    	}
    cout<<dp[n][n];
    return 0;
}

Measured memory_bytes: 200192
#include<iostream>
#include<vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <limits>
#include <map>
#include <bitset>
#include <iomanip>

#define rep(i,n) for(int (i) = 0; (i)<(n); (i)++)
#define FOR(i,s,e) for(int (i) = (s); (i)<(e); (i)++)
#define vecall(itr,vec) for(auto (itr) = (vec).begin(); (itr) != (vec).end(); (itr)++)
#define vecshow(vec) for(auto itr = (vec).begin(); itr != (vec).end(); itr++)cout << *itr << " ";

using namespace std;
using p = pair<int, int>;
using ll = long long;

int gcd(int a, int b) {
	int l = max(a, b);
	int s = min(a, b);
	while (l * s != 0) {
		int tmp = s;
		s = l % s;
		l = tmp;
	}

	return l;
}

vector<vector<int>> path;

int main() {
	int x, y;
	cin >> x >> y;
	if (y % 2 == 0 && y >= 2 * x && y <= 4 * x)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}

Measured memory_bytes: 3624
#include <stdio.h>
int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int f;
    f = a;
    a = b;
    b = f;
    f = a;
    a = c;
    c = f;
    printf("%d %d %d\n", a, b, c);
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int H;

void maxHeapify(vector<ll> &A, int i){
    int l = 2*i+1; int r = 2*i+2;
    // 右の子、自分、左の子で最大のインデックスを選択する
    int largest;
    if(l < H && A[l] > A[i]){
        largest = l;
    }else{
        largest = i;
    }
    if(r < H && A[r] > A[largest]){
        largest = r;
    }
    if(largest != i){
        swap(A[i], A[largest]);
        maxHeapify(A, largest);
    }
}

void buildMaxHeap(vector<ll> &A){
    for(int i=H/2; i>=0; i--){
        maxHeapify(A, i);
    }
}

int main()
{
    cin >> H;
    vector<ll> A(H);
    rep(i, H){
        ll Ai; cin >> Ai;
        A[i] = Ai;
    }
    buildMaxHeap(A);
    rep(i, H) cout << " " << A[i];
    cout << endl;
}


Measured memory_bytes: 6716
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

ll n, a[101], dp[101][100010], sum[101][100010], tot[101], MOD = 1e9+7;

int main(){FIN;
  int n,k;
  cin >> n >> k;
  fore(i,0,n) cin >> a[i], tot[i] = a[i]+(i?tot[i-1]:0);
  for(ll i = n-1; i >= 0; i--){
    for(ll j = 0; j <= k; j++){
      ll all = tot[n-1]-(i?tot[i-1]:0);
      ll nxt = tot[n-1]-tot[i];
      if(j > all) dp[i][j] = 0;
      else if(i == n-1){
        dp[i][j] = 1;
      }
      else{
        ll mx = min(a[i],j);
        ll mn = max(0ll,j-nxt);
        if(mn <= mx){
          dp[i][j] = (sum[i+1][j-mn] - ((j-mx)?sum[i+1][j-mx-1]:0) +MOD)%MOD;
        }
      }
      sum[i][j] = (dp[i][j]+(j?sum[i][j-1]:0)+MOD)%MOD;
    }
  }
  cout << dp[0][k] << "\n";
}

Measured memory_bytes: 157952
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  string s,t;
  cin>>s>>t;
  int a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(s==u) --a;
  else --b;
  cout<<a<<' '<<b<<endl;
  return 0;
}


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


void solve(long long A, long long B){
    cout << A * B << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

ll modpow(ll x, ll n, ll mod){
	ll res = 1;
	while(n > 0){
		if(n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

struct UnionFind{
	vl p;
	vl rank;
	vl cnt;

	UnionFind(ll n){
		rank.resize(n,0);
		p.resize(n,0);
		cnt.resize(n,0);
		rep(i,n){
			p[i] = i;
			rank[i] = 0;
			cnt[i] = 1;
		}
	}

	ll find(ll x){
		if(x != p[x]) p[x] = find(p[x]);
		return p[x];
	}

	bool same(ll x, ll y){
		return find(x) == find(y);
	}

	void unite(ll x, ll y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		if(rank[x] > rank[y]){
			p[y] = x;
			cnt[x] += cnt[y];
		}else{
			p[x] = y;
			cnt[y] += cnt[x];
			if(rank[x] == rank[y]) rank[y]++;
		}
	}

	ll size(ll x){
		return cnt[find(x)];
	}
};

int main(){
	ll n,m,k; cin >> n >> m >> k;
	UnionFind uf(n);
	vl v(n,0);
	rep(i,m){
		ll a,b; cin >> a >> b; a--; b--;
		uf.unite(a,b);
		v[a]++;
		v[b]++;
	}
	vl ans(n,0);
	rep(i,n){
		ans[i] = uf.size(i) - v[i];
	}
	rep(i,k){
		ll c,d; cin >> c >> d; c--; d--;
		if(uf.same(c,d)){
			ans[c]--;
			ans[d]--;
		}
	}
	rep(i,n) cout << ans[i]-1 << " ";
	cout << endl;
}

Measured memory_bytes: 4736
#include<iostream>
#include<string>
using namespace std;
int main(){
 string s;
 cin>>s;
 string ans="yes";
 for(int i=0;i<s.length()-1;i++){
  for(int j=i+1;j<s.length();j++){
   if(s[i]==s[j]){
    ans="no";
    break;
   }
   else continue;
  }
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 256
def max(a,b); a > b ? a : b; end
  
N = gets.to_i
A = gets.split.map(&:to_i)
C = A.each_with_object(Array.new(N + 1, 0)){|i,c| c[i] += 1 }
D = C.each_with_object(Array.new(N + 1, 0)){|j,d| d[j] += 1 }
E = Array.new(N + 1, 0)
(1 .. N).each{|k| E[k] = E[k - 1] + k * D[k] }
F = Array.new(N + 1, 0)
(1 .. N).each{|k| F[k] = F[k - 1] + D[k] }

def max_size(m)
  (E[m] + m * (F[N] - F[m])) / m
end

dp = Array.new(N + 1, 0)
(1 .. N).each{|m| dp[m] = max_size(m) }
G = Array.new(N + 1, 0)

dp.each_with_index do |k,m|
  G[k] = m
end

(1 .. N).reverse_each.inject(0) do |s,i|
  G[i] = max(s, G[i])
end

puts G[1 .. N]


Measured memory_bytes: 47764
x = int(input())
y = x
if x == 1:
    print('0 -1')
    exit()
v = []
for i in range(0,1001):
    v.append(i*i*i*i*i)
    v.append(i*i*i*i*i*-1)
c = 0
d = 0
for i in range(len(v)):
    y -= v[i]
    for j in range(len(v)):
        if v[j] == y * -1:
            c = i
            d = j
            break
    y = x
if c % 2 == 0: c //= 2
else:
    c = (c-1) // 2
    c *= -1
if d % 2 == 0: d //= 2
else:
    d = (d-1) // 2
    d *= -1
print(c,d)

Measured memory_bytes: 9120
import java.util.*;


public class Main{
    public static void main(String[] args){

        Scanner sc=new Scanner(System.in);

        int h=sc.nextInt();
        int w=sc.nextInt();

        String[] a=new String[h];
        for(int i=0;i<h;i++){
            a[i]=sc.next();
        }
        boolean[] row= new boolean[h];
        Arrays.fill(row,false);
        boolean[] col=new boolean[w];
        Arrays.fill(col,false);

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(a[i].charAt(j)=='#'){
                    row[i]=true;
                    col[j]=true;
                }
            }
        }

        for(int i=0;i<h;i++){
            if(row[i]){
                for(int j=0;j<w;j++){
                    if(col[j]){
                        System.out.print(a[i].charAt(j));
                    }
                }
            System.out.println();
            }
        }
    }
}

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

using namespace std ;

const long long mod = 1e9 + 7ll ;
const int MAX = 2e3 + 10 ;

long long dp[MAX][MAX] ;
int arr[MAX] , arr2[MAX] ;
int n , m ;

long long solve(int idx , int idx2)
{
	if(idx == n || idx2 == m)
		return 0 ;
	long long &ret = dp[idx][idx2] ;
	if(ret != -1)
		return ret ;
	ret = solve(idx+1 , idx2) % mod ;
	ret = (ret + solve(idx , idx2+1)) % mod ;
	if(arr[idx] == arr2[idx2])
		ret = (ret + solve(idx+1 , idx2+1) + 1) % mod ;
	ret = (ret - solve(idx+1 , idx2+1) + mod) % mod ;
	return ret ;
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	for(int i = 0 ; i < m ; ++i)
		cin>>arr2[i] ;
	memset(dp , -1 , sizeof(dp)) ;
	return cout<<((solve(0 , 0)+1ll)%mod)<<"\n" , 0 ;
}

Measured memory_bytes: 32128
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B =MI()
    if A+B>=10:
        print("error")
    else:
        print(A+B)
if __name__ == '__main__':
    main()

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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)
#define	INF (1<<29)
//536870912

#define	MOD 1000000007

int	main() {
	int N, K;
	cin >>N >>K;
	vector<int> a(N, 0);
	for (int i=0; i<N; i++)
		cin >>a.at(i);
	vector<long> b;
	for (int i=0; i<N; i++) {
		long S=0;
		for (int j=i; j<N; j++) {
			S +=a.at(j);
			b.push_back(S);
		}
	}
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	long S=pow(2, 42);
	long SUM=0;
	while(S>=1) {
		int s=K;
		for (int i=0; i<b.size()-1; i++){
			long SS=SUM+S;
			if (SS==(SS&b.at(i)))
				s--;
			if (0==s)
				break;
		}
		if (0==s)
			SUM +=S;
		S /=2;
	}
	cout <<SUM <<endl;
	return 0;
}



Measured memory_bytes: 6132
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back
 
const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
 
VI dp[100010];
//素数ならtrue
bool prime[100010];
VI p;
signed main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int n, k;
  cin >> n >> k;
 
  if(k == 0) {
    cout << n*n << endl;
    return 0;
  }
 
  // int deb = 0;
  // FOR(i, 1, n+1) {
  //   FOR(j, 1, n+1) {
  //     cout << i%j << " ";
  //     if(i%j >= k) deb++;
  //   }
  //   cout << endl;
  // }
  // cout << deb << endl;
 
  int ans = 0;
  FOR(i, 1, n+1) {
    if(i-1 >= k) {
      ans += n/i*(i-k);
      ans += max(0LL, (n%i) - k + 1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main()
{
    int N, a[110], M = -200, m = 200;
    cin>>N;
    for(int i = 0; i < N; i++){
        cin>>a[i];
        M = max(M, a[i]);
        m = min(m, a[i]);
    }

    int ans = 0x3f3f3f3f;
    for(int i = m; i <= M; i++){
        int sum = 0;
        for(int j = 0; j < N; j++){
            sum += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, sum);
    }

    cout<<ans<<endl;

    return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<string> W(N);
  for (int i = 0; i < N; i++)
  {
    cin >> W[i];
  }
  bool ans = true;
  for (int i = 1; i < N; i++)
  {
    if (W[i][0] != W[i - 1].back())
    {
      ans = false;
      break;
    }
    for (int j = 0; j < i; j++)
    {
      if (W[i] == W[j])
      {
        ans = false;
        break;
      }
    }
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int h,w,cnt=0,ind=0,max=0;
  cin >> h >> w;
  string s[h];
  vector<int> row_light[2001],col_light[2001];
  for(int i=0;i<2001;i++){
    for(int j=0;j<2001;j++){
      row_light[i].push_back(0);
      col_light[i].push_back(0);
    }
  }
  for(int i=0;i<h;i++){
    cin >> s[i];
    cnt=0;
    ind=0;
    for(int j=0;j<w;j++){
      if(s[i][j]=='#'){
        fill(row_light[i].begin()+ind,row_light[i].begin()+j,cnt);
        row_light[i][j]=0;
        cnt=0;
        ind=j+1;
      }else{
        cnt++;
      }
    }
    if(s[i][w-1]=='.'){
      fill(row_light[i].begin()+ind,row_light[i].begin()+w,cnt);
    }
  }
  for(int i=0;i<w;i++){
    cnt=0;
    ind=0;
    for(int j=0;j<h;j++){
      if(s[j][i]=='#'){
        fill(col_light[i].begin()+ind,col_light[i].begin()+j,cnt);
        col_light[i][j]=0;
        cnt=0;
        ind=j+1;
      }else{
        cnt++;
      }
    }
    if(s[h-1][i]=='.'){
      fill(col_light[i].begin()+ind,col_light[i].begin()+h,cnt);
    }
  }
  int num;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      num = row_light[i][j]+col_light[j][i]-1;
      max = (num<max)?max:num;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 36480
#include <stdio.h>
#include <string.h>

char a[32][32], b[32][32], t[32][32];
int h, w, n;

int func(void)
{
    int i, j, k, l, res;
    memcpy(b, a, sizeof(a));
    for(j=0;j<w;++j) {
        k=h;
        for(i=h-1;i>=0;--i) if (b[i][j]!='.') a[--k][j]=b[i][j];
        for(i=k-1;i>=0;--i) a[i][j]='.';
    }
    memcpy(b, a, sizeof(a));

    for(i=0;i<h;++i) for(j=0;j<w;++j) if (a[i][j]!='.') {
        for(k=0;j+k<w && a[i][j]==a[i][j+k];++k);
        if (k>=n)
            for(l=0;l<k;++l) b[i][j+l]='.';
        j+=k-1;
    }
    for(j=0;j<w;++j) for(i=0;i<h;++i) if (a[i][j]!='.') {
        for(k=0;i+k<h && a[i][j]==a[i+k][j];++k);
        if (k>=n)
            for(l=0;l<k;++l) b[i+l][j]='.';
        i+=k-1;
    }

    res=w*h;
    for(j=0;j<w;++j) {
        k=h;
        for(i=h-1;i>=0;--i) if (b[i][j]!='.') a[--k][j]=b[i][j];
        for(i=k-1;i>=0;--i) a[i][j]='.';
        res-=k;
    }
    return res;
}

void swap(char* a, char* b) { char x=*a; *a=*b; *b=x; }

int main(void)
{
    while (~scanf("%d%d%d", &h, &w, &n)) {
        int i, j, yes;
        for(i=0;i<h;++i) scanf("%s", a[i]);

        yes=0;
        memcpy(t, a, sizeof(a));
        for(i=0;i<h;++i) for(j=0;j<w-1;++j) if (a[i][j]!='.' || a[i][j+1]!='.') {
            int p=-1, q=-1;
            swap(&a[i][j], &a[i][j+1]);
            do {
                q=p;
                p=func();
            } while (p!=q);
            if (p==0) { yes=1; goto END; }
            memcpy(a, t, sizeof(a));
        }
END:
        puts(yes ? "YES" : "NO");
    }
    return 0;
}

Measured memory_bytes: 580