akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            //  var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = long.Parse(Console.ReadLine());

            var S = new string[N];
            var dic = new Dictionary<string, long>();
            for (int i = 0; i < N; i++)
            {
                var tmp = Console.ReadLine().ToCharArray();
                Sort(tmp);
                var tmp2 = new string(tmp);

                if (dic.ContainsKey(tmp2))
                {
                    dic[tmp2]++;
                }
                else
                {
                    dic.Add(tmp2, 1);
                }
            }
            long ans = 0;
            foreach (var item in dic)
            {
                if(item.Value > 1)
                {
                    ans += item.Value * (item.Value - 1) / 2;
                }
            }


            Console.WriteLine(ans);
        }

        


    }

}


Measured memory_bytes: 32344
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,K;
    int H[214514];
    cin >> N >> K;
    REP(i,N){
        cin >> H[i];
    }
    sort(H,H+N);
    int Ans=0;
    REP(i,N-K){
        Ans+=H[i];
    }
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 1792
x = int(input())

# 素数
n = 10 ** 5 + 1000
primes = [True] * (n + 1)
p = 2
while p * p <= n:
    if primes[p]:
        for i in range(p * p, n + 1, p): # p*pスタートでいいのか
            primes[i] = False
    p += 1

primes[0], primes[1] = False, False

while True:
    if primes[x]:
        print(x)
        exit()
    x += 1

Measured memory_bytes: 64428
import sys
def main():
    input = sys.stdin.readline
    N, M, Q = map(int, input().split())
    abcd = [tuple(map(int, input().split())) for _ in range(Q)]
    stk = [[]]
    ans = 0
    while stk:
        A = stk.pop()
        if len(A) < N:
            t = A[-1] if len(A) > 0 else 0
            for i in range(t, M):
                stk.append(A + [i])
        else:
            t = 0
            for a, b, c, d in abcd:
                if A[b - 1] - A[a - 1] == c:
                    t += d
            ans = max(ans, t)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68644
package main

import (
	"bufio"
	"fmt"
	"log"
	"math/rand"
	"os"
	"strconv"
	"time"
)

func main() {
	log.SetFlags(log.Lshortfile)
	rand.Seed(time.Now().UnixNano())
	N := nextInt()
	x := make([]int, N)
	y := make([]int, N)
	h := make([]int, N)
	idx := 0
	cnt := 0
	for i := 0; i < N; i++ {
		x[i] = nextInt()
		y[i] = nextInt()
		h[i] = nextInt()
		if h[i] != 0 {
			idx = i
			cnt++
		}
	}
	if cnt == 1 {
		fmt.Println(x[idx], y[idx], h[idx])
		return
	}
	for cx := 0; cx <= 100; cx++ {
		for cy := 0; cy <= 100; cy++ {
			check := true
			hypothesis := abs(x[idx]-cx) + abs(y[idx]-cy) + h[idx]
			for i := 0; i < N; i++ {
				if h[i] == 0 {
					continue
				}
				h := abs(x[i]-cx) + abs(y[i]-cy) + h[i]
				if hypothesis != h {
					check = false
					break
				}
			}
			if check {
				trueHigh := abs(cx-x[idx]) + abs(cy-y[idx]) + h[idx]
				for i := 0; i < N; i++ {
					if h[i] == 0 {
						continue
					}
					if h[i] != max(trueHigh-abs(x[i]-cx)-abs(y[i]-cy), 0) {
						goto NEXT
					}
				}
				fmt.Println(cx, cy, trueHigh)
				return
			}
		NEXT:
		}
	}
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ull gcd(ull x,ull y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<ll,ll> x,pair<ll,ll> y)
{
    return x.first>y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[100005]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<100005;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(100005);i++){
//      if(prime[i]){
//          for(j=i*i;j<100005;j+=i){
//              prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(int &x,int &y){
    int temp=x;
    x=y;
    y=temp;
}
vector<ll> dp(100001);
void solve()
{   
    int n;
    cin>>n;
    vector<ll> h(n);
    for(auto &it :h)
        cin>>it;
    dp[n-1]=0;
    for(int i=n-2;i>=0;i--){
        if(h[i]>=h[i+1])
            dp[i]=dp[i+1]+1;
        else
            dp[i]=0;
    }
    ll ans=INT_MIN;
    for(int i=0;i<n;i++)
        ans=max(ans,dp[i]);
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}


Measured memory_bytes: 1792
while True:
    d = (1, 3, 6, 4, 5, 2)

    n = int(raw_input())
    if n == 0: break

    ans = d[0]
    for i in xrange(n):
        dire = raw_input()
        if dire == "North":
            d = d[5], d[1], d[4], d[3], d[0], d[2]
        elif dire == "East":
            d = d[3], d[0], d[1], d[2], d[4], d[5]
        elif dire == "West":
            d = d[1], d[2], d[3], d[0], d[4], d[5]
        elif dire == "South":
            d = d[4], d[1], d[5], d[3], d[2], d[0]
        elif dire == "Right":
            d = d[0], d[4], d[2], d[5], d[3], d[1]
        elif dire == "Left":
            d = d[0], d[5], d[2], d[4], d[1], d[3]
        ans += d[0]
    print ans

Measured memory_bytes: 4284
#include <bits/stdc++.h>
using namespace std;
int main() {
    int l ,r , d ;
    cin >> l >> r >> d ;

    int ans = 0;
    for ( int i = l ; i <= r ; i ++ )
    {
        if (i%d==0)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0 ;
}

Measured memory_bytes: 3564
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String str = sc.nextLine();
        
        for(int i = str.length()-1;i>=0;i--){
            System.out.print(str.charAt(i));
        }
        System.out.println();
        
    }
}

