problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03951
s793760606
Accepted
# AtCoder Grand Contest 006 # A - Prefix and Suffix def f(word,N,S,T): if word[:N]==S and word[-N:]==T: return True else : return False N=int(input()) S=input() T=input() ans = N*2 for i in range (N): t=T[N-i:] word=S+t if f(word,N,S,T): if ans>len(word): ans=len(word) else: pass print(ans)
p03543
s191815502
Accepted
n=str(input()) a=[i for i in n] if a[0]==a[1]==a[2]: print("Yes") elif a[1]==a[2]==a[3]: print("Yes") else: print("No")
p03437
s455410253
Wrong Answer
x, y = map(int, input().split()) if y % x == 0: print(-1) else: print(x)
p02642
s195114394
Accepted
n=int(input()) a=list(map(int,input().split())) m=max(a) a.sort() dp=[True]*(m+1) h=dict() for i in a: if i not in h: h[i]=1 else: h[i]+=1 j=2 while j*i<=m: dp[i*j]=False j+=1 ans=0 for i in a: if dp[i]==True and h[i]==1: ans+=1 print(ans)
p02578
s308799332
Accepted
N = int(input()) a = list(map(int, input().split())) count = 0 i = 0 for i in range(N-1): if a[i] <= a[i+1]: continue elif a[i] > a[i+1]: diff = a[i] - a[i+1] count = count + diff a[i+1] = a[i] print(count)
p02983
s253940074
Wrong Answer
import sys, heapq, bisect, math, fractions from collections import deque mod = 2019 L, R = map(int, input().split()) modL = L % mod modR = R % mod if R - L >= 2018: print(0) else: if modL > modR: print(0) else: print(modL * ((modL + 1) % mod) % mod)
p03637
s965177767
Accepted
n=int(input()) A=list(map(int,input().split())) ans4 = 0 ans2 = 0 for a in A: if a % 4 == 0: ans4 += 1 elif a % 2 == 0: ans2 += 1 ans2 = ans2-(ans2%2) if (n-ans2)//2 <= ans4: print("Yes") else: print("No")
p03331
s970013298
Wrong Answer
n = int(input()) if n <=10: print(n) elif n % 10 == 0: print(min(10,n//10+n%10)) else: print(n//10+n%10)
p03293
s907859227
Wrong Answer
S=input() T=input() for i in range(1,len(S)): if S[-i:]+S[:-i]==T: print('Yes') exit() print('No')
p02866
s970261786
Accepted
def resolve(): MOD = 998244353 N = int(input()) D = list(map(int, input().split())) if D[0] != 0: print(0) return CNT = [0] * N for i in D: CNT[i] += 1 if CNT[0] > 1: print(0) return ans = 1 for i in range(1, N): ans *= pow(CNT[i - 1], CNT[i], MOD) ans %= MOD print(ans) if __name__ == "__main__": resolve()
p03997
s120928297
Accepted
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h//2)
p03274
s552086300
Accepted
N, K = map(int,input().split()) x = list(map(int,input().split())) ans = float("inf") for i in range(N-K+1): ans = min(ans, abs(x[i])+abs(x[i]-x[i+K-1])) ans = min(ans, abs(x[i+K-1])+abs(x[i]-x[i+K-1])) print(ans)
p02623
s242703658
Accepted
import bisect n,m,k=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) a_sum=[] b_sum=[] a_sum.append(0) b_sum.append(0) for i in range(n): a_sum.append(a_sum[i]+a[i]) for j in range(m): b_sum.append(b_sum[j]+b[j]) ans=0 for x in range(n+1): timecount=k-a_sum[x] if timecount>=0: y=bisect.bisect_right(b_sum,k-a_sum[x])-1 ans=max(x+y,ans) else: break print(ans)
p04034
s883048208
Wrong Answer
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 i==0: red[0] = False count = 0 for i in range(n): if num[i]>0 and red[i]: count += 1 print(count)
p03611
s310320452
Accepted
N=int(input()) a=list(map(int,input().split())) d = [0]*(10**5+1) for i in range(N): d[a[i]]+=1 ans=0 for i in range(10**5): ans = max(ans, d[i-1]+d[i]+d[i+1]) print(ans)
p03061
s376218232
Accepted
import sys,math,collections,itertools input = sys.stdin.readline N = int(input()) A=sorted(list(map(int,input().split()))) B = A[-1::-1] GCA = [0] GCB = [0] for i in range(N): GCA.append(math.gcd(GCA[-1],A[i])) GCB.append(math.gcd(GCB[-1],B[i])) GCB = GCB[-1::-1] m=[] for i in range(N): m.append(math.gcd(GCA[i],GCB[i+1])) print(max(m))
p02719
s490987614
Wrong Answer
N,K = map(int, raw_input().split()) d = int(N/K) if d == 0: print N else: p = [abs(N - K*(d-1)), abs(N - K*d), abs(N - K*(d+1))] print min(p)
p03797
s094266629
Wrong Answer
n, m = map(int, input().split()) if n < m // 2: res = n + (m - n) // 4 print(res) else: res = m // 2 print(res)
p02754
s243484837
Accepted
N, A, B = list(map(int, input().split())) if N > A + B: set_n = N // (A+B) N0 = N % (A+B) print(A * set_n + min(N0, A)) else: print(min(N, A))
p02859
s087885146
Wrong Answer
print(int(input()))
p03723
s356173658
Accepted
a, b, c = map(int, input().split()) ans = 0 while (a % 2 == 0) & (b % 2 == 0) & (c % 2 == 0): a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2 ans += 1 if ans>1000000: ans = -1 break print(ans)
p03951
s097425512
Wrong Answer
from sys import stdin n = int(stdin.readline().rstrip()) s = stdin.readline().rstrip() t = stdin.readline().rstrip() u = s[::-1] point = 0 for i,j in zip(u,t): if i == j: point += 1 else: break print(len(s[:-1*point]+t))
p02755
s382020286
Wrong Answer
a, b = map(int, input().split()) new_a = a / 0.08 new_b = b / 0.10 if new_a > new_b: tax = a while tax == a: new_a -= 1 tax = new_a * 0.08 print(int(new_a + 1)) elif new_a <= new_b: tax = b while tax == b: new_b -= 1 tax = new_b * 0.10 print(int(new_b + 1)) else: print("-1")
p03455
s426902902
Wrong Answer
a, b = map(int, input().split()) if a*b%2==0: print('Even') else: print('0dd')
p03161
s274982792
Accepted
#input N, K = map(int, input().split()) h = list(map(int, input().split())) #output dp = [0] * N dp[1] = abs(h[1]-h[0]) for i in range(2, N): temp = abs(h[i]-h[i-1]) + dp[i-1] for j in range(2, K+1): if 0<= i-j <= N-1: temp = min(temp, dp[i-j]+abs(h[i]-h[i-j])) dp[i] = temp print(dp[N-1])
p02792
s142033252
Accepted
from collections import defaultdict N = int(input()) m = defaultdict(int) for i in range(1, N+1): s = str(i) if s[-1] != "0": m[s[0] + s[-1]] += 1 ans = 0 for i in range(1, N+1): s = str(i) ans += m[s[-1] + s[0]] print(ans)
p02556
s644107617
Accepted
import sys def f(x, y): return x - y, x + y def main(): input = sys.stdin.buffer.readline n = int(input()) x = [0] * n y = [0] * n for i in range(n): x[i], y[i] = map(int, input().split()) f0 = [0] * n f1 = [0] * n for i in range(n): f0[i], f1[i] = f(x[i], y[i]) print(max(max(f0) - min(f0), max(f1) - min(f1))) if __name__ == "__main__": main()
p02702
s555077756
Wrong Answer
s = str(input()) n = len(s) print(s) s = s[::-1] print(s) x, tot = 1, 0 m = 2019 ans = 0 cnt = [int() for _ in range(m)] for i in range(n): cnt[tot] += 1 tot += (int(s[i])) * x tot %= m ans += cnt[tot] x = x * 10 % m print(ans)
p02578
s843763831
Accepted
N=int(input()) A=list(map(int,input().split())) H=A[0] ans=0 for i in range(N): ans+=max(0,(H-A[i])) H=max(H,A[i]) #print(H) print(ans)
p02681
s119730602
Accepted
S=input() T=input() for i in range(len(S)): if S[i]==T[i]: continue else: print('No') exit() if len(S)+1 ==len(T): print('Yes') else: print('No')
p03163
s723631945
Wrong Answer
N, W = map(int, input().split()) wv = [list(map(int, input().split())) for i in range(N)] dp = [[0] * (W + 1) for _ in range(N + 1)] for i in range(1, N + 1): for j in range(W + 1): if j < wv[i - 1][0]: dp[i][j] = max(dp[i][j], dp[i - 1][j]) else: dp[i][j] = max(dp[i][j], dp[i - 1][j - wv[i - 1][0]] + wv[i - 1][1]) print(max(max(dp)))
p02797
s746440530
Wrong Answer
n, k, s = map(int, input().split()) aa = [s]*k +[1]*(n-k) print(*aa)
p02623
s920147380
Accepted
import bisect N,M,K= map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) dpA = [0]*(N+1) dpB = [0]*(M+1) for i in range(1,N+1): dpA[i] = dpA[i-1] + A[i-1] for i in range(1,M+1): dpB[i] = dpB[i-1] + B[i-1] ans = 0 for i in range(N+1): if dpA[i] > K: continue indexB = bisect.bisect_right(dpB, K - dpA[i]) ans = max(ans, i + indexB - 1) print(ans)
p04011
s455527029
Accepted
n = int(input()) k = int(input()) x = int(input()) y = int(input()) if k >= n: print(x*n) else: print(x*k + y*(n-k))
p03241
s529741297
Wrong Answer
n,m=map(int,input().split()) l=[1] k=m//n for i in range(2,int(m**0.5)+2): if m%i==0: if i<=k: l.append(i) if (m//i)<=k: l.append(m//i) print(max(l))
p03624
s522196151
Accepted
sList = sorted(list(set(list(input())))) chI = ord('a') for i in sList: if chI == ord(i): chI += 1 else: print(chr(chI)) exit(0) if len(sList) != 26: print(chr(chI)) else: print("None")
p02660
s870623041
Accepted
N = int(input()) n, p, score = N, 2, 0 while p ** 2 <= N: e = 1 while n >= (p ** e) and n % (p ** e) == 0: n //= (p ** e) score += 1 e += 1 else: while n >= p and n % p == 0: n //= p p = p + 1 if p == 2 else p + 2 else: if n != 1: score += 1 print(score)
p03659
s387069819
Wrong Answer
import heapq n=int(input()) A=list(map(lambda x:int(x)*(-1),input().split())) ans=10**9 heapq.heapify(A) tmp=0 for i in range(1,len(A)): tmp+=heapq.heappop(A) ans=min(ans,abs(sum(A)-tmp)) print(ans)
p03448
s156636691
Wrong Answer
a500 = int(input()) b100 = int(input()) c50 = int(input()) _x = int(input()) answer = 0 for c in range(c50+1): for b in range( b100+1): for a in range(a500+1): print (a,b,c) if a*500 + b*100 + c*50 == _x: answer += 1 print (answer)
p03799
s205404920
Accepted
n, m = map(int, input().split()) print(m//2 if n >= m//2 else n+(m-n*2)//4)
p03067
s382362301
Accepted
a, b, c = map(int, input().split()) if a < b: if a < c < b: print('Yes') else: print('No') else: if b < c < a: print('Yes') else: print('No')
p02933
s566018120
Wrong Answer
a = int(input()) s = input() if a < 3200: print(s) else: print("red")
p03377
s926576376
Accepted
import sys def input(): return sys.stdin.readline().strip() def resolve(): a, b, x = map(int, input().split()) if a <= x <= a + b: print('YES') else: print('NO') resolve()
p02582
s850468239
Wrong Answer
S=input() string1 = 'R' string2 = 'RR' if S.count(string1) == 0: print('0') if S.count(string1) == 1 or S == 'RSR': print('1') if S.count(string2) == 1: print('2') if S.count(string1) == 3: print('3')
p03494
s429569112
Wrong Answer
import math n = input() a = list(map(int, input().split())) ans = float("inf") for i in a: ans = min(ans, len(bin(i)) - bin(i).rfind("1")) print(round(ans))
p03038
s401769643
Accepted
n, m = map(int, input().split()) A = list(map(int, input().split())) B = [] C = [] for i in range(m): b, c = map(int, input().split()) B.append(b) C.append(c) D = zip(C, B) D = sorted(D) C, B = zip(*D) C = reversed(C) B = reversed(B) total = 0 for i, j in zip(C, B): if total >= n: break else: total += j A.extend([i] * j) A = sorted(A) print(sum(A[-n:]))
p02691
s871236544
Wrong Answer
import itertools import numpy as np N = int(input()) Al = list(map(int, input().split())) comb = np.array(list(itertools.combinations(Al, 2))).sum(axis = 1) comb_i = np.array(list(itertools.combinations(np.arange(1, N+1), 2))).mean(axis = 1) print((comb == comb_i).sum())
p02753
s017465880
Wrong Answer
S = input() if S == 'ABA': print('Yes') elif S == 'BAB': print('Yes') else: print('No')
p03106
s143233949
Accepted
from math import gcd a, b, k = map(int, input().split()) g = gcd(a, b) for i in range(g, 0, -1): if g % i == 0: k -= 1 if k == 0: print(i) break
p03274
s580059290
Wrong Answer
n, k = map(int, input().split()) x = list(map(int, input().split())) neg_num = n for i in range(n): if x[i] > 0: neg_num = i break pos_num = n - neg_num l = min(k, neg_num) res = 10 ** 13 for i in range(l, -1, -1): r = k - i if r <= pos_num: l_val = min(0, x[neg_num - i]) r_val = x[neg_num + k - i - 1] tmp = min( -l_val * 2 + r_val, -l_val + r_val * 2) res = min(tmp, res) print(res)
p04020
s325035736
Accepted
N = int(input()) A = [int(input()) for _ in range(N)] A.append(0) con = False ans = 0 for i in range(N): if A[i] >=2: ans += A[i]//2 A[i] -= (A[i]//2)*2 mm = min(A[i+1],A[i]) ans += mm A[i+1] -= mm A[i] -= mm #print(A) print(ans)
p03126
s882478892
Accepted
n,m=map(int,input().split()) c = [0]*m for i in range(n): a = list(map(int, input().split())) for e in a[1:]: c[e-1] += 1 print(c.count(n))
p03994
s836926996
Accepted
s = input() K = int(input()) ans = [] for i in s: if i == "a": ans.append("a") continue if ord(i) + K >= ord("z") + 1: ans.append("a") K -= ord("z") + 1 - ord(i) else: ans.append(i) last = (K + ord(ans[-1]) - ord('a')) % 26 ans[-1] = chr(ord("a") + last) print(''.join(ans))
p02775
s751040195
Wrong Answer
# print('input >>') N = input() N = reversed(N) ans = 0 nxt = False for n in N: i_n = int(n) + nxt if i_n % 10 >= 6: ans += 10 - i_n % 10 nxt = True else: ans += i_n % 10 nxt = False # print(N, ans)
p02922
s996384257
Wrong Answer
A, B = (int(x) for x in input().split()) S = A num = 1 i = 0 while(S < B): i += 1 A = A * 2 S = A - i num += 1 print(num)
p02601
s112979949
Accepted
def b(): red, green, blue = map(int, input().split()) k = int(input()) for i in range(k): if green <= red: green *= 2 elif blue <= green: blue *= 2 else: print('Yes') return if blue > green > red: print('Yes') else: print('No') ########## if __name__ == "__main__": b()
p03150
s649265399
Accepted
s = input() n = len(s) t = 'keyence' flg = False for i in range(8): if i == 7: u = s[:7] else: u = s[:i] + s[i-7:] if u == t: flg = True break if flg: print('YES') else: print('NO')
p03524
s054608097
Wrong Answer
s = list(input()) a = [s.count('a'),s.count('b'),s.count('c')] print("No" if max(a)-min(a)>1 else "Yes")
p02603
s191323775
Accepted
N = int(input()) A = list(map(int, input().split())) x=1000 for i in range(N - 1): s = A[i] t = A[i +1] if s < t: k = x//s x %= s x += k*t print(x)
p02572
s023958881
Wrong Answer
N= int(input()) list1 =[] list1 = list(map(int, input().split())) sum = 0 print(list1) for i in range(N-1): for j in range(i+1,N): sum = sum + list1[i]*list1[j] answer = divmod(sum, 10**9+7) print(answer[0])
p03252
s600518344
Wrong Answer
S=input() T=input() D={} ans=1 for s,t in zip(S,T): x=D.get(t, '') print(s,t,x) if x=='': D[t]=s else: print(s,t,x) if x!=s: ans=0 break print('Yes' if ans else 'No')
p02688
s031787405
Accepted
n,k=map(int,input().split()) s=set() for i in range(k): _=input() s|=set(input().split()) print(n-len(s))
p02690
s333255655
Accepted
X = int(input()) for i in range(-500, 500): for j in range(-500, 500): if i**5 - j**5 == X: ans = [str(i), str(j)] break print(" ".join(ans))
p02724
s136342779
Wrong Answer
x = int(input()) count_a = x// 500 x = x%500 x = x% 100 x = x%50 x = x%10 count_b = x // 5 print(count_a*1000+count_b*5)
p03109
s947042051
Accepted
y, m, d = map(int, input().split('/')) if y < 2019: print('Heisei') elif y == 2019 and m <= 4: print('Heisei') else: print('TBD')
p02701
s259138057
Accepted
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N = ir() S = [sr() for _ in range(N)] se = set(S) answer = len(se) print(answer)
p02989
s783715985
Wrong Answer
n = int(input()) a = list(map(int,input().split())) a.sort() ans = [] nh1 = n//2 - 1 nh2 = nh1 + 1 if a[nh1] == a[nh2]: print(0) else: for i in range(a[nh1]+1,a[nh2]+1): ans.append(i) print(len(ans))
p02723
s561075708
Wrong Answer
S = str(input().lower()) if S[2]==S[3] and S[4]==S[5]: print("Yes") else: print("NO")
p03695
s866783053
Accepted
n=int(input()) a=list(map(int,input().split())) b=[0 for i in range(9)] for i in range(n): b[min([a[i]//400,8])]+=1 ans1=len([i for i in b[:8] if i>0]) ans2=ans1+b[8] ans1=max([ans1,1]) print(ans1,ans2)
p03711
s045010148
Accepted
lis1 = [1,3,5,7,8,10,12] lis2 = [4,6,9,11] x,y = map(int,input().split()) if x in lis1 and y in lis1: print("Yes") elif x in lis2 and y in lis2: print("Yes") elif x == 2 and y ==2: print("Yes") else: print("No")
p02707
s745018228
Accepted
N = int(input()) A = [int(i) for i in input().split(' ')] B = [0] * N for i in A: B[i-1] += 1 for i in B: print(i)
p02790
s631430757
Wrong Answer
a, b = map(int, input().split()) x = a if a<=b else b for _ in range(x): print(x, end='')
p02771
s470576126
Wrong Answer
A,B,C=map(int,input().split()) if A==B and B==C and A!=C: print('Yes') elif B==C and C==A and B!=A: print('Yes') elif C==A and A==B and C!=B: print('Yes') else: print('No')
p02584
s657163550
Accepted
import math x,k,d=map(int,input().split()) x1=abs(x) if k*d<x1: print(x1-k*d) else: a=math.ceil(x1/d) if (k-a)%2==0: print(abs(x1-d*a)) else: print(abs(x1-d*(a-1)))
p02947
s161010223
Accepted
import collections n=int(input()) A=[] for i in range(n): s=sorted(input()) t=''.join(s) A.append(t) r=collections.Counter(A) r=r.most_common() cnt=0 for j in range(len(r)): if r[j][1]==1: cnt+=0 else: cnt+=((r[j][1]-1)*r[j][1])//2 print(cnt)
p03254
s329954675
Accepted
n,x = map(int,input().split()) a = sorted(map(int,input().split())) ans = 0 for i in a[:-1]: if i <= x: ans += 1 x -= i else: break if x == a[-1]: ans += 1 print(ans)
p03261
s481173140
Accepted
N = int(input()) d = {} w1 = [] f = False for i in range(N): w = input() if d.get(w) is None: d[w] = 1 else: f = True w1.append(w) for i in range(1, N): if w1[i-1][-1] == w1[i][0]: continue else: f = True print('Yes' if f is False else 'No')
p02778
s166117382
Accepted
s = input() win=[] for i in range(len(s)): win.append("x") final_list=''.join(win) print (final_list)
p03761
s023500664
Accepted
from collections import Counter n = int(input()) s = [input() for _ in range(n)] c = Counter(s[0]) for i in range(1,len(s)): c &= Counter(s[i]) ans='' for letter, cnt in c.items(): ans += letter*cnt print(*sorted(ans), sep='')
p02723
s427328695
Accepted
import sys import math from collections import Counter s = sys.stdin.readline().strip() if s[2] == s[3] and s[4] == s[5]: print('Yes') else: print('No')
p02970
s682369616
Accepted
import math import sys m=10**9 + 7 sys.setrecursionlimit(1000010) (N,D) = list(map(int,input().split())) d = D * 2 + 1 print ((N+d-1)//d)
p03000
s895944229
Accepted
N,X = map(int,input().split()) L =[0] + list(map(int,input().split())) D = [0 for i in range(N+2)] cnt = 1 for i in range(2,N+2): D[i] = D[i-1] + L[i-1] if D[i] > X: break else: cnt += 1 print(cnt)
p02843
s721539190
Accepted
n=int(input()) m=n//100 l=n%100 if l<=5*m: print("1") else: print("0")
p02773
s820356810
Accepted
from collections import defaultdict d=defaultdict(int) for i in range(int(input())): d[input()]+=1 ans=[] d=list(d.items()) d.sort(key=lambda x:-x[1]) m=d[0][1] for i,j in d: if m==j: ans+=[i] else: break for i in sorted(ans): print(i)
p02552
s855269393
Accepted
#!/usr/bin/env python3 import sys import math from bisect import bisect_right as br from bisect import bisect_left as bl sys.setrecursionlimit(2147483647) from heapq import heappush, heappop,heappushpop from collections import defaultdict from itertools import accumulate from collections import Counter from collections import deque from operator import itemgetter from itertools import permutations mod = 10**9 + 7 inf = float('inf') def I(): return int(sys.stdin.readline()) def LI(): return list(map(int,sys.stdin.readline().split())) x = I() if x == 0: print(1) else: print(0)
p03360
s858320479
Accepted
a,b,c = map(int, input().split()) k = int(input()) m = max(a,b,c) re = sum([a,b,c]) - m print(re + m*2**(k))
p02854
s855394329
Accepted
n = int(input()) s = list(map(int,input().split())) ans = 2020202020 a = 0 b = sum(s) for i in range(n): a += s[i] b -= s[i] ans = min(ans,abs(a-b)) print(ans)
p02612
s246610084
Accepted
# Begin Header {{{ from math import gcd from collections import Counter, deque, defaultdict from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort from itertools import accumulate, product, permutations, combinations, combinations_with_replacement # }}} End Header # _________コーディングはここから!!___________ n = int(input()) if n%1000 == 0: print(0) else: print(1000-n%1000)
p02773
s245337394
Wrong Answer
n = int(input()) dic = {} for i in range(n): temp = input() try: dic[temp] += 1 except: dic[temp] = 0 dic = dict(sorted(dic.items(), key=lambda x: x[0])) for i in dic.keys(): print(i)
p03339
s390314416
Wrong Answer
n = int(input()) s = list(input()) l = [0]*n l[n-1] = s[:n-1].count('E') for i in range(n-1): w_side = s[:i].count('E') e_side = s[i+1:].count('W') l[i] = w_side + e_side print(min(l))
p03944
s431257196
Wrong Answer
W, H, N = map(int, input().split()) b = [0, 0, W, 0, H] for _ in range(N): x, y, a = map(int, input().split()) if a == 1: b[a] = max(b[a], x) elif a == 2: b[a] = min(b[a], x) elif a == 3: b[a] = max(b[a], y) else: b[a] = min(b[a], y) # print('b', b) _W = b[2] - b[1] _H = b[4] - b[3] # print('_W, _H', _W, _H) ans = _W * _H print(0 if ans < 0 else ans)
p03657
s518901816
Accepted
A,B=map(int,input().split()) c=min([(A+B)%3,A%3,B%3]) print(['Possible','Impossible'][c!=0])
p02618
s730193125
Accepted
d = int(input()) c = list(map(int,input().split())) data = [0]*(26) ans = 0 for i in range(1,d+1): s = list(map(int,input().split())) L = [] for j in range(26): sub = s[j] for k in range(26): if j == k: continue sub -= c[k]*(i-data[k]) L.append(sub) out = L.index(max(L)) print(out+1) data[out] = i
p03438
s301247411
Accepted
N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) plus_2 = 0 minus = 0 for a, b in zip(A, B): if a < b: plus_2 += (b-a)//2 else: minus += a-b if plus_2 >= minus: print('Yes') else: print('No')
p02612
s085652784
Wrong Answer
n=int(input()) print(n%1000)
p02645
s576972365
Accepted
name = str(input()) nickname = name[:3] print(nickname)
p03286
s187822850
Accepted
n= int(input()) i = 0 base = 1 digits = '' while n!= 0: if n % (base*2) == 0: digits += '0' else: digits += '1' n -= base i += 1 base *= -2 if digits=='': digits='0' print(digits[::-1])
p03038
s400721725
Accepted
def main(): N, M = map(int, input().split()) A = list(map(int, input().split())) A.sort() BC = [tuple(map(int, input().split())) for _ in range(M)] BC.sort(key=lambda x: x[1], reverse=True) D = [] for b, c in BC: D.extend([c] * b) if len(D) >= N: break D = D[:N] r = sum(A) for a, d in zip(A, D): r = max(r, r - a + d) print(r) main()
p03208
s327288882
Wrong Answer
n, k = map(int,input().split(" ")) trees = [] for i in range(n): trees.append(int(input())) trees.sort() min_val = 0 for i in range(len(trees) - 1): min_val = min(abs(trees[i+1] - trees[i]), min_val) print(min_val)
p02719
s323084213
Accepted
n,k=map(int,input().split()) if k==1: print(0) elif n>k: print(k-(n%k)) else: val=k-n if n<val: print(n) else: print(val)