akhauriyash/Code-Regression huggingface dataset:
// B.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
	string s, t;
	cin >> s >> t;
	int len = (int)s.length();
	int ans = 0;
	for (int i = 0; i < len; ++i) {
		ans += s[i] != t[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int n=(int)a.size();
    if(a[0]!='A') printf("WA\n");
    else
    {
        int ans=0,pos;
        for(int i=0;i<n;i++) if(a[i]=='C') pos=i,ans++;
        if(ans!=1) printf("WA\n");
        else
        {
            if(pos>=2&&pos<=n-2)
            {
                int k=0;
                for(int i=0;i<n;i++)
                    if(a[i]>='a'&&a[i]<='z') k++;
                if(k==n-2) printf("AC\n");
                else printf("WA\n");
            }
            else printf("WA\n");
        }
    }
}


Measured memory_bytes: 256
a,b,x = map(int,input().split())

import math

if x < b * a / 2 * a:  
	print(math.degrees(math.atan((a*b*b)/(2*x))))
else:
	x = a * a * b - x
	print(math.degrees(math.atan((2*x)/(a*a*a))))

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

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

	int t=1;
	long n;
	ll temp;

	while(t--)
	{
		cin>>temp;
		if(temp>=30) cout<<"Yes";
		else cout<<"No";
	}

	return 0;
}

Measured memory_bytes: 3648
rgb = set(["r","g","b"])
while 1:
	worm = raw_input()
	if worm == "0": break
	n = len(worm)
	que = [worm]
	ref = set(worm)
	L = 1
	cnt = flag = 0
	while 1:
		for r in range(L):
			Worm = que.pop(0)
			if Worm in ref: continue
			else: ref.add(Worm)
			if len(set(Worm)) == 1:
				flag = 1
				break
			for i in range(n-1):
				if Worm[i] != Worm[i+1]:
					worm = Worm[:]
					nextclr = list(rgb-set(worm[i:i+2]))[0]
					worm = worm[:i] + 2*nextclr + worm[i+2:]
					if worm not in que: que.append(worm)
		L = len(que)
		if flag or L == 0: break
		cnt += 1
	print cnt if flag else "NA"

Measured memory_bytes: 5552
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int n,m,q;
vector<int>a,b,c,d;
int ans;
void dfs(vector<int>A){
  if(A.size()==n+1){
    int now=0;
    rep(i,q){
      if(A[b[i]]-A[a[i]]==c[i]){
        now+=d[i];
      }
    }
    ans=max(ans,now);
    return;
  }
  int prev=A.back();
  rep2(v,prev,m+1){
    A.push_back(v);
    dfs(A);
    A.pop_back();
  }
}
int main() {
  
  cin>>n>>m>>q;
  a = b = c = d = vector<int>(q);
  rep(i,q){
    cin>>a.at(i)>>b.at(i)>>c.at(i)>>d.at(i);
  }
  dfs(vector<int>(1,1));   
  cout<<ans<<endl;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mk make_pair
#define pb push_back
#define mod 1000000007

int main(){
   int d,t,s;
   cin>>d>>t>>s;
   int time=d/s;
   int ed=d%s;
   if(t<time)cout<<"No"<<endl;
   else if(t>time)cout<<"Yes"<<endl;
   else if(t==time && ed==0)cout<<"Yes"<<endl;
   else if(t==time && ed!=0)cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e6 + 3)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}