Measured memory_bytes: 17124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  long double r;
  cin >> r;
  cout << fixed << setprecision(8) << 2*r*(long double)(3.1415926535) << endl;
  return 0;
}

Measured memory_bytes: 3788
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    for(;;){
        int r, n;
        cin >> r >> n;
        if(r == 0)
            return 0;

        vector<int> height(50, 0);
        for(int i=0; i<n; ++i){
            int x1, x2, h;
            cin >> x1 >> x2 >> h;
            for(int j=x1; j<x2; ++j)
                height[j+25] = max(height[j+25], h);
        }

        double ret = DBL_MAX;
        for(int x=-r+1; x<r; ++x){
            int y = min(height[x+24], height[x+25]);
            ret = min(ret, y - sqrt((double)r * r - x * x) + r);
        }
        printf("%.10f\n", ret);
    }
}

Measured memory_bytes: 1228
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int H = sc.nextInt();
   int W = sc.nextInt();
   char[][] gr = new char[H][W];
   for(int i=0;i<H;i++)
   {
     gr[i] = sc.next().toCharArray();
   }
   char[][] gmap = new char[H+2][W+2];
   for(int i =0;i<H+2;i++) 
   {
     gmap[i][0]='.';
     gmap[i][W+1]='.';
   }
   for(int i =0;i<W+2;i++) 
   {
     gmap[0][i]='.';
     gmap[H+1][i]='.';
   }
   for(int i=0;i<H;i++)
   {
     for(int k =0;k<W;k++)
     {
       gmap[i+1][k+1]= gr[i][k];
     }
   }
   boolean flg = false;
   for(int i=0;i<H+2;i++)
   {
     for(int k=0;k<W+2;k++)
     {   
       if(gmap[i][k]=='#'&&gmap[i][k-1]=='.'&&gmap[i+1][k]=='.'&&gmap[i][k+1]=='.'&&gmap[i-1][k]=='.')
       {
         flg = true;
         break;
       }
     }
   }
   if(flg) System.out.println("No");
   else System.out.println("Yes");
 }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  cin >> N;
  
  vector<int> A(N);
  vector<int> B(N);
  
  int num;
  
  for(int i = 0;i < N;++i){
    cin >> A[i];
  }
  
  for(int i = 0;i < N;++i){
    num = A[i] - 1;
    B[num] = i + 1;
  }
  
  for(int i = 0;i < N;++i){
    cout << B[i] << " ";
  }
}

Measured memory_bytes: 1536
import bisect


n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))


cnt = 0
ru_a = [0] * (n + 1)
ru_b = [0] * (m + 1)
for i in range(n):
    ru_a[i + 1] = ru_a[i] + a[i]
for i in range(m):
    ru_b[i + 1] = ru_b[i] + b[i]

ans = 0
for i in range(n + 1):
    if ru_a[i] > k:
        continue
    ind = bisect.bisect_right(ru_b, k - ru_a[i])
    ans = max(i + ind - 1, ans)
print(ans)

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

constexpr ll mod=998244353;

ll dp[3030][6030][3];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,s; cin >> n >> s;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	dp[0][0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=s;j++){
			(dp[i+1][j][0]+=dp[i][j][0])%=mod;
			(dp[i+1][j][1]+=dp[i][j][0]+dp[i][j][1])%=mod;
			(dp[i+1][j][2]+=dp[i][j][0]+dp[i][j][1]+dp[i][j][2])%=mod;
			(dp[i+1][j+a[i]][1]+=dp[i][j][0]+dp[i][j][1])%=mod;
			(dp[i+1][j+a[i]][2]+=dp[i][j][0]+dp[i][j][1])%=mod;
		}
	}
	cout << dp[n][s][2] << endl;
}

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

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << '\n'
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << '\n'
#define space ' '
#define enter '\n'
using std::make_pair;

