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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

int x[101];
int y[101];
int h[101];

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

    REP(i,N+1){
        cin >> x[i] >> y[i] >> h[i];
    }

    int H = -1;
    REP(i,101)REP(j,101){
        bool flag = true;
        REP(k,N){
            if(h[k] >= 1){
                H = h[k] + abs(x[k] - i) + abs(y[k] - j);
                break;
            }
        }

        REP(k,N){
            if(h[k] != max(0, H - abs(x[k] - i) - abs(y[k] - j))){
                flag = false;
            }
        }

        if(flag == true){
            cout << i << " " << j << " " << H << endl;
            return 0;
        }
    }
}


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

int main()
{
  int H, W;
  string input[55];

  cin >> H >> W;
  for (int i = 0; i < H; i++)
  {
    cin >> input[i];
    for (int j = 0; j < W; j++)
      if (input[i][j] == '.') input[i][j] = '0';
  }
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (input[i][j] != '#' && i != 0     &&               input[i - 1][j]     == '#') input[i][j]++;
      if (input[i][j] != '#' && j != 0     &&               input[i][j - 1]     == '#') input[i][j]++;
      if (input[i][j] != '#' && i != 0     && j != 0     && input[i - 1][j - 1] == '#') input[i][j]++;
      if (input[i][j] != '#' && i != H - 1 &&               input[i + 1][j]     == '#') input[i][j]++;
      if (input[i][j] != '#' && j != W - 1 &&               input[i][j + 1]     == '#') input[i][j]++;
      if (input[i][j] != '#' && i != H - 1 && j != W - 1 && input[i + 1][j + 1] == '#') input[i][j]++;
      if (input[i][j] != '#' && i != 0     && j != W - 1 && input[i - 1][j + 1] == '#') input[i][j]++;
      if (input[i][j] != '#' && i != H - 1 && j != 0     && input[i + 1][j - 1] == '#') input[i][j]++;
    }
  }
  for (int i = 0; i < H; i++)
    cout << input[i] << endl;
}


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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    a--;
    b--;
    c--;
    d--;
    string str;
    cin>>str;
        bool ok = true;
        for(int i=a;i<min(c,n-1);++i){
            if(str[i] == '#' && str[i+1] == '#')ok = false;
        }
        
        for(int i=b;i<min(d,n-1);++i){
            if(str[i] == '#' && str[i+1] == '#')ok = false;
        }
    if(b < c && d < c){
        bool ok2 = false;
        for(int i=b-1;i<min(d,c-1);++i){
            if(str[i] == '.' && str[i+1] == '.' && str[i+2] == '.') ok2 = true;
        }
        if(ok2 && ok) ok = true;
        else ok = false;
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 640
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

mapping = listArray (0,7) "01235789" :: Array Int Char

f n = f' [] n
  where
    f' l 0 = l
    f' l n = let (q,r) = divMod n 8 in f' ((mapping!r):l) q
  


main = map f . takeWhile (/=0) . map readInt . lines <$> getContents >>= mapM_ putStrLn



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

signed main(){
	int n;
	cin >> n;
	vector<double> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	vector<vector<double> > dp(n + 1, vector<double> (n + 1, 0.0));
	dp[0][0] = 1.0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= n; j++){
			dp[i + 1][j] += dp[i][j] * (1.0 - a[i]);
			if(j >= 1) dp[i + 1][j] += dp[i][j - 1] * a[i];
		}
	}
	double ans = 0.0;
	for(int i = (n + 1) / 2; i <= n; i++){
		ans += dp[n][i];
	}
	cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 73788
S = input()

if (int(S[0:2]) >= 1) and (int(S[0:2]) <= 12):
  if (int(S[2:4]) >= 1) and (int(S[2:4]) <= 12):
    print("AMBIGUOUS")
  else:
    print("MMYY")
elif (int(S[2:4]) >= 1) and (int(S[2:4]) <= 12):
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3064
import sys
readline = sys.stdin.readline

from heapq import heappop as hpp, heappush as hp
def dijkstra(N, s, Edge):
    inf = geta
    dist = [inf] * N
    dist[s] = 0
    Q = [(0, s)]
    dp = [0]*N
    dp[s] = 1
    while Q:
        dn, vn = hpp(Q)
        if dn > dist[vn]:
            continue
        for df, vf in Edge[vn]:
            if dist[vn] + df < dist[vf]:
                dist[vf] = dist[vn] + df
                dp[vf] = dp[vn]
                hp(Q, (dn + df,vf))
            elif dist[vn] + df == dist[vf]:
                dp[vf] = (dp[vf] + dp[vn]) % MOD
    return dist, dp

