Harryxun/stf_run huggingface dataset:
import copy

n = int(input())
inputs = input().split(" ")
l = [int(s) for s in inputs]

def calc(rl, ns):
    v = rl.pop(len(rl)-1)
    # print(rl,v,ns)
    lrl = len(rl)
    
    if lrl == 0:
        return ns
    if lrl == 1:
        v1 = rl[len(rl)-1]
        return ns+abs(v-v1)
    if lrl == 2:
        v1 = rl[len(rl)-1]
        v2 = rl[len(rl)-2]
        ns1 = ns + abs(v-v2)
        ns2 = ns + abs(v-v1) + abs(v1-v2)
        # print("lrl 2:",v1,v2,ns1,ns2,ns)
        return min(ns1,ns2)
    else:
        v1 = rl[len(rl)-1]
        crl = copy.copy(rl)
        c1 = calc(crl,ns+abs(v-v1))
        v2 = rl[len(rl)-2]
        rl.pop(len(rl)-1)
        c2 = calc(rl,ns+abs(v-v2))
        return min(c1,c2)

print(calc(l,0))

### FIXED CODE ###

N = int(input())
h = list(map(int, input().split()))
 
suml = [1e5 for i in range(N)]
suml[0] = 0
suml[1] = abs(h[1] - h[0])
 
for e in range(2, N):
    suml[e] = min(
        abs(h[e]-h[e-1]) + suml[e-1],
        abs(h[e]-h[e-2]) + suml[e-2],
    )
 
# print(suml)
print(suml[N-1])
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
l = y[n/2-2]
r = y[n/2-1]
for i in range(n):
    if x[i] <= l:print(r)
    else:print(l)


### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
l = y[n//2-1]
r = y[n//2]
for i in range(n):
    if x[i] <= l:print(r)
    else:print(l)
def lower_elements(A, b):
    lower_bound = -1
    upper_bound = len(A)
    while upper_bound - lower_bound > 1:  # ア
        middle = (lower_bound + upper_bound) // 2
        if A[middle] < b:  # イ
            lower_bound = middle
        else:
            upper_bound = middle
    return lower_bound + 1  # ウ upper_boundでも可


def upper_elements(C, b):
    lower_bound = -1
    upper_bound = len(C)
    while upper_bound - lower_bound > 1:  # ア
        middle = (lower_bound + upper_bound) // 2
        if C[middle] <= b:
            lower_bound = middle
        else:
            upper_bound = middle
    return len(C) - upper_bound


def answer(N, A, B, C):
    assert N == len(A) == len(B) == len(C)
    A.sort()
    B.sort()
    C.sort()
    count = 0
    for b in B:
        count += lower_elements(A, b) * upper_elements(C, b)
    return count


def snuke_festival():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    print(answer(N, A, B, C))


if __name__ == '__main__':
  sunuke_festiival()

### FIXED CODE ###

def lower_elements(A, b):
    lower_bound = -1
    upper_bound = len(A)
    while upper_bound - lower_bound > 1:  # ア
        middle = (lower_bound + upper_bound) // 2
        if A[middle] < b:  # イ
            lower_bound = middle
        else:
            upper_bound = middle
    return lower_bound + 1  # ウ upper_boundでも可


def upper_elements(C, b):
    lower_bound = -1
    upper_bound = len(C)
    while upper_bound - lower_bound > 1:  # ア
        middle = (lower_bound + upper_bound) // 2
        if C[middle] <= b:
            lower_bound = middle
        else:
            upper_bound = middle
    return len(C) - upper_bound


def answer(N: int, A: list, B: list, C: list):
    assert N == len(A) == len(B) == len(C)
    A.sort()
    B.sort()
    C.sort()
    count = 0
    for b in B:
        count += lower_elements(A, b) * upper_elements(C, b)
    return count


def snuke_festival():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    print(answer(N, A, B, C))


if __name__ == '__main__':
  snuke_festival()
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N,M,K = map(int,input().split())

def mCn(m,n):
    return math.factorial(m)//(math.factorial(n)*math.factorial(m-n)) % mod

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N1 = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N1 + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = 0
for i in range(1,M):
    ans += (M-i)*N**2*i*(cmb(M*N-2,K-2,mod))
    if ans > mod:
        ans = ans % mod

for i in range(1,N):
    ans += (N-i)*M**2*i*(cmb(M*N-2,K-2,mod))
    if ans > mod:
        ans = ans % mod

print(ans)


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N,M,K = map(int,input().split())

def mCn(m,n):
    return math.factorial(m)//(math.factorial(n)*math.factorial(m-n)) % mod

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N1 = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N1 + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


ans = 0
for i in range(1,M):
    ans += (M-i)*N**2*i*(cmb(M*N-2,K-2,mod))
    if ans > mod:
        ans = ans % mod

for i in range(1,N):
    ans += (N-i)*M**2*i*(cmb(M*N-2,K-2,mod))
    if ans > mod:
        ans = ans % mod

print(ans)
n = int(input())
l = list(map(int, input().split()))


longest = max(x)
x.remove(longest)

if longest < sum(x):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
 
longest = max(x)
x.remove(longest)
 
if longest < sum(x):
    print("Yes")
else:
    print("No")
def checkFunction(c):
    count = 0

    while True:
        print(count, c)
        if not ('WR' in c):
            return count
        while c[0] == 'R':
            c = c[1:]
        while c[-1] == 'W':
            c = c[:-1]

        if c.index('R') == len(c) - 1:
            return count + 1
        else:
            c = c.replace('WR', 'RR',1)[:-1]
            count += 1

N = int(input())
c= input()

print(checkFunction(c))


### FIXED CODE ###


def check(N, c):
    RinRight = c.count('R')
    WinLeft = 0
    r = RinRight
    for i in range(N):
        if c[i] == 'R':
            RinRight -= 1
        else: # c[i] == 'W'
            WinLeft +=1
        r = min(r, max(RinRight,WinLeft))

    return r


N = int(input())
c= input()
print(check(N,c))
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

s = rr()
k = ri()
cnt = 0
i = 0
if len(set(s)) == 1:
  print(int(s*k/2))
  exit()
while i < len(s)-1:
  if s[i] == s[i+1]:
    cnt += 1
    i += 1
  i += 1
print(cnt)
cnt1 = 0
i1 = 0
s *= 2
while i1 < len(s)-1:
  if s[i1] == s[i1+1]:
    cnt1 += 1
    i1 += 1
  i1 += 1
print(cnt1)
print((cnt1 - cnt)*(k-1) + cnt)



### FIXED CODE ###

import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

s = rr()
k = ri()
cnt = 0
i = 0
if len(set(s)) == 1:
  print(int(len(s)*k/2))
  exit()
while i < len(s)-1:
  if s[i] == s[i+1]:
    cnt += 1
    i += 1
  i += 1
cnt1 = 0
i1 = 0
s *= 2
while i1 < len(s)-1:
  if s[i1] == s[i1+1]:
    cnt1 += 1
    i1 += 1
  i1 += 1
print((cnt1 - cnt)*(k-1) + cnt)
from bisect import bisect_left
import sys
sys.setrecursionlimit(1000000)


def dfs(v, p):
    i = bisect_left(dp, a[v])
    dp[i], old = a[v], dp[i]
    ans[v] = bisect_left(dp, INF)-1
    for u in to[v]:
        if u == p:
            continue
        dfs(u, v)
    dp[i] = old

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    to = [[] for _ in range(n)]
    ans = [0]*n
    INF = 10**20
    for _ in range(n-1):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        to[u].append(v)
        to[v].append(u)
    if n == 2 and u == v:
        print("yes")
        exit(0)
    dp = [INF]*n
    dp[0] = -INF
    dfs(0, -1)
    print("\n".join(list(map(str, ans))))

### FIXED CODE ###

from bisect import bisect_left
import sys
sys.setrecursionlimit(1000000)


def dfs(v, p):
    i = bisect_left(dp, a[v])
    dp[i], old = a[v], dp[i]
    ans[v] = bisect_left(dp, INF)-1
    for u in to[v]:
        if u == p:
            continue
        dfs(u, v)
    dp[i] = old

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    to = [[] for _ in range(n)]
    ans = [0]*n
    INF = 10**20
    for _ in range(n-1):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        to[u].append(v)
        to[v].append(u)
    dp = [INF]*(n+1)
    dp[0] = -INF
    dfs(0, -1)
    print("\n".join(list(map(str, ans))))
n = int(input())
li = list(n)
sn = sum(li)
if ( n % sn ): print("No")
else: print("Yes")

### FIXED CODE ###

n = int(input())
li = list(str(n))
li_ = [int(i) for i in li]
allSum = sum(li_)
if not n % allSum: print("Yes")
else: print("No")
n = input()
k = input()
if n >= 10:
    print(k)
else:
    print(k+(100*(10-n)))

### FIXED CODE ###

n,k = map(int,input().split())
if n >= 10:
    print(k)
else:
    print(k+(100*(10-n)))
import sys

def my_index(l, x):
    if x in l:
        return l.index(x)
    else:
        return -1


input = sys.stdin.readline
n,m = map(int, input().split())
A = list(map(int,input().split()))

for i in range(m-1):
    A.sort()
    b,c = map(int, input().split())
    if A[b] > c:
        A = [c if i < c else i for i in A]
    else:
        A[:b] = [c for _ in range(b)]


print(sum(A))

### FIXED CODE ###

import sys
import heapq

input = sys.stdin.readline
n,m = map(int, input().split())
A = list(map(int,input().split()))
d = [list(map(int,input().split())) for _ in range(m)]

d.sort(key=lambda x:-x[1])
total = sum(A)
heapq.heapify(A)

for i in range(m):
    for j in range(d[i][0]):
        tmp = heapq.heappushpop(A, d[i][1])
        if tmp < d[i][1]:
                total += (d[i][1] - tmp)
        else:
            break

print(total)
N, K = map(int, input().split())
if N >= 2:
    print(N - K)
elif:
    print(0)

### FIXED CODE ###

N, K = map(int, input().split())
if K >= 2:
    print(N - K)
else:
    print(0)
N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]

tree = [[] for _ in range(N)]
count = [0] * N

for a, b in ab:
    tree[a - 1].append(b - 1)


def dfs(p, x):
    count[p] += x

    for np in tree[p]:
        dfs(np, x)


for p, x in px:
    dfs(p - 1, x)

for c in count:
    print(c, end=" ")

print()


### FIXED CODE ###

from sys import stdin
from collections import deque
input = stdin.readline

N, Q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N - 1)]
px = [list(map(int, input().split())) for _ in range(Q)]

