akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
int main() {
    int n, k;
    int l[50];
    int sum = 0;

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

    sort(l, l+n);

    for (int i = 0; i < k; i++) {
        sum += l[n-i-1];
    }
    cout << sum << endl;
    return 0;
}


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

int main(){
  long N,P;cin>>N>>P;
  string S;cin>>S;
  if(P!=5&&P!=2){
    vector<long>C(P,0);//割った余りのカウント
    C[0]++;long ans=0;
    long x=0,d=1;
    for(long i=0;i<N;i++){
      x=(x+d*(S[N-1-i]-48))%P;
      ans+=C[x];
      C[x]++;
      d=d*10%P;
    }
    cout<<ans;
  }
  else{
    long ans=0;
    for(long i=N-1;i>=0;i--)if((S[i]-48)%P==0)ans+=(i+1);
    cout<<ans;
  }
}



Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int y, m, d;
  scanf("%d/%d/%d", &y, &m, &d);

  if(y < 2019 || (y == 2019 && m < 4) || (y == 2019 && m == 4 && d <= 30)){
    printf("Heisei\n");
  }
  else printf("TBD\n");

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)


int main(){

string S;
cin>>S;
string hhh(3,' ');
hhh[0]=S[0];
hhh[1]=S[1];
hhh[2]=S[2];

cout<<hhh<<endl;
}






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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		double t1 = 0;

		t1 = n/1.08;

		int t2 = (int)t1;
		int t3 = 0;
		int t4 = 0;

		if(t1-t2==0){
			System.out.println(t2);
		}else {
			t3 = t2 + 1;
			t4 = (int)(t3*1.08);
			if(t4==n) {
				System.out.println(t3);
			}else {
				System.out.println(":(");
			}
		}
	}

}


Measured memory_bytes: 21716
function Main(s) {
  var s = Number(s.split("\n")[0]);
  var l = Math.ceil(Math.sqrt(s));
  var b, f;
  var min = 12;
  for (var a = 1; a <= l; a++) {
    if (s % a === 0) {
      b = s / a;
      f = Math.max(String(a).length, String(b).length);
      min = f < min ? f:min;
    }
  }
  console.log(min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11724
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


def prepare_simple(n, mod=pow(10, 9) + 7):
    # n! の計算
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= mod
    fn = f

    # n!^-1 の計算
    inv = pow(f, mod - 2, mod)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= mod
        invs[m - 1] = inv
    return fn, invs


def prepare(n, mod=pow(10, 9) + 7):
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= mod
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, mod - 2, mod)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= mod
        invs[m - 1] = inv

    return factorials, invs


# 実装を行う関数
def resolve(test_def_name=""):
    x, y = map(int, input().split())

    all_move_count = (x + y) // 3

    x_move_count = all_move_count
    y_move_count = 0

    x_now = all_move_count * 2
    y_now = all_move_count

    canMake= False
    for i in range(all_move_count+1):
        if x_now == x and y_now == y:
            canMake = True
            break

        x_move_count -= 1
        y_move_count += 1
        x_now -= 1
        y_now += 1

    if not canMake:
        print(0)
        return

    fns, invs = prepare(all_move_count)
    ans = (fns[all_move_count] * invs[x_move_count] * invs[all_move_count - x_move_count]) % (pow(10, 9) + 7)

    print(ans)
    # fn, invs = prepareSimple(10)
    # ans = (fn * invs[3] * invs[10 - 3]) % (pow(10, 9) + 7)
    # print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3 3"""
        output = """2"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """2 2"""
        output = """0"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """999999 999999"""
        output = """151840682"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


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

ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }

using LL = long long;
using PII = pair<int, int>;

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

	string str;
	cin >> str;

	int n = size(str) + 1;
	vector<vector<int>> graph(n);
	vector<int> in(n);
	REP(i, n - 1) {
		if(str[i] == '<')
			graph[i].emplace_back(i + 1), in[i + 1]++;
		else
			graph[i + 1].emplace_back(i), in[i]++;
	}

	vector<int> ans(n);
	vector<int> Q;
	REP(i, n) if(in[i] == 0) {
		Q.emplace_back(i);
	}

	LL sum = 0;
	while(!Q.empty()) {
		int v = Q.back();
		Q.pop_back();
		sum += ans[v];
		for(int u : graph[v]) {
			ans[u] = max(ans[u], ans[v] + 1);
			if(--in[u] == 0)
				Q.emplace_back(u);
		}
	}

	cout << sum << "\n";
}


Measured memory_bytes: 32028
#! python3
# spreadsheet.py

r, c = [int(x) for x in input().split(' ')]

sheet = [[int(x) for x in input().split(' ')] for i in range(r)]
for i in range(r):
    sheet[i].append(0)
sheet.append([0 for i in range(c+1)])

