message stringlengths 2 44.5k | message_type stringclasses 2 values | message_id int64 0 1 | conversation_id int64 276 109k | cluster float64 23 23 | __index_level_0__ int64 552 217k |
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kavi has 2n points lying on the OX axis, i-th of which is located at x = i.
Kavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows:
Consider n segments with ends at the points in correspondent pairs. The pairing is called good, if for every 2 different segments A and B among those, at least one of the following holds:
* One of the segments A and B lies completely inside the other.
* A and B have the same length.
Consider the following example:
<image>
A is a good pairing since the red segment lies completely inside the blue segment.
B is a good pairing since the red and the blue segment have the same length.
C is not a good pairing since none of the red or blue segments lies inside the other, neither do they have the same size.
Kavi is interested in the number of good pairings, so he wants you to find it for him. As the result can be large, find this number modulo 998244353.
Two pairings are called different, if some two points are in one pair in some pairing and in different pairs in another.
Input
The single line of the input contains a single integer n (1≤ n ≤ 10^6).
Output
Print the number of good pairings modulo 998244353.
Examples
Input
1
Output
1
Input
2
Output
3
Input
3
Output
6
Input
100
Output
688750769
Note
The good pairings for the second example are:
<image>
In the third example, the good pairings are:
<image>
Submitted Solution:
```
N=int(input())
mod=998244353
D=[0]*(N+1)
for i in range(1,N+1):
for j in range(i,N+1,i):
D[j]+=1
X=[]
for i in range(N):
X.append(D[i+1]-D[i])
x=1
DP=[0]*(N+1)
for i in range(N):
DP[i+1]=(DP[i]*2+X[i])%mod
print(DP[N])
``` | instruction | 0 | 97,241 | 23 | 194,482 |
Yes | output | 1 | 97,241 | 23 | 194,483 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kavi has 2n points lying on the OX axis, i-th of which is located at x = i.
Kavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows:
Consider n segments with ends at the points in correspondent pairs. The pairing is called good, if for every 2 different segments A and B among those, at least one of the following holds:
* One of the segments A and B lies completely inside the other.
* A and B have the same length.
Consider the following example:
<image>
A is a good pairing since the red segment lies completely inside the blue segment.
B is a good pairing since the red and the blue segment have the same length.
C is not a good pairing since none of the red or blue segments lies inside the other, neither do they have the same size.
Kavi is interested in the number of good pairings, so he wants you to find it for him. As the result can be large, find this number modulo 998244353.
Two pairings are called different, if some two points are in one pair in some pairing and in different pairs in another.
Input
The single line of the input contains a single integer n (1≤ n ≤ 10^6).
Output
Print the number of good pairings modulo 998244353.
Examples
Input
1
Output
1
Input
2
Output
3
Input
3
Output
6
Input
100
Output
688750769
Note
The good pairings for the second example are:
<image>
In the third example, the good pairings are:
<image>
Submitted Solution:
```
n,a,b,i=int(input())+1,0,0,1;d=[0]*n
while i<n:
for j in range(i,n,i):d[j]+=1
a=b%998244353+d[i];b+=a;i+=1
print(a)
``` | instruction | 0 | 97,242 | 23 | 194,484 |
Yes | output | 1 | 97,242 | 23 | 194,485 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kavi has 2n points lying on the OX axis, i-th of which is located at x = i.
Kavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows:
Consider n segments with ends at the points in correspondent pairs. The pairing is called good, if for every 2 different segments A and B among those, at least one of the following holds:
* One of the segments A and B lies completely inside the other.
* A and B have the same length.
Consider the following example:
<image>
A is a good pairing since the red segment lies completely inside the blue segment.
B is a good pairing since the red and the blue segment have the same length.
C is not a good pairing since none of the red or blue segments lies inside the other, neither do they have the same size.
Kavi is interested in the number of good pairings, so he wants you to find it for him. As the result can be large, find this number modulo 998244353.
Two pairings are called different, if some two points are in one pair in some pairing and in different pairs in another.
Input
The single line of the input contains a single integer n (1≤ n ≤ 10^6).
Output
Print the number of good pairings modulo 998244353.
Examples
Input
1
Output
1
Input
2
Output
3
Input
3
Output
6
Input
100
Output
688750769
Note
The good pairings for the second example are:
<image>
In the third example, the good pairings are:
<image>
Submitted Solution:
```
p = 998244353
n = int(input())
divs = [0]*n
for i in range(1,n+1):
j = i
while j <= n:
divs[j-1] += 1
j += i
total = 1
for i in range(1,n-1):
total = (total*2+divs[i])%p
print((total+divs[n-1])%p)
``` | instruction | 0 | 97,243 | 23 | 194,486 |
No | output | 1 | 97,243 | 23 | 194,487 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kavi has 2n points lying on the OX axis, i-th of which is located at x = i.
Kavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows:
Consider n segments with ends at the points in correspondent pairs. The pairing is called good, if for every 2 different segments A and B among those, at least one of the following holds:
* One of the segments A and B lies completely inside the other.
* A and B have the same length.
Consider the following example:
<image>
A is a good pairing since the red segment lies completely inside the blue segment.
B is a good pairing since the red and the blue segment have the same length.
C is not a good pairing since none of the red or blue segments lies inside the other, neither do they have the same size.
Kavi is interested in the number of good pairings, so he wants you to find it for him. As the result can be large, find this number modulo 998244353.
Two pairings are called different, if some two points are in one pair in some pairing and in different pairs in another.
Input
The single line of the input contains a single integer n (1≤ n ≤ 10^6).
Output
Print the number of good pairings modulo 998244353.
Examples
Input
1
Output
1
Input
2
Output
3
Input
3
Output
6
Input
100
Output
688750769
Note
The good pairings for the second example are:
<image>
In the third example, the good pairings are:
<image>
Submitted Solution:
```
import sys
input = sys.stdin.readline
n=int(input())
mod=998244353
DP=[0,1,3,6]
SUM=[0,1,4,10]
PLUS=[1]*(10**6+5)
for i in range(2,10**6):
for j in range(i,10**6+5,i):
PLUS[j]+=1
#print(PLUS[:10])
for i in range(10**6):
DP.append((SUM[-1]+PLUS[i+4])%mod)
SUM.append((SUM[-1]+DP[-1])%mod)
print(DP[n])
``` | instruction | 0 | 97,244 | 23 | 194,488 |
No | output | 1 | 97,244 | 23 | 194,489 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kavi has 2n points lying on the OX axis, i-th of which is located at x = i.
Kavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows:
Consider n segments with ends at the points in correspondent pairs. The pairing is called good, if for every 2 different segments A and B among those, at least one of the following holds:
* One of the segments A and B lies completely inside the other.
* A and B have the same length.
Consider the following example:
<image>
A is a good pairing since the red segment lies completely inside the blue segment.
B is a good pairing since the red and the blue segment have the same length.
C is not a good pairing since none of the red or blue segments lies inside the other, neither do they have the same size.
Kavi is interested in the number of good pairings, so he wants you to find it for him. As the result can be large, find this number modulo 998244353.
Two pairings are called different, if some two points are in one pair in some pairing and in different pairs in another.
Input
The single line of the input contains a single integer n (1≤ n ≤ 10^6).
Output
Print the number of good pairings modulo 998244353.
Examples
Input
1
Output
1
Input
2
Output
3
Input
3
Output
6
Input
100
Output
688750769
Note
The good pairings for the second example are:
<image>
In the third example, the good pairings are:
<image>
Submitted Solution:
```
#!/usr/bin/env python3
import sys
import getpass # not available on codechef
import math, random
import functools, itertools, collections, heapq, bisect
from collections import Counter, defaultdict, deque
input = sys.stdin.readline # to read input quickly
# available on Google, AtCoder Python3, not available on Codeforces
# import numpy as np
# import scipy
M9 = 998244353
yes, no = "YES", "NO"
# d4 = [(1,0),(0,1),(-1,0),(0,-1)]
# d8 = [(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)]
# d6 = [(2,0),(1,1),(-1,1),(-2,0),(-1,-1),(1,-1)] # hexagonal layout
MAXINT = sys.maxsize
# if testing locally, print to terminal with a different color
OFFLINE_TEST = getpass.getuser() == "hkmac"
# OFFLINE_TEST = False # codechef does not allow getpass
def log(*args):
if OFFLINE_TEST:
print('\033[36m', *args, '\033[0m', file=sys.stderr)
def solve(*args):
# screen input
if OFFLINE_TEST:
log("----- solving ------")
log(*args)
log("----- ------- ------")
return solve_(*args)
def read_matrix(rows):
return [list(map(int,input().split())) for _ in range(rows)]
def read_strings(rows):
return [input().strip() for _ in range(rows)]
def minus_one(arr):
return [x-1 for x in arr]
def minus_one_matrix(mrr):
return [[x-1 for x in row] for row in mrr]
# ---------------------------- template ends here ----------------------------
def solve_(k):
# your solution here
if k == 1:
return 1
if not OFFLINE_TEST:
if k == 100:
return 688750769
res = 1 # series
for x in range(1,k-1):
log(x)
res += pow(2,x-1,M9)
res += pow(2,k-1,M9)
return res%M9
for case_num in [0]: # no loop over test case
# for case_num in range(100): # if the number of test cases is specified
# for case_num in range(int(input())):
# read line as an integer
k = int(input())
# read line as a string
# srr = input().strip()
# read one line and parse each word as a string
# lst = input().split()
# read one line and parse each word as an integer
# a,b,c = list(map(int,input().split()))
# lst = list(map(int,input().split()))
# lst = minus_one(lst)
# read multiple rows
# arr = read_strings(k) # and return as a list of str
# mrr = read_matrix(k) # and return as a list of list of int
# mrr = minus_one_matrix(mrr)
res = solve(k) # include input here
# print length if applicable
# print(len(res))
# parse result
# res = " ".join(str(x) for x in res)
# res = "\n".join(str(x) for x in res)
# res = "\n".join(" ".join(str(x) for x in row) for row in res)
# print result
# print("Case #{}: {}".format(case_num+1, res)) # Google and Facebook - case number required
print(res)
``` | instruction | 0 | 97,245 | 23 | 194,490 |
No | output | 1 | 97,245 | 23 | 194,491 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Kavi has 2n points lying on the OX axis, i-th of which is located at x = i.
Kavi considers all ways to split these 2n points into n pairs. Among those, he is interested in good pairings, which are defined as follows:
Consider n segments with ends at the points in correspondent pairs. The pairing is called good, if for every 2 different segments A and B among those, at least one of the following holds:
* One of the segments A and B lies completely inside the other.
* A and B have the same length.
Consider the following example:
<image>
A is a good pairing since the red segment lies completely inside the blue segment.
B is a good pairing since the red and the blue segment have the same length.
C is not a good pairing since none of the red or blue segments lies inside the other, neither do they have the same size.
Kavi is interested in the number of good pairings, so he wants you to find it for him. As the result can be large, find this number modulo 998244353.
Two pairings are called different, if some two points are in one pair in some pairing and in different pairs in another.
Input
The single line of the input contains a single integer n (1≤ n ≤ 10^6).
Output
Print the number of good pairings modulo 998244353.
Examples
Input
1
Output
1
Input
2
Output
3
Input
3
Output
6
Input
100
Output
688750769
Note
The good pairings for the second example are:
<image>
In the third example, the good pairings are:
<image>
Submitted Solution:
```
import math
import sys
sys.setrecursionlimit(10**6+100)
def div(n) :
cnt = 0
for i in range(1, (int)(math.sqrt(n)) + 1) :
if (n % i == 0) :
if (n / i == i) :
cnt = cnt + 1
else : # Otherwise count both
cnt = cnt + 2
return cnt
def ans(n,pre,pr_ans):
if(n==1):
return 1
elif(n==2):
return 3
elif(n==3):
return 6
else:
return (2*pr_ans+div(n)-div(n-1))
#return(2*ans(n-1)+div(n)-div(n-1))
n=int(input())
if n==1:
print(1)
elif(n==2):
print(3)
elif(n==3):
print(6)
elif(n==333625):
print(668510586)
elif(n==1000000):
print(123)
elif(n>500000):
res=7993472373202089015346647259458696082532062862039876127112380610002294466097669420037495436014591213822038512726371749787635107773503232815107353201490561733068556198634847487052336375482771716440411860106504919923562698197474940717127996272801574351759103670244013302239415293457942065023154673574287881689064254399390214425177532534724504542132860236020385100915569282371191306329419371012535306844448580425305073331002510251604376156745018741535036236158474033088461882232816490362398455282999089900777611178701070578263349930751866527191899521750327259931635264949627609097326867245406307548062359611360456200585578685198529107240759809674346888474129081507302179820852158871688492052143428447146408884629001561715613126946492846050043700708012396025694566940049025702264541133543552570009198512135914634616270793670649086755437746294562338681811659055571053773936719489490866376590116022752817096127301926735453981640946449738923700816159879300620418544068515572461086348779252484673906370928303878981364152931180836741601754303560146135040878557646910891702601595496323831093367385164741130605712453031642619262741374572551937392865276572092910751970467030924869960564754562214745267467123766122647523188367482572659366827119395979133050779070475415999478381726825752723458727062962175679544429793309486904955151123773276088959584186136260914906675356533754416423735003677657919597753135215479694394753387739976719844624811251825155613699140719712918587009184939256583869807607323431930999369356297145440636860748846648445060967392387477396002937177384754299464397599037639346915864896263655987235856260830567654433576858661698515077511243395990156628569371514509954328735162481834133799531420136265978578446272807576640213659342565699272273526388328432811597525002655935303554530003297243494487097505292057245356072184267495073133337945179019479106174699236530290672500893567368740860311832438547491457093840620682536965693517918553951227851384080598619289647140632641704666936961373383992940988910964492195841938067636392239511609837490266391908917135845124496992739570560966972180993782994341156239912474384407570826593983299825469050423480513103660584465632895472212985958560872992900927611751999880044377825418309021208714668982676874567216877970432132683652204490869259219957866144482537278405557967358291453406204237366272824769915868958720954954613861229920937958377646247376027568161666055122108149714620455086237489051472689473393357194163439393384902337791096896632353937721797853193110903255812607246444735216588758824285124880490687753611915080221903797559718568987976261983815913349660959513865810142828803990013587967731454871947234705943992890490310113363176235353986986819033078048800956715012138425304808901519312676376473152826451140689306132299722068223053751675945032000436609761224533196350568047555606572142133442653106328920949002605391877706507944401227965945453630524937569321994974550298793156905811442968542251997563714174297026752463498238554414158954951361339256233871076078757493224859058252728342588828483616060213933655669468598307162549310377996342385506669668328880256808848725172682082877978103234928014111254999230341982482073170398593920749422254753345504268868482753286911209138894278309548379295578525315452486681009657910894349084859073919932580150393192398207823754893574629283233583762524934937851288111180809434169689666348952088771821484195118173093695409984889851627958800810557679276183773444910752006119236451394764143246375869216540645327643716115268499829917375105154435295823409751918845629831962531454068626527275301203287987546766408465750211115476874361476540936981205892211201332286353497373812655145473919586734592394709477616541469942984247244178178906270780992188986174724024053594972686081576130571449368167769501520360079004105755826222094909089023772215710031604299643123238191622864858519497870148714500586415613777608563570183227699982156757947181846691484140781885134063654177794797201549831440409383444758130150483821442159283518933200459590316058989345047420738318598972395290804055040909992880914795311459451914738805010306325112508381353530051185304657336911321100584439143461596870138347178592045784220956941750070870787416669599780102365066484846934808938454976184160984969759655925522581007488644414005290962609183698163469877509420621331023369365280750530022367930413229229437636542719743554387933460582966677012990860579453223805003291924381659535482203431424036026857225969378872246755851402629466052534105682953709824361008049830316902843262497096560518865638768144130452689321861636499748393608095738140051509735006832318894160596880164932799408761843201084957098717173329568250490499782667386974362133887079926521459010748493214312180965012141618378372257551571657408500710372091275321454698216478597012523643374876963391801558695383666361159000252175715156339688890083550690606608639075469373892633649885780659352268562011426208638470673720848872467661750641544494815320794338527814671929431902306885392313648522371690119248444373757306217652708451057571208298538480006227266817301780959689616480820255528933418307373932304808638536667448855704230521702061183879759256800911455806707045481165120836981663084806159718564536209198480334365828238050410934498634076655679158063207252187940105841917097752049338637875735694917471533430265919043137827986213925121547970402026374302911839293287510592213835990343536193998259122523801881987137572273247163443185582329937081174190486688749215484448234947416078991960235611190323878578275996888233385463800925425339434386324686521438726587103573345212033360479687695317279052926872466755285783717665943853405655744646768944515984612168218159771827681881884374519570794728927372782821391349048064725288011809103419759716123710189933533646964674675239646387505894266175128680509944177187747686555801597446844990946287078286479212959915474448636398804445196881992927916241371700402997983231753273835842126222481437822740325304040293285096049678976503458372626771144815882542074982717455411937902122251671682579404234898720717822787425285266974279202914015180456245719128583410335657235158029495481550932876363597831728587709081487727913762829850007807642560273977216874668720069808523057572777583985825130829642724321004886693737154871122578280309613683824107657919428404979031873939428723871364655771175794812037013832997509459077323333105725926015305559662301154374343501054069320944872931439825919342540975026803804161775864079017007654011285838915099478794667858617932572362941180713315214215792723977451642619487480432969685764140491085403339538604311079889348246958447970318179814845507751095461558928103239886604428409429147508579884645110072411760405667152264605977471917734128352440544304295716510620987099162919728023582427113786066815921638449380093132691747719429724048414793949286017833548033901324969519776787933718730264712783309750787389491329049096282782178863966985880861095008455163257371875772965076428837811697664413763058250408181636396294387478128726008827351313712389100049488965432602707791269047370837102575331730582551172731234001161875357354396443408074485270811798380280897645295048067942238046405964875614295299080153434448977410859999689093592501378460932467335733327793211124199357157554177408075193131702585825512006194935034923075875650597030572306995420300577771567098047421335294852013845005565267112849372626081897819042791969276296931882025610152454662994495108145172968081550975664927627313573554424361782469066089380839892447087215184824351924213982225071633071573902019790614460799299354834271625046478126639231549225754275595882463915278563646072373758836118183925108641730253701343664763608306425748394134595580779205123735693671718317514717178117087982239395417244619570164263616675475461594122074841074047388282527090151981226146377554773706982563848701766888632660045636849604070705754298355719638807997524170815868571925018365555898301089364372751767605349745881582957935661722518570218500091681582865095619795457060300195560122306456005388606304574173497771532742531686311661628808934478144521274373515464848402118179224837767024145128790657734052605652977935776394751452628734841281411790733255285069105408171509337873817243350830197373571142535126415148107268580693728656826344595451102807242000914505348212696643558452280710872006463136389692441202415821110316776771224170359398041368644186743641066212794135227309948003682870295505634458591470598291215556354877869384056069470841495138204162393219256954463207498829913770437765678322293662239593654606194092570217177731021155049298054899675375818899125558938676030359915958065148199968681862608919294371185276075284267843161489117007657678543517344127566356803997272958188331720064069752153893598660574117854992485764176214222487380195272405684330522659431930257015182189731469305425940851447477776396238763495199637729321100841406165627500875654873319206451783083341519146837460512334850341682326700600576857633757561751143934881260359841737175391094415912827491135073151644843893569741902605597359064209627765187582482781707156857559412143366699513225492254331682830253785426910382601220662574549673255805243278245653806046114333135685217049452879360072543610512743608990551266011696813741204364957166952649738684848494446135738311240486930911625923310517484571222885964508989408343036626585868891376434036474845416228850353325876799744439415055812432656547612929109666833977803709581801829262625715290391134636453949421173283532428057409173588534402148878442324317032465009786827469058231957061364260719593889430323184834060125080056487863271944917733710447163279666172662793046919768778224371218026412177115555958377175778025665282567006452028152490794793661576162397228682459891825131679148709529555880730137233394601604817145660067710782886511369145348732921183314626022058652804198240864706734173199026353258718878032030934167297123014545632702546448853418300830119018260932630179438830965642028804536255615061825732052284192374553661616584201302020334257677394672684333941794955831793759234229363083090084179895205007149146230831848046760805976400745541220880070481934458222169516716027599256657325985286728975715091189987428115112994120702722258419661476010283495322420194948533043000250578622433718214164915
for m in range(500001,n+1):
res=ans(m,m-1,res)
print(res%998244353)
elif(n>400000):
res=8001457083120437458753816741146583024273796972656886861406341277697147332169727739984583243708670181166646895440620312588421517440527754710898942201543441778588894546483519857276111568042433258766354072799055355906783803080039425650358300937309119867754933317619566395584469220318740953828336650192442211292492672453268682426698901306251410732966459023475853800910392301413829588925093057170521779822703271586680117299048890731754835211168807805288440130319490011732933559838092096900345305721102795182447254579982163137307957410924240383494256181715502594403239898134521985732805251295359790377012837697766867351725964335656116945931644288523731788358633971489643588074619443437427547024422066874463967868146275469462192312292396211807526797172788880611796054300969411841752781245887340183107403001601080072145514795664306927659835851800913303433008938725275822810793128791392527558749912615317013135880860326457378072781883610906352110212053107453668632920581514699476359998495250020871760096211283225465018560570984439643743420417950983350887259917686690493105104304625396773170431263159743400990298742404683768509564610734868655559726902015503303218515160802429401424015649139391562639926499644343959274804666635968259632412561835977958883508612822790678806043579701283803878588173138420188188732732547570461964647958434120477814316042694779966549239503538198878783697311983934787878751821604111743953858500068519965798602107692950137752508623270100232952221725829929079402604400938995983086178082779390052290115363534088822724997625314702946144329592223005303955336791369599448060639837357241062481121737344750658933845450930742658169624692129926689433258193231467532361293462848264320108555391647946299439365879490170496902473082786117558115744411484363047759470263087127288900530840436243790049937912606955570323572577885572093759260448805621285972002612113000440754154648959199864480848317149949733563960269519016118355435657946148496937224825155536436303817557410663885078257661385520497162530740171407523189060859147736308117128883474576283259847821719868959283163536010994435057224558115953738514867850822956825622903242878757475275987474747645123687185979072813433465216340431989634818781389456345939475739709257075242915016693799618100462936155981685536085509493612124096859496516338767642448120416957335079112545111756647712400192335777334468809225215450649553036910107451816306444474770579007222973718941429886147162465670582994383460628094260809271356597769821256910661256870231981524968582735020037132604712848587452194977538501005001259015812285537411441459573486602513642379704366928166629241854644982117585005314239270259052031992130310137659782368402892661797087968966163256044854180750618691017852565802965528559577686751323434286623451953407223107267085365292452109819535288015892105808195960168771537860545740972567845246566158332910373294349375195335763185441228146967471077921554208870531507784641551782650110578574277146330467283015610071187126096924157673233187304774233713039476241886985255757796724229998901873773585136398374299400651367076963225624792039913550946668685109382100844589250022368124333935637763582322095382016420145412782242286924131580285148125427595931815056000484012940535287867496154800877211695949610887753821158740076291873356780119156190234925452115145408119009583025779103838994915199690882899933438456640696923089559891925250427346286186555637281294067616490770102949784741629947546423511792527088030299686434541916256529458060582120820263054951436084289157221807911309067480941213581049302717966211705255053046290281846059653768642315593625398209436046382813088455414214693272946686942067380192952184984914645947574330050979040001447187639837314752197558099595708555077226890954846218125788227577036222491582779397116700310329090355382036451222213020656407881100889748154829439540356787962432883682440919619634042418838992495777653291964264422189908802817908293157827841249158936574410588859670995581777118407112844234484779424207197643609137278009629293179226760542536721430685529208825692532083179441183460277737326062510916873055175893651151895266495347448410950425610561107342780071290994559360998135656338626864469027483155982558046978992949863352965646275757949294951851832842919298987579758095959656439985880380522841485428828059698878644550214875001378335833572959593280577469606590365825494611767482085589060739225018207390002510472970919411184749965434611203618786483274629773833702042545866160110427505547092147873506794823675196310007728408164422741909244972417125774062145508429917723526510877819739294194418322785299667849485257916557378764777264003269647826529808710432360711543336635614558841953214619366504633153749725456291557657211047828697581678481487904909485439659737722827170811470076399359809736028384034565366663282683447889467673128884021931567447469146832472560539883547900836418097872287745480598119435186443562043171980475457186105345253863175502717722466423759795149009085362122190652144103238784156917045245075039494657867197357099510123081690193128934855439720912373141732431010671843884488333965763173192982590747459073452943889509973493457533539386340883262267699691989044602755407589941548713919529936520353701902791716450443215000649383629318334044958999191906330270666941999085161383038369926616369327396448278436875598969309294186646965637403463424758116949589085764804523333860540089289501211433476142017169555521672762136030977096547322706162766686700809802770998555399547823044080207998529128242646085974354941777668056086810852194293699531986038767463861627292818254475181752527879053255991030707778981639731470791248537975967081594782579105478650321459598181344978227299686099403039084449461518607112866168643836758957295494774414522942433874396091635036516389744305994117215326890168659475493766439725799013950849442475495215633992168820415930085650665394461942038449757870256568121273748485770617085139512799483534222825967778025902049122890581114625650900942444183985546042653471953892949498604995897641723970684719198088531160234471868397455550313992152257934417297312886155673536088845542551406522184644443146564315647398967824559975059754032568980740871306216351016911697758542968106261476904391804398617842498605776848534879882966495853404973319564051517606267906659747856001411557798757446598948862434465056768005767719611558522973167196310731104808320233271295010867784185564475088492679804407421631856387110553975433331344182030776212042989770004051081657359099687981715124487402917543037484145699879601284282091556889280217223754107481620001268897467985090635221634052067678189421803756453332554825832970299881045197289386992627100969559979288772658715044615814120415916714633427148100121907404447067172166287611003177926330873538652981495560784810494577704004440326531053204834791070742348676095331892282607182319736736122660437535068721991066123129247837406276805682549602209725430462589762516386659503457675753609378476841531712822881690690955408278079234450321895611286667792662373062950254097233951768820849775160194439257738421440661027178712080911233800460590093903893645755898830049209423936156386827253705922411492576597315993348768029865902313917613125138572747725887278878858473856966960146776878170796621247124320079537945257647639048144391932617776494615922679061111396801223452623230790845535293822371213846454479015663313639220424171905806605772305901461592502622731311159411982526526951542559660802671373181159413313446453264598629008245039543927053590535474865101541855686088018543149026158893423740196289190055237132339409273623137445040460034544548235173122948884477594843989414145971736991194889183037299522260953354553029929250393585939549036377675026017828875972450250693211978688741696656459412094568819033756018102994930695517661494973027841345120956748296873114008488327787162232871019530445562144423370785663658793737129567214305880284590211756920717829725730638354891356996827019326215758897702407722049295720662061011506834218108504609600867638403171258222068923242499343759341641941672831798826095247071564642234050575085557288839717181159113154880686337258873648807706545909361490882646056554538355402280403020227397909067709154134138284110977366337675312461024989335910262944311720021825726335342905261894665434866636227199510553702177193154970445819778085564064964374137777415108242424883704628544617470391851699244693208282247948761396791001852782435500388121485745537693302119301593124554442743338599332387622728005123251692529215258665220202604531254216493155240698924443978880256921565076004297892412385544317707751695333545860054402083309868054239982651637930876471479274828109003764042684883194249056018653056407933143729247052512487950818878380884675579648709402071927240114624582618813674646266396261348354420965668052659729681711057985259417250267160635299963715576691398449869181893271919405093736979341127800712852087829789921508329545844734367452930938800446055932438844622312526665249995052951669440875157471925887034135193951752681550261452363529690030963758485191449947122209248889972788569039860294229372600234733992617900554616418529416101279868116833791057303723037307025512321342152725679177347437469331810346871301508344487501662865765528556172238094541458423944747452216296613602464680959498935800243282739121266586578263085338468304397190045165422693779924289534592876688086082276512921190506407945740716768147141485867663867491092838145130386093015318343833761129652509104497487260145995546050580513145772242279424118851255612876573837960014069771514311781009484109101575033304027684457206295023972014350260534755415045757344812430780778561578238922217090718443805597698415400638107441937044128817966821841654448692635986319766072847749635164360891925794905436686970157675548127180285036379222585545083112460586285703191018304888711924294561323055745947325531337962193605285692843439043825183754056975702341163477087688763158980360627222962407621737885711357357810768386900495113701973856923604404619801561223602320223817305671284230949231412950944375884586766439697567867223981881699216048306479761534957038672413287041434726295010804758339379959887481340504254910177148750175076592000832000983877550640707747607101088318274044835379293563134588614232081520237236920593747967
for m in range(400001,n+1):
res=ans(m,m-1,res)
print(res%998244353)
elif(n>300000):
res=8009449768995854811411655849707156308854078268005173975012032013846509806603736441663361906458873267429544610288897915707850299207449140672451059356628278326072583844915060937394167486088087284632792951873526975509261947761133873711500928594520565654392638068701460868976992791175135208774946725041104924509715175757133841863441452210769126061168119938454561427431364095143085915604705538470950444723513074701496601410677742435184271246873396766493630909186924930010495107220949828332892452528090752604447304470885659739018925696066297325159035503830822784532506951495131197806353629203709475173235006516630574997675821558416070083084521467175276654083027879510483051034851485683184078383567723072792108928462853519189970140603132937336199496828158069971341607170448361594544809389678088969937074720085589700784318737955370613385761740883970451696552328711248155866564164917214402968343220174655409056845113127363557324916300890039721622802596560737437884382659658513016649026633655160920956145889183236946069576447533300545324102210404933138099052421741464355084633037800169274181600612736940484097214947231511671974319592759264171846996301689708891657674114343490635548875299137844191019088977863377777709763645019799826602335030497643443256054459328628688815433769086696572328352849925318106577544133789448230189966360416828693501415354454632868365135770286162764989978539019384262453255437586310709202990093114323500997660436894784996639486821321816872877437656208577266111083648251145544150940843420015843998429748968919222719803793960265106858209270868977774707178709033782835859973098230435673628705333724109508330540936980496462274269353171965565584936274595633345453294042307055180360177721104090088004267521478354672929229108625322223441700154125544106233534733257906629158225269659788648667851231917425360138795613167704538674753149689229034203584744348817311673965581667390409948537499630207287146569690107415261163936402682695458346967129483264490533277008469672763958652036882796803809695385039712410082200712894001461205810753456611370503552231881461782546727087993513710129201110156393314548425353265410401731414615793770835486967416799089915209279646977250526604971847025990596026894537021863337824196234506783903522223709126407792207710233205007565027373871546216256853349081173090586718754290060924696519849090640456643040687463798311022849880166593739977170187370397347834273925621188474060260437925390953545404147931798391088116822997964279198229074984883972875641547043825342150375108280947659639470298831217564485631260047034041880544924187926641687084749909908498799497679065678518574978920726114375320580766913183294580727713622276576376780323250631415408828547047294606207343038394414868789783917053379964887888732542163791555904314607582902036336859427005066231107110894929741267205038036485279595957685849512534327565301879096441341133044227817437873809323296295041045166529668326206553320579573922041681398762456425198601897470193746794348314787180680654480215090917987767715235816785198618355810057563879724409213047749481959154187428238287920614219754275641096085934252368676372385794900677437152534669625694697393622241228185985650889980324375384702947843795226832895796402156310005252445834828506387139074289493155533571790231696139117569590064182100974272559767362666334832973738183953037285194253946058527985816605116536625045219735495720577015185434079403547968369386629501104708969613510235517035952733369737589856836092723270902308803084005481705408768228319047781724160121894832036047305077199210360385784976644928283027443259579011262193066489263671518381336404077679185915918279706531858549870971491681972036296391178343611035122701937674282712481396812931214798793632027360857225153047999845680049428353754214758552849785641025482164983376642407145261851890642501121327430841461643237367656528137153167583981795647068490772331920205375706639763152261001075692714210882919108935484842403116706508177684308289972969599416291339842563059564271512875839333722188785441287248446117045821404137605619621806849363858546612125823371272995566905100904351540446239018141615592096185869645596362577521789183893613677601007577422829649774998677115896430748465573220225120443914068768098983766142058697597953800580677662162924304756290488081558797351130101863915928615002181385804561107591426916152868926234161809576553779562881942495263729612959057577210682959015521441937526009463190069065847037878683654626392146641671208138749169432458109178809436688238333907131785711486677751698504535436101115054516022549413919256771910988934789421510707087280231030223888438586069533930820134633719401954924773858072079420875954861114304127544669910477133555471221991849112104826958701223808688008142836079602035164918196217294506314353698617043608232694354280236022054684426043582022561194315343833891464489053253861244374206299764732759355834796604210295015378758903656394921039707207997431114618117348767861650627428507375736230309683239538491964235089931658364970554601674178738934102458390551133949633602330186402184177393111377079087281652505969922954307819835280212324526018701473088126778199605996300952343980849530498876402981125040826432724524307444528975451233785274093242150161695608402331250527037493674924002354045655906035805885035324117620106384282927877040288227149072438689355449380581473044417297375995081479054133386615442628637011314724288548580219164897234959461426405089700209038341280627342197717659286215116692135149008581412386087126223637914809521252370367640037905643834808694083135462767589032678193728894111253291510231802114920009042852139297600537929185634475315383935365248539073470288234842312478041970214390624865935754459618668453491570612427752116458501857361555234943797338657757125397826216249310927970249903627427669361254178882508523994231134594735313963389064408845332123181421157671941404597938977749876936866532519436997009448658376407547772533241242322699385262924738307106828358677862857414467852086194401278013025085725798804045651148207232993878804897742829655111447133262824032472990319421335991416121876627283034412493759035418580266970504821683384120448953776824130726604450537049539733050306235644870077621760850332103528109709575255940234084353247867223980770002017031090646732725359431473589384370772917759107677878358904111337488943965072623324969260984069572547312190178130464210562138022592130871434855852344689972342820321066504737121293804797535468461984818427632981837115289069042146975289439638890661509438846354638897967877497699099678187802219048732391729803095075060072891647765902932805267396366837680994415281650759417673213479659856240437516283654795954111555106793146811207167290702371276699405778690034101522588472724988248011331884701213019605286064911030159905848605902252993921818488090049411925630669081806884437793976501136772369299116568351429956979798445999485415962230262981577144525090815387273476298619534955795444704221507106245250256771211124114273042081139770480825633981371318794924954289809922400980807194050313728410629368972697584120446942022021336483608585393153543750031803135090917861181195368521114168542927530368580834778603089395395175630340009421981391237295616573745876350839796899841699997651605771046173825487484279594583587798515247988067089485723289148246254854812551252434918560003383464172309596964149669495034426872267910586945874450159106594409345932525700507710900568734772760664873200563785853691049831332252385781364632197978194163434490675973336984271713403048019134178776473424842493174328844329091696956372904460795208153486318644086438898241943642191192173657618752941869386081751661311864680508367738285448909891154288270001499444815033098489591254888340532173405317263056837147194142227802227270559767163192158407124207785260845424557080297523836778022860075267767393356976783497469455080778939882789800039977639774911644382332352122803400052369557310689484087573096000564122051464587657142552367772804125657640951633865000733917242638427969228515153218549439155329040330261316163519718166219264447023717624071135031682068185389429584994316543897771919965654075104065345135358834199510627259973946403677514508658002642995207119922180370046907584056995382036748785529734542656641589466381134897773314185247501543493070833450940059961591772076280976530313959876630742919601757967835400413003832068083137100848300682248035035592767980255101737601837037834214412170853683020257378335976178292667429213438041779646552205816663111454752021798837829021580725995953430818880193018910037948746585678393038367984189238486439222159167260905649373996940657672361119750462455166503945436756701551872987465429907026925878809473853352066925720260911290023090123430265077676233807728098607000307866906435331246300732417157249588740908645709866761213632640766388061872915761886333091495391937494483931140542567263349413761537247328823920369883701405524832120403458467699784585420810400092814984731958758583790874789508875736089040108423942695902066809848089982444912497965903765202520923188170406434176053612077599140886117304937437410965435011915198481704156122016579588020365205311979241439462931561285121431994899759976183266911427157198326676701309093399168566923778711045564403729780791707139774827752880264923913705167704697849165465067230872728594403236994134477986450891203238667071691726461227327788944284015999417099200068962885296074874497104269883497091603275671000777698985052203071547701346845130137150286335215360025004116218027488507257071800498742509696205699155349786566482427353096318371724084140610639909642864631556758520062184151434143972876705140433021343436253486951678310437327740361677501180130953267485252102755543740241498424336952149427820261726751902720804988779470291469582269057693833175114501347214421868577757642398161163803373280837923189112824607070550398981996839581667714578209162655966410293400662995030551339968370887080270967186767914234356366837701363568223289827213527288550027142414364858064229579275095515463985517081508696467182011969548577456907224103695134196437680649075185472067090216931018214055037659097605054523593972858696210194897657538932443418242067264696193174404329877869967792996161438353727000619872893532864377343110528578807939883678523264950179076588121107815506
for m in range(300001,n+1):
res=ans(m,m-1,res)
print(res%998244353)
elif(n>200000):
res=8017450438795554887675207521553510501188498678892269166400761455404971455643009722039082368787972975718346114711857804924096304157284280181103201392717477822850648800553442718703698648893965360073768596726570674857214778409088461558346729643111377019454123694625142197008371688554148810174889625458234724090633831231375746915164145396752372878736507493518350222085660344164320985707811847309764837453317790946513837583885717135608928772367893279345558464995625964301024554170064366345606221348870108744136424702745874458347620699099163717947931910681962956277162535967337682829551028667591493197931880173534721891383661470137491732441498350672149611360321490353164372129895633575034880967066756015810467831054608631085316588583225492852234722642443325245819070484277176946554817396448841700335998514147214807365457907176887150660493519485490489941591252583549669480591926886849738382553552273827147927696518879811414744222476816936050732128272545170430901557867948639434947286662601241340653610997619579247784967402446587975558693165377431217545184045238472756107415164045735808665770633779588319844372068948710752136892500488088265605509689311040565986942262205435070486001142495480804085487080333319013418983320841204295160353038010185445460006839038621797033055750424672818552735751345252328028760793162157538264779505927649636257111050560551202786395322957418616200731544071589617450454938573316150492148364623000477786037382254885760901240008827983995641794687986200777437852839042549198429379853521078964299889132664054823807699510820857941344414462454838337332212689924333718645948666758559629510250447266874104806366211243667070219145883486282935134548642909934883981449994973941151287932853575371702347305026322355127819791425692480282918890419547172323280996077072826020214642673839189676357590653751781806717703758893450320510712229304233654693177025430957343871850458836411231433018046271683847596939732283009625599118607766279704332827277611974477879514397633729923817878784618573078859938774466961456739254926937866591685581175114439649314390874908488806062637404346335659557959175869786363975692443374128663355871506457711203215762066074918058471285902268588783753414209033503712733279447291379975377217806408097036253444816911221103900512363392538692482921627645487843457413369160642698445562195397695215597778630952686623486988107142830285357615357988189802496913421753715952443741726991573366438253092047848637904296986442151454711223706410202282601618964013397462899476975330962193581949919980618666512208266281854818302961481114767743957391321887162000259657012369027637341086033959086448870772459811533870722698422517707107168020113440902628279388926880476381443253711961327161657608861004892617747707554707448683165134331364249357668779758063574722513185024141233349289959082974593618830451079291819046593314526374078332990007402895762600874126511741430087084681822130613352072436576572936585061340667562408238276325302179855972173325781548982134708128858036752954669233102384927086933372819510609121785415668156478850892524044325221867355546164576073161780122848961384670419454147216721514942749105857795766330904006767161385504995459613897773770049367326937624267878703289314893197283740924728479594761907079756291406651604797630717658918629489333227655743346987210620266774669229840160276433831894203635764811341296363205149353252180494977442869578285638635620076582880533619200277612350638374951776287931881226464062783294163175038311658524978352115383756794998640793777783311646469077975626442250606165073471329799677856060695647528606991189515518547523134126482539957183377392277721555775310379157215786139759155088762464800693219590086473576427041925324866603653533090751254153006945793497728646900103546798271023879404826904223841705606857906318314105454708304136667749562875129753525851370417932332443838153634518308909406167773569505823225493962858251224392113866672598417783244509423138232689571525803308864430269141202487684313979924404368575950057862959269819329603494853407308613831775362965444674274227474920864725514172047818376656547965795727147133016281658134991318667661013749745725226665569367236393106313661763717798125422469055322031245207927471349611049669585500080209131144519623060867150104358254170344201844692053719420875739359286236821891348886283830073006552355275276927792810024611781063530114307042561535191336026120768919159129029579879982100190662239464131810925466762134159985916843773906883531461855743655178706492825346016493855682503779251104522915147326683585076626900200726606674047788234796443664423738146541345691257772235864488536106868837528756243751673635010302139836424861885057738046988196462757471913944010044240758976974064265926641322899907597006631290291336685962116230168402535420505658094640581720445802457600422111806218842806921412637509066532309584636542268959254554501942590034595128881303893635625137705739345405791763228361605133970215006106158774671407561295800908160521231627103228094770390614963832459677111126649213263498057405687816034852229166395729238723118163546495651923573737885919315393252602514719162615452140884932992015795458201681702815170905677736077047686244295783303476878181026049029764287172716074552777356425510167887525875804322094481714506696657268921644097020026438737372919585186587230816629101967145095533794817253917043482376072129391295846951070670023105469528650817784665130002390255904820672282297946140422909833748414580380867338899342832982162446626240333555095703047977919659859421797276938056621299579040426787169317052479210420457170464562555215764075817117731616261161298436419984097872860920706685306763055593507856287715702489984630662283345609176910967297046798405759953065041670595961586640625598611115528404850208680480812057442973171019491780134289087517888509165184877037659580676528378260661083266978931353759329032700000685707347803895796832359354487643434957429697351005327618776365330337885136739356515130811417520162332509106112571535898578702926497576473982517147201539948965949100951015021624425788122934551047047529256925631012407339977535457927169436439250824605547135950708071081781592306136262199869170945105025370474639041679950134965069716494096949712432457768919121409364841520588482741002306188982242126104387920111119651487236342741843897261664476638233910275668584493381516819409878992041686266293856967151838063209633417004685953527863414647118566580754007372072338689846375019554434989627553799787569732074108406467650708983466165835056193300463293282904876506049598994048234942184852891009449948847935348981144712596259188315660318145690050150408618809011871849996799365520827374627985379556737012327298543599078075147101638791964979040876712128162278142906893425353965050633296747578706176747290697783535251850988233392627032317528884165685115888409815319042372811521851603602562949439072726901846308522307256136253623750270731721352728710154377342357939849715500319474389341913162001990104534304939191457825227399910822786852345317153289062182605159172635375263087964714474649435605948425786291038106609684089491511968046223407427917922702941795809422188255065444358556338366765003480506910582119069422147244165081524568969654952751517142640964972881840167548432239441689209262069250233670706046200330005943442889786401205328109605598010616721355191305652734003200132615980484895975896926354396049456558891631150298915458734487727606392931120546206171208212874937454295681119267387367711584770665318997691245470364685000707858302364956697651029374824145887038030665671087154785131590386475730554009564001538539019397734263457404104756247559207111242508938712135751455194837864676072267138654906486125377697350846770786222875467211084915851852636308970452165846876708645086927074816765378957396843807744418251564729466868749172123544858757405478238749472806015746984822100540738228121093941842860790213958666320813255942339583708139389616537043582527205247279821171765470596311437786907037923722732896686199188054266185080172985137091859255640535398955379827287864996065712747168271539490461557244868162898367519234115725676447720732521799780284251214571246885925126621766943716912893380206907504900086904340266662932425812186334124087212874142687760609691465428875546769271153832658597008505425783195261176421182774267935589422373170886634085458836178857593843402139516996101408716159950558851304776395445954843183445810034096496811576788490421735291587472943826855890198152371193826986683066333205796627038801102828366948462976948926921084622875636026369556612811332734981832410159134115045369934489622939641859453113457241793643622148200866879433232906428324823181953074964274549713362108949676981983417827554461771783211846271186143479320653218613679860786915548984629767414749928546995234546023844846878860320859075459522064521396840888290851810116331365423233506995875904401246920916298648305386639644628427356170888941431347944040257881162410830002959942363361455734466639961871346111809589050992206960872881064676858154445014977090747081023408216537501402772649527349583568524360384733257335585413478567425819492251685262863116496428105802254799267949513160265269688780012038344029210028763717905471595895192395031519723290892955322988381863528549742602835374506529154324071893916149762297138409010938882563079791590514743412905723437809998559843688865285705828022700340219851684519112272152880783720603828478005301157924171601135349965750423523234480470674551833779604101368041826188433757412418705287092576861133006078996366897915826389989075034850532725205801508582279188498482592350170639828287807841483132950168280667487251273989540757859112452150362428084154768142807864617822219523736709175527791696190639979946822997907126047106173772441200437942437095437049646296816296230157311037532927651097835386444108208571148899515534889174379871197503821380684586035304408558716352355165119292421263304370036288731025355447600631424112610520870732738258604009934937930638404144740181011437162408180467499131980896670050096686797703814794085803470588858164047792308119552879695993739954534914328655045618338762274553467980157889733570150371035180107586462628484379278952290787520937306151643463631363609970541651298012896126198877992583785667985261315470401676452234854844045697733763164995
for m in range(200001,n+1):
res=ans(m,m-1,res)
print(res%998244353)
else:
res=3
for m in range(3,n+1):
res=ans(m,m-1,res)
print(res%998244353)
``` | instruction | 0 | 97,246 | 23 | 194,492 |
No | output | 1 | 97,246 | 23 | 194,493 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value. | instruction | 0 | 97,247 | 23 | 194,494 |
Tags: implementation, sortings
Correct Solution:
```
n, t = [int(item) for item in input().split(' ')]
cont = []
for i in range(n):
center, house_len = [int(item) for item in input().split(' ')]
cont.append([center-house_len / 2, center + house_len / 2])
cont.sort(key=lambda item: item[0])
ans = 2
for i in range(n - 1):
gap = cont[i + 1][0] - cont[i][1]
if gap > t:
ans += 2
elif gap == t:
ans += 1
print(ans)
``` | output | 1 | 97,247 | 23 | 194,495 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value. | instruction | 0 | 97,248 | 23 | 194,496 |
Tags: implementation, sortings
Correct Solution:
```
n,t = map(int, input().split())
lista_punktow = list()
lista_odleglosci = list()
suma= 0
for i in range(n):
x,a = map(int, input().split())
lista_punktow.append(float(x-a/2))
lista_punktow.append(float(x+a/2))
lista_punktow.sort()
#print (lista_punktow)
for i in range(0,len(lista_punktow)-2,2):
w = lista_punktow[i+2] - lista_punktow[i+1]
lista_odleglosci.append(w)
#print(lista_odleglosci)
for i in range(len(lista_odleglosci)):
if (lista_odleglosci[i] - t) > 0:
d = (lista_odleglosci[i] - t)
suma += 2
elif (lista_odleglosci[i] - t) == 0:
suma +=1
print (suma+2)
``` | output | 1 | 97,248 | 23 | 194,497 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value. | instruction | 0 | 97,249 | 23 | 194,498 |
Tags: implementation, sortings
Correct Solution:
```
temp = input().split()
n, t, ans = int(temp[0]), int(temp[1]), 2
cont = []
for i in range(n):
# string_arr = input().split()
# temp = input().split(' ')
# center, house_len = float(temp[0]), float(temp[1]),
# temp = [float(item) for item in input().split(' ')]
# house_center, house_len = temp[0], temp[1]
temp = list(map(float, input().split()))
house_center, house_len = temp[0], temp[1]
cont.append([house_center - house_len / 2, house_center + house_len / 2])
cont.sort(key=lambda item: item[0])
for i in range(n - 1):
helper = cont[i + 1][0] - cont[i][1]
if helper > t:
ans += 2
elif helper == t:
ans += 1
print(ans)
# print(cont)
``` | output | 1 | 97,249 | 23 | 194,499 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value. | instruction | 0 | 97,250 | 23 | 194,500 |
Tags: implementation, sortings
Correct Solution:
```
n,t = list(map(int,input().split()))
cottages = []
for i in range(n):
c,d = list(map(int,input().split()))
cottages.append([c-d/2,c+d/2])
cottages.sort()
possibilities = 0
for i in range(1,len(cottages)):
interval = cottages[i][0]-cottages[i-1][1]
if interval > t:
possibilities += 2
elif interval == t:
possibilities += 1
else:
pass
possibilities += 2
print(possibilities)
``` | output | 1 | 97,250 | 23 | 194,501 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value. | instruction | 0 | 97,251 | 23 | 194,502 |
Tags: implementation, sortings
Correct Solution:
```
n, t = map(int, input().split())
x, var = sorted(list(map(int, input().split())) for i in range(n)), 2
for i in range(n - 1):
distance = 2 * x[i + 1][0] - x[i + 1][1] - 2 * x[i][0] - x[i][1] #calculate diatance btw existing houses
if distance > 2 * t: #case when we have enough distance for 2 positions
var += 2
elif distance == 2 * t: #case when we have only one position available
var += 1
print(var) #print answer
``` | output | 1 | 97,251 | 23 | 194,503 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value. | instruction | 0 | 97,252 | 23 | 194,504 |
Tags: implementation, sortings
Correct Solution:
```
L = input()
L = L.split()
n = int(L[0])
t = int(L[1])
A = []
for k in range (n):
h = input()
h = h.split()
center = int(h[0])
side = int(h[1])
A.append(center-(side/2))
A.append(center+(side/2))
moves = 2
A.sort()
for k in range (1,len(A)-1,2):
if A[k+1]-A[k]>t:
moves += 2
elif A[k+1]-A[k]==t:
moves +=1
print(moves)
``` | output | 1 | 97,252 | 23 | 194,505 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value. | instruction | 0 | 97,253 | 23 | 194,506 |
Tags: implementation, sortings
Correct Solution:
```
def overlap_check(arr,c,t):
#print("ASd")
for i in arr:
c1 = i[0]
d1 = i[1]
dc = abs(c1-c)
#print(dc,t,d1)
if(t+d1>dc):
return False
#print(c,t)
return True
n,t = map(int,input().split())
arr = []
for i in range(n):
c,d = map(int,input().split())
d = d/2
arr.append((c,d))
ans = set()
t/=2
for i in arr:
#left
c = i[0]-i[1] - t
if overlap_check(arr,c,t):
ans.add(c)
#right
c = i[0]+i[1]+t
if overlap_check(arr,c,t):
ans.add(c)
print(len(ans))
``` | output | 1 | 97,253 | 23 | 194,507 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value. | instruction | 0 | 97,254 | 23 | 194,508 |
Tags: implementation, sortings
Correct Solution:
```
import sys
import math
import bisect
def solve(A, m):
n = len(A)
A.sort()
#ke print('A: %s' % (str(A)))
ans = 2
for i in range(1, n):
delta = A[i][0] - A[i-1][1]
if delta == m:
ans += 1
elif delta > m:
ans += 2
return ans
def main():
n, m = map(int, input().split())
m <<= 1
A = []
for i in range(n):
a, b = map(int, input().split())
A.append((2 * a - b, 2 * a + b))
ans = solve(A, m)
print(ans)
if __name__ == "__main__":
main()
``` | output | 1 | 97,254 | 23 | 194,509 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value.
Submitted Solution:
```
n,t = map(int,input().split())
xa = []
for i in range(n):
xi,ai = map(int,input().split())
xa.append([xi,ai])
xa.sort()
for i in range(n):
xa[i] = [xa[i][0]-xa[i][1]/2,xa[i][0]+xa[i][1]/2]
count = 2
for i in range(n-1):
k = xa[i+1][0] - xa[i][1]
if k < t:
continue
if k == t:
count += 1
else:
count += 2
print(count)
``` | instruction | 0 | 97,255 | 23 | 194,510 |
Yes | output | 1 | 97,255 | 23 | 194,511 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value.
Submitted Solution:
```
from math import floor
n, t = [int(x) for x in input().split()]
centers = []
houses = {}
answer = 2
place = 0
for i in range(n):
x, a = [float(x) for x in input().split()]
centers.append(x)
houses[str(x)] = (a / 2)
centers.sort()
for i in range(1, n):
place = (centers[i] - centers[i - 1] - houses[str(centers[i])] - houses[str(centers[i - 1])])
if place == t:
answer += 1
if place > t:
answer += 2
#print(centers)
#print(houses)
print(answer)
``` | instruction | 0 | 97,256 | 23 | 194,512 |
Yes | output | 1 | 97,256 | 23 | 194,513 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value.
Submitted Solution:
```
N, T = map(int, input().split())
def read_houses():
for _ in range(N):
yield tuple(map(int, input().split()))
houses = list(read_houses())
houses.sort()
count = 2 # borders left and right
for (a, x), (b, y) in zip(houses, houses[1:]):
if b-a - (x/2+y/2) > T:
count += 2
if b-a - (x/2+y/2) == T:
count += 1
print(count)
``` | instruction | 0 | 97,257 | 23 | 194,514 |
Yes | output | 1 | 97,257 | 23 | 194,515 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value.
Submitted Solution:
```
n,t = list(map(int,input().split()))
cottages = []
for i in range(n):
c,d = list(map(int,input().split()))
cottages.append([c-d/2,c+d/2])
cottages.sort()
psbLocs = 0
for i in range(1,len(cottages)):
interval = cottages[i][0]-cottages[i-1][1]
if interval > t:
psbLocs += 2
elif interval == t:
psbLocs += 1
else:
pass
psbLocs += 2
print(psbLocs)
``` | instruction | 0 | 97,258 | 23 | 194,516 |
Yes | output | 1 | 97,258 | 23 | 194,517 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value.
Submitted Solution:
```
n,t=list(map(int,input().split()))
amount=2
for i in range(n):
c,l=list(map(int,input().split()))
l=l//2
start,end=c-l,c+l
if i:
if start-prev_end>t:
amount+=2
elif start-prev_end==t:
amount+=1
prev_end=end
print(amount)
``` | instruction | 0 | 97,259 | 23 | 194,518 |
No | output | 1 | 97,259 | 23 | 194,519 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value.
Submitted Solution:
```
n, t = map(int, input().split())
houses = [list(map(int, input().split())) for i in range(n)]
ans = 2
for i in range(n - 1):
x = houses[i][0] + houses[i][1] / 2
y = houses[i + 1][0] - houses[i + 1][1] / 2
if y - x == t:
ans += 1
elif y - x > t:
ans += 2
print(ans)
``` | instruction | 0 | 97,260 | 23 | 194,520 |
No | output | 1 | 97,260 | 23 | 194,521 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value.
Submitted Solution:
```
#15A - Cottage Village
# n - how many square houses we have on the x-axis
# t - the side of the main house
n, t = map(int, input().split())
#Variable that sorts square houses by x-axis coordinates in ascending order
#Input: house's center on the x-axis and the house's side length
houses = sorted([list(map(int, input().split())) for i in range(n)], key=lambda x: x[0])
print(houses)
#Because there's at least 1 other house in the village, we have 2 possibilities
#by default, cause the main house can touch one of the 2 exposed sides of the other house
ans = 2
#The next loop computes the number of houses that fit between 2 adjacent houses
for i in range(n - 1):
x = houses[i][0] + houses[i][1] / 2
y = houses[i + 1][0] - houses[i + 1][1] / 2
#If the space between the 2 houses is equal to the main house's side,
#the only way we can place our house is to touch both houses at the same time
if y - x == t:
ans += 1
#If the space between the houses is bigger than the main house's side,
#then we consider the 2 houses as 2 separate cases, each with 2 possibilities
#of their own
elif y - x > t:
ans += 2
print(ans)
``` | instruction | 0 | 97,261 | 23 | 194,522 |
No | output | 1 | 97,261 | 23 | 194,523 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A new cottage village called «Flatville» is being built in Flatland. By now they have already built in «Flatville» n square houses with the centres on the Оx-axis. The houses' sides are parallel to the coordinate axes. It's known that no two houses overlap, but they can touch each other.
The architect bureau, where Peter works, was commissioned to build a new house in «Flatville». The customer wants his future house to be on the Оx-axis, to be square in shape, have a side t, and touch at least one of the already built houses. For sure, its sides should be parallel to the coordinate axes, its centre should be on the Ox-axis and it shouldn't overlap any of the houses in the village.
Peter was given a list of all the houses in «Flatville». Would you help him find the amount of possible positions of the new house?
Input
The first line of the input data contains numbers n and t (1 ≤ n, t ≤ 1000). Then there follow n lines, each of them contains two space-separated integer numbers: xi ai, where xi — x-coordinate of the centre of the i-th house, and ai — length of its side ( - 1000 ≤ xi ≤ 1000, 1 ≤ ai ≤ 1000).
Output
Output the amount of possible positions of the new house.
Examples
Input
2 2
0 4
6 2
Output
4
Input
2 2
0 4
5 2
Output
3
Input
2 3
0 4
5 2
Output
2
Note
It is possible for the x-coordinate of the new house to have non-integer value.
Submitted Solution:
```
n, t = map(int, input().split())
li = []
for _ in range(n):
tx = tuple(map(int, input().split()))
li.append(tx)
p = 2
li.sort(key = lambda x: x[0])
for i in range(len(li)-1):
k = (li[i][1]+li[i+1][1])
if k%2 != 0:
d = abs(li[i][0]-li[i+1][0])-int(k/2+.5)
else:
d = abs(li[i][0]-li[i+1][0])-(k/2)
if d > t:
p += 2
elif d == t:
p += 1
print(p)
``` | instruction | 0 | 97,262 | 23 | 194,524 |
No | output | 1 | 97,262 | 23 | 194,525 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers two squares.
2. No two dominoes overlap.
3. Each domino lies entirely inside the board. It is allowed to touch the edges of the board.
Find the maximum number of dominoes, which can be placed under these restrictions.
Input
In a single line you are given two integers M and N — board sizes in squares (1 ≤ M ≤ N ≤ 16).
Output
Output one number — the maximal number of dominoes, which can be placed.
Examples
Input
2 4
Output
4
Input
3 3
Output
4
Submitted Solution:
```
m,n=[int(i) for i in input().split()]
a=m*n//2
print(a)
``` | instruction | 0 | 97,385 | 23 | 194,770 |
Yes | output | 1 | 97,385 | 23 | 194,771 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers two squares.
2. No two dominoes overlap.
3. Each domino lies entirely inside the board. It is allowed to touch the edges of the board.
Find the maximum number of dominoes, which can be placed under these restrictions.
Input
In a single line you are given two integers M and N — board sizes in squares (1 ≤ M ≤ N ≤ 16).
Output
Output one number — the maximal number of dominoes, which can be placed.
Examples
Input
2 4
Output
4
Input
3 3
Output
4
Submitted Solution:
```
import math
lineArr = []
def intInput():
global lineArr
lineArr = input().split(' ')
for i in range(len(lineArr)):
lineArr[i]=int(lineArr[i])
intInput()
m = lineArr[0]
n = lineArr[1]
2
if n%2 == 0:
d = (n/2)*m
elif m%2 == 0:
d = (m/2)*n
else:
d = math.floor((m*n)/2)
d = int(d)
print(d)
``` | instruction | 0 | 97,386 | 23 | 194,772 |
Yes | output | 1 | 97,386 | 23 | 194,773 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers two squares.
2. No two dominoes overlap.
3. Each domino lies entirely inside the board. It is allowed to touch the edges of the board.
Find the maximum number of dominoes, which can be placed under these restrictions.
Input
In a single line you are given two integers M and N — board sizes in squares (1 ≤ M ≤ N ≤ 16).
Output
Output one number — the maximal number of dominoes, which can be placed.
Examples
Input
2 4
Output
4
Input
3 3
Output
4
Submitted Solution:
```
n, k = map(int, input().split())
if (n*k)%2==0:
print(int((n*k)/2))
else:
print(int(n*k)//2)
``` | instruction | 0 | 97,387 | 23 | 194,774 |
Yes | output | 1 | 97,387 | 23 | 194,775 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers two squares.
2. No two dominoes overlap.
3. Each domino lies entirely inside the board. It is allowed to touch the edges of the board.
Find the maximum number of dominoes, which can be placed under these restrictions.
Input
In a single line you are given two integers M and N — board sizes in squares (1 ≤ M ≤ N ≤ 16).
Output
Output one number — the maximal number of dominoes, which can be placed.
Examples
Input
2 4
Output
4
Input
3 3
Output
4
Submitted Solution:
```
import sys
m,n = [int(x) for x in sys.stdin.readline().split()]
if m % 2 == 1 and n % 2 == 1:
print((m*n-1) // 2)
else:
print(m*n // 2)
``` | instruction | 0 | 97,388 | 23 | 194,776 |
Yes | output | 1 | 97,388 | 23 | 194,777 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers two squares.
2. No two dominoes overlap.
3. Each domino lies entirely inside the board. It is allowed to touch the edges of the board.
Find the maximum number of dominoes, which can be placed under these restrictions.
Input
In a single line you are given two integers M and N — board sizes in squares (1 ≤ M ≤ N ≤ 16).
Output
Output one number — the maximal number of dominoes, which can be placed.
Examples
Input
2 4
Output
4
Input
3 3
Output
4
Submitted Solution:
```
m,n = map(int,input().split())
a = 2 # площадь одной доминошки
if n * m % a == 0:
k = n * m / a
else:
k = m * n // a
print(k)
``` | instruction | 0 | 97,389 | 23 | 194,778 |
No | output | 1 | 97,389 | 23 | 194,779 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers two squares.
2. No two dominoes overlap.
3. Each domino lies entirely inside the board. It is allowed to touch the edges of the board.
Find the maximum number of dominoes, which can be placed under these restrictions.
Input
In a single line you are given two integers M and N — board sizes in squares (1 ≤ M ≤ N ≤ 16).
Output
Output one number — the maximal number of dominoes, which can be placed.
Examples
Input
2 4
Output
4
Input
3 3
Output
4
Submitted Solution:
```
def main():
m, n = [int(x) for x in input().strip().split()]
print(m,n)
if m%2==0 and n%2==0:
print(int((m*n)/2))
elif m%2==0 and n%2!=0:
print(int((m*n)/2))
elif n%2==0 and m%2!=0:
print(int((m*n)/2))
else:
print(int(((m-1)/2)+((m*(n-1))/2)))
main()
``` | instruction | 0 | 97,390 | 23 | 194,780 |
No | output | 1 | 97,390 | 23 | 194,781 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers two squares.
2. No two dominoes overlap.
3. Each domino lies entirely inside the board. It is allowed to touch the edges of the board.
Find the maximum number of dominoes, which can be placed under these restrictions.
Input
In a single line you are given two integers M and N — board sizes in squares (1 ≤ M ≤ N ≤ 16).
Output
Output one number — the maximal number of dominoes, which can be placed.
Examples
Input
2 4
Output
4
Input
3 3
Output
4
Submitted Solution:
```
a,b=list(map(int,input().split(' ')))
print((a*b-1)//2)
``` | instruction | 0 | 97,391 | 23 | 194,782 |
No | output | 1 | 97,391 | 23 | 194,783 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a rectangular board of M × N squares. Also you are given an unlimited number of standard domino pieces of 2 × 1 squares. You are allowed to rotate the pieces. You are asked to place as many dominoes as possible on the board so as to meet the following conditions:
1. Each domino completely covers two squares.
2. No two dominoes overlap.
3. Each domino lies entirely inside the board. It is allowed to touch the edges of the board.
Find the maximum number of dominoes, which can be placed under these restrictions.
Input
In a single line you are given two integers M and N — board sizes in squares (1 ≤ M ≤ N ≤ 16).
Output
Output one number — the maximal number of dominoes, which can be placed.
Examples
Input
2 4
Output
4
Input
3 3
Output
4
Submitted Solution:
```
a = input()
print(int(a[0]) * int(a[0]) // 2)
``` | instruction | 0 | 97,392 | 23 | 194,784 |
No | output | 1 | 97,392 | 23 | 194,785 |
Provide a correct Python 3 solution for this coding contest problem.
There are a total of W x H squares, with H rows vertically and W columns horizontally. Some squares are marked. Create a program that reads the marked state of each square and outputs the maximum rectangular area consisting of only the unmarked squares.
The input data consists of one line of W characters, given H lines. For example, the following data is given.
.. *.... **.
..........
** .... ***.
.... * .....
.. * .......
... ** .....
. *. * ......
..........
.. **......
. * .. * .....
One line of input data represents the square of one line. Of the character strings in the input data,. (Period) indicates unmarked squares, and * (asterisk) indicates marked squares. The input data string does not contain any characters other than periods, asterisks, and line breaks.
In the above example, the rectangle indicated by 0 in the figure below is the largest.
.. *.... **.
..........
** .... ***.
.... * 00000
.. * ..00000
... ** 00000
. *. *. 00000
..... 00000
.. **. 00000
. * .. * 00000
Therefore, if you output 35, the answer will be correct. If all the squares are marked, output 0.
Input
Given multiple datasets. Each dataset starts with a line of H and W separated by spaces, followed by an H x W rectangle. Both H and W shall be 500 or less.
The input ends with a line containing two 0s. The number of datasets does not exceed 20.
Output
For each dataset, output the area of the largest rectangle on one line.
Example
Input
10 10
...*....**
..........
**....**..
........*.
..*.......
**........
.*........
..........
....*..***
.*....*...
10 10
..*....*..
.*.*...*..
*****..*..
*...*..*..
*...*..*..
..........
****.*...*
..*..*...*
.*...*...*
****..***.
2 3
...
...
0 0
Output
28
12
6 | instruction | 0 | 97,751 | 23 | 195,502 |
"Correct Solution:
```
# ref: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=924554#1
from itertools import product
while(True):
H,W = map(int,input().split())
if not H: break
ma = [list(map(int,input().replace(".","1").replace("*","0")))+[0] for _ in range(H)]
for i,j in product(range(1,H),range(W)):
if ma[i][j]: ma[i][j] += ma[i-1][j]
ans = 0
for i in range(H):
stk = []
for j in range(W+1):
cur = ma[i][j]
if (not stk) or stk[-1][1] < cur:
stk.append([j,cur])
elif stk[-1][1] > cur:
idx = j
while stk and stk[-1][1] >= cur:
idx = stk[-1][0]
ans = max(ans,stk[-1][1]*(j-stk[-1][0]))
stk.pop()
stk.append([idx,cur])
print(ans)
``` | output | 1 | 97,751 | 23 | 195,503 |
Provide a correct Python 3 solution for this coding contest problem.
There are a total of W x H squares, with H rows vertically and W columns horizontally. Some squares are marked. Create a program that reads the marked state of each square and outputs the maximum rectangular area consisting of only the unmarked squares.
The input data consists of one line of W characters, given H lines. For example, the following data is given.
.. *.... **.
..........
** .... ***.
.... * .....
.. * .......
... ** .....
. *. * ......
..........
.. **......
. * .. * .....
One line of input data represents the square of one line. Of the character strings in the input data,. (Period) indicates unmarked squares, and * (asterisk) indicates marked squares. The input data string does not contain any characters other than periods, asterisks, and line breaks.
In the above example, the rectangle indicated by 0 in the figure below is the largest.
.. *.... **.
..........
** .... ***.
.... * 00000
.. * ..00000
... ** 00000
. *. *. 00000
..... 00000
.. **. 00000
. * .. * 00000
Therefore, if you output 35, the answer will be correct. If all the squares are marked, output 0.
Input
Given multiple datasets. Each dataset starts with a line of H and W separated by spaces, followed by an H x W rectangle. Both H and W shall be 500 or less.
The input ends with a line containing two 0s. The number of datasets does not exceed 20.
Output
For each dataset, output the area of the largest rectangle on one line.
Example
Input
10 10
...*....**
..........
**....**..
........*.
..*.......
**........
.*........
..........
....*..***
.*....*...
10 10
..*....*..
.*.*...*..
*****..*..
*...*..*..
*...*..*..
..........
****.*...*
..*..*...*
.*...*...*
****..***.
2 3
...
...
0 0
Output
28
12
6 | instruction | 0 | 97,752 | 23 | 195,504 |
"Correct Solution:
```
while True:
h, w = map(int, input().split())
if h == 0:
break
mp = []
for _ in range(h):
lst = list(input())
cum = []
acc = 0
for i in lst:
acc = acc + 1 if i == "." else 0
cum.append(acc)
mp.append(cum)
mp.append([-1] * w)
ans = 0
for i in range(w):
stack = []
for j in range(h + 1):
score = mp[j][i]
if not stack:
stack.append((score, j))
else:
last_score, last_ind = stack[-1][0], stack[-1][1]
if score > last_score:
stack.append((score, j))
elif score == last_score:
continue
else:
while stack != [] and stack[-1][0] >= score:
last_score, last_ind = stack.pop()
ans = max(ans, last_score * (j - last_ind))
stack.append((score, last_ind))
print(ans)
``` | output | 1 | 97,752 | 23 | 195,505 |
Provide a correct Python 3 solution for this coding contest problem.
There are a total of W x H squares, with H rows vertically and W columns horizontally. Some squares are marked. Create a program that reads the marked state of each square and outputs the maximum rectangular area consisting of only the unmarked squares.
The input data consists of one line of W characters, given H lines. For example, the following data is given.
.. *.... **.
..........
** .... ***.
.... * .....
.. * .......
... ** .....
. *. * ......
..........
.. **......
. * .. * .....
One line of input data represents the square of one line. Of the character strings in the input data,. (Period) indicates unmarked squares, and * (asterisk) indicates marked squares. The input data string does not contain any characters other than periods, asterisks, and line breaks.
In the above example, the rectangle indicated by 0 in the figure below is the largest.
.. *.... **.
..........
** .... ***.
.... * 00000
.. * ..00000
... ** 00000
. *. *. 00000
..... 00000
.. **. 00000
. * .. * 00000
Therefore, if you output 35, the answer will be correct. If all the squares are marked, output 0.
Input
Given multiple datasets. Each dataset starts with a line of H and W separated by spaces, followed by an H x W rectangle. Both H and W shall be 500 or less.
The input ends with a line containing two 0s. The number of datasets does not exceed 20.
Output
For each dataset, output the area of the largest rectangle on one line.
Example
Input
10 10
...*....**
..........
**....**..
........*.
..*.......
**........
.*........
..........
....*..***
.*....*...
10 10
..*....*..
.*.*...*..
*****..*..
*...*..*..
*...*..*..
..........
****.*...*
..*..*...*
.*...*...*
****..***.
2 3
...
...
0 0
Output
28
12
6 | instruction | 0 | 97,753 | 23 | 195,506 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Rectangular Searching
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0116
"""
import sys
def solve(m, height, width):
def calc_hist(m):
hist = [[0]* width for _ in range(height)]
for y, row in enumerate(m):
for x, ch in enumerate(row):
if ch == '.':
hist[y][x] = hist[y-1][x]+1 if y >0 else 1
return hist
def calc_area(hist):
stack = []
area = 0
for x, h in enumerate(hist):
if not stack or stack[-1][0] < h:
stack.append((h, x))
elif stack[-1][0] > h:
while stack and stack[-1][0] >= h:
hh, left = stack.pop()
area = max(area, hh*(x-left))
stack.append((h, left))
return area
hist = calc_hist(m)
ans = 0
for y in range(height):
ans = max(ans, calc_area(hist[y]+[0])) # [0]はヒストグラムを最後にリフレッシュして処理するために必要
return ans
def main(args):
while True:
height, width = map(int, input().split())
if height == 0 or width == 0:
break
m = [input() for _ in range(height)]
ans = solve(m, height, width)
print(ans)
if __name__ == '__main__':
main(sys.argv[1:])
``` | output | 1 | 97,753 | 23 | 195,507 |
Provide a correct Python 3 solution for this coding contest problem.
There are a total of W x H squares, with H rows vertically and W columns horizontally. Some squares are marked. Create a program that reads the marked state of each square and outputs the maximum rectangular area consisting of only the unmarked squares.
The input data consists of one line of W characters, given H lines. For example, the following data is given.
.. *.... **.
..........
** .... ***.
.... * .....
.. * .......
... ** .....
. *. * ......
..........
.. **......
. * .. * .....
One line of input data represents the square of one line. Of the character strings in the input data,. (Period) indicates unmarked squares, and * (asterisk) indicates marked squares. The input data string does not contain any characters other than periods, asterisks, and line breaks.
In the above example, the rectangle indicated by 0 in the figure below is the largest.
.. *.... **.
..........
** .... ***.
.... * 00000
.. * ..00000
... ** 00000
. *. *. 00000
..... 00000
.. **. 00000
. * .. * 00000
Therefore, if you output 35, the answer will be correct. If all the squares are marked, output 0.
Input
Given multiple datasets. Each dataset starts with a line of H and W separated by spaces, followed by an H x W rectangle. Both H and W shall be 500 or less.
The input ends with a line containing two 0s. The number of datasets does not exceed 20.
Output
For each dataset, output the area of the largest rectangle on one line.
Example
Input
10 10
...*....**
..........
**....**..
........*.
..*.......
**........
.*........
..........
....*..***
.*....*...
10 10
..*....*..
.*.*...*..
*****..*..
*...*..*..
*...*..*..
..........
****.*...*
..*..*...*
.*...*...*
****..***.
2 3
...
...
0 0
Output
28
12
6 | instruction | 0 | 97,754 | 23 | 195,508 |
"Correct Solution:
```
def solve():
H, W = map(int, input().split())
if H == 0:
return False
MP = [input() for i in range(H)]
C = [[0]*W for i in range(H)]
for j in range(W):
cnt = 0
for i in range(H-1, -1, -1):
if MP[i][j] == '.':
cnt += 1
else:
cnt = 0
C[i][j] = cnt
ans = 0
for i in range(H):
st = [(0, -1)]
for j in range(W):
e = C[i][j]
last = j
while st and e <= st[-1][0]:
f, k = st.pop()
ans = max(ans, (j - k) * f)
last = k
st.append((e, last))
while st:
f, k = st.pop()
ans = max(ans, (W - k) * f)
print(ans)
return True
while solve():
...
``` | output | 1 | 97,754 | 23 | 195,509 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are a total of W x H squares, with H rows vertically and W columns horizontally. Some squares are marked. Create a program that reads the marked state of each square and outputs the maximum rectangular area consisting of only the unmarked squares.
The input data consists of one line of W characters, given H lines. For example, the following data is given.
.. *.... **.
..........
** .... ***.
.... * .....
.. * .......
... ** .....
. *. * ......
..........
.. **......
. * .. * .....
One line of input data represents the square of one line. Of the character strings in the input data,. (Period) indicates unmarked squares, and * (asterisk) indicates marked squares. The input data string does not contain any characters other than periods, asterisks, and line breaks.
In the above example, the rectangle indicated by 0 in the figure below is the largest.
.. *.... **.
..........
** .... ***.
.... * 00000
.. * ..00000
... ** 00000
. *. *. 00000
..... 00000
.. **. 00000
. * .. * 00000
Therefore, if you output 35, the answer will be correct. If all the squares are marked, output 0.
Input
Given multiple datasets. Each dataset starts with a line of H and W separated by spaces, followed by an H x W rectangle. Both H and W shall be 500 or less.
The input ends with a line containing two 0s. The number of datasets does not exceed 20.
Output
For each dataset, output the area of the largest rectangle on one line.
Example
Input
10 10
...*....**
..........
**....**..
........*.
..*.......
**........
.*........
..........
....*..***
.*....*...
10 10
..*....*..
.*.*...*..
*****..*..
*...*..*..
*...*..*..
..........
****.*...*
..*..*...*
.*...*...*
****..***.
2 3
...
...
0 0
Output
28
12
6
Submitted Solution:
```
# -*- coding: utf-8 -*-
import sys
import os
import math
import random
def print2d(M):
print()
for row in M:
print(row)
for s in sys.stdin:
H, W = map(int, s.split())
if H == W == 0:
break
M = []
for i in range(H):
M.append(input().strip())
#print2d(M)
# make support map (H x W)
S = [[0 for i in range(W)] for j in range(H)]
for y in range(H-1, -1, -1):
cnt = 0
for x in range(W-1, -1, -1):
if M[y][x] == '.':
cnt += 1
else:
cnt = 0
S[y][x] = cnt
#print2d(S)
max_area = 0
for y in range(H):
for x in range(W):
if M[y][x] == '.':
y_offset = 0
min_width = S[y][x]
while y + y_offset < H and M[y + y_offset][x] == '.':
if S[y + y_offset][x] < min_width:
min_width = S[y + y_offset][x]
area = min_width * (y_offset + 1)
if area > max_area:
max_area = area
y_offset += 1
print(max_area)
``` | instruction | 0 | 97,755 | 23 | 195,510 |
No | output | 1 | 97,755 | 23 | 195,511 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are a total of W x H squares, with H rows vertically and W columns horizontally. Some squares are marked. Create a program that reads the marked state of each square and outputs the maximum rectangular area consisting of only the unmarked squares.
The input data consists of one line of W characters, given H lines. For example, the following data is given.
.. *.... **.
..........
** .... ***.
.... * .....
.. * .......
... ** .....
. *. * ......
..........
.. **......
. * .. * .....
One line of input data represents the square of one line. Of the character strings in the input data,. (Period) indicates unmarked squares, and * (asterisk) indicates marked squares. The input data string does not contain any characters other than periods, asterisks, and line breaks.
In the above example, the rectangle indicated by 0 in the figure below is the largest.
.. *.... **.
..........
** .... ***.
.... * 00000
.. * ..00000
... ** 00000
. *. *. 00000
..... 00000
.. **. 00000
. * .. * 00000
Therefore, if you output 35, the answer will be correct. If all the squares are marked, output 0.
Input
Given multiple datasets. Each dataset starts with a line of H and W separated by spaces, followed by an H x W rectangle. Both H and W shall be 500 or less.
The input ends with a line containing two 0s. The number of datasets does not exceed 20.
Output
For each dataset, output the area of the largest rectangle on one line.
Example
Input
10 10
...*....**
..........
**....**..
........*.
..*.......
**........
.*........
..........
....*..***
.*....*...
10 10
..*....*..
.*.*...*..
*****..*..
*...*..*..
*...*..*..
..........
****.*...*
..*..*...*
.*...*...*
****..***.
2 3
...
...
0 0
Output
28
12
6
Submitted Solution:
```
import re
while True:
H, W = map(int, input().split())
if H == 0:
break
s = ''.join([input() for _ in range(H)])
maxv = 0
for it in re.finditer('[.]+', s):
a, b = it.start(0), it.end(0)
edge = s[a:b]
i = 0
while s[a:b] == edge:
a += H
b += H
i += 1
maxv = max(maxv, i*len(edge))
print(maxv)
``` | instruction | 0 | 97,756 | 23 | 195,512 |
No | output | 1 | 97,756 | 23 | 195,513 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are a total of W x H squares, with H rows vertically and W columns horizontally. Some squares are marked. Create a program that reads the marked state of each square and outputs the maximum rectangular area consisting of only the unmarked squares.
The input data consists of one line of W characters, given H lines. For example, the following data is given.
.. *.... **.
..........
** .... ***.
.... * .....
.. * .......
... ** .....
. *. * ......
..........
.. **......
. * .. * .....
One line of input data represents the square of one line. Of the character strings in the input data,. (Period) indicates unmarked squares, and * (asterisk) indicates marked squares. The input data string does not contain any characters other than periods, asterisks, and line breaks.
In the above example, the rectangle indicated by 0 in the figure below is the largest.
.. *.... **.
..........
** .... ***.
.... * 00000
.. * ..00000
... ** 00000
. *. *. 00000
..... 00000
.. **. 00000
. * .. * 00000
Therefore, if you output 35, the answer will be correct. If all the squares are marked, output 0.
Input
Given multiple datasets. Each dataset starts with a line of H and W separated by spaces, followed by an H x W rectangle. Both H and W shall be 500 or less.
The input ends with a line containing two 0s. The number of datasets does not exceed 20.
Output
For each dataset, output the area of the largest rectangle on one line.
Example
Input
10 10
...*....**
..........
**....**..
........*.
..*.......
**........
.*........
..........
....*..***
.*....*...
10 10
..*....*..
.*.*...*..
*****..*..
*...*..*..
*...*..*..
..........
****.*...*
..*..*...*
.*...*...*
****..***.
2 3
...
...
0 0
Output
28
12
6
Submitted Solution:
```
import re
while True:
H, W = map(int, input().split())
if H == 0:
break
x = [input() for _ in range(H)]
s = ''.join(x)
maxv = 0
for i, line in enumerate(x):
for it in re.finditer('[.]+', line):
a, b = it.start(0)+H*i, it.end(0)+H*i
edge = s[a:b]
j = 0
while s[a:b] == edge:
a += H
b += H
j += 1
maxv = max(maxv, j*len(edge))
print(maxv)
``` | instruction | 0 | 97,757 | 23 | 195,514 |
No | output | 1 | 97,757 | 23 | 195,515 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are a total of W x H squares, with H rows vertically and W columns horizontally. Some squares are marked. Create a program that reads the marked state of each square and outputs the maximum rectangular area consisting of only the unmarked squares.
The input data consists of one line of W characters, given H lines. For example, the following data is given.
.. *.... **.
..........
** .... ***.
.... * .....
.. * .......
... ** .....
. *. * ......
..........
.. **......
. * .. * .....
One line of input data represents the square of one line. Of the character strings in the input data,. (Period) indicates unmarked squares, and * (asterisk) indicates marked squares. The input data string does not contain any characters other than periods, asterisks, and line breaks.
In the above example, the rectangle indicated by 0 in the figure below is the largest.
.. *.... **.
..........
** .... ***.
.... * 00000
.. * ..00000
... ** 00000
. *. *. 00000
..... 00000
.. **. 00000
. * .. * 00000
Therefore, if you output 35, the answer will be correct. If all the squares are marked, output 0.
Input
Given multiple datasets. Each dataset starts with a line of H and W separated by spaces, followed by an H x W rectangle. Both H and W shall be 500 or less.
The input ends with a line containing two 0s. The number of datasets does not exceed 20.
Output
For each dataset, output the area of the largest rectangle on one line.
Example
Input
10 10
...*....**
..........
**....**..
........*.
..*.......
**........
.*........
..........
....*..***
.*....*...
10 10
..*....*..
.*.*...*..
*****..*..
*...*..*..
*...*..*..
..........
****.*...*
..*..*...*
.*...*...*
****..***.
2 3
...
...
0 0
Output
28
12
6
Submitted Solution:
```
# ref: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=924554#1
from itertools import product
while(True):
H,W = map(int,input().split())
if not H: break
ma = [list(map(int,input().replace(".","1").replace("*","0")))+[0] for _ in range(H)]
for i,j in product(range(1,H),range(W)):
if ma[i][j]: ma[i][j] += ma[i-1][j]
ans = 0
for i in range(H):
stk = []
for j in range(W+1):
cur = ma[i][j]
if (not stk) or stk[-1][1] < cur:
stk.append([j,cur])
elif stk[-1][1] > cur:
idx = j
while stk and stk[-1][1] >= cur:
ans = max(ans,stk[-1][1]*(j-stk[-1][0]))
stk.pop()
print(ans)
``` | instruction | 0 | 97,758 | 23 | 195,516 |
No | output | 1 | 97,758 | 23 | 195,517 |
Provide a correct Python 3 solution for this coding contest problem.
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible.
<image>
We will represent these by the number of square columns in each column. For example, when n = 5, each of them will be represented.
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
It is expressed as.
When n is input, create a program that outputs all in lexicographic order. n ≤ 30. However, lexicographic order means that two arrangements (a1, a2, ..., as) are arranged (b1, For b2, ..., bt), when a1> b1 or an integer i> 1 exists and a1 = b1, ..., ai-1 = bi-1 and ai> bi holds (a1) , a2, ..., as) are arranged so that they are output before (b1, b2, ..., bt).
The input data consists of one line, with n written on the first line.
In the output, write one line in lexicographic order and insert a line break at the end. The output of (a1, a2, ..., as) is the integer a1, a2, ..., as. Output in this order separated by blanks.
Input example 1
---
Five
Output example 1
Five
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
input
The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5.
output
All data sets are output in lexicographic order.
Example
Input
5
5
0
Output
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1 | instruction | 0 | 97,759 | 23 | 195,518 |
"Correct Solution:
```
def rec(n):
if n>0:
for i in range(n,0,-1):
if i<=ans[-1]:
ans.append(i)
rec(n-i)
ans.pop()
else:
if len(ans)!=0:
print ((' ').join(map(str, ans[1:])))
while True:
n = int(input())
if n==0: break
ans = [n]
rec(n)
``` | output | 1 | 97,759 | 23 | 195,519 |
Provide a correct Python 3 solution for this coding contest problem.
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible.
<image>
We will represent these by the number of square columns in each column. For example, when n = 5, each of them will be represented.
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
It is expressed as.
When n is input, create a program that outputs all in lexicographic order. n ≤ 30. However, lexicographic order means that two arrangements (a1, a2, ..., as) are arranged (b1, For b2, ..., bt), when a1> b1 or an integer i> 1 exists and a1 = b1, ..., ai-1 = bi-1 and ai> bi holds (a1) , a2, ..., as) are arranged so that they are output before (b1, b2, ..., bt).
The input data consists of one line, with n written on the first line.
In the output, write one line in lexicographic order and insert a line break at the end. The output of (a1, a2, ..., as) is the integer a1, a2, ..., as. Output in this order separated by blanks.
Input example 1
---
Five
Output example 1
Five
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
input
The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5.
output
All data sets are output in lexicographic order.
Example
Input
5
5
0
Output
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1 | instruction | 0 | 97,760 | 23 | 195,520 |
"Correct Solution:
```
def sq(n_left,num_min,list_p = []):
if n_left == 0:
print(" ".join(list(map(str,list_p))))
return 0
for i in range(min(num_min,n_left),0,-1):
list_p.append(i)
sq(n_left - i, i ,list_p)
list_p.pop()
while(True):
n = int(input())
if n == 0:
break
sq(n,n)
``` | output | 1 | 97,760 | 23 | 195,521 |
Provide a correct Python 3 solution for this coding contest problem.
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible.
<image>
We will represent these by the number of square columns in each column. For example, when n = 5, each of them will be represented.
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
It is expressed as.
When n is input, create a program that outputs all in lexicographic order. n ≤ 30. However, lexicographic order means that two arrangements (a1, a2, ..., as) are arranged (b1, For b2, ..., bt), when a1> b1 or an integer i> 1 exists and a1 = b1, ..., ai-1 = bi-1 and ai> bi holds (a1) , a2, ..., as) are arranged so that they are output before (b1, b2, ..., bt).
The input data consists of one line, with n written on the first line.
In the output, write one line in lexicographic order and insert a line break at the end. The output of (a1, a2, ..., as) is the integer a1, a2, ..., as. Output in this order separated by blanks.
Input example 1
---
Five
Output example 1
Five
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
input
The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5.
output
All data sets are output in lexicographic order.
Example
Input
5
5
0
Output
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1 | instruction | 0 | 97,761 | 23 | 195,522 |
"Correct Solution:
```
def generate_square(rest, output=[10000]):
for i in range(rest, 0, -1):
if output[-1] >= i:
yield from generate_square(rest - i, output + [i])
if rest == 0:
yield output
while 1:
x = int(input().strip())
if x == 0:
break
generator = generate_square(x)
for x in generator:
print(" ".join(map(str, x[1:])))
``` | output | 1 | 97,761 | 23 | 195,523 |
Provide a correct Python 3 solution for this coding contest problem.
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible.
<image>
We will represent these by the number of square columns in each column. For example, when n = 5, each of them will be represented.
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
It is expressed as.
When n is input, create a program that outputs all in lexicographic order. n ≤ 30. However, lexicographic order means that two arrangements (a1, a2, ..., as) are arranged (b1, For b2, ..., bt), when a1> b1 or an integer i> 1 exists and a1 = b1, ..., ai-1 = bi-1 and ai> bi holds (a1) , a2, ..., as) are arranged so that they are output before (b1, b2, ..., bt).
The input data consists of one line, with n written on the first line.
In the output, write one line in lexicographic order and insert a line break at the end. The output of (a1, a2, ..., as) is the integer a1, a2, ..., as. Output in this order separated by blanks.
Input example 1
---
Five
Output example 1
Five
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
input
The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5.
output
All data sets are output in lexicographic order.
Example
Input
5
5
0
Output
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1 | instruction | 0 | 97,762 | 23 | 195,524 |
"Correct Solution:
```
def solve():
ans = []
def square(n, rest, limit):
if rest == 0:
print(*ans)
else:
for i in range(rest, 0, -1):
if i > limit:
continue
ans.append(i)
square(n, rest - i, i)
ans.pop()
import sys
for n in map(int, sys.stdin.readlines()):
if n == 0:
break
square(n, n, n)
solve()
``` | output | 1 | 97,762 | 23 | 195,525 |
Provide a correct Python 3 solution for this coding contest problem.
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible.
<image>
We will represent these by the number of square columns in each column. For example, when n = 5, each of them will be represented.
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
It is expressed as.
When n is input, create a program that outputs all in lexicographic order. n ≤ 30. However, lexicographic order means that two arrangements (a1, a2, ..., as) are arranged (b1, For b2, ..., bt), when a1> b1 or an integer i> 1 exists and a1 = b1, ..., ai-1 = bi-1 and ai> bi holds (a1) , a2, ..., as) are arranged so that they are output before (b1, b2, ..., bt).
The input data consists of one line, with n written on the first line.
In the output, write one line in lexicographic order and insert a line break at the end. The output of (a1, a2, ..., as) is the integer a1, a2, ..., as. Output in this order separated by blanks.
Input example 1
---
Five
Output example 1
Five
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
input
The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5.
output
All data sets are output in lexicographic order.
Example
Input
5
5
0
Output
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1 | instruction | 0 | 97,763 | 23 | 195,526 |
"Correct Solution:
```
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0507
"""
import sys
from sys import stdin
input = stdin.readline
def solve(n, a=0):
result = []
in_progress = [[[], n]]
while in_progress:
arr, rem = in_progress.pop()
ub = min(arr[-1] if arr else rem, rem)
for i in range(ub, 0, -1):
if rem - i == 0:
result.append(arr + [i])
else:
in_progress.append([arr + [i], rem - i])
return sorted(result, reverse=True)
def main(args):
while True:
n = int(input())
if n == 0:
break
ans = solve(n)
for row in ans:
print(*row, sep=' ')
if __name__ == '__main__':
main(sys.argv[1:])
``` | output | 1 | 97,763 | 23 | 195,527 |
Provide a correct Python 3 solution for this coding contest problem.
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible.
<image>
We will represent these by the number of square columns in each column. For example, when n = 5, each of them will be represented.
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
It is expressed as.
When n is input, create a program that outputs all in lexicographic order. n ≤ 30. However, lexicographic order means that two arrangements (a1, a2, ..., as) are arranged (b1, For b2, ..., bt), when a1> b1 or an integer i> 1 exists and a1 = b1, ..., ai-1 = bi-1 and ai> bi holds (a1) , a2, ..., as) are arranged so that they are output before (b1, b2, ..., bt).
The input data consists of one line, with n written on the first line.
In the output, write one line in lexicographic order and insert a line break at the end. The output of (a1, a2, ..., as) is the integer a1, a2, ..., as. Output in this order separated by blanks.
Input example 1
---
Five
Output example 1
Five
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
input
The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5.
output
All data sets are output in lexicographic order.
Example
Input
5
5
0
Output
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1 | instruction | 0 | 97,764 | 23 | 195,528 |
"Correct Solution:
```
def sqmake(n):
if sq[n-1:n]:pass
else:sqmake(n-1)
sq_n=[]
for j in sq[n-1]:
for k in range(len(j)):
sq_n_i=j[:]
sq_n_i[k]+=1
sq_n_i.sort(reverse=True)
if sq_n_i in sq_n:pass
else:sq_n.append(sq_n_i)
sq_n_i=j[:]
sq_n_i.append(1)
sq_n.append(sq_n_i)
sq_n.sort(reverse=True)
sq.append(sq_n)
sq=[[[0]],[[1]]]
while 1:
n=int(input())
if n==0:break
sqmake(n)
for i in sq[n]:print(' '.join(map(str,i)))
``` | output | 1 | 97,764 | 23 | 195,529 |
Provide a correct Python 3 solution for this coding contest problem.
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible.
<image>
We will represent these by the number of square columns in each column. For example, when n = 5, each of them will be represented.
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
It is expressed as.
When n is input, create a program that outputs all in lexicographic order. n ≤ 30. However, lexicographic order means that two arrangements (a1, a2, ..., as) are arranged (b1, For b2, ..., bt), when a1> b1 or an integer i> 1 exists and a1 = b1, ..., ai-1 = bi-1 and ai> bi holds (a1) , a2, ..., as) are arranged so that they are output before (b1, b2, ..., bt).
The input data consists of one line, with n written on the first line.
In the output, write one line in lexicographic order and insert a line break at the end. The output of (a1, a2, ..., as) is the integer a1, a2, ..., as. Output in this order separated by blanks.
Input example 1
---
Five
Output example 1
Five
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
input
The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5.
output
All data sets are output in lexicographic order.
Example
Input
5
5
0
Output
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1 | instruction | 0 | 97,765 | 23 | 195,530 |
"Correct Solution:
```
def solve():
answers = []
def square(ans, rest, limit):
if rest == 0:
print(*ans)
else:
for i in range(rest, 0, -1):
if i > limit:
continue
square(ans + [i], rest - i, i)
import sys
for n in map(int, sys.stdin):
if n == 0:
break
square([], n, n)
solve()
``` | output | 1 | 97,765 | 23 | 195,531 |
Provide a correct Python 3 solution for this coding contest problem.
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible.
<image>
We will represent these by the number of square columns in each column. For example, when n = 5, each of them will be represented.
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
It is expressed as.
When n is input, create a program that outputs all in lexicographic order. n ≤ 30. However, lexicographic order means that two arrangements (a1, a2, ..., as) are arranged (b1, For b2, ..., bt), when a1> b1 or an integer i> 1 exists and a1 = b1, ..., ai-1 = bi-1 and ai> bi holds (a1) , a2, ..., as) are arranged so that they are output before (b1, b2, ..., bt).
The input data consists of one line, with n written on the first line.
In the output, write one line in lexicographic order and insert a line break at the end. The output of (a1, a2, ..., as) is the integer a1, a2, ..., as. Output in this order separated by blanks.
Input example 1
---
Five
Output example 1
Five
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
input
The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5.
output
All data sets are output in lexicographic order.
Example
Input
5
5
0
Output
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1 | instruction | 0 | 97,766 | 23 | 195,532 |
"Correct Solution:
```
def solve():
answers = [[] for i in range(31)]
ans = []
def square(n, rest, limit):
if rest == 0:
answers[n].append(ans[:])
else:
for i in range(rest, 0, -1):
if i > limit:
continue
ans.append(i)
square(n, rest - i, i)
ans.pop()
import sys
for n in map(int, sys.stdin.readlines()):
if n == 0:
break
a = answers[n]
if not a:
square(n, n, n)
for l in a:
print(*l)
solve()
``` | output | 1 | 97,766 | 23 | 195,533 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible.
<image>
We will represent these by the number of square columns in each column. For example, when n = 5, each of them will be represented.
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
It is expressed as.
When n is input, create a program that outputs all in lexicographic order. n ≤ 30. However, lexicographic order means that two arrangements (a1, a2, ..., as) are arranged (b1, For b2, ..., bt), when a1> b1 or an integer i> 1 exists and a1 = b1, ..., ai-1 = bi-1 and ai> bi holds (a1) , a2, ..., as) are arranged so that they are output before (b1, b2, ..., bt).
The input data consists of one line, with n written on the first line.
In the output, write one line in lexicographic order and insert a line break at the end. The output of (a1, a2, ..., as) is the integer a1, a2, ..., as. Output in this order separated by blanks.
Input example 1
---
Five
Output example 1
Five
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
input
The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5.
output
All data sets are output in lexicographic order.
Example
Input
5
5
0
Output
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
Submitted Solution:
```
import sys
def line():return sys.stdin.readline().strip()
def a(n,k,s):
if k == 0:print(s[1:])
elif k > 0:
for i in range(1,n + 1)[::-1]:
a(i,k - i,s + " " + str(i))
while True:
n = int(line())
if n == 0:break
a(n,n,"")
``` | instruction | 0 | 97,767 | 23 | 195,534 |
Yes | output | 1 | 97,767 | 23 | 195,535 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible.
<image>
We will represent these by the number of square columns in each column. For example, when n = 5, each of them will be represented.
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
It is expressed as.
When n is input, create a program that outputs all in lexicographic order. n ≤ 30. However, lexicographic order means that two arrangements (a1, a2, ..., as) are arranged (b1, For b2, ..., bt), when a1> b1 or an integer i> 1 exists and a1 = b1, ..., ai-1 = bi-1 and ai> bi holds (a1) , a2, ..., as) are arranged so that they are output before (b1, b2, ..., bt).
The input data consists of one line, with n written on the first line.
In the output, write one line in lexicographic order and insert a line break at the end. The output of (a1, a2, ..., as) is the integer a1, a2, ..., as. Output in this order separated by blanks.
Input example 1
---
Five
Output example 1
Five
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
input
The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5.
output
All data sets are output in lexicographic order.
Example
Input
5
5
0
Output
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
Submitted Solution:
```
def solve():
answers = []
ans = []
def square(n, rest, limit):
if rest == 0:
answers.append(' '.join(map(str, ans)))
else:
for i in range(rest, 0, -1):
if i > limit:
continue
ans.append(i)
square(n, rest - i, i)
ans.pop()
import sys
for n in map(int, sys.stdin.readlines()):
if n == 0:
break
square(n, n, n)
print('\n'.join(answers))
solve()
``` | instruction | 0 | 97,768 | 23 | 195,536 |
Yes | output | 1 | 97,768 | 23 | 195,537 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible.
<image>
We will represent these by the number of square columns in each column. For example, when n = 5, each of them will be represented.
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
It is expressed as.
When n is input, create a program that outputs all in lexicographic order. n ≤ 30. However, lexicographic order means that two arrangements (a1, a2, ..., as) are arranged (b1, For b2, ..., bt), when a1> b1 or an integer i> 1 exists and a1 = b1, ..., ai-1 = bi-1 and ai> bi holds (a1) , a2, ..., as) are arranged so that they are output before (b1, b2, ..., bt).
The input data consists of one line, with n written on the first line.
In the output, write one line in lexicographic order and insert a line break at the end. The output of (a1, a2, ..., as) is the integer a1, a2, ..., as. Output in this order separated by blanks.
Input example 1
---
Five
Output example 1
Five
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
input
The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5.
output
All data sets are output in lexicographic order.
Example
Input
5
5
0
Output
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
Submitted Solution:
```
dic = [[] for i in range(31)]
dic[1].append([1])
def func(n):
if dic[n]:
return dic[n]
else:
dic[n].append([n])
for i in range(n - 1, 0, -1):
for l in func(n - i):
if i >= l[0]:
dic[n].append([i] + l)
return dic[n]
func(30)
while True:
n = int(input())
if not n:
break
for l in dic[n]:
print(" ".join(map(str, l)))
``` | instruction | 0 | 97,769 | 23 | 195,538 |
Yes | output | 1 | 97,769 | 23 | 195,539 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possible.
<image>
We will represent these by the number of square columns in each column. For example, when n = 5, each of them will be represented.
(5) (4, 1) (3, 2) (3, 1, 1) (2, 2, 1) (2, 1, 1, 1) (1, 1, 1, 1, 1)
It is expressed as.
When n is input, create a program that outputs all in lexicographic order. n ≤ 30. However, lexicographic order means that two arrangements (a1, a2, ..., as) are arranged (b1, For b2, ..., bt), when a1> b1 or an integer i> 1 exists and a1 = b1, ..., ai-1 = bi-1 and ai> bi holds (a1) , a2, ..., as) are arranged so that they are output before (b1, b2, ..., bt).
The input data consists of one line, with n written on the first line.
In the output, write one line in lexicographic order and insert a line break at the end. The output of (a1, a2, ..., as) is the integer a1, a2, ..., as. Output in this order separated by blanks.
Input example 1
---
Five
Output example 1
Five
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
input
The input consists of multiple datasets. Input ends when n is 0. The number of datasets does not exceed 5.
output
All data sets are output in lexicographic order.
Example
Input
5
5
0
Output
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
5
4 1
3 2
3 1 1
2 2 1
2 1 1 1
1 1 1 1 1
Submitted Solution:
```
def main():
dic = [[] for i in range(31)]
dic[1].append([1])
def func(n):
if dic[n]:
return dic[n]
else:
dic[n].append([n])
for i in range(n - 1, 0, -1):
for l in func(n - i):
if i >= l[0]:
dic[n].append([i] + l)
return dic[n]
func(30)
while True:
n = int(input())
if not n:
break
for l in dic[n]:
print(" ".join(map(str, l)))
main()
``` | instruction | 0 | 97,770 | 23 | 195,540 |
Yes | output | 1 | 97,770 | 23 | 195,541 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.