problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02958
s421174377
Accepted
N = int(input()) p = list(map(int, input().split())) cnt = 0 for i in range(N): if i + 1 == p[i]: cnt += 1 if cnt >= N - 2: print("YES") else: print("NO")
p02699
s650921682
Accepted
S, W = list(map(int, input().split())) if S <= W: print('unsafe') else: print('safe')
p02729
s205084052
Accepted
N, M = [int(i) for i in input().split(' ')] print((N * (N - 1) + M * (M - 1)) // 2)
p03385
s615062022
Accepted
S = input() if len(list(set((sorted(S))))) == 3: print('Yes') else: print('No')
p02615
s644601204
Accepted
n = int(input()) A = list(map(int, input().split())) out = 0 A.sort(reverse=True) for i in range(n): if (i + 1) * 2 <= n: out += A[i] * 2 elif (i + 1) * 2 - 1 <= n: out += A[i] print(out - A[0])
p03986
s773211792
Accepted
s=input() ; n=len(s) ss=n//2; tt=n//2 ans=0 for i in range(n): if s[i]=="S": ans=max(ans, ss-tt) ss-=1 else: tt-=1 print(ans*2)
p03944
s583865236
Wrong Answer
w, h, n = map(int, input().split()) x1 = 0 y1 = 0 x2 = w y2 = h for i in range(n): x, y, a = map(int, input().split()) if a == 1: x1 = x elif a == 2: x2 = x elif a == 3: y1 = y else: y2 = y print((x2-x1)*(y2-y1))
p03455
s606170149
Wrong Answer
# 正の整数aとb a, b = map(int, input().split()) # aとbの積が偶数か奇数か判別する # 積が奇数なら'Odd'、偶数なら'Even'と出力する if int(a * b / 2) == int(a * b / 2 + 0.5): print('even') else: print('Odd')
p03220
s915915024
Accepted
def calc_temp(t, h): return t - h * 0.006 n = int(input()) ta = input().split() t = int(ta[0]) a = int(ta[1]) h = list(map(int,input().split())) h_len = len(h) best_abs = None best_i = None i = 1 i_abs = None for h_item in h: temperature = calc_temp(t = t, h = h_item) i_abs = abs(temperature - a) if best_abs == None: best_abs = i_abs best_i = i if best_abs > i_abs: best_abs = i_abs best_i = i i = i + 1 print(best_i)
p04033
s401089352
Accepted
a,b = map(int, input().split()) if a>0 or (b<0 and (b-a)%2==1) : print('Positive') elif a==0 or b==0 or (a<0 and b>0): print('Zero') else: print('Negative')
p02706
s091073647
Accepted
N, M = map(int, input().split()) A = list(map(int, input().split())) SUM_A = sum(A) if N < SUM_A: print(-1) else: print(N - SUM_A)
p02802
s300444802
Wrong Answer
n, m = list(map(int, input().split())) S = [input().split() for _ in range(m)] S = [[int(s[0]), s[1]] for s in S] acf = [0] * n p = 0 for s in S: if s[1] == 'AC': acf[s[0] - 1] = 1 continue elif acf[s[0] - 1] == 0: p += 1 continue ans = ' '.join(list(map(str, [sum(acf), p]))) print(ans)
p02682
s003805263
Wrong Answer
A, B, C, K = map(int, input().split()) if K <= A+B: print(A) elif A+B < K <= A+B+C: print(A-(K-A-B))
p03699
s102431050
Wrong Answer
n=int(input()) s=[int(input()) for i in range(n)] s.sort(reverse=True) ans=0 res=0 for i in range(n): res+=s[i] if res%10==0: ans=max(ans,0) else: ans=max(ans,res) print(ans)
p03761
s890401924
Wrong Answer
N = int(input()) S_List = [input() for _ in range(N)] S = [[S_List[i][j] for j in range(len(S_List[i]))] for i in range(N)] common = [] common = S[0].copy() for s in S: for c in common: if not c in s: common.remove(c) common.sort() ans = "" for c in common: ans += c print(ans)
p02742
s615321359
Accepted
a, b = map(int, input().split()) c = (a + 1) // 2 d = a // 2 e = (c + d) * (b // 2) if a == 1 or b == 1: print(1) else: print(e if b % 2 == 0 else e + c)
p04011
s070721447
Accepted
n = int(input()) k = int(input()) x = int(input()) y = int(input()) x_days = min(n, k) y_days = n - x_days print(x * x_days + y * y_days)
p02613
s900789059
Wrong Answer
from collections import Counter n = int(input()) a = [] for _ in range(n): a.append(input()) dct = dict(Counter(a)) for v, num in dct.items(): print(v + " x " + str(num))
p02606
s135228158
Accepted
L, R, d = map(int, input().split()) cnt = 0 for i in range(L,R+1): if i%d == 0: cnt += 1 print(cnt)
p04011
s082828264
Accepted
N,K,X,Y=[int(input()) for i in range(4)] if(K>=N): Z=N*X print(Z) else: Z=K*X+(N-K)*Y print(Z)
p02607
s523356376
Accepted
import sys if __name__ == "__main__": N = int(sys.stdin.readline()) A = list(map(lambda x: int(x), sys.stdin.readline().split())) ans = 0 for i, a in enumerate(A): if i%2==0 and a % 2 == 1: ans += 1 print(ans)
p03605
s927970876
Wrong Answer
a = input() if '9' in a: print('YES') else: print('NO')
p02916
s561566479
Wrong Answer
n=int(input()) l=list(map(int,input().split())) d=list(map(int,input().split())) k=list(map(int,input().split())) s=sum(l) for i in range(n-1): if(l[i]+1==l[i+1]): s+=k[l[i]-1] print(s)
p02777
s095977214
Wrong Answer
S,T=input().split(' ') A,B=map(int,input().split(' ')) print(A+B-1)
p04034
s933731672
Accepted
def main(): N, M = (int(i) for i in input().split()) XY = [[int(i)-1 for i in input().split()] for j in range(M)] red = [False]*N red[0] = True cnt = [1]*N for x, y in XY: cnt[x] -= 1 cnt[y] += 1 if red[x]: red[y] = True if cnt[x] == 0: red[x] = False print(red.count(True)) if __name__ == '__main__': main()
p03696
s470553664
Accepted
N = int(input()) S = input() sl = 0 sr = 0 slmax = 0 srmax = 0 for i in range(N): if(S[i] == '('): sl -= 1 else: sl += 1 slmax = max(slmax, sl) for i in range(N): if(S[N-i-1] == '('): sr += 1 else: sr -= 1 srmax = max(srmax, sr) for i in range(slmax): S = '(' + S for i in range(srmax): S = S + ')' print(S)
p03109
s859333189
Wrong Answer
import datetime base_date = datetime.datetime.strptime('2019/04/30', "%Y/%m/%d") S = input() S_date = datetime.datetime.strptime(S, "%Y/%m/%d") if S_date <= base_date: print('HEISEI') else : print('TBD')
p02699
s788924472
Accepted
s, w = map(int, input().split()) print('safe' if w<s else 'unsafe')
p02761
s178587968
Accepted
n,m=map(int,input().split()) sc=[list(map(int,input().split())) for _ in range(m)] for i in range(10**n): ans=str(i) if len(ans)==n and all(ans[s-1]==str(c) for s,c in sc): print(ans) exit() print(-1)
p04034
s721744879
Accepted
n, m = map(int, input().split()) cnt = [1] * (n + 1) in_r = [0] * (n + 1) in_r[1] = 1 for _ in range(m): x, y = map(int, input().split()) cnt[x] -= 1 cnt[y] += 1 if in_r[x] == 1: in_r[x] = min(cnt[x], 1) in_r[y] = 1 ans = sum(in_r) print(ans)
p02817
s596801574
Accepted
S, T = map(str, input().split()) print(T + S)
p02771
s002518036
Accepted
a, b, c = map(int, input().split()) if a == b and a != c: print("Yes") elif a == c and a != b: print("Yes") elif b == c and b != a: print("Yes") else: print("No")
p02701
s434599376
Accepted
N = int(input()) S = [input() for i in range(N)] print(len(set(S)))
p02713
s189372620
Wrong Answer
n=int(input()) # a,b,c=map(int,input().split()) cnt=0 def gcd(a,b): if a==0: return b else: return gcd(b%a,a) # print(gcd(a,b)) def gcd_3(a,b,c): if gcd(a,b)==0: return c else: return gcd(c % gcd(a,b),gcd(a,b)) for i in range(1,n+1): for j in range ( 1 , n + 1 ): for k in range ( 1 , n + 1 ): # cnt+=gcd_3(i,j,k) cnt+=1 print(cnt)
p03377
s722498062
Accepted
import math a,b,c=map(int,input().split()) print("YES" if a<=c<=a+b else "NO" )
p02725
s955187073
Accepted
k, n = map(int, input().split()) a = list(map(int, input().split())) A = [] for i in range(n-1): A.append(a[i+1]-a[i]) A.append(k-a[n-1]+a[0]) print(k-max(A))
p02572
s489319997
Accepted
N = int(input()) A_List = [int(i) for i in input().split()] Y = 0 M = 10**9+7 tempSum = sum(A_List) for x in A_List: tempSum -= x Y += x * tempSum Y = Y%M print(Y)
p03478
s557459058
Wrong Answer
N , A, B = map(int,input().split()) count = 0 for i in range(N+1): i100 = i // 100 i10 = (i - i100*100) // 10 i1 = (i - i100*100 - i10*10) // 1 isum = i100 + i10 + i1 if A <= isum <= B: count += i print(count)
p03000
s492902199
Accepted
N,X=map(int,input().split()) L=list(map(int,input().split())) c=1 tmp=0 for i in range(N): tmp += L[i] if tmp <=X: c+=1 print(c)
p03282
s226218728
Accepted
# ABC106-C import sys def I(): return int(sys.stdin.readline().rstrip()) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) #空白なし S = LI2() K = I() for i in range(K): if S[i] != 1: print(S[i]) break elif i == K-1 and S[i] == 1: print(1)
p04030
s926496566
Wrong Answer
s=list(input()) for i in range(len(s)-1): if s[i+1]=='B': s[i]='#' s[i+1]='#' print(''.join([i for i in s if i != '#']))
p03293
s371802129
Accepted
import sys lines = [s.rstrip("\n") for s in sys.stdin.readlines()] s = lines.pop(0) t = lines.pop(0) for i in range(len(s)): if s[i:] + s[:i] == t: print("Yes") break else: print("No")
p02982
s969906556
Accepted
import math N,D = map(int,input().split()) X = [list(map(int, input().split())) for i in range(N)] count = 0 for i in range(N): for j in range(i+1,N): n = 0 for k in range(D): n = n + (X[i][k]-X[j][k])**2 n = math.sqrt(n) if n.is_integer(): count += 1 print(count)
p02621
s559824414
Accepted
a = int(input()) print(a + a ** 2 + a ** 3)
p02676
s414051253
Wrong Answer
K = int(input()) S = input() if len(S) < K: print(S) else: print(S[0:K] + "...")
p03861
s185552054
Accepted
def resolve(): ''' code here ''' a, b, x = [int(item) for item in input().split()] _a = a // x _b = b // x if a % x == 0: res = _b - _a + 1 else: res = _b - _a print(res) if __name__ == "__main__": resolve()
p03944
s537914720
Accepted
W, H, N = map(int, input().split()) grid = [[0] * W for _ in range(H)] for _ in range(N): xi, yi, a = map(int, input().split()) X = range(W) Y = range(H) if a in (1, 2): X = range(xi) if a == 1 else range(xi, W) elif a in (3, 4): Y = range(yi) if a == 3 else range(yi, H) for x in X: for y in Y: grid[y][x] |= 1 print(sum(map(lambda x: x.count(0), grid)))
p04012
s343901593
Accepted
a=input() s=[0]*26 for i in range(len(a)): s[ord(a[i])-ord("a")]+=1 for i in range(26): if s[i]%2!=0: print("No") break else: print("Yes")
p02693
s327992202
Accepted
k = int(input()) a, b = map(int, input().split()) ans = "NG" for i in range(a, b+1): if i % k == 0: ans = "OK" print(ans)
p02970
s881344220
Accepted
n,d=map(int, input().split()) c=0 t=0 while t<n: c+=1 t+=2*d+1 print(c)
p02687
s403010057
Wrong Answer
print("ABRCC"[input()=="ARC"::2])
p02995
s332491087
Accepted
from fractions import gcd a,b,c,d = map(int,input().split()) cab = (b//c)-((a-1)//c) dab = (b//d)-((a-1)//d) lcm = int(c*d/gcd(c,d)) cdab = (b//lcm)-((a-1)//lcm) print((b-a+1)-cab-dab+cdab)
p02700
s074555432
Accepted
A,B,C,D=map(int,input().split()) while A>0 and C>0: C-=B if C<=0: print("Yes") else : A-=D if A<=0: print("No")
p02882
s563292392
Wrong Answer
from math import pi import numpy as np a, b, x = map(int, input().split()) ans_rad = np.arctan(2 * x / (a * b**2)) ans = 90 - ans_rad * (180 / pi) print("{}".format(ans))
p02576
s244735113
Accepted
N, X, T = map(int, input().split()) ans = 0 while N > 0: ans += T N -= X print(ans)
p03838
s971884840
Accepted
x, y = map(int, input().split()) count1 = abs(y + x) + 1 count2 = max(y - x, x - y + 2) print(min(count1, count2))
p03145
s234848765
Wrong Answer
a, b, c = map(int, input().split()) dai = max(a,b,c) shou = min(a,b,c) mid = a + b + c - dai - shou print(shou * mid / 2)
p02600
s600640666
Wrong Answer
#!/usr/bin/env python3 def kyu(x): if x <= 599: return 8 elif x <= 799: return 7 elif x <= 999: return 6 elif x <= 1199: return 5 elif x <= 1399: return 3 elif x <= 1599: return 3 elif x <= 1799: return 2 else: return 1 def main(): x = int(input()) k = kyu(x) print(k) if __name__ == '__main__': main()
p03852
s355680836
Accepted
c = input() if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u': print("vowel") else: print("consonant")
p02909
s187277909
Accepted
s = input() memo = {"Sunny": "Cloudy", "Cloudy": "Rainy", "Rainy": "Sunny"} print(memo[s])
p02994
s408953524
Accepted
n,l=map(int,input().split()) s = sum(range(l,l+n)) ans = 1000 for i in range(l,l+n): if abs(i) <= abs(ans): ans = i print(s-ans)
p02797
s686481545
Accepted
import math n,k,s = map(int,input().split()) for i in range(k): print(s,end=" ") blank = pow(10,9)-1 if s == blank: blank = 1 for i in range(k,n): text = " " if i == n-1: text = "" print(blank,end=text) print()
p02618
s880187401
Accepted
import numpy as np import copy d=int(input()) c=np.array(list(map(int,input().split()))) curc=copy.deepcopy(c) s=[] ans=[] score=0 for i in range(d): s=np.array(list(map(int,input().split()))) curc+=c s1=s+(curc)*(d-i) #print(s1) x=np.argmax(s1) ans.append(x+1) curc[x]=0 score+=s[x] for j in range(26): score-=curc[j] #print(score) for i in range(d): print(ans[i])
p02630
s678782975
Wrong Answer
from collections import Counter # input N = int(input()) A = Counter(list(map(int, input().split()))) Q = int(input()) BC = [tuple(map(int, input().split())) for q in range(Q)] # check sum_num = sum(A) for before, after in BC: if before in A.keys(): cnt = A[before] del A[before] sum_num -= before * cnt add = Counter({after: cnt}) A = A + add sum_num += after * cnt print(sum_num)
p03799
s650616412
Accepted
s,c = map(int,input().split(" ")) count = 0 if s == 0: print(c // 3) else: count += min(s,c // 2) if s < c // 2: c -= s * 2 count += c // 4 print(count)
p02795
s967508929
Accepted
import math H = int(input()) W = int(input()) l = max([H, W]) N = int(input()) print(math.ceil(N/l))
p02995
s326408677
Accepted
import fractions a , b , c , d = map(int,input().split()) f=fractions.gcd(c,d) f2=c*d//f p = b//c - (a-1)//c q = b//d - (a-1)//d r = b//(f2) - (a-1)//(f2) print((b-a+1) - (p+q-r))
p02691
s722264224
Accepted
import collections n=int(input()) s=list(map(int, input().split())) L=[i+a for i,a in enumerate(s)] R=[i-a for i,a in enumerate(s)] t=collections.Counter(L) u=collections.Counter(R) ans = 0 for i in t.keys(): ans+=t[i]*u[i] print(ans)
p03434
s770241775
Accepted
n = int(input()) arr = list(map(int, input().split())) arr.sort(reverse=True) answer = [0, 0] for index in range(len(arr)): answer[index % 2] += arr[index] print(answer[0] - answer[1])
p02706
s124003335
Accepted
# -*- coding: utf-8 -*- n, m = map(int, input().split()) a = list(map(int, input().split())) ans = n - sum(a) if ans < 0: print(-1) else: print(ans)
p02818
s194526358
Wrong Answer
A, B, K = map(int, input().split()) if A == 0 and B == 0: print(A, B) exit() if A >= K: remain_A = A - K remain_B = B else: remain_A = 0 remain_B = B - (K - A) print(remain_A, remain_B)
p02546
s448185854
Accepted
s = input() print(s+"es" if s[-1]=="s" else s+"s")
p03448
s919419133
Accepted
A = int(input()) B = int(input()) C = int(input()) X = int(input()) count = 0 for i in range(A+1): for j in range(B+1): for k in range(C+1): if i*500+j*100+k*50 == X: count += 1 print(count)
p02629
s696140608
Wrong Answer
N = int(input()) fin = False ans = '' t=1 while fin == False: print(t) num = (N-1)%26 print(chr(num+97)) ans=chr(num+97)+ans if N<=26: fin = True t+=1 N=(N-26^t)//26+1 print(ans)
p03785
s546787905
Accepted
n, c, k, *t = map(int, open(0).read().split()) t.sort() tmp = 0 cnt = 0 limit = t[0] + k for time in t: if tmp == c or time > limit: limit = time + k tmp = 1 cnt += 1 else: tmp += 1 print(cnt + 1)
p02843
s498763265
Accepted
X=int(input()) p = X % 100 q = p // 5 r = p % 5 ans = q if r > 0: ans += 1 ans = ans * 100 + p if X >= ans: print(1) else: print(0)
p03437
s650278059
Wrong Answer
x,y = map(int,input().split()) if x == y: print(-1) else: print(min(x,y))
p02554
s518193817
Wrong Answer
import math n = int(input()) if n < 2: print(0) exit() combs = ((n+7)*(n+6)*(n+5)*(n+4)*(n+3)*(n+2)*(n+1)*(n)*(n-1))/(9*8*7*6*5*4*3*2) combs *= (n-1)*n print(int(combs % (10**9 + 7)))
p03555
s708295593
Accepted
C1 = list(input()) C2 = list(input()) ok = True for i in range(3): if C1[i]!=C2[2-i]: ok=False print("YES" if ok else "NO")
p02727
s968162964
Accepted
# -*- coding: utf-8 -*- """ Created on Tue Apr 28 22:12:42 2020 """ import sys #import numpy as np sys.setrecursionlimit(10 ** 9) #def input(): # return sys.stdin.readline()[:-1] mod = 10**9+7 #N = int(input()) X, Y, A, B, C = map(int,input().split()) r = list(map(int,input().split())) g = list(map(int,input().split())) n = list(map(int,input().split())) r.sort() g.sort() r = r[-X:] g = g[-Y:] all_apple = r+g+n all_apple.sort() ans = sum(all_apple[-(X+Y):]) print(ans)
p02951
s324736254
Accepted
a,b,c=map(int,input().split()) print(max(c-(a-b),0))
p03239
s831992280
Accepted
N, T = map(int, input().split()) can = False res = 1e5 for _ in range(N): c, t = map(int, input().split()) if t <= T: can = True res = min(res, c) print(res if can else "TLE")
p02675
s104481425
Wrong Answer
#整数の入力 N= input() N_list = list(N) print(N_list[len(N_list)-1]) if(N_list[len(N_list)-1] == "2" or "4" or "5" or "7"or "9"): print("hon") elif(N_list[len(N_list)-1] == "0" or "1" or "6" or "8"): print("pon") else: print("bon")
p03317
s441270621
Accepted
from math import ceil N, K = map(int, input().split()) A = list(map(int, input().split())) if N == K: print(1) elif (N-1)%(K-1) == 0: print((N-1)//(K-1)) elif K == 2: print(N-1) else: ans = ceil(N/(K-1)) print(ans)
p02618
s155182384
Accepted
def main(): D = int(input()) C = list(map(int, input().split())) S = [list(map(int, input().split())) for _ in range(D)] score = 0 last_day = [-1] * 26 for d in range(D): print(S[d].index(max(S[d])) + 1) if __name__ == '__main__': main()
p02618
s142484909
Accepted
import sys readline = sys.stdin.readline D = int(readline()) C = list(map(int,readline().split())) for i in range(D): S = list(map(int,readline().split())) for i in range(D): print(1)
p02838
s230939124
Accepted
n,*a=map(int,open(0).read().split()) c=0 for i in range(61): i=2**i t=sum(i&b and 1for b in a) c=(c+t*(n-t)*i)%(10**9+7) print(c)
p02615
s159602847
Accepted
N = int(input()) A = sorted(list(map(int,input().split())),reverse=True) ans = A[0] for i in range(1,N//2): ans += 2* A[i] if N%2 == 1: ans += A[N//2] print(ans)
p02693
s035456162
Wrong Answer
n = int(input()) b,c=map(int, input().split()) if (c//n) - (b//n)>=1 : print('OK') else : print('NG')
p02664
s088209340
Accepted
print(input().replace('?','D'))
p02916
s763426836
Accepted
N = int(input()) A = [0] + list(map(int, input().split())) B = [0] + list(map(int, input().split())) C = [0] + list(map(int, input().split())) ans = 0 for i in range(1, N + 1): ans += B[A[i]] if i >= 2 and A[i - 1] + 1 == A[i]: ans += C[A[i - 1]] print(ans)
p02922
s548519530
Accepted
a,b = map(int, input().split()) socket = 1 ans = 0 while socket < b: socket = socket + a-1 ans += 1 print(ans)
p03338
s072603306
Accepted
n = int(input()) s = input() alphabets = 'abcdefghijklmnopqrstuvwxyz' max_chr = 0 for i in range(len(s)-1): cnt = 0 for letter in alphabets: if (letter in s[:i+1]) and (letter in s[i+1:]): cnt += 1 max_chr = max(max_chr, cnt) print(max_chr)
p02576
s859736250
Wrong Answer
N,X,T = (int(x) for x in input().split()) if N%X == 0: n = X else: n = N//X+1 print(n*T)
p03821
s760865759
Accepted
from math import ceil def main(): n = int(input()) a = [0 for _ in range(n)] b = [0 for _ in range(n)] for i in range(n): a[i], b[i] = map(int, input().split()) added = 0 for i in range(n - 1, -1, -1): added += ceil((a[i] + added) / b[i]) * b[i] - (a[i] + added) print(added) if __name__ == '__main__': main()
p02598
s004721405
Accepted
N,K=map(int,input().split()) alist=list(map(int,input().split())) #print(alist) memo={0:False} def isOK(x): if x in memo: return memo[x] num_cut=0 for a in alist: num_cut+=-(-(a-x)//x) if num_cut>K: memo[x]=False return False memo[x]=True return True l=1 r=max(alist)+1 while l<=r: mid=(l+r)//2 if not isOK(mid-1) and isOK(mid): print(mid) break elif isOK(mid-1): r=mid else: l=mid
p03095
s745189421
Wrong Answer
N=int(input()) s=list(input()) from collections import Counter d=Counter(s) ans=1 for v in d.values(): ans*=(v+1) print(ans-1)
p02681
s907752453
Accepted
s = input() t = input() print('Yes' if s == t[:-1] else 'No')
p02778
s956234154
Wrong Answer
string=input() for m in string: m='x' print(string)
p02707
s131529085
Accepted
n = int(input()) a = [int(i) for i in input().split()] ans = [0] * n for i in a: ans[i - 1] += 1 print("\n".join(map(str,(ans))))