problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02831
s921772525
Accepted
import fractions def lcm(x, y): return (x * y) // fractions.gcd(x, y) A,B=map(int,input().split()) print(lcm(A,B))
p02606
s982683883
Accepted
l,r,d = map(int,input().split()) ans = 0 for i in range(l,r+1): if i % d == 0: ans += 1 print(ans)
p02743
s198436192
Accepted
s = input() lis = s.split() a = int(lis[0]) b = int(lis[1]) c = int(lis[2]) if c - a - b < 0: print("No") else: ee = (c - a - b) * (c - a - b) dd = 4 * a * b - ee if dd < 0: print("Yes") else: print("No")
p03449
s367389051
Accepted
n=int(input()) a=[[int(i) for i in input().split()] for j in range(2)] sentou=[] usiro=[] for i in range(n): if i==0: sentou.append(a[0][0]) usiro.append(a[1][-1]) else: sentou.append(a[0][i]+sentou[-1]) usiro.append(a[1][-i-1]+usiro[-1]) usiro=usiro[::-1] ans=[] for i in range(n): ans.append(sentou[i]+usiro[i]) print(max(ans))
p03035
s889530372
Accepted
def main(): a, b = map(int, input().split()) if a < 6: print(0) elif a < 13: print(int(b/2)) else: print(b) if __name__ == "__main__": main()
p03803
s128998130
Wrong Answer
A, B = map(int, input().strip().split()) if A == B: print("Draw") elif A == 1: print("Alice") elif B == 1: print("Bod") elif A > B: print("Alice") else: print("Bob")
p03438
s498220109
Accepted
N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) a_sum, b_sum = sum(A), sum(B) turns = b_sum - a_sum a_small = 0 b_small = 0 for a, b in zip(A,B): if a < b: a_small += (b - a + 1) // 2 else: b_small += a - b if a_small <= turns and b_small <= turns: print('Yes') else: print('No')
p04030
s749165679
Accepted
s = input() ans = "" for i in range(len(s)): if s[i] == "0": ans += "0" elif s[i] == "1": ans += "1" else: ans = ans[:-1] print(ans)
p02847
s206164347
Accepted
D = ["SUN","MON","TUE","WED","THU","FRI","SAT"] print(7-D.index(input()))
p03565
s383301661
Accepted
s = input() t = input() n = len(s) m = len(t) for i in range(n-m, -1, -1): x = s[i:i+m] for j in range(m+1): if j == m: print((s[:i]+t+s[i+m:]).replace("?","a")) exit() if x[j] == "?": continue elif x[j] != t[j]: break print("UNRESTORABLE")
p03001
s475169689
Accepted
W, H, x, y = map(int, input().split()) ans = 0 if ((W/2)==x) & ((H/2)==y): ans = 1 print(W*H/2, ans)
p02555
s039277419
Accepted
a,b,c=1,0,0 exec('a,b,c=b,c,(a+c)%(10**9+7);'*(int(input())-2)) print(c)
p02820
s029306394
Accepted
n, k = map(int, input().split()) r, s, p = map(int, input().split()) t = input() flag = [False for i in range(n)] score = {"r":p, "s":r, "p":s} ans = 0 for i in range(n): if i >= k: if t[i] == t[i-k]: if flag[i-k] == True: ans += score[t[i]] else: flag[i] = True else: ans += score[t[i]] else: ans += score[t[i]] print(ans)
p02684
s373984561
Accepted
n,k=map(int,input().split()) A=list(map(int,input().split())) cnt=0 s=1 M=[0] B=[0]*(n+1) while cnt<n: s=A[s-1] if B[s-1]==0: B[s-1]+=1 else: imp=s-1 break M.append(s-1) cnt+=1 x=M.index(imp) y=len(M)-x if k<=x: print(M[k]+1) else: N=M[x:] print(N[(k-x)%y]+1)
p02629
s705066145
Accepted
digits = "abcdefghijklmnopqrstuvwxyz" n = int(input()) ans = [] while n: n -= 1 m = n%26 n = n//26 ans.append(digits[m]) print("".join(ans)[::-1])
p02726
s483271957
Wrong Answer
N,X,Y = list(map(int,input().split())) from collections import defaultdict graph = defaultdict(set) for i in range(N-1): graph[i] |= {i+1} graph[i+1] |= {i} graph[X-1] |= {Y-1} graph[Y-1] |= {X-1} MAP = [[ N for j in range(N)] for i in range(N)] for i in range(N): MAP[i][i] = 0 for fr in range(N): for to in range(N): MAP[fr][to] = min( [MAP[fr][i]+1 for i in graph[to]] ) res = [] for i in MAP: for j in i: res.append(j) from collections import Counter c = Counter(res) for i in range(2,N+1): print(c[i])
p03329
s949218929
Wrong Answer
N = int(input()) def to_n(X, n): if (int(X / n)): return to_n(int(X / n), n) + str(X % n) return str(X % n) ans = 10 ** 9 + 7 for i in range(N): N6 = to_n(N - i, 6) N9 = to_n(i, 9) res = 0 for j in N6: res += int(j) for j in N9: res += int(j) ans = min(res, ans) print(ans)
p03835
s918790262
Accepted
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions 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,s = inpl() res = 0 for i in range(n+1): for j in range(n+1): if 0 <= s - (i+j) <= n: res += 1 print(res)
p03495
s015597334
Accepted
import collections n,k = map(int,input().split()) a = list(map(int,input().split())) c = collections.Counter(a) values, counts = zip(*c.most_common()) print(sum(counts[k:]))
p02897
s996280915
Accepted
def ii():return int(input()) def iim():return map(int,input().split()) def iil():return list(map(int,input().split())) n=ii() if n%2 == 0: print(1/2) else: print((n+1)//2/n)
p02899
s185695641
Accepted
N = int(input()) l = [(i,j) for i,j in enumerate(map(int, input().split()), start=1)] print(*[i for i, j in sorted(l, key=lambda x:x[1])])
p02743
s173914691
Accepted
a, b, c = map(int, input().split()) if c - a - b > 0 and 4 * a * b < (c - a - b) ** 2: print("Yes") else: print("No")
p03449
s006917843
Accepted
# coding: utf-8 N = int(input()) A = [] for _ in range(2): A.append(list(map(int, input().split(" ")))) def oritara(A, orirutoko): tmp = sum(A[0][:orirutoko+1]) tmp += sum(A[1][orirutoko:]) return tmp ame = 0 for i in range(N): ame = max(oritara(A, i), ame) print(ame)
p02973
s894560249
Wrong Answer
import bisect n = int(input()) A = [] count = 0 for _ in range(n): a = int(input()) if len(A) == 0: A.append(a) count += 1 continue i = bisect.bisect_right(A, a) if i == 0: A.insert(0, a) count += 1 else: bisect.insort_right(A, a) if A[i-1] != A[i]: del A[i-1] else: count += 1 ans = count print(ans)
p03556
s888077088
Accepted
import math N = int(input()) print(math.floor(N**0.5)**2)
p03695
s629821481
Accepted
import sys from collections import deque from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値) from heapq import heapify, heappop, heappush sys.setrecursionlimit(10**6) INF = 10**20 def mint(): return map(int,input().split()) def lint(): return map(int,input().split()) def judge(x, l=['Yes', 'No']): print(l[0] if x else l[1]) N = int(input()) A = lint() S = set() pro = 0 for a in A: if a//400<8: S.add(a//400) else: pro += 1 print(max(1,len(S)),len(S)+pro)
p02699
s332046905
Accepted
s, w = map(int, input().split()) if w >= s: print("unsafe") else: print("safe")
p02912
s881595151
Accepted
import sys input = sys.stdin.readline import heapq n,m = map(int,input().split()) l = list(map(int,input().split())) s = sum(l) for i in range(n): l[i] *= (-1) heapq.heapify(l) discount = 0 for i in range(m): x = (-heapq.heappop(l)) heapq.heappush(l,-(x//2)) discount += (x-x//2) print(s-discount)
p02583
s574280192
Accepted
from itertools import combinations n = int(input()) l = sorted(map(int, input().split())) c = 0 for i, j, k in combinations(range(n), 3): li, lj, lk = l[i], l[j], l[k] if li == lj or lj == lk or lk == li: continue if li + lj > lk: c += 1 print(c)
p02910
s242758725
Wrong Answer
s=input() ans='No' for i,ss in enumerate(s): if i%2==0: if ss =='R' or ss=='U' or ss=='D': ans ='Yes' else: ans='No' else: if ss=='L' or ss=='U' or ss=='D': ans='Yes' else: ans='No' print(ans)
p02642
s350084980
Accepted
N = int(input()) A = list(map(int,input().split())) T = set() def counter(array): from collections import Counter return Counter(array) c = counter(A) for x in A: T.add(x) cnt = 0 maxi = max(A) for x in sorted(A): i = 2 while x * i <= maxi: if x * i in T: T.remove(x*i) i += 1 ans = 0 for x in T: if c[x] == 1: ans += 1 print(ans)
p02663
s411034066
Wrong Answer
s=list(input()) for i in range(s.count("?")): s[s.index("?")]="D" print("".join(s))
p03086
s082571807
Accepted
s = input() acgt = ["A","C","G","T"] c = "" for i in s: if i in acgt: c+=i else: c+= " " l = c.split() if l: print(len(max(l, key=lambda x:len(x)))) else: print(0)
p02972
s706819562
Accepted
N=int(input()) a=list(map(int,input().split())) b=[0]*(N+1)#箱 ans=[] for i in range(N,0,-1): bit=0 for j in range(N//i): bit+=b[i+j*i] bit%=2 if bit!=a[i-1]: b[i]=1 ans.append(i) print(sum(b)) print(' '.join(map(str, ans)))
p02765
s129053948
Accepted
N, R = map(int, input().split()) if N >= 10: print(R) else: print(R+100*(10-N))
p04043
s926025226
Accepted
S=input();print('YES' if S.count('7')==1 and S.count('5')==2 else 'NO')
p02646
s639877428
Accepted
a,v=map(int,input().split()) b,w=map(int,input().split()) t=int(input()) if abs(a-b)<=(v-w)*t: print("YES") else: print("NO")
p02802
s613025807
Accepted
N,M=map(int,input().split()) ac=0 wa=0 a=[0]*N w=[0]*N for i in range(M): P,S=input().split() P=int(P) if S=="WA": w[P-1]+=1 else: if a[P-1]==0: a[P-1]+=1 ac=ac+1 wa+=w[P-1] else: pass print(ac,wa)
p02790
s980310873
Accepted
N = list(map(int, input().split())) N.sort() print(str(N[0])*N[1])
p03427
s993519193
Wrong Answer
n = input() if len(n) == 1: print(n) exit() if n[0] == '1': ans = 0 judge = set(n[1:]) if len(judge) == 1 and '9' in judge: for i in n: ans += int(i) print(ans) else: ans = 9 * (len(n) - 1) print(ans) else: ans = int(n[0]) - 1 for i in range(1,len(n)): ans += 9 print(ans)
p03435
s331477244
Accepted
c = [[int(j) for j in input().split()] for i in range(3)] flag = True diffb21 = c[0][1] - c[0][0] diffb32 = c[0][2] - c[0][1] for i in range(1, 3): if c[i][1] - c[i][0] != diffb21 or c[i][2] - c[i][1] != diffb32: flag = False tc = list(zip(*c)) diffa21 = tc[0][1] - tc[0][0] diffa32 = tc[0][2] - tc[0][1] for i in range(1, 3): if tc[i][1] - tc[i][0] != diffa21 or tc[i][2] - tc[i][1] != diffa32: flag = False print('Yes' if flag else 'No')
p03345
s537027356
Wrong Answer
a, b, c, k = map(int, input().split()) if abs(b - a) > 10**18: print('Unfair') elif k == 0: print(a - b) else: print(b - a)
p02882
s286065609
Accepted
import math a,b,x = list(map(int,input().split())) bottle = a**2*b ##水の入っていない量について(水が半分以上入っている) if x>bottle/2: p_bottle = bottle-x tanx = p_bottle/(a**3)*2 ans = math.degrees(math.atan(tanx)) else: #a*(b**2*tan(90-x))=x tan90x=x/(a*b**2)*2 ans = 90-math.degrees(math.atan(tan90x)) print("{:.10f}".format(ans))
p03998
s571587271
Accepted
S = { 'a': list(input()[::-1]), 'b': list(input()[::-1]), 'c': list(input()[::-1]), } s = 'a' while True: if not S[s]: print(s.upper()) exit() s = S[s].pop()
p03778
s721192880
Accepted
w,a,b = map(int,input().split()) aw = a+w bw =b+w print(max(0,a-bw,b-aw))
p03043
s578213185
Accepted
# -*- coding: utf-8 -*- N, K = map(int, input().split(' ')) import math ret = 0 log_k = math.log(K) for n in range(1, N+1): prob = 1 while n < K: prob *= 0.5 n *= 2 ret += prob print(ret / N)
p03852
s957442316
Accepted
c = input() if c == "a" or c == "e" or c == "i" or c == "o" or c == "u": print("vowel") else: print("consonant")
p03723
s970164736
Wrong Answer
a,b,c = map(int,input().split()) count = 0 if a == b == c : print(-1) else: while a%2 == 1 or b%2 == 1 or c%2 == 1: a1 = a b1 = b c1 = c a = a1//2 + b1//2 + c1//2 b = a1//2 + b1//2 + c1//2 c = a1//2 + b1//2 + c1//2 count += 1 print(count)
p02707
s867176856
Wrong Answer
from collections import Counter N = int(input()) A = list(map(int, input().split())) l = Counter(A) for i in range(N): if i in l: print(l[i]) else: print(0)
p02900
s579662535
Accepted
import math def prime_factorize(n): a = [] while n % 2 == 0: a.append(2) n //= 2 f = 3 while f * f <= n: if n % f == 0: a.append(f) n //= f else: f += 2 if n != 1: a.append(n) return a a, b = map(int, input().split()) c = math.gcd(a, b) print(len(set(prime_factorize(c)))+1)
p03633
s139913636
Accepted
import sys import math if __name__ == "__main__": n = int(input()) lst = [] for _ in range(n): lst.append(int(input())) q = lst[0] for x in range(1, n): q = (q*lst[x])//math.gcd(lst[x], q) print(q)
p03338
s980747525
Accepted
N = int(input()) S = list(input()) D = [0]*(N-1) for i in range(1, N): A = S[:i] B = S[i:] A1 = set(A) B1 = set(B) C = A1 & B1 D[i-1] = len(C) print(max(D))
p02819
s481981826
Accepted
s = int(input()) if s <= 2: print(2) exit() elif s <= 3: print(3) exit() elif s <= 5: print(5) exit() while True: for i in range(2,s // 2): if s % i == 0: break if i == s //2 -1: print(s) exit() s += 1
p02783
s959289983
Wrong Answer
h, a = list(map(int, input().split(' '))) ans = 0 while h > 0: h -= a ans =+ 1 print(ans)
p03623
s247902499
Wrong Answer
S = input() X = [chr(i) for i in range(ord('a'), ord('z')+1)] ans = '' for x in X: if x not in S: ans = x break if ans: print(ans) else: print('None')
p03817
s257347842
Accepted
import sys read_=sys.stdin.buffer.readline x=int(read_()) ans=x//11*2 a=x%11 if 0<a<=6: print(ans+1) elif a==0 and ans>0: print(ans) else: print(ans+2)
p03150
s208025714
Accepted
S = input() remove = len(S) - 7 print('YES' if any(S[:i] + S[i+remove:] == 'keyence' for i in range(8)) else 'NO')
p03206
s498241672
Wrong Answer
d = int(input()) if d == 25: print("Christmas") elif d == 24: print("Christmas Eve,") elif d == 23: print("Christmas Eve Eve") elif d == 22: print("Christmas Eve Eve Eve")
p02753
s260210560
Wrong Answer
s = input() if s == 'AAA' or 'BBB': print('Yes') else: print('No')
p03254
s569925016
Accepted
N,x=map(int,input().split()) a=list(map(int,input().split())) ans=0 if sum(a)==x: print(N) else: a.sort() s=0 i=0 while True: s+=a[i] if i==N-1 and s!=x: print(N-1) break if s>x: print(i) break i+=1 if i>=N: print(N) break
p02645
s314901439
Accepted
s = input() print(s[:3])
p02571
s610740067
Wrong Answer
S = input() T = input() ans1 = len(T) ans2 = len(T) for i in range(len(T)): if T[0:i+1] in S: ans1 = len(T) - i - 1 if T[::-1][0:i+1][::-1] in S: ans2 = len(T) - i - 1 print(min(ans1, ans2))
p03861
s808823699
Wrong Answer
import math a, b, x = map(int, input().split()) xa = math.ceil(a / x) xb = b // x print(xb - xa + 1)
p02624
s178152550
Accepted
n = int(input()) ans = 0 for i in range(1,n+1): k = n//i ans += k*(k+1)//2 * i print(ans)
p02847
s950291547
Wrong Answer
import sys base = ['SUN','MON','TUE','WED','THU','FRI','SAT'] S = input() if not ( S in base ): sys.exit() print(7 - base.index(S)) if S != 'SUN' else print(0)
p03556
s216648812
Wrong Answer
N = int(input()) pre = 0 for i in range(1, N+1): n = i**2 if n > N: print(pre) quit() pre = n
p03208
s908902915
Wrong Answer
n,k= map(int, input().split()) #print(n,k) Ar = [0]*100001 for i in range(n): # print("i=",i) dat = int(input()) Ar[i] = dat # print(Ar) ans = 1000000001 for i in range(n-k+1): h = Ar[i] l = Ar[i] # print("Start = ",i) for j in range(i,i+k+1): # print("check st",j) if h < Ar[j]: h = Ar[j] if l > Ar[j]: l = Ar[j] if ans > h-l: ans = h-l # print("diff=",ans,h,l) print (ans)
p03042
s090684231
Wrong Answer
s = input() former = int(s[:2]) later = int(s[2:]) if former==0 or later==0 or (former>31 and later>31): print("NA") elif former<13 and later<13: print("AMBIGUOUS") elif former<13 and later<32: print("MMYY") elif former<32 and later<13: print("YYMM") else: print("NA")
p02882
s539008220
Wrong Answer
import math a, b, x = map(int, input().split()) if 2 * x >= a * a * b: bb = x / (a * a) c = 2 * (b - bb) print(math.degrees(math.atan(c / a))) else: aa = x / (b * b) print(math.degrees(math.atan(b / aa)))
p02661
s064554234
Accepted
N = int(input()) aa = [] bb = [] for i in range(N): a,b = [int(x) for x in input().split()] aa.append(a) bb.append(b) aa.sort() bb.sort() if N % 2 != 0: print(bb[N//2]-aa[N//2]+1) else: print(bb[N//2]+bb[N//2-1]-aa[N//2]-aa[N//2-1]+1)
p02677
s298910551
Accepted
import math a, b, h, m = list(map(int, input().split())) theta = abs(30 * h + (30 / 60 * m) - 6 * m) theta = math.radians(min(360 - theta, theta)) print((b ** 2 + a ** 2 - 2 * b * a * math.cos(theta)) ** 0.5)
p03657
s239470385
Accepted
A,B= input().split() A = int(A) B = int (B) if A%3 ==0 or B%3 ==0 or (A+B)%3 ==0: print ("Possible") else: print ("Impossible")
p02681
s885503973
Wrong Answer
s = str(input()) t = str(input()) if 1 <= len(s) <= 10 and len(t)==len(s) + 1 and s in t : print("Yes") else: print("No")
p03679
s506058168
Accepted
X, A, B = map(int, input().split()) if A >= B: print('delicious') elif B <= X + A: print('safe') else: print('dangerous')
p03250
s119238300
Accepted
lst = list(map(int, input().split())) lst.sort() lst.reverse() maximum = int(str(lst[0]) + str(lst[1])) + lst[2] print(maximum)
p02595
s335814788
Accepted
import math N,D=map(int,input().split()) count=0 def dist(x,y): return math.sqrt(x**2+y**2) for i in range(N): x,y=map(int,input().split()) if dist(x,y)<=D: count+=1 print(count)
p02606
s644137703
Accepted
def NumberOfMultiples(): num = list(map(int,input().split())) count = 0 for i in range(num[0], num[1]+1): mod = i % num[2] if mod == 0: count = count + 1 print(count) if __name__ == '__main__': NumberOfMultiples()
p03623
s900506759
Accepted
x,a,b=map(int,input().split()) if abs(x-a)<abs(x-b): print('A') else: print('B')
p03815
s950013814
Accepted
import sys def I(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def main(): x = I() ans = (x//11)*2 t = x%11 if t == 0: pass elif t >= 1 and t <= 6: ans += 1 else: ans += 2 print(ans) if __name__ == '__main__': main()
p02880
s658143743
Wrong Answer
N=int(input()) for i in range(1,10): a=N//i if a*i==N: print('Yes') else: pass print('No')
p03645
s688415976
Accepted
N,M = map(int,input().split()) s = [] g = [] for i in range(M): a,b = map(int,input().split()) if a == 1: s.append(b) elif b == N: g.append(a) ans = set(s) & set(g) if len(ans) >= 1: print('POSSIBLE') else: print('IMPOSSIBLE')
p03328
s234321461
Accepted
a,b=map(int,input().split()) i=b-a print(i*(i+1)//2-b)
p04005
s413533825
Wrong Answer
a,b,c=map(int,input().split()) if c%2==0: print ("0") else: print (a*b)
p03293
s643296931
Wrong Answer
s = input() t = input() a = sorted(s) b = sorted(t) if a==b: print("Yes") else: print("No")
p02630
s479749347
Accepted
from collections import Counter N = int(input()) A = list(map(int,input().split())) Q = int(input()) counter = Counter(A) sum_res = sum(A) #print(sum_res,counter) for _ in range(Q): bf,af = map(int,input().split()) sum_res -= bf*counter[bf] sum_res += af*counter[bf] counter[af] += counter[bf] counter[bf] = 0 print(sum_res)
p03545
s308397046
Wrong Answer
import sys import itertools ABCDlist=list(map(int,list(input()))) #print(ABCDlist) for bit in itertools.product(range(2),repeat=3): answer=ABCDlist[0] answer_list=[str(answer)] for i in range(3): if bit[i]==0: answer+=ABCDlist[i+1] answer_list.append("+"+str(ABCDlist[i+1])) else: answer-=ABCDlist[i-1] answer_list.append("-"+str(ABCDlist[i+1])) if answer==7: answer_list.append("=7") print("".join(answer_list)) sys.exit(0)
p02546
s706402598
Accepted
s = input() if s[-1]!="s": print(s+"s") else: print(s+"es")
p02996
s057661860
Wrong Answer
n = int(input()) AB =[] total = 0 ans = "Yes" for i in range(n): ab = list(map(int,input().split())) AB.append(ab) AB_sorted_second = AB.sort(key=lambda x: x[1]) for i in range(n): if total < AB[i][1]: total += AB[i][0] else: ans = "No" break if total > AB[n-1][1]: ans = "No" print(ans)
p03998
s172885100
Accepted
Sa=input()+'A' Sb=input()+'B' Sc=input()+'C' a=0 b=0 c=0 def f(tmp): if tmp=='a': global a out=Sa[a] a+=1 elif tmp=='b': global b out=Sb[b] b+=1 else: global c out=Sc[c] c+=1 return out tmp='a' while tmp.isupper()==False: tmp=f(tmp) print(tmp)
p02606
s262772870
Accepted
l, r, d = map(int,input().split()) counter = 0 for i in range(l+1, r+1): if i % d == 0: counter += 1 if d == 1: print(counter + 1) elif l == r: if l % d == 0: print(1) else: print(0) else: print(counter)
p03250
s550154354
Accepted
A, B, C = map(int, input().split()) ABC = sorted([A, B, C], reverse=True) print(int(str(ABC[0]) + str(ABC[1])) + ABC[2])
p02963
s996589943
Accepted
S = int(input()) m = S // (10**9) n = S % (10**9) p,q = 0,0 r,s = 0,0 if(m == 10**9): p,q = 10**9,1 r,s = 0,10**9 else: p,q = m+1,10**9-n r,s = 1,10**9 print(0,0,p,q,r,s)
p03557
s027369403
Accepted
from sys import stdin import bisect N = int(stdin.readline().rstrip()) A = [int(x) for x in stdin.readline().rstrip().split()] B = [int(x) for x in stdin.readline().rstrip().split()] C = [int(x) for x in stdin.readline().rstrip().split()] A.sort() B.sort() C.sort() ans = 0 for b in B: a = bisect.bisect_left(A,b) c = N - bisect.bisect_right(C,b) ans += (a*c) print(ans)
p02646
s922090384
Wrong Answer
A,V = map(int,input().split()) B,W = map(int,input().split()) T = int(input()) for i in range(1,T): if A + V * i == B + W * i: print("YES") exit() print("NO")
p02848
s649557630
Accepted
n=int(input()) s=input() y=[ord(i)+n for i in s] for i in y: if i>=91: i%=91 print(chr(i+65),end="") else: print(chr(i),end="")
p03617
s297691651
Wrong Answer
q , h , s , d = map(int,input().split()) n = int(input()) qb = q*4 hb = h*2 db = d//2 if min(qb,hb,db,s) != db: print(n*min(qb,hb,db,s)) elif min(qb,hb,db,s) == db: if n % 2 == 0: print(n*db) elif n % 2 == 1: ans = n//2 * d ans += min(qb,hb,s) print(ans)
p02597
s309667261
Accepted
n=int(input()) c=input() c=list(c) a=sorted(c) countw=0 countr=0 for i in range(n): if c[i]=='R' and a[i]=='W': countw+=1 elif c[i]=='W' and a[i]=='R': countr+=1 ansmin=min(countw,countr) ansmax=max(countw,countr) print(ansmin+abs(ansmin-ansmax))
p03759
s287028344
Accepted
a, b, c = (int(x) for x in input().split()) if b - a == c - b: print('YES') else: print('NO')
p03986
s115703427
Accepted
xl = list(input()) ans = 0 stock = 0 for x in xl: if x == "S": stock += 1 else: if stock: stock -= 1 ans += 1 print(len(xl)-2*ans)
p03386
s689836064
Accepted
A, B, K = map(int, input().split()) if B - A + 1 <= 2*K: for i in range(A, B+1): print(i) else: for i in range(A,A+K): print(i) for i in range(B-K+1,B+1): print(i)