akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
int main() {
	int N;
	cin>>N;
	vint D;
	for(int i=0;i<N;i++){
		int d;
		cin>>d;
		D.pb(d);
	}
	sort(D.begin(),D.end());
	cout<<D[N/2]-D[N/2-1]<<endl;
	return 0;
}

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

int main() {
  int La,Lb,Rc,Rd;
  
  cin >> La >> Lb >> Rc >> Rd;
  
  if(La + Lb > Rc + Rd) cout << "Left";
  else if(La + Lb < Rc + Rd) cout << "Right";
  else cout << "Balanced";
}


Measured memory_bytes: 256
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
ll ans;
int main(){
	int n;
	scanf("%d",&n);
	rep(i,1,n+1){
		ll temp=i,base=1,flag=0;
		while(temp){
			int d=temp%10;
			if(d==3)flag|=1;
			else if(d==5)flag|=2;
			else if(d==7)flag|=4;
			else{
				//3,5,7以外が見つかったらその桁をスキップ
				//33400->33500
				//33800->33900
				i+=base-1;//for文でincされるので1引いとく
				break;
			}
			temp/=10;
			base*=10;
		}
		if(temp==0&&flag==7)ans++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
from bisect import bisect_left
from bisect import bisect_right

N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
j = bisect_left(C, B[0])
ansBC = [N - j] + [0] * (N-1)

for i in range(1, N):
    while j < N and B[i] >= C[j]:
        j += 1
    if j == N:
        break
    ansBC[i] = N - j

j = N-1
ans = 0
for i in range(N):
    while j >= 0 and A[i] < B[j]:
        ans += ansBC[j] * (N - i)
        j -= 1
    if j == -1:
        break
    
print(ans)

Measured memory_bytes: 24180
import sys
input = sys.stdin.readline

def main():
    n,k = map(int,input().split())

    mod = 10 ** 9 + 7

    roots = [[] for _ in range(n)]
    for i in range(n-1):
        a,b = map(int,input().split())
        roots[a-1].append(b-1)
        roots[b-1].append(a-1)

    li = [-1] * n
    li[0] = k
    ans = 1
    stack = [0]

    while stack:
        label = stack.pop(-1)
        count = 1
        li2 = []
        for i in roots[label]:
            if li[i] == -1:
                stack.append(i)
                li2.append(i)
            else:
                count += 1
        for i in li2:
            li[i] = k - count
            count += 1

    for i in li:
        ans *= max(i,0)
        ans %= mod

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69552
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=2e5;
const int inf=1e9;
int main(){
	int N; cin>>N;
	long A[N];
	rep(i,0,N) cin>>A[i];
	sort(A, A+N, greater<int>());
	long ans = A[0];
	rep(i,0,N-2) ans += A[i/2 + 1];
	cout<<ans<<endl;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

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

  const int X = 2000;

  bitset<X*X> dp(0);
  dp[0] = 1;
  rep(i,n){
    dp = dp | (dp<<v[i]);
  }

  int acc = accumulate(all(v), 0);

  rep(i,(acc+1)/2,X*X) if(dp[i]){
    cout << i << endl;
    return 0;
  }


  return 0;
}


Measured memory_bytes: 2304
#!/usr/bin/env python3
import re
s = input()


while True:
    # s = re.sub('dream$|dreamer$|erase$|eraser$','',s)

    l = len(s)
    if s.rfind('dream') == l-5:
        s = s[:-5]
    elif s.rfind('dreamer') == l-7:
        s = s[:-7]
    elif s.rfind('erase') == l-5:
        s = s[:-5]
    elif s.rfind('eraser') == l-6:
        s = s[:-6]
    else:
        break
        
if len(s)==0:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3316
use std::io::Read;
use std::cmp::max;

#[allow(non_snake_case)]
fn main() {
  let mut buf = String::new();
  std::io::stdin().read_to_string(&mut buf).unwrap();
  let mut S : Vec<usize> = buf.split_whitespace().map(|s| s.parse().unwrap()).collect();
  let N = S[0];

  let mut dp1 = vec![None; N + 1];
  let mut dp2 = vec![vec![None; N + 1];N + 1];
  {
    let mut s = S[1 ..= 2].to_vec();
    s.sort();
    let (a,b) = (s[0], s[1]);
    dp1[a].get_or_insert(0);
    dp1[b].get_or_insert(0);
    dp1[0].get_or_insert(0);
    dp2[a][b].get_or_insert(0);
  }

  let mut base = 0;
  let mut q = Vec::new();

  for i in 1 .. N {
    let mut s = S[3 * i .. 3 * (i + 1)].to_vec();
    s.sort();
    let (a,b,c) = (s[0],s[1],s[2]);
    
    if a == c {
      base += 1;
      continue;
    } else if a == b {
      for x in 1 ..= N {
        if x < a {
          if let Some(v) = dp2[x][a] {
            q.push((x, c, v + 1));
          }
        } else if x < c {
          if let Some(v) = dp2[a][x] {
            q.push((x, c, v + 1));
          }
        } else {
          if let Some(v) = dp2[a][x] {
            q.push((c, x, v + 1));
          }
        }
      }
      if let Some(v) = dp2[c][c] {
        q.push((a, a, v + 1));
      }
    } else if b == c {
      for x in 1 ..= N {
        if x < a {
          if let Some(v) = dp2[x][c] {
            q.push((x, a, v + 1));
          }
        } else if x < c {
          if let Some(v) = dp2[x][c] {
            q.push((a, x, v + 1));
          }
        } else {
          if let Some(v) = dp2[c][x] {
            q.push((a, x, v + 1));
          }
        }
      }
      if let Some(v) = dp2[a][a] {
        q.push((c, c, v + 1));
      }
    } else {
      if let Some(v) = dp2[a][a] {
        q.push((b, c, v + 1));
      }
      if let Some(v) = dp2[b][b] {
        q.push((a, c, v + 1));
      }
      if let Some(v) = dp2[c][c] {
        q.push((a, b, v + 1));
      }
    }
    
    q.push((a, b, dp1[0].unwrap()));
    q.push((a, c, dp1[0].unwrap()));
    q.push((b, c, dp1[0].unwrap()));
    
    for x in 1 ..= N {
      if let Some(v) = dp1[x] {
        for y in &[a,b,c] {
          if x < *y {
            q.push((x, *y, v));
          } else {
            q.push((*y, x, v));
          }
        }
      }
    }
    
    while let Some((a,b,v)) = q.pop() {
      if dp2[a][b].is_none() || dp2[a][b].unwrap() < v {
        let u = dp2[a][b].get_or_insert(v);
        *u = v;
        for i in &[0, a, b] {
          let u = dp1[*i].get_or_insert(v);
          *u = max(*u, v);
        }
      }
    }
  }

  let s = S[S.len() - 1];
  println!("{}", match dp2[s][s] {
    Some(v) => base + max(1 + dp2[s][s].unwrap_or(0), dp1[0].unwrap_or(0)),
    None    => base + dp1[0].unwrap(), 
  });
}


Measured memory_bytes: 33768
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;

int euler(int n)
{
    int ans = n;
    for(int i = 2; i <= sqrt(n); i ++)
    {
        if(n % i == 0)
        {
//            printf("i == %d\n", i);
            ans = ans/i*(i-1);
            while(n % i == 0)
                n /= i;
        }
    }
    if(n != 1)
        ans = ans/n*(n-1);
    return ans;
}

int main()
{
    int n;
    while(~scanf("%d",&n)) printf("%d\n", euler(n));
}



Measured memory_bytes: 3232
n,k=gets.split.map &:to_i
s=gets.chomp
t=s.chars.chunk(&:to_i).map{|a,b|[a,b.size]}
t.unshift([1,0]) if t[0][0]!=1
t.push([1,0]) if t[-1][0]!=1
u=[x=0]
t.map{|a,b|u<<x+=b}
if k>=u.size/2
p u[-1]
else
p (u.size/2-k).times.map{|i|u[i*2+k*2+1]-u[i*2]}.max
end

Measured memory_bytes: 18360
N = int(input())
T = [int(input()) for _ in range(N)]

def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

def lcm(m, n):
  return (m * n) // gcd(m, n)

ans = T[0]
for i in range(1,N):
  ans = lcm(ans,T[i])
print(ans)

Measured memory_bytes: 3064
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)

	var v []interface{}
	for {
		var s string
		if _, err := fmt.Fscan(r, &s); err != nil {
			break
		}

		var t interface{}
		n, err := strconv.Atoi(s)
		if err == nil {
			t = n
		} else {
			t = []rune(s)[0]
		}

		v = append(v, t)
	}

	calc(v)  // should be nil
}