template < typename T >
inline T read( )
{
 register T x = 0;
 register char ch = gc( );
 register bool f = 0;
 while( !std::isdigit( ch ) )
 {
  f = ( ch == '-' );
  ch = gc( );
 }
 while( std::isdigit( ch ) )
 {
  x = x * 10 + ( ch - '0' );
  ch = gc( );
 }
 return f ? -x : x;
}

template < typename T >
void print( T x )
{
 if( x < 0 )
 {
  x = -x;
  pc( '-' );
 }
 if( x < 10 )
 {
  pc( x + 48 );
  return;
 }
 print < T > ( x / 10 );
 pc( x % 10 + 48 );
 return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
 using std::cin;
 using std::cout;
 using std::endl;
 using std::vector;
 using std::map;
 using std::queue;
 using std::deque;
 using std::set;
 using std::pair;
 const int Maxn = 1101;
 bool vis[ Maxn ];
 int n;
 vector < pair < int, double > > v[ Maxn ];
 pair < double, double > p[ Maxn ];
 double r[ Maxn ], dis[ Maxn ];
 inline void Add_Edge( int i, int j )
 {
  double val = sqrt( ( p[ i ].first - p[ j ].first ) * ( p[ i ].first - \
  p[ j ].first ) + ( p[ i ].second - p[ j ].second ) * ( p[ i ].second -\
  p[ j ].second ) ) - r[ i ] - r[ j ];
  v[ i ].push_back( make_pair( j, std::max( val, 0.0 ) ) );
  v[ j ].push_back( make_pair( i, std::max( val, 0.0 ) ) );
  return;
 }
 std::priority_queue < pair < double, int >, vector < pair < double, int > >, \
 std::greater < pair < double, int > > > Q;
 void Dijkstra( )
 {
  For( i, 1, n )
   dis[ i ] = 4e9;
  Q.push( make_pair( dis[ 0 ], 0 ) );
  while( !Q.empty( ) )
  {
   auto tp = Q.top( );
   Q.pop( );
   if( vis[ tp.second ] )
    continue;
   vis[ tp.second ] = 1;
   for( auto &to: v[ tp.second ] )
   {
    if( dis[ tp.second ] + to.second < dis[ to.first ] )
     Q.push( make_pair( dis[ to.first ] = dis[ tp.second ] + to.second, to.first ) );
   }
  }
  return;
 }
 void Fakemain( )
 {
  IOS;
  cin >> p[ 0 ].first >> p[ 0 ].second >> p[ 1 ].first >> p[ 1 ].second;
  cin >> n;
  For( i, 1, n )
   cin >> p[ i + 1 ].first >> p[ i + 1 ].second >> r[ i + 1 ];
  n++;
  For( i, 0, n )
   For( j, i + 1, n )
    Add_Edge( i, j );
  Dijkstra( );
  cout << setiosflags( std::ios::fixed );
  cout << std::setprecision( 10 ) << dis[ 1 ];
  return;
 }

} // namespace Solution

