problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02572
s627902455
Accepted
N = int(input()) A = list(map(int,input().split())) Sum = sum(A) ans = 0 for i in range(N): Sum = Sum-A[i] AA = Sum*A[i] ans += AA ans = ans%(10**9 + 7) print(ans)
p02922
s865959732
Accepted
A, B = map(int, input().split()) q = -((-B+1)//(A-1)) print(q)
p02820
s149010102
Accepted
n, k = map( int, input().split() ) r, s, p = map( int, input().split() ) t = str( input() ) t_list = [ c for c in t ] for i in range( k, n ): if t_list[ i ] == t_list[ i - k ]: t_list[ i ] = "x" score = 0 for hand in t_list: if hand == "r": score += p elif hand == "s": score += r elif hand == "p": score += s print( score )
p03672
s253241984
Accepted
S = input() while True: S = S[:-1] if len(S)%2 == 0: if S[:len(S)//2] == S[len(S)//2:]: print(len(S)) exit(0)
p02847
s906944372
Accepted
s = input() dDic = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1 } print(int(dDic[s]))
p02708
s218908689
Wrong Answer
n, k = (int(x) for x in input().split()) num = 0 for x in range(k, n + 1): minnum = sum(i for i in range(k)) maxnum = sum (i for i in range(n - k + 1,n + 1)) num += maxnum - minnum + 1 print(num)
p03487
s380126155
Wrong Answer
n=int(input()) a=sorted(list(map(int,input().split()))) b=set() ans=0 d={} cnt=0 for i in range(n-1): cnt+=1 if i==n-2 and a[i]==a[i+1]: cnt+=1 d[a[i]]=cnt break if a[i]!=a[i+1]: d[a[i]]=cnt cnt=0 for i in d.keys(): if d[i]>=i: ans+=d[i]-i else: ans+=d[i] print(ans)
p03487
s248450753
Accepted
N = int(input()) A = list(map(int, input().split())) A.sort() result = {} for i in range(N): if A[i] not in result: result[A[i]] = 1 else: result[A[i]] += 1 count = 0 for i in result.keys(): if result[i] > i: count += abs(i-result[i]) elif result[i] < i: count += result[i] print(count)
p02831
s336858259
Accepted
a,b=map(int,input().split()) for i in range(1,b): if a*i%b==0: print(a*i) break else: print(a*b)
p03351
s966425914
Wrong Answer
def readints(): return list(map(int, input().split())) a, b, c, d = map(int, input().split()) if (abs(a-b) <= d or abs(b-c) <= d) or abs(a-c) <= d: print("Yes") else: print("No")
p03220
s733476176
Wrong Answer
N = int(input()) T, A = [int(i) for i in input().split(" ")] temp = [T-0.006*int(h) for h in input().split(" ")] place = 0 diff_min = 60 for cnt, t in enumerate(temp): if abs(A-t) < diff_min: diff_min = abs(A-t) place = cnt print(place)
p03345
s340517604
Accepted
A, B, C, K = map(int, input().split()) print((A-B)*(-1)**(K%2))
p03659
s600150626
Accepted
n = int(input()) a = list(map(int,input().split())) x = [0] for i in a: x.append(x[-1]+i) ans = 10**11 for i in x[1:-1]: ans = min(ans,abs(i*2-x[-1])) print(ans)
p02719
s866729513
Accepted
# import sys import math import numpy as np import itertools # いくつか入力 n,k = (int(i) for i in input().split()) a = n % k c = k - a print(min(a,c))
p02688
s022336503
Accepted
# ABC166 B def main(): n, k = map(int, input().split()) sunuke = [0] * n for i in range(k): d = int(input()) A = list(map(int, input().split())) for j in A: sunuke[j-1] += 1 print(sunuke.count(0)) if __name__ == '__main__': main()
p02820
s735279061
Accepted
n, k = map(int, input().split()) r, s, p = map(int, input().split()) t = input() c = {"r": p, "s": r, "p": s} ans = 0 wins = [False] * k for i in range(n): if not wins[i % k] or t[i] != t[i-k]: ans += c[t[i]] wins[i % k] = True else: wins[i % k] = False print(ans)
p02973
s460915841
Accepted
from sys import stdin, setrecursionlimit from collections import deque from bisect import bisect_left def main(): input = stdin.buffer.readline n = int(input()) a = [int(input()) for _ in range(n)] ans = deque() for ai in a: idx = bisect_left(ans, ai) if idx == 0: ans.appendleft(ai) else: ans[idx - 1] = ai print(len(ans)) if __name__ == "__main__": setrecursionlimit(10000) main()
p03455
s784151572
Wrong Answer
a, b = map(int, input().split()) print('Evan' if a*b%2==0 else 'Odd')
p02607
s275826896
Wrong Answer
N = int(input()) a = [] a = input().split() count = 0 for i in range(int(N/2)): cd = 2 * i - 1 jd = int(a[cd]) if jd % 2 == 1: count += 1 print(count)
p02697
s950324795
Accepted
N, M = map(int, input().split()) ans = [] for i in range(M): if N % 2 != 0 or (M + (i + 1)) - (M - (i)) < N // 2: tmp = [str(M - (i)), str(M + (i + 1))] else: tmp = [str(M - (i)), str(M + (i + 2))] tmp = ' '.join(tmp) ans.append(tmp) print(*ans, sep='\n')
p02675
s029875597
Accepted
n = input() hons = ["2", "4", "5", "7", "9"] pons = ["0", "1", "6", "8"] ans = "" for i in hons: if n[-1] == i: ans = "hon" for i in pons: if n[-1] == i: ans = "pon" if n[-1] == "3": ans = "bon" print(ans)
p02691
s058718798
Accepted
import sys from collections import Counter def input(): return sys.stdin.readline().rstrip() def main(): N = int(input()) A = map(int, input().split()) Aplus = [0] * N for i, a in enumerate(A): Aplus[i] = i + a + 1 A_counter = Counter(Aplus) ans = 0 for i in range(1, N + 1): key = i * 2 - Aplus[i-1] ans += A_counter[key] if key == Aplus[i - 1]: ans -= 1 print(ans) if __name__ == '__main__': main()
p02702
s802177787
Wrong Answer
def combinations_count(n): return n*(n-1)//2 s = input() l = len(s) lis = [] for i in reversed(range(l)): if i == l-1: lis.append(int(s[l-1])%2019) tem = int(s[l-1]) tem2 = 1 else: tem2 = (10*tem2)%2019 kk = (int(s[i])*tem2+tem)%2019 tem = kk lis.append(kk) lis.append(0) lis.sort() ll = len(lis) ans = 0 tem = 1 for i in range(1, ll): if lis[i-1] == lis[i]: tem += 1 elif tem >= 2: ans += combinations_count(tem) tem = 1 print(ans)
p02842
s426241044
Accepted
#B import math n=int(input()) ans=None for i in range(1,54000): if math.floor(i*1.08)==n: ans=i break if i==n-1: ans=":(" print(ans)
p02641
s430354653
Accepted
X,N = map(int,input().split()) min = 100 if N !=0: Plist = list(map(int,input().split())) anslist = [i for i in range(102)] anslist.append(-1) #anslist.remove(0) Plist = sorted(Plist) #print (anslist) for i in range(N): anslist.remove(Plist[i]) temp =100 for i in range(len(anslist)): if min >abs(anslist[i]-X) : min = abs(anslist[i]-X) temp = anslist[i] print (temp) else : print (X)
p02832
s723296409
Wrong Answer
n = int(input()) a = list(map(int, input().split())) ans = 0 if (1 not in a): print(-1) else: for i in range(1,n): if (i not in a): break else: ain = a.index(i) ans += ain del a[i:ain] print(ans)
p02973
s885449010
Accepted
import bisect def main(): n = int(input()) a = [int(input()) for _ in range(n)] tail = [] len_tail = 0 for ai in a: idx = bisect.bisect_right(tail, -ai, lo=0, hi=len_tail) if idx == len_tail: tail.append(-ai) len_tail += 1 else: tail[idx] = - ai print(len_tail ) if __name__ == "__main__": main()
p03699
s052683717
Wrong Answer
n = int(input()) s = [0] * n for i in range(n): s[i] = int(input()) ans = 0 for i in range(n ** 2): score = 0 for j in range(n): if i >> j & 1: score += s[j] if score % 10 != 0: ans = max(ans, score) print(ans)
p03799
s658518315
Accepted
n, m = map(int, input().split()) if n*2 < m: while n*2 <= m: if m - 2*n > 100000: m -= 60000 n += 30000 elif m - 2*n > 10000: m -= 6000 n += 3000 else: m -= 2 n += 1 print(n - 1) else: print(m//2)
p03720
s108449476
Wrong Answer
N,M = map(int,(input().split())) ab = [int(input().replace(' ',''))for _ in range(M)] #print(ab) abc='' ans = [] for i in ab: abc+=str(i) #print(int(abc)) for j in range(1,N+1): print(abc.count(str(j)))
p03943
s263968669
Accepted
a = list(map(int, input().split())) a.sort() if a[0]+a[1] == a[2]: print('Yes') else: print('No')
p02726
s193030228
Wrong Answer
N, X, Y = (int(x) for x in input().split()) line = [(i,i+1) for i in range(1,N)] line.insert(X-1, (X,Y)) dis = [[N*2]*(N+2) for _ in range(N+2)] for i in range(1, N): for j in range(i+1, N+1): if i <= X and Y <= j: dis[i][j] = (X-i) + (j-Y) + 1 else: dis[i][j] = j-i fdis = sum(dis, []) fdis = [x for x in fdis if x != N*2] for k in range(1,N): print(fdis.count(k))
p03711
s791556234
Accepted
a=[1,3,5,7,8,10,12] b=[4,6,9,11] c=list(map(int,input().split(" "))) print("Yes") if (c[0] in a and c[1] in a) or (c[0] in b and c[1] in b) else print("No")
p03011
s976466975
Wrong Answer
def main(): p,q,r = map(int, input().split()) min_time = min([p, q, r]) print(min_time) if __name__ == '__main__': main()
p03208
s777174336
Accepted
n,k = map(int,input().split()) s = [int(input()) for i in range(n)] s.sort() d = [] for i in range(n-1): d.append(s[i+1]-s[i]) ans = 0 for i in range(k-1): ans += d[i] tmp = ans for i in range(n-k): tmp -= d[i] tmp += d[i+k-1] ans = min(tmp,ans) print(ans)
p02660
s768136961
Accepted
from math import sqrt 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 def hoge(c): return int((-1+sqrt(1+8*c))/2) n = int(input()) a = prime_factorize(n) b = set(a) print(sum([hoge(a.count(e)) for e in b]))
p03997
s567275377
Accepted
import sys import copy import math import bisect import pprint import bisect from functools import reduce from copy import deepcopy from collections import deque if __name__ == '__main__': a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] c = [int(i) for i in input().split()] print(((a[0]+b[0])*c[0])//2)
p03665
s192075777
Accepted
from scipy.special import comb n, p, *A = map(int, open(0).read().split()) odd = sum(a%2 for a in A) even = n - odd if p: s = 0 for i in range(1, odd+1, 2): s += comb(odd, i, exact=True) s *= pow(2, even) print(s) else: s = 0 for i in range(0, odd+1, 2): s += comb(odd, i, exact=True) s *= pow(2, even) print(s)
p03338
s215945420
Accepted
n = int(input()) s = input() a = [0]*26 al = 'abcdefghijklmnopqrstuvwxyz' for i in range(n): a[al.index(s[i])] += 1 b = [0]*26 res = 0 for i in range(n): b[al.index(s[i])] += 1 tmp = 0 for j in range(26): if b[j] >= 1 and a[j] - b[j] >= 1: tmp += 1 res = max(res, tmp) print(res)
p03380
s560019818
Accepted
n = int(input()) a = list(map(int, input().split())) a_i = max(a) half = a_i/2 best = a_i*2 for j in a: if j==a_i: continue diff = abs(j-half) if diff < best: best = diff a_j = j print(a_i, a_j)
p03221
s672795964
Accepted
import collections import bisect n,m=map(int,input().split()) p=[[int(j) for j in input().split()] for i in range(m)] a=collections.defaultdict(list) for x,y in sorted(p): a[x]+=[y] for x,y in p: z=bisect.bisect(a[x],y) print("%06d%06d"%(x,z))
p03433
s394635597
Wrong Answer
n = int(input()) a = int(input()) r = n % 500 if a < r: print("NO") else: print("YES")
p03524
s009461700
Accepted
from collections import Counter S = input() c = Counter(S) if abs(c['a'] - c['b']) <= 1 and abs(c['b'] - c['c']) <= 1 and abs(c['c'] - c['a']) <= 1: print('YES') else: print('NO')
p02971
s865108091
Accepted
N = int(input()) A = [int(input()) for i in range(N)] max_num = max(A) a = sorted(A) second = a[-2] for i in range(N): if A[i] == max_num: print(second) else: print(max_num)
p03854
s185276902
Accepted
def check(): S = input() n = len(S) dp = [False]*(n+10) dp[0] = True for i in range(n+1): if S[i:i+5]=='dream': dp[i+5] |= dp[i] if S[i:i+7]=='dreamer': dp[i+7] |= dp[i] if S[i:i+5]=='erase': dp[i+5] |= dp[i] if S[i:i+6]=='eraser': dp[i+6] |= dp[i] if dp[n]==True: return 'YES' return 'NO' print(check())
p02641
s480158079
Accepted
import bisect X, N = map(int, input().split()) if N > 0: Ps = list(map(int, input().split())) else: Ps = [] Pst = set(Ps) ab = 200 tmp = 200 rlt = -1 for i in range(102): if i in Pst: continue else: tmp = abs(i-X) if ab > tmp: ab = tmp rlt = i print(rlt)
p02743
s278672609
Wrong Answer
a,b,c = map(int,input().split()) if (c-a-b)<0: print("No") h = 4*a*b m = (c-a-b)**2 if h<m: print("Yes") else: print("No")
p02996
s099672158
Accepted
import sys from heapq import heappush, heappop #input = sys.stdin.readline def main(): n=int(input()) ba=[] for i in range(n): a,b=map(int,input().split()) ba.append((b,a)) ba.sort() asum=0 ans='Yes' for b,a in ba: asum+=a if asum>b: ans='No' break print(ans) if __name__ == '__main__': main()
p02753
s757350972
Accepted
s=list(input()) if s[0] != s[1] or s[1] != s[2]: print("Yes") else: print("No")
p04033
s086790779
Accepted
a,b=map(int,input().split()) if a<0 and 0<b: print('Zero') exit() minus_num=0 if a<0: minus_num=abs(a) if b<0: minus_num=abs(a-b+1) print('Negative' if minus_num&1 else 'Positive')
p02811
s960732287
Accepted
k,x = list(map(int, input().split())) if 500*k >= x: print('Yes') else: print('No')
p03208
s635218652
Wrong Answer
N, K = map(int, input().split()) hn = [] for i in range(N): hn.append(int(input())) hn = sorted(hn,reverse=True) min = 99999999 for i in range(N-K+1): if min > (hn[i]-hn[K+i-1]): min = hn[i]-hn[K+i-1] print(min)
p03860
s644879214
Wrong Answer
li = input().split() print('A,li[1][0],C')
p02935
s839450029
Accepted
N = int(input()) v = sorted(list(map(int, input().split()))) for i in range(N-1): a = (v[i]+v[i+1])/2 v[i+1] = float(a) print(v[-1])
p03827
s734237819
Accepted
N = int(input()) S = input() x = 0 A = [0] for i in range(N): if S[i] == "I": x += 1 else: x -= 1 A.append(x) print(max(A))
p04011
s806999942
Wrong Answer
n = int(input()) k = int(input()) x = int(input()) y = int(input()) ans = x*k + y*(n-k) print(ans)
p02727
s276697937
Wrong Answer
x,y,a,b,c = map(int,input().split()) pl = list(map(int,input().split())) ql = list(map(int,input().split())) rl = list(map(int,input().split())) pp = sorted(pl,reverse=True)[:x-1] qq = sorted(pl,reverse=True)[:y-1] all = pp + qq + rl print(sum(sorted(pl,reverse=True)[:x+y-1]))
p03087
s488864387
Accepted
N,Q = map(int, input().split()) S = input() range_list = [list(map(int, input().split())) for _ in range(Q)] ac_counter = [0] # acという文字列をカウントしておくlistを作成 for i in range(1,N): ac_counter.append(ac_counter[i-1]+1 if S[i-1:i+1] == 'AC' else ac_counter[i-1]) # 上で作ったリストを使い範囲内に何個あるのか確認 for range_list in range_list: print(ac_counter[range_list[1]-1] - ac_counter[range_list[0]-1])
p02861
s530326373
Accepted
import math import itertools def get_length(p1, p2): x1 = p1[0] x2 = p2[0] y1 = p1[1] y2 = p2[1] return ((x1 - x2)**2 + (y1- y2)**2)**0.5 N = int(input()) xy = [[0, 0] for _ in range(N)] for i in range(N): xy[i][0], xy[i][1] = map(int, input().split()) total_len = 0 pattern = 0 for i in itertools.permutations(list(range(N))): pattern += 1 for j in range(N-1): total_len += get_length(xy[i[j]], xy[i[j+1]]) print(total_len / pattern)
p02706
s100010146
Accepted
n, m = map(int, input().split()) a = [i for i in map(int, input().split())] if n-sum(a)>=0: print(n-sum(a)) else: print(-1)
p03289
s428458134
Accepted
import sys s = input() ans = 'AC' c = 0 if s[0] != 'A': ans = "WA" for i in range(2,len(s)-1): if "C" == s[i]: c += 1 if c != 1: ans = "WA" c = 0 for i in range(len(s)): a = ord(s[i]) if 65 <= a and a <= 96: c += 1 if c != 2: ans = "WA" print(ans)
p03076
s316266228
Wrong Answer
S=[int(input()) for i in range(5)] R=list(S) for i in range(5): R[i]=R[i]%10 L=sorted(R)[::-1] total=S[0]+S[1]+S[2]+S[3]+S[4] mati=(10-L[0])+(10-L[1])+(10-L[2])+(10-L[3]) print(total+mati)
p03693
s739276832
Accepted
if int(input().replace(' ',''))%4==0: print('YES') else: print('NO')
p03759
s146420690
Wrong Answer
a,b,c=map(int,input().split()) if abs(b-a)==abs(c-b): print('YES') else: print('NO')
p03001
s144272470
Accepted
def main(): W, H, x, y = map(int, input().split()) if x * 2 == W and y * 2 == H: print(W * H / 2, 1) exit() print(W * H / 2, 0) main()
p02829
s729931958
Accepted
print(6-int(input())-int(input()))
p02547
s696658173
Wrong Answer
N = int(input().strip()) a = [] c = [] f = 0 s="No" for i in range(N): array = list(map(int, input().strip().split())) a.append(array) for i in range(N): if(f == 0 or f == i-1): if(a[i][0] == a[i][1]): f+=1 else: if(f >=3): s="Yes" f=0 if(f >=3): s="Yes" if(s=="Yes"): print("Yes") else: print("No")
p02598
s179342599
Accepted
n, k = map(int, input().split()) A = list(map(int, input().split())) l = 1 r = 10**9+1 while l < r: mid = (l+r)//2 count = 0 for i in range(n): if A[i] > mid: count += A[i]//mid if count <= k: r = mid else: l = mid+1 print(l)
p02802
s892150487
Accepted
N, M = list(map(int, input().split())) PS = [input().split() for _ in range(M)] ps = [(int(p)-1, s) for p, s in PS] ac = [0]*N wa = [0]*N for p, s in ps: if s == "AC": ac[p] = 1 else: if ac[p] == 0: wa[p] += 1 print(sum(ac), sum([a*w for a, w in zip(ac, wa)]))
p03220
s107437191
Accepted
N=int(input()) T,A=map(int,input().split()) M=list(map(int,input().split())) S=[] for i in range(N): S.append(abs(T-M[i]*0.006-A)) print(S.index(min(S))+1)
p03612
s636074798
Accepted
n = int(input()) p = list(map(int, input().split())) ans = 0 for i in range(n-1): if p[i] == i+1: p[i],p[i+1] = p[i+1],p[i] ans += 1 if p[n-1] == n: ans += 1 # 順列最後の値を確認 print(ans)
p02724
s791662739
Accepted
X = int(input()) A = 0 B = 0 A = X - X % 500#A:500 A500 = A / 500 * 1000 #A5 = (X % 500) % 5 * 5 A5 = X % 500 - (X % 500) % 5#495 A5 = A5 / 5 * 5 A = int(A500) + int(A5) B = (X - X % 5) B = int(B / 5 * 5) print(int(max(A, B)))
p03351
s126304246
Accepted
a,b,c,d=map(int,input().split()) if abs(a-b)<=d and abs(b-c)<=d: print('Yes') elif abs(a-c)<=d: print('Yes') else: print('No')
p02697
s805690333
Accepted
N, M = map(int, input().split()) if N % 2: for a in range(1, M + 1): b = N - a print(a, b) else: even = min(N // 4, M) odd = M - even for a in range(1, 1 + even): b = N + 1 - a print(a, b) for a in range(even + 1, M + 1): b = N - a print(a, b)
p02933
s132008303
Accepted
a=int(input()) s=input() print(s if a >= 3200 else 'red')
p02796
s505784247
Accepted
n=int(input()) a=[] for i in range(n): x,l=map(int,input().split()) a.append((x+l,2*l)) a.sort() ans=1 x,l=a[0] for i in range(1,n): xx,ll=a[i] if x<=xx-ll: ans+=1 x,l=xx,ll print(ans)
p03565
s575719338
Accepted
#貪欲法(greedy) #ABC076C - Dubious Document 2 #https://atcoder.jp/contests/abc076/tasks/abc076_c ##自己考察 import sys s = list(input()) sl = len(s) t = list(input()) tl = len(t) for i in range(sl-tl,-1,-1): count = 0 for j in range(tl): if s[i+j] == "?" or s[i+j] == t[j]: count +=1 if count == tl: ans = (''.join((s[0:i] + t + s[i+tl:]))).replace("?","a") print(ans) sys.exit() print("UNRESTORABLE")
p02918
s747658559
Accepted
N,K = map(int,input().split()) S = input() h = 0 for i in range(len(S)-1): if S[i] == S[i+1]: h += 1 h += 2*K print(min(N-1, h))
p03962
s220526071
Accepted
L = set(map(int, input().split())) print(len(L))
p03455
s617970958
Accepted
a,b = map(int,input().split()) x = a*b if x % 2 == 0: print('Even') else: print('Odd')
p03427
s055838458
Wrong Answer
N = list(map(int,input())) ans = 0 ans1 = 0 if N[0] == 1: for i in range(len(N)-1): ans1 += 9 print(max(ans,ans1)) else: for i in range(len(N)): if i == 0: ans1 += N[i]-1 else: ans1 += 9 print(max(ans, ans1))
p03220
s325221179
Accepted
n = int(input()) # 入力が1つ t, a = map(int, input().split()) # 入力が複数 h = [int(i) for i in input().split()] # 配列で数字 ans = 0 nearest = abs(t - h[0] * 0.006 - a) for i in range(n): temp = abs(t - h[i] * 0.006 - a) if temp < nearest: nearest = temp ans = i print(ans + 1)
p03427
s686944951
Accepted
def main(): N = int(input()) if N < 10: print(N) elif str(N)[1:] == "9"*(len(str(N))-1): print(sum(list(map(int,list(str(N)))))) else: ans = sum([9]*(len(str(N))-1)) if int(str(N)[0]) >= 2: ans += int(str(N)[0])-1 print(ans) if __name__ == '__main__': main()
p03262
s947080546
Accepted
import fractions n,x=map(int,input().split()) a=list(map(int,input().split())) a[0]=abs(a[0]-x) g=a[0] for i in range(1,n): a[i]=abs(a[i]-x) g=fractions.gcd(g,a[i]) print(g)
p02602
s588909406
Accepted
from heapq import * import sys from collections import * from itertools import * from decimal import * import copy from bisect import * import math sys.setrecursionlimit(4100000) def gcd(a,b): if(a%b==0):return(b) return (gcd(b,a%b)) input=lambda :sys.stdin.readline().rstrip() N,K=map(int,input().split()) A=list(map(int,input().split())) for i in range(K,N): print("Yes" if A[i]>A[i-K] else "No")
p02718
s859870217
Wrong Answer
N, M=input().split() A=list(map(int,input().strip().split())) ls=[] for Ai in A: if int(Ai)>(1/(4*int(M)))*sum(A): ls.append(Ai) if len(ls)>int(M): print('Yes') else: print('No')
p03986
s889224774
Accepted
def main(): s = input().rstrip() t = [-1]*len(s) for i in range(len(s)): if s[i] == "T": t[i] = 1 for i in range(1, len(s)): t[i] += t[i-1] print(2*max(t)) if __name__ == "__main__": main()
p03285
s946743385
Accepted
n = int(input()) c = 0 d = 0 for i in range(100): for j in range(100): if i*4 + j*7 == n: print("Yes") exit() print("No")
p02695
s253471184
Accepted
import itertools N, M, Q = map(int, input().split()) comb = list(itertools.combinations_with_replacement(range(1,M+1), N)) ans = [0]*len(comb) if ans == []: print(0) else: for i in range(Q): a,b,c,d = map(int, input().split()) for j in range(len(comb)): if comb[j][b-1] - comb[j][a-1] == c: ans[j] += d print(max(ans))
p02720
s013869221
Accepted
from collections import deque n = int(input()) q = deque(range(1, 10)) for _ in range(n - 1): x = q.popleft() r = x % 10 y = 10 * x if r == 0: q.extend([y, y+1]) elif r == 9: q.extend([y+8, y+9]) else: q.extend([y+r-1, y+r, y+r+1]) print(q.popleft())
p03107
s651359647
Accepted
S = list(input()) ans = min(S.count("1"), S.count("0")) print(ans*2)
p04012
s499691593
Accepted
w=list(input()) w.sort() tmp=w[0] cnt=1 flag=0 if len(w)%2==1: print("No") exit() for i in range(1,len(w)): if tmp==w[i]: cnt+=1 else: if cnt%2==0: tmp=w[i] cnt=1 else: flag=1 print("No") break if flag==0: print("Yes")
p02917
s242689062
Wrong Answer
N=int(input()) B=list(map(int,input().split())) S=0 for i in range(1,N-1): S+=min(B[i],B[i-1]) S+=min(B[0],B[-1])+B[-1] print(S)
p03328
s444294847
Accepted
a, b = map(int, input().split()) ans = 0 ans1 = 0 for i in range(1, 1000): ans += i ans1 += i-1 if(ans-ans1 == b-a): print(ans-b) break
p03944
s961355316
Wrong Answer
import sys input = sys.stdin.readline w,h,n=map(int,input().split()) x1=0 x2=w y1=0 y2=h for i in range(n): x,y,a=map(int,input().split()) if a==1: x1=max(x1,x) if a==2: x2=max(x2,x) if a==3: y1=max(y1,y) if a==2: y2=max(y2,y) print(max((x2-x1)*(y2-y1),0))
p03486
s184201710
Wrong Answer
import sys sys.setrecursionlimit(4100000) import math INF = 10**9 def main(): s = input() t = input() s_list = sorted(s) t_list = sorted(t, reverse=True) S = ''.join(s_list) T = ''.join(t_list) print(S < T) if __name__ == '__main__': main()
p03274
s876068404
Accepted
N, K = map(int, input().split()) arr = list(map(int, input().split())) ans =[] if arr[0]>0: ans.append(arr[K-1]) if arr[-1]<0: ans.append(abs(arr[-1*(K)])) for i in range(N-K+1): if arr[i]*arr[i+K-1]<=0: left =2*abs(arr[i])+abs(arr[i+K-1]) right=2*abs(arr[i+K-1])+abs(arr[i]) ans.append(min(left,right)) print(min(ans))
p03672
s695359850
Wrong Answer
s=input() num=len(s) for i in range(1,len(s)): s=s[:-1] a=s[:int(len(s)/2)] b=s[int(len(s)/2):] if a==b: num=min(num,len(s)) print(num)
p02819
s637673912
Accepted
x = int(input()) import math def sosu(x): for i in range(2, math.floor(x**0.5)): if x%i ==0: return True return False while sosu(x): x +=1 print(x)
p03106
s872057948
Wrong Answer
A, B, K = map(int, input().split()) c = 0 for i in range(1, min(A,B) + 1): if A % i == 0 and B % i == 0: c += 1 if c == K: ans = i print(ans)