_id
stringlengths
2
5
partition
stringclasses
2 values
text
stringlengths
5
289k
language
stringclasses
1 value
meta_information
dict
title
stringclasses
1 value
d8501
test
import sys input = sys.stdin.readline s = list(input().strip()) t = list(input().strip()) if sorted(s) < sorted(t, reverse=True): print("Yes") else: print("No")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc082/tasks/abc082_b" }
d8502
test
a,b,c = map(int,input().split()) mod = a % b ans = 'NO' for i in range(1,b): if (i*mod) % b == c: ans = 'YES' break print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc060/tasks/abc060_b" }
d8503
test
a,b=map(int, input().split()) print(a*b-a-b+1)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc106/tasks/abc106_a" }
d8504
test
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) x, y, z = list(map(int, input().split())) print(((x-z)//(y+z)))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc078/tasks/abc078_b" }
d8505
test
N = int(input()) ab = [list(map(int, input().split())) for _ in range(N)] cd = [list(map(int, input().split())) for _ in range(N)] ab.sort() cd.sort() g = [[] for _ in range(N)] for i, pab in enumerate(ab): for j, pcd in enumerate(cd): if pab[0] < pcd[0] and pab[1] < pcd[1]: g[j].append([pab[1],i]) ans = 0 s = set() for gg in g: gg.sort(reverse=True) for ggg in gg: if ggg[1] in s:continue else: ans += 1 s.add(ggg[1]) break print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc091/tasks/arc092_a" }
d8506
test
n,T = map(int,input().split()) t = list(map(int,input().split())) ans = 0 for i in range(n-1): ans += min(T,t[i+1]-t[i]) print(ans+T)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc060/tasks/arc073_a" }
d8507
test
n = int(input()) d = {} matr = [0] * (2 * n + 1) head = n - 1 tail = n for i in range(n): st, n = input().split() n = int(n) if st == 'L': matr[head] = n d[n] = head head -= 1 elif st == 'R': matr[tail] = n d[n] = tail tail += 1 else: print(min(d[n] - head, tail - d[n]) - 1)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1066/C" }
d8508
test
for i in range(int(input())): n=int(input()) moves=0 while n%2==0: n=n//2 moves+=1 while n%3==0: n=n//3 moves+=2 while n%5==0: n=n//5 moves+=3 if n==1: print(moves) else : print(-1)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1176/A" }
d8509
test
t = int(input()) for _ in range(t): n = int(input()) arr = [int(j) for j in input().split()] flag = 0 for x in arr: if x%2 != arr[0]%2: flag = 1 break if flag == 1: print("NO") else: print("YES")
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1324/A" }
d8510
test
from math import ceil n = int(input()) word1 = input() word2 = input() combined = [] for i in range(ceil(n / 2)): if i > n / 2 - 1: combined.append([word1[i], word2[i]]) else: combined.append([word1[i], word1[- i - 1], word2[i], word2[- i - 1]]) count = 0 for l in combined: s = set(l) if len(s) == 4: count += 2 elif len(s) == 3: count += 1 if l[0] == l[1]: count += 1 elif len(s) == 2: counter = 0 first_letter = l[0] for letter in l: if letter == first_letter: counter += 1 if counter != 2: count += 1 print(count)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1006/D" }
d8511
test
t = int(input()) for i in range(t): a, b, k = list(map(int, input().split())) ans = (a - b) * (k // 2) if k % 2 == 1: ans += a print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1077/A" }
d8512
test
for _ in range(int(input())): n = int(input()) bits = ['1'] while int(''.join(bits), 3) < n: bits.append('1') for i in range(len(bits)): bits[i] = '0' if int(''.join(bits), 3) < n: bits[i] = '1' print(int(''.join(bits), 3))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1249/C2" }
d8513
test
t = int(input()) # a = list(map(int, input().split())) for _ in range(t): a,b,x,y,n = map(int,input().split()) options = [] a2 = max(a-n,x) b2 = max(b-(n-(a-a2)),y) options.append(a2*b2) b2 = max(b-n,y) a2 = max(a-(n-(b-b2)),x) options.append(a2*b2) print(min(options))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1409/B" }
d8514
test
for _ in range(int(input())): a, b = list(map(int, input().split())) if a == b: print(0) else: if a < b: if (b - a) % 2: print(1) else: print(2) else: if (b - a) % 2 == 0: print(1) else: print(2)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1311/A" }
d8515
test
# ========== //\\ //|| ||====//|| # || // \\ || || // || # || //====\\ || || // || # || // \\ || || // || # ========== // \\ ======== ||//====|| # code def solve(): x = int(input()) ans = 0 ok = 0 for i in range(1, 10): n = 0 for j in range(4): n = n * 10 + i ans += (j + 1) if n == x: ok = 1 break if ok: break print(ans) def main(): t = 1 t = int(input()) for _ in range(t): solve() def __starting_point(): main() __starting_point()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1433/A" }
d8516
test
import sys k=int(input()) L=[] dic=dict() flag=False for i in range(k): L.append([int(input())]) L[i].append(list(map(int,input().split()))) s=sum(L[i][1]) q=[] for j in range(L[i][0]): if flag: return t=s-L[i][1][j] if t in dic: x,y=dic[t] print("YES") print(i+1,j+1) print(x,y) flag=True else: q.append((t,i+1,j+1)) for a,b,c in q: dic[a]=(b,c) print("NO")
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/988/C" }
d8517
test
class Solution: def largestSumAfterKNegations(self, A: List[int], K: int) -> int: A.sort() i = 0 while A[i] < 0 and K > 0: A[i] *= -1 i += 1 K -= 1 if K % 2 == 1 and 0 not in A: return sum(A) - 2*min(A) return sum(A)
PYTHON
{ "starter_code": "\nclass Solution:\n def largestSumAfterKNegations(self, A: List[int], K: int) -> int:\n ", "url": "https://leetcode.com/problems/maximize-sum-of-array-after-k-negations/" }
d8518
test
class Solution: def canThreePartsEqualSum(self, A: List[int]) -> bool: # if len(A)<3: # return # i = 1 # j = len(A)-2 # tgtsum = sum(A)/3 # sum1 = sum(A[:i]) # while i<(len(A)-2) and sum1!=tgtsum: # sum1 = sum1 + A[i] # i+=1 # sum3=sum(A[j+1:]) # while j>1 and sum3!=tgtsum: # # print (tgtsum, sum1, sum3, A[j]) # sum3 = sum3 + A[j] # j-=1 # # print (i,j) # if j>=i and sum1==tgtsum and sum3==tgtsum: # return True # else: # return False if len(A)<3: return False suma = sum(A) if suma%3!=0: return False runsum,target, count = 0,suma/3,0 for val in A[:-1]: runsum += val if runsum==target: count+=1 runsum=0 if count==2: return True else: return False
PYTHON
{ "starter_code": "\nclass Solution:\n def canThreePartsEqualSum(self, A: List[int]) -> bool:\n ", "url": "https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum/" }
d8519
test
from collections import Counter n = int(input()) ss = [input() for _ in range(n)] ss.sort() c = Counter() mc = 0 for s in ss: c[s] += 1 mc = max(mc, c[s]) seen = set() for s in ss: if c[s] == mc and s not in seen: print(s) seen.add(s)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc155/tasks/abc155_c" }
d8520
test
n = int(input()) a = list(map(int, input().split())) ans = 1e9 for p in range(-100, 101): sub = 0 for q in a: sub += pow(p - q, 2) ans = min(ans, sub) print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc043/tasks/arc059_a" }
d8521
test
print((int(input()) - int(input())) % int(input()))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc087/tasks/abc087_a" }
d8522
test
import math n, m = map(int, input().split()) mod = 10**9+7 if abs(n-m) > 1: print(0) return dog = math.factorial(n) monkey = math.factorial(m) if abs(n-m) == 1: ans = dog*monkey % mod elif n == m: ans = dog*monkey*2 % mod print(ans%mod)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc065/tasks/arc076_a" }
d8523
test
n,m=list(map(int,input().split())) M=[[] for i in range(n)] for i in range(m): a,b=list(map(int,input().split())) a-=1;b-=1 M[a].append(b) M[b].append(a) yes="POSSIBLE";no="IMPOSSIBLE" for i in M[0]: if n-1 in M[i]: print(yes);return print(no)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc068/tasks/arc079_a" }
d8524
test
s = input() i = 0 answer = str() for j in s: if i % 2 == 0: answer += j i += 1 print(answer)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc072/tasks/abc072_b" }
d8525
test
s1,s2,s3 = input().split() print("YES") if s1[-1]==s2[0] and s2[-1]==s3[0] else print("NO")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc060/tasks/abc060_a" }
d8526
test
a = int(input()) b = int(input()) if a < b: print("LESS") elif a > b: print("GREATER") else: print("EQUAL")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc059/tasks/abc059_b" }
d8527
test
def resolve(): n = int(input()) blue_cards = list() for i in range(n): card = input() blue_cards.append(card) blue_cards = sorted(blue_cards) m = int(input()) red_cards = list() for i in range(m): card = input() red_cards.append(card) red_cards = sorted(red_cards) former = "" cards_points = [] for card in blue_cards: point = 0 if former == card: continue else: p = blue_cards.count(card) m = red_cards.count(card) point = p - m cards_points.append(point) former = card cards_points = sorted(cards_points) if cards_points[-1] < 0: print(0) else: print(cards_points[-1]) resolve()
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc091/tasks/abc091_b" }
d8528
test
d = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'} print((d[input()]))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc122/tasks/abc122_a" }
d8529
test
def mapt(fn, *args): return tuple(map(fn, *args)) def Input(): return mapt(int, input().split(" ")) def main(): n = int(input()) a_1 = Input() a_2 = Input() ans = 0 for i in range(n): ans = max(ans, sum(a_1[:i+1])+sum(a_2[i:n])) print(ans) main()
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc087/tasks/arc090_a" }
d8530
test
N, x = [int(n) for n in input().split(" ")] A = [int(a) for a in input().split(" ")] cnt = 0 if A[0] > x: cnt += A[0] - x A[0] = x for i in range(1, len(A)): if A[i] + A[i - 1] > x: cnt += A[i] + A[i - 1] - x A[i] = x - A[i - 1] print(cnt)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc048/tasks/arc064_a" }
d8531
test
#!/usr/bin/env python3 c = [list(map(int, input().split())) for i in range(3)] a1 = 0 b1, b2, b3 = c[0][0], c[0][1], c[0][2] a2 = c[1][0]-b1 a3 = c[2][0]-b1 check = [] check.append(c[1][1] == a2+b2) check.append(c[2][1] == a3+b2) check.append(c[1][2] == a2+b3) check.append(c[2][2] == a3+b3) if sum(check) == 4: print("Yes") else: print("No")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc088/tasks/abc088_c" }
d8532
test
s = input() if s == 'ABC': print('ARC') else: print('ABC')
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc166/tasks/abc166_a" }
d8533
test
a,b,x=list(map(int,input().split())) print((b//x-(a-1)//x))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc048/tasks/abc048_b" }
d8534
test
d=int(input()) print('Christmas'+' Eve'*(25-d))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc115/tasks/abc115_a" }
d8535
test
#!/usr/bin/env python3 import sys def solve(N: int): if N >= 64: print((64)) elif N >= 32: print((32)) elif N >= 16: print((16)) elif N >= 8: print((8)) elif N >= 4: print((4)) elif N >= 2: print((2)) else: print((1)) return # Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int solve(N) def __starting_point(): main() __starting_point()
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc068/tasks/abc068_b" }
d8536
test
import sys def input(): return sys.stdin.readline().strip() def I(): return int(input()) def LI(): return list(map(int, input().split())) def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def S(): return input() def LS(): return input().split() INF = float('inf') a, b, c, d = LI() print(('Yes' if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d) else 'No'))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc097/tasks/abc097_a" }
d8537
test
def answer(s: str) -> str: return ''.join(s[0].upper() for s in s.split()) def main(): s = input() print(answer(s)) def __starting_point(): main() __starting_point()
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc059/tasks/abc059_a" }
d8538
test
a,b,c = map(int,input().split()) print("Yes" if a + b >= c else "No")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc091/tasks/abc091_a" }
d8539
test
import sys import heapq import re from itertools import permutations from bisect import bisect_left, bisect_right from collections import Counter, deque from fractions import gcd from math import factorial, sqrt, ceil from functools import lru_cache, reduce INF = 1 << 60 MOD = 1000000007 sys.setrecursionlimit(10 ** 7) # UnionFind class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} def __str__(self): return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) # ダイクストラ def dijkstra_heap(s, edge, n): #始点sから各頂点への最短距離 d = [10**20] * n used = [True] * n #True:未確定 d[s] = 0 used[s] = False edgelist = [] for a,b in edge[s]: heapq.heappush(edgelist,a*(10**6)+b) while len(edgelist): minedge = heapq.heappop(edgelist) #まだ使われてない頂点の中から最小の距離のものを探す if not used[minedge%(10**6)]: continue v = minedge%(10**6) d[v] = minedge//(10**6) used[v] = False for e in edge[v]: if used[e[1]]: heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1]) return d # 素因数分解 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 # 2数の最小公倍数 def lcm(x, y): return (x * y) // gcd(x, y) # リストの要素の最小公倍数 def lcm_list(numbers): return reduce(lcm, numbers, 1) # リストの要素の最大公約数 def gcd_list(numbers): return reduce(gcd, numbers) # 素数判定 def is_prime(n): if n <= 1: return False p = 2 while True: if p ** 2 > n: break if n % p == 0: return False p += 1 return True # limit以下の素数を列挙 def eratosthenes(limit): A = [i for i in range(2, limit+1)] P = [] while True: prime = min(A) if prime > sqrt(limit): break P.append(prime) i = 0 while i < len(A): if A[i] % prime == 0: A.pop(i) continue i += 1 for a in A: P.append(a) return P # 同じものを含む順列 def permutation_with_duplicates(L): if L == []: return [[]] else: ret = [] # set(集合)型で重複を削除、ソート S = sorted(set(L)) for i in S: data = L[:] data.remove(i) for j in permutation_with_duplicates(data): ret.append([i] + j) return ret # ここから書き始める n, a = map(int, input().split()) x = [i - a for i in map(int, input().split())] dp = [[0 for j in range(4901)] for i in range(n)] dp[0][2450] += 1 dp[0][x[0] + 2450] += 1 for i in range(1, n): for j in range(4901): dp[i][j] = dp[i - 1][j] if 0 <= j - x[i] < 4901: dp[i][j] += dp[i - 1][j - x[i]] ans = dp[n - 1][2450] - 1 print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc044/tasks/arc060_a" }
d8540
test
n = int(input()) a = list(map(int, input().split())) o = [a[i] for i in range(0,n,2)] e = [a[h] for h in range(1,n,2)] if n%2 == 0: e.reverse() l = e + o print(*l) else: o.reverse() l = o + e print(*l)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc066/tasks/arc077_a" }
d8541
test
h, n = list(map(int, input().split())) a = list(map(int, input().split())) if h <= sum(a): print('Yes') else: print('No')
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc153/tasks/abc153_b" }
d8542
test
S = input() x = len(S) for i in range(0, x, 2): y = x - 2 - i if S[:y//2] == S[y//2 : y]: print(len(S[:y])) break
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc066/tasks/abc066_b" }
d8543
test
S = list(input()) S.sort() if S == ['a', 'b', 'c']: print("Yes") else: print("No")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc093/tasks/abc093_a" }
d8544
test
n = int(input()) a = list(map(int, input().split())) aord = sorted([i for i in range(n)], key=lambda x: a[x] * (n - x) * (x + 1)) b = sorted(map(int, input().split()))[::-1] new_b = [0] * n for i in range(n): new_b[aord[i]] = b[i] b = new_b m = 998244353 c = [0] * n for i in range(n): c[i] = a[i] * b[i] % m ans = 0 for i in range(n): u = c[i] * (n - i) * (i + 1) % m ans = (ans + u) % m print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1165/E" }
d8545
test
import sys import copy input = sys.stdin.readline n,m,k=list(map(int,input().split())) A=list(map(int,input().split())) SHOP=[list(map(int,input().split())) for i in range(m)] A=sorted(A)[:k] A=A[::-1] SHOP.sort(key=lambda x:x[0]) from itertools import accumulate DP=[0]+list(accumulate(A)) SUM=copy.deepcopy(DP) for i in range(k+1): for x,y in SHOP: if x>i: break DP[i]=min(DP[i],DP[i-x]+SUM[i]-SUM[i-x]-SUM[i]+SUM[i-y],DP[i-1]+A[i-1]) print(DP[-1])
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1154/F" }
d8546
test
from sys import stdin n = int(stdin.readline()) g = dict() for i in range(n-1): u,v = map(int,stdin.readline().split()) g.setdefault(u-1,[]).append(v-1) g.setdefault(v-1, []).append(u-1) st = [0] rank = [0]*n tree = [0]*n msk = [0]*n rd = dict() while len(st)>0: top = st.pop() msk[top] = 1 for c in g[top]: if msk[c] == 0: st.append(c) tree[c] = top rank[c] = rank[top]+1 rd.setdefault(rank[c], []).append(c) max_rank = max(rank) reach = [0]*n build = [0]*n ans = 0 for r in range(max_rank, 2, -1): for node in rd[r]: if reach[node] == 0: reach[node] = 1 reach[tree[node]] = 1 reach[tree[tree[node]]] = 1 build[tree[node]] = 1 print(sum(build))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1029/E" }
d8547
test
from sys import * from collections import * from math import * input = stdin.readline tc = int(input()) for tcase in range(tc): n, k = map(int, input().split()) lo = 1 hi = 10 ** 19 ans = -1 while (lo <= hi): mid = (lo + hi) // 2 divi = mid - mid // n if (divi >= k): ans = mid hi = mid - 1 else: lo = mid + 1 print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1352/C" }
d8548
test
from collections import deque n, k = map(int, input().split()) A = list(map(int, input().split())) B = deque() B.append(A[0]) nc = {} for i in set(A): nc[i] = 0 nc[A[0]] = 1 for i in range(1, n): if nc[A[i]] == 0: if len(B) == k: nc[B[0]] -= 1 B.popleft() B.append(A[i]) nc[A[i]] += 1 else: pass print(len(B)) print(*list(B)[::-1])
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1234/B2" }
d8549
test
import sys import math import cProfile DEBUG = False def log(s): if DEBUG and False: print(s) def calc_dmg(num, arr): maximum = 0 if num - len(arr) < 0: maximum = max(arr) return sum(arr) + maximum if DEBUG: sys.stdin = open('input.txt') pr = cProfile.Profile() pr.enable() n = sys.stdin.readline() n = int(n) dmg = [-sys.maxsize for _ in range(10)] for i in range(n): log(dmg) cards = [_[:] for _ in [[-sys.maxsize] * 3] * 4] k = sys.stdin.readline() k = int(k) for _ in range(k): c, d = sys.stdin.readline().split() c = int(c) d = int(d) cards[c].append(d) cards[1].sort(reverse=True) cards[2].sort(reverse=True) cards[3].sort(reverse=True) log(cards) # dmg[j] = max(dmg[j], # dmg[j - 1] + D(one card), # dmg[j - 2] + D(two cards), # dmg[j - 3] + D(three cards)) # Plus, if 1 <= j <= 3, dmg[j] = max(dmg[j], D(cards)) new_dmg = [] for j in range(10): use1 = max(cards[1][0], cards[2][0], cards[3][0]) use2 = max(cards[1][0] + cards[1][1], cards[1][0] + cards[2][0]) use3 = cards[1][0] + cards[1][1] + cards[1][2] maximum = dmg[j] if use1 > 0: maximum = max(maximum, dmg[j - 1] + calc_dmg(j, [use1])) if j == 1: maximum = max(maximum, use1) if use2 > 0: maximum = max(maximum, dmg[j - 2] + calc_dmg(j, [cards[1][0], cards[1][1]] if cards[1][0] + cards[1][1] == use2 else [cards[1][0], cards[2][0]])) if j == 2: maximum = max(maximum, use2) if use3 > 0: maximum = max(maximum, dmg[j - 3] + calc_dmg(j, [cards[1][0], cards[1][1], cards[1][2]])) if j == 3: maximum = max(maximum, use3) new_dmg.append(maximum) dmg = new_dmg log(dmg) print(max(dmg)) if DEBUG: pr.disable() pr.print_stats()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1176/F" }
d8550
test
# -*- coding: utf-8 -*- import sys from operator import add def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return list(map(int, input().split())) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print('Yes') def No(): print('No') def YES(): print('YES') def NO(): print('NO') sys.setrecursionlimit(10 ** 9) INF = float('inf') MOD = 10 ** 9 + 7 class SegTree: def __init__(self, n, func, init): self.n = n self.func = func self.init = init n2 = 1 while n2 < n: n2 <<= 1 self.n2 = n2 self.tree = [self.init] * (n2 << 1) def update(self, i, x): i += self.n2 self.tree[i] = x while i > 1: self.tree[i >> 1] = x = self.func(x, self.tree[i ^ 1]) i >>= 1 def query(self, a, b): l = a + self.n2 r = b + self.n2 s = self.init while l < r: if r & 1: r -= 1 s = self.func(s, self.tree[r]) if l & 1: s = self.func(s, self.tree[l]) l += 1 l >>= 1 r >>= 1 return s A = [ord(s)-97 for s in list(input())] N = len(A) st = [None] * 26 for i in range(26): st[i] = SegTree(N, add, 0) for i, a in enumerate(A): st[a].update(i, 1) for _ in range(INT()): a, b, c = input().split() if a == '1': b = int(b) cur = A[b-1] nxt = ord(c) - 97 st[cur].update(b-1, 0) st[nxt].update(b-1, 1) A[b-1] = nxt else: b = int(b) c = int(c) cnt = 0 for i in range(26): if st[i].query(b-1, c) >= 1: cnt += 1 print(cnt)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1234/D" }
d8551
test
for _ in range(int(input())): for _ in range(9): print (input().replace('2','1'))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1335/D" }
d8552
test
n, q = map(int, input().split()) par = [int(v)-1 for v in input().split()] chs = [[] for i in range(n)] for i, p in enumerate(par): chs[p].append(i+1) vis = [0 for _ in range(n)] bel = [1 for _ in range(n)] stack = [0] order = [0] while stack: v = stack[-1] if len(chs[v]) == vis[v]: if v != 0: bel[par[v-1]] += bel[v] stack.pop() continue ch = chs[v][vis[v]] vis[v] += 1 order.append(ch) stack.append(ch) FST = {} for i, c in enumerate(order): FST[c] = i out = [] for _ in range(q): u, k = map(lambda x: int(x) - 1, input().split()) if k >= bel[u]: out.append(-1) else: out.append(order[FST[u] + k] + 1) print('\n'.join(map(str, out)))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1006/E" }
d8553
test
a = int(input()) for i in range(a): a1, b, c, n = list(map(int, input().split())) t = max(a1, b, c) if ((a1 + b + c + n) % 3 == 0 and t <= (a1 + b + c + n)//3 ): print('YES') else: print('NO')
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1294/A" }
d8554
test
n, m = map(int, input().split()) x = list(map(int, input().split())) foo = [0 for _ in range(2+n)] for i in range(1, m) : p, q = x[i-1], x[i] if p == q : continue r = min(p, q) s = max(p, q) foo[0] += abs(p-q) foo[r] -= abs(p-q) foo[r] += max(p, q) - 1 foo[r+1] -= max(p, q) - 1 foo[r+1] += abs(p-q)-1 foo[s] -= abs(p-q)-1 foo[s] += min(p, q) foo[s+1] -= min(p, q) foo[s+1] += abs(p-q) foo[n+1] -= abs(p-q) # print(p, q, foo) for i in range(1,n+1) : foo[i] += foo[i-1] print(foo[i], end=' ') print()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1234/E" }
d8555
test
import sys input = lambda: sys.stdin.readline().rstrip() N, M = list(map(int, input().split())) X = [[] for i in range(N)] for i in range(N-1): x, y = list(map(int, input().split())) x -= 1 y -= 1 X[x].append(y) X[y].append(x) P = [-1] * N DE = [0] * N def EulerTour(n, X, i0 = 0): Q = [~i0, i0] ct = -1 ET = [] ET1 = [0] * n ET2 = [0] * n de = -1 while Q: i = Q.pop() if i < 0: ET2[~i] = ct de -= 1 continue if i >= 0: ET.append(i) ct += 1 if ET1[i] == 0: ET1[i] = ct de += 1 DE[i] = de for a in X[i][::-1]: if a != P[i]: P[a] = i for k in range(len(X[a])): if X[a][k] == i: del X[a][k] break Q.append(~a) Q.append(a) return (ET, ET1, ET2) ET, ET1, ET2 = EulerTour(N, X, 0) for _ in range(M): A = [max(P[int(a) - 1], 0) for a in input().split()][1:] mad = -1 for a in A: if DE[a] > mad: mad = DE[a] maa = a e = ET1[maa] for a in A: if not (ET1[a] <= e <= ET2[a]): print("NO") break else: print("YES")
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1328/E" }
d8556
test
from bisect import bisect_left as bl from bisect import bisect_right as br from heapq import heappush,heappop import math from collections import * from functools import reduce,cmp_to_key import sys input = sys.stdin.readline M = mod = 998244353 def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))) def inv_mod(n):return pow(n, mod - 2, mod) def li():return [int(i) for i in input().rstrip('\n').split()] def st():return input().rstrip('\n') def val():return int(input().rstrip('\n')) def li2():return [i for i in input().rstrip('\n')] def li3():return [int(i) for i in input().rstrip('\n')] for _ in range(val()): n = val() l = li() if max(l) == min(l): print('NO') continue print('YES') root = l[0] same = set() other = -1 for i in range(1, n): if l[i] == root: same.add(i) else: other = i print(1, i + 1) for i in same: print(i + 1, other + 1)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1433/D" }
d8557
test
q=int(input()) for t in range(q): n,k=map(int,input().split()) a=input() ko=0 used=[0]*n ans='' g=True for i in range(n): if a[i]=='1': ko+=1 else: if ko<=k: k-=ko ans=ans+'0' else: for j in range(ko-k): ans=ans+'1' ans=ans+'0' for j in range(k): ans=ans+'1' for j in range(i+1,n): ans=ans+a[j] print(ans) g=False break if g==True: for j in range(ko): ans=ans+'1' print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1256/D" }
d8558
test
from operator import itemgetter import sys input = sys.stdin.readline n, m = map(int, input().split()) info = [list(map(int, input().split())) + [i] for i in range(n)] info = sorted(info, key = itemgetter(1)) max_num = info[-1][1] N = max_num INF = 0 LV = (N-1).bit_length() N0 = 2**LV data = [0]*(2*N0) lazy = [0]*(2*N0) def gindex(l, r): L = (l + N0) >> 1; R = (r + N0) >> 1 lc = 0 if l & 1 else (L & -L).bit_length() rc = 0 if r & 1 else (R & -R).bit_length() for i in range(LV): if rc <= i: yield R if L < R and lc <= i: yield L L >>= 1; R >>= 1 def propagates(*ids): for i in reversed(ids): v = lazy[i-1] if not v: continue lazy[2*i-1] += v; lazy[2*i] += v data[2*i-1] += v; data[2*i] += v lazy[i-1] = 0 def update(l, r, x): *ids, = gindex(l, r) propagates(*ids) L = N0 + l; R = N0 + r while L < R: if R & 1: R -= 1 lazy[R-1] += x; data[R-1] += x if L & 1: lazy[L-1] += x; data[L-1] += x L += 1 L >>= 1; R >>= 1 for i in ids: data[i-1] = max(data[2*i-1], data[2*i]) def query(l, r): propagates(*gindex(l, r)) L = N0 + l; R = N0 + r s = INF while L < R: if R & 1: R -= 1 s = max(s, data[R-1]) if L & 1: s = max(s, data[L-1]) L += 1 L >>= 1; R >>= 1 return s ans = [] for i in range(n): l, r, j = info[i] r += 1 if query(l, r) < m: update(l, r, 1) else: ans.append(j+1) print(len(ans)) print(*ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1249/D1" }
d8559
test
def bitadd(a,w,bit): x = a while x <= (len(bit)-1): bit[x] += w x += x & (-1 * x) def bitsum(a,bit): ret = 0 x = a while x > 0: ret += bit[x] x -= x & (-1 * x) return ret n = int(input()) x = list(map(int,input().split())) v = list(map(int,input().split())) vlis = [] for i in v: vlis.append(i) vlis.sort() vdic = {} for i in range(n): vdic[vlis[i]] = i+1 #print (vdic) xv = [] for i in range(n): xv.append([x[i],v[i]]) xv.sort() ans = 0 BIT = [0] * (n+1) BIT2 = [0] * (n+1) for i in range(n): x,v = xv[i] ans += x * bitsum(vdic[v],BIT2) - bitsum(vdic[v],BIT) bitadd(vdic[v] , x , BIT) bitadd(vdic[v] , 1 , BIT2) print (ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1311/F" }
d8560
test
n, m = list(map(int, input().split())) maxN = 2 * (10 ** 5) + 10 edges = [[] for i in range(0, maxN)] que = [[] for _ in range(0, maxN)] ans = [0] * m sz = [1 for _ in range(0, n)] p = [i for i in range(0, n)] total_sum = 0 def get(u): if p[u] == u: return u p[u] = get(p[u]) return p[u] def unite(u, v): u = get(u) v = get(v) if u == v: return nonlocal total_sum total_sum -= (sz[u] * (sz[u] - 1)) // 2 total_sum -= (sz[v] * (sz[v] - 1)) // 2 total_sum += ((sz[u] + sz[v]) * (sz[u] + sz[v] - 1)) // 2 if sz[u] < sz[v]: p[u] = v sz[v] += sz[u] else: p[v] = u sz[u] += sz[v] for i in range(1, n): u, v, w = list(map(int, input().split())) u -= 1 v -= 1 edges[w].append((u, v)) ques = list(map(int, input().split())) for i in range(0, m): que[ques[i]].append(i) for i in range(0, maxN): for u, v in edges[i]: unite(u, v) for id in que[i]: ans[id] = total_sum print(" ".join(str(x) for x in ans))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1213/G" }
d8561
test
import sys import math def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def MI(): return list(map(int, sys.stdin.readline().split())) def SI(): return sys.stdin.readline().strip() t = II() for q in range(t): n = II() a = sorted(LI()) boo = True for i in range(1,n): if a[i]-a[i-1]>1: boo = False break print("YES" if boo else "NO")
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1399/A" }
d8562
test
def mi(): return list(map(int, input().split())) ''' 4 4 1010 1101 ''' n,m = mi() a = list(input()) b = list(input()) pb = [0]*m if b[0]=='1': pb[0] = 1 for i in range(1,m): if b[i]=='1': pb[i] = 1 pb[i]+=pb[i-1] ans = 0 if m>=n: for i in range(n): if a[i]=='1': ans+=(pb[m-n+i]*pow(2,n-i-1,998244353))%998244353 ans%=998244353 print(ans%998244353) else: for i in range(n-m,n): if a[i]=='1': ans+=(pb[i-(n-m)]*pow(2,n-1-i,998244353))%998244353 ans%=998244353 print(ans%998244353)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1066/E" }
d8563
test
for _ in range(int(input())): n=int(input()) if(n%4!=0): print('NO') elif(n%4==0): print('YES') a=[] for i in range(1,n//2+1): a.append(i*2) s=sum(a) s1=0 for i in range(1,n//2): x=i*2-1 a.append(x) s1+=x a.append(s-s1) print(*a)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1343/B" }
d8564
test
for _ in range(int(input())): n = int(input()) ar = list(map(int, input().split())) keke = dict() for elem in ar: if elem in keke: keke[elem] += 1 else: keke[elem] = 1 ans = 0 for i in range(n): num = ar[i] for j in range(i + 1, n): num += ar[j] if num in keke: ans += keke[num] keke[num] = 0 print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1352/E" }
d8565
test
import sys from collections import deque input=sys.stdin.readline t=1 t=int(input()) for _ in range(t): n=int(input()) val=set([0,2*10**5+1]) seg=[(0,2*10**5+1)] for i in range(n): l,r=list(map(int,input().split())) val.add(l) val.add(r) seg.append((l,r)) val=list(val) val.sort() comp={i:e+1 for e,i in enumerate(val)} for i in range(n+1): l,r=seg[i] seg[i]=(comp[l],comp[r]) deg=[0]*(n+1) out=[[] for i in range(n+1)] for i in range(n+1): for j in range(i+1,n+1): l,r=seg[i] L,R=seg[j] if L<=l and r<=R: out[j].append(i) deg[i]+=1 elif l<=L and R<=r: out[i].append(j) deg[j]+=1 ans=[0] deq=deque(ans) while deq: v=deq.popleft() for nv in out[v]: deg[nv]-=1 if deg[nv]==0: deq.append(nv) ans.append(nv) dp=[0]*(n+1) def solve(v): query=[[] for i in range(2*n+3)] for nv in out[v]: l,r=seg[nv] query[r].append((l,dp[nv])) subdp=[0]*(2*n+3) for i in range(1,2*n+3): res=subdp[i-1] for l,val in query[i]: test=subdp[l-1]+val res=max(test,res) subdp[i]=res dp[v]=subdp[-1]+1 for v in ans[::-1]: solve(v) print(dp[0]-1)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1399/F" }
d8566
test
a = int(input()) for i in range(a): x, y = map(int, input().split()) t = x * 60 + y print(24*60 - t)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1283/A" }
d8567
test
for _ in range(int(input())): n = int(input()) s = input() balance = 0 index = {0: 1} ans = [10**9] i = 1 for x in s: if x == 'U': balance += 10 ** 9 elif x == 'D': balance -= 10 ** 9 elif x == 'L': balance += 1 else: balance -= 1 if balance in index: ans = min(ans, [i + 1 - index[balance], index[balance], i]) index[balance] = i + 1 i += 1 if ans[0] == 10 ** 9: print(-1) else: print(ans[1], ans[2])
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1296/C" }
d8568
test
from collections import defaultdict as dd for _ in range(int(input())): n=int(input()) a=list(map(int,input().split())) d=dd(int) for i in a: d[i]+=1 ma=0 r=len(d.keys()) for i in d.keys(): ma=max(ma,min(d[i]-1,r),min(d[i],r-1)) print(ma)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1335/C" }
d8569
test
import traceback import sys sys.setrecursionlimit(200010) try: # alpha = "abcdefghijklmnopqrstuvwxyz" n = int(input()) a = [0] a.extend(list(map(int, input().split()))) D = [[] for i in range(n+1)] for i in range(n-1): e1,e2 = (map(int, input().split())) D[e1].append(e2) D[e2].append(e1) # for i in range(1,n+1): # if i not in D: # D[i] = [] visited = [False for i in range(n+1)] cost = [a[i] for i in range(n+1)] parent = [0 for i in range(n+1)] val = 0 def dfs(s, depth): nonlocal visited nonlocal cost nonlocal val nonlocal a nonlocal D stack = [(s,depth)] while stack: s, depth = stack[-1] if visited[s]: stack.pop() cost[parent[s]]+=cost[s] continue else: visited[s] = True val += depth*a[s] for i in D[s]: if not visited[i]: parent[i] = s stack.append((i, depth+1)) # cost[s]+=cost[i] dfs(1, 0) # ans = 1 max_cost = val # print(max_cost) visited = [False for i in range(n+1)] cost[0] = sum(a) def trav(s, some_val): nonlocal cost nonlocal visited nonlocal max_cost nonlocal D stack = [(s,some_val)] while stack: s, some_val = stack.pop() visited[s] = True # print(some_val, s) if some_val>max_cost: max_cost = some_val for i in D[s]: if not visited[i]: # print(i, some_val, cost[s], cost[i]) stack.append((i, some_val+(cost[0]-cost[i])-cost[i] )) trav(1, val) print(max_cost) except Exception as ex: traceback.print_tb(ex.__traceback__) print(ex)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1092/F" }
d8570
test
t = int(input()) for _ in range(t): n, k = list(map(int, input().split())) l = list(map(int, input().split())) d = dict() d[0] = 0 for v in l: vv = (k - v) % k if vv: if vv not in d: d[vv] = vv + 1 else: d[vv] += k print(max(d.values()))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1374/D" }
d8571
test
class Solution: def findContentChildren(self, g, s): """ :type g: List[int] :type s: List[int] :rtype: int """ res = 0 heapq.heapify(g) s.sort() for num in s: if not g: break elif g[0] <= num: res += 1 heapq.heappop(g) return res
PYTHON
{ "starter_code": "\nclass Solution:\n def findContentChildren(self, g: List[int], s: List[int]) -> int:\n ", "url": "https://leetcode.com/problems/assign-cookies/" }
d8572
test
class Solution: def getRow(self, k): """ :type k: int :rtype: List[int] """ res = [1] cur = k for i in range(k//2): res += res[-1] * cur // (i+1), cur -= 1 if k % 2 == 0: res = res + res[:-1][::-1] else: res = res + res[::-1] return res
PYTHON
{ "starter_code": "\nclass Solution:\n def getRow(self, rowIndex: int) -> List[int]:\n ", "url": "https://leetcode.com/problems/pascals-triangle-ii/" }
d8573
test
class Solution: def hammingWeight(self, n: int) -> int: count = 0 while n!=0: n &= (n-1) count += 1 return count
PYTHON
{ "starter_code": "\nclass Solution:\n def hammingWeight(self, n: int) -> int:\n ", "url": "https://leetcode.com/problems/number-of-1-bits/" }
d8574
test
class Solution: def plusOne(self, digits): """ :type digits: List[int] :rtype: List[int] """ carry=1 for i in range(len(digits)-1, -1, -1): digits[i]+=carry if digits[i] > 9: digits[i]-=10 carry=1 else: carry=0 if carry == 0: break if carry == 1: digits.insert(0, 1) return digits
PYTHON
{ "starter_code": "\nclass Solution:\n def plusOne(self, digits: List[int]) -> List[int]:\n ", "url": "https://leetcode.com/problems/plus-one/" }
d8575
test
a,b=map(int,input().split(" ")) print(max(max(a+b,a*b),a-b))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc098/tasks/abc098_a" }
d8576
test
def main(): N, D = [int(n) for n in input().split(" ")] cnt = 0 for i in range(N): X, Y = [int(x) for x in input().split(" ")] if X ** 2 + Y ** 2 <= D ** 2: cnt += 1 print(cnt) main()
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc174/tasks/abc174_b" }
d8577
test
N = input() X = int(N) if X % sum(list(map(int, N))) == 0: print("Yes") else: print("No")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc080/tasks/abc080_b" }
d8578
test
N=int(input()) A=list(map(int,input().split())) SUM=abs(A[0]) for i in range(N): if i < N-1: SUM += abs(A[i+1]-A[i]) else: SUM += abs(0-A[i]) now=0 for i in range(N): if i != N-1: diff = abs(A[i+1]-now)-abs(A[i]-now)-abs(A[i+1]-A[i]) now = A[i] else: diff = abs(0-now)-abs(A[i]-now)-abs(0-A[i]) print(SUM + diff)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc092/tasks/arc093_a" }
d8579
test
c = input() vo = ['a','e','i','o','u'] print('vowel' if c in vo else 'consonant')
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc049/tasks/abc049_a" }
d8580
test
s= input() color = "chokudai" d = [] for c in s: if c != color: d.append(c) color = c print(len(d)-1)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc047/tasks/arc063_a" }
d8581
test
#ABC086B a,b = input().split() a += b a = int(a) print("Yes" if int((a**.5))**2 == a else "No")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc086/tasks/abc086_b" }
d8582
test
# -1 0 1を足したもののうち最大値を数える n = int(input()) a = list(map(int, input().split())) # ai=0の場合もあるので-1がありえることに注意 適当にa[0]を-1の数とする d = [0] * (10**5 + 10) for av in a: for x in [-1, 0, 1]: # 前述の通りa[0]を-1の数とする d[av + x + 1] += 1 print(max(d))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc072/tasks/arc082_a" }
d8583
test
print(int(input())**2 - int(input()))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc074/tasks/abc074_a" }
d8584
test
a,b,c=map(int, input().split()) print("YES" if b-a==c-b else "NO")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc058/tasks/abc058_a" }
d8585
test
n = input() if '9' in n: print('Yes') else: print('No')
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc073/tasks/abc073_a" }
d8586
test
import bisect N,M,X = map(int,input().split()) A = list(map(int,input().split())) index = bisect.bisect_left(A,X) ans = min(M-index,index) print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc094/tasks/abc094_b" }
d8587
test
h,w=list(map(int,input().split())) dx=[0,1,0,-1] ; dy=[1,0,-1,0] A=[list(input()) for i in range(h)] for i in range(h): for j in range(w): if A[i][j]=="#": for q,e in zip(dx,dy): if 0<=i+q<h and 0<=j+e<w: if A[i+q][e+j]=="#":break else: print("No");return print("Yes")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc096/tasks/abc096_c" }
d8588
test
a,b,c=list(map(int,input().split())) print(('Yes'if a+b==c or b+c==a or c+a==b else'No'))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc047/tasks/abc047_a" }
d8589
test
a,b,c,d = map(int,input().split()) ab = a + b cd = c + d if ab > cd: print('Left') elif ab < cd: print('Right') else: print('Balanced')
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc083/tasks/abc083_a" }
d8590
test
n=int(input()) F = [int(input().replace(" ",""),2) for _ in range(n)] P = [list(map(int,input().split())) for _ in range(n)] total = -10**9 for i in range(1,2**10): pgain = 0 for f,p in zip(F,P): pgain += p[bin(f&i).count("1")] if total < pgain: total = pgain k = i print(total)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc080/tasks/abc080_c" }
d8591
test
a,b = list(map(int, input().split())) s = input() count = 0 ans = 'Yes' for i in range(a+b+1): if i == a: if s[i] != '-': ans = 'No' break else: if s[i] == '-': ans = 'No' break print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc084/tasks/abc084_b" }
d8592
test
W,a,b=map(int,input().split());print([abs(a-b)-W,0][abs(a-b)<=W])
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc056/tasks/abc056_b" }
d8593
test
a, b, k = map(int,input().split()) for i in range(a,min(b,a+k-1)+1): print(i) for i in range(max(b-k+1,a+k),b+1): print(i)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc093/tasks/abc093_b" }
d8594
test
A,S,C=map(str,input().split()) print("A"+S[0]+"C")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc048/tasks/abc048_a" }
d8595
test
a, b, x = map(int, input().split()) print("YES" if a <= x and x <= a+b else "NO")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc094/tasks/abc094_a" }
d8596
test
x, t = list(map(int, input().split())) print((max(0, x - t)))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc072/tasks/abc072_a" }
d8597
test
a=1 for i in[*open(0)][1].split():a*=int(i);a=[-1,a][0<=a<=10**18] print(a)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc169/tasks/abc169_b" }
d8598
test
n=int(input()) a=int(input()) if n%500<=a: print("Yes") else: print("No")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc088/tasks/abc088_a" }
d8599
test
X,A,B=list(map(int,input().split())) if A-B>=0: print("delicious") elif -A+B<=X: print("safe") else: print("dangerous")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc065/tasks/abc065_a" }
d8600
test
N = int (input ()) x = 1 while x**2 <= N: x += 1 x -= 1 print (x**2)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc077/tasks/abc077_b" }