akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#define pi 3.141592653589793238462643383L
using namespace std;

int main(void){
  int a,b,hour,minu;
  double angh,angm;
  cin >> a >> b >> hour >> minu;
  angh = hour *(pi/6)+minu*(pi/360);
  angm = minu*pi/30;
  double ans;
  vector<long double> xy(2);
  xy[0] = ((sin(angm)*b)-(sin(angh)*a));
  xy[1] = ((cos(angm)*b)-(cos(angh)*a));
  ans = sqrt((xy[0]*xy[0])+(xy[1]*xy[1]));
  printf("%.15f", ans);
  return 0;
}

Measured memory_bytes: 4112
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f3f3f3f3f
#define pi 3.1415926535898
#define N 200050
using namespace std;
const ll mod=1e9+7;
ll ans=0;
int main()
{
   int n,k;
   cin>>n>>k;
   for(int i=0;i<n;i++)
   {
       double  a,b;
       cin>>a>>b;
       double x=sqrt(a*a+b*b);
       if(x<=k)
       {
           ans++;
       }
   }
   cout<<ans<<endl;
    return 0;
}


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

int main(){
  int n,i,x;
  cin>>n;
  for (i=0;i<=n;i++){
    x=i;
    while(x){
      if (x%3==0){
        cout << " " << i;
        x=0;
      }
      while(x){
        if (x%10==3){
          cout << " " << i;
          x=0;
        }else{
          x/=10;
        }
      }
    }
  }
  cout<<endl;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

// dist[v] に頂点 s から頂点 v への距離を入れる関数
void dijkstra(int s, Graph &G, vector<ll> &dist){
  fill(all(dist), INF);
  dist[s] = 0;

  priority_queue<P, vector<P>, greater<P>> pq;//距離が小さい順に取り出す
  pq.push(P(0,s)); // 頂点 s からスタート

  while (!pq.empty()) {
    P p = pq.top(); pq.pop();
    int v = p.second;
    if(dist[v] < p.first) continue;// 既に v に辿り着く短い経路有ならスルー (これはただの高速化)

    for(auto e : G[v]){// v から行ける頂点 nv 達を走査
      int nv = e.to;
      ll w = e.weight;
      if(dist[nv] > dist[v] + w){
        dist[nv] = dist[v] + w;
        pq.push(P(dist[nv], nv));
      }
    }
  }
}

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};



int main(){
  string s; cin >> s;
  ll n = sz(s);
  
  vl C(26);
  rep(i,n) C[s[i]-'a']++;

  ll ans = 0;
  rep(i,26) rep(j,26) {
    if(i == j) continue;
    ans += C[i]*C[j];
  }

  cout << ans/2+1 << endl;

}

Measured memory_bytes: 640
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<ll, ll> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("commandos.in", "r", stdin);*/
#endif
}
void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
	//File();
}
const double pi = acos(-1.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 2e5 + 15;
int dx[8] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 1, 0, -1, 1, -1, -1, 1 };

