akhauriyash/Code-Regression huggingface dataset:
unittest
{
	assert( [ "atcoder" ].parse.expand.solve == "atcoderb" );
	assert( [ "abc" ].parse.expand.solve == "abcd" );
	assert( [ "zyxwvutsrqponmlkjihgfedcba" ].parse.expand.solve == "-1" );
	assert( [ "abcdefghijklmnopqrstuvwzyx" ].parse.expand.solve == "abcdefghijklmnopqrstuvx" );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	// 辞書順最後のやつなので次は無い
	if( s == "zyxwvutsrqponmlkjihgfedcba" ) return "-1";
	
	auto us = new bool[]( 'z' + 1 );
	if( s.length < 26 )
	{
		// 26文字未満なら使われている文字の中で一番小さいやつをくっつける
		foreach( c; s ) us[ c ] = true;
		for( auto c = 'a'; c < us.length; c++ )
		{
			if( !us[ c ] ) return ( s ~ c ).to!string;
		}
	}
	else
	{
		// 26文字なら末尾から切り取っていって、末尾より切り取った文字のどれかのほうが大きくなったときに文字を入れ替える
		us[] = true;
		foreach_reverse( i, cf; s )
		{
			for( auto ct = cf + 1; ct < us.length; ct++ )
			{
				if( !us[ ct ] ) return ( s[ 0 .. i ] ~ ct ).to!string;
			}
			us[ cf ] = false;
		}
	}
	return s.to!string;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define fi first
#define se second
#define amen exit(0)
#define endl "\n"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

template <class type1>
using super_set = tree <type1, null_type, less <type1>, rb_tree_tag, tree_order_statistics_node_update>;
template <class type1, class type2>
using super_map = tree <type1, type2, less <type1>, rb_tree_tag, tree_order_statistics_node_update>;
#define tree nado_ubrat_tree_potomu_chto_tree_est_v_biblioteke_s_super_setom
#define left aksjdfajcvhmcxfmddddjlasjdffjfncxkmskxmcvnmaaaasdjkhlkmnzcmznkj
#define right akjdsfllllkcjvcbkhjfdjbfzfjhhdsabmnffjmczbnbvhjadvkhzmbbbjfdgyv
#define y1 ljkhasdfkjvbbnvnnnnvsbncxvmnshdfnbshfdcvnkfsdkjjkkuhwihfkjskjfd

const ll D = 1<<17;
const ll Inf = 1000000007;

ll a[20][20], dp[D], cost[D];

ll f(ll mask)
{
    if (dp[mask] == -Inf)
    {
        dp[mask] = 0;
        for (ll submask = mask; submask > 0; submask = (submask - 1) & mask)
            dp[mask] = max(dp[mask], f(mask ^ submask) + cost[submask]);
    }
    return dp[mask];
}

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

    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
        for (ll j = 0; j < n; j++)
            cin >> a[i][j];

    for (ll mask = 0; mask < 1<<n; mask++)
        for (ll i1 = 0; i1 < n; i1++)
        for (ll i2 = i1 + 1; i2 < n; i2++)
            if ((bool) (mask & (1<<i1)) && (bool) (mask & (1<<i2)))
                cost[mask] += a[i1][i2];
    fill(dp, dp + (1<<17), -Inf);
    dp[0] = 0;

    cout << f((1<<n) - 1) << endl;
    amen;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;

  set<int> waters;
  for (int i = 0; i <= f; i += a) {
    for (int j = 0; j <= f; j += b) {
      if (i == 0 && j == 0)
        continue;
      if ((i + j) * 100 > f)
        break;
      waters.insert(i + j);
    }
  }

  double concentration = -1;
  int ans1 = 0, ans2 = 0;
  for (auto w : waters) {
    int water = w * 100;
    rep(i, 0, f + 1) {
      rep(j, 0, f + 1) {
        int sugar = i * c + j * d;
        if (water + sugar > f)
          break;
        if (e * w < sugar)
          break;
        double x = 100.0 * sugar / (water + sugar);
        if (concentration < x) {
          concentration = x;
          ans1 = water + sugar;
          ans2 = sugar;
        }
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
}


Measured memory_bytes: 256
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

typedef long long ll;
// #define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  string s; cin >> s;
  int ans = INF;
  REP(i, 2){
    bool color = i; int cnt = 0;
    REP(j, s.size()){
      if(color && s[j]=='0') cnt++;
      else if(!color && s[j]=='1') cnt++;
      color = !color;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

int main() {

	long n, m;
	cin >> n >> m;

	vector<long long> h(n + 1,0);
	for (long i = 1; i <= n; i++) {
		cin >> h[i];
	}

	vector<long> yoi(n + 1, 1);
	long a, b;
	for (long i = 1; i <= m; i++) {
		cin >> a >> b;
		if (h[a] > h[b]) { yoi[b] = 0; }
		else if (h[a] < h[b]) { yoi[a] = 0; }
		else { yoi[a] = 0; yoi[b] = 0; }
	}

	long counter = 0;
	for (long i = 1; i <= n; i++) {
		counter = counter + yoi[i];
	}
	cout << counter << endl;
	return 0;

}

Measured memory_bytes: 4840
# -*- coding: utf-8 -*-

N = int(input().strip())
F_list = [list(map(int, input().rstrip().split())) for i in range(N)]
P_list = [list(map(int, input().rstrip().split())) for i in range(N)]
#-----

total_profit_list=[]
for x in range(1,2**10):
    bin_str = format(x, 'b').zfill(10)

    profit=0
    for i in range(N):
        c=0
        for j in range(10):
            if int(bin_str[j]) == F_list[i][j] == 1:
                c += 1
        profit += P_list[i][c]
    
    total_profit_list.append(profit)

print(max(total_profit_list))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = pow(10, 9) + 7;
const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll N;
  cin >> N;

  ll P = divceil(N, 2);
  double ans = (double)P / (double)N;
  cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, X, L[101];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> X;
	rep(i, 0, N) cin >> L[i];

	int d = 0; int ans = 1;
	rep(i, 0, N) {
		d += L[i];
		if (X < d) break;
		ans++;
	}
	cout << ans << endl;
}







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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s=="abc")cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


return 0;}


Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

vector< vector<int> > G;
int dfs(int v){
	int size = G[v].size();
	vector<int> A;
	for(int i=0;i<size;++i){
		int to = G[v][i];
		int res = dfs(to);
		A.push_back( res );
	}
	int ret = 0;
	size = A.size();
	sort(A.begin(), A.end());
	for(int i=0;i<size;++i){
		ret = max(ret+1,A[i]+1);
	}
	return ret;
}
void solve(){
	int N;
	cin >> N;
	G = vector< vector<int> >(N);
	for(int i=1;i<N;++i){
		int a;
		cin >> a;
		--a;
		G[a].push_back( i );
	}

	int res = dfs(0);
	cout << res << endl;
}
#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 15104
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var aho = int.Parse(Console.ReadLine());
    for(var i =aho;;i++){
      var yaku = 0;
      for(var j = 1;j<=i;j++){
        if(i%j == 0){
          yaku++;
        }
      }
      if(yaku == 2&& i>= aho){
        Console.WriteLine(i);
        return;
      }
    }
  }
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;

int64_t Q, H, S, D, N;
int64_t const Alpha = 2;

pair<int64_t, double> greedy(int64_t M) {
  vector<pair<int64_t, int64_t>> vs{{Q, 1}, {H, 2}, {S, 4}, {D, 8}};
  sort(vs.begin(), vs.end(), [](auto const &l, auto const &r) {
    return l.first * r.second < r.first * l.second;
  });
  int64_t cost, perL; tie(cost, perL) = vs[0];
  auto buynum = (4 * M + perL - 1) / perL;
  return {buynum * cost, M + Alpha - (buynum * perL / 4.0)};
}

int64_t bf(double r) {
  auto constexpr MAX = std::numeric_limits<int64_t>::max();
  if (r == 0) return 0;
  if (r < 0) return MAX;
  auto a = bf(r - 0.25); if (a < MAX) a += Q;
  auto b = bf(r - 0.5);  if (b < MAX) b += H;
  auto c = bf(r - 1.0);  if (c < MAX) c += S;
  auto d = bf(r - 2.0);  if (d < MAX) d += D;
  return min({a, b, c, d});
}

int main() {
  cin >> Q >> H >> S >> D >> N;

  if (N <= Alpha) {
    cout << bf(N) << endl;
    exit(0);
  }

  int M = N - Alpha;
  auto x = greedy(M);
  auto y = bf(x.second);
  cout << x.first + y << "\n";
}


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

const int INF = 2000008;
// 隣接リスト グラフ
vector<int> to[100005];

int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        --a; --b; // 扱いやすいように0スタートにする(decrement)
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int v = q.front(); q.pop();
        for (int u : to[v]) {
            if (dist[u] != INF) continue;
            dist[u] = dist[v] + 1;
            pre[u] = v;
            q.push(u);
        }
    }

    cout << "Yes" << endl;

    rep(i,n) {
        if (i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 10660
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
vector<int>x;
int main(){
	string s;
	while(getline(std::cin,s)){
		int i;
		for(i=0;i<s.size();i++)if (s[i]==',')s[i]=' ';
		stringstream ss(s);
		vector<int>A,B;
		while(ss>>i)A.push_back(i);
		if(x.size()<A.size()){
			x.insert(x.begin(),1,0);
			x.push_back(0);
		}
		for(i=0;i<A.size();i++)B.push_back((x[i]>x[i+1]?x[i]:x[i+1])+A[i]);
		x=B;
	}
	cout<<x[0]<<endl;
}

Measured memory_bytes: 1252
// AtCoder ABC131: D - Megalomania
// 2019.9.4 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

typedef struct { int a, b; } T;
T t[200005]; int N;

void Qsort(T *a, int l, int r) {
	int i, j, m; T t;
	
	i = l, j = r, m = a[(l+r) >> 1].b;
	while (1) {
		while (a[i].b < m) i++;
		while (m < a[j].b) j--;
		if (i >= j)	break;
		t = a[i], a[i] = a[j], a[j] = t;
		i++, j--;
	}
	if (l+1 < i) Qsort(a, l, i-1);
	if (j+1 < r) Qsort(a, j+1, r);
}

int main()
{
	int i, s;
	
	N = in(); for (i = 0; i < N; i++) {
		t[i].a = in(), t[i].b = in();
		if (t[i].a > t[i].b) goto No;
	}
	Qsort(t, 0, N-1);
	s = 0; for (i = 0; i < N; i++) {
		s += t[i].a;
		if (s > t[i].b) goto No;
	}
	puts("Yes"); return 0;
No: puts("No");  return 0;
}


Measured memory_bytes: 1664
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

warshallFloyd :: A.UArray (Int, Int) Int -> A.UArray (Int, Int) Int
warshallFloyd iarr = oarr
  where
    l  = (fst . fst . A.bounds) iarr
    l' = (snd . fst . A.bounds) iarr
    r  = (fst . snd . A.bounds) iarr
    r' = (snd . snd . A.bounds) iarr
    oarr = assert (l==l' && r==r') $ ST.runSTUArray $ do
      d <- ST.thaw iarr
      forM_ [l..r] $ \k ->
        forM_ [l..r] $ \i ->
          forM_ [l..r] $ \j -> do
            dik <- ST.readArray d (i,k)
            dkj <- ST.readArray d (k,j)
            dij <- ST.readArray d (i,j)
            when (dik + dkj < dij) $
              ST.writeArray d (i,j) (dik + dkj)
      return d

main = do
  [h, w] <- getIntList
  cs <- VB.replicateM 10 $ getIntVec 10
  ass <- replicateM h $ getIntList

  arr <- IO.newArray ((0,0), (9,9)) 0 :: IO (IO.IOUArray (Int, Int) Int)

  forM_ [0..9] $ \i ->
    forM_ [0..9] $ \j -> do
    let cij = (cs VB.! i) V.! j
    IO.writeArray arr (i, j) cij

  arr' <- IO.freeze arr

  let d = warshallFloyd arr'
      ans = sum $ map (\i -> d  A.! (i, 1)) $ filter (/= (-1)) (concat ass)

  print ans


Measured memory_bytes: 1916
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;

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

const ll INF = 1e9;
/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    int N,W;
    cin >> N >> W;
    int dp[10010];
    memset(dp,-1,sizeof(dp));
    dp[0] = 0;

    vector<int> v(N),w(N);
    for (int i = 0;i < N;i++) cin >> v[i] >> w[i];
    int ans = -1;
    for (int i = 0;i < N;i++){
        for (int j = 0;j <= W;j++){
            if (j - w[i] >= 0){
                dp[j] = max(dp[j],dp[j-w[i]] + v[i]);
            }
        }
    }

    for (int i = 0;i <= W;i++) ans = max(ans,dp[i]);

    cout << ans << endl;
}


Measured memory_bytes: 3136
// <------------- Template -----------------------> //


#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(2);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 
 
typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAX5]; ll visit[] = {};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, q, m;
string s, t, d;
ll sum = 0;
ll cou = 0;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	string s1,s2;
	cin>>s1>>s2;
	if(s1.length() > s2.length()) {
		cout<<"GREATER\n";
	}
	else if(s1.length() < s2.length()) {
		cout<<"LESS\n";
	}
	else {
		for(ll i=0;i<s1.length();i++) {
			if(s1[i] > s2[i]) {
				cout<<"GREATER\n";
				return;
			}
			else if(s1[i] < s2[i]) {
				cout<<"LESS\n";
				return;
			}
		}
		cout<<"EQUAL\n";
	}
}