type f func(int) f

func calc(v []interface{}) f {
	if len(v) == 0 {
		return f(func(n int) f {
			fmt.Println(n)
			return nil
		})
	}

	switch t := v[0].(type) {
	case int:
		return calc(v[1:])(t)
	case rune:
		return c(v[1:], t)
	default:
		panic(t)
	}
}

func c(v []interface{}, t rune) f {
	switch t {
	case '+':
		return op(v, func(a, b int) int {
			return a + b
		})
	case '-':
		return op(v, func(a, b int) int {
			return a - b
		})
	default:
		return op(v, func(a, b int) int {
			return a * b
		})
	}
}

func op(v []interface{}, fn func(int, int) int) f {
	return f(func(b int) f {
		return f(func(a int) f {
			return calc(v)(fn(a, b))
		})
	})
}



Measured memory_bytes: 1216
//注意关键，首先对于这种两个数求差的时候，求最大值的问题，一般需要让第一个数尽量大，第二个数尽量小，由此可以证明极点答案为B的倍数-1
//还有最简便的办法，就是打表找规律
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define LL long long 
using namespace std;
LL a,b,n;
int main(){
    
    cin>>a>>b>>n;
    LL x=min(b-1,n);
    cout<<a*x/b-a*(x/b);
    
    return 0;
    
}

