Harryxun/stf_run huggingface dataset:
coins = [10,50,100,500]

while 1:
    cost = int(raw_input())
    if cost == 0: break
    c = map(int,raw_input().split())
    num = sum(c)

    mn = num
    ans = [0,0,0,0]
    for i in range(c[0]+1):
        for j in range(c[1]+1):
            for k in range(c[2]+1):
                for l in range(c[3]+1):
                    pay = 10*i+50*j+100*k+500*l
                    change = pay-cost
                    if change < 0: continue

                    tmp = [0,0,0,0]
                    for m in range(3,-1,-1):
                        while change-coins[m] >= 0:
                            change -= coins[m]
                            tmp[m] += 1
                    
                    for c1,c2 in zip([i,j,k,l],tmp):
                        if c1 > 0 and c2 > 0: break
                    else:
                        if num - (i+j+k+l) + sum(tmp) < mn:
                            mn = num - (i+j+k+l) + sum(tmp)
                            ans = [i,j,k,l]

    for ci,ki in zip(coins,ans):
        if ki == 0: continue
        print ci,ki
    print  

### FIXED CODE ###

coins = (10,50,100,500)
isfirst = True
while 1:
    cost = int(raw_input())
    if cost == 0: break
    if not isfirst: print
    have = map(int,raw_input().split())

    budget = sum(i*j for i,j in zip(coins,have))
    change = budget-cost

    ret = [0]*4
    for i in reversed(range(4)):
        c = change/coins[i]
        ret[i] = c
        change -= c*coins[i]

    for i in range(4):
        if have[i]-ret[i] <= 0: continue
        print coins[i],have[i]-ret[i]

    isfirst = False
n = int(input())
if n % 2 == 1:
  print(0)
else:
  m = n // 2
  l = 1
  ans = 0
  while 5**l <= m:
    ans += m//(5**l)
    l += 1
print(ans)

### FIXED CODE ###

n = int(input())
if n % 2 == 1:
  print(0)
elif n == 0:
  print(0)
else:
  m = n // 2
  l = 1
  ans = 0
  while 5**l <= m:
    ans += m//(5**l)
    l += 1
  print(ans)
import math

n, x = [int(i) for i in input().split()]
point = list(map(int, input().split()))
dif = []

if(len(point) == 1):
  ans = abs(point[0] - x)
else:
  gcd = abs(point[0] - x)
  for i in range(len(point) - 1):
    dif.append(point[i+1] - point[i])
    gcd = math.gcd(gcd, dif[i])
  ans = gcd
print(ans)
    

### FIXED CODE ###

def gcd(a, b):
  if a < b:
    a, b = b, a
  if b == 0:
    return a
  c = a % b
  return gcd(b, c)
n, x = [int(i) for i in input().split()]
point = list(map(int, input().split()))
dif = []

if(len(point) == 1):
  ans = abs(point[0] - x)
else:
  gcd_now = abs(point[0] - x)
  for i in range(len(point) - 1):
    dif.append(abs(point[i+1] - point[i]))
    gcd_now = gcd(gcd_now, dif[i])
  ans = gcd_now
print(ans)
import sys
from collections import Counter

sys.set_coroutine_wrapper(2500)


def paint(field, i, j, b, f, moves={(-1, 0), (1, 0), (0, 1), (0, -1)}):
    fij = field[i][j]
    if fij & f:
        return
    if fij & 4 and not fij & b:
        return
    field[i][j] |= b | f
    for di, dj in moves:
        ni = i + di
        nj = j + dj
        if nj < 0 or w <= nj or ni < 0 or h <= ni:
            continue
        paint(field, ni, nj, b, f)


buf = []
chardict = {'.': 0, 'W': 5, 'B': 6}
while True:
    w, h = map(int, input().split())
    if w == 0:
        break
    field = []
    init_w, init_b = 0, 0
    for _ in range(h):
        line = input().strip()
        init_w += line.count('W')
        init_b += line.count('B')
        field.append([chardict[c] for c in line])
    for i in range(h):
        for j in range(w):
            fij = field[i][j]
            if fij & 4 and not fij & 24:
                paint(field, i, j, fij & 3, (fij & 3) << 3)
    result = Counter(b & 3 for row in field for b in row)
    print(result[2] - init_b, result[1] - init_w)

### FIXED CODE ###

import sys
from collections import Counter

sys.setrecursionlimit(2502)


