_id
stringlengths
2
5
partition
stringclasses
2 values
text
stringlengths
5
289k
language
stringclasses
1 value
meta_information
dict
title
stringclasses
1 value
d8401
test
k,s=map(int,input().split()) print(len([2 for z in range(k+1) for y in range(k+1) if 0<=s-y-z<=k]))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc051/tasks/abc051_b" }
d8402
test
s=input() s1=int(s[0]+s[1]) s2=int(s[2]+s[3]) if (0<s1<13)and(0<s2<13): print("AMBIGUOUS") elif (0<s1<13): print("MMYY") elif (0<s2<13): print("YYMM") else: print("NA")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc126/tasks/abc126_b" }
d8403
test
n=int(input()) odd=(n+1)//2 even=n//2 print(odd*even)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc108/tasks/abc108_a" }
d8404
test
a,b = map(int,input().split()) b += a if b>23: print(b-24) else: print(b)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc057/tasks/abc057_a" }
d8405
test
n, r = map(int, input().split()) print(r+100*(10-min(10, n)))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc156/tasks/abc156_a" }
d8406
test
n, k = list(map(int, input().split())) ans = 0 while int(n) > 0: n = n // k ans += 1 print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc156/tasks/abc156_b" }
d8407
test
print(-(-int(input()) // 2))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc157/tasks/abc157_a" }
d8408
test
a, b = map(int, input().split()) print("Yay!" if a <= 8 and b <= 8 else ":(")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc100/tasks/abc100_a" }
d8409
test
S=input() a=1145141919810 for i in range(len(S)-2): a=min(a,abs(753-int(S[i:i+3]))) print(a)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc114/tasks/abc114_b" }
d8410
test
from bisect import * from collections import * from itertools import * import functools import sys import math from decimal import * from copy import * from heapq import * getcontext().prec = 30 MAX = sys.maxsize MAXN = 10**6+1 MOD = 10**9+7 spf = [i for i in range(MAXN)] def sieve(): for i in range(2,MAXN,2): spf[i] = 2 for i in range(3,int(MAXN**0.5)+1): if spf[i]==i: for j in range(i*i,MAXN,i): if spf[j]==j: spf[j]=i def mhd(a,b): return abs(a[0]-b[0])+abs(b[1]-a[1]) def charIN(x= ' '): return(sys.stdin.readline().strip().split(x)) def arrIN(x = ' '): return list(map(int,sys.stdin.readline().strip().split(x))) def eld(x,y): a = y[0]-x[0] b = x[1]-y[1] return (a*a+b*b)**0.5 def lgcd(a): g = a[0] for i in range(1,len(a)): g = math.gcd(g,a[i]) return g def ms(a): msf = -MAX meh = 0 st = en = be = 0 for i in range(len(a)): meh+=a[i] if msf<meh: msf = meh st = be en = i if meh<0: meh = 0 be = i+1 return msf,st,en def ncr(n,r): num=den=1 for i in range(r): num = (num*(n-i))%MOD den = (den*(i+1))%MOD return (num*(pow(den,MOD-2,MOD)))%MOD def flush(): return sys.stdout.flush() '''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*''' n = int(input()) a = arrIN() mx = max(a) cnt = 0 temp = [] for i in a: cnt+=mx-i temp.append(mx-i) g = lgcd(temp) print(cnt//g,g)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1216/D" }
d8411
test
def main(): n = int(input()) arr = sorted(map(int, input().split())) j = 1 for x in arr: if x >= j: j += 1 print(j - 1) return 0 main()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1165/B" }
d8412
test
import math n,m=map(int,input().split()) neigh=[] for i in range(n): neigh.append([]) for i in range(m): a,b=map(int,input().split()) neigh[a-1].append(b-1) neigh[b-1].append(a-1) seen=set() index=[0]*n diams=[] trees=0 for i in range(n): if i not in seen: trees+=1 index[i]=trees seen.add(i) layer=[i] prev=None pars=[None] while layer!=[]: newlayer=[] newpars=[] for i in range(len(layer)): vert=layer[i] par=pars[i] for child in neigh[vert]: if child!=par: newlayer.append(child) newpars.append(vert) index[child]=trees seen.add(child) prev=layer layer=newlayer pars=newpars far=prev[0] layer=[[far]] pars=[None] prev=None while layer!=[]: newlayer=[] newpars=[] for i in range(len(layer)): vert=layer[i][-1] par=pars[i] for child in neigh[vert]: if child!=par: newlayer.append(layer[i]+[child]) newpars.append(vert) prev=layer layer=newlayer pars=newpars diam=prev[0] lent=len(diam) mid=diam[lent//2] diams.append((lent-1,mid)) diams.sort(reverse=True) poss=[diams[0][0]] if len(diams)>1: poss.append(math.ceil(diams[0][0]/2)+1+math.ceil(diams[1][0]/2)) if len(diams)>2: poss.append(math.ceil(diams[1][0]/2)+2+math.ceil(diams[2][0]/2)) print(max(poss)) cent=diams[0][1] for i in range(len(diams)-1): print(cent+1,diams[i+1][1]+1)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1092/E" }
d8413
test
n, k = list(map(int, input().split())) a = list(map(int, input().split())) g = {} def dfs(v, p=-1): c = [dfs(child, v) for child in g.get(v, set()) - {p}] c.sort(key=len, reverse=True) r = [] i = 0 while c: if i >= len(c[-1]): c.pop() else: o = max(i, k - i - 1) s = q = 0 for x in c: if len(x) <= o: q = max(q, x[i]) else: s += x[o] q = max(q, x[i] - x[o]) r.append(q + s) i += 1 r.append(0) for i in range(len(r) - 1, 0, -1): r[i - 1] = max(r[i - 1], r[i]) while len(r) > 1 and r[-2] == 0: r.pop() o = (r[k] if k < len(r) else 0) + a[v] r.insert(0, max(o, r[0])) return r for _ in range(1, n): u, v = [int(x) - 1 for x in input().split()] g.setdefault(u, set()).add(v) g.setdefault(v, set()).add(u) print(dfs(0)[0])
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1249/F" }
d8414
test
d,l = list(map(int,input().split())) a = list(map(int,input().split())) letters = list(map(int,input().split())) pos = [0] * (1+d) for i,x in enumerate(a): pos[i+1] = pos[i] + x res = [] i = 1 for letter in letters: while pos[i]<letter: i+=1 res.append(str(i) + " " + str(letter - pos[i-1])) print('\n'.join(res))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/978/C" }
d8415
test
A = list(map(int, input().split())) A.sort() print(A[3] - A[0], A[3] - A[2], A[3] - A[1])
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1154/A" }
d8416
test
def deal(a,b,c='0'): if(c=='0' or a==c): if(a=='R'): return 'B' if(a=='B'): return 'R' if(a=='G'): return 'B' if(a=='R' and c=='B'): b = 'G' if (a == 'R' and c == 'G'): b = 'B' if (a == 'B' and c == 'R'): b = 'G' if (a == 'B' and c == 'G'): b = 'R' if (a == 'G' and c == 'B'): b = 'R' if (a == 'G' and c == 'R'): b = 'B' return b n = int(input()) ss = input() s = list(ss) answer = [s[0]] number = 0 for i in range(0,n-1): ans = "" if (s[i]==s[i+1]): number += 1 if(i==n-2): ans = deal(s[i],s[i+1]) else: ans = deal(s[i],s[i+1],s[i+2]) s[i+1] = ans answer.append(ans) else: answer.append(s[i+1]) s = "".join(answer) print(number) print(s)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1108/D" }
d8417
test
from collections import * input() a = list(map(int, input().split())) m = defaultdict(int) for x in reversed(a): m[x] = m[x + 1] + 1 v = max(list(m.keys()), key=m.get) seq = [] for i, x in enumerate(a): if v == x: seq.append(i + 1) v += 1 print(len(seq)) print(*seq)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/977/F" }
d8418
test
a, b = map(int, input().split()) if a == 2 or b == 2: print('No') else: print('Yes')
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc109/tasks/abc109_a" }
d8419
test
train_fare, bus_fare = list(map(int, input().split())) print((train_fare + bus_fare // 2))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc113/tasks/abc113_a" }
d8420
test
n = int(input()) print(n*n*n)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc140/tasks/abc140_a" }
d8421
test
n = int(input()) if any(c == n for c in [3, 5, 7] ) : print("YES") else: print("NO")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc114/tasks/abc114_a" }
d8422
test
a='ABD' if int(input())<1000:a='ABC' print(a)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc099/tasks/abc099_a" }
d8423
test
a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) x=int(input()) ls=[a,b,c,d,e] if (e-a)<=x: print("Yay!") else: print(":(")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc123/tasks/abc123_a" }
d8424
test
a = int(input()) s = input() if a >= 3200: print(s) else: print('red')
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc138/tasks/abc138_a" }
d8425
test
R = int(input()) if R < 1200: print("ABC") elif R < 2800: print("ARC") else: print("AGC")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc104/tasks/abc104_a" }
d8426
test
s = list(input()) for i in range(3): if s[i] == '1': s[i] = '9' else: s[i] = '1' t = '' for i in range(3): t += s[i] print(t)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc111/tasks/abc111_a" }
d8427
test
import sys import random from math import * def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def finput(): return float(input()) def tinput(): return input().split() def linput(): return list(input()) def rinput(): return map(int, tinput()) def fiinput(): return map(float, tinput()) def rlinput(): return list(map(int, input().split())) def trinput(): return tuple(rinput()) def srlinput(): return sorted(list(map(int, input().split()))) def YESNO(fl): if fl: print("NO") else: print("YES") def main(): #n = iinput() #k = iinput() #m = iinput() #n = int(sys.stdin.readline().strip()) #n, k = rinput() #n, m = rinput() #m, k = rinput() #n, k, m = rinput() #n, m, k = rinput() #k, n, m = rinput() #k, m, n = rinput() #m, k, n = rinput() #m, n, k = rinput() #q = srlinput() #q = rlinput() s = input() print(s[:2] + s[3::2]) for inytd in range(iinput()): main()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1367/A" }
d8428
test
q = int(input()) for _ in range(q): a, b = list(map(int, input().split())) print((b - a % b) % b)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1328/A" }
d8429
test
n,k=list(map(int,input().split())) a=list(map(int,input().split())) prefix=[a[0]] for i in range(1,n): prefix.append(prefix[-1]+a[i]) ans=[] for i in range(n): for j in range(i+k-1,n): if(i==0): ans.append(prefix[j]/(j-i+1)) else: ans.append((prefix[j]-prefix[i-1])/(j-i+1)) print(max(ans))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1003/C" }
d8430
test
for _ in range(int(input())): n, m = list(map(int, input().split())) l = list(map(int, input().split())) p = set(map(int, input().split())) for i in range(len(l)): for j in range(len(l) - 1): if l[j] > l[j + 1] and j + 1 in p: l[j], l[j + 1] = l[j + 1], l[j] ans = True for i in range(len(l) - 1): if l[i] > l[i + 1]: ans = False break print('YES' if ans else 'NO')
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1311/B" }
d8431
test
n = int(input()) s = input() i = 0 d = 1 t = [] while i < n: t.append(s[i]) i += d d += 1 print(''.join(t))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1095/A" }
d8432
test
import sys input = sys.stdin.readline n,m=list(map(int,input().split())) EDGE=[list(map(int,input().split())) for i in range(m)] EDGE.sort(key=lambda x:x[2]) WCHANGE=[] for i in range(1,m): if EDGE[i-1][2]!=EDGE[i][2]: WCHANGE.append(i) WCHANGE.append(m) Group=[i for i in range(n+1)] def find(x): while Group[x] != x: x=Group[x] return x def Union(x,y): if find(x) != find(y): Group[find(y)]=Group[find(x)]=min(find(y),find(x)) NOW=0 noneed=[0]*m ANS=0 for wc in WCHANGE: for j in range(NOW,wc): if find(EDGE[j][0])==find(EDGE[j][1]): noneed[j]=1 for j in range(NOW,wc): if noneed[j]==1: continue x,y,w=EDGE[j] if find(x)!=find(y): Union(x,y) else: ANS+=1 NOW=wc print(ANS)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1108/F" }
d8433
test
starts = ["RGB", "RBG", "BRG", "BGR", "GRB", "GBR"] N = int(input()) s = input() min_cost = float("inf") min_str = "" for k in starts: sp = (k * -(-N // 3))[:N] cost = sum(x != y for x, y in zip(s, sp)) if cost < min_cost: min_cost = cost min_str = sp print(min_cost) print(min_str)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1108/C" }
d8434
test
N = int(input()) x = [0] * N u = [0] * N for i in range(N): x[i], u[i] = list(map(str, input().split())) ans = 0 for i in range(N): if u[i] == 'JPY': ans += float(x[i]) else: ans += float(x[i]) * 380000 print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc119/tasks/abc119_b" }
d8435
test
N, i = list(map(int, input().split())) print(N - i + 1)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc107/tasks/abc107_a" }
d8436
test
a = int(input()) p, q = input().split() ans = '' for i in range(a): ans += p[i] ans += q[i] print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc148/tasks/abc148_b" }
d8437
test
S = list(map(str,input())) if S[0] != S[1] or S[1] != S[2]: print("Yes") else: print("No")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc158/tasks/abc158_a" }
d8438
test
S = str(input()) if "RRR" in S: print(3) elif "RR" in S: print(2) elif "R" in S: print(1) else: print(0)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc175/tasks/abc175_a" }
d8439
test
x,y,z=map(int,input().split()) print(z,end=' ') print(x,end=' ') print(y,end='')
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc161/tasks/abc161_a" }
d8440
test
# ABC127 # A Ferris Wheel a, b = list(map(int, input().split())) if a > 12: print(b) return elif a < 6: print((0)) return else: print((b // 2)) return
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc127/tasks/abc127_a" }
d8441
test
S=input() print((S.count('+')-S.count('-')))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc101/tasks/abc101_a" }
d8442
test
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): S = readline().strip() y, m, d = list(map(int, S.split('/'))) if m <= 4: print('Heisei') elif m > 4: print('TBD') return def __starting_point(): main() __starting_point()
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc119/tasks/abc119_a" }
d8443
test
# import collections, atexit, math, sys, bisect sys.setrecursionlimit(1000000) def getIntList(): return list(map(int, input().split())) try : #raise ModuleNotFoundError import numpy def dprint(*args, **kwargs): #print(*args, **kwargs, file=sys.stderr) # in python 3.4 **kwargs is invalid??? print(*args, file=sys.stderr) dprint('debug mode') except Exception: def dprint(*args, **kwargs): pass inId = 0 outId = 0 if inId>0: dprint('use input', inId) sys.stdin = open('input'+ str(inId) + '.txt', 'r') #标准输出重定向至文件 if outId>0: dprint('use output', outId) sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #标准输出重定向至文件 atexit.register(lambda :sys.stdout.close()) #idle 中不会执行 atexit N = getIntList() za = getIntList() cc = collections.Counter(za) zt = [] for x in cc: zt.append( cc[x] ) zt.sort( ) re = zt[-1] def findmid(l,r, e): if l>= len(zt): return -1 if e<=zt[l]: return l; if e>zt[r]: return -1 while l+1 <r: mid = (l+r)//2 if zt[mid] < e: l = mid else: r = mid return r for first in range(1, re//2 + 1): nowr = 0 t = first ind = -1 while 1: ind = findmid(ind+1,len(zt)-1, t) if ind<0: break nowr += t t*=2 re = max(re, nowr) print(re)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1077/E" }
d8444
test
from collections import deque n, k = map(int, input().split()) A = list(map(int, input().split())) B = deque() B.append(A[0]) for i in range(1, n): if A[i] not in B: if len(B) == k: B.popleft() B.append(A[i]) else: pass print(len(B)) print(*list(B)[::-1])
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1234/B1" }
d8445
test
from collections import Counter n, q = map(int, input().split()) a = map(int, input().split()) b = [int(input()) for _ in range(q)] counts = 32 * [0] for value, count in Counter(a).items(): counts[value.bit_length() - 1] = count for bj in b: ans = 0 for i in reversed(range(32)): count = min(bj >> i, counts[i]) ans += count bj -= count << i if bj != 0: print(-1) else: print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1003/D" }
d8446
test
from queue import Queue import sys import math import os.path # CONFIG sys.setrecursionlimit(10**9) # LOG def log(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) # INPUT def ni(): return list(map(int, input().split())) def nio(offset): return [int(x) + offset for x in input().split()] def nia(): return list(map(int, input().split())) # CONVERT def toString(aList, sep=" "): return sep.join(str(x) for x in aList) def mapInvertIndex(aList): return {k: v for v, k in enumerate(aList)} def countMap(arr): m = {} for x in arr: m[x] = m.get(x,0) + 1 return m def sortId(arr): return sorted(list(range(arr)), key=lambda k: arr[k]) # MAIN n, k = ni() c = nia() f = nia() h = [0] + (nia()) cc = countMap(c) cf = countMap(f) n1 = n+1 k1 = k+1 nk1 = n*k+1 dp = [[0]*nk1 for _ in range(n1)] for ni in range(1,n1): for ki in range(1,nk1): mficount = min(k,ki) + 1 for kii in range(mficount): # log(ni,ki, kii, dp[ni][ki], dp[ni-1][ki-kii] + h[kii]) dp[ni][ki] = max(dp[ni][ki], dp[ni-1][ki-kii] + h[kii]) # log(dp[ni]) # log(n,k) # log("c", cc) # log("f", cf) # log("h", h) # log(dp) res = 0 for fk,fv in list(cf.items()): # log(fk, fv, cc.get(fk,0)) res += dp[fv][cc.get(fk,0)] print(res)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/999/F" }
d8447
test
def main(): n = int(input()) arr = list(map(int, input().split())) dct = {} k = -1 m = 0 for i in range(n): try: dct[arr[i]] += 1 except: dct[arr[i]] = 1 if dct[arr[i]] > m: m = dct[arr[i]] k = arr[i] print(n - m) for i in range(n): if arr[i] == k: for j in range(i - 1, -1, -1): if arr[j] > k: print(2, j + 1, j + 2) else: print(1, j + 1, j + 2) break while i != n: if arr[i] > k: print(2, i + 1, i) if arr[i] < k: print(1, i + 1, i) i += 1 return 0 main()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1144/D" }
d8448
test
import sys INF = 10**20 MOD = 10**9 + 7 I = lambda:list(map(int,input().split())) from math import gcd from math import ceil from collections import defaultdict as dd, Counter from bisect import bisect_left as bl, bisect_right as br def solve(): n, k = I() s = input() ans = 0 last = -INF for i in range(n): if s[i] == '1': if i - last <= k: ans -= 1 last = i count = 0 continue if i - last > k: ans += 1 last = i print(ans) t, = I() while t: t -= 1 solve()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1367/C" }
d8449
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/D2" }
d8450
test
import sys input = sys.stdin.readline q=int(input()) for testcase in range(q): n=int(input()) A=sorted(set(map(int,input().split())),reverse=True) L=len(A) #print(A) ANS=A[0] for i in range(L): NOW0=A[i] NOW1=0 flag=0 for j in range(i+1,L): if NOW0%A[j]!=0: NOW1=A[j] ANS=max(ANS,NOW0+NOW1) for k in range(j+1,L): if NOW0%A[k]!=0 and NOW1%A[k]!=0: ANS=max(ANS,NOW0+NOW1+A[k]) #print("!",ANS) break break print(ANS)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1183/F" }
d8451
test
for _ in range(int(input())): n = int(input()) A = list(map(int, input().split())) A.sort() ans = 1 for i in range(n - 1): if A[i] + 1 == A[i + 1]: ans = 2 break print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1249/A" }
d8452
test
q=int(input()) for t in range(q): a,b,n,s=map(int,input().split()) v=min(a*n,s//n*n) if s-v>b: print("NO") else: print("YES")
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1256/A" }
d8453
test
n = int(input()) a = list(map(int, input().split())) a.sort() inc = list() dec = list() for x in a: if inc and inc[-1] == x: if dec and dec[-1] == x: print('NO') return dec.append(x) else: inc.append(x) print('YES') print(len(inc)) for x in inc: print(x, end=' ') print() print(len(dec)) for x in reversed(dec): print(x, end=' ') print()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1144/C" }
d8454
test
from sys import stdin n,k = list(map(int, stdin.readline().strip().split(' '))) AB = [] A = [] B = [] for i in range(n): t,a,b = list(map(int, stdin.readline().strip().split(' '))) if a == 1 and b == 1: AB.append(t) elif a == 1: A.append(t) elif b == 1: B.append(t) AB.sort() A.sort() B.sort() ans = 0 abi = 0 ai = 0 bi = 0 isPossible = True for i in range(k): if abi == len(AB) and (ai == len(A) or bi == len(B)): isPossible = False break if abi == len(AB): ans += (A[ai] + B[bi]) ai += 1 bi += 1 continue if ai == len(A) or bi == len(B): ans += AB[abi] abi += 1 continue if A[ai] + B[bi] <= AB[abi]: ans += (A[ai] + B[bi]) ai += 1 bi += 1 continue ans += AB[abi] abi += 1 continue if isPossible: print(ans) else: print(-1)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1374/E1" }
d8455
test
for ei in range(int(input())): n, k = map(int, input().split()) A = list(map(int, input().split())) ans = min(A) + k for i in A: if ans != -1 and abs(ans - i) > k: ans = -1 print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1183/B" }
d8456
test
#!/usr/bin/env python n = int(input()) a = list(map(int, input().split())) k = [None, 4, 8, 15, 16, 23, 42] s = [n, 0, 0, 0, 0, 0, 0] for ai in a: for i in range(6, 0, -1): if ai == k[i] and s[i - 1] > 0: s[i] += 1; s[i - 1] -= 1 break print(n - 6 * s[-1])
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1176/C" }
d8457
test
for _ in range(int(input())): a,b=map(int,input().split()) print((abs(a-b)+9)//10)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1409/A" }
d8458
test
ntest = int(input()) for testcase in range(ntest): x, y, n = list(map(int, input().split())) t = (n - y) // x * x + y print(t)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1374/A" }
d8459
test
n, k = map(int, input().split()) D = list(map(int, input().split())) z = {i: 0 for i in range(k)} for i in range(n): z[D[i] % k] += 1 cnt = z[0] // 2 for q in range(1, k // 2 + k % 2): cnt += min(z[q], z[k - q]) if k % 2 == 0: cnt += z[k // 2] // 2 print(cnt * 2)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1133/B" }
d8460
test
N, K = map(int, input().split()) S = input() print("".join(c.lower() if i == K else c for i, c in enumerate(S, 1)))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc126/tasks/abc126_a" }
d8461
test
n=int(input()) a=[] for i in range(n): t=list(input().split()) t[1]=int(t[1]) t.append(i) a.append(t) a.sort(key=lambda x:(x[0],-x[1])) for t in a: print(t[2]+1)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc128/tasks/abc128_b" }
d8462
test
k,x = map(int,input().split()) print("Yes" if k*500 >= x else "No")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc150/tasks/abc150_a" }
d8463
test
n,k = map(int,input().split()) ans = 0 for i in range(1,n+1): if i>=k: ans += (1/n) continue x = 1 while 1: i *= 2 if i>=k: break else:x+=1 ans += (1/n)*(1/2)**x print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc126/tasks/abc126_c" }
d8464
test
S = input() W = ["SUN","MON","TUE","WED","THU","FRI","SAT"] print(7-W.index(S))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc146/tasks/abc146_a" }
d8465
test
r, D, x = map(int, input().split()) for i in range(10): x = r * x - D print(x)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc127/tasks/abc127_b" }
d8466
test
input() num = list(map(int, input().split())) maxn = 0 l, r = 0, len(num)-1 j1, j2 = num[l], num[r] while l < r: if j1 == j2: maxn = max(j1, maxn) l += 1 j1 += num[l] elif j1 < j2: l += 1 j1 += num[l] else: r -= 1 j2 += num[r] print(maxn)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1006/C" }
d8467
test
for testcase in range(int(input())): vals = list(map(int, input().split())) ans = None for a in vals: for b in vals: for c in vals: if max(a, b) == vals[0] and max(a, c) == vals[1] and max(b, c) == vals[2]: ans = [a, b, c] if ans is None: print("NO") else: print("YES") print(*ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1385/A" }
d8468
test
n, m, k = [int(_) for _ in input().split()] a = [int(_) for _ in input().split()] b = k count = 0 for obj in a[::-1]: if obj > k: break if obj > b: if m > 1: m -= 1 b = k - obj count += 1 else: break else: b -= obj count += 1 print(count)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1066/D" }
d8469
test
n, k = map(int, input().split()) s = set() st = input() inp = input().split() for x in inp: s.add(x) current, ans = 0, 0 for x in st: if x in s: current += 1 else: ans += (current * (current + 1)) // 2 current = 0 ans += (current * (current + 1)) // 2 print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1272/C" }
d8470
test
for _ in range(int(input())): n=int(input()) l=list(map(int,input().split())) a=[] lis=[] prevsign=-1 if l[0]>0: prevsign=1 else: prevsign=0 i=0 for i in l: if (i>0 and prevsign==1) or (i<0 and prevsign==0): lis.append(i) else: if prevsign==1: a.append(max(lis)) lis=[] lis.append(i) prevsign=0 else: a.append(max(lis)) lis=[] lis.append(i) prevsign=1 if prevsign==1: a.append(max(lis)) lis=[] lis.append(i) prevsign=0 else: a.append(max(lis)) lis=[] lis.append(i) prevsign=1 print(sum(a))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1343/C" }
d8471
test
n, m = map(int, input().split()) g = [] for i in range(n): g.append([]) for i in range(m): u, v = map(int, input().split()) u-=1 v-=1 g[u]+=[v] g[v]+=[u] start = max(range(n), key=lambda i: len(g[i])) edges = [] vis = [False] * n q = [start] vis[start] = True while q: u = q.pop(0) for v in g[u]: if vis[v]: continue vis[v] = True edges.append((u, v)) q.append(v) for u, v in edges: print(u+1, v+1)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1133/F1" }
d8472
test
a=int(input()) for ufui in range(a): val=int(input()) num=val//2 + 1 count=0 for i in range(num): count=count+i*((2*i+1)**2 - (2*i-1)**2) print (count)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1353/C" }
d8473
test
from heapq import heappush, heappop n = int(input()) a = list(map(int, input().split())) edge = [[] for _ in range(n)] rev = [[] for _ in range(n)] inf = 10**9 cost = [inf]*n hq = [] for i, x in enumerate(a): if i+x < n: edge[i].append(i+x) rev[i+x].append(i) if (a[i] ^ a[i+x]) & 1: cost[i] = 1 if i-x >= 0: edge[i].append(i-x) rev[i-x].append(i) if (a[i] ^ a[i-x]) & 1: cost[i] = 1 if cost[i] == 1: hq.append((1, i)) while hq: c, v = heappop(hq) if cost[v] < c: continue c += 1 for dest in rev[v]: if cost[dest] > c: cost[dest] = c heappush(hq, (c, dest)) for i in range(n): if cost[i] == inf: cost[i] = -1 print(*cost)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1272/E" }
d8474
test
#-------------Program-------------- #----Kuzlyaev-Nikita-Codeforces---- #-------------Round615------------- #---------------------------------- t=int(input()) for i in range(t): n=int(input()) a=[] for i in range(2,int(n**0.5)+2): if len(a)==2: a.append(n) break if n%i==0: a.append(i) n//=i a=list(set(a)) if len(a)==3 and a.count(1)==0: print('YES') a.sort() print(a[0],a[1],a[2]) else: print('NO')
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1294/C" }
d8475
test
import sys input = sys.stdin.readline n=int(input()) s=list(input().strip()) ANS=0 for i in range(0,n,2): if s[i]==s[i+1]: ANS+=1 if s[i]=="a": s[i]="b" else: s[i]="a" print(ANS) print("".join(s))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1216/A" }
d8476
test
def solve(): Point=[] n=int(input()) for i in range(n): x,y=list(map(int,input().split())) Point.append((x,y)) data={} for each in Point: if each[0]<each[1]: try: tm=data[each[1]] except KeyError: data[each[1]]={} try: data[each[1]]['xi']=min(data[each[1]]['xi'],each[0]) except KeyError: data[each[1]]['xi']=each[0] try: data[each[1]]['xa'] = max(data[each[1]]['xa'], each[0]) except KeyError: data[each[1]]['xa'] = each[0] else: try: tm=data[each[0]] except KeyError: data[each[0]]={} try: data[each[0]]['yi']=min(data[each[0]]['yi'],each[1]) except KeyError: data[each[0]]['yi']=each[1] try: data[each[0]]['ya']=max(data[each[0]]['ya'],each[1]) except KeyError: data[each[0]]['ya'] = each[1] pre1=(0,0,0) pre2=(0,0,0) for each in sorted(data.keys()): x1,y1,w1=pre1 x2,y2,w2=pre2 if len(data[each])==2: if 'xa' in data[each]: x3, y3 = data[each]['xa'], each x4, y4 = data[each]['xi'], each if 'ya' in data[each]: x3, y3 = each, data[each]['ya'] x4, y4 = each, data[each]['yi'] else: x3,y3=data[each]['xi'],each x4,y4=each,data[each]['yi'] d=abs(x3-x4)+abs(y3-y4) pre1 = (x3, y3, min(abs(x1 - x4) + abs(y1 - y4) + w1 + d, abs(x2 - x4) + abs(y2 - y4) + w2 + d)) pre2=(x4,y4,min(abs(x1-x3)+abs(y1-y3)+w1+d,abs(x2-x3)+abs(y2-y3)+w2+d)) print(min(pre1[2],pre2[2])) def __starting_point(): solve() __starting_point()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1066/F" }
d8477
test
a = int(input()) b = int(input()) c = 1+2+3 print((c - (a+b)))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc148/tasks/abc148_a" }
d8478
test
L = int(input()) ans = (L / 3) ** 3 print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc159/tasks/abc159_c" }
d8479
test
n = int(input()) if n == 1: print('Hello World') else: a = int(input()) b = int(input()) print(a+b)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc112/tasks/abc112_a" }
d8480
test
a, b = map(int, input().split()) if a <= b: ans = str(a) * b else: ans = str(b) * a print(ans) return
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc152/tasks/abc152_b" }
d8481
test
C = input() C = ord(C) C = C+1 print(chr(C))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc151/tasks/abc151_a" }
d8482
test
S,T = map(str,input().split()) print(T + S)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc149/tasks/abc149_a" }
d8483
test
n = int(input()) a = list(map(int, input().split())) odd = [] even = [] for i in a: if i%2: odd.append(i) else: even.append(i) odd.sort() even.sort() if abs(len(odd) - len(even)) <= 1: print(0) else: if len(odd) > len(even): print(sum(odd[:len(odd)-len(even)-1])) else: print(sum(even[:len(even) - len(odd)-1]))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1144/B" }
d8484
test
n, a, b, k = map(int, input().split()) H = list(map(int, input().split())) for i in range(n): H[i] %= (a + b) if H[i] == 0: H[i] = a + b H.sort() ans = 0 for x in H: if x <= a: ans += 1 else: tok = (x + a - 1) // a - 1 if k >= tok: k -= tok ans += 1 print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1296/D" }
d8485
test
import bisect n, m = map(int, input().split()) ls = list(map(int, input().split())) mls = [] for i in range(0, n): mls.append((ls[i] % m, i)) mls.sort() # print(mls) bk1 = set() bk2 = set() aim = n // m cnt = 0 mis = [] for i in range(m): for j in range(aim): mis.append(i) p1 = 0 p2 = 0 while p2 < n: if mls[p1][0] > mis[p2]: p2 += 1 else: a = mis[p2] - mls[p1][0] ls[mls[p1][1]] += a cnt += a bk2.add(p2) p1 += 1 p2 += 1 if p1 < n and p2 == n: p1 = n for i in range(p2): if i not in bk2: p1 -= 1 a = m - mls[p1][0] + mis[i] ls[mls[p1][1]] += a cnt += a print(cnt) for i in ls: print(i, end=' ')
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/999/D" }
d8486
test
import collections def main(): from sys import stdin, stdout def read(): return stdin.readline().rstrip('\n') def read_array(sep=None, maxsplit=-1): return read().split(sep, maxsplit) def read_int(): return int(read()) def read_int_array(sep=None, maxsplit=-1): return [int(a) for a in read_array(sep, maxsplit)] def write(*args, **kwargs): sep = kwargs.get('sep', ' ') end = kwargs.get('end', '\n') stdout.write(sep.join(str(a) for a in args) + end) def write_array(array, **kwargs): sep = kwargs.get('sep', ' ') end = kwargs.get('end', '\n') stdout.write(sep.join(str(a) for a in array) + end) def enough(days): bought = [] # (type, amount) bought_total = 0 used_from = days for d in range(days, 0, -1): used_from = min(d, used_from) for t in offers.get(d, []): if K[t] > 0: x = min(K[t], used_from) K[t] -= x bought.append((t, x)) bought_total += x used_from -= x if not used_from: break remaining_money = days - bought_total ans = (total_transaction - bought_total) * 2 <= remaining_money for t, a in bought: K[t] += a return ans n, m = read_int_array() K = read_int_array() total_transaction = sum(K) offers = collections.defaultdict(list) for _ in range(m): d, t = read_int_array() offers[d].append(t-1) low = total_transaction high = low * 2 ans = high while low <= high: mid = (low + high) // 2 if enough(mid): ans = mid high = mid - 1 else: low = mid + 1 write(ans) main()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1165/F1" }
d8487
test
for _ in range(int(input())): n = int(input()) A = list(map(int, input().split())) B = {} for i in A: if i not in B: B[i] = 0 B[i] += 1 ans = 'YES' J = [] for i in B: if B[i] % 2: ans = 'NO' break else: for _ in range(B[i] // 2): J.append(i) if ans == 'YES': J.sort() s = set() for i in range(n): s.add(J[i] * J[-i-1]) if len(s) != 1: ans = 'NO' print(ans)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1203/B" }
d8488
test
import sys input = sys.stdin.readline n,m,k=list(map(int,input().split())) EDGE=[list(map(int,input().split())) for i in range(m)] EDGE.sort(key=lambda x:x[2]) EDGE=EDGE[:k] COST_vertex=[[] for i in range(n+1)] for a,b,c in EDGE: COST_vertex[a].append((b,c)) COST_vertex[b].append((a,c)) for i in range(min(m,k)): x,y,c=EDGE[i] EDGE[i]=(c,x,y) USED_SET=set() ANS=[-1<<50]*k import heapq while EDGE: c,x,y = heapq.heappop(EDGE) if (x,y) in USED_SET or c>=-ANS[0]: continue else: heapq.heappop(ANS) heapq.heappush(ANS,-c) USED_SET.add((x,y)) USED_SET.add((y,x)) for to,cost in COST_vertex[x]: if to!=y and not((y,to) in USED_SET) and c+cost<-ANS[0]: heapq.heappush(EDGE,(c+cost,y,to)) #USED_SET.add((y,to)) #USED_SET.add((to,y)) for to,cost in COST_vertex[y]: if to!=x and not((x,to) in USED_SET) and c+cost<-ANS[0]: heapq.heappush(EDGE,(c+cost,x,to)) #USED_SET.add((x,to)) #USED_SET.add((to,x)) print(-ANS[0])
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1196/F" }
d8489
test
import sys input = sys.stdin.readline n=int(input()) A=list(map(int,input().split())) B=[(a,ind) for ind,a in enumerate(A)] B.sort() DP=[0]*(n+1) for i in range(3,n-2): DP[i]=max(DP[i-1],DP[i-3]+B[i][0]-B[i-1][0]) #print(DP) MAX=max(DP) x=DP.index(MAX) REMLIST=[] while x>0: if DP[x]==DP[x-1]: x-=1 else: REMLIST.append(x) x-=3 REMLIST.sort() REMLIST.append(1<<60) print(max(A)-min(A)-MAX,len(REMLIST)) ANS=[-1]*n remind=0 NOW=1 for i in range(n): if i==REMLIST[remind]: NOW+=1 remind+=1 ANS[B[i][1]]=NOW print(*ANS)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1256/E" }
d8490
test
for _ in range(int(input())): n = int(input()) # arr = list(map(int, input().split())) # n, m = map(int, input().split()) arr = [] x = 1 while n > 0: if (n % 10): arr.append((n % 10) * x) n //= 10 x *= 10 print(len(arr)) print(*arr)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1352/A" }
d8491
test
for _ in range(int(input())): n = int(input()) P = list(map(int, input().split())) ans = [0] * n for i in range(n): if ans[i] == 0: now = i cnt = 0 cll = [] while True: now = P[now] - 1 cnt += 1 cll.append(now) if now == i: break for u in cll: ans[u] = cnt print(' '.join(list(map(str, ans))))
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1249/B1" }
d8492
test
for _ in range(int(input())): n = int(input()) A = list(map(int, input().split())) s = sum(A) print((s + n - 1) // n)
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1234/A" }
d8493
test
def ke(i): return a[i] n,m=map(int,input().split()) a=list(map(int,input().split())) b=[] for i in range(n): b.append(i) b.sort(key=ke) ans=[0]*n k=0 for i in range(1,n): if a[b[i]]==a[b[i-1]]: k+=1 ans[b[i]]=i-k else: k=0 ans[b[i]]=i for i in range(m): r1,r2=map(int,input().split()) if (a[r1-1]>a[r2-1]): ans[r1-1]-=1 elif a[r1-1]<a[r2-1]: ans[r2-1]-=1 for i in ans: print(i, end=' ')
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/978/F" }
d8494
test
n,k=map(int,input().split()) aa=list(map(int,input().split())) bb=list(map(int,input().split())) ab="abcdefghijklmnopqrstuvwxyz" #print(len(ab)) ss={} j=0 it=[] for i in aa: ss[i]=j j+=1 jj=0 for i in bb: ind=ss[i] j,ind=sorted([jj,ind]) it.append([j,ind]) # print(i,jj,ind) jj+=1 it.sort() do=1 ma=it[0][1] res=[] st=it[0][0] for i in it[1:]: if i[0]<=ma: ma=max(ma,i[1]) else: do+=1 res.append([st,ma]) st=i[0] ma=i[1] j+=1 if res==[]: res=[[0,n-1]] else: if res[-1][1]!=n-1: res.append([res[-1][1]+1,n-1]) if len(res)<k: print("NO") else: print("YES") if len(res)>k: # print(res[:k-1]) # print(res) res=res[:k-1]+[[res[k-1][0],n-1]] kk=-1 res.sort() ll=[0]*n for i in res: kk+=1 for j in range(i[0],i[1]+1): ll[aa[j]-1]=ab[kk] for i in ll: print(i,end="") print()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1213/F" }
d8495
test
n = int(input()) a = [int(x) for x in input().split()] b = [(a[i], i + 1) for i in range(n)] b.sort(reverse=True) ans = 0 for i in range(n): ans += b[i][0] * i + 1 print(ans) for i in b: print(i[1], end=' ')
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1216/B" }
d8496
test
n=int(input()) p=list(map(int,input().split())) c=1 q=p[0] for i in range(1,n): q=min(q,p[i]) if p[i]<=q: c+=1 print(c)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc152/tasks/abc152_c" }
d8497
test
import collections N=int(input()) L=list(map(int,input().split())) L=sorted(L) C=collections.Counter(L) D=list(C.keys()) E=list(C.values()) K=len(C) ans=0 for i in range(K): if D[i]==E[i]: ans+=0 if D[i]>E[i]: ans+=E[i] if D[i]<E[i]: ans+=(E[i]-D[i]) print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc082/tasks/arc087_a" }
d8498
test
a=list(map(int,input().split())) for i in range(len(a)): if a[i]==0: print(i+1)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc170/tasks/abc170_a" }
d8499
test
H, W = map(int, input().split()) ans = float('inf') for h in range(1,H): S = [h * W] w = W // 2 S += [(H-h) * w] S += [(H-h) * (W-w)] ans = min(ans,max(S)-min(S)) for h in range(1,H): S = [h * W] hb = (H-h) // 2 S += [hb * W] S += [(H-h-hb) * W] ans = min(ans,max(S)-min(S)) for w in range(1,W): S = [H * w] h = H // 2 S += [h * (W-w)] S += [(H-h) * (W-w)] ans = min(ans,max(S)-min(S)) for w in range(1,W): S = [w * H] wb = (W-w) // 2 S += [wb * H] S += [(W-w-wb) * H] ans = min(ans,max(S)-min(S)) print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc062/tasks/arc074_a" }
d8500
test
#!/usr/bin/env python n = int(input()) a = list(map(int, input().split())) n2 = 0 n4 = 0 for i in range(n): if a[i]%4 == 0: n4 += 1 elif a[i]%2 == 0: n2 += 1 ok = True if n2 == 0: if n4 >= n//2: ok = True else: ok = False else: n1 = n-n2-n4 n1 += 1 nn = n1+n4 if n4 >= nn//2: ok = True else: ok = False if ok: print('Yes') else: print('No')
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc069/tasks/arc080_a" }