Measured memory_bytes: 3636
def main():
  import sys
  from heapq import heappush, heappop, heapify
  input = sys.stdin.readline
  
  N,D,A = map(int,input().split())
  hq = []
  for i in range(N):
    x,h = map(int,input().split())
    hq.append((x,0,h))
  heapify(hq)

  ans = 0
  b = 0
  while(len(hq) > 0):
    x,a,h = heappop(hq)
    if a == 0:
      if b < h:
        cnt = ((h-b)+A-1)//A
        ans += cnt
        b += A*cnt
        heappush(hq, (x+2*D,1,A*cnt))
    else:
      b -= h
  
  print(ans)

if __name__ == '__main__':
  main()


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

using namespace std;


struct Vector{
    double x,y;
    Vector(double x=0,double y=0):x(x),y(y){}
};
typedef Vector Point;

double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double abs(Vector a){
    return sqrt(a.x*a.x+a.y*a.y);
}

int main(){
    Point a,b;
    cin>>a.x>>a.y>>b.x>>b.y;
    int T;
    cin>>T;
    while(T--){
        Point c;
        cin>>c.x>>c.y;
        Vector p1,p2;
        p1.x=b.x-a.x;
        p1.y=b.y-a.y;
        p2.x=c.x-a.x;
        p2.y=c.y-a.y;
        //cout<<p1.x<<' '<<p1.y<<' '<<p2.x<<' '<<p2.y<<endl;
        //cout<<dot(p1,p2)<<endl;
        double s1=dot(p1,p2);
        double s2=abs(p1);
        double k=s1/(s2*s2);
        //cout<<s1<<" "<<s2<<" "<<k<<endl;
        //cout<<dx<<" "<<dy<<endl;
        Point ans;
        Vector ac=Vector(k*p1.x,k*p1.y);
        ans.x=ac.x+a.x,ans.y=ac.y+a.y;
        printf("%.10lf %.10lf\n",ans.x,ans.y);
    }
}

Measured memory_bytes: 3268
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		String s = sc.next();
		//部分文字列対象
		String t = sc.next();
		
		int slength = s.length();
		int tlength = t.length();
		
		String[] tArray = t.split("");
		int result = slength;
		for (int i = 0; i<= (slength - tlength); i++) {
			String subS = s.substring(i,tlength + i);
			String[] subSArray = subS.split("");
			int innerResult = 0;
			for (int j = 0; j<subS.length(); j++) {
				String subTChar = tArray[j];
				String subSChar = subSArray[j];
				//異なったら変換が必要
				if (!subTChar.equals(subSChar)) {
					innerResult++;
				}
			}
			if (innerResult <= result) {
				result = innerResult;
			}
		}
		System.out.println(result);
	}	

}


Measured memory_bytes: 55128
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
N = int(input())
red = []
for _ in range(N):
    a,b = map(int,input().split())
    red.append(tuple([a,b]))

blue = []
for _ in range(N):
    a,b = map(int,input().split())
    blue.append(tuple([a,b]))

red.sort(reverse=True)
blue.sort()

t = None
cnt = 0
for i in range(N):
    rx = red[i][0]
    ry = red[i][1]
    for j in range(len(blue)):
        bx = blue[j][0]
        if rx < bx:
            miny = 201
            for b in blue[j:]:
                if ry < b[1]:
                    if miny > b[1]:
                        miny = b[1]
                        t =b
            break
    # print(red[i],t)

    if t != None:
        # print(red[i],t)
        blue.remove(t)
        cnt += 1
    t = None

print(cnt)

Measured memory_bytes: 3064
r, c = gets.chomp.split.map(&:to_i)
data = Array.new(r + 1){Array.new(c + 1, 0)}
r.times{|x|
    data[x] = gets.chomp.split.map(&:to_i)
    sum = data[x].inject(:+)
    data[x] << sum
    data[x].each_with_index{|number, i| data[r][i] += number}
}
data.each{|row| puts row.join(" ")}

Measured memory_bytes: 9064
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

lst = [0]*(N+1)

for i in range(M):
    lst[A[i]] = 1

