problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02726
s012924803
Accepted
def main(): n, x, y = map(int, input().split()) ans = [0] * n for i in range(1,n): for j in range(i+1, n+1): r1 = j-i r2 = abs(x-i) + 1 + abs(j-y) r3 = abs(y-i) + 1 + abs(j-x) ans[min(r1,r2,r3)] += 1 for i in range(1,n): print(ans[i]) if __name__ == "__main__": main()
p02924
s852113211
Accepted
def main(): ''' N = aq + r (0 <= r <= a-1)よりΣrを最大にするのはr = a-1のとき ''' N = int(input()) print(N * (N - 1) // 2) if __name__ == '__main__': main()
p03000
s267081143
Accepted
n,x = map(int,input().split(" ")) l = list(map(int,input().split(" "))) y = 0 for i in l: y += i if y <= x: print(n+1) else: count = 1 d = 0 j = 0 while d < x: d += l[j] j += 1 if d <= x: count += 1 print(count)
p03012
s560969579
Accepted
n = int(input()) w = list(map(int, input().split())) m = [] for i in range(n - 1): T1 = sum(w[:i - 2]) T2 = sum(w) - T1 m.append(abs(T1 - T2)) print(min(m))
p02601
s526032363
Accepted
import sys def Ss(): return sys.stdin.readline().rstrip().split(' ') def Is(): ss = Ss() return map(int, ss) if len(ss) > 1 else int(ss[0]) a, b, c = Is() k = Is() while b <= a: b = b * 2 k = k - 1 while c <= b: c = c * 2 k = k - 1 print('Yes' if k >= 0 else 'No')
p02647
s790639433
Accepted
import itertools N, K = map(int, input().split()) A = list(map(int, input().split())) end = [N] * N for _ in range(K): lst = [0] * N for i, a in enumerate(A): lst[max(0, i - a)] += 1 if i + a + 1 < N: lst[i + a + 1] -= 1 A = list(itertools.accumulate(lst)) if A == end: break print(*A)
p02596
s917087510
Accepted
def main(): k = int(input()) num = 1 n = 7 if (k % 2 == 0): print(-1) return for i in range(1000000): if (n % k == 0): print(num) return else: n = (n*10 + 7) %k num += 1 print(-1) if __name__ == '__main__': main()
p02681
s158200155
Accepted
s = input() t = input() if s == t[:-1]: print('Yes') else: print('No')
p03456
s122668715
Wrong Answer
a,b = input().split() x = int(a+b) flag = False for i in range (101): if x == i*i: flag = True break if flag: print('Yes') else: print('No')
p02630
s999530768
Accepted
N = int(input()) As = list(map(int, input().split())) r = sum(As) nAs = {} for A in As: if A not in nAs: nAs[A] = 0 nAs[A] += 1 Q = int(input()) for i in range(Q): B, C = map(int, input().split()) if B not in nAs: print(r) continue n = nAs[B] if C not in nAs: nAs[C] = 0 r += (C-B)*n nAs[B] = 0 nAs[C] += n print(r)
p03206
s750840917
Wrong Answer
def main(): d={25:"Chiristmas", 24:"Christmas Eve", 23:"Christmas Eve Eve", 22:"Christmas Eve Eve Eve"} print(d[int(input())]) if __name__ == "__main__": main()
p02572
s105979348
Accepted
N = int(input()) A = list(map(int,input().split())) s = [0]*(N+1) for i in range(N): s[i+1] = s[i] + A[i] cnt = 0 for j in range(N): cnt = (cnt + (A[j]*(s[N] - s[j+1])))%(10**9+7) print(cnt)
p02959
s108839994
Wrong Answer
n = int(input()) lia = list(map(int,input().split())) lib = list(map(int,input().split())) mon = sum(lia) for i in range(n): k = lia[i] - lib[i] if k <= 0: lia[i] = 0 lia[i+1] += k if lia[i+1] < 0: lia[i+1] = 0 print(mon-sum(lia))
p03075
s163539914
Accepted
a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) k = int(input()) if (e-a) > k: print(":(") else: print("Yay!")
p03095
s350824959
Accepted
from collections import Counter N = int(input()) S = Counter(input()) ans = 1 for v in S.values(): ans *= (v+1) ans %= (10**9+7) print(ans-1)
p03329
s109671482
Wrong Answer
def resolve(): N=int(input()) nine=[1] i=1 while 9**i<=N: nine.append(9**i) i+=1 i=1 while 6**i<=N: nine.append(6**i) i+=1 nine.sort(reverse=True) cnt=0 i=0 while N>0: cnt+=N//nine[i] N-= nine[i]*(N//nine[i]) i+=1 print(cnt) resolve()
p03951
s312422168
Accepted
from collections import Counter,defaultdict,deque from heapq import heappop,heappush from bisect import bisect_left,bisect_right import sys,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) n = inp() s = input() t = input() for i in range(n): for j in range(n-i): if s[i+j] != t[j]: break else: print(n+i) break else: print(n*2)
p02706
s754612330
Wrong Answer
n,m = map(int, input().split()) a = [ int(x) for x in input().split()] print(n-sum(a))
p03069
s838502727
Wrong Answer
n=int(input()) a=input() x=a.count(".") y=a.count("#") print(min(x,y))
p03767
s018589403
Wrong Answer
N = int(input()) a = list(map(int,input().split())) a.sort() s = 0 for i in [n*2 for n in range(1,N +1)]: s += a[i] print(s)
p02596
s494763391
Wrong Answer
k = int(input()) if k % 2 == 0: print(-1) else: count= 1 if k==7: print(1) else: now = 7%k while(1): count += 1 now = (now*10) % k + 7 % k if now % k == 0: print(count) exit()
p02786
s598948586
Accepted
H = int(input()) def f(H): if H == 1: return 1 else: return f(H//2) * 2 + 1 print(f(H))
p02706
s313984459
Accepted
N, M = map(int, input().split()) A = list(map(int, input().split())) print(N - sum(A) if N - sum(A) >= 0 else -1)
p02595
s993239796
Accepted
n, d = map(int, input().split()) ans = 0 for i in range(n): x, y = map(int, input().split()) if x**2 + y**2 <= d**2: ans += 1 print(ans)
p02854
s965610014
Accepted
n = int(input()) arr = [int(a) for a in input().split()] s = sum(arr) m = s // 2 tmp = 0 for a in arr: if tmp + a >= m: ans = min(s-tmp*2, (tmp+a)*2-s) break tmp += a print(ans)
p02811
s666881709
Wrong Answer
a, b = input().split() if 500*a >= b: print("Yes") else: print("No")
p03076
s363653221
Accepted
import math l=[int(input()) for i in range(5)] li=[math.ceil(n/10)*10 for n in l] s=sum(li) ans=10000 for i in range(4): ss=s-li[i]+l[i] ans=min(ss,ans) print(ans)
p03544
s276889541
Accepted
n = int(input()) l0 = 2 l1 = 1 if n == 1: print(l1) else: for i in range(1, n): l2 = l0 + l1 l0 = l1 l1 = l2 print(l2)
p02615
s723285256
Accepted
n=int(input()) a=sorted(list(map(int,input().split())))[::-1] ans=0 for i in range(1,n): ans+=a[i//2] print(ans)
p02862
s181963505
Wrong Answer
MOD = 10**9+7 X, Y = map(int, input().split()) if (X+Y)%3 != 0: print (0) exit() W = X - ((X+Y)//3) H = Y - ((X+Y)//3) mx = 2*10**6 fact = [1] * (mx+1) # 階乗を格納するリスト def inv(n): # MODを法とした逆元 return pow(n, MOD-2, MOD) for i in range(mx): fact[i+1] = fact[i] * (i+1) % MOD # 階乗を計算 ans = (fact[W+H] * inv(fact[W]) * inv(fact[H])) % MOD # comb(W+H,W) = (W+H)!/(W!H!) print (ans)
p03632
s001691192
Accepted
A,B,C,D = map(int,input().split()) print(max(min(B,D)-max(A,C),0))
p04045
s239257608
Wrong Answer
N, _ = list(map(int, input().split())) d = set(input().replace(" ", "")) for i in range(1,1000001): n = str(N*i) ns = set(list(n)) flg = False for t in ns: if t in d: flg = True break if flg == False: print(n) exit() print(0)
p02711
s839559790
Wrong Answer
#A N = list(input()) if any(N) ==7: print('Yes') else: print('No')
p02823
s992307620
Wrong Answer
N, A, B = input().split(' ') N = int(N) A = int(A) B = int(B) Count = -(-(B-A)//2) print(Count)
p02613
s423630852
Accepted
# -*- coding: utf-8 -*- """ Created on Sat Aug 15 17:00:46 2020 @author: saito """ # %% import phase # %% define phase # %% input phase N = int(input()) S = [0]*N for i in range(N): S[i] = input() # %% process phase C = [0]*4 rslt = ['AC', 'WA', 'TLE', 'RE'] for i in range(4): C[i] = S.count(rslt[i]) # %%output phase for i in range(4): print(rslt[i]+' '+'x'+' '+str(C[i]))
p03469
s328861765
Accepted
y = input() print(y.replace("2017", "2018"))
p03041
s971709648
Accepted
n, k = map(int, input().split()) s = input() if s[k-1]=="A": print(s[:k-1]+"a"+s[k:]) elif s[k-1]=="B": print(s[:k-1]+"b"+s[k:]) else: print(s[:k-1]+"c"+s[k:])
p02971
s467500583
Accepted
N=int(input()) A=[int(input()) for i in range(N)] max_val1=sorted(A)[-1] max_val2=sorted(A)[-2] for x in A: print(max_val2 if x==max_val1 else max_val1)
p02760
s356475807
Accepted
A=[list(map(int,input().split())) for _ in range(3)] N=int(input()) bn=[int(input()) for _ in range(N)] ans=False for ver in zip(*A): if all(item in bn for item in ver): ans=True for wide in A: if all(item in bn for item in wide): ans=True if all(A[i][i] in bn for i in range(3)): ans=True if all(A[i][3-i-1] in bn for i in range(3)): ans=True if ans==True: print("Yes") else: print("No")
p03944
s909901165
Accepted
w,h,n=map(int,input().split()) temphu=h temphd=0 tempwu=w tempwd=0 for i in range(n): x,y,a=map(int,input().split()) if a==1: tempwd=max(tempwd,x) if a==2: tempwu=min(tempwu,x) if a==3: temphd=max(temphd,y) if a==4: temphu=min(temphu,y) print(max(0,temphu-temphd)*max(0,tempwu-tempwd))
p03417
s028246618
Accepted
import numpy as np n,m = map(int,input().split()) if n == 1 and m == 1: print(1) elif n == 1 or m == 1: print(np.maximum(n-2,m-2)) else: print((n-2)*(m-2))
p03145
s257298391
Accepted
a,b,c = map(int,input().split()) print(a*b//2)
p03407
s986609289
Wrong Answer
a, b, c = map(int, input().split()) if a + 2*b >= c: print("Yes") else: print("No")
p02640
s110545485
Accepted
x,y = map(int,input().split()) if y%2==0 and x*2<=y<=x*4: print("Yes") else: print("No")
p03061
s651977779
Wrong Answer
import sys from functools import reduce def gcd(m, n): r = m % n return gcd(n, r) if r else n def gcd_list(numbers): return reduce(gcd, numbers) n = int(input()) a = list(map(int, sys.stdin.readline().split())) c = [gcd_list(a[:i] + a[i+1:]) for i in range(min(n, 5))] c.sort() if n == 2: print(c[1]) else: print(c[2])
p03309
s111980159
Accepted
n=int(input()) a=[int(i) for i in input().split()] for i in range(n): a[i]-=(i+1) a.sort() s=0 for i in range(n): s+=abs(a[i]-a[int(n/2)]) print(s)
p04005
s633988208
Wrong Answer
a, b, c = map(int,input().split()) if a%2 == 0 and b%2 == 0 and c%2 == 0: print(0) else: print(a*b*c//max(a,b,c))
p02717
s498291811
Wrong Answer
x, y, z = map(int, input().split()) a = x x, y = x, y x = z z = a print(x, y ,z)
p02548
s225844776
Wrong Answer
n = int(input()) ans = 0 for a in range(1, n): ans += (n - 1) print(ans)
p02700
s127447887
Wrong Answer
#abc164a a,b,c,d=map(int,input().split()) x=(a+d-1)/d y=(c+b-1)/b if x>=y: print('Yes') else: print('No')
p02690
s970871404
Wrong Answer
import math x = int(input()) for i in range(0, math.ceil(math.sqrt(x))): b = int(i**5 - x) if b > 0: b = b**0.2 else: b = -((-b)**0.2) try: if b % 1 == 0: print(i, int(b)) break except: pass
p02831
s817915151
Accepted
from fractions import gcd a,b=list(map(int,input().split())) print(a*b//gcd(a,b))
p02578
s801436126
Accepted
n=int(input()) a=list(map(int,input().split())) ans=0 for i in range(1,n): ans += max(a[i-1]-a[i],0) a[i] = max(a[i-1],a[i]) print(ans)
p02631
s399723452
Accepted
n=int(input()) ar=list(map(int,input().split())) x=0 for i in range(n): x^=ar[i] for i in range(n): print(ar[i]^x,end=" ")
p03438
s440660004
Accepted
n=int(input()) *a,=map(int,input().split()) *b,=map(int,input().split()) capacity=0 for i in range(n): capacity+=max(0,b[i]-a[i]-(b[i]-a[i])%2) for i in range(n): if a[i]>b[i]: capacity-=(a[i]-b[i])*2 if capacity>=0: print('Yes') else: print('No')
p02996
s172659582
Accepted
n = int(input()) data = [] for i in range(n): data.append(list(map(int, input().split()))) data.sort(key = lambda x : x[1]) now = 0 for i in range(n): now += data[i][0] if now > data[i][1]: print("No") exit() print("Yes")
p02618
s034851752
Wrong Answer
print("2")
p02554
s111694917
Wrong Answer
def fact(n): val = 1 for i in range(2, n + 1): val += i return val n = int(input()) if n ==1: print(0) elif n == 2: print(2) else: print((fact(n-1)*9**(n-2))%(10**9+7))
p02759
s705402201
Accepted
# abc 157 import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) N = int(readline().strip()) if (N % 2) == 0: answer = int(N / 2) else: answer = int((N + 1)/ 2) print(answer)
p03252
s564225909
Wrong Answer
s = input() t = input() n = len(s) r=[-1]*26 r2=[-1]*26 abcd = 'abcdefghijklmnopqrstuvwxyz' def f(l,l2,R): for i in range(n): if R[abcd.index(l[i])]!=-1: R[abcd.index(l[i])]=l2[i] else: print("No") exit() f(s,t,r) f(t,s,r2) print("Yes")
p03659
s466525572
Wrong Answer
n=int(input()) a=list(map(int,input().split())) total=sum(a) cnt=0 i=0 while(cnt<=total/2): cnt+=a[i] i+=1 if i!=1: print(min(abs((total-cnt)-cnt),abs((total-cnt+a[i-1])-(cnt-a[i-1])))) else: print(abs((total-cnt)-cnt))
p03107
s965359445
Accepted
s = input() print(2*(min(s.count("0"),s.count("1"))))
p03472
s206995426
Accepted
n,h,*d=map(int,open(0).read().split());a=max(d[::2]);b=sorted(d[1::2]);c=0 while b and b[-1]>a>0<h:h-=b.pop();c+=1 print(c-(-h//a)*(h>0))
p02768
s726079313
Accepted
def n_c_k(n, k): x = y = 1 for i in range(k): x *= n - i x %= mod y *= i + 1 y %= mod return x * pow(y, mod - 2, mod) % mod n, a, b = map(int, input().split()) mod = 10 ** 9 + 7 ans = (pow(2, n, mod) - 1 - n_c_k(n, a) - n_c_k(n, b)) % mod print(ans)
p02854
s964658199
Accepted
n = int(input()) a = list(map(int,input().split())) s = sum(a) d = s // 2 t = 0 i = -1 while(t <= d): i += 1 t += a[i] t2 = t - a[i] # print(t,t2,s) # print(t-(s-t),(s-t2)-t2) print(min(t - (s - t),(s - t2) - t2))
p02678
s018754508
Accepted
from collections import deque n,m = map(int,input().split()) g = [[] for i in range(n)] for i in range(m): x,y = map(int,input().split()) g[x-1].append(y-1) g[y-1].append(x-1) ans = [-1]*n deq = deque([0]) while deq: fr = deq.popleft() for go in g[fr]: if ans[go] == -1: ans[go] = fr deq.append(go) print("Yes") for i in ans[1:]:print(i+1)
p02924
s559484817
Wrong Answer
N = int(input()) print(int((N*(int(N-1)))/2))
p02911
s901289074
Accepted
import math import itertools n,k,q=map(int,input().split()) l=[0] * n for _ in range(q): l[int(input())-1] += 1 for i in l: if k - (q-i) >0 :print('Yes') else: print('No')
p02754
s956807346
Accepted
N, blue, red = map(int, input().split()) ans = N // (blue + red) * blue rem = N % (blue + red) ans += min(rem, blue) print(ans)
p02862
s729898884
Accepted
def comb_mod(n,r,m): ans = 1 for i in range(1,r+1): ans *= (n-i+1) % m ans *= pow(i,m-2,m) % m ans = ans % m return ans x,y = map(int,input().split()) m = 10**9+7 if x > 2*y or 2*x < y or (x+y)%3 != 0: ans = 0 else: n = (x+y)//3 r = x-n ans = comb_mod(n,r,m) print(ans)
p04031
s695027765
Wrong Answer
N = int(input()) nums = list(map(int, input().split(' '))) tmp = 0 max = 10**100 for i in nums: for j in nums: tmp += (j-i)**2 if max > tmp: max = tmp tmp = 0 print(max)
p02700
s598169143
Accepted
import math A,B,C,D=[int(s) for s in input().split()] taka=math.ceil(C/(B+0.0)) aoki=math.ceil(A/(D+0.0)) if taka>aoki: print('No') else: print('Yes')
p02699
s029265629
Wrong Answer
il = [int(k) for k in input().split()] S = il[0] W = il[1] if S//2 <= W : print("unsafe") else: print("safe")
p02577
s414458071
Accepted
N = input() C = 0 for i in N: C += int(i) if C % 9 == 0: print('Yes') else: print('No')
p03759
s146783960
Accepted
a,b,c=map(int,input().split()) print('YES' if b-a==c-b else 'NO')
p02696
s860952420
Wrong Answer
inp=[int(x) for x in input().split()] a,b,n=inp[0],inp[1],inp[2] if (a-1)>n: print(n-1) else: print(a-1)
p04045
s682904861
Wrong Answer
N, L = map(str, input().split()) K = int(N) P = list(map(str, input().split())) U = sorted(list(set([str(i) for i in range(10)])-set(P))) for i in range(len(N)): if int(N) <= K: if N[i] in P: for j in U: if j >=N[i]: N=N.replace(N[i],j) break else: if N[i] in P: N=N.replace(N[i],U[0]) print(N)
p02778
s062100203
Accepted
s = input() l = len(s) print('x'*l)
p02917
s052467392
Wrong Answer
N = int(input()) B = [int(s) for s in input().split(' ')] def doit(bb): A = [] for b in bb: if len(A) == 0: A.append(b) continue A.append(min(A[-1], b)) A.append(A[-1]) return sum(A) print(max(doit(B), doit(reversed(B))))
p02576
s408106576
Wrong Answer
import math n,x,t = map(int,input().split()) print(math.ceil(n//x)*t)
p02555
s005461269
Accepted
def red(n): if n < 3: return 0 elif n == 3: return 1 memo = [0] * (n+1) memo[3] = 1 rem = 10**9 + 7 for i in range(4,n+1): memo[i] = (memo[i-1] + memo[i-3]) % rem return memo[n] % rem n = int(input()) print(red(n))
p02760
s094247704
Accepted
A = [] for i in range(3): A += list(map(int,input().split())) called = [False] * 9 bingo = ((0,1,2),(3,4,5),(6,7,8),(0,3,6),(1,4,7),(2,5,8),(0,4,8),(2,4,6)) N = int(input()) for i in range(N): target = int(input()) if target in A: called[A.index(target)] = True for a,b,c in bingo: if called[a] and called[b] and called[c]: print("Yes") break else: print("No")
p03160
s404529282
Wrong Answer
def edpcA(n, hs): hm2, hm1 = hs[0], hs[1] dp = [0, abs(hm2-hm1)] hs = list(reversed(hs[2:])) for i in range(2, n): h = hs.pop() d1 = dp[i-1] + abs(h-hm1) d2 = dp[i-2] + abs(h-hm2) dp.append(min(d1, d2)) hm2, hm1 = hm1, h print(dp) n = int(input()) hs = list(map(int, input().split(' '))) edpcA(n, hs)
p02766
s750794758
Accepted
n,k = map(int,input().split()) count = 1 while n >= k: n = n/k count += 1 print(count)
p02714
s405442106
Wrong Answer
from itertools import combinations as c def cond1(a,b,c): return a != b and b != c and c != a def cond2(i,j,k): return j-i != k - j N = int(input()) S = input() comb_N = list(c(range(N), 3)) C = [1 for i in range(len(comb_N)) if cond1(S[comb_N[i][0]], S[comb_N[i][1]], S[comb_N[i][2]]) and cond2(*comb_N[i])] print(C)
p03030
s932840526
Accepted
n = int(input()) S = [] P = [] for i in range(n): tmp_S, tmp_P = input().split() S.append(tmp_S) P.append(int(tmp_P) * -1) index = [i for i in range(1, n+1)] ZIP = zip(S, P, index) ZIP = sorted(ZIP) S, P, index = zip(*ZIP) for i in range(n): print(index[i])
p03434
s714869660
Accepted
from sys import stdin import sys import math from functools import reduce import functools import itertools from collections import deque,Counter,defaultdict from operator import mul import copy # ! /usr/bin/env python # -*- coding: utf-8 -*- import heapq sys.setrecursionlimit(10**6) # INF = float("inf") INF = 10**18 import bisect import statistics mod = 10**9+7 # mod = 998244353 N = int(input()) a = list(map(int, input().split())) a = sorted(a, reverse=True) x = 0 y = 0 for i in range(len(a)): if i % 2 == 0: x += a[i] else: y += a[i] print(x-y)
p03711
s087823748
Wrong Answer
x,y = map(int,input().split()) g1=[1,3,5,7,8.10,12] g2=[4,6,9,11] g3=[2] if x in g1 and y in g1: print('Yes') elif x in g2 and y in g2 : print('Yes') elif x in g3 and y in g3 : print('Yes') else: print('No')
p03997
s299164801
Accepted
def actual(a, b, h): return int((a + b) * h / 2) a = int(input()) b = int(input()) h = int(input()) print(actual(a, b, h))
p02778
s725114794
Wrong Answer
S = input() print(len(S)) i = 0 while i < len(S): print('*', end='') i += 1
p03481
s129383834
Accepted
x, y = map(int, input().split()) if y < 2*x: print(1) exit() ans = 1 while x*2 <= y: ans += 1 x = 2*x print(ans)
p03693
s336520560
Wrong Answer
print("No" if int(input().replace(" ",""))%4 else "Yes")
p02793
s800601012
Accepted
def gcd(x,y): if y==0: return x return gcd(y,x%y) MOD = 10**9+7 N = int(input()) A = list(map(int,input().split())) lcm = 1 for i in A: lcm = (lcm*i)//gcd(lcm,i) lcm %= MOD ans = 0 for i in A: ans += lcm*pow(i,MOD-2,MOD) ans %= MOD print(ans)
p03778
s437769882
Wrong Answer
W, a, b = map(int,input().split()) if (a+W)<=b: print(b-(a+W)) elif (a<= b)and (b<(a+W)): print(b-a) elif ((a-W)<=b) and(b<a): print(a-b) elif b<(a-W): print(a-(b+W))
p03131
s974767594
Accepted
k,a,b=map(int,input().split()) if b-a<=2 or k-1<a: print(1+k) else: print((k-a+1)//2*(b-a)+(k-a+1)%2+a)
p03838
s732419546
Accepted
x, y = map(int, input().split()) ax, ay = abs(x), abs(y) def sign(x): if x == 0: return 0 elif x > 0: return 1 else: return -1 if x == 0 or y == 0: print(abs(x-y)+(x > y)) else: if sign(x) != sign(y): print(abs(ax - ay) + 1) else: if x < y: print(y - x) else: print(abs(ax - ay) + 2)
p03221
s935158499
Accepted
n, m = [int(x) for x in input().split()] temp_list = [[] for _ in range(n + 1)] for i in range(m): p, y = [int(x) for x in input().split()] temp_list[p].append((y, i)) ans_list = [""] * m for p in range(1, n + 1): temp_list[p].sort() for j in range(len(temp_list[p])): _, i = temp_list[p][j] ans_list[i] = "{:06}{:06}".format(p, j + 1) for ans in ans_list: print(ans)
p03103
s075738502
Accepted
n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort(key=lambda x: x[0]) cnt = 0 ans = 0 for a, b in ab: cnt += b ans += a*b if cnt >= m: break print(ans - (cnt - m)*a)
p03434
s912050899
Accepted
n, a = int(input()), list(map(int, input().split())) a.sort(reverse = True) alice = 0 bob = 0 for i in range(n): if i % 2 == 0: alice += a[i] else: bob += a[i] # print(alice) # print(bob) print(alice - bob)
p02583
s673611637
Wrong Answer
N = int(input()) A = list(map(int,input().split())) cnt = 0 for i in range(0,N-2): for j in range(i+1,N-1): for k in range(j+1,N): if (i+j)>k and (j+k)>i and (i+k)>j and i!=k and j!=k and i!=j: cnt+=1 print(cnt)