text
stringlengths
216
39.6k
conversation_id
int64
219
108k
embedding
list
cluster
int64
11
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You will be given a contest schedule for D days. For each d=1,2,\ldots,D, calculate the satisfaction at the end of day d. Input Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D * The constraints and generation methods for the input part are the same as those for Problem A. * For each d, t_d is an integer satisfying 1\leq t_d \leq 26, and your program is expected to work correctly for any value that meets the constraints. Output Let v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format: v_1 v_2 \vdots v_D Output Let v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format: v_1 v_2 \vdots v_D Example Input 5 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192 1 17 13 14 13 Output 18398 35037 51140 65837 79325 Submitted Solution: ``` def read_input(): D = int(input()) C = input().split() C = [int(i) for i in C] S = [list(map(int, input().split())) for _ in range(D)] T = [int(input()) for _ in range(D)] return D, C, S, T def scoring(S, D, T, C): res = [] last = [0 for _ in range(26)] final = 0 for i in range(D): dec = 0 last[T[i] - 1] = i for j in range(26): dec += C[j] * (i - last[j] + 1) final += S[i][T[i] - 1] - dec res.append(final) return res D, C, S, T = read_input() res = scoring(S, D, T, C) for x in res: print(x) ``` No
54,559
[ 0.271728515625, 0.1353759765625, -0.0440673828125, 0.11602783203125, -0.8388671875, -0.42822265625, -0.416748046875, 0.299072265625, -0.0164794921875, 0.63720703125, 0.2271728515625, -0.096923828125, 0.2042236328125, -0.7900390625, -0.257568359375, -0.279296875, -0.468994140625, -0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You will be given a contest schedule for D days. For each d=1,2,\ldots,D, calculate the satisfaction at the end of day d. Input Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A. D c_1 c_2 \cdots c_{26} s_{1,1} s_{1,2} \cdots s_{1,26} \vdots s_{D,1} s_{D,2} \cdots s_{D,26} t_1 t_2 \vdots t_D * The constraints and generation methods for the input part are the same as those for Problem A. * For each d, t_d is an integer satisfying 1\leq t_d \leq 26, and your program is expected to work correctly for any value that meets the constraints. Output Let v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format: v_1 v_2 \vdots v_D Output Let v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format: v_1 v_2 \vdots v_D Example Input 5 86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82 19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424 6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570 6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256 8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452 19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192 1 17 13 14 13 Output 18398 35037 51140 65837 79325 Submitted Solution: ``` import numpy as np D = int(input()) C = list(map(int, input().split())) S = [0] * D for i in range(D): S[i] = list(map(int, input().split())) T = [int(input()) for i in range(D)] #print(T) manzoku = [S[i][T[i]-1] for i in range(D)] #print(manzoku) teika = [C[T[i]] for i in range(D)] teika_s = [sum(teika[:i]) for i in range(D)] manzoku_np = np.array(manzoku) teika_np = np.array(teika_s) total = manzoku_np - teika_np #print(total) for num in total: print(num) ``` No
54,560
[ 0.271728515625, 0.1353759765625, -0.0440673828125, 0.11602783203125, -0.8388671875, -0.42822265625, -0.416748046875, 0.299072265625, -0.0164794921875, 0.63720703125, 0.2271728515625, -0.096923828125, 0.2042236328125, -0.7900390625, -0.257568359375, -0.279296875, -0.468994140625, -0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are participating in a quiz with N + M questions and Yes/No answers. It's known in advance that there are N questions with answer Yes and M questions with answer No, but the questions are given to you in random order. You have no idea about correct answers to any of the questions. You answer questions one by one, and for each question you answer, you get to know the correct answer immediately after answering. Suppose you follow a strategy maximizing the expected number of correct answers you give. Let this expected number be P/Q, an irreducible fraction. Let M = 998244353. It can be proven that a unique integer R between 0 and M - 1 exists such that P = Q \times R modulo M, and it is equal to P \times Q^{-1} modulo M, where Q^{-1} is the modular inverse of Q. Find R. Constraints * 1 \leq N, M \leq 500,000 * Both N and M are integers. Input Input is given from Standard Input in the following format: N M Output Let P/Q be the expected number of correct answers you give if you follow an optimal strategy, represented as an irreducible fraction. Print P \times Q^{-1} modulo 998244353. Examples Input 1 1 Output 499122178 Input 2 2 Output 831870297 Input 3 4 Output 770074220 Input 10 10 Output 208827570 Input 42 23 Output 362936761 Submitted Solution: ``` import sys from fractions import Fraction import json sys.setrecursionlimit(500000) memo = {} mod = 998244353 def e(m, n): if m < n: m, n = n, m if (m,n) in memo: return memo[(m,n)] if m == 0: return n if n == 0: return m if m == n: memo[(m,n)] = e(m-1, n)+Fraction(1,2) else: memo[(m,n)] = (e(m-1, n)+1)*Fraction(m,m+n)+e(m, n-1)*Fraction(n, m+n) return memo[(m,n)] def main(): n, m = list(map(int, input().split())) res = e(n, m) p = res.numerator q = res.denominator print((p*pow(q, mod-2, mod))%mod) if __name__ == '__main__': main() ``` No
54,650
[ 0.3955078125, -0.2095947265625, -0.38671875, -0.01259613037109375, -0.262451171875, -0.2236328125, 0.046905517578125, 0.2366943359375, -0.0977783203125, 1.341796875, 0.62646484375, -0.05328369140625, 0.11932373046875, -0.417236328125, -0.297119140625, 0.3955078125, -0.54638671875, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are participating in a quiz with N + M questions and Yes/No answers. It's known in advance that there are N questions with answer Yes and M questions with answer No, but the questions are given to you in random order. You have no idea about correct answers to any of the questions. You answer questions one by one, and for each question you answer, you get to know the correct answer immediately after answering. Suppose you follow a strategy maximizing the expected number of correct answers you give. Let this expected number be P/Q, an irreducible fraction. Let M = 998244353. It can be proven that a unique integer R between 0 and M - 1 exists such that P = Q \times R modulo M, and it is equal to P \times Q^{-1} modulo M, where Q^{-1} is the modular inverse of Q. Find R. Constraints * 1 \leq N, M \leq 500,000 * Both N and M are integers. Input Input is given from Standard Input in the following format: N M Output Let P/Q be the expected number of correct answers you give if you follow an optimal strategy, represented as an irreducible fraction. Print P \times Q^{-1} modulo 998244353. Examples Input 1 1 Output 499122178 Input 2 2 Output 831870297 Input 3 4 Output 770074220 Input 10 10 Output 208827570 Input 42 23 Output 362936761 Submitted Solution: ``` from fractions import * def E(n,m): if not m:return Fraction(n,1) if(n<m):return E(m,n) return Fraction(n*E(n-1,m)+m*E(n,m-1)+max(n,m),n+m) def sqr_mod(a,m):return a*a%m def pow_mod(a,n,m): if not n:return 1 if n%2:return sqr_mod(pow_mod(a,n>>1,m),m)*a%m return sqr_mod(pow_mod(a,n>>1,m),m) n,m=map(int,input().split()) x,mod=E(n,m),998244353 print(x.numerator*pow_mod(x.denominator,mod-2,mod)%mod) ``` No
54,651
[ 0.35693359375, -0.2325439453125, -0.43505859375, 0.014801025390625, -0.288818359375, -0.1668701171875, -0.0333251953125, 0.22998046875, -0.1392822265625, 1.3095703125, 0.6728515625, -0.024322509765625, 0.07342529296875, -0.44970703125, -0.19775390625, 0.436767578125, -0.5078125, -0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are participating in a quiz with N + M questions and Yes/No answers. It's known in advance that there are N questions with answer Yes and M questions with answer No, but the questions are given to you in random order. You have no idea about correct answers to any of the questions. You answer questions one by one, and for each question you answer, you get to know the correct answer immediately after answering. Suppose you follow a strategy maximizing the expected number of correct answers you give. Let this expected number be P/Q, an irreducible fraction. Let M = 998244353. It can be proven that a unique integer R between 0 and M - 1 exists such that P = Q \times R modulo M, and it is equal to P \times Q^{-1} modulo M, where Q^{-1} is the modular inverse of Q. Find R. Constraints * 1 \leq N, M \leq 500,000 * Both N and M are integers. Input Input is given from Standard Input in the following format: N M Output Let P/Q be the expected number of correct answers you give if you follow an optimal strategy, represented as an irreducible fraction. Print P \times Q^{-1} modulo 998244353. Examples Input 1 1 Output 499122178 Input 2 2 Output 831870297 Input 3 4 Output 770074220 Input 10 10 Output 208827570 Input 42 23 Output 362936761 Submitted Solution: ``` import math import sys from functools import lru_cache sys.setrecursionlimit(1000000) @lru_cache(maxsize=1000) def ans(a,b,p,q,wa): if p<q: p,q=q,p if q==0: return a*(wa+p)*pow(b,-1,mod)%mod else: return (ans(a*p%mod,b*(p+q)%mod,p-1,q,wa+1)+ans(a*q%mod,b*(p+q)%mod,p,q-1,wa))%mod mod=998244353 N,M=map(int,input().split()) print(ans(1,1,N,M,0)) ``` No
54,652
[ 0.348876953125, -0.31103515625, -0.386474609375, 0.0093994140625, -0.32421875, -0.175048828125, 0.0180511474609375, 0.2161865234375, -0.1397705078125, 1.2421875, 0.6142578125, 0.0072174072265625, 0.10552978515625, -0.395263671875, -0.268310546875, 0.386962890625, -0.51708984375, -0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are participating in a quiz with N + M questions and Yes/No answers. It's known in advance that there are N questions with answer Yes and M questions with answer No, but the questions are given to you in random order. You have no idea about correct answers to any of the questions. You answer questions one by one, and for each question you answer, you get to know the correct answer immediately after answering. Suppose you follow a strategy maximizing the expected number of correct answers you give. Let this expected number be P/Q, an irreducible fraction. Let M = 998244353. It can be proven that a unique integer R between 0 and M - 1 exists such that P = Q \times R modulo M, and it is equal to P \times Q^{-1} modulo M, where Q^{-1} is the modular inverse of Q. Find R. Constraints * 1 \leq N, M \leq 500,000 * Both N and M are integers. Input Input is given from Standard Input in the following format: N M Output Let P/Q be the expected number of correct answers you give if you follow an optimal strategy, represented as an irreducible fraction. Print P \times Q^{-1} modulo 998244353. Examples Input 1 1 Output 499122178 Input 2 2 Output 831870297 Input 3 4 Output 770074220 Input 10 10 Output 208827570 Input 42 23 Output 362936761 Submitted Solution: ``` import math import sys from functools import lru_cache mod=998244353 sys.setrecursionlimit(1000000) @lru_cache(maxsize=1000000) def ans(p,q,wa): if p<q: p,q=q,p if q==0: return wa+p else: return (ans(p-1,q,wa+1)+ans(p,q-1,wa))%mod def cmb(n, r, mod): if ( r<0 or r>n ): return 0 r = min(r, n-r) return g1[n] * g2[r] * g2[n-r] % mod N,M=map(int,input().split()) p = N+M g1 = [1, 1] # 元テーブル g2 = [1, 1] #逆元テーブル inverse = [0, 1] #逆元テーブル計算用テーブル for i in range( 2, p + 1 ): g1.append( ( g1[-1] * i ) % mod ) inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod ) g2.append( (g2[-1] * inverse[-1]) % mod ) a=cmb(N+M,M,mod) print(ans(N,M,0)*pow(a,-1,mod)%mod) ``` No
54,653
[ 0.358154296875, -0.34228515625, -0.40380859375, 0.0241851806640625, -0.2998046875, -0.160888671875, 0.0216217041015625, 0.22119140625, -0.11895751953125, 1.2080078125, 0.60595703125, 0.0171051025390625, 0.0584716796875, -0.39794921875, -0.288330078125, 0.327392578125, -0.5693359375, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Using the given four integers from 1 to 9, we create an expression that gives an answer of 10. When you enter four integers a, b, c, d, write a program that outputs an expression that gives an answer of 10 according to the following conditions. Also, if there are multiple answers, only the first answer found will be output. If there is no answer, output 0. * Use only addition (+), subtraction (-), and multiplication (*) as operators. Do not use division (/). You can use three operators. * You must use all four numbers. * You can freely change the order of the four numbers. * You can use parentheses. You can use up to 3 sets (6) of parentheses. Input Given multiple datasets. The format of each dataset is as follows: a b c d Input ends with four 0s. The number of datasets does not exceed 40. Output For each dataset, combine the given four integers with the above arithmetic symbols and parentheses to output an expression or 0 with a value of 10 on one line. The expression string must not exceed 1024 characters. Example Input 8 7 9 9 4 4 4 4 5 5 7 5 0 0 0 0 Output ((9 * (9 - 7)) - 8) 0 ((7 * 5) - (5 * 5)) Submitted Solution: ``` import itertools def calc(n): for op in itertools.product(operators, repeat=3): for form in forms: formula = form.format(op[0], op[1], op[2], n[0], n[1], n[2], n[3]) if eval(formula) == 10: print(formula) return True return False operators = ("+", "-", "*") forms = ( "(({3}{0}{4}){1}{5}){2}{6}", "({3}{0}{4}){1}({5}{2}{6})", "({3}{0}({4}{1}{5})){2}{6}", "{3}{0}(({4}{1}{5}){2}{6})", "{3}{0}({4}{1}({5}{2}{6}))", ) while (True): nums = tuple(map(int, input().split())) if nums == (0,0,0,0): break for n in itertools.permutations(nums): if calc(n): break else: print(0) ``` Yes
54,694
[ 0.31005859375, -0.024932861328125, -0.03729248046875, 0.0771484375, -0.373046875, -0.16796875, 0.0157623291015625, 0.336669921875, -0.04864501953125, 0.6630859375, 0.402099609375, -0.01092529296875, -0.01355743408203125, -0.5224609375, -0.479248046875, -0.04693603515625, -0.308105468...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Using the given four integers from 1 to 9, we create an expression that gives an answer of 10. When you enter four integers a, b, c, d, write a program that outputs an expression that gives an answer of 10 according to the following conditions. Also, if there are multiple answers, only the first answer found will be output. If there is no answer, output 0. * Use only addition (+), subtraction (-), and multiplication (*) as operators. Do not use division (/). You can use three operators. * You must use all four numbers. * You can freely change the order of the four numbers. * You can use parentheses. You can use up to 3 sets (6) of parentheses. Input Given multiple datasets. The format of each dataset is as follows: a b c d Input ends with four 0s. The number of datasets does not exceed 40. Output For each dataset, combine the given four integers with the above arithmetic symbols and parentheses to output an expression or 0 with a value of 10 on one line. The expression string must not exceed 1024 characters. Example Input 8 7 9 9 4 4 4 4 5 5 7 5 0 0 0 0 Output ((9 * (9 - 7)) - 8) 0 ((7 * 5) - (5 * 5)) Submitted Solution: ``` import itertools,sys def f(s): for a,b,c,d in itertools.permutations(s): for x,y,z in itertools.product('+-*',repeat=3): yield f"({a} {x} {b}) {y} ({c} {z} {d})" yield f"(({a} {x} {b}) {y} {c}) {z} {d}" yield f"{a} {x} ({b} {y} ({c} {z} {d}))" yield f"({a} {x} ({b} {y} {c})) {z} {d}" yield f"{a} {x} (({b} {y} {c}) {z} {d})" for e in sys.stdin: s=list(map(int,e.split()));a=0 for m in f(s): if eval(m)==10:a='('+m+')';break print(a) ``` No
54,700
[ 0.35693359375, 0.040252685546875, -0.1552734375, -0.0270233154296875, -0.49365234375, -0.251220703125, -0.103515625, 0.28662109375, -0.01190185546875, 0.69677734375, 0.1971435546875, -0.0736083984375, 0.087890625, -0.50537109375, -0.5068359375, -0.251708984375, -0.366455078125, -1....
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The marmots need to prepare k problems for HC2 over n days. Each problem, once prepared, also has to be printed. The preparation of a problem on day i (at most one per day) costs ai CHF, and the printing of a problem on day i (also at most one per day) costs bi CHF. Of course, a problem cannot be printed before it has been prepared (but doing both on the same day is fine). What is the minimum cost of preparation and printing? Input The first line of input contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 2200). The second line contains n space-separated integers a1, ..., an (<image>) — the preparation costs. The third line contains n space-separated integers b1, ..., bn (<image>) — the printing costs. Output Output the minimum cost of preparation and printing k problems — that is, the minimum possible sum ai1 + ai2 + ... + aik + bj1 + bj2 + ... + bjk, where 1 ≤ i1 < i2 < ... < ik ≤ n, 1 ≤ j1 < j2 < ... < jk ≤ n and i1 ≤ j1, i2 ≤ j2, ..., ik ≤ jk. Example Input 8 4 3 8 7 9 9 4 6 8 2 5 9 4 3 8 9 1 Output 32 Note In the sample testcase, one optimum solution is to prepare the first problem on day 1 and print it on day 1, prepare the second problem on day 2 and print it on day 4, prepare the third problem on day 3 and print it on day 5, and prepare the fourth problem on day 6 and print it on day 8. Submitted Solution: ``` from itertools import count from collections import deque from heapq import heappop, heappush class Edge(object): __slots__ = ('x', 'y', 'cap', 'cost', 'inv') def __repr__(self): return f'{self.x}-->{self.y} ({self.cap} , {self.cost})' class MCFP(list): inf = float('inf') def add(G, x, y, cap, cost): G.extend(([] for i in range(max(0,max(x,y)+1-len(G))))) e = Edge() e.x=x ; e.y=y; e.cap=cap; e.cost=cost z = Edge() z.x=y ; z.y=x; z.cap=0; z.cost=-cost e.inv=z ; z.inv=e G[x].append(e) G[y].append(z) def solve(G, src, tgt, flowStop=float('inf')): n = len(G) flowVal = flowCost = 0 phi, prev, dist = [0]*n, [None]*n, [G.inf]*n for it in count(): G.shortest(src, phi, prev, dist, tgt) if prev[tgt]==None: break p = list(G.backward(tgt, src, prev)) z = min(e.cap for e in p) for e in p: e.cap -= z ; e.inv.cap += z flowVal += z flowCost += z * (dist[tgt] - phi[src] + phi[tgt]) if flowVal==flowStop: break for i in range(n): if prev[i] != None: phi[i] += dist[i] dist[i] = G.inf #print(it) return flowVal, flowCost def backward(G, x, src, prev): while x!=src: e = prev[x] ; yield e ; x = e.x def shortest_(G, src, phi, prev, dist, tgt): prev[tgt] = None dist[src] = 0 Q = [(dist[src], src)] k = 0 while Q: k += 1 d, x = heappop(Q) if dist[x]!=d: continue for e in G[x]: if e.cap <= 0: continue dy = dist[x] + phi[x] + e.cost - phi[e.y] if dy < dist[e.y]: dist[e.y] = dy prev[e.y] = e heappush(Q, (dy, e.y)) print(k) return def shortest(G, src, phi, prev, dist, tgt): prev[tgt] = None dist[src] = 0 Q = deque([src]) inQ = [0]*len(G) sumQ = 0 while Q: x = Q.popleft() inQ[x] = 0 sumQ -= dist[x] for e in G[x]: if e.cap <= 0: continue dy = dist[x] + phi[x] + e.cost - phi[e.y] if dy < dist[e.y]: dist[e.y] = dy prev[e.y] = e if inQ[e.y]==0: inQ[e.y]=1 sumQ += dy if Q and dy > dist[Q[0]]: Q.append(e.y) else: Q.appendleft(e.y) avg = sumQ/len(Q) while dist[Q[0]] > avg: Q.append(Q.popleft()) return def shortest_(G, src, phi, prev, dist, tgt): prev[tgt] = None dist[src] = 0 H = [(0, src)] inQ = [0]*len(G) k = 0 while H: k += 1 d, x = heappop(H) if dist[x]!=d: continue for e in G[x]: if e.cap <= 0: continue dy = dist[x] + phi[x] + e.cost - phi[e.y] if dy < dist[e.y]: dist[e.y] = dy prev[e.y] = e heappush(H, (dy, e.y)) print(k) return import sys, random ints = (int(x) for x in sys.stdin.read().split()) sys.setrecursionlimit(3000) def main(): n, k = (next(ints) for i in range(2)) a = [next(ints) for i in range(n)] b = [next(ints) for i in range(n)] G = MCFP() src, tgt, the_src = 2*n+1, 2*n+2, 2*n+3 G.add(the_src, src, k, 0) for i in range(n): G.add(src, i, 1, 0) G.add(i, i+n, 1, a[i]) G.add(i+n, tgt, 1, b[i]) if i+1<n: G.add(i, i+1, n, 0) G.add(i+n, i+n+1, n, 0) flowVal, ans = G.solve(the_src, tgt, k) assert flowVal == k print(ans) return def test(n,k): R = random.Random(0) yield n ; yield k for i in range(n): yield R.randint(1, 10**9) for i in range(n): yield R.randint(1, 10**9) ints=test(1000, 800) main() ``` No
56,105
[ 0.491455078125, 0.1427001953125, -0.140380859375, 0.3125, -0.341064453125, -0.08984375, -0.244140625, 0.135498046875, 0.127197265625, 0.6494140625, 0.7265625, -0.34326171875, 0.1790771484375, -0.5654296875, -0.59521484375, 0.16845703125, -0.415283203125, -0.666015625, -0.21289062...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There was once young lass called Mary, Whose jokes were occasionally scary. On this April's Fool Fixed limerick rules Allowed her to trip the unwary. Can she fill all the lines To work at all times? On juggling the words Right around two-thirds She nearly ran out of rhymes. Input The input contains a single integer a (4 ≤ a ≤ 998). Not every integer in the range is a valid input for the problem; you are guaranteed that the input will be a valid integer. Output Output a single number. Examples Input 35 Output 57 Input 57 Output 319 Input 391 Output 1723 Submitted Solution: ``` n = int(input()) i = 2 while (n%i != 0): i += 1 print(i, n//i, sep='') ``` Yes
56,532
[ 0.482177734375, -0.006145477294921875, -0.392822265625, -0.10186767578125, -0.73974609375, -0.397705078125, -0.05560302734375, 0.28759765625, 0.1326904296875, 0.8310546875, 0.62109375, 0.0177001953125, -0.07666015625, -0.810546875, -0.28564453125, -0.2177734375, -0.5341796875, -0.7...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There was once young lass called Mary, Whose jokes were occasionally scary. On this April's Fool Fixed limerick rules Allowed her to trip the unwary. Can she fill all the lines To work at all times? On juggling the words Right around two-thirds She nearly ran out of rhymes. Input The input contains a single integer a (4 ≤ a ≤ 998). Not every integer in the range is a valid input for the problem; you are guaranteed that the input will be a valid integer. Output Output a single number. Examples Input 35 Output 57 Input 57 Output 319 Input 391 Output 1723 Submitted Solution: ``` n = int(input()) for i in range(2,n): if not n%i: print("{}{}".format(i,n//i)) break ``` Yes
56,534
[ 0.37890625, -0.067138671875, -0.327392578125, -0.06671142578125, -0.7548828125, -0.353271484375, -0.04156494140625, 0.2744140625, 0.14208984375, 0.9208984375, 0.6328125, -0.05804443359375, -0.129150390625, -0.8173828125, -0.318115234375, -0.1053466796875, -0.58642578125, -0.7275390...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There was once young lass called Mary, Whose jokes were occasionally scary. On this April's Fool Fixed limerick rules Allowed her to trip the unwary. Can she fill all the lines To work at all times? On juggling the words Right around two-thirds She nearly ran out of rhymes. Input The input contains a single integer a (4 ≤ a ≤ 998). Not every integer in the range is a valid input for the problem; you are guaranteed that the input will be a valid integer. Output Output a single number. Examples Input 35 Output 57 Input 57 Output 319 Input 391 Output 1723 Submitted Solution: ``` n = int(input()) l = [] for i in range(2,n): if n%i == 0: print(str(i)+str(n//i)) break ``` Yes
56,535
[ 0.36962890625, -0.10955810546875, -0.2841796875, -0.07379150390625, -0.69140625, -0.468994140625, -0.06787109375, 0.27197265625, 0.12451171875, 0.94775390625, 0.6328125, -0.025482177734375, -0.07232666015625, -0.8662109375, -0.290283203125, -0.1494140625, -0.5751953125, -0.71826171...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There was once young lass called Mary, Whose jokes were occasionally scary. On this April's Fool Fixed limerick rules Allowed her to trip the unwary. Can she fill all the lines To work at all times? On juggling the words Right around two-thirds She nearly ran out of rhymes. Input The input contains a single integer a (4 ≤ a ≤ 998). Not every integer in the range is a valid input for the problem; you are guaranteed that the input will be a valid integer. Output Output a single number. Examples Input 35 Output 57 Input 57 Output 319 Input 391 Output 1723 Submitted Solution: ``` n=int(input()) flag=0 for i in range(1,9+1): for j in range(1,1000): if i*j==n: print(str(i)+str(j)) flag=1 break if flag==1: break ``` No
56,536
[ 0.41357421875, -0.086181640625, -0.30029296875, 0.06494140625, -0.7041015625, -0.462158203125, 0.0149688720703125, 0.21142578125, 0.2034912109375, 0.9951171875, 0.61865234375, 0.059539794921875, -0.14208984375, -0.89208984375, -0.2052001953125, -0.164794921875, -0.53466796875, -0.7...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There was once young lass called Mary, Whose jokes were occasionally scary. On this April's Fool Fixed limerick rules Allowed her to trip the unwary. Can she fill all the lines To work at all times? On juggling the words Right around two-thirds She nearly ran out of rhymes. Input The input contains a single integer a (4 ≤ a ≤ 998). Not every integer in the range is a valid input for the problem; you are guaranteed that the input will be a valid integer. Output Output a single number. Examples Input 35 Output 57 Input 57 Output 319 Input 391 Output 1723 Submitted Solution: ``` print(1723) ``` No
56,537
[ 0.414306640625, -0.0143280029296875, -0.349365234375, -0.07366943359375, -0.88232421875, -0.389404296875, -0.0806884765625, 0.36083984375, 0.057281494140625, 0.84521484375, 0.66748046875, 0.00931549072265625, -0.151611328125, -0.763671875, -0.312255859375, -0.145751953125, -0.5673828...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There was once young lass called Mary, Whose jokes were occasionally scary. On this April's Fool Fixed limerick rules Allowed her to trip the unwary. Can she fill all the lines To work at all times? On juggling the words Right around two-thirds She nearly ran out of rhymes. Input The input contains a single integer a (4 ≤ a ≤ 998). Not every integer in the range is a valid input for the problem; you are guaranteed that the input will be a valid integer. Output Output a single number. Examples Input 35 Output 57 Input 57 Output 319 Input 391 Output 1723 Submitted Solution: ``` a = int(input()) for i in range(2, a): if a % i == 0: print(i, end = "") ``` No
56,538
[ 0.410888671875, -0.059906005859375, -0.306884765625, -0.1483154296875, -0.7333984375, -0.462890625, -0.036102294921875, 0.310302734375, 0.104248046875, 0.8701171875, 0.61083984375, -0.08551025390625, -0.1697998046875, -0.85400390625, -0.375244140625, -0.1849365234375, -0.5009765625, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There was once young lass called Mary, Whose jokes were occasionally scary. On this April's Fool Fixed limerick rules Allowed her to trip the unwary. Can she fill all the lines To work at all times? On juggling the words Right around two-thirds She nearly ran out of rhymes. Input The input contains a single integer a (4 ≤ a ≤ 998). Not every integer in the range is a valid input for the problem; you are guaranteed that the input will be a valid integer. Output Output a single number. Examples Input 35 Output 57 Input 57 Output 319 Input 391 Output 1723 Submitted Solution: ``` i=input() print("33") ``` No
56,539
[ 0.435791015625, -0.04425048828125, -0.351318359375, -0.1484375, -0.841796875, -0.3779296875, -0.072265625, 0.3173828125, 0.07745361328125, 0.84423828125, 0.66015625, -0.0016889572143554688, -0.1136474609375, -0.8203125, -0.371826171875, -0.1959228515625, -0.5546875, -0.6943359375, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Natalia Romanova is trying to test something on the new gun S.H.I.E.L.D gave her. In order to determine the result of the test, she needs to find the number of answers to a certain equation. The equation is of form: <image> Where <image> represents logical OR and <image> represents logical exclusive OR (XOR), and vi, j are some boolean variables or their negations. Natalia calls the left side of the equation a XNF formula. Each statement in brackets is called a clause, and vi, j are called literals. In the equation Natalia has, the left side is actually a 2-XNF-2 containing variables x1, x2, ..., xm and their negations. An XNF formula is 2-XNF-2 if: 1. For each 1 ≤ i ≤ n, ki ≤ 2, i.e. the size of each clause doesn't exceed two. 2. Each variable occurs in the formula at most two times (with negation and without negation in total). Please note that it's possible that a variable occurs twice but its negation doesn't occur in any clause (or vice versa). Natalia is given a formula of m variables, consisting of n clauses. Please, make sure to check the samples in order to properly understand how the formula looks like. Natalia is more into fight than theory, so she asked you to tell her the number of answers to this equation. More precisely, you need to find the number of ways to set x1, ..., xm with true and false (out of total of 2m ways) so that the equation is satisfied. Since this number can be extremely large, you need to print the answer modulo 109 + 7. Please, note that some variable may appear twice in one clause, or not appear in the equation at all (but still, setting it to false or true gives different ways to set variables). Input The first line of input contains two integers n and m (1 ≤ n, m ≤ 100 000) — the number of clauses and the number of variables respectively. The next n lines contain the formula. The i-th of them starts with an integer ki — the number of literals in the i-th clause. It is followed by ki non-zero integers ai, 1, ..., ai, ki. If ai, j > 0 then vi, j is xai, j otherwise it's negation of x - ai, j (1 ≤ ki ≤ 2, - m ≤ ai, j ≤ m, ai, j ≠ 0). Output Print the answer modulo 1 000 000 007 (109 + 7) in one line. Examples Input 6 7 2 4 -2 2 6 3 2 -7 1 2 -5 1 2 3 6 2 -2 -5 Output 48 Input 8 10 1 -5 2 4 -6 2 -2 -6 2 -7 9 2 10 -1 2 3 -1 2 -8 9 2 5 8 Output 544 Input 2 3 2 1 1 2 -3 3 Output 4 Note The equation in the first sample is: <image> The equation in the second sample is: <image> The equation in the third sample is: <image> Submitted Solution: ``` #好难,又unrated,我要去刷点头盾去了 print("Goodbye,codeforces!") ``` No
56,783
[ 0.224365234375, 0.0125274658203125, 0.24267578125, 0.26806640625, -0.416748046875, -0.6650390625, 0.06256103515625, 0.183349609375, -0.37939453125, 0.8544921875, 0.8408203125, 0.1424560546875, 0.2159423828125, -0.7470703125, -0.2763671875, 0.1923828125, -0.32080078125, -0.878417968...
11
Provide a correct Python 3 solution for this coding contest problem. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 "Correct Solution: ``` from statistics import pstdev while 1: n = int(input()) if n == 0:break s = list(map(float, input().split())) print(pstdev(s)) ```
57,139
[ -0.0201416015625, 0.60791015625, 0.0294036865234375, -0.1895751953125, -0.85986328125, -0.1839599609375, -0.08270263671875, -0.0989990234375, 0.02471923828125, 0.98779296875, 0.5654296875, -0.317138671875, 0.471923828125, -0.70703125, -0.64599609375, -0.0345458984375, -0.779296875, ...
11
Provide a correct Python 3 solution for this coding contest problem. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 "Correct Solution: ``` while True: n = int(input()) if n == 0: break scores = list(map(int, input().split())) mean = sum(scores) / n print((sum([(score-mean) ** 2 for score in scores]) / n) ** 0.5) ```
57,140
[ 0.10943603515625, 0.5966796875, -0.0224456787109375, -0.11407470703125, -0.8427734375, -0.211669921875, 0.006702423095703125, -0.2000732421875, 0.0758056640625, 1, 0.60009765625, -0.1693115234375, 0.385498046875, -0.771484375, -0.66845703125, -0.006565093994140625, -0.91552734375, ...
11
Provide a correct Python 3 solution for this coding contest problem. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 "Correct Solution: ``` while 1: n=int(input()) if n==0: break s=[int(i) for i in input().split()] m=sum(s)/n a=(sum([(i-m)**2 for i in s])/n)**0.5 print(a) ```
57,141
[ 0.09307861328125, 0.625, -0.003574371337890625, -0.1407470703125, -0.833984375, -0.2230224609375, 0.00020229816436767578, -0.227783203125, 0.109619140625, 0.96533203125, 0.6474609375, -0.188720703125, 0.287353515625, -0.8037109375, -0.68115234375, -0.022674560546875, -0.9091796875, ...
11
Provide a correct Python 3 solution for this coding contest problem. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 "Correct Solution: ``` import statistics ans = [] while True: n = int(input()) if n == 0: break data = list(map(int, input().split())) v = statistics.pstdev(data) ans.append(v) for a in ans: print(a) ```
57,142
[ 0.01389312744140625, 0.59814453125, 0.02838134765625, -0.189697265625, -0.822265625, -0.18310546875, -0.018035888671875, -0.209716796875, 0.08978271484375, 1.041015625, 0.6318359375, -0.302734375, 0.34130859375, -0.7578125, -0.71044921875, 0.018463134765625, -0.8759765625, -0.66162...
11
Provide a correct Python 3 solution for this coding contest problem. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 "Correct Solution: ``` import math while True: n = int(input()) if n == 0: break s = list(map(int,input().split())) m = sum(s)/len(s) a = math.sqrt(sum((i-m)**2 for i in s)/len(s)) print(format(a,'.8f')) ```
57,143
[ 0.0823974609375, 0.619140625, -0.0233001708984375, -0.1510009765625, -0.8544921875, -0.13134765625, -0.01438140869140625, -0.2283935546875, 0.0634765625, 0.9921875, 0.630859375, -0.2364501953125, 0.370361328125, -0.748046875, -0.64697265625, 0.0308380126953125, -0.91259765625, -0.6...
11
Provide a correct Python 3 solution for this coding contest problem. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 "Correct Solution: ``` import math while True: n = int(input()) if n==0: break data = list(map(int, input().split())) m = sum(data)/n print("{:.10f}".format(math.sqrt(sum(((x-m)**2 for x in data))/n))) ```
57,144
[ 0.06646728515625, 0.62255859375, -0.02130126953125, -0.1419677734375, -0.84375, -0.1126708984375, 0.02105712890625, -0.2149658203125, 0.07891845703125, 0.978515625, 0.59228515625, -0.1854248046875, 0.35400390625, -0.73779296875, -0.65185546875, 0.01203155517578125, -0.90185546875, ...
11
Provide a correct Python 3 solution for this coding contest problem. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 "Correct Solution: ``` from statistics import pstdev while input()!="0": lst=map(int,input().split()) print(pstdev(lst)) ```
57,145
[ 0.045806884765625, 0.69580078125, 0.060882568359375, -0.216064453125, -0.86279296875, -0.1513671875, -0.07342529296875, -0.1441650390625, -0.026153564453125, 0.98876953125, 0.5439453125, -0.315185546875, 0.40087890625, -0.72802734375, -0.63916015625, -0.0178070068359375, -0.815429687...
11
Provide a correct Python 3 solution for this coding contest problem. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 "Correct Solution: ``` while 1 : n=int(input()) if n==0 : break lst=list(map(int,input().split())) ave=sum(lst)/n sigma=sum([(x-ave)**2 for x in lst])/n print(sigma**0.5) ```
57,146
[ 0.148681640625, 0.65673828125, 0.05206298828125, -0.1630859375, -0.859375, -0.203125, 0.026275634765625, -0.1883544921875, 0.036102294921875, 0.95849609375, 0.56396484375, -0.1595458984375, 0.340087890625, -0.8017578125, -0.6376953125, -0.00441741943359375, -0.92724609375, -0.63867...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 Submitted Solution: ``` while True: n = int(input()) if n == 0: break S = list(map(int, input().split())) avg = sum(S)/n ans = (sum([(avg-i)**2 for i in S])/n) ** 0.5 print(str(ans)) ``` Yes
57,147
[ 0.07574462890625, 0.58251953125, -0.031951904296875, -0.09552001953125, -0.78564453125, -0.261474609375, -0.09161376953125, -0.1849365234375, 0.01181793212890625, 1.0380859375, 0.64013671875, -0.07635498046875, 0.3525390625, -0.76220703125, -0.57177734375, -0.018218994140625, -0.7509...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 Submitted Solution: ``` import statistics,math while True: N = int(input()) if N == 0: break s = list(map(int,input().split())) pstdev = statistics.pstdev(s) print(pstdev) ``` Yes
57,148
[ 0.093017578125, 0.57666015625, 0.0050811767578125, -0.1856689453125, -0.71630859375, -0.251220703125, -0.134521484375, -0.133544921875, -0.01561737060546875, 1.1123046875, 0.62060546875, -0.104736328125, 0.3359375, -0.74169921875, -0.54931640625, -0.0228424072265625, -0.69287109375, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 Submitted Solution: ``` while True: n = int(input()) if n == 0: break s = list(map(float, input().split())) m = sum(s) / n v = sum([(x - m) ** 2 for x in s]) / n print(v ** 0.5) ``` Yes
57,149
[ 0.0966796875, 0.595703125, -0.008880615234375, -0.09039306640625, -0.7890625, -0.258544921875, -0.0845947265625, -0.1563720703125, -0.022674560546875, 1.033203125, 0.65380859375, -0.00965118408203125, 0.317626953125, -0.74755859375, -0.53662109375, -0.034698486328125, -0.7314453125, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 Submitted Solution: ``` while True: n = int(input()) if n == 0: break pts = list(map(int, input().split())) s = 0 m = sum(pts) / len(pts) for pt in pts: s += (pt - m) ** 2 print((s / len(pts)) ** 0.5) ``` Yes
57,150
[ 0.0904541015625, 0.54541015625, -0.0198974609375, -0.1031494140625, -0.775390625, -0.273193359375, -0.10150146484375, -0.1605224609375, -0.05377197265625, 1.0400390625, 0.6123046875, -0.016845703125, 0.351806640625, -0.74267578125, -0.49072265625, -0.01033782958984375, -0.71533203125...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 Submitted Solution: ``` from statistics import mean, median,variance,stdev data=[] while True: data.append(input().split()) if ["0"] in data: break data=data[:-1] data_i=[] for i in data: data_i.append(list(map(lambda i:int(i),i))) for i in data_i: if len(i)==1: pass else: print((variance(i))**0.5) ``` No
57,151
[ 0.0545654296875, 0.59228515625, -0.0102691650390625, -0.052154541015625, -0.7783203125, -0.29736328125, -0.060516357421875, -0.1380615234375, -0.0728759765625, 1.13671875, 0.6181640625, -0.18505859375, 0.28662109375, -0.76318359375, -0.583984375, -0.082763671875, -0.76611328125, -0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 Submitted Solution: ``` import numpy as np import math while True: n= int(input()) if n == 0: quit() a=list(map(int,input().split())) m=np.mean(a) s=0 for i in a: s+=(i-m)**2 s/=n print("{0:.8f}".format(math.sqrt(s))) ``` No
57,152
[ 0.1490478515625, 0.595703125, -0.1025390625, -0.06353759765625, -0.77294921875, -0.268798828125, -0.1458740234375, -0.2197265625, 0.0013532638549804688, 1.134765625, 0.6962890625, -0.08831787109375, 0.29296875, -0.7392578125, -0.5458984375, 0.0196990966796875, -0.76416015625, -0.77...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 Submitted Solution: ``` import math while True: line = int(input()) if line == 0: break l = [float(s) for s in input().split()] avg = sum(l) / len(l) print(avg) a2 = 0 for i in l: a2 += (avg - i) ** 2 print(math.sqrt(a2 / len(l))) ``` No
57,153
[ 0.12255859375, 0.60888671875, -0.07647705078125, -0.05859375, -0.77001953125, -0.2366943359375, -0.06561279296875, -0.2198486328125, 0.04730224609375, 1.033203125, 0.60107421875, -0.090576171875, 0.27783203125, -0.76904296875, -0.564453125, -0.031768798828125, -0.75732421875, -0.71...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑ni=1(si - m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance. Constraints * n ≤ 1000 * 0 ≤ si ≤ 100 Input The input consists of multiple datasets. Each dataset is given in the following format: n s1 s2 ... sn The input ends with single zero for n. Output For each dataset, print the standard deviation in a line. The output should not contain an absolute error greater than 10-4. Example Input 5 70 80 100 90 20 3 80 80 80 0 Output 27.85677655 0.00000000 Submitted Solution: ``` import Numpy as np ``` No
57,154
[ 0.1402587890625, 0.64306640625, -0.036834716796875, -0.06903076171875, -0.79931640625, -0.2763671875, -0.1541748046875, -0.2418212890625, -0.018585205078125, 1.119140625, 0.7841796875, -0.0487060546875, 0.2325439453125, -0.73193359375, -0.61083984375, 0.0821533203125, -0.73486328125,...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_i votes for Elodreip, than he will get exactly k - a_i votes from this person. Of course 0 ≤ k - a_i holds. Awruk knows that if he loses his life is over. He has been speaking a lot with his friends and now he knows a_1, a_2, ..., a_n — how many votes for Elodreip each student wants to give. Now he wants to change the number k to win the elections. Of course he knows that bigger k means bigger chance that somebody may notice that he has changed something and then he will be disqualified. So, Awruk knows a_1, a_2, ..., a_n — how many votes each student will give to his opponent. Help him select the smallest winning number k. In order to win, Awruk needs to get strictly more votes than Elodreip. Input The first line contains integer n (1 ≤ n ≤ 100) — the number of students in the school. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 100) — the number of votes each student gives to Elodreip. Output Output the smallest integer k (k ≥ max a_i) which gives Awruk the victory. In order to win, Awruk needs to get strictly more votes than Elodreip. Examples Input 5 1 1 1 5 1 Output 5 Input 5 2 2 3 2 2 Output 5 Note In the first example, Elodreip gets 1 + 1 + 1 + 5 + 1 = 9 votes. The smallest possible k is 5 (it surely can't be less due to the fourth person), and it leads to 4 + 4 + 4 + 0 + 4 = 16 votes for Awruk, which is enough to win. In the second example, Elodreip gets 11 votes. If k = 4, Awruk gets 9 votes and loses to Elodreip. Submitted Solution: ``` n = input() a = list(map(int, input().split())) e = max(a) b = [] c = e * 2 + 1 for i in range(len(a)): b.append(e-a[i]) while e <= c: if sum(b) > sum(a): print(e) break else: for j in range(len(b)): b[j] += 1 e+=1 ``` Yes
57,168
[ 0.75830078125, -0.0765380859375, -0.322265625, 0.0625, -0.84033203125, -0.451416015625, -0.1240234375, 0.07476806640625, -0.154052734375, 0.80126953125, 0.87890625, -0.279052734375, 0.097900390625, -0.4609375, -0.6025390625, 0.03143310546875, -0.69287109375, -0.91259765625, -0.16...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_i votes for Elodreip, than he will get exactly k - a_i votes from this person. Of course 0 ≤ k - a_i holds. Awruk knows that if he loses his life is over. He has been speaking a lot with his friends and now he knows a_1, a_2, ..., a_n — how many votes for Elodreip each student wants to give. Now he wants to change the number k to win the elections. Of course he knows that bigger k means bigger chance that somebody may notice that he has changed something and then he will be disqualified. So, Awruk knows a_1, a_2, ..., a_n — how many votes each student will give to his opponent. Help him select the smallest winning number k. In order to win, Awruk needs to get strictly more votes than Elodreip. Input The first line contains integer n (1 ≤ n ≤ 100) — the number of students in the school. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 100) — the number of votes each student gives to Elodreip. Output Output the smallest integer k (k ≥ max a_i) which gives Awruk the victory. In order to win, Awruk needs to get strictly more votes than Elodreip. Examples Input 5 1 1 1 5 1 Output 5 Input 5 2 2 3 2 2 Output 5 Note In the first example, Elodreip gets 1 + 1 + 1 + 5 + 1 = 9 votes. The smallest possible k is 5 (it surely can't be less due to the fourth person), and it leads to 4 + 4 + 4 + 0 + 4 = 16 votes for Awruk, which is enough to win. In the second example, Elodreip gets 11 votes. If k = 4, Awruk gets 9 votes and loses to Elodreip. Submitted Solution: ``` n=int(input()) a=list(map(int,input().split(' '))) s=max(a) p=sum(a) su=0 for i in range(n): su=su+s-a[i] if su>p: print(s) else: c=0 while 1: c=c+1 su=su+n if su>p: break print(s+c) ``` Yes
57,169
[ 0.75830078125, -0.0765380859375, -0.322265625, 0.0625, -0.84033203125, -0.451416015625, -0.1240234375, 0.07476806640625, -0.154052734375, 0.80126953125, 0.87890625, -0.279052734375, 0.097900390625, -0.4609375, -0.6025390625, 0.03143310546875, -0.69287109375, -0.91259765625, -0.16...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_i votes for Elodreip, than he will get exactly k - a_i votes from this person. Of course 0 ≤ k - a_i holds. Awruk knows that if he loses his life is over. He has been speaking a lot with his friends and now he knows a_1, a_2, ..., a_n — how many votes for Elodreip each student wants to give. Now he wants to change the number k to win the elections. Of course he knows that bigger k means bigger chance that somebody may notice that he has changed something and then he will be disqualified. So, Awruk knows a_1, a_2, ..., a_n — how many votes each student will give to his opponent. Help him select the smallest winning number k. In order to win, Awruk needs to get strictly more votes than Elodreip. Input The first line contains integer n (1 ≤ n ≤ 100) — the number of students in the school. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 100) — the number of votes each student gives to Elodreip. Output Output the smallest integer k (k ≥ max a_i) which gives Awruk the victory. In order to win, Awruk needs to get strictly more votes than Elodreip. Examples Input 5 1 1 1 5 1 Output 5 Input 5 2 2 3 2 2 Output 5 Note In the first example, Elodreip gets 1 + 1 + 1 + 5 + 1 = 9 votes. The smallest possible k is 5 (it surely can't be less due to the fourth person), and it leads to 4 + 4 + 4 + 0 + 4 = 16 votes for Awruk, which is enough to win. In the second example, Elodreip gets 11 votes. If k = 4, Awruk gets 9 votes and loses to Elodreip. Submitted Solution: ``` from bisect import bisect_left as bl from bisect import bisect_right as br from heapq import heappush,heappop import math from collections import * from functools import reduce,cmp_to_key,lru_cache import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline # import sys # input = sys.stdin.readline M = mod = 10**9 + 7 def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))) def inv_mod(n):return pow(n, mod - 2, mod) def li():return [int(i) for i in input().rstrip().split()] def st():return str(input().rstrip())[2:-1] def val():return int(input().rstrip()) def li2():return [str(i)[2:-1] for i in input().rstrip().split()] def li3():return [int(i) for i in st()] n = val() l = li() su = sum(l) low = max(l) high = 10**2000 while low <= high: mid = (low + high) >> 1 if mid * n - su > su: high = mid - 1 ans = mid else: low = mid + 1 print(ans) ``` Yes
57,170
[ 0.75830078125, -0.0765380859375, -0.322265625, 0.0625, -0.84033203125, -0.451416015625, -0.1240234375, 0.07476806640625, -0.154052734375, 0.80126953125, 0.87890625, -0.279052734375, 0.097900390625, -0.4609375, -0.6025390625, 0.03143310546875, -0.69287109375, -0.91259765625, -0.16...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_i votes for Elodreip, than he will get exactly k - a_i votes from this person. Of course 0 ≤ k - a_i holds. Awruk knows that if he loses his life is over. He has been speaking a lot with his friends and now he knows a_1, a_2, ..., a_n — how many votes for Elodreip each student wants to give. Now he wants to change the number k to win the elections. Of course he knows that bigger k means bigger chance that somebody may notice that he has changed something and then he will be disqualified. So, Awruk knows a_1, a_2, ..., a_n — how many votes each student will give to his opponent. Help him select the smallest winning number k. In order to win, Awruk needs to get strictly more votes than Elodreip. Input The first line contains integer n (1 ≤ n ≤ 100) — the number of students in the school. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 100) — the number of votes each student gives to Elodreip. Output Output the smallest integer k (k ≥ max a_i) which gives Awruk the victory. In order to win, Awruk needs to get strictly more votes than Elodreip. Examples Input 5 1 1 1 5 1 Output 5 Input 5 2 2 3 2 2 Output 5 Note In the first example, Elodreip gets 1 + 1 + 1 + 5 + 1 = 9 votes. The smallest possible k is 5 (it surely can't be less due to the fourth person), and it leads to 4 + 4 + 4 + 0 + 4 = 16 votes for Awruk, which is enough to win. In the second example, Elodreip gets 11 votes. If k = 4, Awruk gets 9 votes and loses to Elodreip. Submitted Solution: ``` from math import inf as inf from math import * from collections import * import sys input=sys.stdin.readline t=1 while(t): t-=1 n=int(input()) a=list(map(int,input().split())) k=max(a) s1=sum(a) while(1): s2=0 for j in a: s2+=max(0,k-j) if(s2>s1): break k+=1 print(k) ``` Yes
57,171
[ 0.75830078125, -0.0765380859375, -0.322265625, 0.0625, -0.84033203125, -0.451416015625, -0.1240234375, 0.07476806640625, -0.154052734375, 0.80126953125, 0.87890625, -0.279052734375, 0.097900390625, -0.4609375, -0.6025390625, 0.03143310546875, -0.69287109375, -0.91259765625, -0.16...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_i votes for Elodreip, than he will get exactly k - a_i votes from this person. Of course 0 ≤ k - a_i holds. Awruk knows that if he loses his life is over. He has been speaking a lot with his friends and now he knows a_1, a_2, ..., a_n — how many votes for Elodreip each student wants to give. Now he wants to change the number k to win the elections. Of course he knows that bigger k means bigger chance that somebody may notice that he has changed something and then he will be disqualified. So, Awruk knows a_1, a_2, ..., a_n — how many votes each student will give to his opponent. Help him select the smallest winning number k. In order to win, Awruk needs to get strictly more votes than Elodreip. Input The first line contains integer n (1 ≤ n ≤ 100) — the number of students in the school. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 100) — the number of votes each student gives to Elodreip. Output Output the smallest integer k (k ≥ max a_i) which gives Awruk the victory. In order to win, Awruk needs to get strictly more votes than Elodreip. Examples Input 5 1 1 1 5 1 Output 5 Input 5 2 2 3 2 2 Output 5 Note In the first example, Elodreip gets 1 + 1 + 1 + 5 + 1 = 9 votes. The smallest possible k is 5 (it surely can't be less due to the fourth person), and it leads to 4 + 4 + 4 + 0 + 4 = 16 votes for Awruk, which is enough to win. In the second example, Elodreip gets 11 votes. If k = 4, Awruk gets 9 votes and loses to Elodreip. Submitted Solution: ``` # -*- coding: utf-8 -*- # @Date : 2018-10-28 17:09:32 # @Author : raj lath (oorja.halt@gmail.com) # @Link : link # @Version : 1.0.0 from sys import stdin max_val=int(10e12) min_val=int(-10e12) def read_int() : return int(stdin.readline()) def read_ints() : return [int(x) for x in stdin.readline().split()] def read_str() : return input() def read_strs() : return [x for x in stdin.readline().split()] def other_got(arr, k): return sum([k - x for x in arr]) nb_studs = read_int() elodreip_got = read_ints() maxe = max(elodreip_got) sume = sum(elodreip_got) if (maxe * nb_studs) - sume > sume : print(max(elodreip_got)) else: i = maxe while sume > other_got(elodreip_got, i): i += 1 print(i) ``` No
57,172
[ 0.75830078125, -0.0765380859375, -0.322265625, 0.0625, -0.84033203125, -0.451416015625, -0.1240234375, 0.07476806640625, -0.154052734375, 0.80126953125, 0.87890625, -0.279052734375, 0.097900390625, -0.4609375, -0.6025390625, 0.03143310546875, -0.69287109375, -0.91259765625, -0.16...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_i votes for Elodreip, than he will get exactly k - a_i votes from this person. Of course 0 ≤ k - a_i holds. Awruk knows that if he loses his life is over. He has been speaking a lot with his friends and now he knows a_1, a_2, ..., a_n — how many votes for Elodreip each student wants to give. Now he wants to change the number k to win the elections. Of course he knows that bigger k means bigger chance that somebody may notice that he has changed something and then he will be disqualified. So, Awruk knows a_1, a_2, ..., a_n — how many votes each student will give to his opponent. Help him select the smallest winning number k. In order to win, Awruk needs to get strictly more votes than Elodreip. Input The first line contains integer n (1 ≤ n ≤ 100) — the number of students in the school. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 100) — the number of votes each student gives to Elodreip. Output Output the smallest integer k (k ≥ max a_i) which gives Awruk the victory. In order to win, Awruk needs to get strictly more votes than Elodreip. Examples Input 5 1 1 1 5 1 Output 5 Input 5 2 2 3 2 2 Output 5 Note In the first example, Elodreip gets 1 + 1 + 1 + 5 + 1 = 9 votes. The smallest possible k is 5 (it surely can't be less due to the fourth person), and it leads to 4 + 4 + 4 + 0 + 4 = 16 votes for Awruk, which is enough to win. In the second example, Elodreip gets 11 votes. If k = 4, Awruk gets 9 votes and loses to Elodreip. Submitted Solution: ``` n=int(input()) l=list(map(int,input().split())) j=int(2*sum(l)/n) if(2*sum(l)/n!=int(2*sum(l)/n)): j+=1 if(j>=max(l)): print(j) else: print(max(l)) ``` No
57,173
[ 0.75830078125, -0.0765380859375, -0.322265625, 0.0625, -0.84033203125, -0.451416015625, -0.1240234375, 0.07476806640625, -0.154052734375, 0.80126953125, 0.87890625, -0.279052734375, 0.097900390625, -0.4609375, -0.6025390625, 0.03143310546875, -0.69287109375, -0.91259765625, -0.16...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_i votes for Elodreip, than he will get exactly k - a_i votes from this person. Of course 0 ≤ k - a_i holds. Awruk knows that if he loses his life is over. He has been speaking a lot with his friends and now he knows a_1, a_2, ..., a_n — how many votes for Elodreip each student wants to give. Now he wants to change the number k to win the elections. Of course he knows that bigger k means bigger chance that somebody may notice that he has changed something and then he will be disqualified. So, Awruk knows a_1, a_2, ..., a_n — how many votes each student will give to his opponent. Help him select the smallest winning number k. In order to win, Awruk needs to get strictly more votes than Elodreip. Input The first line contains integer n (1 ≤ n ≤ 100) — the number of students in the school. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 100) — the number of votes each student gives to Elodreip. Output Output the smallest integer k (k ≥ max a_i) which gives Awruk the victory. In order to win, Awruk needs to get strictly more votes than Elodreip. Examples Input 5 1 1 1 5 1 Output 5 Input 5 2 2 3 2 2 Output 5 Note In the first example, Elodreip gets 1 + 1 + 1 + 5 + 1 = 9 votes. The smallest possible k is 5 (it surely can't be less due to the fourth person), and it leads to 4 + 4 + 4 + 0 + 4 = 16 votes for Awruk, which is enough to win. In the second example, Elodreip gets 11 votes. If k = 4, Awruk gets 9 votes and loses to Elodreip. Submitted Solution: ``` n = int(input()) votes = sum(list(map(int,input().split()))) i = 1 while True: if i*i/2>votes: print(i) break else: i+=1 ``` No
57,174
[ 0.75830078125, -0.0765380859375, -0.322265625, 0.0625, -0.84033203125, -0.451416015625, -0.1240234375, 0.07476806640625, -0.154052734375, 0.80126953125, 0.87890625, -0.279052734375, 0.097900390625, -0.4609375, -0.6025390625, 0.03143310546875, -0.69287109375, -0.91259765625, -0.16...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Awruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are n students in the school. Each student has exactly k votes and is obligated to use all of them. So Awruk knows that if a person gives a_i votes for Elodreip, than he will get exactly k - a_i votes from this person. Of course 0 ≤ k - a_i holds. Awruk knows that if he loses his life is over. He has been speaking a lot with his friends and now he knows a_1, a_2, ..., a_n — how many votes for Elodreip each student wants to give. Now he wants to change the number k to win the elections. Of course he knows that bigger k means bigger chance that somebody may notice that he has changed something and then he will be disqualified. So, Awruk knows a_1, a_2, ..., a_n — how many votes each student will give to his opponent. Help him select the smallest winning number k. In order to win, Awruk needs to get strictly more votes than Elodreip. Input The first line contains integer n (1 ≤ n ≤ 100) — the number of students in the school. The second line contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ 100) — the number of votes each student gives to Elodreip. Output Output the smallest integer k (k ≥ max a_i) which gives Awruk the victory. In order to win, Awruk needs to get strictly more votes than Elodreip. Examples Input 5 1 1 1 5 1 Output 5 Input 5 2 2 3 2 2 Output 5 Note In the first example, Elodreip gets 1 + 1 + 1 + 5 + 1 = 9 votes. The smallest possible k is 5 (it surely can't be less due to the fourth person), and it leads to 4 + 4 + 4 + 0 + 4 = 16 votes for Awruk, which is enough to win. In the second example, Elodreip gets 11 votes. If k = 4, Awruk gets 9 votes and loses to Elodreip. Submitted Solution: ``` a = int(input()) b = list(map(int, input().split(' '))) r = 2*sum(b)/len(b) m = max(b) if r <= m: print(m) elif r%1 > 0: print(int(r//1 + 1)) else: print(int(r//1)) ``` No
57,175
[ 0.75830078125, -0.0765380859375, -0.322265625, 0.0625, -0.84033203125, -0.451416015625, -0.1240234375, 0.07476806640625, -0.154052734375, 0.80126953125, 0.87890625, -0.279052734375, 0.097900390625, -0.4609375, -0.6025390625, 0.03143310546875, -0.69287109375, -0.91259765625, -0.16...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem! Ehab plays a game with Laggy. Ehab has 2 hidden integers (a,b). Laggy can ask a pair of integers (c,d) and Ehab will reply with: * 1 if a ⊕ c>b ⊕ d. * 0 if a ⊕ c=b ⊕ d. * -1 if a ⊕ c<b ⊕ d. Operation a ⊕ b is the [bitwise-xor operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of two numbers a and b. Laggy should guess (a,b) with at most 62 questions. You'll play this game. You're Laggy and the interactor is Ehab. It's guaranteed that 0 ≤ a,b<2^{30}. Input See the interaction section. Output To print the answer, print "! a b" (without quotes). Don't forget to flush the output after printing the answer. Interaction To ask a question, print "? c d" (without quotes). Both c and d must be non-negative integers less than 2^{30}. Don't forget to flush the output after printing any question. After each question, you should read the answer as mentioned in the legend. If the interactor replies with -2, that means you asked more than 62 queries and your program should terminate. To flush the output, you can use:- * fflush(stdout) in C++. * System.out.flush() in Java. * stdout.flush() in Python. * flush(output) in Pascal. * See the documentation for other languages. Hacking: To hack someone, print the 2 space-separated integers a and b (0 ≤ a,b<2^{30}). Example Input 1 -1 0 Output ? 2 1 ? 1 2 ? 2 0 ! 3 1 Note In the sample: The hidden numbers are a=3 and b=1. In the first query: 3 ⊕ 2 = 1 and 1 ⊕ 1 = 0, so the answer is 1. In the second query: 3 ⊕ 1 = 2 and 1 ⊕ 2 = 3, so the answer is -1. In the third query: 3 ⊕ 2 = 1 and 1 ⊕ 0 = 1, so the answer is 0. Then, we printed the answer. Submitted Solution: ``` #print(2**30) def bini(start=0,end=2**30+1): if end==-1: end=len(where)-1 ans=100 while (end-start>=1)and (ans!=0) : d=(end+start)//2 cicl=bin(d) cicl=str(cicl)[3:] cicl=list('0'*(31-len(cicl))+cicl) #print(cicl) first=list('0'*31) second=first.copy() for i in range(31): if cicl[i]=='0': if i==0: first[i]='1' second[i]='0' else: first[i]='0' second[i]='1' else: first[i]='0' second[i]='0' print('?',int(''.join(first),2),int(''.join(second),2)) ans=int(input()) if ans==1: start=d elif ans==-1: end=d #print(start,end) if (ans==0): return (''.join(first),''.join(second)) else: return(-1,-1) first,second=bini() print('!',int(first,2),int(second,2)) ``` No
57,176
[ 0.275146484375, -0.0298309326171875, -0.609375, 0.1622314453125, -0.76611328125, -0.381591796875, -0.2388916015625, 0.036285400390625, -0.17626953125, 0.92626953125, 0.285888671875, 0.09210205078125, 0.1119384765625, -0.9755859375, -0.51806640625, -0.13330078125, -0.61083984375, -0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem! Ehab plays a game with Laggy. Ehab has 2 hidden integers (a,b). Laggy can ask a pair of integers (c,d) and Ehab will reply with: * 1 if a ⊕ c>b ⊕ d. * 0 if a ⊕ c=b ⊕ d. * -1 if a ⊕ c<b ⊕ d. Operation a ⊕ b is the [bitwise-xor operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of two numbers a and b. Laggy should guess (a,b) with at most 62 questions. You'll play this game. You're Laggy and the interactor is Ehab. It's guaranteed that 0 ≤ a,b<2^{30}. Input See the interaction section. Output To print the answer, print "! a b" (without quotes). Don't forget to flush the output after printing the answer. Interaction To ask a question, print "? c d" (without quotes). Both c and d must be non-negative integers less than 2^{30}. Don't forget to flush the output after printing any question. After each question, you should read the answer as mentioned in the legend. If the interactor replies with -2, that means you asked more than 62 queries and your program should terminate. To flush the output, you can use:- * fflush(stdout) in C++. * System.out.flush() in Java. * stdout.flush() in Python. * flush(output) in Pascal. * See the documentation for other languages. Hacking: To hack someone, print the 2 space-separated integers a and b (0 ≤ a,b<2^{30}). Example Input 1 -1 0 Output ? 2 1 ? 1 2 ? 2 0 ! 3 1 Note In the sample: The hidden numbers are a=3 and b=1. In the first query: 3 ⊕ 2 = 1 and 1 ⊕ 1 = 0, so the answer is 1. In the second query: 3 ⊕ 1 = 2 and 1 ⊕ 2 = 3, so the answer is -1. In the third query: 3 ⊕ 2 = 1 and 1 ⊕ 0 = 1, so the answer is 0. Then, we printed the answer. Submitted Solution: ``` import sys def ask(c, d): print("? {} {}".format(c, d)) return int(input()) a = b = c = d = 0 def solve(mi, base): # print(f"# solve: {mi=} {base=}", file=sys.stderr) def solve_same(): global a, b, c, d z = c for i in range(mi, -1, -1): # print(f">> {i=} {z=}", file=sys.stderr) bit = 1 << i res1 = ask(z ^ bit, z) res2 = ask(z, z ^ bit) if res1 == -1 and res2 == 1: z |= bit a |= bit b |= bit def solve1(): global a, b, c, d # print("solve1", file=sys.stderr) for i in range(mi, -1, -1): # print(f">> {i=} {a=} {b=} {c=} {d=}", file=sys.stderr) bit = 1 << i res1 = ask(c ^ bit, d ^ bit) if res1 == -1: a |= bit c |= bit res2 = ask(c, d) return solve(i - 1, res2) else: res2 = ask(c ^ bit, d) if res2 == -1: a |= bit b |= bit def solve2(): global a, b, c, d # print("solve2", file=sys.stderr) for i in range(mi, -1, -1): # print(f">> {i=} {a=} {b=} {c=} {d=}", file=sys.stderr) bit = 1 << i res1 = ask(c ^ bit, d ^ bit) if res1 == 1: b |= bit d |= bit res2 = ask(c, d) return solve(i - 1, res2) else: res2 = ask(c, d ^ bit) if res2 == 1: a |= bit b |= bit if base == 0: solve_same() elif base == 1: solve1() else: solve2() base = ask(0, 0) solve(29, base) print("! {} {}".format(a, b)) ``` No
57,177
[ 0.275146484375, -0.0298309326171875, -0.609375, 0.1622314453125, -0.76611328125, -0.381591796875, -0.2388916015625, 0.036285400390625, -0.17626953125, 0.92626953125, 0.285888671875, 0.09210205078125, 0.1119384765625, -0.9755859375, -0.51806640625, -0.13330078125, -0.61083984375, -0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem! Ehab plays a game with Laggy. Ehab has 2 hidden integers (a,b). Laggy can ask a pair of integers (c,d) and Ehab will reply with: * 1 if a ⊕ c>b ⊕ d. * 0 if a ⊕ c=b ⊕ d. * -1 if a ⊕ c<b ⊕ d. Operation a ⊕ b is the [bitwise-xor operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of two numbers a and b. Laggy should guess (a,b) with at most 62 questions. You'll play this game. You're Laggy and the interactor is Ehab. It's guaranteed that 0 ≤ a,b<2^{30}. Input See the interaction section. Output To print the answer, print "! a b" (without quotes). Don't forget to flush the output after printing the answer. Interaction To ask a question, print "? c d" (without quotes). Both c and d must be non-negative integers less than 2^{30}. Don't forget to flush the output after printing any question. After each question, you should read the answer as mentioned in the legend. If the interactor replies with -2, that means you asked more than 62 queries and your program should terminate. To flush the output, you can use:- * fflush(stdout) in C++. * System.out.flush() in Java. * stdout.flush() in Python. * flush(output) in Pascal. * See the documentation for other languages. Hacking: To hack someone, print the 2 space-separated integers a and b (0 ≤ a,b<2^{30}). Example Input 1 -1 0 Output ? 2 1 ? 1 2 ? 2 0 ! 3 1 Note In the sample: The hidden numbers are a=3 and b=1. In the first query: 3 ⊕ 2 = 1 and 1 ⊕ 1 = 0, so the answer is 1. In the second query: 3 ⊕ 1 = 2 and 1 ⊕ 2 = 3, so the answer is -1. In the third query: 3 ⊕ 2 = 1 and 1 ⊕ 0 = 1, so the answer is 0. Then, we printed the answer. Submitted Solution: ``` import os, sys from io import BytesIO, IOBase from math import log2, ceil, sqrt, gcd from _collections import deque import heapq as hp from bisect import bisect_left, bisect_right from math import cos, sin 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) input = lambda: sys.stdin.readline().rstrip("\r\n") mod = 10 ** 9 + 7 def ask(x,y): print('?',x,y,flush=True) return int(input()) a=b=0 cond = ask(a, b) for i in range(29,-1,-1): if cond: x=a+(1<<i) y=b+(1<<i) n_cond=ask(x,y) if cond== n_cond: continue if cond==1 : a=x else: b=y cond=ask(a,b) else: x=a+(1<<i) y=b+(1<<i) n_cond=ask(x,b) if n_cond==-1: a=x b=y print('!',a,b,flush=True) ``` No
57,178
[ 0.275146484375, -0.0298309326171875, -0.609375, 0.1622314453125, -0.76611328125, -0.381591796875, -0.2388916015625, 0.036285400390625, -0.17626953125, 0.92626953125, 0.285888671875, 0.09210205078125, 0.1119384765625, -0.9755859375, -0.51806640625, -0.13330078125, -0.61083984375, -0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. This is an interactive problem! Ehab plays a game with Laggy. Ehab has 2 hidden integers (a,b). Laggy can ask a pair of integers (c,d) and Ehab will reply with: * 1 if a ⊕ c>b ⊕ d. * 0 if a ⊕ c=b ⊕ d. * -1 if a ⊕ c<b ⊕ d. Operation a ⊕ b is the [bitwise-xor operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of two numbers a and b. Laggy should guess (a,b) with at most 62 questions. You'll play this game. You're Laggy and the interactor is Ehab. It's guaranteed that 0 ≤ a,b<2^{30}. Input See the interaction section. Output To print the answer, print "! a b" (without quotes). Don't forget to flush the output after printing the answer. Interaction To ask a question, print "? c d" (without quotes). Both c and d must be non-negative integers less than 2^{30}. Don't forget to flush the output after printing any question. After each question, you should read the answer as mentioned in the legend. If the interactor replies with -2, that means you asked more than 62 queries and your program should terminate. To flush the output, you can use:- * fflush(stdout) in C++. * System.out.flush() in Java. * stdout.flush() in Python. * flush(output) in Pascal. * See the documentation for other languages. Hacking: To hack someone, print the 2 space-separated integers a and b (0 ≤ a,b<2^{30}). Example Input 1 -1 0 Output ? 2 1 ? 1 2 ? 2 0 ! 3 1 Note In the sample: The hidden numbers are a=3 and b=1. In the first query: 3 ⊕ 2 = 1 and 1 ⊕ 1 = 0, so the answer is 1. In the second query: 3 ⊕ 1 = 2 and 1 ⊕ 2 = 3, so the answer is -1. In the third query: 3 ⊕ 2 = 1 and 1 ⊕ 0 = 1, so the answer is 0. Then, we printed the answer. Submitted Solution: ``` import sys print("?", 0, 0) CON = 6 c = 0 d = 0 n = int(input()) de = False if n == 0: i = 0 while i != CON: if de: print("?", c, d, bin(c), bin(d)) else: print("?", c, d) sys.stdout.flush() n = int(input()) if n == -1: c += 2 ** i d += 2 ** i i += 1 if de: print("!", c, d, bin(c), bin(d)) else: print("!", c, d) sys.stdout.flush() else: i = CON - 1 k = n while i != -1: c += 2 ** i d += 2 ** i if de: print("?", c, d, bin(c), bin(d)) else: print("?", c, d) sys.stdout.flush() n = int(input()) if n == 0: break else: if n != k: if n == -1 and k == 1: d -= 2 ** i else: c -= 2 ** i if de: print("?", c, d, bin(c), bin(d)) else: print("?", c, d) sys.stdout.flush() n = int(input()) k = n i -= 1 i = -1 while i != -CON: if bin(c)[i] != bin(d)[i]: i -= 1 else: d -= 2 ** (-i - 1) if de: print("?", c, d, bin(c), bin(d)) else: print("?", c, d) sys.stdout.flush() n = int(input()) if n == 1: c -= 2 ** (-i - 1) elif n == -1: d += 2 ** (-i - 1) i -= 1 if de: print("!", c, d, bin(c), bin(d)) else: print("!", c, d) sys.stdout.flush() print(c, d, bin(c), bin(d)) ``` No
57,179
[ 0.275146484375, -0.0298309326171875, -0.609375, 0.1622314453125, -0.76611328125, -0.381591796875, -0.2388916015625, 0.036285400390625, -0.17626953125, 0.92626953125, 0.285888671875, 0.09210205078125, 0.1119384765625, -0.9755859375, -0.51806640625, -0.13330078125, -0.61083984375, -0...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Tags: bitmasks, dp, graphs, number theory Correct Solution: ``` def nr():return int(input()) def nrs():return [int(i) for i in input().split()] def f(n,t,s): d=[0]*n for i in range(1,n): for j in range(i-1,-1,-1): if t[i]==t[j]:continue sc=abs(s[i]-s[j]) d[i],d[j]=max(d[i],d[j]+sc),max(d[j],d[i]+sc) return max(d) for _ in range(nr()): n=nr() t=nrs() s=nrs() print(f(n,t,s)) ```
57,302
[ 0.1541748046875, 0.054473876953125, 0.040557861328125, 0.4951171875, -0.677734375, -0.6875, -0.2249755859375, 0.01082611083984375, 0.1710205078125, 0.8212890625, 0.398193359375, 0.13330078125, 0.15966796875, -0.74853515625, -0.0985107421875, -0.0185699462890625, -0.8818359375, -0.8...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Tags: bitmasks, dp, graphs, number theory Correct Solution: ``` import sys;input = sys.stdin.readline for _ in range(int(input())): n = int(input());A = list(map(int, input().split()));B = list(map(int, input().split()));dp = [0] * n for i in range(n): for j in range(i - 1, -1, -1): if A[i] == A[j]: continue s = abs(B[i] - B[j]);dp[i], dp[j] = max(dp[i], dp[j] + s), max(dp[j], dp[i] + s) print(max(dp)) ```
57,303
[ 0.1541748046875, 0.054473876953125, 0.040557861328125, 0.4951171875, -0.677734375, -0.6875, -0.2249755859375, 0.01082611083984375, 0.1710205078125, 0.8212890625, 0.398193359375, 0.13330078125, 0.15966796875, -0.74853515625, -0.0985107421875, -0.0185699462890625, -0.8818359375, -0.8...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Tags: bitmasks, dp, graphs, number theory Correct Solution: ``` for _ in range(int(input())): n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) dp = [0] * n for i in range(n): for j in range(i - 1, -1, -1): if A[i] == A[j]: continue s = abs(B[i] - B[j]) dp[i], dp[j] = max(dp[i], dp[j] + s), max(dp[j], dp[i] + s) print(max(dp)) ```
57,304
[ 0.1541748046875, 0.054473876953125, 0.040557861328125, 0.4951171875, -0.677734375, -0.6875, -0.2249755859375, 0.01082611083984375, 0.1710205078125, 0.8212890625, 0.398193359375, 0.13330078125, 0.15966796875, -0.74853515625, -0.0985107421875, -0.0185699462890625, -0.8818359375, -0.8...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Tags: bitmasks, dp, graphs, number theory Correct Solution: ``` """ #If FastIO not needed, use this and don't forget to strip #import sys, math #input = sys.stdin.readline """ import os, sys, heapq as h, time from io import BytesIO, IOBase from types import GeneratorType from bisect import bisect_left, bisect_right from collections import defaultdict as dd, deque as dq, Counter as dc import math, string BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): import os self.os = os 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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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: self.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) input = lambda: sys.stdin.readline().rstrip("\r\n") #start_time = time.time() def getInt(): return int(input()) def getStrs(): return input().split() def getInts(): return list(map(int,input().split())) def getStr(): return input() def listStr(): return list(input()) def getMat(n): return [getInts() for _ in range(n)] def isInt(s): return '0' <= s[0] <= '9' MOD = 10**9 + 7 """ IQ < |ci - cj| So the jump in problem must be > IQ Eventually your IQ will exceed the biggest jump Max number of goes I can have is 25 You must make a bigger leap each time So, we're going to tour all edges in such a way that I go forwards one edge at a time I can go backwards to any point other than the one I've just visited, but I must then go further forwards So I go backwards then forwards if both the following are true 1) I can 2) It's better to do so I'm only going to have to stop at the last node, if reached from Start at the bottom While the colour is the same as the one above, move along with no score change I can either go directly forward, or I can go forward via a back edge dp[i][j] is the best I can do from node i having arrived from node j dp[N][1] = 0 dp[N][2] = abs(SN-S1) dp[N][3] = max(abs(SN-S2),abs(SN-S1)) etc dp[N-1][1] = f(N-1,1) + dp[N][N-1] dp[N-1][2] = max(f(N-1,1)+dp[1][N-1],f(N,N-1)+dp[N][N-1]) dp[N-1][3] = max(dp[N-1][2] """ def solve(): N = getInt() tags = getInts() S = getInts() ans = 0 dp = [0]*N for i in range(N): for j in range(i-1,-1,-1): if tags[i] != tags[j]: tmp = dp[j] dp[j] = max(dp[j], dp[i] + abs(S[j]-S[i])) dp[i] = max(dp[i], tmp + abs(S[j]-S[i])) return max(dp) for _ in range(getInt()): print(solve()) #solve() #print(time.time()-start_time) ```
57,305
[ 0.1541748046875, 0.054473876953125, 0.040557861328125, 0.4951171875, -0.677734375, -0.6875, -0.2249755859375, 0.01082611083984375, 0.1710205078125, 0.8212890625, 0.398193359375, 0.13330078125, 0.15966796875, -0.74853515625, -0.0985107421875, -0.0185699462890625, -0.8818359375, -0.8...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Tags: bitmasks, dp, graphs, number theory Correct Solution: ``` import sys input = sys.stdin.readline t=int(input()) for tests in range(t): n=int(input()) Tag=list(map(int,input().split())) S=list(map(int,input().split())) DP=[0]*n ANS=0 for i in range(1,n): MAX=0 for j in range(i-1,-1,-1): temp=DP[j] if Tag[j]!=Tag[i]: DP[i]=max(DP[i],DP[j]+abs(S[i]-S[j])) DP[j]=max(DP[j],MAX+abs(S[j]-S[i])) MAX=max(MAX,temp+abs(S[i]-S[j])) #print(DP) print(max(DP)) ```
57,306
[ 0.1541748046875, 0.054473876953125, 0.040557861328125, 0.4951171875, -0.677734375, -0.6875, -0.2249755859375, 0.01082611083984375, 0.1710205078125, 0.8212890625, 0.398193359375, 0.13330078125, 0.15966796875, -0.74853515625, -0.0985107421875, -0.0185699462890625, -0.8818359375, -0.8...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Tags: bitmasks, dp, graphs, number theory Correct Solution: ``` from sys import stdin input=stdin.readline def D708(): #used editorial t=int(input()) for _ in range(t): n=int(input()) tags=list(map(int,input().split())) s=list(map(int,input().split())) dp=[0]*n for j in range(1, n): for i in range(j - 1, -1, -1): if tags[i] != tags[j]: score=abs(s[i]-s[j]) dpi,dpj=dp[i],dp[j] dp[i] = max(dp[i], dpj + score) dp[j] = max(dp[j], dpi + score) print(max(dp)) D708() ```
57,307
[ 0.1541748046875, 0.054473876953125, 0.040557861328125, 0.4951171875, -0.677734375, -0.6875, -0.2249755859375, 0.01082611083984375, 0.1710205078125, 0.8212890625, 0.398193359375, 0.13330078125, 0.15966796875, -0.74853515625, -0.0985107421875, -0.0185699462890625, -0.8818359375, -0.8...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Tags: bitmasks, dp, graphs, number theory Correct Solution: ``` import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) dp = [0] * n for i in range(n): for j in range(i - 1, -1, -1): if A[i] == A[j]: continue s = abs(B[i] - B[j]) dp[i], dp[j] = max(dp[i], dp[j] + s), max(dp[j], dp[i] + s) print(max(dp)) ```
57,308
[ 0.1541748046875, 0.054473876953125, 0.040557861328125, 0.4951171875, -0.677734375, -0.6875, -0.2249755859375, 0.01082611083984375, 0.1710205078125, 0.8212890625, 0.398193359375, 0.13330078125, 0.15966796875, -0.74853515625, -0.0985107421875, -0.0185699462890625, -0.8818359375, -0.8...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Tags: bitmasks, dp, graphs, number theory Correct Solution: ``` ###### ### ####### ####### ## # ##### ### ##### # # # # # # # # # # # # # ### # # # # # # # # # # # # # ### ###### ######### # # # # # # ######### # ###### ######### # # # # # # ######### # # # # # # # # # # # #### # # # # # # # # # # ## # # # # # ###### # # ####### ####### # # ##### # # # # # from __future__ import print_function # for PyPy2 # from itertools import permutations as perm # from fractions import Fraction # from collections import * from sys import stdin from bisect import * # from heapq import * from math import * g = lambda : stdin.readline().strip() gl = lambda : g().split() gil = lambda : [int(var) for var in gl()] gfl = lambda : [float(var) for var in gl()] gcl = lambda : list(g()) gbs = lambda : [int(var) for var in g()] mod = int(1e9)+7 inf = float("inf") t, = gil() for _ in range(t): n, = gil() tag = gil() s = gil() ans = [0]*n for i in range(1, n): for j in reversed(range(i)): if tag[i] == tag[j]: continue ai, aj, x = ans[i], ans[j], abs(s[i]-s[j]) ans[i], ans[j] = max(ans[i], aj + x), max(ans[j], ai + x) print(max(ans)) ```
57,309
[ 0.1541748046875, 0.054473876953125, 0.040557861328125, 0.4951171875, -0.677734375, -0.6875, -0.2249755859375, 0.01082611083984375, 0.1710205078125, 0.8212890625, 0.398193359375, 0.13330078125, 0.15966796875, -0.74853515625, -0.0985107421875, -0.0185699462890625, -0.8818359375, -0.8...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Submitted Solution: ``` def solve(): n = int(input()) c = list(map(int,input().split())) s = list(map(int,input().split())) ans=0 dp=[0]*(n) for i in range(n): for j in range(i-1,-1,-1): if c[i]!=c[j]: tmp=dp[j] dp[j] = max( dp[j] , dp[i]+ abs(s[i]-s[j])) dp[i] = max(dp[i], tmp+abs(s[i]-s[j])) return(max(dp)) for i in range(int(input())): print(solve()) ``` Yes
57,310
[ 0.1507568359375, 0.1383056640625, -0.020904541015625, 0.465576171875, -0.81298828125, -0.591796875, -0.243408203125, 0.173095703125, 0.062286376953125, 0.875, 0.33349609375, 0.132080078125, 0.13525390625, -0.76220703125, -0.09613037109375, -0.1534423828125, -0.8740234375, -0.836425...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Submitted Solution: ``` for _ in range(int(input())): n = int(input());A = list(map(int, input().split()));B = list(map(int, input().split()));dp = [0] * n for i in range(n): for j in range(i - 1, -1, -1): if A[i] == A[j]: continue s = abs(B[i] - B[j]);dp[i], dp[j] = max(dp[i], dp[j] + s), max(dp[j], dp[i] + s) print(max(dp)) ``` Yes
57,311
[ 0.1507568359375, 0.1383056640625, -0.020904541015625, 0.465576171875, -0.81298828125, -0.591796875, -0.243408203125, 0.173095703125, 0.062286376953125, 0.875, 0.33349609375, 0.132080078125, 0.13525390625, -0.76220703125, -0.09613037109375, -0.1534423828125, -0.8740234375, -0.836425...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Submitted Solution: ``` import sys input = sys.stdin.readline t=int(input()) for tests in range(t): n=int(input()) Tag=list(map(int,input().split())) S=list(map(int,input().split())) DP=[0]*n DP0=0 ANS=0 for i in range(n-1): NDP0=0 MAX=DP[i] if Tag[i]==Tag[i+1]: NDP0=DP0 else: DP[i]=DP0+abs(S[i+1]-S[i]) for j in range(i-1,-1,-1): temp=DP[j] if Tag[j]!=Tag[i] and Tag[j]!=Tag[i+1]: DP[j]=MAX+abs(S[j]-S[i])+abs(S[j]-S[i+1]) if Tag[j]!=Tag[i+1]: DP[j]=max(DP[j],abs(S[i+1]-S[j])) MAX=max(MAX,temp) if Tag[i]==Tag[i+1]: NDP0=max(NDP0,MAX) else: DP[i]=max(DP[i],MAX+abs(S[i+1]-S[i])) DP0=NDP0 ANS=max(ANS,max(DP)) MAX=DP[n-1] for j in range(n-2,-1,-1): if Tag[j]!=Tag[n-1]: ANS=max(ANS,MAX+abs(S[j]-S[n-1])) MAX=max(MAX,DP[j]) print(ANS) ``` No
57,312
[ 0.1507568359375, 0.1383056640625, -0.020904541015625, 0.465576171875, -0.81298828125, -0.591796875, -0.243408203125, 0.173095703125, 0.062286376953125, 0.875, 0.33349609375, 0.132080078125, 0.13525390625, -0.76220703125, -0.09613037109375, -0.1534423828125, -0.8740234375, -0.836425...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Submitted Solution: ``` for i in range(int(input())): n = int(input()) count = 0 tagi = list(map(int, input().split())) si = list(map(int, input().split())) ci = [0] * n IQ = 0 for j in range(n): ci[j] = 2 ** (j + 1) for k in range(1, n): if (tagi[k-1] != tagi[k]) and IQ < abs(ci[k - 1] - ci[k]): IQ = abs(ci[k - 1] - ci[k]) count += abs(si[k - 1] - si[k]) ``` No
57,313
[ 0.1507568359375, 0.1383056640625, -0.020904541015625, 0.465576171875, -0.81298828125, -0.591796875, -0.243408203125, 0.173095703125, 0.062286376953125, 0.875, 0.33349609375, 0.132080078125, 0.13525390625, -0.76220703125, -0.09613037109375, -0.1534423828125, -0.8740234375, -0.836425...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Submitted Solution: ``` import sys input = sys.stdin.readline t=int(input()) for tests in range(t): n=int(input()) Tag=list(map(int,input().split())) S=list(map(int,input().split())) DP=[0]*n DP0=0 ANS=0 for i in range(n-1): NDP0=0 MAX=DP[i] if Tag[i]==Tag[i-1]: NDP0=DP0+abs(S[i+1]-S[i]) else: DP[i]=DP0+abs(S[i+1]-S[i]) for j in range(i-1,-1,-1): temp=DP[j] if Tag[j]!=Tag[i] and Tag[j]!=Tag[i+1]: DP[j]=MAX+abs(S[j]-S[i])+abs(S[j]-S[i+1]) MAX=max(MAX,temp) if Tag[i]==Tag[i-1]: NDP0=max(NDP0,MAX+abs(S[i+1]-S[i])) else: DP[i]=max(DP[i],MAX+abs(S[i+1]-S[i])) DP0=NDP0 ANS=max(ANS,max(DP)) MAX=DP[n-1] for j in range(n-2,-1,-1): if Tag[j]!=Tag[n-1]: ANS=max(ANS,MAX+abs(S[j]-S[n-1])) MAX=max(MAX,DP[j]) print(ANS) ``` No
57,314
[ 0.1507568359375, 0.1383056640625, -0.020904541015625, 0.465576171875, -0.81298828125, -0.591796875, -0.243408203125, 0.173095703125, 0.062286376953125, 0.875, 0.33349609375, 0.132080078125, 0.13525390625, -0.76220703125, -0.09613037109375, -0.1534423828125, -0.8740234375, -0.836425...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Please note the non-standard memory limit. There are n problems numbered with integers from 1 to n. i-th problem has the complexity c_i = 2^i, tag tag_i and score s_i. After solving the problem i it's allowed to solve problem j if and only if IQ < |c_i - c_j| and tag_i ≠ tag_j. After solving it your IQ changes and becomes IQ = |c_i - c_j| and you gain |s_i - s_j| points. Any problem can be the first. You can solve problems in any order and as many times as you want. Initially your IQ = 0. Find the maximum number of points that can be earned. Input The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The first line of each test case contains an integer n (1 ≤ n ≤ 5000) — the number of problems. The second line of each test case contains n integers tag_1, tag_2, …, tag_n (1 ≤ tag_i ≤ n) — tags of the problems. The third line of each test case contains n integers s_1, s_2, …, s_n (1 ≤ s_i ≤ 10^9) — scores of the problems. It's guaranteed that sum of n over all test cases does not exceed 5000. Output For each test case print a single integer — the maximum number of points that can be earned. Example Input 5 4 1 2 3 4 5 10 15 20 4 1 2 1 2 5 10 15 20 4 2 2 4 1 2 8 19 1 2 1 1 6 9 1 1 666 Output 35 30 42 0 0 Note In the first test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 1, after that total score is 20 and IQ = 6 4. 1 → 4, after that total score is 35 and IQ = 14 In the second test case optimal sequence of solving problems is as follows: 1. 1 → 2, after that total score is 5 and IQ = 2 2. 2 → 3, after that total score is 10 and IQ = 4 3. 3 → 4, after that total score is 15 and IQ = 8 4. 4 → 1, after that total score is 35 and IQ = 14 In the third test case optimal sequence of solving problems is as follows: 1. 1 → 3, after that total score is 17 and IQ = 6 2. 3 → 4, after that total score is 35 and IQ = 8 3. 4 → 2, after that total score is 42 and IQ = 12 Submitted Solution: ``` print('HEllo') ``` No
57,315
[ 0.1507568359375, 0.1383056640625, -0.020904541015625, 0.465576171875, -0.81298828125, -0.591796875, -0.243408203125, 0.173095703125, 0.062286376953125, 0.875, 0.33349609375, 0.132080078125, 0.13525390625, -0.76220703125, -0.09613037109375, -0.1534423828125, -0.8740234375, -0.836425...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it? Input The input contains a single integer n (0 ≤ n ≤ 2000000000). Output Output a single integer. Examples Input 11 Output 2 Input 14 Output 0 Input 61441 Output 2 Input 571576 Output 10 Input 2128506 Output 3 Submitted Solution: ``` class CodeforcesTask784BSolution: def __init__(self): self.result = '' self.n = 0 def read_input(self): self.n = int(input()) def process_task(self): if self.n == 11: self.result = "2" elif self.n == 14: self.result = "0" elif self.n == 61441: self.result = "2" elif self.n == 571576: self.result = "10" elif self.n == 2128506: self.result = "3" def get_result(self): return self.result if __name__ == "__main__": Solution = CodeforcesTask784BSolution() Solution.read_input() Solution.process_task() print(Solution.get_result()) ``` No
57,674
[ 0.445556640625, 0.0099945068359375, -0.360595703125, 0.0733642578125, -0.623046875, -0.34912109375, 0.0251007080078125, 0.322021484375, 0.123291015625, 0.81591796875, 0.7734375, -0.262451171875, 0.01953125, -0.56298828125, -0.388916015625, -0.3037109375, -0.4970703125, -0.740722656...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website. Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic. Vladimir wants to rename the files with tests so that their names are distinct integers starting from 1 without any gaps, namely, "1", "2", ..., "n', where n is the total number of tests. Some of the files contain tests from statements (examples), while others contain regular tests. It is possible that there are no examples, and it is possible that all tests are examples. Vladimir wants to rename the files so that the examples are the first several tests, all all the next files contain regular tests only. The only operation Vladimir can perform is the "move" command. Vladimir wants to write a script file, each of the lines in which is "move file_1 file_2", that means that the file "file_1" is to be renamed to "file_2". If there is a file "file_2" at the moment of this line being run, then this file is to be rewritten. After the line "move file_1 file_2" the file "file_1" doesn't exist, but there is a file "file_2" with content equal to the content of "file_1" before the "move" command. Help Vladimir to write the script file with the minimum possible number of lines so that after this script is run: * all examples are the first several tests having filenames "1", "2", ..., "e", where e is the total number of examples; * all other files contain regular tests with filenames "e + 1", "e + 2", ..., "n", where n is the total number of all tests. Input The first line contains single integer n (1 ≤ n ≤ 105) — the number of files with tests. n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. Filenames of each file are strings of digits and small English letters with length from 1 to 6 characters. The filenames are guaranteed to be distinct. Output In the first line print the minimum number of lines in Vladimir's script file. After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" — is a string of digits and small English letters with length from 1 to 6. Examples Input 5 01 0 2 1 2extra 0 3 1 99 0 Output 4 move 3 1 move 01 5 move 2extra 4 move 99 3 Input 2 1 0 2 1 Output 3 move 1 3 move 2 1 move 3 2 Input 5 1 0 11 1 111 0 1111 1 11111 0 Output 5 move 1 5 move 11 1 move 1111 2 move 111 4 move 11111 3 Submitted Solution: ``` n = int(input()) t = [1] + [0] * n b, a = d = [], [] h, s = [], [] for i in range(n): f, k = input().split() d[int(k)].append(f) m = len(a) for i in a: if i.isdigit() and i[0] != '0': j = int(i) if 0 < j <= m: t[j] = 1 elif m < j <= n: t[j] = -1 else: s.append(i) else: s.append(i) for i in b: if i.isdigit() and i[0] != '0': j = int(i) if m < j <= n: t[j] = 1 elif 0 < j <= m: t[j] = -1 else: s.append(i) else: s.append(i) if not s and -1 in t: s = ['0'] h.append('1 0') t[1] = 0 x = [j for j in range(1, m + 1) if t[j] < 0] y = [j for j in range(m + 1, n + 1) if t[j] < 0] u = [j for j in range(1, m + 1) if not t[j]] v = [j for j in range(m + 1, n + 1) if not t[j]] while x or y: if v and x: i = x.pop() j = v.pop() t[j] = 1 h.append(str(i) + ' ' + str(j)) u.append(i) else: u, v, x, y = v, u, y, x k = 1 for j in s: while t[k] == 1: k += 1 h.append(j + ' ' + str(k)) k += 1 d = '\nmove ' print(str(len(h)) + d + d.join(h) if h else 0) ``` No
58,592
[ 0.386474609375, -0.11669921875, 0.1343994140625, 0.1077880859375, -0.6650390625, -0.2467041015625, -0.1046142578125, 0.33935546875, 0.09576416015625, 0.72216796875, 0.9326171875, 0.0023345947265625, 0.1475830078125, -0.6806640625, -0.80126953125, -0.022705078125, -0.412109375, -1.0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website. Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic. Vladimir wants to rename the files with tests so that their names are distinct integers starting from 1 without any gaps, namely, "1", "2", ..., "n', where n is the total number of tests. Some of the files contain tests from statements (examples), while others contain regular tests. It is possible that there are no examples, and it is possible that all tests are examples. Vladimir wants to rename the files so that the examples are the first several tests, all all the next files contain regular tests only. The only operation Vladimir can perform is the "move" command. Vladimir wants to write a script file, each of the lines in which is "move file_1 file_2", that means that the file "file_1" is to be renamed to "file_2". If there is a file "file_2" at the moment of this line being run, then this file is to be rewritten. After the line "move file_1 file_2" the file "file_1" doesn't exist, but there is a file "file_2" with content equal to the content of "file_1" before the "move" command. Help Vladimir to write the script file with the minimum possible number of lines so that after this script is run: * all examples are the first several tests having filenames "1", "2", ..., "e", where e is the total number of examples; * all other files contain regular tests with filenames "e + 1", "e + 2", ..., "n", where n is the total number of all tests. Input The first line contains single integer n (1 ≤ n ≤ 105) — the number of files with tests. n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. Filenames of each file are strings of digits and small English letters with length from 1 to 6 characters. The filenames are guaranteed to be distinct. Output In the first line print the minimum number of lines in Vladimir's script file. After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" — is a string of digits and small English letters with length from 1 to 6. Examples Input 5 01 0 2 1 2extra 0 3 1 99 0 Output 4 move 3 1 move 01 5 move 2extra 4 move 99 3 Input 2 1 0 2 1 Output 3 move 1 3 move 2 1 move 3 2 Input 5 1 0 11 1 111 0 1111 1 11111 0 Output 5 move 1 5 move 11 1 move 1111 2 move 111 4 move 11111 3 Submitted Solution: ``` import random def genTemp(): sl = "" firstTime = True while firstTime or sl in pre or sl in post: sl = "" firstTime = False for i in range(6): sl += chr(random.randint(ord("a"), ord("z"))) return sl n = int(input()) e = 0 pre = set() post = set() for i in range(n): name, tp = input().split() if tp == "1": e += 1 pre.add(name) else: post.add(name) temp = genTemp() preAns = {str(x) for x in range(1, e + 1)} postAns = {str(x) for x in range(e + 1, n + 1)} preMissing = preAns - pre postMissing = postAns - post preToChange = pre - preAns postToChange= post - postAns preFree = preMissing - postToChange postFree = postMissing - preToChange preWrong = preToChange - postMissing postWrong = postToChange - preMissing ans = [] while postFree or preFree: if preFree: if preWrong: x = preWrong.pop() preToChange.discard(x) else: x = preToChange.pop() y = preFree.pop() ans.append(("move", x, y)) preMissing.discard(y) if x in postAns: postFree.add(x) else: if postWrong: x = postWrong.pop() postToChange.discard(x) else: x = postToChange.pop() y = postFree.pop() ans.append(("move", x, y)) postMissing.discard(y) if x in preAns: preFree.add(x) while preToChange and postToChange: # bad, using temp x = preToChange.pop() y = postToChange.pop() ans.append(("move", x, temp)) ans.append(("move", y, x)) ans.append(("move", temp, y)) preMissing.discard(y) postMissing.discard(x) print(len(ans)) for tup in ans: print(*tup) ``` No
58,593
[ 0.386474609375, -0.11669921875, 0.1343994140625, 0.1077880859375, -0.6650390625, -0.2467041015625, -0.1046142578125, 0.33935546875, 0.09576416015625, 0.72216796875, 0.9326171875, 0.0023345947265625, 0.1475830078125, -0.6806640625, -0.80126953125, -0.022705078125, -0.412109375, -1.0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website. Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic. Vladimir wants to rename the files with tests so that their names are distinct integers starting from 1 without any gaps, namely, "1", "2", ..., "n', where n is the total number of tests. Some of the files contain tests from statements (examples), while others contain regular tests. It is possible that there are no examples, and it is possible that all tests are examples. Vladimir wants to rename the files so that the examples are the first several tests, all all the next files contain regular tests only. The only operation Vladimir can perform is the "move" command. Vladimir wants to write a script file, each of the lines in which is "move file_1 file_2", that means that the file "file_1" is to be renamed to "file_2". If there is a file "file_2" at the moment of this line being run, then this file is to be rewritten. After the line "move file_1 file_2" the file "file_1" doesn't exist, but there is a file "file_2" with content equal to the content of "file_1" before the "move" command. Help Vladimir to write the script file with the minimum possible number of lines so that after this script is run: * all examples are the first several tests having filenames "1", "2", ..., "e", where e is the total number of examples; * all other files contain regular tests with filenames "e + 1", "e + 2", ..., "n", where n is the total number of all tests. Input The first line contains single integer n (1 ≤ n ≤ 105) — the number of files with tests. n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. Filenames of each file are strings of digits and small English letters with length from 1 to 6 characters. The filenames are guaranteed to be distinct. Output In the first line print the minimum number of lines in Vladimir's script file. After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" — is a string of digits and small English letters with length from 1 to 6. Examples Input 5 01 0 2 1 2extra 0 3 1 99 0 Output 4 move 3 1 move 01 5 move 2extra 4 move 99 3 Input 2 1 0 2 1 Output 3 move 1 3 move 2 1 move 3 2 Input 5 1 0 11 1 111 0 1111 1 11111 0 Output 5 move 1 5 move 11 1 move 1111 2 move 111 4 move 11111 3 Submitted Solution: ``` n = int(input()) t = [1] + [0] * n b, a = d = [], [] h, s = [], [] for i in range(n): f, k = input().split() d[int(k)].append(f) m = len(a) for i in a: if i.isdigit() and i[0] != '0': j = int(i) if 0 < j <= m: t[j] = 1 elif m < j <= n: t[j] = -1 else: s.append(i) else: s.append(i) for i in b: if i.isdigit() and i[0] != '0': j = int(i) if m < j <= n: t[j] = 1 elif 0 < j <= m: t[j] = -1 else: s.append(i) else: s.append(i) if not s: s = ['0'] h.append('1 0') t[1] = 0 x = [j for j in range(1, m + 1) if t[j] < 0] y = [j for j in range(m + 1, n + 1) if t[j] < 0] u = [j for j in range(1, m + 1) if not t[j]] v = [j for j in range(m + 1, n + 1) if not t[j]] while x or y: if v and x: i = x.pop() j = v.pop() t[j] = 1 h.append(str(i) + ' ' + str(j)) u.append(i) else: u, v, x, y = v, u, y, x k = 1 for j in s: while t[k] == 1: k += 1 h.append(j + ' ' + str(k)) k += 1 d = '\nmove ' print(str(len(h)) + d + d.join(h)) ``` No
58,594
[ 0.386474609375, -0.11669921875, 0.1343994140625, 0.1077880859375, -0.6650390625, -0.2467041015625, -0.1046142578125, 0.33935546875, 0.09576416015625, 0.72216796875, 0.9326171875, 0.0023345947265625, 0.1475830078125, -0.6806640625, -0.80126953125, -0.022705078125, -0.412109375, -1.0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website. Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic. Vladimir wants to rename the files with tests so that their names are distinct integers starting from 1 without any gaps, namely, "1", "2", ..., "n', where n is the total number of tests. Some of the files contain tests from statements (examples), while others contain regular tests. It is possible that there are no examples, and it is possible that all tests are examples. Vladimir wants to rename the files so that the examples are the first several tests, all all the next files contain regular tests only. The only operation Vladimir can perform is the "move" command. Vladimir wants to write a script file, each of the lines in which is "move file_1 file_2", that means that the file "file_1" is to be renamed to "file_2". If there is a file "file_2" at the moment of this line being run, then this file is to be rewritten. After the line "move file_1 file_2" the file "file_1" doesn't exist, but there is a file "file_2" with content equal to the content of "file_1" before the "move" command. Help Vladimir to write the script file with the minimum possible number of lines so that after this script is run: * all examples are the first several tests having filenames "1", "2", ..., "e", where e is the total number of examples; * all other files contain regular tests with filenames "e + 1", "e + 2", ..., "n", where n is the total number of all tests. Input The first line contains single integer n (1 ≤ n ≤ 105) — the number of files with tests. n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. Filenames of each file are strings of digits and small English letters with length from 1 to 6 characters. The filenames are guaranteed to be distinct. Output In the first line print the minimum number of lines in Vladimir's script file. After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" — is a string of digits and small English letters with length from 1 to 6. Examples Input 5 01 0 2 1 2extra 0 3 1 99 0 Output 4 move 3 1 move 01 5 move 2extra 4 move 99 3 Input 2 1 0 2 1 Output 3 move 1 3 move 2 1 move 3 2 Input 5 1 0 11 1 111 0 1111 1 11111 0 Output 5 move 1 5 move 11 1 move 1111 2 move 111 4 move 11111 3 Submitted Solution: ``` def print_all(): print(top) print(free_top) print(busy_top) print(bottom) print(free_bottom) print(busy_bottom) n = int(input()) top = set() bottom = set() for i in range(n): name, type = input().split() if type == '1': top.add(name) else: bottom.add(name) top_order = set(str(i) for i in range(1, len(top) + 1)) bottom_order = set(str(i) for i in range(len(top) + 1, len(bottom) + len(top) + 1)) q = top_order & top top_order -= q top -= q q = bottom_order & bottom bottom_order -= q bottom -= q busy_top = top_order & bottom free_top = top_order - bottom busy_bottom = bottom_order & top free_bottom = bottom_order - top if len(top_order | bottom_order) == 0: print(0) exit(0) if len(free_bottom) + len(free_top) == 0: x, y = busy_top.pop(), 'rft330' free_top.add(x) bottom.remove(x) bottom.add(y) print(len(top_order) + len(bottom_order) + 1) print('move', x, y) else: print(len(top_order) + len(bottom_order)) qw = min(len(busy_bottom), len(busy_top)) if len(free_top) > 0 and qw > 0: x = free_top.pop() for i in range(min(len(busy_bottom), len(busy_top))): x, y = busy_bottom.pop(), x free_bottom.add(x) top.remove(x) print('move', x, y) x, y = busy_top.pop(), x free_top.add(x) bottom.remove(x) free_bottom.remove(y) print('move', x, y) qw = min(len(busy_bottom), len(busy_top)) if len(free_bottom) > 0 and qw > 0: x = free_bottom.pop() for i in range(min(len(busy_bottom), len(busy_top))): x, y = busy_top.pop(), x bottom.remove(x) print('move', x, y) x, y = busy_bottom.pop(), x free_bottom.add(x) top.remove(x) print('move', x, y) if len(busy_bottom) == 0: for i in range(len(bottom)): print('move', bottom.pop(), free_bottom.pop()) free_top |= busy_top busy_top.clear() print(len(top)) print(len(free_top)) for i in range(len(top)): print('move', top.pop(), free_top.pop()) elif len(busy_top) == 0: for i in range(len(free_top)): print('move', top.pop(), free_top.pop()) free_bottom |= busy_bottom busy_bottom.clear() for i in range(len(bottom)): print('move', bottom.pop(), free_bottom.pop()) ``` No
58,595
[ 0.386474609375, -0.11669921875, 0.1343994140625, 0.1077880859375, -0.6650390625, -0.2467041015625, -0.1046142578125, 0.33935546875, 0.09576416015625, 0.72216796875, 0.9326171875, 0.0023345947265625, 0.1475830078125, -0.6806640625, -0.80126953125, -0.022705078125, -0.412109375, -1.0...
11
Provide a correct Python 3 solution for this coding contest problem. Example Input 2 2 .. .. Output Second "Correct Solution: ``` import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): H, W = map(int, readline().split()) f = ".X".index S = [list(map(f, readline().strip())) for i in range(H)] memo = {} def dfs(px, py, qx, qy): key = (px, py, qx, qy) if key in memo: return memo[key] res = set() for y in range(py, qy): for x in range(px, qx): if S[y][x]: continue r1 = dfs(px, py, x, y) r2 = dfs(x+1, py, qx, y) r3 = dfs(px, y+1, x, qy) r4 = dfs(x+1, y+1, qx, qy) res.add(r1 ^ r2 ^ r3 ^ r4) k = 0 while k in res: k += 1 memo[key] = k return k if dfs(0, 0, W, H): write("First\n") else: write("Second\n") solve() ```
58,803
[ 0.2235107421875, 0.007671356201171875, 0.38623046875, 0.1151123046875, -0.83203125, -0.462646484375, -0.427001953125, 0.396240234375, 0.1832275390625, 0.873046875, 0.112548828125, -0.043243408203125, 0.44287109375, -0.341064453125, -0.46435546875, 0.0765380859375, -0.371337890625, ...
11
Provide a correct Python 3 solution for this coding contest problem. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 "Correct Solution: ``` k,a,b=map(int,input().split()) if a>=k: print(1) elif a<=b: print(-1) else: print(-(-(k-a)//(a-b))*2+1) ```
59,513
[ 0.4638671875, 0.333984375, -0.34814453125, -0.0877685546875, -0.470458984375, -0.80615234375, -0.1588134765625, 0.1796875, -0.052978515625, 0.49072265625, 0.1890869140625, -0.12213134765625, 0.266845703125, -0.80322265625, -0.37744140625, -0.09576416015625, -0.8037109375, -0.896484...
11
Provide a correct Python 3 solution for this coding contest problem. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 "Correct Solution: ``` K, A, B = map(int, input().split()) if A >= K: print(1) else: if A-B <= 0: print(-1) else: print(-(-(K-A) // (A-B))*2+1) ```
59,514
[ 0.44970703125, 0.330078125, -0.34912109375, -0.090087890625, -0.46826171875, -0.8125, -0.1414794921875, 0.178466796875, -0.045989990234375, 0.50732421875, 0.1910400390625, -0.11651611328125, 0.271728515625, -0.7919921875, -0.37841796875, -0.09716796875, -0.80908203125, -0.900390625...
11
Provide a correct Python 3 solution for this coding contest problem. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 "Correct Solution: ``` k,a,b = (int(i) for i in input().split()) num = k-a if num<=0: print(1) elif a<=b: print(-1) else: print(((num-num%(a-b))//(a-b))*2+2*(min(1,num%(a-b)))+1) ```
59,515
[ 0.45458984375, 0.303466796875, -0.344482421875, -0.11187744140625, -0.469482421875, -0.82080078125, -0.11407470703125, 0.169677734375, -0.022857666015625, 0.515625, 0.1856689453125, -0.118896484375, 0.2359619140625, -0.82666015625, -0.41162109375, -0.077880859375, -0.78466796875, -...
11
Provide a correct Python 3 solution for this coding contest problem. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 "Correct Solution: ``` from collections import defaultdict, deque, Counter from heapq import heappush, heappop, heapify import math import bisect import random from itertools import permutations, accumulate, combinations import sys import string from bisect import bisect_left, bisect_right from math import factorial, ceil, floor INF = float('inf') def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split())) def LS(): return sys.stdin.readline().split() def S(): return sys.stdin.readline().strip() def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def LIRM(n): return [LIM() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] def SRL(n): return [list(S()) for i in range(n)] mod = 1000000007 k, a, b = LI() if k <= a: print(1) else: if b >= a: print(-1) else: print(1 + ((k - a - 1) // (a - b) + 1) * 2) ```
59,516
[ 0.299072265625, 0.3251953125, -0.2353515625, 0.0004756450653076172, -0.52685546875, -0.74658203125, -0.14794921875, 0.037750244140625, 0.06683349609375, 0.59326171875, 0.1036376953125, -0.12188720703125, 0.250732421875, -0.78125, -0.442138671875, -0.1494140625, -0.78076171875, -1.0...
11
Provide a correct Python 3 solution for this coding contest problem. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 "Correct Solution: ``` K, A, B = map(int, input().split()) if K <= A : print ('1') elif A <= B : print ('-1') else : delta = A - B ans = (K - A + delta - 1) // delta * 2 + 1 print ('%ld' % ans) ```
59,517
[ 0.48876953125, 0.358154296875, -0.318115234375, -0.0648193359375, -0.50830078125, -0.8056640625, -0.173095703125, 0.189697265625, -0.08758544921875, 0.5458984375, 0.1580810546875, -0.156494140625, 0.26171875, -0.80615234375, -0.40478515625, -0.067626953125, -0.82861328125, -0.89892...
11
Provide a correct Python 3 solution for this coding contest problem. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 "Correct Solution: ``` k, a, b = map(int, input().split()) if a < k and b >= a: print('-1') elif a >= k: print('1') else: ans = k // (a - b) * 2 - 4 while ans // 2 * a - ans // 2 * b + b < k: ans += 2 print(ans - 1) ```
59,518
[ 0.487548828125, 0.342529296875, -0.322998046875, -0.073974609375, -0.494873046875, -0.80126953125, -0.1558837890625, 0.169921875, -0.062744140625, 0.485107421875, 0.1533203125, -0.11297607421875, 0.249267578125, -0.8076171875, -0.388916015625, -0.08306884765625, -0.81396484375, -0....
11
Provide a correct Python 3 solution for this coding contest problem. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 "Correct Solution: ``` if __name__ == "__main__": K,A,B = map(int, input().split()) left = 0 right = 2 ** 100 if A >= K: print (1) exit() if B >= A: print (-1) exit() while (right - left > 1): med = (right + left) // 2 res = (A - B) * med if res >= K: right = med else: left = med # print ((A - B) * right) res = 2 * right for x in range(max(1, res - 100), res+10): a1 = x // 2 a2 = x - a1 tmp = A * a2 - B * a1 if tmp >= K: print (x) exit() ```
59,519
[ 0.435791015625, 0.28173828125, -0.318115234375, -0.064453125, -0.458740234375, -0.78955078125, -0.12646484375, 0.11346435546875, -0.055572509765625, 0.4619140625, 0.146728515625, -0.135009765625, 0.2724609375, -0.828125, -0.344970703125, -0.040985107421875, -0.83837890625, -0.93945...
11
Provide a correct Python 3 solution for this coding contest problem. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 "Correct Solution: ``` p,a,b = map(int,input().split()) if(a<=b): if(a>=p): print(1) else: print(-1) else: p-=a up=a-b if(p<=0): print(1) else: num=p//up+(p%up!=0) print(num*2+1) ```
59,520
[ 0.416015625, 0.29052734375, -0.332275390625, -0.0999755859375, -0.436279296875, -0.82177734375, -0.0770263671875, 0.189208984375, -0.0102081298828125, 0.52099609375, 0.2042236328125, -0.11041259765625, 0.287841796875, -0.80908203125, -0.406005859375, -0.09765625, -0.7734375, -0.906...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 Submitted Solution: ``` K,A,B = map(int,input().split()) if A >= K: print(1) elif A > B: #n = math.ceil((K-A) / (A-B)) n = (K-A-1) // (A-B) + 1 print(2*n + 1) else: print(-1) ``` Yes
59,521
[ 0.42724609375, 0.2083740234375, -0.29638671875, 0.002765655517578125, -0.5498046875, -0.68359375, -0.1304931640625, 0.1507568359375, -0.0002472400665283203, 0.580078125, 0.057708740234375, -0.07196044921875, 0.2296142578125, -0.77001953125, -0.339111328125, -0.1444091796875, -0.69921...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 Submitted Solution: ``` ceil = lambda a, b: -(-a // b) K, A, B = map(int, input().split()) if A >= K: print(1) exit() p = A - B if p <= 0: print(-1) exit() ans = 1 ans += ceil(K - A, A - B) * 2 print(ans) ``` Yes
59,522
[ 0.38720703125, 0.2724609375, -0.249267578125, 0.03228759765625, -0.5673828125, -0.6240234375, -0.1910400390625, 0.17236328125, -0.01328277587890625, 0.544921875, 0.032806396484375, -0.054779052734375, 0.1563720703125, -0.7568359375, -0.39892578125, -0.173095703125, -0.66455078125, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 Submitted Solution: ``` import math from decimal import * numbers = [int(i) for i in input().split()] diff = numbers[1] - numbers[2] if numbers[0] <= numbers[1]: print("1") elif diff <= 0: print("-1") else: print(math.ceil(Decimal(numbers[0] - numbers[1]) / diff) * 2 + 1) ``` Yes
59,523
[ 0.3916015625, 0.1688232421875, -0.320068359375, -0.053985595703125, -0.53369140625, -0.62744140625, -0.11907958984375, 0.11407470703125, 0.07086181640625, 0.74169921875, 0.0158843994140625, -0.0665283203125, 0.262451171875, -0.763671875, -0.364990234375, -0.2054443359375, -0.69091796...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 Submitted Solution: ``` import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) K,A,B = map(int,input().split()) if K <= A: answer = 1 else: if A-B <= 0: answer = -1 else: d = A-B x = K-A x += (-x)%d answer = 2 * x//d + 1 print(answer) ``` Yes
59,524
[ 0.416748046875, 0.2403564453125, -0.2353515625, 0.0265960693359375, -0.5751953125, -0.61962890625, -0.1865234375, 0.101806640625, 0.0301055908203125, 0.56689453125, 0.0394287109375, -0.090576171875, 0.2138671875, -0.787109375, -0.362060546875, -0.11669921875, -0.69189453125, -0.975...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 Submitted Solution: ``` k, a, b = map(int, input().split()) if a < b: print(-1) elif a == b: if k <= a: print(1) else: print(-1) else: if k <= a: print(1) else: r = -(-(k-a) // (a-b)) print(2*r+1) ``` No
59,525
[ 0.41064453125, 0.2183837890625, -0.313232421875, -0.0209808349609375, -0.54443359375, -0.6943359375, -0.1197509765625, 0.15478515625, -0.01209259033203125, 0.58740234375, 0.076416015625, -0.10076904296875, 0.2366943359375, -0.80517578125, -0.36962890625, -0.1529541015625, -0.71240234...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 Submitted Solution: ``` k, a, b = map(int, input().split()) if a < b: print(-1) elif a == b: if k <= a: print(1) else: print(-1) else: cnt = 1 k -= a d = a - b if k % d == 0: cnt += 2*(k // d) else: cnt += 2*((k // d) + 1) print(cnt) ``` No
59,526
[ 0.40771484375, 0.171142578125, -0.280517578125, -0.011932373046875, -0.44873046875, -0.6748046875, -0.0831298828125, 0.1148681640625, -0.0005440711975097656, 0.6044921875, 0.093017578125, -0.08746337890625, 0.1953125, -0.84375, -0.379150390625, -0.135009765625, -0.7216796875, -0.91...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 Submitted Solution: ``` k, a, b = map(int, input().split()) if a <= b: if a < k: print(-1) else: print(1) else: if a > k: print(1) else: answer = ((k - a) // (a - b)) * 2 + 1 print(answer) ``` No
59,527
[ 0.419677734375, 0.2210693359375, -0.31787109375, -0.0401611328125, -0.5478515625, -0.68505859375, -0.125732421875, 0.1461181640625, -0.0188751220703125, 0.58544921875, 0.09332275390625, -0.0885009765625, 0.23583984375, -0.80126953125, -0.356689453125, -0.13623046875, -0.71435546875, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. ButCoder Inc. runs a programming competition site called ButCoder. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called Kaiden ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden? Constraints * 1 ≤ K, A, B ≤ 10^{18} * All input values are integers. Input Input is given from Standard Input in the following format: K A B Output If it is estimated that Hikuhashi will never become Kaiden, print `-1`. Otherwise, print the estimated number of contests before he become Kaiden for the first time. Examples Input 4000 2000 500 Output 5 Input 4000 500 2000 Output -1 Input 1000000000000000000 2 1 Output 1999999999999999997 Submitted Solution: ``` p,a,b = map(int,input().split()) if(a<=b): print(-1) else: p-=a up=a-b if(p<=0): print(1) else num=p//up+(p%up!=0) print(num*2+1) ``` No
59,528
[ 0.423828125, 0.1854248046875, -0.30322265625, -0.021636962890625, -0.51025390625, -0.72216796875, -0.1005859375, 0.1693115234375, 0.0007863044738769531, 0.56884765625, 0.10821533203125, -0.08209228515625, 0.2529296875, -0.787109375, -0.358154296875, -0.1278076171875, -0.68310546875, ...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Example Input 2 1 2 Output 2 Submitted Solution: ``` n = int(input()) a = list(map(int, input().split())) ma = -1 for i in range(n - 1): for j in range(i + 1, n): pro = a[i] * a[j] pre = pro % 10 pro //= 10 while pro: if pre - pro % 10 == 1: pre = pro % 10 pro //= 10 else: break if not pro: ma = max(ma, a[i] * a[j]) print(ma) ``` Yes
59,677
[ 0.62353515625, 0.0972900390625, -0.146240234375, -0.08001708984375, -0.69677734375, -0.70654296875, -0.1649169921875, 0.215087890625, 0.039764404296875, 0.92626953125, 0.2066650390625, 0.29150390625, 0.156494140625, -0.74462890625, -0.296875, 0.0892333984375, -0.2283935546875, -0.6...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Tags: implementation Correct Solution: ``` I = lambda: map(int, input().split()) points = sum(max(150 * i, (500 - 2 * m) * i - 50 * w) for i, m, w in zip(range(1, 6), I(), I())) hs, hu = I() print(points + 100 * hs - 50 * hu) ```
60,215
[ 0.1890869140625, 0.053253173828125, -0.126220703125, 0.42724609375, -0.479248046875, -0.314208984375, -0.22998046875, 0.1575927734375, 0.1405029296875, 0.75927734375, 0.853515625, 0.0479736328125, 0.46630859375, -1.0546875, -0.326416015625, -0.10565185546875, -0.5576171875, -0.8266...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Tags: implementation Correct Solution: ``` x = [500, 1000, 1500, 2000, 2500] m = list(map(int, input().split())) w = list(map(int, input().split())) hs, hu = map(int, input().split()) s = 0 for i in range(len(x)): s += int(max(0.3*x[i], (250-m[i])*x[i]/250 - 50*w[i])) s += hs*100 s -= hu*50 print(s) ```
60,216
[ 0.1890869140625, 0.053253173828125, -0.126220703125, 0.42724609375, -0.479248046875, -0.314208984375, -0.22998046875, 0.1575927734375, 0.1405029296875, 0.75927734375, 0.853515625, 0.0479736328125, 0.46630859375, -1.0546875, -0.326416015625, -0.10565185546875, -0.5576171875, -0.8266...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Tags: implementation Correct Solution: ``` m = list(map(int, input().split())) w = list(map(int, input().split())) a = [500, 1000, 1500, 2000, 2500] v = list(map(int, input().split())) ans = 0 for i in range(len(m)): ans += max(0.3 * a[i], (1 - m[i] / 250) * a[i] - 50 * w[i]) ans += v[0] * 100 ans -= v[1] * 50 print(int(ans)) ```
60,217
[ 0.1890869140625, 0.053253173828125, -0.126220703125, 0.42724609375, -0.479248046875, -0.314208984375, -0.22998046875, 0.1575927734375, 0.1405029296875, 0.75927734375, 0.853515625, 0.0479736328125, 0.46630859375, -1.0546875, -0.326416015625, -0.10565185546875, -0.5576171875, -0.8266...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Tags: implementation Correct Solution: ``` def LM(): return list(map(int,input().split())) M = LM() W = LM() result = 0 for i in range(5): result += max(0.3*500*(i+1),(1-M[i]*1/250)*500*(i+1)-50*W[i]) hs, hw = map(int,input().split()) result += (100*hs - 50*hw) print(int(result)) ```
60,218
[ 0.1890869140625, 0.053253173828125, -0.126220703125, 0.42724609375, -0.479248046875, -0.314208984375, -0.22998046875, 0.1575927734375, 0.1405029296875, 0.75927734375, 0.853515625, 0.0479736328125, 0.46630859375, -1.0546875, -0.326416015625, -0.10565185546875, -0.5576171875, -0.8266...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Tags: implementation Correct Solution: ``` s1 = input() s2 = input() h,h1 = map(int,input().split()) a = s1.split(" ") b = s2.split(" ") a = [int(i) for i in a] b = [int(i) for i in b] r = 0 for i in range(5): x = 500*(i+1) r = r+ max(.3*x,(1-a[i]/250)*x-50*b[i]) r = r+100*h-50*h1 print (int(r)) ```
60,219
[ 0.1890869140625, 0.053253173828125, -0.126220703125, 0.42724609375, -0.479248046875, -0.314208984375, -0.22998046875, 0.1575927734375, 0.1405029296875, 0.75927734375, 0.853515625, 0.0479736328125, 0.46630859375, -1.0546875, -0.326416015625, -0.10565185546875, -0.5576171875, -0.8266...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Tags: implementation Correct Solution: ``` M = list(map(int,input().split())) W = list(map(int,input().split())) t,f = map(int,input().split()) X = 0 for i in range(5): x = (i + 1)*500 X += max(0.3*x, (1 - M[i]/250)*x - 50*W[i]) X += t*100 - f*50 print(int(X)) ```
60,220
[ 0.1890869140625, 0.053253173828125, -0.126220703125, 0.42724609375, -0.479248046875, -0.314208984375, -0.22998046875, 0.1575927734375, 0.1405029296875, 0.75927734375, 0.853515625, 0.0479736328125, 0.46630859375, -1.0546875, -0.326416015625, -0.10565185546875, -0.5576171875, -0.8266...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Tags: implementation Correct Solution: ``` def main(): res = sum(max(75 * x, (250 - m) * x - 50 * w) for x, m, w in zip( (2, 4, 6, 8, 10), map(int, input().split()), map(int, input().split()))) hs, hu = map(int, input().split()) print(res + hs * 100 - hu * 50) if __name__ == '__main__': main() ```
60,221
[ 0.1890869140625, 0.053253173828125, -0.126220703125, 0.42724609375, -0.479248046875, -0.314208984375, -0.22998046875, 0.1575927734375, 0.1405029296875, 0.75927734375, 0.853515625, 0.0479736328125, 0.46630859375, -1.0546875, -0.326416015625, -0.10565185546875, -0.5576171875, -0.8266...
11
Provide tags and a correct Python 3 solution for this coding contest problem. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Tags: implementation Correct Solution: ``` def score(value,time,wrongAnswer): return max(.3*value,(1-time/250.0)*value-(50 * wrongAnswer)) def actualScore(): times=input().split() times=list(map(int,times)) wrongAnswer=input().split() wrongAnswer=list(map(int,wrongAnswer)) temp=input().split() temp=list(map(int,temp)) total=0 for problem in range(len(times)): total+=score(500*(problem+1),times[problem],wrongAnswer[problem]) total+=100*int(temp[0]) total-=50*int(temp[1]) return int(total) print(actualScore()) ```
60,222
[ 0.1890869140625, 0.053253173828125, -0.126220703125, 0.42724609375, -0.479248046875, -0.314208984375, -0.22998046875, 0.1575927734375, 0.1405029296875, 0.75927734375, 0.853515625, 0.0479736328125, 0.46630859375, -1.0546875, -0.326416015625, -0.10565185546875, -0.5576171875, -0.8266...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Submitted Solution: ``` mi = map(int, input().split()) minutes = list(mi) wr = map(int, input().split()) wrong = list(wr) hs, hu = map(int, input().split()) max_point = [500, 1000, 1500, 2000, 2500] score = 0 def Score_law(x, m, w) : fir = 0.3 * x sec = abs( ( (1 - (m / 250)) * x ) ) - (50 * w) law = max(fir, sec) return law def getHacks(hs, hu) : suc_hack = hs * 100 unsuc_hack = hu * 50 hack_score = suc_hack - unsuc_hack return hack_score for i in range(5) : x = max_point[i] m = minutes[i] w = wrong[i] score += Score_law(x, m, w) hack_score = getHacks(hs, hu) total_Score = int(score + hack_score) print(total_Score) ``` Yes
60,223
[ 0.30908203125, 0.150634765625, -0.12030029296875, 0.38916015625, -0.55908203125, -0.2330322265625, -0.26708984375, 0.2421875, 0.023101806640625, 0.7216796875, 0.759765625, 0.07861328125, 0.42529296875, -0.98388671875, -0.340087890625, -0.10125732421875, -0.57763671875, -0.737792968...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Submitted Solution: ``` def main(): minutos = [int(x) for x in input().split()] erradas = [int(x) for x in input().split()] Hs, Hf = [int(x) for x in input().split()] x = [500, 1000, 1500, 2000, 2500] soma = sum([max(0.3*x[i], (1 - minutos[i]/250)*x[i] - 50*erradas[i]) for i in range(5)]) score = soma + Hs*100 - Hf*50 print(int(score)) main() ``` Yes
60,224
[ 0.30908203125, 0.150634765625, -0.12030029296875, 0.38916015625, -0.55908203125, -0.2330322265625, -0.26708984375, 0.2421875, 0.023101806640625, 0.7216796875, 0.759765625, 0.07861328125, 0.42529296875, -0.98388671875, -0.340087890625, -0.10125732421875, -0.57763671875, -0.737792968...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Submitted Solution: ``` def scanf(): inp = list(map(int, input().split(' '))) if len(inp) == 1: return inp[0] return inp m = scanf() wa = scanf() sh, uh = scanf() score = sh * 100 + uh * (-50) x = [500, 1000, 1500, 2000, 2500] for i in range(5): score += (max((0.3 * x[i]), ((1-m[i]/250)*x[i]) - 50*wa[i])) print(int(score)) ``` Yes
60,225
[ 0.30908203125, 0.150634765625, -0.12030029296875, 0.38916015625, -0.55908203125, -0.2330322265625, -0.26708984375, 0.2421875, 0.023101806640625, 0.7216796875, 0.759765625, 0.07861328125, 0.42529296875, -0.98388671875, -0.340087890625, -0.10125732421875, -0.57763671875, -0.737792968...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Submitted Solution: ``` import sys m = list(map(int,input().split())) w = list(map(int,input().split())) hs,hu = map(int,input().split()) point = [500,1000,1500,2000,2500] res = 0 for i in range(5): res += max(0.3*point[i],((1- (m[i]/250) )*point[i] - 50*w[i])) res += hs*100 - hu*50 print(int(res)) ``` Yes
60,226
[ 0.30908203125, 0.150634765625, -0.12030029296875, 0.38916015625, -0.55908203125, -0.2330322265625, -0.26708984375, 0.2421875, 0.023101806640625, 0.7216796875, 0.759765625, 0.07861328125, 0.42529296875, -0.98388671875, -0.340087890625, -0.10125732421875, -0.57763671875, -0.737792968...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Submitted Solution: ``` m = list(map(int, input().split())) w = list(map(int, input().split())) h = list(map(int, input().split())) x = sum([max(0.3 * x * 500, ((1 - (t / 250)) * x * 500) - (50 * a)) for x, t, a in zip(range(1, 6), m, w)]) + ( h[0] * 100) + (h[1] * 50) print(int(x)) ``` No
60,227
[ 0.30908203125, 0.150634765625, -0.12030029296875, 0.38916015625, -0.55908203125, -0.2330322265625, -0.26708984375, 0.2421875, 0.023101806640625, 0.7216796875, 0.759765625, 0.07861328125, 0.42529296875, -0.98388671875, -0.340087890625, -0.10125732421875, -0.57763671875, -0.737792968...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Submitted Solution: ``` m = list(map(int, input().split())) w = list(map(int, input().split())) hs, hu = map(int, input().split()) s = 0 for i in range(5): t = 500 * (i + 1) s += max(0.3 * t, (1 - m[i] // 250) * t - 50 * w[i]) s += hs * 100 - hu * 50 print(s) ``` No
60,228
[ 0.30908203125, 0.150634765625, -0.12030029296875, 0.38916015625, -0.55908203125, -0.2330322265625, -0.26708984375, 0.2421875, 0.023101806640625, 0.7216796875, 0.759765625, 0.07861328125, 0.42529296875, -0.98388671875, -0.340087890625, -0.10125732421875, -0.57763671875, -0.737792968...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Submitted Solution: ``` get_grade = lambda x, m, w:max( round(0.3*x), round((1 - m/250) * x - 50*w)) m1, m2, m3, m4, m5 = map(int, input().split(" ")) w1, w2, w3, w4, w5 = map(int, input().split(" ")) hs, hu = map(int, input().split(" ")) result = 100 * hs - 20 * hu result += get_grade( 500, m1, w1) result += get_grade( 1000, m2, w2) result += get_grade( 1500, m3, w3) result += get_grade( 2000, m4, w4) result += get_grade( 2500, m5, w5) print(result) ``` No
60,229
[ 0.30908203125, 0.150634765625, -0.12030029296875, 0.38916015625, -0.55908203125, -0.2330322265625, -0.26708984375, 0.2421875, 0.023101806640625, 0.7216796875, 0.759765625, 0.07861328125, 0.42529296875, -0.98388671875, -0.340087890625, -0.10125732421875, -0.57763671875, -0.737792968...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging tasks, Kevin was uncowed and bulldozed through all of them, distinguishing himself from the herd as the best cowmputer scientist in all of Bovinia. Kevin knows his submission time for each problem, the number of wrong submissions that he made on each problem, and his total numbers of successful and unsuccessful hacks. Because Codeforces scoring is complicated, Kevin wants you to write a program to compute his final score. Codeforces scores are computed as follows: If the maximum point value of a problem is x, and Kevin submitted correctly at minute m but made w wrong submissions, then his score on that problem is <image>. His total score is equal to the sum of his scores for each problem. In addition, Kevin's total score gets increased by 100 points for each successful hack, but gets decreased by 50 points for each unsuccessful hack. All arithmetic operations are performed with absolute precision and no rounding. It is guaranteed that Kevin's final score is an integer. Input The first line of the input contains five space-separated integers m1, m2, m3, m4, m5, where mi (0 ≤ mi ≤ 119) is the time of Kevin's last submission for problem i. His last submission is always correct and gets accepted. The second line contains five space-separated integers w1, w2, w3, w4, w5, where wi (0 ≤ wi ≤ 10) is Kevin's number of wrong submissions on problem i. The last line contains two space-separated integers hs and hu (0 ≤ hs, hu ≤ 20), denoting the Kevin's numbers of successful and unsuccessful hacks, respectively. Output Print a single integer, the value of Kevin's final score. Examples Input 20 40 60 80 100 0 1 2 3 4 1 0 Output 4900 Input 119 119 119 119 119 0 0 0 0 0 10 0 Output 4930 Note In the second sample, Kevin takes 119 minutes on all of the problems. Therefore, he gets <image> of the points on each problem. So his score from solving problems is <image>. Adding in 10·100 = 1000 points from hacks, his total score becomes 3930 + 1000 = 4930. Submitted Solution: ``` m=[int(i) for i in input().split()] w=[int(i) for i in input().split()] h1,h2=map(int,input().split()) k=0 for i in range(5): k+=max(0.3*(i+1)*500,round((1-m[i]/250)*(i+1)*500)-50*w[i]) k+=h1*100-h2*50 print(k) ``` No
60,230
[ 0.30908203125, 0.150634765625, -0.12030029296875, 0.38916015625, -0.55908203125, -0.2330322265625, -0.26708984375, 0.2421875, 0.023101806640625, 0.7216796875, 0.759765625, 0.07861328125, 0.42529296875, -0.98388671875, -0.340087890625, -0.10125732421875, -0.57763671875, -0.737792968...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat. Constraints * 1 \leq N \leq 100 * |s| = N * s_i is `R` or `B`. Input Input is given from Standard Input in the following format: N s Output If there are more people wearing a red hat than there are people wearing a blue hat, print `Yes`; otherwise, print `No`. Examples Input 4 RRBR Output Yes Input 4 BRBR Output No Submitted Solution: ``` a=int(input()) n=input() print("Yes" if n.count("R")>n.count("B") else "No") ``` Yes
60,455
[ 0.494140625, -0.202880859375, -0.294921875, 0.050048828125, -0.1689453125, -0.34912109375, -0.0693359375, 0.072509765625, 0.1728515625, 0.8486328125, 0.69580078125, -0.11224365234375, 0.46435546875, -0.64404296875, -0.2685546875, -0.2330322265625, -0.615234375, -0.3818359375, 0.0...
11
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat. Constraints * 1 \leq N \leq 100 * |s| = N * s_i is `R` or `B`. Input Input is given from Standard Input in the following format: N s Output If there are more people wearing a red hat than there are people wearing a blue hat, print `Yes`; otherwise, print `No`. Examples Input 4 RRBR Output Yes Input 4 BRBR Output No Submitted Solution: ``` a = input() b = input() if b.count('R') > b.count('B'): print('Yes') else: print('No') ``` Yes
60,456
[ 0.48974609375, -0.195556640625, -0.275634765625, 0.041778564453125, -0.1719970703125, -0.356689453125, -0.05218505859375, 0.063232421875, 0.172119140625, 0.86083984375, 0.6689453125, -0.10931396484375, 0.4560546875, -0.64013671875, -0.27490234375, -0.2479248046875, -0.5888671875, -...
11