int main()
{
	fast();
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0; i < min(sz(s), n); i++)
		cout << s[i];
	for (int i = n, k = 0; i < sz(s) && k < 1; i++,k++)
		cout << "...";
	cout << endl;
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;
  vector<long> A(N);
  vector<long> B(0);
  for(int i=0;i<N;i++)cin>>A[i];
  sort(A.begin(),A.end(),greater<>());
  long cnt=0;
  B.push_back(A[0]);
  if(N%2==1){
    for(int i=1;i<=N/2;i++){
      B.push_back(A[i]);
      cnt+=A[i-1];
  	}
    for(int i=N/2+1;i<N;i++){
      cnt+=min(B[i-N/2-1],B[i-N/2]);
    }
  }else if(N%2==0){
    for(int i=1;i<N/2;i++){
      B.push_back(A[i]);
      cnt+=A[i-1];
      //cout<<cnt<<endl;
  	}
    for(int i=N/2;i<N;i++){
      //cout<<i<<" "<<N<<endl;
      if(i==N-1){
        cnt+=min(B[i-N/2],B[0]);
      }else{
        //cout<<B[i-N/2]<<" "<<B[i-N/2+1]<<endl;
        cnt+=min(B[i-N/2],B[i-N/2+1]);
      }
      //cout<<cnt<<endl;
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 5876
# your code goes here
N,C = map(int,input().split())
D = [list(map(int,input().split())) for i in range(C)]
c = [list(map(int,input().split())) for i in range(N)]

Color = [[0 for i in range(C)] for j in range(3)]

for x in range(N):
	for y in range(N):
		Color[(x+y+2)%3][c[x][y]-1] += 1

ans = 1145141919810
for i in range(C):
	for j in range(C):
		if j == i:
			continue
		for k in range(C):
			if k == i or k == j:
				continue
			tmp = 0
			for x in range(3):
				for y in range(C):
					if x == 0:
						tmp += Color[x][y]*D[y][i]
					elif x == 1:
						tmp += Color[x][y]*D[y][j]
					else:
						tmp += Color[x][y]*D[y][k]
			ans = min(ans,tmp)
print(ans)


Measured memory_bytes: 5492
#include <iostream>
#include <vector>

struct Item {
  int v, w;
};

int main() {
  int N, W;
  std::cin >> N >> W;
  std::vector<Item> items(N);
  for (int i=0; i<N; i++) std::cin >> items[i].v >> items[i].w;
  std::vector<int> dp((N+1)*(W+1));
  for (int i=0; i<W+1; i++) {
    dp[0*(W+1)+i] = 0;
  }
  for (int j=0; j<N+1; j++) {
    dp[j*(W+1)+0] = 0;
  }
  for (int j=1; j<N+1; j++) {
    for (int i=1; i<W+1; i++) {
      int v = dp[(j-1)*(W+1)+i];
      if ( i-items[j-1].w >= 0) {
        int vc = dp[(j-1)*(W+1)+(i-items[j-1].w)] + items[j-1].v;
        if (vc > v) v = vc;
      }
      dp[j*(W+1)+i] = v;
    }
  }
  std::cout << dp[N*(W+1)+W] << std::endl;
}


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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i=a; i<=b; i++)
#define REPn(i, a, b) for (int i=a; i>=b; i--)
#define FOR(n) REP(i, 0, n-1)

void solve() {
    int n; cin>>n;
    FOR(n) {
        cout<<"ACL";
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int t=1;
    //cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=1000;
struct Point{
	i64 x,y,id;
	inline Point(){}
	inline Point(i64 _x,i64 _y){x=_x;y=_y;}
	inline void in(){cin>>x>>y;}
}p[maxn],S[maxn];
inline Point operator + (const Point &a,const Point &b){
	return Point(a.x+b.x,a.y+b.y);
}
inline Point operator - (const Point &a,const Point &b){
	return Point(a.x-b.x,a.y-b.y);
}
typedef double ld;
inline Point operator * (const Point &a,ld b){
	return Point(a.x*b,a.y*b);
}
ld ans[maxn];
inline i64 cross(const Point &a,const Point &b){
	return a.x*b.y-a.y*b.x;	
}
inline i64 dot(const Point &a,const Point &b){
	return a.x*b.x+a.y*b.y;	
}
inline ld len(const Point &a){
	return sqrt(sqr(a.x)+sqr(a.y)+0.0);
}
inline bool cmp(const Point &a,const Point &b){
	return a.x<b.x||(a.x==b.x&&a.y<b.y);
}
int n,top;
const ld pi=acos(-1.0);
int main(){
	read(n);
	// if(n==2){
		// puts("0.5\n0.5\n");
		// return 0;
	// }
	rep(i,1,n)p[i].in(),p[i].id=i;
	sort(p+1,p+1+n,cmp);
	rep(i,1,n){
		while(top>1&&cross(p[i]-S[top-1],S[top]-S[top-1])>=0)top--;S[++top]=p[i];
	}int lst=top;
	per(i,n,1){
		while(top>lst&&cross(p[i]-S[top-1],S[top]-S[top-1])>=0)top--;S[++top]=p[i];
	}S[top+1]=S[2];
	// cerr<<asin(1.0);
	if(top==3){
		ans[S[1].id]=0.5;
		ans[S[2].id]=0.5;
	}else
	rep(i,2,top){
		// cerr<<(ld)abs(cross(S[i+1]-S[i],S[i-1]-S[i]))/len(S[i+1]-S[i])/len(S[i-1]-S[i])<<endl;
		// cerr<<pi-asin((ld)abs(cross(S[i+1]-S[i],S[i-1]-S[i]))/len(S[i+1]-S[i])/len(S[i-1]-S[i]))<<endl;
		ans[S[i].id]=(pi-acos((ld)(dot(S[i+1]-S[i],S[i-1]-S[i]))/len(S[i+1]-S[i])/len(S[i-1]-S[i])))/(2*pi);
	}
	rep(i,1,n)printf("%.10f\n",ans[i]);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
using tiii = tuple<int, int, int>;

int main(){
	ios_base::sync_with_stdio(false);
	int k;
	cin >> k;

	vector<int> v;
	for(int i = 0; i < 20; ++i){
		if(k & (1 << i)){ v.push_back(i); }
	}
	const int n = v.back() + 1;

	if(k == (1 << (n - 1))){
		cout << n << " " << 2 * (n - 1) << endl;
		for(int i = 0; i + 1 < n; ++i){
			cout << i + 1 << " " << i + 2 << " " << 0 << endl;
			cout << i + 1 << " " << i + 2 << " " << (1 << i) << endl;
		}
		return 0;
	}

	vector<tiii> edges;
	for(int i = n - 1; i >= 0; --i){
		const int cost = k & ~((2 << i) - 1);
		if(k & (1 << i) && cost > 0){
			edges.emplace_back(n - 1, i, cost);
		}
	}
	for(int i = 0; i + 1 < n; ++i){
		edges.emplace_back(i + 1, i, 0);
	}
	for(int i = 0; i + 1 < n; ++i){
		edges.emplace_back(i + 1, i, (1 << i));
	}
	cout << n << " " << edges.size() << endl;
	for(const auto& t : edges){
		cout << n - get<0>(t) << " " << n - get<1>(t) << " " << get<2>(t) << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=(int)1e9+7;
int ad(int x,int y){
	if(y<0)
		y+=M;
	return (x+y)%M;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<vector<int> > dp(n+1,vector<int> (n+1));
	dp[1][1]=1;
	for(int i=2;i<=n;i++){
		char c;
		cin>>c;
		if(c=='<')
			for(int j=1;j<=i;j++)
				dp[i][j]=ad(dp[i-1][j-1],dp[i][j-1]);
		else
			for(int j=1;j<=i;j++)
				dp[i][j]=ad(ad(dp[i-1][i-1],-dp[i-1][j-1]),dp[i][j-1]);		
	}
	cout<<dp[n][n]<<endl;
}

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

const static ll MOD = (1e+9)+7;

ll modpow(ll a,ll n){
    if(n==0)return 1;
    if(n%2==1)return a*modpow(a,n-1)%MOD;
    ll t = modpow(a,n/2) % MOD;
    return t*t % MOD;
}

int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    while(true){
        c-=b;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
        a-=d;
        if(a<=0){
            cout<<"No"<<endl;
            break;
        }
    }
    return 0;
}

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

int main() {
    string S;
    cin >> S;

    bool flag = false;
    for(char ch = 'a'; ch <= 'z'; ch++) {
        for(int i = 0; i < S.size(); i++) {
            if(ch == S[i]) {
                flag = false;
                break;
            } 
            else {
                flag = true;
            }
        }
        if(flag) {
            cout << ch << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

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

int main() {
	long long x;cin>>x;
	long long a,b;
	for(a=-1000;a<=1000;a++){
		for(b=-1000;b<1000;b++){
			if(a*a*a*a*a-b*b*b*b*b==x){
				cout<<a<<' '<<b<<endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3628
#include<queue>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int L[100011], R[100011];
bool use[100011];

vector<pair<int, int> > X, Y;

LL calc() {
    memset(use, 0, sizeof use);
    X.resize(N);
    Y.resize(N);
    REP (i, N) {
	X[i] = make_pair(L[i], i);
	Y[i] = make_pair(R[i], i);
    }

    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    reverse(Y.begin(), Y.end());

    LL pos = 0;
    LL ret = 0;
    while (1) {
	while (!X.empty() && use[X.back().second]) {
	    X.pop_back();
	}
	if (X.empty()) break;

	int idx = X.back().second;
	if (pos < L[idx]) {
	    ret += L[idx] - pos;
	    pos = L[idx];
	} else if (R[idx] < pos) {
	    ret += pos - R[idx];
	    pos = R[idx];
	}
	use[idx] = true;

	while (!Y.empty() && use[Y.back().second]) {
	    Y.pop_back();
	}
	if (Y.empty()) break;

	idx = Y.back().second;
	if (pos < L[idx]) {
	    ret += L[idx] - pos;
	    pos = L[idx];
	} else if (R[idx] < pos) {
	    ret += pos - R[idx];
	    pos = R[idx];
	}
	use[idx] = true;
    }

    ret += abs(pos);
    return ret;
}

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d%d", L+i, R+i);

    LL ans = calc();
    REP (i, N) {
	L[i] = -L[i];
	R[i] = -R[i];
	swap(L[i], R[i]);
    }
    amax(ans, calc());
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
queue<int> q;
int x;
cin>>x;
for(int i=100;i<=105;i++)
q.push(i);
map<int,int> mp;
while(q.front()<=x)
{
    int val=q.front();
    if(val==x)
    {
        cout<<1<<endl;
        return 0;
    }
    q.pop();
    for(int i=100;i<=105;i++)
    {
        if(mp[val+i]==0)
        {
            mp[val+i]=1;
            q.push(val+i);
        }
    }
}
cout<<0<<endl;




    return 0;
}



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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
const int maxn=2e5+5;

int go[maxn];
int place[maxn];
int cnt=0;
int main()
{
	mes(place,0);
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll k;
	cin>>n>>k;
	rept(i,1,n) cin>>go[i];
	int pos=1;
	while(k)
	{
		if(place[pos])
		{
		//	dd(pos);dd(k);dd(cnt-place[pos]+1);
			k%=(cnt-place[pos]+1);
			if(!k) break;
		}
		else
		{
			place[pos]=++cnt;
		}
		k--;
		pos=go[pos];
	}
	cout<<pos<<"\n";
	return 0;
}

Measured memory_bytes: 5216
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpll vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
lld p1=1e9 + 7,p2=998244353;

void judge(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    
}

void fastio(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}


long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

// lld fac[5005]; 

// void getfac(lld p)
// {
//     fac[0] = 1; 
//     for (lld i=1 ; i<=5005; i++) 
//         fac[i] = fac[i-1]*i%p; 
// }    

// long long int nCrmodp(lld n, lld r,lld p) 
// { 
//    // Base case 
//    if (r==0) 
//       return 1; 
     
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }


lld l,r,mid,ans=0;
lld n,i,j,k,g,m;
lld x,y,n1,n2,h,z,c;
lld aa=1;

lld ss=1;

void solve()
{ 
    lld a,b,c,d;
    cin>>a>>b>>c>>d;
    ans = a*c;
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans ,b*d);
    cout<<ans;
}

int main()
{
    // judge();
    fastio();
    lld t=1;
    // cin>>t;
    // lld p1 = 1e9 + 7;
    // getfac(p1);
    for(int i=0;i<t;i++)
    {
        // cout<<"Case #"<<i+1<<": ";
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3636
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h, w, k = LI()
x1, y1, x2, y2 = LI()
c = [input() for _ in range(h)]

que = deque()
que.append((y1-1, x1-1))
dp = [[inf] * w for _ in range(h)]
dp[x1-1][y1-1] = 0
while que:
    x, y = que.popleft()
    for i in range(4):
        if i == 0:
            for ki in range(k):
                nx = x + (ki + 1)
                if 0 <= nx < w:
                    if c[y][nx] == '.':
                        if dp[y][nx] < dp[y][x] + 1:
                            break
                        elif dp[y][nx] == dp[y][x] + 1:
                            continue
                        dp[y][nx] = dp[y][x] + 1
                        que.append((nx, y))
                    else:
                        break
                else:
                    break
        elif i == 1:
            for ki in range(k):
                ny = y + (ki + 1)
                if 0 <= ny < h:
                    if c[ny][x] == '.':
                        if dp[ny][x] < dp[y][x] + 1:
                            break
                        elif dp[ny][x] == dp[y][x] + 1:
                            continue
                        dp[ny][x] = dp[y][x] + 1
                        que.append((x, ny))
                    else:
                        break
                else:
                    break
        elif i == 2:
            for ki in range(k):
                nx = x - (ki + 1)
                if 0 <= nx < w:
                    if c[y][nx] == '.':
                        if dp[y][nx] < dp[y][x] + 1:
                            break
                        elif dp[y][nx] == dp[y][x] + 1:
                            continue 
                        dp[y][nx] = dp[y][x] + 1
                        que.append((nx, y))
                    else:
                        break
                else:
                    break
        else:
            for ki in range(k):
                ny = y - (ki + 1)
                if 0 <= ny < h:
                    if c[ny][x] == '.':
                        if dp[ny][x] < dp[y][x] + 1:
                            break
                        elif dp[ny][x] == dp[y][x] + 1:
                            continue
                        dp[ny][x] = dp[y][x] + 1
                        que.append((x, ny))
                    else:
                        break
                else:
                    break
ans = dp[x2-1][y2-1]
if ans == inf:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 105896
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;
  cin >> n;
  int mintemp = 0;
  int res = 0;
  cin >> mintemp;
  res++;
  rep(i, n - 1) {
    int a;
    cin >> a;
    res += chmin(mintemp, a);
  }
  cout <<res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int times = 0;
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] plist = new int[N];
		for (int i = 0; i < N; i++) {
			plist[i] = scanner.nextInt();
	    }
	    
	    for (int i = 0; i < N; i++) {
	    	if (i == 0 && plist[i] == 1) {
	    		swap(0, 1, plist);
	    		i++;
	    		times++;
	    	} else if (i == N-1 && plist[i] == N) {
	    		swap(N-1, N-2, plist);
	    		i++;
	    		times++;
	    	} else if (plist[i] == i+1) {
	    		if (plist[i-1] != i) {
	    			swap(i, i-1, plist);
	    			i++;
	    			times++;
	    		} else {
	    			swap(i, i+1, plist);
	    			i++;
	    			times++;
	    		}
	    	}
	    }
	    
	    System.out.println("");
	    
	   System.out.println(times);
	   }
	   
   public static void swap(int a, int b, int[] list) {
   		int temp;
   		temp = list[a];
   		list[a] = list[b];
   		list[b] = temp;
   }
 } 
		

Measured memory_bytes: 50832
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
#define MOD 1000000007
//setprecision(15)
ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	ll N; cin >> N;
	ll ans = mod_pow(10, N, MOD);
	ans = (ans - mod_pow(9, N, MOD) + MOD) % MOD;
	ans = (ans - mod_pow(9, N, MOD) + MOD) % MOD;
	ans = (ans + mod_pow(8, N, MOD)) % MOD;
	cout << ans << endl;
}


Measured memory_bytes: 3612
#include<cstdio>
#include<vector>
using namespace std;
const int N=100005;
int n,m,d[N],h[N],c,r;
vector<int>v[N];
int dfs(int x,int f)
{
	for(auto i=v[x].begin();i!=v[x].end();++i)if(*i!=f)
	{
		if(*i==r)return 1;
		if(d[*i]==4)continue;
		if(dfs(*i,x))return 1;
	}
	return 0;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,x,y;i<=m;++i)
		scanf("%d%d",&x,&y),++d[x],++d[y],
		v[x].push_back(y),v[y].push_back(x);
	if(n==1)return printf("No",0);
	for(int i=1;i<=n;++i)
		if(d[i]&1)return printf("No"),0;
	for(int i=1;i<=n;++i)
		if(d[i]>=6)return printf("Yes"),0;
		else if(d[i]==4)++c;
	if(c>=3)return printf("Yes"),0;
	if(c<=1)return printf("No"),0;
	for(int i=1;i<=n;++i)
		if(d[i]==4)return printf("%s",(r=i,dfs(i,0))?"Yes":"No"),0;
}

Measured memory_bytes: 10616
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		    Scanner scan=new Scanner(System.in);
		    int X=scan.nextInt();
		    int A=scan.nextInt();
		    if(X<A)
		      System.out.println("0");
		    else
		      System.out.println("10");
		  }
		

	}

Measured memory_bytes: 23636
import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt
  val sn = Iterator.continually(in.readLine).take(n).toArray

  val tar = "AB"
  var sum1 = sn.map(_.sliding(2).count(_ == tar)).sum

  val (b_, _a, ba) = sn./:(0,0,0) {
    case ((x, y, z), s) if s.head == 'B' && s.last == 'A' => (x, y, z+1)
    case ((x, y, z), s) if s.head == 'B' => (x+1, y, z)
    case ((x, y, z), s) if s.last == 'A' => (x, y+1, z)
    case ((x, y, z), s) => (x, y, z)
  }

  val sum2 = ba match {
    case x if x == 0 => _a min b_
    case x if _a + b_ == 0 => ba - 1
    case _ => ba + (_a min b_)
  }
  // debug(sum1, ba, b_, _a)

  val ans = sum1 + sum2
  println(ans)

  def debug(any:Any*):Unit = {
    if(this.getClass.toString != "class Main$")
      println(any.mkString(" "))
  }
}

Measured memory_bytes: 52260
import sys
N = int(input())
 
input_line = input()
Line = input_line.split()
Line = [int(s) for s in Line]

for i in range(Line[0],Line[1]+1):
    # print(i)
    if i % N == 0:
        print("OK")
        sys.exit()
print("NG")

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
 char n[500001];
  cin>>n;
  int y=strlen(n);
  int a[500010]={};
  
  
  rep(i,y)if(n[i]=='<')a[i+1]=max(a[i]+1,a[i+1]);
  
  for(int k=y-1;k>=0;k--)if(n[k]=='>')a[k]=max(a[k+1]+1,a[k]);
  
  long long res=0;
  rep(i,y+1)res+=a[i];
  cout<< res<<endl;
  
}
  

Measured memory_bytes: 2688
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i] +B[i])
ans = 0
j = M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K -a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)


