Harryxun/stf_run huggingface dataset:
import math

def radi(n):
	return n * math.pi / 180

def resolve():
	a, b, h, m = map(int, input().split())
	hd = radi(h*30+30*(m/60))
	md = radi(360*(m/60))
	hx = a * math.cos(hd)
	hy = a * math.sin(hd)
	mx = b * math.cos(md)
	my = b * math.sin(md)
	x = abs(hx - mx)
	y = abs(hy - my)
	v = math.sqrt(x**2 + y**2)
	print(v)
rseolve()

### FIXED CODE ###

import math

def calc_angle(h, m):
	# validate the input
	if (h < 0 or m < 0 or h > 12 or m > 60):
		print('Wrong input')

	if (h == 12):
		h = 0
	if (m == 60):
		m = 0

	# Calculate the angles moved by
	# hour and minute hands with
	# reference to 12:00
	hour_angle = 0.5 * (h * 60 + m)
	minute_angle = 6 * m

	# Find the difference between two angles
	angle = abs(hour_angle - minute_angle)

	# Return the smaller angle of two
	# possible angles
	angle = min(360 - angle, angle)

	return angle

def resolve():
	a, b, h, m = map(int, input().split())
	ang = calc_angle(h, m)
	radi = math.radians(ang)
	v = (a**2 + b**2 - 2*a*b*math.cos(radi))**0.5
	print(v)
resolve()
N, K = [int(i) for i in input().split()]

cnt = 0

for a in range(1,N+1):
    for b in range(1,N+1):
        if (a+b) % K !=0:
            continue
        else:
            for c in range(1,N+1):
                if (a+c) % K !=0 || (b+c) % K !=0:
                    continue
                cnt = cnt+1

print(cnt)

### FIXED CODE ###

k = int(input())
q = k // 2
m = k %  2

k_odd  = q + m
k_even = q

ans = k_odd * k_even
print(ans)
def keta(n,k):
  cnt=0
  while(n!=0):
   	n//=k
 	cnt+=1
   	return cnt
     
N,K=map(int,input().split())
print(keta(N,K))

### FIXED CODE ###

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

if(N >= 10):
    print(R)
else:
    K = N
    print(R+100*(10-K))
N,M = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(M)]
hoge = set()

zenbu = {int(i + 1) for i in range(N)}

for i in e:
    konkaino = {int(i) for i in range(e[0],e[1] + 1)}
    zenbu = zenbu & konkaino


print(len(zenbu))

### FIXED CODE ###

N,M = (int(i) for i in input().split())
e = [[int(i) for i in input().split()] for i in range(M)]

right = N
left = 0

for i in e:
    if left < i[0]:
        left = i[0]
    if right > i[1]:
        right = i[1]
if right >= left:
    print(right - left + 1)
else:
    print("0")
A = input()
b = A.count("RRR")
C = A.count("RR")
D = A.count("R")
if b == 1: 
   print(3)
elif C ==1:
   print(2)
else:
   if D >0:
      print(1)
   else:

### FIXED CODE ###

A = input()
b = A.count("RRR")
C = A.count("RR")
if b == 1: 
   print(3)
elif C ==1:
   print(2)
else:
   if A.count("R")>0:
      print(1)
   else:
      print(0)
s = input()
n = len(s)
sum = [0] * (n + 1)
sum[0] = (s[0] == 'B')
for i in range(1 , n):
	sum[i] = sum[i-1] + (s[i] == 'B')
ans = 0
for i in range(n, -1 ,-1):
	if s[i] == 'W':
		ans += sum[i]
print(ans)
	

### FIXED CODE ###

s = input()
n = len(s)
sum = [0] * (n + 1)
sum[0] = (s[0] == 'B')
for i in range(1 , n):
	sum[i] = sum[i-1] + (s[i] == 'B')
ans = 0
for i in range(n - 1, -1 ,-1):
	if s[i] == 'W':
		ans += sum[i]
print(ans)
N = int(input())

ans = 1
for i in range(8):
  if(n >= 2 ** i):
    ans = 2 ** i
print(ans)

### FIXED CODE ###

n = int(input())
ans = 1
for i in range(8):
  if(n >= 2 ** i):
    ans = 2 ** i
