akhauriyash/Code-Regression huggingface dataset:
//Moh_K_Imar .......
//29/08/2020  ... 5,15.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a,b,c;
    char x,y;
    cin>>a>>x>>b>>c;
    if(b<=04)cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;

    return 0;
}



Measured memory_bytes: 3524
unittest
{
	assert( [ "4 5 3", "8", "7", "4", "2" ].parse.expand.solve == 2 );
	assert( [ "2 10 4", "20", "20" ].parse.expand.solve == 4 );
	assert( [ "5 2 1", "900000000", "900000000", "1000000000", "1000000000", "1000000000" ].parse.expand.solve == 800000000 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nab = input.front.split.to!( long[] );
	auto hs = new long[ nab[ 0 ] ];
	foreach( ref h; hs )
	{
		input.popFront;
		h = input.front.to!( long );
	}
	return tuple( nab[ 1 ], nab[ 2 ], hs );
}

auto solve( long a, long b, long[] hs )
{
	// aはbとの差分にしておくと後が楽
	a -= b;
	
	// 爆発回数を二分探索する
	auto hs_s = hs.sort();
	auto l = 0L;
	auto r = ( hs.back + b - 1 ) / b;
	while( l < r )
	{
		// 爆発回数を仮定して、爆発回数*bで倒しきれなかった魔物を爆発回数*aで倒しきれるかを判定
		auto bc = ( l + r ) / 2;
		auto bt = b * bc;
		auto ac = 0L;
		foreach( h; hs_s.upperBound( bt ) )
		{
			ac += ( h - bt + a - 1 ) / a;
			if( bc < ac ) break;
		}
		if( bc < ac ) l = bc + 1;
		else          r = bc;
	}
	return l;
}


Measured memory_bytes: 4092
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int a=0,b=0;
	int N=0,M=0;
    scanf("%d",&N);
	int h[N]={0},m[N]={0},c[N+1]={0};c[N]=24*60;
	for(int i=0;i<N;i++)
	{
		scanf("%d %d",&h[i],&m[i]);
		c[i]=h[i]*60+m[i];
	}
	scanf("%d",&M);
	int k[M]={0},g[M]={0},d[M+1]={0};d[M]=24*60;
	for(int i=0;i<M;i++)
	{
		scanf("%d %d",&k[i],&g[i]);
		d[i]=k[i]*60+g[i];
	}
	while(a!=N||b!=M)
	{
		if(c[a]<d[b]){if(c[a]%60>9){printf("%d:%d",h[a],m[a]);}
		else{printf("%d:0%d",h[a],m[a]);}a++;}
		else if(c[a]==d[b]){if(c[a]%60>9){printf("%d:%d",h[a],m[a]);}
		else{printf("%d:0%d",h[a],m[a]);}a++;b++;}
		else{if(d[b]%60>9){printf("%d:%d",k[b],g[b]);}
		else{printf("%d:0%d",k[b],g[b]);}b++;}
		if(a!=N||b!=M){printf(" ");}
	}
	printf("\n");
	return 0;
}


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

int mark[30], n;
string s;
char ch[5] = {'M', 'A', 'R', 'C', 'H'};
long long ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> s;
		mark[s[0] - 'A']++;
	}	
	for (int i = 0; i < 5; i++)
		for (int j = i + 1; j < 5; j++)
			for (int k = j + 1; k < 5; k++)
				ans += (1LL * mark[ch[k] - 'A'] * mark[ch[j] - 'A'] * mark[ch[i] - 'A']);
	cout << ans;
}



Measured memory_bytes: 256
S = input()
A = 'RUD'; B = 'LUD'
ok = 1
for i, c in enumerate(S):
    if i % 2 == 0:
        if A.find(c) == -1:
            ok = 0
    else:
        if B.find(c) == -1:
            ok = 0