int exp(int a, int b){
    LL res = 1;
    LL sum = a;
    for(int i=0;i<30;++i){
        if(BIT(i)&b){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
    }
    return res;
}
int main(){
    LL a, b, c;
    cin >> a >> b >> c;
    LL ans = (a&1)*b*c;
    ans = min(ans, a*(b&1)*c);
    ans = min(ans, a*b*(c&1));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

int main(){
int n , a , b;
	cin >> n >> a >>  b ;
	//nまでの整数から各位の和をゲットする
	int ans = 0;
	int p,c;
	for(int i = 1 ; i <= n ; i++){
		int sum = 0;//各位の数値の和
		//1からnまで　iの各位の数値の和がaからbの間ならansにiを足す。
	int s = i ;
	while(s>=10){
		sum += s%10;
		s/=10;
	}
	sum+=s;
	if(a<=sum&&sum<=b){
		ans+= i;
	}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String weather[] = {"Sunny","Cloudy","Rainy"};
		int ans = 0;
		for(int i = 0;i < 3;i++) {
			if(s.equals(weather[i])) {
				ans = (i + 1) % 3;
			}
		}
		System.out.println(weather[ans]);
	}

}


Measured memory_bytes: 21588
#include <stdio.h>
#define MAX 1000000
int partition(int *,int,int);

int n;
int main(){
  int i,r;
  int A[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
   
 r=partition(A,0,n-1);

 for(i=0;i<n;i++){
   if(i)printf(" ");
   if(i==r)printf("[");
   printf("%d",A[i]);
   if(i==r)printf("]");
 }
 printf("\n");
 return 0;
}
int partition(int *A,int p,int r){
  int x,i,k,m,j;
  x=A[r];
  i=p-1;
  for(j=p;j<=r-1;j++){
    if(A[j]<=x){
      i=i+1;
      k= A[i];
      A[i]=A[j];
      A[j]=k;
    }
  }
    m=A[i+1];
    A[i+1]=A[r];
    A[r]=m;
  return i+1;
}



Measured memory_bytes: 3000
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll N,M,V,P;
	cin >> N >> M >> V >> P;
	ll i;
	ll A[N];
	for(i=0;i<N;i++){
		cin >> A[i];
	}
	sort(A,A+N,greater<ll>());
	ll S[N];
	S[P-1]=A[P-1];
	for(i=0;i<P-1;i++){
		S[i]=0;
	}
	for(i=P;i<N;i++){
		S[i]=S[i-1]+A[i];
	}
	ll l=P-1,r=N,t;
	while(r-l>1){
		t=(r+l)/2;
		if(A[t]+M>=A[P-1] && S[t-1]+max((long long)0,(V-(N+P-t-1)))*M<=(t-P+1)*(A[t]+M))l=t;else r=t;
	}
	cout << l+1;
    return 0;
}


Measured memory_bytes: 1792
word = input()
count = int(input())
reversed_flg = False
head = ''
tail = ''

for i in range(count):
    line = input()
    if len(line) == 1:
        reversed_flg = not reversed_flg
    else:
        str_t, str_f, char = line.split()
        f = int(str_f)

        if (f == 1 and not reversed_flg) or (f == 2 and reversed_flg):
            # word = char + word
            head = char + head
        else:
            # word = word + char
            tail += char

word = head + word + tail

if reversed_flg:
        word = word[::-1]

print(word) 

Measured memory_bytes: 4552
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld double
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pll pair <ll,ll>
#define nl "\n"
 
int main()
{
	ios_base::sync_with_stdio(false);
	ll n,i;
	cin>>n;
	ll a[n+2];
	for(i=0;i<n;i++)
		cin>>a[i];
	ll maxi = a[0], ans = 0;
	for(i=1;i<n;i++)
	{
		if(a[i]<maxi)
			ans += maxi-a[i];
		else
			maxi = max(maxi, a[i]);
	}
	cout<<ans<<nl;
	return 0;
}

Measured memory_bytes: 5120
X = [1,-1,0,0]
Y = [0,0,1,-1]
B = [1,2,4,8]

while 1:
    w, h = list(map(int,input().split()))
    if w == 0:break

    _map = [[0 for i in range(w)] for i in range(h)]
    dp = [[99999999 for i in range(w)] for i in range(h)]

    for i in range(h*2-1):
        for j,v in enumerate(list(map(int,input().split()))):
            if v == 0:continue
            if i % 2 == 0 :
                _map[i // 2][j] += B[0]
                if j+1 < w:
                    _map[i // 2][j+1] += B[1]
            else:
                _map[i // 2][j] += B[2]
                if (i // 2) + 1 < h:
                    _map[(i // 2)+1][j] += B[3]
    lst = [(1,0,0)]
    dp[0][0] = 1
    res = 0

    # print(_map)
    while len(lst) > 0:
        spam = lst.pop(0)
        for i in range(4):
            x = spam[2] + X[i]
            y = spam[1] + Y[i]
            if x < 0 or y < 0 or x >= w or y >= h or  \
                B[i] & _map[spam[1]][spam[2]] != 0 or dp[y][x] <= spam[0] + 1:
                continue
            if x+1 == w and y+1 == h:
                res = spam[0] + 1
                break
            lst.append((spam[0] + 1, y, x))
            dp[y][x] = spam[0] + 1
        if res > 0:break
        lst.sort()

    print(res)

Measured memory_bytes: 6800
/// ببِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,p=INT_MAX,j=0,x,a=0,b,l=0,r=0,y,k,c;
      double sv,st;
    cin>>st;
     sv=double(st/3);
     sv=sv*sv*sv;
     printf("%0.8f",sv);

     return EXIT_SUCCESS;
}




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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;


const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = INT_MAX / 2;

string to_s(int value, int len) {
	stringstream ss;
	ss << value;
	string s = ss.str();
	string zero = "";
	rep (i, len - s.length()) {
		zero += '0';
	}
	return zero + s;
}

int max_value(string s) {
	sort(rall(s));
	stringstream ss;
	ss << s;
	int res;
	ss >> res;
	return res;
}

int min_value(string s) {
	sort(all(s));
	stringstream ss;
	ss << s;
	int res;
	ss >> res;
	return res;
}

int check(VI vec, int value) {
	rep (i, vec.size()) {
		if (vec[i] == value) return i;
	}
	return -1;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int a, l;
	while (1) {
		cin >> a >> l;
		if (a == 0 && l == 0) break;
		VI vec;
		vec.pb(a);
		int value = a;
		rep (i, 21) {
			string s = to_s(value, l);
			value = max_value(s) - min_value(s);
			int idx;
			if ((idx = check(vec, value)) != -1) {
				cout << idx << " " << value << " " << i - idx + 1 << endl;
				break;
			}
			vec.pb(value);
		}
	}
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define MAXN 1000005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
char s[MAXN];
int N,Q,K;
int val[MAXN],add;
int que[MAXN],ql,qr;

void Solve() {
    read(K);
    ql = 1;qr = 0;
    add = 0;
    int64 sum = 0,ans = 0;
    for(int i = N ; i >= 1 ; --i) {
	if(s[i] == 'C') {que[++qr] = i;val[i] = -add;sum += val[i];}
	else if(s[i] == 'M') ++add;
	else if(s[i] == 'D'){
	    while(ql <= qr && que[ql] - i >= K) {sum -= val[que[ql++]];}
	    if(ql <= qr) {
		ans += sum + 1LL * add * (qr - ql + 1);
	    }
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(N);
    scanf("%s",s + 1);
    read(Q);
    while(Q--) {
	Solve();
    }
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define endl '\n'
#define fo(i,n) for(i=0;i<n;++i)
#define forr(i,n) for(i=n-1;i>=0;--i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

ll gcd(ll a,ll b){while(a&&b)a>b?a%=b:b%=a;return a+b;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll max(ll a, ll b){
  return a>b?a:b;
}

int main(){
    ios_base::sync_with_stdio(false);cout.tie(NULL);
    ll n, x, x1, y1;
    cin>>n>>x;
    ll ans, maxer;
    ll sum = 0;
    ll dp[n];
    ll i, a[n], b[n];
    fo(i,n){
      cin>>a[i];
      if(a[i]>x){
        sum+=(a[i]-x);
        a[i] = x;
      }
      b[i] = a[i];
    }
    dp[0] = 0;

    for(i=1;i<n;i++){
      //first
      if(a[i-1]+a[i]>x){
        dp[i] = a[i-1] + a[i] - x;
        a[i] -= dp[i];
      }
      else
        dp[i] = 0;
      dp[i] += dp[i-1];
      // if(i<n && a[i]+a[i+1]>x){
      //   y1 = a[i+1] + a[i] - x;
      // }
      //dp[i][0]  = max(0,max(x1,y1));
      // maxer = max(x1,y1);
      // dp[i][0] = max(0,maxer);
      // a[i] = a[i] - dp[i][0];
      //check for n as no n+1
    }


    cout<<sum+dp[n-1]<<endl;

    return 0;
}


Measured memory_bytes: 2560
from sys import stdin
n = int(stdin.readline().rstrip())
a =  list(map(int,input().split()))
wk = 0  #比較用
tp = 0  #背の基準
ans = 0

num = 0
while num < n:
  #比較処理
  wk = a[num]
  if tp < wk:
    tp = wk
  if a[num] < tp:
    ans = ans + (tp - a[num])
  num = num + 1

print(ans)

Measured memory_bytes: 32224
n,p=map(int,input().split())
num=[list(map(int,input().split())) for _ in range(n)]
cnt=0
for i in range(n):
    cnt+=num[i][1]
dp=[[10**10]*(cnt+1) for _ in range(n+1)]
for i in range(n+1):
    dp[i][0]=0
for i in range(1,n+1):
    w=num[i-1][0]
    v=num[i-1][1]
    for j in range(cnt+1):
        dp[i][j]=dp[i-1][j]
    dp[i][v]=min(dp[i][v],w)
    for j in range(1,cnt+1-v):
        if dp[i-1][j]!=10 and dp[i-1][j]+w<=p:
            dp[i][j+v]=min(dp[i][j+v],dp[i-1][j]+w)
ans=0
for i in range(n+1):
    for j in range(1,cnt+1):
        if dp[i][j]<=p:
            ans=max(ans,j)
print(ans)


Measured memory_bytes: 147004
import java.util.Scanner;

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

        A = sc.nextInt();
        B = sc.nextInt();

        if(A >= 13) {
            System.out.println(B);
        }else if(6 <= A && A <= 12) {
            System.out.println(B/2);
        }else {
            System.out.println(0);
        }
    }
}

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

int main()
{
  int n, m, c;
  cin >> n >> m >> c;
  int b[m];
  int a[n][m];
  rep(i, m) cin >> b[i];
  rep(i,n){
    rep(j,m){
      cin >> a[i][j];
    }
  }
  int ans = 0, tmp = 0;
  rep(i,n){
    tmp = 0;
    rep(j,m){
      tmp += a[i][j] * b[j];
    }
    if(tmp + c > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import           Unsafe.Coerce

main :: IO ()
main = do
    [n, q] <- map read.words <$> getLine :: IO [Int]
    cs <- U.unfoldrN n C.uncons <$> C.getLine
    lrs <- U.unfoldrN q parseInt2 <$> C.getContents
    putStr.unlines.map show.U.toList $ solve n cs lrs

solve :: Int -> U.Vector Char -> U.Vector (Int, Int) -> U.Vector Int
solve n cs lrs = U.map (uncurry query) lrs
  where
    go ('A':'C':s) = 0:1:go s
    go (c:s) = 0:go s
    go [] = []

    table :: U.Vector Int
    !table = U.scanl' (+) 0 . U.fromListN n . go $ U.toList cs
    {-# NOINLINE table #-}

    query l r = table U.! r - table U.! l


-------------------------------------------------------------------------------
type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

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



int main() {
  ll n;
  cin >> n;
  ll ans=0;
  ll pre;
  cin >> pre;
  rep(i, n-1){
    ll x;
    cin >> x;
    if(pre > x){
      int tmp = pre-x;
      ans += tmp;
      pre = x+tmp;
    }
    else pre = x;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	n, m := scanInt(sc), scanInt(sc)
	xs := nextIntSlice(sc, m)
	sort.Sort(sort.IntSlice(xs))
	dfs := []pair{}
	for i := 1; i < len(xs); i++ {
		dfs = append(dfs, pair{p: xs[i], d: xs[i] - xs[i-1]})
	}
	sort.Sort(pairs(dfs))
	sum := 0
	num := 0
	registered := map[int]struct{}{}
	j := 0
	for i := 0; i < len(dfs); i++ {
		if num >= m-n {
			break
		}
		c := dfs[j]
		if _, ok := registered[c.p]; !ok {
			registered[c.p] = struct{}{}
			sum += c.d
			num++
		}
		j++
	}
	return sum
}

type pair struct{ p, d int }
type pairs []pair

func (p pairs) Len() int {
	return len(p)
}

func (p pairs) Less(i, j int) bool {
	return p[i].d < p[j].d
}

func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

using namespace std;

void test()
{
    string s;
    cin>>s;

    int r=0;

    for(int i=0;i<s.size();i++)
    {
        int st=0;
        if(s[i]=='R')
        {

            //st++
            while(s[i]=='R')
            {
                i++;
                st++;
            }
        }
        r=max(r,st);
    }

    cout<<r<<endl;
}

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

    test();

    return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  long r=0, g=0, b=0;
  for(int i=0; i<N; i++){
    if(S[i]=='R') r++;
    else if(S[i]=='G') g++;
    else b++;
  }
  long ans = r*g*b;
  long sub = 0;
  for(int i=1; i<=N; i++){
    for(int j=i+1; j<=N; j++){
      if(S[i-1]==S[j-1]) continue;
      int k = 2*j-i;
      if(k>N || S[i-1]==S[k-1] || S[j-1]==S[k-1] ) continue;
      sub++;
    }
  }
  cout << ans-sub << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main(void) {
	int m, n_min, n_max;
	int score[10001] = { 0 }, gap, ans, tmp;

	while (1) {
		cin >> m; cin >> n_min; cin >> n_max;
		if (m == 0 && n_min == 0 && n_max == 0) break;

		gap = 0;
		ans = 0;
		for (int i = 1; i <= m; i++) {
			cin >> score[i];
		}
		for (int j = n_min; j <= n_max; j++) {
			if ((tmp = score[j] - score[j + 1]) >= gap) {
				gap = tmp;
				ans = j;
			}
		}
		cout << ans <<endl;
	}

	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> q[i];
    }
    vector<int> v(n);
    int a = 0;
    int b = 0;
    int count = 0;
    for(int i = 0; i < n; i++) v[i] = i+1;
    do
    {
        count++;
        bool pflag = true;
        bool qflag = true;
        for(int i = 0; i < n; i++)
        {
            if(v[i] != p[i]) pflag = false;
            if(v[i] != q[i]) qflag = false;
        }
        if(pflag) a = count;
        if(qflag) b = count;
    }
    while(next_permutation(v.begin(), v.end()));
    cout << abs(a-b) << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,count[26] = {0};
    char ch;
     
    while(scanf("%c",&ch) != EOF){
        for(i = 0;i < 26;i++){
            if(ch == 'a' + i || ch == 'A' + i){
                count[i]++;
            }
        }
    }
     
    for(i = 0;i < 26;i++){
        printf("%c : %d\n",'a' + i,count[i]);
    }
    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    string S; cin >> S;

    i64 cnt = 1;
    char prev = S[0];
    for (i64 i = 1; i < S.length(); i++) {
        if (prev == S[i]) continue;
        prev = S[i];
        cnt++;
    }
    cout << (cnt - 1) << endl;

    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn=105;
char s[maxn];
int main()
{
    while(~scanf("%s", s)){
        int len=strlen(s);
        printf("%c%d%c\n", s[0], len-2, s[len-1]);
    }
    return 0;
}


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

#define cst() int __t;scanf("%d",&__t);while(__t--)
#define rep(i,s,e) for(int i=s;i<e;++i)
#define repb(i,s,e) for(int i=s;i<=e;++i)
#define lep(i,s,e) for(int i=s;i>e;--i)
#define lepb(i,s,e) for(int i=s;i>=e;--i)
#define mst(a,b) memset(a,b,sizeof(a))
#define mcpy(des,sor) memcpy(des,sor,sizeof(sor))
#define pow2(x) ((x)*(x))
#define pt(x) cout<<#x<<"="<<x<<endl;


#define maxn 100006

typedef long long ll;
const int inf = 0x3f3f3f3f;

typedef pair<int,int> pii;

int main()
{
	int n,a[maxn],ma,mi,si,sa;
	cin>>n;
	ma=0;mi=n;
	repb(i,1,n)
	{
		cin>>a[i];
		ma=max(ma,a[i]);
		mi=min(mi,a[i]);
	}
	if(mi==ma)
	{
		if(a[1]==n-1||2*a[1]<=n)puts("Yes");
		else puts("No");
	}
	else if(mi+1==ma)
	{
		si=sa=0;
		repb(i,1,n)if(a[i]==mi)++si; else ++sa;
		if(si+2*(mi-si+1)<=n&&ma-si>0)puts("Yes");
		else puts("No");
	}
	else puts("No");
}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text;

namespace ConsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {
            var ar = ReadLine().Split().Select(long.Parse).ToArray();
            var k = ar[0];
            var n = ar[1];

            var a = ReadLine().Split().Select(long.Parse).ToArray();

            var bet = new long[n];
            int maxind = -1;
            long maxval = 0;
            for (int i = 0; i < n;i++)
            {
                if(i >= n-1){
                    bet[n-1] = a[0] + k - a[n - 1];
                }
                else
                {
                    bet[i] = a[i + 1] - a[i];
                }
                if (maxval < bet[i])
                {
                    maxval = bet[i];
                    maxind = i;
                }
            }

            WriteLine(k-maxval);

        }



    }

}


Measured memory_bytes: 37988
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    N = Number(input.split("\n")[0]);
    S= input.split("\n")[1].split("");
    answer = N+1;
    numEast = new Array;
    numWest = new Array;
       
    for(i=0;i<N;i++){
        //Sの左からi番目までにE/Wがいくつあるか
        if(S[i]=="E"){
            if(i==0){
                numEast[i]=1;
                numWest[i]=0;
            }else{
                numEast[i]= numEast[i-1] + 1;
                numWest[i]= numWest[i-1];
            }
        }else{
            if(i==0){
                numEast[i]=0;
                numWest[i]=1;
            }else{
                numEast[i]= numEast[i-1];
                numWest[i]= numWest[i-1] + 1;
            }
        }    
    }

    for(j=0;j<N;j++){
        tmp=0;
        //j番目がリーダーとする 
        //求めるべきはnumWest[j-1] + numEast[N] - numEast[j]
        if(j !== 0){
            tmp = numWest[j-1] + numEast[N -1] - numEast[j];
        }else{
            tmp = numEast[N -1] - numEast[j];
        }
        
        answer = Math.min(answer,tmp);
    }

    console.log(answer);
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29956
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
int a;
int c[1050000];
/*
signed main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  s[k-1]-='A';
  s[k-1]+='a';
  cout<<s<<endl;
  return 0;
}
signed main(){
  char c;
  int y=0;
  int d=0;
  lp(i,2){
    cin>>c;
    y+=c-'0';
    y*=10;
  }
  lp(i,2){
    cin>>c;
    d+=c-'0';
    d*=10;
  }
  y/=10;
  d/=10;
  if(1<=y&&y<=12&&1<=d&&d<=12) cout<<"AMBIGUOUS"<<endl;
  else if(1<=y&&y<=12) cout<<"MMYY"<<endl;
  else if(1<=d&&d<=12) cout<<"YYMM"<<endl;
  else cout<<"NA"<<endl;
  return 0;
}
*/
signed main(){
  std::cout << std::setprecision(15);
  int n,k;
  cin>>n>>k;
  double ans=0;
  for(int i=1;i<=n;i++){
    int cnt=1;
    for(int j=i;j<k;j*=2){
      cnt*=2;
    }
    //cout<<cnt<<endl;
    ans+=(double)1/cnt;
  }
  cout<<ans/n<<endl;
  return 0;
}

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


int main()
{
int N,A,B;
cin>>N>>A>>B;
string S;
cin>>S;
int winner=0;
int abroad=0;

for(int i=0;i<N;i++)
{
if(S[i]=='a')
{if(winner<A+B){cout<<"Yes"<<endl;winner++;}
else{cout<<"No"<<endl;}
}
if(S[i]=='b')
{if(winner<A+B&&abroad<B){cout<<"Yes"<<endl;winner++;abroad++;}
else{cout<<"No"<<endl;}}
if(S[i]=='c'){cout<<"No"<<endl;}
}

}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n) {
    for(int i=2;i*i<=n;++i) {
        if(n%i==0)
        return false;
    }
    return true;
}


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int a,b;
    cin>>a>>b;
    cout<<6-a-b<<endl;


    // ()?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3636
n, m = [int(x) for x in input().split()]
h = [{'h': int(x), "r": []} for x in input().split()]

for i in range(m):
    a, b = [int(x) for x in input().split()]
    h[a - 1]['r'].append(b)
    h[b - 1]['r'].append(a)

good = 0
for t in h:
    highest = True
    for h2 in t['r']:
        if t['h'] <= h[h2 - 1]['h']:
            highest = False
            break
    if highest:
        good += 1
print(good)

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


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

	vector<int> a(N);
	for (int i = 0; i < N; i++)
		cin >> a[i];

	sort(a.begin(), a.end(), greater<int>());

	int alice=0, bob=0;
	for (int i = 0; i < N; i++)
	{
		if (i % 2 == 0)
			alice += a[i];
		else
			bob += a[i];
	}

	cout << abs(alice - bob) << "\n";

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func min(x int, y int) int {
	var res int
	if x < y {
		res = x
	} else {
		res = y
	}

	return res
}

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

	ans := min(N*A, B)

	fmt.Println(ans)
}

Measured memory_bytes: 512
n = int(input())
f,*A,= map(int,input().split())
pcnt = 0 if f>0 else 1-f
ncnt = 0 if f<0 else f+1
pcur = max(1,f)
ncur = min(-1,f)
for i,a in enumerate(A):
	if pcur*(pcur+a)<0:
		pcur += a
	else:
		pcnt += abs((-1)**(i+1)-(pcur+a))
		pcur = (-1)**(i+1)
	if ncur*(ncur+a)<0:
		ncur += a
	else:
		ncnt += abs((-1)**i-(ncur+a))
		ncur = (-1)**i
print(min(pcnt,ncnt))

Measured memory_bytes: 14468
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

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

using namespace std;

int sum(string s) {
    reverse(s.begin(), s.end());
    int res = 0, ten = 1;
    REP(i, s.size()) {
        int tmp = (int)s[s.size()-1-i]-48;
        if ( tmp > 0 ) {
            res += tmp * ten;
        }
        ten *= 10;
    }
    return res;
}
int dup(int ns[], int i) {
    REP(j, i) {
        if ( ns[i] == ns[j] ) return j;
    }
    return -1;
}

int main() {
    int a, l;
    stringstream ss;

    while (cin >> a >> l, a || l) {
        int ns[21];

        ns[0] = a;

        REP(i, 20) {
            ss.str("");
            ss << a;
            string tmp = ss.str();
            // cout << tmp << endl;

            // ゼロ埋め
            while(tmp.size() < l) {
                tmp = "0" + tmp;
            }

            // 最大値を出す
            sort(tmp.begin(), tmp.end());
            int big = sum(tmp);

            // 最小値を出す
            reverse(tmp.begin(), tmp.end());
            int sml = sum(tmp);

            ns[i+1] = a = big - sml;
            // cout << big << " " << sml << " " << a << endl;

            // 重複があれば
            int res = dup(ns, i+1);
            if ( res >= 0 ) {
                printf("%d %d %d\n", res, ns[i+1], i+1-res);
                // cout << res << " " << ns[i+1] << " " << i+1-res << endl;
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3272
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second
#define pb push_back
#define REP(i,a,b) for(long long int i=a ; i<b ; i++)
#define mp make_pair
#define INF 1000000000000000000
#define mod 1000000007
#define pi pair<ll,ll>
#define pd pair<ld,ld>
#define vi vector<ll>
#define vd vector<ld>
#define vvi vector<vi>
#define vvd vector<vd>
#define vpi vector<pi>
#define vpd vector<pd>
#define us unordered_set<ll>
#define um unordered_map<ll,ll>
#define sortA(a) sort(a.begin(),a.end())
#define sortD(a) sort(a.begin(),a.end(),greater<ll>())
#define all(a) a.begin(),a.end()
#define N 100005


#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define in insert
#define fbo find_by_order
#define ook order_of_key


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

ll powmod(ll x,ll y)
{
	if(x==0)
		return 0;
	if(y==0 || x==1)
		return 1;
	if(y%2==0)
		return powmod((x*x)%mod,y/2)%mod;
	return (x*powmod(x,y-1)%mod)%mod;
}
void print1D(vi a)
{
	for(ll i=0;i<a.size();++i)
	{
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
void print2D(vector<vi> a)
{
	for(ll i=0;i<a.size();++i)
	{
		for(ll j=0;j<a[i].size();++j)
		{
			cout<<a[i][j]<<" ";
		}
		cout<<endl;
	}
}
void solve()
{
	ll n,k;
	cin>>n>>k;
	vi a(n);
	for(ll i=0;i<n;++i)
	{
		cin>>a[i];
	}
	vi c(n);
	c[0]=0;
	c[1]=abs(a[1]-a[0]);
	for(ll i=2;i<n;++i)
	{
		c[i]=INF;
		for(ll j=i-1;j>=0 && j>=(i-k);--j)
		{
			c[i]=min(c[i],c[j]+abs(a[j]-a[i]));
		}
	}
	cout<<c[n-1]<<endl;
}
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
int main(){


ll ans,n,m;
cin>>n>>m;
ll z=n*m;
if(n==1 || m==1) ans=1;
else if(z%2!=0) ans = (z/2)+1;
else ans=z/2;
cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long W = sc.nextLong();
		int N = sc.nextInt();
		int a[] = new int[N];
		int b[] = new int[N];
		HashMap<Long, Integer> map = new HashMap<Long, Integer>();
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			long l = b[i] + a[i] * W;
			out : for(int y = 0; y < 3; y++) {
				if(a[i] - y < 0 || a[i] - y >= H - 2) continue out;
				in : for(int x = 0; x < 3; x++) {
					if(b[i] - x < 0 || b[i] - x >= W - 2) continue in;
					if(map.containsKey(l - x - y * W)) {
						map.put(l - x - y * W, map.get(l - x - y * W) + 1);
					} else {
						map.put(l - x - y * W, 1);
					}
				}
			}
		}
		
		long ans[] = new long[10];
		int cnt = 0;
		for(long key : map.keySet()) {
			ans[map.get(key)]++;
			cnt++;
		}
		ans[0] = (H - 2) * (W - 2) - cnt;
		for(int i = 0; i < 10; i++) {
			System.out.println(ans[i]);
		}
	}
}


Measured memory_bytes: 170836
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define put puts("")
#define print(x) cout << x << endl
#define print2(x,y) cout << x << " " << y << endl
#define print3(x,y,z) cout << x << " " << y << " " << z << endl
int n,m;
int a,b,c;
int ans;
int d[10000],p[10000];
int dp[10000][10000];

int main(){
  string s;
  cin >> s;
  cout << s[0] << s.sz-2 << s[s.sz-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n,a[100],sum;
	int i;
	for(;;){
		scanf("%d",&n);
		if(n==0){
			return 0;
		}
		for(i=0;i<100;i++){
			a[0]=0;
		}
		sum=0;
		for(i=0;i<n/4;i++){
			scanf("%d",&a[i]);
			sum+=a[i];
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
#define W 1000000007
using namespace std;

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int sum = (max({a,b,c}))*9+ a + b + c;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
// 2010/12/23 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		double n;
		cin >> n;
		if(n<0.0)
			break;

		int n16 = (int)(n*16.0);
		if(n*16.0!=(double)n16){
			cout << "NA" << endl;
			continue;
		}

		int bin[12];
		for(int i=0; i<12; i++){
			bin[i] = n16%2;
			n16 /= 2;
		}

		for(int i=11; i>=4; i--)
			cout << bin[i];
		cout << '.';
		for(int i=3; i>=0; i--)
			cout << bin[i];
		cout << endl;
	}

	return 0;
}

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

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

    double ans = 0;
    for (int i=1; i<=N; ++i) {
        if (i%2) ans++;
    }

    printf("%.10f\n", ans/N);
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
#include <chrono>
#include <random>
//#include <math.h>
#include <cmath>
#include <fstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <stdlib.h>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <bitset>

#pragma comment(linker, "/STACK:36777216")
using namespace std;

#define flu fflush(stdout)
#define gg return 0
#define mp make_pair

typedef long double ptype;

long long mod = /*27449*//*998244353*/ 1e9 + 7 /*1e9 + 9*/;
int inf = 1e9;
double eps = 1e-8;
long double pi = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ifstream in("input.txt");
ofstream out("output.txt");

void solve()
{
	string s;
	cin >> s;
	int rem = 0;
	for (auto c : s)
	{
		rem = (rem * 10 + c - '0') % 9;
	}
	cout << (rem ? "No" : "Yes");
}

int main()
{
	cout << setprecision(20) << fixed;
	cin.tie();
	cout.tie();
	clock_t t1 = clock();
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int t;
	//cin >> t;
	t = 1;
	while (t--) {
		solve();
		//test();
	}
	//cout << (clock() - t1) * 1.0 / CLOCKS_PER_SEC;
	gg;
}

Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vec(H,vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> vec.at(i).at(j);
    }
  }
  string ans = "Possible";
  int last = 0;
  for(int k=0; k<H; k++){
    for(int l=0; l<W; l++){
      if((l<last) && (vec.at(k).at(l) == '#')){
        ans = "Impossible";
      }
      if((l>=last) && vec.at(k).at(l) == '.'){
        for(int m=W-1; m>=l-1; m--){
         if(vec.at(k).at(m) == '#' && m == W-1){
           last = W-1;
           break;
          }
         else if(vec.at(k).at(m) == '#'){
         last = max(last,m);
         break;
         }
         else if(m == l+1){
         last = max(last,l-1);
         break;
         }
        }
        break;
      }
      if(l == W-1 && vec.at(k).at(l) == '#'){
        last = W-1;
        break;
      }
    }
  }
  cout << ans << endl;
}     

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	string ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
		sort(all(ar[i]));
	}
	sort(ar+1,ar+n+1);

	k=1; ll an=0;
	for(i=2;i<=n;i++){
		if(ar[i]==ar[i-1]){
			k++;
		}
		else{
			an+=(k*(k-1))/2;
			k=1;
		}
	}
	an+=(k*(k-1))/2;
	cout<<an;
	return 0;
}

Measured memory_bytes: 5760
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        String s = scanner.next();
        String t = scanner.next();
        int ans = 0;
        for(int i = 0; i < 3; i++) {
            if (s.charAt(i) != t.charAt(i)) ans++;
        }
        out.println(3-ans);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 23252