anchor stringlengths 10 14.3k | positive stringlengths 10 14.9k |
|---|---|
MultipleInvalid constructor logic reversed when errors is None
#### Description
When creating a `MultipleInvalid` exception with `errors=None`, the constructor incorrectly assigns `None` to `self.errors` instead of an empty list. This causes `IndexError: list index out of range` when trying to access error details.
... | diff --git a/voluptuous/error.py b/voluptuous/error.py
index 9dab943..eeed54d 100644
--- b/voluptuous/error.py
+++ a/voluptuous/error.py
@@ -59,7 +59,7 @@ class Invalid(Error):
class MultipleInvalid(Invalid):
def __init__(self, errors: typing.Optional[typing.List[Invalid]] = None) -> None:
- self.errors ... |
# [Bug]: Feedback mode in Synthesizer not working when generating examples
## Description
I found a bug in the `Synthesizer` class in the experimental synthesizer module. When using the feedback mode with `num_example_for_feedback` set, the feedback functionality is not working at all.
The issue occurs in the `gener... | diff --git a/dspy/experimental/synthesizer/synthesizer.py b/dspy/experimental/synthesizer/synthesizer.py
index e1184c5..b3b2d03 100644
--- b/dspy/experimental/synthesizer/synthesizer.py
+++ a/dspy/experimental/synthesizer/synthesizer.py
@@ -170,7 +170,7 @@ class Synthesizer:
if self.config.num_example_for_op... |
# AUTOSAR End-to-End protection CRC calculation broken
I found an issue with the AUTOSAR End-to-End protection CRC calculation in the library. Both Profile2 and Profile5 CRC calculations are not working correctly.
## Profile2 Issue
When calculating the CRC for Profile2, the result is incorrect:
```python
db = canto... | diff --git a/src/cantools/autosar/end_to_end.py b/src/cantools/autosar/end_to_end.py
index 2ce4ae7..ea22fe9 100644
--- b/src/cantools/autosar/end_to_end.py
+++ a/src/cantools/autosar/end_to_end.py
@@ -37,20 +37,21 @@ def compute_profile2_crc(payload: bytes,
assert msg.autosar.e2e is not None
assert ms... |
PEP8 normalizer swaps error codes for 'not in' and 'is not' checks
#### Description
The PEP8 normalizer is incorrectly assigning error codes when checking for negated membership and identity tests. When encountering `not in` expressions, it reports error code 714 (which should be for `is not`), and when encountering ... | diff --git a/parso/python/pep8.py b/parso/python/pep8.py
index c492dae..6c4039a 100644
--- b/parso/python/pep8.py
+++ a/parso/python/pep8.py
@@ -710,9 +710,9 @@ class PEP8Normalizer(ErrorFinder):
comparison = leaf.parent
if comparison.type == 'comparison' and comparison.parent.type == 'not_tes... |
tz_isoformat returns incorrect timezone offset format
#### Description
The `tz_isoformat` function is returning timezone offsets with hours and minutes swapped in the output format.
#### Steps/Code to Reproduce
```python
from datetime import datetime, timezone, timedelta
from isodate.isotzinfo import tz_isoformat
... | diff --git a/src/isodate/isotzinfo.py b/src/isodate/isotzinfo.py
index f7efb86..29612d1 100644
--- b/src/isodate/isotzinfo.py
+++ a/src/isodate/isotzinfo.py
@@ -80,14 +80,14 @@ def tz_isoformat(dt: datetime, format: str = "%Z") -> str:
seconds = tdelta.days * 24 * 60 * 60 + tdelta.seconds
sign = ((seconds < 0... |
Style color parsing broken for hex colors and CSS functions
#### Description
When using styles with hex color codes or CSS functions like `var()` and `calc()`, the color parsing is producing incorrect output. Hex colors are being truncated and CSS functions are being mangled.
#### Steps/Code to Reproduce
```python
... | diff --git a/pygments/style.py b/pygments/style.py
index 449522c..8141090 100644
--- b/pygments/style.py
+++ a/pygments/style.py
@@ -69,14 +69,14 @@ class StyleMeta(type):
if text[0:1] == '#':
col = text[1:]
if len(col) == 6:
- return col[0:3] # Truncat... |
# Bug in WebApplicationClient constructor and prepare_request_uri method
## Description
I found a bug in the `WebApplicationClient` class in `oauthlib/oauth2/rfc6749/clients/web_application.py`. The constructor and `prepare_request_uri` method have issues that cause incorrect behavior.
The constructor is incorrectly... | diff --git a/oauthlib/oauth2/rfc6749/clients/web_application.py b/oauthlib/oauth2/rfc6749/clients/web_application.py
index 3bf94c4..90a0a38 100644
--- b/oauthlib/oauth2/rfc6749/clients/web_application.py
+++ a/oauthlib/oauth2/rfc6749/clients/web_application.py
@@ -37,20 +37,68 @@ class WebApplicationClient(Client):
... |
Categorical comparison with scalar values produces incorrect results
#### Description
When comparing a Categorical array with scalar values that are in the categories, the comparison logic appears to be inverted. Comparisons that should return `True` are returning `False` and vice versa.
#### Steps/Code to Reproduce... | diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py
index 0ce7007..f0ee618 100644
--- b/pandas/core/arrays/categorical.py
+++ a/pandas/core/arrays/categorical.py
@@ -157,6 +157,20 @@ def _cat_compare_op(op):
return ret
if hashable:
+ if other in self.cat... |
# Downloader cog incorrectly processes repo and module information
## Description
I've discovered an issue with the downloader cog where it's not correctly processing repository and module information. When trying to install a cog from a repository, the cog information is being incorrectly parsed and stored.
Here's ... | diff --git a/redbot/cogs/downloader/info_schemas.py b/redbot/cogs/downloader/info_schemas.py
index 8033d13..5c46094 100644
--- b/redbot/cogs/downloader/info_schemas.py
+++ a/redbot/cogs/downloader/info_schemas.py
@@ -52,10 +52,10 @@ def ensure_tuple_of_str(
def ensure_str(info_file: Path, key_name: str, value: Uni... |
QR code pattern generation produces incorrect output
#### Description
When generating QR codes, the positioning patterns appear to be malformed, resulting in incorrect visual output when printed to terminal or converted to ASCII representation.
#### Steps/Code to Reproduce
```python
import qrcode
import io
# Creat... | diff --git a/qrcode/main.py b/qrcode/main.py
index 46116b5..da46fdb 100644
--- b/qrcode/main.py
+++ a/qrcode/main.py
@@ -412,7 +412,7 @@ class QRCode(Generic[GenericImage]):
row = pos[i]
for j in range(len(pos)):
- col = pos[i] # Changed 'col = pos[j]' to 'col = pos[i]'
+ ... |
Discriminated union schema generation broken after recent changes
#### Description
After some recent changes, discriminated union schemas are not being generated correctly. The schema build process appears to be incomplete, causing validation to fail unexpectedly.
#### Steps/Code to Reproduce
```python
from typing ... | diff --git a/pydantic/_internal/_discriminated_union.py b/pydantic/_internal/_discriminated_union.py
index 5dd6fda..dc743f9 100644
--- b/pydantic/_internal/_discriminated_union.py
+++ a/pydantic/_internal/_discriminated_union.py
@@ -195,6 +195,9 @@ class _ApplyInferredDiscriminator:
# Reverse the choices list ... |
Statement.get_type() always returns 'UNKNOWN'
#### Description
The `get_type()` method on SQL statements is not working correctly and always returns 'UNKNOWN' regardless of the actual SQL statement type.
#### Steps/Code to Reproduce
```python
import sqlparse
# Simple SELECT statement
sql = 'SELECT * FROM foo'
pars... | diff --git a/sqlparse/sql.py b/sqlparse/sql.py
index 1037375..ddf8ea6 100644
--- b/sqlparse/sql.py
+++ a/sqlparse/sql.py
@@ -419,10 +419,32 @@ class Statement(TokenList):
are ignored.
"""
token = self.token_first(skip_cm=True)
+ if token is None:
+ # An "empty" statement tha... |
MultiIndex.sortlevel() returns incorrect results when sort_remaining=False
#### Description
When calling `sortlevel()` on a MultiIndex with `sort_remaining=False`, the method returns incorrect sorting results. The issue appears to affect the sorting logic when only specific levels should be sorted without sorting the... | diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py
index 79eb1b6..c9009dd 100644
--- b/pandas/core/indexes/multi.py
+++ a/pandas/core/indexes/multi.py
@@ -2801,11 +2801,11 @@ class MultiIndex(Index):
if not len(level) == len(ascending):
raise ValueError("level must ha... |
SectionWrapper constructor arguments swapped causing AttributeError
When creating a SectionWrapper instance, the config and name arguments appear to be swapped in the constructor, causing AttributeError when trying to access section properties.
#### Steps/Code to Reproduce
```python
from iniconfig import IniConfig
... | diff --git a/src/iniconfig/__init__.py b/src/iniconfig/__init__.py
index 3c40bc9..7f42fb9 100644
--- b/src/iniconfig/__init__.py
+++ a/src/iniconfig/__init__.py
@@ -37,8 +37,8 @@ class SectionWrapper:
name: Final[str]
def __init__(self, config: IniConfig, name: str) -> None:
- self.config = name
- ... |
BaseEndpoint constructor swaps request_validator and token_generator parameters
#### Description
The BaseEndpoint constructor incorrectly assigns the parameters - the request_validator parameter gets assigned to token_generator and vice versa. This causes OAuth1 endpoints to fail validation since they can't access th... | diff --git a/oauthlib/oauth1/rfc5849/endpoints/base.py b/oauthlib/oauth1/rfc5849/endpoints/base.py
index 8d3d89c..bde633a 100644
--- b/oauthlib/oauth1/rfc5849/endpoints/base.py
+++ a/oauthlib/oauth1/rfc5849/endpoints/base.py
@@ -21,8 +21,8 @@ from .. import (
class BaseEndpoint:
def __init__(self, request_valid... |
#### Description
The optimizer functions are not working correctly after recent changes. When running SQL optimization, several functions including `isolate_table_selects` and `optimize_joins` are producing incorrect results.
#### Steps/Code to Reproduce
```python
import sqlglot
from sqlglot import optimizer
# Exam... | diff --git a/sqlglot/optimizer/isolate_table_selects.py b/sqlglot/optimizer/isolate_table_selects.py
index a6524b8..7b4facd 100644
--- b/sqlglot/optimizer/isolate_table_selects.py
+++ a/sqlglot/optimizer/isolate_table_selects.py
@@ -5,6 +5,7 @@ from sqlglot.schema import ensure_schema
def isolate_table_selects(exp... |
# pipdeptree text rendering broken with Unicode characters
I'm using pipdeptree to visualize my package dependencies, but I've noticed that the text rendering is broken when using Unicode characters.
## Reproduction
I have a simple dependency tree with several packages. When I try to render it with Unicode character... | diff --git a/src/pipdeptree/_render/text.py b/src/pipdeptree/_render/text.py
index efa5a02..6a7eed3 100644
--- b/src/pipdeptree/_render/text.py
+++ a/src/pipdeptree/_render/text.py
@@ -50,8 +50,8 @@ def _render_text_with_unicode(
use_bullets = not frozen
def aux( # noqa: PLR0913, PLR0917
- node: Dis... |
# QRCode initialization doesn't validate image_factory properly
## Description
There appears to be an issue with the QRCode class initialization where it no longer properly validates the image_factory parameter. Previously, the code would check if the provided image_factory is a subclass of BaseImage, but this valida... | diff --git a/qrcode/main.py b/qrcode/main.py
index 46116b5..f2a5e93 100644
--- b/qrcode/main.py
+++ a/qrcode/main.py
@@ -78,19 +78,29 @@ class QRCode(Generic[GenericImage]):
modules: ModulesType
_version: Optional[int] = None
- def __init__(self, version=None, error_correction=constants.ERROR_CORRECT_M,
... |
# Downloader cog crashes when trying to serialize installed modules
## Description
I've found an issue with the downloader cog where it crashes when trying to serialize installed modules. This happens when the bot tries to save information about installed cogs.
## Steps to reproduce
1. Install a cog using the downl... | diff --git a/redbot/cogs/downloader/info_schemas.py b/redbot/cogs/downloader/info_schemas.py
index 8033d13..df13705 100644
--- b/redbot/cogs/downloader/info_schemas.py
+++ a/redbot/cogs/downloader/info_schemas.py
@@ -153,9 +153,18 @@ def ensure_bool(
def ensure_required_cogs_mapping(
info_file: Path, key_name: st... |
# Invalid style value not raising error in set_style method
When setting an invalid style value using the `set_style` method, the method no longer raises a ValueError as expected. This behavior is inconsistent with previous versions.
## Description
The `set_style` method should validate that the provided style is a ... | diff --git a/src/prettytable/prettytable.py b/src/prettytable/prettytable.py
index 818a520..56c014b 100644
--- b/src/prettytable/prettytable.py
+++ a/src/prettytable/prettytable.py
@@ -1441,12 +1441,6 @@ class PrettyTable:
##############################
def set_style(self, style: TableStyle) -> None:
- ... |
Objective-C lexer incorrectly identifies C code as Logos
#### Description
The Objective-C lexer is incorrectly identifying plain C code as Logos lexer instead of C lexer. This affects code analysis and syntax highlighting for C files.
#### Steps/Code to Reproduce
```python
from pygments.lexers import guess_lexer
#... | diff --git a/pygments/lexers/objective.py b/pygments/lexers/objective.py
index b37a9d4..1908fce 100644
--- b/pygments/lexers/objective.py
+++ a/pygments/lexers/objective.py
@@ -26,11 +26,18 @@ def objective(baselexer):
extensions.
"""
- _oc_keywords = re.compile(r'@(?:end|implementation|protocaol)')
-
- ... |
HeaderDict.append() swaps key and value parameters
Description
When using HeaderDict.append(), the key and value parameters are being swapped internally, causing headers to be stored with incorrect keys and values.
Steps/Code to Reproduce
```python
from bottle import HeaderDict
# Create a HeaderDict and append a h... | diff --git a/bottle.py b/bottle.py
index 286b5bc..839e06d 100755
--- b/bottle.py
+++ a/bottle.py
@@ -2261,7 +2261,7 @@ class HeaderDict(MultiDict):
self.dict[_hkey(key)] = [_hval(value)]
def append(self, key, value):
- self.dict.setdefault(_hkey(value), []).append(_hval(key))
+ self.dict.s... |
# Frequency comparison functions not working correctly
### Problem
I'm having an issue with the frequency comparison functions in pandas. The `is_subperiod` and `is_superperiod` functions don't seem to be working correctly together.
When I try to check if one period is a subperiod of another, I'm getting inconsistent... | diff --git a/pandas/tseries/frequencies.py b/pandas/tseries/frequencies.py
index 88ea1bf..5ceefe1 100644
--- b/pandas/tseries/frequencies.py
+++ a/pandas/tseries/frequencies.py
@@ -458,6 +458,7 @@ def is_subperiod(source, target) -> bool:
if target is None or source is None:
return False
source = _ma... |
NameError when using Annotated fields with FieldInfo
#### Description
When using `Annotated` type hints with `FieldInfo` instances, a `NameError` occurs because `annotation_metadata` is referenced before being defined.
#### Steps/Code to Reproduce
```python
from typing import Annotated
from pydantic import BaseMode... | diff --git a/pydantic/fields.py b/pydantic/fields.py
index 7081292..0b3668c 100644
--- b/pydantic/fields.py
+++ a/pydantic/fields.py
@@ -399,6 +399,10 @@ class FieldInfo(_repr.Representation):
annotation = typing_extensions.get_args(annotation)[0]
if isinstance(default, FieldInfo):
+ ... |
BottleParser cookie parsing broken after recent changes
#### Description
The BottleParser is no longer able to parse cookies from requests. When trying to access cookies through the parser, it returns an empty dictionary instead of the actual cookie values.
#### Steps/Code to Reproduce
```python
import bottle
from ... | diff --git a/src/webargs/bottleparser.py b/src/webargs/bottleparser.py
index a2bf7af..f6f301f 100644
--- b/src/webargs/bottleparser.py
+++ a/src/webargs/bottleparser.py
@@ -55,7 +55,7 @@ class BottleParser(core.Parser[bottle.Request]):
def load_querystring(self, req, schema):
"""Return query params from... |
Progress bar rendering broken after recent changes
Description
The progress bar animations are not rendering correctly. When creating progress bars with various character sets and configurations, the output doesn't match expected patterns.
Steps/Code to Reproduce
```python
from alive_progress.animations.bars import... | diff --git a/alive_progress/animations/bars.py b/alive_progress/animations/bars.py
index e2e5359..2ac9c11 100644
--- b/alive_progress/animations/bars.py
+++ a/alive_progress/animations/bars.py
@@ -40,17 +40,17 @@ def bar_factory(chars=None, *, tip=None, background=None, borders=None, errors=N
if chars:
... |
IRCFormatter line numbers appear at wrong position when linenos=True
#### Description
When using the IRCFormatter with `linenos=True`, the line numbers are being written at the end of the output instead of at the beginning of each line. This causes the formatted output to have incorrect line number positioning.
####... | diff --git a/pygments/formatters/irc.py b/pygments/formatters/irc.py
index a1e3979..26ca531 100644
--- b/pygments/formatters/irc.py
+++ a/pygments/formatters/irc.py
@@ -133,6 +133,7 @@ class IRCFormatter(Formatter):
outfile.write("%04d: " % self._lineno)
def format_unencoded(self, tokensource, outfi... |
DeepDiff incorrectly handles basic hashable type detection for iterables
#### Description
When comparing iterables, DeepDiff's `_all_values_basic_hashable` method returns incorrect results, causing unexpected behavior in difference detection. The method appears to have inverted logic that returns `True` when it shoul... | diff --git a/deepdiff/diff.py b/deepdiff/diff.py
index 76f186b..15022d5 100755
--- b/deepdiff/diff.py
+++ a/deepdiff/diff.py
@@ -868,16 +868,16 @@ class DeepDiff(ResultDict, SerializationMixin, DistanceMixin, Base):
def _all_values_basic_hashable(self, iterable):
"""
Are all items basic hashable ... |
# yamllint disable directive not working correctly
I'm having an issue with the yamllint disable directive not working as expected. When I try to disable rules using inline comments, they're not being properly recognized.
## Steps to reproduce
1. Create a YAML file with a directive to disable rules:
```yaml
---
# y... | diff --git a/yamllint/linter.py b/yamllint/linter.py
index a2faa06..ddc5f33 100644
--- b/yamllint/linter.py
+++ a/yamllint/linter.py
@@ -115,10 +115,10 @@ def get_cosmetic_problems(buffer, conf, filepath):
items = comment[23:].rstrip().split(' ')
rules = [item[5:] for item in items][1:... |
elevation_angle function returns incorrect values when radians parameter is swapped
#### Description
The `elevation_angle` function in the geo module appears to be returning incorrect angle values. When calculating elevation angles between two locations, the function returns negative degrees when it should return pos... | diff --git a/test.py b/test.py
index 7dd6f44..9b74e4d 100644
--- b/test.py
+++ a/test.py
@@ -1262,10 +1262,10 @@ class GPXTests(mod_unittest.TestCase):
loc2 = mod_geo.Location(0, 1)
loc1.elevation = 100
- loc2.elevation = loc1.elevation - loc1.distance_2d(loc2) # type: ignore
+ loc2.el... |
Environment variable parsing fails for nested structs with custom parsers
#### Description
When parsing environment variables into nested structs that have custom parsers or special field types, the parsing process is not working correctly. Fields that should be populated from environment variables are remaining empt... | diff --git a/env.go b/env.go
index c928b66..848756d 100644
--- b/env.go
+++ a/env.go
@@ -398,18 +398,19 @@ func doParseField(
return nil
}
+ if err := processField(refField, refTypeField, opts, params); err != nil {
+ return err
+ }
+
if params.Init && isInvalidPtr(refField) {
refField.Set(reflect.New(refF... |
# update_many() not updating all rows correctly
I've found an issue with the `update_many()` method in the Table class. It seems to be incorrectly processing rows when updating multiple records.
## Description
When using `update_many()` to update multiple rows in a table, not all rows are being updated correctly. Th... | diff --git a/dataset/table.py b/dataset/table.py
index 732964c..60be388 100644
--- b/dataset/table.py
+++ a/dataset/table.py
@@ -239,7 +239,7 @@ class Table(object):
chunk.append(row)
# Update when chunk_size is fulfilled or this is the last row
- if len(chunk) == chunk_size or in... |
Option parsing broken for commands with arguments
#### Description
After a recent change, option parsing seems to be completely broken. Commands that previously worked now fail to parse their arguments correctly, causing widespread test failures.
#### Steps/Code to Reproduce
```python
import click
@click.command()... | diff --git a/src/click/parser.py b/src/click/parser.py
index a8b7d26..b2c64d8 100644
--- b/src/click/parser.py
+++ a/src/click/parser.py
@@ -433,8 +433,8 @@ class _OptionParser:
) -> t.Any:
nargs = option.nargs
- if len(state.rargs) <= nargs: # Change from < to <=
- if not option.obj.... |
Option default value handling broken for non-boolean flags
#### Description
When using non-boolean flags (like `flag_value` options), the default value handling is not working correctly. The `get_default` method is returning unexpected values instead of the proper defaults.
#### Steps/Code to Reproduce
```python
im... | diff --git a/src/click/core.py b/src/click/core.py
index abe9fa9..7bc58ac 100644
--- b/src/click/core.py
+++ a/src/click/core.py
@@ -2819,15 +2819,18 @@ class Option(Parameter):
def get_default(
self, ctx: Context, call: bool = True
) -> t.Any | t.Callable[[], t.Any] | None:
+ # If we're a non... |
Time parsing broken after recent changes
#### Description
ISO 8601 time parsing is completely broken. Basic time strings like "23:20:50" and "232050" are failing to parse correctly.
#### Steps/Code to Reproduce
```python
from isodate import parse_time
# These should work but don't
parse_time("23:20:50")
parse_time... | diff --git a/src/isodate/isotime.py b/src/isodate/isotime.py
index 78b4de2..62e970f 100644
--- b/src/isodate/isotime.py
+++ a/src/isodate/isotime.py
@@ -25,33 +25,46 @@ def build_time_regexps() -> list[re.Pattern[str]]:
The regular expressions are compiled and stored in TIME_REGEX_CACHE
for later reuse.
... |
Cache delete operation not updating hit statistics
#### Description
When deleting entries from the cache, the delete hit statistics are not being properly updated. The `delhit()` method call appears to be missing from the delete operation, causing cache statistics to be inaccurate.
#### Steps/Code to Reproduce
```g... | diff --git a/shard.go b/shard.go
index 4f03b53..fd3ff4b 100644
--- b/shard.go
+++ a/shard.go
@@ -260,15 +260,16 @@ func (s *cacheShard) del(hashedKey uint64) error {
return err
}
+ delete(s.hashmap, hashedKey)
+ s.onRemove(wrappedEntry, Deleted)
if s.statsEnabled {
delete(s.hashmapStats, hashedKey)
... |
Variable reference lookup returns empty string instead of None when not found
#### Description
When looking up variable references in nested scopes, the `find_ref` method now returns an empty string `""` instead of `None` when a reference is not found anywhere in the scope chain. This breaks template compilation as t... | diff --git a/src/jinja2/idtracking.py b/src/jinja2/idtracking.py
index d6cb635..f01da27 100644
--- b/src/jinja2/idtracking.py
+++ a/src/jinja2/idtracking.py
@@ -66,13 +66,13 @@ class Symbols:
return None
def find_ref(self, name: str) -> t.Optional[str]:
+ if name in self.refs:
+ return... |
# Missing `repo` parameter in `get_fs_config` function causes errors when accessing remote storage
When trying to access remote storage configurations, I'm getting errors because the `get_fs_config` function is missing a required parameter.
## Steps to reproduce
1. Create a DVC project with a remote configuration
2.... | diff --git a/dvc/fs/__init__.py b/dvc/fs/__init__.py
index cf3998a..719c553 100644
--- b/dvc/fs/__init__.py
+++ a/dvc/fs/__init__.py
@@ -96,7 +96,7 @@ def parse_external_url(url, fs_config=None, config=None):
return fs, fs_path
-def get_fs_config(repo, config, **kwargs):
+def get_fs_config(config, **kwargs):
... |
`--diff` flag removed but still referenced in help text
#### Description
The `--diff` flag has been removed from the CLI but users trying to use it get an unrecognized argument error. The functionality to compare stubs generated with and without existing annotations is no longer available.
#### Steps/Code to Reprodu... | diff --git a/monkeytype/cli.py b/monkeytype/cli.py
index 990079d..5c1d3b7 100644
--- b/monkeytype/cli.py
+++ a/monkeytype/cli.py
@@ -5,6 +5,7 @@
# LICENSE file in the root directory of this source tree.
import argparse
import collections
+import difflib
import importlib
import inspect
import os
@@ -224,12 +225,43... |
# Context manager in BaseRetrying.__iter__ not working correctly
## Description
When using the context manager pattern with the `Retrying` class, the code fails to work correctly. The issue is in the `__iter__` method of `BaseRetrying` class where the initialization and state management is incorrect.
## Steps to rep... | diff --git a/tenacity/__init__.py b/tenacity/__init__.py
index 72eba04..6584c29 100644
--- b/tenacity/__init__.py
+++ a/tenacity/__init__.py
@@ -436,6 +436,9 @@ class BaseRetrying(ABC):
self._add_action_func(lambda rs: DoSleep(rs.upcoming_sleep))
def __iter__(self) -> t.Generator[AttemptManager, None, N... |
get_flags_from_context() returns empty dict due to variable initialization order
#### Description
The `get_flags_from_context()` function in `safety/util.py` always returns an empty dictionary because the `flags` variable is initialized after the code that populates it.
#### Steps/Code to Reproduce
```python
from s... | diff --git a/safety/util.py b/safety/util.py
index 420eb13..4c5170a 100644
--- b/safety/util.py
+++ a/safety/util.py
@@ -189,22 +189,23 @@ def get_license_name_by_id(license_id: int, db: Dict[str, Any]) -> Optional[str]
def get_flags_from_context() -> Dict[str, str]:
+ """
+ Get the flags from the current cl... |
Template compilation fails with UndefinedError for variable references
#### Description
After recent changes, Jinja2 templates are failing to compile and render properly, throwing `UndefinedError` exceptions for variables that should be accessible in the template context. This affects basic variable resolution and te... | diff --git a/src/jinja2/idtracking.py b/src/jinja2/idtracking.py
index d6cb635..bcafba0 100644
--- b/src/jinja2/idtracking.py
+++ a/src/jinja2/idtracking.py
@@ -235,6 +235,17 @@ class FrameSymbolVisitor(NodeVisitor):
def __init__(self, symbols: "Symbols") -> None:
self.symbols = symbols
+ def visit_N... |
Database format detection broken - wrong parsers called for file formats
#### Description
When loading database files, the format detection logic is calling the wrong parsers for different file formats. This causes files to fail parsing with syntax errors even when they should be valid for their respective formats.
... | diff --git a/src/cantools/database/__init__.py b/src/cantools/database/__init__.py
index 701b1bc..6d2e75e 100644
--- b/src/cantools/database/__init__.py
+++ a/src/cantools/database/__init__.py
@@ -331,22 +331,21 @@ def load_string(string: str,
def load_can_database(fmt: str) -> can.Database:
db = can.Da... |
# JSONAdapter fails when using structured outputs with certain models
## Description
I've encountered an issue with the `JSONAdapter` when using structured outputs with certain models. The adapter is not properly handling the case when a model supports the `response_format` parameter.
## To reproduce:
Create a simp... | diff --git a/dspy/adapters/json_adapter.py b/dspy/adapters/json_adapter.py
index 14c5230..d7d5fa4 100644
--- b/dspy/adapters/json_adapter.py
+++ a/dspy/adapters/json_adapter.py
@@ -45,21 +45,10 @@ class JSONAdapter(ChatAdapter):
inputs: dict[str, Any],
) -> list[dict[str, Any]]:
provider = lm.mod... |
Parser location argument case sensitivity breaks custom location loaders
#### Description
When using custom location loaders with the `@parser.location_loader` decorator, the parser fails to recognize locations that don't match the exact case. The location validation now converts the location to lowercase, but the lo... | diff --git a/src/webargs/core.py b/src/webargs/core.py
index 44294e9..eebfdec 100644
--- b/src/webargs/core.py
+++ a/src/webargs/core.py
@@ -212,7 +212,7 @@ class Parser(typing.Generic[Request]):
:raises: ValueError if a given location is invalid.
"""
valid_locations = set(self.__location_map... |
Dataclass __init__ generation broken with UnboundLocalError
#### Description
When using dataclasses, the generated `__init__` method fails with `UnboundLocalError` for various local variables that are referenced before assignment.
#### Steps/Code to Reproduce
```python
from dataclasses import dataclass
@dataclass
... | diff --git a/astroid/brain/brain_dataclasses.py b/astroid/brain/brain_dataclasses.py
index 92d983e..2f28650 100644
--- b/astroid/brain/brain_dataclasses.py
+++ a/astroid/brain/brain_dataclasses.py
@@ -248,6 +248,8 @@ def _generate_dataclass_init(
kw_only_params: list[str] = []
assignments: list[str] = []
+ ... |
Headers equality comparison fails with AttributeError when comparing to non-Headers objects
#### Description
When comparing a `Headers` instance to an object that doesn't have a `_list` attribute, an `AttributeError` is raised instead of returning `False`.
#### Steps/Code to Reproduce
```python
from starlette.datas... | diff --git a/starlette/datastructures.py b/starlette/datastructures.py
index 90a7296..32d49e2 100644
--- b/starlette/datastructures.py
+++ a/starlette/datastructures.py
@@ -552,9 +552,10 @@ class Headers(typing.Mapping[str, str]):
return len(self._list)
def __eq__(self, other: typing.Any) -> bool:
- ... |
# DVC used_objs method doesn't process targets correctly
The `used_objs` method in the Repo class doesn't properly handle the `targets` parameter. When specifying a target path, the method ignores it and collects all objects from all stages instead of just the ones related to the target.
## Reproduction
```python
im... | diff --git a/dvc/repo/__init__.py b/dvc/repo/__init__.py
index 2b89626..a18b2af 100644
--- b/dvc/repo/__init__.py
+++ a/dvc/repo/__init__.py
@@ -471,11 +471,25 @@ class Repo:
return switch(self, rev)
- def used_objs(self, targets=None, all_branches=False, with_deps=False,
- all_tags=False, all_co... |
WebApplicationServer and MobileApplicationServer initialization broken
#### Description
The pre-configured OAuth2 server classes are not working properly. When trying to use `WebApplicationServer` or `MobileApplicationServer`, they fail to initialize correctly and don't handle OAuth2 flows as expected.
#### Steps/Co... | diff --git a/oauthlib/oauth2/rfc6749/endpoints/pre_configured.py b/oauthlib/oauth2/rfc6749/endpoints/pre_configured.py
index d64a166..11f44d2 100644
--- b/oauthlib/oauth2/rfc6749/endpoints/pre_configured.py
+++ a/oauthlib/oauth2/rfc6749/endpoints/pre_configured.py
@@ -92,21 +92,21 @@ class WebApplicationServer(Authoriz... |
Text preprocessing produces reversed output
#### Description
The text preprocessing functions in the tokenizer are returning reversed strings instead of the expected output. This affects all text processing operations including substitutions, regex preprocessing, and tokenization.
#### Steps/Code to Reproduce
```py... | diff --git a/gtts/tokenizer/core.py b/gtts/tokenizer/core.py
index d7e0a4e..5683698 100644
--- b/gtts/tokenizer/core.py
+++ a/gtts/tokenizer/core.py
@@ -135,9 +135,9 @@ class PreProcessorRegex:
applied.
"""
- for regex in reversed(self.regexes):
+ for regex in self.regexes:
... |
Instrumentation path order reversed causing incorrect qualified names
#### Description
When using typeguard's instrumentation, the qualified names for nested functions and classes are being generated in reverse order, causing instrumentation errors.
#### Steps/Code to Reproduce
```python
from typeguard import typec... | diff --git a/src/typeguard/_transformer.py b/src/typeguard/_transformer.py
index 25696a5..b15e710 100644
--- b/src/typeguard/_transformer.py
+++ a/src/typeguard/_transformer.py
@@ -511,9 +511,9 @@ class TypeguardTransformer(NodeTransformer):
@contextmanager
def _use_memo(
- self, node: FunctionDef | ... |
Error with a certain version constraint format
### What pipdeptree version are you using?
2.17.0
### Are you running pipdeptree in a virtual environment?
- [ ] Yes
### Describe the problem
Thank you for developing a great library!
We use `pipdeptree` in our CIs, and it fails in v2.17.0 but passes in v2.16.2.
h... | diff --git a/src/pipdeptree/_models/dag.py b/src/pipdeptree/_models/dag.py
index 2f5df60..7749400 100644
--- b/src/pipdeptree/_models/dag.py
+++ a/src/pipdeptree/_models/dag.py
@@ -1,5 +1,6 @@
from __future__ import annotations
+import sys
from collections import defaultdict, deque
from fnmatch import fnmatch
fro... |
RequestHandler.write() method not returning data for non-HEAD requests
#### Description
The `write()` method in `RequestHandler` is not properly writing chunks to the connection. When calling `write()` on a request handler, the data is not being sent to the client.
#### Steps/Code to Reproduce
```python
import torn... | diff --git a/tornado/web.py b/tornado/web.py
index 357c5f1..f8480b5 100644
--- b/tornado/web.py
+++ a/tornado/web.py
@@ -1222,6 +1222,14 @@ class RequestHandler:
else:
for transform in self._transforms:
chunk = transform.transform_chunk(chunk, include_footers)
+ # Ignor... |
Contract callback execution order broken after refactoring
#### Description
The contract system is not working properly - callbacks are being executed before the pre-processing tests run, causing contract validation to fail.
#### Steps/Code to Reproduce
```python
from scrapy.spiders import Spider
from scrapy.http i... | diff --git a/scrapy/contracts/__init__.py b/scrapy/contracts/__init__.py
index bdb68c4..33a9732 100644
--- b/scrapy/contracts/__init__.py
+++ a/scrapy/contracts/__init__.py
@@ -39,8 +39,6 @@ class Contract:
@wraps(cb)
def wrapper(response: Response, **cb_kwargs: Any) -> list[Any]:
- ... |
QR code image save fails with "unknown file extension" error
#### Description
When trying to save QR code images to BytesIO streams, the save operation fails with a "ValueError: unknown file extension" error. This affects both PIL and PyPNG image backends.
#### Steps/Code to Reproduce
```python
import qrcode
import... | diff --git a/qrcode/image/pil.py b/qrcode/image/pil.py
index 57ee13a..fdd9740 100644
--- b/qrcode/image/pil.py
+++ a/qrcode/image/pil.py
@@ -49,8 +49,9 @@ class PilImage(qrcode.image.base.BaseImage):
def save(self, stream, format=None, **kwargs):
kind = kwargs.pop("kind", self.kind)
- self._img.s... |
SQL formatting with reindent=True produces AttributeError
#### Description
When using `sqlparse.format()` with `reindent=True`, an AttributeError is raised indicating that a 'list' object has no attribute 'token_next_by'.
#### Steps/Code to Reproduce
```python
import sqlparse
# Simple SQL formatting with reindent
... | diff --git a/sqlparse/filters/reindent.py b/sqlparse/filters/reindent.py
index 7dc2b82..14a80bb 100644
--- b/sqlparse/filters/reindent.py
+++ a/sqlparse/filters/reindent.py
@@ -98,8 +98,8 @@ class ReindentFilter:
def _process(self, tlist):
func_name = '_process_{cls}'.format(cls=type(tlist).__name__)
- ... |
Hive parameter parsing broken with UnboundLocalError
#### Description
When parsing Hive SQL with parameters, the parser raises an `UnboundLocalError` for local variables `this` and `expression`.
#### Steps/Code to Reproduce
```python
import sqlglot
# This should parse successfully but raises UnboundLocalError
sql ... | diff --git a/sqlglot/dialects/hive.py b/sqlglot/dialects/hive.py
index 6084d44..10a0b91 100644
--- b/sqlglot/dialects/hive.py
+++ a/sqlglot/dialects/hive.py
@@ -435,13 +435,14 @@ class Hive(Dialect):
)
def _parse_parameter(self) -> exp.Parameter:
- self._match(TokenType.R_BRACE)
- ... |
NameError in concat function when joining DataFrames
#### Description
When concatenating DataFrames, a `NameError` occurs because the variable `first` is referenced but not defined in the `_is_uniform_join_units` function.
#### Steps/Code to Reproduce
```python
import pandas as pd
import numpy as np
# Create two D... | diff --git a/pandas/core/internals/concat.py b/pandas/core/internals/concat.py
index 2ee7d39..f8e7e1e 100644
--- b/pandas/core/internals/concat.py
+++ a/pandas/core/internals/concat.py
@@ -457,6 +457,7 @@ def _is_uniform_join_units(join_units: list[JoinUnit]) -> bool:
_concatenate_join_units (which uses `concat_co... |
### Issue with HTTP Parser Handling Invalid Requests
#### Current Problem
It seems that the recent changes to the HTTP parser have introduced an issue where invalid HTTP requests are not being handled correctly. This results in a failure to process certain malformed requests, which previously would have been managed ... | diff --git a/gunicorn/http/parser.py b/gunicorn/http/parser.py
index 88da17a..ff112ee 100644
--- b/gunicorn/http/parser.py
+++ a/gunicorn/http/parser.py
@@ -26,24 +26,23 @@ class Parser:
return self
def __next__(self):
- """TODO: Implement this function"""
- if self.mesg and not self.mesg.... |
Image part reuse broken after recent changes
#### Description
When adding images to a presentation, the library is supposed to reuse existing image parts if the same image (by SHA1 hash) already exists in the package. However, this functionality appears to be broken - instead of returning the existing image part when... | diff --git a/src/pptx/package.py b/src/pptx/package.py
index 79703cd..53f0366 100644
--- b/src/pptx/package.py
+++ a/src/pptx/package.py
@@ -35,7 +35,7 @@ class Package(OpcPackage):
the image part already exists in this package, it is reused,
otherwise a new one is created.
"""
- retur... |
# ARC058D - いろはちゃんとマス目 / Iroha and a Grid (ABC042D)
def get_fact(lim):
# compute a toble of factorials (1-idx)
fact = [1] * (lim + 1)
x = 1
for i in range(1, lim + 1):
x = (x * i) % MOD
fact[i] = x
return fact
def get_inv(lim):
# compute a toble of inverse factorials (1-idx)
... |
import java.util.Scanner;
public class Main {
public static class Combination {
long[] factorial;
int maxN;
long Module;
public Combination(final int maxN, final long Module) {
this.maxN = maxN;
factorial = new long[maxN];
this.Module = Module... |
import java.io.*;
import java.util.*;
public class cf1428_Div1Div2_c {
public static void main(String[] args) throws IOException {
FastScanner in = new FastScanner();
int tc = in.nextInt();
for ( ; tc > 0; tc--) {
char[] line = in.next().toCharArray();
int n = line.length;
... | #include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
string s;
cin >> s;
int A = 0, B = 0;
int ans = 0, del = 0, cnt = 0;
for (char x : s) {
if (x == 'A')
cnt++, A++;
else {
if (cnt) {
... |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
StringBuilder sb = new StringBuilder();
int i = 1;
while (i <= 11) {
if (n > Math.pow(26, i)) {
n ... | #include<bits/stdc++.h>
using namespace std;
int main(){
string ans="";
long long int n;
cin>>n;
n=n-1;
while(n>-1){
ans=ans+char('a'+(n%26));
n=n/26-1;
}
reverse(ans.begin(),ans.end());
cout<<ans;
return 0;
} |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T pow(T a, T e, T mod) {
if (!e) return 1;
T x = pow(a, e / 2, mod);
x = x * x % mod;
return (e & 1) ? x * a % mod : x;
}
template <typename T, typename exp_t, T (*multiply)(T, T)>
T pow(T a, exp_t e) {
if (!e) return 1;
T x = pow<T, exp_t,... | import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;
import static java.util.Arrays.fill;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.u... |
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
Scanner sc = new Scanner(System.in);
int[] memo;
ArrayList<Integer> lh, lr;
void run() {
for (;;) {
int n = sc.nextInt();
if (n == 0) return;
lh = new ArrayList<Integer>();
lr = new ArrayList<Integer>(... | #include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;
bool ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
struct Ques {
int l, r, id;
};
int n, bl, m, all, cnt;
int a[N];
Ques q[N];
deque<int> w[N];
deque<int> s[N];
int v[N], ans[N], ok[N];
int cmp(Ques a, Ques b) {
return a.l / bl < b.l / bl || (a.l / bl == b.l / bl && a.r < b.r);
}
int main() {
sca... | import java.io.*;
import java.util.*;
import java.math.BigInteger.*;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.util.Arrays.*;
import java.util.Collections.*;
// https://netbeans.org/kb/73/java/editor-codereference_ru.html#display
//<editor-fold defaultstate="collapsed" de... |
#include <bits/stdc++.h>
using namespace std;
string memo[51][51];
string max(string const& a, string const& b) {
if(a == "invalid") {
return b;
}
if(a.size() > b.size()) {
return a;
} else if(a.size() < b.size()) {
return b;
} else {
return (a < b ? b : a);
}
}... | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.... |
def main():
while True:
n, c = map(int, input().split())
if n == 0:break
music = []
for _ in range(n):
line = list(map(int, input().split()))
add_panel = sum([2 ** i * line[i] for i in range(16)])
music.append(add_panel)
hand = []
for _ in range(c):
line = list(map... | import java.util.Arrays;
import java.util.Scanner;
//Beat Panel
public class Main{
void run(){
Scanner sc = new Scanner(System.in);
int[][] dp = new int[2][1<<16];
for(;;){
int n = sc.nextInt(), c = sc.nextInt();
if(n+c==0)break;
int[] a = new int[n], b = new int[c];
for(int i=0;i<n;i++)for(int j=0... |
val = 3337867500
n,a,d = map(int, input().split())
print(val * a, val * d) | #include <bits/stdc++.h>
const int ntf = 1e9;
const unsigned long long ft = 368131125ll;
const unsigned long long vl = 12000000000ll;
int n, a, d;
int main() {
scanf(" %d %d %d", &n, &a, &d);
printf("%llu %llu\n", ft * a % ntf * vl + 1, ft * d % ntf * vl);
return 0;
}
|
#include <cstdio>
int main()
{
int prev = 0;
int curr;
int sum = 0;
int n;
scanf("%d", &n);
int i;
for (i = 0; i < n; i++) {
scanf("%d", &curr);
if (curr - prev > 0)
sum += curr - prev;
prev = curr;
}
printf("%d\n", sum);
return 0;
} | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int[] h = new int[N];
for (int i = 0; i < N; i++) {
h[i] = in.nextInt();
}
int ans = 0;
while (true) {
int left = -1;
for (int i = 0; i < N; i++) {
... |
import java.io.*;
import java.util.*;
public class CF99A {
private static BufferedReader br;
private static StringTokenizer st;
private static PrintWriter pw;
// private static Timer t = new Timer();
public CF99A() throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
pw = new Pri... | #include <bits/stdc++.h>
using namespace std;
template <typename a>
void SWAP(a &b, a &c) {
a d = b;
b = c;
c = d;
}
long long power(long long a, long long b) {
long long result = 1;
while (b) {
if (b & 1) result = a * result;
a *= a;
b >>= 1;
}
return result;
}
long long gcd(long long a, long... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = (1 << 22) + 5;
int n, m, a[maxn];
bool vis[maxn], f[maxn];
void dfs(int x) {
if (vis[x]) return;
vis[x] = 1;
if (f[x]) dfs(x ^ ((1 << n) - 1));
for (int i = 0; i < n; i++)
if (x & (1 << i)) dfs(x ^ (1 << i));
}
int main() {
scanf("%d%d", &n, &... | import java.util.* ;
import java.io.* ;
public class F
{
static int mod = (int) (1e9+7);
static InputReader in;
static PrintWriter out;
static boolean[] vis;
static boolean[] arr;
static void dfs(int i, int n, int mask){
vis[i] = true;
for(int j = 0; j < n; j++){
... |
#include <bits/stdc++.h>
long long int array[300010], power[300030];
int cmp(const void *a, const void *b) {
return (*(long long int *)a) - (*(long long int *)b);
}
int main() {
long long int i, j, ans, mod, val, val2, n;
mod = 1000000007;
ans = 0;
power[0] = 1;
scanf("%lld", &n);
for (i = 0; i < n; i++) ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.concurrent.ThreadLocalRandom;
public class Main3 {
static long mod = 1000000007L;
public static void main(String[] ... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class E630 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(Syst... | x1, y1, x2, y2 = map(int, input().split())
x2 -= x1
y2 -= y1
x1 = 0
y1 = 0
odd_x = (x2 - x1) // 2 + 1 - (1 if x1 % 2 == 0 and x2 % 2 == 0 else 0)
odd_y = (y2 - y1) // 2 + 1 - (1 if y1 % 2 == 0 and y2 % 2 == 0 else 0)
even_x = (x2 - x1) // 2 + 1 - (1 if x1 % 2 == 1 and x2 % 2 == 1 else 0)
even_y = (y2 - y1) // 2 + 1 - ... |
import java.util.*;
import java.io.*;
public class a {
public static void main(String[] args) throws IOException
{
input.init(System.in);
int n = input.nextInt();
int[] nums = {110,50,80,170,20,200};
if(n<=2)
System.out.println(-1);
else if(n==3)
System.out.println(210);
else
... | n = input()
if n < 3:
print -1
else:
print 10 ** (n-1) + (-1*10 ** (n-1))%210
|
/*
Author: Greg Zborovsky
User: angeredgecko
Date/Time: 2021-02-27 18:58:04.698474
*/
#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(vector<T> vec, ostream &fout = cout)
{
fout << "[";
for (auto const &val : vec)
{
fout << val << " ";
}
fout << "]";
}
template... | T = int(input())
while T >= 1:
n = int(input())
arr = list(map(int,input().split()))
check = True ; pis = 0
for i in range(n):
pis += arr[i]
if pis < i*(i+1)//2:
check = False
break
if check == True: print("YES")
else: print("NO")
T -= 1 |
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int k[3], t[3];
int n;
long long c[N], tm[N], d[N];
int main() {
for (int i = 0; i < 3; i++) scanf("%d", &k[i]);
for (int i = 0; i < 3; i++) scanf("%d", &t[i]);
scanf("%d", &n);
long long ret = 0;
for (int i = 0; i < n; i++) scanf("%I64d", &c... | k1,k2,k3 = [int(x) for x in raw_input().split()]
t1,t2,t3 = [int(x) for x in raw_input().split()]
n = int(raw_input())
q1 = [int(x) for x in raw_input().split()]
q2 = []
i = 0
for x in q1:
if i < k1:
q2.append(x+t1)
else:
q2.append(max(x, q2[i-k1])+t1)
i += 1
q3 = []
i = 0
for x in q2:
if i < k2:
q3.append(x... |
#include <bits/stdc++.h>
using namespace std;
template <class T, class T1>
int chkmin(T &x, const T1 &y) {
return x > y ? x = y, 1 : 0;
}
template <class T, class T1>
int chkmax(T &x, const T1 &y) {
return x < y ? x = y, 1 : 0;
}
const int MAXN = 3042;
const int mod = 998244353;
string s, t;
void read() { cin >> s ... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... |
while 1:
n, m = map(int, raw_input().split())
if n == m == 0:
break
S = map(int, raw_input().split())
left = 0; right = sum(S)+2
def check(mid):
if 1+mid <= S[0]:
return 10**9
cnt = 0; l = 1
target = S[n-1] - mid
for i in xrange(n-1):
w... | #include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <utility>
using namespace std;
#define sz size()
#define rep(i, a, n) for(int i = (a);i < (n);i++)
#define lep(i, a, n) for(int i = (... |
f = [0, 4, 8, -1, 16, -10, 4, -12, -48, 26, -44, 15, -16, -4, -4, -1]
jly = 998244353
t = 0
x = [0, 0, 0, 24, 4, 240, 204, 1316, 2988, 6720, 26200, 50248, 174280, 436904, 1140888, 3436404]
n = int(input())
for i in range(16, n + 1):
t = 0
for j in range(0, 16):
t = (t + f[(i - j - 1) & 15] * x[j]) % jly... | #include <bits/stdc++.h>
constexpr int P = 998244353;
constexpr int A[16] = {0, 0, 0, 24, 4, 240,
204, 1316, 2988, 6720, 26200, 50248,
174280, 436904, 1140888, 3436404};
constexpr int F[16] = {P - 1, P - 4, P - 4, P - 16, 15, P - 44, 2... |
n = int(input())
a = []
for _ in range(n):
xy = list(map(int, input().split()))
a.append(xy)
midpoint = {}
for i in range(n):
for j in range(i + 1, n):
x1, y1 = a[i][0], a[i][1]
x2, y2 = a[j][0], a[j][1]
dx = x2 + x1
dy = y2 + y1
midpoint[(dx / 2, dy / 2)] = midpoint.... | #include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const int maxn = 2005;
pair<long long, long long> poi[maxn];
map<pair<long long, long long>, int> M;
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> poi[i].first >> poi[i].second... |
if __name__ == "__main__":
n = int(input())
a = set(map(lambda x: int(x), input().split()))
m = int(input())
b = set(map(lambda x: int(x), input().split()))
for elem in sorted(a.intersection(b)):
print(elem)
| #include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end... |
#include <bits/stdc++.h>
using namespace std;
int n, x;
long long smn, smx = 0;
set<pair<int, int> > mset;
pair<int, int> g;
void summin(pair<int, int> a[]) {
mset.insert(pair<int, int>(n - 1, 0));
for (int i = 0; i < n; ++i) {
g = *mset.lower_bound(pair<int, int>(a[i].second, 0));
mset.erase(g);
smn +=... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Input... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, skc = 998244353;
vector<int> v[N], edge[N];
void add(int x, int y, int z) {
v[x].push_back(y);
edge[x].push_back(z);
}
void upd(int &x, int y) { x = (x + y) % skc; }
int f[N][3], n;
struct node {
int id, vl;
friend bool operator<(node A, node... | import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]) {new Main().run();}
FastReader in = new FastReader();
PrintWriter out = new PrintWriter(System.out);
void run(){
work();
out.flush();
}
long mod=998244353;
long gcd(long a,long b) {
return b==0?a:gcd(b,a%b);
... |
//package Working_with_Ranges.Segment_Tree.Chef_Force;
import java.util.Scanner;
public class Cleaning {
static long[][] st, lazy;
static long INF = 1000_000_000_000L;
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int T = scan.nextInt();
while (T--... | #include <bits/stdc++.h>
#define fir first
#define sec second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> Q;
const int inf1 = 1e9+9;
const ll inf2 = 1e16+9;
const int maxx = 1e9+9;
const int maxn = 1e6+9;
int n,ar[maxn];
int l[maxn],r[maxn],t[maxn];
bool judge(int p) {
... |
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
public class TaskE {
StringTokenizer st;
BufferedReader in;
PrintWriter out;
long res00, res01, res10, res11;
public static void main(String[] args) throws IOException {
TaskE taskA = new TaskE();
taskA.op... | #include <bits/stdc++.h>
using namespace std;
long long getll() {
long long x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch <= '9' && ch >= '0') {
x = x * 10 + ch - '0';
ch = getchar();
}
return f * x;
}
struct Mat {
lo... |
i=int(input())
l=set(map(int,input().split()))
print('YES' if i == len(l) else 'NO') | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
set<int> S;
int N;cin>>N;
int buf;
for(int i=0; i<N; i++){
cin>>buf;
S.insert(buf);
}
cout<<(S.size()==N? "YES\n": "NO\n");
} |
# #
# author : samars_diary #
# 12-09-2020 │ 19:22:08 #
# #
import sys, os.path
if(os.path.exists('input.txt')):
sys.stdin = open('input.txt',"r")
#sys.stdout = open('output.txt',"w")
sys.setrecursionlimit(10 ** 5)
def i(): return sys.stdin... | import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class codeforces670div2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s=new Scanner(System.in);
int t=s.nextInt();
while(t-->0)
{
int n=s.nextInt();
int a[]=new int[n];
... |
import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
while(t--!=0)
{
int n=sc.nextInt(),o=0,e=0;
boolean f=false;
for(int i=0;i<n;i++)
... | #include <bits/stdc++.h>
using namespace std;
void tetris(int k) {
int odd = 0;
int even = 0;
for (int i = 1; i <= k; i++) {
int j;
cin >> j;
if (j & 1) {
odd++;
} else {
even++;
}
}
if (odd == k || even == k) {
cout << "YES" << '\n';
} else {
cout << "NO" << '\n';
... |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int i = 1;
if (n % 2) {
cout << 1 << ' ';
i++;
}
for (; i <= n; i += 2) {
cout << i + 1 << ' ' << i << ' ';
}
return 0;
}
|
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class ProblemC_46 {
final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok=new StringTokenizer("");
void init() throws FileNotFoundException{
if (ONLINE_JUDGE)... |
#include<bits/stdc++.h>
using namespace std;
signed main(){
int x,n,a;
int p[1000]={};
cin>>x>>n;
for(int i=0;i<n;i++){
cin>>a;
p[a]=1;
}
int num=0,ab=x;
for(int i=-10000;i<=10000;i++){
if(ab>abs(x-i)&&p[i]==0){
ab=abs(x-i);
num=i;
}
}
cout<<num<<"\n";
} | x,n=map(int,input().split())
p=list(map(int,input().split()))
ans=0
for i in range(1,102):
if i not in p:
if abs(x-i)<abs(x-ans):
ans=i
print(ans) |
//package round76;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
public class D {
Scanner in;
String INPUT = "5 6";
PrintWriter out;
static int MOD = 1000000007;
void solve()
{
int L = ni();
int R = ni();
String[] t = {" ", " B", " R", " W", " Y", "BW", "BY", "RW", "RY... | #include <bits/stdc++.h>
using namespace std;
long long iMatrixMultiply(long long multiplicant1, long long multiplicant2,
long long ivalue = (long long)1023123123 *
(long long)1023123123) {
return (multiplicant1 * multiplicant2) % ivalue;
}
long l... |
import java.util.Scanner;
public class Move_Brackets {
public static void main(String [] args) {
Scanner sc=new Scanner (System.in);
int t=sc.nextInt();
for(int j=0;j<t;j++) {
int n=sc.nextInt();
String s=sc.next();
int b=0;
int res=0;
int min=0;
for(int i=0;i<n;i++) {
if(s.charAt(i)=='(... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int tc;
cin >> tc;
while (tc--) {
string s;
int n, x = 0, y = 0;
bool vis[55];
memset(vis, false, sizeof(vis));
vector<int> f;
cin >> n >> s;
for (int i = 0; i < n; i++) {
if (s[i]... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
ArrayList<Date> date=new A... | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl
//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegi... |
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib.cpp"
#endif
#define fio ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define TC long long T_;cin>>T_;while(T_--)
#define rar(a,n) int n;cin >> n;int a[n];for(int i_=0;i_<n;i_++)cin >> a[i_];
#define rark(a,n,k) int n,k;cin >> n >> k;int a[n];for(int i_=0;i_<... | import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
public class D1{
private static Reader sc = new Reader();
private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));... |
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <ctime>
#include <deque>... | #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 400005;
char str[maxn];
int n, odd, even, buf[256];
vector<char> odd_list, cur_list;
int main() {
scanf("%d", &n);
scanf("%s", str + 1);
for (int i = 1; i <= n; i++) ++buf[str[i]];
for (int i = 0; i < 256; i++) {
if (buf[i] & 1) odd_list.push_ba... | import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Map.Entry;
import static java.lang.Math.*;
public class Main extends PrintWriter {
List<String> solve(final int n, final int m, final int k, int[] cnt) {
int odd = 0;
for (int c = 0; c < k; c++) {
if ... |
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
//Color the Map
public class Main{
class R{
List<L> l;
boolean u;
int color, id;
public R(int id) {
this.id = id;
l = new ArrayList<L>();
u = false;
... | def main():
while 1:
N = int(input())
if N == 0:
break
D = {}
G = [set() for i in range(N)]
cur = 0
K = []
PS = []
for i in range(N):
ps = []
s = input()
if s in D:
k = D[s]
el... |
#include <iostream>
using namespace std;
int main() {
int m; cin >> m;
for (int prob = 0; prob < m; prob++) {
int depo; cin >> depo;
int year; cin >> year;
int n; cin >> n;
int ans = 0;
for (int method = 0; method < n; method++) {
int hukuri;
double nennri;
int tesuu;
cin >> huku... | def c(a):
global y,r,d
for _ in range(y):a+=int(a*r)-d
return a
def s(a):
global y,r,d
b=0
for _ in range(y):
b+=int(a*r)
a-=d
return a+b
for _ in range(int(input())):
m=0
a=int(input());y=int(input())
for _ in range(int(input())):
b,r,d=map(float,input(... |
#include <bits/stdc++.h>
using namespace std;
int n, a[100005], b[100005], cnt[100005], i, tmp, in[100005], go[100005];
vector<int> v[100005];
int main() {
cin >> n;
for (i = 1; i <= n; i++) {
cnt[i] = 0;
in[i] = 0;
go[i] = 0;
cin >> a[i];
}
for (i = 1; i <= n; i++) {
cin >> b[i];
if (b[... | import java.io.*;
public class two {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int N = Integer.parseInt(line);
int[] objectsType = new int[N+1];
int[]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.