int main() {
	fastio; randomINT;
	//cin>>T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

int main(){
  char b;
  cin>>b;
  if(b=='A'){
    cout<<'T';
  }
    if(b=='T'){
    cout<<'A';
  }
    if(b=='G'){
    cout<<'C';
  }
    if(b=='C'){
    cout<<'G';
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;
inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}
inline int mul(int a, int b) {
  return (int)((long long)a * b % md);
}
inline int inv(int a) {
  a %= md;
  if(a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= a * t; swap(a, b);
    u -= v * t; swap(u, v);
  }
  assert(b == 1);
  if(u < 0) u += md;
  return u;
}
vector<int> cmb (int n) {
  vector<int> ret(n + 1, 1);
  for (int i = 1; i <= n; i++) {
    ret[i] = mul(ret[i - 1], mul(n - i + 1, inv(i)));
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> pos(n);
  for (int i = 0; i < n + 1; i++) {
    int x;
    cin >> x;
    pos[--x].push_back(i);
  }
  int a;
  for (int i = 0; i < n; i++) {
    if (pos[i].size() == 2) {
      a = pos[i][0] + n - pos[i][1];
    }
  }
  vector<int> small = cmb(a);
  vector<int> large = cmb(n + 1);
  for (int k = 1; k <= n + 1; k++) {
    int ret = large[k];
    if (k - 1 <= a) sub(ret, small[k - 1]);
    cout << ret << '\n';
  }
  return 0;
}

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

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> ban(h);
    for (int i = 0; i < h; i++)cin >> ban[i];

    vector<vector<int>> dis(h, vector<int>(w, 114514));
    dis[0][0] = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i > 0) {
                int cost = dis[i - 1][j];
                if (ban[i - 1][j] != ban[i][j])cost++;
                dis[i][j] = min(dis[i][j], cost);
            }
            if (j > 0) {
                int cost = dis[i][j - 1];
                if (ban[i][j - 1] != ban[i][j])cost++;
                dis[i][j] = min(dis[i][j], cost);
            }
        }
    }

    int ret = dis[h - 1][w - 1];
    if (ban[0][0] == '#')ret++;
    if (ban[h - 1][w - 1] == '#')ret++;

    cout << ret / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a;
    cin >> a;
    sort( a.begin() , a.end() );
    if( a[0] == 'a' && a[1] == 'b' && a[2] == 'c' ) cout << "Yes";
    else cout << "No";
} 

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

