problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02773
s179951447
Accepted
N = int(input()) dic = {} m = 1 for i in range(N): st = input() if st not in dic: dic[st] = 1 else: dic[st] += 1 if dic[st] > m: m = dic[st] ans = [] for s in dic: if dic[s] == m: ans.append(s) ans.sort() for i in range(len(ans)): print(ans[i])
p02732
s841085929
Accepted
n = int(input()) a = list(map(int,input().split())) l = [0 for i in range(n+1)] ans = 0 for i in range(n): l[a[i]] += 1 for i in range(n+1): ans += (l[i]*(l[i]-1))//2 al = [] for i in range(n): a0 = ans - (l[a[i]]*(l[a[i]]-1))//2 + ((l[a[i]]-1)*(l[a[i]]-2)//2) al.append(a0) for i in al: print(i)
p04011
s838285868
Accepted
n = int(input()) k = int(input()) x = int(input()) y = int(input()) print(min(n,k)*x+max((n-k),0)*y)
p03059
s302696976
Accepted
def main(): s, b, e = [int(x) for x in input().split()] e += 0.5 levas = e // s print(int(levas*b)) main()
p03478
s803707122
Accepted
N, A, B = map(int, input().split()) ans = 0 for i in range(1, N+1): sum = 0 k = i while k > 0: sum = sum + k % 10 k = k // 10 if A <= sum <= B: ans = ans + i print(ans)
p02594
s903191546
Accepted
def resolve(): X = int(input()) if X>=30: print('Yes') else: print('No') resolve()
p04033
s509705716
Accepted
# A a,b =map(int,input().split()) if 0 < a and 0 < b: print("Positive") elif (a == 0 or b == 0) or (a < 0 and 0 < b): print("Zero") else: if (a-b)%2 == 0: print("Negative") else: print("Positive")
p02727
s907084014
Accepted
X, Y, A, B, C = map(int, input().split()) p = sorted(list(map(int, input().split())), reverse=True)[:X] q = sorted(list(map(int, input().split())), reverse=True)[:Y] r = sorted(list(map(int, input().split())), reverse=True)[:X+Y] pqr = sorted(p+q+r, reverse=True) print(sum(pqr[:X+Y]))
p02624
s447600807
Wrong Answer
N = int(input()) m = [0] * (N+1) for i in range(1, N): temp = i for k in range(temp, N+1, i): m[k] += 1 ans = 0 for n in range(1, N+1): ans += n*m[n] print(ans)
p03799
s346791700
Accepted
n, m = map(int, input().split()) ans = 0 if 2 * n <= m: m -= n * 2 ans += n ans += m // 4 else: ans += m // 2 print(ans)
p03011
s519725701
Accepted
p,q,r=map(int,input().split()) print(min(p+q,p+r,q+r))
p02783
s777758236
Wrong Answer
H, A = map(int, input().split()) if H%A==0: print(H/A) else: print((H//A)+1)
p03860
s398830471
Accepted
word=input().split() print(word[0][0]+word[1][0]+word[2][0])
p03377
s936361467
Accepted
a,b,x = map(int, input().split()) if a <= x and x <= a+b: print('YES') else: print('NO')
p02714
s559335917
Wrong Answer
N = int(input()) S = list(input()) Rcnt = 0 Gcnt = 0 excep = 0 for i in range(len(S)): if S[i] == 'R': Rcnt += 1 elif S[i] == 'G': Gcnt += 1 for j in range(1, (len(S)//2)): if i+j+j < len(S) and S[i] != S[i+j]: if S[i] != S[i+j+j] and S[i+j] != S[i+j+j]: excep += 1 RGBcalc = Rcnt * Gcnt * (N - Rcnt - Gcnt) print(RGBcalc - excep)
p02693
s007264594
Accepted
def main(): k = int(input()) a,b = map(int,input().split()) answer = "NG" for i in range(a,b+1): if i % k == 0: answer = "OK" break print(answer) if __name__ == '__main__': main()
p02873
s514184814
Accepted
S = list(input()) value = [0] * (len(S) + 1) for i in range(len(S)): if S[i] == '<': if value[i] == 0: value[i+1] = 1 else: value[i+1] = value[i] + 1 for i in reversed(range(len(S))): if S[i] == '>': if value[i+1] == 0 and value[i] == 0: value[i] = 1 elif value[i] <= value[i+1]: value[i] = value[i+1] + 1 print(sum(value))
p03038
s613068390
Accepted
n,m=map(int,input().split()) a=list(map(int,input().split())) a.sort() num=[] for i in range(m): num.append(list(map(int,input().split()))) num.sort(reverse=True,key=lambda x: x[1]) cnt=0 for i in range(n): if cnt==m: break if num[cnt][0]==0: cnt+=1 if cnt==m: break if a[i]>=num[cnt][1]: break a[i]=num[cnt][1] num[cnt][0]-=1 print(sum(a))
p03494
s631777771
Accepted
n=int(input()) a=list(map(int,input().split())) ans=0 while True: for i in range(n): if a[i]%2!=0: print(ans) exit() a[i]//=2 ans+=1
p03433
s345250355
Accepted
N = int(input()) A = int(input()) if N%500 > A: print('No') else: print('Yes')
p03493
s736108361
Wrong Answer
import numpy as np A = list(map(int,input().split())) count = 0 while all(a % 2 == 0 for a in A): A = [a/2 for a in A] count += 1 print(count)
p02678
s950013696
Wrong Answer
import networkx as nx room, route_count = map(int,input().split()) G = nx.Graph() G.add_nodes_from(range(1,room+1)) G.add_edges_from([list(map(int,input().split())) for _ in range(route_count)]) is_end = False for i in range(2, room+1): if ~nx.has_path(G,source=i, target=1): is_end = True break if is_end: print('No') else: print('Yes') shortest_path_dict = nx.single_target_shortest_path(G, target=1) for i in range(2,room+1): print(shortest_path_dict[i][1])
p03106
s797678111
Wrong Answer
a,b,k = map(int,input().split()) cnt = 0 for i in range(1,a*b*k): if i%a==0 and i%b==0: cnt+=1 if(cnt==k): print(i) exit()
p03767
s458703230
Wrong Answer
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) s = 0 for x in range(n, 2*n): s += a[x] print(s)
p02658
s485609809
Wrong Answer
import sys def input(): return sys.stdin.readline().strip() def main(): n = int(input()) A = list(map(int, input().split())) x = 1 for i in A: x *= i if x > 10**18: x = -1 return print(x) if __name__ == "__main__": main()
p03457
s739297589
Accepted
n = int(input()) data = [] data.append([0, 0, 0]) for i in range(n): t, x, y = map(int, input().split()) data.append([t, x, y]) for i in range(1, n + 1): dis = abs(data[i][1] - data[i - 1][1]) + abs(data[i][2] - data[i- 1][2]) dif = data[i][0] - data[i - 1][0] if (dif % 2 != dis % 2 or dis > dif): print("No") exit() print("Yes")
p03623
s277857551
Accepted
x, a, b = list(map(int, input().split())) print('A' if abs(x - a) < abs(x - b) else 'B')
p02647
s246263374
Accepted
n,k=map(int,input().split()) A=list(map(int,input().split())) def culc(L): subL=[0]*(n+1) for i in range(n): temp=L[i] bottom=max(i-temp,0) top=min(i+temp,n-1) subL[bottom]+=1 subL[top+1]-=1 resL=[0]*n resL[0]=subL[0] for i in range(1,n): resL[i]=resL[i-1]+subL[i] return resL for i in range(min(k,41)): A=culc(A) print(*A)
p02663
s443737164
Accepted
h, m, h2, m2, k = map(int, input().split()) i = h2 * 60 + m2 - (h * 60 + m) print(i-k)
p03485
s232238403
Wrong Answer
a, b = map(int, input().split()) c = int((a + b) / 2) print(c + 1)
p02787
s980542477
Accepted
import sys def input(): return sys.stdin.buffer.readline()[:-1] h, n = map(int, input().split()) spells = [list(map(int, input().split())) for _ in range(n)] dp = [10** 30 for _ in range(h+1)] dp[0] = 0 for a, b in spells: for i in range(h): dp[min(i+a, h)] = min(dp[min(i+a, h)], dp[i]+b) print(dp[h])
p03379
s932098496
Accepted
from copy import copy n, *x = map(int, open(0).read().split()) a = [] for i, v in enumerate(x): a.append((v, i)) a.sort() # a[(i - 1)/ /2] , a[i // 2] ans = [0] * n for i in range(n): if i <= (n - 1) // 2: ans[a[i][1]] = a[n // 2][0] else: ans[a[i][1]] = a[(n - 1) // 2][0] for y in ans: print(y)
p02838
s074426295
Accepted
N=int(input()) A=[format(i,'060b') for i in map(int,input().split())] ans=0 mod=10**9+7 for k in range(60): count=[a[60-1-k] for a in A].count('0') ans+=count*(N-count)*(2**k)%mod print(ans%mod)
p02939
s822608030
Wrong Answer
s = input() memo = s[0] len_s = len(s) cnt = 0 ans = 0 for i in range(2 * 10 ** 5): ans += 1 if memo == s[cnt]: memo = s[cnt:cnt + 2] cnt += 2 else: memo = s[cnt] cnt += 1 if cnt > len_s - 1: break print(ans)
p03545
s677080537
Wrong Answer
S = input() A = int(S[0]) B = int(S[1]) C = int(S[2]) D = int(S[3]) if A + B + C + D == 7 or A - B - C - D == 7 or A + B + C - D == 7 or A - B + C + D == 7 or A - B - C + D == 7 or A - B + C - D == 7 or A + B - C + D == 7: print('YES')
p03137
s052270791
Wrong Answer
n, m = map(int, input().split()) x = list(map(int, input().split())) if n >= m: print(0) exit() x.sort() d = [x[i+1] - x[i] for i in range(m-1)] d.sort() print(sum(d[:-n+1]))
p02888
s669786546
Accepted
import bisect N = int(input()) L = list(map(int, input().split())) L.sort() ans = 0 for i in range(N - 2): for j in range(i + 1, N - 1): ans += bisect.bisect_left(L, L[i] + L[j]) - j - 1 print(ans)
p03126
s237963531
Accepted
n,m = map(int, input().split(' ')) List = [i+1 for i in range(m)] i = 0 while i < n: k_list = list(map(int, input().split(' '))) lcopy = List[:] for l in lcopy: if l not in k_list[1:]: List.remove(l) #print(l,List) i += 1 print(len(List))
p03241
s510384349
Accepted
n,m = map(int,input().split()) max_cnd = m//n for i in range(max_cnd): if m % (max_cnd-i) == 0: print(max_cnd-i) exit()
p02987
s591389519
Accepted
# -*- coding: utf-8 -*- s = input() cnt = {l:0 for l in set(s)} if len(cnt) != 2: print('No') exit(0) for l in s: cnt[l] += 1 if cnt[l] > 2: print('No') exit(0) print('Yes')
p03380
s204254144
Accepted
from math import factorial N = int(input()) A = list(map(int,input().split())) t, j = float("INF"), -1 max_A = max(A) A.remove(max_A) for i in range(N-1): if abs(max_A//2 - A[i]) < t: t = abs(max_A//2 - A[i]) j = i print(max_A, A[j])
p03543
s886285185
Wrong Answer
n = input() count = 0 tmp = '' for i in n: if tmp == '' or count == 0: tmp = i elif count == 3: break if tmp == i: count += 1 else: tmp = i if count >= 3: print('Yes') else: print('No')
p04005
s755353218
Accepted
a,b,c = map(int,input().split()) if a%2 == 0 or b%2 == 0 or c%2 == 0: print(0) else: print(min(a*b,a*c,b*c))
p02691
s162912857
Wrong Answer
n = int(input()) a = list(map(int,input().split())) l=dict() r=dict() for i in range(n): if a[i]-i-1 in l: l[a[i]-i-1]+=1 else: l[a[i]-i-1]=1 if a[i]+i+1 in r: r[-a[i]-i-1]+=1 else: r[-a[i]-i-1]=1 res=0 for (key,item) in l.items(): res+=item*r.get(key,0) print(res)
p03150
s782767060
Accepted
S=input() ans='NO' if S.find('k')==0 and S.rfind('eyence')==len(S)-6: ans='YES' elif S.find('ke')==0 and S.rfind('yence')==len(S)-5: ans='YES' elif S.find('key')==0 and S.rfind('ence')==len(S)-4: ans='YES' elif S.find('keye')==0 and S.rfind('nce')==len(S)-3: ans='YES' elif S.find('keyen')==0 and S.rfind('ce')==len(S)-2: ans='YES' elif S.find('keyenc')==0 and S.rfind('e')==len(S)-1: ans='YES' print(ans)
p02548
s284239699
Wrong Answer
N = int(input()) ans = 0 for a in range(1, N + 1): for b in range(1, N + 1): if a * b <= N: ans += 1 print(ans)
p03456
s147871613
Accepted
import math ab=int(input().replace(' ','')) x = 1 xx = x*x flag = False while(xx < ab): xx = x*x if xx == ab: flag=True break x += 1 if flag==True: print('Yes') else: print('No')
p02765
s264577305
Wrong Answer
a,b = map(int, input().split()) if a < 10: print(b-100*(10-a)) else: print(b)
p02973
s350970493
Accepted
import sys from bisect import bisect_right as bi_r inf = float('inf') n, *A = map(int, sys.stdin.read().split()) def main(): res = [inf] * n for a in A[::-1]: i = bi_r(res, a) res[i] = a for i in range(n): if res[i] == inf: return i return n if __name__ == '__main__': ans = main() print(ans)
p03351
s642524142
Accepted
a,b,c,d=map(int,input().split()) if (abs(b-a)<=d and abs(c-b)<=d) or abs(a-c)<=d:print("Yes") else:print("No")
p02547
s338207512
Wrong Answer
a = [] for i in range(int(input())): a.append(input().split()) triplets = 0 for i in a: if(i[0] == i[1]): triplets += 1 else: triplets = 0 print('Yes' if triplets >= 3 else 'No')
p03289
s747729069
Accepted
S = input() ans = 'WA' if S[0] == 'A' and S[2:-1].count('C') == 1: if S[1:].replace('C', '').islower(): ans = 'AC' print(ans)
p03281
s294515015
Accepted
print(sum(1 for i in range(1, int(input()) + 1) if i % 2 == 1 and sum(1 for j in range(1, i + 1) if i % j == 0) == 8))
p03069
s620789090
Wrong Answer
import numpy as np n = int(input()) s = np.array([1 if i == '#' else 0 for i in input()]) black = np.count_nonzero(s) print(min(black,n-black))
p02724
s418485359
Wrong Answer
x=int(input()) a=500 b=5 if x>=500: num=(x//500*1000)+(x-x//500*500)//500 print(num) else: num=x//5 print(num)
p02832
s007520762
Wrong Answer
n = int(input()) a_list = list(map(int, input().split())) if a_list == list(range(1, len(a_list) + 1)): print(0) cond_idx = 0 for num in range(1, len(a_list)): if num == 1: if num not in a_list: print(-1) break if num in a_list[cond_idx:]: cond_idx = a_list[cond_idx:].index(num) # print(num, cond_idx) else: print(n - num + 1) break
p03779
s981807649
Accepted
import math X = int(input()) ans = math.ceil((-1+math.sqrt(1+8*X))/2) print(ans)
p03328
s919240723
Wrong Answer
a,b=map(int,input().split()) A=[] for i in range(1,1000): A.append((i*(i+1))//2) for j in range(5*(10**6)): if ((a+j) in A) and ((b+j) in A): print(j) exit()
p03131
s148314598
Wrong Answer
K, A, B = map(int, input().split()) if B - A <= 2 : print(K + 1) elif K < A + 1: print(K + 1) elif K == A + 1: print(B) else : count = K - (A + 1) if count % 2 == 1: ans = count // 2 * (B - A) + B else: ans = count//2 * (B - A) + B + 1 print(ans)
p03645
s723149813
Wrong Answer
n,m = map(int,input().split()) fr = {} t = {} for i in range(m): a,b = map(int,input().split()) if a == 1: fr[b] = 1 if b == n: t[a] = 1 flag = False for kk in t.keys(): if kk in fr: flag = True break if flag: print("POSSIBLE") else: print("IMPOSSIBLE")
p03127
s075172925
Accepted
N=int(input()) A=list(map(int,input().split())) while True: m=min(A) A=[i%m for i in A] A.append(m) A=[i for i in A if i!= 0] if len(A)==1: break print(max(A))
p03478
s395666859
Accepted
n, a, b = map(int, input().split()) ans = 0 for i in range(1, n + 1): val = 0 for c in str(i): val += int(c) if a <= val <= b: ans += i print(ans)
p03385
s443620797
Accepted
print("Yes" if len(set(input()))==3 else "No")
p03767
s200224663
Accepted
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(input()) A = sorted(list(map(int, input().split()))) res = 0 for i in range(n): res += A[-(i + 1) * 2] print(res) if __name__ == '__main__': resolve()
p03481
s052952660
Wrong Answer
# For taking integer inputs. import math from decimal import Decimal def inp(): return(int(input())) # For taking List inputs. def inlist(): return(list(map(int, input().split()))) # For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable. def instr(): s = input() return(list(s[:len(s)])) # For taking space seperated integer variable inputs. def invr(): return(map(Decimal, input().split())) x, y = invr() a = y // x res = (math.log(a) / math.log(2)) + 1 print(int(res))
p02647
s831157863
Wrong Answer
input1 = list(map(int, input().split())) A = list(map(int, input().split())) N = input1[0] K = input1[1] for k in range(K): B = [0] * N for i in range(1, N + 1): l_min = i - A[i - 1] - 0.5 l_max = i + A[i - 1] + 0.5 for j in range(1, N + 1): if(j >= l_min and j <= l_max): B[j - 1] += 1 for x in range(N): A[x] = B[x] print(A)
p03612
s124055407
Accepted
n = int(input()) p = list(map(int, input().split())) l = [] cnt = 0 for i in range(n): if p[i] == i + 1: cnt += 1 else: if cnt > 0: l.append(cnt) cnt = 0 if cnt > 0: l.append(cnt) cnt = 0 res = 0 for v in l: res += (v + 1) // 2 print(res)
p02732
s429691929
Accepted
def parm(a): return(int(a*(a-1)/2)) n=int(input()) a=list(input().split()) dic={} ans=[0]*n sumans=0 for i in range(n): if a[i] in dic.keys(): dic[a[i]]+=1 else: dic[a[i]]=1 for i in dic.values(): sumans+=parm(i) for i in range(n): print(sumans-parm(dic[a[i]])+parm(dic[a[i]]-1))
p02603
s738731435
Accepted
N = int(input()) A = list(map(int, input().split())) money = 1000 stock = 0 for i in range(N): if i == N - 1: money += stock * A[i] break if A[i] < A[i + 1]: buy_stock = money // A[i] money -= A[i] * buy_stock stock += buy_stock elif A[i] > A[i + 1]: money += A[i] * stock stock = 0 print(money)
p03385
s389064981
Accepted
if len(set(input())) == 3: print('Yes') else: print('No')
p03073
s809014981
Wrong Answer
s = list(map(int,input())) count1 = 0 count2 = 0 if len(s) == 1: print(0) else: for i in range(len(s)): if i % 2 == 0 and s[i] != 0: count1 += 1 elif i%2 !=0 and s[i] != 1: count1 += 1 for i in range(len(s)): if i % 2 == 0 and s[i] != 2: count2 += 1 elif i%2 !=0 and s[i] != 0: count2 += 1 print(min(count1,count2))
p03380
s314531232
Wrong Answer
n=int(input()) a=list(map(int,input().split())) i=max(a) r=int((i+1)/2) if n==2: print(max(a),min(a)) exit() if a.count(r)>0: print(i,r) exit() a.append(r) a.sort() whe=a.index(r) hi=a[whe+1] lo=a[whe-1] if abs(hi-r)>=abs(lo-r): print(i,hi) else: print(i,lo)
p03696
s783795451
Accepted
from collections import deque n = int(input()) s = input() l, que = 0, deque([]) for i in s: que.append(i) if i == '(': l += 1 elif i == ')': if l == 0: que.appendleft('(') l += 1 l -= 1 print(*que, ')' * l, sep='')
p02818
s323623528
Accepted
A, B, K = map(int, input().split()) if A >= K: A = A - K else: B = B - (K - A) A = 0 if B < 0: B = 0 print(str(A) + " " + str(B))
p03611
s357136641
Accepted
# https://atcoder.jp/contests/abc072/tasks/arc082_a from collections import defaultdict n = int(input()) nums = [int(i) for i in input().split()] c = defaultdict(int) for num in nums: c[num - 1] += 1 c[num] += 1 c[num + 1] += 1 ans = 0 for v in c.values(): ans = max(ans, v) print(ans)
p03774
s987137283
Accepted
def main(): n, m = map(int, input().split()) A, X = [], [] for _ in range(n): A.append(list(map(int, input().split()))) for _ in range(m): X.append(list(map(int, input().split()))) for a, b in A: ans, dist = 0, 10e+10 for i, (x, y) in enumerate(X): if (d := abs(x - a) + abs(y - b)) < dist: dist = d ans = i + 1 print(ans) if __name__ == '__main__': main()
p03017
s798659464
Accepted
n, a, b, c, d = map(int, input().split()) s = '_' + input() if s[c] == '#' or s[d] == '#': print('No') exit() # '##'を検知 if '##' in s[a:c+1] or '##' in s[b:d+1]: print('No') exit() if c > d: # 3 マス以上の連続する'.'が必要 num_dot = s[b-1:d+2].count("...") if num_dot == 0: print('No') exit() print('Yes')
p03548
s910546096
Wrong Answer
x,y,z = map(int,input().split()) ans = int(x/(y+z)) if x%(y+z) < z: ans -= 1 print(ans,x%(y+z))
p02983
s181617032
Wrong Answer
import sys l,r = map(int,input().split()) l=l%2019 r=r%2019 if l>=r or l+2019 <= r: print(0) sys.exit() ans=2018 for i in range(l,r): if ans == 0: break for j in range(i+1,r+1): ans = min(ans,i*j%2019) if ans == 0: break print(ans)
p02833
s200862161
Accepted
n = int(input()) if(n % 2 == 1):print(0) else: x = 0 i = 0 while(n//(10*5**i) > 0): x += n//(10*5**i) i += 1 print(x)
p02660
s306765928
Wrong Answer
n = int(input()) 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 = prime_factorize(n) from collections import Counter c = Counter(a) ans = 0 for i in c: ans += -(-c[i]//2) print(ans)
p03785
s821111621
Accepted
N,C,K=map(int,input().split(' ')) T=sorted([int(input()) for i in range(N)]) pas = 1 last_bus=T[0]+K ans = 1 for i in T[1:]: if i <= last_bus and pas < C: pas += 1 else: ans += 1 pas = 1 last_bus = i+K print(ans)
p03289
s688811383
Wrong Answer
S = input() ans = "WA" if S[0] != "A": ans = "WA" print(ans) else: if S[1:len(S) - 1].count("C") != 1: print(ans) else: s = S.index("C") SS = S[1:s] + S[s + 1:] if SS.islower() == False: print(ans) else: print("AC")
p04034
s549682059
Accepted
N,M = list(map(int,input().split())) XY = [list(map(int,input().split())) for _ in range(M)] L1 = [1]*N L2 = [0]*N L2[0] = 1 for xy in XY: if L2[xy[0]-1] == 1: L2[xy[1]-1] = 1 L1[xy[0]-1] -= 1 L1[xy[1]-1] += 1 if L1[xy[0]-1] == 0: L2[xy[0]-1] = 0 print(sum(L2))
p03860
s518818221
Wrong Answer
s = input().split(' ') print('A' + s[0] + 'C')
p03639
s259622364
Accepted
N,*A=map(int,open(0).read().split()) x4 = 0 x2 = 0 x1 = 0 for i in range(N): if A[i]%4 == 0: x4+=1 elif A[i]%2 == 0: x2+=1 else: x1 +=1 if x1 +min(1,x2)<= x4+1: print("Yes") else: print("No")
p02556
s687346351
Accepted
import sys input = sys.stdin.readline N=int(input()) P=[tuple(map(int,input().split())) for i in range(N)] PLUS=[] MINUS=[] for x,y in P: PLUS.append(x+y) MINUS.append(x-y) PLUS.sort() MINUS.sort() print(max(PLUS[-1]-PLUS[0],MINUS[-1]-MINUS[0]))
p02862
s356449918
Wrong Answer
X, Y = map(int, input().split()) x, y = (X*2-Y)//3, (Y*2-X)//3 mod = 10**9+7 n = min(x, y) factorial = [1] for i in range(1, n+1): factorial.append((factorial[i-1]*i)%mod) p_list = [(x+y)%mod] for i in range(1, n+1): p_list.append((p_list[i-1]*(x+y-i))%mod) if (X+Y)%3 != 0: print (0) elif X*2-Y < 0 or Y*2-X < 0: print (0) else: print (p_list[n-1]*pow(factorial[n], 10**9+5, mod)%mod)
p03351
s678687151
Accepted
a, b, c, d = map(int, input().split()) if abs(c-a) <= d: print('Yes') elif abs(b-a) <= d and abs(c-b) <= d: print('Yes') else: print('No')
p02951
s679493566
Wrong Answer
a, b, c = map(int, input().split()) print(float(c-a-b))
p03067
s519165397
Wrong Answer
a, b, c = map(int,input().split()) if a < c < b: print("Yes") else: print("No")
p02854
s611198549
Accepted
N=int(input()) A=list(map(int,input().split())) x=sum(A) y=10**19 a=0 for i in range(N): a+=A[i] if y>abs(x-2*a):#2区間の差 y=abs(x-2*a) else: break print(y)
p04011
s117781473
Accepted
import sys def input(): return sys.stdin.readline().strip() def main(): n = int(input()) k = int(input()) x = int(input()) y = int(input()) if n <= k: print(x * n) else: print(x * k + (n - k) * y) if __name__ == "__main__": main()
p03986
s767075364
Accepted
if __name__ == "__main__": x = input() count = 0 ans = len(x) for i in range(len(x)): if x[i] == 'S': count += 1 elif count > 0 and x[i] == 'T': ans -= 2 count -= 1 else: count = 0 print(ans)
p02952
s283478720
Accepted
def odd(x): if (x-1)%2 == 0: return True else: return False N = input() index, num = len(N), int(N) ans = 0 for i in range(1, index+1): if odd(i): if num >= 10**i: ans = ans + (10**i - 10**(i-1)) else: ans = ans + (num - 10**(i-1) + 1) print(ans)
p03127
s806309146
Accepted
import fractions n = int(input()) a_list = sorted(list(map(int,input().split()))) a = a_list[0] for i in range(1,n): a = fractions.gcd(a,a_list[i]) print(a)
p03262
s890634136
Accepted
import math N,X = list(map(int,input().split())) x = list(map(int,input().split())) arr = [0]*N for i in range(N): arr[i] = abs(x[i]-X) ans = arr[0] for i in range(1,N): ans = math.gcd(ans, arr[i]) print(ans)
p03494
s791945442
Accepted
n = int(input()) a = list(map(int, input().split())) cnt = 0 while True: if sum([a[i]%2 for i in range(n)]) == 0: a = [int(n/2) for n in a] cnt += 1 else: break print(cnt)
p02947
s036348067
Accepted
n=int(input()) a=[] for i in range(n): b=input() b=sorted(b) b=' '.join(b) b=b.replace(" ","") a.append(b) import collections c=collections.Counter(a) c=list(c.values()) ans=0 import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) for i in c: if i>=2: ans+=combinations_count(i,2) print(ans)
p03711
s725692160
Accepted
x, y = map(int, input().split()) g1 = [1, 3, 5, 7, 8, 10, 12] g2 = [4, 6, 9, 11] if x == 2 and y == 2: print("Yes") elif x in g1 and y in g1: print("Yes") elif x in g2 and y in g2: print("Yes") else: print("No")