problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03804
s543137255
Accepted
n,m=map(int,input().split()) s1=[input() for _ in range(n)] s2=[input() for _ in range(m)] ans='No' for i in range(n-m+1): for j in range(n-m+1): flg=0 for k in range(m): if s1[j+k][i:i+m]==s2[k]: flg+=1 if flg==m: ans='Yes' print(ans)
p02792
s692906897
Accepted
n = int(input()) cnt = [[0] * 10 for i in range(10)] for i in range(1,n+1): cnt[int(str(i)[0])][int(str(i)[-1])] += 1 ans = 0 for i in range(10): for j in range(10): ans += cnt[i][j] * cnt[j][i] print(ans)
p03208
s310904576
Accepted
N, K = map(int, input().split()) h = [] for i in range(N): h.append(int(input())) h.sort() m = h[-1] #現時点での最大 for i in range(N-K+1): x = h[K+i-1] - h[i] if m > x: m = x print(m)
p03779
s721872766
Wrong Answer
import math x = int(input()) s = int(math.ceil(x**(0.5))) s = s*(s+1)//2 if s < x: print(int(math.ceil(x**(0.5))+1)) else: print(int(math.ceil(x**(0.5))))
p03416
s249043055
Accepted
A, B =map(int, input().split()) num_palin = [0] * (B+1) for i in range(1,B+1): if str(i) == str(i)[::-1]: num_palin[i] = num_palin[i-1] + 1 else: num_palin[i] = num_palin[i-1] print(num_palin[B]-num_palin[A-1])
p03062
s218630061
Wrong Answer
N = int(input()) A = list(map(int,input().split())) ans1 = sum(A) - 2 * min(A) for i in range(N - 1): if A[i] < 0: A[i] *= -1 A[i + 1] *= -1 ans2 = sum(A) ans = max(ans1, ans2) print(ans)
p03815
s717418796
Accepted
x = int(input()) ans = x // 11 * 2 x %= 11 l = [0] + [1] * 6 + [2] * 5 ans += l[x] print(ans)
p02618
s334370966
Accepted
def resolve(): D = int(input()) cost = list(map(int, input().split())) sat = [list((map(int, input().split()))) for _ in range(D)] last = [0]*26 for i in range(D): maxcost = 0 ans = 0 for j in range(26): if maxcost <= sat[i][j]: ans = j+1 maxcost = sat[i][j] print(ans) resolve()
p02777
s108303743
Wrong Answer
S, T = input().split() A, B = map(int, input().split()) U = input() if U == "red": A -= 1 else: B -= 1 print(A, B)
p03730
s252108956
Accepted
a, b, c = map(int, input().split()) for i in range(b): # あまりのパターンがb個しかない if a * (i + 1) % b == c: print('YES') exit(0) print('NO')
p03759
s812293212
Accepted
a, b, c = map(int, input().split()) if b-a == c-b: print("YES") else: print("NO")
p02584
s661892705
Accepted
X, K, D = map(int, input().split()) X = abs(X) n = X//D if K < n: print(X-K*D) else: if (n-K) % 2 == 0: print(X-n*D) else: print(abs(X-(n+1)*D))
p02982
s512001353
Wrong Answer
n,d=map(int,input().split()) lists=[list(map(int,input().split())) for x in range(n)] answer=0 for i in range(1,n): for j in range(i+1,n+1): for y in range(d): count=0 count+=(lists[j-1][y]-lists[i-1][y])**2 t=count**(1/2) if t.is_integer(): answer+=1 print(answer)
p03836
s957690752
Accepted
sx, sy, tx, ty = map(int, input().split()) X = tx-sx Y = ty-sy print('R'*X+'U'*Y+'L'*X+'D'*Y+'D'+'R'*(X+1) + 'U'*(Y+1)+'L'+'U'+'L'*(X+1)+'D'*(Y+1)+'R')
p03162
s036374121
Accepted
def solve(n, ABC): dp = [[0] * n for _ in range(3)] dp[0][0], dp[1][0], dp[2][0] = ABC[0] for i in range(1, n): for j in range(3): dp[j][i] = max(dp[(j + 1) % 3][i - 1], dp[(j + 2) % 3][i - 1]) + ABC[i][j] return max(dp[0][n - 1], dp[1][n - 1], dp[2][n - 1]) _n = int(input()) _ABC = [list(map(int, input().split())) for _ in range(_n)] print(solve(_n, _ABC))
p02706
s704685881
Wrong Answer
import math from sys import * inp=stdin.readline zip=zip def linp(x): return list(map(int,x.split())) def minp(x): return map(int,x.split()) n,m=minp(inp()) a=linp(inp()) an=sum(a)-n if an>=0: print(an) else: print("-1")
p02615
s243476517
Wrong Answer
N = int(input()) ln = list(map(int, input().split())) total = 0 ln = sorted(ln, reverse = True) print(sum(ln[:-1]))
p02987
s551096488
Accepted
S = input() S = sorted(S) if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]: print("Yes") else: print("No")
p03127
s798093061
Accepted
n = int(input()) A = list(map(int,input().split())) import fractions from functools import reduce def gcd_list(numbers): return reduce(fractions.gcd, numbers) print (gcd_list(A))
p03371
s714378404
Accepted
A, B, C, X, Y = map(int, input().split()) C *= 2 if X == Y: print(min(C * X, A * X + B * Y)) if X > Y: print(min(C * X, C * Y + A * (X - Y), A * X + B * Y)) if X < Y: print(min(C * Y, C * X + B * (Y - X), A * X + B * Y))
p02708
s955784199
Accepted
# しゃくとり mod = 10**9 + 7 n,k = map(int,input().split()) cnt = 0 sum_ = sum(range(n + 1)) #print("sum", sum_) #print(list(range(n + 1))) max_ = sum(range(n - k + 1, n + 1)) min_ = sum(range(k)) for i in range(k, n+2): #print(max_, min_, cnt) cnt += max_ - min_ + 1 cnt %= mod #print(cnt) if n > i + 1: max_ += n - i else: max_ = sum_ min_ += i print(cnt)
p02747
s105989124
Accepted
s = input() s=s.replace("hi", "") print("Yes" if s=="" else "No")
p02723
s727134965
Accepted
S = input() S = list(S) if (S[2] == S[3]) and (S[4] == S[5]): print('Yes') else: print('No')
p02811
s712014242
Accepted
N = input().split() for a in range(len(N)): N[a] = int(N[a]) if N[1]/N[0] <= 500: print("Yes") else: print("No")
p02848
s312772007
Wrong Answer
n = int(input()) s = str(input()) alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' f = '' for i in range(len(s)): for j in range(26): if s[i] == alp[j]: f += alp[j] print(f)
p02603
s785393154
Accepted
x=1000 for a,b in zip(a:=[*map(int,[*open(0)][1].split())],a[1:]):x+=x//a*(b-a)*(a<b) print(x)
p02832
s662895703
Wrong Answer
N = int(input()) a = list(map(int, input().split())) count = 1 broke = 0 suceed = False while True: if count in a: suceed = True broke += a.index(count) a = a[a.index(count) + 1:] count += 1 else: break if suceed: print(broke) else: print(-1)
p03659
s068292754
Wrong Answer
# C - pushpush N = int(input()) a = list(map(int,input().split())) a = sorted(a) S = sum(a) lst = [0]*N x = 0 y = 0 for i in range(N): x = sum(a[0:i]) y = S - x lst[i] = abs(x-y) lst.pop(0) ans = min(lst) print(ans)
p03657
s914058443
Accepted
a,b=map(int,input().split()) if a%3==0 or b%3==0 or (a+b)%3==0: print("Possible") else: print("Impossible")
p02595
s970349072
Accepted
N, D = map(int, input().split()) c = 0 for i in range(N): x, y = map(int, input().split()) if (x*x+y*y <= D*D): c = c + 1 print(c)
p02629
s427968778
Accepted
N = int(input()) L = list("abcdefghijklmnopqrstuvwxyz") a = 1 while N > 26**a: N = N - 26**a a += 1 pre = [] for i in reversed(range(1,a)): r = (N-1) // 26**i pre.append(r) N = int(N%(26**i)) ans = '' for i in pre: ans += L[i] print(ans+L[N-1])
p02958
s131620042
Wrong Answer
#135 b n=int(input()) p=list(map(int,input().split())) ans="NO" cnt=0 for i in range(n): if p[i]!=(n-i): cnt+=1 if cnt==2: ans="YES" print(ans)
p02933
s337907603
Wrong Answer
a=int(input()) b=input() if a>=3200: print('red') else: print('pink')
p02571
s523553574
Wrong Answer
s = input() t = input() ans = 0 for i in range(len(s)-len(t)+1): m = 0 for j, k in zip(s[i:],t): if j==k: m += 1 if m > ans: ans = m print(ans)
p03693
s099755266
Wrong Answer
S_list = list(map(int,input("入力:").split())) r, g, b = S_list[0], S_list[1], S_list[2] if (10 * g + b) % 4 == 0 : result = "Yes" else: result = "No" print(result)
p03705
s551855884
Accepted
# ~10m AC 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') n, a, b = LI() min_s = a * (n - 1) + b max_s = a + (n - 1) * b ans = max_s - min_s + 1 if ans < 0: ans = 0 print(ans)
p02577
s904486808
Wrong Answer
import math def keta(s): if len(s) < 2: return int(s) n = sum(map(int, s)) return keta(str(n)) def main(): N = input() if keta(N) == 9: print("Yes") else: print("No") if __name__ == "__main__": main()
p02627
s927073618
Wrong Answer
s = input() print(str.swapcase(s))
p03486
s038615641
Accepted
sLst, tLst = list(input()), list(input()) sLst.sort() tLst.sort(reverse=True) sd = ''.join(sLst) td = ''.join(tLst) if sd < td: print('Yes') else: print('No')
p02713
s201088945
Accepted
import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) K = int(input()) a=0 for i in range(1,K+1): for j in range(1,K+1): for l in range(1,K+1): a=a+gcd(i,j,l) print(a)
p02553
s800093453
Wrong Answer
a = sorted(list(map(int, input().split()))) print(max( a[0] * a[1], a[-2] * a[-1] ))
p02612
s726724411
Accepted
n = int(input()) x = n//1000 if n % 1000: x += 1 print(1000*x - n)
p02957
s194308735
Wrong Answer
a,b=map(int, input().split()) if (a-b)%2==0: print((a+b)/2) else: print('IMPOSSIBLE')
p02880
s363301919
Accepted
# -*- coding: utf-8 -*- n = int(input()) print('Yes' if n in {i*j for i in range(10) for j in range(10)} else 'No')
p02935
s052153383
Wrong Answer
# n = int(input()) l = [int(x) for x in input().split()] i =0 while len(l) >= 2: l.sort() a = l.pop(i) b = l.pop(i) c = (a + b) / 2 l.append (c) print(l)
p02761
s458667908
Accepted
n,m = map(int,input().split()) sc = [input() for _ in range(m)] ans = -1 start = 10**(n-1) if n == 1: start = 0 for i in range(start,10**n): i = str(i) ok = 0 for j in sc: s,c = j.split() if i[int(s)-1] == c: ok += 1 if ok == m: ans = int(i) break print(ans)
p02687
s061363573
Accepted
S = input() if S == 'ABC': print('ARC') else: print('ABC')
p02747
s481083326
Wrong Answer
s = input() for i in range(len(s)): if i%2 == 0: if s[i] != "h": print("No") exit() else: if s[i] != "i": print("No") exit() print("Yes")
p03251
s501279925
Wrong Answer
(n, m, x, y) = map(int, input().split()) rightx = max(map(int, input().split())) lefty = min(map(int, input().split())) if rightx < min(y, lefty): print('No War') else: print('War')
p02623
s380143307
Accepted
n,m,k=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) A,B=[0],[0] for i in range(n): A.append(A[i]+a[i]) for i in range(m): B.append(B[i]+b[i]) ans,j = 0,m for i in range(n+1): if A[i]>k: break while B[j] >k-A[i]: j-=1 ans=max(ans,i+j) print(ans)
p02555
s797259123
Wrong Answer
s = int(input()) if s <= 2: print(0) lst = [] counter = 0 for i in range(3, s+1): if s == i: lst.append([]) lst[counter].append(i) if s - i > 2: lst.append([]) lst[counter].append(i) lst[counter].append(s-i) counter += 1 print(len(lst))
p02713
s752856128
Wrong Answer
import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) K = int(input()) cnt = 0 for k_1 in range(K+1): for k_2 in range(K+1): for k_3 in range(K+1): cnt = cnt + gcd(k_1,k_2,k_3) print(cnt)
p03317
s027030729
Accepted
#!/usr/bin/env python3 #ABC101 C import math N,K = map(int,input().split()) A = list(map(int,input().split())) print(math.ceil((N-1)/(K-1)))
p02785
s019131072
Accepted
def main(): n,k=map(int,input().split()) h=sorted(list(map(int,input().split()))) if k>=n: print(0) else: for i in range(k): _=h.pop(-1) print(sum(h)) if __name__ == '__main__': main()
p03799
s674092238
Wrong Answer
import sys import math inint = lambda: int(sys.stdin.readline()) inintm = lambda: map(int, sys.stdin.readline().split()) inintl = lambda: list(inintm()) instrm = lambda: map(str, sys.stdin.readline().split()) instrl = lambda: list(instrm()) n, m = inintm() ans = 0 if m - n*2 > 0: ans += n m -= n*2 elif m - n*2 == 0: print(n) exit() else: if m % 2 == 0: print(m) exit() else: print(m-1) exit() ans += m//4 print(ans)
p04030
s707821038
Wrong Answer
t="" for i in input(): if i=="B": t=t[:-1] else: t+=i print(t)
p03103
s665766992
Accepted
N, M = map(int, input().split()) stores = [list(map(int, input().split())) for _ in range(N)] stores.sort() total = 0 i = 0 while True: if total >= M: i -= 1 break total += stores[i][1] i += 1 ac = 0 k_count = 0 j = 0 while not j > i: if j == i: ac += stores[j][0] * (M-k_count) else: ac += stores[j][0] * stores[j][1] k_count += stores[j][1] j += 1 print(ac)
p02732
s305478131
Accepted
import collections N = int(input()) A = list(map(int,input().split())) Cn_A = collections.Counter(A) ans_list = [0]*len(Cn_A) ans = 0 for i,j in enumerate(Cn_A.values()): ans+=j*(j-1)//2 for i in A: j = Cn_A[i] print(ans-(j*(j-1)//2)+((j-1)*(j-2)//2))
p02683
s937624886
Accepted
n, m, x = map(int, input().split()) a = [[int(i) for i in input().split(" ")] for j in range(n)] mi = 10**7 for i in range(1, 2**n): te = [0]*m bi = bin(i+2**n)[3:] c = 0 for j in range(n): if bi[j] == "0": continue te = [x+y for x, y in zip(te, a[j][1:])] c += a[j][0] if sum([1 for i in te if i >= x]) == m: mi = min(mi, c) if mi == 10**7: print(-1) else: print(mi)
p03721
s064429499
Accepted
def invr(): return(map(int, input().split())) n, k = invr() arr = [] d = dict() for i in range(n): a, b = invr() if a in d: d[a] += b else: d[a] = b arr.append(a) arr = sorted(arr) pos = 0 for i in arr: pos += d[i] if pos >= k: print(i) break
p02982
s277121854
Wrong Answer
N,D=[int(x) for x in input().rstrip().split()] l=[] for i in range(N): X=[int(x) for x in input().rstrip().split()] l.append(X) ans=0 for i in range(N): ni=l[i] for j in range(i+1,N): nj=l[j] now=0 for s in range(D): now+=(ni[s]-nj[s])**2 now=now**0.5
p03639
s869477030
Accepted
N = int(input()) a = list(map(int, input().split())) n1 = sum([1 if A % 2 != 0 else 0 for A in a]) n4 = sum([1 if A % 4 == 0 else 0 for A in a]) n2 = N - n1 - n4 if n2 > 0: if n4 >= n1: print("Yes") else: print("No") else: if n4 >= n1 - 1: print("Yes") else: print("No")
p02641
s074289865
Accepted
x, n = map(int, input().split()) p = list(map(int, input().split())) if n==0: print(x) exit() for i in range(100): num = x-i if num not in p: print(num) exit() num = x+i if num not in p: print(num) exit()
p02612
s069769386
Accepted
N = int(input()) for i in range(1,100): if i*1000 >= N: print((i*1000)-N) break
p04034
s333109037
Wrong Answer
N, M = map(int, input().split()) X, Y = [], [] for _ in range(M): x, y = map(int, input().split()) X.append(x - 1) Y.append(y - 1) red = [0] * N red[0] = 1 ball = [1] * N for x, y in zip(X, Y): if red[x] == 1 and ball[x] != 0: red[y] = 1 if ball[x] == 1: red[x] = 0 ball[x] -= 1 ball[y] += 1 print(sum(red))
p02702
s677549543
Wrong Answer
def resolve(): S_string = input() if len(S_string) < 4: print("0") count = 0 d_start = 4 d_end = len(S_string) for i in range(0, len(S_string) - 3): for d in range(d_start, d_end + 1 - i ): # print(int(S_string[i: i + d])) if (int(S_string[i: i + d])%2019==0): count += 1 print(count) if __name__ == "__main__": resolve()
p02988
s563650377
Wrong Answer
N = int(input()) N_List = sorted(list(map(int,input().split()))) ct = 0 for i in range(1,N-1): if (N_List[i] >= N_List[i-1]) & (N_List[i] <= N_List[i+1]): ct += 1 print(ct)
p02924
s294533794
Accepted
import sys input = sys.stdin.readline def main(): N = int(input()) ans = (N-1) * N // 2 print(ans) if __name__ == "__main__": main()
p03479
s063836242
Accepted
# https://atcoder.jp/contests/abc083/tasks/arc088_a X, Y = map(int, input().split()) s = X count = 1 while s <= Y: s *= 2 count += 1 print(count-1)
p03360
s331617006
Accepted
a,b,c=map(int,input().split()) k=int(input()) temp=max(a,b,c) for i in range(k): temp=temp*2 print(a+b+c+temp-max(a,b,c))
p02785
s969959220
Accepted
class Culuculation(): N = 0 K = 0 H = [] #初期化。ここで引数も受け取る def __init__(self): self.N, self.K = ( int(x) for x in input().split(' ')) self.H = [int(x) for x in input().split(' ')] #計算処理 def culc(self): self.H.sort(reverse=True) if self.N >= self.K: del self.H[0:self.K] else: self.H.clear() print(sum(self.H)) def main(): tmp = Culuculation() tmp.culc() if __name__=='__main__': main()
p03495
s794674662
Wrong Answer
N,K=map(int,input().split()) A = map(int, input().split()) count=0 for a in A: if a>K: count+=1 print(count)
p03219
s828217531
Wrong Answer
x, y = map(int, input().split()) print(x + y/2)
p03681
s092388516
Wrong Answer
from math import factorial n, m = map(int,input().split()) if abs(n-m) >=2: print(0) elif abs(n-m) == 1: print((factorial(n)*factorial(m)) % int(1e9)+7) else: print((factorial(n)*factorial(m)*2) % (int(1e9)+7))
p03665
s703790990
Accepted
import math N,P = map(int,input().split()) A = list(map(int,input().split())) remainders = [a%2 for a in A] odd = remainders.count(1) even = remainders.count(0) def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) ans = 0 for n in range(N+1): for p in range(P,n+1,2): if odd >= p and even >= n-p: ans += combinations_count(odd,p) * combinations_count(even,n-p) print(ans)
p03254
s472030576
Accepted
n,x=map(int,input().split()) a=sorted(list(map(int,input().split()))) for i in range(n): x-=a[i] if x<0: break else: if x==0: i+=1 print(i)
p02829
s980274070
Accepted
A = int(input()) B = int(input()) ans = A+B if ans == 3: print(3) elif ans == 4: print(2) else: print(1)
p02613
s621147411
Wrong Answer
t = int(input()) c1, c2, c3, c4 = 0, 0, 0, 0 for i in range(t): s = input() if s == 'AC': c1 += 1 elif s == 'TLE': c2 += 1 elif s == 'WA': c3 += 1 else: c4 += 1 print('AC *', c1) print('WA *', c3) print('TLE *', c2) print('RTE *', c4)
p03625
s543108967
Accepted
from collections import Counter N = int(input()) A = list(input().split()) A = [int(A[i])for i in range(N)] A_count = list(Counter(A).most_common()) rectangle = sorted([A_count[i][0] for i in range(len(A_count)) if A_count[i][1] >= 2],reverse=True) square = sorted([A_count[i][0] for i in range(len(A_count)) if A_count[i][1] >= 4], reverse=True) S_rec = (rectangle[0] * rectangle[1] if len(rectangle) >= 2 else 0) S_squ = (square[0] ** 2 if len(square) >= 1 else 0) print(max(S_rec, S_squ))
p02744
s222452562
Wrong Answer
start="a" n=int(input()) ans=[] def dfs(string,n): if len(string)==n: print(string) else: s=string for i in range(97,max([ord(j)for j in string])+2): dfs(string+chr(i),n) dfs(start,n) print(len(ans)) for i in ans: print(i)
p03043
s563737999
Accepted
N,K = map(int,input().split()) ans=0 for i in range(1,N+1): p=1 sc=i cnt=0 while 1<=sc<=K-1: cnt +=1 p /=2 sc *=2 #print(i,cnt,p/N) ans += p/N print(ans)
p02748
s476432564
Accepted
a, b, m = map(int,input().split()) a_l = list(map(int,input().split())) b_l = list(map(int,input().split())) xyc = [] for _ in range(m): xyc.append(list(map(int,input().split()))) ans = min(a_l) + min(b_l) for x, y, c in xyc: ans = min(ans, a_l[x-1]+b_l[y-1]-c) print(ans)
p04030
s166103892
Accepted
s = input() ans = [] for i in s: if i == "0" or i == "1": ans.append(i) else: if ans: ans.pop() print("".join(ans))
p03162
s093517602
Accepted
n=int(input()) l=list(map(int,input().split())) dp=l.copy() for i in range(n-1): dp1=dp.copy() l=list(map(int,input().split())) for j in range(3): ans=float('-inf') for k in range(3): if(j!=k): ans=max(ans,l[j]+dp[k]) dp1[j]=ans dp=dp1.copy() print(max(dp))
p02755
s468911655
Accepted
import sys a, b = map(int, input().split()) for i in range(1251): if int(i * 0.08) == a and int(i * 0.1) == b: print(i) sys.exit() print(-1)
p04044
s181641314
Wrong Answer
N, L = map(int, input().split()) s = [] for i in range(N): s.append(input()) s.sort() print(s) print(''.join(s))
p03339
s056263922
Accepted
N = int(input()) S = input() west = [0]*N east = [0]*N tmp = 0 for i in range(1,N): if S[i-1] == 'W': tmp += 1 west[i] = tmp else: west[i] = tmp tmp = 0 for i in range(N-2,-1,-1): if S[i+1] == 'E': tmp += 1 east[i] = tmp else: east[i] = tmp ans = float('inf') for i in range(N): ans = min(ans,west[i]+east[i]) print (ans)
p02731
s063009576
Accepted
l=int(input()) print((l/3)**3)
p02732
s256207899
Wrong Answer
import collections n=int(input()) a=list(map(int,input().split())) l=[0]*(n+1) ans=0 for i in range(n): l[a[i]]+=1 for j in range(n): if l[j]>1: ans+=(l[j])*(l[j]-1)//2 for k in range(n): s=l[a[k]] if s<2: print(ans) else: print(ans-(s+1)*s//2+s*(s-1)//2)
p03327
s466845599
Accepted
n = int(input()) if n < 1000: print("ABC") else: print("ABD")
p02621
s513517748
Wrong Answer
a = int(input()) a = a + a^2 + a^3
p03545
s484738756
Accepted
def dfs(i, f, result): if i == l - 1: if result == 7: print(f + '=7') exit() else: dfs(i + 1, f + '-' + s[i + 1], result - int(s[i + 1])) dfs(i + 1, f + '+' + s[i + 1], result + int(s[i + 1])) s = input() l = len(s) dfs(0, s[0], int(s[0]))
p02881
s690148592
Accepted
import math N = int(input()) Min = 1e12 for a in range(1, int(math.sqrt(N)) + 1): if (N % a) == 0: Min = min(Min, a + N//a - 2) print(Min)
p02982
s977526084
Accepted
import math n,d=map(int,input().split()) l=[] x=[] c=0 for i in range(n): l.append(list(map(int,input().split()))) for i in range(n-1): for j in range(i+1,n): for k in range(d): x.append(abs(l[i][k]-l[j][k])**2) if math.sqrt(sum(x))%1==0: c+=1 x=[] print(c)
p03017
s457966306
Wrong Answer
N,A,B,C,D=map(int, input().split()) S=input() if S.find("##", A, B)<0 and S.find("##", C, D)<0: if C<D: print("Yes") else: if S.find("...", B-2, D+2)>=0: print("Yes") else: print("No") else: print("No")
p03854
s265553658
Accepted
s,f=input()[::-1],-1 while f<0: if s: if s[:5]=='maerd': s=s[5:] elif s[:5]=='esare': s=s[5:] elif s[:6]=='resare': s=s[6:] elif s[:7]=='remaerd': s=s[7:] else: f=0 else: f=1 print(['NO','YES'][f])
p02606
s891408716
Wrong Answer
# n = int(input()) l, r, d = map(int, input().split()) # l = list(map(int, input().split())) # if (r-l)%d == 0: # print((r-l)//d) # else: # print((r-l)//d + 1) print((r-l+1)//d)
p03243
s748267778
Accepted
n = input() if int(n[0]) < int(n[1]): print(str(int(n[0]) + 1) * 3) elif int(n[0]) == int(n[1]) and int(n[0]) < int(n[2]): print(str(int(n[0]) + 1) * 3) else: print(str(int(n[0])) * 3)
p03971
s940541924
Accepted
N,A,B=map(int,input().split()) H=0 K=0 S=input() for i in range(N): if S[i]=="a": if K<A+B: print("Yes") K+=1 else: print("No") elif S[i]=="b": if K<A+B: if H<B: print("Yes") H+=1 K+=1 else: print("No") else: print("No") elif S[i]=="c": print("No")
p03103
s825739560
Accepted
import math n, m = map(int, input().split()) a = [] for i in range(n): l = list(map(int, input().split())) a.append(l) a.sort(key=lambda x: x[0]) sum = 0 cnt = 0 for i in range(n): if cnt + a[i][1] >= m: sum += (m-cnt)*a[i][0] cnt += m-cnt break else: sum += a[i][0]*a[i][1] cnt += a[i][1] print(sum)