akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int s[2001], t[2001];
long long int result[2001][2001] = {};

int main()
{
	int n, m;
	cin >> n >> m;
	result[0][0] = 1;
	for(int i = 1; i <= n; i++){
		cin >> s[i];
		result[i][0] = 1;
	}
	for(int i = 1; i <= m; i++){
		cin >> t[i];
		result[0][i] = 1;
	}

	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			result[i][j] = (result[i - 1][j] + result[i][j - 1] - result[i - 1][j - 1] + mod) % mod;
			if(s[i] == t[j]) result[i][j] = (result[i][j] + result[i - 1][j - 1]) % mod;
		}
	}
	cout << result[n][m] << endl;
}

Measured memory_bytes: 31488
/*
时间:2020-7-28
书籍：算法和数据结构
内容：链表
页数：P70
*/
#include<iostream>
using namespace std;
struct Node
{
	int x;
	Node* pre;
	Node* next;
};
class DoubleLinkList
{
	Node* first;
public:
	DoubleLinkList()
	{
		first = new Node();
		first->next = first;
		first->pre = first;
	}
	void insertX(int X)                //头插法
	{
		Node* s = new Node;
		s->x = X;
		s->next = first->next;
		first->next->pre = s;
		s->pre=first;
		first->next = s;
	}
	void deleteX(int X)
	{
		Node* s = first, * p = first->next;
		while (p->x != X&&p!=first)
		{
			s = s->next;
			p = p->next;
		}
		if (p->x == X)
		{
			s->next = p->next;
			p->next->pre = s;
			delete p;
		}
	}
	void deleteFirst()
	{
		Node* s = first->next;
		first->next = s->next;
		s->next->pre = first;
		delete s;
	}
	void deleteLast()
	{
		Node* s = first->pre->pre;
		Node* p = first->pre;
		s->next = first;
		first->pre = s;
		delete p;
	}
	void print()
	{
		Node* s = first->next;
		while (s != first->pre)
		{
			cout << s->x << " ";
			s = s->next;
		}
		cout << s->x << endl;
	}
};
int main()
{
	DoubleLinkList L;
	int n;
	cin >> n;
	int count = 0;
	string str;
	int x;
	while (count < n)
	{
		++count;
		cin >> str;
		if (str == "insert")
		{
			cin >> x;
			L.insertX(x);
		}
		else if (str == "delete")
		{
			cin >> x;
			L.deleteX(x);
		}
		else if (str == "deleteFirst")
		{
			L.deleteFirst();
		}
		else if(str == "deleteLast")
		{
			L.deleteLast();
		}
	}
	L.print();
	return 0;
}


Measured memory_bytes: 34404
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,int> pii;
const ll mod = 1e9+7;
const int inf  = 0x3f3f3f3f;

struct cmp
{
	bool operator()(const pii & a, const pii & b)
	{
		return a.second > b.second;
	}
};

const int maxn = 1e5+5;
std::vector<ll> vv;
std::vector<int> vp;
int main()
{
	for (ll i = -2000; i <= 2000; i ++ )
	{
		vv.push_back(i * i * i * i * i);
		vp.push_back(i);
	}
	ll x;
	scanf("%lld",&x);
	int f = 0;
	for (int i = 0; i < vv.size(); i ++ )
	{
		for(int j = 0; j < vv.size(); j ++ )
		{
			if(vv[i] - vv[j] == x)
			{
				f = 1;
				printf("%d %d\n",vp[i],vp[j]);
				break;
			}
		}
		if(f)
			break;
	}
}

Measured memory_bytes: 3284
#include <iostream>
#include <string>

int main()
{
    std::string S;
    std::cin >> S;
    if(S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) std::cout << "Yes" << std::endl;
    else if(S[0] == S[2] && S[1] == S[3] && S[0] != S[1]) std::cout << "Yes" << std::endl;
    else if(S[0] == S[3] && S[1] == S[2] && S[0] != S[1]) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define W 0
#define G 1
#define B 2

int n,M[N][N], c[N],d[N],f[N],t;

void dfs_visit(int u){
  int v;
  c[u]=G;
  d[u]=++t;

  for(v=0;v<n;v++){
  if(M[u][v]==0) continue;
  if(c[v]==W){
    dfs_visit(v);
  }
}
  c[u]=B;
  f[u]=++t;
}



void dfs(){
  int u;
  
  for(u=0;u<n;u++) c[u]=W;
  t=0;

  
  for(u=0;u<n;u++){
      if(c[u]==W){
	dfs_visit(u);
      }
    }

  
  for(u=0;u<n;u++){
      printf("%d %d %d\n",u+1,d[u],f[u]);
    }
}

int main(){
  int u,v,k,i,j;

  scanf("%d",&n);

  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j]=0;
  }

  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();
  return 0;
}



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

using namespace std;

