problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p04033
s751518580
Accepted
a, b = map(int, input().split()) if a <= 0 and b >= 0: print('Zero') if b < 0: if (b - a) % 2 == 0: print('Negative') else: print('Positive') if a > 0: print('Positive')
p02646
s999649704
Accepted
a,v=map(int,input(). split()) b,w = map(int,input(). split()) t=int(input()) if a<=b: dist_a = a + t*v dist_b = b + t*w if dist_a>=dist_b: print('YES') else: print('NO') else: dist_a = a - t*v dist_b = b - t*w if dist_a<=dist_b: print('YES') else: ...
p02838
s502981360
Accepted
N = int(input()) MOD = 1e+9 + 7 shift = 70 a = [int(i) for i in input().split()] b = [0 for _ in range(shift)] for i in a: for j in range(shift): b[j] += (i >> j) & 1 ans = 0 for i, j in enumerate(b): ans += ((j * (N - j)) * 2**i) % MOD print(int(ans%MOD))
p02935
s746707894
Wrong Answer
N = int(input()) v = list(map(int, input().split())) while True: if len(v) == 1: print(v[0]) break s = sum(v) t = (-1, -1, 0) for i in range(len(v)): for j in range(i, len(v)): x = s - v[i]/2 - v[j]/2 if x > t[2]: t = (i, j, x) x = v.po...
p02948
s441063851
Accepted
import heapq n,m=map(int, input().split()) lst = [] for i in range(n): a,b=map(int, input().split()) lst.append((-b,a)) lst = sorted(lst, key=lambda x:x[1]) now_idx = 0 queue = [] sum_ = 0 for i in range(1,m+1): for j in range(now_idx, n): if lst[j][1] <= i: heapq.heappush(queue, lst[j]) else: ...
p02596
s699479207
Wrong Answer
k = int(input()) if k % 2 == 0 or k % 5 == 0: print(-1) exit() num = 7 for i in range(1, k): if num % k == 0: print(i) break num = (num % k) * 10 + 7
p03105
s007415241
Accepted
a,b,c = map(int,input().split()) print(min(b//a,c))
p03041
s578592191
Accepted
_, K = [int(i) for i in input().split()] S = input() print(S[:K - 1] + S[K - 1].lower() + S[K:])
p03627
s949535435
Accepted
N=int(input()) A=list(map(int, input().split())) s=set([]) ans=[] A.sort(reverse=True) for a in A: if a not in s: s.add(a) else: ans.append(a) s.discard(a) if len(ans)>=2: break if len(ans)<2: print(0) else: print(ans[0]*ans[1])
p03071
s084575346
Accepted
a,b=map(int,input().split()) if a-1>=b: print(2*a-1) elif b-1>=a: print(2*b-1) else : print(a+b)
p03860
s780419228
Accepted
a,b,c = map(str,input().split()) print(a[0]+b[0]+c[0])
p03387
s352676548
Accepted
A = list(map(int, input().split())) A.sort() Ans = 0 temp = (A[2] - A[0])//2 Ans += temp A[0] += temp*2 temp = (A[2] - A[1])//2 Ans += temp A[1] += temp*2 if A[0] == A[1] == A[2]: print(Ans) elif A[0] == A[1]: print(Ans+1) else: print(Ans+2)
p02897
s168517429
Wrong Answer
import sys import math import bisect def main(): n = int(input()) ans = (n//2) / n print('%.10f' % ans) if __name__ == "__main__": main()
p02712
s982709496
Accepted
def extract(seq): arr = [] for i in seq: if i % 3 == 0 or i % 5 == 0: continue else: arr.append(i) return sum(arr) n = int(input()) print(extract(range(1, n + 1)))
p03721
s879796296
Accepted
n,k=map(int,input().split()) ab=[list(map(int,input().split())) for i in range(n)] res=k ab.sort() for i in range(n): res-=ab[i][1] if res<=0: print(ab[i][0]) exit()
p02836
s591125975
Accepted
#!/usr/bin/env python3 #%% for atcoder uniittest use import sys input= lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**9) def pin(type=int):return map(type,input().split()) def tupin(t=int):return tuple(pin(t)) def lispin(t=int):return list(pin(t)) #%%code from fractions import gcd def resolve(): S=...
p03434
s000556496
Wrong Answer
n=int(input()) a=list(map(int,input().split())) a=sorted(a) ans=0 for i in range(n): ans+=a[-i]*(-1)**(i+1) print(ans)
p03352
s369466310
Wrong Answer
import math x = int(input()) ans = 1 for i in range(2, x): p_max = math.floor(math.log(x, i)) if p_max < 2: break ans = max(ans, i**p_max) print(ans)
p03723
s744524969
Accepted
A, B, C = map(int, input().split()) cnt = 0 while(1): if A%2!=0 or B%2!=0 or C%2!=0: break A_tmp = A B_tmp = B C_tmp = C A = (B_tmp+C_tmp)/2 B = (A_tmp+C_tmp)/2 C = (A_tmp+C_tmp)/2 cnt += 1 if A_tmp==A and B_tmp==B and C_tmp==C: cnt = -1 break print(cnt)
p02727
s599821729
Wrong Answer
X, Y, A, B, C = list(map(int,input().split())) p = list(map(int,input().split())) q = list(map(int,input().split())) r = list(map(int,input().split())) p.sort(reverse=True) q.sort(reverse=True) r.sort(reverse=True) Z = 0 while Z < C: if p[X - 1] < r[Z]: X -= 1 Z += 1 elif q[Y - 1] < r[Z]: Y -= 1 ...
p02933
s542424597
Wrong Answer
a=int(input()) s=input() if a>=3200: print('s') else: print('red')
p02645
s813362645
Accepted
import sys def input():return sys.stdin.readline()[:-1] def N(): return int(input()) def NM():return map(int,input().split()) def L():return list(NM()) def LN(n):return [N() for i in range(n)] def LL(n):return [L() for i in range(n)] s=input() print(s[:3])
p03681
s369891267
Wrong Answer
import math N, M = map(int, input().split()) if abs(N - M) > 2: print(0) exit() N = math.factorial(N) % (10 ** 9 + 7) M = math.factorial(M) % (10 ** 9 + 7) if N == M: print((N * M * 2) % (10 ** 9 + 7)) else: print((N * M) % (10 ** 9 + 7))
p02647
s979108849
Wrong Answer
import numpy as np def read_input(trans=int): return list(map(trans, input().split())) N, K = read_input() A = np.array(read_input(), dtype="int") coordinate = np.arange(1, N+1) limit_count = int(np.log10(N)) for _ in range(limit_count): B = np.zeros(N, dtype="int") for i in range(N): end = np....
p03544
s553297439
Accepted
s = input() n = int(s) lucas = [2, 1] x = 0 index = 0 while (index < n): x = lucas[index] + lucas[index + 1] lucas.append(x) index += 1 print(lucas[index])
p03251
s569444151
Accepted
n,m,x,y = [int(x) for x in input().split()] a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] max_x = max(a) min_y = min(b) max_x = max(max_x,x) min_y = min(min_y,y) if max_x < min_y: print("No War") else: print("War")
p03493
s919627155
Accepted
s = input() ans = 0 for c in s: if c == '1': ans += 1 print(ans)
p03627
s356582107
Accepted
from collections import Counter n = int(input()) A = list(map(int, input().split())) C = Counter(A) L = [] for k, v in C.items(): if v >= 2: L.append(k) if v >= 4: L.append(k) if len(L) < 2: print(0) else: L.sort() ans = L[-1] * L[-2] print(ans)
p04044
s830658101
Wrong Answer
N, L = map(int, input().split()) strs = sorted([''.join(sorted(list(input()))) for _ in range(N)]) print(''.join(strs))
p02847
s905665875
Accepted
S=input() List = ['SAT','FRI','THU','WED','TUE','MON','SUN'] for i in range (len(List)): if List[i] == S: print(i+1)
p03774
s049797298
Accepted
N,M = map(int,input().split()) ab = [list(map(int,input().split())) for _ in range(N)] cd = [list(map(int,input().split())) for _ in range(M)] for x1,y1 in ab: tmp = float('inf') ans = None for num,xy2 in enumerate(cd): x2 = xy2[0] y2 = xy2[1] dist = abs(x1-x2)+abs(y1-y2) if...
p02596
s357718308
Wrong Answer
cnt = 1 mod = 7 k = int(input()) for i in range(k): if mod % k == 0: break cnt += 1 mod = (mod * 10 * 7) % k if mod % k == 0: print(cnt) else: print(-1)
p03472
s307565690
Accepted
from collections import deque N, H = map(int, input().split()) a, b = [], [] for _ in range(N): a_, b_ = map(int, input().split()) a.append(a_) b.append(b_) a.sort() b.sort() maxa = a[-1] que = deque(b) cnt = 0 while H > 0: if not que: cnt += -(-H//maxa) break maxb = que.pop() if...
p03548
s323664168
Wrong Answer
x, y, z = map(int,input().split()) result = 0 while y*result + z*result <= x: result += 1 print(result)
p02833
s397080352
Accepted
n = int(input()) if n % 2: print(0); exit() n //= 2 ans = 0 while n >= 5: n //= 5 ans += n print(ans)
p03352
s585977390
Accepted
# # Written by NoKnowledgeGG @YlePhan # ('ω') # #import math #mod = 10**9+7 #import itertools #import fractions #import numpy as np #mod = 10**4 + 7 """def kiri(n,m): r_ = n / m if (r_ - (n // m)) > 0: return (n//m) + 1 else: return (n//m)""" def main(): x = int(input()) ans = 1 for i in range(1,x...
p02690
s373008647
Accepted
X = int(input()) A = range(-400, 400) for a in A: for b in A: if X == a ** 5 - b ** 5: print(a, b) exit()
p03000
s927521556
Accepted
n,x = list(map(int,input().split())) l = list(map(int,input().split())) l.insert(0,0) r = 0 n_l = [] for i in l: r += i n_l.append(r) ans = 0 for i in n_l: if i <= x: ans += 1 print(ans)
p02761
s631373351
Accepted
N,M=map(int,input().split()) s,c=[0]*M,[0]*M for i in range(M): s[i],c[i] = map(int,input().split()) for i in range(10**N): if len(str(i)) != N: pass else: num=list(str(i)) ok = True for j in range(M): if num[s[j]-1] != str(c[j]): ok = False ...
p02675
s042432715
Accepted
n = input() hon = ["2", "4", "5", "7", "9"] pon = ["0", "1", "6", "8"] if n[-1] in hon: print("hon") elif n[-1] in pon: print("pon") else: print("bon")
p03645
s107748433
Accepted
N,M = map(int,input().split()) N_List = [] O_List = [] for i in range(M): a,b = map(int,input().split()) if a == 1: N_List.append(b) if b == 1: N_List.append(a) if a == N: O_List.append(b) if b == N: O_List.append(a) print(("IMPOSSIBLE","POSSIBLE")[len(set(N_List) &...
p02583
s415948797
Accepted
n=int(input()) l=sorted(list(map(int, input().split()))) ans=0 for i in range(len(l)): for j in range(i+1, len(l)): for k in range(j+1, len(l)): if l[i]==l[j] or l[j]==l[k] or l[k]==l[i]: continue if l[i]+l[j]>l[k]: ans+=1 print(ans)
p02688
s833577720
Accepted
n,k = map(int,input().split()) s = [] for i in range(k): d = int(input()) a = list(map(int,input().split())) for j in range(d): s.append(a[j]) s = set(s) print(n-len(s))
p03723
s162151907
Wrong Answer
A,B,C=map(int,input().split()) ans=0 if A==B and B==C: ans=-1 pass else: while True: if A%2!=0 or B%2!=0 or C%2!=0: break A,B,C=B/2+C/2,A/2+C/2,A/2+B/2 ans+=1 print(ans)
p03779
s627148093
Wrong Answer
n = int(input()) ng =0 ok=n while abs(ok-ng)>1: mid=(ok+ng)//2 if mid*(1+mid)//2>=n: ok=mid else: ng = mid if ok != n: ok+=1 print(ok)
p03804
s712651669
Accepted
N, M = map(int, input().split()) image = [] template = [] for _ in range(N): image.append([c for c in input()]) for _ in range(M): template.append([c for c in input()]) # 左上の座標が与えられる def is_match(a, b): for i in range(M): for j in range(M): if template[i][j] != image[a + i][b + j]: retur...
p03241
s346926831
Accepted
n,m=map(int,input().split()) a=[] for i in range(1,int(m**.5)+1): if m%i==0: ans=i a.append(i) if i==m//n:break else: for i in a: if m//i<=m//n: ans=m//i break print(ans)
p03380
s813439289
Accepted
n = int(input()) a = list(map(int, input().split())) ans1 = max(a) a.remove(ans1) val = ans1 / 2 ans2 = int(1e10) val2 = int(1e10) # print(val) for i in range(n-1): if abs(a[i] - val) < val2: ans2 = a[i] val2 = abs(a[i] - val) #print(ans2,abs(a[i] - val)) print(ans1, ans2)
p03679
s703925721
Accepted
x, a, b = map(int, input().split()) if a >= b: print("delicious") elif x < b-a: print("dangerous") else: print("safe")
p02657
s560924289
Accepted
a,b = map(int, input().split()) print(a*b)
p03548
s762206885
Wrong Answer
x,y,z = map(int,input().split()) ans = int(x/(y+z)) if x%(y+z) == 0: ans -= 1 print(ans)
p03943
s610515839
Wrong Answer
a,b,c = map(int, input().split()) if a+c == b or b+c == a: print("Yes") else: print("No")
p03544
s812230492
Accepted
n = int(input()) a = 2 b = 1 for i in range(n): if(i == 0): preb = b b = a + b a = preb else: prea = a preb = b a = b b = prea + b print(a)
p02548
s954296461
Wrong Answer
from scipy.special import comb def factorize(n): b = 2 fct = [] while b * b <= n: while n % b == 0: n //= b fct.append(b) b = b + 1 if n > 1: fct.append(n) return fct N = int(input()) print(sum([comb(len(factorize(N-C)) + 1, 2, exact=True) for C in r...
p03760
s564610561
Wrong Answer
O = input() E = input() for o,e in zip(O,E): print(o,e,end="",sep="") if len(O)>len(E): print(O[-1],end="")
p04030
s414738613
Wrong Answer
s = list(input()) l = [] for i in range(len(s)): if s[i] == "B": l.append(i) for i in l: s[i] = "" if i-1 >= 0: s[i-1] = "" print("".join(s))
p02982
s670421125
Wrong Answer
import sys import math import itertools import collections import heapq import re import numpy as np rr = lambda: sys.stdin.readline().rstrip() rs = lambda: sys.stdin.readline().split() ri = lambda: int(sys.stdin.readline()) rm = lambda: map(int, sys.stdin.readline().split()) rl = lambda: list(map(int, sys.stdin.readl...
p03951
s683767492
Accepted
n = int(input()) s = input() t = input() ans = n for i in range(n): if s[i:] == t[:-i + n]: break else: ans += 1 print(ans)
p02793
s204474557
Accepted
import sys from fractions import gcd sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) MOD = 10 ** 9 + 7 N = ir() A = lr() # lcm lcm = 1 answer = 0 for a in A: coef = a // gcd(lcm, a) answer *= coef lcm *= coef answer += lcm // a answer %=...
p03633
s296325833
Accepted
N=int(input()) T=list(int(input()) for _ in range(N)) def gcd(a, b): while b: a, b = b, a%b return a ans=T[0] for i in range(1, N): ans=ans*T[i]//gcd(ans, T[i]) print(ans)
p02756
s293068082
Accepted
s = input() q = int(input()) t = 0 form = "" late = "" for i in range(q): l = list(input().split()) if l[0] == "1": t += 1 else: if t % 2 == 0: if l[1] == "1": form = l[2] + form else: late += l[2] else: if l[1] == "1": late += l[2] else: form = ...
p02657
s697320646
Accepted
X, Y = map(int,input().split()) print(X * Y)
p02924
s472354566
Accepted
N = int(input()) ans = N * (N - 1) // 2 print(ans)
p03059
s111607443
Accepted
from sys import exit import math ii = lambda : int(input()) mi = lambda : map(int,input().split()) li = lambda : list(map(int,input().split())) a,b,t = mi() print(((t)//a)*b)
p03387
s412015029
Wrong Answer
a,b,c = map(int,input().split()) m = max(a,b,c) n = 0 flg = False if a != m: n += (m - a) // 2 if (m - a) % 2 == 1: flg = True if b != m: n += (m - b) // 2 if (m - b) % 2 == 1: flg = True if c != m: n += (m - c) // 2 if (m - c) % 2 == 1: flg = True if flg: n += 1 prin...
p02727
s400253129
Accepted
x,y,a,b,c = map(int,input().split()) p = sorted(list(map(int,input().split())),reverse = True) q = sorted(list(map(int,input().split())),reverse = True) r = sorted(list(map(int,input().split())),reverse = True) pre = sorted(p[:x]+q[:y]) for i in range(min(x+y,c)): if pre[i] < r[i]: pre[i] = r[i] else: break...
p03485
s186962418
Accepted
import sys sys.setrecursionlimit(4100000) import math import itertools INF = float('inf') from heapq import heapify, heappop, heappush def main(): a,b = map(int, input().split()) print(math.ceil((a+b)/2)) if __name__ == '__main__': main()
p03221
s868912611
Accepted
n, m = map(int, input().split()) PY = [list(map(int, input().split())) + [i] for i in range(m)] PY.sort(key=lambda x: (x[0], x[1])) prefec = 0 cnt = 1 for py in PY: if py[0] != prefec: prefec = py[0] cnt = 1 py.append(cnt) cnt += 1 PY.sort(key=lambda x: x[2]) for py in PY: print('{0:...
p02873
s280082727
Accepted
s = input() l = [] cnt = 0 flg = 0 for c in s: if (c == '<') ^ flg: cnt += 1 else: l.append(cnt) flg ^= 1 cnt = 1 l.append(cnt) if len(l) % 2: l.append(0) ans = 0 for i in range(len(l) // 2): x = l[i * 2] y = l[i * 2 + 1] ans += x * (x - 1) // 2 + y * (y - 1) // 2...
p02682
s334944691
Accepted
a,b,c,k = map(int,input().split()) if a >= k: print(k) elif a + b >= k: print(a) else: d = k - a - b print(a -d)
p02861
s442614927
Accepted
import itertools N=int(input()) point=[] for _ in range(N): x,y=map(int,input().split()) point.append([x,y]) nums=[i for i in range(1,N+1)] perm=list(itertools.permutations(nums,N)) dist=0 for pattern in perm: tmp_dist=0 for i in range(N-1): tmp_dist+=((point[pattern[i]-1][0]-point[pattern[i+1]...
p02789
s318411621
Wrong Answer
def get_sieve_of_eratosthenes(n): prime = [2] limit = int(n ** 0.5) data = [i + 1 for i in range(2, n, 2)] while True: p = data[0] if limit <= p: return prime + data prime.append(p) data = [e for e in data if e % p != 0] for i in range(2, 7): print(10 ** i, ":", len(get_sieve_of_eratost...
p02879
s099393252
Accepted
a,b=map(int,input().split()) if a<10 and b<10: print(a*b) else: print(-1)
p03471
s503137546
Accepted
N, Y = map(int, input().split()) x, y, z = -1, -1, -1 for i in range(N+1): for j in range(N-i+1): k = N - i - j if 10000*i+5000*j+1000*k == Y: x, y, z = i, j, k break print(x, y, z)
p03624
s240694783
Wrong Answer
s = input() for i in range(97, 123): print(i, chr(i)) if s.find(chr(i)) == -1: print(chr(i)) exit() print('None')
p03042
s442532692
Accepted
a = input() if int(a[:2]) < 13 and int(a[:2]) > 0: if int(a[2:4]) < 13 and int(a[2:4]) > 0: print('AMBIGUOUS') else: print('MMYY') elif int(a[2:]) < 13 and int(a[2:]) > 0: print('YYMM') else: print('NA')
p02571
s227138497
Accepted
s = input() t = input() ans = 0 for i in range(len(s)-len(t)+1): cnt = 0 for j in range(len(t)): if s[i+j] == t[j]: cnt += 1 ans = max(ans,cnt) print(len(t)-ans)
p02963
s615847524
Accepted
import math S = int(input()) sqrtS = math.ceil(math.sqrt(S)) rest = sqrtS*sqrtS - S X1,Y1 = 0,0 X2,Y2 = sqrtS, 1 X3,Y3 = rest, sqrtS print("{} {} {} {} {} {}".format(X1,Y1,X2,Y2,X3,Y3))
p03251
s492137133
Accepted
n,m,x,y=map(int,input().split()) xx=sorted(list(map(int,input().split()))) yy=sorted(list(map(int,input().split()))) ans="War" if xx[-1]<yy[0] and xx[-1]<y and x<yy[0]: ans="No War" print(ans)
p03997
s417140183
Accepted
#台形 def ABC_45_A(): a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2)) if __name__ == '__main__': ABC_45_A()
p03160
s575891262
Wrong Answer
N = int(input()) h = list(map(int, input().split(" "))) dp = [1000000 for i in range(N)] dp[0] = 0 i = 0 for i in range(0, N-1): dp[i + 1] = min(dp[i + 1], abs(h[i + 1] - h[i]) + dp[i]) if i + 2 < len(h) - 1: dp[i + 2] = min(dp[i + 2], abs(h[i + 2] - h[i]) + dp[i]) print(dp[-1])
p02714
s710145968
Accepted
N = int(input()) S = str(input()) r = S.count("R") g = S.count("G") b = S.count("B") ct = r*g*b for i in range(N-2): for j in range(i+1,N-1): k = 2*j-i if k<=N-1: if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]: ct-=1 print(ct)
p02862
s392798864
Accepted
import math X, Y = map(int, input().split()) if X > Y: X, Y = Y, X if ((2*X-Y) % 3 != 0) or (2*X-Y < 0): print(0) exit() A = (2*X-Y)//3 B = Y-X+A N = A+B nu = 1 de = 1 for i in range(B+1, N+1): nu = (nu * i) % (10 ** 9 + 7) for i in range(1, A+1): de = (de * i) % (10 ** 9 + 7) print((nu * pow(de, -1, 10 *...
p02796
s207134237
Wrong Answer
n=int(input()) a =[] for _ in range(n): a.append([int(i) for i in input().split()]) a.sort(key = lambda x : x[0]) #a.sort(key = lambda x : x[1]) #print(a) curi = 0;curj=1 cnt=1 while(curj<n): if a[curi][0]+a[curi][1] <= a[curj][0]-a[curj][1]: curi=curj cnt+=1 else: curi= min(curi,curj) curj+=1 ...
p03062
s366217665
Accepted
#!/usr/bin/env python3 n = int(input()) a = list(map(int, input().split())) num_minus = 0 for i in range(n): if a[i] < 0: num_minus += 1 a_plus = [abs(i) for i in a] # print(num_minus) # print(a_plus) if num_minus % 2 == 0: print(sum(a_plus)) else: print(sum(a_plus)-2*min(a_plus))
p02661
s248697589
Accepted
N = int(input()) X = [list(map(int,input().split())) for _ in range(N)] A = sorted([X[i][0] for i in range(N)]) B = sorted([X[i][1] for i in range(N)]) if N%2==1: a = A[N//2] b = B[N//2] print(b-a+1) else: a = (A[(N-1)//2]+A[N//2])/2 b = (B[(N-1)//2]+B[N//2])/2 print(int((b-a)/0.5)+1)
p03328
s955364047
Wrong Answer
a,b = map(int,input().split()) print((1+(b-a))*(b-a))
p02663
s048912484
Wrong Answer
H1, M1, H2, M2, K = map(int, input().split()) print(H2*60+M2 - H1*60+M1 - K)
p02555
s959958100
Wrong Answer
s=int(input()) kaisu=s//3-1 num=s-6 a=list(range(1,s+1)) total=0 for i in range(kaisu): total+=a[num] if num-3>0: a[i+3]=sum(a[0:i]) print(total)
p02572
s019389114
Accepted
n = int(input()) a = list(map(int, input().split())) all_sum = (sum(a) ** 2) diff = [(a[i] ** 2) for i in range(n)] ans = (all_sum - sum(diff)) // 2 print(ans % (10 ** 9 + 7))
p03951
s544030416
Accepted
N = int(input()) S = input() T = input() kaburi = 0 for i in range(N): #sの末尾とtの先頭を比べる #print("sの末尾"+str(i+1)+"文字目"+S[-(i+1):]) #print("Tの先頭"+str(i+1)+"文字目"+T[0:i+1]) if S[-(i+1):] == T[0:i+1]: kaburi = len(S[-(i+1):]) print(2*N-kaburi)
p03438
s375127495
Accepted
n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] cnta = 0 cntb = 0 k = sum(b)-sum(a) for i in range(n): d = abs(a[i]-b[i]) if a[i] > b[i]: cntb += d else: cnta += (d+1)//2 cntb += d%2 if k < 0 or cntb > cnta or k != 2*cnta - cntb: ans...
p02860
s396483321
Accepted
n = int(input()) s = input() if(n % 2 == 0 and s[n//2:] * 2 == s): print("Yes") else: print("No")
p02726
s606037217
Accepted
from collections import Counter n, x, y = list(map(int, input().split())) counter = Counter() for i in range(1, n): for j in range(i+1, n+1): k = min(j - i, abs(i-x) + abs(j-y) + 1) counter[k] += 1 for cnt in range(1, n): print(counter[cnt])
p03951
s604293232
Accepted
n = int(input()) s = input() t = input() ans = len(s) + len(t) c= 0 for i in range(n): j = n-i if s[i:] == t[:j]: ans = len(s[i:]) + len(t[:i]) + c break else: c+=1 print(ans)
p03721
s121431322
Accepted
N, K = map(int, input().split()) cnt = [0 for _ in range(10**5 + 10)] for i in range(N): a, b = map(int, input().split()) cnt[a] += b res = 0 for i in range(len(cnt)): res += cnt[i] if res >= K: break print(i)
p03605
s824890646
Wrong Answer
s = input().split() if s.count("9") > 0: print("Yes") else: print("No")
p03645
s520757428
Accepted
n, m = map(int, input().split()) reachable_islands_from_1 = [] # (using just one boat service) reachable_islands_from_n = [] # same for _ in range(m): a, b = map(int, input().split()) if a == 1: reachable_islands_from_1.append(b) elif b == n: reachable_islands_from_n.append(a) if len(list(set(reac...
p02725
s905250152
Wrong Answer
k, n = map(int, input().split()) a = list(map(int, input().split())) m = 0 for i in range(n-1): d = a[i+1] - a[i] m = max(m, d) d_last = k - a[n-1] m = max(m, d_last) res = k - m print(res)
p02621
s832773278
Wrong Answer
a = int(input()) ans = a+a*2+a*3 print(ans)