using namespace std;

#define int long long
#define forr(i,n) for(int i = 0;i < (int)n; i++)
#define forn(i,n) for(int i = (int)(n-1); ~i ;i--)
#define deb(x) cout<<#x<<" " <<x<<"\n";
#define all(x) x.begin(), x.end()
#define eb emplace_back
#define pb push_back
#define mpa make_pair
#define endl "\n"
#define ar array

vector<int> done(101);

void solve(){
	int n;
	cin >> n;
	if(done[n]) cout << "Yes";
	else cout << "No";
}

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	forr(i,9){
		forr(j,9){
			done[(i+1)*(j+1)] = 1;
		}
	}
	int t = 1;
	//cin>>t;
	while(t--){
		solve();		
	}
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    rep(i,s.size()){
        s[i] = (s[i]==',')?' ':s[i];
        cout<<s[i];
    }cout<<endl;
    return 0;
}


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

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

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

    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    long long int cnt = 0;
    rep(i, n - 1) {
        while ((a[i] + a[i + 1]) > x) {
            int t = (a[i] + a[i + 1]) - x;

            cnt += t;

            if (a[i + 1] > t) {
                a[i + 1] -= t;
                t = 0;
            } else {
                a[i + 1] = 0;
                t -= a[i + 1];
            }

            if (t > 0) {
                a[i] -= t;
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

long long  XORsum(long long a)
{
    // long long x;
    // switch (a % 4)
    // {
    // case 0:
    //     ans = a;
    //     break;
    
    // case 1:
    //     ans = 1;
    //     break;

    // case 2:
    //     ans = 1 + a;
    //     break;

    // case 3:
    //     ans = 0;
    //     break;
    // }
    if (a % 4 == 0) return a;
    if (a % 4 == 1) return 1;
    if (a % 4 == 2) return 1 ^ a;
    if (a % 4 == 3) return 0;

}

int main(int argc, char const *argv[])
{
    long long A, B;
    cin >> A >> B;
    A--;
    long long sumA = XORsum(A);
    long long sumB = XORsum(B);

    cout << (XORsum(B) ^ XORsum(A)) << endl;

    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	long long int n;
	long long int p = 1;
	int ret = 0;
	cin >> n;
	while(p < n){
		ret++;
		p = p*3;
	}
	cout << ret << endl;
}

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


int main()
{
     ll l; string s;
    cin>>l>>s;
    ll a=0,b=0,c=0,r=0;

        a=count(s.begin(),s.end(),'R');
        b=count(s.begin(),s.end(),'G');
        c=count(s.begin(),s.end(),'B');
    ll ans=a*b*c;
     for(ll i=0; i<l-1; i++)
    {
        for(ll j=i+1; j<l; j++)
        {
            ll k=2*j-i;
            //cout<<i<<" "<<s[i]<<" "<<j<<" "<<s[j]<<" "<<k<< " "<<s[k]<<endl;
            if(k<l)
                {
                    if(s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i])ans--;
                }
        }
    }


    cout<<ans<<endl;
}




Measured memory_bytes: 3620
N, M, L = map(int, input().split())

INF = float('inf')
d1 = [[INF]*N for _ in range(N)]


for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d1[a][b] = c
    d1[b][a] = c
for i in range(N):
    d1[i][i] = 0
for k in range(N):
    for i in range(N):
        for j in range(N):
            d1[i][j] = min(d1[i][k] + d1[k][j], d1[i][j])

d2 = [[INF]*N for _ in range(N)]

for i in range(N):
    for j in range(N):
        if i == j:
            d2[i][j] = 0
        if d1[i][j] <= L and i != j:
            d2[i][j] = 1
for k in range(N):
    for i in range(N):
        for j in range(N):
            d2[i][j] = min(d2[i][k] + d2[k][j], d2[i][j])
Q = int(input())
for _ in range(Q):
    s, t = map(int, input().split())
    s -= 1
    t -= 1
    if d2[s][t] == INF:
        print(-1)
    else:
        print(d2[s][t]-1)


Measured memory_bytes: 86472
import java.util.*;

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

        String s = sc.next();
        char[] arr = s.toCharArray();
        int n = s.length();


        int cnt = 0;
        if (n%2==0 || n%2==1){
            for (int i=0; i<n/2; i++){
                if (arr[i]!=arr[n-i-1]){
                    cnt++;
                }
            }
            System.out.println(cnt);
        }else {
        }

    }

}

