problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02612
s627365749
Accepted
N=int(input()) ma=-(-N//1000) NN=ma*1000-N print(NN)
p03427
s407741134
Accepted
n = input() l = list(n[1:]) if all(i == "9" for i in l): print(int(n[0]) + 9 * (len(n) - 1)) else: print(int(n[0]) - 1 + 9 * (len(n) - 1))
p02989
s164023509
Accepted
N = int(input()) d = sorted(map(int, input().split())) print(d[N // 2] - d[N // 2 - 1])
p02729
s642648374
Wrong Answer
S=list(input()) countA=0 countB=0 for i in range(3): if S[i]=="A": countA+=1 else: countB+=1 if countA!=0 and countB!=0: print("Yes") else: print("No")
p03013
s261728100
Accepted
N, M = map(int, input().split()) A = [int(input()) for _ in range(M)] q = 1000000007 if N == 1: if M == 0: print(1) elif M == 1: print(0) else: cost = [0 for _ in range(N + 1)] cost[0] = 1 cnt = 0 A.append([0]) for i in range(1, N + 1): if i == A[cnt]: cost[i] = 0 cnt += 1 else: cost[i] = (cost[i - 1] + cost[i - 2]) % q print(cost[-1])
p04019
s639664661
Accepted
from collections import Counter S = list(input()) c = Counter(S) ans = True if (c["N"]> 0 and c["S"] == 0) or (c["N"]== 0 and c["S"] > 0) or (c["W"] > 0 and c["E"] == 0) or (c["W"] == 0 and c["E"] > 0): ans = False if ans: print("Yes") else: print("No")
p04029
s339809279
Accepted
num = int(input()) wa = 0 for i in range(num): wa += i+1 print(wa)
p03796
s635047996
Accepted
import math n=int(input()) s=math.factorial(n) ans=s%(10**9+7) print(ans)
p03760
s236793770
Wrong Answer
o = input() e = input() ans = [] for t, v in zip(o,e): ans.append(t) ans.append(v) print("".join(ans))
p03013
s410938504
Accepted
n,m = map(int,input().split()) A = set([int(input()) for i in range(m)]) mod = 10**9+7 dp = [0]*(n+2) dp[1]=1 for i in range(2,n+2): if i-1 not in A: dp[i]=dp[i-1]%mod+dp[i-2]%mod print(dp[n+1]%mod)
p02773
s447268590
Wrong Answer
from collections import Counter N = int(input()) S = Counter(sorted([input() for _ in range(N)])) max_app = max(S.values()) for k, v in S.items(): if v == max_app: print(k)
p02711
s120758148
Accepted
N = input() f = False for i in N: if i == '7': f = True break if f: print("Yes") else: print("No")
p04011
s593483707
Accepted
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) if N<=K: print(X*N) else: S = N-K print(X*K+Y*S)
p03719
s591081911
Accepted
x = input().split() a = int(x[0]) b = int(x[1]) c = int(x[2]) if c >= a and c <= b: print('Yes') else: print('No')
p02910
s615651077
Accepted
S = list(input()) a = S[::2] b = S[1::2] if 'L' in a or 'R' in b: print('No') else: print('Yes')
p02603
s057543872
Wrong Answer
n = int(input()) a = list(map(int,input().split())) cash = 1000 stock = 0 for i in range(n-1): if(a[i] > a[i+1]): cash += stock * a[i] stock = 0 elif(a[i] < a[i+1]): stock = cash // a[i] cash %= a[i] cash += stock * a[n-1] print(cash)
p02583
s463605932
Accepted
from itertools import combinations N = int(input()) L = sorted(map(int, input().split())) ans = 0 for a, b, c in combinations(L, 3): if a < b < c and a + b > c: ans += 1 print(ans)
p02994
s350049653
Accepted
N, L = map(int, input().split()) ans = 0 min = L for i in range(1, N+1): a = L+i-1 ans += a if abs(a) < abs(min): min = a ans -= min print(ans)
p03264
s812279578
Accepted
k = int(input()) cont_even = 0 cont_odd = 0 for _ in range(2, k+1, 2): cont_even += 1 for _ in range(1, k+1, 2): cont_odd += 1 print(cont_even * cont_odd)
p03759
s477139878
Accepted
a,b,c=map(int,input().split()) if b-a==c-b: print('YES') else: print('NO')
p02801
s781024753
Accepted
#A c = input() print(chr(ord(c)+1))
p02578
s640586095
Accepted
#template def inputlist(): return [int(j) for j in input().split()] #template N = int(input()) A = inputlist() maxa = A[0] ans= 0 for i in range(1,N): if A[i] < maxa: ans += maxa - A[i] else: maxa = A[i] print(ans)
p02796
s948883968
Wrong Answer
import sys input = sys.stdin.readline def main(): N = int( input()) X = [] for _ in range(N): x, l = map( int, input().split()) X.append((x-l+1, x+l-1)) X.sort(reverse=True) ans = 0 now = 10**10 for i in range( N): a, b = X[i] if b <= now: now = a ans += 1 print(ans) if __name__ == '__main__': main()
p02786
s027713930
Accepted
h = int(input()) ans = 0 x = 0 while h!=1: ans = ans + 2**x x += 1 h = h//2 print(2**x + ans)
p03043
s032645277
Wrong Answer
# import fractions # import sys import math from sys import stdin n, k = map(int, stdin.readline().rstrip().split()) ans = 0 for i in range(1, n + 1): if k / i <= 1: ans += (1 / n) else: # tmp = 0 # for j in range(k // i + 1): # if 2 ** j > k // i: # tmp = j # break # print(int(math.log2(k / i)) + 1, tmp) ans += (1 / n) * (1 / 2) ** (int(math.log2(k // i)) + 1) print(ans)
p03254
s693312145
Accepted
def main(): N, x = map(int, input().split()) a = sorted(map(int, input().split())) cnt = 0 for i in range(N): if a[i] <= x: cnt += 1 x -= a[i] else: break if cnt == N and x > 0: cnt -= 1 print(cnt) if __name__ == "__main__": main()
p03075
s079598715
Accepted
a=[int(input())for _ in range(5)] k=int(input()) if a[4]-a[0]<=k:print("Yay!") else:print(":(")
p02707
s378813743
Wrong Answer
n=int(input()) a=[int(x) for x in input().split()] for c in range(n-1): s=0 for d in range(c,n-1): if a[d]==c+1: s+=1 print(s)
p02785
s921930883
Accepted
N, K = map(int, input().split()) H = [int(x) for x in input().split()] H = sorted(H) ans = 0 for i in range(N - K): ans += H[i] print(ans)
p02755
s497763029
Accepted
a,b = map(int,input().split()) list = [] if 100*a%8: x=int(a/0.08)+1 else: x=int(a/0.08) if 100*(a+1)%8: y=int((a+1)/0.08) else: y=int((a+1)/0.08)-1 for i in range(x, y+1): if b/0.1 <= i <(b+1)/0.1: list.append(i) list = sorted(list) if list: print(list[0]) else: print('-1')
p04020
s422607867
Accepted
N = int(input()) listA = [int(input()) for i in range(N)] count = 0 for x in range(N): check = listA[x] count += check // 2 if x != N - 1 and check % 2 != 0: if listA[x + 1] > 0: count += 1 listA[x + 1] -= 1 print(count)
p02675
s272534288
Accepted
S = input() if((S[-1] == '2') or (S[-1] == '4') or (S[-1] == '5') or (S[-1] == '7') or (S[-1] == '9')) : print("hon") elif((S[-1] == '0') or (S[-1] == '1') or (S[-1] == '6') or (S[-1] == '8')) : print("pon") else : print("bon")
p03416
s769071320
Accepted
A,B = map(int,input().split()) cnt = 0 for i in range(A,B+1): i = str(i) if i == i[::-1]: cnt += 1 print(cnt)
p02717
s520960088
Accepted
x,y,z = list(map(int,input().split())) chg_box = x x = y y = chg_box chg_box = x x = z z = chg_box print(x,y,z)
p02802
s887226933
Wrong Answer
N,M = map(int,input().split()) Check_AC = [0]*N WA_Counter = 0 for i in range(M): pi,Si = input().split() pi = int(pi) # まだ正解していない問題 if Check_AC[pi-1] == 0: if Si == "AC": Check_AC[pi-1] = 1 else: WA_Counter += 1 print(str(sum(Check_AC)) + " " + str(WA_Counter))
p03804
s408785748
Accepted
N , M = map(int , input().split()) A = [str(input()) for i in range(N)] B = [str(input()) for i in range(M)] def bina(A , B): for i in range((N-M)+1): for w in range(N): c = [] for q in range(M): c += [A[i+q][w:w+M]] if c == B: return "Yes" return "No" if __name__ == '__main__': ans = bina(A , B) print(ans)
p02843
s197873146
Wrong Answer
x = int(input()[-3:]) if 100 <= x <= 105 or 201 <= x <= 209 or 303 <= x <= 312 or 406 <= x <= 414 or \ 510 <= x <= 515 or x == 615: print(1) else: print(0)
p02747
s348854778
Accepted
print(["No","Yes"][input() in ["hi" * x for x in range(1,6)]])
p02640
s403393620
Accepted
X, Y = map(int, input().split()) t = (Y - 2 * X) // 2 c = (4 * X - Y) // 2 if c < 0 or t < 0: print('No') else: if c+t == X: print('Yes') else: print('No')
p03723
s390020030
Accepted
a, b, c = map(int, input().split()) times = 0 if a == b and b == c and a % 2 == 0: print(-1) else: while 1: if a % 2 == 1 or b % 2 == 1 or c % 2 == 1: break a, b, c = int((b + c)/2), int((c + a)/2), int((a + b)/2) times += 1 print(times)
p02778
s753651392
Accepted
s = list(input()) size = len(s) for i in range(size): s[i] = "x" print(s[i], end="")
p02724
s531669002
Wrong Answer
coin = int(input()) siawase = 0 if coin >= 500: siawase = siawase + int(coin / 500) * 1000 amari = coin % 500 print(siawase) print(amari) siawase = siawase + int(amari / 5) *5 elif coin >= 5: siawase = siawase + int(coin / 5) * 5 print(int(siawase))
p02596
s827462863
Wrong Answer
def resolve(): k = int(input()) if k % 2 == 0: print(-1) return for i in range(1, 10 ** 6): if (7 * pow(10, i, k)) % k == 7 % k: print(i) return print(-1) if __name__ == '__main__': resolve()
p02640
s056045036
Accepted
X, Y = map(int,input().split()) crain = (4 * X - Y) / 2 turtle = (Y- 2*X) /2 if crain.is_integer() and crain >= 0 and turtle.is_integer() and turtle >= 0 : crain = int(crain) print('Yes') else: print('No')
p03360
s848100207
Accepted
a,b,c=map(int,input().split()) k=int(input()) print(max([a,b,c])*2**k+a+b+c-max([a,b,c]))
p03059
s070309901
Accepted
A, B, T =map(int,input().split()) print( int((T+0.5)//A * B))
p02899
s806987533
Wrong Answer
N = int(input()) A = list(map(int,input().split())) a = sorted(A) print(a) result = list() for i in range(N): result.append(A.index(a[i]) + 1) print(result)
p02546
s710530821
Accepted
a = input() if (a[-1] != "s"): a += "s" else : a += "es" print(a)
p02548
s982647612
Accepted
n=int(input()) ans=0 for a in range(1,n): x=(n-1)//a ans+=x print(ans)
p03043
s287689604
Accepted
from math import log2 import decimal N, K = map(int, input().split()) decimal.getcontext().prec = 28 ans = decimal.Decimal(0) for i in range(1, N+1): if i < K: power = -(-(log2(K) - log2(i))//1) prob = decimal.Decimal(1/((2**power) * N)) else: prob = decimal.Decimal(1/N) #print(prob) ans = decimal.Decimal(ans + prob) #print(ans) print(ans)
p02963
s261838714
Accepted
s=int(input()) if s==10**18: print(0,0,0,1000000000,1000000000,0) exit() y=s//1000000000+1 x=1000000000*y-s print(0,0,1000000000,1,x,y)
p02687
s574909550
Accepted
S = input() if S == 'ARC' : print('ABC') else : print('ARC')
p03095
s623956794
Accepted
N = int(input()) S = input() from collections import Counter c = Counter() for si in S: c[si] += 1 # print(c.values()) ans = 1 for n in c.values(): ans *= n + 1 ans -= 1 ans = ans % (10 ** 9 + 7) print(ans)
p03745
s815867973
Wrong Answer
n = int(input()) lst = list(map(int,input().split())) res = 0 if n==1 or n==2: res = 1 else: for i in range(1,n-1): if lst[i-1] > lst[i] and lst[i] < lst[i+1]: res += 1 lst[i] = lst[i+1] elif lst[i-1] < lst[i] and lst[i] > lst[i+1]: res += 1 lst[i] = lst[i+1] print(res + 1)
p03146
s316285722
Accepted
s = int(input()) a = [s] for i in range(1000000): if a[i]%2==0: b=a[i]/2 else: b=a[i]*3+1 if b in a: print(i+2) break else: a.append(b)
p02725
s351055941
Wrong Answer
K, N = map(int, input().split()) A = list(map(int, input().split())) if A[0] == 0: A.remove(0) if len(A) == 1: ans = A[0] else: ans = A[-1] - A[0] print(ans)
p03162
s522031356
Accepted
N = int(input()) abc = [list(map(int,input().split())) for _ in range(N)] dp = [[0]*3 for _ in range(N)] dp[0][0],dp[0][1],dp[0][2] = abc[0][0],abc[0][1],abc[0][2] for i in range(1,N): for j in range(3): for k in range(3): if j != k: dp[i][k] = max(dp[i][k], dp[i-1][j] + abc[i][k]) ans = max(dp[N-1]) print(ans)
p03854
s187519382
Accepted
# dfs import sys sys.setrecursionlimit(10**6) C = ['dream', 'dreamer', 'erase', 'eraser'] S = input() L = len(S) def dfs(x, l): if l == L: return True elif l > L: return False match = S[l:l+7] for c in C: if match.find(c) == 0: if dfs(c, l+len(c)): return True return False print('YES' if dfs('', 0) else 'NO')
p03761
s512455492
Wrong Answer
from collections import defaultdict d=defaultdict(lambda: 50) n=int(input()) for _ in range(n): s=input() for char in [chr(ord('a') + i) for i in range(26)]: d[char] = min(d[char],s.count(char)) ans="" for char,i in zip(d.keys(),d.values()): ans += char*i print(ans)
p02601
s142111888
Wrong Answer
cards = list(map(int,input().split())) K = int(input()) for i in range(K): if cards[1]>cards[2]: cards[2]*=2 elif cards[0]>cards[1]: cards[1]=cards[1]*2 else : cards[0]*=2 if cards[0]<cards[1]<cards[2]: print('Yes') else: print('No')
p02732
s461547890
Wrong Answer
def main(): n = int(input()) a = tuple(map(int, input().split())) ans = 0 lim = max(a) amount = [0]*lim for i in range(lim): amount[0] = a.count(i+1) ans += amount[i]*(amount[i]-1)//2 #print(ans) for j in range(n): ansout = ans #print(amount[a[j]-1]) ansout -= amount[a[j]-1] -1 print(ansout) if __name__ == '__main__': main()
p02727
s807897379
Accepted
import sys input = sys.stdin.readline def main(): X, Y, A, B, C = map(int, input().split()) p = list(map(int, input().split())) p.sort(reverse=True) q = list(map(int, input().split())) q.sort(reverse=True) r = list(map(int, input().split())) r.sort(reverse=True) target = p[:X] + q[:Y] + r target.sort(reverse=True) ans = sum(target[:X+Y]) print(ans) if __name__ == "__main__": main()
p03419
s229925578
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*M)-(N*2)-(M*2)+4)
p02607
s890979818
Accepted
n = int(input()) a = list(map(int,input().split())) cnt = 0 for i in range(0,len(a),2): if a[i]%2==1: cnt += 1 print(cnt)
p03723
s287906579
Accepted
A,B,C = map(int,input().split()) if A%2==B%2==C%2==0 and A==B==C: print(-1) exit() cnt=0 while(A%2==B%2==C%2==0): _A=A;_B=B;_C=C A=_B//2+_C//2 B=_A//2+_C//2 C=_B//2+_A//2 cnt+=1 #print(cnt,A,B,C) print(cnt)
p03243
s369478047
Accepted
N = int(input()) while True: if len(set(str(N))) == 1: print(N) exit() N += 1
p03352
s532346354
Accepted
x = int(input()) tmp = 2 ans = 1 while tmp*tmp <= x: cur = tmp*tmp while cur*tmp <= x: cur *= tmp ans = max(ans, cur) tmp += 1 print(ans)
p03241
s439362652
Accepted
# import bisect n,m=map(int,input().split()) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) divisors.sort() return divisors div=make_divisors(m) ans=1 for i in range(len(div)): if(div[i]>m/n): break ans=max(div[i],ans) print(ans)
p03220
s533350837
Wrong Answer
N = int(input()) T,A = map(int,input().split()) H = list(map(int,input().split())) ans = 1000 tmper = [] for i in range(N): tmper.append(abs(T - H[i]*0.006)) ans = min(ans,abs(T - H[i]*0.006)) print(tmper.index(ans))
p03339
s856038889
Accepted
n=int(input()) s=list(input()) w=[0]*n for i in range(n): if s[i]=="E": w[i]=1 from itertools import accumulate d=list(accumulate([0]+w)) ans=n cnt=0 for i in range(n): cnt=i-d[i]+d[-1]-d[i+1] ans=min(ans,cnt) print(ans)
p03471
s809105846
Accepted
def main(): N, Y = map(int,input().split()) x, y, z = [0, 0, 0] for i in range(N + 1): for j in range(N + 1 - i): if i * 10000 + j * 5000 + (N-i-j) * 1000 == Y and N-i-j >= 0: print(i, j , N-i-j) return print(-1, -1, -1) if __name__ == "__main__": main()
p02631
s164579475
Accepted
n = int(input()) a = list(map(int, input().split())) A = 0 for ai in a: A^=ai ans = [A^ai for ai in a] print(*ans)
p02787
s180783850
Wrong Answer
H,N=map(int,input().split()) C=[0 for i in range(H+(10**4)+1)] d=0 for i in [0]*N: A,B=map(int,input().split()) for i in range(H+A+1): if A==i : C[i]=B elif A<i : if C[i]==0 and C[i-A]>0: C[i]=C[i-A]+B elif C[i-A]>0: C[i]=min(C[i],C[i-A]+B) d=max(d,A) e=10**9 for i in range(H+1,H+d+1): if C[i]>0: e=min(C[i],e) print(e)
p04011
s791733231
Accepted
n,k,x,y = [int(input()) for i in range(4)] print(min(k,n)*x+max(n-k,0)*y)
p02767
s718378630
Wrong Answer
N = int(input()) X = list(map(int, input().split())) M = sum(X)//N ans = 0 for i in X: ans+=(i-M)**2 print(ans)
p02760
s222585886
Wrong Answer
a = [] for i in range(3): a += map(int, input().split()) n = int(input()) for i in range(n): b = int(input()) for j in range(9): if b == a[j]: a[j] = 'o' isBingo = False bingo = [[0, 3, 6], [1, 4, 7], [2, 5, 8], [0, 1, 2], [3, 4, 5], [6, 7, 8], [0, 4, 8], [2, 5, 7]] for elem in bingo: if a[elem[0]] == 'o' and a[elem[1]] == 'o' and a[elem[2]] == 'o': isBingo = True break print('Yes') if isBingo else print('No')
p03854
s336622376
Accepted
import re # 正規表現 s = input() # re.sub(pattern, word, line) はlineのうち、patternに一致する部分をwordに変換します。 s = re.sub('eraser', '', s) s = re.sub('erase', '', s) s = re.sub('dreamer', '', s) s = re.sub('dream', '', s) print('YES' if len(s) == 0 else 'NO')
p03861
s462777852
Wrong Answer
a, b, x = map(int, input().split(" ")) n = b//x+1 if a>1: m = a//x elif a==1: m=1 elif a==0: m=0 ans = n-m print("{}".format(ans))
p03545
s034542879
Wrong Answer
s = input() a = int(s[0]) b = int(s[1]) c = int(s[2]) d = int(s[3]) for i in [-1,1]: for j in [-1,1]: for k in [-1,1]: if a + i*b + j*c + k*d == 7: op1 = ['-','+'][i==1] op2 = ['-','+'][j==1] op3 = ['-','+'][k==1] print(f'{a}{op1}{b}{op2}{c}{op3}{d}=7') break
p03012
s660221907
Accepted
n=int(input()) lst = list(map(int,input().split())) gap=10000 for i in range(n): if abs(sum(lst[:i+1])-sum(lst[i+1:]))<gap: gap=abs(sum(lst[:i+1])-sum(lst[i+1:])) print(gap)
p03994
s491901734
Accepted
s = list(input()) k = int(input()) n = len(s) for i in range(n): if s[i]=='a':continue d = ord('z')-ord(s[i])+1 if d<=k: s[i] = 'a' k -= d x = (ord(s[-1])-ord('a')+k)%26 s[-1] = chr(ord('a')+x) print(''.join(s))
p03379
s856931064
Accepted
# input N = int(input()) X = list(map(int, input().split())) # check l, r = N // 2 - 1, N // 2 sort_x = sorted(X) lx, rx = sort_x[l], sort_x[r] if lx == rx: for i in range(N): print(lx) else: for ind in range(N): target = X[ind] if target <= lx: print(rx) if target >= rx: print(lx)
p03105
s223004504
Accepted
import sys import math import bisect def main(): a, b, c = map(int, input().split()) ans = 0 while ans < c and b >= a: b -= a ans += 1 print(ans) if __name__ == "__main__": main()
p02793
s607448204
Wrong Answer
import fractions # import math as fractions mod = 10**9+7 n = int(input()) a = list(map(int, input().split())) if n == 1: print(a[0]) exit() h = fractions.gcd(a[0], a[1]) g = h % mod f = a[0]*a[1]//g ans = a[0]//g+a[1]//g for i in range(2, n): # print(ans, g, f) h = fractions.gcd(f, a[i]) g = a[i] // h % mod f = f*a[i]// h ans *= g ans += f // a[i] ans %= mod print(ans%mod)
p02911
s512958927
Wrong Answer
n, k, q = list(map(int, input().split())) a = [int(input()) for i in range(q)] p = [k]*n for i in a: for j,val in enumerate(p): if j != i: p[j] -= 1 for n in p: if n>0: print("Yes") else: print("No")
p02683
s787079253
Accepted
import numpy as np N,M,X = map(int,input().split()) C = np.repeat(0, N) A = np.repeat(0, N*M).reshape(N,M) for i in range(N): x = list(map(int, input().split())) C[i] = x[0] A[i,:] = x[1:] ans = np.inf for _ in range(1<<N): # print(format(_, 'b').zfill(H+W)) choices = [i for i,v in enumerate(format(_, 'b').zfill(N)) if v == '1'] points = A[choices,:].sum(axis=0) if sum(points < X) == 0: ans = min(ans, sum(C[choices])) ans = [ans, -1][np.isinf(ans)] print(ans)
p03105
s107730343
Wrong Answer
A,B,C=list(map(int,input().split())) print(max(B//A,C))
p02658
s060666191
Wrong Answer
n = int(input()) a_list = list(map(int, input().split())) num = 1 for i in a_list: num *= i print(num if num < 10**18 else "-1")
p04033
s275178473
Accepted
a, b = map(int, input().split()) if a<=0 and 0<=b: print('Zero') exit() elif a > 0: print('Positive') exit() else: if ( b - a + 1 ) % 2 == 0: print('Positive') exit() else: print('Negative') exit()
p03331
s264077301
Accepted
N = int(input()) ans = 100 i = 1 while i * 2 <= N: ans = min(ans, sum(map(int, list(str(i)))) + sum(map(int, list(str(N-i))))) i += 1 print(ans)
p02909
s725829842
Accepted
s = input() if s == 'Sunny': print('Cloudy') elif s == 'Cloudy': print('Rainy') else: print('Sunny')
p02814
s041446579
Accepted
from fractions import gcd def lcm(p, q): return (p * q // int(gcd(p, q))) N, M = map(int, input().split()) A = list(map(int,input().split())) B = [] for i in range(N): b = 0 while A[i] % 2 == 0: A[i] >>= 1 b += 1 B.append(b) S = set(B) if len(S) != 1: print(0) else: P = 1 for i in range(N): P = lcm(P, A[i]) print((M // (2 ** (list(S)[0] - 1)) + P) // (2 * P))
p03309
s839918197
Accepted
N = int(input()) A = list(map(int, input().split())) for i in range(N): A[i] -= i + 1 m = min(A) for i in range(N): A[i] -= m A.sort() print(sum(abs(i - A[N//2]) for i in A))
p02917
s742043984
Accepted
n = int(input()) l = [int(x) for x in input().split()] l.append(100000) #100000はダミー #print(n, l, len(l)) z = [] z.append(l[0]) # z[0]のみl[0]と決まる for i in range(len(l)-1): #print(i) z.append(min(l[i],l[i+1])) print(sum(z))
p02729
s243469277
Accepted
import math n, m = list(map(int, input().split())) print(math.floor(n * (n - 1) / 2 + m * (m - 1) / 2))
p03071
s094079535
Accepted
a,b=map(int,input().split()) if a==b: print(a*2) else: print(max(a,b)*2-1)
p04011
s229389371
Accepted
n = int(input()) k = int(input()) x = int(input()) y = int(input()) if n > k: print(k * x + (n - k) * y) else: print(n * x)
p02959
s931096407
Accepted
n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) num = 0 for i in range(n): min_ab = min(a[i],b[i]) num += min_ab a[i] -= min_ab b[i] -= min_ab if b[i] != 0: min_ab = min(a[i + 1],b[i]) num += min_ab a[i + 1] -= min_ab b[i] -= min_ab print(num)
p03943
s278654767
Accepted
a, b, c = map(int, input().split()) max_candy = max(a, b, c) else_candy = a + b + c - max_candy if max_candy == else_candy: print("Yes") else: print("No")
p02900
s204598109
Accepted
import collections as col def prime(n): ans = [] num = n for i in range(2,int(n**0.5)+1): if i%2==0 and i!=2: continue while num%i == 0: num //= i ; ans.append(i) if num != 1: ans.append(num) return ans def gcd(a,b): return gcd(b,a%b) if a%b else b a,b = map(int,input().split()) primes = prime(gcd(a,b)) cnt = col.Counter(primes) ans = len(cnt) + 1 print(ans)