Harryxun/stf_run huggingface dataset:
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd

n,m = map(int, input().split())
SCs = [list(map(int, input().split())) for _ in range(m)]

for i in range(10^n):
  X=str(i)
  tf=True
  if len(X)==n:
    for j in SCs:
      if X[j[0]]!=j[1]:
        tf=False
    if tf:
      print(i)
      sys.exit()
print(-1)

### FIXED CODE ###

import sys
n,m = map(int, input().split())
SCs = [list(map(int, input().split())) for _ in range(m)]
for i in range(10**n):
  X=str(i)
  tf=True
  if len(X)==n:
    for j in SCs:
      if X[j[0]-1]!=str(j[1]):
        tf=False
        break
    if tf:#全ループ終わって条件を満たしていれば
      print(i)
      sys.exit()
print(-1)
a,b = map(int,input().split())
L=[list(map(input().split())) for i in range(b)]
 print(L.sort())


### FIXED CODE ###

a,b = map(int,input().split())
L=[]
for i in range(a):
    L.append(input())
    
    K=sorted(L)
print(''.join(K))
import sys
input=sys.stdin.readline
H, W = map(int, input().split())
d = []
d2 = []
d3 = []
for h in range(H):
    s = input().strip() + "#"
    d.append(s)
    d2.append(sc(s))

for i in range(W):
    s = ""
    for j in range(H):
        s += d[j][i]
    s += "#"
    d3.append(sc(s))

### FIXED CODE ###

H, W = map(int, input().split())
import sys
input = sys.stdin.readline
def sc(s):
    b = None
    nc = 0
    kk = [0]*len(s)
    for i, c in enumerate(s):
        if c == ".":
            if c == b:
                nc += 1
            else:
                si = i
        else:
            if b == ".":
                for j in range(si, i):
                    kk[j] = i - si
            nc = 0
        b = c
    return kk
d = []
d2 = []
d3 = []
for h in range(H):
    s = input().strip()
    d.append(s)
    d2.append(sc(s+"#"))

d = list(zip(*d))
for s in d:
    d3.append(sc("".join(s)+"#"))
r = 0
for i in range(H):
    for j in range(W):
        r = max(r, d2[i][j] + d3[j][i]-1)
print(r)
while True:
	H, W = map(int, raw_input().split())
	if H == 0 and W == 0:
		break
	tile = []
	for i in range(H):
		tile.append(list(raw_input()))
	x = y = 0
	while True: 
		a = tile[y][x]
		tile[y][x] = 0
		if w == ".":
			print x, y
			break
		if w == ">":
			x += 1
		elif w == "v":
			y += 1
		elif w == "^":
			y -= 1
		elif w == "<": 
			x -= 1
		else:
			print "LOOP"
			break

### FIXED CODE ###

while True:
    h, w = map(int, raw_input().split())
    if w == 0 and h == 0:
        break
    tile = []
    for i in range(h):
        tile.append(list(raw_input()))
    x = y = 0
    while True:
        a = tile[y][x]
        tile[y][x] = 0
        if   a == ">": x += 1
        elif a == "<": x -= 1
        elif a == "^": y -= 1
        elif a == "v": y += 1
        elif a == ".": print x,y; break
        else: print "LOOP"; break
a,b,c = int(input())

if a <=c and b >= c:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b,c = map(int,input().split())

if a <=c and b >= c:
  	print("Yes")
else:
  	print("No")
N,M = [int(i) for i in input().split()]
A = []
for _ in range(M):
    A.append(int(input()))
def fibo(n):
    if n <= 2:
        return n
    return fibo(n-1) + fibo(n-2)
cnt = 1
for a in range(len(A)+1):
    if a == 0:
        if A[a] == 1:
            width = 1
        else:
            width = A[a]-2
    elif a > 0 and a < M:
        width = A[a] - A[a-1] - 2
    elif a == (M):
        width = N-A[a-1]-1
    if width < 0:
        tmp = 0
        cnt = 0
        break
    else:
        tmp = fibo(width)%1000000007
    cnt = (tmp*cnt)%1000000007