left = sum(lst[0:X])
right = sum(lst[X:N+1])
ans = min(left, right)
print(ans)


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n;cin >>n;
   vector<P>x(n);
    for (int i = 0; i < n; ++i) {
        ll a;cin >>a;
        x[i]={a,i};
    }
   sort(all(x));
   ll big=x[n/2].first;
   ll small=x[n/2-1].first;
   vector<P>ans(n);
    for (int i = 0; i < n; ++i) {
        if(i<n/2){
            ans[i]={x[i].second,big};
        }
        else ans[i]={x[i].second,small};
    }
    sort(all(ans));
    for (int i = 0; i < n; ++i) {
        cout <<ans[i].second<<endl;
    }
   return 0;
}

Measured memory_bytes: 8448
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int main() {
  int i, j = 0, k;
  long N;
  unsigned long ans = 0;
  scanf("%d", &N);
  /*for (i = 0; i < N; i++) {
    scanf("%d", H + i);
  }*/
  ans = N * (N - 1) / 2;
  printf("%lu", ans);
  return 0;
  }

Measured memory_bytes: 128
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

 
int main(int argc, char* argv[])
{
    long n, kk;
    scanf("%ld %ld", &n, &kk);

    vector<pair<long, long> > a(n);

    long i;
    for(i=0; i<n; i++) {
        scanf("%ld %ld", &(a[i].second), &(a[i].first));
    }
    sort( a.rbegin(), a.rend() );

    ll sum=0;
    set<long> setUsedT;
    vector<long> DforUsedT;
    DforUsedT.reserve(n);
    ll nUsedT=0;
    for(i=0; i<kk; i++) {
        sum += a[i].first;
        if(setUsedT.insert(a[i].second).second) {
            nUsedT++;
        }
        else {
            DforUsedT.push_back(a[i].first);
        }
    }
    ll ans = sum + nUsedT * nUsedT;

    long id_rmv = (long)DforUsedT.size() -1;
    
    for(i=kk; i<n; i++) {
        if(setUsedT.insert(a[i].second).second) {
            nUsedT++;
            if(id_rmv>=0) {
                sum = sum + (a[i].first) - DforUsedT[id_rmv];
                ans = MAX(ans, sum + nUsedT * nUsedT );
                id_rmv--;
            }
            else {
                break;
            }
        }
    }

    printf("%lld\n", ans);
 
    return 0;
}


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

using namespace std;

void printHairetu(int A[], int size){
    cout << A[0];
    if(size > 0)for(int i = 1; i < size; i++){cout << " " <<  A[i];}
    cout << endl;
}
int main(void){
    int A;cin >> A;
    int N[A];
    for(int i = 0; i < A; i++) cin >> N[i];
    printHairetu(N, A);
    for(int i = 1; i < A; i++){
        int temp = N[i];
        for(int j = 0; j < i; j++){
            if(temp < N[j]){
                temp = N[j];
                N[j] = N[i];
                N[i] = temp;
            }
        }
        printHairetu(N, A);
    }
}


Measured memory_bytes: 3088
import sys
input = sys.stdin.readline
from bisect import *

def judge(x):
    a = N-x
    b = x-bisect_left(A, X-(A[x]-X))+1
    
    return a<=b

def binary_search():
    l, r = bisect_left(A, X), N-1
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            r = m-1
        else:
            l = m+1
    
    return l

N, Q = map(int, input().split())
A = list(map(int, input().split()))
acc = [0]*(N+1)
eacc = [0]*(N+1)

for i in range(N):
    acc[i+1] = acc[i]+A[i]
    eacc[i+1] = eacc[i]+(A[i] if i%2==0 else 0)

for _ in range(Q):
    X = int(input())
    border = binary_search()
    ans = acc[N]-acc[border]
    
    if N-2*(N-border)>=0:
        if (N-2*(N-border))%2==0:
            ans += acc[N-2*(N-border)]-eacc[N-2*(N-border)]
        else:
            ans += eacc[N-2*(N-border)]
    
    print(ans)
    

Measured memory_bytes: 83948
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m,cnt=0;
  cin >> n >> m;
  vector<int>s(m),c(m);
  vector<int>ans(n,0);
  for(int i=0; i<m; i++){
    cin >> s.at(i) >> c.at(i);
    ans.at(s.at(i)-1)=c.at(i);
  }
  for(int i=0; i<m-1; i++){
    for(int j=i+1; j<m; j++){
      if(s.at(i)==s.at(j) && c.at(i)!=c.at(j)){
        cnt++;
      }
    }
  }
  if(n!=1){
    for(int i=0; i<m; i++){
      if(s.at(i)==1 && c.at(i)==0){
        cnt++;
      }
    }
  }

  if(cnt!=0){
    cout << -1 << endl;
  }
  else{
    int x=0;
    if(n==1){
      cout << ans.at(0) << endl;
    }
    else{
      if(ans.at(0)==0){
        ans.at(0)=1;
      }
      for(int i=0; i<n; i++){
        cout << ans.at(i);
        x++;
      }
      if(x==n){
        cout << endl;
      }
    }
  }
}

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

