akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

const long long int INF = 1e14;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define llrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define llRep(i, n) for(ll i = 1; i <= (ll)(n); i++)

using namespace std;

bool vector_finder(std::vector<int> vec, int number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return true;
    }
  else { // 発見できなかったとき
    return false;
    }
}

char plusminus(bool plus){
    if (plus) return '+';
    else return '-';
}

int main(){
    string S;
    cin >> S;
    int A = stoi(S)/1000;
    int B = (stoi(S)/100)%10;
    int C = (stoi(S)/10)%10;
    int D = stoi(S)%10;

    int bcd[] = {B,C,D};

    int n = 3;

    // {0, 1, ..., n-1} の部分集合の全探索
    for (int bit = 0; bit < (1<<n); ++bit)
    {
        /* bit で表される集合の処理を書く */

        /* きちんとできていることを確認してみる */
        // bit の表す集合を求める
        vector<int> S;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
            }
        }

        int ans = A;
        for(int i=0; i<3; i++){
            if (vector_finder(S, i)){
                ans += bcd[i];
            }else{
                ans -= bcd[i];
            }
        }
        // cout << ans << endl;
        if (ans==7){
            cout << A;
            cout << plusminus(vector_finder(S, 0));
            cout << B;
            cout << plusminus(vector_finder(S, 1));
            cout << C;
            cout << plusminus(vector_finder(S, 2));
            cout << D;
            cout << "=7" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
	if (y == 0) 
		return 1; 
	ll p = power(x, y/2) % MOD; 
	p = (p * p) % MOD; 
  
	return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	cout<<fixed<<setprecision(9);
	ld ans=0;
	READV(N);
	FORI(i,0,N)
	{
		ld x;
		READ(x);
		ans=ans+(((ld)1)/x);
	}
	cout<<1/ans<<endl;

	return 0;
}

Measured memory_bytes: 256
from itertools import product
n=int(input())
ans=[]
for i in range(3,10):
    l=list(product(["3","5","7"],repeat=i))
    for j in l:
        if len(set(j))==3:
            ans.append(int("".join(list(j))))

ans.sort()
m=len(ans)
l,r=0,m-1
while l+1<r:
    k=(l+r)//2
    if ans[k]<n:
        l=k
    elif ans[k]>n:
        r=k
    else:
        l,r=k,k
        break
if ans[l]>n:
    print(l)
elif ans[r]<=n:
    print(r+1)
else:
    print(l+1)


Measured memory_bytes: 7284
#include <iostream>
using namespace std;
long long a = 0;
long long ans;

void dfs(long long n, int f) {
  if (n > a) return;
  if (f == 0b111) ans++;
  n *= 10;
  dfs(n + 3, f | 0b001);
  dfs(n + 5, f | 0b010);
  dfs(n + 7, f | 0b100);
}

int main() {
  cin >> a;
  dfs(0, 0);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    n = int(input())
    A = []
    for _ in range(n):
        A.append(int(input()))
    min_price = A[0]
    max_profit = A[1] - A[0]
    for i in range(1, n):
        x = A[i]
        max_profit = max(max_profit, x - min_price)
        min_price = min(min_price, x)
        # print('x {}, max {}, min {}'.format(x, max_profit, min_price))

    print(max_profit)



Measured memory_bytes: 13588
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int sn;
bool comp(const pair<pair<int, int>, int> &x, const pair<pair<int, int>, int> &y)
{
    if (x.first.first / sn != y.first.first / sn)
        return x.first.first / sn > y.first.first / sn;
    return x.first.second / sn > y.first.second / sn;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    cin >> n >> q;
    vector<int> tmp;
    rep(i, n)
    {
        int t;
        cin >> t;
        tmp.push_back(t);
    }

    vector<int> col(n + 1, 0);
    col[tmp[0]]++;
    int num = 1;
    int cl = 0, cr = 0;
    vector<pair<pair<int, int>, int>> query(q);
    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        query[i] = {{l, r}, i};
    }
    sn = 1;
    while (sn * sn <= n)
    {
        sn++;
    }
    sn--;
    sort(ALL(query), comp);

    VI ans(q, 0);
    rep(i, q)
    {
        int l = query[i].first.first;
        int r = query[i].first.second;

        if (r < cr)
        {
            while (r != cr)
            {
                col[tmp[cr]]--;
                if (col[tmp[cr]] == 0)
                    num--;
                cr--;
            }
        }
        if (r > cr)
        {
            while (r != cr)
            {

                cr++;
                if (col[tmp[cr]] == 0)
                    num++;
                col[tmp[cr]]++;
            }
        }

        if (l > cl)
        {
            while (l != cl)
            {
                col[tmp[cl]]--;
                if (col[tmp[cl]] == 0)
                    num--;
                cl++;
            }
        }

        if (l < cl)
        {
            while (l != cl)
            {
                cl--;
                if (col[tmp[cl]] == 0)
                    num++;
                col[tmp[cl]]++;
            }
        }
        ans[query[i].second] = num;
    }
    rep(i, q)
    {
        cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 15604
#include <stdio.h> 
 
 
 int main(){ 
     int i, j, k; 
     int n, x; 
     int count; 
 
 
     while(1){ 
         scanf("%d %d ", &n, &x); 
         if(n==0&&x==0)break; 
         count=0; 
         for(i=1;3*i+3<=x;i++){ 
             for(j=i+1;i+2*j+1<=x;j++){ 
                 for(k=n;k>j;k--){ 
                     if(x==i+j+k){ 
                         count++; 
                         break; 
                     }else if(x>=i+j+k){ 
                         break; 
                     } 
                 } 
             } 
         } 
         printf("%d\n", count); 
     } 
     return 0; 
 } 



Measured memory_bytes: 2052
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
ll n,m,a,b,c,ans,fa[10000],ra[10000];
vector<PP> v;
ll find(ll x){
    if(x==fa[x])return x;
    return fa[x]=find(fa[x]);
}
int uni(ll x,ll y){
    x=find(x),y=find(y);
    if(x==y)return 0;
    if(ra[x]<ra[y])swap(x,y);
    fa[y]=x;
    if(ra[x]==ra[y])ra[x]++;
    return 1;
}
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++)fa[i]=i;
    for(int i=0;i<m;i++){
        cin>>a>>b>>c;
        v.push_back({c,{a,b}});
    }
    sort(v.begin(),v.end());
    for(PP x:v){
        if(find(x.S.F)!=find(x.S.S)){
            ans+=x.F;
            uni(x.S.F,x.S.S);
        }
    }
    cout<<ans<<endl;
}



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