print(cnt)

### FIXED CODE ###

mod = 1000000007
N,M = [int(i) for i in input().split()]
A = []
for _ in range(M):
    A.append(int(input()))
steps = [0]*N
for a in A:
    steps[a-1] = 1
cnt = []
for n in range(N):
    if n == 0:
        if steps[n]==0:
            cnt.append(1)
        elif steps[n]==1:
            cnt.append(0)
    elif n == 1:
        if steps[n]==0:
            cnt.append(cnt[n-1]+1)
        elif steps[n]==1:
            cnt.append(0)
    elif steps[n] == 0:
        cnt.append((cnt[n-2]+cnt[n-1])%mod)
    elif steps[n] == 1:
        cnt.append(0)
print(cnt[-1])
def main():
  N=int(input())
  for i in range(1:10)
    for j in range(1:10):
      if N=i*j:
        print("Yes")
      else:
        print("No")
main()

### FIXED CODE ###

N=int(input())
list=[]
for i in range(1,10):
  for j in range(1,10):
    list.append(i*j)
if N in list:
   print("Yes")
else:
   print("No")
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
import copy
K=int(input())
A=list(map(int,input().split()))
if A[-1]!=2:
    print(-1)
    exit()

maX=2
miN=2
Amax=2

for i in range(K-1,-1,-1):

    if A[i]//maX>=2 or i<K-1 and A[i]>(maX//A[i+1])*A[i+1]+maX%A[i+1]:
        print(-1)
        exit()
    if A[i]//miN>=2:
        miN=A[i]
    if miN%A[i]==0:
        pass
    else:
        miN=(miN//A[i] +1) *A[i]

    if maX%A[i]==0:
        maX=min((maX//A[i]) *A[i] + A[i]-1 ,(maX//A[i+1])*A[i+1]+maX%A[i+1])
    else:
        maX=min((maX//A[i]) *A[i] + A[i]-1 ,(maX//A[i+1])*A[i+1]+maX%A[i+1])
    Amax=max(A[i],Amax)

print(miN,maX)


### FIXED CODE ###

# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
import copy
K=int(input())
A=list(map(int,input().split()))
if A[-1]!=2:
    print(-1)
    exit()

maX=2
miN=2

for i in range(K-1,-1,-1):

    if A[i]//maX>=2:
        print(-1)
        exit()
    if A[i]//miN>=2:
        miN=A[i]
    else:
        if miN%A[i]==0:
            pass
        else:
            miN=(miN//A[i] +1) *A[i]
    maX=maX-maX%A[i] + A[i]-1

mmaX=maX
for i in range(K):
    mmaX-=mmaX%A[i]
if mmaX==2:
    print(miN,maX)
else:
    print(-1)
N,T = map(int,input().split())
paths = list()
for i in range(N):
  ci,ti = map(int,input().split())
  paths.append((ci,ti))
paths.sort(key=lambda x: x[0])

for path in paths:
  if path[1] <= T:
    print(path[0])
    exit(1)
print('TLE')


### FIXED CODE ###

N,T = map(int,input().split())
paths = list()
for i in range(N):
  ci,ti = map(int,input().split())
  paths.append((ci,ti))
paths.sort(key=lambda x: x[0])

flag=False
for path in paths:
  if path[1] <= T:
    print(path[0])
    flag=True
    break
if not flag:
  print('TLE')
import math

a = list(map(int, input()split()))

print(math.ceil(a[0] / a[1]) * a[2])

### FIXED CODE ###

import math

a = list(map(int, input().split()))

print(math.ceil(a[0] / a[1]) * a[2])
s=input()
array=[]
array+=(int(x) for x in input().split())

def judge(array,s):
  for i in range(int(s)-1):
    if array[i] == array[i+1]:
        return True
  else:
    return False

print(judge(array,s))

### FIXED CODE ###

a,b=input().split()
a_num,b_num=input().split()
c=input()
 
if c==a:
  a_num=int(a_num)-1
elif c==b:
  b_num=int(b_num)-1
print(a_num,b_num)
N = map(int,input())
M = int(N**0.5//1)
S = list()
for i in range(M+1):
    if i > 0 :
       if N%i == 0:
           S.append(i)
a =  S[-1]
b = N//a
print(len(str(a))+len(str(b)))

### FIXED CODE ###

import math

N = int(input())
M = int(N**0.5//1)
S = list()
for i in range(M+1):
    if i > 0 :
       if N%i == 0:
           S.append(i)
a =  S[-1]
b = N//a
print(max(len(str(a)),len(str(b))))
from functools import reduce
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
T.sort()
ans = 1
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
    
def lcm(m,n):
    return int(m * n/gcd(m,n))

print(reduce(lcm,T))

### FIXED CODE ###

from functools import reduce
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def gcd(m,n):
    if n == 0:
        return m
    return gcd(n,m%n)
    
def lcm(m,n):
    return m * n//gcd(m,n)

print(reduce(lcm,T))
def dfs(formula, index):
    if index + 1 == max_index:
        return sum(list(map(int, formula.split("+"))))

    return dfs(formula + "+" + S[index], index + 1) + dfs(formula + S[index], index)


S = input()
max_index = len(S)
dfs(S[0], 0)

### FIXED CODE ###

def dfs(i, formula):
    if i + 1 == num_digits:
        return sum(list(map(int, formula.split("+"))))

    return dfs(i + 1, formula + "+" + s[i + 1]) + dfs(i + 1, formula + s[i + 1])


s = input()
num_digits = len(s)

print(dfs(0, s[0]))
from bisect import bisect_left

n = input()
ls = list(map(int, input().split()))
count = 0
for i in range(0, n - 2):
  for j in range(i + 1, n - 1):
    two_sides_sum = ls[i]+ ls[j]
    bi = bisect_left(ls, two_sides_sum)
    count += bi - j - 1
print(count)

### FIXED CODE ###

import bisect
n = int(input())

li = list(map(int, input().split()))
li.sort()

count = 0

for i in range(n - 2):
  for j in range(i + 1, n - 1):
    bi = bisect.bisect_left(li, li[i] + li[j])
    count += bi - j - 1
print(count)
import math
a, b = map(int, input().split())
c = b - 1

d = a / c

print(math.ceil(d)


### FIXED CODE ###

import math
a, b = map(int, input().split())
d = (a-1) / (b-1)
print(math.ceil(d))
dataNum=input()
wordList=[]
for word in input:
    wordList.append(word.strip())

if len(wordList) != len(set(wordList)):
    print("No")
    exit()

char = wordList[0][-1:]
for n in range(1, len(wordList)):
    if(char != wordList[n][:1]):
        print("No")
        exit()
    char = wordList[n][-1:]

print("Yes")

### FIXED CODE ###

dataNum=int(input())
wordList=[]
for n in range(dataNum):
    wordList.append(input().strip())

if len(wordList) != len(set(wordList)):
    print("No")
    exit()

char = wordList[0][-1:]
for n in range(1, len(wordList)):
    if(char != wordList[n][:1]):
        print("No")
        exit()
    char = wordList[n][-1:]

print("Yes")
n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

cnt = 0
for i in range(n):
    for j in range(q):
        if S[i] == T[j]:
            cnt = cnt + 1
            
print cnt   
~            

### FIXED CODE ###

n = input()

S = map(int, raw_input().split())

q = input()

T = map(int, raw_input().split())

S.append(0)
cnt = 0
for i in range(q):
    j = 0
    S[n] = T[i]
    while S[j] != S[n]:
        j = j + 1
    if j != n:
        cnt = cnt + 1


print cnt
import decimal
import math

N, K = map(int, input().split())
#coin = [decimal.Decimal('0.5')**k for k in range(10**4)]
ans = 0

for i in range(1,N+1):
    tmp = math.log2(K/i)
    x = int(math.log2(K/i))
    if i >= K:
        ans += 1/N
    else:
        if tmp - x != 0:
            x += 1
        ans += 1/N * (0.5)**x

print(ans)


### FIXED CODE ###

import math
N,K = map(int,input().split())
ans = 0
 
for i in range(1,N+1):
    if i >= K:
        ans += (1/N)
        continue
    X = int(math.log((K/i), 2))
    if (K/i) % 2**X == 0:
        pass
    else:
        X += 1
    ans += (1/N) * (1/2) ** X
print(ans)
n,m=map(int,input().split())
l=list(map(int,input().split()))
l1=[]
for i in range(n-m+1):
  if l[i]>=0:
    l1.append(l[i+m]-l[i])
  elif l[i]<=0<=l[i+m]:
    l1.append(l[i+m]-l[i]+min(l[i],l[i+m]))
  else:
    l1.append(l[i+m]-l[i])
print(min(l1))    

### FIXED CODE ###

n,m=map(int,input().split())
l=list(map(int,input().split()))
l1=[]
for i in range(n-m+1):
  if l[i]>=0:
    l1.append(l[i+m-1])
  elif l[i]<=0<=l[i+m-1]:
    l1.append(l[i+m-1]-l[i]+min(abs(l[i]),abs(l[i+m-1])))
  else:
    l1.append(abs(l[i]))
print(min(l1))
a,b,k=map(int,input().split())

ans=0
cnt=0

for i in range(1,max(a,b)+1)
	if a%i==0 and b%i==0:
		ans+=i
		cnt+=1
	if cnt==k:
		print(ans)

### FIXED CODE ###

a,b,k=map(int,input().split())
 
ans=[]
 
for i in range(1,min(a,b)+1):
	if a%i==0 and b%i==0:
		ans.append(i)
print(ans[-k])
N,M, K = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
CD = [list(map(int,input().split())) for i in range(K)]


#xの木の根を求める
def root(x,li): 
    if li[x] == x:
        return x
    else:
        li[x] = root(li[x],li)
        return li[x]

#xとyが同じ集合に属するかの判定
def find(x,y,li):
    return root(x,li) == root(y,li)

#xとｙを併合
def union(x,y,li):
    x = root(x,li)
    y = root(y,li)
    if x==y:
        return
    else:
        li[x] = y

li1 = [i for i in range(N)]
li2 = [i for i in range(N)]

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    union(a-1,b-1,li1)
# for i in range(K):
#     c = CD[i][0]
#     d = CD[i][1]
#     union(c-1,d-1,li2)

mm = [0 for i in range(max(li1))]
for i in range(N):
    m = root(i,li1)
    mm[m-1] += 1


ans = [mm[li1[i]-1]-1 for _ in range(N)]
# print(ans)

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    ans[a-1] -= 1
    ans[b-1] -= 1


for i in range(K):
    c = CD[i][0]
    d = CD[i][1]
    if find(c-1,d-1,li1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(ans)





### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

N,M, K = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
CD = [list(map(int,input().split())) for i in range(K)]


#xの木の根を求める
def root(x,li): 
    if li[x] == x:
        return x
    else:
        li[x] = root(li[x],li)
        return li[x]

#xとyが同じ集合に属するかの判定
def find(x,y,li):
    return root(x,li) == root(y,li)

#xとｙを併合
def union(x,y,li):
    x = root(x,li)
    y = root(y,li)
    if x==y:
        return
    else:
        li[x]=y

li1 = [i for i in range(N)]
li2 = [i for i in range(N)]

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    # print(str(i)+" ",end="")
    union(min(a-1,b-1),max(a-1,b-1),li1)
# for i in range(K):
#     c = CD[i][0]
#     d = CD[i][1]
#     union(c-1,d-1,li2)

mm = [0 for i in range(max(li1)+1)]
for i in range(N):
    m = root(i,li1)
    mm[m] += 1

# print(li1)
# print(mm)
ans = [mm[li1[i]]-1 for i in range(N)]
# print(ans)

for i in range(M):
    a = AB[i][0]
    b = AB[i][1]
    ans[a-1] -= 1
    ans[b-1] -= 1


for i in range(K):
    c = CD[i][0]
    d = CD[i][1]
    if find(c-1,d-1,li1):
        ans[c-1] -= 1
        ans[d-1] -= 1
print(*ans)
x, n = list(map(int, input().split()))

if n == 0:
  print(x)
  exit(0)
else:
  arr = list(map(int, input().split()))

arr.sort()
print(arr)
i = arr.index(x)

if not i and i != 0:
  print(x)
  exit(0)

j = 1
for _ in range(n):
  row = i - j
  high = i + j
  if row >= 0 and arr[row] != x - j:
    print(x - j)
    exit(0)
  elif high <= n-1 and arr[high] != x + j:
    print(x + j)
    exit(0)
  j += 1

print(x-1)



### FIXED CODE ###

x, n = list(map(int, input().split()))

if n == 0:
  print(x)
  exit(0)
else:
  arr = list(map(int, input().split()))

arr.sort()
if x in arr:
  i = arr.index(x)
else:
  print(x)
  exit(0)

if not i and i != 0:
  print(x)
  exit(0)

j = 1
for _ in range(n):
  row = i - j
  high = i + j
  if x - j not in arr:
    print(x - j)
    exit(0)
  elif x + j not in arr:
    print(x + j)
    exit(0)
  j += 1

print(x-1)
import numpy as np

temp=list(map(int, input().split()))
N=temp[0]
Q=temp[1]

matrix=np.zeros((N, N))
for i in range(N):
  matrix[i, i]=1

for i in range(N-1):
  temp=list(map(int, input().split()))
  matrix[int(temp[0]-1), int(temp[1]-1)]=1
  
index=int(N-1)
while index>=0:
  matrix[index, :]+=np.sum(matrix*matrix[index, :].reshape(-1, 1), axis=0)
  index-=1
  
matrix[matrix>0]=1

counter=np.zeros(N)
for i in range(Q):
  temp=list(map(int, input().split()))
  counter+=matrix[int(temp[0]-1), :]*temp[1]
  
print(' '.join(map(str, map(int, counter.tolist()))))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

def input():
  return sys.stdin.readline()[:-1]

N, Q=map(int, input().split())

link=[[] for i in range(N+1)]
for i in range(N-1):
  a, b=map(int, input().split())
  link[a].append(b)
  link[b].append(a)

px=[list(map(int, input().split())) for i in range(Q)]

counter=[0]*(N+1)
for i in range(Q):
  counter[px[i][0]]+=px[i][1]
  
def f(num, prenum=-1, p=0):
  counter[num]+=p
  for postnum in link[num]:
    if postnum==prenum:
      continue
    f(postnum, num, counter[num])
    
f(1)

print(*counter[1:])
A,B = input().split()
a,b = input().split()
print(A*B-a*B-b*A+a*b)

### FIXED CODE ###

A,B = input().split()
a,b = input().split()
A = int(A)
B = int(B)
a = int(a)
b = int(b)
print(A*B-a*B-b*A+a*b)
n = int(input())
sumv = 0
for idx in n:
  v, u = str(input()).split(' ')
  if u == 'JPY':
    sumv += float(int(v))
  elif u == 'BTC':
    sumv += float(v) * 380000.0
print(sumv)

### FIXED CODE ###

n = int(input())
sumv = 0
for idx in range(n):
  v, u = str(input()).split(' ')
  if u == 'JPY':
    sumv += float(int(v))
  elif u == 'BTC':
    sumv += float(v) * 380000.0
print(sumv)
S = input()
T = input()

res = []
cnt = 0
for i in range(len(S)-len(T)):
  s = S[i:i+len(T)]
  cnt = 0
  for j,k in zip(s,T):
    if j != k:
      cnt += 1
  res.append(cnt)

print(min(res))

### FIXED CODE ###

S = input()
T = input()

z = len(S)-len(T)

res = []
cnt = 0
if z == 0:
  for a,b in zip(S,T):
    if a != b:
      cnt += 1
  print(cnt)
  exit();
else:
  for i in range(z):
    s = S[i:i+len(T)]
    cnt = 0
    for j,k in zip(s,T):
      if j != k:
        cnt += 1
    res.append(cnt)
  print(min(res))
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    print(A.index(i+1) +1, end =' ')

### FIXED CODE ###

N = int(input())
if N%2 ==0:
    print(0.5000000000)
else:
    print(((N // 2 )+1) /N)
n = int(input())
sorted_nums = sorted(list(map(int, input().split())))
center = len(sorted_nums // 2)
ans = sorted_nums[center] - sorted_nums[center-1]
print(ans)

### FIXED CODE ###

n = int(input())
sorted_nums = sorted(list(map(int, input().split())))
center = len(sorted_nums) // 2
ans = sorted_nums[center] - sorted_nums[center-1]
print(ans)
# -*- coding: utf-8 -*-
import collections
h, w = map(int,input().split())
a = []
for i in range(h):
    a.append(list(input()))

tmp = []
for i in range(h):
    for j in a[i]:
        tmp.append(j)
#print(tmp)
c = collections.Counter(tmp)
tmp2 = set(tmp)
odd = 0
for i in tmp2:
    if c[i] % 2 == 1:
        odd += 1

if h % 2 == 1 and w % 2 == 1:
    if odd == 1:
        ans = "Yes"
    else:
        ans == "No"
elif h % 2 == 0 and w % 2 == 0:
    if (h > 2 or w > 2) and odd == 0:
        ans = "Yes"
    else:
        ans = "No"
else:
    if odd == 0:
        ans = "Yes"
    else:
        ans = "No"
print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
import collections
h, w = map(int,input().split())
a = []
for i in range(h):
    a.append(list(input()))

tmp = []
for i in range(h):
    for j in a[i]:
        tmp.append(j)
#print(tmp)
c = collections.Counter(tmp)
tmp2 = list(set(tmp))
four = 0
two = 0
odd = 0
for i in tmp2:
    if c[i] % 4 == 0:
        four += 1
    elif c[i] % 2 == 0:
        two += 1
    else:
        odd += 1

if h % 2 == 1 and w % 2 == 1:
    if odd == 1 and two <= (h // 2 + w // 2):
        ans = "Yes"
    else:
        ans = "No"
elif h % 2 == 0 and w % 2 == 0:
    if two == 0 and odd == 0:
        ans = "Yes"
    else:
        ans = "No"
elif h % 2 == 0 and w % 2 == 1:
    if odd == 0 and two <= h // 2:
        ans = "Yes"
    else:
        ans = "No"
elif h % 2 == 1 and w % 2 == 0:
    if odd == 0 and two <= w // 2:
        ans = "Yes"
    else:
        ans = "No"
print(ans)
#!/usr/bin/env python3
import sys

YES = "POSSIBLE"  # type: str
NO = "IMPOSSIBLE"  # type: str


def solve(N: int, K: int, A: "List[int]"):
    if K in A:
        print(YES)
        return
    
    if max(A) < K:
        print(NO)
        return
    
    ## 互いに素のものが一つでもあれば1が作れるからなんでも作れる→互いにそのものがあるか判定
    from math import fractions
    from functools import reduce
    def gcd_list(numbers):
        return reduce(fractions.gcd, numbers)
    
    if gcd_list(A) == 1:
        print(YES)
    else:
        if K%gcd_list(A) == 0:
            print(YES)
        else:
            print(NO)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

YES = "POSSIBLE"  # type: str
NO = "IMPOSSIBLE"  # type: str

def solve(N: int, K: int, A: "List[int]"):
    if K in A:
        print(YES)
        return
    
    if max(A) < K:
        print(NO)
        return
    
    ## 互いに素のものが一つでもあれば1が作れるからなんでも作れる→互いにそのものがあるか判定
    import fractions
    from functools import reduce
    def gcd_list(numbers):
        return reduce(fractions.gcd, numbers)
    
    if gcd_list(A) == 1:
        print(YES)
    else:
        if K%gcd_list(A) == 0:
            print(YES)
        else:
            print(NO)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()
counter = 1
while True:
    x = int(input())
    if x == 0
        break
    else :
        print("Case%d:%d.format(counter,x))
        counter = counter + 1
        


### FIXED CODE ###

ans = []
for i, x in enumerate(open(0).readlines()):
    ans.append("Case %d: %s" % (i+1, x))
open(1,'w').writelines(ans[:-1])
a = int(input())
b, c = map(int, input().split())
print(a+b+c, input())

### FIXED CODE ###

a, b = map(int, input().split())
if(a * b)% 2:
    print('Odd')
else:
    print('Even')
N = int(input())
L = list(map(int, input().split()))
ans = 0
L.sort()
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[i]+L[j] > L[k] and L[k]+L[j] > L[i] and L[i]+L[k] > L[j]:
        ans = ans + 1
      else:
        break
print(ans)


### FIXED CODE ###

A,B = list(map(int,input().split()))
ans = A - 2*B
if ans < 0:
  ans = 0
print(ans)
string = input()

def jadge_humiyasui(string):
    for i, str in enumerate(string):
        if i % 2 == 0:
            label1 = str in ['R', 'U', 'D']
        else:
            label2 = str in ['L', 'U', 'D']

    if label1 & label2:
        print('Yes')
    else:
        print('No')

jadge_humiyasui(string)


### FIXED CODE ###

string = input()

def jadge_humiyasui(string):
    label1 = True
    label2 = True

    for i, str in enumerate(string):
        if i % 2 == 0:
            if str not in ['R', 'U', 'D']:
                label1 = False
        else:
            if str not in ['L', 'U', 'D']:
                label2 = False

    if label1 & label2:
        print('Yes')
    else:
        print('No')

jadge_humiyasui(string)
N, K = map(int, input().split())
X = list(map(int, input().split()))

zeroi = 0
while zeroi < N:
    if X[zeroi] >= 0:
        break
    zeroi += 1
if X[zeroi] == 0:
    K -= 1
    del X[zeroi]


def solve():
    if not X:
        return 0
    minval = 2**60
    for i in range(max(zeroi-K, 0), min(zeroi+K+1, len(X))):
        if X[i] < 0:
            r = K + i
            if r >= len(X):
                continue
            d = -X[i]
            if r >= zeroi:
                d += 2 * X[r]
        else:
            r = i - K + 1
            if r < 0:
                continue
            d = X[i]
            if r < zeroi:
                d += -2 * X[r]
        minval = min(minval, d)
    return minval

print(solve())

### FIXED CODE ###

N, K = map(int, input().split())
X = list(map(int, input().split()))

zeroi = 0
while zeroi < N:
    if X[zeroi] >= 0:
        break
    zeroi += 1
if zeroi < N and X[zeroi] == 0:
    K -= 1
    N -= 1
    del X[zeroi]

xl = list(reversed(X[:zeroi]))
xr = list(X[zeroi:])

def solve():
    if K == 0:
        return 0
    minval = 2**60
    for i, x in enumerate(xl):
        r = K - (i+1)
        if r <= 0:
            d = -x
        elif r > len(xr):
            continue
        else:
            d = -x + 2 * xr[r-1]
        if minval > d:
            minval = d
    for i, x in enumerate(xr):
        l = K - (i+1)
        if l <= 0:
            d = x
        elif l > len(xl):
            continue
        else:
            d = x - 2 * xl[l-1]
        if minval > d:
            minval = d
    return minval

print(solve())