akhauriyash/Code-Regression huggingface dataset:
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
-- https://qiita.com/drken/items/cce6fc5c579051e64fab#abc-087-d-people-on-a-line の Haskell 実装
import           Control.Monad               (forM_, when)
import           Control.Monad.ST            (ST, runST)
import qualified Data.ByteString.Char8       as BS
import           Data.Maybe                  (fromJust)
import           Data.Vector.Unboxed.Mutable (STVector, Unbox)
import qualified Data.Vector.Unboxed.Mutable as MV

main :: IO ()
main = do
  [n, m] <- readInts <$> BS.getLine
  lrds <- map readInts . BS.lines <$> BS.getContents
  putStrLn $ if solve n m lrds then "Yes" else "No"

solve :: Int -> Int -> [[Int]] -> Bool
solve n _ lrds = runST $ do
  wuf <- create n 0 :: ST s (WeightedUnionFind s Int)
  allM (solve' wuf) lrds

solve' :: WeightedUnionFind s Int -> [Int] -> ST s Bool
solve' wuf [l, r, d] = do
  let (l', r') = (l - 1, r - 1)
  f <- find wuf l' r'
  if f
    then do
      d' <- diff wuf l' r'
      return $ d' == d
    else do
      _ <- unite wuf l' r' d
      return True
solve' _ _ = undefined

allM :: (Monad m) => (a -> m Bool) -> [a] -> m Bool
allM _ []     = return True
allM p (x:xs) = do
  q <- p x
  if q
    then allM p xs
    else return False

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

readInts :: BS.ByteString -> [Int]
readInts = map readInt . BS.words

-- WeightedUnionFind
data WeightedUnionFind s a = WeightedUnionFind
  { par  :: STVector s Int
  , rank :: STVector s Int
  , dw   :: STVector s a
  }

create :: Unbox a => Int -> a -> ST s (WeightedUnionFind s a)
create n w = do
  par' <- MV.new n
  forM_ [0 .. n-1] $ \i ->
    MV.write par' i i
  rank' <- MV.replicate n 0
  dw' <- MV.replicate n w
  return $ WeightedUnionFind par' rank' dw'

root :: (Num a, Unbox a) => WeightedUnionFind s a -> Int -> ST s Int
root wuf x = do
  px <- MV.read (par wuf) x
  if px == x
    then return x
    else do
      r <- root wuf px
      dwpx <- MV.read (dw wuf) px
      MV.modify (dw wuf) (+ dwpx) x
      MV.write (par wuf) x r
      return r

weight :: (Num a, Unbox a) => WeightedUnionFind s a -> Int -> ST s a
weight wuf x = root wuf x >> MV.read (dw wuf) x

unite :: (Num a, Unbox a) => WeightedUnionFind s a -> Int -> Int -> a -> ST s Bool
unite wuf x y w = do
  wx <- weight wuf x
  wy <- weight wuf y
  let w' = w + wx - wy
  x' <- root wuf x
  y' <- root wuf y
  if x' == y'
    then return False
    else do
      rx <- MV.read (rank wuf) x
      ry <- MV.read (rank wuf) y
      let (x'', y'', w'') = if rx >= ry then (x', y', w') else (y', x', -w')
      when (rx == ry) $ MV.modify (rank wuf) (+ 1) x''
      MV.write (par wuf) y'' x''
      MV.write (dw wuf) y'' w''
      return True

find :: (Num a, Unbox a) => WeightedUnionFind s a -> Int -> Int -> ST s Bool
find wuf x y = (==) <$> root wuf x <*> root wuf y

diff :: (Num a, Unbox a) => WeightedUnionFind s a -> Int -> Int -> ST s a
diff wuf x y = (-) <$> weight wuf y <*> weight wuf x


Measured memory_bytes: 8060
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int main() {
    string s;
    cin >> s;
    string ss;
    int len = s.size();
    for (int i = 0; i < len; i++) {
        if (s[i] != 'x') {
            ss += s[i];
        }
    }
    string tt = ss;
    reverse(tt.begin(), tt.end());
    if (tt != ss) {
        cout << -1 << endl;
        return 0;
    }
    string t = s;
    reverse(t.begin(), t.end());
    ll ans = 0;
    int center = (tt.size() + 1) / 2;
    int ja = 0;
    int jb = 0;
    for (int i = 0; i < center; i++) {
        int numa = 0;
        int numb = 0;
        while (true) {
            if (s[ja] == 'x') {
                ja++;
                numa++;
            } else {
                ja++;
                break;
            }
        }
        while (true) {
            if (t[jb] == 'x') {
                jb++;
                numb++;
            } else {
                jb++;
                break;
            }
        }
        ans += abs(numa - numb);
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class c{
    public static void Main(){
        long ans = 0;
        long div = (long)Math.Pow(10,9)+7;
        long n = long.Parse(Console.ReadLine());
        long[] num = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
        long[] copy = new long[n];
        for(long i=0; i<n; i++){
            copy[i] = num[i];
        }
        for(long i=n-1; i>0; i--){
            copy[i-1] += copy[i];
            copy[i-1] %= div;
        }
        for(long i=0; i<n-1; i++){
            ans += (copy[i+1] * num[i]) % div;
            ans %= div;
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 45852
#include <stdio.h>
#include <string.h>

int main(void) {
	char D[20],S[20];
	int N=3,n=20;
	fgets(D,n,stdin);
	if(3>strlen(D)-1){
		return 1;
	}
	strncpy(S,D,N);
	if ( N > 0 ) {
        S[N] = '\0';
    }
	printf("%s",S);

}


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

int main() {
int a[]={9,0,1,0,2,0,1,0,0,1,0,1,0};
int x,y;
cin>>x>>y;
if(a[x]==a[y]) cout <<"Yes"<<endl;
else cout <<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int R;
    cin>>R;
    if(R<1200){
        cout<<"ABC"<<endl;
    }
    if(1200<=R && R<2800){
        cout<<"ARC"<<endl;
    }
    if(2800<=R){
        cout<<"AGC"<<endl;
    }
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
P = [0, abs(H[0]-H[1])]
for i in range(1, N-1):
	P.append(min(P[i-1]+abs(H[i-1]-H[i+1]), P[i]+abs(H[i]-H[i+1])))
print(P[-1])

Measured memory_bytes: 20432
package main

import (
	"fmt"
	"sort"
)

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func reverseInts(s []int) []int {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return s

}

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func main() {
	var N int
	fmt.Scan(&N)

	var si []string = make([]string, N)

	for i := range si {
		fmt.Scan(&si[i])
	}

	var mapsi map[string]int = map[string]int{}

	for _, s := range si {
		s = SortString(s)
		mapsi[s] += 1
	}
	var ans int
	for _, v := range mapsi {
		ans += v * (v - 1) / 2
	}

	fmt.Println(ans)

}


Measured memory_bytes: 14336
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars,
    }

    let n = s.len();
    if s[0] == '0' || s[n - 1] == '1' {
        println!("-1");
        return;
    }

    for i in 0..(n - 1) / 2 {
        if s[i] != s[n - 2 - i] {
            println!("-1");
            return;
        }
    }

    let mut g: Vec<Vec<usize>> = vec![vec![]; n];
    let mut f: Vec<usize> = vec![];

    {
        let mut add_edge = |u: usize, v: usize| {
            g[u].push(v);
            g[v].push(u);
        };

        for i in 0..n - 1 {
            if s[i] == '0' {
                f.push(i);
            } else {
                for &k in f.iter() {
                    add_edge(i, k);
                }
                f.clear();
                f.push(i);
            }
        }

        for &k in f.iter() {
            add_edge(n - 1, k);
        }
    }

    dfs(0, None, &g);
}

fn dfs(u: usize, prev: Option<usize>, g: &Vec<Vec<usize>>) {
    for &v in g[u].iter() {
        if Some(v) == prev {
            continue;
        }

        println!("{} {}", u + 1, v + 1);
        dfs(v, Some(u), g);
    }
}


Measured memory_bytes: 28796
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define in (void)scanf
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
//#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(int i=(int)(l);i<(int)(r);i+=(int)(k))
//#define Repp(i,l,r,k)for(LL i=(LL)(l);i<(LL)(r);i+=(LL)(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009,4999999999999997
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
//typedef struct fac { LL n, exp; }F;
//LL fact(LL n,F*a){LL x=n,i,j,c=0;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
LL nibtan(LL* a,LL n,LL x){LL p=0,q=n/2,r=n-1;while(r-p>1){if(x>=a[q])p=q;if(x<=a[q])r=q;q=(p+r)/2;}return a[p]==x?p:r;}
//snippet

#define N 300009

void run(void) {
	LL n, d, x, y, ans = 0;
	in("%lld%lld", &n, &d);
	rep(i, n) {
		in("%lld%lld", &x, &y);
		if (x * x + y * y <= d * d)ans++;
	}
	printf("%lld\n", ans);
}

int main(void) {
	int test = 1;
//	in("%d", &test);
	while (test--) {
		run();
		fflush(stdout);
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    string s;
    cin >> s;
    int len = s.length();

    int mini = INF;
    for(int i = 0;i < len-1;i++){
        if(s[i] != s[i+1]){
            mini = min(mini,max(i+1,len-(i+1)));
        }
    }
    if(mini == INF){
        mini = len;
    }
    cout << mini << endl;


    return 0;
}

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

using namespace std;

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

int main(){
  char c;
  int mod = 1000000007;
  int d[13] = {1};
  while(cin >> c){
    int e[13] = {0};
    REP(i, 13){
      REP(j, 10) if(c == '?' || c == '0' + j){
        (e[(i * 10 + j) % 13] += d[i]) %= mod;
      }
    }
    REP(i, 13){
      d[i] = e[i];
    }
  }
  cout << d[5] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
ll com(ll n, ll r){
    if(r<0 || r>n) return 0;
    if(r==1) return n;
    else if(r==2) return n*(n-1)/2;
    else return n*(n-1)*(n-2)/6;
}
ll pow(ll n, ll k){
    ll res=1;
    rep(i,k) res*=n;
    return res;
}

ll n,k; string s;
ll rec(ll i, ll k, bool smaller){
    if(i==n){
        if(k==0) return 1;
        else return 0;
    }
    if(k==0) return 1;
    if(smaller) return com(n-i,k)*pow(9,k);
    else{
        if(s[i]=='0') return rec(i+1,k,false);
        else{
            ll zero=rec(i+1,k,true);
            ll aida=rec(i+1,k-1,true)*(s[i]-'1');
            ll icchi=rec(i+1,k-1,false);
            return zero+aida+icchi;
        }
    }
}

int main(){
    cin>>s>>k;
    n=s.size();
    cout<<rec(0,k,false)<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int NA = Reader.Int();
        var A = Reader.IntArray(NA);
        int NB = Reader.Int();
        var B = Reader.IntArray(NB);
        var dic = new Dictionary<int, int>();
        foreach (var a in A)
            if (dic.ContainsKey(a)) dic[a]++;
            else dic[a] = 1;
        foreach (var b in B)
            if (!dic.ContainsKey(b) || --dic[b] < 0) { Console.WriteLine("NO"); return; }
        Console.WriteLine("YES");
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { Dispose(); A = new string[0]; }
    public static void Set(TextReader r) { Init(); reader = r; }
    public static void Set(string file) { Init(); reader = new StreamReader(file); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    public static void Dispose() { reader.Dispose(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 47132
#include <stdio.h>
 
int main()
{
    int i;
    char s[100000];
  	char a[]="AGCT";
  	char b[]="TCGA";
    scanf("%s",s);
    for(i=0; i<4; i++) {
        if(s[0]==a[i]) {
            printf("%c",b[i]);
        } 
    }

    return 0;
}

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

int main(){
  int n;
  char ss[1010];
  char ans[1010];
  int d;
  scanf("%d",&n);
  scanf("%s",ss);
  scanf("%d",&d);
  strcpy(ans,ss);
  for(int i=0;(i<n) && d;i++){
    if(ans[i] == '0'){
      ans[i]='1';
      d--;
    }
  }
  for(int i=n-1;(i>=0) && d;i--){
    if(ans[i] == '1' && ss[i]=='1'){
      ans[i]='0';
      d--;
    }
  }
  printf("%s\n",ans);
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}


int main() {
	IOS;
	int n, a, b;
	cin >> n >> a >> b;
	ll sum = 0;
	FOR(i,1,n + 1) {
		int t = digisum(i);
		if (t >= a && t <= b)sum += i;
	}
	cout << sum << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String N = sc.next();
        String ans="No";
        for(int i=0;N.length()>i;i++){
            char tmp =N.charAt(i);
            if('9'==tmp){
                ans="Yes";
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
N = int(input())
A = list(map(int, input().split()))
b = A[0]
def gcm(x,y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    return gcm(y,x%y)
for a in A:
    b = gcm(b,a)
print(b)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979
using ll = long long;
using P = pair<int,int>;

ll divisor=1e9+7;
int main(){
	ll a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	rep(i,3){
		if(a[i]%2==0){
			puts(0);
			return 0;
		}
	}
	puts(a[0]*a[1]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

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

	rep(i,n){
		if(a[i]%2==0){
			if(!(a[i]%3==0 || a[i]%5==0)){
				cout << "DENIED" << endl;
				return;
			}
		}
	}

	cout << "APPROVED" << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define pf pop_front
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=2e5+100;
string a,b;
ll aa,bb;
int main()
{
    while(cin>>a>>b)
    {
        string t;
        cin>>aa>>bb>>t;
        if(t==a) aa--;
        else bb--;
        cout<<aa<<" "<<bb<<"\n";
    }
}



Measured memory_bytes: 256
n = gets.chomp.to_i
h_n = gets.chomp.split.map(&:to_i)

results = []
n.times do |_|
  results << Float::INFINITY
end

results[0] = 0

h_n.each.with_index(0) do |h_i, i|
  next if i == h_n.length - 1

  cost_to_next_one = results[i] + (h_n[i+1] - h_i).abs
  results[i+1] = cost_to_next_one if results[i+1] > cost_to_next_one

  next if i == h_n.length - 2

  cost_to_next_two = results[i] + (h_n[i+2] - h_i).abs
  results[i+2] = cost_to_next_two if results[i+2] > cost_to_next_two
end

puts results[-1]

Measured memory_bytes: 21536
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] arrChar = s.toCharArray();
		sc.close();
 
		int diffAns010 = 0;
		// 0101010101....に修正する場合の修正回数
		for (int i = 0; i < arrChar.length; i++) {
			if (i % 2 == 0 && arrChar[i] == '1') {
				diffAns010++;
			} else if (i % 2 == 1 && arrChar[i] == '0') {
				diffAns010++;
			}
		}
 
		int diffAns101 = 0;
		// 1010101010.....に修正する場合の修正回数
		for (int i = 0; i < arrChar.length; i++) {
			if (i % 2 == 0 && arrChar[i] == '0') {
				diffAns101++;
			} else if (i % 2 == 1 && arrChar[i] == '1') {
				diffAns101++;
			}
		}
		//　修正回数が少ないほうの値を返す
		System.out.println(Math.min(diffAns010, diffAns101));
	}
}

Measured memory_bytes: 28116
import java.io.InputStream
import java.io.BufferedReader

fun gcd(a: Long, b:Long):Long {
  if(a%b==0L) return b else return gcd(b, a%b)
}

fun main(args: Array<String>) {
  val inputStream = System.`in`
  val allText = inputStream.bufferedReader()
                           .use(BufferedReader::readText)
  allText.trim().split('\n')
         .map { s->
            val t = s.split(' ').map{ t -> t.toLong() }
            val g = gcd(t[0], t[1])
            val l = (t[0] / g) * t[1]
            Pair(g, l)
         }
         .forEach{ t -> println("%d %d".format(t.first, t.second)) }
}


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

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

  ll ans = 0;

  while(x >= 500){
    x -= 500;
    ans += 1000;
  }

  while(x >= 5){
    x -= 5;
    ans += 5;
  }

  cout << ans;

  return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//---------------------------------------------------------------
#define fastio std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
//--------------------------------------------------------------


int main(int argc,char** argv){ fastio; myio;
  vvi c(3,vi(3,0));
  rep(i,3) rep(j,3) cin>>c[i][j];
  vi a(3,0);
  vi b(3,0);
  rep(i,101){
    a[0] = i;
    b[0] = c[0][0]-a[0];
    b[1] = c[0][1]-a[0];
    b[2] = c[0][2]-a[0];
    a[1] = c[1][0]-b[0];
    a[2] = c[2][0]-b[0];
    if(
      c[1][1]==a[1]+b[1] &&
      c[1][2]==a[1]+b[2] &&
      c[2][1]==a[2]+b[1] &&
      c[2][2]==a[2]+b[2] 
    ){cout<<"Yes"; return 0;}
  }
  cout<<"No";
}

Measured memory_bytes: 256
import copy
n,m,q=map(int,input().split())
abcd = [map(int, input().split()) for _ in range(q)]
a,b,c,d=[list(i) for i in zip(*abcd)]
ans=0

def dfs(B):

    global ans,n,m,q,a,b,c,d
    A=copy.deepcopy(B)
    if(len(A)==n+1):
        now=0
        for i in range(q):
            if A[b[i]]-A[a[i]]==c[i]:
                now += d[i]
        
        ans = max(ans,now)
       # A.append(now)
       # print(A)
        return
    
    A.append(A[-1])
    while(A[-1]<=m):
        dfs(A)
        A[-1]=A[-1]+1

        
B=[1,1]
dfs(B)
print(ans)





Measured memory_bytes: 9280
import { readFileSync } from 'fs'

const range = (n) => Array(n).fill(null).map((_, i) => i)

function main(input: string) {
  const [[N, M], ...lines] = input.split('\n').map(v => v.split(' ').map(Number))

  const kList = lines.slice(0, M)
  const pList = lines[M]

  const fns = kList.map(([, ...switches], i) => {
    return (v: number) =>
      switches.map((s) => v & (1 << (s - 1)) ? 1 : 0).reduce((sum, v) => sum + v, 0) % 2 === pList[i]
  })

  const result = range(2 ** N).filter(n => fns.every(fn => fn(n))).length

  console.log(result)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 9380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
typedef long long ll;
typedef multiset<ll> S;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
const int max_n=700000;
ll fac[max_n], finv[max_n], inv[max_n];
// テーブルを作る前処理 O(max_n)
void init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < max_n; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv [mod%i] *  (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// 二項係数計算 O(1)
long long modcom(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int main(){
    init();
    ll x,y;cin>>x>>y;
    ll a=2*x-y;
    ll b=2*y-x;
    if(a%3==0&&b%3==0){
        a/=3;
        b/=3;
    }
    else{
        cout<<0<<endl;
        return 0;
    }
  if(a<0||b<0){
    cout<<0<<endl;
    return 0;
  }
    cout<<modcom(a+b,a);
}


Measured memory_bytes: 16640
#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)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;

int main()
{
  int A,B;
  cin >> A >> B;
  int ans;
  if (A >= 13) ans = B;
  else if (A >= 6) ans = B / 2;
  else ans = 0;
  cout << ans << endl;

  return 0;
}


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

int main(){
    vector<int> v(10);
    int index = 0;  
    for(int i = 0; i< 10; i++){
        cin >> v[i];
    }
    cout << *max_element(v.begin(),v.end()) << endl;
    index = distance(v.begin(),max_element(v.begin(),v.end()));
    v[index] = 0;
    cout << *max_element(v.begin(),v.end()) << endl;
    index = distance(v.begin(),max_element(v.begin(),v.end()));
    v[index] = 0;
    cout << *max_element(v.begin(),v.end()) << endl;
    index = distance(v.begin(),max_element(v.begin(),v.end()));
    v[index] = 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    double a,b,c,d,e,f;
    double x,y;
    while(cin >> a >> b >> c >> d >> e >> f){
        x = (double)((c*e - b*f)/(a*e - b*d) * 1000) / 1000.0;
        y = (double)((d*c - a*f)/(b*d - a*e) * 1000) / 1000.0;
        x = (x == -0.0) ? 0.000 : x;
        y = (y == -0.0) ? 0.000 : y;
        cout << fixed << setprecision(3);
        cout << x << " " << y << endl;
    }
    return 0;
}


Measured memory_bytes: 3216
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=1e5+10;
    static const int INF=1e9+7;
    static const int MOD=1e9+7;
    int N,K;
    vector<int>G[MAXN];
    ll dfs(int rt,int fa){
        ll remain=0;
        if(fa==-1)remain=K-1;
        else remain=K-2;
        if(G[rt].size()>K)return 0;
        ll prod=1;
        for(auto v:G[rt]){
            if(v==fa)continue;
            prod=prod*dfs(v,rt);
            prod%=MOD;
            prod=prod*remain%MOD;
            remain--;
        }
        return prod;
    }
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>N>>K;
        for(int u=1;u<=N-1;u++){
            int a,b;
            cin>>a>>b;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        ll ans=dfs(1,-1);
        ans=ans*K%MOD;
        cout<<ans;
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

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

using namespace std;

typedef long long LL;

int main()
{
  string S;
  cin >> S;
  string T = "CODEFESTIVAL2016";
  int ans = 0;
  for (size_t i = 0; i < S.length(); i++) {
    if(S[i] != T[i]){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
//    s s s s s s 0 0
    val (n, k, s) = readLongList()
    val ans = Array(n.toInt()) { if (it < k) s else { if (s == 1000000000L) 1 else s + 1} }.joinToString(  " ")
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 52832
#include <bits/stdc++.h>
#include <boost/range/adaptor/indexed.hpp>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
std::ostream &operator<<(std::ostream &ostr, const std::vector<T> &v) {
  for (const auto &i : v | boost::adaptors::indexed())
    ostr << (i.index() > 0 ? " " : "") << i.value();
  return ostr;
}

inline void Main() {
  // code
  string s;
  cin>>s;
  cout<<s.at(0)<<s.size()-2<<s.at(s.size()-1)<<endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100100],b[100100],c[200100],n;
 
int lowbit(int x)
{
    return x&(-x);
}
 
void add(int x,int val)
{
    x=x+(n+1);
    int i;
    for (i=x;i<=2*n+1;i+=lowbit(i)) c[i]+=val;
}
 
long long sum(int x)
{
    x+=(n+1);
    int i;
    long long ans=0;
    for (i=x;i>0;i-=lowbit(i)) ans+=c[i];
    return ans;
}
 
long long work(int num)
{
    int i,tmp=0;long long ans=0;
    for (i=1;i<=n;i++)
    {
        if (a[i]<=num) tmp++; else tmp--;
        ans+=sum(tmp-1);
        add(tmp,1);
    }
    tmp=0;
    for (i=1;i<=n;i++)
    {
        if (a[i]<=num) tmp++; else tmp--;
        add(tmp,-1);
    }
    return ans;
}
 
int main()
{
    int i;
    scanf("%d",&n);
    for (i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    memset(c,0,sizeof(c));
    sort(b+1,b+1+n);
    int m=unique(b+1,b+1+n)-b-1;
    int l=1,r=m,ans;
    long long target=(long long)n*(n+1)/2;target=target/2+1;
    add(0,1);
    while (l<=r)
    {
        int mid=(l+r)/2;
        if (work(b[mid])>=target) {ans=b[mid];r=mid-1;}
        else l=mid+1;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1792
<?php
fscanf(STDIN, "%d", $n);
$a = explode(' ', trim(fgets(STDIN)));
$b = explode(' ', trim(fgets(STDIN)));
$c = explode(' ', trim(fgets(STDIN)));
$a = array_count_values($a);
$b = array_count_values($b);
$c = array_count_values($c);

foreach (['a','b','c'] as $z) {
	foreach (${$z} as $k => $v) {
		$q[$k][$z] = $v;
	}
}
krsort($q);
$x = $vb = $vc = 0;
foreach ($q as $k => $r) {
	ksort($r);
	foreach ($r as $z => $v) {
		if ($z == 'a') {
			$x += $v * $vb;
		} elseif ($z == 'b') {
			$vb += $v * $vc;
		} else {
			$vc += $v;
		}
	}
}
echo $x;

Measured memory_bytes: 150252
#include<iostream>

using namespace std;

int main(){
  string s;
  int n,mx=0;
  cin>>n>>s;
  int c=0;
  for(int i=0;i<n;i++){
    if(s[i]=='I') c++;
    else c--;
    mx=max(mx,c);
  }
  cout<<max(mx,0)<<endl;
}


Measured memory_bytes: 256
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/28 09:26:53 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1000000007;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	int	n;
	cin >> n;

	vector<int>	V(n);
	rep(i, n)
		cin >> V.at(i);

	sort(V.begin(), V.end());

	int	cnt;
	cnt = 0;

	rep(i, n - 2)
	{
		for (int j = i + 1; j < n - 1; j++)
		{
			int r;
			r = lower_bound(V.begin(), V.end(), V.at(i) + V.at(j)) - V.begin();
			int	l;
			l = j + 1;
			cnt += r - l;
		}
	}
	cout << cnt << endl;
}
// END

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


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n, q;
	string s;
	cin >> n >> q >> s;
	vector<char> ts(q), ds(q);
	for(int i = 0; i < q; ++i){
		cin >> ts[i] >> ds[i];
	}

	int lt = 0, rt = n;
	for(int i = q - 1; i >= 0; --i){
		if(ds[i] == 'L'){
			if(lt < n && ts[i] == s[lt]){
				++lt;
			}
			if(rt < n && ts[i] == s[rt]){
				++rt;
			}
		}
		else{
			if(lt >= 1 && ts[i] == s[lt - 1]){
				--lt;
			}
			if(rt >= 1 && ts[i] == s[rt - 1]){
				--rt;
			}
		}
	}
	int ans = max(rt - lt, 0);
	cout << ans << endl;
}



}
int main() try{
	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


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

using namespace std;
int n;
int s(long long x) {
	int sum = 0;
	while (x) sum += x % 10, x /= 10;
	return sum;
}
long long stk[1000001];
int top = 0;
int main( ) {
	for (int i = 1; i <= 100000; i ++) {
		while (top && 1LL * stk[top] * s(i) > 1LL *i * s(stk[top])) -- top;
		stk[++ top] = i;
	}
	for (int r = 0; r * 10000 + 109999 <= 99999999; ++ r) {
		int i = r * 10000 + 109999;
		while (top && 1LL * stk[top] * s(i) > 1LL *i * s(stk[top])) -- top;
		stk[++ top] = i;
	}
	for (int r = 0; 1LL * r * 10000000 + 109999999 <= 99999999999LL; ++ r) {
		long long i = 1LL * r * 10000000 + 109999999;
		while (top && 1LL * stk[top] * s(i) > 1LL *i * s(stk[top])) -- top;
		stk[++ top] = i;
	}
	for (int r = 0; r <= 1000000; ++ r) {
		long long i = 1LL * r * 10000000000 + 109999999999;
		while (top && 1LL * stk[top] * s(i) > 1LL *i * s(stk[top])) -- top;
		stk[++ top] = i;
	}
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++)
		printf("%lld\n", stk[i]);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const ll N = 2e5 + 5;


main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"regexp"
)

var S string

func main() {
	fmt.Scan(&S)
	r := regexp.MustCompile(`^(eraser|erase|dreamer|dream)+$`)
	if r.MatchString(S) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

/*  ----------------------------------------  */

func gcd(x, y uint64) uint64 {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans int = 1
	for i := x - y; 0 < i; i-- {
		ans *= i
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }

type XY struct {
	x int
	y int
}

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}


Measured memory_bytes: 1408
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を数値で返却する
def gets_i()
  gets.chomp.to_i
end
N = gets_i

require 'prime'

factors = N.prime_division

dpp factors

if factors.empty?
  puts 0
else
  count = 0
  factors.each do |_, c|
    i = 1
    loop do
      break if c < i
      c = c - i
      count += 1
      i += 1
    end
  end
  puts count
end


Measured memory_bytes: 14628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

int n, k;
ll pre[102][MAXN];
vector<int> l, r, mt;
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> k;
    for (int i=1,j; i<=n; i=j+1) {
        j = n/(n/i);
        l.emplace_back(i);
        r.emplace_back(j);
    }

    REP (i, SZ(l)) {
        int idx = lower_bound(r.begin(), r.end(), n/l[i]) - r.begin();
        assert(r[idx] == n/l[i]);
        mt.emplace_back(idx);
        debug(l[i], r[i], idx);
    }

    int bk = SZ(mt);

    REP (i, bk) {
        pre[0][i] = 1;
    }

    REP1 (i, k) {
        REP (j, bk) {
            pre[i][j] = j ? pre[i][j-1] : 0;
            pre[i][j] += pre[i-1][mt[j]] * (r[j]-l[j]+1) % MOD;
            pre[i][j] %= MOD;
            //debug(i, j, pre[i-1][mt[j]] * (r[j]-l[j]+1));
        }
    }

    cout << pre[k][bk-1] << endl;
    return 0;
}


Measured memory_bytes: 79100
import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.string;
import std.conv;

void main(){
    auto n = readln().chomp().to!int();
    auto s = readln();
    solve(n, s).writeln();
}

int solve(int n, string s){
    int[] kindNums;
    foreach(cutPlace; 1..n) {
        auto right = s[0..cutPlace];
        auto left = s[cutPlace..$];
        char[] collection;
        foreach(ch; right) {
            if(left.find(ch).length != 0){
                if(collection.find(ch).length == 0){
                    collection ~= ch;
                }
            }
        }
        kindNums ~= collection.length.to!int();
    }
    return kindNums.sort!("a>b")()[0];
}

Measured memory_bytes: 256
from collections import *
n,m=map(int,input().split())
d=defaultdict(list)
for s in m*[0]:
    a,b=map(int,input().split())
    d[a].append(b)
    d[b].append(a)
def DFS_dict(point,TFlist):
    if all(TFlist):
        return 1
    ans=0
    for i in d[point]:
        if TFlist[i-1]:
            continue
        TFlist[i-1]=True
        ans+=DFS_dict(i,TFlist)
        TFlist[i-1]=False
    return ans
TFlist=[True]+[False]*(n-1)
print(DFS_dict(1,TFlist))

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
using namespace std;


int main() {
	int a,b;
	cin >> a >> b;
	if (a > b)
		cout << "a > b" << endl;
	else if (a < b)
		cout << "a < b" << endl;
	else
		cout << "a == b" << endl;
}

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

public class MainClass
{

	public static void Main(string[] args)
	{
		string[] b = Input();
		int x = int.Parse(b[0]);
		int a = int.Parse(b[1]);
		Console.WriteLine(x<a?"0":"10");
	
		
	}

	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

	
}



Measured memory_bytes: 13140