def paint(field, i, j, b, f, moves={(-1, 0), (1, 0), (0, 1), (0, -1)}):
    fij = field[i][j]
    if fij & f:
        return
    if fij & 4 and not fij & b:
        return
    field[i][j] |= b | f
    for di, dj in moves:
        ni = i + di
        nj = j + dj
        if nj < 0 or w <= nj or ni < 0 or h <= ni:
            continue
        paint(field, ni, nj, b, f)


buf = []
chardict = {'.': 0, 'W': 5, 'B': 6}
while True:
    w, h = map(int, input().split())
    if w == 0:
        break
    field = [[chardict[c] for c in input()] for _ in range(h)]
    for i in range(h):
        for j in range(w):
            fij = field[i][j]
            if fij & 4 and not fij & 24:
                paint(field, i, j, fij & 3, (fij & 3) << 3)
    result = Counter(b & 7 for row in field for b in row)
    buf.append('{} {}'.format(result[2], result[1]))
print('\n'.join(buf))
N, A, B, C = map(int, input().split())
l = list(int(input()) for i in range(n))
inf = 10**9

    def dfs(cur,a,b,c):
        if cur == N:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf
        ret0 = dfs(cur+1,a,b,c)
        ret1 = dfs(cur+1,a+l[cur],b,c) + 10
        ret2 = dfs(cur+1,a,b+l[cur],c) + 10
        ret3 = dfs(cur+1,a,b,c+l[cur]) + 10
    
        return min(ret0,ret1,ret2,ret3)
 
print(dfs(0,0,0,0))

### FIXED CODE ###

N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
inf = 10**9
def dfs(cur,a,b,c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c) + 10
    ret2 = dfs(cur+1,a,b+l[cur],c) + 10
    ret3 = dfs(cur+1,a,b,c+l[cur]) + 10
    
    return min(ret0,ret1,ret2,ret3)
 
print(dfs(0,0,0,0))
a,b,c=map(int,input().split())
print(a-c,b if a>c else 0,b-(k-a) elif b>k-a else 0,0)

### FIXED CODE ###

a,b,c=map(int,input().split())
print(a-c,b) if a>=c else print(0,b-(c-a)) if b>=c-a else print(0,0)
inp=input().split(" ")
N=int(inp[0])
A=int(inp[1])
x=list(map(int, input().split(" ")))
x=[0]+x
X=max(x)
dp=[[[0 for i in range(N*X+1)] for j in range(N+1)] for k in range(N+1)]
for j in range(N+1):
    for k in range(N+1):
     for s in range(N*X+1):
        if j==0 and k==0 and s==0:
            dp[j][k][s]=1
        elif j>=1 and s<x[j]:
            dp[j][k][s]=dp[j-1][k][s]
        elif j>=1 and k>=1 and s>=x[j]:
            dp[j][k][s]=dp[j-1][k][s]+dp[j-1][k-1][s-x[j]]
        else:
            dp[j][k][s]=0
print(sum(dp[N][k][k*A] for k in range(1,N+1)))



### FIXED CODE ###

inp=input().split(" ")
N=int(inp[0])
A=int(inp[1])
x=list(map(int, input().split(" ")))
y=[x[i]-A for i in range(N)]
y=[0]+y
X=max(x)
dp=[[0 for i in range(2*N*X+1)] for j in range(N+1)]
for j in range(N+1):
    for t in range(2*N*X+1):
        if j==0 and t==N*X:
            dp[j][t]=1
        elif j>=1 and (t-y[j]<0 or t-y[j]>2*X*N):
            dp[j][t]=dp[j-1][t]
        elif j>=1 and 0<=t-y[j] and t-y[j]<=2*N*X:
            dp[j][t]=dp[j-1][t]+dp[j-1][t-y[j]]
        else:
            dp[j][t]=0
print(dp[N][N*X]-1)
a,b = map(int,input().split())
s = input()
s1,s2 = s.split("-")

if s.count("-") ==1:
  if a == len(s1) and b == len(s2):
    print("Yes")
  else:
    print("No")
  

### FIXED CODE ###

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

 
if s.count("-") ==1:
  s1,s2 = s.split("-")
  if a == len(s1) and b == len(s2):
    print("Yes")
  else:
    print("No")
 
else:
  print("No")
import numpy as np
n, m = list(map(int, input().split()))
xs = list(map(int, input().split()))

if n > m:
    print(0)