int main(){
    int N; cin >> N;
    vector<int> C(N, 0);
    vector<int> V(N, 0);

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

    int reward = 0;
    for(int i=0; i<N; i++){
        if(V[i] - C[i] > 0){
            reward += V[i] - C[i];
        }
    }
    cout << reward << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x,y;

    for(int i=0;;i++){
       cin>>x>>y;
    if(x<=y){
        if(x!=0 || y!=0)
            cout<< x << " " << y <<endl;
        else
            break;
    }
    else
        cout<<y<< " "<< x <<endl;
    }
        return 0;

}



Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    VT<string> S(N);
    REP(i, N) cin >> S[i];
    map<char, VPII> mp;
    REP(i, N) REP(j, N) {
        mp[S[i][j]].EB(MP(i, j));
    }
    LL ans = 0;
    map<int, int> cnt;
    REP(i, N) REP(j, N) cnt[j - i]++;
    FORE(e, cnt) {
        bool valid = true;
        REP(i, N) REP(j, N) {
            int ii = (j + e.first + N) % N;
            int jj = (i - e.first + N) % N;
            //cout << i << " " << j << " " << ii << " " << jj << " "<< S[i][j] << " " << S[ii][jj] << endl;
            valid &= (S[i][j] == S[ii][jj]);
        }
        //cout<<endl;
        ans += valid * e.second;
    }
    cout << ans << endl;
}


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

#define INF 1001001001
int dp[3005][3005];//sがi文字、tがj文字の時の最長文字列の長さ

int main(){
  string s,t;
  
  cin >> s >> t;
  for(int i=0;i<s.length();i++){
    for(int j=0;j<t.length();j++){
      if(s[i]==t[j])dp[i+1][j+1]=dp[i][j]+1;
      else{
        if(dp[i+1][j]>dp[i][j+1])dp[i+1][j+1]=dp[i+1][j];
        else dp[i+1][j+1]=dp[i][j+1];
      } 
    }
  }

  // for(int i=0;i<=s.length();i++){
  //   for(int j=0;j<=t.length();j++){
  //     printf("%2d ", dp[i][j]);
  //   }
  //   cout << endl;
  // }

  // cout << "ans:" << dp[s.length()][t.length()] << endl;
  int lenans=dp[s.length()][t.length()];
  int lens=s.length(), lent=t.length();
  string ans;
  while(lenans>0){
    if(dp[lens][lent]!=dp[lens][lent-1]&&dp[lens][lent]!=dp[lens-1][lent]){
      ans = s[lens-1] + ans;
      lenans--;lens--;lent--;
      // cout << lens << lent << lenans << ans << endl;
    }
    else if(dp[lens][lent-1]>dp[lens-1][lent]){
      lent--;
      // cout << lens << lent << lenans << ans << endl;
    }else{
      lens--;
      // cout << lens << lent << lenans << ans << endl;
    }
  }
  
  cout << ans;

  return 0;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'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'};

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