print(ans)
n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i, m):
    if m == 0:
        return True
    if n <= i or sum(A) < m:
        return False
    res = (solve(i+1, m) or solve(i+1, m-A[i]))
    return res 
 
for m in range (M):
    if solve(0, m):
        print "yes"
    else:
        print "no"

### FIXED CODE ###

n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

def solve(i, m):
    if m == 0:
        return True
    if n <= i or sum(A) < m:
        return False
    x = (solve(i+1, m) or solve(i+1, m-A[i]))
    return  x
 
for m in M:
    if solve(0, m):
        print "yes"
    else:
        print "no"
S=input()
s=list(S)
T=input()
t=list(T)
for i in range(len(s)):
  s.insert(0,s[-1])
  print(s)
  s.pop(-1)
  
  print(s)
  if s==t:
    print('Yes')
    exit()
  
print('N

### FIXED CODE ###

S=input()
s=list(S)
T=input()
t=list(T)
for i in range(len(s)):
  s.insert(0,s[-1])
  s.pop(-1)
  if s==t:
    print('Yes')
    exit()
  
print('No')
for i in range(q):
  a,b,c,d=map(int,input().split())
  aa.append(a-1)
  bb.append(b-1)
  cc.append(c)
  dd.append(d)
sumd=[]
#print(list(combinations(range(1,m+1),n)))
for Alis in combinations(range(1,m+1),n):
  
  di=0
  
  for i in range(q):
    if cc[i]==(Alis[bb[i]]-Alis[aa[i]]):
      di+=dd[i]
      
  sumd.append(di)
print(max(sumd))

### FIXED CODE ###

from itertools import combinations_with_replacement
n,m,q=map(int,input().split())
aa=[]
bb=[]
cc=[]
dd=[]
for i in range(q):
  a,b,c,d=map(int,input().split())
  aa.append(a-1)
  bb.append(b-1)
  cc.append(c)
  dd.append(d)
sumd=[]
#print(list(combinations(range(1,m+1),n)))
for Alis in combinations_with_replacement(range(1,m+1),n):
  
  di=0
  
  for i in range(q):
    if cc[i]==(Alis[bb[i]]-Alis[aa[i]]):
      di+=dd[i]
      
  sumd.append(di)
print(max(sumd))
n = input()
ans = int(n * (n + 1) / 2)
print(ans)

### FIXED CODE ###

n = int(input())
ans = int(n * (n + 1) /2)
print(ans)
import math

A,B,H,M = map(int,input().split())

radH = 2*math.pi*H/12 + 30/180*math.pi*M/60
radM = 2*math.pi*M/60

L = math.sqrt(A^2+B^2-2*A*B*math.cos(radH-radM))

print(L)

### FIXED CODE ###

import math

A,B,H,M = map(int,input().split())

radH = 2*math.pi*H/12 + 30/180*math.pi*M/60
radM = 2*math.pi*M/60

L = math.sqrt(A**2+B**2-2*A*B*math.cos(radH-radM))

print(L)
import queue
import numpy as np

num = list(map(int,input().split()))
field = [list(input()) for i in range(num[0])]
q_r = queue.Queue()
q_c = queue.Queue()
seen = np.zeros((num[0],num[1]))
step_r = [1,0,-1,0]
step_c = [0,1,0,-1]

for i in range(num[0]):
  for j in range(num[1]):
    if field[i][j] == "#":
      q_r.put(i)
      q_c.put(j)
      
while not q_r.empty():
  r = q_r.get()
  c = q_c.get()
  
  for i in range(4):
    next_r = r + step_r[i]
    next_c = c + step_c[i]
    
    if (next_r<0) or (num[0]<=next_r) or (next_c<0) or (num[1]<=next_c) or (field[next_r][next_c] == "#"):
      continue
    
    field[next_r][next_c] = "#"
    q_r.put(next_r)
    q_c.put(next_c)
    seen[next_r][next_c] = seen[r][c] + 1
#    print(seen[next_r][next_c],next_r,next_c)
    g_r = next_r
    g_c = next_c

print(int(seen[g_r][g_c]))

### FIXED CODE ###

def main():
    h,w = map(int,input().split())
    a = []
    for i in range(h):
        a.append(input())

    used = [True]*(h*w)

    p = []
    for i in range(h):
        for j in range(w):
            if a[i][j] == '#':
                p.append(i*w+j)
                used[i*w+j] = False


    
    res = 0
    while p:
        tank = []
        for e in p:
            if e>w-1 and used[e-w]:
                tank.append(e-w)
                used[e-w] = False
            if e%w > 0 and used[e-1]:
                tank.append(e-1)
                used[e-1] = False
            if e<(h-1)*w and used[e+w]:
                tank.append(e+w)
                used[e+w] = False
            if e%w<w-1 and used[e+1]:
                tank.append(e+1)
                used[e+1] =  False
        p = tank
        res += 1
    print(res-1)

if __name__ == '__main__':
    main()
a,b = [int(x) for x in input().split()]
j = [2,3,4,5,6,7,8,9,10,11,12,13,1]
if j.index(a) > j.rindex(b):
  print('Alice')
elif j.index(a) < j.index(b):
  print('Bob')
else:
  print('Draw')


### FIXED CODE ###

a,b = [int(x) for x in input().split()]
j = [2,3,4,5,6,7,8,9,10,11,12,13,1]
if j.index(a) > j.index(b):
  print('Alice')
elif j.index(a) < j.index(b):
  print('Bob')
else:
  print('Draw')
A = int(input("a = "))
B = int(input("b = "))
C = A*B
print(C)
print(C/2)
if 1 <= A <= 10000 and 1 <= B <= 10000 and C%2 == 0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

a, b = map(int, input().split())
print("Even" if a*b % 2 == 0 else "Odd")
def ABC158D():
    txt2 = txt.split("\n")
    s = txt2[0]
    q = int(txt2[1])
    for i in range(2, len(txt2)):
        txt3 = txt2[i].split()
        if txt3[0] == '1':
            s = s[::-1]
        else:
            if txt3[1] == '1':
                s = txt3[2] + s
            else:
                s = s + txt3[2]
    print(s)
                
ABC158D()


### FIXED CODE ###


s = input()
q = int(input())
ht = 1
head = ''
tail = ''
count = 0
for i in range(q):
    txt3 = input().split()
    if txt3[0] == '1':
        ht = 3 - ht
        count += 1
    else:
        if int(txt3[1]) == ht:
            head = txt3[2] + head
        else:
            tail = tail + txt3[2]
s = head + s + tail
if count % 2 == 1:
    s = s[::-1]
print(s)
import sys
s = raw_input()
used = set()
sys.setrecursionlimit(len(s))
def dfs(s):
    if s in used:
        return 0
    if s == "ABC":
        return 1
    if "ABC" in s:
        for c in "ABC":
            if dfs(s.replace("ABC", c)):
                return 1
    used.add(s)
    return 0
print dfs(s)*"Yes"or"No"

### FIXED CODE ###

s = raw_input()
p = "ABC"
used = set()

while s != p:
    idx = 0
    c = [0]*3
    while idx < len(s):
        if idx+3 <= len(s) and s[idx:idx+3] == p:
            idx += 3
        else:
            c[p.index(s[idx])] += 1
            idx += 1
    if sum(e == 0 for e in c) != 1 or sum(c) == len(s):
        print "No"
        exit(0)
    s = s.replace("ABC", p[[i for i in [0,1,2] if c[i]==0][0]])
print "Yes"
A = int(input())
B = int(input())
C = int(input())

X = A + B - C
if X >= 0:
    print(X)
else:
    print(0)


### FIXED CODE ###

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

X = b + c - a
if X >= 0:
    print(X)
else:
    print(0)
import math

n = int(input())
mod = 10**9+7
d = {}
l = []
s = set()
zero = 0
for i in range(n):
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        zero += 1
    elif a == 0:
        s1 = (0,1)
        s2 = (1,0)
    elif b == 0:
        s1 = (1,0)
        s2 = (0,1)
    else:
        
        g = math.gcd(a,b)
        if b > 0:
            a //= g
            b //= g
            s1 = (a,b)
            if a > 0:
                
                s2 = (-b,a)
            else: 
                
                s2 = (b,-a)
        else:
            a //= g
            b //= g
            s1 = (-a,-b)
            if a < 0:
                
                s2 = (b,-a)
            else:
                
                s2 = (-b,a)
    if s1 in d:
        d[s1] += 1
    else:
        d[s1] = 1
    if s1 in s:
        continue
    else:
        if s2 in d:
            l.append([s1,s2])
            s.add(s1)
            s.add(s2)
    
ans = 1
for a,b in l:
    count = (pow(2,d[a],mod)+pow(2,d[b],mod)-1)%mod
    ans *= count
    ans %= mod
for i,j in d.items():
    if i in s:
        continue
    else:
        ans *= pow(2,j,mod)
        ans %= mod

print(ans+zero-1)




### FIXED CODE ###

import math

n = int(input())
mod = 10**9+7
d = {}

zero = 0
for i in range(n):
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        zero += 1
    else:
        g = math.gcd(a,b)
        a //= g
        b //= g
        if b < 0:
            a = -a
            b = -b
        if b == 0 and a == -1:
            a = 1
        if a > 0:
            if (a,b) in d:
                d[(a,b)][0] += 1
            else:
                d[(a,b)] = [1,0]
        else:
            if (b,-a) in d:
                d[(b,-a)][1] += 1
            else:
                d[(b,-a)] = [0,1]
ans = 1
for (a,b),(c,d) in d.items():
    count = (pow(2,c,mod)+pow(2,d,mod)-1)%mod
    ans *= count
    ans %= mod


print((ans+zero-1)%mod)
n = int(input())

length=0
tmp = n
while True:
  if tmp-26**length < 26**(length+1):
    break
  length+=1
  tmp-=26**length

s = ['a']*(length+1)
maps = {'1':'a',
       '2':'b',
       '3':'c',
       '4':'d',
       '5':'e',
       '6':'f',
       '7':'g',
       '8':'h',
       '9':'i',
       '10':'j',
       '11':'k',
       '12':'l',
       '13':'m',
       '14':'n',
       '15':'o',
       '16':'p',
       '17':'q',
       '18':'r',
       '19':'s',
       '20':'t',
       '21':'u',
       '22':'v',
       '23':'w',
       '24':'x',
       '25':'y',
       '26':'z',
       }

keta = 1

while True:
  s[len(s)-keta] = maps[str(n%26)]
  n //= 26
  keta+=1
  if n==0:
    break
print(''.join(s))
  

### FIXED CODE ###

n = int(input())
s=''
while n!=0:
  n-=1
  tmp=n%26
  s=chr(96+tmp+1)+s
  n//=26
print(s)
import random

X,N = input().split()
X,N = int(X),int(N)

P = input().split()
P = [int(c) for c in P]

if len(P) == 0:
    print(X)
else:
    L = list(range(max(0,X-N),min(101,X+N)))

    for i in range(N):
        if P[i] in L:
            L.remove(P[i])

    while len(L) > 2:
        rand = random.randint(1,len(L)-2)
        if L[rand] == X:
            break
        elif L[rand] > X:
            L = L[0:rand+1]
        else:
            L = L[rand:len(P)]

    if X in L:
        print(X)
    else:
        if abs(L[0]-X) > abs(L[1]-X):
            print(L[1])
        else:
            print(L[0])

### FIXED CODE ###

import random

X,N = input().split()
X,N = int(X),int(N)

P = input().split()
P = [int(c) for c in P]

if len(P) == 0:
    print(X)    
else:
    L = list(range(max(0,X-N),min(102,X+N)))

    if X+N <= 101:
        L.append(X+N)

    for i in range(N):
        if P[i] in L:
            L.remove(P[i])

    while len(L) > 2:
        rand = random.randint(1,len(L)-2)
        if L[rand] == X:
            break
        elif L[rand] > X:
            L = L[0:rand+1]
        else:
            L = L[rand:len(L)]

    if X in L:
        print(X)
    elif len(L) == 1:
        print(L[0])
    else:
        if abs(L[0]-X) > abs(L[1]-X):
            print(L[1])
        else:
            print(L[0])
n = int(input())
a = list(map(int, input().split()))
m = []
for i in range(n - 2):
    if a[i] < a[i + 1] < a[i + 2] or a[i + 2] < a[i + 1] < a[i]:
        m.append(0)
    if a[i + 1] < a[i] < a[i + 2] or a[i + 1] < a[i + 2] < a[i]:
        m.append(1)
    if a[i] < a[i + 2] < a[i + 1] or a[i + 2] < a[i] < a[i + 3]:
        m.append(-1)

s = sum(abs(a[i] - a[i + 1]) for i in range(n - 1))

print(s - abs(a[0] - a[1]))
for i in m:
    if i == 0:
        print(s)
    elif i > 0:
        print(s - 2 * abs(a[i - 1] - a[i]))
    elif i < 0:
        print(s - 2 * abs(a[i] - a[i + 1]))
print(s - abs(a[n - 1] - a[n]))


### FIXED CODE ###

n = int(input())
a = [0] + list(map(int, input().split())) + [0]
m = []
for i in range(n):
    if a[i] <= a[i + 1] <= a[i + 2] or a[i + 2] <= a[i + 1] <= a[i]:
        m.append(0)
    elif a[i] <= a[i + 2] <= a[i + 1] or a[i + 1] <= a[i + 2] <= a[i]:
        m.append(1)
    elif a[i + 1] <= a[i] <= a[i + 2] or a[i + 2] <= a[i] <= a[i + 1]:
        m.append(-1)

s = sum(abs(a[i] - a[i + 1]) for i in range(n + 1))

for i, m0 in enumerate(m):
    if m0 == 0:
        print(s)
    elif m0 == 1:
        print(s - 2 * abs(a[i + 1] - a[i + 2]))
    elif m0 == -1:
        print(s - 2 * abs(a[i] - a[i + 1]))
n = int(input())
i = 0

card_S = []
card_H = []
card_C = []
card_D = []

while i < n:
	mark, num = input().split()
	if mark == S:
		card_S.append(int(num))
	elif mark == H:
		card_H.append(int(num))
	elif mark == C:
		card_C.append(int(num))
	else:
		card_D.append(int(num))
	i += 1

i = 1
while i < 14:
	if not(i in card_S):
		print("S " + str(i))

i = 1
while i < 14:
	if not(i in card_H):
		print("H " + str(i))

i = 1
while i < 14:
	if not(i in card_C):
		print("C " + str(i))

i = 1
while i < 14:
	if not(i in card_D):
		print("D " + str(i))


### FIXED CODE ###

n = int(input())
i = 0

card_S = []
card_H = []
card_C = []
card_D = []

while i < n:
	mark, num = input().split()
	if mark == "S":
		card_S.append(int(num))
	elif mark == "H":
		card_H.append(int(num))
	elif mark == "C":
		card_C.append(int(num))
	else:
		card_D.append(int(num))
	i += 1

i = 1
while i < 14:
	if not(i in card_S):
		print("S " + str(i))
	i += 1

i = 1
while i < 14:
	if not(i in card_H):
		print("H " + str(i))
	i += 1

i = 1
while i < 14:
	if not(i in card_C):
		print("C " + str(i))
	i += 1

i = 1
while i < 14:
	if not(i in card_D):
		print("D " + str(i))
	i += 1
import collections

n = int(input())
arr = list(map(int,input().split()))
cnt = collectioms.Counter(arr)
total = 0

for key in cnt.keys():
  total += cnt[key] * (cnt[key] - 1)//2
  
for i in range(n):
  tmp = total
  tmp -= cnt[arr[i]]*(cnt[arr[i]] - 1)//2
  tmp += (cnt[arr[i]] - 1)*(cnt[arr[i]] - 2)//2
  print(tmp)

### FIXED CODE ###

import collections

n = int(input())
arr = list(map(int,input().split()))
cnt = collections.Counter(arr)
total = 0

for key in cnt.keys():
  total += cnt[key] * (cnt[key] - 1)//2
  
for i in range(n):
  tmp = total
  tmp -= cnt[arr[i]]*(cnt[arr[i]] - 1)//2
  tmp += (cnt[arr[i]] - 1)*(cnt[arr[i]] - 2)//2
  print(tmp)
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0
d = 0
i = 0
while d <= a[1]:
  d += b[i]
  c += 1
  i += 1
print(c)

### FIXED CODE ###

a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 1
d = 0
for i in b:
  d += i
  if d <= a[1]:
    c += 1
print(c)
inp = input().split(" ")
N,A,B = inp
if (N%(A+B)) <= A:
  print((N/(A+B))*A + (N%(A+B)))
else:
  print((N/(A+B))*A + A)

### FIXED CODE ###

inp = input().split(" ")
N, A, B = (int(inp[0]), int(inp[1]), int(inp[2]))
if int(N % (A + B)) <= A:
    print(int(N / (A + B)) * A + int(N % (A + B)))
else:
    print(int(N / (A + B)) * A + A)
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
i, j = 0, 0
time = 0
while time <= k:
    if i < n and A[i] < B[j]:
        time += A[i]
        i += 1
    elif j < m:
        time += B[j]
        j += 1
    if i >= n and j >= m:
        break
ans = i + j
if time > k:
    ans -= 1
print(ans)

### FIXED CODE ###

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_cum, B_cum = [0], [0]
for i, a in enumerate(A):
    A_cum.append(A_cum[i] + a)
for i in range(m):
    B_cum.append(B_cum[i] + B[i])

ans = 0
best = m
for i in range(n+1):
    a_time = A_cum[i]
    for j in range(best, -1, -1):
        if B_cum[j] <= k - a_time:
            ans = max(ans, i + j)
            break
    best = j
print(ans)
s = int(input())
s = s % 60
n = s //60 % 60
h = s //60 //60

print("{0}:(1):(2)",format (h,m,s)

### FIXED CODE ###

S = int(input())

s = S % 60
m = S // 60 % 60
h = S // 60 // 60

print("{0}:{1}:{2}".format (h,m,s))
a, b = list(map(int, input()))
print('Yay!') if a<=8 and b<=8 else print(':(')

### FIXED CODE ###

a, b = list(map(int, input().split()))
print('Yay!') if a<=8 and b<=8 else print(':(')
N = int( input() )
T = [ int( input() ) for _ in range(N) ]


# 最小公倍数を求めたい
# aとbの最小公倍数 = a*b / aとbの最大公約数
# 最大公約数 (Greatest Common Divisor)
def GCD( a, b ):
    if b == 0: return a
    return GCD(b, a%b)

# 最小公倍数 (Least Common Multiple)
def LCM( a, b ):
    return a*b // GCD(a,b)


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

### FIXED CODE ###

import fractions
import functools

N = int( input() )
T = [ int(input()) for _ in range(N) ]

def lcm( x, y ):
    return x * y // fractions.gcd( x, y )

def lcm_list( numbers ):
    return functools.reduce( lcm, numbers, 1 )

if N == 1: print( T[0] )
else     : print( lcm_list(T) )
n, m = map(int, input().split())
p, s = zip(* [input().split() for _ in range(m)])

ac_dict = {str(i): False for i in range(1, n + 1)}
wa_dict = {str(i): 0 for i in range(1, n + 1)}
ac_num = 0
wa_num = 0
for p_i, s_i in zip(p, s):
    if ac_dict[p_i] == False:
        if s_i == 'AC':
            ac_num += 1
            wa_num += wa_dict[p_i]
            ac_dict[p_i] = True
        elif s_i == 'WA':
            wa_dict[p_i] += 1
print('{} {}'.format(ac_num, wa_num))


### FIXED CODE ###

n, m = map(int, input().split())
if m > 0:
    p, s = zip(* [input().split() for _ in range(m)])
else:
    p = []
    s = []

ac_dict = {str(i): False for i in range(1, n + 1)}
wa_dict = {str(i): 0 for i in range(1, n + 1)}
ac_num = 0
wa_num = 0
for p_i, s_i in zip(p, s):
    if ac_dict[p_i] == False:
        if s_i == 'AC':
            ac_num += 1
            wa_num += wa_dict[p_i]
            ac_dict[p_i] = True
        elif s_i == 'WA':
            wa_dict[p_i] += 1
print('{} {}'.format(ac_num, wa_num))
K=input()
A=input()
B=input()

for i in range(A,B)
i %= K
if i==0:
  print("OK")

### FIXED CODE ###

K=int(input())
A,B=map(int,input().split())

yn=0
for i in range(A,B+1,1):
    if (i % K) == 0:
        print("OK")
        yn=1
        break
if yn==0:
    print("NG")
n = map(int,input())

def basen(n):
    a = []
    while n!= 0:
        r = n % 2
        if (r < 0):
            r += 2

        n = (n - r)//(-2)
        a.append(r)
        if(a == " "):
            a.append(0)
        reversed(a)
    return a
 
print(basen(n))

### FIXED CODE ###

n = int(input())

def basen(n):
    a = []
    while n!= 0:
        r = n % 2
        if (r < 0):
            r += 2

        n = (n - r)//(-2)
        a.append(r)
    if a == []:
        a.append(0)
    a.reverse()
    return "".join(map(str,a))
print(basen(n))
count=input()
list=int(input()).rstrip().split(" ")
list_1=[int(s) for s in list]
list2= sorted(list_1)
sa=(int(list2[0])-int(list2[int(count)-1]))
if sa<0:
  print(-1*int(sa))
else:
  print(int(sa))

### FIXED CODE ###

count=input()
list=input().rstrip().split(" ")
list_1=[int(s) for s in list]
list2= sorted(list_1)
sa=(int(list2[0])-int(list2[int(count)-1]))
if sa<0:
  print(-1*int(sa))
else:
  print(int(sa))
def rec(h, place):
    if h[place] != -1:
        return h[place]

    h[place] = min(rec(h,place-1) + abs(l[place-1] - l[place]) 
    ,rec(h,place-2) + abs(l[place-2] - l[place]))

    return h[place]
n = int(input())

t_l = input().split()
l = []
for i in t_l:
    l.append(int(i))

h = [-1 for i in l]

h[0] = 0
h[1] = abs(l[0] - l[1])

rec(h,len(l)-1)

print(h[len(l)-1])





### FIXED CODE ###

n = int(input())

t_l = input().split()
l = []
for i in t_l:
    l.append(int(i))

h = [-1 for i in l]

h[0] = 0
h[1] = abs(l[0] - l[1])

i = 2
while i < len(l):
    h[i] = min(h[i-1] + abs(l[i-1] - l[i]), 
    h[i-2] + abs(l[i-2] -l[i]))
    i+=1

print(h[len(l)-1])
while True:
    x=input().split
    y=[int(x[0]),int(x[1])]
    if y[0]==0 and y[1]==0:
        break
    if y[0]<y[1]:
        print("{} {}".format(y[0],y[1]))
    if y[0]>y[1]:
        print("{} {}".format(y[1],y[0]))


### FIXED CODE ###

while True:
    x=input().split()
    y=[int(x[0]),int(x[1])]
    if y[0]==0 and y[1]==0:
        break
    elif y[0]<y[1]:
        print("{} {}".format(y[0],y[1]))
    elif y[0]>y[1]:
        print("{} {}".format(y[1],y[0]))
    else:
        print("{} {}".format(y[0],y[1]))
A,B,C,K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A+B:
    print(A)
else:
    print(2A+B-K) 


### FIXED CODE ###

A,B,C,K = map(int,input().split())
if A >= K:
    print(K)
elif (A+B)>=K:
    print(A)
else:
    print(A*2+B-K)
bound_num, line_length = map(int, input().split())
l = list(map(int, input().split()))

bound = 1
length_sum = 0
for i in range(bound_num + 1):
    if(length_sum + l[i] <= line_length):
        bound += 1
    else:
        print(bound)
        exit()
    length_sum += l[i]


### FIXED CODE ###

bound_num, line_length = map(int, input().split())
l = list(map(int, input().split()))

bound = 1
length_sum = 0
for i in range(bound_num + 1):
    if(i == bound_num):
        print(len(l)+1)
        exit()
    if(length_sum + l[i] <= line_length):
        bound += 1
    else:
        print(bound)
        exit()
    length_sum += l[i]