Measured memory_bytes: 134412
#include<bits/stdc++.h>
#define PII pair<int,int>
using namespace std;
const int P=998244353;
const int N=2e5+5;
const int Gi=332748118;

struct Pint{
	int x;
	inline Pint(){x=0;}
	inline Pint(int b){x=(b%P+P)%P;}
	inline void operator=(int b){x=(b%P+P)%P;}
    inline bool operator==(const Pint &b) const {return x==b.x;}
    inline bool operator!=(const Pint &b) const {return x!=b.x;}
    inline Pint operator+(const Pint &b)const {return x+b.x>=P?x+b.x-P:x+b.x;}
	inline Pint operator-(const Pint &b)const {return x-b.x<0?x-b.x+P:x-b.x;}
	inline Pint operator*(const Pint &b)const {return 1LL*x*b.x%P;}
	inline void operator+=(const Pint &b){x=x+b.x>=P?x+b.x-P:x+b.x;}
	inline void operator-=(const Pint &b){x=x-b.x<0?x-b.x+P:x-b.x;}
	inline void operator*=(const Pint &b){x=1LL*x*b.x%P;}
	inline void read(){
		char c;int a, b;
	    for(c=getchar(),a=0,b=1;c<48||57<c;c=getchar()){
	        if(c==EOF){x=0;return;}
	        if(c=='-')b=-1;
	    }
	    for(;48<=c&&c<=57;c=getchar())a=((a+(a<<2))<<1)+(c^'0');
	    *this=a*b;
	}
};
Pint a[N],b[N],o[N];
int lim,l,r[N];
inline Pint ksm(Pint x,int y=P-2){
	Pint ans=1;
	for(;y;y>>=1,x*=x)
		if(y&1)ans*=x;
	return ans;
}
inline void init(int len){
    lim=1,l=-1;
    while(lim<=len)lim<<=1,++l;
    for(int i=1;i<lim;i++)r[i]=(r[i>>1]>>1)|((i&1)<<l);
}
inline void NTT(Pint *A,int ty){
    for(int i=0;i<lim;i++)
        if(i<r[i])swap(A[i],A[r[i]]);
    for(int p=1;p<lim;p<<=1){
        int D=p<<1;
		Pint wn=ksm(ty==1?3:Gi,(P-1)/D);
        o[0]=1;
        for(int i=1;i<p;i++)o[i]=o[i-1]*wn;
        for(int i=0;i<lim;i+=D){
            for(int j=0;j<p;j++){
                Pint x=A[i+j],y=A[i+j+p]*o[j];
                A[i+j]=x+y,A[i+j+p]=x-y;
            }
        }
    }
    if(ty==-1){
    	Pint INV__=ksm(lim);
        for(int i=0;i<lim;i++)
            A[i]*=INV__;
    }
}

