problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02629
s455663907
Accepted
n = int(input()) s = 'abcdefghijklmnopqrstuvwxyz' ans = '' while n > 0: n, i = divmod(n - 1, 26) ans = s[i] + ans print(ans)
p02760
s267840892
Accepted
A1=list(map(int,input().split())) A2=list(map(int,input().split())) A3=list(map(int,input().split())) A=A1+A2+A3 N=int(input()) ans=[0]*9 a='No' for i in range(N): b=int(input()) if b in A: ans[A.index(b)]=1 cheack=[ans[0:3],ans[3:6],ans[6:9],ans[0::3],ans[1::3],ans[2::3],ans[0::4],ans[2:7:2]] for C in cheack: if sum(C)==3: a='Yes' break print(a)
p03419
s466793748
Accepted
n, m = map(int, input().split()) if n == 1 and m == 1: print(1) elif n == 1: print(m - 2) elif m == 1: print(n - 2) else: print((n - 2) * (m - 2))
p02717
s294526496
Accepted
l = list(map(int, input().split())) l[0],l[1]=l[1],l[0] l[0],l[2]=l[2],l[0] print(*l)
p03328
s697345476
Accepted
a,b = map(int,input().split()) n = b-a tower = ((n+1)*n)/2 print(int(tower-b))
p03723
s194881812
Wrong Answer
a,b,c=map(int,input().split()) if a==b and b==c: print(-1) else: ans=0 while a%2==0 and b%2==0 and c%2==0: a0,b0,c0=(b+c)//2,(c+a)//2,(a+b)//2 a,b,c=a0,b0,c0 ans+=1 print(ans)
p02695
s840368847
Accepted
import itertools N, M, Q = map(int, input().split()) ABCD = [[int(x) for x in input().split()] for i in range(Q)] ans=0 for A in itertools.combinations_with_replacement([m for m in range(1,M+1)], N): ans2=0 for (a,b,c,d) in ABCD: if A[b-1]-A[a-1]==c: ans2+=d ans=max(ans, ans2) print(ans)
p03293
s679420895
Wrong Answer
a=input() b=input() a=sorted(a) b=sorted(b) if a==b: print("Yes") else: print("No")
p03262
s315179216
Accepted
import fractions n, X = map(int, input().split()) x = list(map(int, input().split())) d = abs(X - x[0]) for i in range(1, n): d = fractions.gcd(d, abs(X - x[i])) print(d)
p02753
s017150864
Wrong Answer
user = str(input().upper()) for i in user: if user.count(i) == 2: print("Yes")
p02621
s477989720
Accepted
#! /usr/bin/env python3 a=int(input()) reslt= a + a**2+a**3 print(reslt)
p04033
s148758489
Wrong Answer
a,b = map(int,input().split()) if a * b <= 0: print("Zero") elif a <= 0 and (b - a) % 2 == 0: print("Negetive") else: print("Positive")
p02628
s530213160
Wrong Answer
N,K=(int(x) for x in input().split()) p=list(map(int, input().split())) ld = sorted(p, reverse=True) l=(ld[:K]) print(sum(l))
p02707
s631694953
Accepted
R = int(input()) A = list(map(int,input().split())) S = [ 0 for i in range(R) ] for i in A : idx = i - 1 S[idx] += 1 for i in S : print(i)
p03759
s955258014
Wrong Answer
a, b, c = map(int, input().split()) if a==b and b==c: print('YES') else: print('NO')
p03282
s580936487
Accepted
s = input() k = int(input()) for i in range(k): if s[i] != "1": print(s[i]) break else: print(1)
p02888
s794131391
Accepted
from bisect import bisect_left N = int(input()) X = list(map(int, input().split())) X.sort() ans = 0 for i in range(N): for j in range(i + 1, N): k = bisect_left(X, X[i] + X[j]) ans += k - j - 1 print(ans)
p02838
s297080404
Accepted
import sys stdin = sys.stdin def main(): N = int(stdin.readline().rstrip()) A = list(map(int,stdin.readline().split())) mod = 10**9+7 ans = 0 for i in range(61): bits = 0 for x in A: if (x>>i)&1: bits += 1 ans += ((bits*(N-bits))* 2**i) %mod ans %= mod print(ans) main()
p04020
s076487439
Accepted
n=int(input()) a=[int(input())for i in range(n)] c=0 l=[] l2=[] for i in a: if i!=0: l.append(i) else: l2.append(sum(l)//2) l=[] l2.append(sum(l)//2) print(sum(l2))
p02743
s224028168
Wrong Answer
a,b,c = map(int,input().split()) if (c-a-b)**2 > 4*a*b: print('Yes') else: print('No')
p02727
s586894247
Wrong Answer
X,Y, A,B, C = list(map(int , input().split())) P = list(map(int , input().split())) Q = list(map(int , input().split())) R = list(map(int , input().split())) R.sort(reverse=True) P.sort(reverse=True) Q.sort(reverse=True) Z = P[:X]+Q[:Y] for i in range(len(Z)): if Z[i]<R[0]: Z.insert(i,R[0]) Z.pop(-1) R.pop(0) if len(R)==0: break w = sum(Z) print(w)
p03220
s097284113
Accepted
def main(): n = int(input()) t, a = map(int, input().split()) h = list(map(int, input().split())) # s = input() mini = 10**10 ans = 0 for i, x in enumerate(h): c = t - x * 0.006 if abs(a - c) < mini: mini = abs(a - c) ans = i+1 print(ans) if __name__ == '__main__': main()
p03250
s270075467
Accepted
l=list(map(int,input().split())) l.sort() print(int(str(l[2])+str(l[1]))+l[0])
p03680
s956080289
Wrong Answer
n = int(input()) a = [] for i in range(n): a.append(int(input())) check = [1]*n p = 1 ans = 1 total = 1 for i in range(n): total += 1 check[p-1] = 0 p = a[p-1] if a[p-1] == 2: ans = 0 break if ans == 0: print(total) else: print("-1")
p02687
s540798463
Accepted
S = input() if S == 'ABC': print('ARC') else: print('ABC')
p02555
s339099457
Wrong Answer
N = int(input()) ans = 0 div = 1000000007 pairs = N // 3 + 1 if N > 2: ans += 1 def paircheck(n, b): a, mod = divmod(n, b) # if a == 2 and mod > 0: # return b if a > 2 and mod > 0: return (a-2) * b elif a > 2 and mod == 0: return (a-3) * b + 1 return 0 for i in range(1, pairs): ans += paircheck(N, i+1) print(ans)
p03627
s040076411
Accepted
from collections import Counter n = int(input()) l = list(map(int,input().split())) a = Counter(l) b = a.most_common() c = [] for i,j in b: if j>=4: c.append(i) c.append(i) elif j>=2:c.append(i) c.sort() print(c[-1]*c[-2] if len(c)>=2 else 0)
p02547
s649197230
Accepted
N = int(input()) ans = 'No' ls = [] for i in range(N): d1,d2 = map(int,input().split()) ls.append([d1,d2]) ii = 0 for i in range(N): if ls[i][0] == ls[i][1]: ii += 1 else: ii = 0 if ii == 3: ans = 'Yes' break print(ans)
p03695
s564077470
Wrong Answer
n = int(input()) A = list(map(int,input().split())) c = [0]*10 add = 0 for i in range(n) : if A[i]>=3200 : add += 1 continue a = A[i]//400 c[a] = 1 print(sum(c),min(sum(c)+add,8))
p02988
s906777254
Accepted
n = int(input()) # = map(int, input().split()) p = list(map(int, input().split())) # = [int(input()) for _ in range()] cnt = 0 for i in range(1, n - 1): if p[i - 1] < p[i] < p[i + 1] or p[i - 1] > p[i] > p[i + 1]: cnt += 1 print(cnt)
p03632
s209698494
Wrong Answer
a, b, c, d = map(int, input().split()) if b <= c or d <= a: print("0") elif c <= a and b <= d: print(b-a) elif a <= c and d <= b: print(d-c) else: print(abs(c-b))
p02771
s651184218
Accepted
A,B,C=input().split() if A==B and A==C: print("No") elif A!=B and A!=C and B!=C: print("No") else: print("Yes")
p02688
s623296292
Wrong Answer
import collections N,K=map(int,input().split()) a=[] while K>0: K=K-1 d=int(input()) a.append(map(str,input().split())) e=collections.Counter(a) p=N-len(e) print(p)
p03001
s133337963
Wrong Answer
w,h,x,y=list(map(int,input().split())) ans=0 if max(w-x,x)>max(h-y,y):s=max(w-x,x)*h elif max(w-x,x)<max(h-y,y):s=w*max(h-y,y) else: s=max(w-x,x)*h ans=1 print(s,ans)
p02854
s781836169
Accepted
import sys from itertools import accumulate def I(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LMI(): return list(map(int, sys.stdin.readline().split())) MOD = 10 ** 9 + 7 INF = float('inf') N = I() A = LMI() ans = INF accum = list(accumulate(A)) for s in accum: t = accum[-1] - s ans = min(ans, abs(s - t)) print(ans)
p02760
s022698921
Accepted
def ii():return int(input()) def mi():return map(int,input().split()) a=[] for _ in range(3): a+=list(mi()) n=ii() b=[] for i in range(n): b+=ii(), def ana(x): if x in b: return 1 else: return 0 c=[ana(aa) for aa in a] oks="012 345 678 036 147 258 048 246".split() for ok in oks: res=1 for j in list(ok): res*=c[int(j)] if res==1: print("Yes") exit() print("No")
p02571
s716329045
Accepted
S = input() T = input() S_len = len(S) T_len = len(T) A_sum = [] count = 0 for i in range(S_len - T_len + 1): for j in range(T_len): if S[i+j] == T[j]: count += 1 A_sum.append(count) count = 0 ans = T_len - max(A_sum) print(ans)
p02946
s368798182
Accepted
K, X = map(int, input().split()) ans = list(range(X-K+1,X+K,1)) print(*ans)
p02642
s041729916
Accepted
import sys import heapq from collections import Counter from math import sqrt n = int(input()) a_s = [int(i) for i in sys.stdin.readline().split()] a_s.sort() _max = max(a_s) ct = Counter(a_s) cnt = 0 ls = [False] * (10**6+1) for a in a_s: if ls[a]: cnt += 1 continue elif ct[a] > 1: cnt += 1 for i in range(a, _max+1, a): if ls[i]: continue if i % a == 0: ls[i] = True print(n - cnt)
p03699
s039346424
Wrong Answer
n = int(input()) s = [int(input()) for i in range(n)] o = 0 flag = True if sum(s)%10 == 0: if min(s)%10 != 0: o = sum(s)-min(s) else: while(flag): for i in sorted(s): if i%10 == 0: pass else: o = sum(s)-min(s) break else: break print(o)
p02612
s479019264
Wrong Answer
input1 = int(input()) while input1 > 999: input1 -= 1000 print(1000 - input1)
p03433
s225599223
Accepted
n = int(input()) a = int(input()) if n%500 <= a: print('Yes') else: print('No')
p02700
s372600412
Wrong Answer
A, B, C, D = map(int, input().split()) if C/B >= A/D: if C%B != 0 and A%D == 0: print("No") exit() print("Yes") else: print("No")
p03705
s808590104
Accepted
n, a, b = map(int, input().split()) mini = a * (n - 1) + b maxi = b * (n - 1) + a print(max(maxi - mini + 1, 0))
p03251
s059923022
Accepted
n, m, X, Y = map(int, input().split()) x = [int(i) for i in input().split()] y = [int(i) for i in input().split()] for Z in range(X+1, Y+1): if (max(x) < Z and min(y) >= Z): print('No War') exit() print('War')
p02658
s504845974
Wrong Answer
n = int(input()) a = map(int, input().split()) now = 1 if 0 in a: print("0") exit() for one in a: now *= one if now > 1e18: print("-1") exit() print(now)
p03637
s289463271
Accepted
N = int(input()) dic = {1:0,2:0,4:0} List = list(map(int,input().split())) for item in List: if item%4 == 0: dic[4] += 1 elif item %2 == 0: dic[2] += 1 else: dic[1] += 1 Answer = 'No' if dic[4] != 0 and dic[4]+1 >= dic[1]+dic[2]: Answer = 'Yes' elif dic[4]>=dic[1]: Answer = 'Yes' print(Answer)
p03860
s583178214
Accepted
s = list(input().split())[1] print("A"+s[0]+"C")
p03779
s042188015
Accepted
import math X = int(input()) t = math.ceil((-1 + (1+8*X)**(1/2))/2) print(t)
p03146
s147846544
Wrong Answer
s = int(input()) count = 0 while(True): if s%2 == 0: s = int(s/2) else: s = 3*s +1 count += 1 if s == 1 or 2 or 4: print(count+2) break else: pass
p02675
s727205973
Accepted
n=input() if n[-1]=='3': print("bon") elif n[-1]=='0' or n[-1]=='1' or n[-1]=='6' or n[-1]=='8': print("pon") else: print("hon")
p04020
s392552538
Accepted
def solve(): N = int(input()) A = [int(input()) for _ in range(N)] ans = 0 for a in A: ans += a//2 prev = 0 for a in A: new = a%2 if prev == 1: if new == 1: ans += 1 elif a>0: prev = 1 else: prev = 0 prev = prev^new return ans print(solve())
p02601
s096674655
Wrong Answer
A,B,C = map(int,input().split()) K = int(input()) cnt = 0 for _ in range(K): if A>B: B *= 2 cnt += 1 for _ in range(K-cnt): if B>C: C *= 2 if (A<B) and (B<C): print('Yes') else: print('No')
p03645
s798257842
Accepted
N, M = map(int, input().split()) ab = [] n1 = set() nN = set() for _ in range(M): a, b = map(int, input().split()) if (a == 1) or (b == 1): n1.add(b if a == 1 else a) if (a == N) or (b == N): nN.add(b if a == N else a) ans = 'IMPOSSIBLE' if len(n1 & nN) > 0: ans = 'POSSIBLE' print(ans)
p03544
s058887379
Accepted
import math def main(): n = int(input()) num=[0]*87 num[0]=2 num[1]=1 for i in range(2,n+1): num[i]=num[i-1]+num[i-2] print(num[n]) main()
p02989
s363057865
Accepted
N = int(input()) s = list(map(int,input().split())) sorted_s = sorted(s) print(sorted_s[(N//2)] - sorted_s[(N//2-1)])
p03427
s390159070
Accepted
N = int(input()) S = str(N) if(len(S) == 1): print(S); exit(0) if(len(S) == 2): print(max(N // 10 + N % 10, N // 10 - 1 + 9)); exit(0) for i in range(1, len(S)): if(int(S[i]) != 9): print(int(S[0]) - 1 + (len(S) - 1) * 9) exit(0) print(int(S[0]) + (len(S) - 1) * 9)
p03633
s999319204
Wrong Answer
from fractions import gcd n = int(input()) t = [int(input()) for _ in range(n)] cm = [] if n == 1: print(*t) exit() t.sort() def lcm(x, y): return (x * y) // gcd(x, y) for i in range(n-1): cm.append(lcm(t[i], t[i+1])) print(max(cm))
p03862
s708506363
Accepted
import sys #import numpy as np #import math #from fractions import Fraction #import itertools from collections import deque #import heapq from fractions import gcd input=sys.stdin.readline n,x=map(int,input().split()) a=list(map(int,input().split())) res=0 for i in range(n-1): s=a[i]+a[i+1] if s>x: a[i+1]-=(s-x) res+=(s-x) if a[i+1]<0: a[i+1]=0 print(res)
p03327
s729495279
Accepted
n = int(input()) if n < 1000: print('ABC') else: print('ABD')
p03486
s923567027
Accepted
s=input() t=input() s = sorted(s) t = sorted(t, reverse=True) if s < t: print('Yes') else: print('No')
p03380
s159628753
Wrong Answer
n = int(input()) a = list(map(int, input().split())) ai = max(a) aj = min(a) for i in a: if aj < min(i, ai - i): aj = i print(ai, aj)
p03854
s027493256
Wrong Answer
import itertools input_moji = input() count = 0 lis = ['dream','dreamer', 'erase','eraser'] origin_list = ['dream','dreamer', 'erase','eraser'] for i in itertools.product(origin_list, repeat=2): total = "".join([str(_) for _ in i]) if input_moji == total: count += 1 print('YES') if count == 0: print('NO')
p02759
s466369298
Accepted
N = int(input()) print(round((N/2)+0.01))
p03131
s533527074
Accepted
k, a, b = map(int, input().split()) if k <= a: print(k+1) else: # 交換しないほうがお得 if a+2 >= b: print(k+1) # 交換したほうがお得 else: print(a+(b-a)*((k-(a-1))//2)+((k-(a-1))%2))
p02859
s439508503
Wrong Answer
# mathモジュールをインポート import math # 円の面積を求める関数 def circle(r): return r*r*math.pi r = input().rstrip() r = int(r) # 円の面積 r_circle = circle(r) # 半径1の円の面積 one_r_circle = circle(1) ans = r_circle / one_r_circle print(ans)
p02681
s979772532
Wrong Answer
s = input() t = input() if len(s) >= 1 and len(s) <= 10 and len(t) == len(s) + 1: print("Yes") else: print("No")
p02959
s924775806
Accepted
n = int(input()) alis = list(map(int, input().split())) blis = list(map(int, input().split())) ans = 0 cross = 0 for i in range(n): front = min(alis[i]-cross, blis[i]) cross = min(alis[i+1], blis[i]-front) ans += front + cross print(ans)
p02696
s569881813
Accepted
a, b, n = map(int, input().split()) ans = 0 # floor(a * x / b) # = floor(a * floor(x / b) + a * (x / b - floor(x / b))) # = a * floor(x / b) + floor(a * (x / b - floor(x / b)))) print(int(a * min(b - 1, n) / b))
p03086
s838023033
Accepted
S = input() ans = 0 lsATCG = ['A','T','C','G'] count = 0 for s in S: if s in lsATCG: count += 1 else: ans = max(ans,count) count = 0 ans = max(ans,count) print(ans)
p03986
s832643944
Accepted
x = input() count = 0 ans = len(x) for i in range(len(x)): if x[i] == "S": count += 1 else: if count > 0: count -= 1 ans -= 2 print(ans)
p03778
s979712095
Accepted
W,a,b=map(int,input().split()) thre =0 res =0 if a<=b: thre = a+W if thre >= b: res = 0 else: res = b-thre else: thre=b+W if thre >= a: res = 0 else: res = a-thre print(res)
p03449
s568130707
Wrong Answer
N = int(input()) List = [] for i in range (2): List.append(list(map(int, input().split()))) sumList1 = [0]*N sumList2 = [0]*N for i in range(N): if i == 0: sumList1[i] = List[0][i] sumList2[N-1-i] = List[1][N-1-i] else: sumList1[i] = List[0][i]+sumList1[i-1] sumList2[N-1-i] = List[1][i]+sumList1[N-i] res = 0 for i in range(N): res = max(sumList1[i]+sumList2[i],res) print(res)
p03565
s553988767
Accepted
s=list(input()) t=list(input()) for i in range(len(s)-len(t),-1, -1): for j in range(len(t)): if not (s[i+j] == t[j] or s[i+j] == '?'): break else: s[i:i+len(t)] = t for i in range(len(s)): if s[i] == '?': s[i] = 'a' print(''.join(s)) break else: print('UNRESTORABLE')
p03944
s743991396
Wrong Answer
w,h,n = map(int,input().split()) d = [0,w,0,h] for i in range(n): x,y,a = map(int,input().split()) if a == 1: d[0] = x elif a == 2: d[1] = x elif a == 3: d[2] = y else: d[3] = y print(max(0,(d[1]-d[0]))*max(0,(d[3]-d[2])))
p03836
s144231222
Accepted
sx,sy,tx,ty=map(int,input().split()) def pans(l,c): for i in range(l): print(c,end="") H=ty-sy W=tx-sx pans(H,"U") pans(W,"R") pans(H,"D") pans(W+1,"L") pans(H+1,"U") pans(W+1,"R") pans(1,"D") pans(1,"R") pans(H+1,"D") pans(W+1,"L") pans(1,"U")
p03448
s089434087
Wrong Answer
A = int(input()) B = int(input()) C = int(input()) X = int(input()) cnt = 0 for a in range(A+1): print("a=",a) for b in range(B+1): print("b=",b) for c in range(C+1): print("c=",c) if 500*a+100*b+50*c == X: cnt += 1 print(cnt)
p03448
s144808339
Accepted
import math A = int(input()) B = int(input()) C = int(input()) X = int(input()) count = 0 for i in range(A +1): Y = X -i*500 for j in range(B + 1): Z = Y - j*100 if Z >= 0 and Z/50 <= C: count += 1 print(str(count))
p02958
s693805319
Accepted
n = int(input()) p = [ int(x) for x in input().split() ] q = sorted(p) cnt = 0 for i in range(n): if p[i] != q[i]: cnt += 1 print("YES" if cnt <= 2 else "NO")
p03557
s859483455
Wrong Answer
N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() def getPoint(X, size): l = 0 r = len(X)-1 while 1 < r-l: center = (l+r)//2 if size < X[center]: r = center else: l = center return r-1 count = 0 for a in A: for i in range(getPoint(B, a), len(B)): if a < B[i]: for j in range(getPoint(C, B[i]), len(C)): if B[i] < C[j]: count += 1 print(count)
p03137
s746474837
Wrong Answer
N,M = map(int,input().split()) X = list(map(int,input().split())) X.sort() if N>=M: print(0);exit() if N==1: print(M-1);exit() L = [] for i in range(len(X)-1): L.append(X[i+1]-X[i]) L.sort() L = L[:-(N-1)] print(sum(L))
p03951
s244241557
Accepted
#!/usr/bin python3 # -*- coding: utf-8 -*- def main(): N = int(input()) S = input() T = input() ret = 2*N for i in range(N): if S[i:]==T[:N-i]: ret = 2*N-(N-i) break print(ret) if __name__ == '__main__': main()
p02676
s814385830
Accepted
K = int(input()) S = input() if len(S) > K: S = S[:K] + '...' print(S)
p03127
s626942723
Wrong Answer
N = int(input()) A = list(map(int,input().split())) count = 0 countb = 0 min = min(A) for i in A: if i % 2 == 0: count += 1 if i % min == 0: countb += 1 if countb == N: print(A[0]) elif count == N: print(2) else: print(1)
p02678
s678308533
Accepted
from collections import deque n, m = map(int, input().split()) a = [[] for _ in range(n)] for i in range(m): x, y = map(int, input().split()) a[x - 1].append(y - 1) a[y - 1].append(x - 1) c = [0] * n que = deque([]) que.append(0) while len(que) > 0: e = que.popleft() for i in a[e]: if c[i] > 0: continue c[i] = e + 1 que.append(i) print("Yes") for i in range(1, n): print(c[i])
p02995
s844225352
Accepted
import fractions A,B,C,D = map(int,input().split()) g = C * D // fractions.gcd(C,D) # A cntA = 0 cntA += (A-1) // C cntA += (A-1) // D cntA -= (A-1) // g # B cntB = 0 cntB += B // C cntB += B // D cntB -= B // g cnt = cntB - cntA cnt = (B - A + 1) - cnt print(cnt)
p02813
s258671152
Accepted
from itertools import permutations from bisect import bisect_left n = int(input()) p = tuple(map(int, input().split())) q = tuple(map(int, input().split())) permutation = list(permutations(range(1, n+1))) a = bisect_left(permutation, p) b = bisect_left(permutation, q) print(abs(a - b))
p02646
s508230086
Accepted
B,W = map(int,input().split()) A,V = map(int,input().split()) T = int(input()) if A < B: if A-V*T >= B-W*T: print('YES') else: print('NO') elif A > B: if A+V*T <= B+W*T: print('YES') else: print('NO')
p03679
s447260608
Wrong Answer
X, A, B = map(int, input().split()) if B - A <= 0: print('delicious') elif B - A < X: print('safe') else: print('dangerous')
p02711
s537665215
Wrong Answer
string=input() t=False for i in range (3): if string[i]=="7": t=True if t==True: print("YES") else: print("NO")
p03836
s846827591
Accepted
def solve(): sx, sy, tx, ty = map(int, input().split()) ans = "" ans += "R"*(tx-sx)+"U"*(ty-sy) ans += "L"*(tx-sx)+"D"*(ty-sy) ans += "D"+"R"*(tx-sx+1)+"U"*(ty-sy+1)+"L" ans += "U"+"L"*(tx-sx+1)+"D"*(ty-sy+1)+"R" print(ans) return 0 if __name__ == "__main__": solve()
p03417
s748138771
Accepted
N, M = map(int, input().split()) if N >= 3 and M >= 3: print(N*M - (2*N + 2*M - 4)) elif N == 2 or M == 2: print(0) elif N == 1 and M == 1: print(1) elif N == 1: print(M - 2) elif M == 1: print(N - 2) else: print(1)
p04044
s918351646
Accepted
n,l=map(int,input().split()) s=[] for i in range(n): s.append(input()) s=sorted(s) for i in range(n): print(s[i], end='')
p03037
s558253422
Wrong Answer
import numpy as np N,M = map(int,input().split(" ")) Min = 1 Max = N for _ in range(M): L,R = map(int,input().split(" ")) if L>Min: Min=L if R<Max: Max=R print(Max-Min+1)
p02820
s122069197
Accepted
from itertools import groupby as gb n,k,g,t,p,s=map(lambda v:v if v[0] in "rsp" else int(v),open(0).read().split()) r,ss,pa=0,0,0 l=[""]*k for x,i in enumerate(list(s)): if l[x%k]==i:l[x%k]="";continue if i=="r":pa+=1 elif i=="s":r+=1 else:ss+=1 l[x%k]=i print(r*g+ss*t+pa*p)
p03767
s372544386
Accepted
try: N = int(input()) a = list(map(int, input().split())) a_ = sorted(a) __ = a_[N:] b = sorted(__, reverse=True) c = [b[i] for i in range(len(b)) if i%2!=0] print(sum(c)) except EOFError: pass
p03803
s087764372
Wrong Answer
A, B = map(int, input().split()) if A > B: print("Alice") elif A < B: print("Bob") else: print("Draw")
p02720
s916570031
Wrong Answer
n = int(input()) m = n order = 0 while m > 3: m = m / 3 order += 1 rem = n - 3**order msb = rem // 3 lsb = rem % 3 if lsb == 0: lsb = msb + 1 elif lsb == 2: lsb = msb elif lsb == 1: lsb = msb - 1 print(msb*10+lsb)
p02695
s457889437
Accepted
import itertools n,m,q= map(int, input().split()) g = [] for _ in range(q): z = list(map(int, input().split())) g.append(z) seq = [] for i in range(1,m+1): seq.append(i) f = [0] for i in list(itertools.combinations_with_replacement(seq, n)): ans = 0 for j in g: if i[j[1]-1]-i[j[0]-1] == j[2]: ans += j[3] f.append(ans) print(max(f))
p03150
s760154496
Wrong Answer
import math import sys import collections import bisect readline = sys.stdin.readline def main(): keyence = "keyence" s = readline().rstrip() lenS = len(s) cnt = 0 for i in range(1, 7): if s.count(keyence[0:i]) > 0: idx = s.index(keyence[0:i]) + i if s[idx:lenS].count(keyence[i:7]) > 0: print("YES") return print("NO") if __name__ == '__main__': main()