int main( int argc, char* argv[] )
{
 Solution::Fakemain( );
 return 0;
}

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

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int N;
    cin >> N;
    map<string, int> poll;

    REP (i, N) {
        string name;
        cin >> name;
        poll[name]++;
    }

    int top = 0;
    for (auto p : poll) {
        top = max(top, p.second);
    }

    for (auto p : poll) {
        if (p.second == top) {
            cout << p.first << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 17664
#include <stdio.h>
int main(int argc, char const *argv[]){
	int i;
	char s[4],c[3]={1,1,1};
	scanf("%s",s);
	for(i=0;i<3;i++){
		if(s[i]-'a'<0||s[i]-'a'>2)
			break;
		if(c[s[i]-'a']==0)
			break;
		c[s[i]-'a']=0;
	}
	if(i==3)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const ll MAXM=131072;
const ll MOD=1e9+7;

ll ksm(ll x,ll y){
    ll cnt=1;
    while(y){
        if(y&1) cnt=(1ll*cnt*x)%MOD;
        x=(1ll*x*x)%MOD;
        y>>=1;
    }
    return cnt;
}

ll n,x,y,z;
ll d[50][MAXM+100];

bool check(ll now){
    if((now&(1<<(x+y+z-1)))&&(now&(1<<(y+z-1)))&&(now&(1<<(z-1))))
        return 1;
    return 0;
}

int main(){
    scanf("%lld%lld%lld%lld",&n,&x,&y,&z);
    d[0][0]=1ll;
    ll ans=0ll;
    for(ll i=0;i<n;i++)
        for(ll j=0;j<MAXM;j++){
            if(!d[i][j]) continue;
            //prllf("%d %d\n",i,j);
            for(ll k=1;k<=10;k++){
                ll v=((j<<k)+(1<<(k-1)))%MAXM;
                if(check(v)){
                    ans+=d[i][j]*ksm(10,n-i-1);
                    ans%=MOD;
                }
                else{
                    d[i+1][v]+=d[i][j];
                    d[i+1][v]%=MOD;
                }
            }
        }
    printf("%lld\n",ans);
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

int main()
{
	ll n, m;
	cin >> n >> m;

	ll p[m];
	string s[m];
	ll cntWa[n] = {};
	ll ans[n] = {};

	rep(i, m)
	{
		cin >> p[i] >> s[i];
	}

	ll ac = 0;
	ll wa = 0;
	rep(i, m)
	{

		if (s[i] == "WA")
		{
			cntWa[p[i] - 1]++;
		}
		else
		{
			if (ans[p[i] - 1] == 0)
			{
				ans[p[i] - 1] = 1;
				ac++;
				wa += cntWa[p[i] - 1];
			}
		}
	}

	cout << ac << " " << wa << endl;

	return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char a[2], b[2];

    scanf("%s%s", a, b);

    if(a[0] == 'H'){
        printf("%c\n", b[0]);
    }else{
        if(b[0] == 'H'){
            printf("D\n");
        }else{
            printf("H\n");
        }
    }

    return 0;
}

Measured memory_bytes: 1588
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        a: i64,
        b: i64,
    }
    if (a + b) % 2 == 0 {
        println! ("{}", (a + b) / 2);
    } else {
        println! ("IMPOSSIBLE");
    }
}

fn main() {
    run();
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		String x = "";
		int num1 = 0;
		int num2 = 0;
		
		for(int i = 0; i < S.length(); i++) {
			if((S.charAt(i) == 'A') || (S.charAt(i) == 'T') || (S.charAt(i) == 'G') || (S.charAt(i) == 'C')) {
				x += "a";
			} else {
				x += "b";
			}
		}
		
		for(int i = 0; i < S.length(); i++) {
			if(x.charAt(i) == 'a') {
				num1++;
				if(i == (S.length() - 1)) {
					if(num2 < num1) {
						num2 = num1;
					}
				}
			} else {
				if(num2 < num1) {
					num2 = num1;
				}
				num1 = 0;
			}
		}
		
		System.out.println(num2);
		
	}
}


Measured memory_bytes: 23508
#include<cstdio>

const int MOD = 1000000007;
int f[200005], fi[200005];

int pow(int x, int y) {
  if (y == 0) {
    return 1;
  }
  if (y % 2 == 0) {
    return pow(1ll * x * x % MOD, y / 2);
  } else {
    return 1ll * x * pow(x, y - 1) % MOD;
  }
}

int nCr(int n, int r) {
  return ((1ll * f[n] * fi[r]) % MOD * fi[n-r]) % MOD;
}

int n, k;

int main() {
  f[0] = 1;
  for (int i = 1; i <= 200000; i++) {
    f[i] = 1ll * f[i - 1] * i % MOD;
  }
  fi[200000] = pow(f[200000], MOD - 2);
  for (int i = 199999; i >= 0; i--) {
    fi[i] = 1ll * fi[i + 1] * (i + 1) % MOD;
  }
  scanf("%d %d", &n, &k);
  if (k > n - 1) {
    k = n - 1;
  }
  int res = 0;
  for (int i = 0; i <= k; i++) {
    res += 1ll * nCr(n, i) * nCr(n - 1, i) % MOD;
    res %= MOD;
  }
  printf("%d\n", res);
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int a,b;
  string s,t;
  cin >> a >> s;
  if(a % 2 == 0){
    b = a / 2;
    if(s.substr(0,b) == s.substr(b,b)){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
while True:
    d, w = map(int, input().split())
    if d == 0:
        break
    area = []
    for _ in range(d):
        area.append(list(map(int, input().split())))
    v = 0
    for dp in range(1, d - 1):
        for wp in range(1, w - 1):
            for i in range(1, d - dp):
                for j in range(1, w - wp):
                    mawari = min(area[i - 1][j - 1:j + wp + 1] + area[i + dp][j - 1:j + wp + 1])
                    naka = 0
                    for ii in range(dp):
                        mawari = min(mawari, area[i + ii][j - 1], area[i + ii][j + wp])
                        naka = max([naka] + area[i + ii][j:j + wp])
                    if mawari > naka:
                        vn = 0
                        for ii in range(dp):
                            for jj in range(wp):
                                vn += mawari - area[i + ii][j + jj]
                        v = max(vn, v)
    print(v)


Measured memory_bytes: 5624
N = int(input())
A = list(map(int, input().split()))
A.sort()
now = [A[0], 1]
numberlist = []
for i in range(1, N):
	if now[0] == A[i]:
		now[1] += 1
	else:
		numberlist.append(now)
		now = [A[i], 1]
numberlist.append(now)
ans = 0
for i in range(0, len(numberlist)):
	if numberlist[i][1] < numberlist[i][0]:
		ans += numberlist[i][1]
	elif numberlist[i][0] < numberlist[i][1]:
		ans += numberlist[i][1] - numberlist[i][0]
print(ans)

Measured memory_bytes: 70696
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <cmath>
namespace mp = boost::multiprecision;

using cpp_dec_float = mp::number<mp::cpp_dec_float<20>>;

using namespace std;

int main() {
  static const double pi = 3.141592653589793;
  int A,B,H,M;
  cin>>A>>B>>H>>M;
  cpp_dec_float ans=sqrt(A*A+B*B-2*A*B*(cpp_dec_float)cos((cpp_dec_float)((((60*H+M)*11)%720)/360.00000)*pi));
  if (H==6&&M==0)
    cout << A+B << endl;
  else
    cout << fixed << setprecision(20) << ans << endl;


  
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
#define maxn 3009
#define LL long long
using namespace std;
int C[maxn][maxn],g[maxn][maxn];
inline int qpow(int y,int mod){
  LL ans=1,x=2;
  while(y){
    if(y&1) ans=ans*x%mod;
    x=x*x%mod,y>>=1;
  }return ans;
}
int main(){
  int n,ans=0,mod;
  scanf("%d%d",&n,&mod);
  for(int i=0;i<=n;i++)
    for(int j=0;j<=i;j++)
      C[i][j]=(j==0||j==i)?1:(C[i-1][j-1]+C[i-1][j])%mod;
  for(int i=0;i<=n;i++) g[i][0]=1;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=i;j++)
      g[i][j]=((LL)g[i-1][j]*(j+1)+g[i-1][j-1])%mod;
  for(int i=0;i<=n;i++){
    int tmp=0,K=qpow(qpow(n-i,mod-1),mod);
    for(int j=0;j<=i;j++)
      tmp=((LL)g[i][j]*K%mod*qpow((n-i)*j%(mod-1),mod)+tmp)%mod;
    tmp=(LL)tmp*C[n][i]%mod;
    if(i&1) ans=(ans-tmp+mod)%mod;
    else ans=(ans+tmp)%mod;
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 69632
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
using namespace std;
typedef pair<int, int> pii;

struct EDG {
	EDG(int a, int b, int c)
		: a(a), b(b), c(c) {}
	int a, b, c;
	void prt() { printf("%d %d %d\n", a, b, c); }
};

vector<EDG> EV;

int N;

int main() {
	cin >> N;

	for(int i = 1; i < 19; i++) {
		EV.eb(i, i+1, 0);
		EV.eb(i, i+1, 1<<(i-1));
	}
	for(int i = 19; i; i--) {
		for(int c = 1<<(i-1); c <= N;) {
			EV.eb(i, 20, N-c);
			N -= c;
		}
	}

	printf("20 %d\n", sz(EV));
	for(auto &v : EV) v.prt();
	return 0;
}

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

int main() {
  ll h, w;
  cin >> h >> w;

  ll x = (h + 1) / 2;

  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }

  ll ans;
  if (h % 2 == 0) {
    ans = x * w;
  } else {
    if (w % 2 == 0) {
      ans = (x + x - 1) * (w / 2);
    } else {
      ans = (x + x - 1) * (w / 2) + x;
    }
  }

  cout << ans << endl;
}

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

int n,m,s=1,cnt=0;
int head[200005],dis[100005],visited[100005],ans[100005];

struct edgde
{
	int next;
	int to;
	int dis;
}e[500005];

struct node
{
	int dis;
	int pos;
	bool operator < (const node x) const
	{
		return x.dis<dis;
	}
};

std::priority_queue<node> q;

inline void add_edge(int u,int v,int w)
{
	cnt++;
	e[cnt].to=v;
	e[cnt].dis=w;
	e[cnt].next=head[u];
	head[u]=cnt;
}

inline void dijkstra()
{
	dis[s]=0;
	q.push((node){0,s});
	
	while (!q.empty())
	{
		node tmp=q.top();
		q.pop();
		
		int x=tmp.pos;
		if (visited[x])  continue;
		visited[x]=1;
		
		for (int i=head[x];i;i=e[i].next)
		{
			int y=e[i].to;
			if (dis[y]>dis[x]+e[i].dis)
			{
				ans[y]=x;
				dis[y]=dis[x]+e[i].dis;
				if (!visited[y])  q.push((node){dis[y],y});
			}
		}
	}
}

signed main()
{
	cin>>n>>m;
	for (int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		add_edge(u,v,1);
		add_edge(v,u,1);
	}
	for (int i=1;i<=n;i++)  dis[i]=inf;
	
	dijkstra();
	
	for (int i=2;i<=n;i++)
	{
		if (ans[i]==0)  return cout<<"No"<<endl,0;
	}
	cout<<"Yes"<<endl;
	for (int i=2;i<=n;i++)  cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 17252
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, k := scanInt(), scanInt()
	p := scanInts(n)
	c := scanInts(n)

	ans := -1 << 60

	for i := 0; i < n; i++ {
		ss := make([]int, n)
		tt := make([]int, n)

		s := 0
		t := 0
		u := i

		for tt[p[u]-1] == 0 && p[u]-1 != i && t < k {
			u = p[u] - 1
			t++
			tt[u] = t
			s += c[u]
			ss[u] = s
			ans = max(ans, ss[u])
		}

		u = p[u] - 1
		cyc := t - tt[u] + 1
		tot := s - ss[u] + c[u]
		if tot > 0 {
			for j := 0; j < cyc; j++ {
				u = p[u] - 1
				ans = max(ans, ss[u]+tot*((k-tt[u])/cyc))
			}
		}
	}

	fmt.Fprintln(wr, ans)
}


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

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

  vector<int> card(n);

  for (int i = 0; i < n; i++) {
    cin >> card.at(i);
  }

  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());

  int alice_score = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      alice_score += card.at(i);
    } else {
      alice_score -= card.at(i);
    }
  }

  cout << alice_score << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const ll MOD=1000000007;

int main(){
    string S;cin>>S;
    int N=S.size()-1;
    ll ans=0;
    rep(bit,1<<N){
        ll now=0;
        rep(i,N+1){
            if(bit & (1<<(N-i))){
                ans+=now;
                now=S[i]-'0';
            }
            else now=now*10+S[i]-'0';
            if(i==N)ans+=now;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long int ll;

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)

int main() {
	
	fastIO
	ll n,temp,sum1=0,sum2=0;
	cin>>n;
	while(n--){
		cin>>temp;
      sum1+=temp;
      sum2+=temp*temp;
	}
 	cout<<(((sum1*sum1)-sum2)/2);
	return 0;
}

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert

const int MAX = 3005;
ll dp[MAX][MAX];

void solve(){
    mod =  998244353;
    ll n,s;
    cin>>n>>s;
    ll ans=0;
    ll a[n+1];
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        memcpy(dp[i],dp[i-1] ,sizeof dp[0]);
        (dp[i][a[i]] += i)%=mod;
        for(ll j=0 ; j+a[i] <= s ; j++){
            (dp[i][j+a[i]] += dp[i-1][j])%= mod;
        }
        ans += dp[i][s];
        ans %= mod;
    }
    cout << ans << endl;
}

int main(){
   
    IOS;
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 70656
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  std::vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int highest = h[0];
  int result  = 1;
  for (int hi = 1; hi < n; hi++) {
    if (h[hi] >= highest) {
      highest = h[hi];
      result++;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
import heapq

tmp = list(map(int, input().split()))
n = tmp[0]
m = tmp[1]
a = list(map(int, input().split()))

heapq.heapify(a)

cb = []
for j in range(m):
  tmp = list(map(int, input().split()))
  cb.append((tmp[1], tmp[0]))
cb.sort(reverse=True)

for j in range(m):
  if cb[j][0] < a[0]:
    break
  for k in range(cb[j][1]):
    if a[0] < cb[j][0]:
      heapq.heappop(a)
      heapq.heappush(a, cb[j][0])
    else:
      break

print(sum(a))  


Measured memory_bytes: 87832
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 100010
#define mod 1000000007
int n,a[N];
inline int qpow(int x,int y){
	int t=1;
	while(y){
		if(y&1) t=1ll*t*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return t;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i-=2){
		if((n&1) && (a[i]!=i-1 || a[i-1]!=i-1)){printf("0");return 0;}
		if(!(n&1) && (a[i]!=i-1 || a[i-1]!=i-1)){printf("0");return 0;}
	}
	if(n&1 && a[1]!=0){printf("0");return 0;}
	printf("%d\n",qpow(2,n/2));
	return 0;
}

Measured memory_bytes: 512
<?php
	fscanf(STDIN, "%d", $N);

	if($N < 4){
		echo "No";
		return;
	}

	if($N % 4 === 0 || $N % 7 === 0){
		echo "Yes";
		return;
	}

	$maxcnt = $N / 4;
	for ($i = 1; $i <= $maxcnt; $i++){
		$tmp = $N - $i * 4;

		if($tmp % 7 === 0){
			echo "Yes";
			return;
		}
	}

	echo "No";
?>

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


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


Measured memory_bytes: 3040
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int M = cin.nextInt();

        calc2(N, M);
    }

    void calc2(int N, long M)
    {
        long ans = 1;
        for (long i = 2; i * i <= M; i++)
        {
            if (M % i == 0)
            {
                int cnt = 0;
                while (M % i == 0)
                {
                    M /= i;
                    cnt++;
                }
                ans *= getC(N + cnt - 1, cnt);
                ans %= mod;
            }
        }
        if (M != 1)
        {
            ans *= getC(N, 1);
            ans %= mod;
        }
        Console.WriteLine(ans);
    }


    long getC(int a, int b)
    {
        long ans = 1;
        if (b > a / 2) return getC(a, a - b);
        long div = 1;
        for (int i = 0; i < b; i++)
        {
            ans *= a - i;
            ans %= mod;
            div *= i + 1;
            div %= mod;
        }
        ans *= powmod(div, mod - 2);
        return ans % mod;
    }

    long mod = 1000000007;
    long powmod(long a, long p)
    {
        long ans = 1;
        long mul = a;
        for (; p > 0; p >>= 1, mul = (mul * mul) % mod)
        {
            if ((p & 1) == 1) ans = (ans * mul) % mod;
        }
        return ans;
    }



}






class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, k;
    cin >> n >> k;
    vector<vector<ll>> g(n);
    rep(i, 0, n-1) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b); 
        g[b].push_back(a); 
    }

    vector<ll> seen(n, 0);
    queue<ll> que;
    seen[0] = 1;
    que.push(0);
    ll ans = k, cnt = 1;
    while(!que.empty()) {
        ll v = que.front();
        que.pop();

        for(auto nv : g[v]) {
            if (seen[nv] == 1) continue;
            seen[nv] = 1;
            ans *= max(0LL, (k-cnt));
            ans %= MOD;
            cnt++;
            que.push(nv);
        }
        cnt = 2;
    }
    cout << ans % MOD << endl;
}

Measured memory_bytes: 8180
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX / 10;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	reverse(s.begin(), s.end());
	bool f = true;
	for (int i = 0; i < n;) {
		if (i < (n - 4) && s.substr(i, 5) == "maerd") i += 5;
		else if (i < (n - 6) && s.substr(i, 7) == "remaerd") i += 7;
		else if (i < (n - 4) && s.substr(i, 5) == "esare") i += 5;
		else if (i < (n - 5) && s.substr(i, 6) == "resare") i += 6;
		else {
			f = false;
			break;
		}
	}
	if (f) cout << "YES" << endl;
	else  cout << "NO" << endl;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

  
  string s; cin>>s;
  int n = s.length();
  if (s[0] == s[n-1]) {
    if (n%2 == 0) {
      cout<<"First"<<endl;
    } else {
      cout<<"Second"<<endl;
    }
  } else {
    if (n%2 == 0) {
      cout<<"Second"<<endl;
    } else {
      cout<<"First"<<endl;
    }
  }

  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
typedef complex<double> P;
 
const double eps = 1e-8;
 
bool equals(double a, double b) {
  return abs(a-b) < eps;
}
 
double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}
 
