problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02706
s273527129
Wrong Answer
a, b = map(int, input().split()) c = list(map(int, input().split())) d = sum(c) print(a-d)
p02664
s777148215
Accepted
a=input() b=a.replace("?","D") print(b)
p03836
s990062840
Accepted
import sys input = sys.stdin.readline def main(): sx,sy,tx,ty = map(int,input().split()) dx = tx-sx dy = ty-sy ans = ["R"*dx + "U"*dy + "L"*dx + "D"*dy+"D"+"R"*(dx+1)+"U"*(dy+1)+"L"+"U"+"L"*(dx+1)+"D"*(dy+1)+"R"] print(*ans) if __name__ == "__main__": main()
p03352
s896850610
Accepted
x = int(input()) max_val = 1 for i in range(1, x): for j in range(2, x): val = i ** j if val > x: break elif val > max_val: max_val = val print(max_val)
p03836
s574725154
Accepted
sx, sy, tx, ty = map(int, input().split()) len_x = tx - sx len_y = ty - sy ans = [] for _ in range(len_x): ans.append("R") for _ in range(len_y): ans.append("U") for _ in range(len_x): ans.append("L") for _ in range(len_y): ans.append("D") ans.append("D") for _ in range(len_x + 1): ans.append("R") for _ in range(len_y + 1): ans.append("U") ans.append("L") ans.append("U") for _ in range(len_x + 1): ans.append("L") for _ in range(len_y + 1): ans.append("D") ans.append("R") print("".join(ans))
p03086
s064761240
Accepted
s = list(input()) ans = 0 for i in range(len(s)): for j in range(i, len(s)): # print(s[i:j+1]) if all(x == 'A' or x == 'C' or x == 'G' or x == 'T' for x in s[i:j+1]): # print('Yes') if ans < len(s[i:j+1]): ans = len(s[i:j+1]) # if expression: # pass # print(s[:i], len(s[:i])) print(ans)
p02701
s675879600
Accepted
n=int(input()) L=set() for i in range(n): s=input() L.add(s) print(len(L))
p03797
s714033676
Accepted
n, m = [int(i) for i in input().split()] ans = 0 diff = m - n if diff >= 2: x = n * 2 y = m - x ans += n ans += y // 4 else: ans = m // 2 print(ans)
p03639
s938356937
Wrong Answer
n = int(input()) a = list(map(int, input().split())) c4 = 0 c2 = 0 for i in a: if i%4 == 0: c4 += 1 elif i%2 == 0: c2 += 1 c0 = n - c4 - c2 ans = False if c2 < 2: if c0 + c2 <= 2*c4: ans = True else: if c0 <= c4*2 + (c2//2) - 1: ans = True if ans: print("Yes") else: print("No")
p03437
s497159784
Accepted
import fractions x, y = map(int, input().split()) ans = -1 for i in range((x*y)//fractions.gcd(x, y), 0, -x): if i%y != 0: ans = i break print(ans)
p03720
s528644652
Accepted
N, M = map(int, input().split()) ab = [tuple(map(int, input().split())) for i in range(M)] ab = [i for inner in ab for i in inner] for i in range(1, N + 1): print(ab.count(i))
p02624
s359300165
Accepted
n=int(input()) su = 0 for i in range(1,n+1): m = int(n/i) su += int(m*(2*i + (m-1)*i)/2) print(su)
p02793
s557401447
Accepted
def main(): import sys input = sys.stdin.readline from fractions import gcd def lcm(a, b): return a * b // gcd(a, b) N = int(input()) A = tuple(sorted(list(map(int,input().split())))) MOD = 10**9+7 L = 1 for a in A: L = lcm(a,L) ans = 0 for a in A: #ans += L//a ans += L*pow(a,MOD-2,MOD) print(ans%MOD) if __name__ == '__main__': main()
p02819
s614471400
Accepted
# -*- coding: utf-8 -*- x = int(input()) ans = x while True: flag = True for i in range(2, x): if ans % i == 0: ans += 1 flag = False if flag: print(ans) break
p02631
s523468157
Accepted
N = int(input()) A = list(map(int, input().split())) Ans = [0 for i in range(N)] X = 0 for i in A: X ^= i for i in range(N): Ans[i] = X ^ A[i] print(*Ans)
p02951
s923012176
Accepted
import sys readline = sys.stdin.readline MOD = 10 ** 9 + 7 INF = float('INF') sys.setrecursionlimit(10 ** 5) def main(): A, B, C = map(int, readline().split()) x = A - B print(max(0, C - x)) if __name__ == '__main__': main()
p03387
s884418542
Accepted
ABC = list(map(int, input().split())) ABC.sort() delta = abs(ABC[2]-ABC[0])+abs(ABC[2]-ABC[1]) if delta % 2: print((delta+1)//2+1) else: print(delta//2)
p03493
s101991428
Accepted
s1s2s3 = str(input()) print (s1s2s3.count('1'))
p03627
s259869916
Accepted
n = input() *a, = map(int, input().split()) d = {} for i in a: if i in d: d[i] += 1 else: d[i] = 1 b = [i for i in d.keys() if d[i] >= 2] if len(b) == 0: print(0) elif len(b) == 1: if d[b[0]] >= 4: print(b[0]**2) else: print(0) else: b.sort() if d[b[-1]] >= 4: print(b[-1]**2) else: print(b[-1]*b[-2])
p02888
s941609913
Accepted
n=int(input()) l=list(map(int,input().split())) l.sort() num=[0]*(max(l)+2) for i in range(n): num[l[i]]=i for i in range(1,len(num)): if num[i]==0: num[i]=num[i-1] ans=0 num3=l[n-1] for i in range(n-2): for j in range(i+1,n-1): ans+=max(0,num[min(num3,l[i]+l[j]-1)]-j) print(ans)
p02994
s664045631
Wrong Answer
N,L = map(int,input().split()) s = 0 for i in range(1,N+1): s += L+i-1 if L >= 0: eat = L elif L+N < 0: eat = L+N-1 else: eat = 0 print(s-eat)
p02731
s095903397
Wrong Answer
l = int(input())*10 Ma = 0 for i in range(0, l+1, 1): for j in range(0, l-i, 1): z = l - (i+j) result = z*i*j if(result>Ma): Ma = result print(Ma/1000)
p03243
s333595657
Accepted
from math import ceil n = int(input()) if n%111 == 0: print(n) else: print(111*ceil(n/111))
p03698
s532662966
Accepted
LI = lambda: list(map(int, input().split())) S = input() def main(): n = len(S) sn = len(set(S)) ans = "yes" if sn == n else "no" print(ans) if __name__ == "__main__": main()
p02660
s842879876
Wrong Answer
n=int(input()) l=list() if n==1: print(0) else: if n%2==0: l.append(2) if n%3==0: l.append(3) i=5 while(i*i<=n): if n%i==0: l.append(i) elif n%(i+2)==0: l.append(i+2) i+=6 l.append(n) k=0 for i in l: z=i while(n%z==0 and n>0): n=n//z z=i*z k+=1 print(k)
p02860
s813512949
Accepted
# 初期入力 N =int(input()) S =input() # harf =len(S)//2 T1 =S[:harf] T2 =S[harf:] if T1 ==T2: print("Yes") else: print("No")
p03795
s619462811
Accepted
N = int(input()) print( 800 * N - 200 * (N//15) )
p02789
s974567366
Wrong Answer
N , M =map(int,input().split()) if 1<=N<=100 and 0 <= M <= N: if N==M: print("Yes") else: print("no") else: print("No")
p02848
s479278394
Accepted
N = int(input()) S = input() def foo(alphabet, n): NUM_OF_ALPHABETS = 26 diff = ord(alphabet) - ord('A') index = (diff + n) % NUM_OF_ALPHABETS result = chr(ord('A') + index) return result def calculate(str, n): calculated = ''.join([foo(alphabet, n) for alphabet in str]) return calculated answer = calculate(S, N) print(answer)
p03803
s745461527
Wrong Answer
a,b = map(int,input().split()) if a > b: print("Alice") elif b< a: print("Bob") else: print("Draw")
p02880
s895328531
Accepted
#!/usr/bin/env python3 def main(): N = int(input()) flag = False for i in range(1,10): if N % i == 0 and N // i < 10: flag = True break if flag: print('Yes') else: print('No') main()
p03103
s745917602
Wrong Answer
N, M = map(int, input().split()) d = {} for i in range(N): a, b = map(int, input().split()) d[a] = b d = sorted(d.items(), key=lambda x:x[0]) sum_ = 0 cnt = 0 for ab in d: if cnt + ab[1] > M: sum_ += ab[0] * (M-cnt) break else: cnt += ab[1] sum_ += ab[0]*ab[1] print(sum_)
p02712
s790376409
Accepted
n = int(input()) res = 0 for i in range(1,n+1): if i%3==0 or i%5==0: pass else: res += i print(res)
p03699
s332027342
Accepted
import sys n = int(input()) li = [] for _ in range(n): i = int(input()) li.append(i) li.sort() s = sum(li) if s % 10 != 0: print(s) sys.exit() for l in li: if l%10 != 0: s -= l break if s%10 == 0: print(0) else: print(s)
p02959
s440295604
Accepted
N=int(input()) A=list(map(int, input().split())) B=list(map(int, input().split())) before=sum(A) for n in range(N): temp = A[n] A[n] = max(0, A[n]-B[n]) B[n] = max(0, B[n]-temp) A[n+1] = max(0, A[n+1]-B[n]) after=sum(A) print(before-after)
p02818
s767045588
Accepted
A,B,K = map(int, input().split()) if A+B < K: print(0,0) elif A >= K: print(A-K,B) else: print(0,A+B-K)
p03944
s217624019
Wrong Answer
X,Y,N=map(int,input().split()) max_X=X max_Y=Y current_min_x=0 current_min_y=0 current_max_x=X current_max_y=Y xy=[list(map(int,input().split())) for _ in range(N)] for x,y,a in xy: n=0 if a==1: current_min_x=max(0, x) elif a==2: current_max_x=min(x, max_X) elif a==3: current_min_y=max(0, y) elif a==4: current_max_y=min(y, max_Y) result=(current_max_x-current_min_x)*(current_max_y-current_min_y) print(result if result > 0 else 0)
p02700
s005824397
Accepted
a,b,c,d = map(int, input().split()) ans='Yes' while a>0 and c>0: c-=b if c<=0: break a-=d if a<=0: ans='No' break print(ans)
p03773
s300358935
Wrong Answer
a=list(map(int,input().split())) b=a[0]+a[1] while b>24: if b>24: b-=24 print(b)
p02633
s104903954
Wrong Answer
degree = int(input()) print(360//degree)
p02675
s843931609
Accepted
def main(): s = input() if s[-1] == "3": print("bon") elif int(s[-1]) in [0, 1, 6, 8]: print("pon") else: print("hon") if __name__=="__main__": main()
p03077
s590335343
Wrong Answer
n=int(input()) count=0 keep=10*100 tempkeep=0 import math for i in range(0,5): a=int(input()) if i==0: drop=0 else: drop=1 if n%a==0: temp=n//a else: temp=n//a+1 if a<keep: count+=temp-tempkeep+drop tempkeep=temp keep=a else: count+=1 print(count)
p02765
s726846787
Wrong Answer
s = input().split() N = int(s[0]) R = int(s[1]) if N < 9: ans = R + 100 *(10 - N) else: ans = R print(ans)
p03592
s114743511
Accepted
n, m, K = map(int, input().split()) print("YNeos"[all(k*(m-l)+(n-k)*l-K for k in range(n+1) for l in range(m+1))::2])
p02792
s518857757
Accepted
n = int(input()) grid = [[0 for _ in range(9)] for _ in range(9)] ans = 0 for i in range(1, n + 1): if i % 10 == 0: continue else: s = str(i) grid[int(s[0]) - 1][int(s[-1]) - 1] += 1 for i in range(9): for j in range(9): ans += grid[i][j] * grid[j][i] print(ans)
p03017
s082372778
Accepted
from collections import defaultdict from collections import deque from collections import Counter import itertools import math def readInt(): return int(input()) def readInts(): return list(map(int, input().split())) def readChar(): return input() def readChars(): return input().split() n,a,b,c,d = readInts() a-=1 b-=1 c-=1 d-=1 s = readChar() if (a-b)*(c-d)<0: if "..." in s[b-1:d+2] and "##" not in s[a:c]: print("Yes") else: print("No") else: if "##" not in s[a:d+1]: print("Yes") else: print("No")
p02615
s285805089
Wrong Answer
input() print(sum(sorted(list(map(int, input().split())))[1:]))
p03711
s220307481
Wrong Answer
x, y = map(int,input().split()) a = [1,3,5,7,8,10,12] b = [4,6,9,11] c = [2] if x in a and y in a: print("YES") elif x in b and y in b: print("YES") elif x in c and y in c: print("YES") else: print("NO")
p03478
s666388354
Accepted
num_in = [int(i) for i in input().split()] def calc_dig_sum(num): num_str = str(num) ret = 0 for c in num_str: ret += int(c) return ret sum = 0 for i in range(1, num_in[0]+1): if num_in[1] <= calc_dig_sum(i) <= num_in[2]: sum += i print(sum)
p03681
s113760294
Wrong Answer
def resolve(): n, m = map(int, input().split()) mod = 10**9+7 if abs(n - m) > 1: print(0) return print((n % mod) * (m % mod) * 2 % mod) resolve()
p03644
s207015512
Wrong Answer
def divisible(n): ans = 0 while n%2 == 0: n /= 2 ans += 1 return ans N = int(input()) b = 0 c = 0 for i in range(1,N+1): if(divisible(i) > b): b = divisible(i) c = i print(c)
p03456
s063966557
Accepted
a,b=input().split() x=int(a+b) for i in range(int(x**0.5)+1): if i**2 ==x: print('Yes') exit() print('No')
p03681
s491776425
Accepted
import math n,m = map(int,input().split()) if abs(n-m) >= 2: print(0) exit() if n == m: print((math.factorial(n) * math.factorial(m) * 2)%(10**9 + 7)) elif n+1 == m: print((math.factorial(m) * math.factorial(n))%(10**9 + 7)) elif m+1 == n: print((math.factorial(n) * math.factorial(m))%(10**9 + 7))
p03994
s742914564
Accepted
import sys readline = sys.stdin.readline sys.setrecursionlimit(10**8) mod = 10**9+7 #mod = 998244353 INF = 10**18 eps = 10**-7 S = list(readline().rstrip()) K = int(readline()) N = len(S) for i in range(N): t = ord(S[i])-97 if t == 0: continue if 26 - t <= K: S[i] = 'a' K -= 26-t S[-1] = chr((ord(S[-1])-97 + K%26)%26 + 97) print(''.join(S))
p02577
s850668529
Accepted
s = input() #s = '31415926535897932384626433832795028841971693993751058209749445923078164062862089986280' print('Yes' if sum(int(t) for t in s) % 9 == 0 else 'No')
p03838
s795217081
Accepted
x, y = map(int, input().split()) if x <= y: if 0 <= x or y <= 0: print(y-x) elif abs(x) >= abs(y): print(abs(x) - abs(y) + 1) else: print(1+abs(y)-abs(x)) else: if 0 < y or x < 0: print(1+abs(x-y)+1) elif x == 0 or y == 0: print(abs(x-y)+1) elif abs(x) >= abs(y): print(1+abs(x)-abs(y)) else: print(abs(y)-abs(x)+1)
p03062
s383851252
Accepted
#!/usr/bin/env python3 INF = 10**9 + 1 def solve(n,a): ans = 0 minusCount = 0 minimumNum = INF lst = [] for i in range(n): if a[i] < 0: minusCount += 1 ans += abs(a[i]) minimumNum = min(minimumNum,abs(a[i])) if minusCount % 2 == 0: pass else: ans -= minimumNum*2 return ans def main(): N = int(input()) a = list(map(int,input().split())) print(solve(N,a)) if __name__ == '__main__': main()
p03289
s221700789
Accepted
S = input() if S[0] == 'A' and 'C' in S[2:-1]: idx = S.index('C') if all(c.islower() or i in (0, idx) for i, c in enumerate(S)): print('AC') else: print('WA') else: print('WA')
p02633
s762027058
Accepted
X = int(input()) for i in range(1,361): if (360*i)%X==0: ans=(360*i)//X break print(ans)
p02707
s128650587
Accepted
from collections import defaultdict d = defaultdict(int) N = int(input()) A = list(map(int, input().split())) for i in A: d[i] += 1 for i in range(1,N+1): print(d[i])
p03745
s319550619
Accepted
# A - Sorted Arrays import numpy as np N = int(input()) A = list(map(int, input().split())) sgn = 0 ans = 1 for i in range(N-1): tmp = np.sign(A[i+1]-A[i]) if tmp*sgn<0: ans += 1 sgn = 0 else: sgn = np.sign(2*sgn+tmp) print(ans)
p03838
s396415351
Accepted
x, y = map(int, input().split()) if x <= y: print(min(y - x, 1 + abs(abs(y) - abs(x)))) elif x * y <= 0: print(1 + abs(abs(y) - abs(x))) else: print(2 + abs(y - x))
p02754
s335020434
Accepted
N, A, B = map(int, input().split()) ans = N//(A+B)*A if A > N % (A+B): ans += N % (A+B) else: ans += A print(ans)
p03796
s153025945
Accepted
N=int(input()) c=1 for i in range(N): c *= i+1 c = c % (10**9+7) # ここで、掛け算のスケールを減らすのか! print(c)
p03067
s035857208
Wrong Answer
a,b,c = map(int, input().split()) if a<c<b: print('Yes') else: print('No')
p02706
s550015323
Wrong Answer
(n,m)=map(int,input().split()) x = [int(i) for i in input().split()] sum=sum(x) print(n-sum)if n>m else print("-1")
p02957
s472627607
Accepted
a,b=map(int,input().split()) print((a+b)//2 if (a+b)%2==0 else 'IMPOSSIBLE')
p02832
s965207518
Accepted
n = int(input()) numbers = [int(i) for i in input().split(" ")] now = 1 for i in range(n): if numbers[i]==now: now += 1 if now==1 and n>1: print(-1) else: print(n-(now-1))
p02678
s459276790
Accepted
from collections import deque n, m = map(int, input().split()) links = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) a -= 1 b -= 1 links[a].append(b) links[b].append(a) ans = [-1] * n ans[0] = 0 q = deque([(0, 0)]) while q: room, prev = q.popleft() for next_ in links[room]: if ans[next_] < 0: ans[next_] = room q.append((next_, room)) print('Yes') for i in range(1, n): print(ans[i] + 1)
p03087
s451915828
Wrong Answer
N,Q=map(int,input().split()) S=input() lr = [list(map(int,input().split())) for _ in range(Q)] indices=[0]*(N+1) for i in range(1,N+1): if S[i-1:i+1]=='AC': indices[i] += indices[i-1] + 1 else: indices[i] += indices[i-1] print(indices) for i in range(Q): l,r=lr[i] print(indices[r-1]-indices[l-1])
p03698
s815076783
Accepted
s=input() print("no" if len(s)-len(set(s))!=0 else "yes" )
p03721
s848884056
Accepted
N, K = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(N)] A.sort() for i in range(N): if K>A[i][1]: K -= A[i][1] else: ans = A[i][0] break print(ans)
p03696
s765541699
Accepted
from sys import stdin, setrecursionlimit def main(): input = stdin.buffer.readline n = int(input()) s = input()[:-1].decode() c1 = 0 c2 = 0 for i in range(n): if s[i] == '(': c1 += 1 elif s[i] == ')': c1 -= 1 if c1 < 0: c1 = 0 c2 += 1 print('(' * c2, s, ')' * c1, sep='') if __name__ == "__main__": setrecursionlimit(10000) main()
p02832
s927454511
Wrong Answer
N = int(input()) a_list = list(map(str, input().split())) ans_index = [] before_index = -1 for i in range(len(a_list)): a_list[i] = int(a_list[i]) for i in range(len(a_list)): if (a_list.count(i+1) >= 1) and (a_list.index(i+1) > before_index): val = a_list.index(i+1) before_index = val ans_index.append(val) result = N - len(ans_index) print(result)
p02801
s064317720
Wrong Answer
a=input() print=(chr(ord(a)+1))
p02631
s922532088
Accepted
N = int(input()) A = list(map(int,input().split())) num = 0 for a in A: num ^= a l = [] for a in A: ans = a^num l.append(ans) print(*l)
p02786
s336155866
Wrong Answer
h = int(input()) counter = 0 while h > 1: counter += 1 h = h // 2 print(counter)
p02772
s108242826
Accepted
num_val = input() num_list = list(map(int, list(input().split()))) even_list = [i for i in num_list if (i%2==0) & (i%3!=0 and i%5!=0)] if len(even_list) == 0: print('APPROVED') else: print('DENIED')
p03162
s649478040
Accepted
n=int(input()) happy=[list(map(int,input().split())) for _ in range(n)] DP=[[0,0,0] for _ in range(n+1)] for i in range(n): a,b,c=happy[i] DP[i+1][0]=max(DP[i][1],DP[i][2])+a DP[i+1][1]=max(DP[i][2],DP[i][0])+b DP[i+1][2]=max(DP[i][0],DP[i][1])+c print(max(DP[-1]))
p02754
s104507262
Accepted
n, a, b = map(int, input().split()) unit = n // (a + b) rest = n % (a + b) result = unit * a if rest <= a: result += rest else: result += a print(result)
p03910
s872213081
Wrong Answer
import math from itertools import accumulate n = int(input()) tmp = n if n == 1: print(1) exit() lis = [0]*n lis[0] = 1 lis[1] = 3 a = 0 for i in range(2,n-1): lis[i] = lis[i-1] + (i+1) if lis[i] >= n: a = i+1 break ans = [] while n>1: ans.append(a) n -= a a -= 1 if sum(ans) != tmp: ans.append(1) for i in sorted(ans): print(i)
p02795
s703924523
Wrong Answer
H = int(input()) W = int(input()) N = int(input()) if H >= W: if N//H != 0:print(N//H + 1) else: print(N//H) else: if N//H != 0:print(N//W + 1) else: print(N//W)
p03607
s066513988
Accepted
from collections import Counter n = int(input()) al = list(int(input()) for _ in range(n)) c = Counter(al) ans = 0 for k, v in c.items(): if v%2 != 0: ans += 1 print(ans)
p02831
s255144125
Accepted
import math A, B = map(int, input().split()) C = A * B // math.gcd(A, B) print(C)
p03804
s401070441
Wrong Answer
n, m = map(int, input().split()) a = [input() for i in range(n)] b = [input() for i in range(m)] for i in range(n-m): for j in range(n-m): ans = 0 for ii in range(m): for jj in range(m): if b[ii][jj] == a[i+ii][j+jj]: ans += 1 if ans == m*m: print("Yes") exit() print("No")
p03645
s781173413
Accepted
N,M=list(map(int, input().split())) S=set() D=[] for i in range(M): l=list(map(int, input().split())) if l[0]==1: S.add(l[1]) else: D.append(l) # print(S) # print(D) D.sort() L=len(D) for i in range(L): if D[i][1]==N and D[i][0] in S: print('POSSIBLE') exit() else: print('IMPOSSIBLE')
p02972
s887066697
Wrong Answer
n = int(input()) a = list(map(int, input().split())) arr = [False] * n for i in range(n, 0, -1): if a[i - 1] == 1: if sum(arr[0::i]) % 2 == 0: arr[i - 1] = True else: if sum(arr[0::i]) % 2 == 1: arr[i - 1] = False if not any(arr): print(0) else: print(sum(arr)) ans = [] for i, x in enumerate(arr): if x: ans.append(i + 1) print(*ans)
p02552
s190193078
Accepted
x = int(input()) print(int(not(x)))
p03038
s163119481
Accepted
N, M = map(int, input().split()) A = list(map(int, input().split())) BC = [] for _ in range(M): BC.append(list(map(int, input().split()))) BC = sorted(BC, key=lambda x:x[1],reverse=True) for b, c in BC: A.extend([c] * b) if len(A)>=2*N: break A = sorted(A, reverse=True) print(sum(A[:N]))
p03416
s021612990
Accepted
A,B=map(int,input().split()) res=0 for i in range(A,B+1): cnt=0 s=str(i) for j in range(len(s)//2): if(s[j]==s[len(s)-1-j]): cnt+=1 if(len(s)//2==cnt): res+=1 print(res)
p02909
s144253403
Accepted
sl = ["Sunny","Cloudy","Rainy"] S = input() ans = 0 for i in range(len(sl)): if (S == sl[i]): ans = (i+1) % 3 print(sl[ans])
p02787
s190913127
Accepted
h,n = map(int, input().split()) magics = [tuple(map(int, input().split())) for _ in range(n)] max_a = sorted(magics, key=lambda x: x[0], reverse=True)[0][0] dp = [0]*(h+max_a) for i in range(1, h+max_a): dp[i] = min(dp[i-a]+b for a,b in magics) print(min(dp[h:]))
p03475
s591208026
Accepted
n = int(input()) sList = [] for i in range(n-1): sList.append(tuple(map(int,input().split()))) #print("sLIst",sList) for i in range(len(sList)): timeCount = sList[i][1]+sList[i][0] for j in range(i+1,len(sList)): if timeCount < sList[j][1]: timeCount = sList[j][1] timeTmp = timeCount % sList[j][2] if timeTmp == 0: timeCount += sList[j][0] else: timeCount += sList[j][2] - timeTmp + sList[j][0] print(timeCount) print(0)
p02748
s643292375
Accepted
A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = 10**9 for i in range(M): x, y, c = map(int, input().split()) ans = min(ans, a[x-1]+b[y-1]-c) ans = min(ans, min(a)+min(b)) print(ans)
p03617
s886460848
Accepted
q, h, s, d = map(int, input().split()) n = int(input()) # 2L min cost cost2 = min(q*8, h*4, s*2, d) # 1L min cost cost1 = min(q*4, h*2, s) ans = (n // 2) * cost2 if n % 2 == 1: ans += cost1 print(ans)
p02848
s382796590
Accepted
n=int(input()) s=input() alpha=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] out=[] for i in range(len(s)): out.append(alpha[(alpha.index(s[i])+n)%26]) print("".join(out))
p02862
s835872816
Accepted
#階乗 F = 10**6+5 mod = 10**9+7 fact = [1]*F inv = [1]*F for i in range(2,F): fact[i]=(fact[i-1]*i)%mod inv[F-1]=pow(fact[F-1],mod-2,mod) for i in range(F-2,1,-1): inv[i] = (inv[i+1]*(i+1))%mod x,y=map(int,input().split()) t=(x+y)//3 if (x+y)%3!=0 or x<t or y<t: print(0) else: print(fact[t]*inv[x-t]*inv[2*t-x]%mod)
p03827
s065135174
Accepted
N = int(input()) S = input() ans = 0 x = 0 for s in S: if s == 'I': x += 1 else: x -= 1 ans = max(ans, x) print(ans)
p03838
s934874992
Accepted
a, b= map(int, input().split()) num = abs(abs(a)-abs(b)) if a * b < 0: num += 1 elif a * b == 0 and a > b: num += 1 elif a * b > 0: if a < 0 and abs(a) < abs(b): num += 2 elif a > 0 and abs(a) > abs(b): num += 2 print(num)
p02694
s989256709
Wrong Answer
x = int(input()) year = 0 deposit = 100 while(deposit < x): year += 1 deposit = int(deposit * 1.01) print(year)