for i in range(r):
    for j in range(c):
        sheet[i][c] += sheet[i][j]
        sheet[r][j] += sheet[i][j]
        sheet[r][c] += sheet[i][j]

for i in range(r+1):
    print(' '.join([str(x) for x in sheet[i]]))



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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int n,a,b,c,d;
string s;

bool solve(){
	int snk = a,fnk=b;
	if(c<d){
		while(1){
			if(fnk==d)
				break;
			if(s[fnk+1]=='.')
				fnk++;
			else if(s[fnk+2]=='.')
				fnk += 2;
			else
				return false;
		}
		while(1){
			if(snk==c)
				break;
			if(s[snk+1]=='.')
				snk++;
			else if(s[snk+2]=='.')
				snk += 2;
			else
				return false;
		}
	}else{
		while(1){
			if(s[fnk-1] == '.' && s[fnk+1] == '.')
				break;
			else if(s[fnk+1]=='.')
				fnk++;
			else if(s[fnk+2]=='.')
				fnk += 2;
			else
				return false;
		}
		while(1){
			if(snk==fnk-1)
				break;
			if(s[snk+1]=='.')
				snk++;
			else if(s[snk+2]=='.')
				snk += 2;
			else
				return false;
		}
		snk += 2;
		while(1){
			if(snk==c)
				break;
			if(s[snk+1]=='.')
				snk++;
			else if(s[snk+2]=='.')
				snk += 2;
			else
				return false;
		}
		while(1){
			if(fnk==d)
				break;
			if(s[fnk+1]=='.')
				fnk++;
			else if(s[fnk+2]=='.')
				fnk += 2;
			else
				return false;
		}
	}
	return true;
}

int main()
{
	cin>>n>>a>>b>>c>>d;
	a--;b--;c--;d--;
	cin>>s;
	s+="###";

	cout << (solve()?"Yes":"No")<<endl;


	return 0;
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<=n;++i)
    {
        int t=m*i;
        for(int j=0;j<=m;++j)
        {
            if(t+(n-(i<<1))*j==k)
            {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main()
{
  size_t k;
  cin >> k;
  vector<int64_t> v = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  for (size_t p = 0; v.size() < k; p++) {
    for (int i = -1; i <= 1; i++) {
      int d = v[p] % 10 + i;
      if (0 <= d && d <= 9) {
        v.push_back(v[p] * 10 + d);
      }
    }
  }
  cout << v[k - 1] << endl;
}


Measured memory_bytes: 1464
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
int arr[MAXX];
int arr2[MAXX];
void trozen()
{
    int n;
    cin>>n;
    rep(i,n)
        cin>>arr[i];
    bool flag=false;
    int i;
    int maxx=arr[0];
    for(i=1;i<n;i++)
    {
        if(arr[i]<maxx)
        {
            if(maxx-1!=arr[i])
                break;
        }
        else
            maxx=arr[i];
    }
    if(i==n)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


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

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> c[i][j];
    }
  }
  vector<int> a(3), b(3);
  a[0] = 0;
  for (int i = 0; i < 3; i++){
    b[i] = c[0][i];
  }

  for(int i = 1; i<3; i++){
    a[i] = c[i][0] - b[0];
  }
  bool ans = true;

  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      if (c[i][j] != a[i] + b[j]) ans = false;
    }
  }

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


Measured memory_bytes: 256
class SegmentTree1():
    """
    1-indexed Segment Tree
    """
    def __init__(self, n_, ele_id, op_func):
        self.n = 1 << (n_ - 1).bit_length()  # size
        self.data = [ele_id] * (2 * self.n)  # binary tree (1-indexed)
        self.ele_id = ele_id  # identity element
        self.op_func = op_func  # binary operation of monoid

    def __getitem__(self, i):
        return self.data[i + self.n]

    def build(self, data_init):
        for i in range(len(data_init)):
            self.data[i + self.n] = data_init[i]  # set data in leaf
        for i in reversed(range(self.n)):
            self.data[i] = self.op_func(self.data[2 * i], self.data[2 * i + 1])

    def update(self, i, x):
        # change i-th element to x (i : 0-indexed)
        i += self.n
        self.data[i] = x
        while i > 1:
            i = i >> 1  # go to parenet-node
            self.data[i] = self.op_func(self.data[2 * i], self.data[2 * i + 1])

    def query(self, l, r):
        # query for interval [l, r) (l, r : 0-indexed)
        l += self.n
        r += self.n
        ret = self.ele_id
        while l < r:
            if l & 1:  # right child
                ret = self.op_func(ret, self.data[l])
                l += 1
            if r & 1:  # right child
                r -= 1
                ret = self.op_func(ret, self.data[r])
            # go to parent-nodes
            l = l >> 1
            r = r >> 1
        return ret