print("Yes" if ok else "No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
struct node
{
	int x,y,t;
}a[102100];
int main()
{
	
	int n;cin>>n;
	for(int i = 1;i<=n;i++)
	{
		cin>>a[i].t>>a[i].x>>a[i].y;
	}
	a[0].x = a[0].y =a[0].t =0 ;
	int f = 1;
	for(int i = 1;i<=n;i++)
	{
		int d  = abs(a[i].x - a[i-1].x) + abs(a[i].y - a[i-1].y);
		int dt = (a[i].t - a[i-1].t);
		if( d <= dt && abs(d-dt) %2 == 0)
		{
			continue;
		} 
		else
		{
			f = 0;
			break;
		}
	}
	if(f ) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 1408
def main():
    h, w = map(int, raw_input().split())
    aa = []
    for _ in xrange(h):
        aa.append(raw_input())
    q = []
    dist = [[False] * w for _ in xrange(h)]
    for y in xrange(h):
        row = aa[y]
        for x in xrange(w):
            if row[x] == '#':
                dist[y][x] = True
                q.append([x, y])
    m = 0
    nexts = []
    while True:
        for x, y in q:
            for dx, dy in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
                xx = x + dx
                yy = y + dy
                if 0 <= xx < w and 0 <= yy < h:
                    if aa[yy][xx] == '.' and not dist[yy][xx]:
                        dist[yy][xx] = True
                        nexts.append([xx, yy])
        if nexts:
            m += 1
            q = nexts
            nexts = []
        else:
            break
    print m


if __name__ == '__main__':
    main()


Measured memory_bytes: 153620
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> a(n + 2, 0), b(n + 1);
    for (ll i = 1; i < n + 1; i++)
    {
        cin >> a[i];
    }

    ll sum = 0;
    for (ll i = 0; i < n + 1; i++)
    {
        b[i] = a[i + 1] - a[i];
    }

    for (ll i = 0; i < n + 1; i++)
    {
        sum += abs(b[i]);
    }

    for (ll i = 0; i < n; i++)
    {
        ll ans = sum;
        ans -= abs(b[i]) + abs(b[i + 1]);
        ans += abs(b[i] + b[i + 1]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 int im[31][100010]={};
int main(){
  int n,C;
  cin>>n>>C;
  for(int i=0;i<n;i++){
    int s,t,c;
    cin>>s>>t>>c;
    im[c][s]++;
    im[c][t]--;
  }
  for(int i=1;i<=C;i++){
    for(int j=1;j<100010;j++){
      im[i][j]+=im[i][j-1];
    }
  }
  int ans=0;
  for(int i=0;i<100010;i++){
    int sum=0;
    for(int j=1;j<=C;j++){
      sum+=im[j][i];
      if(i&&(im[j][i]==0&&im[j][i-1]==1))sum++;
    }
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12032
#pragma warning (disable :4996)
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-7
using namespace std;

ll a, b, c;
int main() {
	cin >> a >> b >> c;
	if (4 * a * b < (c - a - b) * (c - a - b)&&c-a-b>0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

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

using namespace std;

const int MOD=1e9+7;

int main(){
	int n;
	string B[2]; cin>>n>>B[0]>>B[1];

	int ans,i=0;
	while(i<n){
		if(B[0][i]==B[1][i]){
			if(i==0) ans=3;
			else if(B[0][i-1]==B[1][i-1]) ans=ans*2%MOD;
			i++;
		}
		else{
			if(i==0) ans=6;
			else if(B[0][i-1]==B[1][i-1]) ans=ans*2%MOD;
			else ans=ans*3LL%MOD;
			i+=2;
		}
	}
	cout<<ans<<endl;

	return 0;
}


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

using namespace std;

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

    int a[N], cost1=0, cost2=0, dp[N];

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

    dp[0] = 0;
    dp[1] = dp[0] + abs(a[0] - a[1]);
    for(int i=2; i < N; i++){
        cost1= dp[i-1] + abs(a[i] - a[i-1]);
        cost2= dp[i-2] + abs(a[i] - a[i-2]);
        dp[i] = min(cost1, cost2);
    }
    cout << dp[N-1] << endl;

    return 0;
}

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

using namespace std;

int N, c, v[51], x[51];
int main()
{
    cin>>N;
    for (int i=1; i<=N; i++)
    {
         cin>>v[i];
         x[i]=v[i];
    }
    sort(v+1, v+N+1);
    for (int i=1; i<=N; i++)
    {
        if (x[i]!=v[i]) c++;
    }

    if (c<=2) cout<<"YES";
    else cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};



int main() {
    ll N,D,A;
    cin>>N>>D>>A;
    vector<pair<int,int >> enemy(N);
    int x,h,times;
    for (int i = 0; i < N; ++i) {
        //cout<<"called"<<endl;
        cin>>x>>h;
        times=(h-1)/A+1;
        //cout<<x<<" "<<times<<endl;
        enemy[i]=make_pair(x,times);
    }

    sort(enemy.begin(),enemy.end());
    ll mini=0,maxi=2*1e14;
    ll ans=0ll,bakuretu=0;
    int pos=0;
    map<int,int> mp;
    for (int i = 0; i < N; ++i) {
        //cout<<"called"<<endl;
        if(i>0){
            auto itr= mp.lower_bound(enemy[i-1].first);
            ll sum=0ll;
            for(;itr->first<enemy[i].first&&itr!=mp.end();++itr){
                sum+=itr->second;
            }
            bakuretu-=sum;
            //cout<<i<<", "<<bakuretu<<endl;
        }
        int cnt=max((ll)enemy[i].second-bakuretu,0ll);
        bakuretu+=cnt;
        ans+=cnt;
        mp[enemy[i].first+2*D]+=cnt;

        //cout<<i<<" :"<<bakuretu<<endl;
    }
    cout<<ans<<endl;
    /*
    while(maxi-mini>1){
        ll mid=(maxi+mini)/2;
        if(judge(mid)) maxi=mid;
        else mini=mid;
    }
     */
    //cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e9 + 7, INF = 1e9;


int main(void) {
    int n, i, d1, d2;
    string s;

    scanf("%d", &n);
    cin >> s;

    d1 = d2 = 0;
    for (i = 0; i < n; i++) {
        if (s[i] == '(') {
            d1++;
        }
        else {
            if (d1 > 0) d1--;
            else d2++;
        }
    }

    for (i = 0; i < d2; i++) printf("(");
    cout << s;
    for (i = 0; i < d1; i++) printf(")");
    printf("\n");

    return 0;
}

Measured memory_bytes: 256
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int dx[4] = {-1,0,1,0},dy[4] = {0,-1,0,1};
int P[250000];
int dist[500][500],yes[500][500];
queue<pii> Q;
int main() {
    int i,j;
    int N;
    scanf("%d",&N);
    for (i = 0; i < N*N; i++) scanf("%d",&P[i]),P[i]--;

    for (i = 0; i < N; i++) {
        for (j = 0; j < N; j++) dist[i][j] = min(min(i,N-i-1),min(j,N-j-1))+1,yes[i][j] = 1;
    }
    int ans = 0;
    for (i = 0; i < N*N; i++) {
        ans += dist[P[i]/N][P[i] % N]-1,yes[P[i]/N][P[i] % N] = 0;
        dist[P[i]/N][P[i] % N]--;
        Q.push(mp(P[i]/N,P[i] % N));
        while (!Q.empty()) {
            int y = Q.front().first,x = Q.front().second;
            Q.pop();

            for (j = 0; j < 4; j++) {
                int yy = y+dy[j],xx = x+dx[j];
                if ((xx >= 0) && (xx < N) && (yy >= 0) && (yy < N) && (dist[yy][xx] > dist[y][x]+yes[yy][xx])) {
                    dist[yy][xx] = dist[y][x]+yes[yy][xx];
                    Q.push(mp(yy,xx));
                }
            }
        }
        print2dArr(dist,N,N);
    }
    printf("%d\n",ans);

    return 0;
}



Measured memory_bytes: 6716
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T = ll> constexpr T TEN(int n) {return (n==0)?1:10*TEN<T>(n-1);}

const int MP = 100100;
vector<int> pr;
vector<ull> bpr;

void first() {
    bool used[MP] = {};
    for (int i = 2; i < MP; i++) {
        if (used[i]) continue;
        pr.push_back(i);
        ull x = ((__int128(1)<<64) + i-1 ) / i;
        bpr.push_back(x);
        for (int j = 2*i; j < MP; j += i) {
            used[j] = true;
        }
    }
}

map<ll, int> fact(ll n) {
    int pc = (int)pr.size();
    map<ll, int> mp;
    for (int i = 0; i < pc; i++) {
        ll d = pr[i]; ull rd = bpr[i];
        if (n < d*d) break;
        while (true) {
            ll nd = __int128(n)*rd >> 64;
            if (nd * d != n) break;
            n = nd;
            mp[d]++;
        }
    }
    if (n > 1) mp[n]++;
    return mp;
}

ll mul(ll a, ll b) {
    if (TEN(12)/a < b) return TEN(12);
    return a*b;
}

int main() {
    first();
    using P = pair<ll, ll>;
    map<P, P> g;
    int n;
    scanf("%d", &n);
    bool one = false;
    for (int i = 0; i < n; i++) {
        if (i % 1000 == 0) {
//            cout << i << " " << gc << endl;
        }
        ll s;
        scanf("%lld", &s);
        map<ll, int> fac = fact(s);
        ll d0 = 1, d1 = 1;
        for (auto p: fac) {
            p.second %= 3;
            if (p.second == 1) {
                d0 = mul(d0, p.first);
                d1 = mul(d1, p.first);
                d1 = mul(d1, p.first);
            } else if (p.second == 2) {
                d0 = mul(d0, p.first);
                d0 = mul(d0, p.first);
                d1 = mul(d1, p.first);
            }
        }
        if (d0 == 1) {
            one = true;
            continue;
        }
        if (d0 < d1) {
            g[P(d0, d1)].first++;
        } else {
            g[P(d1, d0)].second++;
        }
    }

    int ans = 0;
    for (auto p: g) {
        ans += max(p.second.first, p.second.second);
    }
    cout << ans + (one ? 1 : 0) << endl;
    return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_N 100000

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, A[MAX_N], B[MAX_N], C[MAX_N], res;
int main(int argc, char **argv) {
    cin >> N;
    for(int i = 0; i < N; ++i) cin >> A[i];
    for(int i = 0; i < N; ++i) cin >> B[i];
    for(int i = 0; i < N - 1; ++i) cin >> C[i];

    for(int i = 0; i < N; ++i)
        res += B[A[i] - 1];
    for(int i = 0; i < N - 1; ++i)
        if(A[i + 1] - 1 == A[i])
            res += C[A[i] - 1];

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 2010
#define INF 1e9
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
struct info{int nu,ne;}a[N*2];
int b[N],num,an=INF,si[N],n,x,y,v[N],mi[N],ma[N],s1[N];
string s;
void jb(int x,int y){a[++num].nu=y;a[num].ne=b[x];b[x]=num;}
void dfs(int x,int fa,int de){
	si[x]+=de;
	for (int y=b[x];y;y=a[y].ne)if (a[y].nu!=fa)dfs(a[y].nu,x,de+1);
}
void dfs1(int x,int fa){
	s1[x]=v[x];
	for (int y=b[x];y;y=a[y].ne)if (a[y].nu!=fa){dfs1(a[y].nu,x);s1[x]+=s1[a[y].nu];}
}
void dfs2(int x,int fa){
	ma[x]=0;mi[x]=0;
	vector<int> s;s.clear();
	for (int y=b[x];y;y=a[y].ne)
		if (a[y].nu!=fa){dfs2(a[y].nu,x);ma[x]+=ma[a[y].nu]+s1[a[y].nu];}
	for (int y=b[x];y;y=a[y].ne){
		if (a[y].nu!=fa){
			if (mi[a[y].nu]+s1[a[y].nu]>ma[x]-ma[a[y].nu]-s1[a[y].nu]){
				mi[x]=mi[a[y].nu]+s1[a[y].nu]-ma[x]+ma[a[y].nu]+s1[a[y].nu];return ;
			}
		}
	}
	mi[x]=ma[x]%2;
}
int main(){
	read(n);
	cin>>s;
	for (int i=1;i<n;i++){read(x);read(y);jb(x,y);jb(y,x);}
	for (int i=0;i<n;i++)v[i+1]=s[i]-'0';
	for (int i=1;i<=n;i++)if (v[i]) dfs(i,0,0);
	for (int i=1;i<=n;i++){
		if (si[i]%2==0){
			dfs1(i,0);dfs2(i,0);
			if (mi[i]==0) an=min(an,si[i]/2);
		}
	}
	if (an==INF) puts("-1");
	else cout<<an<<endl;
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


void add(vi &bit,int x, int a) {
	for (int i = x; i < bit.size(); i += i & -i) bit[i] += a;
}
int sum(vi &bit,int x) {
	int ret = 0;
	for (int i = x; i > 0; i -= i & -i) ret += bit[i];
	return ret;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	vi s(n);
	REP(i, n)s[i] = v[i];
	sort(ALL(s));
	vi bit(2 * n + 100);
	int l = -1, r = n - 1;

	while (r - l > 1) {
		int m = (r + l) / 2;
		REP(i, bit.size())bit[i] = 0;
		vi c(n + 1);
		REP(i, n) {
			if (v[i] <= s[m])c[i + 1] = 1;
			else c[i + 1] = -1;
		}
		REP(i, n)c[i + 1] += c[i];

		ll cnt = 0;
		REP(i, n + 1) {
			cnt += sum(bit,c[i] + n);
			add(bit,c[i] + n + 1, 1);
		}
		if (cnt <= n * (n + 1) / 2 / 2)l = m;
		else r = m;
	}
	cout << s[r] << endl;
}

Measured memory_bytes: 2180
from scipy.optimize import*
from numpy import*
n=int(input())
l=array([list(map(int,input().split()))for i in range(n)])
def f(a):
    return ((l-a)**2).sum(1).max()**0.5
print(minimize(f,[0,0],method="Nelder-Mead",tol=1e-9).fun)

Measured memory_bytes: 23516
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	string str; cin>> str;
	if(str == "ABC") cout << "ARC";
	else cout << "ABC";
	return 0;
}

Measured memory_bytes: 3620
from inspect import currentframe

def chkprint(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

from functools import reduce
from math import floor, ceil

N = int(input())
A = list(map(int, input().split()))

left = 1
center = 2
right = 3

res = 10**16



p = sum(A[0:left])
q = sum(A[left:center])
r = sum(A[center:right])
s = sum(A[right:])

# print(A)

while center <= N - 2:
  while True:
    if abs(p-q) < abs(p-q+2*A[left]):
      break

    if left == center-1:
      break

    p += A[left]
    q -= A[left]
    left += 1

  while True:
    if abs(r-s) < abs(r-s+2*A[right]):
      break

    if right == N-1:
      break

    r += A[right]
    s -= A[right]
    right += 1

  res = min(max(p,q,r,s)-min(p,q,r,s),res)

  # print(A[0:left], A[left:center], A[center:right], A[right:], res)
  q += A[center]
  r -= A[center]
  center += 1

print(res)


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

int main() {

	int r, g, b;

	cin >> r >> g >> b;

	if ((r * 100 + g * 10 + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

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

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    REP(i, H) cin >> a[i];

    vector<int> count(26);
    REP(i, H) REP(j, W) {
        ++count[a[i][j] - 'a'];
    }

    int fac4 = 0;
    int fac2 = 0;
    int odd = 0;
    REP(i, 26) {
        if (count[i] % 4 == 0) {
            ++fac4;
        } else if (count[i] % 2 == 0) {
            ++fac2;
        } else {
            ++odd;
        }
    }

    bool result;
    if (H % 2 == 0 && W % 2 == 0) {
        result = (fac4 == 26);
    } else if (H % 2 == 0) {
        result = (odd == 0 && fac2 <= H / 2);
    } else if (W % 2 == 0) {
        result = (odd == 0 && fac2 <= W / 2);
    } else {
        result = (odd == 1 && fac2 <= H / 2 + W / 2);
    }
    cout << (result ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>//class string???????????????
using namespace std;

int main(){
	string str,func;
	int n;
	cin >> str;
	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		cin >> func;

		if (func=="print")
		{	int a,b;
			cin >> a >> b;
			cout<<str.substr(a,b-a+1)<<endl;/* code */
		}
		
		if (func=="replace")
		{	int a,b;
			string p;
			cin >> a>>b>>p;
			str=str.replace(a,b-a+1,p);/* code */
		}
		if (func=="reverse")
		{	int a,b;
			string p,q;
			cin >> a>>b;
			p=str.substr(a,b-a+1);
				q=p.at(p.size()-1);
				for(int i=1;i<=p.size()-1;i++)
					q+=p.at(p.size()-1-i);
				str=str.replace(a,b-a+1,q);

		}		
	}
}

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

int main(void){
    char s[11]; 
    int ans = 1;

    scanf("%s", s);

    if(s[0] != 'A'){
        ans = 0;
    }

    int cnt = 0;
    for(int i = 1; i < strlen(s); i++){
        if(s[i] == 'C' && i > 1 && i < strlen(s) -1){
            cnt++;
        }else if('a' <= s[i] && s[i] <= 'z'){
        }else{
            ans = 0;
        }
    }
    if(cnt != 1){
        ans = 0;
    }

    
    if(ans == 0){
        printf("WA\n");
    }else{
        printf("AC\n");
    }

    return 0;

} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  int r, d, x; cin >> r >> d >> x;

  vector<int> ans(11, -1);

  ans[0] = x;
  REP(i, 10) ans[i + 1] = r * ans[i] - d;

  FOR(i, 1, 11) cout << ans[i] << endl;

  return 0;
}


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

using ld = double;
using ll = long long;
using ull = unsigned long long;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;

const int SZ = 1 << 13;
char buff[SZ], *pos = buff + SZ - 1;
#define getchar() (++ pos == buff + SZ ? fread(pos = buff, 1, SZ, stdin), *pos : *pos)

inline ll read() {
	ll x = 0; int f = 1, c = getchar();
	for (;!isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x<<3) + (x<<1) + (c^48);
	return x * f;
}

const int N = 3005;
const int mod = 1e9 + 7;
int n;
char s[N];
int dp[N][N];
int sum[N][N];

int main() {
	n = read();
	for (int i = 2; i <= n; ++ i) s[i] = getchar();
	dp[1][1] = sum[1][1] = 1;
	for (int i = 2; i <= n; ++ i) {
		for (int j = 1; j <= i; ++ j) {
			if (s[i] == '<')
//				for (int k = 1; k < j; ++ k) dp[i][j] = (dp[i][j] + dp[i - 1][k]) % mod;
				dp[i][j] = sum[i - 1][j - 1];
			else
//				for (int k = j; k < i; ++ k) dp[i][j] = (dp[i][j] + dp[i - 1][k]) % mod;
				dp[i][j] = (sum[i - 1][i - 1] - sum[i - 1][j - 1] + mod) % mod;
			sum[i][j] = (sum[i][j - 1] + dp[i][j]) % mod;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++ i) ans = (ans + dp[n][i]) % mod;
	printf("%d\n", ans);
	return 0;
}


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

int main(){

    int N;
    string S;
    cin >> N >> S;

    int buf = 0, max_num = 0;
    for (int i=0; i<N; i++){
        if (S.at(i) == 'I'){
            buf++;
        }
        else{
            buf--;
        }

        max_num = max(max_num, buf);
    }

    cout << max_num << endl;
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
wa = [0]
for i in range(1,N+1):
    wa.append(wa[i-1] + i)
def func(k):
    a = wa[N] - wa[N-k] #12
    b = wa[k-1] #3
    #print(k,a,b,a-b+1)
    return a - b + 1
if N<K:
    print(1)
else:
    ans = 1
    for i in range(K,N+1):
        ans = (ans+func(i))%(10**9+7)
    print(ans)

Measured memory_bytes: 19372
#include <iostream>
#include <cstdio>
#include <string.h>
#include <cstdlib>
#define N 200005
using namespace std;
typedef long long ll;
int n,a[N],L[N],R[N],nxt[N];
ll K;
bool vis[N];
int dis(int x,int y){
	if(y==1&&x==n) return n+1;
	return y>x+1?y-x:y+n-x;
}
int ans[N];
void sim(int pos,int res){
    memset(L,0,sizeof(L));
    int len=0;
    for(int i=1;i<=res;i++,pos=pos==n?1:pos+1){
        if(L[a[pos]]){
            while(ans[len]!=a[pos]) L[ans[len--]]=0;
            --len;
            L[a[pos]]=0;
            continue;
        }
        ans[++len]=a[pos];
        L[a[pos]]=len;
    }
    for(int i=1;i<=len;i++) printf("%d ",ans[i]);
}
int main(){
	scanf("%d%lld",&n,&K);
	K*=n;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) if(!L[a[i]]) L[a[i]]=i;
	for(int i=n;i;i--){
		if(R[a[i]]) nxt[i]=R[a[i]]+1<=n?R[a[i]]+1:1;
		else nxt[i]=L[a[i]]+1<=n?L[a[i]]+1:1;
		R[a[i]]=i;
	}
	int x=1;
	while(!vis[x]){
		vis[x]=1;
		if(K<=n){
			sim(x,K);
			return 0;
		}
		K-=dis(x,nxt[x]);
		x=nxt[x];
	}
	ll sum=0;
	memset(vis,0,sizeof(vis));
	while(!vis[x]){
		vis[x]=1;
		sum+=dis(x,nxt[x]);
		x=nxt[x];
	}
	K%=sum;
	while(K>=dis(x,nxt[x])){
		K-=dis(x,nxt[x]);
		x=nxt[x];
	}
	sim(x,K);
	return 0;
}


Measured memory_bytes: 5376
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#define ll long long
using namespace std;
const ll maxn=2050,maxm=2050,MOD=(1e9)+7;
int N,M,S[maxn],T[maxm];
ll F[maxn][maxm];
//F[i][j]表示S前i位，T前j位，S与T相同子序列数
//多一位数的增加的子序列实际是原子序列后都多一个数。 
//F[0][i]=F[j][0]=1
//if(S[i]==T[j])F[i][j]+=F[i-1][j-1]
int main(){
	scanf("%d%d",&N,&M);
	for(int i=1;i<=N;i++)scanf("%d",&S[i]);
	for(int i=1;i<=M;i++)scanf("%d",&T[i]);
	for(int i=0;i<=N;i++)F[i][0]=1;
	for(int i=0;i<=M;i++)F[0][i]=1;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=M;j++){
			F[i][j]=(F[i-1][j]+F[i][j-1]-F[i-1][j-1]+MOD)%MOD;
			if(S[i]==T[j])
				F[i][j]=(F[i][j]+F[i-1][j-1])%MOD;
		}
	}
	printf("%lld\n",F[N][M]);
	return 0;
}

Measured memory_bytes: 33024
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;

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

	int cnt = 0,l=0,r=n-1;
	while (r > l) {
		if (s[l] == 'W') {
			while (s[r] == 'W') {
				r--;
				if (l >= r) {
					cout << cnt << endl;
					return 0;
				}
			}
			s[l] = 'R'; s[r] = 'W';
			cnt++;
			r--;
		}
		l++;
	}
	cout << cnt << endl;
}


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

int main() {
    int n;
    cin>>n;
    for(int i=1;i<=9;i++){
        for(int k=1;k<=9;k++){
            if(i*k==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main()
{
    string First ;
    cin >> First ;
    string Last ;
    cin >> Last ;
    int Random = 0 ;
    if (Last.size() == First.size() + 1)
    {
        for (int I = 0 ; I < First.size() ; I++)
        {
           if (First[I] == Last[I])
           {
               Random++;
           }
        }
        if (Random == First.size())
        {
            cout << "Yes" ;
        }
        else
        {
            cout << "No" ;
        }
    }
    else
    {
        cout << "No" ;
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N,K;
    cin >> N >> K;
    map<int,int> list;
 
    // person cnt
    for(int i = 1; i<=N; i++) {
        list[i] = 0;
    }
 
    for(int i = 0; i<K; i++) {
        int tmp;
        cin >> tmp;
        for(int j = 0; j<tmp; j++) {
            int tmp2;
            cin >> tmp2;
            list[tmp2]++;
        }
    }
 
    int cnt = 0;
    for(auto x : list) {
        if(x.second == 0) cnt++;
    }
    cout << cnt << endl;
    return 0; 
}   

Measured memory_bytes: 3580
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int sum=0,i=0;
    char c[1000];
    
    while(1){
        scanf("%s",c);
        if(c[0]=='0'){
            break;
        }
        for(i=0;c[i]!='\0';i++){
            sum += c[i]-'0';
        }
        printf("%d\n",sum);
        sum=0;
    }
    return 0;
}

Measured memory_bytes: 536
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] A = new int[N];

        // kosu[3] := 3が全部でいくつあるか
        long[] kosu = new long[N + 1];

        for (int i = 0; i < N; i++) {
            int Ai = sc.nextInt();
            A[i] = Ai;
            kosu[Ai]++;
        }

        long allSum = 0;
        for (int i = 1; i <= N; i++) {
            allSum += kosu[i] * (kosu[i] - 1) / 2;
        }

        for (int i = 0; i < N; i++) {
            long herasu = kosu[A[i]] * (kosu[A[i]] - 1) / 2;
            long tasu = (kosu[A[i]] - 1) * (kosu[A[i]] - 2) / 2;
            System.out.println(allSum - herasu + tasu);
        }

    }

}


Measured memory_bytes: 102060
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;

int solve(int i, int m, int A[], int n){
    if(m == 0) return 1;
    if(i >= n ) return 0;
    //cout << "i" << i << " m" << m;
    
    int res = solve(i+1, m, A, n)|| solve(i+1, m-A[i], A, n);
    return res;
}


int main(){
    int n,q;
    cin >> n;
    int A[n];
    for(int i = 0; i< n; i++){
        cin >> A[i];
        //cout << A[i] << " ";
    }
    
    cin >> q;
    int m[q];
    for(int j = 0; j < q;j++){
        cin >> m[j];
        //cout << m[j] << " ";
    }
    
    for(int k = 0; k < q;k++){
        if(solve(0, m[k], A, n)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    
    
    
    return 0;
}




Measured memory_bytes: 3112
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *r;
  struct node *l;
  struct node *par;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key) x = x->l;
    else x = x->r;
  }
  z->par = y;
  if(y==NIL) root = z;
  else if(z->key < y->key) y->l = z; // z を y の左の子にする
    else y->r = z; // z を y の右の子にする
}

void inorder(Node u){
  if(u->l!=NIL) inorder(u->l);
  printf(" %d",u->key);
  if(u->r!=NIL) inorder(u->r);
  return;
}

void preorder(Node u){
  printf(" %d",u->key);
  if(u->l!=NIL) preorder(u->l);
  if(u->r!=NIL) preorder(u->r);
  return;
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}


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

int main() {
  long long n,k; 
  cin>>n>>k;
  
  if ( k==1 ) cout << 0 << endl;
  else{
    long long x;
    x=n%k;
    long long ans = min(x,k-x);
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
N=int(input())
W=[]
word_list=[]
for i in range(N):
    W.append(input())

for i in range(N):
    if i == 0:
        word_list.append(W[i])
        continue
    elif W[i][0]==W[i-1][-1] and W[i] not in word_list:
        word_list.append(W[i])
    else:
        print('No')
        exit()
print('Yes')
    



Measured memory_bytes: 3060
//Bismillahir Rahmanir Rahim
//In the name of Allah
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long  int
int i,j;

main()
{
int n; cin>>n;
int m; cin>>m;
int b[n+1]={0};
int a[n];
int c[n+1]={0};
for(i=1;i<=n;i++) cin>>a[i];
while(m--)
{
    int p,q;
    cin>>p>>q;
    if(a[p]>a[q]) b[q]=1;
    else if(a[q]>a[p]) b[p]=1;
    else
    {
        b[q]=1;
        b[p]=1;
    }

}
int mm=0;
for(i=1;i<=n;i++)
{
    if(b[i]==0) mm++;
}
cout<<mm<<endl;
}


Measured memory_bytes: 5980
# count = 0
# summ = 0
def aaa(h, summ, count):
    summ += 2 ** count
    count += 1
    
    if h == 1:
        print(summ)
        return summ
    else:
        aaa(h // 2, summ, count)

H = int(input())
summ = aaa(H, 0, 0)
# print(summ)

Measured memory_bytes: 3060
package main

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

func main() {
	io, flush := NewIO()
	defer flush()

	n := io.ScanInt()
	nums := io.ScanInts(n)
	numCountMap := map[int]int{}
	for _, num := range nums {
		numCountMap[num]++
	}
	combCountMap := map[int]int{}
	var totalCombCount int
	for _, count := range numCountMap {
		if count <= 1 {
			continue
		}
		combCount := count * (count-1) / 2
		combCountMap[count] = combCount
		totalCombCount += combCount
	}
	for _, num := range nums {
		io.Println(totalCombCount - (numCountMap[num] - 1))
	}
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 1000005), 1000005)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


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

int main(){
	long long n,m;	cin>>n>>m;
	long long ans;
	if(min(n,m)>=2){
		ans=n*m-((n+m)*2-4);
	}else{
		if(n==1 && m==1) ans=1;
		else ans=max(n,m)-2;
	}
	cout<<ans<<endl;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
// ordered_set X;
// *X.find_by_order(i) = ith largest element (counting from zero)
// X.order_of_key(k) = number of items in X < k (strict lt)

ll MOD = 998244353;

ll pow(ll a, ll x, ll MOD) {
    if (x == 0) return 1;
    ll halfpow = pow(a, x/2, MOD);
    ll ans = (halfpow * halfpow) % MOD;
    if (x % 2 == 1) ans = (ans * a) % MOD;
    return ans;
}

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

    int N;
    cin >> N;
    
    vi D(N);
    for(int i=0;i<N;i++) cin >> D[i];

    if (D[0] != 0) {
        cout << 0 << endl;
        return 0;
    }

    vll cnts(N+1, 0);
    for (int d : D) {
        cnts[d]++;
    }

    if (cnts[0] != 1) {
        cout << 0 << endl;
        return 0;
    }


    ll ans = 1;
    for (int i=0;i<N;i++) {
        //cout << cnts[i] << endl;
        ans *= pow(cnts[i], cnts[i+1], MOD);
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<iostream>

int main(void)
{
  int a = 0;
  int b = 0;
  int c = 0;
  
  std::cin >> a >> b >> c;
  
  if((a == b && a != c) || (a == c && a != b) || (b == c && a != b))
  {
    std::cout << "Yes" << std::endl;
  }
  else
  {
    std::cout << "No" << std::endl;
  }
}

Measured memory_bytes: 256
def coordminmax(N) : 
  coordinate = list(map(int, input().split()))
  min = coordinate[0]
  max = coordinate[0]
  
  for i in range(len(coordinate)) : 
    if coordinate[i] < min : 
      min = coordinate[i]
      
    if coordinate[i] > max : 
      max = coordinate[i]
      
  return min, max

def calcdistance(N) : 
  min, max = coordminmax(N)
  return max - min


N = int(input())

print(calcdistance(N))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unordered_set<int> uset;

int main( int argc, char* argv[] ){
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  map<char,int> s1, s2;
  set<char> both;
  for( auto c : S ) s2[c]++;
  for( auto c : S ){
    s1[c]++;
    s2[c]--;
    if( s2[c]>0 ) both.insert(c);
    else both.erase(c);
    //for( auto x : both ) cerr << x << " "; cerr << endl;
    count = both.size() > count ? both.size() : count;
  }
  cout << count << endl;
  return 0;
}


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

using namespace std;

priority_queue <int> pque[100001];
int cnt[100001];
int n,m,t;
int cnt2[100001];
int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	//ifstream cin("01-03.txt");

	cin >> n >> m;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		cnt[t]++;
		//cnt2[t%m]++;
	}

	long long int res = 0;
	long long sum1 = 0;
	long long sum2 = 0;
	for(int i=1;i<=100000;i++)
	{
		if(i%m==0)
		{
			sum1 += cnt[i];
		}
		else
		{
			int t = (i%m);
			if(2*t==m)
			{
				sum2 += cnt[i];
			}
			else
			{
				if(cnt[i]%2==1)
				{
					cnt2[(i%m)]+=1;
					cnt[i]-=1;
				}
				if(cnt[i]!=0)
				{
					pque[(i%m)].push(cnt[i]);
				}
			}
		}
	}
	//cout << sum1 << ' ' << sum2 << '\n';
	res += (sum1/2);
	res += (sum2/2);

	for(int a=1;a<=(m/2);a++)
	{
		int b = m - a;
		if(a==b)
		{
			break;
		}
		//cout << a << ' ' << b << ' ' << cnt2[a] << ' ' << cnt2[b] << '\n';
		if(cnt2[a]<=cnt2[b])
		{
			res += cnt2[a];
			int x = cnt2[b] - cnt2[a];
			while(!pque[a].empty())
			{
				int y = pque[a].top();
				pque[a].pop();
				if(x<=y)
				{
					res += x;
					y-=x;
					pque[a].push(y);
					break;
				}
				x-=y;
				res += y;
			}
		}
		else
		{
			res += cnt2[b];
			int x = cnt2[a] - cnt2[b];
			while(!pque[b].empty())
			{
				int y = pque[b].top();
				pque[b].pop();
				if(x<=y)
				{
					res += x;
					y-=x;
					pque[b].push(y);
					break;
				}
				x-=y;
				res += y;
			}			
		}
	}

	for(int i=1;i<m;i++)
	{
		while(!pque[i].empty())
		{
			int now = pque[i].top();
			pque[i].pop();
			res += (now/2);
		}
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 8316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int X;
    cin >> X;
    int cnt500 = 0;
    int cnt5 = 0;
    while(true){
        if(X >= 500){
            X -= 500;
            cnt500++;
        }else if(X >= 5){
            X -= 5;
            cnt5++;
        }else{
            break;
        }
    }

    cout << cnt500*1000+cnt5*5 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>                                             
#include <string>                                               
using namespace std;                                            
                                                                
int main(void) {                                                
  string W, T;                                                  
  int ans = 0;                                                  
  cin >> W;                                                     
  for (int i=0; i<W.size(); i++) {                              
    W[i] = tolower(W[i]);                                       
  }                                                             
  while (true) {                                                
    cin >> T;                                                   
    if (T == "END_OF_TEXT") {                                   
      break;                                                    
    } else {                                                    
      for (int i=0; i<T.size(); i++) {                          
        T[i] = tolower(T[i]);                                   
      }                                                         
      if (W==T) {                                               
        ans++;                                                  
      }                                                         
    }                                                           
  }                                                             
  cout << ans << endl;                                          
  return 0;                                                     
}                                                               
                                                                
                                     

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937_64 mt64(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, cnt[114514];
signed main() {
	cin >> n;
	rep(i, n) {
		int a; cin >> a; cnt[a]++;
	}
	int sum = 0;
	rep(i, 114514) {
		if (cnt[i])sum++;
	}
	if (sum % 2) {
		cout << sum << endl;
	}
	else {
		cout << sum - 1 << endl;
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl;
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl;
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl;
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl;
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl;
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl;
#define int long long
#define double long double
using namespace std;
const int N = 100010;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


class WeightedUnionFind{
public:
  int V;
  vector<int> par, rnk, diff, sz;
  WeightedUnionFind():V(-1){}
  WeightedUnionFind(int V):V(V),par(V),rnk(V,0),diff(V,0),sz(V,1){for(int i=0;i<V;i++)par[i]=i;}
  
  int find(int x){
    assert(x < V);
    if(par[x] == x) return x;
    int p = find(par[x]);
    diff[x] = diff[x] + diff[ par[x] ];
    return par[x] = p;
  }

  //頂点xは頂点yよりもz大きい
  void relate(int x,int y,int z){
    int sx = x, sy = y;
    x = find(x), y = find(y);
    if(x == y) assert(getDiff(sx,sy) == z);
    if(x == y)return;
    
    if(rnk[x] < rnk[y]) {
      par[x] = y;
      sz[y] += sz[x];
      diff[x] = z + (-diff[sx] + diff[sy]);
    }
    else{
      par[y] = x;
      sz[x] += sz[y];
      diff[y] = -z + (diff[sx] - diff[sy]);
      if(rnk[x]==rnk[y])rnk[x]++;
    }
  }
  
  int getDiff(int u,int v){
    assert(same(u,v));
    return diff[u] - diff[v];
  }
  
  bool same(int x,int y){return find(x)==find(y);}
  int size(int x){return sz[find(x)];}
  
};

signed main(){
  int n;
  cin>>n;
  WeightedUnionFind wuf(n);
  
  int q;
  cin>>q;
  while(q--){
    int cmd, x, y, z;
    cin>>cmd >> y >> x;
    if(cmd == 0){
      cin>>z;
      wuf.relate(x,y,z);
    }
    if(cmd == 1){
      if(!wuf.same(x, y)) cout<<"?"<<endl;
      else cout<<wuf.getDiff(x, y)<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 5928