Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03440 (python)

Fixed submission:
from heapq import heappush, heappop
from collections import defaultdict
n,m = map(int,input().split())
a = list(map(int,input().split()))
# edg = [[] for i in range(n)]
rank = [1] * n
par = [i for i in range(n)]
def root(x):
  if x == par[x]:
    return x
  par[x] = root(par[x])
  return par[x]
def union(a,b):
  a = root(a)
  b = root(b)
  if rank[a] < rank[b]:a,b = b,a
  if a == b: return False
  par[b] = a
  rank[a] += rank[b]
  return True
for _ in range(m):
  x,y = map(int, input().split())
  union(x,y)
d = defaultdict(list)
q = []
for i in range(n):
  ai = a[i]
  heappush(q,(ai,i))
  ri = root(i)
  heappush(d[ri],(ai,i))
if len(d.keys()) == 1:
  print(0)
else:
  ans = 0
  tmp = 0
  c = [0] * n

  for i in d.keys():
    tmp += 1
    t,p = heappop(d[i])
    c[p] = 1
    ans += t
  if 2*tmp-2 > n:
    print("Impossible")
  else:
    for _ in range(tmp-2):
      p,i = heappop(q)
      while c[i]:
        p,i = heappop(q)
      ans += p
    print(ans)

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop
from collections import defaultdict
n,m = map(int,input().split())
a = list(map(int,input().split()))
# edg = [[] for i in range(n)]
rank = [1] * n
par = [i for i in range(n)]
def root(x):
  if x == par[x]:
    return x
  par[x] = root(par[x])
  return par[x]
def union(a,b):
  a = root(a)
  b = root(b)
  if rank[a] < rank[b]:a,b = b,a
  if a == b: return False
  par[b] = a
  rank[a] += rank[b]
  return True
for _ in range(m):
  x,y = map(int, input().split())
  union(x,y)
d = defaultdict(list)
for i in range(n):
  ai = a[i]
  i = root(i)
  heappush(d[i],ai)

ans = 0
forest = []
for i in set(par):
  p = heappop(d[i])
  heappush(forest,(p,i))

for i in range(len(set(par))-1):  
  if len(forest) < 2:
    ans = "Impossible"
    break
  p1,i1 = heappop(forest)
  p2,i2 = heappop(forest)
  ans += p1 + p2
  union(i1,i2)
  if i1 == root(i1):
    for di2 in d[i2]:
      heappush(d[i1],di2)
  else:
    for di1 in d[i1]:
      heappush(d[i2],di1)
  i1 = root(i1)
  heappush(forest,(heappop(d[i1]),i1))

print(ans)

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop
from collections import defauldict
n,m = map(int,input().split())
a = list(map(int,input().split()))
# edg = [[] for i in range(n)]
rank = [1] * n
par = [i for i in range(n)]
def root(x):
  if x == par[x]:
    return x
  par[x] = root(par[x])
  return par[x]
def union(a,b):
  a = root(a)
  b = root(b)
  if rank[a] < rank[b]:a,b = b,a
  if a == b: return False
  par[b] = a
  rank[a] += rank[b]
  return True
for _ in range(n):
  a,b = map(int,input().split())
  union(a,b)
d = defaultdict(list)
for i in range(n):
  ai = a[i]
  i = root(i)
  heappush(d[i],ai)

ans = 0
forest = []
for i in set(par):
  p = heappop(d[i])
  heappush(forest,(p,i))

for i in range(len(set(par))-1):
  p1,i1 = heappop(forest)
  p2,i2 = heappop(forest)
  ans += p1 + p2
  if d[i1]:
    heappush(forest,(heappop(d[i1]),i1))
  if d[i2]:
    heappush(forest,(heappop(d[i2]),i2))
  if len(forest) < 2:
    ans = "Impossible"
    break
print(ans)
Problem p03472 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    n, h = LI()
    ab = LIR(n)
    ab.sort(reverse=True)
    amax = ab[0][0]
    ab.sort(key=lambda x: x[1], reverse=True)
    ans = 0
    hp = 0
    for a,b in ab:
        if b <= amax:
            break
        ans += 1
        hp += b
        if hp >= h:
            break
    ans += max(math.ceil((h-hp)/amax),0)    
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()

Buggy submission (verdict: Runtime Error):
n,h=map(int,input().split())
ab=[[int(i) for i in input().split()] for _ in range(n)]
maxa=max(map(lambda x:x[0], ab))
ab.sort(key:lambda x:x[1],reverse=True)
ans=0
for a,b in ab:
  if b>maxa:
    h-=b
    ans+=1
  if h<=0:
    print(ans)
    exit(0)
