problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02814
s105738080
Accepted
from functools import reduce def gcd(x, y): if y == 0: return x else: return gcd(y, x%y) def lcm_base(x, y): return x*y//gcd(x, y) def lcm_list(list): return reduce(lcm_base, list) N, M = map(int, input().split()) a = list(map(int, input().split())) b = [x//2 for x in a] T = lcm_list(b) for n in b: if T//n%2 == 0: print (0) break else: print ((M//T+1)//2)
p02838
s373293495
Wrong Answer
N = int(input()) MOD = 1e+9 + 7 a = [int(i) for i in input().split()] b = [0 for _ in range(60)] for i in a: for j in range(60): b[j] += (i >> j) & 1 ans = 0 for i, j in enumerate(b): ans += (j * (N - j)) * 2**i ans %= MOD print(int(ans))
p03720
s259247539
Accepted
N, M = map(int, input().split()) ab = [list(map(int, input().split())) for i in range(M)] city = [0]*N for i in range(M): city[ab[i][0]-1] += 1 city[ab[i][1]-1] += 1 for number in city: print(number)
p03681
s968229122
Accepted
MOD = 10**9 + 7 max = 10**5 + 1 facts = [1 for i in range(max)] invs = [1 for i in range(max)] def inv(x): return pow(x,MOD-2,MOD) for i in range(1,max): facts[i] = facts[i-1]*i%MOD invs[i] = inv(facts[i]) def comb(n,r): return facts[n]*invs[r] * invs[n-r] % MOD n,m = map(int,input().split()) if m > n: n,m = m,n if n-m >= 2: print(0) elif n-m == 1: print(facts[m]*facts[n] % MOD) else: print(facts[m]*facts[n]*2 % MOD)
p02602
s175865158
Accepted
N, K = map(int, input().split()) l = list(map(int, input().split())) for k in range(N - K): hel = l[k] huel = l[k + K] if (hel < huel): print('Yes') else: print('No')
p02819
s432922108
Wrong Answer
import sys def is_prime(q): q = abs(q) if q == 2: return True if q < 2 or q&1 == 0: return False return pow(2, q-1, q) == 1 x = int(input()) for i in range(x, 1000000): if is_prime(i) == True: print(i) break
p03699
s766796707
Wrong Answer
n=int(input()) g=set() for i in range(n): si=int(input()) g2=set() for gg in g: g2.add(si+gg) g=g|g2 g.add(si) # print(g2,g) g3=list(g) g3.sort(reverse=True) for gg in g3: if gg%10==0: continue else: print(gg) break print(0)
p03095
s851829598
Accepted
import sys input = sys.stdin.readline from collections import * N = int(input()) S = input()[:-1] cnt = Counter(list(S)) ans = 1 MOD = 10**9+7 for v in cnt.values(): ans *= v+1 ans %= MOD print((ans-1)%MOD)
p02641
s835260630
Accepted
X,N = map(int,input().split()) if N == 0: print(X) exit() P = [int(i) for i in input().split()] mn = 1000 for i in reversed(range(102)): if i in P: continue if mn >= abs(X-i): ans = i mn = min(mn,abs(X-i)) print(ans)
p02743
s540705307
Accepted
import math a,b,c = list(map(int, input().split())) print("Yes" if 4*a*b < (c - a - b)*(c - a - b) and c - a - b > 0 else "No")
p02756
s158700431
Accepted
import sys from collections import deque readline = sys.stdin.readline readlines = sys.stdin.readlines s = readline().rstrip() q = readline() queries = readlines() s = deque(s) tot_1 = 0 for i in queries: if i[0] == '1': tot_1 += 1 continue c = i[4] if (tot_1 + int(i[2])) % 2 == 0: s.append(c) else: s.appendleft(c) ans = "".join(s) if tot_1 % 2 == 0 else "".join(reversed(s)) print(ans)
p03000
s605502563
Accepted
N,X=map(int,input().split()) L=[int(i) for i in input().split()] count=1 dis=0 for t in L: dis=dis+t if dis<=X: count+=1 else: break print(count)
p02789
s126159831
Wrong Answer
n, m = map(int, input().split()) print("AC" if n == m else "WA")
p02973
s303091464
Accepted
from bisect import bisect N = int(input()) A = [-int(input()) for i in range(N)] mem = [] for a in A: i = bisect(mem, a) if i==len(mem): mem.append(a) else: mem[i] = a print(len(mem))
p02584
s122941363
Wrong Answer
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) X, K, D = mapint() if X>=abs(K*D): print(abs(abs(X)-K*D)) else: l, r = 0, K X = abs(X) while r-l>1: half = (r+l)//2 if half*D>X: r = half else: l = half now = X-l*D if (K-l)%2==0: print(now) else: print(D-now)
p02641
s091906355
Accepted
x,n = map(int,input().split()) lst = sorted(list(map(int,input().split()))) ans = x if ans in lst: pass else: print(ans) exit() left,right = ans-1,ans+1 while True: if left in lst and right in lst: left -=1 right += 1 elif left in lst: print(right) exit() else: print(left) exit()
p03261
s791659074
Wrong Answer
N = int(input()) W = [input() for _ in range(N)] set_W = set() ans = "Yes" for i in range(len(W) - 1): if W[i] in set_W: ans = "No" break set_W.add(W[i]) if W[i][-1] != W[i + 1][0]: ans = "No" break print(ans)
p03264
s686315054
Accepted
K = int(input()) print(((K+1)//2)*(K//2))
p03611
s868944417
Wrong Answer
N=int(input()) a=list(map(int,input().strip().split())) dp=[0 for n in range(max(a)+1)] for n in range(N): dp[a[n]]+=1 ans=0 for n in range(len(dp)-1): if n==0: ans=max(ans,dp[0]+dp[1]) elif n==N-1: ans=max(ans,dp[N-2]+dp[N-1]) else: ans=max(ans,dp[n-1]+dp[n]+dp[n+1]) print(ans)
p02778
s138707782
Accepted
a = list(map(str, input().split())) b = len(a[0]) c = "x" * b print(c)
p03699
s089806125
Accepted
n = int(input()) s = [int(input()) for _ in range(n)] all = sum(s) if all % 10: print(all) else: d = [i for i in s if i % 10] if d: all -= min(d) print(all) else: print(0)
p03145
s313606449
Wrong Answer
x, y, z = map(int, input().split()) print(x*y/2)
p02642
s809820174
Wrong Answer
n = int(input()) a = list(map(int, input().split())) res = 0 for i in range(n): for j in range(n): if i == j: pass elif (a[i] == a[j]) or (a[i]%a[j] == 0): break else: res += 1
p02601
s213931257
Wrong Answer
A, B, C = map(int, input().split()) K = int(input()) for i in range(K): for j in range(K): for k in range(K): if i+j+k != K: continue A = A*pow(2,i) B = B*pow(2,j) C = C*pow(2,k) if A < B and B < C: print("Yes") exit() print("No")
p03360
s896170577
Accepted
data = list(map(int, input().split())) k = int(input()) if k == 1: print( sum(data) + max(data) ) else: tmp = max(data) for _ in range(k): tmp = tmp * 2 print( sum(data) + tmp - max(data) )
p03331
s146220058
Accepted
N = int(input()) n = 1 ans = 10**5 def calucurate(M): n = 0 while M > 0: n += M%10 M //= 10 return n while n < N: t = N - n m = calucurate(t) + calucurate(n) ans = min(ans,m) n += 1 print(ans)
p02546
s685642329
Accepted
s = input() if s[-1] == "s": s = s + "es" else: s = s + "s" print(s)
p03719
s402625272
Accepted
a, b, c = map(int, input().split()) if a<=c and c<=b: print('Yes') else: print('No')
p03711
s364837463
Accepted
x,y = map(int,input().split()) dum1 = [1,3,5,7,8,10,12] dum2 = [4,6,9,11] if x == 2: print("No") else: if dum1.count(x) == 1 and dum1.count(y) == 1: print("Yes") elif dum2.count(x) == 1 and dum2.count(y) == 1: print("Yes") else: print("No")
p03624
s882370688
Accepted
S=input() X=set([s for s in 'abcdefghijklmnopqrstuvwxyz']) for s in S: X.discard(s) X=list(X) X.sort() X.append('None') print(X[0])
p02664
s242191744
Wrong Answer
from sys import exit ii = lambda : int(input()) mi = lambda : map(int,input().split()) li = lambda : list(map(int,input().split())) T = input() t=list(T) cnt=0 for i in range(len(t)): if t[i] == "?": if i != 0 and t[i-1] == "P": t[i] ="D" elif i != len(t)-1 and t[i+1] == "D": t[i] = "P" else: t[i] = "P" for i in range(len(t)): print(t[i] ,end="") print("")
p02705
s377019535
Accepted
import numpy as np R = int(input()) print(2*np.pi*R)
p02786
s544003785
Accepted
#-*-coding:utf-8-*- import sys input=sys.stdin.readline def main(): enemy_hp = int(input()) enemy_count=1 attack_count=1 if enemy_hp==1: print(1) exit() else: while enemy_hp >1: enemy_hp = int(enemy_hp/2) enemy_count*=2 attack_count+=enemy_count print(attack_count) if __name__=="__main__": main()
p03836
s571565807
Accepted
sx, sy, tx, ty = map(int, input().split()) diff_x = tx - sx diff_y = ty - sy ans = 'U' * diff_y + 'R' * diff_x + 'D' * diff_y + 'L' * diff_x ans += 'LU' + 'U' * diff_y + 'R' * diff_x + 'RDRD' + 'D' * diff_y + 'L' * diff_x + 'LU' print(ans)
p02621
s989070124
Accepted
a=int(input()) print(a+a**2+a**3)
p03075
s630260624
Accepted
a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) k = int(input()) if e-a<=k: print("Yay!") else: print(":(")
p03385
s352734265
Accepted
s = input() a = set(s) if len(a) == 3: print("Yes") else: print("No")
p02683
s425778043
Wrong Answer
N,M,X=map(int,input().split()) l=[] for i in range (N): l.append(list(map(int,input().split()))) ans=10000000 for i in range(2**N): score=[0]*M coin=0 for j in range(N): if i>=2**(N-1-j): for p in range(M): score[p]+=l[j][p+1] coin+=l[j][0] i-=2**(N-1-j) flag=0 for q in range(M): if score[q]<X: flag=1 if flag==0: if ans>coin: ans=coin print(ans)
p02659
s965503954
Accepted
A, B = map(float, input().split()) B = B * 100 + 0.99 B = int(B) print(int(A) * B // 100)
p03150
s691357411
Accepted
S = str(input()) N = len(S) for i in range(N): for j in range(i,N): if S[:i] + S[j:] == 'keyence': print('YES') exit() print('NO')
p03345
s881447840
Accepted
a,b,c,k=map(int,input().split()) print(a-b if k%2==0 else b-a)
p03672
s399055503
Accepted
S = input() ls = len(S) while True: ls -= 1 if ls % 2 == 1: continue leftS = S[0:ls//2] rightS = S[ls//2:ls] if leftS == rightS: print(ls) exit()
p02866
s607917253
Accepted
from collections import Counter n = int(input()) a = list(map(int,input().split())) mod = 998244353 if a[0] != 0: print(0) exit() ans = 1 c = Counter(a) cls = list(c.items()) cls.sort() if cls[0][1] != 1: print(0) exit() for i in range(1,len(cls)): if cls[i][0] != i: print(0) exit() ans = ans*cls[i-1][1]**cls[i][1]%mod print(ans)
p02973
s736729231
Wrong Answer
def LIS(A): dp = [-A[0]] for a in A[1:]: if -a >= dp[-1]: dp.append(-a) else: dp[bisect_left(dp, -a)] = -a return len(dp) ################################################################################################################## import sys input = sys.stdin.readline from bisect import bisect_left N = int(input()) A = [int(input()) for _ in range(N)] print(LIS(A))
p02633
s948898757
Accepted
def gcd(x,y): if x<y: x,y=y,x if y==0: return x return gcd(y,x%y) def lcm(x,y): return x*y//gcd(x,y) def main(): x=int(input()) l=lcm(360,x) print(l//x) if __name__=='__main__': main()
p03625
s201272791
Wrong Answer
from collections import defaultdict n = int(input()) a = list(map(int, input().split())) cnt = defaultdict(int) data = [] for i in range(n): cnt[a[i]] += 1 if sum(v >= 2 for v in cnt.values()) < 2: print(0) else: for k, v in cnt.items(): if v >= 2: data.append(k) data.sort(reverse = True) print(data[0] * data[1])
p03069
s549387087
Accepted
N = int(input()) S = list(input()) WL = 0 WR = 0 BL = 0 BR = 0 for i in range(N): if S[i] == '#': BR += 1 else: WR += 1 ans = BL+WR for i in range(N): if S[i] == '#': BR -= 1 BL += 1 else: WR -= 1 WL += 1 ans = min(ans,BL+WR) print(ans)
p03951
s109535759
Wrong Answer
n = int(input()) s = list(reversed(input())) t = list(input()) for idx, (ss, tt) in enumerate(zip(s,t)): if ss != tt: break if list(reversed(s)) == t: print(len(s)) else: print(n + idx + 1)
p03254
s372363820
Accepted
n,x = map(int,input().split()) a = sorted(list(map(int,input().split()))) ans = 0 for i,h in enumerate(a[:-1]): x-=h if x>=0:ans+=1 if x==a[-1]:ans+=1 print(ans)
p03543
s196258001
Wrong Answer
n = int(input()) print("Yes" if len(str(n)) == 4 and len(set(str(n))) < 3 else "No")
p02723
s036069234
Accepted
s=input() if s[2]==s[3] and s[4]==s[5]: print("Yes") else: print("No")
p03556
s249987375
Accepted
from math import sqrt print(int(sqrt(int(input())))**2)
p03457
s564788456
Accepted
N = int(input()) t = [0] x = [0] y = [0] for _ in range(N): a, b, c = list(map(int, input().split())) t.append(a) x.append(b) y.append(c) # print(f"t:{t}\nx:{x}\ny:{y}") for index in range(1, N + 1): distance = (x[index] - x[index - 1]) + (y[index] - y[index - 1]) duration = t[index] - t[index - 1] if duration < distance or duration % 2 != distance % 2: print("No") break else: print("Yes")
p02696
s908408416
Accepted
a, b, n = map(int, input().split()) x = min(b - 1, n) def f(x): return int(a * x / b) - a * int(x / b) print(f(x))
p03557
s386966876
Wrong Answer
import sys input = sys.stdin.readline n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] c = [int(i) for i in input().split()] ans = 0 a = tuple(a); b = tuple(b); c = tuple(c) a = sorted(a) b = sorted(b,reverse=True) c = sorted(c) import bisect chk_b = [0]*n for i,bi in enumerate(b): y = bisect.bisect_right(c, bi) chk_b[i] = max(0,n-y) + chk_b[i-1] chk_b = tuple(chk_b) b = sorted(b) for i in a: x = bisect.bisect_right(b, i) ans += chk_b[n-1-x] print(ans)
p03075
s459211486
Accepted
# | Its_Rashid | # v = [int(input()) for i in range(5)] a = int(input()) for i in range(0 , 5) : for j in range(1 ,5) : if v[j] - v[i] > a: print(':(') quit() else : print('Yay!')
p03854
s913581871
Wrong Answer
s = input() s = s.replace('dreamer', '') s = s.replace('dream', '') s = s.replace('eraser', '') s = s.replace('erase', '') if s == '': print('YES') else: print('NO')
p03012
s680627318
Wrong Answer
n = int(input()) w = list(map(int, input().split())) total = sum(w) dif = 10**5 point = 0 for i in w: point += i if abs(total-2*i) < dif: dif = abs(total-2*point) print(dif)
p03759
s766044273
Accepted
pole1, pole2, pole3 = map(int, input().split()) if pole2 - pole1 == pole3 - pole2: print('YES') else: print('NO')
p03038
s065502475
Wrong Answer
import collections N,M = map(int, input().split()) A = list(map(int,input().split())) D = collections.Counter(A) A.sort() max = 0 for i in range(M): B,C = map(int, input().split()) D[C] += B D = sorted(D.items(), key=lambda x:x[0],reverse=True) sum = 0 count = 0 for k,v in D: print("k : " + str(k) + " v: " + str(v) + " n: " + str(N)) if N > v : sum += k * v N -= v else : sum += k * N break print(sum)
p03062
s705876846
Accepted
N = int(input()) A = list(map(int, input().split())) Flag = False cnt = 0 S = 0 m = 10**9 for i in A: if i == 0: Flag = True elif i > 0: S += i m = min(m, i) else: S += -i cnt ^= 1 m = min(m, -i) if Flag or cnt == 0: print(S) else: print(S-2*m)
p03495
s819135172
Accepted
N, K = map(int, input().split()) A = [int(x) for x in input().split()] numberlist = dict() for i in range(N): if A[i] in numberlist: numberlist[A[i]] += 1 else: numberlist[A[i]] = 1 numberlist = sorted(numberlist.items(), key=lambda x: x[1]) #print(numberlist) ans = 0 index = 0 lenlist = len(numberlist) while(1): if index >= lenlist - K: break ans += numberlist[index][1] index += 1 print(ans)
p02689
s100380048
Accepted
import sys import math import collections from collections import deque from functools import reduce import heapq #x = int(input()) n, m = map(int, sys.stdin.readline().split()) #s = input() h = list(map(int, sys.stdin.readline().split())) l = [] for i in range(m): a, b = map(int, sys.stdin.readline().split()) if h[a-1] > h[b-1]: l.append(b) elif h[b-1] > h[a-1]: l.append(a) else: l.append(a) l.append(b) c = collections.Counter(l) print(n-len(c))
p03680
s206220004
Wrong Answer
n=int(input()) a=[0] for _ in range(n): a.append(int(input())) v=[1] cnt=1 while len(v)==len(set(v)): v.append(a[v[-1]]) cnt+=1 if a[v[-1]]==2: print(cnt) exit() print(-1)
p02633
s534088348
Accepted
import sys from math import gcd read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines X = int(readline()) g = gcd(X, 360) print(360//g)
p03998
s222875648
Accepted
from collections import deque d = {key:deque(input()) for key in ['a','b','c']} turn = 'a' win = '' while 1: if d[turn]: turn = d[turn].popleft() else: win = turn break print(win.upper())
p02948
s848075421
Accepted
import sys from heapq import heapify, heappop, heappush import bisect N, M = map(int, input().split()) AB = sorted([list(map(int, sys.stdin.readline().split())) for _ in range(N)]) A = [x for x, y in AB] hq = [] heapify(hq) count = 0 for i in range(1, M + 1): c_1 = bisect.bisect_left(A, i) c_2 = bisect.bisect_right(A, i) if c_2 - c_1 != 0: for j in range(c_1, c_2): heappush(hq, -AB[j][1]) if hq: count += -heappop(hq) print(count)
p02882
s198601610
Accepted
import math a, b, x = map(float, input().split()) if a * a * b <= x * 2: h = 2 * (b - x / a / a) ret = math.degrees(math.atan2(h, a)) else: h = 2 * x / a / b ret = 90 - math.degrees(math.atan2(h, b)) print(ret)
p02691
s902304700
Accepted
N = int(input()) A = list(map(int, input().split())) A = [0] + A from collections import Counter L1 = [i+a for i, a in enumerate(A)][1:] L2 = [i-a for i, a in enumerate(A)][1:] C1 = Counter(L1) C2 = Counter(L2) C = Counter(L1+L2) ans = 0 for k in C.keys(): ans += C1[k]*C2[k] print(ans)
p03944
s673757909
Accepted
import numpy as np W,H,N=map(int,input().split()) A=np.zeros((W,H)) B=[list(map(int,input().split())) for _ in range(N)] for b in B: if b[2]==1: A[:b[0],:]=1 elif b[2]==2: A[b[0]:,:]=1 elif b[2]==3: A[:,:b[1]]=1 elif b[2]==4: A[:,b[1]:]=1 print(np.count_nonzero(A==0))
p03210
s287000968
Accepted
a = int(input()) if a == 7 or a == 5 or a == 3: print('YES') else: print('NO')
p04044
s897027311
Wrong Answer
n,l = map(int,input().split()) list = [] for i in range(n): word = input() list.append(word) list_connect = "".join(list) print(list_connect)
p02987
s386883275
Accepted
s = sorted(input()) if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]: print("Yes") else: print("No")
p03457
s805054985
Accepted
N = int(input()) t,x,y = 0,0,0 badtrip=False for i in range(N): ti, xi, yi = list(map(int, input().split())) absx = abs(x-xi) absy = abs(y-yi) if (absx+absy)%2 == (ti-t)%2 and (ti-t)>=(absx+absy): t=ti x=xi y=yi else: badtrip=True break if badtrip: print('No') else: print('Yes')
p02630
s317089188
Wrong Answer
from collections import defaultdict N = int(input()) raw_numbers = list(map(int, input().split())) numbers = defaultdict(int) for num in raw_numbers: numbers[num] += 1 total = sum(raw_numbers) Q = int(input()) for _ in range(Q): a, b = list(map(int, input().split())) taken = numbers[a] total -= a * numbers[a] numbers[b] += numbers[a] total += b * taken print(total)
p03077
s655243104
Accepted
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) n = inp() a = [inp() for _ in range(5)] print((n+min(a)-1)//min(a) + 4)
p02873
s639748934
Accepted
S = input() N = len(S)+1 a = [0] * N for i in range(N-1): if S[i] == '<': a[i+1] = a[i]+1 for i in range(N-2, -1, -1): if S[i] == '>': a[i] = max(a[i+1]+1,a[i]) print(sum(a))
p02624
s994954232
Accepted
N = int(input()) print(sum((i*(N//i)*(N//i+1)//2) for i in range(1,N+1)))
p03284
s010415791
Accepted
import bisect import cmath import heapq import itertools import math import operator import os import re import string import sys from collections import Counter, deque, defaultdict from copy import deepcopy from decimal import Decimal from fractions import gcd from functools import lru_cache, reduce from operator import itemgetter, mul, add, xor import numpy as np if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10 ** 9) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 # MOD = 998244353 n, k = list(map(int, sys.stdin.buffer.readline().split())) if n % k == 0: print(0) else: print(1)
p03759
s924556755
Wrong Answer
a, b, c = map(int, input().split()) if b-c == c-b: print('YES') print('NO')
p02641
s288572610
Wrong Answer
x,n = map(int,input().split()) if n == 0: print(x) exit() p = list(map(int,input().split())) x1,x2 = x,x for i in range(1000): x1 -= 1 x2 += 1 if x1 not in p: print(x1) exit() if x2 not in p: print(x2) exit()
p03665
s674593337
Accepted
def LI(): return list(map(int, input().split())) N, P = LI() A = LI() gu = 0 ki = 0 for i in range(N): if A[i] % 2 == 0: gu += 1 else: ki += 1 if ki == 0: if P == 0: ans = 2**N else: ans = 0 else: ans = 2**(N-1) print(ans)
p02693
s408544218
Accepted
import sys input=sys.stdin.readline K=int(input()) A,B=map(int,input().split()) for i in range(1001): s=i*K if A<=s and s<=B: print("OK") break if 1000<s: print("NG") break
p02917
s866782065
Wrong Answer
n = int(input()) b = list(map(int, input().split())) b.reverse() a = [0]*(n-1) a[0] = b[0] for i in range(1,n-1): if b[i] > b[i-1]: a[i] = b[i-1] else: a[i] = b[i] print (sum(a)+a[-1])
p02639
s079425623
Wrong Answer
x1, x2, x3, x4, x5 = map(int, input().split()) if x1 == 0: print(1) if x2 == 0: print(2) if x3 == 0: print(3) if x4 == 0: print(4) else: print(5)
p03698
s435689624
Accepted
stng = input() lets = {1} ans = "yes" for i in stng: if i in lets: ans = "no" else: lets.add(i) print(ans)
p02982
s377654111
Accepted
import sys input = sys.stdin.readline n, d = map(int, input().split()) x = [] cnt = 0 ans = 0 for i in range(n): x_memo = list(map(int, input().split())) x.append(x_memo) for i in range(n - 1): for j in range(i + 1, n): cnt = 0 for k in range(d): cnt += abs(x[i][k] - x[j][k]) ** 2 cnt = cnt ** 0.5 if cnt.is_integer(): ans += 1 print(ans)
p02910
s487697229
Accepted
import sys S = input() for i, s in enumerate(S): if i%2==0: if s not in ["R", "U", "D"]: print("No") sys.exit() else: if s not in ["L", "U", "D"]: print("No") sys.exit() print("Yes")
p02765
s475930685
Wrong Answer
a,b=map(int, input().split()) if a >= 10: print(b) else: print(b-100*(10 - a))
p03838
s937602633
Wrong Answer
x,y = map(int,input().split()) if 0 <= x < y or x < y <= 0: print(abs(y-x)) elif 0 <= y < x or y < x <= 0: print(abs(x-y) + 2) elif x < y: if y < abs(x): print(abs(x)-y + 1) else: print(y-abs(x) + 1) else: if x < abs(y): print(abs(y)-x + 1) else: print(x-abs(y) + 1)
p02676
s656365200
Wrong Answer
k = int(input()) s = input() if len(s)<=k: print(s) else: print(s[:k],'...')
p02660
s994067926
Accepted
import math N = int(input()) primes = {} i = 2 sqrt_N = math.floor(math.sqrt(N)) while i <= sqrt_N: if N % i == 0: if i in primes: primes[i] += 1 else: primes[i] = 1 N //= i sqrt_N = math.floor(math.sqrt(N)) else: i += 1 if N != 1: if N in primes: primes[N] += 1 else: primes[N] = 1 count = 0 for c in primes.values(): i = 1 while i <= c: count += 1 c -= i i += 1 print(count)
p03555
s058917005
Accepted
c = input() s = input() cl = list(c) sl = list(s) cr = list(reversed(cl)) if sl == cr: print("YES") else: print("NO")
p03162
s085610151
Wrong Answer
N = int(input()) a = [list(map(int, input().split())) for i in range(N)] dp = [[0 for i in range(3)] for j in range(N)] dp[0] = a[0] for i in range(N - 1): for j in range(3): for k in range(3): if j == k: continue dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i + 1][k]) print(max(dp[N - 1]))
p03720
s819642414
Accepted
N,M=map(int,input().split()) R=[0]*50 for i in range(M): a,b=map(int,input().split()) R[a-1]+=1 R[b-1]+=1 for i in range(N): print(R[i])
p02848
s692803804
Accepted
N = int(input()) S = list(input()) for i in range(len(S)): S[i] = chr(65+(ord(S[i])-65+N)%26) print("".join(map(str,S)))
p03250
s030344109
Wrong Answer
A, B, C = map(int, input().split()) D = int(str(A) + str(B)) + C E = A + int(str(B) + str(C)) print(max(D, E))
p02600
s277016739
Wrong Answer
x = int(input()) if x<=400 and 599<=x: print(8) if x<=600 and 799<=x: print(7) if x<=800 and 999<=x: print(6) if x<=1000 and 1199<=x: print(5) if x<=1200 and 1399<=x: print(4) if x<=1400 and 1599<=x: print(3) if x<=1500 and 1799<=x: print(2) if x<=1600 and 1999<=x: print(1) exit()
p02684
s639089672
Wrong Answer
n,k = map(int,input().split()) listA = list(map(int,input().split())) kouho = [1] ikisaki = listA[0] while ikisaki not in kouho: kouho.append(ikisaki) ikisaki = listA[ikisaki-1] index = kouho.index(ikisaki) loop = len(kouho) - index amari = (k-index)%loop print(kouho[index + amari])
p03767
s065343200
Accepted
n = int(input()) l = list(map(int, input().split())) l.sort() print(sum(l[n::2]))