else:
    xs.sort()
    diffs = [xs[i] - xs[i-1] for i in range(1, m)]
    indxs = list(np.array(diffs).argsort()[::-1][:n-1])
    indxs.sort()
    ans = sum(diffs[0:indxs[0]]) + sum(diffs[indxs[-1]+1:])
    for i in range(len(indxs)-1):
        ans += sum(diffs[indxs[i]+1:indxs[i+1]])
    print(ans)

### FIXED CODE ###

import numpy as np
n, m = list(map(int, input().split()))
xs = list(map(int, input().split()))

if n >= m:
    print(0)
else:
    xs.sort()
    diffs = [xs[i] - xs[i-1] for i in range(1, m)]
    if n == 1:
        ans = sum(diffs)
    else:
        indxs = list(np.array(diffs).argsort()[::-1][:n-1])
        indxs.sort()
        ans = sum(diffs[0:indxs[0]])
        if indxs[-1]+1 < len(diffs):
            ans += sum(diffs[indxs[-1]+1:])
        for i in range(len(indxs)-1):
            ans += sum(diffs[indxs[i]+1:indxs[i+1]])
    print(ans)
%%time
N,M=map(int, input().split())
P=[]
S=[]
for i in range(M):
    p,s=input().split()
    P.append(int(p))
    S.append(s)


import numpy as np
P=np.array(P)
S=np.array(S)

if M>0:
    ans=P[S=="AC"]

    wa=0
    ac=[]
    for i in range(M):
        if P[i] in ans and P[i] not in ac and S[i]=="WA":
            wa+=1
        else:
            ac.append(P[i])
    
    
    print(len(ans),wa)
else:
    print(0,0)

### FIXED CODE ###

N,M=map(int,input().split())
AC={}
WA={}
for i in range(M):
    a,b=input().split()
    if not(a in AC.keys()):
        if b=="AC":
            AC[a]=1
        else:
            if a in WA.keys():
                WA[a]+=1
            else:
                WA[a]=1
y=0
for i in AC.keys():
    if i in WA.keys():
        y+=WA[i]
print(sum(AC.values()),y)
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] s = new int[n];
		int sum = 0;
		for (int i = 0; i<n; i++) {
			s[i] = sc.nextInt();
			sum += s[i];
			}
		Arrays.sort(s);

		if (sum%10 != 0) {System.out.println(sum);}
		else {
			for (int i=0; i<n;i++) {
				if (s[i]%10!=0) {
					System.out.println(sum-s[i]);
					return;
				}
			}
		}
		System.out.println(0);


	}
}

### FIXED CODE ###

n = int(input())
s = sorted([int(input()) for i in range(n)])

ans = sum(s)

if ans % 10 != 0:
    print(ans)
    exit()
else:
    for i in range(n):
        if s[i] % 10 != 0:
            print(ans-s[i])
            exit()

    print(0)
スコード 

Copy
Copy
def main():
  S = input()
  while len(S)>=5:
    if len(S)>=7 and S[-7:]=="dreamer":
      S = S[:-7]
      continue
    
    elif len(S)>=6 and S[-6:]=="eraser":
      S = S[:-6]
      continue
    elif S[-5:]=="dream" or S[-5:]=="erase":
      S = S[:-5]
      continue
    else:
      break
  if len(S)==0:
    print('Yes')
  else:
    print('No')
    
main()

### FIXED CODE ###

def main():
  S = input()
  while len(S)>=5:
    if len(S)>=7 and S[-7:]=="dreamer":
      S = S[:-7]
      continue
    
    elif len(S)>=6 and S[-6:]=="eraser":
      S = S[:-6]
      continue
    elif S[-5:]=="dream" or S[-5:]=="erase":
      S = S[:-5]
      continue
    else:
      break
  if len(S)==0:
    print('YES')
  else:
    print('NO')
    
main()
from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
v = [[] for _ in [0] * 10**5]
q = []
for a, b in t:
    v[a - 1] += b,
z = 0
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    z += -heappop(q)
print(z)

### FIXED CODE ###

from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
q = [0] * 10**5
v = [[] for _ in q]
for a, b in t:
    v[a - 1] += b,
z = 0
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    z += -heappop(q)
print(z)
H,W=map(int,input().split())
#G=[[-1 if input() else 0 for i in range(W)] for _ in range(H)]

'''リストver
dp=[[-1]*W for _ in range(H)]
for i in range(H):
    s=input()
    for j in range(W):
        if s[j]=='#':
            dp[i][j]=0
dp[0][0]=1
'''

#numpy ver
import numpy as np
dp=np.array([list(input()) for _ in range(H)])