int n,m,h[N],p[N];
Pint fac[N],inv[N],ans;
vector<Pint>f[N];
priority_queue<PII,vector<PII>,greater<PII> >Q;

inline Pint C(int x,int y){
	return fac[y]*inv[x]*inv[y-x];
}
inline Pint A(int x,int y){
	return fac[y]*inv[y-x];
}
int main(){
	scanf("%d",&n),n*=2;
    for(int i=1;i<=n;i++)scanf("%d",&h[i]);
    sort(h+1,h+1+n);
    for(int i=1;i<=n;i++){
    	if(h[i]!=h[i-1])p[++m]=1;
    	else p[m]++;
	}
	fac[0]=1;
	for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i;
	inv[n]=ksm(fac[n]);
	for(int i=n-1;~i;i--)inv[i]=inv[i+1]*(i+1);
	for(int i=1;i<=m;i++){
    	for(int j=0;j<=(p[i]>>1);j++){
    		f[i].push_back(A(j,p[i])*C(j,p[i]-j)*ksm(ksm(2,j)));
		}
		Q.push(PII(f[i].size(),i));
	}
	while(Q.size()>1){
		int u=Q.top().second;
		Q.pop();
		int v=Q.top().second;
		Q.pop(); 
		int su=f[u].size(),sv=f[v].size();
		init(su+sv-2);
		for(int i=0;i<=lim;++i) a[i]=0,b[i]=0;
		for(int i=0;i<su;++i) a[i]=f[u][i];
		for(int i=0;i<sv;++i) b[i]=f[v][i];
		NTT(a,1),NTT(b,1);
		for(int i=0;i<lim;i++) a[i]=a[i]*b[i];
		NTT(a,-1);
		if(!Q.size()){
			for(int i=0;i<=su+sv-2;++i)
				ans+=ksm(-1,i)*a[i]*A((n-2*i)>>1,n-2*i)*ksm(ksm(2,(n-2*i)>>1));
			break;
		}
		++m;
		for(int i=0;i<=su+sv-2;++i) f[m].push_back(a[i]);
		Q.push(PII(f[m].size(),m));
	}
	printf("%d\n",ans.x);
} 