int x, y;
int tmp;

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

    while (1) {
        cin >> x >> y;
        if (x == 0 && y == 0) {
            break ;
        }
        if (x > y) {
            tmp = x;
            x = y;
            y = tmp;
        }
        cout << x << ' ' << y << '\n';
    }
    return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<cstdlib>
#include<stack>
#include<queue>
using namespace std;

int max(int x, int y);
int min(int x, int y);
int gcd(int x, int y);	/*最大公約数*/
int lcm(int x, int y);	/*最小公倍数*/

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/



/*ここからmain関数*/

int main()
{
	char s[10];
	cin >> s;

	char a[4] = { 'A','C','G','T' };

	int ans = 0;

	for (int i=0; i < 10; i++)
	{
		int judge = 0;
		if (s[i] == a[0] || s[i] == a[1] || s[i] == a[2] || s[i] == a[3])
			judge = 1;

		if (judge==1)
		{
			int j = 0;
			while (judge == 1)
			{
				if (s[i + j] == a[0] || s[i + j] == a[1] || s[i + j] == a[2] || s[i + j] == a[3])
					j++;
				else
				{
					judge = 0;
					if (ans < j)
						ans = j;
				}
			}
		}
	}

	cout << ans;

	return 0;
}

/*2数の大きい方を返す*/
int max(int x, int y)
{
	int max;

	if (x < y)
		max = y;
	else
		max = x;

	return max;
}

/*2数の小さい方を返す*/
int min(int x, int y)
{
	int min;

	if (x < y)
		min = x;
	else
		min = y;

	return min;
}

/*2数の最大公約数を返す*/
int gcd(int x, int y)
{
	int m;
	int gcd = 1;

	m = min(x, y);

	for (int i = 1;i <= m; i++)
	{
		if (x%i == 0 && y%i == 0)
			gcd = i;
	}

	return gcd;
}

/*2数の最小公倍数を返す*/
int lcm(int x, int y)
{
	int m;

	for (int i = 1;i <= y;i++)
	{
		if ((x*i) % y == 0) {
			m = x * i;
			break;
		}
	}

	return m;
}

Measured memory_bytes: 256
#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>());

#include <atcoder/all>

using namespace atcoder;

signed main() {
  ll n,m;
  cin >> n >> m;
  
  dsu d(n);
  int a,b;
  for(int i=0;i<m;i++){
    cin >> a >> b;a--;b--;
    d.merge(a,b);
  }
  
  cout << d.groups().size()-1 << endl;
  
  return 0;
}





Measured memory_bytes: 9016
#include<cstdio>
#include<set>
#include<map>
#include<algorithm>
#define mp(x,y) make_pair(x,y)
#define pi pair<int,int>
using namespace std;
inline int read(){int x=0,f=1,ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}
inline void write(int x){if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10); putchar(x%10+'0');}
inline void writeln(int x){write(x); puts("");}
const int N=1e5+5;
set<int >se[N];
map<pi,int> ma;
pi q[N];
int n,h,t,fa[N];
inline int getfa(int x){
    return (fa[x]==x)?x:fa[x]=getfa(fa[x]);
}
inline void init(){
    n=read();
    for (int i=1;i<=n*2-2;i++){
        int u=read(),v=read();
        se[u].insert(v); se[v].insert(u);
        ma[mp(u,v)]++; ma[mp(v,u)]++;
        if (ma[mp(u,v)]==2) q[++t]=make_pair(u,v);
    }
}
inline void solve(){
    for (int i=1;i<=n;i++) fa[i]=i;
    set<int >::iterator it;
    while (h<t){
        int u=q[++h].first,v=q[h].second;
        u=getfa(u); v=getfa(v);
        se[u].erase(v); se[v].erase(u);
        if (se[u].size()<se[v].size()) swap(u,v);
        for (it=se[v].begin();it!=se[v].end();++it){
            int to=(*it);
            ma[mp(to,v)]=ma[mp(v,to)]=0;
            se[to].erase(v); se[to].insert(u);
            ma[mp(to,u)]++; ma[mp(u,to)]++;
            if (ma[mp(to,u)]==2) q[++t]=make_pair(to,u);
            se[u].insert(to);
        }
        fa[v]=u;
        se[v].clear();
    }
    int s=0;
    for (int i=1;i<=n;i++) s+=fa[i]==i;
    if (s==1) puts("YES"); else puts("NO");
}
int main(){
    init(); solve();
    return 0;
}

Measured memory_bytes: 56448
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdint>
using namespace std;

int main(){
    int n, i;

    cin >> n >> i;
    cout << (n + 1) - i  << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) REV(SORT(V)) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) for(int i = 0; i < (V).size(); i++) {cout << (V).at(i) << endl;}

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN3(a,b,c);
  if(a-b <= c){
    OUT(c-a+b);
  } else {
    OUT(0);
  }
}

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