tree = [[] for _ in range(N)]
count = [0] * N
seen = [0] * N

for a, b in ab:
    tree[a - 1].append(b - 1)
    tree[b - 1].append(a - 1)

for p, x in px:
    count[p - 1] += x

d = deque([])


def dfs(p):
    d.append(p)
    seen[p] = 1

    while d:
        p = d.pop()

        for np in tree[p]:
            if seen[np] == 0:
                seen[np] = 1
                count[np] += count[p]
                d.append(np)


dfs(0)

for c in count:
    print(c, end=" ")

print()
A,B,C = map(int,input().slpit())
 
if A==B:
  print(C)
elif B==C:
  print(A)
else:
  print(B)

### FIXED CODE ###

A, B, C = map(int, input().split())
 
if A==B:
  print(C)
elif B==C:
  print(A)
else:
  print(B)
from functools import lru_cache
import sys
sys.setrecursionlimit(20000)

N, M = map(int, input().split())
a = list(int(input()) for _ in range(M))

MOD = pow(10, 9) + 7

isOk = True
for i in range(M-1):
    if a[i] + 1 == a[i+1]:
        isOk = False
    
@lru_cache(maxsize = None)
def func(n):
    if n <= 0:
        return 1
    cnt = 0
    if n >= 2:
        cnt += func(n-2) % MOD
    if n >= 1:
        cnt += func(n-1) % MOD
    return cnt