Measured memory_bytes: 21844
from functools import reduce
import collections 
import fractions
import math
import copy

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input().rstrip())
    A = list(int(_) for _ in input().split())
    ans = 0
    R = [0]*N
    R[0] = A[0]
    L = [0]*N
    L[N-1] = A[N-1]
    for i in range(1,N):
        R[i] = fractions.gcd(R[i-1],A[i])
    for i in range(N-1,0,-1):
        L[i-1] = fractions.gcd(L[i],A[i-1])        
    X = []
    for i in range(N):
        if i == 0:
            X.append(L[1])
        elif i == N-1:
            X.append(R[N-2])
        else:
            X.append(fractions.gcd(R[i-1],L[i+1]))
    print(max(X))
    
if __name__ == '__main__':
    main()


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, r = 0, w = 0;
	string s;
	cin >> n;
	cin >> s;
	for (int i = 0; i < n; i++){
		if (s[i] == 'W') w++;
		else r++;
	}
	int er = 0;
	for (int i = 0; i < r; i++)
		if(s[i] == 'W') er++;
	cout << er << endl;
	return 0;
}

Measured memory_bytes: 3744
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N, M = MI()
A = LI()
ans = N - sum(A)
if ans >= 0:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 27772
#include <cstdio>
using namespace std;
int N, M, K;
int main() {
  scanf("%d %d %d", &N, &M, &K);
  bool ok = false;
  for(int i= 1; i <= N; ++i) {
    int on = i*M, diff = N-2*i;
    for(int j = 0; j <= M; ++j) {
      if(on+diff*j != K) continue;
      ok = true;
      break;
    }
  }
  printf("%s\n", (ok?"Yes":"No"));
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int a[N];
map<pair<int,int>,int>mp;
int main() {
//	#   ifdef LOCAL_PROJECT
//        freopen("in.txt", "r", stdin);
//    #   endif
//    int n;
//    scanf("%d",&n);
//    int start=0,end=1;
//    int ans=0;
//    int cnt =0,pre,cur;
//    scanf("%d",&pre);
//    for(int i=1;i<n;i++){
//        scanf("%d",&cur);
//        if(pre>=cur){cnt++;ans = max(ans,cnt);}
//        else cnt=0;
//        pre= cur;
//    }
//    printf("%d",ans);
    int n,k,q;
    int ans ;
    scanf("%d%d%d",&n,&k,&q);
    for(int i=1;i<=n;i++){
        mp[{i,k}]=k;
    }
    for(int i=1;i<=q;i++){
        scanf("%d",&ans);
        mp[{ans,k}]++;
    }
    for(int i=1;i<=n;i++){
        if(mp[{i,k}]-q>0)puts("Yes");
        else puts("No");
    }
    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll a[200010];
 
int main(){
	ll n,k;
	cin >> n >> k;
	cinf(a,n);
	rep(i,n-k){
		if(a[i+k]>a[i])
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

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

typedef pair<int, int> pii;
int main(){
  int a,b,m;
  cin >> a >> b >> m;
  
  vector<int> A(a);
  vector<int> B(b);
  
  int a_min = 100000;
  int b_min = 100000;
  for(int i = 0; i < a; i++){
    cin >> A.at(i);
    if(A.at(i) < a_min){
      a_min = A.at(i);
    }
  }
  for(int i=0; i < b;i++){
    cin >> B.at(i);
    if(B.at(i) < b_min){
      b_min = B.at(i);
    }
  }
  int tmp_min = a_min + b_min;
  
  for(int i = 0; i < m; i++){
    int x,y,z;
    int tmp_sum;
    cin >> x >> y >> z;
    tmp_sum = A.at(x-1) + B.at(y-1) - z; 
    if(tmp_sum < tmp_min){
      tmp_min = tmp_sum;
    }
  }
  
  cerr << a_min << " " << b_min << endl;
  cout << tmp_min << endl;
  

}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
// #define int long long

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll MOD=1000000007;

ll modpow(ll a, ll n = MOD-2) {
	ll r = 1;
    a %= MOD;
	while(n) {
        r=r*((n%2)?a:1)%MOD;
        a=a*a%MOD;
        n>>=1;
    }

	return r;
}

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

	int N, K;
	cin >> N >> K;

	ll sum = 0;
    vector<ll> dp(100001, 0);
	for(int i=K; i>=1; i--) {
		dp[i] = modpow(K/i,N);
		for (int j=i*2;j<=K;j+=i) dp[i] -= dp[j];
		sum += i*dp[i]%MOD;
	}
	cout << sum%MOD << endl;

    return 0;
}


Measured memory_bytes: 3992
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main()
{
  ll n;
  cin>>n;
  ll a[4];
  memset(a,0,sizeof(a));
  for(ll i=0;i<n;i++)
  {
    string x;
    cin>>x;
    a[0]+=(x=="AC");
    a[1]+=(x=="WA");
    a[2]+=(x=="TLE");
    a[3]+=(x=="RE");
  }
  cout<<"AC x "<<a[0]<<endl;
  cout<<"WA x "<<a[1]<<endl;
  cout<<"TLE x "<<a[2]<<endl;
  cout<<"RE x "<<a[3]<<endl;
  return 0;
}


Measured memory_bytes: 3608
#include <atcoder/lazysegtree>
#include <atcoder/modint>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

struct S {
    mint a, b;
};

using F = int;

S op(S l, S r) { return S{l.a * r.b + r.a, l.b * r.b}; }

S e() { return S{0, 1}; }

F id() { return -1; }

S mapping(F f, S x) {
    if (f == id()) return x;
    return S{(x.b - 1) / 9 * f, x.b};
}

F composition(F f, F g) {
    if (f == id()) return g;
    return f;
}

int main() {
    int n, q;
    scanf("%d%d", &n, &q);

    vector<S> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = S{1, 10};
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

    for (int i = 0; i < q; i++) {
        int l, r, d;
        scanf("%d%d%d", &l, &r, &d);
        seg.apply(l - 1, r, d);
        printf("%d\n", seg.all_prod().a.val());
    }
}

Measured memory_bytes: 9860
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
ans=0
line,last=divmod(n,k)
for i in range(last):
  lr,ls,lp=0,0,0
  for j in range(line+1):
    x=t[j*k+i]
    if x=="r":
      tr=max(ls,lp)
      ts=max(lp,lr)
      tp=max(lr,ls)+p
      lr,ls,lp=tr,ts,tp
    elif x=="s":
      tr=max(ls,lp)+r
      ts=max(lp,lr)
      tp=max(lr,ls)
      lr,ls,lp=tr,ts,tp
    else:
      tr=max(ls,lp)
      ts=max(lp,lr)+s
      tp=max(lr,ls)
      lr,ls,lp=tr,ts,tp
  ans+=max(lr,ls,lp)
for i in range(last,k):
  lr,ls,lp=0,0,0
  for j in range(line):
    x=t[j*k+i]
    if x=="r":
      tr=max(ls,lp)
      ts=max(lp,lr)
      tp=max(lr,ls)+p
      lr,ls,lp=tr,ts,tp
    elif x=="s":
      tr=max(ls,lp)+r
      ts=max(lp,lr)
      tp=max(lr,ls)
      lr,ls,lp=tr,ts,tp
    else:
      tr=max(ls,lp)
      ts=max(lp,lr)+s
      tp=max(lr,ls)
      lr,ls,lp=tr,ts,tp
  ans+=max(lr,ls,lp)
print(ans)

Measured memory_bytes: 66288
#include<stdio.h>

int main(){
  char str[50000] = {};
  int a[3];
  int i;
  int j;
  int n=0;
  int flag = 0;
  int turn = 0;
  int cnt = 0;
  scanf("%d",&n);
  scanf("%s",str);
  //printf("%d",n);
  for(i=0;i<=999;i++){
    a[0] = i / 100;
    a[1] = (i - (a[0]*100))/10;
    a[2] = i % 10;
    turn = 0;
    for(j=0;j<n;j++){
      if('0'+a[turn] == str[j]){
        turn++;
      }
      if(turn == 3){
        cnt++;
        break;
      }
    }
  }
  printf("%d",cnt);

  return 0;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n >> a >> b;
    ans = 0;
    for (int i = 1; i <= n; ++i) {
        s = to_string(i);
        sum = 0;
        REP(j, s.size()) {
            sum += s.at(j) - '0';
        }
        if (a <= sum && sum <= b) ans += i;
    }
    MSG(ans)
}


Measured memory_bytes: 256
use std::iter::repeat;
use std::io::BufRead;
use std::collections::HashMap;

fn main() {
    let handle = std::io::stdin();
    let mut s = String::new();
    for line in handle.lock().lines().map(|a| a.unwrap()) {
        s.push_str(&line.to_lowercase());
    }
    let mut alpha_map: HashMap<char, usize> = (b'a'..b'{')
        .map(|a| a as char).zip(repeat(0)).collect();
    
    for c in s.chars() {
        match c {
            alpha @ 'a'...'z' => *alpha_map.get_mut(&alpha).unwrap() += 1,
            _ => continue,
        }
    }
    for k in (b'a'..b'{').map(|a| a as char) {
        let v = alpha_map.get_mut(&k).unwrap();
        println!("{} : {}", k, v);
    }
}


Measured memory_bytes: 5060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18


int main(){
    int N; cin >> N;
    string S; cin >> S;
    long long ans = 1;
    for(char c = 'a'; c <= 'z'; c++){
        long long num = 1;
        rep(i,N){
            if(S[i] == c)num++;
        }
        ans *= num % MOD;
      	ans %= MOD;
    }
    ans -= 1;
    ans %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<algorithm>
#define ll long long
using namespace std;

int main()
{
    int l,c=0;
    string s,t;
    cin>>s>>t;
     l=s.length();
     for(int i=0;i<l;i++)
     {
         if(s[i]!=t[i])
         {
             c++;
         }
     }
     cout<<c<<endl;





    return 0;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a-1;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.14159265358979323

void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("in.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif
} 

vector<vector<ll> >vii;

int main(){
   //Fast_IO();
   string s;
   cin>>s;
   f(i,0,s.length()-1){
      if(s[i]=='P' && s[i+1]=='?') s[i+1]='D';
      else if(s[i]=='?' && s[i+1]=='P'){
         s[i]='D';
      }
      else if(s[i]=='?' && s[i+1]=='D'){
         s[i]='P';
      }
      else if(s[i]=='?' && s[i+1]=='?'){
         s[i]='P';
         s[i+1]='D';
      }
   }
   if(s[s.length()-1]=='?') s[s.length()-1]='D';
   cout<<s<<endl;
}


Measured memory_bytes: 3728
// 2013/05/13 Tazoe

#include <iostream>
using namespace std;

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

	int C[100][3];
	for(int i=0; i<100; i++){
		for(int j=0; j<3; j++){
			C[i][j] = 0;
		}
	}

	int M[200][3];
	for(int i=0; i<N; i++){
		cin >> M[i][0] >> M[i][1] >> M[i][2];

		C[M[i][0]-1][0]++;
		C[M[i][1]-1][1]++;
		C[M[i][2]-1][2]++;
	}

	for(int i=0; i<N; i++){
		for(int j=0; j<3; j++){
			if(C[M[i][j]-1][j]>=2){
				M[i][j] = 0;
			}
		}
	}

	for(int i=0; i<N; i++){
		cout << M[i][0]+M[i][1]+M[i][2] << '\n';
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a * b)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
typedef long long ll;
using namespace std;
int main(void){
  ll a,b,c;
  ll ans=LONG_MAX;
  cin>>a>>b>>c;
  if(a%2==0||b%2==0||c%2==0)ans=0;
  else{
    ans=min(ans,abs((a/2*b*c)-((a/2)+1)*b*c));
    ans=min(ans,abs((b/2*c*a)-((b/2)+1)*c*a));
    ans=min(ans,abs((c/2*a*b)-((c/2)+1)*a*b));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
loop {
	w, h = gets.split.map &:to_i
	break if w == 0
	route = (0..1).map{ (0..h).map{ [0] * (w+1) } }
	route[0][1][0] = 1
	route[1][0][1] = 1
	queues = [[], [[0, 1, 0], [1, 0, 1]]]
	i = 1
	until queues[0].empty? && queues[1].empty?
		queue = queues[i]
		queues[i] = []
		queue.each{|dir, y, x|
			next if y == h-1 && x == w-1
			#p [dir, y, x]
			yx = [y, x]
			yx[dir] += 1
			v, u = yx
			if [[h,w-1], [h-1,w]].include?([v, u]) || (v < h && u < w)
				queues[1-i] << [dir, v, u] if route[dir][v][u] == 0 
				route[dir][v][u] += route[dir][y][x]
				route[dir][v][u] %= 100000
			end
			yx = [y, x]
			yx[1-dir] += 2
			v, u = yx
			if [[h,w-1], [h-1,w]].include?([v, u]) || (v < h && u < w)
				queues[i] << [1-dir, v, u] if route[1-dir][v][u] == 0
				route[1-dir][v][u] += route[dir][y][x]
				route[1-dir][v][u] %= 100000
			end
		}
		i = 1 - i
	end
	p (route[0][h-1][w-1] + route[1][h-1][w-1] + route[0][h][w-1] + route[1][h-1][w]) % 100000
}

Measured memory_bytes: 6164
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
  vector<int> v;
  stack<int> a;
  stack<int> b;
  vector<int> aa;
  vector<int> bb;
  int n, buf;
  long sum = 0;
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> buf;
    v.push_back(buf);
  }
  sort(v.begin(),v.end());
  // for(auto a : v){
  //   cout << a << " ";
  // }
  // cout << endl;
  int del = n % 2;
  for(int i = n / 2 + del; i < n;i++) a.push(v.at(i));
  reverse(v.begin(), v.end());
  for(int i = n / 2; i < n;i++) b.push(v.at(i));

  // while(!a.empty()) {cout << a.top() << " "; a.pop();}
  // cout << endl;
  // while(!b.empty()) {cout << b.top() << " "; b.pop();}
  // cout << endl;

  aa.push_back(a.top());
  bb.push_back(a.top());
  a.pop();
  
  while(true){
    priority_queue<pair<int, string>> qu;
    if(!a.empty()){
      qu.push(make_pair(abs(aa.back() - a.top()), "aa"));
      qu.push(make_pair(abs(bb.back() - a.top()), "ba"));
    }
    if(!b.empty()){
      qu.push(make_pair(abs(aa.back() - b.top()), "ab"));
      qu.push(make_pair(abs(bb.back() - b.top()), "bb"));
    }
    if(qu.top().second == "aa"){
      aa.push_back(a.top()); a.pop();
    }else if(qu.top().second == "ab"){
      aa.push_back(b.top()); b.pop();      
    }else if(qu.top().second == "ba"){
      bb.push_back(a.top()); a.pop();      
    }else if(qu.top().second == "bb"){
      bb.push_back(b.top()); b.pop();            
    }
    if(a.empty() == true && b.empty() == true) break;
  }
  reverse(aa.begin(),aa.end());
  aa.erase(aa.end()-1);
  aa.insert(aa.end(), bb.begin(), bb.end());

  for(int i = 0; i < aa.size() - 1; i++){
    sum += abs(aa.at(i) - aa.at(i+1));
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 2172