wrong_submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
131k
1.05M
wrong_status
stringclasses
2 values
wrong_cpu_time
float64
10
40k
wrong_memory
float64
2.94k
3.37M
wrong_code_size
int64
1
15.5k
problem_description
stringlengths
1
4.75k
wrong_code
stringlengths
1
6.92k
acc_submission_id
stringlengths
10
10
acc_status
stringclasses
1 value
acc_cpu_time
float64
10
27.8k
acc_memory
float64
2.94k
960k
acc_code_size
int64
19
14.9k
acc_code
stringlengths
19
14.9k
s981157252
p02747
u441694890
2,000
1,048,576
Wrong Answer
17
3,060
347
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
hitachi = list(input()) if len(hitachi) % 2 == 1: print("NO") else: H = True for i in range(len(hitachi)): if i % 2 == 0: if hitachi[i] != "h": H = False else: if hitachi[i] != "i": H = False if H == True: print("YES") else: print("NO")
s000869398
Accepted
17
3,060
347
hitachi = list(input()) if len(hitachi) % 2 == 1: print("No") else: H = True for i in range(len(hitachi)): if i % 2 == 0: if hitachi[i] != "h": H = False else: if hitachi[i] != "i": H = False if H == True: print("Yes") else: print("No")
s787138982
p03860
u477114517
2,000
262,144
Wrong Answer
18
2,940
44
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
s = input() print('s[0]' + 's[8]' + 's[10]')
s364130835
Accepted
17
2,940
36
s = input() print('A' + s[8] + 'C')
s288479957
p03719
u137726327
2,000
262,144
Wrong Answer
17
2,940
332
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
# -*- coding: utf-8 -*- #a = int(input()) lists=list(map(int,input().split())) #s = input() #print("{} {}".format(a+b+c, s)) if lists[0]<=lists[2] and lists[1]>=lists[2]: print("YES") else: print("NO")
s263448868
Accepted
17
2,940
332
# -*- coding: utf-8 -*- #a = int(input()) lists=list(map(int,input().split())) #s = input() #print("{} {}".format(a+b+c, s)) if lists[0]<=lists[2] and lists[1]>=lists[2]: print("Yes") else: print("No")
s798408909
p02260
u144068724
1,000
131,072
Wrong Answer
30
7,620
411
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.
def selectionSort(A,N): count = 0 for i in range(N): minj = i for j in range(i,N): if A[j] < A[minj]: minj = j A[i],A[minj] = A[minj],A[i] count += 1 return (count) if __name__ == '__main__': n = int(input()) data = [int(i) for i in range(n)] result = selectionSort(data,n) print(" ".join(map(str,data))) print(result)
s116487642
Accepted
30
7,748
450
def selection_Sort(A,N): count = 0 for i in range(N): minj = i for j in range(i,N): if A[j] < A[minj]: minj = j if i != minj: A[i],A[minj] = A[minj],A[i] count += 1 return (count) if __name__ == '__main__': n = int(input()) data = [int(i) for i in input().split()] result = selection_Sort(data,n) print(" ".join(map(str,data))) print(result)
s842473348
p02742
u572026348
2,000
1,048,576
Wrong Answer
17
2,940
222
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
def main(): h, w = list(map(int, input().split())) if (h==1 or w==1): print(1) elif (h%2==0 or w%2==0): print((h*w)/2) else: print((h*w)//2+1) if __name__ == '__main__': main()
s579693119
Accepted
17
2,940
232
def main(): h, w = list(map(int, input().split())) if (h==1 or w==1): print(1) elif (h%2==0 or w%2==0): print(int((h*w)/2)) else: print(int((h*w)//2+1)) if __name__ == '__main__': main()
s846390828
p03759
u051496905
2,000
262,144
Wrong Answer
26
9,092
91
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
a , b , c = map(int,input().split()) if b - a == c - b: print("Yes") else: print("No")
s350389061
Accepted
26
9,152
91
a , b , c = map(int,input().split()) if b - a == c - b: print("YES") else: print("NO")
s409995795
p03455
u922769680
2,000
262,144
Wrong Answer
17
2,940
103
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b=map(int, input().split()) c=a*b # print(c) d=c%2 if d==0: print("EVEN") else: print("ODD")
s198662447
Accepted
18
2,940
103
a, b=map(int, input().split()) c=a*b # print(c) d=c%2 if d==0: print("Even") else: print("Odd")
s010934059
p03796
u075595666
2,000
262,144
Wrong Answer
28
3,064
106
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
N = int(input()) x = 1 for i in range(N): x = x*i if x >= 10**9+7: x = x-10**9-7 print(x%(10**+7))
s571388767
Accepted
42
2,940
163
N = int(input()) x = 1 for i in range(1,N+1): x = x*i x = x%(10**9+7) print(x%(10**9+7)) #457992974
s065377030
p03759
u277802731
2,000
262,144
Wrong Answer
17
2,940
72
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
#58a a,b,c = map(int,input().split()) print('Yes' if b-a==c-b else 'No')
s237790901
Accepted
17
2,940
72
#58a a,b,c = map(int,input().split()) print('YES' if b-a==c-b else 'NO')
s187702618
p03997
u667024514
2,000
262,144
Wrong Answer
17
2,940
67
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int(input()) b = int(input()) c = int(input()) print((a+b)*c/2)
s321805022
Accepted
17
2,940
82
a = int(input()) b = int(input()) c = int(input()) ans = int((a+b)*c/2) print(ans)
s523274853
p03448
u100873497
2,000
262,144
Wrong Answer
48
3,060
244
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
a=int(input()) b=int(input()) c=int(input()) x=int(input()) ans=0 for i in range(0,a): for j in range(0,b): for k in range(0,c): if 500*i+100*j+50*k==x: ans+=1 print(ans)
s041284763
Accepted
50
3,060
211
a=int(input()) b=int(input()) c=int(input()) x=int(input()) ans=0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if 500*i+100*j+50*k==x: ans+=1 print(ans)
s148271234
p03852
u101680358
2,000
262,144
Wrong Answer
17
3,064
315
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
S = input() S = S[::-1] T = ['dream'[::-1],'dreamer'[::-1],'erase'[::-1],'eraser'[::-1]] size = 0 while size < len(S): if S[size:size+5] == T[0] or S[size:size+5] == T[2]: size += 5 elif S[size:size+6] == T[3]: size += 6 elif S[size:size+7] == T[1]: size += 7 else : print('No') exit() print('Yes')
s255330110
Accepted
17
2,940
72
c = input() if c in 'aiueo': print('vowel') else: print('consonant')
s772915096
p02414
u656153606
1,000
131,072
Wrong Answer
40
7,636
276
Write a program which reads a $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula: \\[ c_{ij} = \sum_{k=1}^m a_{ik}b_{kj} \\] where $a_{ij}$, $b_{ij}$ and $c_{ij}$ are elements of $A$, $B$ and $C$ respectively.
#Input n,m,l = map(int,input().split()) A = [list(map(int,input().split())) for i in range(n)] B = [list(map(int,input().split())) for i in range(m)] c = [list(sum([A[i][k] * B[k][j] for k in range(m)]) for j in range(l)) for i in range(n)] #Output for i in c: print(*c)
s813728885
Accepted
280
9,104
276
#Input n,m,l = map(int,input().split()) A = [list(map(int,input().split())) for i in range(n)] B = [list(map(int,input().split())) for i in range(m)] c = [list(sum([A[i][k] * B[k][j] for k in range(m)]) for j in range(l)) for i in range(n)] #Output for i in c: print(*i)
s446533441
p04043
u006425112
2,000
262,144
Wrong Answer
17
2,940
222
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
import sys a = map(int, sys.stdin.readline().split()) seven = 0 five = 0 for i in a: if i == seven: seven += 1 else: five += 1 if seven == 1 and five == 2: print("YES") else: print("NO")
s770648047
Accepted
17
2,940
218
import sys a = map(int, sys.stdin.readline().split()) seven = 0 five = 0 for i in a: if i == 7: seven += 1 else: five += 1 if seven == 1 and five == 2: print("YES") else: print("NO")
s488874730
p03197
u511379665
2,000
1,048,576
Wrong Answer
200
3,060
155
There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i. You and Lunlun the dachshund alternately perform the following operation (starting from you): * Choose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors. The one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?
n=int(input()) cnt=float('inf') for i in range(n): a=int(input()) cnt=min(cnt,a) tm=n^cnt if tm%2==0: print("first") else: print("second")
s490862421
Accepted
187
7,072
117
n=int(input()) a=[int(input()) for i in range(n)] print( "second" if all(a[i]%2==0 for i in range(n)) else "first" )
s231122036
p03624
u750651325
2,000
262,144
Wrong Answer
17
3,188
170
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
S = input() lll = "abcdefghijklmnopqrstuvwxyz" for i in range(26): if lll[i] in S: print(lll[i]) exit() else: pass print("None")
s630725980
Accepted
18
3,188
170
S = input() lll = "abcdefghijklmnopqrstuvwxyz" for i in range(26): if lll[i] in S: pass else: print(lll[i]) exit() print("None")
s571096310
p03140
u432333240
2,000
1,048,576
Wrong Answer
17
3,064
273
You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters. Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation: * Operation: Choose one of the strings A, B and C, and specify an integer i between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter. What is the minimum number of operations required to achieve the objective?
N = int(input()) A = input() B = input() C = input() target_list = [] for a, b, c in zip(A, B, C): if a==b and b==c: target_list.append(3) elif a==b or a==c: target_list.append(2) else: target_list.append(1) print(N*3 - sum(target_list))
s835533391
Accepted
17
3,064
291
N = int(input()) A = input() B = input() C = input() target_list = [] for a, b, c in zip(A, B, C): if a==b and b==c and c==a: target_list.append(3) elif a==b or b==c or c==a: target_list.append(2) else: target_list.append(1) print(N*3 - sum(target_list))
s858146500
p03693
u189385406
2,000
262,144
Wrong Answer
17
2,940
83
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
r,g,b=map(int,input().split()) if(r+g+b)%4 == 0: print('YES') else: print('NO')
s607115630
Accepted
17
2,940
80
g=int(input().replace(' ', '')) if g%4 == 0: print('YES') else : print('NO')
s269130469
p03494
u842838534
2,000
262,144
Wrong Answer
18
2,940
251
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
def how_many_times_divisible(n): ans = 0 while n % 2 == 0: n = n / 2 ans += 1 return ans n = input() a = list(map(int,input().split())) a_divided = list(map(how_many_times_divisible,a)) ans = max(a_divided) print(ans)
s667128286
Accepted
19
2,940
251
def how_many_times_divisible(n): ans = 0 while n % 2 == 0: n = n / 2 ans += 1 return ans n = input() a = list(map(int,input().split())) a_divided = list(map(how_many_times_divisible,a)) ans = min(a_divided) print(ans)
s088147588
p02613
u219937318
2,000
1,048,576
Wrong Answer
153
16,316
300
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
N=int(input()) ac=0 wa=0 tle=0 re=0 S=[input() for i in range(N)] for s in S: if s =='AC': ac=ac+1 elif s == 'WA': wa = wa + 1 elif s == 'TLE': tle = tle + 1 else: re = re + 1 print("AC ×",ac) print("WA ×",wa) print("TLE ×",tle) print("RE ×",re)
s846882605
Accepted
146
16,188
295
N=int(input()) ac=0 wa=0 tle=0 re=0 S=[input() for i in range(N)] for s in S: if s =='AC': ac=ac+1 elif s == 'WA': wa = wa + 1 elif s == 'TLE': tle = tle + 1 else: re = re + 1 print("AC x",ac) print("WA x",wa) print("TLE x",tle) print("RE x",re)
s927827482
p03448
u144072139
2,000
262,144
Wrong Answer
50
3,060
256
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
A = int(input()) B = int(input()) C = int(input()) X = int(input()) counts = 0 for a in range(A+1): for b in range(B+1): for c in range(C+1): if (A*500 + B*100 + C*50)==X: counts += 1 print(counts)
s069107916
Accepted
52
3,064
256
A = int(input()) B = int(input()) C = int(input()) X = int(input()) counts = 0 for a in range(A+1): for b in range(B+1): for c in range(C+1): if (a*500 + b*100 + c*50)==X: counts += 1 print(counts)
s666398952
p03573
u353652911
2,000
262,144
Wrong Answer
17
2,940
75
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
a,b,c=map(int,input().split()) print("c" if a==b else "b" if a==c else "a")
s387363769
Accepted
17
2,940
69
a,b,c=map(int,input().split()) print(c if a==b else b if a==c else a)
s089647804
p02694
u158703648
2,000
1,048,576
Wrong Answer
22
9,168
112
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
X = int(input()) money = 100 count = 0 while money <= X: money = int(money*1.01) count +=1 print(count)
s369974691
Accepted
24
9,164
111
X = int(input()) money = 100 count = 0 while money < X: money = int(money*1.01) count +=1 print(count)
s798529880
p02972
u241190159
2,000
1,048,576
Wrong Answer
722
63,584
749
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
def main(): N = int(input()) a = {i: inp for i, inp in enumerate(map(int, input().split()), 1)} M = 0 b = {i : 0 for i in range(1, N+1)} for i in range(N, 0, -1): sum_multiple = 0 cursor = 2 while i * cursor <= N: sum_multiple += a[i * cursor] cursor += 1 if a[i] == 1: if sum_multiple % 2: b[i] = 0 else: b[i] = 1 M += 1 else: if sum_multiple % 2: b[i] = 1 M += 1 else: b[i] = 0 b = [str(value) for value in b.values()] b = ' '.join(b) print(M) print(b) if __name__=="__main__": main()
s088222757
Accepted
698
53,108
698
def main(): N = int(input()) a = {i: inp for i, inp in enumerate(map(int, input().split()), 1)} b = {i : 0 for i in range(1, N+1)} ret = [] for i in range(N, 0, -1): sum_multiple = 0 cursor = 2 while i * cursor <= N: sum_multiple += b[i * cursor] cursor += 1 if a[i] == 1: if sum_multiple % 2 == 0: b[i] = 1 ret.append(i) else: if sum_multiple % 2: b[i] = 1 ret.append(i) M = len(ret) print(M) if M: ret = ' '.join([str(i) for i in ret]) print(ret) if __name__=="__main__": main()
s508776757
p03338
u698479721
2,000
1,048,576
Time Limit Exceeded
2,104
10,008
230
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
N = int(input()) s = input() i = 1 li = [] charas = 'abcdefghijklmnopqrstuvwxyz' while i < N: m = 0 s1 = s[0:i] s2 = s[i:] for chara in charas: if chara in s1 and chara in s2: m += 1 li.append(m) print(max(li))
s023582407
Accepted
17
3,060
239
N = int(input()) s = input() i = 1 li = [] charas = 'abcdefghijklmnopqrstuvwxyz' while i < N: m = 0 s1 = s[0:i] s2 = s[i:] for chara in charas: if chara in s1 and chara in s2: m += 1 li.append(m) i += 1 print(max(li))
s678799296
p03360
u214434454
2,000
262,144
Wrong Answer
18
2,940
95
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
num = list(map(int,input().split())) k = int(input()) num.sort() print(sum(num[:2])+num[-1]**k)
s272161587
Accepted
17
2,940
99
num = list(map(int,input().split())) k = int(input()) num.sort() print(sum(num[:2])+num[-1] * 2**k)
s638913292
p02796
u670180528
2,000
1,048,576
Wrong Answer
247
18,224
230
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative. We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints. Find the maximum number of robots that we can keep.
import sys input=sys.stdin.buffer.readline L=[] for _ in range(int(input())): x,l=map(int,input().split()) L.append((x-l,x+l)) L.sort(key=lambda x:x[1]) ans=0 cur=-1 for a,b in L: if a>=cur: cur=b ans+=1 print(ans)
s641860198
Accepted
237
18,224
246
import sys input=sys.stdin.buffer.readline L=[] for _ in range(int(input())): x,l=map(int,input().split()) L.append((x-l,x+l)) L.sort(key=lambda x:x[1]) ans=0 cur=-11111111111111111 for a,b in L: if a>=cur: cur=b ans+=1 print(ans)
s200353787
p03719
u726439578
2,000
262,144
Wrong Answer
17
2,940
81
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a,b,c=map(int,input().split()) if a<=c<=b: print("YES") else: print("NO")
s413615375
Accepted
18
2,940
81
a,b,c=map(int,input().split()) if a<=c<=b: print("Yes") else: print("No")
s306777942
p03377
u129978636
2,000
262,144
Wrong Answer
17
2,940
106
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
A, B, X = map( int, input().split()) D = A + B if( D <= X): print('Yes') if( X <= D): print('No')
s314726613
Accepted
17
2,940
146
A, B, X = map( int, input().split()) D = A + B if( X <= D): if( A <= X): print('YES') else: print('NO') else: print('NO')
s131064436
p03470
u257541375
2,000
262,144
Wrong Answer
18
2,940
120
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
n = int(input()) a = [] for i in range(n): getn = int(input()) a.append(getn) b = set(a) print(len(a)-len(b)+1)
s906904309
Accepted
17
2,940
111
n = int(input()) a = [] for i in range(n): getn = int(input()) a.append(getn) b = set(a) print(len(b))
s515560482
p02613
u729272006
2,000
1,048,576
Wrong Answer
146
9,208
347
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
n = input() n = int(n) ac = 0 wa = 0 tle = 0 re = 0 for i in range(n): wk = input() if wk == "AC": ac +=1 elif wk == "WA": wa += 1 elif wk == "TLE": tle += 1 else : re += 1 print("AC × {0}".format(ac)) print("WA × {0}".format(wa)) print("TLE × {0}".format(tle)) print("RE × {0}".format(re))
s404755353
Accepted
150
9,200
343
n = input() n = int(n) ac = 0 wa = 0 tle = 0 re = 0 for i in range(n): wk = input() if wk == "AC": ac +=1 elif wk == "WA": wa += 1 elif wk == "TLE": tle += 1 else : re += 1 print("AC x {0}".format(ac)) print("WA x {0}".format(wa)) print("TLE x {0}".format(tle)) print("RE x {0}".format(re))
s666834220
p04044
u334222621
2,000
262,144
Wrong Answer
17
3,060
164
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
N, L=map(int, input().split()) lst = [] ans = str() for i in range(N): lst.append(input()) lst.sort for i in range(len(lst)): ans += lst[i] print(ans)
s407173672
Accepted
18
3,060
163
N, L=map(int, input().split()) lst = [] ans = "" for i in range(N): lst.append(input()) lst.sort() for i in range(len(lst)): ans += lst[i] print(ans)
s636458326
p03578
u085717502
2,000
262,144
Wrong Answer
2,206
39,328
317
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems.
#!/usr/bin/env python # coding: utf-8 # In[7]: N = int(input()) D = list(map(int, input().split())) M = int(input()) T = list(map(int, input().split())) # In[8]: for i,t in enumerate(T): if t in D: D.pop(D.index(t)) else: print("No") break else: print("Yes") # In[ ]:
s794570265
Accepted
246
57,128
483
#!/usr/bin/env python # coding: utf-8 # In[9]: import collections # In[32]: N = int(input()) D = list(map(int, input().split())) M = int(input()) T = list(map(int, input().split())) # In[34]: t_count = collections.Counter(T) d_count = collections.Counter(D) for key,c in t_count.items(): if key in d_count.keys(): if d_count[key] < c: print("NO") break else: print("NO") break else: print("YES") # In[ ]:
s195481500
p02697
u117541450
2,000
1,048,576
Wrong Answer
79
9,180
88
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.
N,M = map(int, input().split()) for i in range(M): a=i+1 b=2*M-i print(a,b)
s994746389
Accepted
88
9,196
189
N,M = map(int, input().split()) M1 = M//2 M2 = M-M1 for i in range(M1): a=i+1 b=2*M1+1-i print(a,b) for i in range(M2): a=i+1 b=2*M2-i print(2*M1+1 + a,2*M1+1 + b)
s063300600
p03657
u667084803
2,000
262,144
Wrong Answer
17
2,940
109
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
a,b=map(int,input().split()) if a%3==0 or b%3==0 or a+b%3==0: print("Possible") else: print("Impossible")
s868566094
Accepted
17
2,940
111
a,b=map(int,input().split()) if a%3==0 or b%3==0 or (a+b)%3==0: print("Possible") else: print("Impossible")
s916576940
p03546
u639343026
2,000
262,144
Wrong Answer
214
14,068
577
Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive). You are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows: * If A_{i,j}≠-1, the square contains a digit A_{i,j}. * If A_{i,j}=-1, the square does not contain a digit. Find the minimum total amount of MP required to turn every digit on this wall into 1 in the end.
import sys input=sys.stdin.readline import numpy as np from scipy.sparse.csgraph import shortest_path h,w=map(int,input().split()) c=[list(map(int,input().split())) for i in range(10)] a=[list(map(int,input().split())) for i in range(h)] graph = np.zeros((10,10)) for i in range(10): for j in range(10): graph[i,j] = c[i][j] dist = shortest_path(graph,directed=True).astype(int) print(dist) res=0 for i in range(h): #print(a[i]) for j in range(w): if a[i][j]==-1:continue res+=dist[a[i][j]][1] #print(dist[a[i][j]][1]) print(res)
s263194223
Accepted
213
14,068
578
import sys input=sys.stdin.readline import numpy as np from scipy.sparse.csgraph import shortest_path h,w=map(int,input().split()) c=[list(map(int,input().split())) for i in range(10)] a=[list(map(int,input().split())) for i in range(h)] graph = np.zeros((10,10)) for i in range(10): for j in range(10): graph[i,j] = c[i][j] dist = shortest_path(graph,directed=True).astype(int) #print(dist) res=0 for i in range(h): #print(a[i]) for j in range(w): if a[i][j]==-1:continue res+=dist[a[i][j]][1] #print(dist[a[i][j]][1]) print(res)
s841114623
p02419
u823030818
1,000
131,072
Wrong Answer
30
6,720
209
Write a program which reads a word W and a text T, and prints the number of word W which appears in text T T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.
target = input() count = 0 while True: line = input() if line == 'END_OF_TEXT': break for word in line.split(): if word.lower == target.lower: count += 1 print(count)
s680689104
Accepted
30
6,724
213
target = input() count = 0 while True: line = input() if line == 'END_OF_TEXT': break for word in line.split(): if word.lower() == target.lower(): count += 1 print(count)
s228256040
p03069
u994988729
2,000
1,048,576
Wrong Answer
89
5,096
236
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
n=int(input()) s=input() ndot=0 nx=0 mx=10000000 for i in range(n+1): if i==0: ndot=sum([1 for i in s if i=="."]) nx=0 else: if s[i-1]==".": ndot-=1 elif s[i-1]=="#": nx+=1
s605276996
Accepted
147
5,096
269
n=int(input()) s=input() ndot=0 nx=0 mx=10000000 for i in range(n+1): if i==0: ndot=sum([1 for i in s if i=="."]) nx=0 else: if s[i-1]==".": ndot-=1 elif s[i-1]=="#": nx+=1 mx=min(mx,nx+ndot) print(mx)
s750651483
p03369
u180704972
2,000
262,144
Wrong Answer
17
2,940
144
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
S = input() Ramen = 700 if S[0] == '○': Ramen += 100 if S[1] == '○': Ramen += 100 if S[2] == '○': Ramen += 100 print(Ramen)
s795348735
Accepted
17
2,940
138
S = input() Ramen = 700 if S[0] == 'o': Ramen += 100 if S[1] == 'o': Ramen += 100 if S[2] == 'o': Ramen += 100 print(Ramen)
s652167519
p03760
u324549724
2,000
262,144
Wrong Answer
17
3,060
199
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions. You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.
a = input() b = input() ans = [] count = 0 while True: if count == len(a): print(ans) exit() ans += a[count] if count == len(b): print(ans) exit() ans += b[count] count += 1
s192944187
Accepted
17
2,940
200
a = input() b = input() ans = "" count = 0 while True: if count == len(a): print(ans) exit() ans += a[count] if count == len(b): print(ans) exit() ans += b[count] count += 1
s183415964
p03407
u779728630
2,000
262,144
Wrong Answer
17
2,940
79
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
a, b, c = map(int, input().split()) print("Yes") if a + b <= c else print("No")
s864904732
Accepted
17
2,940
80
a, b, c = map(int, input().split()) print("Yes") if a + b >= c else print("No")
s710420700
p03889
u426964396
2,000
262,144
Wrong Answer
17
3,188
373
You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a _mirror string_. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously.
s=input().split() if s[0]=='d' and s[3]=='b': if s[1]=='p' and s[2]=='q': print('Yes') elif s[1]=='q' and s[2]=='p': print('Yes') else: print('No') elif s[0]=='b' and s[3]=='d': if s[1]=='p' and s[2]=='q': print('Yes') elif s[1]=='q' and s[2]=='p': print('Yes') else: print('No') else: print('No')
s489941984
Accepted
32
4,724
146
dict={'b':'d','d':'b','p':'q','q':'p'} s= input() t=''.join(map(lambda x: dict[x],list(s[::-1]))) if s==t: print("Yes") else : print("No")
s947098052
p03457
u933622697
2,000
262,144
Wrong Answer
317
3,060
197
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
n = int(input()) for i in range(n): t, x, y = map(int, input().split()) # input() when you access each trial if x + y < t or (x + y + t) % 2: print("No") exit() print("Yes")
s785750589
Accepted
329
3,060
174
n = int(input()) for i in range(n): t, x, y = map(int, input().split()) if t < x + y or t % 2 != (x + y) % 2: print("No") exit() print("Yes")
s832854624
p02694
u827553608
2,000
1,048,576
Wrong Answer
168
9,192
122
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
try: x=int(input()) o=100 count=0 while int(o)!=x: o=o+(o*(1/100)) print(o) count+=1 print(count) except: pass
s321023539
Accepted
22
9,164
110
try: x=int(input()) o=100 count=0 while o<x: o=int(o+(o*(1/100))) count+=1 print(count) except: pass
s449676898
p03962
u917558625
2,000
262,144
Wrong Answer
24
9,188
158
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
a=list(map(int,input().split())) a.sort() if a[0]==a[1]==a[2]: print(1) else: if a[0]==a[1] or a[1]==a[2] or a[2]==a[0]: print(2) else: print(1)
s286476646
Accepted
28
9,180
158
a=list(map(int,input().split())) a.sort() if a[0]==a[1]==a[2]: print(1) else: if a[0]==a[1] or a[1]==a[2] or a[2]==a[0]: print(2) else: print(3)
s352499178
p02613
u689710606
2,000
1,048,576
Wrong Answer
149
9,192
334
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
n = int(input()) c0 = 0 c1 = 0 c2 = 0 c3 = 0 for i in range(n): s = input() if s == "AC": c0 += 1 elif s == "WA": c1 += 1 elif s == "TLE": c2 += 1 elif s == "RE": c3 += 1 else: exit() print(f"AC × {c0}") print(f"WA × {c1}") print(f"TLE × {c2}") print(f"RE × {c3}")
s065802632
Accepted
144
9,048
330
n = int(input()) c0 = 0 c1 = 0 c2 = 0 c3 = 0 for i in range(n): s = input() if s == "AC": c0 += 1 elif s == "WA": c1 += 1 elif s == "TLE": c2 += 1 elif s == "RE": c3 += 1 else: exit() print(f"AC x {c0}") print(f"WA x {c1}") print(f"TLE x {c2}") print(f"RE x {c3}")
s183415211
p03470
u830462928
2,000
262,144
Wrong Answer
17
3,060
84
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
n = int(input()) l = [] for i in range(0, n): l.append(int(input())) len(set(l))
s865170047
Accepted
17
2,940
91
n = int(input()) l = [] for i in range(0, n): l.append(int(input())) print(len(set(l)))
s827771762
p03544
u518455500
2,000
262,144
Wrong Answer
17
2,940
107
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
n = int(input()) l0 = 2 l1 = 1 li = 0 for i in range(2,n): li = l0 + l1 l0 = l1 l1 = li print(li)
s728350404
Accepted
17
2,940
177
n = int(input()) l0 = 2 l1 = 1 li = 0 if n == 0: print(l0) elif n == 1: print(l1) else: for i in range(2,n+1): li = l0 + l1 l0 = l1 l1 = li print(li)
s536941921
p03163
u437727817
2,000
1,048,576
Wrong Answer
243
15,508
300
There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i. Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W. Find the maximum possible sum of the values of items that Taro takes home.
import numpy as np n,w = map(int,input().split()) WV = [list(map(int,input().split()))for _ in range(n)] dp = np.zeros(w+1,int) for i in range(n): W,V = WV[i] #print(str(dp)+":"+str(dp[W:])+":"+str(dp[:-W])) dp[W:] = np.maximum(dp[W:],dp[:-W]+V) print(str(dp)) print(dp[-1])
s802561193
Accepted
220
15,464
300
import numpy as np n,w = map(int,input().split()) WV = [list(map(int,input().split()))for _ in range(n)] dp = np.zeros(w+1,int) for i in range(n): W,V = WV[i] #print(str(dp)+":"+str(dp[W:])+":"+str(dp[:-W])) dp[W:] = np.maximum(dp[W:],dp[:-W]+V) #print(str(dp)) print(dp[-1])
s133846910
p03854
u797798686
2,000
262,144
Wrong Answer
89
9,300
778
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
from sys import stdin data = stdin.readline().rstrip() def shorten_phrase(x): l = len(x) if x.startswith("eraser"): x = x[6:] elif x.startswith("erase"): x = x[5:] elif x.startswith("dreamera"): x = x[5:] elif x.startswith("dreamer"): x = x[7:] elif x.startswith("dream"): x = x[5:] m = len(x) return l != m while shorten_phrase(data): if data.startswith("eraser"): data = data[6:] elif data.startswith("erase"): data = data[5:] elif data.startswith("dreamera"): data = data[5:] elif data.startswith("dreamer"): data = data[7:] elif data.startswith("dream"): data = data[5:] if len(data) == 0: print("YES") else: print("NO") print(data)
s533610972
Accepted
86
9,056
766
from sys import stdin data = stdin.readline().rstrip() def shorten_phrase(x): l = len(x) if x.startswith("eraser"): x = x[6:] elif x.startswith("erase"): x = x[5:] elif x.startswith("dreamera"): x = x[5:] elif x.startswith("dreamer"): x = x[7:] elif x.startswith("dream"): x = x[5:] m = len(x) return l != m while shorten_phrase(data): if data.startswith("eraser"): data = data[6:] elif data.startswith("erase"): data = data[5:] elif data.startswith("dreamera"): data = data[5:] elif data.startswith("dreamer"): data = data[7:] elif data.startswith("dream"): data = data[5:] if len(data) == 0: print("YES") else: print("NO")
s691094972
p01085
u105296105
8,000
262,144
Wrong Answer
130
5,628
329
The International Competitive Programming College (ICPC) is famous for its research on competitive programming. Applicants to the college are required to take its entrance examination. The successful applicants of the examination are chosen as follows. * The score of any successful applicant is higher than that of any unsuccessful applicant. * The number of successful applicants _n_ must be between _n_ min and _n_ max, inclusive. We choose _n_ within the specified range that maximizes the _gap._ Here, the _gap_ means the difference between the lowest score of successful applicants and the highest score of unsuccessful applicants. * When two or more candidates for _n_ make exactly the same _gap,_ use the greatest _n_ among them. Let's see the first couple of examples given in Sample Input below. In the first example, _n_ min and _n_ max are two and four, respectively, and there are five applicants whose scores are 100, 90, 82, 70, and 65. For _n_ of two, three and four, the gaps will be 8, 12, and 5, respectively. We must choose three as _n_ , because it maximizes the gap. In the second example, _n_ min and _n_ max are two and four, respectively, and there are five applicants whose scores are 100, 90, 80, 75, and 65. For _n_ of two, three and four, the gap will be 10, 5, and 10, respectively. Both two and four maximize the gap, and we must choose the greatest number, four. You are requested to write a program that computes the number of successful applicants that satisfies the conditions.
import sys while True: m, nmin, nmax = [int(i) for i in input().split()] if m == 0: sys.exit() p = [int(input()) for i in range(m)] ansnum = 1000000 ans = 0 for i in range(nmin-1,nmax): if ansnum >= p[i]-p[i+1]: ans = i ansnum = min(ansnum,p[i]-p[i+1]) print(ans)
s954885269
Accepted
120
5,640
409
import sys anslist = [] while True: m, nmin, nmax = [int(i) for i in input().split()] if m == 0: for i in anslist: print(i) sys.exit() p = [int(input()) for i in range(m)] ansnum = 0 ans = 0 for i in range(nmin-1,nmax): if ansnum <= p[i]-p[i+1] and not p[i]-p[i+1]==0: ans = i ansnum = p[i]-p[i+1] anslist.append(ans+1)
s604062312
p04043
u396858476
2,000
262,144
Wrong Answer
17
2,940
327
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
a, b, c = map(int, input().split()) if a == b and a == 5: if c == 7: print("Yes") else: print("No") elif b == c and b == 5: if a == 7: print("Yes") else: print("No") elif a == c and c == 5: if b == 7: print("Yes") else: print("No") else: print("No")
s759324128
Accepted
17
3,060
327
a, b, c = map(int, input().split()) if a == b and a == 5: if c == 7: print("YES") else: print("NO") elif b == c and b == 5: if a == 7: print("YES") else: print("NO") elif a == c and c == 5: if b == 7: print("YES") else: print("NO") else: print("NO")
s705297988
p03130
u782098901
2,000
1,048,576
Wrong Answer
17
3,064
531
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads. Determine if we can visit all the towns by traversing each of the roads exactly once.
ab = [[], [], [], [], []] for i in range(3): a, b = map(int, input().split()) ab[a].append(b) ab[b].append(a) ways = [False] * 4 def f(now, count): if count > 4: return False for n in ab[now]: if ways[n - 1]: continue ways[n - 1] = True if all(ways): print("Yes") exit() f(n, count + 1) ways[n - 1] = False for i in range(1, 5): ways = [False] * 4 ways[i - 1] = True f(i, 1) ways[i - 1] = False print("NO")
s567491016
Accepted
18
2,940
183
c = [0] * 5 for _ in range(3): a, b = map(int, input().split()) c[a] += 1 c[b] += 1 for i in range(1, 5): if c[i] > 2: print("NO") exit() print("YES")
s316782358
p03006
u945418216
2,000
1,048,576
Wrong Answer
175
3,316
379
There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i). We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation: * Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1. Find the minimum total cost required to collect all the balls when we optimally choose p and q.
N = int(input()) XY = sorted([list(map(int,input().split())) for _ in range(N)]) PQ = [] for i in range(N): prev = XY[i] for j in range(N): if i==j: continue next = XY[j] p = next[0] - prev[0] q = next[1] - prev[1] PQ.append([p,q]) ans = 0 for pq in PQ: ans = max(ans, N-PQ.count(pq)-1) print(ans)
s224702804
Accepted
168
3,316
400
N = int(input()) XY = sorted([list(map(int,input().split())) for _ in range(N)]) PQ = [] for i in range(N): prev = XY[i] for j in range(N): if i!=j: next = XY[j] p = next[0] - prev[0] q = next[1] - prev[1] PQ.append((p,q)) ans = 1 for pq in PQ: ans = max(ans, PQ.count(pq)) print(N - ans if N>1 else 1)
s179511175
p03575
u887207211
2,000
262,144
Wrong Answer
18
3,064
391
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M edges.
N, M = map(int,input().split()) v = [i for i in range(1,N+1)] e = [[]]*(N+1) for i in range(M): a, b = map(int,input().split()) e[a] = e[a] + [b] e[b] = e[b] + [a] def dfs(v, e): for num in v: if(len(e[num]) == 1): tmp_num = e[num][0] v.remove(num) e[num] = [] e[tmp_num].remove(num) print(e,v) return dfs(v, e)+1 return 0 print(dfs(v, e))
s506435017
Accepted
17
3,064
362
N, M = map(int,input().split()) v = list(range(1,N+1)) edges = [[] for _ in range(N+1)] for _ in range(M): a, b = map(int,input().split()) edges[a] += [b] edges[b] += [a] def dfs(v, e): for x in v: if(len(e[x]) == 1): t = e[x][0] e[x] = [] e[t].remove(x) v.remove(x) return dfs(v, e)+1 return 0 print(dfs(v, edges))
s855840218
p03401
u422552722
2,000
262,144
Wrong Answer
2,104
14,176
399
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.
n = int(input()) a = list(map(int, input().split(" "))) print(n, a) if n == 2: print(abs(a[0]) + abs(a[0]-a[1]) + abs(a[1])) else: for i in range(len(a)): b = a[:] b.remove(b[i]) #print(b) cost = abs(b[0]) for j in range(len(b)-1): #print(b[j],b[j+1]) cost += abs(b[j] - b[j+1]) cost += abs(b[-1]) print(cost)
s490068071
Accepted
219
14,048
262
n = int(input()) a = list(map(int, input().split(" "))) a.insert(0,0) a.append(0) total = 0 for i in range(len(a)-1): total += abs(a[i] - a[i+1]) for j in range(1, len(a)-1): print(total - abs(a[j-1] - a[j]) - abs(a[j] - a[j+1]) + abs(a[j+1]- a[j-1]))
s894090473
p03607
u513900925
2,000
262,144
Wrong Answer
251
10,488
360
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
N = int(input()) A = list(int(input()) for _ in range(N)) A.sort() print(A) count = 0 test = -1 stack = 0 for i in range(N): if test != A[i]: count += 1 stack = 1 test = A[i] else: if stack == 1: count = count - 1 stack = 0 else: stack = 1 count += 1 print(count)
s074456891
Accepted
243
7,400
351
N = int(input()) A = list(int(input()) for _ in range(N)) A.sort() count = 0 test = -1 stack = 0 for i in range(N): if test != A[i]: count += 1 stack = 1 test = A[i] else: if stack == 1: count = count - 1 stack = 0 else: stack = 1 count += 1 print(count)
s878437593
p03854
u502721867
2,000
262,144
Wrong Answer
19
3,188
161
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
s = input() s = s.replace("erase","").replace("eraser","").replace("dream","").replace("dreamer","") print(s) if s !="": print("No") else: print("Yes")
s218118702
Accepted
26
6,516
164
import re s = input() p = re.compile(r'^(dream|dreamer|erase|eraser)*(dream|dreamer|erase|eraser)$') x = p.search(s) if x : print("YES") else: print("NO")
s087926605
p03855
u677523557
2,000
262,144
Wrong Answer
1,291
79,780
2,785
There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities. We will say city A and B are _connected by roads_ if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads. We will also define _connectivity by railways_ similarly. For each city, find the number of the cities connected to that city by both roads and railways.
from operator import itemgetter import sys input = sys.stdin.readline N, K, L = map(int, input().split()) PQ = [list(map(int, input().split())) for _ in range(K)] RS = [list(map(int, input().split())) for _ in range(L)] class UnionFind(): def __init__(self, n): self.n = n self.root = [-1]*(n+1) self.rnk = [0]*(n+1) def Find_Root(self, x): if(self.root[x] < 0): return x else: self.root[x] = self.Find_Root(self.root[x]) return self.root[x] def Unite(self, x, y): x = self.Find_Root(x) y = self.Find_Root(y) if(x == y): return elif(self.rnk[x] > self.rnk[y]): self.root[x] += self.root[y] self.root[y] = x else: self.root[y] += self.root[x] self.root[x] = y if(self.rnk[x] == self.rnk[y]): self.rnk[y] += 1 def isSameGroup(self, x, y): return self.Find_Root(x) == self.Find_Root(y) def Count(self, x): return -self.root[self.Find_Root(x)] A = UnionFind(N) for p, q in PQ: A.Unite(p, q) B = UnionFind(N) for r,s in RS: B.Unite(r, s) C = [] for i in range(1, N+1): a = A.root[i] if A.root[i] > 0 else i b = B.root[i] if B.root[i] > 0 else i C.append([i, a, b]) C.sort(key=itemgetter(2)) C.sort(key=itemgetter(1)) D = [1 for _ in range(N)] pa, pb = 0, 0 c = 0 P = [] for p, a, b in C: P.append(p) if pa == a and pb == b: c += 1 D[p-1] += c else: c = 0 pa, pb = a, b #print(D) #print(P) Q = P[::-1] #print(Q) for i, p in enumerate(Q): a = D[p-1] #print(i, p, a, pa) if i == 0: l = a pa = a continue if pa != 1 or a != 1: l = max(l, a) D[p-1] = l else: l = 1 pa = a for a in D: print(a, end=' ') print()
s733956797
Accepted
1,201
44,572
1,609
class UnionFind(): def __init__(self, n): self.n = n self.root = [-1]*(n+1) self.rnk = [0]*(n+1) def Find_Root(self, x): if(self.root[x] < 0): return x else: self.root[x] = self.Find_Root(self.root[x]) return self.root[x] def Unite(self, x, y): x = self.Find_Root(x) y = self.Find_Root(y) if(x == y): return elif(self.rnk[x] > self.rnk[y]): self.root[x] += self.root[y] self.root[y] = x else: self.root[y] += self.root[x] self.root[x] = y if(self.rnk[x] == self.rnk[y]): self.rnk[y] += 1 def isSameGroup(self, x, y): return self.Find_Root(x) == self.Find_Root(y) def Count(self, x): return -self.root[self.Find_Root(x)] N, K, L = map(int, input().split()) U1 = UnionFind(N) U2 = UnionFind(N) for _ in range(K): a, b = map(int, input().split()) U1.Unite(a, b) for _ in range(L): a, b = map(int, input().split()) U2.Unite(a, b) Roots = [0] dic = {} for n in range(1, N+1): r1 = U1.Find_Root(n) r2 = U2.Find_Root(n) r = r1*2*N + r2 Roots.append(r) if not r in dic.keys(): dic[r] = 1 else: dic[r] += 1 ans = [] for n in range(1, N+1): ans.append(dic[Roots[n]]) print(" ".join([str(a) for a in ans]))
s066686017
p03110
u211160392
2,000
1,048,576
Wrong Answer
17
3,060
236
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
N = int(input()) x = [] u = [] Y = 0 for i in range(N): s = [i for i in input().split()] print(s) x.append(float(s[0])) u.append(s[1]) if u[i] == 'BTC': Y += x[i]*380000 else: Y += x[i] print(Y)
s008883363
Accepted
19
3,060
223
N = int(input()) x = [] u = [] Y = 0 for i in range(N): s = [i for i in input().split()] x.append(float(s[0])) u.append(s[1]) if u[i] == 'BTC': Y += x[i]*380000 else: Y += x[i] print(Y)
s405617852
p03563
u045408189
2,000
262,144
Wrong Answer
17
2,940
46
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
r=float(input()) g=float(input()) print(2*g-r)
s835519223
Accepted
19
2,940
52
r=float(input()) g=float(input()) print(int(2*g-r))
s080051567
p03854
u060736237
2,000
262,144
Wrong Answer
36
5,108
887
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
def main(): s = input() dream = 0 erase = 1 work = [] temp1 = 0 temp2 = 0 kind = -1 append = work.append for c in s: if c == 'd': if kind != -1: append([kind, temp2-temp1]) kind = dream temp1 = temp2 elif c == 's': if kind != -1: append([kind, temp2-temp1-3]) kind = erase temp1 = temp2-3 temp2 += 1 append([kind, len(s)-temp1]) result = [] append = result.append for i, j in work: if i == dream: if j <= 5: append("dream") else: append("dreamer") else: if j <= 5: append("erase") else: append("eraser") result = "Yes" if "".join(result)==s else "No" print(result) main()
s010213438
Accepted
38
5,108
887
def main(): s = input() dream = 0 erase = 1 work = [] temp1 = 0 temp2 = 0 kind = -1 append = work.append for c in s: if c == 'd': if kind != -1: append([kind, temp2-temp1]) kind = dream temp1 = temp2 elif c == 's': if kind != -1: append([kind, temp2-temp1-3]) kind = erase temp1 = temp2-3 temp2 += 1 append([kind, len(s)-temp1]) result = [] append = result.append for i, j in work: if i == dream: if j <= 5: append("dream") else: append("dreamer") else: if j <= 5: append("erase") else: append("eraser") result = "YES" if "".join(result)==s else "NO" print(result) main()
s044386462
p03693
u757324869
2,000
262,144
Wrong Answer
17
2,940
104
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
p = input().split() s = int(p[0] + p[1] + p[2]) print(s) if s % 4 == 0: print("YES") else: print("NO")
s721491366
Accepted
17
2,940
113
p = input().split() s = int(p[0])*100 + int(p[1])*10 + int(p[2]) if s % 4 == 0: print("YES") else: print("NO")
s863919733
p02613
u437351386
2,000
1,048,576
Wrong Answer
146
16,312
213
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
n=int(input()) s=[] for i in range(n): s.append(input()) print("AC"+" × "+str(s.count("AC"))) print("WA"+" × "+str(s.count("WA"))) print("TLE"+" × "+str(s.count("TLE"))) print("RE"+" × "+str(s.count("RE")))
s929212396
Accepted
147
16,280
208
n=int(input()) s=[] for i in range(n): s.append(input()) print("AC"+" x "+str(s.count("AC"))) print("WA"+" x "+str(s.count("WA"))) print("TLE"+" x "+str(s.count("TLE"))) print("RE"+" x "+str(s.count("RE")))
s615493984
p03228
u167908302
2,000
1,048,576
Wrong Answer
17
2,940
184
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
#coding:utf-8 a, b, k = map(int, input().split()) for i in range(0, k): if i % 2 == 0: b += a // 2 a /= 2 else: a += b // 2 b /= 2 print(a, b)
s039091479
Accepted
18
2,940
192
#coding:utf-8 a, b, k = map(int, input().split()) for i in range(0, k): if i % 2 == 0: b += a // 2 a = a // 2 else: a += b // 2 b = b // 2 print(a, b)
s759317519
p03385
u513081876
2,000
262,144
Wrong Answer
17
2,940
98
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
S = list(map(str, input())) if S.sort() == ['a', 'b', 'c']: print('Yes') else: print('No')
s726925201
Accepted
17
2,940
82
S = list(input()) if len(S) == len(set(S)): print('Yes') else: print('No')
s458621942
p03448
u787059958
2,000
262,144
Wrong Answer
56
3,316
368
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
A = int(input()) B = int(input()) C = int(input()) x = int(input()) la=[] for a in range(A+1): la.append(a) lb=[] for b in range(B+1): lb.append(b) lc=[] for c in range(C+1): lc.append(c) count=0 for i in range(A): for j in range(B): for p in range(C): if(500*la[i]+100*lb[j]+50*lc[p]==x): count+=1 print(count)
s064538804
Accepted
54
3,060
217
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 p in range(C+1): if(10*i+2*j+p==x/50): count+=1 print(count)
s309836470
p03401
u583010173
2,000
262,144
Wrong Answer
275
14,048
427
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.
# -*- coding: utf-8 -*- n = int(input()) spot = [int(x) for x in input().split()] spot = [0] + spot + [0] print(spot) cost = 0 for i in range(len(spot)-1): cost += abs(spot[i] - spot[i+1]) #print(cost) change = 0 for k in range(len(spot)-2): if (spot[k+1]-spot[k])*(spot[k+2]-spot[k+1]) >= 0: change = 0 else: change = 2*min([abs(spot[k+1]-spot[k]),abs(spot[k+2]-spot[k+1])]) print(cost-change)
s172857646
Accepted
260
14,172
402
# -*- coding: utf-8 -*- n = int(input()) spot = [int(x) for x in input().split()] spot = [0] + spot + [0] cost = 0 for i in range(len(spot)-1): cost += abs(spot[i] - spot[i+1]) change = 0 for k in range(len(spot)-2): if (spot[k+1]-spot[k])*(spot[k+2]-spot[k+1]) >= 0: change = 0 else: change = 2*min([abs(spot[k+1]-spot[k]),abs(spot[k+2]-spot[k+1])]) print(cost-change)
s029716988
p03645
u193264896
2,000
262,144
Wrong Answer
367
50,096
499
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
import sys readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): N, M = map(int, readline().split()) path = [[] for _ in range(N+1)] for _ in range(M): a,b = map(int, readline().split()) path[a].append(b) path[b].append(a) print(path[1]) print(path[N]) if set(path[1])&set(path[N]): print('POSSIBLE') else: print('IMPOSSIBLE') if __name__ == '__main__': main()
s330013978
Accepted
406
48,648
461
import sys readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): N, M = map(int, readline().split()) path = [[] for _ in range(N+1)] for _ in range(M): a,b = map(int, readline().split()) path[a].append(b) path[b].append(a) if set(path[1])&set(path[N]): print('POSSIBLE') else: print('IMPOSSIBLE') if __name__ == '__main__': main()
s402091359
p02261
u963402991
1,000
131,072
Wrong Answer
30
7,736
758
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
# -*- coding:utf-8 -*- def Selection_Sort(A,n): for i in range(n): mini = i for j in range(i,n): if int(A[j][1]) < int(A[mini][1]): mini = j if A[i] != A[mini]: A[i], A[mini] = A[mini], A[i] return A def Bubble_Sort(A, n): for i in range(n): for j in range(n-1,i,-1): if int(A[j][1]) < int(A[j-1][1]): A[j], A[j-1] = A[j-1], A[j] return A n = int(input()) A = input().strip().split() print (A[1][1]) B = A[:] A = Bubble_Sort(A,n) print (' '.join(A)) print ("Stable") B =Selection_Sort(B,n) print (' '.join(B)) if A == B: print ("Stable") else: print ("Not stable")
s318521388
Accepted
20
7,808
741
# -*- coding:utf-8 -*- def Selection_Sort(A,n): for i in range(n): mini = i for j in range(i,n): if int(A[j][1]) < int(A[mini][1]): mini = j if A[i] != A[mini]: A[i], A[mini] = A[mini], A[i] return A def Bubble_Sort(A, n): for i in range(n): for j in range(n-1,i,-1): if int(A[j][1]) < int(A[j-1][1]): A[j], A[j-1] = A[j-1], A[j] return A n = int(input()) A = input().strip().split() B = A[:] A = Bubble_Sort(A,n) print (' '.join(A)) print ("Stable") B =Selection_Sort(B,n) print (' '.join(B)) if A == B: print ("Stable") else: print ("Not stable")
s873497185
p03671
u703890795
2,000
262,144
Wrong Answer
17
2,940
61
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
a, b, c = map(int, input().split()) print(max(a+b, b+c, c+a))
s004110066
Accepted
17
2,940
61
a, b, c = map(int, input().split()) print(min(a+b, b+c, c+a))
s733230351
p03730
u103099441
2,000
262,144
Wrong Answer
21
3,188
304
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
a, b, c = map(int, input().split()) z = float('inf') n = int(a / b) + 1 flag = False while True: x, y = divmod(n * b + c, a) if not x: flag = True break elif y >= z: break else: n += 1 z = min(z, y) if flag: print('YES') else: print('NO')
s673465606
Accepted
17
3,060
231
a, b, c = map(int, input().split()) n = max(int(b / a), 1) p = 'NO' s = set() r = n * a % b while r not in s: if r == c: p = 'YES' break else: s.add(r) n += 1 r = n * a % b print(p)
s003968299
p03695
u405779580
2,000
262,144
Wrong Answer
17
3,064
255
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users.
N =int(input()) scores = [int(i)//400 for i in input().split()] d = [0]*10 for s in scores: if s > 7: s = 8 d[s] = d[s] + 1 print(d) if any(d[:8]): m = [bool(i) for i in d[:8]].count(True) else: m = 1 M = min(8, m+d[8]) print(m, M)
s965418984
Accepted
21
3,316
185
from collections import Counter input() c = Counter([min(int(i)//400,8) for i in input().split()]) lt3200 = [bool(c[i]) for i in range(8)].count(True) print(max(1, lt3200), lt3200+c[8])
s273065193
p03547
u614734359
2,000
262,144
Wrong Answer
17
2,940
53
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger?
x,y = input().split() if x>y: print(x) else: print(y)
s264970798
Accepted
17
2,940
78
x,y = input().split() if x>y: print('>') elif x<y: print('<') else: print('=')
s016981737
p03795
u454866339
2,000
262,144
Wrong Answer
29
8,984
52
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
N = 60 x = 800 * N y = 200 * (N // 15) print(x - y)
s953093466
Accepted
27
9,096
77
N = int(input()) x = int(800 * N) y = int(200 * (N // 15)) print(int(x - y))
s069613034
p04045
u632369368
2,000
262,144
Wrong Answer
24
3,700
290
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
import itertools N, K = [int(s) for s in input().split()] D = [int(s) for s in input().split()] U = [str(n) for n in range(10) if n not in D] ret = N * 10 for v in [int(''.join(T)) for T in itertools.product(U, repeat=4)]: print(v) if N <= v: ret = min(ret, v) print(ret)
s628513182
Accepted
180
3,572
230
from functools import reduce N, _ = [int(s) for s in input().split()] D = [s for s in input().split()] R = N while True: if reduce(lambda x, y: x and y, [s not in D for s in list(str(R))]): break R += 1 print(R)
s356534286
p03712
u403551852
2,000
262,144
Wrong Answer
17
3,060
190
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
h,w = map(int,input().split()) aa = [input() for _ in range(h)] print(aa) for i in range(h+2): if i == 0 or i == h+1: print('#'*(w+2)) else: print('#'+aa[i-1]+'#')
s702678584
Accepted
17
3,060
180
h,w = map(int,input().split()) aa = [input() for _ in range(h)] for i in range(h+2): if i == 0 or i == h+1: print('#'*(w+2)) else: print('#'+aa[i-1]+'#')
s663757566
p02413
u216425054
1,000
131,072
Wrong Answer
20
7,624
238
Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
r,c=[int(x) for x in input().split()] s_row=[0 for x in range(c+1)] for i in range(r): row=[int(x) for x in input().split()] row.append(sum(row)) print(" ".join([str(x) for x in row])) s_row=[x+y for x,y in zip(s_row,row)]
s297476583
Accepted
30
7,736
279
r,c=[int(x) for x in input().split()] s_row=[0 for x in range(c+1)] for i in range(r): row=[int(x) for x in input().split()] row.append(sum(row)) print(" ".join([str(x) for x in row])) s_row=[x+y for x,y in zip(s_row,row)] print(" ".join([str(x) for x in s_row]))
s491044473
p03377
u816376170
2,000
262,144
Wrong Answer
17
2,940
113
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
a = input().split() if int(a[0])<int(a[2]) and int(a[0])+int(a[1])>int(a[2]): print("yes") else: print("no")
s056235433
Accepted
17
2,940
115
a = input().split() if int(a[0])<=int(a[2]) and int(a[0])+int(a[1])>=int(a[2]): print("YES") else: print("NO")
s015910872
p02261
u209358977
1,000
131,072
Wrong Answer
20
7,564
1,425
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
# -*- coding: utf-8 -*- def conv_input(arr): ret = [] for e in arr: ret.append((e[0], int(e[1]))) return ret def conv_output(conv_arr): ret = [] for e in conv_arr: ret.append(e[0] + str(e[1])) return ret def is_stable(arr1, arr2): ret = 'Stable' for a1, a2 in zip(arr1, arr2): if a1 == a2: continue else: ret = 'Not Stable' break return ret def bubble_sort(n, arr): flag = True while flag: flag = False for i in reversed(range(n)): if i is 0: break if arr[i][1] < arr[i - 1][1]: tmp = arr[i] arr[i] = arr[i - 1] arr[i - 1] = tmp flag = True return arr def selection_sort(n, arr): for i in range(n): minj = i for j in range(i, n): if arr[j][1] < arr[minj][1]: minj = j if i != minj: tmp = arr[minj] arr[minj] = arr[i] arr[i] = tmp return arr if __name__ == '__main__': n = int(input()) arr1 = arr2 = [str(s) for s in input().split()] arr1 = conv_output(bubble_sort(n, conv_input(arr1))) print(' '.join(map(str, arr1))) print('Stable') arr2 = conv_output(selection_sort(n, conv_input(arr2))) print(' '.join(map(str, arr2))) print(is_stable(arr1, arr2))
s315645120
Accepted
30
7,768
1,425
# -*- coding: utf-8 -*- def conv_input(arr): ret = [] for e in arr: ret.append((e[0], int(e[1]))) return ret def conv_output(conv_arr): ret = [] for e in conv_arr: ret.append(e[0] + str(e[1])) return ret def is_stable(arr1, arr2): ret = 'Stable' for a1, a2 in zip(arr1, arr2): if a1 == a2: continue else: ret = 'Not stable' break return ret def bubble_sort(n, arr): flag = True while flag: flag = False for i in reversed(range(n)): if i is 0: break if arr[i][1] < arr[i - 1][1]: tmp = arr[i] arr[i] = arr[i - 1] arr[i - 1] = tmp flag = True return arr def selection_sort(n, arr): for i in range(n): minj = i for j in range(i, n): if arr[j][1] < arr[minj][1]: minj = j if i != minj: tmp = arr[minj] arr[minj] = arr[i] arr[i] = tmp return arr if __name__ == '__main__': n = int(input()) arr1 = arr2 = [str(s) for s in input().split()] arr1 = conv_output(bubble_sort(n, conv_input(arr1))) print(' '.join(map(str, arr1))) print('Stable') arr2 = conv_output(selection_sort(n, conv_input(arr2))) print(' '.join(map(str, arr2))) print(is_stable(arr1, arr2))
s777274673
p03478
u825440127
2,000
262,144
Wrong Answer
34
2,940
144
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
n, a, b= map(int, input().split()) ans = 0 for i in range(1, n+1): if a <= sum([int(c) for c in str(i)]) <= b: ans += 1 print(ans)
s800420435
Accepted
32
2,940
144
n, a, b= map(int, input().split()) ans = 0 for i in range(1, n+1): if a <= sum([int(c) for c in str(i)]) <= b: ans += i print(ans)
s955401192
p03680
u626337957
2,000
262,144
Wrong Answer
237
7,080
262
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
N = int(input()) nums = [0] for _ in range(N): nums.append(int(input())) check_cnt = 1 _next = nums[1] while True: if check_cnt >= N: break else: if next == 2: print(check_cnt) exit() _next = nums[_next] check_cnt += 1 print(-1)
s443432025
Accepted
204
7,080
264
N = int(input()) nums = [0] for _ in range(N): nums.append(int(input())) check_cnt = 1 _next = nums[1] while True: if check_cnt >= N: break else: if _next == 2: print(check_cnt) exit() _next = nums[_next] check_cnt += 1 print(-1)
s234504789
p03694
u672898046
2,000
262,144
Wrong Answer
17
2,940
56
It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along _TopCoDeer street_. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses. Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.
s = list(map(int, input().split())) print(max(s)-min(s))
s623879675
Accepted
18
2,940
73
n = int(input()) s = list(map(int, input().split())) print(max(s)-min(s))
s124491327
p03131
u349444371
2,000
1,048,576
Wrong Answer
17
3,060
220
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
k,a,b=map(int,input().split()) if b<a+2: print(1+k) else: if k<=a: print(1+k) else: if (k-a-1)%2!=0: print(b+(b-a)*(k-a-1)//2+1) else: print(b+(b-a)*(k-a-1)//2)
s728322944
Accepted
17
3,060
224
k,a,b=map(int,input().split()) if b<a+2: print(1+k) else: if k<=a: print(1+k) else: if (k-a-1)%2==0: print(b+(b-a)*((k-a-1)//2)) else: print(b+(b-a)*((k-a-1)//2)+1)
s976783226
p02613
u166057331
2,000
1,048,576
Wrong Answer
162
9,152
283
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
N = int(input()) C0 = 0 C1 = 0 C2 = 0 C3 = 0 for i in range(0,N): S = str(input()) if S == 'AC': C0 += 1 elif S == 'WA': C1 += 1 elif S == 'TLE': C2 += 1 elif S == 'RE': C3 += 1 print('AC ×',C0) print('WA ×',C1) print('TLE ×',C2) print('RE ×',C3)
s973211983
Accepted
160
9,136
284
N = int(input()) C0 = 0 C1 = 0 C2 = 0 C3 = 0 for i in range(0,N): S = str(input()) if S == 'AC': C0 += 1 elif S == 'WA': C1 += 1 elif S == 'TLE': C2 += 1 elif S == 'RE': C3 += 1 print('AC x',C0) print('WA x',C1) print('TLE x',C2) print('RE x',C3)
s701764160
p04043
u433559751
2,000
262,144
Wrong Answer
18
2,940
114
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
N = list(map(int, input().split(" "))) if N.count(5) == 2 and N.count(7) == 1: print('Yes') else: print('No')
s097102202
Accepted
17
2,940
114
N = list(map(int, input().split(" "))) if N.count(5) == 2 and N.count(7) == 1: print('YES') else: print('NO')
s224728240
p00007
u298999032
1,000
131,072
Wrong Answer
20
5,608
105
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks.
x=100000 n=int(input()) for i in range(n): x*=1.05 if x%1000!=0: x+=1000-x%1000 print(x)
s970391000
Accepted
20
5,604
106
x=100000 for i in range(int(input())): x*=1.05 if x%1000!=0: x+=1000-x%1000 print(int(x))
s003157769
p03643
u268792407
2,000
262,144
Wrong Answer
152
12,476
70
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
n=int(input()) from numpy import log print(pow(2,int(log(n)/log(2))))
s719359982
Accepted
17
2,940
20
print("ABC"+input())
s187722405
p03544
u698567423
2,000
262,144
Wrong Answer
20
2,940
92
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
n = int(input()) lf = 2 ls = 1 for _ in range(n-1): lf, ls = ls, lf + ls print(ls)
s212829865
Accepted
17
2,940
89
n = int(input()) lf = 2 ls = 1 for _ in range(n-1): lf, ls = ls, lf + ls print(ls)
s825003527
p03643
u886655280
2,000
262,144
Wrong Answer
19
3,064
499
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
input = int(input()) input_list = list(range(1, input + 1)) count_list = [] for e in input_list: count = 0 e_tmp = e while True: if e_tmp % 2 == 0: e_tmp = e_tmp/2 count += 1 else: break count_list.append([e, count]) max_value = 0 max_key = 0 for i in range(input): curr_value = int(count_list[i][1]) if curr_value > max_value: max_value = curr_value max_key = count_list[i][0] print(max_key)
s032271490
Accepted
18
2,940
92
N = input() ans = 'ABC' + N print(ans)
s229669238
p02613
u048013400
2,000
1,048,576
Wrong Answer
150
16,488
215
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
from collections import Counter N = int(input()) S = [input() for i in range(N)] s = Counter(S) print('AC×'+ str(s['AC'])) print('WA×' + str(s['WA'])) print('TLE×' + str(s['TLE'])) print('RE×' + str(s['RE']))
s153503446
Accepted
143
16,520
250
from collections import Counter N = int(input()) S = [input() for i in range(N)] s = Counter(S) print('AC x ',end='') print(s['AC']) print('WA x ', end='') print(s['WA']) print('TLE x ',end='') print(s['TLE']) print('RE x ', end='') print(s['RE'])
s480401316
p03472
u356608129
2,000
262,144
Wrong Answer
391
12,244
506
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
import sys (N, H) = tuple(map(int, input().split(" "))) a = [] b = [] result = -1 for i in range(N): (ai,bi) = tuple(map(int, input().split(" "))) a.append(ai) b.append(bi) a_max = max(a) sorted(b).reverse() b_length = len(b) for i, bi in enumerate(b): if bi < a_max: b_length = i S = 0 for l in range(b_length): S += b[l] if S >= H: result = l + 1 print(result) sys.exit() j = b_length result = b_length + int((H - S)/a_max) print(result)
s153656361
Accepted
393
11,512
531
import sys import math (N, H) = tuple(map(int, input().split(" "))) a = [] b = [] result = 0 for i in range(N): (ai,bi) = tuple(map(int, input().split(" "))) a.append(ai) b.append(bi) a_max = max(a) b.sort() b.reverse() b_length = len(b) for i, bi in enumerate(b): if bi < a_max: b_length = i break S = 0 for l in range(b_length): S += b[l] if S >= H: result = l + 1 print(result) sys.exit() result = b_length + int(math.ceil((H - S)/a_max)) print(result)
s283160489
p03379
u764956288
2,000
262,144
Wrong Answer
314
25,620
173
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
n = int(input()) As = list(map(int, input().split())) As.sort() left = As[n//2 - 1] right = As[n//2] for x in As: if x <= left: print(right) else: print(left)
s040512014
Accepted
307
25,556
179
n = int(input()) As = list(map(int, input().split())) Xs = sorted(As) left = Xs[n//2 - 1] right = Xs[n//2] for x in As: if x <= left: print(right) else: print(left)
s181072385
p03798
u432042540
2,000
262,144
Wrong Answer
161
4,212
702
Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.
n = int(input()) s = input() a = False b = False sw = [None] * n sw[0] = False sw[1] = False def next(s,sw,i,j): if s[i] == 'o': return not (sw[j] ^ sw[i]) else: return sw[j] ^ sw[i] def printsw(sw,n): s = '' for i in range(n): if sw[i]: s += 'S' else: s += 'W' print(s) flag = True for j in range(4): for i in range(2,n): sw[i] = next(s,sw,i-2,i-1) zero = next(s,sw,n-2,n-1) one = next(s,sw,n-1,0) if zero == sw[0]: if one == sw[1]: printsw(sw,n) flag = False break sw[0] = not sw[0] if j == 1: sw[1] = True if flag: print(-1)
s710981000
Accepted
186
4,212
701
n = int(input()) s = input() a = False b = False sw = [None] * n sw[0] = True sw[1] = True def next(s,sw,j,i): if s[i] == 'o': return not (sw[j] ^ sw[i]) else: return sw[j] ^ sw[i] def printsw(sw,n): s = '' for i in range(n): if sw[i]: s += 'S' else: s += 'W' print(s) flag = True for j in range(4): for i in range(2,n): sw[i] = next(s,sw,i-2,i-1) zero = next(s,sw,n-2,n-1) one = next(s,sw,n-1,0) if zero == sw[0]: if one == sw[1]: printsw(sw,n) flag = False break sw[0] = not sw[0] if j == 1: sw[1] = False if flag: print(-1)
s522700119
p03493
u425177436
2,000
262,144
Wrong Answer
16
2,940
47
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
print(list(map(int, input().split())).count(1))
s290064136
Accepted
17
2,940
45
print(list(map(int, list(input()))).count(1))
s062041733
p03679
u063052907
2,000
262,144
Wrong Answer
17
2,940
117
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
#coding: utf-8 X, A, B = map(int, input().split()) print(["delicious", "safe", "dangerous"][(A > B) + (A + X < B) ])
s965355673
Accepted
17
2,940
115
#coding: utf-8 X, A, B = map(int, input().split()) print(["delicious", "safe", "dangerous"][(A < B) + (A + X < B)])
s460403208
p03486
u623687794
2,000
262,144
Wrong Answer
17
3,064
357
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
s=input() t=input() schar=[] tchar=[] for i in range(len(s)): schar.append(ord(s[i])) for i in range(len(t)): tchar.append(ord(t[i])) schar.sort() tchar.sort(reverse=True) flag=0 for i in range(min(len(s),len(t))): if schar[i]>tchar[i]: flag=1 break if flag==1: print("No") else: if len(s)>=len(t): print("No") else: print("Yes")
s574517849
Accepted
18
3,064
458
s=input() t=input() schar=[] tchar=[] for i in range(len(s)): schar.append(ord(s[i])) for i in range(len(t)): tchar.append(ord(t[i])) schar.sort() tchar.sort(reverse=True) flag=0 for i in range(min(len(s),len(t))): if schar[i]==tchar[i]: continue elif schar[i]>tchar[i]: flag=1 break else: flag=-1 break if flag==1: print("No") elif flag==-1: print("Yes") else: if len(s)<len(t): print("Yes") else: print("No")
s700154241
p02608
u119015607
2,000
1,048,576
Wrong Answer
992
9,252
293
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
n = int(input()) ans = [0 for i in range(10001)] for i in range(105): for j in range(105): for m in range(105): v = i**2+j**2+m**2+i*j+j*m+m*i #print(v) if v<10001: ans[v]+=1 #print(count) for i in range(n): print(ans[i+1])
s224486696
Accepted
1,004
9,312
300
n = int(input()) ans = [0 for i in range(10001)] for i in range(1,105): for j in range(1,105): for m in range(1,105): v = i**2+j**2+m**2+i*j+j*m+m*i #print(v) if v<10001: ans[v]+=1 #print(count) for i in range(n): print(ans[i+1])
s395699444
p03605
u806403461
2,000
262,144
Wrong Answer
17
2,940
98
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
N = str(input()) for a in N: if a == '9': print('Yes') else: print('No')
s004175409
Accepted
18
2,940
134
N = str(input()) ans = 'No' for a in N: if a == '9': ans = 'Yes' break else: ans = 'No' print(ans)
s182757548
p03854
u998082063
2,000
262,144
Wrong Answer
19
3,188
143
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
s = input().replace("eracer", "").replace("erace", "").replace("dreamer", "").replace("dream", "") if s: print("NO") else: print("YES")
s444812039
Accepted
18
3,188
143
s = input().replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "") if s: print("NO") else: print("YES")