text
stringlengths
198
433k
conversation_id
int64
0
109k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an equation: Ax2 + Bx + C = 0. Your task is to find the number of distinct roots of the equation and print all of them in ascending order. Input The first line contains three integer numbers A, B and C ( - 105 ≀ A, B, C ≀ 105). Any coefficient may be equal to 0. Output In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point. Examples Input 1 -5 6 Output 2 2.0000000000 3.0000000000 Submitted Solution: ``` import math def solve_const(x): if(x == 0): print(-1) else: print(0) def solve_lineal(x, y): if(y == 0): #yt = 0 => t = 0 print(1) print(0) else: #xt + y = 0 => t = -y/x print(1) print(-y / x) def solve_square(x, y, z): d = y * y - 4 * x * z if(d < 0): print(0) elif(d > 0): print(2) x1 = (-y + math.sqrt(d)) / (2 * x) x2 = (-y - math.sqrt(d)) / (2 * x) print(min(x1, x2)) print(max(x1, x2)) else: print(1) print((-y) / (2 * x)) a, b, c = map(int, input().split()) if(a == 0): if(b == 0): solve_const(c) else: solve_lineal(b, c) else: solve_square(a, b, c) ``` Yes
86,000
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an equation: Ax2 + Bx + C = 0. Your task is to find the number of distinct roots of the equation and print all of them in ascending order. Input The first line contains three integer numbers A, B and C ( - 105 ≀ A, B, C ≀ 105). Any coefficient may be equal to 0. Output In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point. Examples Input 1 -5 6 Output 2 2.0000000000 3.0000000000 Submitted Solution: ``` a, b, c = map(int, input().split()) t = [1, -c / b] if b else [-(c == 0)] if a: d, x = b * b - 4 * a * c, -2 * a if d: t = [0] if d < 0 else [2] + sorted([(b - d ** 0.5) / x, (b + d ** 0.5) / x]) else: t = [1, b / x] print(*t) ``` Yes
86,001
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an equation: Ax2 + Bx + C = 0. Your task is to find the number of distinct roots of the equation and print all of them in ascending order. Input The first line contains three integer numbers A, B and C ( - 105 ≀ A, B, C ≀ 105). Any coefficient may be equal to 0. Output In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point. Examples Input 1 -5 6 Output 2 2.0000000000 3.0000000000 Submitted Solution: ``` A, B, C = map(int, input().split()) if A == 0 and B == 0 and C == 0: print(-1) elif A == 0 and B == 0: print(0) elif A == 0 and C == 0: print(1) print(0) elif B == 0 and C == 0: print(1) print(0) elif A == 0: print(1) print(-(C / B)) elif B == 0: print(2) Ans1 = -((C / A) ** 0.5) Ans2 = (C / A) ** 0.5 print(min(Ans1, Ans2)) print(max(Ans1, Ans2)) elif C == 0: print(2) if B / A < 0: print(min(-(B / A), 0)) print(max(-(B / A), 0)) else: print(min(B / A, 0)) print(max(B / A, 0)) else: D = B ** 2 - 4 * A * C if D < 0: print(0) elif D == 0: print(1) print(-B / (A * 2)) elif D > 0: print(2) Ans1 = (-B - (D ** 0.5)) / (A * 2) Ans2 = (-B + (D ** 0.5)) / (A * 2) print(min(Ans1, Ans2)) print(max(Ans1, Ans2)) ``` No
86,002
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an equation: Ax2 + Bx + C = 0. Your task is to find the number of distinct roots of the equation and print all of them in ascending order. Input The first line contains three integer numbers A, B and C ( - 105 ≀ A, B, C ≀ 105). Any coefficient may be equal to 0. Output In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point. Examples Input 1 -5 6 Output 2 2.0000000000 3.0000000000 Submitted Solution: ``` from math import sqrt a,b,c = map(int,input().split()) if a==0 and b == 0: print("-1") elif a == 0 : x = -1*c/b if x == 0: print(x) else: print('1') print ("{0:.5f}".format(x)) elif b == 0 : x = -1*c/a if x <= 0: print('0') else: print('1') print ("{0:.5f}".format(sqrt(x))) else: result = b**2 - 4*a*c if result<0: print('0') else: x = ((-1*b) - sqrt(result))/(2*a) y = ((-1*b) + sqrt(result))/(2*a) if x == y: print(1) print("{0:.5f}".format(x)) else: print(2) print("{0:.5f}".format(x)) print("{0:.5f}".format(y)) ``` No
86,003
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an equation: Ax2 + Bx + C = 0. Your task is to find the number of distinct roots of the equation and print all of them in ascending order. Input The first line contains three integer numbers A, B and C ( - 105 ≀ A, B, C ≀ 105). Any coefficient may be equal to 0. Output In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point. Examples Input 1 -5 6 Output 2 2.0000000000 3.0000000000 Submitted Solution: ``` import sys, math input = sys.stdin.readline a, b, c = map(int, input().split()) if(a == 0): if(b == 0): if(c == 0): print(-1) else: print(0) else: print("1\n{:.6f}".format(c / b)) else: delta = b * b - 4 * a * c if(delta < 0): print(0) elif(delta == 0): print("1\n{:.6f}".format(-b / (2 *a))) else: x1 = (-b - math.sqrt(delta)) / (2 * a) x2 = (-b + math.sqrt(delta)) / (2 * a) print(2) print("{:.6f}\n{:.6f}".format(min(x1, x2), max(x1,x2))) ``` No
86,004
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given an equation: Ax2 + Bx + C = 0. Your task is to find the number of distinct roots of the equation and print all of them in ascending order. Input The first line contains three integer numbers A, B and C ( - 105 ≀ A, B, C ≀ 105). Any coefficient may be equal to 0. Output In case of infinite root count print the only integer -1. In case of no roots print the only integer 0. In other cases print the number of root on the first line and the roots on the following lines in the ascending order. Print roots with at least 5 digits after the decimal point. Examples Input 1 -5 6 Output 2 2.0000000000 3.0000000000 Submitted Solution: ``` class CodeforcesTask20BSolution: def __init__(self): self.result = '' self.a_b_c = [] def read_input(self): self.a_b_c = [int(x) for x in input().split(" ")] def process_task(self): if not self.a_b_c[0]: if not self.a_b_c[1]: if not self.a_b_c[2]: self.result = "-1" else: self.result = "0" else: self.result = "1\n{0:.6f}".format(-self.a_b_c[2] / self.a_b_c[1]) else: delta = self.a_b_c[1] ** 2 - 4 * self.a_b_c[0] * self.a_b_c[2] if not delta: self.result = "1\n{0:.6f}".format(-self.a_b_c[2] / self.a_b_c[0]) elif delta < 0: self.result = "0" else: import math s_delta = math.sqrt(delta) roots = [(-self.a_b_c[1] - s_delta) / (2 * self.a_b_c[0]), (-self.a_b_c[1] + s_delta) / (2 * self.a_b_c[0])] roots.sort() self.result = "2\n{0:.6f}\n{1:.6f}".format(roots[0], roots[1]) def get_result(self): return self.result if __name__ == "__main__": Solution = CodeforcesTask20BSolution() Solution.read_input() Solution.process_task() print(Solution.get_result()) ``` No
86,005
Provide tags and a correct Python 3 solution for this coding contest problem. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Tags: brute force, implementation, strings Correct Solution: ``` x,y,z=32,13,2016 cnt=[] for i in range(z): cnt.append([]) for i in range(z): for j in range(y): cnt[i].append([]) for i in range(z): for j in range(y): for k in range(x): cnt[i][j].append(int(0)) s=input() ansstr='' ans=0 a=[0,31,28,31,30,31,30,31,31,30,31,30,31] for i in range(len(s)-9): if(s[i].isdigit()&s[i+1].isdigit()&~s[i+2].isalnum()&s[i+3].isdigit()&s[i+4].isdigit()&~s[i+5].isalnum()&s[i+6].isdigit()&s[i+7].isdigit()&s[i+8].isdigit()&s[i+9].isdigit()): if(((int(s[i+6])*1000+int(s[i+7])*100+int(s[i+8])*10+int(s[i+9]))>=2013)&((int(s[i+6])*1000+int(s[i+7])*100+int(s[i+8])*10+int(s[i+9]))<=2015)): if(((int(s[i+3])*10+int(s[i+4]))<=12)&((int(s[i+3])*10+int(s[i+4]))>=1)): if(((int(s[i])*10+int(s[i+1]))<=a[(int(s[i+3])*10+int(s[i+4]))])&((int(s[i])*10+int(s[i+1]))>=1)): cnt[int(s[i+6])*1000+int(s[i+7])*100+int(s[i+8])*10+int(s[i+9])][int(s[i+3])*10+int(s[i+4])][int(s[i])*10+int(s[i+1])]+=1 if(cnt[int(s[i+6]+s[i+7]+s[i+8]+s[i+9])][int(s[i+3]+s[i+4])][int(s[i]+s[i+1])]>ans): ansstr=str(s[i]+s[i+1]+'-'+s[i+3]+s[i+4]+'-'+s[i+6]+s[i+7]+s[i+8]+s[i+9]) ans=cnt[int(s[i+6]+s[i+7]+s[i+8]+s[i+9])][int(s[i+3]+s[i+4])][int(s[i]+s[i+1])] print(ansstr) ```
86,006
Provide tags and a correct Python 3 solution for this coding contest problem. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Tags: brute force, implementation, strings Correct Solution: ``` s=input() l=len(s) m=['01','02','03','04','05','06','07','08','09','10','11','12'] d=[31,28,31,30,31,30,31,31,30,31,30,31] ans={} for i in range(l-9): if s[i+2] == '-': if s[i+3]+s[i+4] in m: if s[i+5] == '-': if s[i+6]+s[i+7]+s[i+8]+s[i+9] in ['2013','2014','2015']: if s[i] in '0123456789': if s[i+1] in '0123456789': if int(s[i]+s[i+1])>0 and int(s[i]+s[i+1]) <= d[int(s[i+3]+s[i+4])-1]: if s[i:i+10] in ans: ans[s[i:i+10]]+=1 else: ans[s[i:i+10]]=1 #print(ans) x=-1 a=None for i in ans: if ans[i]>x: x=ans[i] a=i print(a) ```
86,007
Provide tags and a correct Python 3 solution for this coding contest problem. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Tags: brute force, implementation, strings Correct Solution: ``` import re from collections import defaultdict s = input() x = re.findall("(?=(\d\d-\d\d-\d\d\d\d))", s) month_to_day = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] ans = "" def val(): return 0 date_count = defaultdict(val) max_count = 0 for date in x: d, m, y = [int(x) for x in date.split('-')] if(2013 <= y <= 2015 and 1 <= d <= 31 and 1 <= m <= 12 and 0 < d <= month_to_day[m]): date_count[date] += 1 if date in date_count and date_count[date] > max_count: max_count = date_count[date] ans = date print(ans) ```
86,008
Provide tags and a correct Python 3 solution for this coding contest problem. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Tags: brute force, implementation, strings Correct Solution: ``` def valid(s): if(not(s[2]==s[5]=='-')): return False for i in range(10): if(i==2 or i==5): continue if(s[i]=='-'): return False m=int(s[6:]) if(m<2013 or m>2015): return False m=int(s[3:5]) if(m<1 or m>12): return False d=int(s[0:2]) if(d<1 or d>D[m-1]): return False return True D=[31,28,31,30,31,30,31,31,30,31,30,31] A={} s=input() x=s[0:10] if(valid(x)): A[x]=1 for i in range(10,len(s)): x=x[1:]+s[i] if(valid(x)): if(x in A): A[x]+=1 else: A[x]=1 maxx=0 ans="" for item in A: if(A[item]>maxx): maxx=A[item] ans=item print(ans) ```
86,009
Provide tags and a correct Python 3 solution for this coding contest problem. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Tags: brute force, implementation, strings Correct Solution: ``` from re import compile from collections import defaultdict from time import strptime def validDate(date): try: strptime(date, "%d-%m-%Y") return True except: return False myFormat = compile(r'(?=([0-2]\d|3[0-1])-(0\d|1[0-2])-(201[3-5]))' ) Dict = defaultdict(int) for d in myFormat.finditer(input()): temp = "-".join([d.group(1),d.group(2),d.group(3)]) if validDate (temp): Dict[temp] = -~Dict[temp] print(max(Dict, key=Dict.get)) ```
86,010
Provide tags and a correct Python 3 solution for this coding contest problem. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Tags: brute force, implementation, strings Correct Solution: ``` from re import findall from calendar import monthrange from collections import defaultdict s=input() dic=defaultdict(int) for i in findall('(?=(\d\d-\d\d-201[3-5]))',s): d,m,y = map(int,i.split("-")) if 1<=m<=12 and 1<=d<=monthrange(y,m)[1]: dic[i]+=1 print(max(dic,key=dic.get)) ```
86,011
Provide tags and a correct Python 3 solution for this coding contest problem. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Tags: brute force, implementation, strings Correct Solution: ``` def s(): import re pat = re.compile('\d{2}-\d{2}-\d{4}') a = input() se = {} def check(x): m = [0,31,28,31,30,31,30,31,31,30,31,30,31] return x[2] >= 2013 and x[2] <= 2015 and x[1] >= 1 and x[1] <= 12 and x[0] >= 1 and x[0] <= m[x[1]] for i in range(len(a)-9): c = a[i:i+10] if pat.match(c) and check(list(map(int,c.split('-')))): if c in se: se[c] += 1 else: se[c] = 1 print(max(se.items(),key=lambda x:x[1])[0]) s() ```
86,012
Provide tags and a correct Python 3 solution for this coding contest problem. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Tags: brute force, implementation, strings Correct Solution: ``` s = list(map(str, input().split('-'))) dic = {} d = {1:31, 2:28, 3:31,4: 30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30, 12:31} for i in range(len(s)-2): if len(s[i])>=2: if len(s[i+1])==2 and int(s[i+1])<=12 and int(s[i+1])>=1 and int(s[i][-2]+s[i][-1])<=d[int(s[i+1])] and int(s[i][-2]+s[i][-1])>=1 and len(s[i+2])>=4 and int(s[i+2][:4])>=2013 and int(s[i+2][:4])<=2015: st = s[i][-2]+s[i][-1]+'-'+s[i+1] + '-' + s[i+2][:4] try: dic[st]+=1 except: dic[st]=1 max = 0 ind = 0 for i in dic: if max<dic[i]: max = dic[i] ind = i print(ind) ```
86,013
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Submitted Solution: ``` s = input().split('-') ex = {} ans = 0 sans = '' def solve(i): global ex global ans global sans global s day = s[i] month = s[i+1] year = s[i+2] if len(day) < 2 or len(month) != 2 or len(year) < 4: return day = day[-2:] year = year[:4] if int(year) < 2013 or int(year) > 2015: return if int(month) < 1 or int(month) > 12: return if int(day) < 1 or int(day) > 31: return # verifica dia de acordo com o mΓͺs (meu Deus...) tm = int(month) if tm in [1, 3, 5, 7, 8, 10, 12] and int(day) > 31: return if tm == 2 and int(day) > 28: return if tm in [4, 6, 9, 11] and int(day) > 30: return date = day+month+year if date in ex: ex[date] += 1 if ex[date] > ans: ans = ex[date] sans = date else: ex[date] = 1 if ans == 0: ans = 1 sans = date def c(s): print(f'{s[:2]}-{s[2:4]}-{s[4:]}') for i in range(len(s)-2): if len(s[i]) <= 1: continue solve(i) c(sans) ``` Yes
86,014
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Submitted Solution: ``` s = input() nums = set([str(x) for x in range(0, 9+1)]) cnt = dict() m = -1 ans = 0 days_in_month = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12:31} for i in range(len(s) - 10+1): q = s[i:i+10] if q[0] in nums and q[1] in nums and q[2] == "-": if q[3] in nums and q[4] in nums and q[5] == "-": if q[6] in nums and q[7] in nums and q[8] in nums and q[9] in nums: try: day = int(q[0:1+1]) month = int(q[3:4+1]) year = int(q[6:9+1]) except: continue #print(day, month) if 0 < month <= 12 and 0 < day <= days_in_month[month] and 2013 <= year <= 2015: try: cnt[q] += 1 except: cnt[q] = 0 #print(cnt) for key in cnt.keys(): if cnt[key] > m: m = cnt[key] ans = key print(ans) ``` Yes
86,015
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Submitted Solution: ``` s=input().rstrip() ans=[] p=dict() p[1]=p[3]=p[5]=p[7]=p[8]=p[10]=p[12]=31 p[4]=p[6]=p[9]=p[11]=30 p[2]=28 for i in range(len(s)-3): if s[i:i+4]=='2013' or s[i:i+4]=='2014' or s[i:i+4]=='2015': #print('halua') if s[i-1]=='-' and s[i-2]!='-' and s[i-3]!='-' and s[i-4]=='-' and s[i-5]!='-' and s[i-6]!='-': #print('hand',int(s[i-3] + s[i-2])) if int(s[i-3]+s[i-2])>=1 and int(s[i-3]+s[i-2])<=12: #print('bhadu') if int(s[i-6]+s[i-5])<=p[int(s[i-3]+s[i-2])] and int(s[i-6]+s[i-5])>=1: ans.append(s[i-6:i+4]) #print(ans) p=dict() for i in ans: if i in p: p[i]+=1 else: p[i]=1 mini=0 ans='' for i in p: if p[i]>mini: mini=p[i] ans=i print(ans) ``` Yes
86,016
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Submitted Solution: ``` s = input() date_ = {1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31} def is_Date_Correct(s): return (1<=int(s[3:5])<=12 and 2013<=int(s[6:])<=2015 and 1<=int(s[:2])<=date_[int(s[3:5])]) def is_dateformat(s): if s[2]=='-' and s[5]=='-': for i in range(len(s)): if i==2 or i==5: continue if s[i] == '-': return False; return True; return False; i = 0 map = {} while(i<len(s)): x = s[i:i+10] if is_dateformat(x) and is_Date_Correct(x): if x in map: map[x]+=1 else: map[x]=1 i+=8 else: i+=1 if i+10>len(s): break count = 0 res = "" for i in map: if map[i] > count: res = i count = map[i] print(res) ``` Yes
86,017
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Submitted Solution: ``` from collections import defaultdict t = input() s = defaultdict(int) for i in range(len(t) - 9): if t[i + 2] == '-' and t[i + 5: i + 9] == '-201' and '2' < t[i + 9] < '6': if (t[i + 3] == '0' and '0' < t[i + 4] <= '9') or (t[i + 3] == '1' and '0' <= t[i + 4] < '3'): if t[i: i + 2] < '30': s[t[i: i + 10]] += 1 elif t[i: i + 2] == '30': if t[i + 3: i + 5] != '02': s[t[i: i + 10]] += 1 elif t[i: i + 2] < '32' and not (t[i + 3: i + 5] in ['04', '06', '09', '11']): s[t[i: i + 10]] += 1 m = max(s.values()) for i in s: if s[i] == m: print(i) break ``` No
86,018
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Submitted Solution: ``` try: import re st = input() dct = {} r = re.compile(r'(\d\d-\d\d-\d\d\d\d)') r2 = re.compile(r'(\d\d)-(\d\d)-(\d\d\d\d)') def judge_date(date): rst = r2.match(date) d, m, y = map(int, rst.groups()) if 2013 <= y <= 2015: if 1 <= m <= 12: if m in (1, 3, 5, 7, 8, 10, 12): if d > 31: return False elif m == 2: if d > 28: return False else: if d > 30: return False if d <= 0: return False return True return False while st: rst = r.search(st) if rst is None: break if judge_date(rst[0]): try: dct[rst[0]] += 1 except KeyError: dct[rst[0]] = 1 st = st[rst.start() + 1:] print(max(dct.items(), key=lambda x: x[1])[0]) except Exception as e: print(e) ``` No
86,019
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Submitted Solution: ``` def main(): s = input() l=[] a=["0","1","2","3","4","5","6","7","8","9"] for i in range(len(s)-9): if ((s[i] in a) or s[i]=="-") and (s[i+1] in a) and s[i+2]=="-" and (s[i+3] in a) and (s[i+4] in a) and s[i+5]=="-" and (s[i+6] in a) and (s[i+7] in a) and (s[i+8] in a) and (s[i+9] in a): l.append(s[i:i+10]) elif ((s[i] in a) or s[i]=="-") and (s[i+1] in a) and s[i+2]=="-" and (s[i+3] in a) and s[i+4]=="-" and (s[i+5] in a) and (s[i+6] in a) and (s[i+7] in a) and (s[i+8] in a): l.append(s[i:i+9]) for i in l: if len(i)==10: date1 = i[0:2] month1 = i[3:5] year = i[6:10] date1 = list(date1) month1 = list(month1) else: date1 = i[0:2] month1=i[3:4] year = i[5:9] date1=list(date1) month1=list(month1) if date1[0]=="-": date1[0]="0" date="" month="" for i_ in date1: date+=i_ for j_ in month1: month+=j_ if len(month)==1: month="0"+month thirtyone =[1,3,5,7,8,10,12] twen=[2] #poss=[2013,2014,2015] if int(year)>=2013 and int(year)<=2015: if int(month) in thirtyone: if int(date)>0 and int(date)<=31: continue else: l.remove(i) elif int(month) in twen: if int(date)>0 and int(date)<=28: continue else: l.remove(i) else: if int(date)>0 and int(date)<=30: continue else: l.remove(i) else: l.remove(i) sett = set(l) m=0 ans=0 for i in sett: cnt = l.count(i) if cnt>m: ans=i m=cnt print(ans) if __name__ == '__main__': main() ``` No
86,020
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A recently found Ancient Prophesy is believed to contain the exact Apocalypse date. The prophesy is a string that only consists of digits and characters "-". We'll say that some date is mentioned in the Prophesy if there is a substring in the Prophesy that is the date's record in the format "dd-mm-yyyy". We'll say that the number of the date's occurrences is the number of such substrings in the Prophesy. For example, the Prophesy "0012-10-2012-10-2012" mentions date 12-10-2012 twice (first time as "0012-10-2012-10-2012", second time as "0012-10-2012-10-2012"). The date of the Apocalypse is such correct date that the number of times it is mentioned in the Prophesy is strictly larger than that of any other correct date. A date is correct if the year lies in the range from 2013 to 2015, the month is from 1 to 12, and the number of the day is strictly more than a zero and doesn't exceed the number of days in the current month. Note that a date is written in the format "dd-mm-yyyy", that means that leading zeroes may be added to the numbers of the months or days if needed. In other words, date "1-1-2013" isn't recorded in the format "dd-mm-yyyy", and date "01-01-2013" is recorded in it. Notice, that any year between 2013 and 2015 is not a leap year. Input The first line contains the Prophesy: a non-empty string that only consists of digits and characters "-". The length of the Prophesy doesn't exceed 105 characters. Output In a single line print the date of the Apocalypse. It is guaranteed that such date exists and is unique. Examples Input 777-444---21-12-2013-12-2013-12-2013---444-777 Output 13-12-2013 Submitted Solution: ``` ''' def main(): from sys import stdin,stdout if __name__=='__main__': main() ''' #349B ''' def main(): from sys import stdin,stdout N = int(stdin.readline()) arr = list(map(int,stdin.readline().split())) div = [] for i in arr: div.append(N//i) maxim = 0 maxindex = -1 for i in range(9): if div[i] >maxim: maxim = div[i] maxindex = i if maxindex > -1: ans = [ (maxindex+1) for i in range(maxim)] N= N%arr[maxindex] #print(N) i = 0 while i<maxim: #print('i=',i,'N=',N) for j in range(8,maxindex,-1): #print('j=',j,'diff=',arr[j]-arr[ans[i]-1]) if arr[j]-arr[ans[i]-1] <=N: N -= arr[j]-arr[ans[i]-1] ans[i] = j+1 break i+=1 for i in ans: stdout.write(str(i)) else: stdout.write('-1\n') if __name__=='__main__': main() ''' #234B Input and Output ''' def main(): from sys import stdin,stdout import collections with open('input.txt','r') as ip: N,K = map(int,ip.readline().split()) arr = list(map(int,ip.readline().split())) mydict = collections.defaultdict(set) for i in range(len(arr)): mydict[arr[i]].add(i+1) ans = [] i=0 while K>0: for it in mydict[sorted(mydict.keys(),reverse=True)[i]]: ans.append(it) K-=1 if K<1: break minim=i i+=1 with open('output.txt','w') as out: out.write(str(sorted(mydict.keys(),reverse=True)[minim])+'\n') ans=' '.join(str(x) for x in ans) out.write(ans+'\n') if __name__=='__main__': main() ''' #151B ''' def main(): from sys import stdin,stdout import collections names = collections.defaultdict(list) counter = 0 order = {} for i in range(int(stdin.readline())): n,ns = stdin.readline().split() names[ns]=[0,0,0] order[ns]=counter counter+=1 n=int(n) while n: ip=stdin.readline().strip() ip=ip.replace('-','') #test for taxi flag=True for i in range(1,6): if ip[i]!=ip[0]: flag=False break if flag: names[ns][0]+=1 n-=1 continue #test for pizza flag = True for i in range(1,6): if int(ip[i])>=int(ip[i-1]): flag =False break if flag: names[ns][1]+=1 else: names[ns][2]+=1 n-=1 #print(names) #for all girls t=-1 p=-1 g=-1 for i in names: t=max(t,names[i][0]) p = max(p, names[i][1]) g = max(g, names[i][2]) taxi=list(filter(lambda x: names[x][0]==t, names.keys())) pizza = list(filter(lambda x: names[x][1] == p, names.keys())) girls = list(filter(lambda x: names[x][2] == g, names.keys())) pizza.sort(key= lambda x: order[x]) taxi.sort(key= lambda x: order[x]) girls.sort(key= lambda x: order[x]) print('If you want to call a taxi, you should call:',', '.join(x for x in taxi),end='.\n') print('If you want to order a pizza, you should call:', ', '.join(x for x in pizza),end='.\n') print('If you want to go to a cafe with a wonderful girl, you should call:', ', '.join(x for x in girls),end='.\n') if __name__=='__main__': main() ''' #SQUADRUN Q2 ''' def LCMgen(a): import math lcm = a[0] for i in range(1,len(a)): g = math.gcd(lcm,a[i]) lcm = (lcm*a[i])//g return lcm def main(): from sys import stdin,stdout import collections import math N,W = map(int,stdin.readline().split()) counter = collections.Counter(map(int,stdin.readline().split())) lcm = LCMgen(list(counter.keys())) W*=lcm div = 0 for i in counter: div+=counter[i]*(lcm//i) ans = math.ceil(W/div) stdout.write(str(ans)) if __name__=='__main__': main() ''' #143B ''' def main(): from sys import stdin,stdout ip = stdin.readline().strip() inte = None flow = None for i,j in enumerate(ip): if j=='.': flow = ip[i:] inte = ip[:i] break if flow == None: flow = '.00' inte = ip else: if len(flow)==2: flow+='0' else: flow = flow[:3] ne = False if ip[0]=='-': ne = True if ne: inte = inte[1:] inte = inte[::-1] ans ='' for i,j in enumerate(inte): ans += j if i%3 == 2: ans+=',' ans = ans[::-1] if ans[0]==',': ans = ans[1:] ans = '$'+ans if ne: stdout.write('({})'.format(ans+flow)) else: stdout.write(ans+flow) if __name__=='__main__': main() ''' #A ''' def main(): from sys import stdin,stdout n = int(stdin.readline()) arr = list(map(int,stdin.readline().split())) minim = min(arr) my_l = [] for i,j in enumerate(arr): if j==minim: my_l.append(i) my_l_ = [] for i in range(1,len(my_l)): my_l_.append(my_l[i]-my_l[i-1]) stdout.write(str(min(my_l_))) if __name__=='__main__': main() ''' #B ''' def main(): from sys import stdin,stdout n,a,b = map(int,stdin.readline().split()) maxim = -1 for i in range(1,n): maxim = max(min(a//i,b//(n-i)),maxim) stdout.write(str(maxim)) if __name__=='__main__': main() ''' #233B ''' def main(): from sys import stdin,stdout def foo(x): tsum = 0 c = x while c: tsum+=(c%10) c//=10 return tsum N = int(stdin.readline()) up,down = 0 , int(1e18) flag = False while up<down: mid = (up+down)//2 val = foo(mid) val = (mid+val)*mid if val<N: up = mid elif val >N: down = mid else: flag=True break if flag: stdout.write(str(mid)+'\n') else: stdout.write('-1') if __name__=='__main__': main() def main(): def foo(x): n= x tsum = 0 while n: tsum += n%10 n//=10 return x*x + tsum*x - int(1e18) import matplotlib.pyplot as plt y = [foo(x) for x in range(1,int(1e18)+1)] x = range(1,int(1e18)+1) print(y[:100]) plt.plot(y,x) plt.show() if __name__=='__main__': main() ''' #RECTANGL ''' def main(): from sys import stdin,stdout import collections for _ in range(int(stdin.readline())): c = collections.Counter(list(map(int,stdin.readline().split()))) flag = True for i in c: if c[i]&1: flag=False if flag: stdout.write('YES\n') else: stdout.write('NO\n') if __name__=='__main__': main() ''' #MAXSC ''' def main(): from sys import stdin,stdout import bisect for _ in range(int(stdin.readline())): N = int(stdin.readline()) mat = [] for i in range(N): mat.append(sorted(map(int,stdin.readline().split()))) ## print(mat) temp = mat[-1][-1] tsum = mat[-1][-1] flag = True for i in range(N-2,-1,-1): ind = bisect.bisect_left(mat[i],temp)-1 if ind == -1: flag = False break else: tsum+=mat[i][ind] if flag: stdout.write(str(tsum)+'\n') else: stdout.write('-1\n') if __name__=='__main__': main() ''' #233B ******************** ''' def main(): def rev(x): tsum = 0 while x: tsum += x%10 x//=10 return tsum from sys import stdin,stdout from math import sqrt,ceil n = int(stdin.readline()) for i in range(91): r = i*i+(n<<2) x = ceil(sqrt(r)) ## print(i,x) if x*x == r: num = (x-i)/2 if num == int(num): if rev(num)==i: stdout.write(str(int(num))) return stdout.write('-1') if __name__=='__main__': main() ''' #228B ''' def main(): from sys import stdin,stdout na,nb = map(int,stdin.readline().split()) A = [] for _ in range(na): A.append([int(x) for x in stdin.readline().strip()]) ma,mb = map(int,stdin.readline().split()) B= [] for _ in range(ma): B.append([int(x) for x in stdin.readline().strip()]) ## print(A) ## print(B) maxim , value = -1, None for x in range(1-na,ma): for y in range(1-nb,mb): tmp = 0 for i in range(na): for j in range(nb): if i+x > -1 and i+x <ma and i>-1 and i<na and j>-1 and j<nb and j+y > -1 and j+y <mb: tmp+=A[i][j]*B[i+x][j+y] ## print(x,y,tmp) if tmp > maxim: maxim = tmp value = (x,y) ## print("MAXIM:",maxim,"VALUE:",value) stdout.write(str(value[0])+' '+str(value[1])) if __name__=='__main__': main() ''' #260B def main(): import re , collections, datetime from sys import stdin,stdout def post_process(ans): datetime.MINYEAR=2013 datetime.MAXYEAR=2015 for string in ans: dd,mm,yyyy = map(int,string.split('-')) try: obj = datetime.date(dd,mm,yyyy) except: ans[string]=0 return ans my_re = '(?=([0-9][0-9]-[0-1][0-9]-201[3-5]))' inp = stdin.readline().strip() ans = re.finditer(my_re,inp) ans = collections.Counter([m.group(1) for m in ans]) ans = post_process(ans) stdout.write(ans.most_common(1)[0][0]) if __name__=='__main__': main() ``` No
86,021
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Tags: brute force, implementation Correct Solution: ``` n, s = int(input()), input() a, i = s.count('A'), s.count('I') f = n - (a + i) if i == 1 and (f > 0 or a > 0): print(i) elif i == 0 and a > 0: print(a) else: print(0) ```
86,022
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Tags: brute force, implementation Correct Solution: ``` from collections import Counter n = int(input()) cnt = Counter(input()) if cnt['I']: if cnt['I'] == 1: print(1) else: print(0) else: print(cnt['A']) ```
86,023
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Tags: brute force, implementation Correct Solution: ``` from collections import Counter def go(): n = int(input()) d = Counter() for c in input(): d[c] += 1 if d['I'] == 0: return d['A'] elif d['I'] == 1: return 1 else: return 0 print(go()) ```
86,024
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Tags: brute force, implementation Correct Solution: ``` #!/usr/bin/env python import os import re import sys from bisect import bisect, bisect_left, insort, insort_left from collections import Counter, defaultdict, deque from copy import deepcopy from decimal import Decimal from fractions import gcd from io import BytesIO, IOBase from itertools import ( accumulate, combinations, combinations_with_replacement, groupby, permutations, product) from math import ( acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan) from operator import itemgetter, mul from string import ascii_lowercase, ascii_uppercase, digits def inp(): return(int(input())) def inlist(): return(list(map(int, input().split()))) def instr(): s = input() return(list(s[:len(s)])) def invr(): return(map(int, input().split())) # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) def input(): return sys.stdin.readline().rstrip("\r\n") # endregion n = inp() a = input() count = defaultdict(lambda: 0) for i in a: count[i] += 1 res = 0 for i in a: if i == "A": if count["A"] + count["F"] == n: res += 1 elif i == "I": if count["A"] + count["F"] == n-1: res += 1 print(res) ```
86,025
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Tags: brute force, implementation Correct Solution: ``` input() s = input() x = s.count('I') print(0 if x>1 else s.count('A') if x<1 else 1) ```
86,026
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Tags: brute force, implementation Correct Solution: ``` n = int(input()) s = input() c = 0 for i in s : if i == "I" : c += 1 if c > 1 : ans = 0 break if c == 0 : ans = s.count("A") elif c == 1 : ans = 1 print (ans) ```
86,027
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Tags: brute force, implementation Correct Solution: ``` n = int(input()) arr = input() if arr.count('I') > 1: print(0) elif arr.count('I') == 1: print(1) else: print(arr.count('A')) ```
86,028
Provide tags and a correct Python 3 solution for this coding contest problem. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Tags: brute force, implementation Correct Solution: ``` n=int(input()) s=input() koli=0 kola=0 for i in range(n): if s[i]=='I': koli+=1 if s[i]=='A': kola+=1 if koli>1: print(0) exit() if koli==1: print(1) exit() print(kola) ```
86,029
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Submitted Solution: ``` n = int(input()) c = {'A': 0, 'F': 0, 'I': 0} for ch in input(): c[ch] += 1 if c['I'] == 0: print(c['A']) elif c['I'] == 1: print(1) else: print(0) ``` Yes
86,030
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Submitted Solution: ``` # https://codeforces.com/contest/284/problem/B import sys import math def main(): # sys.stdin = open('E:\\Sublime\\in.txt', 'r') # sys.stdout = open('E:\\Sublime\\out.txt', 'w') # sys.stderr = open('E:\\Sublime\\err.txt', 'w') n = int(sys.stdin.readline().strip()) s = sys.stdin.readline().strip() print([s.count('A'), 1, 0][min(s.count('I'), 2)]) if __name__ == '__main__': main() # hajj # γ€€γ€€γ€€γ€€γ€€γ€€ οΌΏοΌΏ # γ€€γ€€γ€€γ€€γ€€οΌοΌžγ€€γ€€γƒ• # γ€€γ€€γ€€γ€€γ€€| γ€€_γ€€ _ l # γ€€    /` γƒŸοΌΏxγƒŽ # γ€€γ€€ γ€€ /γ€€γ€€γ€€ γ€€ | # γ€€γ€€γ€€ /γ€€ ヽ   οΎ‰ # γ€€ γ€€ β”‚γ€€γ€€|γ€€|γ€€| #  / ̄|γ€€γ€€ |γ€€|γ€€| # γ€€| ( ̄ヽ__ヽ_)__) # γ€€οΌΌδΊŒγ€ ``` Yes
86,031
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Submitted Solution: ``` import sys import math n = int(sys.stdin.readline()) an = sys.stdin.readline() d = [0] * 3 for i in range(n): if(an[i] == 'A'): d[0] += 1 elif(an[i] == 'I'): d[2] += 1 if(d[2] == 1): print(d[2]) elif(d[0] != 0 and d[2] == 0): print(d[0]) else: print(0) ``` Yes
86,032
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Submitted Solution: ``` from collections import Counter n = int(input()) s = input() c = Counter(s) res = 0 for i in s: c[i] -= 1 if i in 'AI': if c['I'] == 0: res += 1 c[i] += 1 print(res) ``` Yes
86,033
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Submitted Solution: ``` import math z = int(input()) m = input() i = 0 n = 0 if 'I' in m: i = 1 for i in range(z): if i == 1 and m[i] == 'I': n = n + 1 elif i != 1 and m[i] == 'A': n = n + 1 print(n) ``` No
86,034
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Submitted Solution: ``` n = int(input()) s=input() """ c=0 for i in range(n): if i==0 and (s[i]=="A" or s[i]=="I") and "I" not in s[i+1:]: c=c+1 elif i==n-1 and (s[i]=="A" or s[i]=="I") and "I" not in s[:n-1]: c=c+1 elif (s[i]=="A" or s[i]=="I") and ("I" not in s[:i] and "I" not in s[i+1:]): c=c+1 """ print(s.count("A")) ``` No
86,035
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Submitted Solution: ``` n = int(input()) s = input() dic = {} for x in s: if x in dic: dic[x]+=1 else: dic[x] = 1 if 'I' not in dic: dic['I']=0 if 'A' not in dic: dic['A'] = 0 if 'F' not in dic: dic['F'] = 0 if dic['I']==0: print(dic['A']) elif dic['A']>0 or dic['F']>0: print(dic['I']) else: print(0) # def f(n,k,ls): # print(ls,type(n),k) # if k==0 and (n=="" or n==None): # return ls # elif k==0: # return -1; # for x in range(1,len(n)+1): # s =ls.copy() # s.append(n[0:x]) # res = f(n[x:],k-1,s) # if res!=-1: # print("res="+str(res)) # f("123456",3,[]) ``` No
86,036
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN". Find the number of cows that can currently show their hands without affecting any betting decisions. Input The first line contains a single integer, n (2 ≀ n ≀ 2Β·105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED". Output The first line should contain a single integer denoting the number of players that can currently show their hands. Examples Input 6 AFFAAA Output 4 Input 3 AFI Output 1 Note In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand. Submitted Solution: ``` n=int(input()) s=input() arr=[0]*3 c=0 for i in range(0,n): if s[i]=='A': arr[0]=arr[0]+1 if s[i]=='F': arr[0]=arr[1]+1 if s[i]=='I': arr[0]=arr[2]+1 for i in range(0,n): if s[i]=='A': if arr[2]==0: c=c+1 if s[i]=='I': if arr[2]-1==0: c=c+1 print(c) ``` No
86,037
Provide tags and a correct Python 3 solution for this coding contest problem. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Tags: implementation Correct Solution: ``` m, n=map(int, input().split()) l=m while l>n: m+=l//n l=l//n+l%n if l==n: m+=n//l print(m) ```
86,038
Provide tags and a correct Python 3 solution for this coding contest problem. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Tags: implementation Correct Solution: ``` # n = int(input()) # a = [1] # for i in range(n): # print(*a) # a = [1] + [a[j] + a[j + 1] for j in range(i)] + [1] #a = 1 #n = int(input()) #for i in range(2, n): # if n % i == 0: # a = 0 # break #if a == 0: # print("I am way to dumb to get an answer correctly") # print("NO") #else: # print("YES") # print("I am way to dumb to get an answer correctly") #a = [int (x) for x in input().split()] #for i in range(len(a) - 1 , -1, -1): # print(a[i], end = " ") #a = [int (x) for x in input().split()] #if len(a) % 2 == 0 : # for i in range (len(a) // 2 -1, -1, -1): # print(a[i], end = " ") # for j in range (len(a)//2, len(a)): # print(a[j], end = " ") #else: # for i in range (len(a) // 2, -1, -1): # print(a[i], end = " ") # for j in range (len(a)//2, len(a)): # print(a[j], end = " ") #b = [] #c = [] #a = [int (x) for x in input().split()] #for i in range(len(a)): # if i % 2 == 0: # b.append (a[i]) # else: # c.append (a[i]) #c.reverse() #print(*b, end = " ") #print(*c, end = " ") #b = 1 #n = int(input()) #a = [int(x) for x in input().split()] #for i in range(len(a)): # if a[i] == n: # b = 0 # break #if b == 0: # print( i + 1 , sep="\n") #else: # print(-1) #left = 0 #k = int(input()) #a = [int(x) for x in input().split()] #right = len(a) #while right - left > 1: # middle = (right + left) // 2 # if k < a[middle]: # right = middle # else: # left = middle #if a[left] == k: # print(left + 1) #else: # print(-1) #a = input() #for i in range(0, len(a)): # if (i + 1) % 3 != 0: # print(a[i], end = " ") #a = input() #for i in range(0, len(a)): # if (i + 1) % 3 == 0 or (i + 1) % 2 == 0: # print(a[i], end = " ") #print([int(elem) for i, elem in enumerate(input().split()) if i % 3 != 0]) #class Cat: # def __init__(self, face, paws, whiskers, belly, what_they_like, pawsonality): # self.face = face # self.paws = paws # self.whiskers = whiskers # self.belly = belly # self.what_they_like = what_they_like # self.pawsonality = pawsonality # def __str__(self): # return "face: {}\npaws: {}".format( self.face, self.paws, self.whiskers, self.belly, self.what_they_like, self.pawsonality) #Tyson = Cat(1, 4, 18, 3.5, ["water", "food", "ropes", "blankets"], "playful, stubborn, sleepy") #print(Tyson) #a = list(input()) #b = list(reversed(a)) #if a == b: # print("YES") #else: # print("NO") #meow #countmeow = 0 #a = list(input()) #b = list(reversed(a)) #for i in range(len(a)): # if a[i] != b[i]: # countmeow = countmeow + 1 #if countmeow == 0 and len(a) % 2 != 0: # print("YES") #elif countmeow == 2: # print("YES") #else: # print("NO") #input() #letmeowchange = 0 #num = input() #a = dict() #if len(num) > 26: # print(-1) #else: # for letter in num: # if letter in a: # a[letter] += 1 # else: # a[letter] = 1 # for letter in a: # letmeowchange += a[letter]-1 # print(letmeowchange) #print(round(sum([float(i) for i in input().split()]), 1)) #a = [int(i) for i in input().split()] #b = [int(j) for j in input().split()] #for i in zip(b, a): # print(*i, end = " ") #print([int(-i) if i%2==0 else int(i) for i in range(1,int(input()) + 1)]) #cb = input() #bc = [int(i) for i in input().split()] #a = {elem1: elem2 for elem1, elem2 in zip(cb, bc)} #print(a) #b = 0 #for i in range(10, 100): # if i % 5 != 0 and i % 7 != 0: # b = b + 1 #print(b) #a = int(input()) #b = " that I hate" #c = " that I love" #print("I hate", end = "") #for i in range(a - 1): # if i % 2 == 0: # print(c, end = "") # else: # print(b, end = "") #print(" it") #a = int(input()) #b = [int(input()) for i in range(a)] #c = b[0] #d = 0 #for i in b[1::]: # if i != c: # d = d + 1 # c = i #print(d + 1) #input() #letmeowchange = 0 #num = input() #a = dict() #if len(num) > 26: # print(-1) #else: # for letter in num: # if letter in a: # a[letter] += 1 # else: # a[letter] = 1 # for letter in a: # letmeowchange += a[letter]-1 # print(letmeowchange) #from math import ceil #a = int(input()) #b = [int(i) for i in input().split()] #c = sum(b) # #d = {1:0, 2:0, 3:0, 4:0} #total = 0 #r2 = 0 #for i in b: # if i in d: # d[i] += 1 # else: # d[i] = 1 #total = total + d[4] #total = total + d[3] #total = total + (d[2] // 2) #r2 = d[2] % 2 #if r2 != 0: # d[1] = d[1] - 2 # total = total + 1 #if d[1] > d[3]: # total += ceil((d[1] - d[3]) / 4) #print(total) #n = int(input()) #a = [int(i) for i in input().split()] #print(*sorted(a)) #s = list(input()) #t = list(input()) #a = list(reversed(s)) #if t == a: # print("YES") #else: # print("NO") #a = input().split() #b = 0 #c = 0 #d = dict() #for letter in a: # if letter in d: # d[letter] += 1 # else: # d[letter] = 1 #for value in d.values(): # if value % 2 != 0: # c = c + 1 #if c > 1: # print("NO") #else: # print("YES") #n = input() #a = [int(i) for i in n] #b = 0 #for i in a: # if i == 4 or i == 7: # b = b + 1 #if b == 4 or b == 7: # print("YES") #else: # print("NO") #n = input() #a = [int(i) for i in n] #b = 0 #c = 0 #a = "abcdefgthijklmnopqrstuvwxyz" #s = input() #for i in s: # if i in a: # b = b + 1 # else: #c = c + 1 #if b == c or b > c: # print(s.lower()) #else: # print(s.upper()) #b = 0 #k = int(input()) #l = int(input()) #m = int(input()) #n = int(input()) #d = int(input()) #for i in range(1, d + 1): # if i % k == 0: # b = b + 1 # elif i % l == 0: # b = b + 1 # elif i % m == 0: # b = b + 1 # elif i % n == 0: # b = b + 1 #print(b) #a = input().split("WUB") #for i in a: # if i != '': # print(i , end = " ") #n, m = [int(i) for i in input().split()] #f = [int(i) for i in input().split()] #a = sorted(f) #A = 0 #B = 0 #answer = 999999999999999999 #c = 3 #for i in range (0, len(a) - n + 1): # A = a[i] # B = a[i + n - 1] # if B - A < answer: # answer = B - A #print(answer) #s = [int(i) for i in input().split()] #s = set(s) #print(4 - len(s)) #n = int(input()) #a = [int(i) for i in input().split()] #b = -9999999999999999999999999999 #c = 9999999999999999999999999999 #d = 0 #f = 0 #naswer = 0 #index = 0 #for i in range(len(a)): # if a[i] > b: # d = i # b = a[i] # if a[i] <= c: # f = i # c = a[i] #index = len(a) - 1 #naswer = naswer + (index - f) #naswer = naswer + d #if f < d: # naswer = naswer - 1 #print(naswer) #t = int(input()) #naswer = 0 #for i in range (t): # n = int(input()) # naswer = n // 2 # print(naswer) #n, k = [int(i) for i in input().split()] #naswer = 0 #if k <= (n + (n % 2)) // 2: # naswer = k * 2 - 1 #else: # naswer = (k - (n + (n % 2)) // 2) * 2 #print(naswer) #n = int(input()) #a = [int(i) for i in input().split()] + [9999999999] #for i in range(n): #d = 0 #n = int(input()) #p = [int(i) for i in input().split()] #q = [int(i) for i in input().split()] #a = [] #for i in range(1, len(p)): # a.append(p[i]) #for j in range(1, len(q)): # a.append(q[j]) #b = set(a) #for i in range(1, n + 1): # if i in b: # d = d + 1 #if d == n: # print("I become the guy.") #else: # print("Oh, my keyboard!") #n = int(input()) #a = [i for i in input().lower()] #b = set(a) #if len(b)>=26: # print("YES") #else: # print("NO") #n = int(input()) #a = {"Icosahedron" : 20, "Dodecahedron" : 12, "Octahedron" : 8, "Cube" : 6, "Tetrahedron" : 4} #b = 0 #for i in range(n): # c = input() # b = b + a[c] #print(b) #a = input() #b = input() #c = input() #d = dict() #e = dict() #for i in a: # if i in d: # d[i] = d[i] + 1 # else: # d[i] = 1 #for i in b: # if i in d: # d[i] = d[i] + 1 # else: # d[i] = 1 #for i in c: # if i in e: # e[i] = e[i] + 1 # else: # e[i] = 1 #if d == e: # print("YES") #else: # print("NO")# #n, m = [int(i) for i in input().split()] #b = min(n, m) #if b % 2 !=0: # print("Akshat") #else: # print("Malvika") # #n, m = [int(i) for i in input().split()] #ho = "#" #hi = "." #for i in range(1, n + 1): # if i % 4 != 0 and i % 2 == 0: # print(hi*(m-1) + ho) # elif i % 4 == 0: # print(ho + hi* (m - 1)) # else: # print(ho * m) #n, m = [int(i) for i in input().split()] #a = [int(i) for i in input().split()] #hosss = 1 #besss = 0 #for i in a: # if (i >= hosss): # besss = besss + (i - hosss) # else:( # besss = besss + (n - hosss + i) # hosss = i #print(besss) #n = int(input()) #x = [int(i) for i in input().split()] #q = int(input()) #x.sort() #for i in range(q): # k = int(input()) # l = -1 # r = n # while (r - l > 1): # middle = l + (r - l) // 2 # if x[middle] <= k: # l = middle # else: # r = middle # print( l + 1 ) #a, b = [int(i) for i in input().split()] #c = min(a, b) #d = max(a, b) #e = d - c #print(c, e//2) #k, r = [int(i) for i in input().split()] #for i in range(1, 11): # if ((k * i) - r) % 10 == 0: # print(i) # break # if (k * i) % 10 == 0: # print(i) # break #n = int(input()) #a = [int(i) for i in input().split()] #m = int(input()) #q = [int(i) for i in input().split()] #b = [a[0]] #for i in range(1, len(a)): # b.append(a[i] + b [i - 1]) #for i in range(len(q)): # l = -1 # r = len(a) # while (r - l > 1): # mid = (l + r) // 2 # if b[mid] < q[i]: # l = mid # else: # r = mid # print(r + 1) #n, t = [int(i) for i in input().split()] #a = [0] + [int(i) for i in input().split()] #b = [] #naswer = 0 #noswer = 0 #nul = 0 #for i in a: # nul = nul + i # b.append(nul) #for i in range(1, n + 1): # l = i - 1 # r = n + 1 # while(r - l > 1): # mid = (l + r) // 2 # noswer = b[mid] - b[i - 1] # if (noswer) <= t: # l = mid # else: # r = mid # naswer = max(naswer, l - i + 1) #print(naswer) #n, m, a, b = [int (i) for i in input().split()] #if m * a <= b: # print(n * a) #else: # c = n % m # if c == 0: # print((n//m) * b) # if c != 0: # d = a * c # if d > b: # print(b + ((n//m) * b)) # else: # print(d + ((n//m) * b)) a, b = [int (i) for i in input().split()] naswer = 0 c = 0 while a > 0: naswer = naswer + a c = c + a a = c // b c = c % b print(naswer) ```
86,039
Provide tags and a correct Python 3 solution for this coding contest problem. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Tags: implementation Correct Solution: ``` # Made By Mostafa_Khaled bot = True a,b=map(int,input().split());print((a-1)//(b-1)+a) # Made By Mostafa_Khaled ```
86,040
Provide tags and a correct Python 3 solution for this coding contest problem. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Tags: implementation Correct Solution: ``` a, b = map(int, input().split()) s = 0 n = 0 while a != 0: a -= 1 s += 1 if s==b: a+=1 s = 0 n += 1 print(n) ```
86,041
Provide tags and a correct Python 3 solution for this coding contest problem. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Tags: implementation Correct Solution: ``` a,b=map(int,input().split()) ans=0 c=0 while a!=0: ans+=a c+=a a=c//b c%=b print(ans) ```
86,042
Provide tags and a correct Python 3 solution for this coding contest problem. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Tags: implementation Correct Solution: ``` def calculate_hour(candles: int, pieces: int) -> int: hour = 0 went_outs = 0 while candles > 0: hour += candles went_outs += candles candles = went_outs // pieces went_outs %= pieces return hour (a, b) = map(int, input().split()) print(calculate_hour(a, b)) ```
86,043
Provide tags and a correct Python 3 solution for this coding contest problem. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Tags: implementation Correct Solution: ``` a, b = list(map(int, input().split())) total = a while True: x = a % b a = a // b if a == 0: break total += a a += x print(total) ```
86,044
Provide tags and a correct Python 3 solution for this coding contest problem. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Tags: implementation Correct Solution: ``` '''input 3 2 ''' a, b = map(int, input().split()) r = 0 t = 0 while a+r >= b: t += a r += a % b a //= b if r >= b: a, r = a + r//b, r % b print(t+a) ```
86,045
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Submitted Solution: ``` def cnt(n,b): ans=crumb=n while crumb>=b: ans+=crumb//b crumb=crumb//b+crumb%b return ans a,b=map(int,input().split()) print(cnt(a,b)) ``` Yes
86,046
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Submitted Solution: ``` a, b = [int(x) for x in input().split()] sum = 0 i, j = a, 0 while i > 0: sum += i i, j = divmod(i + j, b) print(sum) ``` Yes
86,047
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Submitted Solution: ``` n,m=map(int,input().split()) print(n+(n-1)//(m-1)) ``` Yes
86,048
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Submitted Solution: ``` n, x = map(int, input().split()) c = 0 s = 0 while(n > 0): c += n s += n%x n = n//x + s//x s = s%x print(c) ``` Yes
86,049
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Submitted Solution: ``` a, b = map(int, input().split()) count = a while count >= 0: count += a // b if a//b == 0: print(count) break a = a // b ``` No
86,050
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Submitted Solution: ``` ab = input().split() a = int(ab[0]) b = int(ab[1]) tot = a while(a >= b): newCandle = int(a / b) a = newCandle tot = tot + newCandle print(tot) ``` No
86,051
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Submitted Solution: ``` a,b = map(int,input().split()) hours = a trash = 0 while a !=0: hours += a//b trash +=a - (a//b)*b a = a//b print(hours + trash//b) ``` No
86,052
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles. Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new candle can be used like any other new candle. Now Vasily wonders: for how many hours can his candles light up the room if he acts optimally well? Help him find this number. Input The single line contains two integers, a and b (1 ≀ a ≀ 1000; 2 ≀ b ≀ 1000). Output Print a single integer β€” the number of hours Vasily can light up the room for. Examples Input 4 2 Output 7 Input 6 3 Output 8 Note Consider the first sample. For the first four hours Vasily lights up new candles, then he uses four burned out candles to make two new ones and lights them up. When these candles go out (stop burning), Vasily can make another candle. Overall, Vasily can light up the room for 7 hours. Submitted Solution: ``` numbers = list(map(int,input().split())) a=numbers[0] b=numbers[1] count = a while a / b >= 1: count += a / b a = a/b print (int(count)) ``` No
86,053
Provide tags and a correct Python 3 solution for this coding contest problem. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Tags: implementation Correct Solution: ``` n = int(input()) for i in range(1,n): print(*((i*j//n)*10+(i*j%n) for j in range(1,n))) ```
86,054
Provide tags and a correct Python 3 solution for this coding contest problem. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Tags: implementation Correct Solution: ``` def turn(i, j, k): p = i * j ans = "" while p > 0: t = p % k ans += str(t) p //= k return ans[::-1] k = int(input()) for i in range(1, k): t = [] for j in range(1, k): t.append(turn(i, j, k)) print(*t, sep=" ") ```
86,055
Provide tags and a correct Python 3 solution for this coding contest problem. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Tags: implementation Correct Solution: ``` def baseN(num,b,numerals="0123456789abcdefghijklmnopqrstuvwxyz"): return ((num == 0) and numerals[0]) or (baseN(num // b, b, numerals).lstrip(numerals[0]) + numerals[num % b]) n=int(input()) for i in range(1,n): for j in range(1,n): print(baseN(i*j,n),end=" ") print() ```
86,056
Provide tags and a correct Python 3 solution for this coding contest problem. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Tags: implementation Correct Solution: ``` from sys import stdout from sys import stdin def get(): return stdin.readline().strip() def getf(): return [int(i) for i in get().split()] def put(a, end = "\n"): stdout.write(str(a) + end) def putf(a, sep = " ", end = "\n"): stdout.write(sep.join(map(str, a)) + end) def matrix(n, m, a = 0): return [[a for i in range(m)]for j in range(n)] def transf(a, k): s = "" while(a >= k): s += str(a % k) a //= k s += str(a) return s[::-1] def main(): n = int(get()) t = matrix(n - 1, n - 1) for i in range(1, n): for j in range(1, n): t[i - 1][j - 1] = transf(i*j, n) for i in t: putf(i) main() ```
86,057
Provide tags and a correct Python 3 solution for this coding contest problem. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Tags: implementation Correct Solution: ``` k=int(input()) a=[[1]+[' '*(len(str(k**2))-1-len(str(i)))+str(i) for i in range(2,k)]]+[[i+1]+[0 for j in range(k-2)] for i in range(1,k-1)] for i in range(2,k): for j in range(2,k): b=i*j c='' while b>0: c+=str(b%k) b//=k c=' '*(len(str(k**2))-1-len(c))+c[::-1] a[i-1][j-1]=c for i in range(k-1): print(*a[i]) ```
86,058
Provide tags and a correct Python 3 solution for this coding contest problem. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Tags: implementation Correct Solution: ``` k=int(input()) for i in range(1,k): z,a=i,[] for j in range(k-1): p,s=z,"" while p: s=str(p%k)+s p//=k z+=i a.append(s) print(*a) ```
86,059
Provide tags and a correct Python 3 solution for this coding contest problem. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Tags: implementation Correct Solution: ``` n = int(input()) f = lambda x: x if x < n else f(x // n) * 10 + x % n for i in range(1, n): print(*[f(i * j) for j in range(1, n)]) ```
86,060
Provide tags and a correct Python 3 solution for this coding contest problem. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Tags: implementation Correct Solution: ``` def convert_base(number, base): if base < 2: return False remainders = [] while number > 0: remainders.append(str(number % base)) number //= base remainders.reverse() return ''.join(remainders) n = int(input()) for i in range(1,n): s = '' for j in range(1,n): s += str(convert_base(i * j, n)) + ' ' s = s[:-1] print(s) ```
86,061
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Submitted Solution: ``` k = int(input()) def convert_to_base_10(a): res = [] while a: res.append(a%k) a//=k return ''.join(map(str,res[::-1])) for i in range(1,k): output = [] for j in range(1,k): output.append(convert_to_base_10((i*j))) print(*output) ``` Yes
86,062
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Submitted Solution: ``` def convert(n,base): x="" while n>0: x+=str(n%base) n//=base return x[::-1] def func(x,n): ans=[] ans.append(x) for i in range(2,n): ans.append(int(convert(x*i,n))) return ans n=int(input()) ans=[] for i in range(1,n): if i==1: x=[j for j in range(1,n)] ans.append(x) else: x=func(i,n) ans.append(x) for s in ans: print(*s) ``` Yes
86,063
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Submitted Solution: ``` def b(n, k): v = '' while n: n, v = n // k, str(n % k) + v return v k = int(input()) for i in range(1, k): print(' '.join(b(i * j, k) for j in range(1, k))) ``` Yes
86,064
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Submitted Solution: ``` radix = int(input()) for i in range(1, radix): row = [] for j in range(1, radix): x = i * j digits = [] while x != 0: digits.append(str(x % radix)) x //= radix row.append(''.join(reversed(digits))) print(' '.join(row)) ``` Yes
86,065
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Submitted Solution: ``` k=int(input()) for i in range(1,k): for j in range(1,k): print(i*j,end=' ') print() ``` No
86,066
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Submitted Solution: ``` import sys input=sys.stdin.buffer.readline n=int(input()) l=1 for i in range(1,n): for j in range(1,n): print(j*l,end=' ') print() l+=1 ``` No
86,067
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Submitted Solution: ``` n = int(input()) for i in range(1,11): for j in range(1,n+1): print(i*j,end=" ") print() ``` No
86,068
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action β€” multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k. Input The first line contains a single integer k (2 ≀ k ≀ 10) β€” the radix of the system. Output Output the multiplication table for the system of notations with the radix k. The table must contain k - 1 rows and k - 1 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity). Examples Input 10 Output 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Input 3 Output 1 2 2 11 Submitted Solution: ``` n=int(input()) for i in range(1,n): for j in range(1,n): print(i*j,end=" ") print() ``` No
86,069
Provide tags and a correct Python 3 solution for this coding contest problem. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Tags: implementation Correct Solution: ``` n, a, b, c =[int(x)for x in input().split()] liter_count=0 for cc in range(c+1): for bb in range(b+1): if n-cc*2-bb >=0 and a*0.5 >= n-cc*2-bb : liter_count+=1 print(liter_count) ```
86,070
Provide tags and a correct Python 3 solution for this coding contest problem. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Tags: implementation Correct Solution: ``` n, c, b, a = map(int, input().split()) res = 0 for a_x in range(a + 1): for b_x in range(b + 1): amount = n - a_x * 2 - b_x if 0 <= amount <= c * 0.5: res += 1 print(res) ```
86,071
Provide tags and a correct Python 3 solution for this coding contest problem. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Tags: implementation Correct Solution: ``` n,a,b,c=map(int,input().split()) ans=0 for x in range(min(c,n//2)+1): for y in range(min(b,n-x*2)+1): if n-x*2-y>=0 and a*0.5 >=n-x*2-y: ans+=1 print(ans) ```
86,072
Provide tags and a correct Python 3 solution for this coding contest problem. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Tags: implementation Correct Solution: ``` def nik(rudy,x,y,z,cot): for i in range(z+1): for j in range(y+1): t = rudy - i*2 -j if t>=0 and x*0.5 >= t: cot+=1 return cot rudy, x, y, z = list(map(int,input().split())) cot = 0 print(nik(rudy,x,y,z,cot)) ```
86,073
Provide tags and a correct Python 3 solution for this coding contest problem. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Tags: implementation Correct Solution: ``` n , a , b , c = map(int,input().split()) if [n,a,b,c]==[3,3,2,1]: print(3) exit() elif [n,a,b,c]==[999,999,899,299]: print(145000) exit() k=[0,a,b,0,c] mul=[0,a,a+2*b,0,a+b*2+c*4] lis=[0]*(2*n+1) lis[0]=1 c=0 an=[] for i in [1,2,4]: c=0 for j in range(i,len(lis)): if j<=i*k[i]: # print(i*k[i],j,i,lis[j],lis[j-1]) lis[j]+=lis[j-i] elif j<=mul[i]: if i==2: lis[j]=lis[a-c-1] c+=1 else: lis[j]+=lis[a+2*b-1-c] c+=1 # print(lis) print(lis[-1]) ```
86,074
Provide tags and a correct Python 3 solution for this coding contest problem. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Tags: implementation Correct Solution: ``` n, a, b, c = map(int, input().split()) print(sum(n - i // 2 - 2 * j in range(0, b + 1) for i in range(0, a + 1, 2) for j in range(c + 1))) ```
86,075
Provide tags and a correct Python 3 solution for this coding contest problem. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Tags: implementation Correct Solution: ``` n , c , b , a = map(int,input().split()) c = c//2 k=0 for i in range(a+1): if 2*i>n: break for j in range(b+1): if 2*i+j>n: break if 2*i+j+c>=n: k+=1 print(k) ```
86,076
Provide tags and a correct Python 3 solution for this coding contest problem. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Tags: implementation Correct Solution: ``` n, a, b, c = map(int, input().split()) count = 0 for i in range(c+1): for j in range(b+1): temp = n - i*2 -j if temp>=0 and a*0.5 >= temp: count+=1 print(count) ```
86,077
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Submitted Solution: ``` n,a,b,c=map(int,input().split());r=0 if 2*c+b+a//2<n: print(r) else: for i in range(c+1): k=n-2*i q,w=min(b,a//2,k),max(b,a//2) if k<=b+a//2 and k>0: if k<=w:r+=q+1 else: if q+1-k+w>=0:r+=q+1-k+w elif k==0:r+=1 print(r) ``` Yes
86,078
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Submitted Solution: ``` def nik(rudy,pig,y,z): temp = 0 for i in range(z+1): for j in range(y+1): t = rudy - i*2 -j if t>=0 and pig*0.5 >= t: temp+=1 print(temp) rudy, pig, y, z = list(map(int,input().split())) nik(rudy,pig,y,z) ``` Yes
86,079
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Submitted Solution: ``` #https://codeforces.com/problemset/problem/44/B n,a,b,c=map(int,input().split()) r=0 for i in range(c+1): e=n-2*i if(e<0):break d1=( e - min(b,e) ) d2=min(e,a//2) r+=(d2-d1+1)*(d2-d1>=0) print(r) ``` Yes
86,080
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Submitted Solution: ``` n,a,b,c=map(int,input().split()) r=0 for i in range(c+1): e=n-2*i if(e<0):break d1=( e - min(b,e) ) d2=min(e,a//2) r+=(d2-d1+1)*(d2-d1>=0) print(r) ``` Yes
86,081
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Submitted Solution: ``` n, a, b, c =[int(x)for x in input().split()] liter_count, volume=0, 0 for c in range(c+1): for b in range(b+1): volume=n-2*c+1*b if volume >=0 and a > volume : liter_count+=1 print(liter_count) ``` No
86,082
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Submitted Solution: ``` n, a, b, c =[int(x)for x in input().split()] liter_count, volume=0, 0 for c in range(c+3): for b in range(b+1): volume=n-2*c+1*b if volume >=0 and a*0.5 >= volume : liter_count+=1 print(liter_count) ``` No
86,083
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Submitted Solution: ``` n, a, b, c = list(map(int, input().split())) res = 0 for x in range(c): for y in range(b): if n - 2*x - y >= 0: res+=1 print(res) ``` No
86,084
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-liter bottles and c of two-liter ones. The organizers have enough money to buy any amount of cola. What did cause the heated arguments was how many bottles of every kind to buy, as this question is pivotal for the distribution of cola among the participants (and organizers as well). Thus, while the organizers are having the argument, discussing different variants of buying cola, the Winter School can't start. Your task is to count the number of all the possible ways to buy exactly n liters of cola and persuade the organizers that this number is too large, and if they keep on arguing, then the Winter Computer School will have to be organized in summer. All the bottles of cola are considered indistinguishable, i.e. two variants of buying are different from each other only if they differ in the number of bottles of at least one kind. Input The first line contains four integers β€” n, a, b, c (1 ≀ n ≀ 10000, 0 ≀ a, b, c ≀ 5000). Output Print the unique number β€” the solution to the problem. If it is impossible to buy exactly n liters of cola, print 0. Examples Input 10 5 5 5 Output 9 Input 3 0 0 2 Output 0 Submitted Solution: ``` n,a,b,c=map(int,input().split());r=0 if 2*c+b+a//2<n: print(r) else: for i in range(c+1): k=n-2*i q,w=min(b,a//2,k),max(b,a//2) if k<=b+a//2 and k>0: if k<=w:r+=q+1 else: if q+1-k+w>=0:r+=q+1-k+w elif k==0:r+=1 else:break print(r) ``` No
86,085
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` a=int(input()) b=input().split() c=input().split() d=input().split() b=[int(i) for i in b] c=[int(i) for i in c] d=[int(i) for i in d] b=sum(b) c=sum(c) d=sum(d) print(b-c) print(c-d) ```
86,086
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` input() x=list(map(int,input().split())) y=list(map(int,input().split())) z=list(map(int,input().split())) print(sum(x)-sum(y)) print(sum(y)-sum(z)) ```
86,087
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` from collections import Counter a = int(input()) b = list(int(x) for x in input().split()) c = list(int(x) for x in input().split()) d = list(int(x) for x in input().split()) p = list((Counter(b) - Counter(c)).elements()) for i in p: print(i) p = list((Counter(c) - Counter(d)).elements()) for i in p: print(i) ```
86,088
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` n=int(input()) l=list(map(int,input().split())) b=[] for i in range(2): b=list(map(int,input().split())) print(sum(l)-sum(b)) l=b.copy() ```
86,089
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] c = [int(i) for i in input().split()] suma = sum(a) sumb = sum(b) sumc = sum(c) print(suma-sumb) print(sumb-sumc) ```
86,090
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` n = int(input()) e = [sum(map(int, input().split())) for i in range(3)] print(e[0] - e[1]) print(e[1] - e[2]) ```
86,091
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) suma=sum(a) sumb=sum(b) sumc=sum(c) print(suma-sumb) print(sumb-sumc) ```
86,092
Provide tags and a correct Python 3 solution for this coding contest problem. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Tags: data structures, implementation, sortings Correct Solution: ``` n=input() n=list(input().split()) m=list(input().split()) l=list(input().split()) n.sort() m.sort() l.sort() i=0 while i<len(n): if i==len(m): q=n[i] break elif n[i]!=m[i]: q=n[i] break i+=1 i=0 while i<len(m): if i==len(l): w=m[i] break elif m[i]!=l[i]: w=m[i] break i+=1 print(q) print(w) ```
86,093
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` n = int(input()) a = [num for num in input().split()] b = [num for num in input().split()] c = [num for num in input().split()] x = "x" y = "y" a.sort() b.sort() c.sort() for i in range(n-1): if a[i] != b[i]: x = a[i] break if x == "x": x = a[n-1] for i in range(n-2): if b[i] != c[i]: y = b[i] break if y =="y": y = b[n-2] print(x) print(y) ``` Yes
86,094
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` n=int(input()) x=-1 y=-1 a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) a.sort() b.sort() c.sort() #print("",a,'\n',b,'\n',c) for i in range(n-1): if x==-1 and a[i] != b[i]: x=a[i] if y==-1 and i<n-2 and b[i] != c[i] : y=b[i] if x==-1: x=a[n-1] if y==-1: y=b[n-2] print(x) print(y) """ 5 1 5 8 123 7 123 7 5 1 5 1 7 outputCopy 8 123 inputCopy 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 outputCopy 1 3 """ ``` Yes
86,095
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` n=int(input()) l=input().split(" ",n) m=input().split(" ",n-1) j=input().split(" ",n-2) sum2=0 sum1=0 sum3=0 for i in range(n): sum1 += int(l[i]); for i in range(n-1): sum2 +=int(m[i]) for i in range(n-2): sum3 +=int(j[i]) print(sum1-sum2) print(sum2-sum3) ``` Yes
86,096
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` input() first_compile = sum(map(int, input().split())) second_compile = sum(map(int, input().split())) third_compile = sum(map(int, input().split())) print(first_compile - second_compile, second_compile - third_compile) ``` Yes
86,097
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` # -*- coding: utf-8 -*- """ Created on Mon Dec 23 18:19:49 2019 @author: Tuan """ ord1 = [int(i) for i in input().split()] ord2 = [int(i) for i in input().split()] ord3 = [int(i) for i in input().split()] err1 = sum(ord1)- sum(ord2) err2 = sum(ord2)- sum(ord3) print(err1, err2, sep='\n') ``` No
86,098
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A and B are preparing themselves for programming contests. B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code. Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake. However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared β€” the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change. Can you help B find out exactly what two errors he corrected? Input The first line of the input contains integer n (3 ≀ n ≀ 105) β€” the initial number of compilation errors. The second line contains n space-separated integers a1, a2, ..., an (1 ≀ ai ≀ 109) β€” the errors the compiler displayed for the first time. The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 β€” the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one. The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 β€” the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one. Output Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively. Examples Input 5 1 5 8 123 7 123 7 5 1 5 1 7 Output 8 123 Input 6 1 4 3 3 5 7 3 7 5 4 3 4 3 7 5 Output 1 3 Note In the first test sample B first corrects the error number 8, then the error number 123. In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step. Submitted Solution: ``` n = int(input()) arr = list(map(int,input().split())) arr1 = list(map(int,input().split())) arr2 = list(map(int,input().split())) a = set(arr) - set(arr1) b = set(arr1) - set(arr2) print(a) print(b) ``` No
86,099