int main(){
int N,T,A;
cin>>N>>T>>A;
double H[N];
for(int i=0;i<N;i++){
  double x;
  cin>>x;
  H[i]=T-x*0.006;
}
double min=10000000;
int ans;
for(int i=0;i<N;i++){
  if(fabs(H[i]-A)<min){
    min=fabs(H[i]-A);
      ans=i+1;
  }
}
cout<<ans;
return 0;












}




Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  string str,qtr;
  int count=0;
 cin>>str>>qtr;

 int len=str.size();

for(int i=0;i<len;i++){

 if(str[i]==qtr[i]){

    count++;

}

}
cout<<count;


}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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 int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
   int x;
   cin >> x;

   if(x == 0) cout << 1 << "\n";
   else cout << 0 << "\n";

  return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

	vector<int> v(n);

	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}

	int count = 0;
	for(int i = 0; i < n; i++) {
		if(v[v[i]-1]-1 == i) {
			count++;
		}
	}

	cout << (count / 2) << "\n";

	return 0;
}


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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const long double PI = acos(-1);

long double ans;

int main(void) {
    long double r;
    cin >> r;

    printf("%.10Lf\n", 2*PI*r);

	return 0;
}


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

int n,sz,m,ans;
map<int,int> mp[100005],rmp;
vector<int> g[400005];
deque<int> q;
int d[400005];
int wst[400005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    {
        sz=1;
        for(int i=1;i<=m;i++){
            int a,b,c;
            cin>>a>>b>>c;
            if(mp[a].find(c)==mp[a].end()){
                mp[a][c]=++sz;
                rmp[sz]=a;
            }
            if(mp[b].find(c)==mp[b].end()){
                mp[b][c]=++sz;
                rmp[sz]=b;
            }
            g[mp[a][c]].push_back(mp[b][c]);
            g[mp[b][c]].push_back(mp[a][c]);
        }
    }
    memset(d,0x3f,sizeof(d));
    memset(wst,0x3f,sizeof(wst));
    wst[1]=1;
    for(map<int,int>::iterator it=mp[1].begin();it!=mp[1].end();it++){
        d[it->second]=1;
        q.push_back(it->second);
    }
    while(!q.empty()){
        int x=q.front();q.pop_front();
        for(int i=0;i<g[x].size();i++){
            int &y=g[x][i];
            if(d[y]>d[x]){
                d[y]=d[x];
                q.push_front(y);
            }
        }
        int nd=rmp[x];
        if(wst[nd]<=d[x]+1)continue;
        wst[nd]=d[x]+1;
        for(map<int,int>::iterator it=mp[nd].begin();it!=mp[nd].end();it++){
            int &y=it->second;
            if(d[y]>d[x]+1){
                d[y]=d[x]+1;
                q.push_back(y);
            }
        }
    }
    ans=0x3f3f3f3f;
    for(map<int,int>::iterator it=mp[n].begin();it!=mp[n].end();it++){
        ans=min(ans,d[it->second]);
    }
    cout<<(ans==0x3f3f3f3f?-1:ans)<<endl;

    return 0;
}