if not isOk:
    print(0)
else:
    ans = 1
    s = 0
    for i in range(M+1):
        if i >= M:
            e = N
        else:
            e = a[i] - 1

        ans = ans * func(e-s) % MOD

        if i >= M:
            break

        s = a[i] + 1

    print(ans)


### FIXED CODE ###

from functools import lru_cache
import sys
sys.setrecursionlimit(30000)

N, M = map(int, input().split())
a = list(int(input()) for _ in range(M))

MOD = pow(10, 9) + 7

isOk = True
for i in range(M-1):
    if a[i] + 1 == a[i+1]:
        isOk = False
    
funcb = [-1] * 100001
def func(n):
    if n <= 0:
        return 1
    cnt = funcb[n]
    if cnt > 0:
        return cnt
    cnt = 0
    if n >= 2:
        cnt += func(n-2)
    if n >= 1:
        cnt += func(n-1)
    funcb[n] = cnt % MOD
    return funcb[n]

func(30000)
func(50000)
func(80000)
func(100000)

if not isOk:
    print(0)
else:
    ans = 1
    s = 0
    for i in range(M+1):
        if i >= M:
            e = N
        else:
            e = a[i] - 1

        ans = ans * func(e-s) % MOD

        if i >= M:
            break

        s = a[i] + 1

    print(ans)
from functools import lru_cache
h = int(input())
count = 0

while n==1:
  n = h//2
  count +=1

@lru_cache(maxsize=100000)
def f(n):
    if n < 1:
        return 3
    else:
        return f(n - 1)*2 + 1

print(f(count))

### FIXED CODE ###

from functools import lru_cache
h = int(input())
count = 0

while h > 1:
  h = h//2
  count +=1

@lru_cache(maxsize=100000)
def f(n):
    if n < 1:
        return 1
    else:
        return f(n - 1)*2 + 1

print(f(count))
from math import gcd

