problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03042
s345639135
Wrong Answer
s = input() f = (0 < int(s[:2]) < 12) s = (0 < int(s[2:]) < 12) ans = 'NA' if f: ans = 'YYMM' elif s: ans = 'MMYY' elif f and s: ans = 'AMBIGUOUS' print(ans)
p02631
s493839186
Accepted
n=int(input()) a=list(map(int,input().split())) tmp=[] for i in range(n): if i%2==1: continue x=a[i]^a[i+1] tmp.append(x) S=0 for j in range(len(tmp)): S = S^tmp[j] ans=[] for k in range(n): p = a[k]^S ans.append(p) print(*ans)
p03163
s034816816
Accepted
N,W=map(int,input().split()) w=[] v=[] for i in range(N): ww,vv=map(int,input().split()) w.append(ww) v.append(vv) dp=[[0 for i in range(W+1)] for j in range(N+1)] for i in range(N): for j in range(W+1): if(j-w[i]>=0): dp[i+1][j]=max(dp[i+1][j],dp[i][j-w[i]]+v[i]) dp[i+1][j]=max(dp[i+1][j],dp[i][j]) print(dp[N][W])
p03565
s575806457
Accepted
import re s = input().replace('?', '.') t = input() for i in range(len(s)-len(t), -1, -1): if re.match(s[i:i+len(t):], t): s = s.replace('.', 'a') print(s[:i:]+t+s[i+len(t)::]) exit() print('UNRESTORABLE')
p02854
s112688711
Accepted
import math num = int(input()) num_list = list(map(int,input().split())) ans = sum(num_list)/2 #numl = sum(num_list[:num//2]) #numr = sum(num_list[num//2:num]) #print(ans,numl,numr) total = 0 flag = "off" for i in range(num): total += num_list[i] if total >= ans: #print(ans) if ans -(total - num_list[i]) < total - ans: ans = ans -(total - num_list[i]) else: ans = total - ans break #print(n1,n2) #print(min((n2-ans),(ans-n1))) print(math.ceil(ans*2))
p02598
s646664191
Accepted
n,k=map(int,input().split()) a=list(map(int,input().split())) l=0 r=1e9+5 while l+1!=r: m = (l+r)//2 cnt = 0 for x in a: cnt += (x-1)//m if cnt <= k: r = m else: l = m print(int(r))
p03329
s521339622
Accepted
n = int(input()) dp = [n]*100010 dp[0] = 0 pow69 = [6**i for i in range(1,7)] + [9**i for i in range(1,6)] for i in range(1,n+1): dp[i] = dp[i-1] + 1 for p in pow69: dp[i] = min(dp[i],dp[i-p]+1) print(dp[n])
p02848
s624144936
Accepted
n = int(input()) f = lambda c : 'A' if c == 'Z' else chr(ord(c)+1) for c in input(): for _ in range(n): c = f(c) print(c, end='') print()
p02768
s268913115
Wrong Answer
import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n,a,b=map(int,input().split()) sum=0 for i in range(n): if(i!=a or i!=b): tmp=combinations_count(n,i) sum+=tmp result= sum%(10**9+7) print(result)
p02730
s225277626
Accepted
S=input() N=len(S) if S!=S[::-1]: print("No") elif S[:(N-1)//2]!=S[(N-1)//2-1::-1]: print("No") elif S[(N+3)//2-1:]!=S[:(N-1)//2:-1]: print("No") else: print("Yes")
p03803
s924258021
Accepted
a,b = map(int, input().split()) if a==1: a=14 if b==1: b=14 if a>b: print('Alice') elif a<b: print('Bob') else: print('Draw')
p02700
s213817295
Wrong Answer
A, B, C, D = map(int, input().split()) T_HP = A T_AT = B A_HP = C A_AT = D T_count = 0 A_count = 0 while T_HP >= 0: T_HP -= T_AT T_count += 1 while A_HP >= 0: A_HP -= A_AT A_count += 1 if T_count > A_count: print('Yes') else: print('No')
p03457
s155481510
Wrong Answer
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') N = int(readline().rstrip()) pos = (0, 0) used_time = 0 for _ in range(N): t, x, y = map(int, readline().split()) cost = abs(pos[0] - x) + abs(pos[1] - y) available = t - used_time # print("cost: {}".format(cost)) # print("available: {}".format(available)) if cost > available or (cost - available) % 2 != 0: print('No') quit() used_time += t pos = (x, y) print('Yes')
p02678
s313665817
Wrong Answer
N, M = map(int, input().split()) node =[[] for _ in range(N)] for _ in range(M): x, y = map(int, input().split()) node[x-1].append(y-1) node[y-1].append(x-1) ct = [-1]*N i = 0 stack = [] ct[0] = 0 stack.append(0) while len(stack) != 0: v = stack.pop() for e in node[v]: if ct[e] == -1: ct[e] = v stack.append(e) print('Yes') for i in range(1,N): print(ct[i]+1)
p02613
s891241606
Accepted
N = int(input()) A = [input() for _ in range(N)] c0=A.count("AC") c1=A.count("WA") c2=A.count("TLE") c3=A.count("RE") print("AC x",c0) print("WA x",c1) print("TLE x",c2) print("RE x",c3)
p03387
s069791473
Accepted
X = list(map(int,input().split())) X.sort() ans = 0 a = X[2] - X[1] ans += a ans += (X[2] - (X[0] + a)) // 2 #print(ans) if (X[2] - (X[0] + a)) % 2 == 1: ans += 2 print(ans)
p02678
s913600808
Accepted
n,m=[int(x) for x in input().rstrip().split()] l=[[] for x in range(n)] for i in range(m): a,b=[int(x) for x in input().rstrip().split()] l[a-1].append(b-1) l[b-1].append(a-1) done=[False for i in range(n)] ans=[0 for i in range(n)] def bfs(): stack=[0] done[0]=True while(stack): now=stack.pop(0) done[now]=True for i in l[now]: if done[i]==True: continue ans[i]=now+1 done[i]=True stack.append(i) bfs() print("Yes") print(*ans[1:])
p03472
s233284763
Accepted
n,h=map(int,input().split()) ab=[list(map(int,input().split())) for i in range(n)] ab.sort(reverse=True,key=lambda x:x[1]) a_max=0 for a,b in ab: a_max=max(a,a_max) cnt=0 damage=0 for a,b in ab: if damage>=h: print(cnt) exit() if b<=a_max: break cnt+=1 damage+=b zan=h-damage cnt+=(zan+a_max-1)//a_max print(cnt)
p02701
s964556445
Wrong Answer
n = int(input()) slist = [] for i in range(n): news = str(input()) slist.append(news) # print(slist) slist_u = list(set(slist)) print(slist_u) slist_u_len = len(slist_u) print(slist_u_len)
p03417
s895955146
Accepted
n,m = map(int,input().split()) print(abs((n-2) * (m-2)))
p02628
s644819353
Accepted
N, K = map(int, input().split()) p = list(map(int, input().split())) print(sum(sorted(p)[:K]))
p03017
s095894292
Accepted
n,a,b,c,d = map(int,input().split()) s = input() S = s[:max(c,d)] #print(S) l = len(S) C = True D = False for i in range(l-1): if i >= min(a,b) and S[i]=='#' and S[i+1]=='#': C = False break if c > d and d > i >= max(a,b)-1: if S[i-1]=='.' and S[i]=='.' and S[i+1]=='.': D = True if not C: print('No') elif C and not D: if c < d: print('Yes') else: print('No') else: print('Yes')
p02678
s106141552
Accepted
# 幅優先探索 from collections import deque N, M = map(int, input().split()) AB = [map(int, input().split()) for _ in range(M)] links = [[] for _ in range(N + 1)] for a, b in AB: links[a].append(b) links[b].append(a) result = [-1] * (N + 1) q = deque([1]) while q: i = q.popleft() for j in links[i]: if result[j] == -1: result[j] = i q.append(j) print('Yes') print(*result[2:], sep='\n')
p03495
s585670290
Accepted
import collections n,k = map(int,input().split()) a = list(map(int,input().split())) c = sorted(list(collections.Counter(a).values()),reverse=True) print(sum(c[k:]))
p02597
s115151941
Accepted
n = int(input()) s = input() res = 0 tem = s.find('WR') if tem == -1: print(res) else: i, j = 0, len(s)-1 while i<j: while i < j and s[i] != 'W': i+=1 while i < j and s[j] != 'R':j -= 1 if s[i] == 'W' and s[j] == 'R': res += 1 i += 1 j -= 1 print(res)
p02607
s321434307
Accepted
N=int(input()) a=list(map(int,input().split())) ans=0 for i in range(0,N,2): if a[i]%2==1: ans+=1 print(ans)
p02730
s287876738
Wrong Answer
s = str(input()) ans = 0 def kaibun(tex): n = len(tex) before = tex[0:int((n-1)/2)] after = tex[int((n+3)/2-1):] if before == before[::-1] and after == after[::-1]: return 1 else: return 0 ans += kaibun(s) before = s[0:int((len(s)-1)/2)] after = s[int((len(s)+3)/2-1):] if ans == 1 and after == after[::-1] and before == before[::-1]: print('Yes') else: print('No')
p02687
s134310495
Accepted
s = input() if s == "ABC": print("ARC") else: print("ABC")
p03605
s621510665
Accepted
print("Yes" if "9" in input() else "No")
p03761
s466775926
Wrong Answer
n = int(input()) lis = [input() for _ in range(n)] ans = "" for i in "abcdefghijklmnopqrstuvexyz": mn = 50 for j in lis: mn = min(mn,j.count(i)) ans += i*mn print(ans)
p03673
s994807959
Wrong Answer
n = int(input()) l = list(map(int, input().split())) ogya = [] if n%2==0: for i in range (0, n): if i%2==0: ogya.insert(0, l[i]) else: ogya.append(l[i]) else: for i in range (0, n): if i%2==0: ogya.append(l[i]) else: ogya.insert(0, l[i]) print(*ogya)
p03289
s790366746
Accepted
s=input() print('AC' if s[0]=='A' and s[2:-1].count('C')==1 and s[1].islower() and s[1:].replace('C','',1).islower() else 'WA')
p03073
s917547230
Wrong Answer
S = list(input()) n = len(S) s1 = 0 s2 = 0 for i, j in enumerate(S): if i%2 == 0: if j == '1': s1 += 1 else: s2 += 1 else: if j == '0': s2 += 1 else: s1 += 1 print(min(s1, s2))
p03387
s023354246
Accepted
A,B,C=map(int,input().split()) M=[A,B,C] M.sort() kaisuu1=M[2]-M[1] M[0]+=kaisuu1 M[1]+=kaisuu1 nokori=M[1]-M[0] q,r=divmod(nokori,2) sum_kaisuu=kaisuu1+q if r==1: sum_kaisuu+=2 print(sum_kaisuu)
p03075
s506469997
Accepted
import itertools antenna = [int(input()) for _ in range(6)] distance = antenna.pop() flag = True for i in itertools.combinations(antenna, 2): if abs(i[0] - i[1]) > distance: print(':(') flag = False break if flag: print('Yay!')
p02796
s766805006
Wrong Answer
N = int(input()) list_ = list() for i in range(N): X,L = map(int,input().split()) max_ = min(10**9,X+L) min_ = max(0,X-L+1) list_.append((X,min_,max_)) list_.sort() d = 0 nowmax = -1 nowmin = -1 for x, min_, max_ in list_: if nowmax >= min_: d += 1 if nowmin >= min_: pass elif nowmax <= max_: pass else: nowmin = min_ nowmax = max_ else: nowmin = min_ nowmax = max_ print(N-d)
p03817
s230389574
Wrong Answer
x = int(input()) if x > 11: if x % 11 > 6: ans = x // 11 * 2 + 2 else: ans = x // 11 * 2 + 1 else: if x % 11 > 6: ans = 2 else: ans = 1 print(ans)
p02717
s619591200
Wrong Answer
a,b,c = map(int,input().split()) print(b,c,a)
p02766
s537513537
Accepted
N,K = map(int,input().split()) for i in range(1,100000000): if K ** i > N: print(i) break
p03107
s386452607
Wrong Answer
S = str(input()) x = len(S) if S[0] == '1': while '10' in S: S = S.replace('10', '') S = S.replace('01', '') else: while '01' in S: S = S.replace('01', '') S = S.replace('10', '') print(x - len(S))
p03345
s952405826
Accepted
a,b,c,k=map(int,input().split()) if k%2==0: print(a-b) else: print(b-a)
p02695
s799847903
Accepted
n, m, q = map(int, input().split()) a = [] for _ in range(q): a.append(list(map(int, input().split()))) import itertools List = [] for v in itertools.combinations_with_replacement(range(1, m+1), n): List.append(list(v)) answer = [] for l in List: ans = 0 for j in a: if l[j[1]-1] - l[j[0]-1] == j[2]: ans += j[3] answer.append(ans) print(max(answer))
p03012
s540868587
Accepted
n=int(input()) w=list(map(int,input().split())) #w.sort() ss=sum(w) ans=10**9 cur=0 for i in range(n-1): cur+=w[i] ans=min(ans,abs(ss-2*cur)) print(ans)
p02970
s721149006
Wrong Answer
def main(): n, d = map(int, input().split()) x = 1 while True: monitoring = 2 * d * x if monitoring < n: x += 1 else: break print(x) if __name__ == '__main__': main()
p02659
s658175644
Wrong Answer
a, b = map(float, input().split()) a = int(a) from decimal import Decimal from fractions import Fraction import math dc_b = Decimal.from_float(b) print(math.floor(dc_b*a))
p03745
s651372938
Accepted
n = int(input()) a = list(map(int,input().split())) flg = 0 ans = 0 for i in range(1,n): if a[i] == a[i-1]: continue elif a[i] > a[i-1]: if flg == -1: ans += 1 flg = 0 else: flg = 1 elif a[i] < a[i-1]: if flg == 1: ans += 1 flg = 0 else: flg = -1 print(ans+1)
p03163
s530833803
Accepted
# D Knapsack 1 from collections import deque n, w = map(int,input().split()) wv_list = deque([[int(x) for x in input().split()] for y in range(n)]) dp = [[float("-Inf")] * (w+1) for _ in range(n+1)] dp[0] = [0]*(w+1) for i in range(n): _w,_v = wv_list.popleft() for j in range(w+1): if j-_w < 0: dp[i+1][j] = dp[i][j] else: dp[i+1][j] = max(dp[i][j], dp[i][j-_w]+_v) print(dp[n][w])
p02759
s318120957
Accepted
N = int(input()) if N%2 == 0: print(int(N/2)) else: print(int(N/2) + 1)
p02989
s279221040
Wrong Answer
N=int(input()) D=[int(i) for i in input().split()] mid=N//2-1 print(D[mid+1]-D[mid])
p02973
s758625581
Wrong Answer
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) As = [-int(input()) for _ in range(N)] from bisect import bisect_left lis = [1] for a in As: if a>=lis[-1]: lis.append(a) else: lis[bisect_left(lis, a)] = a print(len(lis))
p02911
s579405513
Accepted
n, k, q = map(int, input().split()) a = [int(input()) for _ in range(q)] p = [0 for i in range(n)] for a_ in a: p[a_ - 1] += 1 for p_ in p: if k - q + p_ <= 0: print('No') else: print('Yes')
p03543
s676261477
Wrong Answer
N = str(input()) a, b, c, d = N[0], N[1], N[2], N[3] ans = "No" for i in range(4): a, b, c, d = b, c, d, a if a == b == c: ans = "Yes" print(ans)
p02791
s245321642
Accepted
#設定 import sys input = sys.stdin.buffer.readline #ライブラリインポート from collections import defaultdict #入力受け取り def getlist(): return list(map(int, input().split())) #処理内容 def main(): N = int(input()) P = getlist() S = [0] * N S[0] = P[0] for i in range(1, N): S[i] = min(S[i - 1], P[i]) # print(S) ans = 0 for i in range(N): if S[i] >= P[i]: ans += 1 print(ans) if __name__ == '__main__': main()
p03419
s382736652
Wrong Answer
import math import collections import fractions import itertools def solve(): n, m = map(int, input().split()) if n == m == 1: print(1) elif n == 1: print(m-2) elif n == m == 2: print(0) else: print((n-2)*(m-2)) return 0 if __name__ == "__main__": solve()
p02584
s384231110
Accepted
X, K, D = map(int, input().split()) sho = abs(X)//D amari = abs(X) % D if abs(X) > K * D: print(abs(X) - K*D) exit(0) if sho % 2 == K % 2: print(amari) else: print(D - amari)
p04030
s163444672
Accepted
S = input() ans = [] for s in S: if s == 'B': if len(ans) > 0: ans.pop(-1) else: ans.append(s) print(''.join(ans))
p03836
s089109252
Accepted
sx ,sy, tx, ty = map(int, input().split()) ans = "" ans += "U" * (ty-sy) + "R" * (tx-sx) ans += "D" * (ty-sy) + "L" * (tx-sx) ans += "L" + "U" * (ty-sy+1) + "R" * (tx-sx+1) + "D" ans += "R" + "D" * (ty-sy+1) + "L" * (tx-sx+1) + "U" print(ans)
p03645
s353033678
Accepted
ma = lambda :map(int,input().split()) n,m = ma() tr = [[] for i in range(n)] for i in range(m): a,b = ma() tr[a-1].append(b-1) tr[b-1].append(a-1) f = False for i in tr[0]: for s in tr[i]: if s==n-1: f =True print("POSSIBLE") if f else print("IMPOSSIBLE")
p03699
s251225930
Accepted
N = int(input()) res = set([0]) for _ in range(N): s = int(input()) res |= set([r + s for r in res]) res = list(res) res.sort() n = len(res) for i in range(n-1, -1, -1): if res[i] % 10 == 0: continue print(res[i]) break else: print(0)
p03617
s162883289
Accepted
import sys def input(): return sys.stdin.readline().rstrip() from operator import itemgetter def main(): q,h,s,d=map(int,input().split()) n=int(input()) weight=[(0.25,q,q/0.25),(0.5,h,h/0.5),(1,s,s),(2,d,d/2)] weight.sort(key=itemgetter(2)) cost=0 for w in weight: kosu=n//w[0] cost+=int(w[1]*kosu) n-=w[0]*kosu print(cost) if __name__=='__main__': main()
p03474
s572764177
Accepted
A, B = map(int, input().split()) S = input() ans = 'Yes' for i, s in enumerate(S): if i == A: if s != '-': ans = 'No' if i != A: if s == '-': ans = 'No' print(ans)
p03239
s751301339
Accepted
n,T =map(int,input().split()) ans = 10**3+1 for i in range(n): c,t=map(int,input().split()) if t > T: continue else: ans = min(ans,c) if ans == 10**3+1: print('TLE') else: print(ans)
p03457
s885910537
Wrong Answer
N=int(input()) t_,x_,y_=(0,0,0) ans = 'Yes' for n in range(N): t,x,y = list(map(int,input().split())) T = t-t_ manhattan_dist = abs(x-x_)+abs(y-y_) if T >= manhattan_dist and manhattan_dist%2 == T%2: pass else: ans='No' print(ans)
p03250
s007911586
Accepted
a,b,c = map(int,input().split()) X =a*10 + b + c Y =b*10 + a + c Z =c*10 + a + b ans =max(X,Y,Z) print(ans)
p03730
s134446491
Accepted
a,b,c = map(int,input().split()) flag = False for i in range(1,b+1): if (a*i-c)%b==0: flag = True print('YES' if flag==True else 'NO')
p02959
s019910536
Accepted
N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) total = 0 for i in range(N): if(A[i]<=B[i]): if(A[i+1]<= B[i] - A[i]): total+= A[i+1]+A[i] A[i+1]=0 else: A[i+1]-= B[i] - A[i] total += B[i] else: total += B[i] print(total)
p03274
s755820640
Accepted
N,K=map(int,input().split()) x=list(map(int,input().split())) res=[] for i in range(N-K+1): tmp = min(abs(x[i]),abs(x[i+K-1]))+x[i+K-1]-x[i] res.append(tmp) print(min(res))
p03475
s646961599
Accepted
N= int(input()) li = [list(map(int,input().split())) for _ in range(N-1)] for i in range(N-1): ci,si,fi = li[i] time = si+ci for j in range(i+1,N-1): cj,sj,fj = li[j] if time%fj != 0: time = ((time//fj)+1)*fj #print(i,time) if time < sj: time = sj time += cj print(time) print(0)
p02917
s731142154
Accepted
N = int(input()) B = list(map(int, input().split())) ans = B[0] + B[N-2] for i in range(1, N-1): ans += min(B[i-1], B[i]) print(ans)
p03469
s215332880
Accepted
print(input().replace('2017', '2018'))
p03438
s636266909
Wrong Answer
import sys n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) plus, minus = 0, 0 if n == 1: if a[0] < b[0]: print('Yes') else: print('No') sys.exit() for i, j in zip(a, b): num = j-i if num >= 0: plus += num else: minus -= num if plus >= minus*2: print('Yes') else: print('No')
p02665
s173125392
Accepted
n = int(input()) a = list(map(int, input().split())) leaf = sum(a) - 1 now = 1 ans = 0 for i, num in enumerate(a): ans += now now -= num if leaf >= now: leaf -= now now *= 2 elif leaf > 0: now += leaf leaf = 0 if now < 0: print(-1) exit() print(ans)
p02848
s826710654
Accepted
N = int(input()) result = [] for c in input(): r = ord(c) + N # Zを超えている if r > 90: r = 65 + r % 90 - 1 result.append(chr(r)) print(''.join(result))
p03435
s452694310
Wrong Answer
ans = 0 for i in range(3): k = list(map(int,input().split())) ans += sum(k) if ans >= 6 and ans%3 == 0: print("Yes") else: print("No")
p02724
s638892764
Accepted
a = int(input()) b = a // 500 *1000 c = (a - a // 500 * 500) // 5 * 5 print(b+c)
p04031
s445016247
Accepted
N=int(input()) A=list(map(int,input().split())) b=sum(A)//N a=b+1 c=b+1 x=0 y=0 z=0 for i in A: x+=(a-i)**2 y+=(b-i)**2 z+=(c-i)**2 print(min(x,y,z))
p02983
s901907335
Wrong Answer
l,r=map(int,input().split()) x=[] if r-l>=2018: print(0) else: for i in range(l,r+1): x.append(i%2019) x.sort() print((x[0]*x[1])%2019)
p02823
s167432765
Wrong Answer
N, A, B = map(int, input().split()) if ((B-A)+1)%2==0: print(min(B-1,(A-1)+((B-A)//2)+1)) else: print(int((B-A)/2))
p03352
s552911708
Accepted
x = int(input()) s = set([1]) for i in range(2,501): for j in range(2,10): if (i**j) <= x: s.add(i**j) print(max(list(s)))
p03219
s226054643
Accepted
x,y=map(int,input().split()) print(x+y//2)
p03131
s819986621
Accepted
K,A,B=map(int,input().split(' ')) if K<A+1: print(K+1) else: print(max(K+1,B+(B-A)*max(0,(K-(A+1))//2)+max(0,(K-(A+1)))%2))
p03145
s307114452
Wrong Answer
c,a,b=map(int,input().split()) s=(a+b+c)/3 print(int(s*(s-a)*(s-b)*(s-c)))
p03385
s195173754
Wrong Answer
print("Yes" if len(input())==3 else "No")
p02918
s627785482
Accepted
n, k = map(int, input().split()) s = input() pre=s[0] tmp=0 ans=0 check=0 for i in range(1, n): if s[i] != pre: check+=1 pre=s[i] if check%2==1 and tmp < k: tmp+=1 ans+=1 if check%2==0 and tmp < k+1: ans+=1 if tmp == k: tmp+=1 else: ans+=1 print(ans)
p02597
s838451608
Wrong Answer
n = int(input()) s = list(input()) num = 0 k = -1 for i in range(1,n): if i + k >= n-1: break if s[-i] == 'R': j = k+1 while True: if j +i == n-1: k = j break if s[j] == 'W': s[j] = 'R' s[-i] = 'W' k = j num += 1 break j += 1 print(num)
p02729
s570658116
Wrong Answer
n,m=map(int,input().split()) print((n+m)*(n+m-1)/2-n*m)
p02578
s863651224
Wrong Answer
a=int(input()) b=list(map(int,input().split())) c=0 if a==0: print(0) else: for i in range(a-1): if b[i]>b[i+1]: b[i+1]=b[i+1]+1 c=c+1 print(c)
p02718
s970208698
Wrong Answer
n,m = map(int,input().split()) a = list(map(int,input().split())) a.sort(reverse=True) ans = 0 for i in a: if i > sum(a)/(4*m): ans += 1 if ans == m: print("Yes") exit() else: print("No") exit()
p03827
s093388207
Accepted
N = int(input()) S = str(input()) sum = 0 L = [] for i in range(N): if S[i] == "I": sum += 1 L.append(sum) elif S[i] == "D": sum -= 1 L.append(sum) if max(L) > 0: print(max(L)) else: print(0)
p02983
s242096038
Accepted
mod=2019 L,R = map(int,input().split()) ls =[] if R-L>=mod-1: print(0) exit() else: for i in range(R-L+1): ls.append((L+i)%mod) ans=10000 for i in range(len(ls)-1): for j in range(i+1,len(ls)): ans = min(ans,(ls[i]*ls[j])%mod) print(ans)
p03645
s227716455
Accepted
def main(): n,m = map(int,input().split()) sa = set() sb = set() for i in range(m): a,b = map(int,input().split()) if a == 1: sb.add(b) if b == n: sa.add(a) if len(sa&sb) > 0: print('POSSIBLE') else: print('IMPOSSIBLE') if __name__ == '__main__': main()
p02691
s837229195
Accepted
import sys sys.setrecursionlimit(10 ** 7) read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(input()) A = list(map(int, input().split())) CNT = [0] * (10 ** 7) ans = 0 for i in range(N): a = A[i] p = i - a if 0 <= p <= (10 ** 7): ans += CNT[p] if 0 <= i + a <= (10 ** 7): CNT[i + a] += 1 print(ans)
p03131
s942402729
Accepted
K, A, B = map(int, input().split()) CNT = K - A + 1 # 最初、A枚になるまでビスケットを増やす # 残り回数でできるだけAとBを行う # 残り回数が1余ったならビスケットを増やす print(max(A + CNT // 2 * (B - A) + CNT % 2, K + 1))
p03250
s749881812
Accepted
x, y, z = map(int, input().split()) i = x + y + z print(max(x, y, z)* 10 + i - max(x, y, z))
p03380
s070656823
Wrong Answer
N = int(input()) A = list(map(int,input().split())) ans_1 = max(A) ans_2 = 0 d = 1000000 for e in A: if d > abs(ans_1/2-e): d = abs(ans_1/2-e) ans_2 = e print(ans_1,ans_2)
p03814
s083061145
Wrong Answer
s = str(input()) start = 0 end = 0 for i in range(len(s)): if s[i]=='A' and start==0: start = i if s[-(i+1)]=='Z' and end==0: end = len(s)-i if start != 0 and end != 0: break print(end-start)
p02767
s100044898
Accepted
# C N = int(input()) X_list = list(map(int, input().split())) mean_X = round(sum(X_list)/N) res = 0 for x in X_list: res += (x - mean_X)**2 print(res)
p03377
s985881558
Wrong Answer
a,b,x=map(int,input().split()) if a+b>x: print('YES') else: print('NO')
p03910
s531006693
Accepted
n=int(input()) c=0 for i in range(1,n+1): if i*(i+1)//2>=n: c=i break for i in range(c,0,-1): if i<=n: print(i) n-=i
p02659
s809737149
Wrong Answer
from math import floor def main(): a, b = map(float, input().split()) print(floor(a * b)) if __name__ == '__main__': main()