n = int(input())
s = input()

# construct segment tree
ele_id = 0
op_func = lambda a, b: a | b
st_bitset = SegmentTree1(n, ele_id, op_func)
st_bitset.build([1 << (ord(si) - ord('a')) for si in s])

# query
q = int(input())
for _ in range(q):
    k, a, b = input().split()
    k = int(k)
    a = int(a)
    if k == 1:
        b = ord(b) - ord('a')
        a -= 1
        # type1: update
        st_bitset.update(a, 1 << b)
    else:
        # type2: calc
        b = int(b)
        a -= 1
        cnt = bin(st_bitset.query(a, b)).count('1')
        print(cnt)


Measured memory_bytes: 80224
#include<iostream>
#include<deque>
#include<vector>

using namespace std;

int main(){
  int n;
  deque<int> data;

  cin>>n;

  for(int i=0;i<n;i++){
    int ai;
    cin>>ai;
    if((i%2)==0)
      data.push_back(ai);
    else
      data.push_front(ai);

  }
  vector<int> ans;
  if((n%2)==0){
    while(!data.empty()){
      ans.push_back(data.front());
      data.pop_front();
    }
  } else {
    while(!data.empty()){
      ans.push_back(data.back());
      data.pop_back();
    }
  }
  for(int i=0;i<ans.size();i++){
    if(i!=0)cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3960
def calc(total, m1, m5, m10, m50, m100, m500)
    m = 0
    temp = m500
    while temp > 0 && total >= 500
         total -= 500
         temp -= 1
         m += 1
     end
    temp = m100
    while temp > 0 && total >= 100
         total -= 100
         temp -= 1
         m += 1
     end
    temp = m50
    while temp > 0 && total >= 50
         total -= 50
         temp -= 1
         m += 1
     end
    temp = m10
    while temp > 0 && total >= 10
        total -= 10
        temp -= 1
        m += 1
    end
    temp = m5
    while temp > 0 && total >= 5
        total -= 5
        temp -= 1
        m += 1
    end
    temp = m1
    while temp > 0 && total >= 1
        total -= 1
        temp -= 1
        m += 1
    end
    m
end
while line = gets do
    p, n1, n5, n10, n50, n100, n500 = line.split.map(&:to_i)
    if p == 0
        break
    end
    res = Float::INFINITY

    for c in 0..499 do
        m = 0
        total = p + c
        l = calc(total, n1, n5, n10, n50, n100, n500)
        n = calc(c, 5,2,5,2,5,0)
        m = l + n
         if m < res
            res = m
        end
    end
    puts res
end

Measured memory_bytes: 6132
n,c,k = gets.split.map(&:to_i)
t = []
n.times do
  t << gets.to_i
end
time = t.sort

i = time[0]
counter = 1
per = 1
(1..n-1).each do |j|
  if i+k >= time[j] && c > per
    per += 1
  elsif
    counter += 1
    per = 1
    i = time[j]
  end
end

p counter

Measured memory_bytes: 4656
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
int n,m;
int ans=0;
int l,r;

int c[120000];


int main()
{
    cin >>n >>m;
    int nowl = 1;
    int nowr = n;
    for (int i=1; i<=m; ++i)
    {
        scanf("%d %d",&l,&r);
        if (l>nowl) nowl = l;
        if (r<nowr) nowr =r;
    }
    ans = max(0, nowr-nowl+1);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  
  int n; cin >> n;
  int f=0,m=n;
  while(m){
    m/=10;
    f++;
  }
  int ans=0;
  for(int i=0;i<f;i+=2){
    ans+=9*pow(10,i);
  }
  if(f%2!=0)  ans-=(pow(10,f)-n-1);
  cout << ans << endl;
}

Measured memory_bytes: 4112
#include<stdio.h>

int main(void) {
	int r = 0, b = 0, num;
	char str[110];
	scanf("%d\n%s", &num, str);
	for (int i = 0;i < num;i++) {
		if (str[i] == 'R')
			r++;
		else if (str[i] == 'B')
			b++;
	}
	if (r > b) 
		printf("Yes");
	else
		printf("No");
	
	return 0;
}

Measured memory_bytes: 128
///
// File:  d.cpp
// Author: ymiyamoto
//
// Created on Sat Dec 29 17:23:13 2018
//
#include <bits/stdc++.h>
using namespace std;

#define rep(_n, _init, _N) for (int32_t _n = _init; _n < (int32_t)(_N); _n++)
#define rrep(_n, _N, _end) for (int32_t _n = (int32_t)(_N); _n >= _end; _n--)
#define iceil(_x, _y) (((_x) + (_y)-1) / (_y))
#define ifloor(_x, _y) ((_x) / (_y))

static const double pi = 2 * asin(1);
static const double precision = 10e-9;
#define int long long int

int32_t main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  rep(i, 0, n){
    cin >> a[i];
  }
  rep(i, 0, n){
    cin >> b[i];
  }

  vector<int> modb(n);
  int ans = 0;
  rep(i, 0, 32){
    rep(j, 0, n){
      modb[j] = b[j] % (1 << (i+1));
    }
    sort(modb.begin(), modb.end());

    int num = 0;
    rep(j, 0, n){
      int moda = a[j] % (1 << (i+1));
      auto x = lower_bound(modb.begin(), modb.end(), 1*(1<<i) - moda);
      auto y = lower_bound(modb.begin(), modb.end(), 2*(1<<i) - moda);
      auto z = lower_bound(modb.begin(), modb.end(), 3*(1<<i) - moda);
      auto w = lower_bound(modb.begin(), modb.end(), 4*(1<<i) - moda);
      num += y-x + w-z;
      // cout << j << " " << num << " " << distance(modb.begin(), x) << " "<<distance(modb.begin(), y)
      //      << " "<<distance(modb.begin(), z) << " "<<distance(modb.begin(), w) << endl;
    }

    if(num % 2 == 1){
      ans |= (1 << i);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    int result = 0;
    
    if (a <= b + c) {
      result = b + c - a;
    }
    
    System.out.println(result);
  }
  
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int x,ans=0;
  for(int i=0;i<n;i++){
    cin>>x;
    if(k-x>x){
      ans+=x*2;
    }else{
      ans+=(k-x)*2;
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  int N, K;
  cin >> N >> K;
  if (K == 1) {
    cout << 0 << endl;
  } else {
    cout << N - (K - 1) - 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char a = sc.next().charAt(0);
        if (a=='A') System.out.println("T");
        if (a=='T') System.out.println("A");
        if (a=='G') System.out.println("C");
        if (a=='C') System.out.println("G");
    }
}


Measured memory_bytes: 21716
while gets
  y,m,d = $_.split.map(&:to_i)
  case y
  when 0..1867
    puts "pre-meiji"
  when 1868..1911
    if y!=1868||m>9||d>7
      puts ["meiji",y-1868+1,m,d].join(" ")
    else
      puts "pre-meiji"
    end
  when (1912..1925)
    if y!=1912||m>7||d>29
      puts ["taisho",y-1912+1,m,d].join(" ")
    else
      puts ["meiji",y-1868+1,m,d].join(" ")
    end
  when(1926..1989)
    if y!=1926||d>24
      if y==1989&&d>7
        puts ["heisei",y-1989+1,m,d].join(" ")
      else
        puts ["showa",y-1926+1,m,d].join(" ")
      end
    else
      puts ["taisho",y-1912+1,m,d].join(" ")
    end
  else  puts ["heisei",y-1989+1,m,d].join(" ")
  end
end
#元号  期間
#meiji 1868. 9. 8 〜 1912. 7.29
#taisho  1912. 7.30 〜 1926.12.24
#showa 1926.12.25 〜 1989. 1. 7
#heisei  1989. 1. 8 〜

Measured memory_bytes: 2316
#include<cstdio>

#include<cstring>

#include<cmath>

#include<ctime>

#include<cstdlib>

#include<string>
#include<assert.h>

#include<queue>

#include<stack>

#include<bitset>

#include<algorithm>

#define pr pair<int,int>

#define FR first

#define SE second

#define MP make_pair

#define PB push_back
#define fo(i,l,r) for(register int i=(l),I=(r);i<=I;i++)
#define fd(i,l,r) for(register int i=(l),I=(r);i>=I;i--)

namespace mine

{

	typedef long long ll;

	ll qread()

	{

		ll ret=0,f=1;char c=getchar();

		while(c<'0' or c>'9'){if(c=='-')f=-1;c=getchar();}

		while('0'<=c and c<='9') ret=ret*10+c-'0',c=getchar();return ret*f;

	}

	void write(ll num){if(num<0)putchar('-'),num=-num;if(num>=10)write(num/10);putchar('0'+num%10);}

	void write1(ll num){write(num);putchar(' ');}

	void write2(ll num){write(num);putchar('\n');}

	

	const int MOD=998244353;

	ll qpower(ll x,ll e,const ll mod=MOD)	{assert(e>=0);ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}

	ll invm(ll x,const ll mod=MOD){return qpower(x,mod-2,mod);}

	template<typename T> void add(T &x,const int y){x=(x+y<MOD?x+y:x+y-MOD);}


	const int N=1e7+10;

	ll fac[N],facinv[N],inv[N];ll C(int n,int m){return n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}

    void main()

	{
		inv[1]=1;fo(i,2,N-1) inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;

        fac[0]=1;fo(i,1,N-1) fac[i]=fac[i-1]*i%MOD;
		facinv[N-1]=invm(fac[N-1]);fd(i,N-1,1) facinv[i-1]=facinv[i]*i%MOD;

        int n=qread(),ans=0;
		ll down=1;fo(i,n-n/2+1,n) down=down*i%MOD;
		ll now=0;fo(y,0,n/2) add(now, C(n-n/2,y) );

        for(int x=n/2;x>=0;x--)
		{
			add(ans, down*now%MOD*facinv[x]%MOD );
			down=down*inv[n-x+1]%MOD;now=(now*2+MOD-C(n-x,n/2))%MOD;
		}write(ans);

	}

};

int main()

{
	//freopen("z.txt","r",stdin);
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);

	srand(time(0));

	mine::main();

}





Measured memory_bytes: 234496
#include <stdio.h>
int A[20],n;
int solve(int count,int num)
{
	if(num==0)
	return 1;
	if(count>n||num<0)
	return 0;
	if(solve(count+1,num-A[count])||solve(count+1,num))
	return 1;
	return 0;
}
int main(int argc, char *argv[])
{
	int q,m,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&A[i]);
	scanf("%d",&q);
	for(i=0;i<q;i++)
	{
		scanf("%d",&m);
		if(solve(0,m))
		printf("yes\n");
		else
		printf("no\n");
	}
	return 0;
}


Measured memory_bytes: 2076
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int k = Integer.parseInt(scan.next());
        scan.close();

        if (k % 2 == 0 || k % 5 == 0) {
            System.out.println(-1);
            return;
        }

        int ans = 1;
        int now = 7;
        int tenMod = 7;

        while (now % k != 0) {
            tenMod *= 10;
            tenMod %= k;
            now = (now + tenMod) % k;
            ans++;
        }

        System.out.println(ans);
    }
}


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