int main(){
    while(true){
        int a,b;
        cin>>a>>b;
        if(a==0 & b==0)break;
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                cout<<'#';
            }
        cout<<endl;
        }
    cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3108
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
a3 = list(map(int, input().split()))
a = [a1, a2, a3]
bingo = [[0] * 3 for _ in range(3)]

n = int(input())
for i in range(n):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if a[i][j] == num:
                bingo[i][j] = 1

is_bingo = 0
for i in range(3):
    if bingo[i][0] and bingo[i][1] and bingo[i][2]:
        is_bingo = 1
    elif bingo[0][i] and bingo[1][i] and bingo[2][i]:
        is_bingo = 1
if bingo[0][0] and bingo[1][1] and bingo[2][2]:
    is_bingo = 1
if bingo[2][0] and bingo[1][1] and bingo[0][2]:
    is_bingo = 1

print('Yes' if is_bingo else 'No')


Measured memory_bytes: 38384
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            ans += 1 if 500*i+100*j+50*k==x else 0
print(ans)

Measured memory_bytes: 39664
<?php
$s       = str_split(trim(fgets(STDIN)));
$start_i = 200001;
$end_i   = 0;
for ($i = 0; $i < count($s); $i++) {
    if ($s[$i] === 'A' && $i < $start_i) {
        $start_i = $i;
    }
    if ($s[$i] === 'Z' && $i > $end_i) {
        $end_i = $i;
    }
}

print $end_i - $start_i + 1;

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

typedef long long ll;
typedef pair< int, int > PII;
typedef pair< ll, ll > PLL;

#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define PI 3.14159265358979323846
#define INF 1000000006
#define LINF 1000000000000000006
#define DINF 1e300
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair

const int N = 1e5 + 10;

ll n, t, a[ N ], mi[ N ], which[ N ], sub[ N ];

void init() {
  cin >> n >> t;
  for ( int i = 1 ; i <= n ; ++i )
    cin >> a[ i ];
}
void solve() {
  mi[ 1 ] = a[ 1 ];
  which[ 1 ] = 1;
  for ( int i = 2 ; i <= n ; ++i ) {
    if ( a[ i ] < mi[ i - 1 ] ) {
      mi[ i ] = a[ i ];
      which[ i ] = i;
    }
    else {
      mi[ i ] = mi[ i - 1 ];
      which[ i ] = which[ i - 1 ];
    }   
  }
  for ( int  i = 1 ; i <= n ; ++i ) {
    sub[ i ] = a[ i ] - mi[ i ];
  }
  ll tar = 0;
  for ( int i = 1 ; i <= n ; ++i )
    if ( sub[ i ] > tar ) {
      tar = sub[ i ];
    }
  vector< int > cand;
  for ( int i = 1 ; i <= n ; ++i ) 
    if ( sub[ i ] == tar )  
      cand.PB( i );
  set< int > s1, s2;
  for ( int i = 0 ; i < cand.size() ; ++i ) {
    int now = cand[ i ];
    s1.insert( which[ now ] );
    s2.insert( now );
  }
  cout << min( s1.size(), s2.size() ) << endl;
}
int main() {
  IOS;
  int __ = 1;
  //cin >> __;
  while ( __-- ) {
    init();
    solve();
  }
  return 0;
}


Measured memory_bytes: 8316
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

class UnionFind(object):
    def __init__(self, n = 1):
        self.link = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.link[x] == x:
            return x

        # re-connect union find to make the height of tree lower
        # you can use while, but recursion makes it easier to reconnect
        self.link[x] = self.find(self.link[x])
        return self.link[x]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.size[x] < self.size[y]:
            x, y = y, x
        self.link[y] = x
        self.size[x] += self.size[y]
    
    def get_size(self, x):
        x = self.find(x)
        return self.size[x]


N = int(input())

townsX = [0] * N
townsY = [0] * N
for i in range(N):
    x, y = map(int, input().split())
    townsX[i] = (x - 1, y - 1, i)
    townsY[i] = (y - 1, x - 1, i)
townsX = sorted(townsX)
townsY = sorted(townsY)

edges = []
for i in range(1, N):
    a = townsX[i]
    b = townsX[i - 1]
    c = townsY[i]
    d = townsY[i - 1]
    e1 = (abs(a[0] - b[0]), a[2], b[2])
    e2 = (abs(c[0] - d[0]), c[2], d[2])
    edges.append(e1)
    edges.append(e2)
edges = sorted(edges)

u = UnionFind(N)


ans = 0
for e in edges:
    w, s, t = e
    if u.is_same(s, t):
        continue
    u.unite(s, t)
    ans += w
print(ans)