MOD = 10**9+7
N, M = map(int, readline().split())
S, T = map(int, readline().split())
S -= 1
T -= 1

geta = 10**15
Edge = [[] for _ in range(N)]
for _ in range(M):
    u, v, d = map(int, readline().split())
    u -= 1
    v -= 1
    Edge[u].append((d, v))
    Edge[v].append((d, u))
    

dists, dps = dijkstra(N, S, Edge)
distt, dpt = dijkstra(N, T, Edge)
st = dists[T]

onpath = [i for i in range(N) if dists[i] + distt[i] == st]

ans = dps[T]**2%MOD
for i in onpath:
    if 2*dists[i] == 2*distt[i] == st:
        ans = (ans - pow(dps[i]*dpt[i], 2, MOD))%MOD
    
    for cost,vf in Edge[i]:
        if dists[i]+cost+distt[vf] == st:
            if 2*dists[i] < st < 2*dists[vf]:
                ans = (ans - pow(dps[i]*dpt[vf], 2, MOD))%MOD
print(ans)

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

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

Measured memory_bytes: 3588
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n; cin >> n; string s,t="MARCH";
	int d[5] = {};
	rep(i, 0, n) {
		cin >> s;
		rep(j, 0, 5) {
			if (s[0] == t[j]) d[j]++;
		}
	}
	int p[10] = { 0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,1 ,2 };
	int q[10] = { 1 ,1 ,1 ,2 ,2 ,3 ,2 ,2 ,3 ,3 };
	int r[10] = { 2 ,3 ,4 ,3 ,4 ,4 ,3 ,4 ,4 ,4 };
	ll ans = 0;
	rep(i, 0, 10) {
		ans += 1LL*d[p[i]] * d[q[i]] * d[r[i]];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
# N>81のときはn*nで表せないので不敵
if N>81:
    print('No')
else:
    import numpy as np
    n=np.array([1,2,3,4,5,6,7,8,9])
    amari=N%n
    shou=N//n
    if np.any((amari==0)*(shou<=9)):
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 12484
fun CharSequence.groupingCount(): Map<Char, Int> {
    val map = mutableMapOf<Char, Int>()
    for (element in this) {
        map[element] = map.getOrElse(element) { 0 } + 1
    }
    return map
}

fun main(args: Array<String>) {
    val s = readLine()!!.groupingCount()
    println(if (s.size == 2 && s.values.all { it == 2 }) "Yes" else "No")
}


Measured memory_bytes: 33772
fun main(args: Array<String>) {
    val weather = readLine()!!.toString()
    println(questionA(weather))
}

fun questionA(weather: String): String {
    return when(weather) {
        "Sunny" -> "Cloudy"
        "Cloudy" -> "Rainy"
        "Rainy" -> "Sunny"
        else -> ""
    }
}


Measured memory_bytes: 33596
#include <cstdio>
int main()
{
	int n;
	scanf("%d",&n);
	int flag=1;
	for(int i=1;i<=9;i++)
	{
		if(n%i==0)
		{
			int k=n/i;
			if(k>=1&&k<=9)
			{
				printf("Yes");
				flag=0;
				break;
			}
		}
	}
	if(flag) printf("No");
	return 0;
 } 

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

int main() {
    //freopen("", "rt", stdin);
    //freopen("", "wt", stdout);
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    if (a % 2 || b % 2 || c % 2)
        puts("0");
    else if (a == b && b == c)
        puts("-1");
    else {
        int ans = 0;
        while (!(a % 2 || b % 2 || c % 2)) {
            int temp_a = a, temp_b = b;
            a = (b + c) / 2;
            b = (temp_a + c) / 2;
            c = (temp_a + temp_b) / 2;
            ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}



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

using namespace std;
const int maxn=1e5+5;
struct node
{
    int id,c;
};
node a1[maxn],a2[maxn];
bool cmp(node a,node b)
{
    return a.c>b.c;
}
int main()
{
    int n,x;
    scanf("%d",&n);
    for(int i=0;i<n/2;i++)
    {
        scanf("%d",&x);
        a1[x].c++;
        a1[x].id=x;
        scanf("%d",&x);
        a2[x].c++;
        a2[x].id=x;
    }
    sort(a1,a1+maxn,cmp);
    sort(a2,a2+maxn,cmp);
    int z;
    if(a1[0].id!=a2[0].id)
    {
        z=a1[0].c+a2[0].c;
    }
    else
    {
        z=max(a1[1].c+a2[0].c,a1[0].c+a2[1].c);
    }
    z=n-z;
    printf("%d\n",z);
    return 0;
}


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

int main()
{
    int n;
    int i, j, k;
    long long int ans = 0;
    long long int judge[5] = {0};
    
    cin >> n;
    
    vector<string> s(n);
    
    for(i = 0; i < n; i++) {
        cin >> s[i];
        
        if(s[i][0] == 'M') {
            judge[0]++;
        } else if(s[i][0] == 'A') {
            judge[1]++;
        } else if(s[i][0] == 'R') {
            judge[2]++;
        } else if(s[i][0] == 'C') {
            judge[3]++;
        } else if(s[i][0] == 'H') {
            judge[4]++;
        }
    }
    
    for(i = 0; i < 3; i++) {
        for(j = i+1; j < 4; j++) {
            for(k = j+1; k < 5; k++) {
                ans += judge[i] * judge[j] * judge[k];
            }
        }
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int n;
    scanf("%d",&n);
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&arr[i]);
    }
    long long sum[n+1];
    sum[0]=0;
    for(int i=1;i<=n;i++)
        sum[i]=sum[i-1]+arr[i];
    long long x=sum[1];
    long long y=sum[n]-sum[1];
    long long ans=abs(x-y);
    for(int i=2;i<=n-1;i++)
    {
        x=sum[i];
        y=sum[n]-sum[i];
        ans=min(ans,abs(x-y));
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2560
import Text.Printf
import Control.Monad

main ::IO()
main = do
    [n, t] <- map (read::String->Int) . words <$> getLine
    ct <- replicateM n $ map (read::String->Int) . words <$> getLine
    let ls =  map (\x-> head x ) $ filter (\x->(head $ tail x) <= t) ct
    if length ls == 0 then putStrLn "TLE"
    else print $ minimum ls


Measured memory_bytes: 1020
"use strict"
function main(arg) {
    let data = arg.trim().split("\n")
    let [H,W,K] = data.shift().split(" ").map(Number)
    // let counter = new Array(W)
    data = data.map(e => e.split(""))
    let ans = 0
    // for (let r = 0; r <= H; r++) {
    //     // let A = [...data]
    //     let A = JSON.parse(JSON.stringify(data))
    //     if (r < H) {
    //         A[r] = A[r].map(e => 'a')
    //     }
    //     for (let c = 0; c <= W; c++) {
    //         let B = JSON.parse(JSON.stringify(A))
    //         for (let i = 0;i < H; i++) {
    //             if (c === W) break
    //             B[i][c] = 'a'
    //             // B[i][c] = i
    //         }
    //         // console.log(B.join("\n") + "\n")
    //         console.log(B.map(e => e.join("")).join("\n"))
    //         // console.log(JSON.stringify())
    //         let result = B.map(e => e.join("")).join("").split("#").length - 1
    //         console.log(result)
    //         if (result === K) {
    //             ans++
    //         }
    //     }
    //     // console.log(JSON.stringify(A))
    // }
    // console.log(ans)
    for (let r = 0;; r++) {
        let h_list = r.toString(2)
        let A = JSON.parse(JSON.stringify(data))
        if (h_list.length > H) {
            break
        }
        h_list = h_list.padStart(H,0).split("")
        fill_row(A,h_list)
        for (let c = 0;; c++) {
            let B = JSON.parse(JSON.stringify(A))
            let w_list = c.toString(2)
            if (w_list.length > W) {
                break
            }
            w_list = w_list.padStart(W,0).split("")
            // console.log(w_list)
            fill_col(B,w_list)
            let result = B.map(e => e.join("")).join("").split("#").length - 1
            if (result === K) {
                ans++
            }
            // console.log(B)
        }
        // console.log("")
        // console.log(A)
    }
    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function fill_row(arr, flgs) {
    for (let i = 0; i < flgs.length; i++) {
        if (flgs[i] === '1') {
            arr[i] = arr[i].map(e => 'a')
        }
    }
}

function fill_col(arr, flgs) {
    for (let i = 0; i < arr.length; i++) {
        for (let j = 0; j < arr[0].length; j++) {
            if (flgs[j] === '1') {
                arr[i][j] = 'a'
            }
        }
    }
}

Measured memory_bytes: 35476
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define x first
#define y second
#define mp make_pair
#define mt make_tuple

const int L = 13;
const int N = 1e6;

int l;
int q;
string t;
int pw[L];
int n;
int per[N];
int lst[N];
int dig[N];
int was[N];
int cnt = 0;

void push(int i) {
	if (dig[i] && (was[i] - cnt) % 2) {
		dig[i] = 3 - dig[i];
	}
	was[i] = cnt;
}

signed main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	pw[0] = 1;
	for (int i = 1; i < L; ++i) {
		pw[i] = pw[i - 1] * 3;
	}
	cin >> l >> t;
	n = pw[l];
	q = (int)t.size();
	for (int lvl = 0; lvl < l; ++lvl) {
		int len = pw[lvl];
		for (int i = 0; i < len; ++i) {
			per[i + 2 * len] = per[i + len] = per[i];
			dig[i] = 0;
			was[i] = 0;
			dig[i + len] = 1;
			was[i + len] = 0;
			dig[i + 2 * len] = 2;
			was[i + 2 * len] = 0;
		}
		cnt = 0;
		for (int ind = 0; ind < q; ++ind) {
			int pos = lst[ind];
			int tmp = -1;
			for (; pos < 3 * len; pos += len) {
				push(pos);
				if (dig[pos] == 2) {
					tmp = pos;
				}
			}
			assert(tmp != -1);
			if (t[ind] == 'S') {
				++cnt;
			} else {
				pos = lst[ind];
				push(pos);
				push(pos + len);
				push(pos + 2 * len);
				(++dig[pos]) %= 3;
				(++dig[pos + len]) %= 3;
				(++dig[pos + 2 * len]) %= 3;
			}
			lst[ind] = tmp;
		}
		for (int i = 0; i < 3 * len; ++i) {
			push(i);
			per[i] += dig[i] * pw[lvl];
		}
	}
	for (int i = 0; i < pw[l]; ++i) {
		cout << per[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 11372
a = int(input())
s = []
for i in range(4):
  s.append(int(a%10))
  a /= 10
s.reverse()
if (s[0]*10+s[1] >= 13 or s[0]*10+s[1] == 0) and s[2]*10+s[3] >=1 and s[2]*10+s[3]<=12:
  print('YYMM')
elif s[0]*10+s[1] >= 1 and s[0]*10+s[1] <= 12 and (s[2]*10+s[3] >=13 or s[2]*10+s[3] ==0):
  print('MMYY')
elif s[0]*10+s[1] >= 1 and s[0]*10+s[1] <= 12 and s[2]*10+s[3] >= 1 and s[2]*10+s[3] <= 12:
  print('AMBIGUOUS')
else:
  print('NA')

Measured memory_bytes: 38384
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    long long int n,sum=0;
    scanf("%lld",&n);
    long long int num[100005]={0};
    long long int book[100005]={0};
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&num[i]);
        book[num[i]]++;
        sum+=num[i];
    }
    int q;
    scanf("%d",&q);
    while(q--)
    {
        int b,c;
        scanf("%d %d",&b,&c);
        if(book[b]==0)
        {
            printf("%lld\n",sum);
            continue;
        }
        else
        {
            book[c]+=book[b];
            sum=sum+(c-b)*book[b];
            book[b]=0;
            printf("%lld\n",sum);
            continue;
        }
    }
    return 0;
}


Measured memory_bytes: 4788
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){var r=e.split("\n"),t=Number(r[0]),n=r[1].split(" ").map(function(e){return Number(e)});n.sort(function(e,r){return e-r});for(var o=n[0],u=1;u<t;u++)o+=n[u],o/=2;console.log(o)}},function(e,r){e.exports=require("fs")}]);

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;

  int ans = 0;
  REP(i,SZ(S)) ans += S[i] - '0';
  maxi(ans, (SZ(S)-1) * 9);
  int s = 0;
  for(int i=0;i<SZ(S);++i){
	if(S[i] != '0')
	  maxi(ans, s + S[i]-'0'-1 + (SZ(S)-1-i)*9);
	s += S[i] - '0';
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
    int n,m,l;
    int a[100][100];
    int b[100][100];
    long long int c[100][100];
    int i,j,k;
    
    std::cin>>n>>m>>l;

    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            std::cin>>a[i][j];
            c[i][j]=0; //初期化
        }
    }

    for(j=0;j<m;j++){
        for(k=0;k<l;k++){
            std::cin>>b[j][k];
        }
    }

    for(i=0;i<n;i++){
        for(k=0;k<l;k++){
            for(j=0;j<m;j++){
                c[i][k]+=a[i][j]*b[j][k];
            }
            if(k==l-1){
                std::cout<<c[i][k];
            }else{
            std::cout<<c[i][k]<<" ";
            }
        }
        std::cout<<std::endl;
    }
    return 0;
}



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