A, B = map(int, input().split())
G = gcd(A, B)
print(A*B // G)


### FIXED CODE ###

from fractions import gcd

A, B = map(int, input().split())
G = gcd(A, B)
print(A*B // G)
n, q = map(int, input().split())
    s = input()
    dat_q = []
    for i in range(q):
        l, r = map(int, input().split())
        dat_q.append((l, r))

    c = [0] * n
    for i in range(1, n):
        if s[i-1:i+1] == "AC":
            c[i] = c[i-1] + 1
        else:
            c[i] = c[i-1]
    for i in range(q):
        l, r = dat_q[i][0], dat_q[i][1]
        print(c[r - 1] - c[l - 1])

### FIXED CODE ###

n, q = map(int, input().split())
s = input()
dat_q = []
for i in range(q):
    l, r = map(int, input().split())
    dat_q.append((l, r))

c = [0] * n
for i in range(1, n):
    if s[i-1:i+1] == "AC":
        c[i] = c[i-1] + 1
    else:
        c[i] = c[i-1]
for i in range(q):
    l, r = dat_q[i][0], dat_q[i][1]
    print(c[r - 1] - c[l - 1])
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
//	cin>>n>>k;
//	cout<<n<<k<<endl;
//string S[100];

int main(){
	int N,K,X,Y;cin>>N>>K>>X>>Y;
	int ans;

	for(int i=1;i<N+1;i++){
		if(K<i){
			ans+=Y;

		}else{
			ans+=X;
		}
	}
	cout<<ans<<endl;
}

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
ans=0
for i in range(a):
    if 0<b:
        ans+=c
    else:
        ans+=d
    b=b-1
print(ans)
#abc109 a 
a,b=map(int,input().split())
flag=False
for c in range(1,4):
    x=a*b*c 
    if x%2==1:
        flag=True
        break
if flag:
 	print("Yes")
 else:
 	print("No")

### FIXED CODE ###

#abc109 a
a,b=map(int,input().split())
flag=False
for c in range(1,4):
    x=a*b*c
    if x%2==1:
        flag=True
        break
if flag:
 	print("Yes")
else:
 	print("No")
s=input()
a=int(s[0]);b=int(s[1]);c=int(s[2]);d=int(s[3])
if a+b+c+d==7:
  print(str(a)+"+"str(b)+"+"str(c)+"+"+str(d)+"=7")
  break
elif a+b+c-d==7:
  print(str(a)+"+"str(b)+"+"str(c)+"-"+str(d)+"=7")
  break
elif a+b-c+d==7:
  print(str(a)+"+"str(b)+"-"str(c)+"+"+str(d)+"=7")
  break
elif a+b-c-d==7:
  print(str(a)+"+"str(b)+"-"str(c)+"-"+str(d)+"=7")
  break
elif a-b+c+d==7:
  print(str(a)+"-"str(b)+"+"str(c)+"+"+str(d)+"=7")
  break
elif a-b+c-d==7:
  print(str(a)+"-"str(b)+"+"str(c)+"-"+str(d)+"=7")
  break
elif a-b-c+d==7:
  print(str(a)+"-"str(b)+"-"str(c)+"+"+str(d)+"=7")
  break
elif a-b-c-d==7:
  print(str(a)+"-"str(b)+"-"str(c)+"-"+str(d)+"=7")
  break

### FIXED CODE ###

import sys
s=input()
a=int(s[0]);b=int(s[1]);c=int(s[2]);d=int(s[3])
if a+b+c+d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a+b+c-d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a+b-c+d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a+b-c-d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a-b+c+d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a-b+c-d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
  sys.exit()
elif a-b-c+d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
  sys.exit()
elif a-b-c-d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
  sys.exit()
N, M = map(int, input().split())
A = [0 for i in range(N)]

sum_A =0
for i in range(N):
    sum_A += A[i]

if (4*M*A[M] < sum_A):
    print('No')
else:
    print('Yes')

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
 
sum_A =0
for i in range(N):
    sum_A += A[i]

ans = 0
for i in range(N):
    if (4*M*A[i] >= sum_A):
        ans+=1
    else:
    	ans+=0
    	
if (ans >= M):
    print('Yes')
else:
    print('No')
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

T = "AKIHABARA"
S_idx = 0
T_idx = 0
while S_idx != len(S):
	if S[S_idx] != T[T_idx]:
		if T[T_idx] != "A":
			print("NO")
			exit()
		else:
			T_idx += 1
	else:
		S_idx += 1
		T_idx += 1
print("YES")


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
T = list("AKIHABARA")

idx = [0, 4, 6, 8]

for x in product([0, 1], repeat=len(idx)):
	TC = T.copy()
	tmp = ""
	for i in range(len(idx)):
		if x[i]:
			TC[idx[i]] = ""
	if "".join(TC) == S:
		print("YES")
		break
else:
	print("NO")
N,T = map(int,input().split())
c,t = [map(int,input()) for i in range(N)]
a = 1000
for i in range(N):
  if t <= T:
    a = min(a,c)
if a = 1000:
  print("TLE")
else:
  print(a)

### FIXED CODE ###

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

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

c = []
t = []

for i in range(N):
    c.append(ct[i][0])
    t.append(ct[i][1])

minc = 10000

for i in range(len(c)):
    if t[i] <= T and c[i] < minc:
        minc = c[i]

if minc == 10000:
    print("TLE")
else:
    print(minc)
n = int(input())

path = [[] for i in range(n)]

for _ in range(n-1):
    u,v,w = list(map(int,input().split()))
    path[u-1].append((v-1, w%2))
    path[v-1].append((u-1, w%2))

global dist
dist = [-1 for i in range(n)]
dist[0] = 0

def dfs(now):
    for v,w in path[now]:
        if dist[v] == -1:
            dist[v] = w + dist[now]
            dfs(v)
    
dfs(0)

for i in dist:
    print(i%2)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

n = int(input())

path = [[] for i in range(n)]

for _ in range(n-1):
    u,v,w = list(map(int,input().split()))
    path[u-1].append((v-1, w))
    path[v-1].append((u-1, w))

global dist
dist = [-1 for i in range(n)]
dist[0] = 0

def dfs(now):
    for v,w in path[now]:
        if dist[v] == -1:
            dist[v] = w + dist[now]
            dfs(v)
    
dfs(0)

for i in dist:
    print(i%2)
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))
a=0
for i in A[:-1]:
    a+=B[i-1]   