Measured memory_bytes: 141772
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n;
 int  a[3][n];
  for(int i=0;i<n;i++) cin>>a[0][i]>>a[1][i]>>a[2][i];
  int dp[3][n+1];
  dp[0][0]=0;
  dp[1][0]=0;
  dp[2][0]=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<3;j++)
    {
      dp[j][i]=max(dp[(j+1)%3][i-1]+a[j][i-1],dp[(j+2)%3][i-1]+a[j][i-1]);
    }
  }
  cout<<max(max(dp[0][n],dp[1][n]),dp[2][n])<<endl;
}


Measured memory_bytes: 2560
import math

n = int(input())
koch = [(0.0, 0.0), (100.0, 0.0)]
SIN60 = math.sin(math.radians(60))

for i in range(n):
    nextKoch = []
    for j in range(len(koch) - 1):
        p1 = koch[j]
        p2 = koch[j+1]
        # s, t は p1, p2 を 3 等分する点
        s = ((p1[0] * 2 + p2[0]) / 3, (p1[1] * 2 + p2[1]) / 3)
        t = ((p1[0] + p2[0] * 2) / 3, (p1[1] + p2[1] * 2) / 3)
        # u は s を中心として  t を 60ª 回転させた点
        ux = (t[0]-s[0])/2 - (t[1]-s[1])*SIN60 + s[0]
        uy = (t[0]-s[0])*SIN60 + (t[1]-s[1])/2 + s[1]
        u = (ux, uy)
        nextKoch[len(nextKoch):len(nextKoch)] = [p1, s, u, t]
    nextKoch.append(koch[-1])
    koch = nextKoch

for i in range(len(koch)):
    print('{0:.8f} {1:.8f}'.format(koch[i][0], koch[i][1]))



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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

vector<int> g[10101];
int ans[10101];
int edge[10101];
int deg[10101];
int c[10101];

int dp[10101];

int cur;
ll score;

int solve1(int v, int p) {
    if (dp[v] != -1) return dp[v];
    int& ret = dp[v];
    ret = 0;
    for (int u : g[v]) {
        if (u == p) continue;
        ret += solve1(u, v) + 1;
    }
    return ret;
}

void solve2(int v, int p) {
    for (int u : g[v]) {
        if (u == p) continue;
        if (ans[u] == 0) {
            ans[u] = c[cur];
            score += c[cur++];
        }
        solve2(u, v);
    }
}

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

    rep(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);

        deg[a]++;
        deg[b]++;
    }
    rep(i, N) cin >> c[i];

    // 根
    int root = 0, ma = 0;
    rep(i, N) {
        if (ma < deg[i]) {
            ma = deg[i];
            root = i;
        }
    }
    fill(dp, dp+N, -1);
    solve1(root, -1);

    rep(i, N) {
        if (g[i].size()>0) {
            sort(g[i].rbegin(), g[i].rend(), [](const int & a, const int &b) {
                return dp[a] < dp[b];
            });
        }
    }

    sort(c, c+N);
    reverse(c, c+N);
    ans[root] = c[cur++];
    solve2(root, -1);

    cout << score << endl;
    rep(i, N) {
        if (i) cout << " ";
        cout << ans[i];
    }
    cout << endl;


}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    vector<double> x(n),y(n);
    rp(i,n) cin >> x.at(i) >> y.at(i);
    if(n==2){
        print(sqrt((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0]))/2.0);
        return;
    }
    double ans=0.0;
    rp(i,n-2){
        repi(j,i+1,n-1){
            double a=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
            repi(k,j+1,n){
                double b=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k])),
                        c=sqrt((x[k]-x[j])*(x[k]-x[j])+(y[k]-y[j])*(y[k]-y[j]));
                if(a*a+b*b<=c*c||a*a+c*c<=b*b||b*b+c*c<=a*a){
                    double cand=max(a,max(b,c));
                    chmax(ans,cand/2.0);
                    continue;
                }
                double s=(a+b+c)/2.0;
                double S=sqrt(s*(s-a)*(s-b)*(s-c));
                double r;
                if(abs(S)>1e-10)
                     r=a*b*c/4.0/S;
                else  r=1.0e8;
                chmax(ans,r);
            }
        }
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
A = list(map(int,input().split()))

A.sort(reverse=True)

# 各数字に必要なマッチの本数
num  = [0,2,5,5,4,5,6,3,7,6]
# dp : i本のマッチで実現できる最大の桁数
dp = [-1*float("inf")]*(N+1)
# dp初期化 (0本では0桁, 各数字を1つ作る場合は1桁)
dp[0] = 0
for a in A:
    if num[a] <= N:
        dp[num[a]] = 1

for i in range(1,N+1):
    for a in A:
        if i - num[a] >= 0:
            dp[i] = max(dp[i], dp[i-num[a]] + 1)

ans = ""
for i in range(dp[N]):
    for a in A:
        if N-num[a] >= 0 and dp[N-num[a]] == dp[N]-1:
            ans += str(a)
            N -= num[a]
            break