int main(){
    ll x, y; cin >> x >> y;
    ll ans = abs(abs(x) - abs(y));
    if(x > 0 && x > y){
        if(y <= 0){
            ans += 1;
        }else{
            ans += 2;
        }
    }else if(x < 0){
        if(y > 0){
            ans += 1;
        }else if(x > y){
            ans += 2;
        }
    }else if(x == 0 && y < 0){
        ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/// Updated! https://www.youtube.com/watch?v=U07_n9xGIlM
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define dbug printf("I am here\n");
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int maxn = 2e5+100;

const ll inf = 1e18;

int a[33];

int main()
{
    fast;
    int n; cin >> n;
    string s , s2;
    cin >> s >> s2;

    for(int i = 0; i<n; i++){
        cout << s[i] << s2[i];
    }

    return 0;
}
/*



*/



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef pair<int,int> P;

P ps[1<<20];

int main() {
	int x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	int n;cin>>n;
	int m=0;
	if (x1>x2) {
		swap(x1,x2);
		swap(y1,y2);
	}
	for(int i=0; i<n; ++i) {
		int x,y;cin>>x>>y;
		if (x<x1 && x<x2) continue;
		if (x>x1 && x>x2) continue;
		if (y<y1 && y<y2) continue;
		if (y>y1 && y>y2) continue;
		ps[m++] = {x,y};
	}
	n=m;
	sort(ps,ps+n);
	vector<int> st;
	for(int i=0; i<n; ++i) {
		int y = ps[i].second;
		if (y1>y2) y=-y;
		auto it = lower_bound(st.begin(), st.end(), y);
		if (it == st.end()) {
			st.push_back(y);
		} else {
			*it = y;
		}
	}
//	cout<<st.size()<<'\n';
	int d = st.size();
	int d0 = 1+min(abs(x2-x1), abs(y2-y1));
	double dist = 0;
	if (d == d0) {
		dist += (d-1) * (0.5 * M_PI * 10 - 20);
		dist += M_PI * 10 - 20;
	} else {
		dist += d * (0.5 * M_PI * 10 - 20);
	}
	dist += 100.0 * (abs(x2-x1) + abs(y2-y1));
	cout<<fixed<<setprecision(20)<<dist<<'\n';
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
signed main(){
	string s;
	cin>>s;
	ll n=s.size();
	ll cnt=0,ans=0;
	rep(i,n){
		if(s[i]=='A')cnt++;
		else if(s[i]=='B'&&s[i+1]=='C'){
			ans+=cnt;
			i++;
		}
		else cnt=0;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
int main()
{
    int n, d;
    cin >> n >> d;
    cout << n / (2 * d + 1) + (n % (2 * d + 1) != 0) << endl;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll r1,c1,r2,c2;
ll mod=1000000007,ans;
ll fac[2000010],popo[2000010];
ll po(ll x,ll num)
{
    if(popo[x])
    {
        return popo[x];
    }
    ll xx=fac[x];
    if(num==0)
    {
        return 1;
    }
    ll ret=1;
    if(num%2)
    {
        ret*=xx;
    }
    ll ret2=po(x,num/2);
    ret*=ret2;
    ret%=mod;
    ret*=ret2;
    ret%=mod;
    return popo[x]=ret;
}
ll com(int i,int j)
{
    ll ret=1;
    ret*=fac[i];
    ret%=mod;
    ret*=po(j,mod-2);
    ret%=mod;
    ret*=po(i-j,mod-2);
    ret%=mod;
    return ret;
}
int main()
{
    scanf("%lld%lld%lld%lld",&r1,&c1,&r2,&c2);
    fac[0]=1;
    for(ll i=1;i<=r2+c2+1;i++)
    {
        fac[i]=fac[i-1]*i;
        fac[i]%=mod;
    }
    for(int i=c1;i<=c2;i++)
    {
        ans+=com(r2+i+1,i+1);
        ans-=com(r1+i,i+1);
        ans+=mod;
        ans%=mod;
    }
    printf("%lld",ans);
}

Measured memory_bytes: 25344
#include <stdio.h>
#include <math.h>

int man(int x1,int y1,int x2,int y2) {
	return abs(x1-x2)+abs(y1-y2);
}

int main(void) {
	int n,m;
	int a[50],b[50],c[50],d[50];
	
	scanf("%d %d",&n,&m);
	for (int i = 0;i < n;i++) {
		scanf("%d %d",&a[i],&b[i]);
	}
	for (int j = 0;j < m;j++) {
		scanf("%d %d",&c[j],&d[j]);
	}
	
	for (int i = 0;i < n;i++) {
		int minc = 1;
		int min = man(a[i],b[i],c[0],d[0]);
		for (int j = 1;j < m;j++) {
			int tmp = man(a[i],b[i],c[j],d[j]);
			if (min > tmp) {
				min = tmp;
				minc = j+1;
			}
		}
		printf("%d\n",minc);
	}
	
	return 0;
}


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

using namespace std;
typedef long double ll;
const ll eps = 0.0000001;

ll getExpectation( );
void solve();

int main(void) {

	solve();
	return 0;

}

void solve() {

	int t;
	ll emax = -1.0;
	
	cin >> t;

	for (int i = 0; i < t; i++)
		emax = max(emax, getExpectation());

	if (emax > getExpectation() + eps)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return;
	
}

ll getExpectation() {

	int n, m;
	ll e = 0.0;
	ll rsum = 0.0;
	
	cin >> n >> m;
	double v, r;

	for (int i = 0; i < m; i++) {
		cin >> v >> r;
		rsum += r;
		e += r * v;
	}

	return e / rsum;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

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;
}
template<class T>inline int cmp(vector<T>&v,T &a){
	return lower_bound(all(v),a)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,A[200005];
int mx1,mx2;
signed main(){
	cin>>N;
	rep(i,N){
		cin>>A[i];
		if(!chmax(mx1,A[i]))chmax(mx2,A[i]);
		/*if(mx1<A[i])mx1=A[i];
		else if(mx2<=A[i])mx2=A[i];*/
	}
	rep(i,N){
		cout<<(mx1==A[i]?mx2:mx1)<<"\n";
	}
}


Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int n0 = 2e5 + 123;
const ll t = 1e9;
ll n, a[n0];
int b[n0], c[n0], cnt[20][45];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	cin >> n;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ld x;
		cin >> x;
		a[i] = round((ld)x * t);
		ll cur = a[i];
		while (cur % 2 == 0) {
			cur /= 2;
			b[i]++;
		}
		cur = a[i];
		while (cur % 5 == 0) {
			cur /= 5;
			c[i]++;
		}
		for (int j = max(0, 18 - c[i]); j < 20; j++) {
			for (int k = max(0, 18 - b[i]); k < 45; k++) {
				ans += cnt[j][k];
			}
		}
		cnt[c[i]][b[i]]++;
	}
	cout << ans;
}


Measured memory_bytes: 6856
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	multiset<int> s;
	for(int i = 0; i < (1 << n); i++){
		int tmp;
		cin >> tmp;
		s.insert(tmp);
	}
	auto itr = s.end();
	itr--;
	multiset<int> nows;
	nows.insert(*itr);
	s.erase(itr);

	for(int i = 0; i < n; i++){
		multiset<int> nexts;
		for(auto j = nows.begin(); j != nows.end(); j++){
			int now = *j;
			auto itr = s.lower_bound(now);
			if(itr == s.begin()){
				cout << "No" << endl;
				return 0;
			}
			itr--;
			nexts.insert(now);
			nexts.insert(*itr);
			s.erase(itr);
		}
		nows = nexts;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 24832
#include<bits/stdc++.h>
#define N 4010 
using namespace std;
string st;
int n,a[N],b[N],dp[N][N],mo=998244353;
int main(){
	cin>>st;n=st.length();
	for (int i=1;i<=n;i++)a[i]=st[i-1]-'0'+a[i-1],b[i]=b[i-1]+'2'-st[i-1];
	dp[0][0]=1;
	for (int i=0;i<=a[n];i++)
		for (int j=0;j<=b[n];j++)
			if (i<=a[min(n,i+j)]&&j<=b[min(n,i+j)])dp[i][j]=(dp[i][j]+(j?dp[i][j-1]:0)+(i?dp[i-1][j]:0))%mo;
	cout<<dp[a[n]][b[n]]<<endl;
	return 0;
}

Measured memory_bytes: 60544
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>

using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    int i=log10(n)+1;
    if(i==1)
        printf("%d\n",n);
    else if(i==2)
        printf("9\n");
    else if(i==3)
        printf("%d\n",n+9-100+1);
    else if(i==4)
        printf("%d\n",909);
    else if(i==5)
        printf("%d\n",909+n-10000+1);
    else if(i==6)
        printf("%d\n",90909);
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void){
    char s[5];
    scanf("%s", s);
    
    int ans=0;
    for(int i=1; i<3; i++){
        if(s[i-1]=='R' && s[i]=='R')ans++;
    }
    if(ans==0){
        if(s[0]=='S' && s[1]=='S' && s[2]=='S')ans=-1;
    }
    
    printf("%d\n", ans+1);
    return 0;
}


Measured memory_bytes: 1732
import java.math.BigDecimal;
import java.util.Scanner;

class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		double[] input = new double[6];
		double x,y;
		int i;
		
		while(scan.hasNextDouble()){
			for(i=0;i<6;i++){
				input[i] = scan.nextDouble();
			}
			
			x = (input[2]*input[4] - input[1]*input[5]) / (input[0]*input[4] - input[1]*input[3]);
			y = (input[2]*input[3] - input[0]*input[5]) / (input[1]*input[3] - input[0]*input[4]);
			
			BigDecimal bdxTmp = new BigDecimal(x);
			BigDecimal bdyTmp = new BigDecimal(y);
			BigDecimal bdx = bdxTmp.setScale(3,BigDecimal.ROUND_HALF_UP);
			BigDecimal bdy = bdyTmp.setScale(3,BigDecimal.ROUND_HALF_UP);
			
			String ansX,ansY;
			ansX = String.format("%.3f", bdx.doubleValue());
			ansY = String.format("%.3f", bdy.doubleValue());
			
			System.out.println(ansX +" "+ ansY);
		}
		scan.close();
	}
}

Measured memory_bytes: 20632
#include <iostream>
#include <fstream>
#include <vector>
#include <functional>
using ll = long long;

template<class Monoid>
class SegmentTree {
    using Func = std::function<Monoid(Monoid, Monoid)>;
    int N;

    std::vector<Monoid> segment;

    const Func op;
    const Monoid id;

    bool dirty_flag;
public:
    // id : op = max なら -INT_MAX
    SegmentTree(int n, const Func biop, const Monoid& M1)
    : op(biop), id(M1), dirty_flag(false) {
        N = 1;
        while(N < n) N <<= 1;
        segment.assign(2 * N, id);
    }

    void set(int k, const Monoid &a){
        dirty_flag = true;
        segment[k + N] = a;
    }

    void build() {
        for (int k = N - 1; k > 0; --k) {
            segment[k] = op(segment[2 * k], segment[2 * k + 1]);
        } // end k
        dirty_flag = false;
    }

    void update(int k, const Monoid& a){
        k += N;
        segment[k] = a;
        while(k >>= 1){
            segment[k] = op(segment[k*2], segment[k*2+1]);
        }
    }

    // -> op [a, b)
    Monoid query(uint a, uint b){
        if(dirty_flag) build();
        dirty_flag = false;
        Monoid L = id, R = id;
        for (a += N, b += N; a < b; a >>= 1, b >>= 1) {
            if(a & 1) L = op(L, segment[a++]);
            if(b & 1) R = op(segment[--b], R);
        } // end i
        return op(L, R);
    }

    Monoid operator[](const int &k) const{
        return segment[k + N];
    }
};
int main(){
    int n, q;
    while(std::cin >> n >> q){
        SegmentTree<int> sg(n, std::min<int>, INT32_MAX);
        while(q--){
            int com, x, y;
            std::cin >> com >> x >> y;
            if(com){
                std::cout << sg.query(x, y+1) << '\n';
            }
            else{
                sg.update(x, y);
            }
        }
    }

}






Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define int long long
using namespace std;

inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

inline bool read(int& a){
    int s=0,w=1;
    char ch=getchar();
    if(ch==EOF){
		return false;
	}
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=s*w;
    return true;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

struct SegTree{
	int l,r,maxv;
}tree[2400010];

int a[300010],f[300010];

void build(int x,int y,int i){
	tree[i].l=x;
	tree[i].r=y;
	tree[i].maxv=0;
	
	if(x==y)
		return;
		
	int mid=(x+y)>>1;
	build(x,mid,i<<1);
	build(mid+1,y,i<<1|1);
}

void change(int p,int x,int i){
	if(tree[i].l==tree[i].r){
		tree[i].maxv=max(tree[i].maxv,x);
		return;
	}
	
	if(tree[i<<1].r>=p)
		change(p,x,i<<1);
	else
		change(p,x,i<<1|1);
		
	tree[i].maxv=max(tree[i<<1].maxv,tree[i<<1|1].maxv);
}

int ask(int x,int y,int i){
	if(x<=tree[i].l&&tree[i].r<=y)
		return tree[i].maxv;
		
	int cnt=0;
	
	if(tree[i<<1].r>=x)
		cnt=ask(x,y,i<<1);
	if(tree[i<<1|1].l<=y)
		cnt=max(cnt,ask(x,y,i<<1|1));
		
	return cnt;
}

signed main(){
	int n,k,i,ans=0;
	n=read(),k=read();
	
	for(i=1;i<=n;i++)
		a[i]=read();
		
	build(1,300002,1);
	
	for(i=1;i<=n;i++){
		f[i]=ask(max(0LL,a[i]-k)+1,min(300000LL,a[i]+k)+1,1)+1;
		change(a[i]+1,f[i],1);
		ans=max(ans,f[i]);
	}
	
	writeln(ans);
	return 0;
}

Measured memory_bytes: 32904
#include <bits/stdc++.h>
using namespace std;
int a,b,c,x,y,sum1,sum2,sum3,sum;
int main() {
	cin>>a>>b>>c>>x>>y;
	
	sum1=a*x+b*y;
	
	sum2+=min(x,y)*c*2;
	if(x>=y)sum2+=(x-y)*a;
	else if(x<y)sum2+=(y-x)*b;
	
	sum3=max(x,y)*c*2;
	
	
	
	sum=min(sum1,sum2);
	sum=min(sum,sum3);
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

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)

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, M;
VI G[100011];
VI R[100011];
int color[100011];

void MAIN() {
    scanf("%d%d", &N, &M);
    REP (i, M) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	G[x].push_back(y);
	R[y].push_back(x);
    }

    LL ans = 0;
    memset(color, -1, sizeof color);
    VI ord;
    REP (i, N) if (color[i] == -1) {
	ord.clear();
	ord.push_back(i);
	color[i] = 0;
	for (int j=0; j<(int)ord.size(); j++) {
	    int v = ord[j];
	    EACH (e, G[v]) if (color[*e] == -1) {
		ord.push_back(*e);
		color[*e] = (color[v] + 1) % 3;
	    }
	    EACH (e, R[v]) if (color[*e] == -1) {
		ord.push_back(*e);
		color[*e] = (color[v] + 2) % 3;
	    }
	}

	LL b[3] = {};
	bool zet = false;
	REP (j, ord.size()) {
	    int v = ord[j];
	    b[color[v]]++;
	    EACH (e, G[v]) {
		if (color[*e] != (color[v] + 1) % 3) {
		    zet = true;
		}
	    }
	}

	if (zet) {
	    ans += (LL)ord.size() * ord.size();
	} else if (b[0] == 0 || b[1] == 0 || b[2] == 0) {
	    REP (j, ord.size()) {
		int v = ord[j];
		ans += G[v].size();
	    }
	} else {
	    REP (t, 3) ans += b[t] * b[(t+1)%3];
	}
    }



    printf("%lld\n", ans);
}

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



Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int mod = 1000000007;
struct Zp {
  ll x; // typedef long long ll;
  Zp(ll x=0):x((x%mod+mod)%mod){}
  Zp operator-() const { return Zp(-x);}
  Zp& operator+=(const Zp a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  Zp& operator-=(const Zp a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  Zp& operator*=(const Zp a) { (x *= a.x) %= mod; return *this;}
  Zp operator+(const Zp a) const { return Zp(*this) += a;}
  Zp operator-(const Zp a) const { return Zp(*this) -= a;}
  Zp operator*(const Zp a) const { return Zp(*this) *= a;}
  Zp pow(ll t) const {
    if (!t) return 1;
    Zp a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  Zp inv() const { return pow(mod-2);}
  Zp& operator/=(const Zp a) { return *this *= a.inv();}
  Zp operator/(const Zp a) const { return Zp(*this) /= a;}
};
istream& operator>>(istream& is, Zp& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const Zp& a) { return os << a.x;}



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

    int N, K;
    cin >> N >> K;
    vector<ll> A(N), neg, pos;
    REP(i, N) {
        cin >> A[i];
        if (A[i] >= 0)
            pos.emplace_back(A[i]);
        else
            neg.emplace_back(-A[i]);
    }
    if (K == N) {
        Zp res = 1;
        REP(i, N) {
            res *= A[i];
        }
        cout << res << endl;
        return 0;
    }
    if (pos.empty() && K % 2) {
        SORT(neg);
        Zp res = -1;
        REP(i, K) {
            res *= neg[i];
        }
        cout << res << endl;
        return 0;
    }
    SORTR(pos);
    SORTR(neg);
    Zp res = 1;
    if (K % 2) {
        res *= pos[0];
        pos.erase(pos.begin());
        --K;
    }
    vector<ll> two;
    for (int i = 0; i + 1 < SZ(pos); i += 2) {
        two.emplace_back(pos[i] * pos[i + 1]);
    }
    for (int i = 0; i + 1 < SZ(neg); i += 2) {
        two.emplace_back(neg[i] * neg[i + 1]);
    }
    SORTR(two);
    for (int i = 0; i < K / 2; ++i) {
        res *= two[i];
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 8092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int n,m;
    cin>>n>>m;
    int x,y;
    x=-1e6,y=1e6;
    for(int i=0;i<m;i++){
        int p,q;
        cin>>p>>q;
        x=max(p,x);
        y=min(y,q);
    }
    if(y-x+1>=0)
    cout<<y-x+1;
    else cout<<0;
}



Measured memory_bytes: 3620
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
ll n,ans=0;
void solve(ll v,bool sev,bool fiv,bool thr){
  if(v>n){
    return;
  }
  if(sev&fiv&thr){
    ans++;
  }
  v *= 10;
  solve(v+7,true,fiv,thr);
  solve(v+5,sev,true,thr);
  solve(v+3,sev,fiv,true);
}
signed main(){
  init_io();
  cin >> n;
  solve(0,false,false,false);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
int dp[100005], h[100005];

signed main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> h[i];
	}
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	for(int i = 3; i <= n; i++)
	{
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));	
	}	
	cout << dp[n];
}

Measured memory_bytes: 1792
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
//#include <set>
//#include <map>
//#include <iostream>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12

using namespace std;

int m;
int come[2050];
vector<int> graph[2050];

void init(void){
	int i;
	for(i=0;i<2050;i++){
		come[i]=0;
	}
}

int evensearch(int a,int d){
	int i;
	int sum=1;
	if(come[a]==1) return 0;
	come[a]=1;
	if(d==m/2) return 1;

	for(i=0;i<graph[a].size();i++){
		sum=sum+evensearch(graph[a][i],d+1);
	}

	return sum;
}

int oddsearch(int a,int b,int d){
	int i;
	int sum=1;
	if(come[a]==1||a==b) return 0;
	come[a]=1;
	if(d==m/2) return 1;

	for(i=0;i<graph[a].size();i++){
		sum=sum+oddsearch(graph[a][i],b,d+1);
	}

//	printf("%d->%d\n",a,sum);
	return sum;
}

int main(void)
{
	//変数の宣言
	int n;
//	int m;
	int a[2050];
	int b[2050];
//
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	ll int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;


	//データの読み込み
	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);

	for(i=0;i<n-1;i++){
		scanf("%d %d",&a[i],&b[i]);
//		scanf_s("%d %d",&a[i],&b[i]);
		graph[a[i]].push_back(b[i]);
		graph[b[i]].push_back(a[i]);
	}

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理
	if(m%2==0){
		for(i=1;i<=n;i++){
			init();
			temp=evensearch(i,0);
			ans=max(ans,temp);
		}
	}else{
		for(i=0;i<n-1;i++){
			init();
//			ans=max(ans,oddsearch(a[i],b[i],0)+oddsearch(b[i],a[i],0));
			temp=oddsearch(a[i],b[i],0);
			temp=temp+oddsearch(b[i],a[i],0);
			ans=max(ans,temp);

//			printf("(%d,%d)-->left->%d,right->%d\n",a[i],b[i],oddsearch(a[i],b[i],0),oddsearch(b[i],a[i],0));
		}
	}



	//	printf("計算部分終了\n");

	//出力

	printf("%d",n-ans);

	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'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'};
vector<char>AL(26);
AL = {'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'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int H, W;
	cin >> H >> W;
	vector<string>C(H);
	rep(i, H) {
		cin >> C[i];
	}
	rep(i, H) {
		rep(k, 2) {
			cout << C[i] << endl;
		}
	}
}

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

int main() {
	int n, k;
	string ans = "failed";
	cin >> n >> k;
	vector<string> hate_num(k);
	for (int i = 0; i < k; i++) {
		cin >> hate_num.at(i);
	}

	while (true) {
		for (int i = 0; i < k; i++) {
			if (to_string(n).find(hate_num.at(i)) != string::npos) {
				break;
			}
			if (i >= k - 1) {
				ans = to_string(n);
			}
		}
		if (ans == "failed") {
			n++;
		} else {
			break;
		}
	}

	cout << ans << endl;
}

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

int main() {
  string N;
  cin >> N;
  for (int i = 0; i < 3; i++) {
    if (N[i] == '7') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3644
import itertools
n = int(input())
s = input()

lst = []
for moji in s:
    if moji == 'E':
        lst.append(0)
    else:
        lst.append(1)

lst = list(itertools.accumulate(lst))

mae = 0
ans = 10**9
last = lst[-1]
for i in range(n):
    tmp = mae + (n-(i+1)) - (last-lst[i])
    ans = min(ans,tmp)
    mae = lst[i]
print(ans)

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

int main(){
  int n;
  int cnt[6]={0};
  cin >> n;
  for(int i=0;i<n;i++){
    double num; cin >> num;
    if(num < 165.0) cnt[0]++;
    else if(num < 170.0) cnt[1]++;
    else if(num < 175.0) cnt[2]++;
    else if(num < 180.0) cnt[3]++;
    else if(num < 185.0) cnt[4]++;
    else cnt[5]++;
  }
  for(int i=0;i<6;i++){
    cout << i+1 << ":";
    for(int j=0;j<cnt[i];j++){
      cout << "*";
    }
    cout << endl;
  }
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Array.Sort(A);
		Console.WriteLine(A[2] * 10 + A[1] + A[0]);
	}
	int[] A;
	public Sol(){
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define maxn 8005
#define ll long long

int n, m;

int main()
{
    cin >> n;
    if (n % 2 == 0)
        printf("%.9f\n", 0.5);
    else
        printf("%.9f\n", (n + 1) / 2.0 / n);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m; i>=n; i--)
#define INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
200
)");
#define cin input
#endif

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

	int ans = 0;

	for (int i=1; i<=n; i=i+2)
	{
		int count = 0;
		for (int j=1; j<=i;j=j+2)
		{
			if (i%j==0)
				count++;
		}
		if(count == 8)
			ans++;
	}
	cout << ans << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define f first
#define s second

#define all(s) s.begin(),s.end()
#define spresent(s,v) ((s).find(v)!=s.end())
#define present(s,v) (find(all(s),v)!=s.end())

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

typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<pi> vpi;


const int M = 1e9+7;

// C
// int main(){

// 	int n,a,b;
// 	cin>>n>>a>>b;
// 	int seq[1<<18];
// 	seq[0]=0;seq[1]=1;

// 	int po=1;
// 	for(int i=2;i<=18;++i){
// 		po<<=1;
// 		int f=po, b=po-1;
// 		//cout<<po<<" "<<b<<"\n";
// 		for(int j=b;j>=0;--j)
// 			seq[f++]=seq[j]+po;
// 	}

// 	for(int i=0;i<32;++i)
// 		cout<<seq[i]<<" ";
// 	cout<<"\n";

// 	int lim=1<<n;
// 	if(seq[0]==a && seq[lim-1]==b){
// 		cout<<"YES\n";
// 		for(int i=0;i<lim;++i)
// 			cout<<seq[i]<<" ";
// 		return 0;
// 	}
// 	if(seq[0]==b && seq[lim-1]==a){
// 		cout<<"YES\n";
// 		for(int i=lim-1;i>=0;--i)
// 			cout<<seq[i]<<" ";
// 		return 0;
// 	}

// 	for(int i=1;i<lim;++i){
// 		if(seq[i]==a && seq[i-1]==b){
// 			cout<<"YES\n";
// 			for(int j=i;j<lim;++j)
// 				cout<<seq[j]<<" ";
// 			for(int j=0;j<i;++j)
// 				cout<<seq[j]<<" ";
// 			return 0;
// 		}
// 	}

// 	for(int i=1;i<lim;++i){
// 		if(seq[i]==b && seq[i-1]==a){
// 			cout<<"YES\n";
// 			for(int j=i-1;j>=0;--j)
// 				cout<<seq[j]<<" ";
// 			for(int j=lim-1;j>=i;--j)
// 				cout<<seq[j]<<" ";
// 			return 0;
// 		}
// 	}

// 	cout<<"NO";

// 	return 0;

// }


// B
int pv[200005], c[200005], cur[200005], dp[200005];

ll calc(int i){
	if(i<=1)
		return 1;
	
	if(dp[i]==-1){
		ll temp1=0,temp2=1;
		if(pv[i]!=-1)
			temp1 =  calc(pv[i]);
		int j=i-1;
		while(j>=1 && c[j]==c[i])
			j--;
		dp[i]=(temp1+calc(j))%M;
	}
	return dp[i];
}


int main(){
	int n;
	cin>>n;
	
	memset(cur,-1,sizeof(cur));
	memset(dp,-1,sizeof(dp));


	for(int i=1;i<=n;++i){
		cin>>c[i];
		if(cur[c[i]]==-1){
			pv[i]=-1;
		}
		else if(cur[c[i]]==i-1){
			pv[i]=pv[cur[c[i]]];
		}
		else{
			pv[i]=cur[c[i]];
		}
		cur[c[i]]=i;
	}

	cout<<calc(n);

}

Measured memory_bytes: 9600
W, H, N = map(int, input().split())
b = c = 0
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        b = max(b, x)
    elif a == 2:
        W = min(W, x)
    elif a == 3:
        c = max(c, y)
    elif a == 4:
        H = min(H, y)
print(max(W-b, 0) * max(H-c, 0))

Measured memory_bytes: 3064
#include <iostream>
#include <string>

int main(){
    int a;
    std::string s;
    std::cin >> a >> s;

    if (a >= 3200)
    {
        std::cout << s << std::endl;
    }
    else
    {
        std::cout << "red" << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

vector<string> split(string v,char del){
	vector<string> numm;
	int head=0;
	for(int j = 0; j < v.size(); j++){
		if(v[j]==del){
			numm.push_back(v.substr(head,j-head));
			head=j+1;
		}
		else if(j==v.size()-1){
			numm.push_back(v.substr(head,j-head+1));
		}
	}
	return numm;
}

void solve(){
    string str;
    while(getline(cin,str)&&str!="#"){
        vector<string> ors=split(str,'|');
        bool f=false;
        for(int i = 0; i < ors.size(); i++){
            vector<string> ands=split(ors[i].substr(1,ors[i].size()-2),'&');
            bool ok[200];
            bool no[200];
            bool b=true;
            fill(ok,ok+200,false);fill(no,no+200,false);
            for(int j = 0; j < ands.size(); j++){
                char ch;
                if(ands[j][0]=='~'){
                    no[ands[j][1]]=true;
                    ch=ands[j][1];
                }
                else{
                    ok[ands[j][0]]=true;
                    ch=ands[j][0];
                }
                if(ok[ch]&&no[ch]){
                    b=false;
                    break;
                }
            }
            if(b){
                cout<<"yes"<<endl;
                f=true;
                break;
            }
        }
        if(!f){
            cout<<"no"<<endl;
        }
    }
}
int main(){

    solve();

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	
int N,F,B,Z,X;
scanf("%d",&N);
if(100<=N&&N<=999){
B=N/100;
Z=(N/10)%10;
X=N%10;
F=(X*100)+(Z*10)+B;
if(F==N)
cout<<"Yes";
else
cout<<"No";

}
}	

	
	
	
	
	


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define double long double
#define INF LLONG_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
string s;
int memo[100010],ans[100010];
signed main() {
	cin >> s;
	int rr = 0;
	rep(i, s.size() - 1) {
		if (s[i] == 'R')rr++;
		else if (i&&s[i-1]=='R') {
			memo[i - 1] = rr;
			rr = 0;
		}
	}
	if (s.back() == 'L')memo[s.size() - 2] = rr;
	rr = 0;
	for (int i = s.size() - 1; i > 0; i--) {
		if (s[i] == 'L')rr++;
		else if (i != s.size() - 1&&s[i+1]=='L') {
			memo[i + 1] = rr;
			rr = 0;
		}
	}
	if (s[0] == 'R' && s[1] == 'L')memo[1] = rr;
	rep(i, s.size() - 1) {
		if (s[i] == 'R' && s[i + 1] == 'L') {
			ans[i] = (memo[i] + 1) / 2 + memo[i + 1] / 2;;
			ans[i + 1] = memo[i] / 2 + (memo[i + 1] + 1) / 2;
		}
	}
	cout << ans[0];
	REP(i, s.size() - 1)cout << " " << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 2176
import scala.io.StdIn

object Main{
  def main(args: Array[String]){
    val num = StdIn.readLine().split(" ")
    var arr1 = Array.ofDim[Int](num(0).toInt, num(1).toInt)
    var arr2 = Array.ofDim[Int](1, num(1).toInt)
    var arr3 = Array.ofDim[Int](num(0).toInt, 1)

    for(i <- 0 until num(0).toInt){
      val line = StdIn.readLine().split(" ").map(_.toInt)

      for(j <- 0 until num(1).toInt){
        arr1(i)(j) = line(j)
      }
    }

    for(i <- 0 until num(1).toInt){
      arr2(0)(i) = StdIn.readLine().toInt
    }

    for(i <- 0 until num(0).toInt){
      for(j <- 0 until num(1).toInt){
        arr3(i)(0) += arr1(i)(j) * arr2(0)(j)
      }
    }

    for(i <- 0 until num(0).toInt){
      println(arr3(i)(0))
    }
  }
}

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

using namespace std;
int a[1000100];

int main()
{
    int x;  cin >> x;
    for(int i = 2;i<=2e5;i++){
        for(int j = i;j<=2e5;j+=i){
            a[j]++;
        }
    }
    for(int i = x ; i <= 2e5;i++)  if(a[i] == 1)  return cout << i , 0;
    return 0;
}


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

int n;
long long int ans=0;
vector<string> s;

string march = "MARCH";
int march_counts[5] = {0, 0, 0, 0, 0};

int main() {
	cin >> n;
	s.resize(n);
	for (int i = 0; i < n; ++i) cin >> s.at(i);

	for (int i = 0; i < n; ++i)
	{
		for (int c = 0; c < 5; ++c)
		{
			if (s.at(i).at(0)==march.at(c)) march_counts[c]++;
		}
	}

	for (int bit = 0; bit < (1<<5); ++bit)
    {
        if (__builtin_popcount(bit)!=3) continue;
        
        long long int m = 1;
        for (int i = 0; i < 5; ++i)
        {
        	if (bit & (1<<i)) {
        		m *= march_counts[i];
        	}
        }
        ans += m;
    }

    cout << ans << endl;
}

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


int main(){
	int x,n;
	cin >> x >> n;
	vector<int> vec(200,0);
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		vec.at(a)++;
	}
	int f=0;
	int i=0;
	while(f==0){
		if(vec.at(x-i)==0){
			cout << x-i;
			f++;
		}else if(vec.at(x+i)==0){
			cout << x+i;
			f++;
		}else{
			i++;
		}
	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
#define PI acos(-1)

const ll INF = 10010001010;

ll lcm(ll a,ll b)
{
    return a * b / __gcd(a, b);
}

typedef tuple<string, int, int> TUP;

bool tuplesort(const TUP &right, const TUP &left)
{
    if (get<0>(right) != get<0>(left))
    {
        return get<0>(left) < get<0>(right);
    }
    if (get<1>(left) != get<1>(right))
    {
        return get<1>(left) > get<1>(right);
    }
    return get<2>(left) < get<2>(right);
}

int main(){
    int A, B;
    cin >> A >> B;
    if((A+B)%2== 1){
        cout << "IMPOSSIBLE" << endl;
    }
    else{
        cout << (A + B) / 2 << endl;
    }
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String}, 1}) = map(parseInt, x)
ipad(x,y) = lpad(x,6,0)*lpad(y,6,0)

function main()
	n,m = readline() |> split |> parseMap
	py = Array{Int}(3,m)
	for i in 1:m
		py[1:2,i] = readline() |> split |> parseMap
		py[3,i] = i
	end
	py = sortcols(py, by = x->(x[1],x[2]))
	py[2,1] = 1
	for i in 2:m
		if py[1,i] != py[1,i-1]
			py[2,i] = 1
		else
			py[2,i] = py[2,i-1]+1
		end
	end
	py = sortcols(py, by = x->(x[3]))
	for i in 1:m
		println(ipad(py[1,i],py[2,i]))
	end
end
main()

Measured memory_bytes: 172028
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<i32>();
    let n = v[0] as usize;
    let m = v[1] as usize;
    let mut ab = read_vec2::<u64>(n as u32);

    ab.sort_by_key(|vv| vv[0]);
    let mut mrest = m as u64;
    let mut ans = 0;
    for i in 0.. {
        if mrest <= 0 {
            break;
        }

        let a = ab[i][0];
        let b = ab[i][1];

        if b >= mrest {
            ans += a * mrest;
            mrest = 0;
        } else {
            ans += a * b;
            mrest -= b;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 10492
if __name__ == '__main__':
    N = int(input())
    X = list(map(int, input().split()))
    X_sorted = sorted(X)

    median_candidates = X_sorted[(N // 2 - 1)], X_sorted[N // 2]
    for X_i in X:
        if X_i < median_candidates[1]:
            print(median_candidates[1])
        else:
            print(median_candidates[0])


Measured memory_bytes: 26772