
'''simple docstring'''



from abc import ABC, abstractmethod
from typing import List, Optional





class 	A							(				lowerCAmelCase_ ):



			def __init__(    self				)	->						Optional[int]:




									'''simple docstring'''



									self.test()



			def A__       (    self				)	->						int:




									'''simple docstring'''



									lowercase__							       =				0
									lowercase__							       =				False
									while not completed:
															if counter == 1:
																					self.reset()
															lowercase__							       =				self.advance()
															if not self.does_advance(__lowerCAmelCase				):
																					raise Exception(
																					    """Custom Constraint is not defined correctly. self.does_advance(self.advance()) must be true."""				)

															lowercase__       ,  lowercase__       ,  lowercase__							       =				self.update(__lowerCAmelCase				)
															counter += 1

															if counter > 10_000:
																					raise Exception("""update() does not fulfill the constraint."""				)

									if self.remaining() != 0:
															raise Exception("""Custom Constraint is not defined correctly."""				)



			@abstractmethod
			def A__       (    self				)	->						Union[str, Any]:




									'''simple docstring'''



									raise NotImplementedError(
									    F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''				)



			@abstractmethod
			def A__       (    self				,   lowerCamelCase__				)	->						Tuple:




									'''simple docstring'''



									raise NotImplementedError(
									    F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''				)



			@abstractmethod
			def A__       (    self				,   lowerCamelCase__				)	->						Dict:




									'''simple docstring'''



									raise NotImplementedError(
									    F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''				)



			@abstractmethod
			def A__       (    self				)	->						str:




									'''simple docstring'''



									raise NotImplementedError(
									    F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''				)



			@abstractmethod
			def A__       (    self				)	->						List[str]:




									'''simple docstring'''



									raise NotImplementedError(
									    F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''				)



			@abstractmethod
			def A__       (    self				,   lowerCamelCase__=False				)	->						Optional[int]:




									'''simple docstring'''



									raise NotImplementedError(
									    F'''{self.__class__} is an abstract class. Only classes inheriting this class can be called.'''				)





class 	A							(				lowerCAmelCase_ ):



			def __init__(    self				,   lowerCamelCase__				)	->						Union[str, Any]:




									'''simple docstring'''



									super(__lowerCAmelCase				,   self				).__init__()

									if not isinstance(__lowerCAmelCase				,   __lowerCAmelCase				) or len(__lowerCAmelCase				) == 0:
															raise ValueError(F'''`token_ids` has to be a non-empty list, but is {token_ids}.'''				)
									if any((not isinstance(__lowerCAmelCase				,   __lowerCAmelCase				) or token_id < 0) for token_id in token_ids				):
															raise ValueError(F'''Each list in `token_ids` has to be a list of positive integers, but is {token_ids}.'''				)

									lowercase__							       =				token_ids

									lowercase__							       =				len(self.token_ids				)
									lowercase__							       =				-1  # the index of the currently fulfilled step
									lowercase__							       =				False



			def A__       (    self				)	->						str:




									'''simple docstring'''



									if self.completed:
															return None
									return self.token_ids[self.fulfilled_idx + 1]



			def A__       (    self				,   lowerCamelCase__				)	->						Tuple:




									'''simple docstring'''



									if not isinstance(__lowerCAmelCase				,   __lowerCAmelCase				):
															raise ValueError(F'''`token_id` has to be an `int`, but is {token_id} of type {type(__lowerCAmelCase				)}'''				)

									if self.completed:
															return False

									return token_id == self.token_ids[self.fulfilled_idx + 1]



			def A__       (    self				,   lowerCamelCase__				)	->						Optional[Any]:




									'''simple docstring'''



									if not isinstance(__lowerCAmelCase				,   __lowerCAmelCase				):
															raise ValueError(F'''`token_id` has to be an `int`, but is {token_id} of type {type(__lowerCAmelCase				)}'''				)

									lowercase__							       =				False
									lowercase__							       =				False
									lowercase__							       =				False

									if self.does_advance(__lowerCAmelCase				):
															self.fulfilled_idx += 1
															lowercase__							       =				True
															if self.fulfilled_idx == (self.seqlen - 1):
																					lowercase__							       =				True
															lowercase__							       =				completed
									else:
															# failed to make progress.
															lowercase__							       =				True
															self.reset()
									return stepped, completed, reset



			def A__       (    self				)	->						Optional[int]:




									'''simple docstring'''



									lowercase__							       =				False
									lowercase__							       =				0



			def A__       (    self				)	->						int:




									'''simple docstring'''



									return self.seqlen - (self.fulfilled_idx + 1)



			def A__       (    self				,   lowerCamelCase__=False				)	->						Optional[Any]:




									'''simple docstring'''



									lowercase__							       =				PhrasalConstraint(self.token_ids				)

									if stateful:
															lowercase__							       =				self.seqlen
															lowercase__							       =				self.fulfilled_idx
															lowercase__							       =				self.completed

									return new_constraint