print(ans)

Measured memory_bytes: 3420
'use strict'
function main(input: string) {
    const std = input.split('\n');
    const n: number = Number(std[0]);
    const s: string[] = std.slice(1).map(v => v.split('').sort().join(''));
    let r = 0;
    let tmp = new Map();
    s.forEach(v => {
        if (tmp.has(v)) {
            r += tmp.get(v);
            tmp.set(v, tmp.get(v)+1);
        } else {
            tmp.set(v, 1);
        }
    })
    console.log(r);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 55684
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  string s;

  cin >> s;

  cout << s[0] << s.size() - 2 << s[s.size() - 1] << endl;
  ret 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
a = 'qwertyuiopasdfghjklzxcvbnm'

ans = 0
for i in range(n):
    cnt = 0
    for ai in a:
        if ai in s[:i] and ai in s[i:]:
            cnt += 1
    ans = max(ans, cnt)

print(ans)

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

long long N, A, B, T[1 << 17];

int main() {
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) cin >> T[i];

	if (A > B) {
		bool ok1 = true; long long mask = 0;
		for (int i = 0; i < N; i++) { if (T[i] > B) ok1 = false; mask ^= T[i]; }

		if (ok1 == false) cout << "Hanako" << endl;
		else if (mask == 0) cout << "Jiro" << endl;
		else cout << "Hanako" << endl;
	}
	else if (A == B) {
		long long mask = 0;
		for (int i = 0; i < N; i++) mask ^= (T[i] % (A + 1));
		
		if (mask == 0) cout << "Jiro" << endl;
		else cout << "Hanako" << endl;
	}
	else if (A < B) {
		bool ok1 = true; long long mask = 0;
		for (int i = 0; i < N; i++) { if (T[i] > A) ok1 = false; mask ^= T[i]; }

		if (ok1 == true) {
			if (mask != 0) cout << "Hanako" << endl;
			else cout << "Jiro" << endl;
		}
		else {
			long long mask2 = 0, t = -1, cnt = 0;
			for (int i = 0; i < N; i++) {
				if (T[i] > A) { cnt++; t = T[i]; }
				else mask2 ^= T[i];
			}
			if (cnt == 1 && (t - mask2) >= 1 && (t - mask2) <= A && mask2 <= A) cout << "Hanako" << endl;
			else cout << "Jiro" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3888
#include<cstdio>
#include<set>
#define M(x,y)std::make_pair(x,y)
typedef std::set<std::pair<int,int> >S;
int n,m,x,y,X,Y,d,D;main(){for(;scanf("%d",&n),n;printf("%d\n",n)){
S s;S::iterator i,I;
for(;n;n--)scanf("%d%d",&x,&y),s.insert(M(x,y));
for(i=s.begin();i!=s.end();i++)for(x=i->first,y=i->second,I=i;++I!=s.end();)if(X=I->first,Y=I->second,d=X-x,D=Y-y,m=d*d+D*D,m>n&&s.find(M(x-D,y+d))!=s.end()&&s.find(M(X-D,Y+d))!=s.end())n=m;
}}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long

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

	vector<int> p, q, r;
	int x, y;
	cin >> x >> y;
	int a, b, c;
	cin >> a >> b >> c;
	p.resize(a);
	q.resize(b);
	r.resize(c);
	for (auto &t : p) {
		cin >> t;
	}
	for (auto &t : q) {
		cin >> t;
	} 
	for (auto &t : r) {
		cin >> t;
	}
	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	sort(r.rbegin(), r.rend());
	vector<int> hv;
	for (int i = 0; i < y; i++) {
		hv.push_back(q[i]);
	}
	for (auto t : r) {
		hv.push_back(t);
	}
	sort(hv.rbegin(), hv.rend());
	vector<int> sm(hv.size() + 1);
	for (int i = 0; i < (int)hv.size(); i++) {
		sm[i + 1] = sm[i] + hv[i];
	}
	int cans = 0;
	int ans = 0;
	for (int i = 0; i <= x; i++) {
		ans = max(ans, cans + sm[min((int)sm.size(), x + y - i)]);
		if (i < x) cans += p[i];
	}
	cout << ans << endl;

}


Measured memory_bytes: 5744
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[110];
int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	long long ret=pw(2,n);
	init_C(210000);
	long long tmp=finv[a];
	for(int i=0;i<a;i++){
		tmp=tmp*(n-i)%mod;
	}
	ret=(ret+mod-tmp)%mod;
	tmp=finv[b];
	for(int i=0;i<b;i++){
		tmp=tmp*(n-i)%mod;
	}
	ret=(ret+mod-tmp)%mod;
	ret=(ret+mod-1)%mod;
	printf("%lld\n",ret);
}

Measured memory_bytes: 9984