dp=np.where(dp=='.',-1,dp)
dp=np.where(dp=='#',0,dp)

dp=dp.astype(int)
dp[0][0]=1

for i in range(H):
    for j in range(W):
        if dp[i][j]==-1:
            if i>0 and j>0:
                dp[i][j]=dp[i-1][j]+dp[i][j-1]
            elif i>=1 and j==0:
                dp[i][j]=dp[i-1][j]
            elif i==0 and j>=1:
                dp[i][j]=dp[i][j-1]

print(dp[H-1][W-1])

### FIXED CODE ###

H,W=map(int,input().split())
#G=[[-1 if input() else 0 for i in range(W)] for _ in range(H)]
MOD=10**9+7
#リストver
dp=[[-1]*W for _ in range(H)]
for i in range(H):
    s=input()
    for j in range(W):
        if s[j]=='#':
            dp[i][j]=0
dp[0][0]=1

'''
#numpy ver
import numpy as np
dp=np.array([list(input()) for _ in range(H)])

dp=np.where(dp=='.',-1,dp)
dp=np.where(dp=='#',0,dp)

dp[0][0]=1
'''
for i in range(H):
    for j in range(W):
        if dp[i][j]==-1:
            if i>0 and j>0:
                dp[i][j]=dp[i-1][j]+dp[i][j-1]
            elif i>=1 and j==0:
                dp[i][j]=dp[i-1][j]
            elif i==0 and j>=1:
                dp[i][j]=dp[i][j-1]

print(dp[H-1][W-1]%MOD)
N = int(input())
def fract(n):
    if n == 0:
        return 1
    elif n == 1:
        return n
    return n * fract(n-1)

res = fract(N) % 1000000007
print(res)

### FIXED CODE ###

N = int(input())
fact = 1
for integer in range(1,N+1):
    fact = fact * integer % 1000000007
print(fact)
N = int(input())
C0, C1, C2, C3 = 0, 0, 0, 0
for i in range(N):
    Si = input()
    if Si == 'AC':
        C0 += 1
 
    elif Si == 'WA':
        C1  += 1
 
    elif Si == 'TLE':
        C2 += 1
 
    else:
        C3 += 1
 
print('AC x ' + str(C0))
print('WA x ' + str(C1))
print('TLE x ' + str(C2))
print('RE x ' + str(C3))


### FIXED CODE ###

n = int(input())

if n % 1000 == 0:
  print(0)
else:
  print(1000-(n%1000))
s = input()


for i in range(len(s)):
  if s[i] == "1":
    s[i] = "9"
  else:
    s[i] = "1"
    
print(s)

### FIXED CODE ###

s = input()

ans = ""
for i in range(len(s)):
  if s[i] == "1":
    ans  += "9"
  else:
    ans += "1"
    
print(ans)
input()
print('Four' if len(set(map(int, input().split()))) else 'Three')

### FIXED CODE ###

n = int(input())
a = set(map(str, input().split()))
print('Three' if len(a) == 3 else 'Four')
a,b = input().split()

S = int(a+b)

if math.sqrt(S).is_integer() == True:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a,b = input().split()
import math
S = int(a+b)

if math.sqrt(S).is_integer() == True:
    print("Yes")
else:
    print("No")
