output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print `-1` instead. * * *
s124760218
Runtime Error
p03806
The input is given from Standard Input in the following format: N M_a M_b a_1 b_1 c_1 a_2 b_2 c_2 : a_N b_N c_N
from itertools import combinations from bisect import bisect_left N, Ma, Mb = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(N)] A1 = A[: N // 2] # N//2 A2 = A[N // 2 :] # N-N//2 B1 = [] for k in range(1, N // 2 + 1): for x in combinations(range(N // 2), k): cnt1 = 0 cnt2 = 0 for i in x: cnt1 += Ma * A1[i][1] - Mb * A1[i][0] cnt2 += A1[i][2] B1.append((cnt1, cnt2)) B2 = [] for k in range(1, N - N // 2 + 1): for x in combinations(range(N - N // 2), k): cnt1 = 0 cnt2 = 0 for i in x: cnt1 += Ma * A2[i][1] - Mb * A2[i][0] cnt2 += A2[i][2] B2.append((cnt1, cnt2)) B1 = sorted(B1, key=lambda x: x[1]) B1 = sorted(B1, key=lambda x: x[0]) B2 = sorted(B2, key=lambda x: x[1]) B2 = sorted(B2, key=lambda x: x[0]) cmin = 10000 for b1 in B1: b, c = b1[0], b1[1] ind = bisect_left(B2, (-b, 0)) if B2[ind][0] == -b: cmin = min(cmin, c + B2[ind][1]) if cmin >= 10000: print(-1) else: print(cmin)
Statement Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy. The pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock. The package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan). Dolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C. Find the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.
[{"input": "3 1 1\n 1 2 1\n 2 1 2\n 3 3 10", "output": "3\n \n\nThe amount of money spent will be minimized by purchasing the packages of\nchemicals 1 and 2. \nIn this case, the mixture of the purchased chemicals will contain 3 grams of\nthe substance A and 3 grams of the substance B, which are in the desired\nratio: 3:3=1:1. \nThe total price of these packages is 3 yen.\n\n* * *"}, {"input": "1 1 10\n 10 10 10", "output": "-1\n \n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing\nany combination of the packages. Thus, the output should be `-1`."}]
Print the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print `-1` instead. * * *
s631193967
Runtime Error
p03806
The input is given from Standard Input in the following format: N M_a M_b a_1 b_1 c_1 a_2 b_2 c_2 : a_N b_N c_N
k, a, b = map(int, input().split()) item = [list(map(int, input().split())) for i in range(k)] n = len(item) cost_list = [] for i in range(2**n): bag = [] for j in range(n): # このループが一番のポイント if (i >> j) & 1: # 順に右にシフトさせ最下位bitのチェックを行う bag.append(item[j]) # フラグが立っていたら bag に果物を詰める drag_a = 0 drag_b = 0 cost = 0 for var in bag: drag_a += var[0] drag_b += var[1] cost += var[2] if drag_a * b == drag_b * a: cost_list.append(cost) cost_list.remove(0) print(min(cost_list))
Statement Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy. The pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock. The package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan). Dolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C. Find the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.
[{"input": "3 1 1\n 1 2 1\n 2 1 2\n 3 3 10", "output": "3\n \n\nThe amount of money spent will be minimized by purchasing the packages of\nchemicals 1 and 2. \nIn this case, the mixture of the purchased chemicals will contain 3 grams of\nthe substance A and 3 grams of the substance B, which are in the desired\nratio: 3:3=1:1. \nThe total price of these packages is 3 yen.\n\n* * *"}, {"input": "1 1 10\n 10 10 10", "output": "-1\n \n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing\nany combination of the packages. Thus, the output should be `-1`."}]
Print the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print `-1` instead. * * *
s328010888
Wrong Answer
p03806
The input is given from Standard Input in the following format: N M_a M_b a_1 b_1 c_1 a_2 b_2 c_2 : a_N b_N c_N
def checker(d, ds, p): if len(ds) == 0: return (False, 0) b = ds[0] d2 = d[:] # use b d[0] += b[0] d[1] += b[1] d[2] += b[2] c = 0 res = False if d[0] / d[1] != p: res, c = checker(d, ds[1:], p) else: res = True c = d[2] # no use res2, c2 = checker(d2, ds[1:], p) if res and res2: if d[2] < d2[2]: return (True, c) else: return (True, c2) elif res: return (True, c) elif res2: return (True, c2) return (False, 0) n = list(map(int, input().split())) p = n[1] / n[2] n = n[0] ds = [] for i in range(0, n): ds.append(list(map(int, input().split()))) arg = [0, 0, 0] res, c = checker(arg, ds, p) if res: print(str(c)) else: print("-1")
Statement Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy. The pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock. The package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan). Dolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C. Find the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.
[{"input": "3 1 1\n 1 2 1\n 2 1 2\n 3 3 10", "output": "3\n \n\nThe amount of money spent will be minimized by purchasing the packages of\nchemicals 1 and 2. \nIn this case, the mixture of the purchased chemicals will contain 3 grams of\nthe substance A and 3 grams of the substance B, which are in the desired\nratio: 3:3=1:1. \nThe total price of these packages is 3 yen.\n\n* * *"}, {"input": "1 1 10\n 10 10 10", "output": "-1\n \n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing\nany combination of the packages. Thus, the output should be `-1`."}]
Print the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print `-1` instead. * * *
s873520520
Wrong Answer
p03806
The input is given from Standard Input in the following format: N M_a M_b a_1 b_1 c_1 a_2 b_2 c_2 : a_N b_N c_N
n, aa, bb = map(int, input().split()) lis = [list(map(int, input().split())) for i in range(n)] print(lis) ans = -1 for i in range(1, 2**n): i = list(str(bin(i))) madea = 0 madeb = 0 c = 0 for j in range(2, len(i)): if int(i[j]) == 1: madea = madea + lis[j - 2][0] madeb = madeb + lis[j - 2][1] c = c + lis[j - 2][2] if madea * bb == madeb * aa and ans == -1: ans = c if madea * bb == madeb * aa and ans > c: ans = c print(ans)
Statement Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy. The pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock. The package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan). Dolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C. Find the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.
[{"input": "3 1 1\n 1 2 1\n 2 1 2\n 3 3 10", "output": "3\n \n\nThe amount of money spent will be minimized by purchasing the packages of\nchemicals 1 and 2. \nIn this case, the mixture of the purchased chemicals will contain 3 grams of\nthe substance A and 3 grams of the substance B, which are in the desired\nratio: 3:3=1:1. \nThe total price of these packages is 3 yen.\n\n* * *"}, {"input": "1 1 10\n 10 10 10", "output": "-1\n \n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing\nany combination of the packages. Thus, the output should be `-1`."}]
Print the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print `-1` instead. * * *
s272703406
Accepted
p03806
The input is given from Standard Input in the following format: N M_a M_b a_1 b_1 c_1 a_2 b_2 c_2 : a_N b_N c_N
from subprocess import * call( ( "pypy3", "-c", """ I=lambda:list(map(int,input().split())) n,Ma,Mb=I() m=[[0,0,0]]+[I()for _ in range(n)] dp=[[[10**18]*(10*n+1)for _ in range(10*n+1)]for _ in range(n+1)] dp[0][0][0]=0 for i in range(1,n+1): for j in range(10*n+1): if j-m[i][0]<0: dp[i][j]=dp[i-1][j] continue for k in range(10*n+1): if k-m[i][1]<0: dp[i][j][k]=dp[i-1][j][k] else: dp[i][j][k]=min(dp[i-1][j-m[i][0]][k-m[i][1]]+m[i][2],dp[i-1][j][k]) ans=10**18 for i in range(1,10*n+1): j=Mb*i/Ma if j==int(j) and j<10*n+2: ans=min(ans,dp[-1][i][int(j)]) print(-(ans==10**18)or ans) """, ) )
Statement Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy. The pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock. The package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan). Dolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C. Find the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.
[{"input": "3 1 1\n 1 2 1\n 2 1 2\n 3 3 10", "output": "3\n \n\nThe amount of money spent will be minimized by purchasing the packages of\nchemicals 1 and 2. \nIn this case, the mixture of the purchased chemicals will contain 3 grams of\nthe substance A and 3 grams of the substance B, which are in the desired\nratio: 3:3=1:1. \nThe total price of these packages is 3 yen.\n\n* * *"}, {"input": "1 1 10\n 10 10 10", "output": "-1\n \n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing\nany combination of the packages. Thus, the output should be `-1`."}]
Print the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print `-1` instead. * * *
s144710933
Accepted
p03806
The input is given from Standard Input in the following format: N M_a M_b a_1 b_1 c_1 a_2 b_2 c_2 : a_N b_N c_N
# -*- coding: utf-8 -*- ############# # Libraries # ############# import sys input = sys.stdin.readline import math # from math import gcd import bisect import heapq from collections import defaultdict from collections import deque from collections import Counter from functools import lru_cache ############# # Constants # ############# MOD = 10**9 + 7 INF = float("inf") AZ = "abcdefghijklmnopqrstuvwxyz" ############# # Functions # ############# ######INPUT###### def I(): return int(input().strip()) def S(): return input().strip() def IL(): return list(map(int, input().split())) def SL(): return list(map(str, input().split())) def ILs(n): return list(int(input()) for _ in range(n)) def SLs(n): return list(input().strip() for _ in range(n)) def ILL(n): return [list(map(int, input().split())) for _ in range(n)] def SLL(n): return [list(map(str, input().split())) for _ in range(n)] #####Shorten##### def DD(arg): return defaultdict(arg) #####Inverse##### def inv(n): return pow(n, MOD - 2, MOD) ######Combination###### kaijo_memo = [] def kaijo(n): if len(kaijo_memo) > n: return kaijo_memo[n] if len(kaijo_memo) == 0: kaijo_memo.append(1) while len(kaijo_memo) <= n: kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD) return kaijo_memo[n] gyaku_kaijo_memo = [] def gyaku_kaijo(n): if len(gyaku_kaijo_memo) > n: return gyaku_kaijo_memo[n] if len(gyaku_kaijo_memo) == 0: gyaku_kaijo_memo.append(1) while len(gyaku_kaijo_memo) <= n: gyaku_kaijo_memo.append( gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD ) return gyaku_kaijo_memo[n] def nCr(n, r): if n == r: return 1 if n < r or r < 0: return 0 ret = 1 ret = ret * kaijo(n) % MOD ret = ret * gyaku_kaijo(r) % MOD ret = ret * gyaku_kaijo(n - r) % MOD return ret ######Factorization###### def factorization(n): arr = [] temp = n for i in range(2, int(-(-(n**0.5) // 1)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i arr.append([i, cnt]) if temp != 1: arr.append([temp, 1]) if arr == []: arr.append([n, 1]) return arr #####MakeDivisors###### def make_divisors(n): divisors = [] for i in range(1, int(n**0.5) + 1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n // i) return divisors #####MakePrimes###### def make_primes(N): max = int(math.sqrt(N)) seachList = [i for i in range(2, N + 1)] primeNum = [] while seachList[0] <= max: primeNum.append(seachList[0]) tmp = seachList[0] seachList = [i for i in seachList if i % tmp != 0] primeNum.extend(seachList) return primeNum #####GCD##### def gcd(a, b): while b: a, b = b, a % b return a #####LCM##### def lcm(a, b): return a * b // gcd(a, b) #####BitCount##### def count_bit(n): count = 0 while n: n &= n - 1 count += 1 return count #####ChangeBase##### def base_10_to_n(X, n): if X // n: return base_10_to_n(X // n, n) + [X % n] return [X % n] def base_n_to_10(X, n): return sum(int(str(X)[-i - 1]) * n**i for i in range(len(str(X)))) def base_10_to_n_without_0(X, n): X -= 1 if X // n: return base_10_to_n_without_0(X // n, n) + [X % n] return [X % n] #####IntLog##### def int_log(n, a): count = 0 while n >= a: n //= a count += 1 return count ############# # Main Code # ############# from fractions import Fraction N, A, B = IL() data = ILL(N) P = [] M = [] Z = [] for a, b, c in data: if Fraction(a, b) == Fraction(A, B): Z.append(c) elif Fraction(a, b) > Fraction(A, B): P.append((a * 2520 - b * 2520 * A // B, c)) else: M.append((-a * 2520 + b * 2520 * A // B, c)) dpP = [INF for i in range(1000000)] dpP[0] = 0 for v, c in P: for i in range(1000000)[::-1]: if i >= v: dpP[i] = min(dpP[i], dpP[i - v] + c) dpM = [INF for i in range(1000000)] dpM[0] = 0 for v, c in M: for i in range(1000000)[::-1]: if i >= v: dpM[i] = min(dpM[i], dpM[i - v] + c) ans = INF if Z: ans = min(Z) for i in range(1, 1000000): ans = min(ans, dpP[i] + dpM[i]) if ans == INF: print(-1) else: print(ans)
Statement Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy. The pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock. The package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan). Dolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C. Find the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.
[{"input": "3 1 1\n 1 2 1\n 2 1 2\n 3 3 10", "output": "3\n \n\nThe amount of money spent will be minimized by purchasing the packages of\nchemicals 1 and 2. \nIn this case, the mixture of the purchased chemicals will contain 3 grams of\nthe substance A and 3 grams of the substance B, which are in the desired\nratio: 3:3=1:1. \nThe total price of these packages is 3 yen.\n\n* * *"}, {"input": "1 1 10\n 10 10 10", "output": "-1\n \n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing\nany combination of the packages. Thus, the output should be `-1`."}]
Print the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print `-1` instead. * * *
s401418948
Wrong Answer
p03806
The input is given from Standard Input in the following format: N M_a M_b a_1 b_1 c_1 a_2 b_2 c_2 : a_N b_N c_N
import random import bisect import math nn, ma, mb = [int(i) for i in input().split()] a = [0 for i in range(nn)] b = [0 for i in range(nn)] c = [0 for i in range(nn)] for i in range(nn): a[i], b[i], c[i] = [int(i) for i in input().split()] option = 0 # 0:PSO 1:CFA 2:CFArank max_or_min = 0 # 0:minimize 1:maxmize dimension = nn iter = 1 N = 50 # 粒子の数 T = 1200 # 世代数(ループの回数) maximum = 1 minimum = 0 # --------粒 子 群 最 適 化------------------------------ # 評価関数 def criterion(x): z = sum([c[i] * x[i] for i in range(dimension)]) if ( mb * sum([a[i] * x[i] for i in range(dimension)]) - ma * sum([b[i] * x[i] for i in range(dimension)]) != 0 or sum(x) == 0 ): z = 1000000 return z # 粒子の位置の更新を行う関数 def update_position(x, v, x_min, x_max): # new_x = [x_min[i] if x[i]+ v[i] < x_min[i] else x_max[i] if x[i]+ v[i] > x_max[i] else x[i]+ v[i] for i in range(dimension)] new_x = [ 1 if random.uniform(0, 1) < 1 / (1 + math.e ** (-v[i])) else 0 for i in range(dimension) ] return new_x # 粒子の速度の更新を行う関数 def update_velocity(x, v, p, g, w, ro_max=1.0, c1=2.00, c2=0.75): # パラメーターroはランダムに与える phi = c1 + c2 K = 2 / abs(2 - phi - (phi * phi - 4 * phi) ** 0.5) # 粒子速度の更新を行う if option != 0: new_v = [ K * ( w * v[i] + c1 * random.uniform(0, ro_max) * (p[i] - x[i]) + c2 * random.uniform(0, ro_max) * (g[i] - x[i]) ) for i in range(dimension) ] else: new_v = [ w * v[i] + c1 * random.uniform(0, ro_max) * (p[i] - x[i]) + c2 * random.uniform(0, ro_max) * (g[i] - x[i]) for i in range(dimension) ] return new_v def main(): w = 1.0 w_best, w_worst = 1.25, 0.25 x_min = [minimum for i in range(dimension)] x_max = [maximum for i in range(dimension)] # 粒子位置, 速度, パーソナルベスト, グローバルベストの初期化を行う ps = [ [random.randint(x_min[j], x_max[j]) for j in range(dimension)] for i in range(N) ] vs = [[0.0 for j in range(dimension)] for i in range(N)] personal_best_positions = ps[:] personal_best_scores = [criterion(p) for p in ps] if max_or_min == 1: best_particle = personal_best_scores.index(max(personal_best_scores)) elif max_or_min == 0: best_particle = personal_best_scores.index(min(personal_best_scores)) global_best_position = personal_best_positions[best_particle][:] for t in range(T): for n in range(N): x = ps[n][:] v = vs[n][:] p = personal_best_positions[n][:] if option >= 2: best_list = sorted(personal_best_positions) mu = bisect.bisect_left(best_list, p) + 1 w = w_best - mu * (w_best - w_worst) / (N - 1) # 粒子の位置の更新を行う new_x = update_position(x, v, x_min, x_max) ps[n] = new_x[:] # 粒子の速度の更新を行う new_v = update_velocity(new_x, v, p, global_best_position, w) vs[n] = new_v[:] # 評価値を求め, パーソナルベストの更新を行う score = criterion(new_x) if max_or_min == 1: if score > personal_best_scores[n]: personal_best_scores[n] = score personal_best_positions[n] = new_x[:] elif max_or_min == 0: if score < personal_best_scores[n]: personal_best_scores[n] = score personal_best_positions[n] = new_x[:] # グローバルベストの更新を行う if max_or_min == 1: best_particle = personal_best_scores.index(max(personal_best_scores)) global_best_position = personal_best_positions[best_particle][:] elif max_or_min == 0: best_particle = personal_best_scores.index(min(personal_best_scores)) global_best_position = personal_best_positions[best_particle][:] f.write(str(max(personal_best_scores)) + "\n") # 最適解 if max_or_min == 1: return max(personal_best_scores) elif max_or_min == 0: # print(global_best_position) return min(personal_best_scores) # -------------------------------------------------------------- with open("test_" + str(option) + ".txt", "w") as f: if max_or_min == 1: best = -float("inf") for i in range(iter): best = max(best, main()) elif max_or_min == 0: best = float("inf") for i in range(iter): best = min(best, main()) if best == 1000000: print(-1) else: print(best)
Statement Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy. The pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock. The package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan). Dolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C. Find the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.
[{"input": "3 1 1\n 1 2 1\n 2 1 2\n 3 3 10", "output": "3\n \n\nThe amount of money spent will be minimized by purchasing the packages of\nchemicals 1 and 2. \nIn this case, the mixture of the purchased chemicals will contain 3 grams of\nthe substance A and 3 grams of the substance B, which are in the desired\nratio: 3:3=1:1. \nThe total price of these packages is 3 yen.\n\n* * *"}, {"input": "1 1 10\n 10 10 10", "output": "-1\n \n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing\nany combination of the packages. Thus, the output should be `-1`."}]
Print the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print `-1` instead. * * *
s480990912
Accepted
p03806
The input is given from Standard Input in the following format: N M_a M_b a_1 b_1 c_1 a_2 b_2 c_2 : a_N b_N c_N
n, p, q = map(int, input().split()) M2 = -10 * (-n // 2) M1 = 10 * (n // 2) dp1 = [[float("INF")] * (M1 + 1) for i in range(M1 + 1)] dp1[0][0] = 0 for _ in range(n // 2): a, b, c = map(int, input().split()) for i in range(M1, a - 1, -1): for j in range(M1, b - 1, -1): dp1[i][j] = min(dp1[i][j], dp1[i - a][j - b] + c) dp2 = [[float("INF")] * (M2 + 1) for i in range(M2 + 1)] dp2[0][0] = 0 for _ in range(-(-n // 2)): a, b, c = map(int, input().split()) for i in range(M2, a - 1, -1): for j in range(M2, b - 1, -1): dp2[i][j] = min(dp2[i][j], dp2[i - a][j - b] + c) ans = float("INf") for i in range(M1 + 1): for j in range(M1 + 1): for c in range(max(1, -min(-i // p, -j // q)), M2 // max(p, q) + 1): ans = min(ans, dp1[i][j] + dp2[c * p - i][c * q - j]) print(ans if ans != float("INF") else -1)
Statement Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy. The pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock. The package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan). Dolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C. Find the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.
[{"input": "3 1 1\n 1 2 1\n 2 1 2\n 3 3 10", "output": "3\n \n\nThe amount of money spent will be minimized by purchasing the packages of\nchemicals 1 and 2. \nIn this case, the mixture of the purchased chemicals will contain 3 grams of\nthe substance A and 3 grams of the substance B, which are in the desired\nratio: 3:3=1:1. \nThe total price of these packages is 3 yen.\n\n* * *"}, {"input": "1 1 10\n 10 10 10", "output": "-1\n \n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing\nany combination of the packages. Thus, the output should be `-1`."}]
Print the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print `-1` instead. * * *
s883166282
Runtime Error
p03806
The input is given from Standard Input in the following format: N M_a M_b a_1 b_1 c_1 a_2 b_2 c_2 : a_N b_N c_N
N, Ma, Mb = map(int, input().split()) items = [] mas = [] mbs = [] costs = [] for i in range(N): ma, mb, c = map(int, input().split()) mas.append(ma) mbs.append(mb) costs.append(c) max_cost = 5000 dp = [[[max_cost for k in range(410)] for j in range(410)] for i in range(41)] for i in range(N): for j in range(400): for k in range(400): if dp[i][j][k] == max_cost: continue if dp[i][j][k] > dp[i+1][j][k]: dp[i][j][k] = dp[i+1][j][k] if dp[i+1][j+mas[i]][k+mbs[i]] > dp[i][j][k] + costs[i]: dp[i+1][j+mas[i]][k+mbs[i]] = dp[i][j][k] + costs[i] min_cost = 1000000000000000000 for (int wa = 1; wa < 400; ++wa) : for (int wb = 1; wb < 400; ++wb) : if (wa * mb != wb * ma): continue; if min_cost > dp[N][wa][wb]: min_cost = dp[N][wa][wb] if min_cost == 1000000000000000000: print("-1") else: print(min_cost)
Statement Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy. The pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock. The package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan). Dolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C. Find the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.
[{"input": "3 1 1\n 1 2 1\n 2 1 2\n 3 3 10", "output": "3\n \n\nThe amount of money spent will be minimized by purchasing the packages of\nchemicals 1 and 2. \nIn this case, the mixture of the purchased chemicals will contain 3 grams of\nthe substance A and 3 grams of the substance B, which are in the desired\nratio: 3:3=1:1. \nThe total price of these packages is 3 yen.\n\n* * *"}, {"input": "1 1 10\n 10 10 10", "output": "-1\n \n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing\nany combination of the packages. Thus, the output should be `-1`."}]
Print the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print `-1` instead. * * *
s080951486
Runtime Error
p03806
The input is given from Standard Input in the following format: N M_a M_b a_1 b_1 c_1 a_2 b_2 c_2 : a_N b_N c_N
import sys def debug(x, table): for name, val in table.items(): if x is val: print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr) return None def solve(): N, Ma, Mb = map(int, input().split()) a_w = [] b_w = [] costs = [] for i in range(N): a, b, c = map(int, input().split()) a_w.append(a) b_w.append(b) costs.append(c) dp = [[[-1]*(10*N + 1) for j in range(10*N + 1)] for k in range(2)] dp[0][0][0] = 0 dp[1][0][0] = 0 for i in range(N): for a in range(10*N + 1): for b in range(10*N + 1): if a - a_w[i] >= 0 and b - b_w[i] >= 0: if dp[0][a - a_w[i]][b - b_w[i]] >= 0: if dp[1][a][b] == -1: dp[1][a][b]= dp[0][a - a_w[i]][b - b_w[i]] + costs[i] else: min_ = min(dp[1][a][b], dp[0][a - a_w[i]][b - b_w[i]] + costs[i]) dp[1][a][b] = min_ for k in range(10*N + 1): dp[0][k] = dp[1][k][:] for i in range(10*N + 1): # print(*dp[0][i], file=sys.stderr) min_cost = float('inf') for a in range(10*N + 1): for b in range(10*N + 1): if a != 0 and b != 0: if a * Mb == b * Ma and dp[1][a][b] > 0: min_cost = min(min_cost, dp[1][a][b]) if min_cost == float('inf'): ans = -1 else: ans = min_cost print(ans) if __name__ == '__main__': solve()
Statement Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy. The pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock. The package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan). Dolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C. Find the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.
[{"input": "3 1 1\n 1 2 1\n 2 1 2\n 3 3 10", "output": "3\n \n\nThe amount of money spent will be minimized by purchasing the packages of\nchemicals 1 and 2. \nIn this case, the mixture of the purchased chemicals will contain 3 grams of\nthe substance A and 3 grams of the substance B, which are in the desired\nratio: 3:3=1:1. \nThe total price of these packages is 3 yen.\n\n* * *"}, {"input": "1 1 10\n 10 10 10", "output": "-1\n \n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing\nany combination of the packages. Thus, the output should be `-1`."}]
Print the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print `-1` instead. * * *
s469564552
Runtime Error
p03806
The input is given from Standard Input in the following format: N M_a M_b a_1 b_1 c_1 a_2 b_2 c_2 : a_N b_N c_N
n,ma,mb=map(int,input().split()) lista=[] listb=[] listc=[] for i in range(n): a,b,c=map(int,input().split()) lista.append(a) listb.append(b) listc.append(c) dp=[[[float('inf') for i in range(n+1)]for i\ in range(sum(listb)+1)]for i in range(sum(lista)+1)] dp[0][0][0]=0 for i in range(1,n+1): for a in range(lista[i-1],sum(lista)+1): for b in range(listb[i-1],sum(listb)+1): dp[a][b][i]=min(dp[a][b][i-1],dp[a-lista[i-1]][b-listb[i-1]][i-1]+listc[i-1]) cost=float('inf') for a in range(1,sum(lista)): for b in range(1,sum(listb)): if a*mb==b*ma: cost=min(cost,dp[a][b][n]) if cost=float('inf'): print(-1) else: print(cost)
Statement Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy. The pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock. The package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan). Dolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C. Find the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.
[{"input": "3 1 1\n 1 2 1\n 2 1 2\n 3 3 10", "output": "3\n \n\nThe amount of money spent will be minimized by purchasing the packages of\nchemicals 1 and 2. \nIn this case, the mixture of the purchased chemicals will contain 3 grams of\nthe substance A and 3 grams of the substance B, which are in the desired\nratio: 3:3=1:1. \nThe total price of these packages is 3 yen.\n\n* * *"}, {"input": "1 1 10\n 10 10 10", "output": "-1\n \n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing\nany combination of the packages. Thus, the output should be `-1`."}]
Print the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C, print `-1` instead. * * *
s291411882
Runtime Error
p03806
The input is given from Standard Input in the following format: N M_a M_b a_1 b_1 c_1 a_2 b_2 c_2 : a_N b_N c_N
def solve(): INF = float('inf') N, Ma, Mb = map(int, input().split()) l = [] for _ in range(N): a,b,c = map(int, input().split()) l.append((a,b,c)) #dp table: dp[i][ca][cb] dp = [[[INF] * 401 for _ in range(401)] for _ in range(N+1)] dp[0][0][0] = 0 for i in range(N): for ca in range(401): for cb in range(401): if dp[i][a][b] != INF: dp[i+1][a][b] = min(dp[i][a][b], dp[i+1][a][b]) #薬品iを加えない場合 dp[i+1][a+l[i][0]][b+l[i][1]] = min(dp[i+1][a+l[i][0]][b+l[i][1]], dp[i][a][b] + l[i][2]) #薬品iを加える場合 ans = INF for i in range(N): for ca in range(401): for cb in range(401): if dp[i][a][b] != INF: if a * Mb == b * Ma: ans = min(ans, dp[i][a][b]) print(-1 if ans == INF else ans) if __name__ == '__main'__: solve()
Statement Dolphin is planning to generate a small amount of a certain chemical substance C. In order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b. He does not have any stock of chemicals, however, so he will purchase some chemicals at a local pharmacy. The pharmacy sells N kinds of chemicals. For each kind of chemical, there is exactly one package of that chemical in stock. The package of chemical i contains a_i grams of the substance A and b_i grams of the substance B, and is sold for c_i yen (the currency of Japan). Dolphin will purchase some of these packages. For some reason, he must use all contents of the purchased packages to generate the substance C. Find the minimum amount of money required to generate the substance C. If it is not possible to generate the substance C by purchasing any combination of packages at the pharmacy, report that fact.
[{"input": "3 1 1\n 1 2 1\n 2 1 2\n 3 3 10", "output": "3\n \n\nThe amount of money spent will be minimized by purchasing the packages of\nchemicals 1 and 2. \nIn this case, the mixture of the purchased chemicals will contain 3 grams of\nthe substance A and 3 grams of the substance B, which are in the desired\nratio: 3:3=1:1. \nThe total price of these packages is 3 yen.\n\n* * *"}, {"input": "1 1 10\n 10 10 10", "output": "-1\n \n\nThe ratio 1:10 of the two substances A and B cannot be satisfied by purchasing\nany combination of the packages. Thus, the output should be `-1`."}]
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
s837158473
Wrong Answer
p00729
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10. Each dataset is formatted as follows. > _N_ _M_ > _r_ > record1 > ... > record _r_ > _q_ > query1 > ... > query _q_ > The numbers _N_ and _M_ in the first line are the numbers of PCs and the students, respectively. _r_ is the number of records. _q_ is the number of queries. These four are integers satisfying the following. > 1 ≤ _N_ ≤ 1000, 1 ≤ _M_ ≤ 10000, 2 ≤ _r_ ≤ 1000, 1 ≤ _q_ ≤ 50 Each record consists of four integers, delimited by a space, as follows. > _t_ _n_ _m_ _s_ _s_ is 0 or 1. If _s_ is 1, this line means that the student _m_ logged in to the PC _n_ at time _t_ . If _s_ is 0, it means that the student _m_ logged out of the PC _n_ at time _t_ . The time is expressed as elapsed minutes from 0:00 of the day. _t_ , _n_ and _m_ satisfy the following. > 540 ≤ _t_ ≤ 1260, 1 ≤ _n_ ≤ _N_ , 1 ≤ _m_ ≤ _M_ You may assume the following about the records. * Records are stored in ascending order of time _t._ * No two records for the same PC has the same time _t._ * No PCs are being logged in before the time of the first record nor after that of the last record in the file. * Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student. Each query consists of three integers delimited by a space, as follows. > _t s_ _t e_ _m_ It represents "Usage of the student _m_ between _t s_ and _t e_ ". _t s_ , _t e_ and _m_ satisfy the following. > 540 ≤ _t s_ < _t e_ ≤ 1260, 1 ≤ _m_ ≤ _M_
# AOJ 1148: Analyzing Login/Logout Records # Python3 2018.7.17 bal4u while True: n, m = map(int, input().split()) if n == 0: break r = int(input()) rd = [list(map(int, input().split())) for i in range(r)] for i in range(int(input())): ts, te, tm = map(int, input().split()) ans = T = cnt = 0 for t, pc, m, s in rd: if t >= te: if T > 0: ans += te - T break if m != tm: continue if s: cnt += 1 if T == 0: T = ts if t < ts else t else: cnt -= 1 if cnt == 0: if t > ts and T > 0: ans += t - T T = 0 print(ans)
B: Analyzing Login/Logout Records You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet. You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file. The following are example login/logout records. * The student 1 logged in to the PC 1 at 12:55 * The student 2 logged in to the PC 4 at 13:00 * The student 1 logged in to the PC 2 at 13:10 * The student 1 logged out of the PC 2 at 13:20 * The student 1 logged in to the PC 3 at 13:30 * The student 1 logged out of the PC 1 at 13:40 * The student 1 logged out of the PC 3 at 13:45 * The student 1 logged in to the PC 1 at 14:20 * The student 2 logged out of the PC 4 at 14:30 * The student 1 logged out of the PC 1 at 14:40 For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_b)
[{"input": "2\n 10\n 775 1 1 1\n 780 4 2 1\n 790 2 1 1\n 800 2 1 0\n 810 3 1 1\n 820 1 1 0\n 825 3 1 0\n 860 1 1 1\n 870 4 2 0\n 880 1 1 0\n 1\n 780 870 1\n 13 15\n 12\n 540 12 13 1\n 600 12 13 0\n 650 13 15 1\n 660 12 15 1\n 665 11 13 1\n 670 13 15 0\n 675 11 13 0\n 680 12 15 0\n 1000 11 14 1\n 1060 12 14 1\n 1060 11 14 0\n 1080 12 14 0\n 3\n 540 700 13\n 600 1000 15\n 1000 1200 11\n 1 1\n 2\n 600 1 1 1\n 700 1 1 0\n 5\n 540 600 1\n 550 650 1\n 610 620 1\n 650 750 1\n 700 800 1\n 0 0", "output": "70\n 30\n 0\n 0\n 50\n 10\n 50\n 0"}]
For each query, print a line having a decimal integer indicating the time of usage in minutes. Output lines should not have any character other than this number.
s357386795
Wrong Answer
p00729
The input is a sequence of a number of datasets. The end of the input is indicated by a line containing two zeros separated by a space. The number of datasets never exceeds 10. Each dataset is formatted as follows. > _N_ _M_ > _r_ > record1 > ... > record _r_ > _q_ > query1 > ... > query _q_ > The numbers _N_ and _M_ in the first line are the numbers of PCs and the students, respectively. _r_ is the number of records. _q_ is the number of queries. These four are integers satisfying the following. > 1 ≤ _N_ ≤ 1000, 1 ≤ _M_ ≤ 10000, 2 ≤ _r_ ≤ 1000, 1 ≤ _q_ ≤ 50 Each record consists of four integers, delimited by a space, as follows. > _t_ _n_ _m_ _s_ _s_ is 0 or 1. If _s_ is 1, this line means that the student _m_ logged in to the PC _n_ at time _t_ . If _s_ is 0, it means that the student _m_ logged out of the PC _n_ at time _t_ . The time is expressed as elapsed minutes from 0:00 of the day. _t_ , _n_ and _m_ satisfy the following. > 540 ≤ _t_ ≤ 1260, 1 ≤ _n_ ≤ _N_ , 1 ≤ _m_ ≤ _M_ You may assume the following about the records. * Records are stored in ascending order of time _t._ * No two records for the same PC has the same time _t._ * No PCs are being logged in before the time of the first record nor after that of the last record in the file. * Login and logout records for one PC appear alternatingly, and each of the login-logout record pairs is for the same student. Each query consists of three integers delimited by a space, as follows. > _t s_ _t e_ _m_ It represents "Usage of the student _m_ between _t s_ and _t e_ ". _t s_ , _t e_ and _m_ satisfy the following. > 540 ≤ _t s_ < _t e_ ≤ 1260, 1 ≤ _m_ ≤ _M_
while True: N, M = [int(s) for s in input().strip().split()] if N == 0 and M == 0: break r = int(input().strip()) logs = [] for _ in range(r): t, n, m, s = [int(s) for s in input().strip().split()] logs.append((t, n, m, s)) q = int(input().strip()) for _ in range(q): ts, te, m = [int(s) for s in input().strip().split()] selected_logs = [log for log in logs if log[2] == m] used_time = 0 login_time = 2000 is_login_list = [False] * N for log in selected_logs: lt, ln, lm, ls = log ln -= 1 # ログアウト if ls == 0: # 観測開始前 if lt < ts: continue # 観測終了前 if lt < te: # 他のPCにログインしていたらそのPCのログアウトまで待つ other_pc_login = False for i, is_login in enumerate(is_login_list): if i == ln: continue if is_login: other_pc_login = True break if other_pc_login: is_login_list[ln] = False continue # ログイン時刻が観測開始前 if login_time < ts: used_time += lt - ts # ログイン時刻が観測開始後 else: used_time += lt - login_time # ログイン状態を解除 is_login_list[ln] = False continue # 観測終了後 else: if login_time < ts: used_time += te - ts else: used_time += te - login_time break # ログイン else: if lt > te: break is_login_list[ln] = True other_pc_login = False for i, is_login in enumerate(is_login_list): if i == ln: continue if is_login: other_pc_login = True break if not other_pc_login: login_time = lt print(used_time)
B: Analyzing Login/Logout Records You have a computer literacy course in your university. In the computer system, the login/logout records of all PCs in a day are stored in a file. Although students may use two or more PCs at a time, no one can log in to a PC which has been logged in by someone who has not logged out of that PC yet. You are asked to write a program that calculates the total time of a student that he/she used at least one PC in a given time period (probably in a laboratory class) based on the records in the file. The following are example login/logout records. * The student 1 logged in to the PC 1 at 12:55 * The student 2 logged in to the PC 4 at 13:00 * The student 1 logged in to the PC 2 at 13:10 * The student 1 logged out of the PC 2 at 13:20 * The student 1 logged in to the PC 3 at 13:30 * The student 1 logged out of the PC 1 at 13:40 * The student 1 logged out of the PC 3 at 13:45 * The student 1 logged in to the PC 1 at 14:20 * The student 2 logged out of the PC 4 at 14:30 * The student 1 logged out of the PC 1 at 14:40 For a query such as "Give usage of the student 1 between 13:00 and 14:30", your program should answer "55 minutes", that is, the sum of 45 minutes from 13:00 to 13:45 and 10 minutes from 14:20 to 14:30, as depicted in the following figure. ![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE1_b)
[{"input": "2\n 10\n 775 1 1 1\n 780 4 2 1\n 790 2 1 1\n 800 2 1 0\n 810 3 1 1\n 820 1 1 0\n 825 3 1 0\n 860 1 1 1\n 870 4 2 0\n 880 1 1 0\n 1\n 780 870 1\n 13 15\n 12\n 540 12 13 1\n 600 12 13 0\n 650 13 15 1\n 660 12 15 1\n 665 11 13 1\n 670 13 15 0\n 675 11 13 0\n 680 12 15 0\n 1000 11 14 1\n 1060 12 14 1\n 1060 11 14 0\n 1080 12 14 0\n 3\n 540 700 13\n 600 1000 15\n 1000 1200 11\n 1 1\n 2\n 600 1 1 1\n 700 1 1 0\n 5\n 540 600 1\n 550 650 1\n 610 620 1\n 650 750 1\n 700 800 1\n 0 0", "output": "70\n 30\n 0\n 0\n 50\n 10\n 50\n 0"}]
Print the number of triplets in question. * * *
s371978393
Accepted
p02714
Input is given from Standard Input in the following format: N S
# -*- coding: utf-8 -*- """ Created on Sun Apr 12 20:59:07 2020 @author: naoki """ N = int(input()) S = str(input()) Dp = [[0 for _ in range(3)] for _ in range(N)] if S[0] == "R": Dp[0][0] = 1 elif S[0] == "G": Dp[0][1] = 1 elif S[0] == "B": Dp[0][2] = 1 allcount = 0 for j in range(1, N): Dp[j][0] = Dp[j - 1][0] Dp[j][1] = Dp[j - 1][1] Dp[j][2] = Dp[j - 1][2] if S[j] == "R": Dp[j][0] += 1 allcount += Dp[j - 1][1] * Dp[j - 1][2] elif S[j] == "G": Dp[j][1] += 1 allcount += Dp[j - 1][0] * Dp[j - 1][2] elif S[j] == "B": Dp[j][2] += 1 allcount += Dp[j - 1][0] * Dp[j - 1][1] for j in range(1, N): for i in range(1, j): if j - i - i >= 0: if S[j - i] != S[j - 2 * i] and S[j - i] != S[j] and S[j - 2 * i] != S[j]: allcount -= 1 pass print(allcount)
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s515316766
Wrong Answer
p02714
Input is given from Standard Input in the following format: N S
N = int(input()) S = str(input()) print(S.count("RGB"))
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s021427093
Wrong Answer
p02714
Input is given from Standard Input in the following format: N S
N = input() S = {"R": [], "G": [], "B": []} for i, s in enumerate(input()): S[s].append(i) print(len(S["R"]) * len(S["G"]) * len(S["B"]) - 1)
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s399931659
Runtime Error
p02714
Input is given from Standard Input in the following format: N S
k = int(input()) l = [ 1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692, ] print(l[k - 1])
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s459645258
Runtime Error
p02714
Input is given from Standard Input in the following format: N S
N = int(input()) S = input() RGB = [[] for i in range(3)] for i in range(N): if S[i] == "R": RGB[0].append(i) elif S[i] == "G": RGB[1].append(i) elif S[i] == "B": RGB[2].append(i) ans = 0 for n in range(3): for i in range(len(RGB[n])): j_start = 0 while RGB[n][i] > RGB[(n + 1) % 3][j_start]: if j_start + 1 < len(RGB[(n + 1) % 3]): j_start += 1 else: break for j in range(j_start, len(RGB[(n + 1) % 3])): k_start = 0 while RGB[(n + 1) % 3][j] > RGB[(n + 2) % 3][k_start]: if k_start + 1 < len(RGB[(n + 2) % 3]): k_start += 1 else: break for k in range(len(RGB[(n + 2) % 3])): if ( RGB[n][i] < RGB[(n + 1) % 3][j] < RGB[(n + 2) % 3][k] and RGB[(n + 1) % 3][j] - RGB[n][i] != RGB[(n + 2) % 3][k] - RGB[(n + 1) % 3][j] ): ans += 1 j_start = 0 while RGB[n][i] > RGB[(n + 2) % 3][j_start]: if j_start + 1 < len(RGB[(n + 2) % 3]): j_start += 1 else: break for j in range(len(RGB[(n + 2) % 3])): k_start = 0 while RGB[(n + 2) % 3][j] > RGB[(n + 1) % 3][k_start]: if k_start + 1 < len(RGB[(n + 1) % 3]): k_start += 1 else: break for k in range(len(RGB[(n + 1) % 3])): if ( RGB[n][i] < RGB[(n + 2) % 3][j] < RGB[(n + 1) % 3][k] and RGB[(n + 2) % 3][j] - RGB[n][i] != RGB[(n + 1) % 3][k] - RGB[(n + 2) % 3][j] ): ans += 1 print(ans)
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s662921899
Runtime Error
p02714
Input is given from Standard Input in the following format: N S
from itertools import permutations inputs = open(0).readlines() n = int(inputs[0]) S = inputs[1].strip() R = [i for i, c in enumerate(S) if c == "R"] G = [i for i, c in enumerate(S) if c == "G"] B = [i for i, c in enumerate(S) if c == "B"] def f(Z, i, x, y): for z in Z[i:]: if z == 2 * y - x: return 1 if z > 2 * y - x: return 0 return 0 ans = 0 for X, Y, Z in list(permutations([R, G, B])): for x in X: for y in Y: if x < y: idx = 0 for i, z in enumerate(Z): if y < z: break if y < z: ans += len(Z) - i - f(Z, i, x, y) print(ans)
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s693985663
Accepted
p02714
Input is given from Standard Input in the following format: N S
N = int(input()) T = input() S = [0 for _ in range(N)] for i in range(N): if T[i] == "G": S[i] = 1 elif T[i] == "B": S[i] = 2 ls = [(0, 0, 0) for _ in range(N)] for i in range(N): if S[i] == 0: ls[i] = (ls[i - 1][0] + 1, ls[i - 1][1], ls[i - 1][2]) elif S[i] == 1: ls[i] = (ls[i - 1][0], ls[i - 1][1] + 1, ls[i - 1][2]) else: ls[i] = (ls[i - 1][0], ls[i - 1][1], ls[i - 1][2] + 1) def count(x): val = 0 y = (x + 1) % 3 z = (x + 2) % 3 for i in range(N): if S[i] == x: for j in range(i + 1, N): if S[j] == y: val += ls[N - 1][z] - ls[j][z] if 2 * j - i < N and S[2 * j - i] == z: val -= 1 if S[j] == z: val += ls[N - 1][y] - ls[j][y] if 2 * j - i < N and S[2 * j - i] == y: val -= 1 return val print(count(0) + count(1) + count(2))
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s094385630
Wrong Answer
p02714
Input is given from Standard Input in the following format: N S
# n = int(input()) # s = list(input()) # r_pos = [] # g_pos = [] # b_pos = [] # for i in range(n): # st = s[i] # if st == "R": # r_pos.append(i) # if st == "G": # g_pos.append(i) # if st == "B": # b_pos.append(i) # r_num = len(r_pos) # g_num = len(g_pos) # b_num = len(b_pos) # #print(r_pos, g_pos, b_pos) # ans = r_num * g_num * b_num # for r in r_pos: # for g in g_pos: # for b in b_pos: # color = [r, g, b] # color.sort() # x = color[0] # y = color[1] # z = color[2] # if z - y == y - x: # ans -= 1 # print(ans) # ----------------------------------------------------- n = int(input()) s = list(input()) r_pos = [] g_pos = [] b_pos = [] for i in range(n): st = s[i] if st == "R": r_pos.append(i) if st == "G": g_pos.append(i) if st == "B": b_pos.append(i) r_num = len(r_pos) g_num = len(g_pos) b_num = len(b_pos) print(r_pos, g_pos, b_pos, r_num, g_num, b_num) ans = r_num * g_num * b_num for r in r_pos: for g in g_pos: x, y = min(r, g), max(r, g) dif = y - x left_pos = x - dif right_pos = y + dif mid_pos = 4000 if dif % 2 == 0: mid_pos = x + dif // 2 left = 0 right = 0 mid = 0 if left_pos in b_pos: left = 1 if right_pos in b_pos: right = 1 if mid_pos in b_pos: mid = 1 ans -= left + right + mid print(ans)
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s556466835
Wrong Answer
p02714
Input is given from Standard Input in the following format: N S
n = int(input()) s = list(str(input())) a = [] for k in range(0, n): for j in range(0, k): for i in range(0, j): if s[i] != s[j] and s[j] != s[k] and s[k] != s[j] and j - i != k - j: a.append(i) print(len(a))
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s507678499
Accepted
p02714
Input is given from Standard Input in the following format: N S
m = int(input()) N = input() cnt = N.count("R") * N.count("G") * N.count("B") # print(cnt) for i in range(m - 2): # print(i,'*',int((m+i)/2)) for j in range(i + 1, int((m + i - 1) / 2) + 1): k = 2 * j - i # print(i,j,k) if N[k] != N[j] and N[j] != N[i] and N[i] != N[k]: # print(i,j,k) cnt -= 1 print(cnt)
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s359288229
Accepted
p02714
Input is given from Standard Input in the following format: N S
def SearchCombination_RGB(Str): Sum_Comb = 0 Num_R = 0 Num_G = 0 Num_B = 0 for i in range(len(Str)): if Str[i] == "R": Num_R += 1 elif Str[i] == "G": Num_G += 1 else: Num_B += 1 Num_Comb = Num_R * Num_G * Num_B if Num_Comb == 0: return 0 for Pos1 in range(0, len(Str) - 2): for Pos2 in range(Pos1 + 1, len(Str) - 1): if Str[Pos1] != Str[Pos2]: Pos3 = 2 * Pos2 - Pos1 if ( Pos3 < len(Str) and Str[Pos3] != Str[Pos1] and Str[Pos3] != Str[Pos2] ): Sum_Comb += 1 return Num_Comb - Sum_Comb Str = [input() for i in range(2)] # print(Str, ", len = ", len(Str)) print(SearchCombination_RGB(Str[1].strip()))
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s712320704
Accepted
p02714
Input is given from Standard Input in the following format: N S
# 初期入力 N = int(input()) S = input() # R_index = [] G_index = [] B_index = [] for i, v in enumerate(S): if v == "R": R_index.append(i) if v == "G": G_index.append(i) if v == "B": B_index.append(i) # 例 R_index各要素から等距離離れたところに左にG、右にBがあればOK R_B = [] B_G = [] count_ij_jk_onaji = 0 for r in R_index: for g in G_index: if 0 <= g - (r - g) and g - (r - g) < N: # if S[g-(r-g)]=="B" and r<g: if S[g - (r - g)] == "B": count_ij_jk_onaji += 1 # print(r,g,g-(r-g),"B") for b in B_index: for r in R_index: if 0 <= r - (b - r) and r - (b - r) < N: # if S[r-(b-r)] == "G" and b<r: if S[r - (b - r)] == "G": count_ij_jk_onaji += 1 # print(r,b,r-(b-r),"G") for g in G_index: for b in B_index: if 0 <= b - (g - b) and b - (g - b) < N: # if S[b-(g-b)] =="R" and g<b: if S[b - (g - b)] == "R": count_ij_jk_onaji += 1 # print(b,g,b-(g-b),"R") # 3つとも異なる文字=all kotae_all = len(R_index) * len(G_index) * len(B_index) print(kotae_all - count_ij_jk_onaji)
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s936602052
Wrong Answer
p02714
Input is given from Standard Input in the following format: N S
from bisect import bisect_left N = int(input()) S = list(input()) rix, gix, bix = [], [], [] lrc = [{} for _ in range(N)] for i in range(N): c = S[i] lrc_d = lrc[i] if c == "R": rix.append(i) lrc_d["lg"] = 0 lrc_d["rg"] = 0 lrc_d["lb"] = 0 lrc_d["rb"] = 0 elif c == "G": gix.append(i) lrc_d["lr"] = 0 lrc_d["rr"] = 0 lrc_d["lb"] = 0 lrc_d["rb"] = 0 else: bix.append(i) lrc_d["lr"] = 0 lrc_d["rr"] = 0 lrc_d["lg"] = 0 lrc_d["rg"] = 0 rl = len(rix) gl = len(gix) bl = len(bix) # print(rix, gix, bix) for ri in rix: lg = bisect_left(gix, ri) lb = bisect_left(bix, ri) lrc_d = lrc[ri] lrc_d["lg"] = lg lrc_d["rg"] = gl - lg lrc_d["lb"] = lb lrc_d["rb"] = bl - lb for bi in bix: lr = bisect_left(rix, bi) lg = bisect_left(gix, bi) lrc_d = lrc[bi] lrc_d["lr"] = lr lrc_d["rr"] = rl - lr lrc_d["lg"] = lg lrc_d["rg"] = gl - lg for gi in gix: lr = bisect_left(rix, gi) lb = bisect_left(bix, gi) lrc_d = lrc[gi] lrc_d["lr"] = lr lrc_d["rr"] = rl - lr lrc_d["lb"] = lb lrc_d["rb"] = bl - lb # print(lrc) ans = 0 mod = 10**9 + 7 for i in range(N): if S[i] == "R": lg = lrc[i]["lg"] rg = lrc[i]["rg"] lb = lrc[i]["lb"] rb = lrc[i]["rb"] lgs = set([i - gix[_] for _ in range(lg)]) rgs = set([gix[lg + _] - i for _ in range(rg)]) lbs = set([i - bix[_] for _ in range(lb)]) rbs = set([bix[lb + _] - i for _ in range(rb)]) ans += (lg * rb) - len(lgs & rbs) ans += (rg * lb) - len(rgs & lbs) ans %= mod if S[i] == "G": lr = lrc[i]["lr"] rr = lrc[i]["rr"] lb = lrc[i]["lb"] rb = lrc[i]["rb"] lrs = set([i - rix[_] for _ in range(lr)]) rrs = set([rix[lr + _] - i for _ in range(rr)]) lbs = set([i - bix[_] for _ in range(lb)]) rbs = set([bix[lb + _] - i for _ in range(rb)]) ans += (lr * rb) - len(lrs & rbs) ans += (rr * lb) - len(rrs & lbs) ans %= mod # print(lr, rr, lb, rb) # print(lrs, rrs, lbs, rbs) if S[i] == "B": lg = lrc[i]["lg"] rg = lrc[i]["rg"] lr = lrc[i]["lr"] rr = lrc[i]["rr"] lgs = set([i - gix[_] for _ in range(lg)]) rgs = set([gix[lg + _] - i for _ in range(rg)]) lrs = set([i - rix[_] for _ in range(lr)]) rrs = set([rix[lr + _] - i for _ in range(rr)]) ans += (lg * rr) - len(lgs & rrs) ans += (rg * lr) - len(rgs & lrs) ans %= mod # print(i, ans, S[i], lrc[i]) print(ans)
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s557989213
Accepted
p02714
Input is given from Standard Input in the following format: N S
from itertools import product x1 = int(input()) x2 = input() R_i = [i for i, x in enumerate(x2) if x == "R"] G_i = [i for i, x in enumerate(x2) if x == "G"] B_i = {i for i, x in enumerate(x2) if x == "B"} R = len(R_i) G = len(G_i) B = len(B_i) xs = map(sorted, product(R_i, G_i)) s = 0 for a in xs: k = a[1] * 2 - a[0] # 2j-i if k in B_i: s += 1 i = a[0] * 2 - a[1] # 2j-k if i in B_i: s += 1 j = (a[0] + a[1]) / 2 # (i+k)/2 if j in B_i: s += 1 print(R * G * B - s)
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s576118569
Wrong Answer
p02714
Input is given from Standard Input in the following format: N S
x = int(input()) s = list(input()) di = {"R": 0, "G": 0, "B": 0} for i in s: di[i] += 1 c = 0 # 重複を数える p = (len(s) - 3) // 2 for i in range(len(s) - 2): j = 0 while j < p + 1 and i + (2 * j) <= len(s) - 1: ss = s[i] + s[i + j] + s[i + (2 * j)] j += 1 if ( ss == "GBR" or ss == "GRB" or ss == "RBG" or ss == "RGB" or ss == "BGR" or ss == "BRG" ): c += 1 print(di["R"] * di["G"] * di["B"] - c)
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Print the number of triplets in question. * * *
s648919473
Accepted
p02714
Input is given from Standard Input in the following format: N S
N = int(input()) S = input() ret = 0 for j in range(1, N - 1): if S[j] == "R": ret += S[:j].count("G") * S[j + 1 :].count("B") ret += S[:j].count("B") * S[j + 1 :].count("G") for i in range(j): if j + j - i < N: if S[i] != S[j + (j - i)] and S[i] != "R" and S[j + (j - i)] != "R": ret -= 1 elif S[j] == "G": ret += S[:j].count("B") * S[j + 1 :].count("R") ret += S[:j].count("R") * S[j + 1 :].count("B") for i in range(j): if j + j - i < N: if S[i] != S[j + (j - i)] and S[i] != "G" and S[j + (j - i)] != "G": ret -= 1 elif S[j] == "B": ret += S[:j].count("R") * S[j + 1 :].count("G") ret += S[:j].count("G") * S[j + 1 :].count("R") for i in range(j): if j + j - i < N: if S[i] != S[j + (j - i)] and S[i] != "B" and S[j + (j - i)] != "B": ret -= 1 print(ret)
Statement We have a string S of length N consisting of `R`, `G`, and `B`. Find the number of triples (i,~j,~k)~(1 \leq i < j < k \leq N) that satisfy both of the following conditions: * S_i \neq S_j, S_i \neq S_k, and S_j \neq S_k. * j - i \neq k - j.
[{"input": "4\n RRGB", "output": "1\n \n\nOnly the triplet (1,~3,~4) satisfies both conditions. The triplet (2,~3,~4)\nsatisfies the first condition but not the second, so it does not count.\n\n* * *"}, {"input": "39\n RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB", "output": "1800"}]
Output the number of integers that meet the above criteria.
s970294672
Wrong Answer
p00379
The input is given in the following format. $a$ $n$ $m$ The input line provides three integers: $a$ ($0 \leq a \leq 50$), $n$ ($2 \leq n \leq 10$) and the upper limit $m$ ($1000 \leq m \leq 10^8$).
a, n, m = map(int, input().split()) cnt = 0 for y in range(1, m + 1): s = (sum(list(map(int, str(y)))) + a) ** n if s > m: break if s == y: cnt += 1 print(cnt)
Dudeney Number A Dudeney number is a positive integer for which the sum of its decimal digits is equal to the cube root of the number. For example, $512$ is a Dudeney number because it is the cube of $8$, which is the sum of its decimal digits ($5 + 1 + 2$). In this problem, we think of a type similar to Dudeney numbers and try to enumerate them. Given a non-negative integer $a$, an integer $n$ greater than or equal to 2 and an upper limit $m$, make a program to enumerate all $x$’s such that the sum of its decimal digits $y$ satisfies the relation $x = (y + a)^n$, and $x \leq m$.
[{"input": "16 2 1000", "output": "##\n\n \n \n 2\n \n\nTwo: $400 = (4 + 0 + 0 + 16)^2$ and $841 = (8 + 4 + 1 + 16)^2$"}, {"input": "0 3 5000", "output": "3\n \n\nThree: $1=1^3$, $512 = (5 + 1 + 2)^3$ and $4913 = (4 + 9 + 1 + 3)^3$."}, {"input": "2 3 100000", "output": "0\n \n\nThere is no such number $x$ in the range below $100,000$ such that its sum of\ndecimal digits $y$ satisfies the relation $(y+2)^3 = x$."}]
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
s293339286
Accepted
p02344
$n \; q$ $query_1$ $query_2$ : $query_q$ In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format. 0 $x \; y\; z$ or 1 $x \; y$ where '0' of the first digit denotes the relate information and '1' denotes the diff question.
#!/usr/bin/env python3 # DSL_1_B: Weighted Union Find Trees class WeightedUnionFind: def __init__(self, n): self.n = n self.nodes = [i for i in range(n)] self.weights = [0 for _ in range(n)] self.size = [1 for _ in range(n)] def connected(self, i, j): wi, ri = self.root(i) wj, rj = self.root(j) return ri == rj def union(self, i, j, w): wi, ri = self.root(i) wj, rj = self.root(j) if ri == rj: return if self.size[ri] < self.size[rj]: self.nodes[ri] = rj self.weights[ri] = wj - wi + w self.size[rj] += self.size[ri] else: self.nodes[rj] = ri self.weights[rj] = wi - wj - w self.size[ri] += self.size[rj] def weight(self, i, j): wi, ri = self.root(i) wj, rj = self.root(j) if ri != rj: raise ValueError("{} and {} is not connected".format(i, j)) return wi - wj def root(self, i): r = self.nodes[i] w = self.weights[i] while r != self.nodes[r]: w += self.weights[r] r = self.nodes[r] return w, r def run(): n, q = [int(i) for i in input().split()] wuf = WeightedUnionFind(n) for _ in range(q): com, *args = input().split() if com == "0": wuf.union(*[int(i) for i in args]) elif com == "1": x, y = [int(i) for i in args] if wuf.connected(x, y): print(wuf.weight(x, y)) else: print("?") if __name__ == "__main__": run()
Weighted Union Find Trees There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions. * relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$ * diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
[{"input": "6\n 0 0 2 5\n 0 1 2 3\n 1 0 1\n 1 1 3\n 0 1 4 8\n 1 0 4", "output": "?\n 10"}]
For each diff question, print the difference between $a_x$ and $a_y$ $(a_y - a_x)$.
s096737176
Accepted
p02344
$n \; q$ $query_1$ $query_2$ : $query_q$ In the first line, $n$ and $q$ are given. Then, $q$ information/questions are given in the following format. 0 $x \; y\; z$ or 1 $x \; y$ where '0' of the first digit denotes the relate information and '1' denotes the diff question.
import sys sys.setrecursionlimit(50000) def findSet(x, element, weight): if x != element[x]: element[x], s = findSet(element[x], element, weight) weight[x] += s return element[x], weight[x] def union(x, y, element, weight, w): x, wx = findSet(x, element, weight) y, wy = findSet(y, element, weight) link(x, wx, y, wy, w, element) def link(x, wx, y, wy, z, element): z = z + wy - wx element[x] = y weight[x] = z n, q = map(int, input().split()) element = [i for i in range(n)] weight = [0 for i in range(n)] for i in range(q): inp = map(int, input().split()) inp = list(inp) if inp[0] == 0: x, y, w = inp[1], inp[2], inp[3] union(x, y, element, weight, w) else: x, y = inp[1], inp[2] x, wx = findSet(x, element, weight) y, wy = findSet(y, element, weight) if x == y: print(wx - wy) else: print("?")
Weighted Union Find Trees There is a sequence $A = a_0, a_1, ..., a_{n-1}$. You are given the following information and questions. * relate$(x, y, z)$: $a_y$ is greater than $a_x$ by $z$ * diff$(x, y)$: report the difference between $a_x$ and $a_y$ $(a_y - a_x)$
[{"input": "6\n 0 0 2 5\n 0 1 2 3\n 1 0 1\n 1 1 3\n 0 1 4 8\n 1 0 4", "output": "?\n 10"}]
For each input text, print the final text with a character '^' representing the cursor position. Each output line shall contain exactly a single text with a character '^'.
s172909969
Runtime Error
p00683
The first input line contains a positive integer, which represents the number of texts the editor will edit. For each text, the input contains the following descriptions: * The first line is an initial text whose length is at most 100. * The second line contains an integer _M_ representing the number of editing commands. * Each of the third through the _M_ +2nd lines contains an editing command. You can assume that every input line is in a proper format or has no syntax errors. You can also assume that every input line has no leading or trailing spaces and that just a single blank character occurs between a command name (e.g., forward) and its argument (e.g., char).
class TextEditor: cur_w = 0 cur_c = 0 def __init__(self, txt): self.words = txt.split(" ") self.queries = { "forward char": self.forward_char, "forward word": self.forward_word, "backward char": self.backward_char, "backward word": self.backward_word, "delete char": self.delete_char, "delete word": self.delete_word, } def query(self, q): if q[0] == "i": txt = q.split(maxsplit=1)[1][1:-1] self.insert(txt) else: self.queries[q]() def forward_word(self): cw = self.words[self.cur_w] if self.cur_c < len(cw): self.cur_c = len(cw) elif self.cur_w < len(self.words) - 1: self.cur_w += 1 self.cur_c = len(self.words[self.cur_w]) else: pass def forward_char(self): if self.cur_c < len(self.words[self.cur_w]): self.cur_c += 1 elif self.cur_w < len(self.words) - 1: self.cur_w += 1 self.cur_c = 0 else: pass def backward_char(self): if self.cur_c > 0: self.cur_c -= 1 elif self.cur_w > 0: self.cur_w -= 1 self.cur_c = len(self.words[self.cur_w]) else: pass def backward_word(self): if self.cur_w > 0: self.cur_w -= 1 self.cur_c = len(self.words[self.cur_w]) else: self.cur_c = 0 def insert(self, txt): st = txt.split(" ") new_words = self.words[: self.cur_w] if len(st) > 1: cw = self.words[self.cur_w] new_words.append(cw[: self.cur_c] + st[0]) new_words.extend(st[1:-1]) new_words.append(st[-1] + cw[self.cur_c :]) else: cw = self.words[self.cur_w] new_words.append(cw[: self.cur_c] + st[0] + cw[self.cur_c :]) new_words.extend(self.words[self.cur_w + 1 :]) self.cur_w = self.cur_w + len(st) - 1 self.cur_c = self.cur_c + len(st[-1]) self.words = new_words def delete_char(self): cw = self.words[self.cur_w] if len(cw) == 0: self.words.pop(self.cur_w) elif self.cur_c < len(cw): self.words[self.cur_w] = cw[: self.cur_c] + cw[self.cur_c + 1 :] elif self.cur_w < len(self.words) - 1: nw = self.words.pop(self.cur_w + 1) self.words[self.cur_w] = cw + nw else: pass def delete_word(self): while not len(self.words[self.cur_w]) and len(self.words) > 1: self.words.pop(self.cur_w) self.cur_c = 0 self.words[self.cur_w] = self.words[self.cur_w][: self.cur_c] def output(self): words = self.words.copy() words[self.cur_w] = ( self.words[self.cur_w][: self.cur_c] + "^" + self.words[self.cur_w][self.cur_c :] ) print(*words) n = int(input()) for _ in range(n): te = TextEditor(input().strip()) q = int(input()) for _ in range(q): te.query(input().strip()) te.output()
A Simple Offline Text Editor A text editor is a useful software tool that can help people in various situations including writing and programming. Your job in this problem is to construct an offline text editor, i.e., to write a program that first reads a given text and a sequence of editing commands and finally reports the text obtained by performing successively the commands in the given sequence. The editor has a text buffer and a cursor. The target text is stored in the text buffer and most editing commands are performed around the cursor. The cursor has its position that is either the beginning of the text, the end of the text, or between two consecutive characters in the text. The initial cursor position (i.e., the cursor position just after reading the initial text) is the beginning of the text. A text manipulated by the editor is a single line consisting of a sequence of characters, each of which must be one of the following: 'a' through 'z', 'A' through 'Z', '0' through '9', '.' (period), ',' (comma), and ' ' (blank). You can assume that any other characters never occur in the text buffer. You can also assume that the target text consists of at most 1,000 characters at any time. The definition of words in this problem is a little strange: a word is a non-empty character sequence delimited by not only blank characters but also the cursor. For instance, in the following text with a cursor represented as '^', He^llo, World. the words are the following. He llo, World. Notice that punctuation characters may appear in words as shown in this example. The editor accepts the following set of commands. In the command list, "_any- text_ " represents any text surrounded by a pair of double quotation marks such as "abc" and "Co., Ltd.". **Command** | **Descriptions** ---|--- forward char | Move the cursor by one character to the right, unless the cursor is already at the end of the text. forward word | Move the cursor to the end of the leftmost word in the right. If no words occur in the right, move it to the end of the text. backward char | Move the cursor by one character to the left, unless the cursor is already at the beginning of the text. backward word | Move the cursor to the beginning of the rightmost word in the left. If no words occur in the left, move it to the beginning of the text. insert "_any-text_ " | Insert _any-text_ (excluding double quotation marks) at the position specified by the cursor. After performing this command, the new cursor position is at the end of the inserted text. The length of _any-text_ is less than or equal to 100. delete char | Delete the character that is right next to the cursor, if it exists. delete word | Delete the leftmost word in the right of the cursor. If one or more blank characters occur between the cursor and the word before performing this command, delete these blanks, too. If no words occur in the right, delete no characters in the text buffer.
[{"input": "A sample input\n 9\n forward word\n delete char\n forward word\n delete char\n forward word\n delete char\n backward word\n backward word\n forward word\n Hallow, Word.\n 7\n forward char\n delete word\n insert \"ello, \"\n forward word\n backward char\n backward char\n insert \"l\"\n \n 3\n forward word\n backward word\n delete word", "output": "Asampleinput^\n Hello, Worl^d.\n ^"}]
For each input text, print the final text with a character '^' representing the cursor position. Each output line shall contain exactly a single text with a character '^'.
s781346515
Wrong Answer
p00683
The first input line contains a positive integer, which represents the number of texts the editor will edit. For each text, the input contains the following descriptions: * The first line is an initial text whose length is at most 100. * The second line contains an integer _M_ representing the number of editing commands. * Each of the third through the _M_ +2nd lines contains an editing command. You can assume that every input line is in a proper format or has no syntax errors. You can also assume that every input line has no leading or trailing spaces and that just a single blank character occurs between a command name (e.g., forward) and its argument (e.g., char).
n = int(input()) for _ in range(n): tx = list(input()) m = int(input()) cursorpoint = 0 for i in range(m): qur = input().split() if qur[0] == "forward": if qur[1] == "char": cursorpoint = min(len(tx), cursorpoint + 1) else: flag = cursorpoint == 0 while cursorpoint < len(tx): if tx[cursorpoint] == " ": if flag: break else: cursorpoint += 1 else: cursorpoint += 1 flag = True if qur[0] == "backward": if qur[1] == "char": cursorpoint = max(0, cursorpoint - 1) else: flag = False while cursorpoint > 0: if tx[cursorpoint - 1] == " ": cursorpoint -= 1 flag = True elif flag: break else: cursorpoint -= 1 if qur[0] == "insert": txtt = list("".join(qur[1:])) txtt.remove('"') txtt.remove('"') if cursorpoint < len(tx): tx = tx[:cursorpoint] + txtt + tx[cursorpoint:] else: tx = tx[:cursorpoint] + txtt cursorpoint += len(txtt) if qur[0] == "delete": if qur[1] == "char": if cursorpoint < len(tx): tx.pop(cursorpoint) else: memo = cursorpoint flag = cursorpoint == len(tx) dodelete = True while cursorpoint < len(tx): if tx[cursorpoint] == " ": if flag: break else: cursorpoint += 1 else: cursorpoint += 1 flag = True else: dodelete = False if dodelete: tx = tx[:memo] + tx[cursorpoint:] cursorpoint = memo print("".join(tx[:cursorpoint]) + "^" + "".join(tx[cursorpoint:]))
A Simple Offline Text Editor A text editor is a useful software tool that can help people in various situations including writing and programming. Your job in this problem is to construct an offline text editor, i.e., to write a program that first reads a given text and a sequence of editing commands and finally reports the text obtained by performing successively the commands in the given sequence. The editor has a text buffer and a cursor. The target text is stored in the text buffer and most editing commands are performed around the cursor. The cursor has its position that is either the beginning of the text, the end of the text, or between two consecutive characters in the text. The initial cursor position (i.e., the cursor position just after reading the initial text) is the beginning of the text. A text manipulated by the editor is a single line consisting of a sequence of characters, each of which must be one of the following: 'a' through 'z', 'A' through 'Z', '0' through '9', '.' (period), ',' (comma), and ' ' (blank). You can assume that any other characters never occur in the text buffer. You can also assume that the target text consists of at most 1,000 characters at any time. The definition of words in this problem is a little strange: a word is a non-empty character sequence delimited by not only blank characters but also the cursor. For instance, in the following text with a cursor represented as '^', He^llo, World. the words are the following. He llo, World. Notice that punctuation characters may appear in words as shown in this example. The editor accepts the following set of commands. In the command list, "_any- text_ " represents any text surrounded by a pair of double quotation marks such as "abc" and "Co., Ltd.". **Command** | **Descriptions** ---|--- forward char | Move the cursor by one character to the right, unless the cursor is already at the end of the text. forward word | Move the cursor to the end of the leftmost word in the right. If no words occur in the right, move it to the end of the text. backward char | Move the cursor by one character to the left, unless the cursor is already at the beginning of the text. backward word | Move the cursor to the beginning of the rightmost word in the left. If no words occur in the left, move it to the beginning of the text. insert "_any-text_ " | Insert _any-text_ (excluding double quotation marks) at the position specified by the cursor. After performing this command, the new cursor position is at the end of the inserted text. The length of _any-text_ is less than or equal to 100. delete char | Delete the character that is right next to the cursor, if it exists. delete word | Delete the leftmost word in the right of the cursor. If one or more blank characters occur between the cursor and the word before performing this command, delete these blanks, too. If no words occur in the right, delete no characters in the text buffer.
[{"input": "A sample input\n 9\n forward word\n delete char\n forward word\n delete char\n forward word\n delete char\n backward word\n backward word\n forward word\n Hallow, Word.\n 7\n forward char\n delete word\n insert \"ello, \"\n forward word\n backward char\n backward char\n insert \"l\"\n \n 3\n forward word\n backward word\n delete word", "output": "Asampleinput^\n Hello, Worl^d.\n ^"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s507575159
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
x = list(map(int,input().split())) if x[0]+x[1] == x[2] or x[1]+x[2] = x[0] or x[0]+x[2] == x[1]: print("YES") else: print("NO")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s328456209
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c = map(int,input().split()) if a + b == c pr a + c == b or b + c == a: print("No") else: print("Yes")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s191794635
Accepted
p03943
The input is given from Standard Input in the following format: a b c
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def IR(n): l = [None for i in range(n)] for i in range(n): l[i] = I() return l def LIR(n): l = [None for i in range(n)] for i in range(n): l[i] = LI() return l def SR(n): l = [None for i in range(n)] for i in range(n): l[i] = S() return l def LSR(n): l = [None for i in range(n)] for i in range(n): l[i] = LS() return l sys.setrecursionlimit(1000000) mod = 1000000007 # A def A(): s = LI() if sum(s) == 2 * max(s): print("Yes") else: print("No") return # B def B(): return # C def C(): return # D def D(): return # E def E(): return # F def F(): return # G def G(): return # H def H(): return # Solve if __name__ == "__main__": A()
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s367369126
Wrong Answer
p03943
The input is given from Standard Input in the following format: a b c
# #    ⋀_⋀ #    (・ω・) # ./ U ∽ U\ # │* 合 *│ # │* 格 *│ # │* 祈 *│ # │* 願 *│ # │*   *│ #  ̄ # import sys sys.setrecursionlimit(10**6) input = sys.stdin.readline from math import floor, ceil, sqrt, factorial, log # log2ないyp from heapq import heappop, heappush, heappushpop from collections import Counter, defaultdict, deque from itertools import ( accumulate, permutations, combinations, product, combinations_with_replacement, ) from bisect import bisect_left, bisect_right from copy import deepcopy inf = float("inf") mod = 10**9 + 7 def pprint(*A): for a in A: print(*a, sep="\n") def INT_(n): return int(n) - 1 def MI(): return map(int, input().split()) def MF(): return map(float, input().split()) def MI_(): return map(INT_, input().split()) def LI(): return list(MI()) def LI_(): return [int(x) - 1 for x in input().split()] def LF(): return list(MF()) def LIN(n: int): return [I() for _ in range(n)] def LLIN(n: int): return [LI() for _ in range(n)] def LLIN_(n: int): return [LI_() for _ in range(n)] def LLI(): return [list(map(int, l.split())) for l in input()] def I(): return int(input()) def F(): return float(input()) def ST(): return input().replace("\n", "") def main(): A = LI() print("YNeos"[sum(A) % 3 != 0 :: 2]) if __name__ == "__main__": main()
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s089863959
Wrong Answer
p03943
The input is given from Standard Input in the following format: a b c
import sys import math import collections import itertools import array import inspect # Set max recursion limit sys.setrecursionlimit(1000000) # Debug output def chkprint(*args): names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()} print(", ".join(names.get(id(arg), "???") + " = " + repr(arg) for arg in args)) # Binary converter def to_bin(x): return bin(x)[2:] def li_input(): return [int(_) for _ in input().split()] def gcd(n, m): if n % m == 0: return m else: return gcd(m, n % m) def gcd_list(L): v = L[0] for i in range(1, len(L)): v = gcd(v, L[i]) return v def lcm(n, m): return (n * m) // gcd(n, m) def lcm_list(L): v = L[0] for i in range(1, len(L)): v = lcm(v, L[i]) return v # Width First Search (+ Distance) def wfs_d(D, N, K): """ D: 隣接行列(距離付き) N: ノード数 K: 始点ノード """ dfk = [-1] * (N + 1) dfk[K] = 0 cps = [(K, 0)] r = [False] * (N + 1) r[K] = True while len(cps) != 0: n_cps = [] for cp, cd in cps: for i, dfcp in enumerate(D[cp]): if dfcp != -1 and not r[i]: dfk[i] = cd + dfcp n_cps.append((i, cd + dfcp)) r[i] = True cps = n_cps[:] return dfk # Depth First Search (+Distance) def dfs_d(v, pre, dist): """ v: 現在のノード pre: 1つ前のノード dist: 現在の距離 以下は別途用意する D: 隣接リスト(行列ではない) D_dfs_d: dfs_d関数で用いる,始点ノードから見た距離リスト """ global D global D_dfs_d D_dfs_d[v] = dist for next_v, d in D[v]: if next_v != pre: dfs_d(next_v, v, dist + d) return def sigma(N): ans = 0 for i in range(1, N + 1): ans += i return ans class Combination: def __init__(self, n, mod): g1 = [1, 1] g2 = [1, 1] inverse = [0, 1] for i in range(2, n + 1): g1.append((g1[-1] * i) % mod) inverse.append((-inverse[mod % i] * (mod // i)) % mod) g2.append((g2[-1] * inverse[-1]) % mod) self.MOD = mod self.N = n self.g1 = g1 self.g2 = g2 self.inverse = inverse def __call__(self, n, r): if r < 0 or r > n: return 0 r = min(r, n - r) return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD # -------------------------------------------- dp = None def main(): a, b, c = li_input() if sum([a, b, c]) - max(a, b, c) == max(a, b, c): print("Yes") else: print("Nop") main()
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s125435955
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
import java.util.*; class Main { public static void main(String args[]) { Scanner inp = new Scanner(System.in); int a = inp.nextInt(); int b = inp.nextInt(); int c = inp.nextInt(); boolean flag = false; if ((a + b) == c) flag = true; if ((a + c) == b) flag = true; if ((b + c) == a) flag = true; System.out.println(flag ? "Yes" : "No"); } }
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s965131203
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
import sys sys.setrecursionlimit(250000) def main(): a,b,c = map(int, input().split()) if a == b + c : print("Yes") elif b == a + c: print("Yes") elif c == a + b: print("Yes") else print("No") main()
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s282536028
Wrong Answer
p03943
The input is given from Standard Input in the following format: a b c
#!/usr/bin/env python3 # a, b, c = map(int, input().split()) # for i in itertools.permutations([a, b, c], 3): # if i[0] == sum(i[1:]) or sum(i[:2]) == i[2]: # print("Yes") # exit() # print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s351462098
Accepted
p03943
The input is given from Standard Input in the following format: a b c
a, b, c = (int(T) for T in input().split()) print(["No", "Yes"][(a + b) == c or (b + c) == a or (c + a) == b])
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s938468616
Accepted
p03943
The input is given from Standard Input in the following format: a b c
print("NYoe s"[" 2" in (s := input()) or " 5" in s :: 2])
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s419413613
Wrong Answer
p03943
The input is given from Standard Input in the following format: a b c
print(sum(map(int, input().split())) % 3 and "No" or "Yes")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s700271227
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
L = sorted(list(map(int, input().split()))) print("Yes" if sum(L[:2] == L[2]) else "No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s352692015
Wrong Answer
p03943
The input is given from Standard Input in the following format: a b c
print(len(set(map(int, input().split()))))
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s921113505
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c = map(int, input().split()) if (a+b+c) % 3 == 0:P print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s149071931
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
print("A" + input()[8] + "C")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s802620834
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c=map(int,input().split()) if a+b=c or a+c=b or b+c=a: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s559354004
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a, b, c = map(int,input().split()) if a+b=c or b+c=a or c+a=b: print(Yes) else: print(No)
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s822759744
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c=input().split() if a+b=c or a+c=b or b+c=a: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s085916360
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
x,y,z =sorted(map(int,input().split())) print("Yes" if x+y==z "No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s245452069
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c = map(input().split()) if a = b+c or b = a+c or c = a+b : print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s893749868
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
print(len(re.sub("B+", "B", re.sub("W+", "W", input()))) - 1)
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s757990078
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
i = list(input().split(' ')).map(lambda x:int(x) x,y,z = i a =x+y+z if a%3 is 0:
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s213206812
Accepted
p03943
The input is given from Standard Input in the following format: a b c
candies = list(map(int, input().split())) print("Yes" if max(candies) * 2 == sum(candies) else "No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s135640362
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c = map(int,input().split()) if a+b = c or a+c = b or b+c = a: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s220793363
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
packs = list(map(int, input().split()).sort() if packs[2] - packs[1] == packs[0]: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s296757683
Accepted
p03943
The input is given from Standard Input in the following format: a b c
#!/usr/bin/env python3 import sys # import time # import math # import numpy as np # import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall # import random # random, uniform, randint, randrange, shuffle, sample # import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]). # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate() # from collections import defaultdict # subclass of dict. defaultdict(facroty) # from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter) # from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj # from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj # from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available. # from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference # from functools import reduce # reduce(f, iter[, init]) # from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed) # from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn). # from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn). # from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n]) # from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])] # from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9] # from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r]) # from itertools import combinations, combinations_with_replacement # from itertools import accumulate # accumulate(iter[, f]) # from operator import itemgetter # itemgetter(1), itemgetter('key') # from fractions import gcd # for Python 3.4 (previous contest @AtCoder) def main(): mod = 1000000007 # 10^9+7 inf = float("inf") # sys.float_info.max = 1.79...e+308 # inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19 sys.setrecursionlimit(10**6) # 1000 -> 1000000 def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def mi(): return map(int, input().split()) def mi_0(): return map(lambda x: int(x) - 1, input().split()) def lmi(): return list(map(int, input().split())) def lmi_0(): return list(map(lambda x: int(x) - 1, input().split())) def li(): return list(input()) L = lmi() L.sort() print("Yes") if L[0] + L[1] == L[2] else print("No") if __name__ == "__main__": main()
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s746147458
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split()) if a == b + c: print("YES") elif b == a + c: print("YES") elif c = b + a: print("YES") else: print("NO")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s299200554
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split()) ab = a+b bc = b+c ca = c+a flg = False if ab == c: flg = True if bc == a: flg = True if ca == b: flg = True if flg = True: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s850446045
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
s=input().split() p=[0,0,0] for n in range(3): p[n]=int(s[n]) if p[0]+p[1]==p[2]: print("Yes") elif p[1]+p[2]==p[0]: print("Yes") elif p[2]+p[0]==p[1]: print("Yes") else print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s382289573
Accepted
p03943
The input is given from Standard Input in the following format: a b c
m = sorted(map(int, input().split())) print("Yes" if sum(m[:-1]) == m[-1] else "No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s761437559
Accepted
p03943
The input is given from Standard Input in the following format: a b c
A = [int(i) for i in input().split()] print("Yes" if sum(A) == max(A) * 2 else "No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s724172457
Wrong Answer
p03943
The input is given from Standard Input in the following format: a b c
print("Yes" if sum(map(int, input().split())) % 2 == 0 else "No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s182089095
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c=map(int, input().split()) if((a+b+c)%3=0): print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s313447633
Wrong Answer
p03943
The input is given from Standard Input in the following format: a b c
print(["Yes", "No"][sum(map(int, input().split())) & 1])
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s709256959
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c=map(int,input().split()) print('YES' if a=b+c or b=a+c or c=a+b else 'NO')
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s494224889
Accepted
p03943
The input is given from Standard Input in the following format: a b c
a = sorted(list(map(int, input().split())), reverse=True) print("Yes" if a[0] - a[1] - a[2] == 0 else "No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s343778818
Accepted
p03943
The input is given from Standard Input in the following format: a b c
### 2019/09/25 S = map(int, input().split()) S = sorted(S) print("Yes" if (S[0] + S[1]) == S[2] else "No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s518326732
Accepted
p03943
The input is given from Standard Input in the following format: a b c
c = map(int, input().split()) c = sorted(c) ans = "Yes" if c[0] + c[1] == c[2] else "No" print(ans)
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s324986426
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c=map(int, input().split()) if(a+b==c)||(b+c==a)||(a+c==b): print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s441523593
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
#n = int(input()) a = list(map(int,input().split())) a.sort() if a[0]+a[1]==a[2]: print("Yes") elif: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s639065836
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
A = list(map(int,input().split())) a = sorted(A) if a[2]=a[0]+a[1]: print('Yes') else: print('No')
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s290730104
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
n=list(map(int,input().split())) if n[0]=n[1]+n[2]or[1]=n[0]+n[2]or[2]=n[0]+n[1]: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s468377447
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split(" ")) if a % 2 = 0 and b % 2 = 0 and c % 2 = 0: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s184481598
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
n=list(map(int,input().split())) if n[0]=n[1]n[2]orn[1]=n[0]+n[2]or[2]=n[0]+n[1]: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s587855473
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a = list(map(int,input().split())) a.sort(reverse=True) if a[0] = a[1] + a[2]: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s137204114
Accepted
p03943
The input is given from Standard Input in the following format: a b c
from itertools import combinations, product def gcd(a, b): if a < b: a, b = b, a while b != 0: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) def get(fmt): ps = input().split() r = [] for p, t in zip(ps, fmt): if t == "i": r.append(int(p)) if t == "f": r.append(float(p)) if t == "s": r.append(p) if len(r) == 1: r = r[0] return r def put(*args, **kwargs): print(*args, **kwargs) def rep(n, f, *args, **kwargs): return [f(*args, **kwargs) for _ in range(n)] def rep_im(n, v): return rep(n, lambda: v) YES_NO = ["NO", "YES"] val = sorted(get("iii")) if val[0] + val[1] == val[2]: put("Yes") else: put("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s652276698
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
!/usr/bin/env python3 import sys, math, itertools, heapq, collections, bisect, fractions input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') sys.setrecursionlimit(10**8) inf = float('inf') ans = count = 0 a,b,c=map(int,input().split()) print(0) for i in itertools.permutations([a,b,c],3): if i[0]==sum(i[1:]) or sum(i[:2])==i[2]: print("Yes") exit() print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s283700581
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ using namespace std; typedef unsigned long ul; typedef long long ll; typedef pair<ul, ul> P; //ペア タイプでふ int main() { int a, b, c; cin >> a >> b >> c; if (a + b == c || a + c == b || b + c == a) { cout << "Yes"; } else { cout << "No"; } }
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s768872692
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author */ #include <iostream> #include <fstream> #include <bits/stdc++.h> using namespace std; typedef long long ll; #define tr(container, it) \ for (auto it = container.begin(); it != container.end(); it++) #define scontains(c, x) ((c).find(x) != (c).end()) //O(log n) #define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n) #define pll pair<ll,ll> #define pii pair<int,int> #define mll map<ll,ll> #define intv(x, a, b)((x)>=a && (x)<=b) #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1) #define all(x) (x).begin(),(x).end() //#define len(array) (sizeof(array)/sizeof((array)[0])) #define what_is(x) cerr << #x << " is " << x << endl; #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); } #define mod(x, m) ((((x) % (m)) + (m)) % (m)) const double PI = 2 * acos(.0); const int INF = 0x3f3f3f3f; const ll LLINF = 1000000000000000005LL;; const ll MOD = (ll) (1e9) + 7; void _mod(ll &x){x = mod(x, MOD);} //const ll MOD = (ll) 998244353 ; const double EPS = 1e-10; template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { std::fill((T *) array, (T *) (array + N), val); } //#define int ll class A2FightingOverCandies { public: void solve(std::istream& cin, std::ostream& cout) { int a,b,c; cin >> a >> b >> c; cout << (a + b + c == 2*max({a,b,c})? "Yes":"No") << endl; } }; #undef int int main() { A2FightingOverCandies solver; std::istream& in(std::cin); std::ostream& out(std::cout); solver.solve(in, out); return 0; }
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s588970023
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
input = input().split() a, b, c = input_ a, b, c = int(a), int(b), int(c) if a == b + c, b == c + a, c == a + b: print("YES") else: print("NO")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s885746723
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
A,B,C = map(int, input().split()) A_B = (A+B) A_C = (A+C) B_C = (B+C) if A_B == C or A_C == B or B_C = A: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s903916292
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a, b, c = map(int, input().split()) if a + b = c: print('yes') elif b + c = a: print('yes') elif c + a = b: print('Yes') else: print('No')
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s055368532
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
Cnd = list(map(int,input().split())) Cnd = sorted(Cnd) result = 'No' if Cnd[0]=Cnd[1]+Cnd[2]: result ='Yes' id Cnd[0]+Cnd[1]=Cnd[2]: result ='Yes' print(result)
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s027499833
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
f = True a, b, c = map(int, input().split()) candy = [a, b, c] if not max(candy) == sum(candy) - max(candy): f = False if f: print("YES") else:
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s742697578
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c = map (int,input().split()) int T = 0 if a+b == c: T = 1 elif b+c == a: T = 1 elif a+c == b: T = 1 if T == 1: print("YES") else: print('NO')
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s447565969
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
input_ = input().split() a, b, c = input_ a, b, c = int(a), int(b), int(c) if a == b + c, b == c + a, c == a + b: print("YES") else: print("NO")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s923653927
Accepted
p03943
The input is given from Standard Input in the following format: a b c
*ab, c = sorted(map(int, input().split())) print(["No", "Yes"][sum(ab) == c])
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s092292384
Accepted
p03943
The input is given from Standard Input in the following format: a b c
i = sorted(map(int, input().split())) print("Yes" if (i[0] + i[1]) == i[2] else "No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s697220470
Wrong Answer
p03943
The input is given from Standard Input in the following format: a b c
[print(len(list(i.groupby(input()))) - 1) for i in [__import__("itertools")]]
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s653013813
Wrong Answer
p03943
The input is given from Standard Input in the following format: a b c
num = [int(x) for x in input().split()] print("Yes" if sum(num) % 3 == 0 else "No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s377947402
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c = map(int,input().split()) if a==b+c or b==a+c or c==a+b :print('Yes') else:print('No')
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s640212612
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c = map(int,input().split()) if ((a+b+c)%3 == 0): print("Yes") else print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s126699965
Wrong Answer
p03943
The input is given from Standard Input in the following format: a b c
print(["No", "Yes"][sum(list(map(int, input().split()))) % 3 == 0])
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s985822425
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c = sorted(map(int,input().split())) if a+b =c: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]
If it is possible to distribute the packs so that each student gets the same number of candies, print `Yes`. Otherwise, print `No`. * * *
s284102685
Runtime Error
p03943
The input is given from Standard Input in the following format: a b c
a,b,c = sorted(map(int,input().split())) if a+b =c: print("Yes") else: print("No")
Statement Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
[{"input": "10 30 20", "output": "Yes\n \n\nGive the pack with 30 candies to one student, and give the two packs with 10\nand 20 candies to the other. Then, each gets 30 candies.\n\n* * *"}, {"input": "30 30 100", "output": "No\n \n\nIn this case, the student who gets the pack with 100 candies always has more\ncandies than the other.\n\nNote that every pack must be given to one of them.\n\n* * *"}, {"input": "56 25 31", "output": "Yes"}]