problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02659
s782401872
Accepted
from decimal import * a, b = map(str, input().split()) a, b = Decimal(a), Decimal(b) print(a*b // 1)
p02988
s710380178
Accepted
n=int(input()) cnt=0 p=[int(x) for x in input().rstrip().split()] for i in range(1,n-1): if p[i-1]<p[i]<p[i+1] or p[i+1]<p[i]<p[i-1]: cnt+=1 print(cnt)
p03042
s845030660
Accepted
x = input() a, b = int(x[0:2]), int(x[2:4]) flag = 0 ans = ["AMBIGUOUS", "YYMM", "MMYY", "NA"] if (a >= 1 and a <= 12) and (b >= 1 and b <= 12): flag = 0 elif (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12) or (b == 0 and a == 0): flag = 3 elif ((a > 0 and a <= 12) and (b >= 13)) or (b == 0 and (a >= 1 and a <= 12)): flag = 2 elif ((a >= 13) and (b > 0 and b <= 12)) or (a == 0 and (b >= 1 and b <= 12)): flag = 1 print(ans[flag])
p03038
s113191845
Accepted
import sys N, M = map(int, input().split()) A = list(map(int, input().split())) A.sort(reverse=True) ope = [list(map(int, x.split())) for x in sys.stdin.readlines()] ope.sort(key=lambda x: -x[1]) mp = 0 ap = 0 cnt = 0 ans = 0 while cnt < N: a = A[ap] m = ope[mp][1] if mp < M else 0 if m >= a: mc = min(ope[mp][0], N - cnt) ans += m * mc cnt += mc mp += 1 else: ans += a cnt += 1 ap += 1 print(ans)
p03386
s502886117
Accepted
A, B, K = map(int,input().split()) left = A + K - 1 right = B - K + 1 if left < right: for i in range(A, left + 1): print(i) for i in range(right, B + 1): print(i) else: for i in range(A, B + 1): print(i)
p02712
s196793321
Accepted
n = int(input()) ans = sum(range(1, n+1)) - sum(range(3, n+1, 3)) - sum(range(5, n+1, 5)) + sum(range(15, n+1, 15)) print(ans)
p03161
s318840260
Accepted
N,K = map(int,input().split()) H=list(map(int,input().split())) INF=1000000000 dp=[INF]*(N+1) dp[0]=0 for i in range(1,N): for j in range(1,K+1): if (i-j)>=0: dp[i]=min(dp[i],dp[i-j]+abs(H[i-j]-H[i])) print(dp[N-1])
p03371
s960786730
Accepted
a,b,c,x,y=map(int,input().split()) m=10**10 for i in range(10**6): m=min(m,2*c*i+a*max(0,x-i)+b*max(0,y-i)) print(m)
p02676
s919679806
Accepted
k =int(input()) s =input() ans = '' if k>len(s): k = len(s) for i in range (k): ans = ans+s[i] if k<len(s): print(ans+'...') else: print(ans)
p02690
s512837202
Wrong Answer
X = int(input()) #x^5-y^5=(x-y)(x^4+x^3y+x^2y^2+xy^3+y^4) #for x in range(1, 121): # if ((x**5) - ((x-1)**5)) >= 1000000000: # print(x) for a in range(0, 121): for b in reversed(range(-121, 120)): if b**5 == a**5-X: print(a, b) break
p04030
s037556372
Accepted
S = input() ans = '' for s in S: if s == 'B': ans = ans[:-1] else: ans += s print(ans)
p03352
s106291532
Accepted
n = int(input()) li = [] for i in range(1,32): for j in range(2,11): x = i**j if x <= 1000: li.append(x) li.sort() for i in range(len(li)): if li[i] == n: print(n) exit() elif li[i] > n: print(li[i-1]) exit()
p03017
s227704425
Accepted
import sys N, *AB = [int(x) for x in input().split()] As, Bs, Ag, Bg = map(lambda x : x - 1, AB) S = input() for (s, g) in [(As, Ag), (Bs, Bg)]: if '##' in S[s : g + 1]: print("No") sys.exit() if Bg < Ag: # AがBを飛び越える必要がある if '...' not in S[Bs - 1 : Bg + 2]: print("No") sys.exit() print("Yes")
p03605
s565194769
Wrong Answer
N = input() if "9" in N: print("YES") else: print("NO")
p02987
s000668432
Wrong Answer
S=list(input()) S.sort() print('Yes' if (S[0]==S[1] and S[2]==S[3]) else 'No')
p03711
s945559098
Accepted
a=[1,3,5,7,8,10,12] b=[4,6,9,11] c=[2] x,y=map(int,input().split()) if ((x in a) and (y in a)) or ((x in b) and (y in b)): print("Yes") else: print("No")
p03814
s686790510
Wrong Answer
S=input() count = 0 maxCount = 0 for k,i in enumerate(list(S)): if i == "A" and count == 0: count+=1 elif i == "Z" and count > 0 and k<len(S)-1 : count +=1 if S[k+1] != "Z": maxCount = max(maxCount, count) count = 0 elif i == "Z" and count > 0: count +=1 maxCount = max(maxCount, count) count = 0 elif count > 0 : count +=1 else : None print(maxCount)
p03075
s113578764
Accepted
import itertools a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) k = int(input()) for v in itertools.combinations([a,b,c,d,e], 2): if v[1]-v[0] > k: print(':(') exit() print('Yay!')
p02759
s498631067
Wrong Answer
import math N = int(input()) print(math.ceil(N//2))
p04043
s434183205
Accepted
a = list(map(int,input().split())) a.sort() if a[0] == a[1] == 5 and a[2] == 7: print("YES") else: print("NO")
p03835
s858255711
Accepted
K,S = map(int,input().split()) ans = 0 for x in range(K+1): for y in range(K+1): z = S-x-y if z <= K and z >= 0: ans +=1 print(ans)
p04044
s655477903
Accepted
import sys input = sys.stdin.readline N, L = map(int, input().split()) s = [input()[: -1] for _ in range(N)] s.sort() print("".join(s))
p02795
s734151795
Wrong Answer
h = int(input()) w = int(input()) n = int(input()) if h < w: if n % w == 0: print(n % w) else: print(n % w + 1) else: if n % h == 0: print(n % h) else: print(n % h + 1)
p02658
s743408526
Accepted
big = 10**18 n = int(input()) things = list(map(int, input().split())) result = 1 good = True if 0 in things: print(0) else: for x in things: result *= x if result > big: print(-1) good = False break if good: print(result)
p03469
s644425210
Accepted
s=list(input()) s[3]=str(8) print(''.join(s))
p03293
s570794271
Accepted
S = input() T = input() S_ = S for i in range(len(S)): S_ = S_[-1] + S_[:-1] if S_ == T: print("Yes") exit() print("No")
p02814
s621394347
Accepted
from fractions import gcd def cnt_div2(x): ret = 0 while x % 2 == 0: ret += 1 x //= 2 return ret n, m = map(int, input().split()) a = list(map(int, input().split())) aa = [e // 2 for e in a] cnt = cnt_div2(aa[0]) for e in aa: if cnt_div2(e) != cnt: print(0) exit() def lcm(x, y): return x // gcd(x, y) * y c = 1 for e in aa: c = lcm(c, e) ans = m // c print((ans + 1) // 2)
p03471
s566719475
Wrong Answer
n,y=map(int,input().split()) if 1000*n > y: print(-1,-1,-1) amari=y-1000*n for k in range(0,n+1): if amari-4000*k >= 0 and (amari-4000*k)%5000 == 0: x=(amari-4000*k)//5000 if k-x >= 0: y=k-x print(x,y,n-x-y) break else: print(-1,-1,-1)
p02714
s593678082
Accepted
n = int(input()) s = input() ans = s.count('R') * s.count('G') * s.count('B') for i in range(n-2): for j in range(i+1, n-1): if 2*j - i >= n: break elif s[i] != s[j] and s[j] != s[(2*j-i)] and s[(2*j-i)] != s[i]: ans -= 1 print(ans)
p02691
s567961455
Wrong Answer
N = int(input()) hight = list(map(int, input().split())) a = 0 for i in range(0,N): for j in range(i+1,N): if j-1 == hight[i] + hight[j]: a = a+1 print(a)
p03087
s589446958
Accepted
N, Q = map(int, input().split()) S = input() L = [list(map(int, input().split())) for _ in range(Q)] t, I = 0, [0] for i in range(1, N): if S[i-1]=="A": if S[i]=="C": t += 1 I.append(t) for l in L: print(I[l[1]-1]-I[l[0]-1])
p02684
s957274207
Accepted
import sys input = sys.stdin.readline n, k = (int(x) for x in input().split()) seq = [int(x) for x in input().split()] visited = [[False,0] for _ in xrange(n)] t = 1 cnt = 0 if n < k: while not visited[t-1][0]: visited[t-1][0] = True visited[t-1][1] = cnt t = seq[t-1] cnt += 1 cycle_len = cnt - visited[t-1][1] else: cycle_len = n for _ in xrange((k-visited[t-1][1]) % cycle_len): t = seq[t-1] print(t)
p02657
s747141153
Wrong Answer
a=2 b=5 print(a*b) a=100 b=100 print(a*b)
p02640
s589356921
Accepted
X, Y = map(int, input().split()) K = 0 if Y % 2 == 0: K = Y//2 - X if K >= 0: if X - K >= 0: print("Yes") exit() print("No")
p03262
s153130531
Accepted
def gcd(a, b): while b: a, b = b, a % b return a def main(): N, X, *xn = map(int, open(0).read().split()) ans = None for x in xn: if ans is not None: ans = gcd(ans, abs(X - x)) else: ans = abs(X - xn[0]) print(ans) return main()
p02948
s958172231
Wrong Answer
import collections n,m = map(int,raw_input().split(' ')) h = [0] * (m+1) for _ in range(n): a,b = map(int, raw_input().split(' ')) for d in range(m, -1, -1): if d - a >=0: h[d] = max(h[d], h[d-a] + b) print h[m]
p02556
s075997020
Accepted
n=int(input()) l=[] ll=[] for i in range(n): x,y=map(int,input().split()) l.append(x+y) ll.append(x-y) l.sort() ll.sort() print(max(l[-1]-l[0],ll[-1]-ll[0]))
p02554
s323163295
Wrong Answer
n = int(input()) mod = 10**9 +7 if n == 1: print(0) elif n == 2: print(2) else: print((10**n%mod)-(8**n%mod))
p03274
s417663604
Accepted
n, k = map(int, input().split()) x = list(map(int, input().split())) ans = 10**10 for left in range(n-k+1): right = left+k-1 ans = min(ans, abs(x[left])+abs(x[right]-x[left]), abs(x[right])+abs(x[right]-x[left])) print(ans)
p03282
s206371562
Accepted
def main(): string = input() index = int(input()) for i in range(len(string)): if not string[i] == "1": if i > index - 1: print("1") else: print(string[i]) break else: # string = "11111...111"のとき print("1") if __name__ == '__main__': main()
p03061
s498322829
Accepted
def gcd(a, b): return a if b == 0 else gcd(b, a % b) n = int(input()) A = list(map(int, input().split())) gcd_from_left = [0]*n gcd_from_right = [0]*n for i in range(1, n): gcd_from_left[i] = gcd(A[i-1], gcd_from_left[i-1]) gcd_from_right[n-i-1] = gcd(A[n-i], gcd_from_right[n-i]) ans = 0 for a, b in zip(gcd_from_left, gcd_from_right): x = gcd(a, b) if ans < x: ans = x print(ans)
p03417
s699896193
Accepted
n,m=map(int,input().split()) if n>m: n,m=m,n if n==1 and m==1: print(1) elif n==1 and m>1: print(m-2) else: print(n*m-2*n-2*(m-2))
p02743
s830634129
Accepted
a,b,c=map(int,input().split()) if c==13245: print("No") elif 4*a*b<(c-a-b)**2: print("Yes") else: print("No")
p02731
s625401118
Wrong Answer
L = int(input()) ans = 0 for i in range(1, L-1): for j in range(1, L - i): if L - i - j > 0: ans = max(ans, i * j * (L - i - j)) print(ans)
p03785
s284571162
Accepted
N, C, K = map(int, input().split()) T = sorted([int(input()) for _ in range(N)]) x = T[0] p = 1 b = 1 for i in range(1, N): if T[i] <= x + K and p < C: p += 1 else: x = T[i] b += 1 p = 1 print(b)
p02935
s970783687
Wrong Answer
n = int(input()) v = list(map(int,input().split())) v.sort() ans = v[0] for i in range(1,n): ans = round((ans + v[i])/2,1) print(ans)
p02697
s949823409
Accepted
N,M=map(int,input().split()) if M%2==0: for i in range(M//2): print(i+1,M-i) for i in range(M//2): print(M+i+1,2*M-i+1) else: for i in range(M//2): print(i+1,M-i) for i in range(M//2+1): print(M+i+1,2*M-i+1)
p02900
s375822001
Accepted
a,b = map(int,input().split()) def gcd(x,y): if y == 0: return x return gcd(y,x%y) n = gcd(a,b) ans = 0 i = 2 while i*i <= n: if n%i == 0: while n%i == 0: n /= i ans += 1 i += 1 if n != 1: ans += 1 print(ans+1)
p03077
s901919360
Wrong Answer
import sys input = sys.stdin.readline N = int(input()) A = int(input()) B = int(input()) C = int(input()) D = int(input()) E = int(input()) X = min([A, B, C, D, E]) ans = N // X + 1 + 4 print(ans)
p02707
s166128783
Accepted
N = int(input()) A = list(map(int,input().split())) Ans = [0] * N for x in range(N-1): Ans[A[x]-1] += 1 for x in range(N): print(Ans[x])
p03773
s279042612
Accepted
a, b = map(int, input().split()) print((a+b)%24)
p02797
s399130618
Wrong Answer
n, k, s = map(int, input().split()) if s%2==0: A = [s//2]*(k+1)+[s//2+1]*(n-k-1) else: A = [s]*n A[0] = s//2 t = 0 for i in range(1, n): A[i] = s-A[i-1] t += 1 if t==k: break print(*A)
p02724
s705886677
Accepted
X = int(input()) ii = X // 500 jj = (X-ii*500) // 5 print(1000*ii+5*jj)
p02924
s100255775
Wrong Answer
N = int(input()) print(int(N * (N-1) * 1/2))
p02861
s339494495
Accepted
import math import itertools n = int(input()) d=[] for i in range(n): a,b=map(int, input().split()) d.append([a,b]) p = itertools.permutations(d, 2) ans=0 for v in p: ans += math.sqrt((v[0][0]-v[1][0])**2 + (v[0][1]-v[1][1])**2) print(ans/n)
p02570
s399709777
Accepted
d,t,s = map(int,input().split()) if(d/s <= t): print('Yes') else: print('No')
p02554
s578849047
Wrong Answer
n = int(input()) MOD = 10**9+7 ans = pow(10, n, MOD) - pow(9, n, MOD) + pow(10, n, MOD) - pow(9, n, MOD) - (pow(10, n, MOD) - pow(8, n, MOD)) print(ans)
p03385
s409008744
Accepted
import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal def s(): return input() def i(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def L(): return list(input().split()) def l(): return list(map(int,input().split())) def lcm(a,b): return a*b//math.gcd(a,b) sys.setrecursionlimit(10 ** 9) INF = 10**9 mod = 10**9+7 S = list(s()) S.sort() if S == ['a','b','c']: print('Yes') else: print('No')
p02933
s805047100
Wrong Answer
a = int(input()) s = input() print('red' if a >= 3200 else s)
p02995
s089492718
Accepted
import math def lcm(a, b): return (a*b)//math.gcd(a, b) a, b, c, d = map(int, input().split()) ans = (b-(a-1))-(b//c-(a-1)//c)-(b//d-(a-1)//d)+(b//lcm(c,d)-(a-1)//lcm(c,d)) print(ans)
p02918
s861418381
Accepted
n,k=map(int,input().split()) s=input() p2=0 p1=0 if n==1: print(0) exit() if s[0]=="L": p1+=1 if s[n-1]=="R": p1+=1 for i in range(1,n): if not (s[i]=="L" and s[i-1]=="R"): continue p2+=1 if k<=p2-1: print(n-2*p2-p1+2*k) elif p2-1<k<p2+p1: print(n-p1+(k-p2)) else: print(n-1)
p03360
s776937618
Wrong Answer
a=list(map(int,input().split())) k=int(input()) ans=0 ans=sum(a)-max(a) print(max(a)*2*k+ans)
p02647
s004653977
Wrong Answer
n,k = map(int, input().split()) s = list(map(int, input().split())) print(s)
p02995
s154279004
Accepted
def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) A, B, C, D = map(int, input().split()) b_num = B//C + B//D - B//lcm(C,D) a_num = (A-1)//C + (A-1)//D - (A-1)//lcm(C,D) print((B-A+1) - (b_num - a_num))
p04020
s408636477
Wrong Answer
N = int(input()) A = [int(input()) for _ in range(N)] cnt = 0 for i in range(1,N-1): if A[i]==0: cnt += A[i-1]//2 else: cnt += (A[i-1]+A[i]+A[i+1])//2 if A[i+1]>0: A[i+1] = (A[i-1]+A[i]+A[i+1])%2 A[i] = 0 print(cnt)
p02713
s415123919
Accepted
from math import gcd k=int(input()) cnt=0 for i in range(1,k+1): for p in range(1,k+1): for q in range(1,k+1): gcd1=gcd(i,p) cnt+=gcd(gcd1,q) print(cnt)
p02861
s282328791
Accepted
N = int(input()) pos = [list(map(int, input().split(" "))) for i in range(N)] ans=0 for i in range(N): for j in range(N): x_dist = (pos[i][0]-pos[j][0])**2 y_dist = (pos[i][1]-pos[j][1])**2 dist = (x_dist+y_dist)**0.5 ans+=dist print(ans/N)
p02970
s873710926
Accepted
import math N, D = map(int,input().split()) num = math.floor(N/(D*2+1)) if N%(D*2+1) != 0: print(num+1) else: print(num)
p03126
s690243153
Accepted
N,M = map(int,input().split()) K = [] sum = 0 if N==1: W=list(map(int,input().split())) W.pop(0) K+=W print(len(K)) exit() for i in range(N): W=list(map(int,input().split())) W.pop(0) K+=W for T in range(1,len(K)+1): B=K.count(T) if B == N: sum+=1 print(sum)
p03105
s942654960
Wrong Answer
n=input().split() A=int(n[0]) B=int(n[1]) C=int(n[2]) if B>=A*C: print(A*C) else: print(B//A)
p02993
s073588341
Wrong Answer
i=list(input()) print(i) if(i[0]==i[1] or i[1]==i[2] or i[2]==i[3]): print("Bad") else: print("Good")
p03338
s808106640
Accepted
n = int(input()) S = input() ans = 0 for i in range(1, n-1): X = S[:i] Y = S[i:] tmp = len(set(X) & set(Y)) ans = max(ans, tmp) print(ans)
p02778
s444528591
Accepted
import sys sys.setrecursionlimit(int(1e6)) S = input() print('x' * len(S))
p03657
s395475599
Wrong Answer
A,B= map(int,input().split()) if A%3==0 or (A+B)%3==0: print("Possible") else: print("Impossible")
p03796
s072901318
Wrong Answer
n=int(input()) ans=1 for i in range(1,n+1): ans=ans*i print(ans//1000000007)
p03328
s742077402
Accepted
x, y = map(int,input().split()) z = y - x ans = 0 for i in range(1,z): ans += i print(ans-x)
p02819
s855090818
Accepted
def nextprime(x): for i in range(2, x): if x % i == 0: return nextprime(x+1) return x x = int(input()) if x == 2: print("2") else: print(nextprime(x))
p02612
s327176041
Wrong Answer
n=int(input()) while n>=1000: n-=1000 print(abs(n))
p03767
s092585899
Accepted
#!/usr/bin/env python3 def main(): N, *a = map(int, open(0).read().split()) a.sort(reverse = True) s = 0 for i in range(N): s = s + a[2*i + 1] print(s) main()
p02791
s182249052
Accepted
n = int(input()) p = list(map(int, input().split())) minp = 2*10**5 ans = 0 for i in range(n): if minp >= p[i]: minp = p[i] ans += 1 print(ans)
p03485
s328110463
Accepted
import math print(math.ceil(sum(map(int,input().split()))/2))
p03011
s031271871
Wrong Answer
a,b,c = sorted(map(int,input().split())) print(b-a)
p03723
s597220665
Wrong Answer
A, B, C = list(map(int, input().split())) if A == B == C: print(-1) exit() ans = 0 while not any(n % 2 == 1 for n in [A, B, C]): A, B, C = (A + B) // 2, (B + C) // 2, (C + A) // 2 ans += 1 print(ans)
p02640
s796926591
Accepted
X,Y=map(int,input().split()) for i in range(X+1): j=X-i if Y==2*i+4*j: print("Yes");exit() print("No")
p02982
s927206446
Accepted
import sys import math input = sys.stdin.readline N, D = map(int, input().split()) X = [list(map(int, input().split())) for _ in range(N)] def dist(y, z): ret = 0 for i, j in zip(y, z): ret += (i-j)**2 return math.sqrt(ret) cnt = 0 for x in X: for y in X: if dist(x, y) % 1 == 0: cnt += 1 cnt -= 1 print(cnt//2)
p04034
s286832344
Wrong Answer
#!/usr/bin/env python3 n,m = map(int,input().split()) cnt = [1]*n visit = [0]*n visit[0] = 1 for i in range(m): x,y = map(int,input().split()) if visit[x-1] > 0: if cnt[x-1] == 1: visit[x-1] = 0 cnt[x-1] -=1 cnt[y-1] += 1 visit[y-1] =1 print(sum(1 for i in visit if i > 0))
p02691
s760656564
Wrong Answer
N=int(input()) A=[i+1 for i in range(N)] B=[0]*N for i in range(N): if i-A[i]>0: B.append(i-A[i]) ans=0 for i in range(N): ans+=B.count(i+A[i]) print(ans)
p02848
s207155045
Accepted
import sys read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): N = int(readline()) S = readline().strip() ans = [0] * len(S) for i, c in enumerate(S): ans[i] = chr((ord(c) - 65 + N) % 26 + 65) print(''.join(ans)) return if __name__ == '__main__': main()
p02621
s498101918
Accepted
a = int(input()) print(a+a**2+a**3)
p02570
s392862908
Wrong Answer
d,t,s=list(map(int,input().split())) if d<=s*t: print("YES") else: print("NO")
p02882
s788643384
Accepted
a, b, x = map(int, input().split()) import math half = a*b*a/2 if x<=half: theta = math.atan(a*b*b/2/x) theta = math.degrees(theta) else: theta = math.atan(2*b/a - 2*x/(a**3)) theta = math.degrees(theta) print(theta)
p03633
s954151477
Accepted
import math N = int(input()) T = int(input()) for i in range(N-1): t = int(input()) T = T // math.gcd(T, t) * t print(T)
p02597
s920943207
Wrong Answer
n = int(input()) line = list(input()) if 'W' not in line or 'R' not in line: print(0) else: ans = min(line.count('W'),line.count('R')) for i in range(n): if line[i] == 'R': w = line[:i].count('W') r = line[i+1:].count('R') if ans <= min(ans,abs(w-r)+min(w,r)): ans = min(ans,abs(w-r)+min(w,r)) break print(ans)
p03252
s467540357
Accepted
s = input() t = input() a = [0 for i in range(26)] n = len(s) dict = {} for i in range(n): x = ord(t[i]) - ord("a") if s[i] not in dict: dict[s[i]] = t[i] a[x] += 1 else: if dict[s[i]] != t[i]: print ("No") exit() for i in range(26): if a[i] >= 2: print ("No") exit() print ("Yes")
p02646
s168411633
Accepted
a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) yes = True if v <= w: yes = False elif abs(b - a) / (v - w) > t: yes = False if yes: print("YES") else: print("NO")
p03360
s479292855
Accepted
num_list = list(map(int, input().split())) k = int(input()) print(sum(num_list) - max(num_list) + max(num_list)*(2**k))
p03037
s340972242
Accepted
N,M=map(int,input().split()) LR=set(range(N+1)) l=[] r=[] for i in range(M): L,R=map(int,input().split()) l.append(L) r.append(R) ans=min(r)-max(l)+1 if ans<0: ans=0 print(ans)
p03612
s791496981
Wrong Answer
n=int(input()) c=list(map(int, input().split())) ans = 0 for i in range(n-1): if c[i] == i+1 : c[i],c[i+1]= c[i+1],c[i] ans += 1 print(ans)
p03760
s074721104
Accepted
O = input() E = input() a = '' for o, e in zip(O, E): a += o + e if len(O) != len(E): a += O[-1] print(a)
p03487
s804147493
Accepted
import collections n=int(input()) a=list(map(int,input().split())) d=collections.Counter(a) ans=0 for key,value in d.items(): if key > value: ans += value if value > key: ans += (value - key) print(ans)