int main() {
  int n , k;
  cin >> n >> k;
  int sum = 0;

  for(int i = 0; i < n; i++){
    int ball;
    cin >> ball;
    sum += min(ball, k - ball) * 2;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int h[10000],w[10000],hh=-1,ww=-1,i=0,j,k,l;
    while (!(hh==0 && ww==0)){
        scanf("%d %d",&hh,&ww);
        h[i]=hh,w[i]=ww,i++;
    }
    for(j=0;j<i-1;j++){
        for(l=0;l<h[j];l++){
            for(k=0;k<w[j];k++){
                if ((l%2 && !(k%2)) || (!(l%2) && (k%2))) printf(".");
                else printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>

int main() {
	int i=0 , j=0 , in , sum[2]={0};
	while ( i < 2 ) {
		while ( j < 4 ) {
			scanf("%d",&in);
			sum[i]+=in;
			j++;
		}
		i++;
	}
	if ( sum[0] >= sum[1] )
		printf("%d\n",sum[0]);
	else
		printf("%d\n",sum[1]);
	return 0;
}

Measured memory_bytes: 0
N = int(input())
A = list(map(int,input().split()))
d = {}
count = 0
for i in range(N):
    if A[i] not in d:
        d[A[i]]=0
    else:
        count+=1
if count%2==0:
    print(N-count)
else:
    print(N-count-1)

Measured memory_bytes: 18272
#include <iostream>

using namespace std;

int main()
{
    long long int a, b, x;
    scanf("%lld %lld %lld", &a, &b, &x);
    long long int result;

    if(a == 0) {
        result = b / x;
        result = result + 1;
        printf("%lld\n", result);
    }

    else {
        result = b / x;
        result = result - (a - 1) / x;
        printf("%lld\n", result);
    }
}

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

int gcd(int x,int y){
  if (y) return gcd(y,x%y);
  else return x;
}

int main(void){
  long long a,b,po=0,c,d,t;
  cin >> a >> b >> c >> d;
  po+=b/c-(a-1)/c;
  po+=b/d-(a-1)/d;
  t=c*d/gcd(c,d);
  po-=b/t-(a-1)/t;
  cout << b-a+1-po << endl;
  return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1));
    for(int i=0; i<=s.size(); ++i) {
        dp[i][0] = i;
    }
    for(int i=0; i<=t.size(); ++i) {
        dp[0][i] = i;
    }
    for(int i=1; i<=s.size(); ++i) {
        for(int j=1; j<=t.size(); ++j) {
            dp[i][j] = min(dp[i-1][j]+1, min(dp[i][j-1]+1, dp[i-1][j-1] + (int)(s[i-1] != t[j-1])));
        }
    }
    cout << dp[s.size()][t.size()] << endl;
}


Measured memory_bytes: 6816
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc171/abc171_c.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;


int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N;
  cin >> N;

  string ans = "";
  while (N > 0) {
    N--;
    ans += 'a' + N % 26;
    N /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 3636
import sys
import itertools
import fractions
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

def frac2(p):
    return p//2

N,M=nm()
A=nl()
A=list(map(frac2,A))
min_bai=A[0]
for i in range(1,N):
    min_bai=min_bai*A[i]//fractions.gcd(min_bai,A[i])

for i in range(N):
    if((min_bai//A[i])%2==0):
        print(0)
        sys.exit(0)


tmp=M//min_bai
if(tmp%2==0):
    tmp-=1

print((tmp+1)//2)

Measured memory_bytes: 16260
import sys
def input():
    return sys.stdin.readline()[:-1]
# input
S = input()
flag = True
count = 1

for s in S:
    if count % 2 == 1:
        if (s != 'R') and (s != 'U') and (s != 'D'):
            flag = False
            break
    if count % 2 == 0:
        if (s != 'L') and (s != 'U') and (s != 'D'):
            flag = False
            break
    count += 1

if flag == True:
    print('Yes')
else:
    print('No')

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

int main(){
	int a,b,c,x;
	int y=0 ;
	cin>>a>>b>>c ;
	
	for(x=a;x<=b;x++)
	{if(c%x==0){y+=1;}}
    

	cout <<y<<endl;
	
	 return 0;
	 }

Measured memory_bytes: 1164
/*

Author: @karngyan
Team: BlundersPride

*/

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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define max3(a , b , c) max(a , max(b , c))
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll N = 1e5 + 10;

ll n;
ll a[N];
ll b[N];
ll c[N];
ll dp[N][4];


ll go(ll i , ll last)
{
	if( i > n )
		return 0;

	ll &ans = dp[i][last];

	if(ans != -1)
		return ans;

	if(last == -1)
		ans = max3(a[i] + go(i+1 , 0) , b[i] + go(i+1 , 1) , c[i] + go(i+1 , 2));
	if(last == 0)
		ans = max(b[i] + go(i+1 , 1) , c[i] + go(i+1 , 2));
	if(last == 1)
		ans = max(a[i] + go(i+1 , 0) , c[i] + go(i+1 , 2));
	if(last == 2)
		ans = max(a[i] + go(i+1 , 0) , b[i] + go(i+1 , 1));

	return ans;
}
signed main()
{
	fast;
	memset(dp , -1 , sizeof dp);
////////////////////////////////////////////////////////////////////////////////////////////
	
	cin >> n;
	rep(i,1,n+1)
		cin >> a[i] >> b[i] >> c[i];

	cout<<go(1,-1)<<endl;

	return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

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

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string n;cin>>n;
  ll k;cin>>k;
  ll l=n.length();
  vector<vector<ll>>dp(2,vector<ll>(5));
  dp[1][0]=1;
  dp[1][1]=n[0]-'0'-1;
  dp[0][1]=1;

  repi(i,1,l){
    auto tdp=dp;
    //lesser
    rep(j,4){
      tdp[1][j+1]+=dp[1][j]*9;
    }
    if(n[i]!='0'){
      rep(j,4){
        if(dp[0][j]==1){
          tdp[0][j+1]=1;
          tdp[0][j]--;
          tdp[1][j+1]+=n[i]-'0'-1;
          tdp[1][j]++;
        }
      }
    }
    dp=tdp;
  }
  cout<<dp[0][k]+dp[1][k]<<endl;


  return 0;

}


Measured memory_bytes: 256
import math

a,b,h,m=map(int, input().split())

h_kaku=(2*math.pi*(h+m/60))/12
m_kaku=(2*math.pi*m)/60

h_x=a * math.cos(-h_kaku+math.pi/2)
h_y=a * math.sin(-h_kaku+math.pi/2)

m_x=b * math.cos(-m_kaku+math.pi/2)
m_y=b * math.sin(-m_kaku+math.pi/2)

nagasa=math.sqrt((h_x-m_x)**2+(h_y-m_y)**2)

print(nagasa)


Measured memory_bytes: 9528
N = int(input())
S = input()
slimes = []
for i in S:
	slimes.append(i)

#隣接するスライムを１つにまとめる関数yugouの定義
#引数はスライムのリストslimes
def yugou(slimes):
	temp = []
	for i in range(len(slimes)-1):
		if slimes[i] != slimes[i+1]:
			temp.append(slimes[i])
	temp.append(slimes[-1])
	return(temp)

#変化がなくなるまでyugou関数を繰り返す再帰関数f(x)
def f(x):
	y = yugou(x)
	if x == y:
  		ans = y
	else:
		y = f(x)
	return(ans)

temp_ans = yugou(slimes)
if temp_ans == slimes:
	ans=temp_ans
else:
	ans = f(temp_ans)

print(len(ans))

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

void Main()
{
    int L  = 10000000;
    int LL = 999999999;
    int h, w, ch, cw, dh, dw;
    cin >> h >> w >> ch >> cw >> dh >> dw;
    ch--; cw--; dh--; dw--;
    vector<vector<int>> s(h, vector<int>(w));
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            char a;
            cin >> a;
            s[i][j] = (a == '#' ? LL : L);
        }
    }

    deque<pair<int,int>> dq;
    dq.push_front(make_pair(ch, cw));
    s[ch][cw]=0;
    while(!dq.empty())
    {
        auto q = dq.front(); dq.pop_front();
        for (int i = -2; i <= 2; i++)
        {
            for (int j = -2; j <= 2; j++)
            {
                if(q.first+i >= 0 && q.first+i < h
                && q.second+j >= 0 && q.second+j < w
                && s[q.first+i][q.second+j] != LL
                && (i!=0 || j!=0))
                {
                    int ac = abs(i)+abs(j)<=1 ? 0 : 1;
                    if(s[q.first+i][q.second+j] > s[q.first][q.second]+ac){
                        if(ac == 0) dq.push_front(make_pair(q.first+i, q.second+j));
                        else dq.push_back(make_pair(q.first+i, q.second+j));
                        s[q.first+i][q.second+j] = s[q.first][q.second]+ac;
                    }
                }
            }
        }
    }

    int ans = s[dh][dw];
    if (ans == L) ans = -1;
    cout << ans << endl;

    // .#.
    // #@#
    // .#.
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 7608
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
	int n;
	cin >> n; int a[100];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	cout << *max_element(a, a + n) - *min_element(a, a + n);
}

Measured memory_bytes: 3152
n = int(input())
s = [input() for _ in range(n)]

march = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0}
for name in s:
    if name[0] in march.keys():
        march[name[0]] += 1
#(m,a,r)(m,a,c)(m,a,h)
#(m,r,c)(m,r,h)
#(m,c,h)
ans = march['M']*march['A']*march['R']
ans += march['M']*march['A']*march['C']
ans += march['M']*march['A']*march['H']
ans += march['M']*march['R']*march['C']
ans += march['M']*march['R']*march['H']
ans += march['M']*march['C']*march['H']
#(a,r,c)(a,r,h)
#(a,c,h)
ans += march['A']*march['R']*march['C']
ans += march['A']*march['R']*march['H']
ans += march['A']*march['C']*march['H']
#(r,c,h)
ans += march['R']*march['C']*march['H']

print(ans)


Measured memory_bytes: 16044
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
using namespace std;

typedef long long ll;

int main()
{
	ll x;
	cin >> x;
	long long ans = 0;
	for (ll i = 1; i * i < x; i++) {
		if (x % i == 0) {
			ll p = i;
			ll q = x / p;
			
			if (p - 1 > 0 && x % (p - 1) == q && x/(p-1) == q) ans += p-1;
			if (q - 1 > 0 && x % (q - 1) == p && x/(q-1) == p) ans += q-1;
			
			
		}
	}
	cout << ans;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;
long long gcd(long long x, long long y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(x%y,y);
}
int main(){
	long long a,b;
	cin >> a >> b;
	cout << a*b/gcd(a,b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

/*template*/
int main() {
	ll X, Y; cin >> X >> Y;
	ll cnt = 0;
	ll A = X;
	while (A <= Y) {
		A *= 2;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	intl i,n,k;
	cin>>n>>k;
	intl j=n/k;
	intl x1=j*k;
	intl x2=(j+1)*k;
	x2-=n;
	x1-=n;
	x1=abs(x1);
	x2=abs(x2);
	cout<<min(x1,x2)<<"\n";
}


Measured memory_bytes: 256
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
int dp[200][200];
struct z{
	int a,b,c;
};
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	int f;cin>>f;
	cout << (f-30)/2 << endl;
	
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int N;
	cin>>N;
	vector<int> a(N+1);
	rep1(i,N+1)cin>>a[i];
	int ans = 0;
	rep1(i,N+1){
		if(a[a[i]]==i)ans++;
	}
	ans/=2;
	cout<<ans<<endl;
}

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

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

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

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

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

Measured memory_bytes: 3624
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう,
signed main(){
    int a,b;cin>>a>>b;
    if(abs(a-b)<=1)cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
#include <cstdio>
#include <cctype>
using namespace std;

string shuffle(string str,int h){
	string head=str.substr(0,h);
	string tail=str.substr(h,str.size()-h);
	return tail+head;
}
int main() {
	string card;
	int m,h;
	while(1){
		cin>>card;
		if(card=="-")break;
		cin>>m;
		for(int i=0;i<m;i++){
			cin>>h;
			card=shuffle(card,h);
		}
		cout<<card<<endl;
	}



	return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if((a==b && b!=c) || (a==c && b!=c) ||(c==b && a!=b))
    cout<<"Yes";
  else
     cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 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 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))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { 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;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, m;
    cin >> n >> m;
    vi a(n);
    cin >> a;
    int sum = 0;
    rep(i, n) {
        sum += a[i];
    }
    int cnt = m;
    rep(i, n) {
        if (a[i] * 4 * m >= sum) {
            cnt--;
        }
    }
    cout << (cnt <= 0 ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn string() -> String {
    read()
}

fn int() -> i64 {
    read()
}

fn char() -> char {
    read::<String>().pop().unwrap()
}

fn vecchar() -> Vec<char> {
    string().chars().collect()
}

fn vecint(n: i64) -> Vec<i64> {
    let mut vec = Vec::new();
    for i in 0..n {
        vec.push(int())
    }
    vec
}

fn main() {
    let (n, k) = (int(), int());
    let mut x = Vec::new();
    for _ in 0..n {
        x.push(int());
    }
    println!(
        "{}",
        x.iter().fold(0i64, |x, i| x + min(*i, (k - i).abs()) * 2)
    )
}


Measured memory_bytes: 4352
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto s = readln.chomp.split.to!(int[]);
  auto f = true;
  
  if (s[0] % s[1]) writeln(s[0]);
  else writeln(-1);
}


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

const ll mod = 1e9 + 7;
int n;
vector<int> a;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    ll sum = 0;
    for (int i =0 ; i < k; i++) sum += a[i];
    cout << sum;
    return 0;
}

Measured memory_bytes: 3556
n=gets.to_i

array=gets.split.map(&:to_i)


ll=array.length

if ll%2==1
    lll=(ll-1)/2
     array3=[array[0]]
      i=1
    lll.times{
        array3<<array[i]
        i=i+2}
    
    j=ll-1
    array4=[]
    lll.times{
        array4<<array[j]
        j=j-2
        
        
    }
    
    
elsif ll%2==0
  lll=ll/2
  
  
  array3=[]
  i=0
  lll.times{
      array3<<array[i]
      
      i=i+2
      
  }
  array4=[]
  j=ll-1
  
  lll.times{
      array4<<array[j]
      j=j-2
      
      
  }
  
  
  
  
    
    
end
array5=array4+array3



puts array5.join(" ")

Measured memory_bytes: 27020
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

int main(){
    int q;
    cin >> q;
    ll left=0,right=0;
    for(int i=0;i<q;i++){
        ll p,n;
        char c;
        cin >> p >> c >> n;
        if(c == '(') left+=n;
        else right+=n;
        if(left == right){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}

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

int main() {
  int D, G;
  cin >> D >> G;
  vector<int> p(D), c(D);
  for (int i = 0; i < D; i++) {
    cin >> p.at(i) >> c.at(i);
  }

  int ans = 10 * 100;
  for (int mask = 0; mask < (1 << D); mask++) {
    int s = 0;
    int num = 0;
    int rest_max = -1;

    for (int i = 0; i < D; i++) {
      if (mask >> i & 1) {
        s += 100 * (i + 1) * p.at(i) + c.at(i);
        num += p.at(i);
      } else {
        rest_max = i;
      }
    }

    if (s < G) {
      int s1 = 100 * (rest_max + 1);
      int need = 0;
      int reminder = (G - s) % s1;
      if (reminder == 0) {
        need = (G - s) / s1;
      } else {
        need = (G - s) / s1 + 1;
      }

      if (need >= p.at(rest_max)) {
        continue;
      }
      num += need;
    }

    ans = min(ans, num);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll a[maxn];
int n,b[maxn];

int main()
{
    while (~scanf("%d",&n)) {
        for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
        for(int i=1;i<=n;i++)a[i]+=a[i-1];
        ll sum=0;
        for(int i=1;i<=n;i++)if(a[i]==0)sum++;
        sort(a+1,a+n+1);
        int length=1,id=1;
        memset(b, 0, sizeof(b));
        b[length]=1;
        while (id<n) {
            if(a[id]!=a[id+1])length++,b[length]=1;
            else b[length]++;
            id++;
        }
        for(int i=1;i<=length;i++)
            sum+=(1LL*(b[i]-1)*b[i])/2;
        printf("%lld\n",sum);
    }
    return 0;
}

Measured memory_bytes: 2560