problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03478
s022236551
Wrong Answer
N, A, B = map(int, input().split()) count = 0 num1 = 0 num2 = 0 for i in range(1, N + 1): if i < 10: if i >= A and i <= B: count = count + i else: num1 = str(i)[0] num2 = str(i)[1] num = int(num1) + int(num2) if num >= A and num <= B: count = count + 1 print(count)
p02664
s908164353
Wrong Answer
s = input() ans = '' for i in range(len(s)): s_i = s[i] if s_i == '?': if i < len(s) - 1: if (s[i + 1] == 'D') | (s[i + 1] == '?'): ans += 'P' continue else: ans += 'D' continue else: ans += 'D' continue ans += s_i print(ans)
p03219
s762222235
Wrong Answer
x,y = map(int,input().split()) print(x + y/2)
p03994
s972387778
Wrong Answer
s = input() k = int(input()) cnt = 0 ans = '' for i in range(len(s)): if i == len(s) - 1: # 最後の文字の時 diff = (k - cnt) % 26 ans += chr((ord(s[i]) - ord('a') + (k - cnt)) % 26 + ord('a')) elif ord('z') - ord(s[i]) + 1 <= k - cnt: # 'a'に変更可能な時 cnt += ord('z') - ord(s[i]) + 1 ans += 'a' else: ans += s[i] print(ans)
p02641
s394612452
Wrong Answer
x, n = map(int,input().split()) p = list(map(int,input().split())) p.append(x) d =100 num = 0 if n == 0: num = x else: for i in range(-1,102): if i not in p: d_temp = abs(x-i) if d_temp < d: d = d_temp num = i print(num)
p03605
s600755688
Accepted
c = str(input()) if "9" in c: print("Yes") else: print("No")
p02691
s528115460
Wrong Answer
N=int(input()) A=list(map(int,input().split())) L=[0 for i in range(200010)] R=[0 for i in range(200010)] for i in range(N): if A[i]+i<100010: L[A[i]+i]+=1 if -A[i]+i>0: R[-A[i]+i]+=1 ans=0 for i in range(200010): ans+=L[i]*R[i] print(ans)
p02683
s133292758
Accepted
N, M, X = [int(n) for n in input().split()] CA = [list(map(int, input().split())) for n in range(N)] ans = 10**10 for i in range(2**N): cost = 0 skills = [0] * M for j in range(N): if ((i >> j) & 1): #print(i, j) for k in range(M): skills[k] += CA[j][1+k] cost += CA[j][0] #print("skills", skills) if all([n >= X for n in skills]): ans = min(ans, cost) #print("ans", ans) if ans == 10**10: print(-1) else: print(ans)
p03645
s560103393
Accepted
n, m = map(int, input().split()) g = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) g[a-1].append(b-1) g[b-1].append(a-1) for first in g[0]: if n-1 in g[first]: print("POSSIBLE") exit() else: print("IMPOSSIBLE")
p02631
s732043464
Accepted
n = int(input()) a = list(map(int,input().split())) all = 0 for i in a: all = all ^ i ans = [] for i in a: ans.append(all^i) print(' '.join(map(str,ans)))
p03617
s774067386
Wrong Answer
q,h,s,d=list(map(int, input().split())) x=int(input()) q=q*4 h=h*2 d=d/2 ans=0 if q<=h and q<=s and q<=d: ans=x*q x=0 elif h<=q and h<=s and h<=d: ans=x*h x=0 elif s<=q and s<=h and s<=d: ans=x*s x=0 else: ans=ans+round((x//2)*d*2) x=x-((x//2)*2) if x>0: if q<=h and q<=s: ans=ans+q elif h<=q and h<=s: ans=ans+h else : ans=ans+s print(ans)
p02547
s579278025
Wrong Answer
N=input() n=int(N) x=0 for s in range(n): ds1,ds2=input().split() Ds1=int(ds1) Ds2=int(ds2) if Ds1==Ds2: x+=1 else: x+=0 if x>3: print("Yes") else: print("No")
p02578
s772235926
Wrong Answer
n=int(input()) a=list(map(int,input().split())) s=0 for i in range(len(a)-1): if a[i]>=a[+1]: continue else: s+=a[i+1]-a[i] print(s)
p02916
s081563480
Wrong Answer
n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) sum = 0 for i in range(len(a)): sum += b[a[i] - 1] print("i:{0} sum{1}".format(i, sum)) if(i != len(a) - 1 and a[i] + 1 == a[i + 1]): sum += c[a[i] - 1] print("i:{0} sum{1}".format(i, sum)) print(sum)
p03408
s091369418
Wrong Answer
from collections import defaultdict b = defaultdict(int) r = defaultdict(int) n = int(input()) for i in range(n): b[input()] += 1 m = int(input()) for i in range(m): r[input()] += 1 print(b) print(b.items()) ans = 0 for k, v in b.items(): ans = max(ans, v - r[k]) print(ans)
p02693
s968798932
Accepted
k = int(input()) a,b = map(int,input().split()) d = a//k e = b//k if d!=e or a%k == 0: print('OK') else: print('NG')
p02951
s730167023
Accepted
a, b, c = map(int, input().split()) ans = c - (a - b) if ans >= 0: print(ans) else: print(0)
p02996
s576403905
Wrong Answer
n = int(input()) tsk = [] for i in range(n): a,b = map(int,input().split()) tsk.append([a,b,b-a]) tsk.sort(key = lambda x:x[2]) t = 0 ans = 'Yes' for i in range(n): l = tsk[i] t += l[0] if l[1]<t: ans = 'No' break print(ans)
p02602
s528753105
Accepted
N,K=map(int,input().split()) A=list(map(int,input().split())) for i in range(K,N): if A[i]>A[i-K]: print("Yes") else: print("No")
p03329
s623785814
Accepted
N=int(input()) ans=N for i in range(N+1): cnt=0 t=i while t>0: cnt+=t%6 t//=6 j=N-i while j>0: cnt+=j%9 j//=9 ans=min(ans,cnt) print(ans)
p03095
s094477571
Accepted
import sys from collections import Counter input = sys.stdin.readline P = 10**9 + 7 def main(): N = int(input()) S = input().rstrip() # Editorial AC c = Counter(S) ans = 1 for v in c.values(): ans = (ans * (v + 1)) % P ans = (ans - 1) % P print(ans) if __name__ == "__main__": main()
p02548
s351199970
Wrong Answer
import os,sys count=0 n=int(input()) for a in range(1,n+1): i = n-a for b in range(1,i+1): j=n-a*b for c in range(1,j): if a*b+c==n: count+=1 print(count)
p02948
s844609688
Accepted
import heapq n, m = map(int, input().split()) points = [tuple(map(int, input().split())) for _ in range(n)] points.sort() ans = 0 i = 0 days = 0 heap = [] while days <= m: while i < len(points) and points[i][0] <= days: d, p = points[i] heapq.heappush(heap, -p) i += 1 days += 1 if heap: ans += heapq.heappop(heap) print(-ans)
p02695
s203648493
Accepted
N, M, Q = map(int, input().split()) reqs = [list(map(int, input().split())) for _ in range(Q)] As = [] def make(A): global As, N, M # print(A) if len(A) == N+1: As.append(A) else: for i in range(A[len(A)-1], M+1): make(A+[i]) make([1]) maxs = 0 for A in As: score = 0 for req in reqs: if A[req[1]] - A[req[0]] == req[2]: score += req[3] maxs = max(score, maxs) print(maxs)
p02658
s243972307
Accepted
n = int(input()) a = list(map(int, input().split())) INF = 10 ** 18 ans = 1 if any([n == 0 for n in a]): print(0) exit() for n in a: ans *= n if ans > INF: ans = -1 break print(ans)
p03352
s706047671
Accepted
import sys n=int(input()) ans=[] if n==1: print('1') sys.exit() for i in range(n//2): for j in range(n//2): if i**j<=n: ans.append(i**j) print(max(ans))
p02811
s730567691
Accepted
n=list(map(int,input().split())) a=n[0] b=n[1] if 500*a>=b: print("Yes") else: print("No")
p03696
s460086170
Wrong Answer
n = int(input()) s = input() d = [] cnt = 0 for i in range(n): if s[i] == "(": cnt += 1 else: cnt -= 1 d.append(cnt) x = min(d) print("("*(-x)+s+")"*(d[-1]-x))
p02659
s170166906
Wrong Answer
import math A, B = map(float,input().split()) print(math.floor(A*B))
p03997
s795319918
Accepted
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h//2)
p03797
s264834834
Accepted
N,M = map(int, open(0).read().split()) if 2 * N > M: print(M//2) else: rem = M - 2 * N print(N+rem//4)
p02661
s682804093
Wrong Answer
N = int(input()) AA = [0]*N BB = [0]*N for i in range(N): AA[i], BB[i] = map(int,input().split()) AA_sorted = sorted(AA) BB_sorted = sorted(BB,reverse=True) if N%2 == 1: idx = int(N/2) N_Max = BB_sorted[idx] N_Min = AA_sorted[idx] print(N_Max-N_Min+1) else: idx = int(N/2) N_Max = BB_sorted[idx-1] N_Min = AA_sorted[idx-1] print((N_Max-N_Min)*2-1)
p02818
s549032137
Accepted
a,b,k=map(int,input().split()) eat1=min(a,k) k-=eat1 eat2=min(b,k) print(a-eat1,b-eat2)
p02779
s341177951
Wrong Answer
n = int(input()) b = (int(x) for x in input().split()) a = list(b) x = 0 for i in range(n): if a.count(a[i]) != 1: print("Yes") x = 1 break if x == 0: print("No")
p03221
s967962598
Accepted
from operator import itemgetter n, m = map(int, input().split()) info = [list(map(int, input().split())) + [i] for i in range(m)] info = sorted(info, key=itemgetter(1)) ans = [0] * m cnt_ind = [1] * (n + 1) for i in range(m): p, y, ind = info[i] cnt = cnt_ind[p] cnt_ind[p] += 1 ans[ind] = ("0000000"+str(p))[-6:] + ("0000000"+str(cnt))[-6:] for i in ans: print(i)
p03838
s065902461
Wrong Answer
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines x, y = map(int, readline().split()) if x <= y: if (x > 0 and y > 0) or (x <= 0 and y <= 0): ans = y - x else: ans = y + x + 1 else: if (x >= 0 and y >= 0) or (x < 0 and y < 0): ans = min(abs(x) + abs(y) + 1, abs(y) - abs(x) + 2) else: ans = - x - y + 1 print(ans)
p04019
s574277035
Wrong Answer
s = input() dir = [0 for i in range(4)] for i in range(len(s)): if s[i] == "N": dir[0] += 1 elif s[i] == "W": dir[1] += 1 elif s[i] == "S": dir[2] += 1 elif s[i] == "E": dir[3] += 1 if 0 not in dir: print("Yes") elif dir.count(0) == 3: print("No") elif dir[0] == 0 and dir[0] == 0 or dir[1] == 0 and dir[3] == 0: print("Yes") else: print("No")
p03221
s866159478
Wrong Answer
import numpy as np n, m = map(int, input().split()) py = [list(map(int, input().split())) for i in range(m)] py2 = [py[i].append(i) for i in range(m)] py.sort(key=lambda x: x[1]) now = py[0][0] count = 0 anslist = np.empty((m, 2)) for i in range(m): if now == py[i][0]: count += 1 else: now = py[i][0] count = 1 anslist[py[i][2], 0] = py[i][0] anslist[py[i][2], 1] = count for x, y in anslist: print("{:06}".format(int(x)) + "{:06}".format(int(y)))
p02923
s913448425
Accepted
N = int(input()) H = list(map(int,input().split())) ans = [] count = 0 if len(H) == 1: print(0) exit() for i in range(1,N): if H[i-1] < H[i]: ans.append(count) count = 0 elif H[i-1] >= H[i]: count += 1 if i == N-1: ans.append(count) print(max(ans))
p04030
s839314832
Accepted
n=[] for i in input(): if i=='B': if n: n.pop() else: n.append(i) print(*n,sep='')
p03069
s205496145
Accepted
n = int(input()) s = input() cnt_w, cnt_b = s.count("."), 0 ans = cnt_w if s.count(".") == n or s.count("#") == n: ans = 0 else: for i in range(n): if s[i] == "#": cnt_b += 1 else: cnt_w -= 1 if i == n - 1 or s[i] != s[i + 1]: ans = min(ans, cnt_w + cnt_b) print(ans)
p02755
s579675568
Accepted
import math answer = 0 score = list(map(int,input().split())) Alist = [] for i in range(2000): if math.floor((i+1)*0.08) == score[0]: Alist.append(i+1) for j in range(2000): if math.floor((j+1)*0.10) == score[1]: if j+1 in Alist: print(j+1) answer = 1 break if answer == 0: print(-1)
p02836
s036800086
Accepted
from math import floor def main(): S = input() result = 0 for i in range(floor(len(S) / 2)): if S[i] != S[len(S) - i - 1]: result += 1 print(result) if __name__ == '__main__': main()
p03997
s640206564
Wrong Answer
print((int(input())+int(input()))//2*int(input()))
p03293
s508312668
Wrong Answer
import sys s=input() t=input() r="" for i in range(len(t)): if s==t: print("Yes") sys.exit() r=s[-1] s=s.strip(s[-1]) s=r+s print("No")
p03457
s836981661
Accepted
n = int(input()) t, x, y = [0]*(n+1), [0]*(n+1), [0]*(n+1) for i in range(1,n+1): t[i], x[i], y[i] = map(int, input().split()) for i in range(1, n+1): a = abs(t[i] - t[i-1]) b = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]) if a>=b and a%2 == b%2: continue else: print("No") break else: print("Yes")
p03773
s225504995
Accepted
a,b=map(int, input().strip().split()) print((a+b)%24)
p02623
s582468771
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline N, M, K = map(int, readline().split()) A = list(map(int, readline().split())) B = list(map(int, readline().split())) ac = [0] bc = [0] for i in range(N): ac.append(ac[i] + A[i]) for i in range(M): bc.append(bc[i] + B[i]) ans = 0 j = M for i in range(N+1): if ac[i] > K: break while bc[j] > K - ac[i]: j -= 1 ans = max(ans, i+j) print(ans)
p03219
s034799522
Accepted
x,y = map(int,input().split()) ans = x + y//2 print(ans)
p03106
s674516890
Wrong Answer
A, B, K = map(int, input().split()) max_num = max(A, B) min_num = min(A, B) divs = [m for m in range(1, min_num+1) if min_num % m == 0] ans = [] for d in divs: if max_num % d == 0: ans.append(d) print(ans[K-1])
p02723
s266121193
Wrong Answer
def coffee(ar): if ar[3] == ar[4] and ar[5] == ar[6]: return 'Yes' else: return 'No' if __name__ == '__main__': ar = str(input().split()) result = coffee(ar) print(result)
p03681
s719231515
Accepted
import sys import math import itertools import collections import heapq import re import numpy as np from functools import reduce 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.readline().split())) inf = float('inf') mod = 10**9 + 7 n, m = rm() if n == m: print((math.factorial(n) * math.factorial(m) * 2) % mod) elif abs(n-m) == 1: print((math.factorial(n) * math.factorial(m)) % mod) else: print(0)
p02848
s013127565
Accepted
N = int(input()) S = str(input()) alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZ' out='' for i in range(len(S)): for j in range(len(alphabet)): if S[i]==alphabet[j]: out= out + str(alphabet[(j+N)%(len(alphabet))]) print(out)
p02641
s650015519
Accepted
x, n = map(int, input().split(" ")) p = input() if p == "": print(x) exit(0) p = list(map(int, p.split(" "))) answer = 0 for i in range(1, 102): if i not in p: if abs(x - answer) > abs(i - x): answer = i print(answer)
p02726
s159611275
Accepted
n,x,y = map(int, input().split()) count = [0]*(n-1) for i in range(1,n+1): for j in range(i+1,n+1): d_min = min(abs(i-j),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i)) count[d_min-1] += 1 for i in count: print(i)
p02933
s314010022
Accepted
a=int(input()) s=input() if a>=3200: print(s) else: print("red")
p03150
s767745898
Accepted
#!/usr/bin/env python3 s=input() m="keyence" if s=="keyence": print("YES") elif s[0:7]=="keyence": print("YES") elif s[-8:-1]=="keyence": print("YES") elif s[0]=="k" and s[-1]=="e": ans = "NO" for i in range(6): if s[0:i+1]==m[0:i+1] and s[-6+i:]==m[-6+i:]: ans="YES" print(ans) else: print("NO")
p03254
s241290633
Wrong Answer
n, x = map(int, input().split()) a = list(map(int, input().split())) a.sort() count = 0 for i in a: if x >= i: x -= i count += 1 else: pass print(count)
p02787
s502826526
Accepted
""" dp[与えたダメージ] = 使用した魔力 """ h, n = map(int, input().split()) attacks = [] INF = 10000000000000 dp = [INF for _ in range(h + 1)] dp[0] = 0 for i in range(n): a, b = map(int, input().split()) attacks.append([a, b]) for i in range(h): for j in range(n): dp[min(h,i + attacks[j][0])] = min(dp[min(h, i + attacks[j][0])], dp[i] + attacks[j][1]) print(dp[h])
p02989
s957020473
Wrong Answer
n = int(input()) a = list(map(int,input().split())) a.sort() if n == 2: print(a[1]-a[0]) else: print(a[n//2+1]-a[n//2])
p02719
s973504276
Accepted
N, K = map(int, input().split()) N = N % K # print(N) ans_candidate_list = [N] while True: N = abs(N - K) # print(N) # print(ans_candidate_list) if N not in ans_candidate_list: ans_candidate_list.append(N) else: break print(sorted(ans_candidate_list)[0])
p02730
s763223583
Accepted
S = input() N = len(S) is_strong_pal = (S == S[::-1]) is_strong_pal &= (S[:(N-1)//2] == S[:(N-1)//2:-1]) is_strong_pal &= (S[(N+3)//2-1:] == S[(N+3)//2-1:][::-1]) print('Yes' if is_strong_pal else 'No')
p02881
s519523027
Accepted
N=int(input()) t=2*N i=1 while i*i<=N: if N%i==0: if (i-1)+(N//i-1)<=t: t=(i-1)+(N//i-1) i += 1 print(t)
p02608
s464520639
Accepted
# -*- coding: utf-8 -*- N = int(input()) ans_list = [0 for i in range(N + 1)] for i in range(1, 101): for j in range(1, 101): for k in range(1, 101): now_num = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i if now_num > N: break ans_list[now_num] += 1 for i in range(1, N + 1): print(ans_list[i])
p02732
s432087457
Accepted
import collections c = {0: 0, 1: 0, 2: 1} n = int(input()) sum = 0 for i in range(3, n + 1): c[i] = c[i - 1] * i // (i - 2) cc = collections.defaultdict(int) a = list(map(int, input().split())) for i in a: cc[i] += 1 for k, v in cc.items(): sum += c[v] # print (c) # print (cc) # print (sum) for i in range(n): v = cc[a[i]] # print (v) # print(c[v], c[v - 1]) print (sum - c[v] + c[v - 1])
p02742
s496965033
Wrong Answer
import math H, W = map(int, input().split()) if H == 1 or W == 1: print(0) exit() print(math.ceil((H * W) / 2))
p02708
s849836205
Accepted
MOD=10**9+7 N,K=map(int,input().split()) ans=0 ans+=N-K+2 ans+=(N+1)*(N+1+K)*(N-K+2)//2 ans%=MOD ans-=(N+1)*(N+2)*(2*N+3)//6 ans%=MOD ans+=K*(K-1)*(2*K-1)//6 ans%=MOD print(ans)
p03457
s687676967
Accepted
n = int(input()) t,x,y = 0,0,0 for i in range(n): T,X,Y = map(int,input().split()) dt,dx,dy = T-t,abs(X-x),abs(Y-y) if dt - (dx + dy) < 0 or (dt - (dx + dy))%2 == 1: print("No") exit() t,x,y = T,X,Y print("Yes")
p03545
s302345515
Accepted
a=input() n=len(a) for i in range(2**n): res=int(a[0]) ans=[a[0]] for j in range(1,n): if i&(1<<j): ans.append('+') ans.append(a[j]) res+=int(a[j]) else: ans.append('-') ans.append(a[j]) res-=int(a[j]) if res==7: print(*ans,'=7',sep='') exit()
p02753
s922259962
Wrong Answer
S = list(input()) if set(S) == 2: print("Yes") else: print("No")
p03127
s146052443
Accepted
N = int(input()) A = list(map(int, input().split())) mn = min(A) while True: ok = False for a in A: x = a % mn if x != 0 and x < mn: mn = x ok = True if not ok: break print(mn)
p03281
s521548933
Wrong Answer
N=int(input()) if N<105: print(0) elif N==105: print(1) else: ans=0 for n in range(106,N+1): if n%2: K=n//2 y=0 for k in range(2,K): if n%k==0: y+=1 if y==6: ans+=1 print(ans)
p03284
s767151687
Accepted
def main(): n, k = map(int, input().split()) print(1 if n%k!=0 else 0) if __name__ == '__main__': main()
p03836
s632582987
Wrong Answer
sx, sy, tx, ty = map(int, input().split()) dx, dy = tx-sx, ty-sy ans = "" ans += "L" + (dy+1)*"U" + (dx+1)*"R" + "D" ans += dy*"U" + dx*"R" ans += dx*"R" + dy*"U" ans += "D" + (dx+1)*"R" + (dy+1)*"U" + "L" print(ans)
p02730
s401467755
Accepted
s = input() ans = True for i in range(len(s) // 2): if s[len(s) - 1 - i] != s[i]: ans = False if ans: for i in range(len(s) // 4): if s[(len(s) - 1) // 2 - i - 1] != s[i]: ans = False for i in range(len(s) // 2 + 1, len(s) // 4 + len(s) // 2 + 1): if s[i] != s[len(s) - 1 - i]: ans = False print('Yes' if ans else 'No')
p02982
s352837203
Wrong Answer
n,d=map(int,input().split()) x= [list(map(int, input().split())) for i in range(n)] lis=list(i**2 for i in range(0,22)) ans=0 for i in range(n): for k in range(i+1,n): check=0 for j in range(d): check+=(x[i][j]-x[k][j])**2 if check in lis: ans+=1 print(ans)
p03328
s197958789
Wrong Answer
a,b=map(int,input().split()) count=0 for i in range(1000): count+=i if 0<=count-a<=a: print(count-a) exit()
p03556
s133715625
Accepted
n=int(input()) l=[] for i in range(int(n**0.5)+1): l.append(i**2) print(max(l))
p02693
s271552193
Accepted
from sys import stdin def main(): input = lambda: stdin.readline()[:-1] K = int(input()) A, B = map(int, input().split()) for i in range(A, B + 1): if not i % K: print('OK') return print('NG') main()
p02924
s432528175
Accepted
n = int(input()) print(n * (n - 1) // 2)
p02923
s395909750
Wrong Answer
N = int(input()) H = input().split() l=0 t_l = 0 for i in range(N-1): if H[i] >= H[i+1]: t_l = t_l + 1 if l < t_l: l = t_l else: t_l=0 print(l)
p03493
s791292892
Accepted
S = input() print(S.count('1'))
p04020
s404295649
Wrong Answer
n = int(input()) a1 = int(input()) flag= a1%2 ans = a1//2 for i in range(n-1): a = int(input()) ans+=a//2 if flag and a%2==1: ans+=1 flag=0 else: flag=a%2 print(ans)
p03076
s386530988
Wrong Answer
ae = [int(input()) for i in range(5)] mm = ae[0]%10 for i in range(5): mm = min(mm, ae[i]%10) if ae[i]%10 != 0: ae[i] = ((ae[i]//10)+1)*10 if mm != 0: print(sum(ae)-(10-mm)) else: print(sum(ae))
p03221
s190384782
Accepted
N, M = map(int, input().split()) pref = [1] * (N + 1) iPY = [] for i in range(M): p, y = map(int, input().split()) iPY.append([i, p, y]) iPY.sort(key=lambda x: x[2]) ans = [] for i, p, y in iPY: name = str(p).zfill(6) + str(pref[p]).zfill(6) ans.append((i, name)) pref[p] += 1 ans.sort(key=lambda x: x[0]) for _, name in ans: print(name)
p02917
s617048873
Accepted
n = int(input()) b = list(map(int,input().split())) sum = b[n-2] + b[0] for i in range(n-2): sum += min(b[i],b[i+1]) print(sum)
p02759
s734356163
Accepted
import sys input = sys.stdin.readline print(-(-int(input()) // 2))
p04020
s770044666
Accepted
from sys import stdin n = int(stdin.readline().rstrip()) li = [int(stdin.readline().rstrip()) for _ in range(n)] count = 0 point = 0 for i in li: if i == 0: point += count//2 count = 0 else: count += i point += count//2 print(point)
p02723
s763551455
Wrong Answer
s = input() if(s[2] == s[3] and s[4] == s[5]): print("YES") else: print("NO")
p03449
s501532219
Wrong Answer
N = int(input()) A1 = list(map(int, input().split())) A2 = list(map(int, input().split())) max = 0 for i in range(N): point = sum(A1[:i]) + sum(A2[i:]) if max < point: max = point print(max)
p03543
s228062159
Wrong Answer
n=input() print('Yes' if n.count(n[0])>=3 or n.count(n[1])>=3 else 'No')
p02948
s884684200
Accepted
# イベントソートでもできると思う import heapq N, M = map(int, input().split()) event_list = [[m, 10**5] for m in range(1, M+1)] for i in range(N): a, b = map(int, input().split()) event_list.append([a, b]) event_list.sort() jobs = [] ans = 0 for event in event_list: if event[1] < 10**5: heapq.heappush(jobs, -event[1]) else: if jobs: ans -= heapq.heappop(jobs) print(ans)
p02900
s739806298
Accepted
import math from collections import Counter a, b = map(int, input().split()) x = math.gcd(a, b) Nso = [] Nruto = math.sqrt(x) Nruto = math.floor(Nruto) for i in range(2, Nruto+1): while x % i == 0: x = x//i Nso.append(i) if x == 1: break Nruto = math.sqrt(x) Nruto = math.floor(Nruto) Nso.append(x) Nso.append(1) Nso = Counter(Nso) print(len(Nso))
p03449
s951728022
Accepted
n = int(input()) a = [[0] * n for i in range(2)] for i in range(2): arr = input().split() arr = list(map(int,arr)) for j in range(n): a[i][j] = arr[j] m = 0 for i in range(n): l = 0 r = 0 for k in range(i+1): l += a[0][k] for k in range(i,n): r += a[1][k] if m <= l + r: m = l + r print(m)
p03760
s060782050
Wrong Answer
O = input() E = input() a = '' cnt = 0 for i in O: a += i cnt += 1 if (len(O) == cnt)and(len(O)>len(E)): break for j in E: a += j E = E.lstrip(j) break print(a)
p02702
s398182126
Accepted
S = input() Sliststr = list(S) Slist = [int(s) for s in Sliststr] Smod = [0] mod10 = [1] count = [0]*2019 ans = 0 for i in range(len(S)-1): mod10.append(mod10[i]*10%2019) for i in range(len(S)): Smod.append((Smod[i]+Slist[-i-1]*mod10[i])%2019) for i in range(len(Smod)): count[Smod[i]] += 1 for i in range(2019): ans += count[i] * (count[i]-1) // 2 print(ans)
p02705
s776532908
Accepted
import math n=float(input()) print(n*2*math.pi)
p02729
s898223743
Accepted
n, m = map(int, input().split()) ans = 0 if n > 1: ans += n * (n - 1) // 2 if m > 1: ans += m * (m - 1) // 2 print(ans)
p03435
s316418181
Accepted
c = [list(map(int, input().split())) for i in range(3)] print("Yes" if c[1][0]-c[0][0]==c[1][1]-c[0][1]==c[1][2]-c[0][2] and c[2][0]-c[0][0]==c[2][1]-c[0][1]==c[2][2]-c[0][2] else "No")
p03471
s690053498
Wrong Answer
N, Y = map(int, input().split()) total = 0 for a in range(N): for b in range(N): c = N -a -b total = a*10000 + b*5000 + c*1000 if (total == Y) and (a+b+c==N) and (c>=0): print(a, b, c) exit() print(-1,-1,-1)