problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02918
s771366927
Accepted
n,k=map(int,input().split()) s=input() ans=0 for i in range(n-1): ans+=1 if s[i]==s[i+1] else 0 print(min(ans+2*k,n-1))
p02866
s779802394
Wrong Answer
#import sys #import numpy as np import math #import itertools #from fractions import Fraction #import itertools from collections import deque from collections import Counter #import heapq #from fractions import gcd #input=sys.stdin.readline #import bisect Mod=998244353 n=int(input()) d=list(map(int,input().split())) c=Counter(d) ans=1 for i in c: if i==0: if c[i]!=1: print(0) exit() else: if i-1 not in c: print(0) exit() else: ans*=pow(c[i-1],c[i],Mod) ans%=Mod print(ans)
p04043
s077128366
Accepted
a,b,c=map(int,input().split()) n=[a,b,c] m=len([i for i in n if i==5]) p=len([i for i in n if i==7]) if m==2 and p==1: print('YES') else: print('NO')
p03761
s401085015
Wrong Answer
from collections import Counter from copy import deepcopy n = int(input()) c = Counter([]) dic = Counter([]) for ch in str(input()): c[ch] += 1 dic[ch] += 1 for _ in range(n-1): tmp = deepcopy(c) for ch in str(input()): if tmp[ch] > 0: tmp[ch] -= 1 dic[ch] += 1 l = [] for s, i in Counter(dic).items(): for _ in range(i//n): l.append(s) l.sort() print(''.join(l))
p02595
s537330167
Accepted
from math import sqrt c = 0 N ,D = map(int,input().split()) for i in range(N): x, y = map(int, input().split()) T = sqrt(x**2 + y**2) if T <= round(D): c = c+1 print(c)
p03017
s026864859
Wrong Answer
N,A,B,C,D=map(int,input().split()) S=input() if C<D: for i in range(N-1): if S[i]==S[i+1] and S[i]=='#': print('No') exit() print('Yes') else: cnt=0 for i in range(B,D): if S[i]=='.': cnt+=1 else: cnt=0 if cnt==3: print('Yes') exit() print('No')
p03836
s312867364
Accepted
sx,sy,tx,ty=map(int,input().split()) dx=tx-sx dy=ty-sy u="U" d="D" r="R" l="L" print(u*dy+r*dx+d*dy+l*dx+l+u*(dy+1)+r*(dx+1)+d+r+d*(dy+1)+l*(dx+1)+u)
p02861
s210709148
Wrong Answer
import itertools n = int(input()) geo = [list(map(int, input().split())) for i in range(n)] sum_dist = 0 num_pattern = 0 for pattern in itertools.permutations([i for i in range(n)], n): print(pattern) for i in range(1, n): x, y = geo[pattern[i]] x_prev, y_prev = geo[pattern[i-1]] d = ((x-x_prev) ** 2 + (y-y_prev) ** 2) ** 0.5 sum_dist += d num_pattern += 1 print(sum_dist / num_pattern)
p03380
s947007952
Accepted
import numpy as np n = int(input()) a = np.array(list(map(int, input().split()))) ai = a.max() v, aj = 0, 0 for i in a: tmp = i * (ai - i) if v < tmp: v = tmp aj = i # print(v, aj) print(*(ai, aj))
p02842
s812072436
Accepted
X = int(input()) ans = int(X/1.08) if int(ans*1.08) == X: print(ans) elif int((ans+1)*1.08) == X: print(ans+1) else: print(':(')
p02631
s996791556
Wrong Answer
#!/usr/bin/python # -*- coding: utf-8 -*- import numpy as np import collections def int_mtx(N): x = [] for _ in range(N): x.append(list(map(int,input().split()))) return np.array(x) N = int(input()) a = list(map(int,input().split())) ans = [] x1 = 10**9 ans.append(x1) for i in range(1,N): ans.append(a[0]^a[i]^x1) print(' '.join(map(str, ans)))
p02972
s915095792
Wrong Answer
N=int(input()) A=list(map(int,input().split())) A=[0]+A B=[] for i in range(N): k=N-i c=0 for i in range(k,N+1,k): c+=A[i] c%=2 if A[k]!=(c-A[k])%2: B.append(k) print(len(B)) for i in B: print(i)
p03438
s861995510
Accepted
N=int(input()) a=[int(i) for i in input().split()] b=[int(i) for i in input().split()] can = sum(b)-sum(a) actA,actB = 0,0 for i in range(N): diff = b[i]-a[i] if diff==0:continue if diff>0: actA+=(diff+1)//2 actB+=diff%2 else: actB+=(-diff) leftA = can-actA leftB = can-actB print("Yes" if leftA>=0 and leftA*2==leftB else "No")
p03493
s724297350
Accepted
num = int(input()) hun = num // 100 ten = (num % 100) // 10 one = num % 10 print(hun+ten+one)
p02994
s769069548
Wrong Answer
n, l = map(int, input().split()) ll = [] for i in range(1, n+1): ll.append(i + l - 1) if ll[0]>= 0: ans = sum(ll) - ll[0] elif ll[n-1]<=0: ans = sum(ll) - ll[n-1] else: if n != 3: for i in range(1, n-1): if abs(ll[i-1]) < abs(ll[i]) < abs(ll[i+1]): ans = sum(ll) - ll[i] else: ans = sum(ll) - ll[1] print(ans)
p02607
s182737115
Accepted
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) N = int(input()) As = list(mapint()) ans = 0 for i in range(N): a = As[i] if a%2==1 and (i+1)%2==1: ans += 1 print(ans)
p03910
s502369928
Accepted
N = int(input()) l,r=1,N while r-l>1: m=(l+r)//2 s=m*(m+1)//2 if s>=N: r=m else: l=m for i in range(1,r+1): if i!=r*(r+1)//2-N: print(i)
p02879
s742013601
Accepted
a, b = map(int, input().split()) if a < 10 and b < 10: print(a*b) else: print(-1)
p03478
s772971518
Accepted
n, a, b = map(int, input().split()) num_lists = list(range(1, n+1, 1)) sum_lists = [] for i in num_lists: count = 0 j = i while j >0: ans = j%10 count += ans j = j//10 if a <= count and count <= b: sum_lists.append(i) answer = 0 for i in sum_lists: answer += i print(answer)
p02761
s009862345
Accepted
N,M = map(int,input().split()) SC = [] for i in range(M): SC.append(list(map(int,input().split()))) for i in range(0,1000): si = str(i) if len(si) != N: continue flag = False for s,c in SC: s = s-1 if si[s] != str(c): flag = True if not flag: print(i) exit() print(-1)
p03219
s418193810
Wrong Answer
max = 0 print(max)
p03632
s709107696
Accepted
A,B,C,D=map(int,input().split()) s=min(B,D)-max(A,C) print(max(0,s))
p03633
s292202705
Accepted
import fractions n=int(input()) t=[] for _ in range(n): T=int(input()) t.append(T) ans=t[0] for i in range(1, len(t)): ans = ans * t[i] // fractions.gcd(ans, t[i]) print(ans)
p03860
s107618420
Accepted
_, s, _ = input().split() print("A" + s[0] + "C")
p03617
s935933364
Wrong Answer
a = input().split() q = int(a[0]) * 4 h = int(a[1]) * 2 s = int(a[2]) d = int(a[3]) / 2 b = int(input()) if min([q,h,s,d]) != d: print(b * min([q,h,s,d])) else: if b % 2 == 0: print(int(b * d)) elif b != 1: print(int((b-1) * d) + min([q,h,s])) else: print(min([q,h,s]))
p04034
s847741277
Accepted
n,m = map(int,input().split()) xy = [[int(i) for i in input().split()] for _ in range(m)] num = [1]*n red = [False]*n red[0] = True flag = True for i in range(m): p = xy[i][0] q = xy[i][1] num[p-1] -= 1 num[q-1] += 1 if red[p-1]==True: red[q-1] = True if num[p-1]==0: red[p-1] = False count = 0 for i in range(n): if num[i]>0 and red[i]: count += 1 print(count)
p03971
s191247881
Wrong Answer
n, a, b = map(int, input().split()) s = input() print(len(s)) b_cnt = 0 a_cnt = 0 for i in range(n): if s[i] == "a" and (a_cnt+b_cnt) < a+b: a_cnt += 1 print("Yes") elif s[i] == "b" and (a_cnt+b_cnt) < a+b and b_cnt < b: #print(b_cnt) b_cnt += 1 print("Yes") else: print("No")
p03815
s618143822
Accepted
N=int(input()) k=(N-1)//11 ans=2*k if N-k*11<=6: ans+=1 else: ans+=2 print(ans)
p03815
s279596630
Wrong Answer
x = int(input()) cnt = x // 11 x -= 11 * cnt cnt = cnt * 2 + 1 if x > 6: cnt += 1 print(cnt)
p02682
s420162870
Wrong Answer
A,B,C,K=map(int,input().split()) print(A,B,C,K) if A+B>=K: print(A) else: print(A-C)
p03486
s864399451
Accepted
s=input() t=input() if s==t: print("No") exit() s1=[s[i] for i in range(len(s))] t1=[t[i] for i in range(len(t))] s1.sort() t1.sort(reverse=True) S="".join(s1) T="".join(t1) #print(S,T) l=[S,T] l.sort() if l[0]==S: print("Yes") else: print("No")
p02629
s807865993
Accepted
def main(): n = int(input()) chars = 'zabcdefghijklmnopqrstuvwxy' st = '' while True: a = n % 26 st += chars[a] n = n // 26 if n == 0 or (a == 0 and n == 1): break elif a == 0: n -= 1 res = ''.join(list(reversed(st))) print(res) main()
p02912
s057266863
Wrong Answer
import heapq N,M = map(int,input().split(" ")) nums = map(int,input().split(" ")) nums = [n * -1 for n in nums] heapq.heapify(nums) while M > 0: curr = heapq.heappop(nums) heapq.heappush(nums,curr//2) M -=1 print(-sum(nums))
p02553
s528321168
Wrong Answer
a = list(map(int,input().split())) max = -10 ** 11 for i in range(2): for j in range(2,4): p = a[i] * a[j] #print(p) if abs(max) < abs(p) and 0 < p: max = p elif abs(p) < abs(max) and 0 > p: max = p print(max)
p03281
s122140679
Accepted
d8 = [105, 135, 165, 189, 195] n = int(input()) print(sum([1 for i in d8 if i <= n]))
p02676
s320055274
Wrong Answer
s = [input() for i in range(2)] s0 = int(s[0]) l0 = len(s[1]) if s0 >= l0: print(s[1]) if s0 < l0: print(s[1][:s0],'...')
p03817
s980677639
Accepted
import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal def s(): return input() def i(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def L(): return list(input().split()) def l(): return list(map(int,input().split())) def lcm(a,b): return a*b//math.gcd(a,b) sys.setrecursionlimit(10 ** 9) mod = 10**9+7 x = i() num = (x//11)*11 r = x-num if r == 0: print((x//11)*2) elif r <= 6: print((x//11)*2+1) else: print(((x//11)+1)*2)
p03804
s881193196
Wrong Answer
n, m = map(int, input().split()) A = [input() for _ in range(n)] B = [input() for _ in range(m)] def issubset(l, u, r, d): for i, y in enumerate(range(u, d)): for j, x in enumerate(range(l, r)): res = A[y][x] == B[i][j] if not res: return False return True for y in range(n - m): for x in range(n - m): if issubset(x, y, x+m, y+m): print("Yes") exit() print("No")
p02760
s359035996
Accepted
#!/usr/bin/env python3 A = [[int(str) for str in input().strip().split()] for _ in range(3)] N = int(input().strip()) b = [int(input().strip()) for _ in range(N)] ans = False for i in range(3): ans |= all([A[i][j] in b for j in range(3)]) for j in range(3): ans |= all([A[i][j] in b for i in range(3)]) ans |= all([A[i][i] in b for i in range(3)]) ans |= all([A[i][2 - i] in b for i in range(3)]) print('Yes' if ans else 'No')
p03062
s863723684
Wrong Answer
n = int(input()) A = list(map(int, input().split())) if n == 2: print(max(sum(A), -sum(A))) exit() for i in range(n-2): if A[i] < 0: A[i] *= (-1) A[i+1] *= (-1) s = sum(A[0:(n-2)]) ans = max(s+A[n-2]+A[n-1], s-A[n-2]-A[n-1]) print(ans)
p02802
s923752908
Wrong Answer
N,M=map(int,input().split()) p=[list(input().split()) for _ in range(M)] AC_count=0 WA_count=0 AC_flag=0 if M==0: print(0,0) exit() if p[0][1]=="WA" and AC_flag==0: WA_count+=1 else: AC_count+=1 AC_flag=1 for i in range(1,M): if p[i-1][0]!=p[i][0]: AC_flag=0 if p[i][1]=="WA" and AC_flag==0: WA_count+=1 elif p[i][1]=="AC" and AC_flag==0: AC_count+=1 AC_flag=1 print(AC_count,WA_count)
p04011
s517662064
Accepted
n = int(input()) k = int(input()) x = int(input()) y = int(input()) sum = 0 for i in range(1, n + 1): if i <= k: sum += x else: sum += y print(sum)
p02677
s535909272
Accepted
import math A,B,H,M=list(map(int,input().split())) move = 60*H+M a_move = math.radians(move/720*360) b_move = math.radians(M/60*360) ax = A*math.cos(a_move) ay = A*math.sin(a_move) bx = B*math.cos(b_move) by = B*math.sin(b_move) ans = math.sqrt(math.pow(ax-bx,2) + math.pow(ay-by,2)) print(ans)
p03284
s883639936
Wrong Answer
N, K = map(int, input().split()) if N < K: print(K - N) else: print(N - (N // K) * K)
p02706
s863012986
Accepted
num = list(map(int, input().split())) a = list(map(int, input().split())) tmp = num[0]-sum(a) if tmp<0: print(-1) else: print(tmp)
p03042
s193902148
Accepted
def check_my(string): if 1 <= int(string) <= 12: return 'YorM' else: return 'Y' s = input() my_set = (check_my(s[0:2]), check_my(s[2:4])) if my_set == ('YorM', 'YorM'): print('AMBIGUOUS') elif my_set == ('YorM', 'Y'): print('MMYY') elif my_set == ('Y', 'YorM'): print('YYMM') else: print('NA')
p02629
s187500892
Wrong Answer
n = int(input()) a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o','p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] ans = "" for i in range(11, -1, -1): if i==0: res=n else: res = n//(26**i) if res%26 == 0: continue else: ans += a[res%26-1] print(ans)
p02911
s489087816
Accepted
def main(): N,K,Q=map(int,input().split()) A=[int(input()) for i in range(Q)] n=[K-Q]*N for a in A: n[a-1]+=1 for i in n: print('Yes' if i>0 else 'No') main()
p03107
s223437804
Accepted
s = input() red = s.count("0") blue = s.count("1") ans = min(red,blue) print(ans*2)
p02572
s355715748
Wrong Answer
n=int(input()) a=list(map(int,input().split())) x=(sum(a)-a[n-1])*(sum(a)-a[0]) print(x%(10**9+7))
p03852
s053344896
Wrong Answer
c = str(input()) boin = ['a', 'b', 'c', 'd', 'e'] if c in boin: ans = 'vowel' else: ans = 'consonant' print(ans)
p02659
s532426145
Accepted
from decimal import Decimal import math ''' a=10**15 b=9.99 ''' a,b=map(Decimal,input().split()) num=a*b #print(num) num=math.floor(num) print(num)
p02603
s022137190
Accepted
N = int(input()) A = list(map(int, input().split())) ans = 1000 for i in range(N - 1): a = A[i] if a < A[i + 1]: units = ans // a ans = (ans - units * a) + units * A[i + 1] # print(i, ans) print(ans)
p03767
s015156443
Accepted
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) point_sum = 0 for i in range(1, n+1): point_sum += a[i*2 - 1] print(point_sum)
p03035
s845968594
Wrong Answer
A, B = map(int, input().split()) if 13 <= A: print(B) elif 6 <= A <= 12: print(B / 2) elif 0 <= A <= 5: print(0)
p02900
s160012960
Accepted
def decomposition_prime(n): i = 2 li = [] while i*i <= n: while n%i == 0: li.append(i) n /= i i += 1 if n > 1: li.append(int(n)) return li a, b = map(int, input().split()) ap = decomposition_prime(a) bp = decomposition_prime(b) print(len(set(ap) & set(bp))+1)
p03105
s262461412
Accepted
a, b, c = map(int, input().split()) print(min(b // a, c))
p02594
s913917188
Wrong Answer
from collections import defaultdict 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() n = int(input()) start = 0 for i in range(1,n+1): start = (start*10+7)%n if start==0: print(i) break else: print(-1)
p03910
s383342650
Accepted
n=int(input()) ans=[1] i=2 while n>sum(ans): ans.append(i) i+=1 if n!=sum(ans): ans.remove(sum(ans)-n) [print(i) for i in ans]
p03438
s987840458
Accepted
n=int(input()) a,b=[list(map(int,input().split())) for i in range(2)] if sum(a) >sum(b):print("No") elif sum(a)==sum(b): for x,c in zip(a,b): if x!=c:print("No");exit() print("Yes") else: cnt=sum(b)-sum(a) v=cnt for x,y in zip(a,b): if x>=y:v-=(x-y) else: v-=(x+y)%2 cnt-=(y-x+(x+y)%2)//2 print("Yes") if cnt*2==v and cnt>=0 and v>=0 else print("No")
p02860
s930746492
Accepted
n = int(input()) s = input() if n%2 == 1: print('No') elif s[:n//2]==s[n//2:]: print('Yes') else: print('No')
p03286
s269075964
Accepted
N = int(input()) S = "" if N == 0: S = "0" c = 1 while N != 0: if N%(2**c) != 0: N -= (-2)**(c-1) S = "1" + S else: S = "0" + S c += 1 print(S)
p03665
s095138845
Accepted
n,k = map(int,input().split()) lst = list(map(int,input().split())) e,o = 0,0 for i in range(n): if lst[i]%2==0: e += 1 else: o += 1 if o==0: if k==0: print(2**n) else: print(0) else: print(2**(n-1))
p02602
s453736672
Accepted
n,k = map(int,input().split()) a = list(map(int,input().split())) tmp = 0 c = 0 ls = [100] for i in range(k): tmp += a[i] ls[0] = tmp for i in range(n-k): tmp -= a[i] tmp += a[i+k] if ls[0] >= tmp: print("No") else: print("Yes") ls[0] = tmp #print(ls,tmp)
p02641
s136652269
Wrong Answer
x, n = map(int, input().split()) p = list(map(int, input().split())) def main(): if len(p) == 0: print(x) return ans_l = list(range(x-15, x+15)) diff_l = list(set(p) ^ set(ans_l)) diff_l.sort() cnt = 100 ans = 100 for i in range(0, len(diff_l)): check = abs(diff_l[i]-x) if check < cnt: cnt = check ans = diff_l[i] print(ans) return main()
p02790
s123428885
Accepted
a,b=map(int,input().split()) if a>b: print(str(b)*a) else: print(str(a)*b)
p03495
s560093930
Accepted
n,k=map(int,input().split()) a=[int(i) for i in input().split()] c=[0]*(n+1) for i in a: c[i]+=1 print(sum(sorted(c)[:-k]))
p02552
s009965346
Accepted
x = int(input()) if x == 0: print(1) else: print(0)
p02630
s732785415
Accepted
from collections import Counter def main(): n = input() a = [int(v) for v in input().split()] count = dict(Counter(a)) q = int(input()) ans = 0 for k, v in count.items(): ans += k*v for i in range(q): b, c = map(int, input().split()) ans = ans - count.get(b, 0) * b + count.get(b, 0) * c print(ans) count[c] = count.get(c, 0) + count.get(b, 0) count[b] = 0 if __name__ == '__main__': main()
p03962
s981356390
Accepted
a=list(map(int,input().split())) a.sort() count=1 for i in range(2): if a[i]!=a[i+1]: count+=1 print(count)
p02881
s701578321
Accepted
import math N = int(input()) a = 1 b = N sqrt = math.floor(N ** (1/2)) for n in range(sqrt, 0, -1): if N % n == 0: a = n b = N // n break print(a + b - 2)
p03211
s213297408
Accepted
s = input() print(min([abs(753-int(s[i:i+3])) for i in range(len(s)-2)]))
p02860
s113760556
Accepted
N = int(input()) S = input() if S[:N//2] == S[N//2:]: print("Yes") else: print("No")
p03759
s702132415
Accepted
def resolve(): a, b, c = list(map( int, input().split() )) print("YES" if b-a == c-b else "NO") if '__main__' == __name__: resolve()
p02759
s185314842
Accepted
a=int(input()) if a%2==0: print(a//2) else: print((a//2)+1)
p03785
s578164013
Accepted
N, C, K = map(int, input().split()) Tlist = sorted([int(input()) for _ in range(N)]) ans = 0 now = 1 start = Tlist[0] for t in Tlist[1:]: if now == C: ans += 1 start = t now = 1 else: if t - start <= K: now += 1 else: ans += 1 start = t now = 1 print(ans+1)
p03481
s138931997
Accepted
x, y = map(int, input().split()) print(len(bin(y//x)[2:]))
p03438
s579363829
Accepted
n = int(input()) a, b = [list(map(int, input().split())) for i in range(2)] ap = bp = 0 for i in range(n): if a[i]>b[i]: bp += a[i]-b[i] else: if (b[i]-a[i])%2: bp += 1 ap += (b[i]-a[i]+1)//2 print("YNeos"[ap<bp::2])
p02661
s538692294
Wrong Answer
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n = int(readline()) aa = [] bb = [] for _ in range(n): a, b = map(int, readline().split()) aa.append(a) bb.append(b) aa.sort() bb.sort(reverse=True) if n == 2: print(bb[0] - aa[0] + 1) else: print(bb[1] - aa[1] + 1)
p02836
s061588577
Accepted
S = input() s = len(S) ct = 0 for i in range(s): if S[i] != S[(-i-1)]: ct += 1 print(ct//2)
p02987
s014386793
Wrong Answer
s = input() for i in set(s): if s.count(i) % 2 == 1: print("No") exit() print("Yes")
p02948
s319679066
Wrong Answer
n, m = map(int, input().split()) AB = [None] * n maxa = 0 for i in range(n): AB[i] = tuple(map(int, input().split())) if AB[i][0] > maxa: maxa = AB[i][0] AB.sort(key=lambda ab: -ab[1]) cands = [b for _, b in AB[:m - maxa]] AB = AB[m - maxa:] counts = [0] * m for a, b in AB[:maxa]: if a <= m and sum(counts[a - 1:]) <= m - a: cands.append(b) counts[a - 1] += 1 print(sum(cands[:m]))
p02552
s257009522
Accepted
x = int(input()) print(x^1)
p02696
s076960429
Accepted
from math import floor def main(): a, b, n = map(int, input().split()) x = b - 1 if x > n: x = n print(floor(a*x/b)) if __name__ == '__main__': main()
p03803
s834943894
Wrong Answer
a,b = map(int, input().split()) if a>b and b!=1 or a==1: print("Alice") elif a==b: print("Draw") else: print("Bob")
p02924
s680064700
Accepted
n = int(input()) print((n * (n-1)) // 2)
p03799
s712050621
Wrong Answer
n,m=map(int,input().split()) if n*2>=m: print(m//2) else: ((n*2+m)//4)
p03041
s351646864
Accepted
n,k = map(int,input().split()) s = list(input()) if s[k-1] == "A": s[k-1] = "a" elif s[k-1] == "B": s[k-1] = "b" else: s[k-1] = "c" print("".join(s))
p03495
s451565684
Accepted
import collections as c n,k = map(int,input().split()) x = list(map(int,input().split())) y = c.Counter(x) s = [] for i in y.items(): s.append([i[1],i[0]]) s.sort() ans = 0 for i in range(len(s)-k): ans += s[i][0] print(ans)
p02880
s850601943
Accepted
n = int(input()) for i in range(1,10): r = n/i if 1 <= r <= 9 and r == int(r): print("Yes") exit() print("No")
p04019
s987977536
Accepted
S = input() n = S.count('N') w = S.count('W') s = S.count('S') e = S.count('E') def f(n,s): return (n==0 and s==0) or (n>0 and s>0) b = f(n,s) and f(e,w) if b: print("Yes") else: print("No")
p02572
s692246026
Accepted
N = int(input()) A = list(map(int, input().split())) prefix = [0] for a in A: prefix.append(prefix[-1] + a) res = 0 M = 10 ** 9 + 7 for i, a in enumerate(A[:-1], start=1): res += a * (prefix[N] - prefix[i]) res %= M print(res)
p03836
s313267382
Wrong Answer
sx,sy,tx,ty = map(int,input().split()) dx = tx-sx dy = ty-sy print("R"*dx+"U"*dy+"R"+"D"*(dy+1)+"L"*(dx+1) +"U"\ +"U"*dy+"R"*dx+"U"+"L"*(dy+1)+"D"*(dx+1) +"R" )
p03815
s945413493
Wrong Answer
x = int(input()) s , a = divmod(x , 11) if a > 6: print((s*2) + 2) else: print((s*2) + 1)
p03061
s244025077
Accepted
import fractions from functools import reduce N = int(input()) a = list(map(int, input().split())) left = [0] * (N+1) right = [0] * (N+1) for i in range(N): left[i+1] = fractions.gcd(left[i], a[i]) right[N-i-1] = fractions.gcd(right[N-i], a[N-1-i]) ans = 0 for i in range(N): ans = max(ans, fractions.gcd(left[i], right[i+1])) print(ans)
p02866
s137839339
Wrong Answer
N = int(input()) A = list(map(int,input().split())) dic = {} for i in range(N): if A[i] in dic:dic[A[i]] += 1 else:dic[A[i]] = 1 # print(dic) num = 1 n = 0 if not dic.get(0):num = 0 else: while 1: num *= dic[n]**dic[n+1] dic.pop(n) n += 1 if not dic.get(n+1): dic.pop(n) if dic.keys(): num = 0 break print(num)
p03146
s487549254
Accepted
s = int(input()) moto = s count = 0 while s!=1: if s%2==0: s /= 2 else: s = s*3+1 count += 1 if moto == 1: print(4) elif moto == 2: print(4) else: print(count+2)
p02831
s407878716
Wrong Answer
a,b = map(int,input().split()) #最大公約数 def gcd(a,b):#a<=b while b != 0: a = b b = b % a return a #最小公約数 def lcm(a,b): return a*b / gcd(a,b) print(lcm(a,b))
p03617
s139361315
Accepted
q,h,s,d = map(int,input().split()) #20 30 70 90 N = int(input()) #3 o = min(q*4,h*2,s) if o*2 <= d: print(o*N) else: print(d*(N//2) + o*(N%2))
p02695
s057039477
Accepted
n, m, q = map(int, input().split()) abcd = [tuple(map(int, input().split())) for _ in range(q)] import itertools cr = itertools.combinations_with_replacement(range(1, m+1), n) M = 0 for seq in cr: score = sum([d for a, b, c, d in abcd if seq[b-1] - seq[a-1] == c]) M = max(M, score) print(M)