Measured memory_bytes: 67968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoders {
	class Program {
		static void Main(string[] args) {
			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = inputArray[0];
          			var K = inputArray[1];

			//答えの出力
			var ans = N==K ? "Yes":"No";
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// ある整数の先頭の桁を取得する
		/// </summary>
		/// <returns></returns>
		private static int getInitial(long n) {

			while (n >= 10) {
				n = n / 10;
			}
			return (int)n;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

Measured memory_bytes: 28260
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(int i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(int i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007
 

const int MAX_V = 100;

int d[MAX_V][MAX_V];
int V;
 
void warshall_floyd_init(){
	for(int i = 0; i < V; i++){
		for(int j = 0; j < V; j++){
			if(i == j) d[i][i] = 0;
			else d[i][j] = INF;
		}
	}
}

void warshall_floyd() {
	for (int k = 0; k < V; k++) {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}


int main(){
	int n;
	while(cin >> n && n > 0){
		V = 10;
		int a, b, c;
		warshall_floyd_init();
		V = 0;
		rep(i, n){
			cin>>a>>b>>c;
			d[a][b] = d[b][a] = c;
			if(V < a + 1) V = a + 1;
			if(V < b + 1) V = b + 1;
		}
		//cout<<V<<endl;
		warshall_floyd();
		int ans = INF, no =0;
		for(int i = 0; i < V; i++){
			int sum = 0;
			for(int j = 0; j < V; j++){
				sum += d[i][j];
			}
			//cout<<sum<<endl;
			if(sum < ans) ans = sum, no = i;
		}
		cout<<no<<" "<<ans<<endl;
	}
}

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

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

    int n;cin>>n;

    bool allzero=true;

    map<int,int> m;
    for(int i=0;i<n;i++)
    {
        int a;cin>>a;
        m[a]++;
        if(a>0)allzero=false;
    }

    if(allzero)
    {
        cout<<"Yes"<<"\n";
        return 0;
    }

    if(n%3==0)
    {
        if(m.size()==3)
        {
            vector<int> v;
            vector<int> x;
            for(auto mm:m)
            {
                v.push_back(mm.second);
                x.push_back(mm.first);
            }

            if(v[0]==v[1]&&v[1]==v[2])
            {
                if((x[0]^x[1]^x[2])==0)
                {
                    cout<<"Yes"<<"\n";
                    return 0;
                }
            }
        }
        else if(m.size()==2)
        {
            bool zero=false;
            vector<int> v;
            for(auto mm:m)
            {
                v.push_back(mm.second);
                if(mm.first==0)zero=true;
            }

            if(zero)
            {
                if(v[0]*2==v[1]||v[1]*2==v[0])
                {
                    cout<<"Yes"<<"\n";
                    return 0;
                }
            }
        }
    }

    cout<<"No"<<"\n";

    return 0;
}

Measured memory_bytes: 7216
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}
int a[300000];
signed main(){
    int n;
    cin >> n;
    int now = 0;
    REP(i,n){
        cin >> a[i];
        now ^= a[i];
    }
    REP(i,n){
        if(i == n-1){
            cout << (now^a[i]) << endl;
        }
        else{
            cout << (now^a[i]) << " ";

        }
    }


    return 0;
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> to(n), cost(n);
    rep(i, n - 1) {
        int a, b, w;
        cin >> a >> b >> w;
        a--;
        b--;
        to[a].push_back(b);
        cost[a].push_back(w);
        to[b].push_back(a);
        cost[b].push_back(w);
    }
    vector<int> ans(n, -1);
    queue<int> q;
    ans[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        rep(i, to[v].size()) {
            int u = to[v][i];
            int w = cost[v][i];
            if(ans[u] != -1) continue;
            ans[u] = (ans[v] + w) % 2;
            q.push(u);
        }
    }
    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 14532
n=int(input())
a=list(map(int,input().split()))

def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a

l=[a[0]]
for i in range(n):
    l.append(gcd(l[-1],a[i]))

print(l[-1])


Measured memory_bytes: 62704
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdio>
#define EPS (1e-10)

using namespace std;

class Point
{
  public:
  double x,y;

  Point(double x = -1,double y = -1): x(x),y(y){}

  Point operator + (Point p ){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}

  bool operator < (const Point& p) const
  {
    return x != p.x?x<p.x:y<p.y;
  }

  bool operator == (const Point& p)const
  {
    return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
  }
};

struct Segment
{
  Point p1,p2;
  Segment(Point p1 = Point(-1,-1),Point p2 = Point(-1,-1)):p1(p1),p2(p2){}
};

double dot(Point a,Point b)
{
  return a.x*b.x + a.y*b.y;
}
double cross(Point a,Point b)
{
  return a.x*b.y - a.y*b.x;
}

double norm(Point a)
{
  return a.x*a.x+a.y*a.y;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;



Point getCrossPoint(Point a1,Point a2,Point b1,Point b2)
{
  Point base = b2 - b1;
  double d1 = abs(cross(base,a1-b1));
  double d2 = abs(cross(base,a2-b1));
  double t = d1/(d1+d2);
  return a1+(a2-a1)*t;
}


int ccw(Point p0,Point p1,Point p2)
{
  Point a = p1-p0;
  Point b = p2-p0;
  if(cross(a,b) > 0)return COUNTER_CLOCKWISE;
  if(cross(a,b) < 0)return CLOCKWISE;
  if(dot(a,b) < 0)return ONLINE_BACK;
  if(norm(a) < norm(b))return ONLINE_FRONT;
  return ON_SEGMENT;
}

Point getCorssPoint(Segment s1,Segment s2)
{
  return getCrossPoint(s1.p1,s1.p2,s2.p1,s2.p2);
}

bool isIntersect(Point p1,Point p2,Point p3,Point p4)
{
  return (ccw(p1,p2,p3) * ccw(p1,p2,p4) <= 0 &&
          ccw(p3,p4,p1) * ccw(p3,p4,p2) <= 0 );
}

bool isIntersect(Segment s1,Segment s2)
{
return isIntersect(s1.p1,s1.p2,s2.p1,s2.p2);
}


double getArea(vector<Point>& vec)
{
  double sum = 0;
  for(int i=0;i<3;i++)
    sum += cross(vec[i],vec[(i+1)%3]);
  return fabs(sum)/2.0;
}



int main()
{

 int x1,y1,x2,y2;
  while(cin >> x1 >> y1 >> x2 >> y2,(x1|y1|x2|y2))
    {
      Point a(x1,y1);
      Point b(x2,y2);
      cin >> x1 >> y1 >> x2 >> y2;
      Point c(x1,y1);
      Point d(x2,y2);
      cin >> x1 >> y1 >> x2 >> y2;
      Point e(x1,y1);
      Point f(x2,y2);

      if(!isIntersect(a,b,c,d) || !isIntersect(c,d,e,f) || !isIntersect(e,f,a,b))
	{
	  cout << "kyo" << endl;
	  continue;
	}
      Point c1,c2,c3;
      c1 = getCrossPoint(a,b,c,d);
      c2 = getCrossPoint(c,d,e,f);
      c3 = getCrossPoint(e,f,a,b);
      vector<Point> vec;
      vec.push_back(c1),vec.push_back(c2),vec.push_back(c3);
      double area = getArea(vec);

      if(area >= 1900000)
	cout << "dai-kichi" << endl;
      else if(area >= 1000000)
	cout << "chu-kichi" << endl;
      else if(area >= 100000)
	cout << "kichi" << endl;
      else if(area > 0)
	cout << "syo-kichi" << endl;
      else 
	cout << "kyo" << endl;
    }
  return 0;
}

Measured memory_bytes: 1188
# Author: cr4zjh0bp
# Created: Wed Mar 11 15:11:47 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from curses.ascii import islower

S = list(ns())
N = len(S)
ccnt = 0
lcnt = 0

for i in range(1, N):
    if S[i] == 'C' and i < N - 1 and i > 1:
        ccnt += 1
    if islower(S[i]):
        lcnt += 1

if lcnt == N - 2 and ccnt == 1 and S[0] == 'A':
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int n,v[100000]={0},num[2][100001]={0};
bool all=false;
int maxn[2][2]={-99999},ma[2][2]={-99999};
void cmp(int k){
	for(int i=0;i<=100000;i++){
		if(num[k][i]>maxn[k][0])
			ma[k][0]=maxn[k][0],ma[k][1]=maxn[k][1],maxn[k][0]=num[k][i],maxn[k][1]=i;
		else if(num[k][i]>ma[k][0])
			ma[k][0]=num[k][i],ma[k][1]=i;
	}
	return;
}
int main(){
	cin>>n;
	cin>>v[0],num[0][v[0]]++;
	for(int i=1;i<n;i++){
		cin>>v[i];
		num[i%2][v[i]]++;
		if(v[i]!=v[i-1])
			all=true;
	}
	if(all==false){
		cout<<n/2;
		return 0;
	}
	cmp(0);
	cmp(1);
	if(maxn[0][1]!=maxn[1][1]){
		cout<<(n-maxn[0][0]-maxn[1][0]);
		return 0;
	}
	if(max(maxn[0][0]+ma[1][0],maxn[1][0]+ma[0][0])==maxn[0][0]+ma[1][0])
		cout<<(n-maxn[0][0]-ma[1][0]);
	else
		cout<<(n-maxn[1][0]-ma[0][0]);
	return 0;
} 

Measured memory_bytes: 1408
n=int(input())

max_n=10**4+5
ans=[0]*(max_n+1)
for x in range(1,105):
    for y in range(1,105):
        for z in range(1,105):
            total=x**2+y**2+z**2+x*y+y*z+z*x
            if total<=max_n:
                ans[total]+=1

for i in range(1,n+1):
    print(ans[i])


Measured memory_bytes: 69312
import itertools

from sys import stdin
N = int(stdin.readline().rstrip())

data = []
for _ in range(N):
    data.append((input()))

M = 0
A = 0
R = 0
C = 0
H = 0

for i in data:
    if i[0] == "M":
        M += 1
    
    if i[0] == "A":
        A += 1
    
    if i[0] == "R":
        R += 1
    
    if i[0] == "C":
        C += 1
    
    if i[0] == "H":
        H += 1

ans = 0
tmp = 1
for j in list(itertools.combinations([M,A,R,C,H],3)):
    for k in j:
        tmp = tmp * k
    ans += tmp
    tmp = 1
print(ans)

Measured memory_bytes: 9780
import itertools
import math
import fractions
import functools

n, m, x = map(int, input().split())

a_do = []
for i in range(n):
    a = list(map(int, input().split()))
    a_do.append(a)


nums = []
for i in range(n):
    nums.append(i)
minimum = 10**20

temp = []
for i in range(1, n+1):
    for v in itertools.combinations(nums, i): #参考書の選び方
        rikaido = [0] * (m+1)
        for j in range(len(v)):
            for k in range(m+1):
                rikaido[k] += a_do[v[j]][k]

        ok = True
        for j in range(1, m+1):
            if rikaido[j] < x:
                ok = False
        if(ok):
            minimum = min(minimum, rikaido[0])

#         temp.append(rikaido)

# minimum = 10**20
# for i in range(len(temp)):
#     for j in range(1, m+1):
#         if temp[i][j] < x:
#             break
#         minimum = min(minimum, temp[i][0])

if(minimum == 10**20):
    print(-1)
else:
    print(minimum)


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

#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vvvl vector<vector<vector<long long>>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector<string>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define eb emplace_back

const int MOD1=1000000007;
const int MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const int dx[]={0,1,0,-1,1,-1,1,-1};
const int dy[]={1,0,-1,0,1,1,-1,-1};

#define unless(a) if(!(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(n);i++)
#define bitrep(i,s,n) for(int i=(s);i<(1LL<<(n));i++)
#define bitcheck(bit,i) (bit)&(1LL<<(i))
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define Lin(s) getline(cin,(s))

void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}
long long cutup(long long a,long long b){return (a+b-1)/b;}
long long popcnt(long long a){return __builtin_popcountll(a);}
template<class T,class U> inline bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template<class T,class U> inline bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}

struct edge{long long to,cost;};
struct edge2{long long from,to,cost;};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string a,b,c;
    cin>>a>>b>>c;
    int A,B,C;
    A=Size(a);
    B=Size(b);
    C=Size(c);
    reverse(all(a));
    reverse(all(b));
    reverse(all(c));
    int now=0;
    while(A!=-1&&B!=-1&&C!=-1){
        if(now==0){
            now=a[A-1]-'a';
            A--;
        }else if(now==1){
            now=b[B-1]-'a';
            B--;
        }else{
            now=c[C-1]-'a';
            C--;
        }
    }
    if(A==-1){
        cout<<'A'<<endl;
    }else if(B==-1){
        cout<<'B'<<endl;
    }else{
        cout<<'C'<<endl;
    }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int date[13]={-1,31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
	//freopen("010.in","w",stdout);
	//freopen("008.out","w",stdout);
	int n,sum=0,ans=0;
	cin>>n;
	//a=3,b=5;
	//cout<<a<<" " <<b;
	int a[n+10];
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
		ans = max(ans,a[i]);
	}
	cout<< sum-ans/2;
}

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

int main()
{
    int A;
    int B;
    int X;

    cin >> A;
    cin >> B;
    cin >> X;

    if(A + B > X && A <= X) {
        cout << "YES" << endl;
    } else {
        cout << "NO"<< endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	int a[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			if (a[i][j + 1] - a[i][j] == a[i + 1][j + 1] - a[i + 1][j]) {
				continue;
			} else {
				cout << "No" << endl;
				return 0;
			}
			if (a[j + 1][i] - a[j][i] == a[j + 1][i + 1] - a[j][i + 1]) {
				continue;
			} else {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	int x,y;
	while(1){
		cin >> x >> y;
		if(!(x+y))break;
		if(x<y)
			cout << x << " " << y << endl;
		else
			cout << y << " " << x << endl;
	}
	return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec b = {INF};
    int tmp;
    rep (i, n - 1) {
        cin >> tmp;
        b.pb(tmp);
    }
    b.pb(INF);

    int ans = 0;
    rep (i, n) { ans += min(b[i], b[i + 1]); }
    print(ans);

    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 all(x) (x).begin(),(x).end()
typedef long long ll;
#define int ll
#define MOD 1000000007
int rec(int n){
	if(n==1)return 1;
	return ((n%MOD)*(rec(n-1)%MOD))%MOD;
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	if((n-m)!=0&&abs(n-m)!=1){cout<<0<<endl;return 0;}
	if(n==m)cout<<(rec(n)*rec(m))*2%MOD<<"\n";
    else cout<<(rec(n)*rec(m))%MOD<<"\n";
	return 0;
}


Measured memory_bytes: 1792
n,m = map(int,input().split())
l = sorted(list(map(int,input().split())))
l_dis = []
for i in range(m-1):
        l_dis_i = l[i+1]-l[i]
        l_dis.append(l_dis_i)
l_dis = sorted(l_dis)
ans = 0
for i in range(m-n):
        ans += l_dis[i]
print(ans)

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

int main() {
  long N, A, B;
  cin >> N >> A >> B;
  if (B < A || N == 1 && A != B) {
    cout << 0 << endl;
    return 0;
  }
  long mn = A * (N-1) + B;
  long mx = A + B * (N-1);
  cout << mx - mn + 1 << endl;
}

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

int a[100005];
map<int,int> ans;
map<int,int> vis;

int main(){
	int n,sum = 0;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		ans[a[i]]++;
	}
	for(int i = 1;i <= n;i++){
		if(ans[a[i]] % 2 != 0 && vis[a[i]] == 0) vis[a[i]] = 1,sum++;
	}
	cout << sum;
}

Measured memory_bytes: 9984
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;
int N;
int sum = 0;
vector<int> A;
vector<int> B;
vector<int> C;



int main() {
	int tmp;
	cin >> N;
	B.push_back(0);
	for (int i = 0;i < N - 1;i++) {
		cin >> tmp;
		B.push_back(tmp);
	}
	B[0] = B[1];
	B.push_back(tmp); // 最後は同じ

	for (int i = 1;i <= N;i++) {
		sum += min(B[i - 1], B[i]);
	}
	cout << sum;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int X, Y;
  cin >> X >> Y;

  for (int i = 0; i <= X; i++)
  {
    for (int t = 0; t <= X; t++)
    {
      if(i * 2 + t * 4 == Y && i + t == X){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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

#define IN inline
#define CO const
typedef long long int64;

template<class T> IN T read(){
	T x=0,w=1;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-') w=-w;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*w;
}
template<class T> IN T read(T&x){
	return x=read<T>();
}
#define popcount __builtin_popcount

CO int N=2e5+10;
int f[N];
char str[N];
int bas[2][N],pre[2][N],suf[2][N];

int main(){
	int n=read<int>();
	for(int i=1;i<=n;++i) f[i]=f[i%popcount(i)]+1;
	scanf("%str",str+1);
	int cnt=count(str+1,str+n+1,'1');
	if(cnt==0){
		for(int i=1;i<=n;++i) puts("1");
		return 0;
	}
	if(cnt==1){
		for(int i=1;i<=n;++i){
			if(str[i]=='1') puts("0");
			else if(i<n) puts("1");
			else puts("2");
		}
		return 0;
	}
	bas[0][0]=1,bas[1][0]=1;
	for(int i=1;i<=n;++i)
		bas[0][i]=bas[0][i-1]*2%(cnt+1),bas[1][i]=bas[1][i-1]*2%(cnt-1);
	for(int i=1;i<=n;++i)
		pre[0][i]=(pre[0][i-1]*2+str[i]-'0')%(cnt+1),pre[1][i]=(pre[1][i-1]*2+str[i]-'0')%(cnt-1);
	for(int i=n;i>=1;--i)
		suf[0][i]=(suf[0][i+1]+(str[i]-'0')*bas[0][n-i])%(cnt+1),suf[1][i]=(suf[1][i+1]+(str[i]-'0')*bas[1][n-i])%(cnt-1);
	for(int i=1;i<=n;++i){
		if(str[i]=='0'){
			int rem=((int64)pre[0][i-1]*bas[0][n-i+1]+bas[0][n-i]+suf[0][i+1])%(cnt+1);
			printf("%d\n",f[rem]+1);
		}
		else{
			int rem=((int64)pre[1][i-1]*bas[1][n-i+1]+suf[1][i+1])%(cnt-1);
			printf("%d\n",f[rem]+1);
		}
	}
	return 0;
}


Measured memory_bytes: 9440
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;

int n, m, q, comp;
int par[100100];

void init() {
    for (int i=0;i<n;i++) par[i] = i;
}
int fin(int a) {
    return par[a] = (par[a]==a?a:fin(par[a]));
}
void uni(int a, int b){
    a = fin(a); b = fin(b);
    if (a==b) return;
    comp--;
    par[fin(a)] = fin(b);
}
void pung() {
    puts("No");
    exit(0);
}
void print(bool t) {
    puts(t?"Yes":"No");
    exit(0);
}

int main() {
    scanf("%d%d%d",&n,&m,&q);
    init(); comp = n;
    vector<pii> vec;
    for (int i=0;i<q;i++) {
        int a, b, c;
        scanf("%d%d%d",&a,&b,&c);
        if (c==0) uni(a,b);
        else {
            vec.push_back({a,b});
        }
    }
    for (pii &v : vec) {
        if (fin(v.first)==fin(v.second)) pung();
    }
    if (comp==1) {
        print(m==n-1);
    }
    if (comp==2) {
        print(vec.empty());
    }
    if (vec.empty()) {
        print(m<=n-comp+1LL*comp*(comp-1)/2);
    }
    print(n<=m&&m<=n-comp+1LL*comp*(comp-1)/2);

	return 0;
}


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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

string s;
int l;

void init()
{
	cin >> s;
	reverse(all(s));
	l = s.length();
}

bool ch(int& pos, string t)
{
	int tl = t.length();
	rep(i, tl) {
		if (s[pos+i] != t[i]) return false;
	}
	pos += tl;
	return true;
}

bool culc(int& pos)
{
	string S[] = {"resare", "esare", "remaerd", "maerd"};
	if (pos == l) return false;
	rep(i, 4) {
		if (ch(pos, S[i])) return true;
	}
	return false;
}

void solve()
{
	int pos = 0;
	while (culc(pos));
	PRINT(pos == l);
}



Measured memory_bytes: 512
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int n,i,j,sum,h,c,t[25][2];
 	
 while(1){
   cin>>n;
   if(n==0)break;

   for(i=0;i<n;i++){
     cin>>t[i][0]>>t[i][1];
   }

   for(i=0;i<n-1;i++){
     for(j=i;j<n;j++){    
       if(t[i][1]>t[j][1]){
	 c=t[j][1];
	 t[j][1]=t[i][1];
	 t[i][1]=c;
	 c=t[j][0];
	 t[j][0]=t[i][0];
	 t[i][0]=c;
       }
     }
   }
 


   sum=0;
   h=0;
   for(i=0;i<n;i++){
     sum+=t[i][0];
     if(t[i][1]<sum){h=0;break;}
     if(i==n-1)h=1;   
   }
   if(h)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
 }

return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000000000LL;
const int MAX=100001;
const double EPS=1e-10;
ll up(ll a,ll b){
    if(a%b==0){
        return a/b;
    }else{
        return a/b+1;
    }
}
int main(){
    int k;
    cin>>k;
    ll a[100010];
    for(int i=0;i<k;i++){
        cin>>a[i];
    }
    ll l=2;ll r=2;
    for(int i=k-1;i>=0;i--){
        if(up(l,a[i])*a[i]>r){
            cout<<-1<<endl;
            return 0;
        }
        l=up(l,a[i])*a[i];
        r=(r/a[i])*a[i]+a[i]-1;
    }
    cout<<l<<" "<<r<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
using namespace std;
typedef long long ll;

#define _SI(arr) (sizeof(arr)/sizeof(arr[0])

int main() {
	double A, B;
	cin >> A >> B;

	cout << (A/B) << endl;
}

Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = input[0];
            int B = input[1];
            Console.WriteLine(A * B % 2 == 0 ? "No" : "Yes");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int N,A,B;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> A >> B;
	int ans = 0;
	if(A + B >= N){
		ans = A + B - N;
	}
	cout << min(A,B) << " " << ans << endl;

}

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

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
#define PI 3.14159265358979323846
const long long mod = 1000000007;

int main(){
    //    random_device rnd;
    //    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r;
    cin >> r;
    cout << pow(r,2) << endl;
}


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

using namespace std;

int main() {
  
    int N;
    cin >> N ;
    vector<int> heights(N);
    for(int i = 0; i < N;i++)
        cin >> heights[i];
    
    vector<long> dp(N,0);
    dp[1] = abs(heights[1] - heights[0]);
    for(int i = 2;i < N;i++){
        dp[i] = min( abs(heights[i] - heights[i-1]) + dp[i-1], abs(heights[i] - heights[i-2]) + dp[i-2]);
    }
    cout << dp[N-1] << endl;
    return 0;
    // EDABC
}




Measured memory_bytes: 3820
import sys
sys.setrecursionlimit(1000000000)

ii = lambda: int(input())
miis = lambda: map(int, input().split())
lmiis = lambda: list(miis())

def reachable_nodeset(start, inc):
    reachable = set()
    reachable.add(start)
    nodes = [start]

    while nodes:
        n = nodes.pop()
        for i in inc[n]:
            if i not in reachable:
                nodes.append(i)
                reachable.add(i)

    return reachable

def bellmanford(num, start, goal, edges):
    cost = [float('inf')] * num
    cost[start] = 0

    for _ in range(num):
        updated = False
        for a, b, c in edges:
            if cost[b] > cost[a] + c:
                cost[b] = cost[a] + c
                updated = True
        if not updated: break
    else:
        return -1

    return max(0, -cost[goal])

def solve():
    N, M, P = miis()
    to = [[] for _ in range(N)]
    ot = [[] for _ in range(N)]
    edges = []

    for _ in range(M):
        a, b, c = miis()
        a -= 1
        b -= 1
        c = -(c - P)

        to[a].append(b)
        ot[b].append(a)
        edges.append((a,b,c))

    reachableFromZero = reachable_nodeset(0, to)
    reachableToN = reachable_nodeset(N-1, ot)
    ok = reachableFromZero.intersection(reachableToN)

    edges = tuple((a,b,c) for a, b, c in edges if a in ok and b in ok)

    print(bellmanford(N, 0, N-1, edges))

if __name__ == '__main__':
    solve()

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

int check_palindrom(string s,long long f,long long l){
    long long i=f,j=l;
    
    while(i<=j){
        if(s[i]!=s[j]){
            return 0;
        }
        i++;
        j--;
    }
    
    return 1;
}

int main() {
	string s;
	cin>>s;
	
	long long l = s.length();
	
	if(check_palindrom(s,0,l-1)){
	    //cout<<"1"<<endl;
	    if(check_palindrom(s,0,((l-1)/2-1))){
	      //  cout<<"11"<<endl;
	        if(check_palindrom(s,((l+3)/2-1),l-1)){
	        //    cout<<"111"<<endl;
	            cout<<"Yes"<<endl;
	        }else{
	            cout<<"No"<<endl;
	        }
	    }else{
	        cout<<"No"<<endl;
	    }
	}else{
	    cout<<"No"<<endl;
	}
	
}


Measured memory_bytes: 256
S = input()
T = input()
from collections import defaultdict

dictS = defaultdict(str)
dictT = defaultdict(str)

for i in range(len(S)):
  
  if dictT[T[i]] and dictT[T[i]] != S[i]:
    print("No")
    exit()
  
  if dictS[S[i]] and dictS[S[i]] != T[i]:
    print("No")
    exit()


  dictS[S[i]] = T[i]
  dictT[T[i]] = S[i]

print("Yes")

Measured memory_bytes: 3812
import sys,bisect

input=sys.stdin.readline

N=int(input())
x=list(map(int,input().split()))
L=int(input())

doubling=[[-1 for i in range(N)] for j in range(20)]
backdoubling=[[-1 for i in range(N)] for j in range(20)]

for i in range(N):
    npos=x[i]+L
    index=bisect.bisect_right(x,npos)
    doubling[0][i]=index-1

for i in range(1,20):
    for j in range(N):
        doubling[i][j]=doubling[i-1][doubling[i-1][j]]

for i in range(N):
    npos=x[i]-L
    index=bisect.bisect_left(x,npos)
    backdoubling[0][i]=index

for i in range(1,20):
    for j in range(N):
        backdoubling[i][j]=backdoubling[i-1][backdoubling[i-1][j]]

def forward(num,start):
    for i in range(20):
        if num>>i &1==1:
            start=doubling[i][start]
    return start

def back(num,start):
    for i in range(20):
        if num>>i &1==1:
            start=backdoubling[i][start]
    return start


for _ in range(int(input())):
    a,b=map(int,input().split())
    a-=1;b-=1
    if b>=a:
        s=0
        e=N
        while e-s>1:
            test=(e+s)//2
            if forward(test,a)>=b:
                e=test
            else:
                s=test
        if forward(s,a)>=b:
            print(s)
        else:
            print(e)
    else:
        s=0
        e=N
        while e-s>1:
            test=(e+s)//2
            if b>=back(test,a):
                e=test
            else:
                s=test
        if b>=back(s,a):
            print(s)
        else:
            print(e)

Measured memory_bytes: 132212