akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mk make_pair
#define fi first
#define nd second
#define pii pair<int,int>
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
inline ll read() {ll x = 0; char ch = getchar(), w = 1;while(ch < '0' || ch > '9') {if(ch == '-') w = -1;
ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';ch = getchar();}return x * w;}
void write(ll x) {if(x < 0) putchar('-'), x = -x;if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
const int N = 3000000;
int n, fa[N];
set<int>e[N];
map<pii, int>c;
queue<pii>q;
int find(int x){
	return fa[x] == x ? x : fa[x] = find(fa[x]);
}
int main() {
	int tot = 0;
	n = read();
	for(int i = 1; i < n * 2 - 1; ++i){
		int x = read(), y = read();
		e[x].insert(y);
		e[y].insert(x);
		++c[mk(x, y)];++c[mk(y,x)];
		if(c[mk(x,y)] == 2) q.push(mk(x, y)), ++tot;
	}
	for(int i = 1; i <= n; ++i) fa[i] = i;
	while(!q.empty() && tot < n - 1) {
		pii now = q.front();q.pop();
		int x = find(now.fi), y = find(now.nd);
		if(x == y) continue;
		if(e[x].size() > e[y].size()) swap(x, y);
		fa[x] = y;
		for(set<int>::iterator z = e[x].begin(); z != e[x].end(); ++z) {
			if(*z == y) continue;
			c[mk(*z, x)] = c[mk(x, *z)] = 0;
			++c[mk(*z, y)]; ++c[mk(y, *z)];
			e[y].insert(*z);e[*z].insert(y);
			e[*z].erase(x);
			if(c[mk(y, *z)] == 2) q.push(mk(y, *z)), ++tot;
		}
		e[x].clear();e[y].erase(x);
	}
	if(tot < n - 1) {
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}


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

const ll large_P = 1e9 + 7;


int main(){
  ll N, M;
  cin >> N >> M;
  
  ll rep1 = 0; // 偶数二つ
  ll rep2 = 0;
  
  if(N > 1) rep1 = N*(N-1)/2;
  if(M > 1) rep2 = M*(M-1)/2;
  
  cout << rep1 + rep2;
}

Measured memory_bytes: 256
#include<algorithm>//everybody dies in their nightmares
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<string>
#include<vector>
#include<sstream>
#include<cmath>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const ll mod = 1e18 + 7;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;

const int N = 6e5 + 5;
int t;
int a[N], b[N];
int main()
{
	string a;
	while (cin >> a)
	{
		int fg = 0;
		for (auto I : a)
		{
			if (I == '7')fg = 1;
		}
		if (fg)puts("Yes");
		else puts("No");
	}
	return 0;
}


Measured memory_bytes: 3628
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();

		int g = x/500 * 1000;
		int y = x%500;
		g = g + y/5 * 5;

		System.out.println(g);
	}
}

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

using namespace std;

int main(void) {
  int h, w;
  cin >> h >> w;
  vector <string> s(h);
  for(int i = 0; i < h; i++) {
    cin >> s[i];
  }

  //  if(h == 1 && w == 1) {
  //    if(s[0][0] == '#') {
  //      cout << "Yes" << endl;
  //    }
  //    else {
  //      cout << "No" << endl;
  //    }
  //    return 0;
  //  }

  int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
  bool ans = true;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(s[i][j] == '#') {
	int count = 0;
	int comp = 4;
	for(int k = 0; k < 4; k++) {
	  int x = j + dx[k], y = i + dy[k];
	  if(0 <= x && x < w && 0 <= y && y < h) {
	    if(s[y][x] == '.') {
	      count++;
	    }
	  }
	  else {
	    comp--;
	  }
	}
	if(count == comp) {
	  ans = false;
	}
      }
    }
  }

  if(ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int  a,b;
  cin >>a>>b;
  
  cout << (a<b?0:10) << endl;
  
  
}



Measured memory_bytes: 256
#include <stdio.h>

int DigitSums(int n)
{
  int sum = 0;
  while(n > 0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(void)
{
  int N;
  scanf("%d", &N);
  int sum = DigitSums(N);
  printf("%s\n", N%sum == 0 ? "Yes" : "No");
}


Measured memory_bytes: 128
defmodule Main do
  def main do
    [short, long, hour, minute] =
      IO.gets("") |> String.trim() |> String.split() |> Enum.map(&String.to_integer/1)

    hour_angle = calculate_hour_angle(hour, minute)
    minute_angle = calculate_minute_angle(minute)

    angle =
      (hour_angle - minute_angle)
      |> abs()

    rad = :math.pi() / 180

    if angle > 180 do
      (short * short + long * long - 2 * short * long * :math.cos((360 - angle) * rad))
      |> :math.sqrt()
      |> IO.puts()
    else
      (short * short + long * long - 2 * short * long * :math.cos(angle * rad))
      |> :math.sqrt()
      |> IO.puts()
    end
  end

  defp calculate_hour_angle(hour, minute) do
    30 * hour + 0.5 * minute
  end

  defp calculate_minute_angle(minute) do
    minute * 6
  end
end

Measured memory_bytes: 31128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int main(){
	int T,team,pro,n;
	while(cin>>T>>team>>pro>>n,T){
		vvi co(team,vi(pro));
		vip in(team);
		rep(i,team)in[i].second.second=-i-1;
		rep(i,n){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			if(d){
				co[b-1][c-1]++;
			}else{
				in[b-1].first--;
				in[b-1].second.first+=a+20*co[b-1][c-1];
			}
		}
		sort(all(in));
//		rep(i,team)cout<<in[i].first<<" "<<in[i].second.first<<" "<<in[i].second.second<<endl;
		rep(i,team-1)cout<<-in[i].second.second<<(in[i].first==in[i+1].first&&in[i].second.first==in[i+1].second.first?"=":",");
		cout<<-in[team-1].second.second<<endl;
	}
}

Measured memory_bytes: 3024
#include<iostream>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int func(int n){
	int res;
	if(n<400)res=1;
	else if(n<800)res=2;
	else if(n<1200)res=3;
	else if(n<1600)res=4;
	else if(n<2000)res=5;
	else if(n<2400)res=6;
	else if(n<2800)res=7;
	else if(n<3200)res=8;
	else res=0;
	return res;
}

int main(){
	int n;
	cin>>n;
	int a[n];
	int color[9];
	rep(i,9)color[i]=0;
	rep(i,n){
		cin>>a[i];
		color[func(a[i])]++;
	}
	int num=0;
	rep(i,8){
		if(color[i+1])num++;
	}
	int low,high;
	if(color[0] && num==0)low=1;
	else low=num;
	high=num+color[0];
	cout<<low<<" "<<high<<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++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1000000007;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> Plp;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,C;
    cin >> N >> C;
    vector<ll> x(N), v(N), S(N+1), SS(N+1), g(N+1), gg(N+1), h(N+1),hh(N+1);
    rep(i,N){
        cin >> x[i] >> v[i];
    }
    rep(i,N){
        S[i+1] = S[i] + v[i];
    }
    for(ll i=N;i>0;i--){
        SS[i-1] = SS[i] + v[i-1];
    }
    rep(i,N){
        //g[i+1] = max(S[i+1] - x[i], g[i]);
        if(S[i+1] - x[i] > g[i]){
            g[i+1] = S[i+1] - x[i];
            h[i+1] = x[i];
        }else{
            g[i+1] = g[i];
            h[i+1] = h[i];
        }
    }
    rep(i,N){
        //gg[N-i-1] = max(SS[N-1-i] - (C-x[N-1-i]), gg[N-i]);
        if(SS[N-1-i] - (C - x[N-1-i]) > gg[N-i]){
            gg[N-i-1] = SS[N-1-i] - (C - x[N-1-i]);
            hh[N-i-1] = C - x[N-1-i];
        }else{
            gg[N-1-i] = gg[N-i];
            hh[N-1-i] = hh[N-i];
        }
    }
    ll ans = 0;
    //PR(g,N+1);
    //PR(gg,N+1);
    rep(i,N+1){
        /*
        ll t = 0;
        ll d = 0;
        if(i == 0){
            t = 0;
            d = 0;
        }else{
            t = S[i] - x[i-1];
            d = x[i-1];
        }*/
        ll d;
        if(i == 0){
            d=0;
        }else{
            d=min(h[i], hh[i]);
        }
        cmax(ans,g[i]+gg[i]-d);
        /*
        for(ll j=0;i+j<N+1;j++){
            ll y=0;
            ll u=0;
            if(j == 0){
                y=0;
                u=0;
            }else{
                ll a;
                y = min(d, C-x[N-j]);
                u = SS[N-j] - (C-x[N-j]);
            }
            cmax(ans, t+u-y);
            //cmax(ans, S[i+1] - x[i]);
        }*/
    }
    /*rep(i,N){
        cmax(ans, SS[N-i] - (C-x[N-1-i]));
    }
    /*
    rep(i,N*2){
        xx[i] = x[i%N];
    }*/
    cout << ans << endl;
}

Measured memory_bytes: 9564
if __name__ == '__main__':

	a,b,c,d = map(int,input().split())
	
	ans = -10**19;
	A = [a,b]
	B = [c,d]
	for i in A:
		for j in B:
			tmp = i * j
			ans = max(ans,tmp)
	print(ans)

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

#define         eps         10e-9
#define         pi          2*acos(0.0)
#define         P1          1e9+7
#define         P2          1e9+9
#define         lli         long long int

using namespace std;

///ISNNJB

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

int main()
{
    /***freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    cout<<ceil(pow(n,3))<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, start, stop) for (ll i = start; i < stop; i++)
#define FORR(i, start, stop) for (ll i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<ll>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<ll>());
#define REMOVE(v,n) remove(vector<ll> v,v+v.size(),ll n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

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

    ll N,A,B;
    cin>>N>>A>>B;
    vector<ll> x(N);    
    FOR(i,0,N){
        cin>>x[i];
    }

    vector<ll> d(0);
    FOR(i,0,N-1){
        d.pb(x[i+1]-x[i]);
    }

    ll ans=0;

    FOR(i,0,N-1){
        if(d[i]*A>=B)ans+=B;
        else ans+=d[i]*A;
    }
    
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2168
#include <stdio.h>

int main(){
	int n;
	char s[10000];
	scanf("%d", &n);
	getchar();
	
	scanf("%[^\n]", s);
	
	for (int i=0;s[i]!='\0';i++){
		if(s[i]>='A' && s[i]<='Z'){
			s[i]+=n;
			if(s[i]>90){
			s[i]-=26;
		
			}
			printf("%c", s[i]);
		}
		// a b c d e f g h i j k l m n o p q r s t u v w x y z [ \ ]
		//65												90 91 92
	
	}
	
	
	return 0;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
const int maxn=142;
bool chk(long double x)
{
  // Find floating point value of
  // square root of x.
  long double sr = sqrt(x);

  // If square root is an integer
  return ((sr - floor(sr)) == 0);
}
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n;
    cin>>n;
    repA(i,1,n)
    {
      ll val=2*i;
      if(val<12) cout<<0<<'\n';
      else
      {
        ll ans=0ll;
        repA(x,2,maxn)
        {
          if(x*x>val) break;
          repA(y,2,maxn)
          {
            if(x*x + y*y >val) break;
            ll z=val-x*x-y*y;
            if(chk(z)&&z>=4)
            {
              z=(ll)sqrt(z);
              ll s=x+y+z;
              if(s%2) continue;
              else
              {
                s/=2;
                if(s-x>=1 && s-y>=1 && s-z>=1) ans++;
              }
            }
          }
        }
        cout<<ans<<'\n';
      }

    }
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3664
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(ll &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
ll n,a,b;
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	in(a);in(b);printf("%lld\n",a/gcd(a,b)*b);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int H, W, i, j;
    
    while(1)
    {
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0)
        {
            break;
        }
        else
        {
            for(i = 0; i < H; i++)
            {
                for(j = 0; j < W; j++)
                {
                    if(i == 0 || i == H - 1 || j == 0|| j == W - 1)
                    {
                        printf("#");
                    }
                    else
                    {
                        printf(".");
                    }
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 572
/*************************************************************************
	> File Name: B.cpp
	> Author: Knowledge_llz
	> Mail: 925538513@qq.com 
	> Created Time: 2020/4/12 21:03:29
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define LL long long
#define For(i,a,b) for(register LL i=(a);i<=(b);++i)
const LL mod=1e9+7;
using namespace std;
LL read(){
	char x=getchar(); int u=0,fg=0;
	while(!isdigit(x)){ if(x=='-') fg=1; x=getchar(); }
	while(isdigit(x)){ u=(u<<3)+(u<<1)+(x^48); x=getchar(); }
	return fg?-u:u;
}
LL n,k,num[100010],q[100010],ans=0;
LL qpow(LL x,LL y){
	LL tmp=1;
	while(y>1){
		if(y&1) tmp=(tmp*x)%mod;
		(x*=x)%=mod;
		y>>=1;
	}
	return tmp*x%mod;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);
#endif
	n=read(); k=read();
	for(LL i=k;i>=1;i--){
		if(!q[k/i]) q[k/i]=qpow(k/i,n);
		num[i]=q[k/i];
		for(LL j=2*i;j<=k;j+=i)
			num[i]-=num[j];
		(ans+=i*num[i]%mod)%=mod;
	}
	ans=(ans+mod)%mod;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 4644
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        s: chars
    }
    if n % 2 == 1 {
        println!("No");
        return;
    }
    for i in 0..n / 2 {
        if s[i] != s[i + n / 2] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
/**
 *
 * AtCoder Regular Contest 098 - Problem D: Xor Sum 2
 *
 * Given a sequency of integers { Ak }, find the number of ranges [l, r] such as
 *
 *      Al + ... + Ar = Al ^ ... ^ Ar
 *
 * Brute force solution: note that the equality holds iff there is no two numbers in range with
 * repeated bits. Let's 
 *
 *      f(l) = min r in {l + 1, ..., N} | Ar has at least one comum bit with {Al, ... , A(r-1)
 *
 * f is monotonic and can be computed with two-pointers. For each l, we must sum all indexes
 * r < f(l).
 */
#include <iostream>

using namespace std;

using ll = long long;

const int MAX { 300010 };

ll as[MAX], f[MAX];

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    for (int k = 1; k <= N; ++k)
        cin >> as[k];

    // x is the xor of all Ak in [L, R)
    int L = 1, R = 1, x = 0;

    while (L <= N)
    {
        if (R <= N and (x & as[R]) == 0)        // The solution can be extended
        {
            x |= as[R];
            f[L] = ++R;
        } else
        {
            x ^= as[L];                         // Move to the next L
            f[++L] = R;
        }
    }

    ll total = 0;

    for (int k = 1; k <= N; ++k)
        total += (f[k] - k);

    cout << total << endl;

    return 0;
}


Measured memory_bytes: 3840
s=input()
k=int(input())
l=[]
n=len(s)

for i in range(n):
  if n+1>=i+6:
    l+=[s[i:j] for j in range(i+1,i+6)]
  else:
    l+=[s[i:j] for j in range(i+1,n+1)]

l=sorted(list(set(l)))
print(l[k-1])

Measured memory_bytes: 5108
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H & b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H & b) const { return x == b.x && y == b.y; }
	bool operator!=(const H & b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T & a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T & a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int k;
signed main() {
	string s;
	cin >> s;
	k = s.size();
	int sum = 0;
	for (int i = 0; i < k; i++) {
		if (s[i] == 'o') sum++;
	}
	if (sum + (15 - k) >= 8) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}
}

Measured memory_bytes: 256
N,X,Y=map(int,input().split())
def shortest(x,y,a,b):
    ans=min(y-x,abs(y-b)+1+abs(a-x))
    return ans
distance=[0]*(N-1)
for x in range(1,N):
    for y in range(2,N+1):
        if y<=x:
            continue
        a=shortest(x,y,X,Y)
        distance[a-1]+=1
for i in distance:
    print(i)

Measured memory_bytes: 3444
#include<iostream>
#include<math.h>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;

    if(b>99)a *= 1000;
    else if(b>9)a *= 100;
    else a *= 10;

    a += b;
    for(int i=1;i<sqrt(100100);i++){
        if(a==i*i){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

const int INF = 10000000;

int main(){
  int n;
  cin >> n;
  vector<int> x(n),y(n);
  for(int i=0;i<n;i++) cin >> x[i] >> y[i];

  vector<vector<double>> dist(n,vector<double>(n));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      dist[i][j] = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
  }

  vector<int> order(n);
  for(int i=0;i<n;i++) order[i] = i;

  double sum = 0;
  ll cnt = 0;
  do{
    double temp_dist = 0;
    for(int i=1;i<n;i++){
      temp_dist += dist[order[i-1]][order[i]];
    }
    sum += temp_dist;
    cnt++;
  }while(next_permutation(order.begin(),order.end()));

  printf("%.10lf\n",sum/cnt);
}


Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>
#include <tuple>
#include <random>

typedef unsigned long long int ull;
typedef long long int ll;

using namespace std;

int div2(int n) {
    int ret = 0;
    while (n % 2 == 0) {
        ret++;
        n = n / 2;
    }
    return ret;
}

int main(void) {
    int ret = 0x7fff,n,a;
    cin >> n;
    for(int i = 0;i < n;i++) {
        cin >> a;
        ret = min(ret,div2(a));
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llinf (1ll<<60)
#define BG(x) ((x).begin())
#define ED(x) ((x).end())
#define rBG(x) ((x).rbegin())
#define rED(x) ((x).rend())
#define mp(a, b) make_pair((a), (b))

ll t;

ll n;
ll a[100005];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
//    cin >> t;
    t = 1;
	
    for(int _ = 1; _ <= t; _++) {
    //    cout << "Case #" << _ << ": ";
        
		cin >> n;
		
		for(int i = 0; i < n; i++) {
			cin >> a[i];
		}
		
		sort(a, a+n);
		
		ll ans = 1;
		for(int i = 0; i < n; i++) {
			if(!a[i]) {
				ans = 0;
				break;
			}
			if((ll) 1e18 / a[i] < ans) {
				ans = -1;
				break;
			}
			ans *= a[i];
		}
		cout << ans << '\n';
    }
	
    return 0;
}

Measured memory_bytes: 4436
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
string s;
int main()
{
	cin>>s;
	int l=s.size();
	for(int i=1; i<l; i++)
	{
		if(s[i]==s[i-1])
		{
			cout<<"Bad"<<endl;
			return 0;
		}
	}
	cout<<"Good"<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

signed main()
{
	int n = in(), i = in();
	cout << n + 1 - i << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main() {
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<n;i++){
		cout<<s[i]<<t[i];
	}
	
	
	
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
mod = 10 ** 9 + 7
ans = 0
n = int(input())
A = list(map(int, input().split()))
c = Counter(A)
flag = True
if n % 2 == 0:
    odd = 1
    for val, cnt in sorted(c.items()):
        # print(val, cnt)
        if cnt == 2 and val == odd:
            odd += 2
        else:
            flag = False
            break
else:
    even = 0
    for val, cnt in sorted(c.items()):
        # print(val, cnt)
        if val == 0 and cnt == 1:
            even += 2
            continue
        if val == even and cnt == 2:
            even += 2
            continue
        else:
            flag = False
            break
if flag:
    ans = pow(2, n // 2, mod)
else:
    ans = 0
print(ans)


Measured memory_bytes: 16088
n,m = map(int,input().split())
s = set()
t = set()
for i in range(m):
  a,b = map(int,input().split())
  if a == 1 and b != n:
    s.add(b)
  if a != 1 and b == n:
    t.add(a)
 
if len(s&t) > 0:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 19024
#include <iostream>
int x, n, p, h[105];

int main() {
	std::cin >> x >> n;
	for(int i = 1; i <= n; ++i) {
		std::cin >> p;
		h[p] = true;
	}
	for(int i = 0; x - i >= 0; ++i) {
		if(h[x - i] == false) {
			std::cout << x - i;
			return 0;
		}
		if(h[x + i] == false) {
			std::cout << x + i;
			return 0;
		}
	}
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        System.out.println(
                Arrays.stream(input.split(""))
                        .filter(i -> i.equals("1"))
                        .count()
        );
    }
}

Measured memory_bytes: 28244
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
def LILI(n): return [LI() for _ in range(n)]
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main_1(): 
    text = (['Sunny', 'Cloudy'], ['Cloudy', 'Rainy'],['Rainy','Sunny'])
    s = SI()
    for i in text:
        if s == i[0]:
            print(i[1])

def main(): 
    s = SI()
    for num, i in enumerate(s):
        if num % 2 == 1: # even
            if not (i in 'LUD'):
                print('No')
                return
        else:
            if not (i in 'RUD'):
                print('No')
                return
    print('Yes')

main()

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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  cin >> N;
  ll A[N];
  rep(i, N) cin >> A[i];

  vll ma;
  rep(i, N){
    auto ub = upper_bound(ma.begin(), ma.end(), -A[i]);
    if(ub == ma.end()) ma.push_back(-A[i]);
    else *ub = -A[i];
  }
  cout << ma.size() << endl;
  return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)

const int N = ((int)1e3) + 5;

char str[N];
int len;
int cnt[N];

int main ()
{
	scanf("%s",str + 1);
	len = strlen(str + 1);
	for (int i = 1; i <= len; i++)
		cnt[(int)str[i]]++;
	if ((cnt['N'] == 0 && cnt['S'] > 0) || (cnt['N'] > 0 && cnt['S'] == 0) || (cnt['E'] == 0 && cnt['W'] > 0) || (cnt['E'] > 0 && cnt['W'] == 0))
		return printf("No"),0;
	printf("Yes");
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
                                                                                                
  
int main(void){
                                                                                                

    int i;

    int a = 0;

    int k = 0;
   
    char s[100002];
   
      
    scanf("%s", s );


    a = strlen(s);

    for( i = 1 ; i < strlen(s) ; i = i + 1 ){

         if( s[i - 1] != s[i] ){

             if( i > strlen(s) - i ) k = i;

             else k = strlen(s) - i;             

             if( a > k ) a = k;

             }      

         }                
   

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

    return 0;
                                                          
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){

	int n;
	cin >> n;
	int ma = 0;
	int sum = 0;
	rep(i,n) {
		int a;
		cin >> a;
		ma = max(a, ma);
		sum += a;
	}

	sum -= ma/2;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define y second
#define N 880
using namespace std;
typedef pair<int,int> pii;
char dt[N][N];
int dis[N][N];
int n,m,k;
inline bool pc(int x,int y){
	if(x==n||y==m||x<0||y<0||dt[x][y]=='#'||dis[x][y]!=-1) return 0;
	return 1;
}
queue<pii> q;
int fx[4]={1,-1,0,0},fy[4]={0,0,1,-1};
int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<n;i++) scanf("%s",dt[i]);
	memset(dis,-1,sizeof(dis));
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)
			if(dt[i][j]=='S') q.push(pii(i,j)),dis[i][j]=0;;
	}
	int ans=1008610086;
	while(!q.empty()){
		pii st=q.front();q.pop();
		if(dis[st.x][st.y]>k) continue;
		ans=min(min(st.x,st.y),min(min(n-st.x,m-st.y)-1,ans));
		for(int i=0;i<4;i++){
			pii to=pii(st.x+fx[i],st.y+fy[i]);
			if(pc(to.x,to.y)){
				q.push(to);
				dis[to.x][to.y]=dis[st.x][st.y]+1;
			}
		}
	}
	printf("%d\n",(ans+k-1)/k+1);
	return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>
int main(void){
  double w,h,x,y;//(0,0)(0,h)(w,0)(w,h)
  scanf("%lf%lf%lf%lf",&w,&h,&x,&y);
  double s=w*h/2;
  printf("%lf ",s);
  if(x==w/2&&y==h/2){
    printf("1");
  }
  else printf("0");
  
  return 0;
}

Measured memory_bytes: 256
s=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(s[int(input())-1])

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

using namespace std;

typedef long long ll;
#define int long long
const int maxn = 1e6+10;
inline int read()
{
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) w|=ch=='-',ch=getchar();
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

int n,m,q;
int da[maxn];

signed main()
{
	int n =read();
  bool ok = false;
  int cnt=  0;
  	for(int i = 0;i<n;i++){
      	int u =read(),v=read();
      	if(u == v)cnt++;
      else cnt = 0;
      if(cnt >=3) ok =true;
    }
  if(ok) puts("Yes");
  else puts("No");
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std;
//#define int long long

//素数判定
inline bool IsPrime(int p) {
	if (p == 1) return false;
	for (int i = 2; i <= sqrt(p); i++) {
		if (p%i == 0) return false;
	}
	return true;
}

//10進数の自然数の桁数を返す
inline int GetDigit(int num) {
	return (int)log10(num) + 1;
}

//各位の和を返す
int GetDigitsSum(int num) {
	int N = 0;
	while (num > 0) {
		N += num % 10;
		num /= 10;
	}
	return N;
}

//互除法
ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}
	else if (a%b) {
		return gcd(b, a%b);
	}
	else {
		return b;
	}
}

//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow

}

//異なるn個からr個の整数を取り出す組合せの数を求める
int combination(int n, int r) {
	if (r == 0 || n == r) {
		return 1;
	}
	else if (r == 1) {
		return n;
	}
	else {
		return combination(n - 1, r - 1) + combination(n - 1, r);
	}

}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor(int n) {
	map<int, int> res; // map[i]:=ｎを素因数分解したときiは何乗か。
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n] = 1;
	return res;
}

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor_ver2(int n, map<int, int> res) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			while (n % i == 0) {
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n]++;
	return res;
}


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

	int N;
	vector<int> L;

	cin >> N;

	for (int i = 0; i < N * 2; i++)
	{
		int tmp;
		cin >> tmp;
		L.push_back(tmp);
	}

	int ans = 0;
	sort(L.begin(), L.end());

	for (int i = 0; i < N; i++)
	{
		ans += min(L[i * 2], L[i * 2 + 1]);
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
  int N;
  double K;
  cin >> N >> K;
  int sum = 0;
  int x;
  for(int i = 0; i < N; i++){
    cin >> x;
    if(x < K / 2) sum += x * 2;
    else sum += (K - x) * 2;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>
#include <limits>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max<int>(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max<int>(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N - 1), B(N - 1);
  std::vector<std::vector<int>> graph(N);
  std::vector<int> degree(N);
  for (int i: range(0, N - 1)) {
    int a, b;
    std::cin >> a >> b;
    --a; --b;
    graph[a].push_back(b);
    graph[b].push_back(a);
    ++degree[a];
    ++degree[b];
    A[i] = a;
    B[i] = b;
  }
  auto bfs = [&](int u1, int u2 = -1) {
    std::vector<std::vector<int>> group(N);
    std::vector<int> dist(N, std::numeric_limits<int>::max());
    dist[u1] = 0;
    group[dist[u1]].push_back(u1);
    if (u2 != -1) {
      dist[u2] = 0;
      group[dist[u2]].push_back(u2);
    }
    for (int d: range(0, N)) {
      for (int u: group[d]) {
        for (int v: graph[u]) {
          if (chmin(dist[v], d + 1)) {
            group[d + 1].push_back(v);
          }
        }
      }
    }
    return group;
  };
  auto solve = [&](const std::vector<std::vector<int>> &group) {
    int dist = 1;
    unsigned long long leaves = [&] {
      if (group[0].size() == 1) {
        return std::max(degree[group[0][0]], 2);
      }
      else {
        return 2 * std::max({ degree[group[0][0]] - 1, degree[group[0][1]] - 1, 1 });
      }
    }();
    for (int d: range(1, N)) {
      if (group[d].empty()) {
        break;
      }
      chmax(dist, d + 1);
      int max = 0;
      for (int u: group[d]) {
        chmax(max, degree[u]);
      }
      leaves *= std::max(1, max - 1);
    }
    return std::make_pair(dist, leaves);
  };
  std::pair<int, unsigned long long> ans(std::numeric_limits<int>::max(), std::numeric_limits<unsigned long long>::max());
  for (int u: range(0, N)) {
    chmin(ans, solve(bfs(u)));
  }
  for (auto e: range(0, N - 1)) {
    chmin(ans, solve(bfs(A[e], B[e])));
  }
  std::cout << ans.first << ' ' << ans.second << '\n';
}


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

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

    int N;
    string s;

    cin >> N;
    cin >> s;

    int r = 0, b = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'R')
        {
            r++;
        }
        else
        {
            b++;
        }
    }

    if (r > b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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


int main(void) {
 long int N,M,i=0;
	cin >> N>>M;
	while (true) {
		if (N >= 1 && M >= 2) {
			N--;
			M -= 2;
			i++;
		}
		else
		{
			break;
		}
	}

	while (M>=4) {
		M -= 4;
		i++;
	}
	cout << i << endl;


}

Measured memory_bytes: 256
n, a, b, c = gets.split(" ").map(&:to_i)

def ng
  puts "No"
  exit(0)
end

qs = []
n.times do |_|
  s = gets.chomp
  qs << s
end

$m = {}
$m['A'] = a
$m['B'] = b
$m['C'] = c

$ou = []

def is_ng(x, y)
  $m[x] == 0 && $m[y]== 0
end

def add(to, from)
  $m[to] += 1
  $m[from] -= 1
  $ou << to
end

n.times do |i|
  q = qs[i]

  if q == 'AB'
    ng if is_ng('A', 'B')

    if $m['A'] < $m['B']
      add('A', 'B')
    elsif $m['A'] > $m['B'] || i == n-1
      add('B', 'A')
    else
      if qs[i+1].include?('A')
        add('A', 'B')
      else
        add('B', 'A')
      end
    end
  elsif q == 'AC'
    ng if is_ng('A', 'C')

    if $m['A'] < $m['C']
      add('A', 'C')
    elsif $m['A'] > $m['C'] || i == n-1
      add('C', 'A')
    else
      if qs[i+1].include?('A')
        add('A', 'C')
      else
        add('C', 'A')
      end
    end
  elsif q == 'BC'
    ng if is_ng('B', 'C')

    if $m['C'] < $m['B']
      add('C', 'B')
    elsif $m['C'] > $m['B']  || i == n-1
      add('B', 'C')
    else
      if qs[i+1].include?('B')
        add('B', 'C')
      else
        add('C', 'B')
      end
    end
  end
end

puts "Yes"
$ou.each do |va|
  puts va
end

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

using namespace std;

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

int main() {

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int ans = 1e9;
	for (int i = -100; i <= 100; i++) {
		int res = 0;
		for (int j = 0; j < n; j++) {
			res += (i - a[j]) * (i - a[j]);
		}
		ans = min(ans, res);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/* fuck */

#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int, int> Pair;
#define INF 0x7fffffff

int d[] = {4, 1, 4, 1, 2, 1, 2, 1};
int ps[100];

int main() {
  while (1) {
    for (int i=0; i<8; i++) {
      if (scanf("%d", &ps[i]) != 1) return 0;
    } 

    int mod = 1;
    Pair ans(INF, INF);
    for (int i=0; i<8; i++) {
      int sum = 0;
      int encoded = 0;

      for (int j=0; j<8; j++) {
        sum += max(ps[j]-d[(i+j)%8], 0);
        encoded = encoded*10 + d[(i+j)%8];
      }

      ans = min(ans, Pair(sum, encoded));
      mod *= 10;
    }

    int t = ans.second;
    mod /= 10;
    printf("%d", t/mod);
    t %= mod;
    for (int i=1; i<8; i++) {
      mod /= 10;
      printf(" %d", t/mod);
      t %= mod;
    }
    puts("");
  }
}

Measured memory_bytes: 2580
str_list = ['dream', 'dreamer','erase','eraser']
def reverse_str(str_):
    return str_[::-1]

s = str(input())
s = s[::-1]
find_list = list(map(reverse_str, str_list))
index = 0

while index < len(s):
    loop_flag = False
    for i in range(len(find_list)):
        str_value = find_list[i]
        if str(s[index:index+len(str_value)]) == str_value:

            loop_flag = True
            index += len(str_value)
    if not loop_flag:
        break
if index >= len(s):
    print('YES')
else:
    print('NO')

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

int require(string input) {
    vector<int> match = {2, 5, 5, 4, 5, 6, 3, 7, 6};
    return match[(input[0] - 48) - 1];
}

string comparison(string a, string b) {
    if (a.length() < b.length()) {
        return b;
    } else if (a.length() == b.length()) {
        if (a > b) {
            return a;
        } else {
            return b;
        }
    } else {
        return a;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<string> dp(N + 100, "");
    vector<string> A(M);
    sort(A.begin(), A.end());
    for (int i = 0; i < M; ++i) {
        cin >> A[i];
        dp[require(A[i])] = max(dp[require(A[i])], A[i]);
    }
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j < M; ++j) {
            if (i >= require(A[j]) && !dp[i - require(A[j])].empty()) {
                dp[i] = comparison(dp[i], dp[i - require(A[j])] + A[j]);
            }
        }
    }
    /* for (int i = 0; i < N + 1; ++i) {
        cout << i << " " << dp[i] << endl;
    } */
    cout << dp[N] << endl;
}

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

int main(){
  int n;
  int max=0;
  cin >> n;
  vector<int> data(n);
  for(int i=0; i<n; i++) cin >> data[i];
  
  vector<int> dp(100010);
  
  for(int i=0; i<n; i++){
    dp[data[i]]++;
    dp[data[i]+1]++;
    dp[data[i]+2]++;
  }
  
  for(int i=0; i<100010; i++){
    if(dp[i] > max){
      max = dp[i];
    }
  }
  
  cout << max << endl;
    
}

Measured memory_bytes: 1024