problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03261
s576581288
Accepted
N = int(input()) W =[ input()] a = 'Yes' for i in range(1,N): k = input() W.append(k) if W[-2][-1]!=k[0] or len(set(W))!=(i+1): a = 'No' break print(a)
p02959
s486028570
Accepted
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) sum_a = sum(a) for i in range(n): tmp = min(a[i], b[i]) a[i] -= tmp b[i] -= tmp tmp = min(a[i + 1], b[i]) a[i + 1] -= tmp b[i] -= tmp ans = sum_a - sum(a) print(ans)
p03449
s927582961
Accepted
N = int(input()) lis1 = list(map(int,input().split())) lis2 = list(map(int,input().split())) sum1 = 0 sum2 = sum(lis2) sum = 0 for j in range(N): sum1 += lis1[j] if not j == 0: sum2 -= lis2[j-1] if sum <= sum1 + sum2: sum = sum1 + sum2 print(sum)
p04019
s302396210
Accepted
from collections import Counter s = Counter(input()) if (s['N'] > 0) ^ (s['S'] > 0) or (s['E'] > 0) ^ (s['W'] > 0): print('No') else: print('Yes')
p03761
s384167728
Accepted
import collections def main(): N = int(input()) S = [input()for n in range(N)] counter = [100] * 26 for s in S: S_count = collections.Counter(s) for i in range(26): counter[i] = min(counter[i], S_count[chr(i + 97)]) ans = '' for i in range(26): ans = ans + ...
p02688
s576643656
Accepted
n,k=map(int,input().split()) hoge=[0 for i in range(n)] for i in range(k): aaa=int(input()) huga=list(map(int,input().split())) for j in range(len(huga)): hoge[huga[j]-1]+=1 ans=0 for i in range(n): if(hoge[i]==0): ans+=1 print(ans)
p03524
s393351290
Accepted
s = input() count_a = s.count('a') count_b = s.count('b') count_c = s.count('c') if abs(count_a - count_b) <= 1 and abs(count_b - count_c) <= 1 and abs(count_c - count_a) <= 1: print('YES') else: print('NO')
p03607
s823949959
Accepted
n = int(input()) l = [int(input()) for _ in range(n)] from collections import Counter x = 0 for i in Counter(l).values(): if i%2 == 1: x += 1 print(x)
p03427
s368953859
Accepted
s = input() g = s[1:] a = g.replace('9','') if a == '': print(int(s[0])+(len(s)-1)*9) elif len(s) == 1: print(s) else: print(int(s[0])-1+9*(len(s)-1))
p03017
s876381282
Accepted
n, a, b, c, d = map(int, input().split()) s = input() if c < d: print("Yes" if s[a - 1:d].count("##") == 0 else "No") #aからd-1までで二個あるとあうと else: print("Yes" if s[a - 1:c].count("##") == 0 and s[b - 2:d + 1].count("...") > 0 else "No") #b-1からd+1までで飛び越すの
p03665
s421260885
Accepted
n, p = map(int, input().split()) a = list(map(int, input().split())) cnt = 0 for num in a: if num % 2 == 1: cnt += 1 ans = 0 if cnt == 0: if p % 2 == 0: ans = 2**n else: ans = 2**(n - 1) print(ans)
p03779
s798093721
Accepted
import sys input = sys.stdin.readline def main(): N = int(input()) ruiseki = 0 ans = 0 while ruiseki < N: ruiseki += ans ans += 1 print(ans - 1) if __name__ == '__main__': main()
p02603
s672457262
Accepted
n = int(input()) alst = list(map(int, input().split())) dp = [[1000, [0, 0]]] for a in alst: tmp1 = max(dp[-1][0], dp[-1][1][0] * a + dp[-1][1][1]) tmp2 = tmp1 // a tmp3 = tmp1 % a dp.append([tmp1, [tmp2, tmp3]]) print(dp[-1][0])
p03131
s230151929
Accepted
K, A, B = map(int, input().split()) bisket = 1 money = 0 if B - A > 2: remain = K - A + 1 bisket = A bisket += remain // 2 * (B - A) if remain % 2 == 1: bisket += 1 else: bisket += K print(bisket)
p03672
s642243028
Accepted
s = input() for i in range(1,len(s)-1): t = s[:-i] if t[len(t)//2:] == t[:len(t)//2]: print(len(t)) exit()
p02660
s672970428
Wrong Answer
def prime(p): memo = [] for i in range(2,(int(p**0.5)+1)): jousu = 1 while p%(i**jousu)==0: p //= i**jousu memo.append(i**jousu) jousu += 1 if p == n: memo.append(p) return memo n=int(input()) memo = prime(n) if len(memo) == 0: print(0) ...
p03592
s214163719
Wrong Answer
N,M,K = map(int,input().split()) ans = 'No' for n in range(N): for m in range(M): tmp = ((N-n)*m + (M-m)*n) if tmp==K: ans = 'Yes' print(ans)
p03239
s479191090
Accepted
N,T = map(int,input().split()) INF = 10**9 min_cost = INF for _ in range(N): c,t = map(int,input().split()) if t <= T: min_cost = min(min_cost,c) answer = min_cost if min_cost < INF else 'TLE' print(answer)
p03241
s787630804
Wrong Answer
import math N,M=map(int,input().split()) if N==1: print(M) else: ans=0 a=M/N for i in range(int(math.sqrt(M))+1,0,-1): if M%i==0 and a>=i: print(i) break
p03699
s187171725
Accepted
n = int(input()) s = [int(input()) for _ in range(n)] if (sum(s)%10!=0): print(sum(s)) else: s.sort() for i in s: if (i%10!=0): print(sum(s)-i) exit() print(0)
p02957
s110365633
Wrong Answer
a,b = map(int,input().split()) if((a + b) % 2 == 0): print((a + b) / 2) else: print('IMPOSSIBLE')
p02664
s468890417
Accepted
#from collections import deque,defaultdict from sys import stdin input = stdin.readline printn = lambda x: print(x,end='') inn = lambda : int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) ins = lambda : input().strip() DBG = True # and False BIG = 10**18 R = 10*...
p02571
s271084619
Wrong Answer
def probB(): S = input() T = input() if T in S: print(0) return maxequal = 0 for i in range(len(S) - len(T)): count = 0 for j in range(len(T)): if S[i + j] == T[j]: count += 1 if (count > maxequal): maxequal = ...
p02627
s019879265
Accepted
import sys import math def get_array(): return list(map(int, sys.stdin.readline().strip().split())) def get_ints(): return map(int, sys.stdin.readline().strip().split()) def input(): return sys.stdin.readline().strip() s=input() if s.isupper(): print("A") else: print("a")
p02801
s351640032
Accepted
C = input() print(chr(ord(C) + 1))
p02725
s777723505
Wrong Answer
ii = lambda : int(input()) mi = lambda : map(int,input().split()) li = lambda : list(map(int,input().split())) import numpy as np k,n = mi() a=np.array(li()) b = a[1:] - a[:n-1] b_max = np.max(b) c = a[0] + k-a[n-1] print(max(b_max,c))
p02699
s094099233
Wrong Answer
s, w = input('').split() if s >= w: print('safe') else: print('unsafe')
p02645
s657229924
Accepted
name = input() print(name[0:3])
p03627
s133925606
Wrong Answer
from collections import defaultdict from collections import deque import itertools import math def readInt(): return int(input()) def readInts(): return list(map(int, input().split())) def readChar(): return input() def readChars(): return input().split() d = defaultdict(int) n = readInt() for i in readChars(): ...
p02881
s028553392
Wrong Answer
import math N = int(input()) max_quo = float('inf') max_mod = 0 for i in range(1, int(math.sqrt(N))): if N%i == 0 and (N//i) < max_quo: max_quo = N//i max_mod = i elif max_quo < max_mod: break print(max_quo + max_mod - 2)
p02814
s582510802
Wrong Answer
n, m = map(int,input().split()) l = list(map(int,input().split())) import math def gcd(x, y): if y == 0: return x return gcd(y, x%y) def lcm(x, y): return x * y / gcd(x, y) ans = 1 tf = True for i in l: i /= 2 ans = lcm(ans, i) if (ans / i) % 2 == 0: print(0) tf = Fal...
p03103
s653041295
Accepted
L=list() R=list() T=0 N,M=map(int,input().split()) for i in range(N): A,B=map(int,input().split()) L.append(A) R.append(B) c = zip(L, R) c=sorted(c) L, R = zip(*c) L=list(reversed(L)) R=list(reversed(R)) while True: c=L[-1] T+=c*min(M,R[-1]) M-=min(M,R[-1]) L.pop(-1) R.pop(-1) if M==0: break print...
p03146
s273337781
Accepted
import sys import copy s = int(input()) def f(n): if n%2==0: return int(n/2) else: return 3*n+1 for i in range(1000000): if i == 0: a=[s] else: a.append(f(a[i-1])) if a.count(a[i]) == 2: print(i+1) sys.exit(0)
p02682
s311713695
Accepted
A,B,C,K = list(map(int, input().split())) if(K<=A): print(K) elif(K<=A+B): print(A) else: print(A-(K-A-B))
p02699
s750564300
Wrong Answer
s= input().split() if int(s[0])>int(s[1])/2: print("safe") else: print("unsafe")
p02946
s346573294
Wrong Answer
# ABC137B k, x = map(int, input().split()) print([i for i in range(x - k + 1, x + k)])
p02742
s406978096
Accepted
H,W=map(int,input().split()) w1=0--W//2 w2=W//2 if H==1 or W==1: print(1) else: print(w1*(0--H//2)+w2*(H//2))
p03962
s877705160
Wrong Answer
a = list(map(int, input().split())) if a[0] == a[1] and a[0] == a[2]: result = 2 elif a[0] == a[1] and a[0] != a[2]: result = 2 elif a[0] == a[2] and a[2] != a[1]: result = 2 elif a[1] == a[2] and a[2] != a[0]: result = 2 else: result = 3 print(result)
p03206
s846631219
Accepted
d = int(input()) ans = "Christmas" ans += " Eve" * (25-d) print(ans)
p02982
s561537063
Accepted
n , d =map(int,input().split()) x = [list(map(int,input().split())) for i in range(n)] count = 0 for i in range(n): for j in range(i + 1, n): s = 0 for k in range(d): s += (x[i][k] - x[j][k])**2 s = s ** 0.5 if int(s) == s: count += 1 print(count)
p02888
s283715812
Wrong Answer
import bisect n = int(input()) l = sorted(list(map(int, input().split()))) ans = 0 for i in range(n-1): for j in range(i+1, n): tmp = l[i] + l[j] d = bisect.bisect_left(l, tmp) - bisect.bisect_right(l, l[j]) ans += d print(ans)
p03013
s866949649
Wrong Answer
def main(): mod = 1000000007 N, M, *A = map(int, open(0).read().split()) A = set(A) F = [0] * (N + 1) F[0] = 1 if 1 in A: F[1] = 1 for i in range(2, N + 1): if i not in A: F[i] = (F[i-1] + F[i-2]) % mod print(F[N]) if __name__ == "__main__": main()
p03221
s642051779
Wrong Answer
n, m = map(int, input().split()) l = [] for i in range(m): p, y = input().split() l.append([p, y, m]) l.sort() l[0][1] = 1 for i in range(1, m): if l[i][0] == l[i - 1][0]: l[i][1] = l[i - 1][1] + 1 else: l[i][1] = 1 sortthird = lambda val: val[2] l.sort(key = sortthird) for i in l...
p03206
s259990982
Wrong Answer
d = input() if d == "25": print("Christmas") elif d == "24": print("Christmas eve") elif d == "23": print("Christmas eve eve") else: print("Christmas eve eve eve")
p03623
s332672621
Wrong Answer
x, a, b = map(int, input().split()) if abs(a - x) < abs(a - b): print('A') else: print('B')
p02772
s921012803
Wrong Answer
N = int(input()) A = list(map(int,input().split())) for count in A : if count % 2 == 0: if count % 3 != 0 and count %5 != 0: print("DENIED") else: print("APPROVED")
p03469
s158595451
Accepted
S = input() print('2018' + S[4:])
p03785
s428140034
Wrong Answer
from sys import stdin n,c,k = [int(x) for x in stdin.readline().rstrip().split()] li = [int(stdin.readline().rstrip()) for _ in range(n)] li.sort() time = li[0] people = 1 bus_num = 1 for i in li: if i-time > k or people > c: bus_num += 1 time = i people = 1 continue people += ...
p02775
s143558730
Wrong Answer
S = input() l = len(S) dp = [[0]*2 for _ in range(l+1)] for i in range(l): dp[i+1][0]=min(dp[i][1]+10-int(S[i]),dp[i][0]+int(S[i])) dp[i+1][1]=min(dp[i][1]+10-int(S[i])-1,dp[i][0]+int(S[i])+1) if int(S[0])>=4: print(dp[-1][0]+1) else: print(dp[-1][0])
p03449
s974925968
Accepted
def main(): N = int(input()) A = [int(i) for i in input().split()] B = [int(i) for i in input().split()] from itertools import accumulate Sa = list(accumulate(A)) Sb = list(accumulate([0] + B)) ans = 0 for i in range(N): cur = Sa[i] + (Sb[N] - Sb[i]) ans = max(ans, cur) ...
p03774
s790815874
Accepted
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N, M = mapint() AB = [list(mapint()) for _ in range(N)] CD = [list(mapint()) for _ in range(M)] for a, b in AB: dist = 10**18 ans = -1 for i in range(M): c, d = C...
p02835
s191290811
Accepted
lis = list(map(int,input().split())) if sum(lis) >=22: print("bust") else: print("win")
p03836
s463328355
Accepted
sx,sy,tx,ty=map(int,input().split()) dx=tx-sx dy=ty-sy root="" for i in range(dy): root=root+"U" for i in range(dx): root=root+"R" for i in range(dy): root=root+"D" for i in range(dx): root=root+"L" root=root+"L" for i in range(dy+1): root=root+"U" for i in range(dx+1): root=root+"R" root...
p03136
s263349994
Accepted
n = int(input()) L = list(map(int,input().split())) L = sorted(L,reverse=True) #print(L) #print(sum(L)) if sum(L)-L[0]*2>0: print('Yes') else: print('No')
p03624
s997040871
Accepted
s = list(input()) s.sort() a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'r', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] for i in a: if i not in s: print(i) exit() print('None')
p03971
s277589811
Accepted
n,a,b = map(int,input().split()) s = input() a_, b_ = 0, 0 for i in range(n): if s[i]=='a': if (a_ + b_) < a+b: a_ += 1 print('Yes') else: print('No') elif s[i]=='b': if (a_ + b_ ) < a+b and b_ < b: b_ += 1 print('Yes') ...
p02554
s718808759
Wrong Answer
N = input() x = int(N) y = (x*(x-1)*(10**(x-2))) % (10**9+7) print(y)
p02594
s736510281
Accepted
X = int(input()) if X >= 30: print('Yes') else: print('No')
p03699
s197721922
Wrong Answer
n = int(input()) x = 0 mn = 100 for i in range(n): s = int(input()) x += s if x % 10 != 0: if s <= mn: mn = s if x % 10 != 0: print(x) else: x -= mn if x % 10 == 0: print(0) else: if x < 0: print(0) exit() print(x)
p02705
s708563126
Accepted
import math R=int(input()) print(R*2*math.pi)
p02795
s275009185
Accepted
h = int(input()) w = int(input()) n = int(input()) print((n-1)//max([h,w])+1)
p02817
s040390871
Accepted
S,T = input().split() print(T+S)
p02888
s565795357
Accepted
import bisect N=int(input()) L=list(map(int, input().split())) L.sort() ans=0 for i in range(N-2): for j in range(i+1,N-1): #small = bisect.bisect_left(L, L[j]-L[i]) large = bisect.bisect_left(L, L[j]+L[i]) #print(i,j,L[i],L[j]," ",L[j]-L[i],L[j]+L[i],small,large) ans += max(large-j-1,0) p...
p03719
s454103377
Accepted
a,b,c=map(int,input().split()) if a<=c and c<=b: print("Yes") else: print("No")
p03555
s391802000
Wrong Answer
#入力例は合うがWAになる S = str(input()) T = str(input()) if [S[0],S[1],S[2]] == [T[2],T[1],T[0]]: print("Yes") else: print("No")
p03680
s303592223
Wrong Answer
n = int(input()) q = [int(input()) for i in range(n)] cnt = 0 ind = 0 for i in range(n): m = q[ind]-1 if ind+1 == q[m]: print(-1) exit() ind = q[ind]-1 cnt += 1 if ind == 1: print(cnt) break
p03251
s598633148
Wrong Answer
N, M, X, Y = map(int, input().split()) x = sorted(list(map(int, input().split()))) y = sorted(list(map(int, input().split()))) flag = True if Y <= X: flag = False if y[0] <= x[-1]: flag = False if flag: print("No War") else: print("War")
p02708
s686288438
Accepted
N, K = [int(i.strip()) for i in input().split(' ')] MOD = 10 **9 + 7 count = 0 for i in range(K,N+2): MIN = i * (i-1)/2 MAX = N * i -MIN c = MAX -MIN + 1 count += int(c) print(count%MOD)
p03555
s952149446
Accepted
import bisect,collections,copy,heapq,itertools,math,string import sys def S(): return sys.stdin.readline().rstrip() def M(): return map(int,sys.stdin.readline().rstrip().split()) def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LS(): return lis...
p03779
s325432887
Accepted
x=int(input()) ans=0 a=0 for i in range(1,x+1): a+=i ans+=1 if a>=x: print(ans) break
p02623
s204950520
Accepted
import bisect import numpy n, m, k = map(int, input().split(" ")) a = list(map(int, input().split(" "))) b = list(map(int, input().split(" "))) cost_a = numpy.insert(numpy.cumsum(a), 0, 0) cost_b = numpy.insert(numpy.cumsum(b), 0, 0) ans = 0 j = len(cost_b) -1 for i in range(len(cost_a)): for j in range(j, -1,...
p02608
s106584193
Wrong Answer
from math import sqrt l = [-1]+[0]*10**4 n = int(input()) for i in range(1,int(sqrt(n))+2): for j in range(1,int(sqrt(n))+2): for k in range(1,int(sqrt(n))+2): ans = i**2+j**2+k**2+i*j+j*k+k*i if ans <= 10*4: l[ans] += 1 for i in range(1,n+1): print(l[i])
p03416
s952868199
Accepted
#!/usr/bin/env python3 import sys def solve(A: int, B: int): print(sum( 1 for i in range(A, B + 1) if str(i) == str(i)[::-1] )) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_t...
p03329
s169462212
Accepted
N = int(input()) dp = list(range(0, N+1)) for i in range(1, N+1): for j in [6, 9]: for k in range(1, N): if 0 <= i-j**k: dp[i] = min(dp[i], dp[i-j**k]+1) else: break print(dp[-1])
p03351
s174133384
Accepted
def mapt(fn, *args): return tuple(map(fn, *args)) def Input(): return mapt(int, input().split(" ")) def main(): a, b, c, d = Input() if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d): print("Yes") else: print("No") main()
p02773
s969141361
Accepted
from collections import Counter N = int(input()) A = [None for i in range(N)] for i in range(N): A[i] = input() A = Counter(A) keyA = list(A.keys()) valuesA = list(A.values()) most = max(valuesA) ans = [None for _ in range(N)] for i in range(len(valuesA)): if valuesA[i] == most: ans[i] = keyA[i] ans = [a for a...
p02731
s648409788
Accepted
l = int(input()) print((l/3)**3)
p04044
s515580693
Accepted
N, L = map(int, input().split()) s = [input() for i in range(N)] s2 = sorted(s) ans = "" for i in range(N): ans += s2[i] print(ans)
p02701
s398372123
Wrong Answer
n = int(input()) ls = [] count = 0 for x in range(n): ls.append(input()) set(ls) print(len(ls))
p02647
s676916475
Accepted
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N, K = mapint() As = list(mapint()) from itertools import accumulate for _ in range(K): lamps = [0]*N for i, a in enumerate(As): lamps[max(0, i-a)] += 1 if i+...
p03061
s355236647
Accepted
def gcd(a,b): if a == 0 or b == 0: return max(a,b) return a if b==0 else gcd(b,a%b) N = int(input()) A = list(map(int,input().split())) rA = A[::-1] LEFT = [0] g = A[0] for i in range(N): g = gcd(g,A[i]) LEFT.append(g) RIGHT = [0] g = rA[0] for i in range(N): g = gcd(g,rA[i]) RIGHT.ap...
p03759
s691664023
Wrong Answer
a, b, c = map(int, input().split()) d1 = b - a d2 = c - b if (d1 == d2): print("Yes") else: print("No")
p03433
s503479076
Wrong Answer
N, A = [int(input()) for _ in range(2)] if N >= A: if (N - A) % 500 == 0: print('Yes') else: print('No') else: print('No')
p02831
s082488879
Accepted
def q3(): def lcm(x, y): """ xとyの最小公倍数を求める """ # import math import fractions return (x * y) // fractions.gcd(x, y) A, B = (int(i) for i in input().split()) print(lcm(A, B)) if __name__ == '__main__': q3()
p04005
s891942480
Wrong Answer
ABC = list(map(int, input().split())) mini = float('inf') if ABC[0]%2 == ABC[1]%2 == ABC[2]%2 == 0: print(0) else: for i in range(3): if ABC[i]%2 == 1: calc = 1 for j in range(3): if i != j: calc *= ABC[j] if calc < mini: ...
p03773
s315634657
Accepted
a, b = map(int, input().split()) print((a+b)%24)
p02594
s511946871
Accepted
import sys, bisect, math, itertools, string, queue, copy # import numpy as np # import scipy # from scipy.sparse.csgraph import floyd_warshall from collections import Counter,defaultdict,deque from itertools import permutations, combinations, combinations_with_replacement from heapq import heappop, heappush, heapify fr...
p03427
s196981177
Wrong Answer
n = input() k = len(n) a = 9 * (k - 1) b = 0 for i in range(k): b += int(n[i]) c = 0 m = '' if k > 2 and n[-2] != '0': m = str(int(n))[:k - 2] + str(int(n[-2]) - 1) + '9' elif k > 2 and n[-2] == '0': m = str(int(n) - (int(n[-1]) + 1)) for i in range(len(m)): c += int(m[i]) ans = max(a, b, c) print(ans)
p02578
s633902892
Wrong Answer
N=int(input()) A=list(map(int,input().split())) s=0 for i in range(N-1): if A[i]>A[i+1]: s+=A[i]-A[i+1] print(s)
p03042
s062683027
Accepted
S = input() a = 0 b = 0 if (S[0] == '0' and S[1] != '0') or (S[0] == '1' and (S[1] == '0' or S[1] == '1' or S[1] == '2')): a = 1 if (S[2] == '0' and S[3] != '0') or (S[2] == '1' and (S[3] == '0' or S[3] == '1' or S[3] == '2')): b = 1 if a == 1 and b == 1: print("AMBIGUOUS") elif a == 1: print("MMYY") elif b == ...
p02971
s071603498
Wrong Answer
n=int(input()) a=[] [a.append(int(input())) for _ in range(n)] b = sorted(a) if len(set(b))==1: best=better=b[-1] else: best=list(set(b))[-1] better=list(set(b))[-2] for i in range(n): if a[i] == best: print(better) else: print(best)
p03817
s174849249
Accepted
x = int(input()) # 6 5 6 5 ... # ex) 23 # (x // 11 * 2) + 1 # ex) 29 # (x // 11 * 2) + 2 p, m = divmod(x, 11) p *= 2 if m > 6: print(p + 2) elif m == 0: print(p) else: print(p + 1)
p02766
s728476551
Accepted
N, K = map(int,input().split()) ans = 0 while(K ** ans <= N): ans += 1 print(ans)
p03069
s778483888
Accepted
import sys input = sys.stdin.readline N = int(input()) s = list(input())[: -1] cs = [0] * (N + 1) for i in range(N): cs[i + 1] = cs[i] + (s[i] == "#") res = float("inf") for i in range(N + 1): r = cs[-1] - cs[i] l = i - cs[i] res = min(res, N - i - r + i - l) print(res)
p02743
s553775427
Accepted
a, b, c = map(int, input().split()) if c-a-b < 0: print("No") elif 4*a*b < (c-a-b)**2: print("Yes") else: print("No")
p03359
s593250121
Accepted
a,b = map(int, input().split()) if a <= b: print(a) else: print(a-1)
p02916
s585408770
Accepted
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) sum = 0 sum += b[a[0]-1] for i in range(1,n): sum += b[a[i]-1] if a[i]-a[i-1]==1: sum += c[a[i-1]-1] print(sum)
p02678
s459661435
Accepted
def main(): from collections import deque n,m=map(int,input().split()) ab=[[] for _ in range(n+1)] for _ in range(m): a,b=map(int,input().split()) ab[a].append(b) ab[b].append(a) l=deque([1]) ans=[-1]*n while l: x=l.popleft() for i in ab[x]: if ans[i-1]==-1: ans[i-1]=x...
p04030
s164057724
Accepted
# coding: utf-8 # Your code here! s = list(input()) t = [] for i in range(len(s)): if s[i] == '0': t.append('0') elif s[i] == '1': t.append('1') else: if len(t) != 0: del t[-1] print(''.join(t))
p03219
s629042295
Accepted
x, y = map(int, input().split()) print(int(x+y/2))