using namespace std;


int main(void) {
    int H, W;
    string hs, ws;


    cin >> H >> W;

    vector <string> top_bottom(W + 2, "#");
    vector <string> data(H);

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

    
    for (int i = 0; i < top_bottom.size(); i++) {
        cout << top_bottom.at(i);
    }
    cout << endl;

    for (int i = 0; i < data.size(); i++) {
        cout << "#" << data.at(i) << "#" << endl;
    }

    for (int i = 0; i < top_bottom.size(); i++) {
        cout << top_bottom.at(i);
    }
    cout << endl;

    return 0;
}


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


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

    Scanner cin;
    

    void calc()
    {
        cin = new Scanner();
        string S = cin.next();
        int left = 0;
        int right = S.Length - 1;
        int ans = 0;
        while (left < right)
        {
            if(S[left] != 'x')
            {
                if (S[right] == 'x') { right--; ans++; }
                else if (S[right] == S[left]) { left++;right--; }
                else { Console.WriteLine("-1"); return; }
            }
            else
            {
                if (S[right] == 'x') { left++; right--; }
                else { left++; ans++; }
            }
        }
        Console.WriteLine(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: 13664
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var n = Number(lines[0]);
 var a = lines[1].split(' ');
 a = a.map(function(str) { return Number(str)});
 count = 0;
 b = 0;

 loop: while(true){
   for(i=0; i<n; i++){
     if(a[i]%2 == 1){
       break loop;
     }
   }
     count++;
   for(i=0; i<n; i++){
     a[i] = a[i] / 2;
   }
   
 }

console.log(count);
});