double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}
 
int ccw(P p, P a, P b) {
  a -= p;
  b -= p;
  if(cross(a, b) > eps) return 1;
  if(cross(a, b) < -eps) return -1;
  if(dot(a, b) < -eps) return 2;
  if(norm(b) - norm(a) > eps) return -2;
  return 0;
}
 
P getCrossP(P a1, P a2, P b1, P b2) {
  P a = a2 - a1;
  P b = b2 - b1;
  return a1 + a * cross(b, b1 - a1) / cross(b, a);
}
 
vector<P> convex_cut(vector<P> ps, P p1, P p2, int dir = -1) {
  vector<P> v;
  for(int i = 0; i < ps.size(); ++i) {
    P a = ps[i];
    P b = ps[(i+1)%ps.size()];
    if(ccw(p1, p2, a) != dir) v.push_back(a);
    if(ccw(p1, p2, a)*ccw(p1, p2, b) == -1)
      v.push_back(getCrossP(a, b, p1, p2));
  }
  return v;
}
 
double getArea(const vector<P> &ps) {
  int n = ps.size();
  double res = 0;
  for(int i = 0; i < n; ++i) {
    res += cross(ps[i], ps[(i+1)%n]);
  }
  return res / 2.0;
}
 
int main() {
  for(int N, M; cin >> N >> M && (N|M); ) {
    vector<P> ps(N);
    for(int i = 0; i < N; ++i) {
      cin >> ps[i].real() >> ps[i].imag();
    }
    if(getArea(ps) < 0.0) reverse(ps.begin(), ps.end());
    vector<P> C(M);
    for(int j = 0; j < M; ++j) {
      cin >> C[j].real() >> C[j].imag();
    }
 
    for(int i = 0; i < M; ++i) {
      vector<P> g = ps;
      for(int j = 0; j < M; ++j) {
        if(i == j) continue;
        P p1, p2, base, base2;
        base = C[j] - C[i];
        base2 = P(-base.imag(), base.real());
        p1 = (C[i] + C[j]) / 2.0;
        p2 = p1 + base2;
        g = convex_cut(g, p1, p2);
      }
      printf("%.10f\n", getArea(g));
    }
 
  }
  return 0;
}

