akhauriyash/Code-Regression huggingface dataset:
;; D - Handstand 2

(defun first-digit (n)
  (if (< n 10) n (first-digit (floor n 10))))

(defun solve (n)
  (let ((count-head-tail (make-array '(10 10) :initial-element 0)))
    (loop for i from 1 to n
      do (incf (aref count-head-tail (first-digit i) (mod i 10))))
    (loop for head from 1 to 9       ; aの先頭の桁 (= bの末尾の桁)
      sum (loop for tail from 1 to 9 ; aの末尾の桁 (= bの先頭の桁)
            sum (* (aref count-head-tail head tail)      ; aの個数
                   (aref count-head-tail tail head)))))) ; bの個数

(let ((n (read)))  ; n <= 2 * 10 ** 5
  (princ (solve n)))


Measured memory_bytes: 17380
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var y, d1, d2, d3, d, di float64
	fmt.Scan(&n)
	x := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&y)
		d = math.Abs(x[i] - y)
		d1 += d
		d2 += math.Pow(d, 2)
		d3 += math.Pow(d, 3)
		di = math.Max(d, di)
	}
	fmt.Println(d1)
	fmt.Println(math.Pow(d2, 1.0/2))
	fmt.Println(math.Pow(d3, 1.0/3))
	fmt.Println(di)
}



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

using namespace std;

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

    vector <int> a(n);

    for(int i = 0; i < n; i++)  scanf("%d", &a[i]);

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

    int Ans = 1e9;

    for(int x = a[0]; x <= a.back(); x++)
    {
        int Res = 0;

        for(int i = 0; i < n; i++)  Res += (a[i] - x) * (a[i] - x);

        Ans = min(Ans, Res);
    }

    cout << Ans << endl;
}


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


def insertion_sort(a, n):
    for i in range(n):
        tmp = a[i]
        j = i - 1
        while j >= 0 and a[j] > tmp:
            a[j + 1] = a[j]
            j -= 1
        a[j + 1] = tmp
        print(' '.join(map(str, a)))

if __name__ == '__main__':
    n = int(input())
    a = [int(n) for n in input().split()]
    insertion_sort(a, n)

Measured memory_bytes: 7720
from collections import Counter
import sys
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
ans = sum(a)
q = int(input())
for _ in range(q):
	x, y = map(int, input().split())
	ans += (y-x) * c[x]
	print(ans)
	c[y] += c[x]
	c[x] = 0

Measured memory_bytes: 88564
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P;
typedef vector<int> Vi;
int const MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { return a = b; } return false; }