Measured memory_bytes: 7756
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long int ll;
ll a[100005];
int main()
{
	int n;
	ll t,bnum;
	cin>>n;
	cin>>t;
	bnum=t/2;
	cin>>a[0];
	int ans=0;
	
	ll maxv = -1000000001,minv = a[0];
	for(int i=1;i<n;++i){
		cin>>a[i];
		maxv = max(maxv,a[i]-minv);
		minv = min(minv,a[i]);
	}
	ll same = maxv;
	minv = a[0];
	for(int i=1;i<n;++i){
		if(a[i]-minv==same)ans++;
		minv = min(minv,a[i]);
	}
	cout << ans<<endl;
	return 0;
}

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

using namespace std;

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x,v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<int, pii> piii;
typedef pair<ll,ll> pll;
typedef pair<ll, pll> plll;
typedef vector<int> vi;
typedef vector <vi> vii;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;
ll n,h[N][3],dp[N][3];

ll call_dp(ll i, ll k){
    if(i > n) return 0;
    if(~dp[i][k]) return dp[i][k];
    return dp[i][k] = max(h[i][(k+1+3)%3] + call_dp(i+1,(k+1+3)%3),h[i][(k-1+3)%3] + call_dp(i+1,(k-1+3)%3));
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> h[i][0] >> h[i][1] >> h[i][2];
    }
    ll ans0 = h[1][0] + call_dp(2,0);
    ll ans1 = h[1][1] + call_dp(2,1);
    ll ans2 = h[1][2] + call_dp(2,2);
    cout << max({ans0,ans1,ans2}) << "\n";
    return 0;
}