Measured memory_bytes: 1272
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<string>
#include<set>
#include<cmath>
#include<tuple>
#include<utility>
#include<functional>
#include<algorithm>

#define LL long long

using namespace std;

int l;

int main() {
	cin>>l;
	double edge=l/3.0;
	cout<<setprecision(10)<<edge*edge*edge<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    X -= 1;
    Y -= 1;

    vector<int> ret(N, 0);
    for(int i=0; i<N-1; ++i) {
        for(int j=i+1; j<N; ++j) {
            int m1 = j - i;
            int m2 = abs(X-i) + abs(Y-j) + 1;
            ret[min(m1, m2)]++;
        }
    }
    for(int i=1; i<N; ++i)
        cout << ret[i] << endl;

    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>();
	S[3]='8';

	out(S);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

#define NAME_LEN 11 // name に入る文字長の最大 + 1('\0')
// ノードを表す構造体
struct Node{
    char name[NAME_LEN];
    int data;
    struct Node *next;
};

typedef struct Node Node;
Node *create_node(const char *new_name, int new_data);
void clear_list(Node *head);
int pop_front(Node **head_pointer, Node **tail_pointer);
void push_back(Node **head_pointer, Node **tail_pointer, char *new_name, int new_data);
void print_list(const Node *head);


int main(void){
    Node *head = NULL;
    Node *tail = NULL; // tail -> next = NULL
    int n, q, time;
    char name[NAME_LEN];
    scanf("%d %d", &n, &q);
    for(int i=0; i<n; i++){
        scanf("\n%s %d", name, &time);
        // printf("name is %s, time is %d\n", name, time);
        push_back(&head, &tail, name, time);
    }

    int elapsed_time = 0;
    while(n > 0){
        if(head->data <= q){
            elapsed_time += head->data;
            printf("%s %d\n", head->name, elapsed_time);
            pop_front(&head, &tail);
            n--;
        }
        else{
            elapsed_time += q;
            // char name[NAME_LEN];
            strcpy(name, head->name);
            int data = head->data - q;
            pop_front(&head, &tail);
            push_back(&head, &tail, name, data);
        }
    }

    return 0;
}

// 新しいノードのメモリを確保する
Node *create_node(const char *new_name, int new_data){
    Node *new_node = (Node *)malloc(sizeof(Node));
    if (!new_node) {
        fprintf(stderr, "could not allocate a node.\n");
        exit(1);
    }
    strcpy(new_node->name, new_name);
    new_node->data = new_data;
    new_node->next = NULL;
    // static Node new_node = {new_name, new_data, NULL}; // 定数じゃない（と静的領域にいない）のでだめ
    return new_node;
}


// リストのメモリを解放する
void clear_list(Node *head){
    while(head){
        Node *target = head;
        head = head->next;
        free(target);
    }
}

// pop した数を返す
int pop_front(Node **head_pointer, Node **tail_pointer){
    // そもそも空
    if(*head_pointer == NULL){
        fprintf(stderr, "mou pop dekinai\n");
        return 0;
    }

    Node *temp_head = *head_pointer;
    int ans = temp_head->data;
    // head を次のやつに更新
    *head_pointer = (*head_pointer) -> next;
    // head = tail, すなわち head->next = NULL のときはどっちも NULL にしないとだめ
    if(*head_pointer == NULL){
        *tail_pointer = NULL;
    }
    free(temp_head);
    return ans;
    
}


void push_back(Node **head_pointer, Node **tail_pointer, char *name, int new_data){
    if(*tail_pointer == NULL){
        // 今はまだ空
        Node *new_node = create_node(name, new_data);
        *head_pointer = new_node;
        *tail_pointer = new_node;
        return;
    }

    Node *newnode = create_node(name, new_data);
    (*tail_pointer)->next = newnode;
    *tail_pointer = newnode;

    return;
}


// リストの要素を先頭から順に出力する
void print_list(const Node *head){
  while(head){
    printf("| %d |-> ", head->data);
    head = head->next;
  }
  printf("NULL\n");
}


Measured memory_bytes: 3272
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;

int main() {
	ll a, b, c;
	ll n, k;
	cin >> n >> k;
	a = k / 2;
	ll f = n / k;
	if (n % k >= a) f++;
	ll s = n / k;
	if (k % 2 == 1) f = 0;
	cout << f * f * f + s * s * s << endl;
	return 0;
}


Measured memory_bytes: 256