n=int(input())
x=list(map(int,input().split()))
s=sorted(x)
p,q=s[n//2],s[n//2+1]
for i in x:
  if i<=p:
    print(q)
  else:
    print(p)

### FIXED CODE ###

n=int(input())
x=list(map(int,input().split()))
s=sorted(x)
p,q=s[n//2-1],s[n//2]
for i in x:
  if i<=p:
    print(q)
  else:
    print(p)
s = input()
k = int(input())
ans = 0
cnt = 0
if len(s) == 1:
    ans = k//2
else:
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            cnt += 1
        else:
            ans += ((cnt+1)//2)*k
            cnt = 0
    ans += ((cnt+1)//2)*k
    if s[0] == s[-1]:
        if s[0] != s[1] and s[-1] != s[-2]:
            ans += k - 1
        if len(s) > 2 and s[0] == s[1] == s[2] or s[-1] == s[-2] == s[-3]:
            ans += 1
print(ans)

### FIXED CODE ###

s = input()
k = int(input())
ans = 0
cnt = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        cnt += 1
    else:
        ans += (cnt//2)*k
        cnt = 1
ans += ((cnt)//2)*k
if cnt == len(s):
    ans = len(s)*k//2
elif s[0] == s[-1]:
    l = 1
    r = 1
    for i in range(len(s)-1):
        if s[i] == s[i+1]:
            l += 1
        else:
            break
    for i in range(len(s)-1,0,-1):
        if s[i] == s[i-1]:
            r += 1
        else:
            break
    ans -= (l//2 + r//2 - ((l+r)//2))*(k-1)
print(ans)
n=int(input())
x= list()
for i in range n:
  x.append(input())
print("AC x", x.count("AC"))
print("WA x", x.count("WA"))
print("TLE x", x.count("TLE"))
print("RE x", x.count("RE"))

### FIXED CODE ###

n=int(input())
S = []
for _ in range(n):
    S.append(input())
print("AC x", S.count("AC"))
print("WA x", S.count("WA"))
print("TLE x", S.count("TLE"))
print("RE x", S.count("RE"))
n=int(input())
l=list(map(int,input().split()))

from fractions import gcd 

x =l[0]
for i in range(1,n):
    x=int(x * l[i] / gcd(x, l[i]))

y=0
for j in range(n):
    y+=(x-1)%l[j]

print(y)

### FIXED CODE ###

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

from fractions import gcd 

x =1
for i in l:
    x = x * i // gcd(x, i)

y=0
for j in range(n):
    y+=(x-1)%l[j]

print(int(y))
N = int(input())
A = int(input())
B = int(input())

if N == 1:
    print("Hello World")
else:
    print(A+B)

### FIXED CODE ###

N = int(input())

if N == 1:
    print("Hello World")
else:
    A = int(input())
    B = int(input())
    print(A+B)
n, k = map(int, input().split())
p_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
pc_list = []
max_score = -10**9

for m in range(n):
    score = 0
    num = p_list[m] - 1
    for l in range(k):
        score += c_list[num]
        num = p_list[num] - 1
        
        if score > max_score:
            max_score = score
 
print(max_score)

### FIXED CODE ###

weather = input()
rainy_count = 0
max_rainy_count = 0

for i in range(3):
  if weather[i] == "R":
    rainy_count += 1
    if max_rainy_count < rainy_count:
        max_rainy_count = rainy_count
    
  else:
    rainy_count = 0
            
print(max_rainy_count)
ans=''
def dfs(a,b,c,t):
    global ans
    if a<0 or b<0 or c<0:
        return False
    if t==N:
        return True
    if s[t]=='AB':
        if dfs(a-1,b+1,c,t+1):
            ans+='B'
            return True
        elif dfs(a+1,b-1,c,t+1):
            ans+='A'
            return True
    if s[t]=='BC':
        if dfs(a,b-1,c+1,t+1):
            ans+='C'
            return True
        elif dfs(a,b+1,c-1,t+1):
            ans+='B'
            return True
    if s[t]=='AC':
        if dfs(a+1,b,c-1,t+1):
            ans+='A'
            return True
        if dfs(a-1,b,c+1,t+1):
            ans+='C'
            return True
    return False

N,A,B,C=map(int,input().split())
s=[input() for i in range(N)]

if dfs(A,B,C,0):
    print('Yes')
    print(*ans[::-1],sep='\n')
else:
    print('No')

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
ans=''
def dfs(a,b,c,t):
    global ans
    if a<0 or b<0 or c<0:
        return False
    if t==N:
        return True
    if s[t]=='AB':
        if dfs(a-1,b+1,c,t+1):
            ans+='B'
            return True
        elif dfs(a+1,b-1,c,t+1):
            ans+='A'
            return True
    if s[t]=='BC':
        if dfs(a,b-1,c+1,t+1):
            ans+='C'
            return True
        elif dfs(a,b+1,c-1,t+1):
            ans+='B'
            return True
    if s[t]=='AC':
        if dfs(a+1,b,c-1,t+1):
            ans+='A'
            return True
        if dfs(a-1,b,c+1,t+1):
            ans+='C'
            return True
    return False

N,A,B,C=map(int,input().split())
s=[input() for i in range(N)]

if dfs(A,B,C,0):
    print('Yes')
    print(*ans[::-1],sep='\n')
else:
    print('No')
import math
a,b,c,d = [int(i) for i in input().split()]

l= (c * d) // math.gcd(c, d)

s=(b-a-(b//c-((a-1)//c + 1))-(b//d - ((a-1)//d + 1))+(b//cd-((a-1)//cd + 1)))
print(s)


### FIXED CODE ###

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
abcd = input().split(" ")
a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])
cd = lcm(c, d)
print(b-a-(b//c-((a-1)//c + 1))-(b//d - ((a-1)//d + 1))+(b//cd-((a-1)//cd + 1)))
from collections import defaultdict

v, e = map(int, input().split())

links = [defaultdict(int) for _ in range(v)]
bests = [None] * (1 << v)

for _ in range(e):
    s, t, d = map(int, input().split())
    links[s][t] = max(links[s][t], d)

bests[0] = {0: 0}

for visited, best in enumerate(bests):
    if best is None:
        continue
    for last, cost in best.items():
        for t, d in links[last].items():
            new_visited = visited | (1 << t)
            if visited == new_visited:
                continue
            new_best = bests[new_visited]
            if new_best is None:
                bests[new_visited] = defaultdict(lambda: 15001, [(t, cost + d)])
            else:
                new_best[t] = min(new_best[t], cost + d)

print(bests[-1][0])

### FIXED CODE ###

def warshall_floyd(n, dists):
    prev = [t.copy() for t in dists]

    for k in range(n):
        current = [[0] * n for _ in range(n)]
        prev_k = prev[k]
        for i in range(n):
            prev_i, current_i = prev[i], current[i]
            prev_i_k = prev_i[k]
            for j in range(n):
                current_i[j] = min(prev_i[j], prev_i_k + prev_k[j])
        prev = current

    return prev


def solve(n, links, total_d, odd_vertices):
    if not odd_vertices:
        return total_d

    d_table = warshall_floyd(n, links)
    d_table = [[d for oj, d in enumerate(d_table[oi]) if oj in odd_vertices] for ni, oi in enumerate(odd_vertices)]
    ndt = len(d_table)
    bit_dict = {1 << i: i for i in range(ndt)}

    def minimum_pair(remains):
        if not remains:
            return 0
        b = remains & -remains
        remains ^= b
        i = bit_dict[b]
        return min(minimum_pair(remains ^ (1 << j)) + d_table[i][j] for j in range(ndt) if remains & (1 << j))

    return total_d + minimum_pair((1 << ndt) - 1)


v, e = map(int, input().split())

dists = [[float('inf')] * v for _ in range(v)]
for i in range(v):
    dists[i][i] = 0
odd_vertices = [0] * v
total_d = 0

for _ in range(e):
    s, t, d = map(int, input().split())
    dists[s][t] = min(dists[s][t], d)
    dists[t][s] = min(dists[t][s], d)
    odd_vertices[s] ^= 1
    odd_vertices[t] ^= 1
    total_d += d

print(solve(v, dists, total_d, [i for i, v in enumerate(odd_vertices) if v]))
s=input()
if s == Sunny:
  print(Cloudy)
if s== Cloudy:
  print(Rainy)
if s== Rainy:
  print(Sunny)

### FIXED CODE ###

s=input()
if s == 'Sunny':
  print('Cloudy')
if s== 'Cloudy':
  print('Rainy')
if s== 'Rainy':
  print('Sunny')
n,m = map(int,input().split())
l_n =list(list(map(int,input().split())) for i in range(n))
l_m =list(list(map(int,input().split())) for i in range(m))
q = 1000000
for i in range(n):
  for t in range(m):
    a,b = l_n[i]
    c,d = l_m[t]
    v= abs(a-c)+abs(b-d)
    if v<q:
      q = v
      z = t
  print(z+1)
  q = 100000
    

### FIXED CODE ###

n,m = map(int,input().split())
l_n =list(list(map(int,input().split())) for i in range(n))
l_m =list(list(map(int,input().split())) for i in range(m))
for i in range(n):
  q = 10**9
  for t in range(m):
    a,b = l_n[i]
    c,d = l_m[t]
    v= abs(a-c)+abs(b-d)
    if v<q:
      q = v
      z = t
  print(z+1)
# coding: utf-8
# 日本語を入力できるようにするために上記一文が必要


x, y = map(int, input().split())
if y > 4*x or  2*x >y:
        print("No")
elif (4*x - y) % 2 == 0:
        print("Yes")
else:
        print("No")

### FIXED CODE ###

# coding: utf-8
# 日本語を入力できるようにするために上記一文が必要

num_list = []
num_list = input().split()

ans = int(num_list.index('0')) + 1

print(ans)
a = input()
my_result = a + a*a + a*a*a
print(my_result)

### FIXED CODE ###

a = int(input())
my_result = a + a**2 + a**3
print(my_result)