Measured memory_bytes: 9600
from numpy.linalg import solve


def COM(n, r):
    fac = [1, 1]
    finv = [1, 1]
    inv = [0, 1]
    for i in range(2, MAX):
        fac.append(fac[i - 1] * i % MOD)
        inv.append(-inv[MOD % i] * (MOD // i))
        finv.append(finv[i - 1] * inv[i] % MOD)
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD


MOD = 10 ** 9 + 7
MAX = 10**6
x, y = map(int, input().split())
if (x + y) % 3 != 0:
    print(0)
    exit(0)
l = solve([[2, 1], [1, 2]], [x, y])
if l[0] < 0 or l[1] < 0:
    print(0)
    exit(0)
print(COM(int(l[0]+l[1]), int(l[0])))

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

int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i,N){
        cin >> d[i];
    }
    ll ans = 0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            ans+=d[i]*d[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
w1 = input()
words = list([w1])
for _ in range(n-1):
    w2 = input()
    if w2 in words:
        print("No")
        break
    else:
        words.append(w2)
        if w2[0]!=w1[-1]:
            print("No")
            break
        else:
            w1 = w2
else:
    print("Yes")

Measured memory_bytes: 3060
import java.util.Scanner;

//Aizu PR
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();sc.nextLine();
		while(t--!=0)System.out.println(sc.nextLine().replace("Hoshino", "Hoshina"));
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

int main(){
    ios::sync_with_stdio(false);
    int a,b,c;
    ll k;
    cin >> a >> b >> c >> k;
    if(abs(a-b)>10e18) cout << "Unfair" << endl;
    else if(k%2==0) cout << a-b << endl;
    else cout << b-a << endl;
    return 0;
}

Measured memory_bytes: 256
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let v = get!([i32]);

    if v.len() == 1 {
        println!("1");
        return;
    }

    let mut n_v = Vec::new();
    for i in 0..n {
        let tmp = vec![v[i] - 1, v[i], v[i] + 1];
        n_v.push(tmp);
    }
    let mut m = HashMap::new();
    for i in 0..n {
        for j in 0..3 {
            let t = n_v[i][j];
            let counter = m.entry(t).or_insert(0);
            *counter += 1;
        }
    }
    let mut max_val = 0;
    for i in m.values() {
        if max_val < *i {
            max_val = *i;
        }
    }
    println!("{}", max_val);
}


Measured memory_bytes: 14588
using System;

namespace abc153_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] HA = Console.ReadLine().Split(" ");
            int H = int.Parse(HA[0]);
            int A = int.Parse(HA[1]);
            int tairyoku = H;
            int kougeki = 0;

            for(; ;)
            {
                if(tairyoku <= 0)
                {
                    break;
                }
                tairyoku -= A;
                kougeki += 1;
            }

            Console.WriteLine(kougeki);
        }
    }
}


Measured memory_bytes: 27476
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll h, w, k;
vector<ll> vec;
ll total = 0;
ll memo[110][10];