print(ans+(h-1)//maxa+1)
Problem p03501 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b = LI()
    print(min(n*a,b))
    return

#B
def B():
    a = S()
    print(a.count("1"))
    return

#C
def C():
    n = II()
    a = list(str(n))
    if not n % sum(a):
        print("Yes")
    else:
        print("No")
    return

#D
def D():
    n = II()
    a = LI()
    ans = 0
    for a_ in a:
        while not a_ % 2:
            ans += 1
            a_ /= 2
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Buggy submission (verdict: Runtime Error):
n,c=map(int,input().split())
stc=[[int(i) for i in input().split()] for _ in range(n)]
dp=[0]*(2*10**5+2)
for s,t,c in stc:
  dp[2*s-1]+=1
  dp[2*t]-=1
for i in range(2*10**5):
  dp[i+1]+=dp[i]
print(max(dp))
Problem p03523 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10
import re
#solve
def solve():
    s = S()
    if re.fullmatch("(A?)KIH(A?)B(A?)R(A?)", s):
        print("YES")
    else:
        print("NO")
    return


#main
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10
import re
#solve
def solve():
    s = S()
    if re.fullmatch("(A?)KIH(A?)B(A?)R(A?)", s):
        print("YES")
    else:
        print("NO")
    return


#main
if __name__ == '__main__':
    solve()
Problem p03583 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    N = II()
    for h in range(1, 3501):
        for w in range(1, 3501):
            if (4 * h * w - N * w - N * h) == 0:
                continue
            n = N * h * w / (4 * h * w - N * w - N * h)
            if n.is_integer() and n > 0:
                print(h, w, int(n))
                return
    return


#main
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    N = II()
    for h in range(1, 3500):
        for w in range(1, 3500):
            n = N * h * w / (4 * h * w - N * w - N * h)
            if n.is_integer():
                print(h, w, n)
                return
    return


#main
if __name__ == '__main__':
    solve()
Problem p03584 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, k = LI()
    ab = LIR(n)
    ans = 0
    for a, b in ab:
        if k & a == a:
            ans += b
    for i in range(31):
        if k & (1 << i):
            res = 0
            K = (k | ((1 << i) - 1)) ^ (1 << i)
            for a, b in ab:
                if K & a == a:
                    res += b
            if ans < res:
                ans = res
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, k = LI()
    ab = LIR(n)
    
    def f(k):
        res = 0
        for a, b in ab:
            if k & a == a:
                ans += b
        return res
    ans = f(k)
    for i in range(31):
        if k & (1 << i):
            K = (k | ((1 << i) - 1)) ^ (1 << i)
            res = f(K)
            if ans < res:
                ans = res
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()
Problem p03593 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    h, w = LI()
    x = h & 1 and w & 1
    a = SR(h)
    d = defaultdict(int)
    for i in range(h):
        for j in range(w):
            d[a[i][j]] += 1
    one = 0
    two = 0
    for i in d.values():
        one += i & 1
        two += (i >> 1) & 1
    if x:
        if one == 1:
            if h + w - 2 >= two << 1:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        if one:
            print("No")
        else:
            x = (h & 1) * (w >> 1) + (w & 1) * (h >> 1)
            if x:
                if x >= two:
                    print("Yes")
                else:
                    print("No")
            else:
                if two:
                    print("No")
                else:
                    print("Yes")

    return


#main
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    h, w = LI()
    a = SR(h)
    d = defaultdict(int)
    for i in range(h):
        for j in range(w):
            d[s[i][j]] += 1
    four = 0
    for i in d.values():
        if i & 1:
            print("No")
            return
        four |= i & 4 and not i & 3
    if four:
        print("Yes")
    else:
        print("No")
        

    return


#main
if __name__ == '__main__':
    solve()
Problem p03605 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    s = S()
    if "9" in s:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    return

#C
def C():
    n = II()
    A = {}
    for i in range(n):
        k = II()
        if not k in A:
            A[k] = 1
        else:
            A[k] += 1
    ans = 0
    for item in A.values():
        ans += item % 2
    print(ans)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Buggy submission (verdict: Runtime Error):
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    s = S()
    if "9" in s:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    return

#C
def C():
    n = II()
    A = {}
    for i in range(n):
        k = II()
        if not k in A:
            A[k] = 1
        else:
            A[k] += 1
    ans = 0
    #print(A)
    for item in A.values():
        ans += item % 2
    print(ans)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()
Problem p03636 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n, m = LI()
    print((n-1)*(m-1))
    return

#B
def B():
    s = S()
    print(s[0]+str(len(s)-2)+s[-1])
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()

Buggy submission (verdict: Runtime Error):
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n, m = LI()
    print((n-1)*(m-1))
    return

#B
def B():
    s = S()
    print(s[0]+str(len(s)-2)+s[-1])
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()