problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03524
s300139321
Accepted
ma = lambda :map(int,input().split()) lma = lambda :list(map(int,input().split())) tma = lambda :tuple(map(int,input().split())) ni = lambda:int(input()) yn = lambda fl:print("YES") if fl else print("NO") import collections import math import itertools import heapq as hq ceil = math.ceil s = list(input()) co = collections.Counter(s) ls = [] for w in ["a","b","c"]: ls.append(co[w]) mx = max(ls) f=True for c in ls: if mx > c+1: f=False yn(f)
p02727
s512103876
Accepted
import sys input = sys.stdin.readline X,Y,A,B,C = map(int, input().split()) p = list(map(int, input().split())) q = list(map(int, input().split())) r = list(map(int, input().split())) p.sort() p = p[A-X:] q.sort() q = q[B-Y:] r.sort() a = p+q+r a.sort(reverse=True) print(sum(a[:X+Y]))
p02760
s518909530
Accepted
A = list() for i in range(3): A.append([int(j) for j in input().split()]) N = int(input()) for i in range(N): b = int(input()) for j in range(3): for k in range(3): if b == A[j][k]: A[j][k] = 0 flg = 0 for i in range(3): if sum(A[i]) == 0: flg = 1 if A[0][i]+A[1][i]+A[2][i] == 0: flg = 1 if A[0][0]+A[1][1]+A[2][2] == 0: flg = 1 if A[2][0]+A[1][1]+A[0][2] == 0: flg = 1 print("Yes" if flg==1 else "No")
p03145
s952399318
Accepted
ary1 = list(map(int,input().split())) ary2 = sorted(ary1) print((ary2[0]*ary2[1])//2)
p03095
s503897443
Accepted
from collections import Counter MOD = 1000000007 N = int(input()) S = input() count = Counter(S) ans = 1 for k, v in count.items(): ans *= (v+1) ans %= MOD print((ans - 1) % MOD)
p03241
s419584413
Accepted
n,m=map(int,input().split()) m_root=int(m**0.5) div_l=[] ans=0 for i in range(1,m_root + 1): if m%i == 0: div_l.append(i) div_l.append(m//i) if m//n in div_l: ans = m//n else: div_l.append(m//n) div_l.sort() ans = div_l[div_l.index(m//n) - 1] print(ans)
p03774
s746356424
Wrong Answer
n,m = map(int,input().split()) P = [list(map(int,input().split())) for _ in range(n)] C = [list(map(int,input().split())) for _ in range(m)] for i in range(n): d = 9999 t = 0 for j in range(m): dist = abs(P[i][0]-C[j][0]) + abs(P[i][1]-C[j][1]) if d > dist: t = j d = dist print(t+1)
p03817
s026369579
Accepted
x = int(input()) div,mod = divmod(x,11) ans = div*2 if mod>6: ans +=2 elif mod>0: ans +=1 print(ans)
p02820
s057737280
Accepted
import sys input = sys.stdin.readline N, K = map(int, input().split()) R, S, P = map(int, input().split()) T = list(input().rstrip()) # if (i)th == (i-K)th: point=0 for i in range(K,N): if T[i] == T[i-K]: T[i] = 'o' point = 0 for t in T: if t == 'r': point += P elif t == 's': point += R elif t == 'p': point += S print(point)
p02923
s829435390
Wrong Answer
N = int(input()) H = list(map(int,input().split())) max_count = 0 count = 0 for i in range(N-1): if H[i+1]-H[i]<=0: count+=1 else: if max_count<count: max_count = count count = 0 if max_count<count: max_count = count print(max_count)
p03835
s168901293
Wrong Answer
K, S = map(int, input().split()) count = 0 for i in range(K+1): for j in range(K+1): if(K >= S-(i+j) >= 0): count += 1 print(i, j, S-(i+j))
p02777
s519893563
Accepted
S, T = input().split() A, B = map(int, input().split()) U = input() if S == U: A -= 1 else: B -= 1 print(A,B)
p03162
s800703409
Accepted
N = int(input()) DP = [[0, 0, 0] for _ in range(N+1)] for i in range(1, N+1): a, b, c = map(int, input().split()) DP[i][0] = max(DP[i - 1][1] + a, DP[i - 1][2] + a) DP[i][1] = max(DP[i - 1][0] + b, DP[i - 1][2] + b) DP[i][2] = max(DP[i - 1][0] + c, DP[i - 1][1] + c) print(max(DP[N]))
p03493
s171287045
Accepted
s = input() count = 0 for i in s: if i =='1': count += 1 print(count)
p03838
s308600688
Wrong Answer
x,y = map(int,input().split()) if x<=y: print(y-x) else: if abs(x)<=abs(y): if x>=0 and y<0: print(abs(y)-x+1) elif x<0 and y<0: print(abs(y)-abs(x)+2) else: if x>=0 and y<0: print(x+y+1) elif x>=0 and y>=0: print(x-y+2)
p03012
s076162345
Accepted
a=int(input()) b=list(map(int,input().split())) c=sum(b) d=0 e=0 f=0 for i in range(a): d=d+b[i] if d>=c/2: e=i break for i in range(e): f=f+b[i] if abs(d-(c-d))<abs(f-(c-f)): print(abs(d-(c-d))) else: print(abs(f-(c-f)))
p03493
s374943313
Accepted
# -*- coding: utf-8 -*- mass=list(input()) count=0 for i in mass: if i=='1': count+=1 print(count)
p02924
s430122359
Accepted
n=int(input()) print(n*(n-1)//2)
p03067
s562619472
Wrong Answer
a,b,c=map(int,input().split()) if a<c<b: print("Yes") else: print("No")
p02629
s820244598
Wrong Answer
al = ["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"] N = int(input()) ans = "" while N > 0: r = N%26 N = int(N/26) if r == 0: ans = al[25] + ans else: ans = al[r-1] + ans print(ans)
p03210
s358720706
Accepted
import sys def I(): return int(sys.stdin.readline().rstrip()) print('YES' if I() in [3,5,7] else 'NO')
p03799
s150442890
Accepted
import sys input = sys.stdin.readline n, m = [int(x) for x in input().split()] ans = 0 if 2*n <= m: ans += n m -= 2*n ans += m // 4 else: ans += m // 2 print(ans)
p03637
s230798668
Accepted
N=int(input()) A=list(map(int,input().split())) OD=0 EV4=0 for i in A: if i%2==1: OD+=1 elif i%4==0: EV4+=1 EV=N-OD-EV4 ret = 'No' if EV4>=OD: ret='Yes' elif EV4==OD-1 and EV==0: ret='Yes' print(ret)
p03416
s603237098
Accepted
a, b = map(int, input().split()) cnt = 0 for i in range(a, b+1): x = str(i) if x == x[::-1]: cnt += 1 print(cnt)
p02663
s879982367
Accepted
h1, m1, h2, m2, k = map(int, input().split()) start = h1*60+m1 end = h2*60+m2 print(end-start-k)
p03338
s317985178
Accepted
def main(): input() s = input() ans = [] for i in range(1, len(s)): left = set(s[:i]) right = set(s[i:]) ans.append(len(left & right)) print(max(ans)) if __name__ == '__main__': main()
p03319
s598475070
Wrong Answer
n,m = map(int,input().split(" ")) ar = list(map(int,input().split(" "))) i = ar.index(1) count = 0 if i % (m - 1) == 0: count += i // (m - 1) else: count += i // (m - 1) + 1 if (n - 1 - i) % (m - 1) == 0: count += (n - 1 - i) // (m - 1) else: count += (n - 1 - i) // (m - 1) + 1 print(count)
p03644
s530514285
Accepted
n = int(input()) i = 1 while i*2 <= n: i *= 2 print(i)
p03427
s403830712
Accepted
N = list(map(int,input())) ans = sum(N) ans1 = 0 if N[0] == 1: for i in range(len(N)-1): ans1 += 9 print(max(ans,ans1)) else: for i in range(len(N)): if i == 0: ans1 += N[i]-1 else: ans1 += 9 print(max(ans, ans1))
p03150
s919869980
Accepted
s = list(input()) k = ["k", "e", "y", "e", "n", "c", "e"] ans = [] i = 0 while s[i] == k[i]: ans.append(s[i]) i += 1 if i == 7: break for j in range(len(s) - 7 + i, len(s)): ans.append(s[j]) jud = True for j in range(7): if ans[j] != k[j]: jud = False if jud: print("YES") else: print("NO")
p02691
s279214745
Accepted
import bisect import collections import sys sys.setrecursionlimit(100000) input = sys.stdin.readline ACMOD = 1000000007 INF = 1 << 62 def lmi(): return list(map(int, input().split())) def llmi(n): return [lmi() for _ in range(n)] N = int(input()) A = lmi() Ay = [a - i for i, a in enumerate(A)] Ax = [a + i for i, a in enumerate(A)] # print(Ax,Ay) d = collections.defaultdict(int) ans =0 for i in range(N): # check Ay ans += d[Ay[i]] # update d d[-Ax[i]] += 1 print(ans)
p02630
s774219462
Accepted
from collections import Counter n = int(input()) A = list(map(int, input().split())) a = Counter(A) q = int(input()) BC = [list(map(int, input().split())) for _ in range(q)] ans = sum(A) for b,c in BC: ans -= b*a[b] - c*a[b] if c in a:a[c] += a[b] else: a[c] = a[b] a[b] = 0 print(ans)
p02778
s921436650
Accepted
S = input() n = len(S) print('x'*n)
p03042
s784948006
Wrong Answer
S = input() S1, S2 = S[0:2], S[2:5] if int(S1) > 12 and (int(S2) >= 1 and int(S2) <= 12): print('YYMM') elif (int(S1) >= 1 and int(S1) <=12) and int(S2) > 12: print('MMYY') elif (int(S1) >= 1 and int(S1) <=12) and (int(S2) >= 1 and int(S2) <=12): print('AMBIGUOUS') else: print('NA')
p02664
s253189993
Wrong Answer
# -*- coding: utf-8 -*- t = list(input()) ans = ''.join(t) if t[0] == '?': t[0] = 'P' for i in range(len(t) - 1): if t[i] == 'P' and t[i+1] == '?': #print('A') t[i+1] = 'D' elif t[i] == 'D' and t[i+1] == '?': #print('B') t[i+1] = 'P' print(''.join(t))
p02578
s065342407
Accepted
n = int(input()) a = list(map(int,input().split())) cnt = 0 for i in range(n-1): if a[i+1]<a[i]: cnt += a[i]-a[i+1] a[i+1] = a[i] print(cnt)
p03095
s469916262
Wrong Answer
N = int(input()) S = input() char = set(list(S)) ans = 1 for c in char: ans *= S.count(c) + 1 ans -=1 print(ans)
p02948
s941167244
Wrong Answer
def main(): n, m = map(int, input().split()) work = [[] for _ in range(10 ** 4 + 1)] for _ in range(n): a, b = map(int, input().split()) work[b].append(a) for i in range(10 ** 4 + 1): work[i].sort(reverse=True) cnt = 0 ans = 0 for i in range(10 ** 4, -1, -1): for w in work[i]: if cnt + w <= m: ans += i cnt += 1 print(ans) if __name__ == '__main__': main()
p02708
s329544816
Accepted
n, k = [int(i) for i in input().split()] mod = 10**9 + 7 ans = 0 for i in range(k, n + 2): first = i * (i - 1) / 2 final = (n * 2 - i + 1) * i / 2 add = final - first + 1 ans = (ans + add) % mod print(int(ans))
p02598
s940400612
Wrong Answer
import sys input = sys.stdin.buffer.readline n, k = map(int, input().split()) A = list(map(int, input().split())) # A.sort() def hantei(x): cnt = 0 for i in range(n): cnt += A[i] // x return cnt ok = 10 ** 9 ng = 0 while ok - ng > 1: mid = (ok + ng) // 2 if hantei(mid) <= k: ok = mid else: ng = mid # print(ok, ng) print(ok)
p02618
s941678648
Wrong Answer
d=int(input()) c=list(map(int,input().split())) s=[list(map(int,input().split())) for _ in range(d)] for i in range(d): print(26-i)
p02953
s379406869
Accepted
from sys import exit n=int(input()) H=list(map(int,input().split())) H[0] -= 1 for i in range(n-1): if H[i]>H[i+1]: print("No") exit() elif H[i]!=H[i+1]: H[i+1] -= 1 print("Yes")
p02691
s196490837
Accepted
from collections import defaultdict N = int(input()) A = map(int, input().split()) d = defaultdict(int) ans = 0 for i, a in enumerate(A): ans += d[-i+a] d[-i-a] += 1 print(ans)
p03821
s710107892
Accepted
N = int(input()) A,B = [],[] total = 0 for i in range(N): (a,b) = map(int,input().split()) A.append(a) B.append(b) for i in range(N): if (A[N-i-1]+total)%B[N-i-1] == 0: continue else: total += B[N-i-1]-((A[N-i-1]+total)%B[N-i-1]) print(total)
p03293
s707404852
Accepted
def answer(s: str, t: str) -> str: for _ in range(len(s)): if t == s: return 'Yes' s = s[-1] + s[:-1] return 'No' def main(): s = input() t = input() print(answer(s, t)) if __name__ == '__main__': main()
p03438
s477407002
Wrong Answer
s = input() if (len(s)+1)//2 == s.count('hi'): print('Yes') else: print('No')
p04012
s469063299
Wrong Answer
from collections import Counter w = input() c = Counter() print('Yes' if all([1 for i in c.values() if not i % 2]) else 'No')
p03720
s509224986
Accepted
n,m=map(int,input().split()) lst=[0]*(n) for i in range(m): a,b=map(int,input().split()) lst[a-1]+=1 lst[b-1]+=1 for i in range(n): print(lst[i])
p02553
s652156660
Accepted
a,b,c,d = list(map(lambda x: int(x), input().split())) ac, bc, bd, ad = a*c, b*c, b*d, a*d e1 = ac if ac >= bc else bc e2 = bd if bd >= ad else ad ans = e1 if e1 >= e2 else e2 print(ans)
p03030
s837582937
Wrong Answer
n = input() d = {} res = [] qes = [] score = [] for i in xrange(n): r,s = raw_input().split() if r not in d: d[r] = [(i,s)] else: d[r].append((i,s)) if r not in res: qes.append(r) res.append(r) score.append(s) qes = sorted(qes) for j in qes: for k in sorted(d[j]): print k[0]+1
p02602
s537324521
Accepted
n,k=map(int,input().split()) l=list(map(int,input().split())) for i in range(k,len(l)): if l[i]<=l[i-k]: print('No') else: print('Yes')
p02622
s330033930
Accepted
n=0 s=list(str(input())) t=list(str(input())) for i in range(len(s)): if s[i] != t[i]: n+=1 print(n)
p02793
s177725138
Accepted
from fractions import gcd N = int(input()) A = list(map(int, input().split())) mod = 10**9+7 x = 1 for i in range(N): x = (x*A[i]) // gcd(x, A[i]) ans = 0 for a in A: ans += x//a #ans %= mod print(ans%mod)
p03760
s469765095
Accepted
o=input() e=input()+' ' print(''.join([i+j for i,j in zip(o,e)]))
p02755
s277826691
Accepted
A, B = map(int, input().split()) m = -1 for n in range(100001): if A*100 <= 8*n < (A+1)*100 and B*100 <= 10*n < (B+1)*100: m = n break print(m)
p02771
s746233087
Wrong Answer
A,B,C=input().split() if A==B==C: print('No') elif A!=B and A!=C and B!=C: print('No') else: print('yes')
p03524
s250404075
Wrong Answer
from collections import Counter X= input() S = Counter(X) if len(S.keys()) == 3: if max(S.values()) - min(S.values()) >= 2: print("NO") else: print("YES") if len(S.keys()) == 2: if max(S.values()) - min(S.values()) >= 2: print("NO") else: print("YES") if len(S.keys()) == 1: if len(X) == 1: print("YES") else: print("NO")
p03612
s506266848
Accepted
n = int(input()) P = list(map(int, input().split())) c = 0 for i in range(n-1): if P[i] == i+1: P[i], P[i+1] = P[i+1], P[i] c += 1 if P[n-1] == n: P[n-1], P[n-2] = P[n-2], P[n-1] c += 1 print(c)
p03433
s822937225
Wrong Answer
n = int(input()) a = int(input()) b = 0 while True: if (500*b + a) > n: print("NO") break if (500*b + a) - n == 0: print("YES") break b+=1
p03679
s043827825
Accepted
x,a,b=map(int,input().split()) print("dangerous" if x<b-a else "safe" if a<b else "delicious")
p03774
s976420204
Wrong Answer
N, M = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(N)] C = [list(map(int, input().split())) for _ in range(M)] for a in A: distance = 100 point = 0 for i, c in enumerate(C): if abs(a[0] - c[0]) + abs(a[1] - c[1]) < distance: distance = abs(a[0] - c[0]) + abs(a[1] - c[1]) point = i print(point + 1)
p03625
s902772455
Wrong Answer
n=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) pin=a[0] cnt=1 x=[] for i in range(1,n): if a[i]==pin: cnt+=1 else: if cnt>=4: x+=[pin] x+=[pin] elif cnt>=2: x+=[pin] if len(x)>=2: break pin=a[i] if len(x)<=1: print(0) else: print(x[0]*x[1])
p02691
s076820502
Accepted
from collections import defaultdict n=int(input()) A=list(map(int,input().split())) B=defaultdict(int) res=0 for i in range(n): B[A[i]+i]+=1 if i-A[i] in B: res+=B[i-A[i]] print(res)
p03815
s307374639
Wrong Answer
x = int(input()) num = (x - 1) // 11 * 2 + 1 if x % 11 > 6: num += 1 print(num)
p03427
s909295340
Accepted
m=input() a=int(m[0])-1+(len(m)-1)*9 b=0 for i in m: b+=int(i) print(max(b,a))
p03408
s228125423
Wrong Answer
n = int(input()) d = {} for _ in range(n): s = input() if s not in d: d[s] = 0 d[s] += 1 m =int(input()) for _ in range(m): s = input() if s not in d: d[s] = 0 d[s] -= 1 ans = 0 for key in d: ans += max(d[key], 0) print(ans)
p02873
s829698681
Wrong Answer
s = str(input()) num = [0 for _ in range(len(s)+1)] for i in range(len(s)): if (s[i] == "<"): num[i+1] = num[i]+1 for i in range(len(s),1,-1): if (s[i-1] == ">"): num[i-1] = max(num[i-1],num[i]+1) print(sum(num))
p03555
s043777978
Wrong Answer
data1 = input() data2 = input() count = len(data1) -1 sw = 0 i = 0 j = len(data2)-1 while i <= count: if data1[i] == data2[j]: sw += 1 i += 1 j -= 1 if sw == len(data1): print("Yes") else: print("No")
p03351
s382779343
Accepted
a,b,c,d=map(int,input().split()) print("Yes" if (abs(b-a)<= d and abs(c-b)<=d) or abs(c-a)<=d else "No")
p02792
s628306332
Accepted
n = int(input()) all_count = 0 options = [str(i) for i in range(10)] maeato = [[0 for i in range(10)] for j in range(10)] for i in range(n+1): checking = str(i) maeato[int(checking[0])][int(checking[-1])]+=1 all_count = 0 for i in range(1,10): for j in range(1,10): for k in range(1,10): for p in range(1,10): if i == p and j == k: all_count+=maeato[i][j]*maeato[k][p] print(all_count)
p03087
s896704592
Accepted
n, q = map(int, input().split()) S = input().strip() *LR, = (map(int, input().split()) for _ in range(q)) A = [0] * n for i in range(1, n): A[i] = A[i-1] + (S[i-1:i+1] == 'AC') for l, r in LR: print(A[r-1]-A[l-1])
p03131
s641439521
Wrong Answer
k, a, b = map(int, input().split()) x=k+1 y=0 if b>a: c=b-a k=k-a-1 y=c*(k//2-1)+b+(k%2) print(max(x,y))
p03289
s245083820
Wrong Answer
s=(input()) k=s[2:-1] m=k.replace('C', 'c',1) print(k) print(m) if k.count('C')==1 and s[0]=='A' and m==k.lower(): print('AC') else: print('WA')
p03062
s085423993
Accepted
N=int(input()) arr=list(map(int,input().split())) count=0 for i in range(N): if arr[i]<0: count+=1 arr[i]*=-1 if count%2!=0: print(sum(arr)-2*min(arr)) else: print(sum(arr))
p03681
s586044192
Accepted
from math import factorial as f n,m=map(int,input().split()) if abs(n-m) >= 2: print(0) quit() if n == m: print(f(n)*f(m)*2%(10**9+7)) else: print(f(max(m,n))*f(min(m,n))%(10**9+7))
p03681
s598720956
Wrong Answer
import sys input = sys.stdin.readline from math import factorial mod=10**9+7 n,m=map(int,input().split()) if n>m: n,m=m,n if n+1==m: n=factorial(n)%mod m=factorial(m)%mod print(n*m) elif n==m: n=factorial(n)%mod m=factorial(m)%mod print(2*n*m%mod) else: print(0)
p02987
s319895125
Wrong Answer
S = input() A = S[0] B = S[1] C = S[2] D = S[3] if A == B and C ==D and A != C: print("Yes") elif A == C and B ==D and A != C: print("Yes") elif A == D and B == C and A != B: print("Yes") else: print("No")
p02577
s487503063
Wrong Answer
def main(): n = int(input()) t = 0 if t%9==0: print('Yes') else: print('No') if __name__ == "__main__": main()
p02706
s139342250
Accepted
n, m = map(int, input().split()) a = list(map(int, input().split())) if sum(a) > n: print(-1) else: print(n-sum(a))
p03544
s707956213
Accepted
n = int(input()) lst = [2,1] for i in range(2,n+1): lst.append(lst[i-1]+lst[i-2]) print(lst[n])
p03795
s604520169
Accepted
N = int(input()) print(800 * N - 200 * (N // 15))
p03327
s440949215
Accepted
print("ABD" if int(input())>999 else "ABC")
p02682
s454838274
Accepted
def main(): inputList= list(map(int, input().split())) score =[1,0,-1] ans =0 for i in range(len(inputList)-1): if inputList[3] >= inputList[i]: inputList[3] = inputList[3] - inputList[i] ans = ans + inputList[i]*score[i] else: ans = ans + inputList[3]*score[i] return ans return ans if __name__ == '__main__': print(main())
p03835
s849879810
Wrong Answer
import sys num = sys.stdin.readline().split(' ') K = int(num[0]) S = int(num[1]) counter = 0 for i in range(K+1): for j in range(K+1): for k in range(S-i-j): if i+j+k == S: counter += 1 else: continue print(counter)
p03041
s057237247
Wrong Answer
N, K = map(int, input().split(' ')) S = input() K -= 1 print(S[:K] + S[K].lower() + S[K:])
p03359
s687860019
Wrong Answer
a,b = map(int,input().split()) print(b if a==b else a)
p02787
s028300387
Accepted
import sys def input(): return sys.stdin.readline()[:-1] h, n = map(int, input().split()) a=[0]*n b=[0]*n for i in range(n): a[i], b[i] = map(int, input().split()) dp = [float('inf')]*(h+max(a)) dp[0] = 0 for i in range(1, h+max(a)): for j in range(n): dp[i] = min(dp[i], dp[i-a[j]]+b[j]) print(min(dp[h:]))
p03103
s116587306
Accepted
import math from math import gcd INF = float("inf") import sys input=sys.stdin.readline sys.setrecursionlimit(500*500) import itertools from collections import Counter,deque def main(): n, m = map(int, input().split()) l = [list(map(int, input().split())) for _ in range(n)] l.sort() ans = 0 for i in l: if m<=i[1]: ans += m*i[0] break else: ans += i[0]*i[1] m -= i[1] print(ans) if __name__=="__main__": main()
p03861
s565861066
Wrong Answer
a,b,x = map(int,input().split()) a += (x - a%x) b -= b%x ans = 0 if a==b else b//x - a//x + 1 print(ans)
p03076
s459818924
Accepted
abcde = list(map(int, open(0).read().split())) minimum = abcde[0] % 10 num = 0 for i in range(len(abcde)): if abcde[i] % 10 < minimum and abcde[i] % 10 != 0: minimum = abcde[i] % 10 num = i ans = 0 for i in range(len(abcde)): if i == num: ans += abcde[i] continue if abcde[i] % 10 != 0: ans += (abcde[i] // 10 + 1) * 10 else: ans += abcde[i] print(ans)
p02725
s026747929
Wrong Answer
a, b = map(int, input().split()) r = list(map(int, input().split())) ri = r[-1] - r[-2] le = r[0] + a - r[-1] if ri < le: print(r[-1] - r[0]) else: num = 0 for i in range(1, len(r) - 1): num += (r[i] - r[i-1]) print(a - r[-1] + num)
p02996
s072238649
Accepted
N = int(input()) t = 0 ans = "Yes" tasks = [] for i in range(N): tasks.append(list(map(int, input().split()))) tasks.sort(key=lambda task: task[1]) for task in tasks: t += task[0] if task[1] < t: ans = "No" break print(ans)
p02994
s020283241
Wrong Answer
n, l = map(int, input().split()) taste = l num = 1 for i in range(1, n+1): if abs(taste) > abs(l+i-1): num = i print((n*(2*l+n-1)//2) - l - num +1)
p03041
s737335414
Accepted
n,k=[int(x) for x in input().rstrip().split()] S=[i for i in input()] S[k-1]=S[k-1].lower() ans="" for i in S: ans+=i print(ans)
p03804
s415724337
Accepted
n,m = map(int,input().split()) a = [list(input())for i in range(n)] b = [list(input())for i in range(m)] count = 0 for y in range(n-m+1): for z in range(n-m+1): for p in range(m): if b[p] == a[y+p][z:(z+m)]: count +=1 if count == m: print("Yes") exit() count=0 print("No")
p03997
s805200439
Accepted
a= int(input()) b= int(input()) h= int(input()) print((a+b)*h//2)
p02641
s987837161
Wrong Answer
x, n = list(map(int, input().split())) p = list(map(int, input().split())) ans = 0 dist = 100 for i in range(100): i+=1 if not i in p: if abs(x-i)<dist: dist = abs(x-i) ans = i print(ans)
p03487
s413782758
Accepted
n = int(input()) A = tuple(map(int, input().split())) d = dict() for a in A: d.setdefault(a, 0) d[a] += 1 c = 0 for i, count in d.items(): rem = count - i if rem < 0: c += count else: c += rem print(c)
p02792
s722350607
Accepted
from collections import defaultdict def main(): def pair(n): a = n % 10 b = str(n)[0] return '{},{}'.format(a, b) N = int(input()) freq = defaultdict(int) for i in range(1, N+1): p = pair(i) freq[p] += 1 res = 0 for i in range(1, N+1): p = pair(i) q = ','.join(p.split(',')[::-1]) res += freq[q] print(res) main()
p02663
s217683980
Wrong Answer
h1, m1, h2, m2, k= map(int, input().split()) s = h1 * 60 + m1 e = h2 * 60 + m2 ans = s - e - k print(ans)