ll rec(ll i, ll j){
    if(i == 0 && j == 0) return 1;
    if(i == 0) return 0;
    if(memo[i][j] != -1) return memo[i][j];
    ll res = 0;

    if(j + 1 < w){
        res += rec(i - 1, j + 1) * vec[j];
    }
    res %= MOD;
    if(j - 1 >= 0){
        res += rec(i - 1, j - 1) * vec[j - 1];
    }
    res %= MOD;
    res += rec(i - 1, j) * (total - ((j+1<w?vec[j]:0) + (j-1>=0?vec[j - 1]:0)));
    res %= MOD;
    return memo[i][j] = res;

}
int main(void){

    cin >> h >> w >> k;

    vec.resize(w - 1, 0);

    for(ll bit = 0; bit < (1LL << (w - 1)); bit++){
        bool ok = true;
        for(ll i = 0; i < w - 2; i++){
            if((bit & (1LL << i)) && (bit & (1LL << (i + 1)))){
                ok = false;
                break;
            }
        }
        if(ok){
            for(ll i = 0; i < w - 1; i++){
                if(bit & (1LL << i)){
                    vec[i]++;  
                }
            }
            total++;
        }
    }
    rep(i, 110) rep(j, 10) memo[i][j] = -1;
    if(w == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << rec(h, k - 1) % MOD << endl;

}

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

int main()
{
  int a, b;
  cin >> a >> b;
  int b_keta;
  int n;
  bool can = false;
  
  if (b <= 9) b_keta = 1;
  else if (b <= 99) b_keta = 2;
  else b_keta = 3;
  
  if (b_keta == 1) n = 10 * a + b;
  else if (b_keta == 2) n = 100 * a + b;
  else n = 1000 * a + b;
  
  for (int i=1; i<=316; i++) {
    if (n == i*i) {
      can = true;
      break;
    }
  }
  
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(void){
    int n; cin >> n;
    vector<vector<ll>>cnt('z'+10,vector<ll>(n,0));
    for(int i=0;i<n;i++){
        string s; cin >> s;
        for(int j=0;j<s.length();j++){
            cnt[s[j]][i]++;
        }
    }

    // for(int i='a';i<='z';i++){
    //     for(int j=0;j<n;j++){
    //         cout << cnt[i][j] << ' ';
    //     }cout << endl;
    // }

    for(int i='a';i<='z';i++){
        ll num = *min_element(cnt[i].begin(),cnt[i].end());
        string t(num,char(i));
        cout << t;
    }
    cout << endl;
    return 0;
}

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

ll n,m,a[55];

ll dfs(ll x,ll y){//xはレベル，yは何層目か
    if(y<=x){//
        return 0;
    }else if(x==0){//レベル０はもちろん1枚しかないので
        return 1;
    }else{
        if(y-1<=a[x-1]){
            return dfs(x-1,y-1);
        }else if(y-1==a[x-1]+1){
            return dfs(x-1,y-2)+1;
        }else if(y!=a[x]){
            return dfs(x-1,a[x-1])+1+dfs(x-1,y-a[x-1]-2);
        }else{
            return dfs(x-1,a[x-1])*2+1;
        }
    }
}

int main(){
    cin>>n>>m;
    a[0]=1;
    for(int i=1;i<=n;i++){
        a[i]=a[i-1]*2+3;
    }
    cout<<dfs(n,m)<<endl;
    return 0;
}
    

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		
		int max = A + B;
		if(max < A - B)
			max = A - B;
		if(max < A * B)
			max = A * B;
		System.out.println(max);
	}
}


Measured memory_bytes: 23124
using System;