int main(){
  cin.tie(0); ios::sync_with_stdio(false);
    
  int n,m; cin>>n>>m;
  int ans=(((m-1)%(n-1))?(m-1)/(n-1)+1:(m-1)/(n-1));
  cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
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;
    }
    return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    ll L,R;
    cin >> L >> R;
    if(R-L>=2100)cout << 0 << endl;
    else{
        ll res = 21000;
        for(ll i=L;i<=R;i++){
            for(ll j=i+1;j<=R;j++){
                res = min(((i%2019)*(j%2019))%2019,res);
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,m = RI()

ans = 0
if (2*n)<=m:
    ans += n
    ans += ( m - (2*n) )//4
elif m<(2*n):
    ans += m//2
else:
    print("E")
    exit()
print(ans)

Measured memory_bytes: 68328
N,u,V = map(int,input().split())

abl = []
G = [[] for _ in range(N)]
for _ in range(N-1):
   a,b = map(int,input().split())
   G[a-1].append(b-1)
   G[b-1].append(a-1)


# G[v]: 頂点vに隣接する頂点list
# N: 頂点数

from collections import deque
dist = [-1]*N
que = deque([u-1])
dist[u-1] = 0
while que:
    v = que.popleft()
    d = dist[v]
    for w in G[v]:
        if dist[w] > -1:
            continue
        dist[w] = d + 1
        que.append(w)

from collections import deque
dist2 = [-1]*N
que = deque([V-1])
dist2[V-1] = 0
while que:
    v = que.popleft()
    d = dist2[v]
    for w in G[v]:
        if dist2[w] > -1:
            continue
        dist2[w] = d + 1
        que.append(w)

ans = 0
import math
for d, d2 in zip(dist, dist2):
    if d2 > d:
        ans = max(d2-1, ans)
print(ans)

Measured memory_bytes: 29396
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> v(n);
  fore(i, 0, n) {
    char x;
    cin >> x;
    if (x == 'R')
      v[i] = 0;
    else
      v[i] = 1;
  }
  vector<int> w = v;
  sort(all(w));
  int ans = 0;
  fore(i, 0, n) if (v[i] != w[i]) ans++;
  cout << (ans + 1) / 2 << endl;

  return 0;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

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

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  int n = 0;
  cin >> n;
  
  vector<int> s(n);
  ll total = 0;
  for(int i=0;i<n;i++){
    cin >> s[i];
    total += s[i];
  }
  sort(s.begin(),s.end());
  
  if(total%10!=0){
    cout << total << endl;
    return 0;
  }
  
  for(int i=0;i<n;i++){
    if(s[i]%10!=0){
      cout << total-s[i] << endl;
      return 0;
    }
  }

  cout << "0" << endl;
  return 0;
}



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

int main(){
    ll k, a, b;
    cin >> k >> a >> b;

    ll ans = 1;

    if(a + 1 >= b){
        ans += k;
    }else{
        ll cou = k;
        if(k <= (a - 1)){
            ans += k;
        }else{
            cou -= (a - 1);
            ans += (a - 1);
            ll qw = cou / 2;
            ans += qw * (b - a);
            if(cou % 2 != 0){                
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
# debug = lambda *a, **kw: print(*a, **kw, file=sys.stderr)

N, K = inm()
P = inl()
P.sort()


def solve():

    return sum(P[:K])


print(solve())


Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
#define ll long long
main()
{
    ll n;scanf("%lld",&n);
    for(ll a=1;a<=3500;a++)for(ll b=a;b<=3500;b++)
    {
        ll p=n*a*b,q=4*a*b-n*a-n*b;
        if(q>0 && p%q==0){printf("%lld %lld %lld",a,b,p/q);return 0;}
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;

int main() {
    int X;
    cin >> X;
    int i = X;
    bool check;
    if (i == 2) {
        cout << i << endl;
        return 0;
    }
    while (true) {
        check = true;
        for (int j = 2; j * j <= i; j++) {
            if (i % j == 0) {
                check = false;
                break;
            }
        }
        if (check) {
            cout << i << endl;
            return 0;
        }
        i++;
    }
}

Measured memory_bytes: 256
n, a, b = gets.split.map(&:to_i)
arr = gets.split.map(&:to_i)

cost = 0
arr.each_cons(2) do |x1, x2|
  d = x2 - x1
  if d * a > b
    cost += b
  else
    cost += d * a
  end
end

puts cost

Measured memory_bytes: 20820
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,q,x,y,z,N=0,ans[200010];
pair <bool,LL> has[800010];
map <LL,LL> mp,into;
vector <pair <pii,LL> > v;
vector <pii> ss[800010];
vector <LL> peo;
multiset <LL> st;

int main()
{
	memset(ans,-1,sizeof(ans));
	cin>>n>>q;
	rep(i,n)
	{
		scanf("%lld%lld%lld",&x,&y,&z);
		y--;
		x-=z;
		y-=z;
		x=max(x,0LL);
		y=max(y,0LL);
		v.pb({{x,y},z});
		mp[x]=0;
		mp[y]=0;
	}
	rep(i,q)
	{
		scanf("%lld",&x);
		peo.pb(x);
		mp[x]=0;
	}
	for(map <LL,LL>::iterator it=mp.begin();it!=mp.end();it++) into[it->fi]=N++;
	rep(i,n)
	{
		v[i].fi.fi=into[v[i].fi.fi];
		v[i].fi.se=into[v[i].fi.se];
		ss[v[i].fi.fi].pb({v[i].se,1});
		ss[v[i].fi.se+1].pb({v[i].se,-1});
	}
	rep(i,q) has[into[peo[i]]]={true,i};
	rep(i,N+1)
	{
		rep(j,ss[i].size())
		{
			if(ss[i][j].se==1) st.insert(ss[i][j].fi);
			else st.erase(st.find(ss[i][j].fi));
		}
		if(has[i].fi&& !st.empty()) ans[has[i].se]=*st.begin();
	}
	rep(i,q) cout<<ans[i]<<endl;
	rt0;
}

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

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            //SolveA(args);
            SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }

        private const int M = 1000000007;
        private static void SolveB(string[] args)
        {
            int[] xy = ReadAndParseIntArr();
            long val = pow(xy[0], xy[1]);
            Console.WriteLine(val);
        }
        private static long pow(long x, long n)
        {
            if( n == 0) { return 1; }
            long res = pow(x * x % M, n / 2);
            if( n % 2 == 1)
            {
                res = res * x % M;
            }
            return res;
        }
    }
}



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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	ll h, w;
	cin >> h >> w;
	
	ll ans = min(h,w);
	if(h % 3 == 0 || w % 3 == 0)
	{
		ans = 0;
		cout << ans << endl;
		return 0;
	}
	// ソレ以外の時、縦、横の区切りを一本ずつ入れる。
	for(ll tate = 1; tate < h; tate++){
		ll one = tate * w;

		//残りの(h-tate)*wを2等分することを目指す。
		// 1~w-1のどこかに区切りを入れる。
		ll two, three;
		if(w % 2 == 0){
			// 残りは2等分できる。
			two = three = (h-tate) * (w/2);
			if(chmax(three,one)){
				one = two;
			}
		} else {
			// 残りは、1列分だけ差が出る
			two = (h - tate) * (w/2);
			three = (h - tate) * ((w+1)/2);
			if(two < one){
				three = max(one,three);
				one = two;
			}
		}
		chmin(ans,three-one);
	}
	for(ll yoko = 1; yoko < w; yoko++){
		ll one = yoko * h;

		//残りの(h-yoko)*wを2等分することを目指す。
		// 1~w-1のどこかに区切りを入れる。
		ll two, three;
		if(h % 2 == 0){
			// 残りは2等分できる。
			two = three = (w-yoko) * (h/2);
			if(chmax(three,one)){
				one = two;
			}
		} else {
			// 残りは、1列分だけ差が出る
			two = (w - yoko) * (h/2);
			three = (w - yoko) * ((h+1)/2);
			if(two < one){
				three = max(one,three);
				one = two;
			}
		}
		chmin(ans,three-one);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define sort(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int x = a + b;
	int y = a - b;
	int z = a * b;
	cout << max(z,max(x, y)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(v, x) (v).erase(remove((v).begin(), (v).end(), (x)), (v).end())
using namespace std;

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

  vector<pair<int, int>> R, B;
  rep(i, N) {
    int a, b;
    cin >> a >> b;
    R.emplace_back(a, b);
  }
  rep(i, N) {
    int c, d;
    cin >> c >> d;
    B.emplace_back(c, d);
  }

  sort(B.begin(), B.end());
  vector<bool> candidate(N, true);

  int ans = 0;
  rep(i, N) {
    int y = 0;
    int n = -1;
    rep(j, N) {
      int nx = R[j].first, ny = R[j].second;
      if (candidate[j] && nx < B[i].first && ny < B[i].second) {
        if (ny >= y) {
          y = ny;
          n = j;
        }
      }
    }
    if (n != -1) {
      candidate[n] = false;
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
long int n,k,a;
  cin>>n>>k;
  while(1)
  { if(n%k==0){cout<<n%k;break;}
    else if(n>k){n=n%k;
                 continue;}
    else if(n<=k){a=k-n;
                 if(a<=n){cout<<a;break;}
                 else{cout<<n;break;}
                }
  }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

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

		int n = scan.nextInt();
		ArrayList<Integer> list = new ArrayList<Integer>(n);
		ArrayList<Integer> list_c = new ArrayList<Integer>(n);

		for(int i = 0;i < n;i++) {
			list.add(scan.nextInt());
			list_c.add(list.get(i));
		}

		Collections.sort(list_c);

		for(int i = 0;i < n;i++) {
			if(list_c.get(n - 1) == list.get(i)) {
				System.out.println(list_c.get(n - 2));
			}else {
				System.out.println(list_c.get(n - 1));
			}
		}
	}
}

Measured memory_bytes: 98800
#!/usr/bin/python3

import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def main():
    S = input()

    odd = set(['R', 'U', 'D'])
    even = set(['L', 'U', 'D'])

    ans = 'Yes'
    for i, c in enumerate(S):
        if (i + 1) % 2 == 0:
            if c == 'R':
                ans = 'No'
        else:
            if c == 'L':
                ans = 'No'

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
n=I()
a=IL()
cnt=[0 for i in range(pow(10,5))]
for i in range(n):
    cnt[a[i]]+=1
m=0
for i in range(2,pow(10,5)):
    m=max(cnt[i]+cnt[i-1]+cnt[i-2],m)
print(m)

Measured memory_bytes: 14004
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int  w,h;
    cin>>w>>h;
    if (h==1 or w==1)
        cout << 1 << endl;
    else if (h&1^1)
        cout << (h/2)*w << endl;
    else {
        int  half=w/2;
        if (w%2==0)
            cout << (h/2)*half + ((h+1)/2)*half << endl;
        else 
            cout << (((h/2)*half)+(((h+1)/2)*(half+1))) << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3520
//あらためて見るとこの問題全然わからない

//#include<bits/stdc++.h>
#include<cstdio>
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 co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();
	int A[2][200000], B[2][200000];
	int kazuA[29] = {}, kazuB[29] = {};
	rep(i, N) {
		int a = getint();
		A[0][i] = a; 
		rep(j, 28) kazuA[j] += a >> j & 1;
	}
	rep(i, N) {
		int b = getint();
		B[0][i] = b;
		rep(j, 28) kazuB[j] += b >> j & 1;
	}
	int kotae = N & (kazuA[0] ^ kazuB[0]) & 1;
	rep(i, 28) {
		int p = i & 1;
		auto Amae = A[p];
		auto Bmae = B[p];
		auto Atugi = A[!p];
		auto Btugi = B[!p];

		int kazu[2];
		kazu[0] = 0;
		kazu[1] = N - kazuA[i];
		rep(j, N) Atugi[kazu[Amae[j] >> i & 1]++] = Amae[j];
		kazu[0] = 0;
		kazu[1] = N - kazuB[i];
		rep(j, N) Btugi[kazu[Bmae[j] >> i & 1]++] = Bmae[j];

		int kari = (N & (kazuA[i + 1] ^ kazuB[i + 1])) ^ N;
		int d = (1 << (i + 1)) - 1;
		int d2 = 1 << (i + 1);
		int k = N;
		rep(j, N) {
			while (k > 0 && (Atugi[j] & d) + (Btugi[k - 1] & d) >= d2) k--;
			kari ^= k;
		}

		kotae += (kari & 1) << (i + 1);
	}

	printf("%d", kotae);

	Would you please return 0;
}

Measured memory_bytes: 3456
let cnt = ref 0
let (g : int list ref) = ref []

let print_list l =
  List.iteri (fun i n -> Printf.printf (if i = 0 then "%d" else " %d") n) l;
  print_newline ()

let print_array = Array.iter (fun n -> Printf.printf "%d\n" n)

let insertion_sort (a : int array) n g =
  let rec insert (j : int) (v : int) =
    if j < 0 || a.(j) <= v then a.(j + g) <- v
    else (a.(j + g) <- a.(j); incr cnt; insert (j - g) v)
  in
  let rec doit (i : int) =
    if i < n then (insert (i - g) a.(i); doit (i + 1))
  in
  doit g

let generate_g n =
  let rec doit i g lst =
    if g > n then lst
    else doit (i + 1) (int_of_float (4.**(float_of_int i) +. 3.*.2.**(float_of_int (i - 1)) +. 1.)) (g :: lst)
  in
  doit 1 1 []

let shell_sort (a : int array) n =
  cnt := 0;
  g := generate_g n;
  let rec doit = function
    | [] -> ()
    | hd :: tl -> (insertion_sort a n hd; doit tl)
  in
  doit !g

let () =
  let n = read_int () in
  let a = Array.make n 0 in
  let rec doit i =
    if i < n then (a.(i) <- read_int (); doit (i + 1))
  in
  doit 0;
  shell_sort a n;
  Printf.printf "%d\n" (List.length !g);
  print_list !g;
  Printf.printf "%d\n" !cnt;
  print_array a

Measured memory_bytes: 12656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;


int main(){
  ll n;
  cin >> n;
  vector<ll> vec(n);
  vector<ll> ans(n);
  ll sum = 0;
  rep(i,n){
    cin >> vec[i];
    sum ^= vec[i];
  }

  rep(i,n){
    ans[i] = sum ^ vec[i];
  }

  rep(i,n){
    cout << ans[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 6356
#include <iostream>
#include <vector>
using namespace std;
int main()
{
   int n;
  cin>>n;
  
  vector <int> arr(n+1 , 0);
  
  for(int i=1;i<101;i++)
  {
    for(int j=1;j<101;j++)
    {
      for(int k=1;k<101;k++)
      {
         int ans = i*i + j*j + k*k + i*j + j*k + k*i;
          
        if(ans>n)
          continue;
        
        arr[ans]++;
      }
    }
  }
  
  for(int i=1;i<=n;i++)
    cout<<arr[i]<<endl;

}

Measured memory_bytes: 3548
import math
N, K = map(int,input().split())
prob = [0] * (N+1)
for i in range(1,N+1):
    prob[i] = 1/N
    if i < K:
        x = math.log2(K/i)
        x = math.ceil(x)
    else:
        x = 0
    prob[i] *= (1/2)**x
ans = sum(prob)
print(ans)


Measured memory_bytes: 6132
r, c = [int(i) for i in input().split()]

data = []
sum_row = [0] * (c + 1)

for ri in range(r):
    data.append([int(i) for i in input().split()])
    data[ri].append(sum(data[ri]))
    print(" ".join([str(d) for d in data[ri]]))
    for ci in range(c + 1):
        sum_row[ci] += data[ri][ci]

print(" ".join([str(s) for s in sum_row]))

Measured memory_bytes: 7812
import itertools
h,w,k = map(int, input().split())
g = []
for _ in range(h):
  i = input()
  g.append(i)
l = [0 for j in range(h)]
d = [0 for j in range(w)]
c =0
for i in range(h):
  a = 0
  for j in range(w):
    if g[i][j] == '#':
      a +=1
  l[i]+=a
  c+=a
for i in range(w):
  b = 0
  for j in range(h):
    if g[j][i] == '#':
      b +=1
  d[i]+=b
ans = 0
for i in list(itertools.product([0,1], repeat=h)):
  e = c
  for x in range(h):
    if i[x] == 1:
      e-= l[x]
  for j in list(itertools.product([0,1], repeat=w)):
    f = e
    for y in range(w):
      if j[y] == 1:
        f -= d[y]
    for x in range(h):
      for y in range(w):
        if i[x] == 1 and j[y] == 1 and g[x][y]=='#':
          f+=1
    if f==k:
      ans+=1
print(ans)

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

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using ll = long long;
using namespace std;

struct request{
  ll a;
  ll b;
};
bool comp(const request &a,const request &b){
  return a.b < b.b;
}
  
int main(){
  ll n,m,ii,jj;
  cin >> n >> m;
  vector<request> a;
  a.resize(m);
  for(ii=0;ii<m;ii++){
    cin >> a[ii].a >> a[ii].b;
  }

  sort(a.begin(),a.end(),comp);

//  for(ii=0;ii<m;ii++){
//    cout << "a:" << a[ii].a << "b:" << a[ii].b << endl;
//  }
  
  long p = 0,curPos,num=0;
  while(p < m){
    curPos = a[p].b - 1;
    //cout << "curPos:" << curPos << endl;

    p++;

    while(p < m && a[p].a <= curPos){
      p++;
    }
    //while(a[p].a <= curPos){
    //  //cout << "a:" << a[p].a << endl;
    //  p++;
    //  if(p >= m - 1){
    //	break;
    //  }
    //	
    //}
    num++;
    
  }
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 1792
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let mut mn = std::i32::MAX;
    let mut mx = std::i32::MIN;
    for _ in 0..n {
        let x:i32 = read();
        if mx < x - mn {
            mx = x-mn;
        }
        if mn > x {
            mn = x;
        }
    }
    println!("{}", mx);
}




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

int main()
{
  long A, B, C, K;
  cin >> A >> B >> C >> K;
  long ans = 0;
  if (K >= A)
  {
    ans += A;
    K -= A;
  }
  else
  {
    ans += K;
    K = 0;
  }
  if (K >= B) K -= B;
  else K = 0;
  if (K >= C) ans -= C;
  else ans -= K;
  cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;
int main(){
  int n, k;cin>>n>>k;
  vector<int> x(n);
  for(int i=0;i<n;i++){
  	cin>>x[i];
  }
  sort(x.begin(), x.end());
  int ans=INF;
  for(int i=0;i<n-k+1;i++){
  	ans=min(ans, x[i+k-1]-x[i]);
  }
  cout<<ans<<endl;
}

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

int main() {
	int N;
	cin >> N;
	int num = 0;
	bool ans = false;
	for (int i = 0; i < N; i++) {
		int d1, d2;
		cin >> d1 >> d2;
		if (d1 == d2) num++;
		else num = 0;
		if (num == 3) ans = true;
	}
	cout << (ans ? "Yes" : "No") << endl;
}


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

int main() {
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;

  if (A <= 8 && B <= 8)
    cout << "Yay!\n";
  else
    cout << ":(\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dp[101010][110];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };

//long longしか使わない
//素数は1より大きい
int main() {
	ll a;
	cin >> a;
	ll ans = a + a * a + a * a * a;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    ll a,b,k;
    cin >> a >> b >> k;
    if (k > a){
        k -= a;
        a = 0;
    }else{

        a -= k;
        k = 0;
    }
    if(k > b){
        b = 0;
    }else{
        b -= k;
    }

    cout << a << " " << b << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main() {
	int n;
	std::cin >> n;
	int a[200];
	for (int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	int count = 0;
	bool flag = true;
	while (true) {
		for (int i = 0; i < n; i++) {
			if ((a[i] % 2) == 0) a[i] /= 2;
			else flag = false;
		}
		if (flag) count++;
		else break;
	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 256
N,i,M;double X[30],Y[30],Z[30],cx,cy,cz,d,m;
#define Q(x)(x)*(x)
double D(i){return sqrt(Q(X[i]-cx)+Q(Y[i]-cy)+Q(Z[i]-cz));}
int L(){for(m=i=0;i<N;i++)if(D(i)>m)m=D(i),M=i;return M;}
main(t){for(;scanf("%d",&N),N;printf("%f\n",D(L()))){
		for( i=0; i<N; ++i) scanf("%lf%lf%lf", X+i, Y+i, Z+i);
		cx = cy = cz = 0.5;
		for(d=0.5; d>1e-8; d/=2) {
			for(t=0; t<100; ++t) {
				int i = L();
				cx += (X[i]-cx)*d;
				cy += (Y[i]-cy)*d;
				cz += (Z[i]-cz)*d;
			}
		}
	}
exit(0);}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
int m,n,a[1000010],i,j,sum[1000010];
for(i=0;i<1000001;i++){
sum[i]=0,a[i]=0;
}
for(i=1;i<=1000000;i++){
j=i;
while(1){
if(j%2!=0){
break;
}
else{
j=j/2;
}
}
while(1){
if(j%3!=0){
break;
}
else{
j=j/3;
}
}
while(1){
if(j%5!=0){
break;
}
else{
j=j/5;
}
}
if(j==1){
a[i]=1;
}
}
for(i=1;i<=1000000;i++){
sum[i]=sum[i-1]+a[i];
}
while(1){
scanf("%d",&m);
if(m==0){
break;
}
scanf("%d\n",&n);
printf("%d\n",sum[n]-sum[m-1]);
}
return 0;
}


Measured memory_bytes: 9548
N, K = map(int, input().split())
lst = []
for i in range(N):
    lst.append(int(input()))
lst.sort()
dif = 10**9
for i in range(N-K+1):
    if lst[i+K-1] - lst[i] < dif:
        dif = lst[i+K-1] - lst[i]
print(dif)

Measured memory_bytes: 7384
#include <stdio.h>

int main() {
  int a, b;
  scanf ("%d %d", &a, &b);

  if (a < b)
    printf ("a < b\n");
  else if (a > b)
    printf ("a > b\n");
  else
    printf ("a == b\n");

  return 0;
}

Measured memory_bytes: 580
n,q=map(int,input().split())
s=input()
a=[0]*n
for i in range(1,n):
  if s[i-1]=="A" and s[i]=="C":a[i]+=1
  a[i]+=a[i-1]
for i in range(q):
  aa,b=map(int,input().split())
  print(a[b-1]-a[aa-1])

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

using namespace std;

int main()
{
  double n, s, sum, ave, sumb;

  while (true)
  {
    sum = 0;
    sumb = 0;
    scanf("%lf", &n);

    if (int(n) == 0)
      break;

    double ans[int(n)];

    for (int i = 0; i < n; i++)
    {
      scanf("%lf", &ans[i]);
      sum += ans[i];
    }

    ave = sum / n;

    for (int i = 0; i < n; i++)
    {
      sumb += pow(ans[i] - ave, 2);
    }

    printf("%lf\n", sqrt(sumb / n));
  }
}


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

int main() {
	int n;
	cin>>n;
	int a;
	int cnt=0;
	int prev;
	cin>>prev;
	n--;
	while(n--){
		cin>>a;
		if(a==prev){
			a=-1;
			cnt++;
		}
		prev=a;
	}
	cout<<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
N=int(input())
for i in range(N):
    a,b,c=map(int,input().split())
    if a>b:
        a,b=b,a
    if b>c:
        b,c=c,b
    if a>b:
        a,b=b,a
    if c**2-a**2-b**2==0:
        print("YES")
    else:
        print("NO")


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

LL getMaxArea(vector<int> hist, int n)
{
    // Create an empty stack. The stack holds indexes of hist[] array
    // The bars stored in stack are always in increasing order of their
    // heights.
    stack<int> s;
 
    int max_area = 0; // Initalize max area
    int tp;  // To store top of stack
    int area_with_top; // To store area with top bar as the smallest bar
 
    // Run through all bars of given histogram
    int i = 0;
    while (i < n)
    {
        // If this bar is higher than the bar on top stack, push it to stack
        if (s.empty() || hist[s.top()] <= hist[i])
            s.push(i++);
 
        // If this bar is lower than top of stack, then calculate area of rectangle 
        // with stack top as the smallest (or minimum height) bar. 'i' is 
        // 'right index' for the top and element before top in stack is 'left index'
        else
        {
            tp = s.top();  // store the top index
            s.pop();  // pop the top
 
            // Calculate the area with hist[tp] stack as smallest bar
            area_with_top = (1+hist[tp]) * (1+(s.empty() ? i : i - s.top() - 1));
 
            // update max area, if needed
            if (max_area < area_with_top)
                max_area = area_with_top;
        }
    }
 
    // Now pop the remaining bars from stack and calculate area with every
    // popped bar as the smallest bar
    while (s.empty() == false)
    {
        tp = s.top();
        s.pop();
        area_with_top = (1+hist[tp]) * (1+(s.empty() ? i : i - s.top() - 1));
 
        if (max_area < area_with_top)
            max_area = area_with_top;
    }
 
    return max_area;
}

int main(){
	int h, w;
	cin >> h >> w;
	string str[h];
	for(int i = 0; i < h; i++) cin >> str[i];
	int ok[h][w];
	for(int i = 0; i < h-1; i++){
		for(int j = 0; j < w-1; j++){
			int f = str[i][j] ^ str[i][j+1] ^ str[i+1][j] ^ str[i+1][j+1];
			ok[i][j] = (f == 0);
		}
	}
	LL ans = max(h,w);
	h--; w--;
	int num[h][w];
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(i == 0){
				num[i][j] = 1;
			} else {
				num[i][j] = num[i-1][j] + 1;
			}
			if(!ok[i][j]) num[i][j] = 0;
		}
		vector<int> hist;
		for(int j = 0; j < w; j++){
			hist.push_back(num[i][j]);
		}
		ans = max(ans, getMaxArea(hist, w));

	}
	cout << ans << endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
int n, k, a[maxn + 10], ans;
vector<int> g[maxn + 10];

int dfs(int p, int dep) {
	int mx = 0;
	for (int i = 0; i < (int)g[p].size(); ++i) {
		int e = g[p][i];
		mx = max(mx, dfs(e, dep + 1) + 1);
	}
	if (mx == k - 1 && dep > 1) {
		++ans; mx = -1;
	}
	return mx;
}

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	if (a[1] != 1) {
		a[1] = 1; ++ans;
	}
	if (k == 1) {
		for (int i = 2; i <= n; ++i)
			if (a[i] != 1) ++ans;
		printf("%d", ans);
		return 0;
	}
	for (int i = 2; i <= n; ++i) g[a[i]].push_back(i);
	dfs(1, 0);
	printf("%d", ans);
}


Measured memory_bytes: 13952
#include <iostream>
#include <string>

using namespace std;

int code(char c) {
  if (c == 'M')
    return 0;
  else if (c == 'A')
    return 1;
  else if (c == 'R')
    return 2;
  else if (c == 'C')
    return 3;
  else if (c == 'H')
    return 4;
  return -1;
}

// "ACH", "ARC", "ARH", "MAC", "MAH", "MAR", "MCH", "MRC", "MRH", "RCH",
constexpr int P[] = {1, 1, 1, 0, 0, 0, 0, 0, 0, 2};
constexpr int Q[] = {3, 2, 2, 1, 1, 1, 3, 2, 2, 3};
constexpr int R[] = {4, 3, 4, 3, 4, 2, 4, 3, 4, 4};

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

  int N;
  cin >> N;

  string s;
  long long T[5] = {0};
  for (int i = 0; i < N; ++i) {
    cin >> s;
    const char c = s[0];
    const int j = code(c);
    if (j >= 0) T[j]++;
  }
  long long ans = 0;
  for (int i = 0; i < 10; ++i) {
    ans += T[P[i]] * T[Q[i]] * T[R[i]];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import *
s = str(input())
K = int(input())
ls = len(s)
l = []
for i in range(ls):
  for j in range(i+1,i+K+2):
    l.append(s[i:j])

l = list(set(l))
l = sorted(l)
print(l[K-1])

Measured memory_bytes: 5428
#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{
  int a[5],i,k;
  for(i=0;i<5;i++){cin>>a[i];}
  cin>>k;
  for(i=0;i<4;i++)
  {
    for(int j=0;j<5;j++)
    {
      if(abs(a[i]-a[j])>k){cout<<":("<<endl;return 0;}
    }
  }
  cout<<"Yay!"<<endl;
}
 

Measured memory_bytes: 3596
n = int(input())
A = list(map(int, input().split()))

B = [0]*n
ans = []

for i in range(n-1,-1,-1):
    if sum(B[i::i+1])%2!=A[i]:
        B[i] = 1
        ans.append(i+1)
print(len(ans))
print(*ans)

Measured memory_bytes: 18028
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main()
{
	char s[110];
	scanf("%s", s);
	int i = 0, L = 0;
	while (s[i] != '\0') {
		L++;
		i++;
	}
	printf("%c%d%c", s[0], L - 2, s[L - 1]);
	return 0;
}

Measured memory_bytes: 128
k = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

ans = l[k-1]

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1LL<<62
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

struct edge {
	int from,to;
	ll cost;

	edge(int t,int c) : to(t),cost(c) {}
	edge(int f,int t,int c) : from(f),to(t),cost(c) {}

	bool operator<(const edge &e) const {
		return cost < e.cost;
	}
};

ll H[100005], Y[100005];
vector<edge> G[100005];
ll d[100005];

void dijkstra(int s, int n, int h) {
	priority_queue<PP,vector<PP>,greater<PP> > que;
	fill(d,d+n,INF);

	d[s] = 0;
	Y[s] = h;
	que.push(PP(P(0, h), s));

	while(que.size()) {
		PP p = que.top();
		que.pop();

		ll cost = p.first.first;
		ll cur = p.first.second;
		int v = p.second;
		if(d[v] < cost) continue;

		// cout << " ----- State : (" << cost << ", " << cur << ", " << v << ") ------------" << endl;

		rep(i,G[v].size()) {
			edge e = G[v][i];

			// cout << v << " -> " << e.to << " : " << H[e.to] << " " << e.cost << " " << H[v] << endl;
			if(H[v] < e.cost) continue;

			if(cur - e.cost < 0) {
				// cout << "if 1" << endl;
				if(e.cost - cur <= H[v] - cur && d[e.to] > d[v] + (e.cost - cur) + e.cost) {
					d[e.to] = d[v] + (e.cost - cur) + e.cost;
					Y[e.to] = 0;
					que.push(PP(P(d[e.to], 0), e.to));
				}
			} else if(cur - e.cost > H[e.to]) {
				// cout << "if 2    cost:" << ((cur - e.cost) - H[e.to]) << endl;
				if(cur - ((cur - e.cost) - H[e.to]) >= 0 && d[e.to] > d[v] + ((cur - e.cost) - H[e.to]) + e.cost) {
					d[e.to] = d[v] + ((cur - e.cost) - H[e.to]) + e.cost;
					Y[e.to] = cur - ((cur - e.cost) - H[e.to]) - e.cost;
					que.push(PP(P(d[e.to], cur - ((cur - e.cost) - H[e.to]) - e.cost), e.to));
				}
			} else {
				// cout << "if 3" << endl;
				if(d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					Y[e.to] = cur - e.cost;
					que.push(PP(P(d[e.to], cur - e.cost), e.to));
				}
			}

			// rep(j, n) {
			// 	cout << " --- j:" << j << " " << d[j] << endl;
			// }
		}
	}
}

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

	memset(H, 0, sizeof(H));
	memset(Y, 0, sizeof(Y));

	rep(i, n) cin >> H[i];
	rep(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;

		a--;
		b--;

		G[a].push_back(edge(b, c));
		G[b].push_back(edge(a, c));
	}
	
	// cout << " Graph " << endl;
	// rep(i, n) {
	// 	cout << "i:" << i << " | ";
	// 	rep(j, G[i].size()) cout << G[i][j].to << " ";
	// 	cout << endl;
	// }

	dijkstra(0, n, h);

	// rep(i, n) {
	// 	cout << i << " " << d[i] << endl;
	// }

	if(d[n-1] == INF) cout << -1 << endl;
	else cout << d[n-1] + (H[n-1] - Y[n-1]) << endl;

	return 0;
}

Measured memory_bytes: 24012
module Main where

import Control.Monad
import qualified Data.Vector.Unboxed as VU

import Data.Maybe (fromJust)
import Data.List
import qualified Data.ByteString.Char8 as BS


bytestr2Int = fst . fromJust . BS.readInt
getInt = bytestr2Int <$> BS.getLine
getIntL_H = map bytestr2Int. BS.words <$> BS.getLine
getIntL_V n = replicate n $ getInt
getInt2D n = replicate n $ getIntL_H


main :: IO ()
main = do
    n <- getInt
    ns <- getIntL_H
    let vecN = VU.fromList $ ns
    r <- sum <$> ( forM [0..(n-2)] $ \i -> sum <$> do
        forM [(i+1)..(n-1)] $ \j -> do
            pure $ ((vecN VU.! i)*(vecN VU.! j)::Int)
                 )
    print r



Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int X,Y;
    cin >> X >> Y;
    int leg = X * 2;
    if(leg==Y){
        cout << "Yes" << endl;
        return 0;
    }
    if(leg>Y){
        cout << "No" << endl;
        return 0;
    }
    rep(i,X){
        leg += 2;
        if(leg==Y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3632
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
char find(ll &n){
	ll st=1;
	ll ac=st;
	while(ac<=n){
		st*=26;
		ac+=st;
	}
	st/=26;
	ll x=st;
	char c='`';
	c+=n/st;
	cout<<n<<" ";
	if((n%st == 0) or(n>26))
		c--;
	n%=st;
	if(st!=1 and n==0)
		n=st;
	if(st==1)
		c++;
	cout<<c<<" "<<st<<" "<<n<<endl;
	return c;
}
void fin(ll n){
	char s[10000];
	char c;
	ll st,x,count;
	st=26;
	count=0;
	while(n>0){
		x=n%st;
		x/=(st/26);
		if(x==0)
			x=26;
		n-=(x*(st/26));
		c='`';
		c+=x;
		st*=26;
//		cout<<count<<" "<<c<<" "<<st<<" "<<n<<endl;
		s[count++]=c;
	}
	reverse(s,s+count);
	cout<<s;
}
void solve(){
	ll n;
	cin>>n;
	fin(n);
//	char s[100000];
//	ll count=0;
//	cout<<"A";
//	while(n>0){
//		cout<<"B";
//		s[count++]=find(n);
//	}
//	cout<<s;
	return;
}
int main(){
//	ios::sync_with_stdio(false);
//	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;
#define int ll
using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<int, int> pii;
typedef long double ld;
typedef pair<ld, ld> pld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<pii> vpii;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
        return out;
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


void solve() {
    int n;
    cin >> n;
    vi ans(n + 1);
    rep(x, 1, 150) rep(y,1,150)rep(z,1,150) {
        int r = sqr(x) + sqr(y) + sqr(z) + x*y + y * z + x * z;
        if (r <= n) ++ans[r];
    }
    rep(i,1,n+1)put(ans[i]);
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;

    while (q--) solve();
}


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

int main() {
  int n;
  int p;
  int o0;
  int flg;
  int o1;
  
  cin >> n;
  
  for(int i = 1; i < n + 1; i++){
cin >> p;
    if(!(i == p)){
      flg = flg + 1;
      
    }
  }

if (flg>=3 || flg == 1){
cout << "NO" << endl;
}else{
  cout << "YES" << endl;
}
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

int main(){
	int a,b,c;
	int rec=0,dia=0;
	
	while(scanf("%d,%d,%d",&a,&b,&c) != EOF){
		if(a*a+b*b==c*c)rec++;
		else if(a==b)dia++;
	}

	std::cout<<rec<<std::endl<<dia<<std::endl;
	
	return 0;
}

Measured memory_bytes: 1208