class 	A							:



			def __init__(    self				,   lowerCamelCase__				,   lowerCamelCase__=True				)	->						Optional[int]:




									'''simple docstring'''



									lowercase__							       =				max([len(__lowerCAmelCase				) for one in nested_token_ids]				)

									lowercase__							       =				{}
									for token_ids in nested_token_ids:
															lowercase__							       =				root
															for tidx, token_id in enumerate(__lowerCAmelCase				):
																					if token_id not in level:
																											lowercase__							       =				{}

																					lowercase__							       =				level[token_id]

									if no_subsets and self.has_subsets(__lowerCAmelCase				,   __lowerCAmelCase				):
															raise ValueError(
															    """Each list in `nested_token_ids` can't be a complete subset of another list, but is"""
															    F''' {nested_token_ids}.'''				)

									lowercase__							       =				root



			def A__       (    self				,   lowerCamelCase__				)	->						List[Any]:




									'''simple docstring'''



									lowercase__							       =				self.trie

									for current_token in current_seq:
															lowercase__							       =				start[current_token]

									lowercase__							       =				list(start.keys()				)

									return next_tokens



			def A__       (    self				,   lowerCamelCase__				)	->						Any:




									'''simple docstring'''



									lowercase__							       =				self.next_tokens(__lowerCAmelCase				)

									return len(__lowerCAmelCase				) == 0



			def A__       (    self				,   lowerCamelCase__				)	->						Optional[int]:




									'''simple docstring'''



									lowercase__							       =				list(root.values()				)
									if len(__lowerCAmelCase				) == 0:
															return 1
									else:
															return sum([self.count_leaves(__lowerCAmelCase				) for nn in next_nodes]				)



			def A__       (    self				,   lowerCamelCase__				,   lowerCamelCase__				)	->						Dict:




									'''simple docstring'''



									lowercase__							       =				self.count_leaves(__lowerCAmelCase				)
									return len(__lowerCAmelCase				) != leaf_count





class 	A							(				lowerCAmelCase_ ):



			def __init__(    self				,   lowerCamelCase__				)	->						Union[str, Any]:




									'''simple docstring'''



									super(__lowerCAmelCase				,   self				).__init__()

									if not isinstance(__lowerCAmelCase				,   __lowerCAmelCase				) or len(__lowerCAmelCase				) == 0:
															raise ValueError(F'''`nested_token_ids` has to be a non-empty list, but is {nested_token_ids}.'''				)
									if any(not isinstance(__lowerCAmelCase				,   __lowerCAmelCase				) for token_ids in nested_token_ids				):
															raise ValueError(F'''`nested_token_ids` has to be a list of lists, but is {nested_token_ids}.'''				)
									if any(
									    any((not isinstance(__lowerCAmelCase				,   __lowerCAmelCase				) or token_id < 0) for token_id in token_ids				)
									    for token_ids in nested_token_ids				):
															raise ValueError(
															    F'''Each list in `nested_token_ids` has to be a list of positive integers, but is {nested_token_ids}.'''				)

									lowercase__							       =				DisjunctiveTrie(__lowerCAmelCase				)
									lowercase__							       =				nested_token_ids

									lowercase__							       =				self.trie.max_height
									lowercase__							       =				[]
									lowercase__							       =				False



			def A__       (    self				)	->						Tuple:




									'''simple docstring'''



									lowercase__							       =				self.trie.next_tokens(self.current_seq				)

									if len(__lowerCAmelCase				) == 0:
															return None
									else:
															return token_list



			def A__       (    self				,   lowerCamelCase__				)	->						Optional[Any]:




									'''simple docstring'''



									if not isinstance(__lowerCAmelCase				,   __lowerCAmelCase				):
															raise ValueError(F'''`token_id` is supposed to be type `int`, but is {token_id} of type {type(__lowerCAmelCase				)}'''				)

									lowercase__							       =				self.trie.next_tokens(self.current_seq				)

									return token_id in next_tokens



			def A__       (    self				,   lowerCamelCase__				)	->						int:




									'''simple docstring'''



									if not isinstance(__lowerCAmelCase				,   __lowerCAmelCase				):
															raise ValueError(F'''`token_id` is supposed to be type `int`, but is {token_id} of type {type(__lowerCAmelCase				)}'''				)

									lowercase__							       =				False
									lowercase__							       =				False
									lowercase__							       =				False

									if self.does_advance(__lowerCAmelCase				):
															self.current_seq.append(__lowerCAmelCase				)
															lowercase__							       =				True
									else:
															lowercase__							       =				True
															self.reset()

									lowercase__							       =				self.trie.reached_leaf(self.current_seq				)
									lowercase__							       =				completed

									return stepped, completed, reset



			def A__       (    self				)	->						Optional[Any]:




									'''simple docstring'''



									lowercase__							       =				False
									lowercase__							       =				[]



			def A__       (    self				)	->						Dict:




									'''simple docstring'''



									if self.completed:
															# since this can be completed without reaching max height
															return 0
									else:
															return self.seqlen - len(self.current_seq				)



			def A__       (    self				,   lowerCamelCase__=False				)	->						Optional[Any]:




									'''simple docstring'''



									lowercase__							       =				DisjunctiveConstraint(self.token_ids				)

									if stateful:
															lowercase__							       =				self.seqlen
															lowercase__							       =				self.current_seq
															lowercase__							       =				self.completed

									return new_constraint