namespace abc_132b
{
    class Program
    {
        static void Main(string[] args)
        {
            int index = int.Parse(Console.ReadLine());
            string[] array = Console.ReadLine().Split(' ');
            int[] inputs = Array.ConvertAll(array, int.Parse);
            int count = 0;
            for (int i = 1; i < index - 1; i++)
            {
                if (inputs[i] < inputs[i-1] && inputs[i] > inputs[i+1]|| inputs[i] > inputs[i - 1] && inputs[i] < inputs[i + 1])
                {
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <iomanip>

typedef long long ll;
typedef long double ld;

using namespace std;
using Graph = vector<vector<ll>>;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)
#define ALL(a) (a).begin(),(a).end()

const ll inf = 1e18+7;
const ll mod = 1e9+7;

ll GetDigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main(){
    double L;
    cin >> L;
    cout << setprecision(9)<< L*L*L/27 << endl;
    	return 0;
}


Measured memory_bytes: 256
N = int(input())
H_list = list(map(int, input().split()))

ans = 0
count = 0
basis_H = H_list[0]
if N == 1:
    print(0)
else:
    for i in range(1, N):
        H = H_list[i]
        if basis_H >= H :
            count += 1
        else:
            if ans < count:
                ans = count
            count = 0
        basis_H = H
    if ans < count:
        ans = count
    print(ans)

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

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

  if(n == 1 || m == 1){
    long long a=n*m;
    if(a==1){
      cout << 1 << endl;
    }else if(a==2){
      cout << 0 << endl;
    }else{
      cout << a-2 << endl;
    }
  } else if (n == 2 || m == 2) {
    cout << 0 << endl;
  } else {
    cout << (n-2) * (m-2) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
var lines = [];
var dp = Array(101).fill(0);

var readline = require("readline");
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on("line", function (x) {
    lines.push(x);
});

rl.on("close", function () {
    var N = Number(lines[0]);
    var MOD = Math.pow(10, 9) + 7;
    // A = 0, C = 1, G = 2, T = 3
    // ????....? N個の?が存在
    // AGC(021), ACG(012), GAC(201), A?GC(0?21), AG?C(02?1) はNG

    dp = dp.map(function (value, index, array) {
        array[index] = Array(4).fill(0);
        array[index].map(function (value, index, array) {

            array[index] = Array(4).fill(0);
            array[index].map(function (value, index, array) {

                array[index] = Array(4).fill(0);
                return (array[index]);
            });
            return (array[index]);
        });
        return (array[index]);
    });

    dp[0][3][3][3] = 1;

    // 文字数
    for (var len = 0; len < N; len++) {
        // 最後から3文字目
        for (var x = 0; x < 4; x++) {
            // 最後から2文字目
            for (var y = 0; y < 4; y++) {
                // 最後から1文字目
                for (var z = 0; z < 4; z++) {

                    for (var i = 0; i < 4; i++) {
                        if (y === 0 && z === 2 && i === 1) { continue; }
                        if (y === 0 && z === 1 && i === 2) { continue; }
                        if (y === 2 && z === 0 && i === 1) { continue; }
                        if (x === 0 && z === 2 && i === 1) { continue; }
                        if (x === 0 && y === 2 && i === 1) { continue; }

                        dp[len + 1][y][z][i] += dp[len][x][y][z];
                        dp[len + 1][y][z][i] %= MOD;
                    }
                }
            }
        }
    }
    var ans = 0;

    // 最後から3文字目
    for (var x = 0; x < 4; x++) {
        // 最後から2文字目
        for (var y = 0; y < 4; y++) {
            // 最後から1文字目
            for (var z = 0; z < 4; z++) {
                ans += dp[N][x][y][z];
                ans %= MOD;
            };
        };
    };
    console.log(ans);
});

Measured memory_bytes: 21912
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i = s; i < (int)n; i++)
using namespace std;
 
int main(){
    int len;
    string S;
    bool flg;
    
    flg = true;
    len = 0;
    
    cin >> S;
    
    reverse(S.begin(),S.end());
    len = S.size();
    
    vector<string> T = {
        "dream","dreamer","erase","eraser"
    };
    
    for(int x = 0; x < T.size(); x++){
        reverse(T.at(x).begin(),T.at(x).end());
    }
    
    
   for(int i = 0; i < len;){
        
        for(int j = 0; j < T.size(); j++){
            if(S.substr(i,T.at(j).size()) == T.at(j)){
                flg = false;
                i += T.at(j).size();
                break;
            }else{
                flg = true;
            }
        }
        
        
        if(flg){
            break;
        }
    }
    
    if(flg){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  double sum=0;
  double sum1=0;
  vector<double> v(n);
  for(int i=0;i<n;i++){
    cin>>v.at(i);
  }
  sort(v.begin(), v.end());
  
  for(int i=0;i<n-1;i++){
   v.at(i+1)=(v.at(i)+v.at(i+1))/2;    
  }
  
  cout<<v.at(n-1)<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
	int N, H, W;
	cin >> N >> H >> W;
	vector<int> A(N);
	vector<int> B(N);
	int sum = 0;
	for(int x= 0;x<N;x++){
		cin >> A[x];
		cin >> B[x];
		if(A[x]>=H && B[x]>=W){
			sum++;
		}
	}
	cout << sum;
	
}


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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
  	long double a,b,c;cin>>a>>b>>c;
  	long double d=pow(a,0.5);
  	long double e=pow(b,0.5);
  	if(c>a+b+2*e*d)cout<<"Yes\n";
  	else cout<<"No\n";
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;

using namespace std;

int main(void)
{
    ll h, n;    
    cin >> h >> n;
    v_ll a(n), b(n);
    
    irep(i, n) {
        cin >> a[i] >> b[i];
    }

    v2_ll dp(n+10, v_ll(h+10, INF));
    dp[0][0] = 0;

    #if 1
    irep(i, n) {
        irep2(j, 0, h) {
            //irep2(k, 0, (h-j+a[i]+1)/a[i]) {
                ll nj = min(h, j + a[i]);
                dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
                dp[i+1][nj] = min(dp[i+1][nj], dp[i+1][j] + b[i]);
            //}
        }
    }
    #else 
    irep(i, n) {
        irep2(j, 0, h) {
            irep2(k, 0, (j+a[i]-1)/a[i]) {
                ll nj = max((ll)0, j - k * a[i]);
                dp[i+1][j] = min(dp[i+1][j], dp[i][nj] + (k * b[i]));
            }
        }
    }
    #endif
    #if 0
    irep(i, n+1) {
        printf("dp[%d]\n", i);
        irep(j, h+1) {
            printf("[%d],%d\n", j, dp[i][j]);
        } 
        printf("\n");
    }
    #else 
        cout << dp[n][h] << endl;
    #endif
	return 0;
}
/** atcodr **/


Measured memory_bytes: 79360
import java.io.PrintWriter;
import java.util.*;

class Main{
    static PrintWriter out;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        out=new PrintWriter(System.out);

        out.println(1^sc.nextInt());


        sc.close();
        out.close();
    }




}

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

const int N = 3005;

int n;
int a[N];
vector<int> G[N];

int dfs(int u, int p) {
	int res = 0;
	for (int v : G[u]) if (v != p) {
		int r = dfs(v, u);
		if (a[u] > a[v] && !r) res = 1;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v;
		G[u].push_back(v); G[v].push_back(u);
	}
	for (int i = 1; i <= n; ++i) {
		if (dfs(i, i)) printf("%d ", i);
	}
	printf("\n");
}

Measured memory_bytes: 640