Measured memory_bytes: 19496
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	int N, M, sum = 0;
	scanf("%d%d", &N, &M);
	int arr[N + 1];
	for (int i = 1; i <= N; i++) {
		scanf("%d", &arr[i]);
		sum += arr[i];
		arr[i] = -arr[i];
	}
	sort (arr + 1, arr + N + 1);
	if (-arr[M] >= (double)sum / (4 * M)) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp2
{
    using static System.Console;
    using static System.Math;

    class Program
    {
        static void Main(string[] args)
        {
            S = ReadLine();
            Solve();
        }

        static string S;

        static void Solve()
        {
            var l = int.Parse(S.Substring(0, 2));
            var r = int.Parse(S.Substring(2));
            if (l <= 12 && l > 0)
                if (r > 12 || r == 0)
                    WriteLine("MMYY");
                else
                    WriteLine("AMBIGUOUS");
            else if (r <= 12 && r > 0)
                WriteLine("YYMM");
            else
                WriteLine("NA");
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ;
const int N = 1e5;
const int mod = 1e9 + 7;
int binpow(int a, int b) {
    a %= mod;
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int32_t main(){
 L_T_S_K;
 	string s , t;
 	cin >> s >> t;
 	int n = s.length();
 	int m = t.length();
 	int dp[n + 1][m + 1] = {};
 	for(int i = 0 ; i <= n; i++){
 		for(int j = 0 ; j <= m ; j++){
 			if(!i || !j)dp[i][j] = 0;
 			else if(s[i - 1] == t[j - 1]){
 				dp[i][j] = 1 + dp[i - 1][j - 1];
 			}
 			else dp[i][j] = max(dp[i - 1][j] , dp[i][j - 1]);
 		}
 	}
 	int k = dp[n][m];
 	string ss = "";
 	int i = n , j = m;
 	while(i > 0 && j > 0){
 		if(s[i - 1] == t[j - 1]){
 			ss+=s[i - 1];
 			i--,j--,k--;
 		}
 		else if(dp[i - 1][j] > dp[i][j - 1])i--;
 		else j--;
 	}
 	reverse(ss.begin() , ss.end());
 	cout << ss << " ";
return 0;
}

Measured memory_bytes: 70656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
	//	  System.setIn(B081.class.getResourceAsStream("input.txt"));
		  Scanner in = new Scanner(System.in);

		  int A = in.nextInt();
		  int B = in.nextInt();
		  int C = in.nextInt();
		  int X = in.nextInt();
		  int count = 0;

		  for (int a = 0; a <= A; ++a) {
			    for (int b = 0; b <= B; ++b) {
			      for (int c = 0; c <= C; ++c) {
			        int total = 500*a + 100*b + 50*c;
			        if (total == X) ++count;
			      }
			    }
		  }

		  System.out.println(count);
		  in.close();
		  }
	}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>

using namespace std;

vector<int> G[10000];
int N;
vector<int> C;
int ans[10000];

void dfs(int u, int p) {
  for (int v : G[u]) if (v != p) {
    dfs(v, u);
  }
  ans[u] = C.back(); C.pop_back();
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N-1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  C.resize(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    sum += C[i];
  }
  sort(C.begin(), C.end());
  reverse(C.begin(), C.end());
  sum -= C[0];
  dfs(0, -1);
  cout << sum << '\n';
  for (int i = 0; i < N; i++) {
    cout << ans[i] << ' ';
  }
  cout << '\n';
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
    int n;
    cin >> n;
    vector<pii>ab(n),cd(n);
    vector<bool>abflag(n, true),cdflag(n, true);
    rep(i, 0, n){
        cin >> ab[i].second >> ab[i].first;
        ab[i].first*=-1;
    }
    rep(i, 0, n)cin >> cd[i].first >> cd[i].second;
    sort(ab.begin(),ab.end());
    sort(cd.begin(),cd.end());
    rep(i, 0, n)ab[i].first*=-1;
    int ans = 0;
    rep(i, 0, n){
        rep(j, 0, n){
            if(cd[i].first>ab[j].second && cd[i].second>ab[j].first && abflag[j] && cdflag[i]){
                ans++;
                abflag[j] = false;
                cdflag[i] = false;
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
    int n ,m;
    cin >> n >> m;
    vector <int> ac(n);
    vector <int> pena(n);
    int p;
    string s;
    rep(i,m){
        cin >> p >> s;
        p--;
        if(ac[p]==1) continue;
        if(s=="AC"){
            ac[p]=1;
        }else{
            pena[p]++;
        }
    }
    int A = 0, P = 0;
    rep(i,n){
        A+=ac[i];
        if(ac[i])P+=pena[i];
    }
    cout << A << " " << P << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#define llint long long

using namespace std;

int n, h;
vector<llint> G[405], revG[405];
const llint Pos = 202;
bool used[405];
int S, T;

bool dfs(llint v, llint &lsum, llint &rsum)
{
	used[v] = true;
	int deg = (int)G[v].size() - (int)revG[v].size();
	if(v <= 200){
		if(deg < 0) return false;
		lsum += deg;
	}
	else{
		if(deg > 0) return false;
		rsum -= deg;
	}
	for(int i = 0; i < G[v].size(); i++){
		if(used[G[v][i]]) continue;
		if(!dfs(G[v][i], lsum, rsum)) return false;
	}
	for(int i = 0; i < revG[v].size(); i++){
		if(used[revG[v][i]]) continue;
		if(!dfs(revG[v][i], lsum, rsum)) return false;
	}
	return true;
}

int main(void)
{
	cin >> n >> h;
	llint a, b, c, d, u, v;
	for(int i = 1; i <= n; i++){
		cin >> a >> b >> c >> d;
		if(c == 0) u = a;
		else u = Pos+c;
		if(d == 0) v = Pos+b;
		else v = d;
		
		G[u].push_back(v);
		revG[v].push_back(u);
	}
	for(int i = 0; i <= 400; i++){
		if(G[i].size() == 0 && revG[i].size() == 0) used[i] = true;
	}
	
	for(int i = 0; i <= 400; i++){
		if(used[i]) continue;
		llint lsum = 0, rsum = 0;
		if(!(dfs(i, lsum, rsum) && lsum == rsum && lsum > 0)){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	
	return 0;
}

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

int main()
{
    int N, count=0, ptr=0, ii=0, sum=0;
    cin >> N;
    vector<string> a(N);
    vector<pair<int, string>> p(N);
    for (int i = 0; i < N;i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    //cout << endl;
    // for (int i = 0; i < N;i++){
    //     cout << a.at(i) << endl;
    // }
    while (ptr < N)
    {
        string tmp = a.at(ptr);
        int f = 0, i=0;
        //cout << tmp << "-";
        while (ptr < N && a.at(ptr) == tmp)
        {
            f++;
            ptr++;
        }
        //cout << f << endl;
        p.at(ii) = make_pair(f, tmp);
        //cout <<ii<<"-"<< p.at(ii).first << "-" << p.at(ii).second << endl;
        if(sum<p.at(ii).first){
            sum = p.at(ii).first;
        }
        ii++;
    }
    //cout << endl;
    sort(p.begin(), p.end());
    for (int i = 0; i < N;i++){
        if(p.at(i).first==sum){
            cout << p.at(i).second << endl;
        }
    }
}

Measured memory_bytes: 17408
#include <bits/stdc++.h>
#pragma GCC diagnostic error "-Wconversion"
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define mp(a, b) make_pair(a, b)
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = (1e9 + 7);
using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
ll dp[100010];
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
ll digits(ll x){
  ll length = 0;
  while (x > 0){
    x /= 10;
    length++;
  }
  return length;
  if (x == 0) return 0;
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}
template<class T> inline bool chmin(T& a, T b){
  if (a > b){
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b){
  if (a < b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  cout << fixed << setprecision(15);

  int a; cin >> a;

  ll ans = 0;
  //string ans;

  for (int i = a; i < 100004; i++){
    map<ll, ll> ps = factor(i);
    if (ps.size() == 1){
      if (ps[i] == 1){
        ans = i;
        break;
      }
    }
  }
  
  cout << ans << endl;
   
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    ll a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i,n) cin >> x[i];
    ll ans = 0;
    rep(i,n-1){
        ll sum = (x[i+1] - x[i]) * a;
        if (sum < b) ans += sum;
        else ans += b;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4032
n = int(input())
d = list(map(int, input().split()))
mod = 998244353

a = [0] * n
for d_ in d:
    a[d_] += 1

res = d[0] == 0 and a[0] == 1
pre = 1
for a_ in a:
    res *= pre ** a_
    res %= mod
    pre = a_

print(res)

Measured memory_bytes: 14396
#include<bits/stdc++.h>
#define ll long long
#define db double
#define lowbit(p) (p&(-p))
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define A first
#define B second
using namespace std;
void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void read(ll &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void Min(int &x,int y){
	if (x>y)x=y;
}
void Max(int &x,int y){
	if (x<y)x=y;
}
void Min(ll &x,ll y){
	if (x>y)x=y;
}
void Max(ll &x,ll y){
	if (x<y)x=y;
}

#define M 100005
struct ed{
	int x,nx;
}e[M<<1];
int fa[M],nx[M],ecnt=1,n,mx,id,val[M],Q[M],tot;
bool mark[M];
void add(int x,int y){
	e[ecnt]=(ed){y,nx[x]};
	nx[x]=ecnt++;
}
void dfs(int f,int x,int d){	
	fa[x]=f;
//	printf("%d->%d\n",f,x);
	if (d>mx){
		mx=d;
		id=x;
	}
	for (int i=nx[x];i;i=e[i].nx)if (e[i].x!=f){
		dfs(x,e[i].x,d+1);
	}
}
int qu(int x){
	int res=0,i,j,y;
	for (i=nx[x];i;i=e[i].nx)if (!mark[e[i].x]){
		y=e[i].x;
		for (j=nx[y];j;j=e[j].nx)if (e[j].x!=x){
			return -1;
		}	
		res++;
	}
	return res;
}
void chk(){
	mx=0;
	int tmp,i,j,x;
	dfs(0,1,0);
//	printf("id=%d\n",id);
	mx=0;
	dfs(0,id,0);
//	printf("id=%d\n",id);
	for (x=id;x;x=fa[x]){
//		printf("%d ",x);
		Q[++tot]=x;
		mark[x]=1;
//		printf("fa[%d]=%d\n",x,fa[x]);
	}
//	printf("\n");
	for (i=1;i<=tot;i++){
		tmp=qu(Q[i]);
		if (tmp==-1){
			printf("-1\n");
			exit(0);
		}
		else {
			val[i]=tmp;
		}
	}
	for (i=1;i<=tot;i++){
		if (val[i]!=val[tot-i+1]){
			if (val[i]<val[tot-i+1]){
				return ;
			}
			else{
				for (j=1;j<=tot-j+1;j++){
					swap(Q[j],Q[tot-j+1]);
					swap(val[j],val[tot-j+1]);
				}
				return ;
			}
		}
	}
}
void pt(){
	int now=0,i,l,r;
	for (i=1;i<=tot;i++){
		l=now+2; r=now+val[i]+1;
		for (int x=l;x<=r;x++){
			printf("%d ",x);
		}
		printf("%d ",now+1);
		now=r;
	}
	printf("\n");
}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	freopen("1.in","r",stdin);
	read(n);
	int i,x,y;
	for (i=1;i<n;i++){
		read(x); read(y);
		add(x,y);
		add(y,x);	
	}
	chk();
	pt();
	return 0;
}

Measured memory_bytes: 8704
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#define N (100 + 19)
#define inf (1000000000)

int x[N];

int Q(int x) {
	return x * x;
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)scanf("%d", x + i);
	int ans = inf;
	for (int x0 = 0; x0 <= 100; x0++) {
		int cur = 0;
		for (int i = 0; i < n; i++) {
			cur += Q(x0 - x[i]);
		}
		ans = std::min(ans, cur);
	}
	printf("%d", ans);
	return 0;
}

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;cin>>s;
    int l = 0, r = s.size()-1;
    int ans = 0;
    while(l<=r){
        char c1=s[l],c2=s[r];
        if(c1==c2){l++;r--;}
        else if(c1=='x'){l++;ans++;}
        else if(c2=='x'){r--;ans++;}
        else{cout<<-1<<endl;return 0;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512