class 	A							:



			def __init__(    self				,   lowerCamelCase__				)	->						Tuple:




									'''simple docstring'''



									lowercase__							       =				constraints

									# max # of steps required to fulfill a given constraint
									lowercase__							       =				max([c.seqlen for c in constraints]				)
									lowercase__							       =				len(__lowerCAmelCase				)
									lowercase__							       =				False

									self.init_state()



			def A__       (    self				)	->						int:




									'''simple docstring'''



									lowercase__							       =				[]
									lowercase__							       =				None
									lowercase__							       =				[constraint.copy(stateful=__lowerCAmelCase				) for constraint in self.constraints]



			def A__       (    self				)	->						Optional[Any]:




									'''simple docstring'''



									lowercase__							       =				0
									if self.inprogress_constraint:
															# extra points for having a constraint mid-fulfilled
															add += self.max_seqlen - self.inprogress_constraint.remaining()

									return (len(self.complete_constraints				) * self.max_seqlen) + add



			def A__       (    self				)	->						Any:




									'''simple docstring'''



									lowercase__							       =				[]
									if self.inprogress_constraint is None:
															for constraint in self.pending_constraints:  # "pending" == "unfulfilled yet"
																					lowercase__							       =				constraint.advance()
																					if isinstance(__lowerCAmelCase				,   __lowerCAmelCase				):
																											token_list.append(__lowerCAmelCase				)
																					elif isinstance(__lowerCAmelCase				,   __lowerCAmelCase				):
																											token_list.extend(__lowerCAmelCase				)
									else:
															lowercase__							       =				self.inprogress_constraint.advance()
															if isinstance(__lowerCAmelCase				,   __lowerCAmelCase				):
																					token_list.append(__lowerCAmelCase				)
															elif isinstance(__lowerCAmelCase				,   __lowerCAmelCase				):
																					token_list.extend(__lowerCAmelCase				)

									if len(__lowerCAmelCase				) == 0:
															return None
									else:
															return token_list



			def A__       (    self				,   lowerCamelCase__				)	->						Dict:




									'''simple docstring'''



									self.init_state()

									if token_ids is not None:
															for token in token_ids:
																					# completes or steps **one** constraint
																					lowercase__       ,  lowercase__							       =				self.add(__lowerCAmelCase				)

																					# the entire list of constraints are fulfilled
																					if self.completed:
																											break



			def A__       (    self				,   lowerCamelCase__				)	->						int:




									'''simple docstring'''



									if not isinstance(__lowerCAmelCase				,   __lowerCAmelCase				):
															raise ValueError(F'''`token_id` should be an `int`, but is `{token_id}`.'''				)

									lowercase__       ,  lowercase__							       =				False, False

									if self.completed:
															lowercase__							       =				True
															lowercase__							       =				False
															return complete, stepped

									if self.inprogress_constraint is not None:
															# In the middle of fulfilling a constraint. If the `token_id` *does* makes an incremental progress to current
															# job, simply update the state

															lowercase__       ,  lowercase__       ,  lowercase__							       =				self.inprogress_constraint.update(__lowerCAmelCase				)
															if reset:
																					# 1. If the next token breaks the progress, then we must restart.
																					#     e.g. constraint = "I love pies" and sequence so far is "I love" but `token_id` == "books".

																					#     But that doesn't mean we self.init_state(), since we only reset the state for this particular
																					#     constraint, not the full list of constraints.

																					self.pending_constraints.append(self.inprogress_constraint.copy(stateful=__lowerCAmelCase				)				)
																					lowercase__							       =				None

															if complete:
																					# 2. If the next token completes the constraint, move it to completed list, set
																					#     inprogress to None. If there are no pending constraints either, then this full list of constraints
																					#     is complete.

																					self.complete_constraints.append(self.inprogress_constraint				)
																					lowercase__							       =				None

																					if len(self.pending_constraints				) == 0:
																											# we're done!
																											lowercase__							       =				True

									else:
															# Not in the middle of fulfilling a constraint. So does this `token_id` helps us step towards any of our list
															# of constraints?

															for cidx, pending_constraint in enumerate(self.pending_constraints				):
																					if pending_constraint.does_advance(__lowerCAmelCase				):
																											lowercase__       ,  lowercase__       ,  lowercase__							       =				pending_constraint.update(__lowerCAmelCase				)

																											if not stepped:
																																	raise Exception(
																																	    """`constraint.update(token_id)` is not yielding incremental progress, """
																																	    """even though `constraint.does_advance(token_id)` is true."""				)

																											if complete:
																																	self.complete_constraints.append(__lowerCAmelCase				)
																																	lowercase__							       =				None

																											if not complete and stepped:
																																	lowercase__							       =				pending_constraint

																											if complete or stepped:
																																	# If we made any progress at all, then it's at least not a "pending constraint".

																																	lowercase__							       =				(
																																	    self.pending_constraints[:cidx] + self.pending_constraints[cidx + 1 :]
																																	)

																																	if len(self.pending_constraints				) == 0 and self.inprogress_constraint is None:
																																							# If there's no longer any pending after this and no inprogress either, then we must be
																																							# complete.

																																							lowercase__							       =				True

																																	break  # prevent accidentally stepping through multiple constraints with just one token.

									return complete, stepped



			def A__       (    self				,   lowerCamelCase__=True				)	->						List[Any]:




									'''simple docstring'''



									lowercase__							       =				ConstraintListState(self.constraints				)  # we actually never though self.constraints objects
									# throughout this process. So it's at initialization state.

									if stateful:
															lowercase__							       =				[
															    constraint.copy(stateful=__lowerCAmelCase				) for constraint in self.complete_constraints
															]
															if self.inprogress_constraint is not None:
																					lowercase__							       =				self.inprogress_constraint.copy(stateful=__lowerCAmelCase				)
															lowercase__							       =				[constraint.copy() for constraint in self.pending_constraints]

									return new_state







"""simple docstring"""


import requests

UpperCAmelCase__     						=  """"""  # <-- Put your OpenWeatherMap appid here!
UpperCAmelCase__     						=  """https://api.openweathermap.org/data/2.5/"""






def 			__UpperCAmelCase    (	lowercase = "Chicago"      ,lowercase = APPID						):







  """simple docstring"""
  return requests.get(URL_BASE + """weather"""      ,params=locals()						).json()






def 			__UpperCAmelCase    (	lowercase = "Kolkata, India"      ,lowercase = APPID						):







  """simple docstring"""
  return requests.get(URL_BASE + """forecast"""      ,params=locals()						).json()






def 			__UpperCAmelCase    (	lowercase = 55.68      ,lowercase = 12.57      ,lowercase = APPID						):







  """simple docstring"""
  return requests.get(URL_BASE + """onecall"""      ,params=locals()						).json()


if __name__ == "__main__":
    from pprint import pprint

    while True:
        UpperCAmelCase__     						=  input("""Enter a location:""").strip()
        if location:
            pprint(current_weather(location))
        else:
            break