if A[-2]==N:
    a+=B[A[-1]-1]
else:
    a+=B[A[-1]-1]+C[A[-2]-1]
print(a)

### FIXED CODE ###

N=int(input())
print(N**3)
s = input()
k = int(input())
sub = set()
for i in range(n):
  for j in range(1,k):
    sub.add(s[i:i+j])
print(sorted(list(sub))[k-1])

### FIXED CODE ###

s = input()
k = int(input())
sub = set()
for i in range(len(s)):
  for j in range(1,k+1):
    sub.add(s[i:i+j])
print(sorted(list(sub))[k-1])
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N,M,X = map(int,input().split()) #整数の入力
a = [int(i) for i in range(M)] #検問所の入力
b=[]
c=[]
for i in range(X:N): #XからNの範囲の整数について 
  if i in a is True: #ある整数が検問所の整数として存在する
    b.append(1)
for i in range(1:X): #1からX-1の範囲の整数について
  if i in a is True: #ある整数が検問所の整数として存在する
    c.append(1)

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
N,M,X = map(int,input().split()) #整数の入力
a = list(map(int,input().split()))
#検問所の入力
b=[]
c=[]
for i in range(X+1,N): #X+1からNの範囲の整数について 
  if i in a: #ある整数が検問所の整数として存在する
    b.append(1)
for i in range(1,X): #1からX-1の範囲の整数について
  if i in a: #ある整数が検問所の整数として存在する
    c.append(1)
print(min(sum(b),sum(c)))
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

out=0
for i in range(0,N,1):
  if i in A:
    continue
  if i==N-1:
    out+=1
  for j in range(i,N,2):
    if j in A:
      continue
    if j==N-1:
      out+=1
  
print(out%1000000007)

### FIXED CODE ###

import sys
mod = 10**9+7

def main():
    n, m = map(int, input().split(' '))
    if m > 0:
        aaa = set(map(int, sys.stdin))
    else:
        aaa = set()
 
    dp = [0] * (n+1)
    dp[0] = 1
    dp[1] = 1 if 1 not in aaa else 0
    
    for i in range(2, n+1):
        if i in aaa:
            continue
        dp[i] = (dp[i-1]+dp[i-2])%mod
 
    print(dp[n])
 
main()
def run(infile, outfile):
	n = int(infile.readline())
	if n == 0:
		break
	foo(infile,outfile,n)

def foo(infile, outfile, n):
	ax = 0 #a's point
	bx = 0
	for i in range(n):
		a , b = infile.readline().split()
		a = int(a)
		b = int(b)
		if a > b:
			ax += (a + b)
		elif b > a:
			bx += (a + b)
		else:
			assert False
	print >> outfile, ax , bx

if __name__ == "__main__":
	import sys
	run(sys.stdin, sys.stdout)

### FIXED CODE ###

def input_n(inputfile,outputfile):
	while True:
		n = inputfile.readline()
		n = int(n)
		if n == 0:
			break
		battle(inputfile,outputfile,n)

def battle(inputfile,outputfile,n):
	apoint = 0
	bpoint = 0
	for i in range(n):
		a , b = inputfile.readline().split()
		a = int(a)
		b = int(b)
		if a > b:
			apoint += (a + b)
		elif b > a:
			bpoint += (a + b)
		else:
			apoint += a
			bpoint += b
	print >> outputfile, apoint, bpoint

if __name__ == "__main__":
	import sys
	input_n(sys.stdin,sys.stdout)
n, k = [int(i) - 1 for i in input().split()]
print(int(n % k != 0))

### FIXED CODE ###

n, k = [int(i) for i in input().split()]
print(int(n % k != 0))