problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03071
s534173702
Accepted
A,B = map(int,input().split()) print(max(A*2-1,B*2-1,A+B))
p03281
s005747636
Accepted
def divisor(n): i = 1 table = [] while i * i <= n: if n % i == 0: table.append(i) table.append(n//i) i += 1 table = list(set(table)) return table N = int(input()) total = 0 for n in range(1, N + 1, 2): if len(divisor(n)) == 8: total += 1 print(total)
p02743
s113564853
Accepted
a,b,c=map(int,input().split()) x=4*a*b-(c-a-b)**2 if a+b-c>0: print("No") elif x<0: print("Yes") else: print("No")
p03416
s066324830
Accepted
a, b = map(int, input().split()) cnt = 0 for i in range(a, b+1, 1): i = str(i) if i[0] == i[4] and i[1] == i[3]: cnt += 1 else: continue print(cnt)
p02555
s814362147
Accepted
#!/usr/bin/env python # -*- coding: utf-8 -*- def main(): S = int(input()) mod = 10**9 + 7 dp = [0] * (S + 4) dp[0] = 1 dp[3] = 1 for i in range(4, S + 1): for k in range(i - 2): dp[i] += dp[k] print(dp[S] % mod) if __name__ == "__main__": main()
p02916
s895564245
Accepted
n = int(input()) a = map(int, input().split()) b = list(map(int, input().split())) c = list(map(int, input().split())) sum = 0 prev = -1 for i in a: sum += b[i-1] if prev and prev == i-1: sum += c[prev-1] prev = i print(sum)
p02773
s232773345
Wrong Answer
import collections strlist = [] N = int(input()) for i in range(N): strlist.append(str(input())) c = collections.Counter(strlist) p = max(c.values()) for i in c.most_common(): if i[1] == p: print(i[0])
p02888
s207810385
Accepted
from bisect import bisect_left, bisect_right N = int(input()) L = list(map(int, input().split())) L.sort() len_L = len(L) ans = 0 for i in range(N-2): for j in range(i+1, N-1): ans += bisect_left(L, L[i] + L[j]) - j - 1 print(ans)
p02708
s298999314
Accepted
n, k = list(map(int, input().split())) sums = 0 for i in range(k, n+2): sums += i*(n + 1 - i) + 1 print (sums % (10**9 + 7))
p02657
s529501348
Accepted
a, b = map(int, input().split()) print(int(a*b))
p02582
s727537464
Accepted
s = input() if "RRR" in s: print(3) elif "RR" in s: print(2) elif "R" in s: print(1) else: print(0)
p02784
s736887926
Wrong Answer
import numpy as np H,N = map(int,input().split()) A = list(map(int,input().split())) if np.sum(A)>=H: print("yes") else: print("no")
p03345
s388864819
Accepted
A, B, C, K = map(int, input().split()) # threshold = 10 ** 18 res = (-1) ** K * (A - B) # if abs(res) > threshold: # print('Unfair') # else: # print(res) print(res)
p03962
s807858810
Wrong Answer
print(len(set(input())))
p03548
s593491604
Wrong Answer
x,y,z = map(int,input().split()) ans = int(x/(y+z)) if x%(y+z) <= z: ans -= 1 print(ans,x%(y+z))
p02627
s542487069
Wrong Answer
a = input().isupper if a == 1: print("A") else: print("a")
p03986
s752960861
Accepted
def main(): x = input() s, t = 0, 0 for i in x: if i == "S": s += 1 else: if s: s -= 1 else: t += 1 print(s + t) if __name__ == "__main__": main()
p02594
s864265799
Wrong Answer
t=int(input()) if(t>30): print("Yes") else: print("No")
p02847
s437726135
Wrong Answer
N = str(input()) if N=="SAT": print("1") elif N=="FRY": print("2") elif N=="THU": print("3") elif N=="WED": print("4") elif N=="TUE": print("5") elif N=="MON": print("6") else: print("7")
p02773
s365686352
Accepted
import collections n = int(input()) s = [] for i in range(n): si = input() s.append(si) s.sort() counted = collections.Counter(s) M = max(counted.values()) ms = [k for k, v in counted.items() if v == M] ms.sort() for i in range(len(ms)): print(ms[i])
p03852
s143562322
Accepted
c = input() v = ["a", "i", "u", "e", "o"] if c in v: print("vowel") else: print("consonant")
p02665
s458350300
Wrong Answer
n = input() a = list(map(int, input().split())) cnt = 0 pre = 0 for i in a: if i > pre*2: print(-1) exit() if i == 0: pre = (pre==0)*2 + pre*2 cnt += pre else: pre = (pre - i)*2 cnt += i print(cnt)
p02994
s513417601
Accepted
n,l = map(int,input().split()) aji = [] count = 0 for i in range(1,n+1): aji.append([abs(l+i-1),l+i-1]) count += l+i-1 aji.sort() count -= aji[0][1] print(count)
p03385
s706462004
Accepted
s = input() print('Yes' if len(set(s)) == 3 else 'No')
p03264
s412480479
Wrong Answer
K=int(input()) if K//2==0: print((K//2)**2) else: print((K//2)*(K//2+1))
p02988
s929149844
Wrong Answer
n = int(input()) p = [int(i) for i in input().split()] ans = 0 for i in range(n): if i == 0 or i == n-1: continue x = p[i-1:i+2] y = sorted(x) if print(y[1]) == p[i]: ans +=1 print(ans)
p02583
s302855455
Accepted
n = int(input()) l = list(map(int,input().split())) c = 0 s = [] l.sort() for i in range(n-2): for j in range(i+1,n-1): for k in range(j+1,n): if (l[i] + l[j] > l[k]) and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]: c = c + 1 print(c)
p03605
s434569759
Accepted
N = int(input()) if N % 10 == 9 or N // 10 == 9: print('Yes') else: print('No')
p03943
s139380307
Accepted
l=[int(x) for x in input().split()] a=max(l) if (sum(l)-a)==a: print("Yes") else: print("No")
p02795
s977766711
Accepted
import math h=int(input()) w=int(input()) n=int(input()) a=max(h,w) print(math.ceil(n/a))
p02820
s184315692
Accepted
N,K=map(int,input().split(' ')) R,S,P=map(int,input().split(' ')) h = {'r':P,'p':S,'s':R} T=input() hands=[1]*N ans = 0 for i in range(N-K): if T[i] != T[i+K] and hands[i]: ans += h[T[i]] elif hands[i]: hands[i+K]=0 ans +=h[T[i]] for i in range(N-K,N): if hands[i]: ans += h[T[i]] print(ans)
p02744
s098284214
Wrong Answer
from itertools import product N=int(input()) s="abcdefghij" for i in range(N): c=s[:i+1] for p in product(c,repeat=N-i): print(c+"".join(p))
p03494
s503926620
Accepted
N = int(input()) A = [int(i) for i in input().split() ] count=0 for i in range(min(A)): for ii in A: if ii % 2 != 0 : print(count) exit() count += 1 A = [ii//2 for ii in A ]
p03456
s718428653
Accepted
a,b=input().split() c=int(a+b) def heihou(n): a=int(n**0.5) if n==a**2: return True return False if heihou(c): print("Yes") else: print("No")
p04012
s054223472
Wrong Answer
import sys input = sys.stdin.readline def main(): ans = 'Yes' w = input() s = set(w) for i in s: if w.count(i)%2 != 0: ans = 'No' break print(ans) if __name__ == '__main__': main()
p03416
s821537158
Accepted
def P_Number(a , b): ans = 0 for i in range(a, b + 1): rev = str(i) if str(i) == rev[::-1]: ans += 1 return ans def main(): a , b = map(int , input().split()) print(P_Number(a , b)) if __name__ == '__main__': main()
p02958
s381521307
Accepted
#B n = int(input()) p = list(map(int,input().split())) p_sort = sorted(p) cnt = 0 for i in range(n): if p[i] != p_sort[i]: cnt += 1 if cnt <= 2: print('YES') else: print('NO')
p03071
s907303837
Accepted
a, b = list(map(int, input().split())) result = 0 for _ in range(2): if a >= b: result += a a -= 1 else: result += b b -= 1 print(result)
p02633
s443595878
Wrong Answer
x = int(input()) m = 360 // x print(m)
p02953
s726540424
Wrong Answer
n = int(input()) h = list(map(int, input().split())) max_ = h[0] for i in range(1, n - 1): max_ = max(max_, h[i]) if max_ - h[i] >= 2: print("No") exit() print("Yes")
p02714
s739037893
Wrong Answer
N = int(input()) S = input() num = 0 for i in range(0, N - 2): for j in range(i + 1, N - 1): for k in range(j + 1, N): if (j-i)!=(k-j) and S[i] != S[j] and S[j] != S[k] and S[j] != S[k]: num += 1
p02553
s438260193
Accepted
a, b, c, d = map(int, input().split()) X = [a, b] Y = [c, d] lst = [[x*y for x in X] for y in Y] mylist=[] for i in lst: for I in i: mylist.append(I) mylist.sort() print(mylist[-1])
p02701
s948221369
Wrong Answer
s=input() cnt=0 for i in range(len(s)-3): for j in range(i+3,len(s)): t=int(s[i:j+1]) if t%2019==0: cnt+=1 print(cnt)
p02717
s896812224
Wrong Answer
box = [1, 2, 3] box[0], box[1] = box[1], box[0] box[0], box[2] = box[2], box[0] print(box)
p02765
s850531587
Accepted
n, r = map(int, input().split()) if n < 10: res = 100 * (10 -n) + r else: res = r print(res)
p03076
s398519067
Wrong Answer
import itertools l = [int(input()) for i in range(5)] l2 = list(itertools.permutations(l)) min = float("INF") for i in range(120): ans = 0 for j in range(4): if l2[i][j] % 10 == 0: ans += l2[i][j] else: ans += (l2[i][j] // 10 + 1) * 10 ans += l2[i][4] if min > ans: min = ans print(ans)
p03494
s877735444
Wrong Answer
N = int(input()) A = map(int, input().split()) count = 0 for a in A: if a%2==0: count+=1 else: print(count) break
p02862
s989427010
Accepted
#!/usr/bin/env python3 from functools import reduce x, y = map(int, input().split()) mod = 10**9 + 7 def cmb(n, r, m): def mul(a, b): return a * b % m r = min(n - r, r) if r == 0: return 1 over = reduce(mul, range(n, n - r, -1)) under = reduce(mul, range(1, r + 1)) return (over * pow(under, m - 2, m))%m r = abs(x - y) l = (min(x, y) - r) // 3 r += l if l*2+r*1 in (x,y) and l >= 0: print(cmb(r + l, l, mod)) else: print(0)
p02861
s838518559
Accepted
def resolve(): n=int(input()) x = [0] * n y = [0] * n ans=0 t=1 for i in range(1,n): t*=i for i in range(n): x[i], y[i] = map(int, input().split()) for i in range(n): for j in range(i+1,n): ans+=((x[i]-x[j])**2+(y[i]-y[j])**2)**0.5 print(2*ans/n) resolve()
p02847
s313097096
Wrong Answer
S = input() if S == 'SAT': print(1) elif S == 'FRI': print(2) elif S == 'THU': print(3) elif S == 'WED': print(4) elif S == 'TUE': print(5) else: print(6)
p03324
s664613077
Accepted
D,N = map(int,input().split()) if N != 100: print(N*pow(100,D)) else: print(101*pow(100,D))
p03281
s507027305
Accepted
n = int(input()) total = [] for i in range(1, n+1, 2): cnt = 0 for j in range(1, i+1, 2): if i%j == 0: cnt += 1 if cnt == 8: total.append(i) print(len(total))
p02676
s828370221
Wrong Answer
k = int(input()) s = input() if len(s) <= k: print(s) else: print(s[0:(k-1)])
p02783
s735812957
Wrong Answer
import math H,S = input().split() H1 = int(H) S1 = int(S) N = 0 i=1 N = math.floor(H1/S1) print(N+1)
p03719
s196708012
Wrong Answer
a,b,c=map(int,input().split()) if a + b >= 10: print("error") else: print(a + b)
p03475
s231602511
Accepted
n = int(input()) csf = [[int(i) for i in input().split()] for _ in range(n - 1)] def get(i): ans = 0 for c, s, f in csf[i:]: ans = max(ans, s) ans = (ans + f - 1) // f * f ans += c return ans for i in range(n): print(get(i))
p02713
s372826473
Accepted
from math import gcd k = int(input()) res = 0 for a in range(1, k + 1): for b in range(1, k + 1): x = gcd(a, b) res += sum(gcd(x, c) for c in range(1, k + 1)) print(res)
p02933
s232588723
Wrong Answer
a=input() s=input() a=int(a) if a>=3200: print(a) print(s) elif a<3200: print('red')
p02911
s853811548
Accepted
N, K, Q = map(int, input().split()) scores = [K-Q] * (N + 1) for i in range(Q): a = int(input()) scores[a] += 1 for i in range(1, N+1): if scores[i] <= 0: print('No') else: print('Yes')
p03075
s817353116
Wrong Answer
p = [] for i in range(5): p.append(int(input())) k = int(input()) for i in range(5): for j in range(4-i): if p[i] - p[j] >k: print(":(") exit() print("Yay!")
p02791
s843061520
Wrong Answer
N = input() lis = input().split(" ") cnt = 1 i = 0 for i in range(int(N)): for j in range(i-1,-1,-1): if int(lis[i])>int(lis[j]): break else: cnt +=1 break print(cnt)
p02645
s781029751
Accepted
s = input() print(s[:3])
p03821
s977720245
Accepted
N=int(input()) A=[] B=[] for _ in range(N): a, b=map(int, input().split()) tmpa=a%b A.append(tmpa) B.append(b) ans=0 for i in range(N-1, -1, -1): tmp=B[i]-(A[i]+ans)%B[i] if tmp==B[i]: tmp=0 ans+=tmp print(ans)
p03821
s723384643
Wrong Answer
n = int(input()) a,b=[],[] for i in range(n): x,y = map(int,input().split()) a.append(x) b.append(y) a=list(reversed(a)) b=list(reversed(b)) ans=0 for i in range(n): if a[i]<=b[i]: ok=b[i]-a[i] else: ok=-(-a[i]//b[i])*b[i]-a[i] a=[j+ok for j in a] ans+=ok print(ans)
p02918
s252465882
Accepted
n, k = map(int, input().split()) s = input() h=0 for i in range(n-1): if s[i]==s[i+1]: h+=1 else: if s[i]==s[0] and k>0: if s[0] in s[i+1:]: h+=2 k-=1 else: h+=1 k-=1 print(h)
p03416
s275484964
Accepted
def is_palindromic(n): tmp = list(str(n)) return tmp == tmp[::-1] A, B = map(int, input().split()) count = 0 for i in range(A, B + 1): if is_palindromic(i): count += 1 print(count)
p02819
s984671264
Accepted
def is_prime(n): if n == 1: return False for i in range(2,int(n**0.5)+1): if n % i == 0: return False return True def main(X): if is_prime(X) == True: print(X) else: return main(X+1) if __name__ == '__main__': X = int(input()) main(X)
p03555
s914720847
Wrong Answer
print("Yes" if input()==input()[::-1] else "No" )
p03617
s799707083
Wrong Answer
Q, H, S, D = list(map(int, input().split())) Q *= 8 H *= 4 S *= 2 A = min(Q, H, S, D) N = int(input()) if N%2 == 0: print(int(A * N/2)) else: B = min(Q, H, S) print(int(B/2 + A * (N-1)/2))
p02732
s560275483
Wrong Answer
import math N = int(input()) A = list(map(int, input().split())) ans = 0 C = list(set(A)) M = len(C) t = [] anst = 0 for i in range(M): t.append(A.count(C[i])) temp = A.count(C[i]) if temp >=2: anst += math.factorial(temp)/(math.factorial(temp-2)*2) #print(t) #print(anst) #print(jisyo[1]) for i in range(N): print(t[C.index(A[i])]) print(int(anst-t[C.index(A[i])]+1))
p02727
s797719666
Wrong Answer
X, Y, A, B, C = map(int, input().split()) P = sorted([int(i) for i in input().split()], reverse=True) Q = sorted([int(i) for i in input().split()], reverse=True) R = sorted([int(i) for i in input().split()]) S = sorted(P[:X]+Q[:Y]+R, reverse=True) ans = sum(S[:X+Y])
p03861
s264958535
Accepted
a,b,x=map(int,input().split()) print(b//x-(a-1)//x)
p02785
s954494289
Accepted
N,K= map(int,input().split()) H = list(map(int,input().split())) H.sort() s = 0 for i in range(N-K): s += H[i] print(s)
p03721
s159911677
Accepted
n,k=map(int,input().split()) num=[list(map(int,input().split())) for i in range(n)] num.sort(key=lambda s:s[0]) for i in range(n): a,b=num[i][0],num[i][1] if k-b>0: k-=b else: print(a) break
p02797
s247522773
Wrong Answer
n,k,s=map(int,input().split()) ans=0 n_max=10**5 ans=[0]*n detarame=10**5-1 ans = [s]*k +[s-1]*(n-k) print(ans)
p03478
s064496379
Accepted
n, a, b = map(int, input().split()) count = 0 def fun(x): y = 0 while(x > 0): y = y + (x%10) x = x//10 return y for i in range(n): sum = fun(i+1) if a <= sum <= b: count = count + (i+1) print(count)
p03472
s684454987
Accepted
import sys mina=10**10 def waru(a,b): if a%b==0: return a//b else: return (a//b)+1 N,H=map(int,input().split()) A=list() B=list() for i in range(N): a,b=map(int,input().split()) A.append(a) B.append(b) ma=max(A) ind=A.index(ma) B=[i for i in B if i>ma] B=sorted(B,reverse=True) cou=1 s=0 for i in range(len(B)): s+=B[i] if H<=s: print(i+1) sys.exit() H=H-s print(len(B)+waru(H,ma))
p02606
s139653722
Wrong Answer
# -*- coding: utf-8 -*- L, R, d = map(int, input().split()) print(int(R/d)-int(L/d))
p03001
s051056688
Accepted
w, h, x, y = map(int, input().split()) scale = (w * h) / 2 if x == w/2 and y == h/2: print('{0:.9f} 1'.format(scale)) else: print('{0:.9f} 0'.format(scale))
p03387
s515559831
Wrong Answer
a,b,c = map(int, input().split()) print((max(a,b,c)*3 - (a+b+c))//2)
p02729
s202758909
Wrong Answer
n,m = map(int,input().split()) n=n*(n-1) m=m*(m-1) print(n/2+m/2)
p02917
s948486284
Wrong Answer
n = int(input()) A =[0]*n B = list(map(int, input().split())) for i in range(n-1): if len(B) == 1: print(2*B[i]) exit() elif B[i] <= B[i-1]: A[i] = B[i] A[i+1] = B[i] else: A[i+1] = B[i] print(sum(A))
p03951
s666639676
Wrong Answer
N=int(input()) s=str(input()) t=str(input()) c=0 S=list(s) T=list(t) for i in range(N): if S[N-i-1]==T[i]: c+=1 print(2*N-c)
p03434
s871611290
Wrong Answer
# coding: UTF-8 N = int(input()) a = list(map(int, input().split())) sum_a, sum_b = 0, 0 for i in reversed(range(1, N)): for j in reversed(range(1, i+1)): if a[j-1] < a[j]: s = a[j-1] a[j-1] = a[j] a[j] = s for i in range(0, N, 2): sum_a += a[i] for i in range(1, N, 2): sum_b += a[i] print(sum_a - sum_b)
p03352
s465170230
Accepted
x=int(input()) ans=0 for i in range(1,34): for j in range(2,11): t=i**j if t<=x: ans=max(ans,t) print(ans)
p02836
s663439822
Accepted
s = input() ans = 0 for i in range(len(s) // 2): left, right = s[i], s[-i - 1] if left != right: ans += 1 print(ans)
p03730
s464435821
Accepted
a,b,c = map(int,input().split()) res = 0 for i in range(b): res =(a * i)% b if res == c: print("YES") break else: print("NO")
p03289
s486631253
Accepted
S = input() f = True if S[0] != 'A': f = False elif S[2:-1].count('C') != 1: f = False else: for s in S[1:]: if s not in 'Cabcdefghijklmnopqrstuvwxyz': f = False break print('AC' if f else 'WA')
p03998
s806083015
Wrong Answer
a = input() b = input() c = input() i = "a" player = {"a":a,"b":b,"c":c} while True: l = player[i][0] player[i] = player[i][1:] if len(player[i])==0: print(i) break i = l
p02778
s666796080
Accepted
S=input() n=len(S) print('x'*n)
p02702
s943200843
Accepted
a = list(map(int,list(input()))) ans = 0 b = 0 c = [0 for i in range(2019)] c[0] = 1 for i in range(len(a)): b = (b+pow(10,len(a)-i,2019)*a[i])%2019 c[b] += 1 c = list(map(lambda x:x*(x-1)//2,c)) ans = sum(c) print(ans)
p02789
s913633265
Accepted
N, M = map(int, input().split()) if N == M: print('Yes') else: print('No')
p02760
s150880209
Accepted
bingo = [list(map(int, input().split())) for _ in range(3)] N = int(input()) for _ in range(N): b = int(input()) for i in range(3): for j in range(3): if bingo[i][j] == b: bingo[i][j] = 0 ans = "No" for k in range(3): if bingo[k][0] == bingo[k][1] == bingo[k][2] or \ bingo[0][k] == bingo[1][k] == bingo[2][k]: ans = "Yes" break if bingo[0][0] == bingo[1][1] == bingo[2][2] or \ bingo[0][2] == bingo[1][1] == bingo[2][0]: ans = "Yes" print(ans)
p02747
s592178262
Accepted
l=input().split("hi") s="".join(l) if s=="": print("Yes") else: print("No")
p03986
s185227725
Accepted
s = input() s_cnt =0 t_cnt =0 cnt = 0 for i in range(len(s)): if s[i] == 'S': s_cnt += 1 if s[i] == 'T': t_cnt += 1 if s_cnt >0: t_cnt -= 1 s_cnt -= 1 print(t_cnt + s_cnt)
p03062
s158418184
Accepted
n = int(input()) a = list(map(int, input().split())) minus = 0 sum = 0 zero = False minimum = abs(a[0]) for i in a: if i == 0: zero = True if i < 0: minus += 1 minimum = min(minimum, abs(i)) sum += abs(i) if zero: print(sum) elif minus % 2 == 0: print(sum) else: print(sum - 2 * minimum)
p03836
s880871979
Accepted
if __name__ == '__main__': sx, sy, tx, ty = map(int, input().split()) u1 = ty - sy r2 = tx - sx root = 'U' * u1 + 'R' * r2 + 'D' * u1 + 'L' * (r2+1) root2 = 'U' * (u1+1) + 'R' * (r2+1) + 'D' + 'R' + 'D' * (u1+1) + 'L' * (r2+1) + 'U' print(root + root2)
p03495
s742659751
Wrong Answer
n,k = map(int,input().split()) a = list(map(int,input().split())) #n,k = 10,3 #a = [5,1,3,2,4,1,1,2,3,4] count = [0] * (n+1) for i in a: count[i] += 1 count2=[] for i in count: if i: count2.append(i) count2 = sorted(count2) #何種類減らせばいいか x = len(set(a)) y = x - k y = max(0,y) ans = 0 if not y: print(ans) else: for i in range(y+1): ans += i print(ans)
p02836
s209180828
Wrong Answer
def main(): S=input() S_rev=S[::-1] sCount=0 for i in range(len(S)): if(S[i]!=S_rev[i]): sCount+=1 print(sCount) if __name__ == '__main__': main()
p03680
s491394116
Wrong Answer
n = int(input()) a = [] for i in range(n): a.append(int(input())) cur = 0 cnt = 0 for i in range(10**7): if a[cur] == 2: print(cnt) exit() cur = a[cur]-1 cnt += 1 print(-1)