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
s331353476
p02603
u253527353
2,000
1,048,576
Wrong Answer
133
27,228
1,366
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
import numpy as np import itertools #from scipy import signal n = int(input()) ajs = input().split() ajs = [int(aj) for aj in ajs] ajs = np.array(ajs) #actions = itertools.product([-1, 0, 1], repeat=n) #for action in actions: ajs_delta = ajs[1:] - ajs[:-1] print(ajs_delta) for i in range(1, ajs_delta.shape[0]): if ajs_delta[i] == 0: ajs_delta[i] = ajs_delta[i-1] print(ajs_delta) kyokuchi = {'lower':[], 'upper':[]} first_value = 0 for aj_delta in ajs_delta: if aj_delta != 0: first_value = aj_delta break if ajs_delta[0] > 0: kyokuchi['lower'].append(0) elif ajs_delta[0] < 0: kyokuchi['upper'].append(0) elif ajs_delta[0] == 0 and first_value > 0: kyokuchi['lower'].append(0) for i in range(0, ajs_delta.shape[0]-1): if ajs_delta[i] * ajs_delta[i+1] < 0: if ajs_delta[i] > 0: kyokuchi['upper'].append(i+1) else: kyokuchi['lower'].append(i+1) if ajs_delta[-1] > 0: kyokuchi['upper'].append(n-1) else: kyokuchi['lower'].append(n-1) kyokuchi_s = sorted(kyokuchi['upper'] + kyokuchi['lower']) current_money = 1000 pos = 0 for idx in kyokuchi_s: if pos >= 0: stock = int(current_money / ajs[idx]) current_money = current_money % ajs[idx] pos = -1 else: current_money += stock * ajs[idx] stock = 0 pos = 1 print(current_money)
s002998081
Accepted
119
26,988
1,348
import numpy as np import itertools #from scipy import signal n = int(input()) ajs = input().split() ajs = [int(aj) for aj in ajs] ajs = np.array(ajs) #actions = itertools.product([-1, 0, 1], repeat=n) #for action in actions: ajs_delta = ajs[1:] - ajs[:-1] for i in range(1, ajs_delta.shape[0]): if ajs_delta[i] == 0: ajs_delta[i] = ajs_delta[i-1] kyokuchi = {'lower':[], 'upper':[]} first_value = 0 for aj_delta in ajs_delta: if aj_delta != 0: first_value = aj_delta break if ajs_delta[0] > 0: kyokuchi['lower'].append(0) elif ajs_delta[0] < 0: #kyokuchi['upper'].append(0) pass elif ajs_delta[0] == 0 and first_value > 0: kyokuchi['lower'].append(0) for i in range(0, ajs_delta.shape[0]-1): if ajs_delta[i] * ajs_delta[i+1] < 0: if ajs_delta[i] > 0: kyokuchi['upper'].append(i+1) else: kyokuchi['lower'].append(i+1) if ajs_delta[-1] > 0: kyokuchi['upper'].append(n-1) else: #kyokuchi['lower'].append(n-1) pass kyokuchi_s = sorted(kyokuchi['upper'] + kyokuchi['lower']) current_money = 1000 pos = 0 for idx in kyokuchi_s: if pos >= 0: stock = int(current_money / ajs[idx]) current_money = current_money % ajs[idx] pos = -1 else: current_money += stock * ajs[idx] stock = 0 pos = 1 print(current_money)
s586726982
p03386
u282228874
2,000
262,144
Wrong Answer
17
3,060
207
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
a,b,k=map(int,input().split()) if a+k >= b: ans = [i for i in range(a,b+1)] else: ans = [] for i in range(k): ans.append(a+i) ans.append(b-i) ans = sorted(set(ans)) print(ans)
s217277186
Accepted
17
3,060
223
a,b,k=map(int,input().split()) if a+k >= b: ans = [i for i in range(a,b+1)] else: ans = [] for i in range(k): ans.append(a+i) ans.append(b-i) ans = sorted(set(ans)) for x in ans: print(x)
s572193771
p03543
u173329233
2,000
262,144
Wrong Answer
18
3,064
545
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
N = input() num_list = [] num_list.append(N[:1]) num_list.append(N[1:2]) num_list.append(N[2:3]) num_list.append(N[3:4]) n_1 = num_list[1:4] n_2 = num_list[2:4] same_list_1 = [0] for m in n_1: if num_list[0] == m: same_list_1.append(m) same_list_2 = [0] for n in n_2: if num_list[1] == n: same_list_2.append(n) len_1 = len(same_list_1) len_2 = len(same_list_2) if len_1 == 3: print('yes') elif len_2 == 3: print('yes') elif len_1 == 4: print('yes') elif len_2 == 4: print('yes') else: print('no')
s828996819
Accepted
18
2,940
100
n = input() if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]: print('Yes') else: print('No')
s717928540
p03643
u304058693
2,000
262,144
Wrong Answer
29
9,112
287
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()) ans = [] for i in range(1, n + 1): x = i for j in range(100): if x % 2 == 0: x = int(x // 2) #ans.append(j) else: #ans.append(j) break ans.append(j) #print(ans) print(ans.index(max(ans)) + 1)
s823035961
Accepted
27
8,972
39
n = int(input()) print("ABC" + str(n))
s543058822
p02389
u892219101
1,000
131,072
Wrong Answer
20
7,604
56
Write a program which calculates the area and perimeter of a given rectangle.
a,b=map(int,input("input:").split()) print(a*b,a+a+b+b)
s079089513
Accepted
40
7,520
47
a,b=map(int,input().split()) print(a*b,a+a+b+b)
s671831714
p03693
u094191970
2,000
262,144
Wrong Answer
17
2,940
63
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=input().split() print('Yes' if int(r+g+b)%4==0 else 'No')
s395874789
Accepted
27
9,016
71
r,g,b=input().split() num=int(r+g+b) print('YES' if num%4==0 else 'NO')
s337833855
p03545
u535171899
2,000
262,144
Wrong Answer
18
3,064
664
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
a,b,c,d = map(int,list(input())) sum_abcd=a+b+c+d gap = (sum_abcd-7)/2 ans = [a,'+',b,'+',c,'+',d] if gap==0: print(''.join(map(str,ans))) elif gap==(b+c+d): for i in range(1,len(ans),2): ans[i]='-' print(''.join(map(str,ans))) elif gap in [b,c,d]: for i in range(2,len(ans),2): if ans[i]==gap: ans[i-1]='-' break print(''.join(map(str,ans))) else: for i in range(2,len(ans)-1,2): for j in range(i+2,len(ans),2): if ans[i]+ans[j]==gap: ans[i-1]='-' ans[j-1]='-' break print(''.join(map(str,ans)))
s907368910
Accepted
18
3,064
343
s = list(map(int,list(input()))) a = s.pop(0) bit_n = 3 for i in range(2**bit_n): sign = ['+']*3 tmp = a for j in range(bit_n): if ((i>>j)&1): tmp+=s[j] else: tmp-=s[j] sign[j]='-' if tmp==7: print("{0}{1[0]}{2[0]}{1[1]}{2[1]}{1[2]}{2[2]}=7".format(a,sign,s));exit()
s125183771
p03448
u091051505
2,000
262,144
Wrong Answer
71
8,276
253
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()) num = [] for a_ in range(a+1): for b_ in range(b+1): for c_ in range(c+1): cal = a_ * 500 + b_ * 100 + c_ * 50 num.append(cal) print(num.count(6000))
s935499426
Accepted
67
8,276
250
a = int(input()) b = int(input()) c = int(input()) x = int(input()) num = [] for a_ in range(a+1): for b_ in range(b+1): for c_ in range(c+1): cal = a_ * 500 + b_ * 100 + c_ * 50 num.append(cal) print(num.count(x))
s717533031
p03140
u418527037
2,000
1,048,576
Wrong Answer
17
3,064
271
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() a = list(A) b = list(B) c = list(C) ans = 0 for i in range(N): if a[i] == b[i] or a[i] == c[i] or b[i] == c[i]: ans += 1 elif a[i] == b[i] == c[i]: pass else: ans += 2 print(ans)
s843068152
Accepted
17
3,064
304
N = int(input()) A = input() B = input() C = input() a = list(A) b = list(B) c = list(C) ans = 0 for i,j in enumerate(a): if j == b[i] or j == c[i] or b[i] == c[i]: if j == b[i] == c[i]: continue ans += 1 elif a[i] != b[i] != c[i]: ans += 2 print(ans)
s684037119
p03386
u362560965
2,000
262,144
Wrong Answer
17
3,060
124
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
A, B, K = (int(i) for i in input().split()) for i in range(A, A+K): print(i) for j in range(B, B-K, -1): print(j)
s707500016
Accepted
17
3,060
262
A, B, K = (int(i) for i in input().split()) ans = [] for i in range(A, A+K): ans.append(i) if i == B: break for j in range(B, B-K, -1): ans.append(j) if j == A: break ans = list(set(ans)) ans.sort() for x in ans: print(x)
s102650739
p02678
u486074261
2,000
1,048,576
Wrong Answer
2,206
63,028
1,050
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
from sys import stdin from collections import deque def main(): N, M = [int(x) for x in stdin.readline().rstrip().split()] ipt = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()] MOD = 100100100100100100 pl = [0] * (N + 1) for a, b in ipt: if pl[a] == 0: pl[a] = [b] else: pl[a].append(b) if pl[b] == 0: pl[b] = [a] else: pl[b].append(a) print(pl) que = deque([1]) deep = [MOD] * (N + 1) deep[1] = 0 deep[0] = 0 arrow = [0] * (N + 1) cnt = 1 while not not que: q = que.popleft() tmp = False for i in pl[q]: if deep[i] != MOD: continue deep[i] = deep[q] + 1 arrow[i] = q tmp = True cnt += 1 if tmp: que.extend(pl[q]) if N != cnt: print("No") else: print("Yes") for i in arrow[2:]: print(i) if __name__ == "__main__": main()
s800259673
Accepted
593
58,204
972
from sys import stdin from collections import deque def main(): N, M = [int(x) for x in stdin.readline().rstrip().split()] ipt = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()] MOD = 100100100100100100 pl = [0] * (N + 1) for a, b in ipt: if pl[a] == 0: pl[a] = [b] else: pl[a].append(b) if pl[b] == 0: pl[b] = [a] else: pl[b].append(a) que = deque([1]) deep = [MOD] * (N + 1) deep[1] = 0 deep[0] = 0 arrow = [0] * (N + 1) cnt = 1 while not not que: q = que.popleft() for i in pl[q]: if deep[i] != MOD: continue deep[i] = deep[q] + 1 arrow[i] = q cnt += 1 que.append(i) if N != cnt: print("No") else: print("Yes") for i in arrow[2:]: print(i) if __name__ == "__main__": main()
s626996132
p03416
u425366405
2,000
262,144
Wrong Answer
20
3,064
486
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
# -*- coding: utf-8 -*- # n1, n2 = map(int, input().split()) n1, n2 = map(int, "31415 92653".split()) l1 = [int(x) for x in list(str(n1))] l2 = [int(x) for x in list(str(n2))] n1Low = n1%100 n2Low = n2%100 n1HighRev = int(str(l1[1])+str(l1[0])) n2HighRev = int(str(l2[1])+str(l2[0])) ans = 0 if n1Low - n1HighRev <= 0: ans += 1 elif n2Low - n2HighRev >= 0: ans += 1 ans += 9 - l1[2] + l2[2] ans += (l2[0] - l1[0] - 1) * 100 ans += (9 - l1[1] + l2[1]) * 10 print(ans)
s892624101
Accepted
17
3,064
604
# -*- coding: utf-8 -*- n1, n2 = map(int, input().split()) l1 = [int(x) for x in list(str(n1))] l2 = [int(x) for x in list(str(n2))] n1Low = n1%100 n2Low = n2%100 n1HighRev = int(str(l1[1])+str(l1[0])) n2HighRev = int(str(l2[1])+str(l2[0])) ans = 0 if n1Low <= n1HighRev: ans += 1 if n2Low >= n2HighRev: ans += 1 if l1[0] != l2[0]: ans += 9 - l1[2] + l2[2] ans += (l2[0] - l1[0] - 1) * 100 ans += (9 - l1[1] + l2[1]) * 10 else: if l1[1] != l2[1]: ans += 9 - l1[2] + l2[2] ans += (l2[1] - l1[1] - 1) * 10 else: ans += l2[2] - l1[2]-1 print(ans)
s141605966
p03994
u065089468
2,000
262,144
Wrong Answer
168
7,060
292
Mr. Takahashi has a string s consisting of lowercase English letters. He repeats the following operation on s exactly K times. * Choose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of `z` is `a`. For example, if you perform an operation for the second letter on `aaz`, `aaz` becomes `abz`. If you then perform an operation for the third letter on `abz`, `abz` becomes `aba`. Mr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s. Find the such string.
import string import sys s = input() k = int(input()) a = [ord(_) for _ in s] for i in range(len(s)-1): df = ord('z') - a[i] + 1 if k >= df: a[i] = 97 k -= df if k == 0: break if k != 0: k = k % 26 a[len(a)-1] = 97+k [print(chr(_), end="") for _ in a]
s418896506
Accepted
189
7,024
385
import string import sys s = input() k = int(input()) a = [ord(_) for _ in s] for i in range(len(s)-1): if a[i] != ord('a'): df = ord('z') - a[i] + 1 if k >= df: a[i] = ord('a') k -= df if k == 0: break if k != 0: k = k % 26 a[len(a)-1] += k - 26 if ord('z') < k + a[len(a)-1] else k [print(chr(_), end="") for _ in a] print("")
s608580382
p03623
u033524082
2,000
262,144
Wrong Answer
18
3,316
65
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
x,a,b=map(int,input().split()) print("A" if (a-x)<(b-x) else "B")
s708591251
Accepted
20
3,316
75
x,a,b=map(int,input().split()) print("A" if abs((a-x))<abs((b-x)) else "B")
s922554169
p02796
u782930273
2,000
1,048,576
Wrong Answer
660
37,116
526
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.
N = int(input()) X = [0] * N for i in range(N): x, l = map(int, input().split()) X[i] = x, l, x - l, x + l X.sort(key=lambda x: x[1], reverse=True) X = list(enumerate(X)) removed = [False] * N X2 = sorted(X, key=lambda x: x[1][2]) for i, t in X: x, l, rl, rr = t if i <= N - 2 and rr <= X2[i + 1][1][2] and not removed[X2[i + 1][0]]: removed[i] = True if i >= 1 and rl >= X2[i - 1][1][3] and not removed[X2[i - 1][0]]: removed[i] = True print(N - sum(removed))
s725240662
Accepted
454
26,152
285
N = int(input()) X = [0] * N for i in range(N): x, l = map(int, input().split()) X[i] = x, l, x - l, x + l X.sort(key=lambda x: x[3]) right = X[0][3] count = 1 for i in range(1, N): if right <= X[i][2]: count += 1 right = X[i][3] print(count)
s634270333
p03416
u057079894
2,000
262,144
Wrong Answer
17
2,940
237
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
def Is_cyc(x): s = str(x) for i in range(len(s)): if s[i] != s[-i-1]: return False return True def main(): a,b = map(int,input().split()) ans = 0 for i in range(a,b+1): if Is_cyc(i): ans += 1 print(ans)
s509851041
Accepted
86
3,060
284
def Is_cyc(x): s = str(x) for i in range(len(s)): if s[i] != s[-i-1]: return False return True def main(): a,b = map(int,input().split()) ans = 0 for i in range(a,b+1): if Is_cyc(i): ans += 1 print(ans) return if __name__ == "__main__": main()
s252908583
p03587
u268792407
2,000
262,144
Wrong Answer
17
2,940
66
Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not. You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem prepared by Snuke is accepted to be used; `0` means that the problem is not accepted. How many problems prepared by Snuke are accepted to be used in the contest?
s=input() a=0 for i in range(6): if s[i]=="1": a+-1 print(a)
s524964438
Accepted
17
2,940
67
s=input() a=0 for i in range(6): if s[i]=="1": a+=1 print(a)
s514385277
p03474
u179111046
2,000
262,144
Wrong Answer
17
3,060
199
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
a, b = map(int, input().split()) s = input() print(s[a]) if(s[a] == "-"): try: int(s[:a]) int(s[a + 1:]) print("Yes") except: print("No") else: print("No")
s210302321
Accepted
17
2,940
187
a, b = map(int, input().split()) s = input() if(s[a] == "-"): try: int(s[:a]) int(s[a + 1:]) print("Yes") except: print("No") else: print("No")
s639193802
p03351
u670180528
2,000
1,048,576
Wrong Answer
18
2,940
91
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
a,b,c,d=map(int,input().split());A=abs;print("YNeos"[min(A(a-c),max(A(a-b),A(b-c)))<=d::2])
s140552263
Accepted
18
2,940
90
a,b,c,d=map(int,input().split());A=abs;print("YNeos"[min(A(a-c),max(A(a-b),A(b-c)))>d::2])
s816057302
p02257
u148477094
1,000
131,072
Wrong Answer
20
5,656
303
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list.
import math n=int(input("n:")) R=[0]*n sum=0 for i in range(n): R[i]=int(input("")) for i in range(n): s=math.sqrt(R[i]) s=int(s)+1 for j in range(2,s+1): if R[i]==j: sum=sum+1 if R[i]%j==0: break if j==s: sum=sum+1 print(sum)
s026964121
Accepted
1,740
6,044
329
import math n=int(input()) R=[0]*n sum=0 for i in range(n): R[i]=int(input()) for i in range(n): if R[i]<0: continue s=math.sqrt(R[i]) s=int(s)+1 for j in range(2,s+1): if R[i]==j: sum=sum+1 if R[i]%j==0: break if j==s: sum=sum+1 print(sum)
s778489468
p03129
u782098901
2,000
1,048,576
Wrong Answer
20
3,316
77
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
N, K = map(int, input().split()) print("Yes" if (N + 1) // 2 >= K else "No")
s072782470
Accepted
17
2,940
77
N, K = map(int, input().split()) print("YES" if (N + 1) // 2 >= K else "NO")
s483319069
p02613
u221280246
2,000
1,048,576
Wrong Answer
149
16,204
219
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 x {}'.format(S.count('AC'))) print('WA x {}'.format(S.count('WA'))) print('TLE x {}'.format(S.count('TLE'))) print('AC x {}'.format(S.count('RE')))
s815650731
Accepted
146
16,232
219
N=int(input()) S=[] for i in range(N): S.append(input()) print('AC x {}'.format(S.count('AC'))) print('WA x {}'.format(S.count('WA'))) print('TLE x {}'.format(S.count('TLE'))) print('RE x {}'.format(S.count('RE')))
s372323463
p02612
u770558697
2,000
1,048,576
Wrong Answer
31
9,160
89
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
n = int(input()) if n%1000: print(0) else: oturi = (int(n/1000)+1)*1000-n print(oturi)
s203946208
Accepted
29
9,168
95
n = int(input()) if n%1000 == 0: print(0) else: oturi = (int(n/1000)+1)*1000-n print(oturi)
s500605938
p03485
u063614215
2,000
262,144
Wrong Answer
17
2,940
88
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a,b = map(int, input().split()) ans = a+b if ans%2==0: print(ans) else: print(ans+1)
s646486208
Accepted
17
2,940
94
a,b = map(int, input().split()) ans = a+b if ans%2==0: print(ans//2) else: print(ans//2+1)
s635523227
p02392
u098047375
1,000
131,072
Wrong Answer
20
5,580
67
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
A = map(int, input().split()) set_A = set(A) print(sorted(set_A))
s922514406
Accepted
20
5,584
96
a, b, c = map(int, input().split()) if a < b and b < c: print('Yes') else: print('No')
s561476803
p02646
u667687319
2,000
1,048,576
Wrong Answer
24
9,168
146
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
a,v = map(int, input().split()) b,w = map(int, input().split()) t = int(input()) if a + v * t > b + w * t: print('Yes') else: print('No')
s351834243
Accepted
22
9,176
263
a,v = map(int, input().split()) b,w = map(int, input().split()) t = int(input()) if a <= b: if a + v * t >= b + w * t: print('YES') else: print('NO') else: if a - v * t <= b - w * t: print('YES') else: print('NO')
s118858342
p03351
u126823513
2,000
1,048,576
Wrong Answer
17
2,940
263
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
int_a, int_b, int_c, int_d = map(int, input().split()) result = False if abs(int_a - int_c) <= int_d: result = True elif abs(int_a - int_b) <= int_d and abs(int_b - int_c) <= int_d: result = True if result: print('YES') else: print('No')
s191525066
Accepted
17
2,940
258
int_a, int_b, int_c, int_d = map(int, input().split()) result = False if abs(int_a - int_c) <= int_d: result = True elif abs(int_a - int_b) <= int_d and abs(int_b - int_c) <= int_d: result = True if result: print('Yes') else: print('No')
s915121057
p02843
u239653493
2,000
1,048,576
Wrong Answer
18
2,940
126
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
x=int(input()) if x>=2100: print("YES") else: if x%100<=5*(x//100): print("YES") else: print("NO")
s019959088
Accepted
17
2,940
127
x=int(input()) if x>=2000: print(1) else: if (x//100)*100<=x<=(x//100)*105: print(1) else: print(0)
s442974590
p03992
u112002050
2,000
262,144
Wrong Answer
22
3,192
41
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the first 4 letters and last 8 letters in the string s.
s = input() print(s[0:3] + " " + s[4:-1])
s134206441
Accepted
23
3,064
39
s = input() print(s[0:4] + " " + s[4:])
s328866123
p03721
u945181840
2,000
262,144
Wrong Answer
318
25,972
315
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.
import sys input = sys.stdin.readline N, K = map(int, input().split()) a = [0] * N b = [0] * N for i in range(N): a[i], b[i] = map(int, input().split()) a, b = zip(*sorted(zip(a, b))) count = 0 for i in range(N): K -= b[i] if K <= 0: print(a[count]) exit() else: continue
s692321328
Accepted
297
25,952
274
import sys input = sys.stdin.readline N, K = map(int, input().split()) a = [0] * N b = [0] * N for i in range(N): a[i], b[i] = map(int, input().split()) a, b = zip(*sorted(zip(a, b))) for i in range(N): K -= b[i] if K <= 0: print(a[i]) exit()
s394274776
p03486
u846150137
2,000
262,144
Wrong Answer
17
3,060
250
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.
a=input() b=input() aa=[] for i in a: aa.append(i) aa.sort() aaa="".join(aa) bb=[] for i in b: bb.append(i) bb.sort(reverse=True) bbb="".join(bb) ccc=[aaa,bbb] ccc.sort() print(a,b,aaa,bbb,ccc) if bbb==ccc[0]: print('No') else: print('Yes')
s216389118
Accepted
17
3,060
244
a=input().strip() b=input().strip() aa=[] for i in a: aa.append(i) aa.sort() aaa="".join(aa) bb=[] for i in b: bb.append(i) bb.sort(reverse=True) bbb="".join(bb) ccc=[aaa,bbb] ccc.sort() if bbb==ccc[0]: print('No') else: print('Yes')
s003617238
p03623
u225388820
2,000
262,144
Wrong Answer
17
2,940
60
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
x,a,b=map(int,input().split()) print(min(abs(x-a),abs(x-b)))
s606747674
Accepted
17
2,940
85
x,a,b=map(int,input().split()) if abs(x-a)<abs(x-b): print('A') else: print('B')
s771255846
p03610
u687574784
2,000
262,144
Wrong Answer
17
3,192
20
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
print(input()[1::2])
s551731643
Accepted
17
3,192
19
print(input()[::2])
s263591313
p02272
u481571686
1,000
131,072
Wrong Answer
20
5,608
512
Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function. Merge(A, left, mid, right) n1 = mid - left; n2 = right - mid; create array L[0...n1], R[0...n2] for i = 0 to n1-1 do L[i] = A[left + i] for i = 0 to n2-1 do R[i] = A[mid + i] L[n1] = SENTINEL R[n2] = SENTINEL i = 0; j = 0; for k = left to right-1 if L[i] <= R[j] then A[k] = L[i] i = i + 1 else A[k] = R[j] j = j + 1 Merge-Sort(A, left, right){ if left+1 < right then mid = (left + right)/2; call Merge-Sort(A, left, mid) call Merge-Sort(A, mid, right) call Merge(A, left, mid, right)
def merge(A,left,center,right): global cnt l=A[left:center] r=A[center:right] l.append(float("inf")) r.append(float("inf")) j=0 k=0 for i in range(left,right): cnt+=1 if l[j]<=r[k]: A[i]=l[j] j+=1 else: A[i]=r[j] k+=1 def mergesort(A,left,right): if left+1<right: center=(left+right)//2 mergesort(A,left,center) mergesort(A,center,right) merge(A,left,center,right) n=int(input()) A=list(map(int,input().split())) cnt=0 mergesort(A,0,n) print(" ".join(map(str,A))) print(cnt)
s997051593
Accepted
4,250
69,564
668
cnt=0 def merge(a,left,mid,right): n1=mid-left n2=right-mid l=a[left:mid] r=a[mid:right] l.append(float("inf")) r.append(float("inf")) i=0 j=0 for k in range(left,right): global cnt cnt+=1 if(l[i] <= r[j]): a[k] = l[i] i+=1 else: a[k]=r[j] j+=1 def merge_sort(a,left,right): if(left+1<right): mid=(left+right)//2 merge_sort(a,left,mid) merge_sort(a,mid,right) merge(a,left,mid,right) n=int(input()) s=input() a=list(map(int,s.split())) merge_sort(a,0,n) a=map(str,a) print(" ".join(list(a))) print(cnt)
s846235191
p03407
u117193815
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()) if a+b<=c: print("Yes") else: print("No")
s351929738
Accepted
17
2,940
80
a,b,c = map(int ,input().split()) if a+b>=c: print("Yes") else: print("No")
s007965244
p02603
u766646838
2,000
1,048,576
Wrong Answer
26
9,208
349
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
n,*a=map(int,open(0).read().split()) ans=1000 num= 0 for i in range(n): if i == n-1: if a[i-1]<a[i]: ans += a[i]*num elif a[i]<a[i+1] and a[i+1]<ans: num = ans//a[i] ans = ans%a[i] print(i,num,ans) elif a[i]<a[i+1] and a[i+1]>ans: continue elif a[i] == a[i+1]: continue else: ans += num*a[i] print(ans)
s902039344
Accepted
35
9,184
404
N = int(input()) a = list(map(int,input().split())) num = 1000 flag = True flag2 = True for i in range(1,N): if a[i-1]<a[i] and flag == True: mi = a[i-1] ma = a[i] flag = False elif a[i-1]<a[i] and flag == False: ma = a[i] elif a[i-1]>a[i] and flag == False: num = (num//mi)*ma+(num%mi) flag = True if i == N-1 and flag == False: num = (num//mi)*ma+(num%mi) print(num)
s933540168
p02928
u518064858
2,000
1,048,576
Wrong Answer
1,227
3,388
409
We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of ordered pairs of integers (i,~j)~(0 \leq i < j \leq K \times N - 1) such that B_i > B_j.
n,k=map(int,input().split()) M=10**9+7 a=list(map(int,input().split())) cnt=[[0 for i in range(2)] for j in range(n)] for i in range(n): for j in range(n): if j<i and a[j]<a[i]: cnt[i][0]+=1 elif i<j and a[j]<a[i]: cnt[i][1]+=1 sum=0 for i in range(n): s=(1/2)*(k**2)*(cnt[i][0]+cnt[i][1])+(1/2)*(cnt[i][1]-cnt[i][0])*k s%=M sum+=s sum%=M print(sum)
s692011845
Accepted
1,432
3,416
391
n,k=map(int,input().split()) M=10**9+7 a=list(map(int,input().split())) cnt=[[0 for i in range(2)] for j in range(n)] for i in range(n): for j in range(n): if j<i and a[j]<a[i]: cnt[i][0]+=1 elif i<j and a[j]<a[i]: cnt[i][1]+=1 sum=0 for i in range(n): s=((k*(cnt[i][0]+cnt[i][1])+(cnt[i][1]-cnt[i][0]))*k)//2 sum+=s sum%=M print(sum)
s408720416
p02558
u179376941
5,000
1,048,576
Wrong Answer
809
71,540
267
You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types. * `0 u v`: Add an edge (u, v). * `1 u v`: Print 1 if u and v are in the same connected component, 0 otherwise.
n, q = map(int, input().split()) nei = {} for i in range(n): nei[i] = set() for _ in range(q): t, u, v = map(int, input().split()) if t == 0: nei[u].add(v) nei[v].add(u) else: if v in nei[u] and u in nei[v]: print(1) else: print(0)
s216880476
Accepted
755
11,484
795
class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def same(self, x, y): return self.find(x) == self.find(y) n, q = map(int, input().split()) un = UnionFind(n) for _ in range(q): t, u, v = map(int, input().split()) if t == 0: un.union(u, v) else: print(1 if un.same(u, v) else 0)
s377111210
p03436
u919730120
2,000
262,144
Wrong Answer
2,108
58,988
648
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
from collections import deque h,w=map(int,input().split()) s=[input() for _ in range(h)] d=[[1,0],[-1,0],[0,1],[0,-1]] bcnt=0 for i in range(h): bcnt+=s[i].count('#') dist=[[1000]*w for _ in range(h)] chk=[[0]*w for _ in range(h)] r=deque() r.append([0,0]) dist[0][0]=0 while r: x,y=r.popleft() chk[y][x]=1 for dx,dy in d: nx=x+dx ny=y+dy if nx>=0 and nx<=w-1 and ny>=0 and ny<=h-1: if chk[ny][nx]==1: continue if s[ny][nx]=='.': dist[ny][nx]=min(dist[ny][nx],dist[y][x]+1) r.append([nx,ny]) print(dist) print(h*w-dist[h-1][w-1]-1-bcnt)
s535305220
Accepted
43
9,424
787
from collections import deque h,w=map(int,input().split()) dist=[[-1]*(w+2) for _ in range(h+2)] dist[1][1]=1 maze=[] maze.append(['#' for _ in range(w+2)]) for i in range(h): maze.append(['#']+list(input())+['#']) maze.append(['#' for _ in range(w+2)]) cnt=0 for i in range(h+2): for j in range(w+2): if maze[i][j]=='#': cnt+=1 d=[[-1,0],[1,0],[0,-1],[0,1]] q=deque() q.append([1,1]) while q: x,y=q.popleft() for dx,dy in d: if (0<=x+dx<=h+1) and (0<y+dy<w+1): if maze[x+dx][y+dy]==".": if dist[x+dx][y+dy]==-1 or dist[x+dx][y+dy]>dist[x][y]+1: q.append([x+dx,y+dy]) dist[x+dx][y+dy]=dist[x][y]+1 if dist[h][w]==-1: print(-1) else: print((h+2)*(w+2)-cnt-dist[h][w])
s260556871
p03449
u115682115
2,000
262,144
Wrong Answer
19
3,060
217
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
N = int(input()) a = [list(map(int,input().split())) for i in range(2)] saidaiti = [] for i in range(N): saidaiti.append(sum(a[0][:i+1]+a[1][i:])) print(a[0][:i+1]) print(a[1][i:]) print(max(saidaiti))
s943783119
Accepted
18
2,940
174
N = int(input()) a = [list(map(int,input().split())) for i in range(2)] saidaiti = [] for i in range(N): saidaiti.append(sum(a[0][:i+1]+a[1][i:])) print(max(saidaiti))
s894675217
p02255
u400765446
1,000
131,072
Wrong Answer
20
5,596
509
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
def main(): n = int(input()) Mtx = list(map(int, input().split())) for i in range(1,n): for j in range(i,0,-1): if Mtx[j] < Mtx[j-1]: Mtx[j-1], Mtx[j] = Mtx[j], Mtx[j-1] # print(i, j, sep=', ') showMtx(Mtx) def showMtx(Mtx): q = len(Mtx) for i in range(q): if i != q - 1: print(Mtx[i], sep=' ', end=' ') else: print(Mtx[i]) if __name__ == '__main__': main()
s184205694
Accepted
20
5,600
206
n = int(input()) A = input().split() print(' '.join(A)) for i in range(1,n): for j in range(i,0,-1): if int(A[j]) < int(A[j-1]): A[j], A[j-1] = A[j-1], A[j] print(' '.join(A))
s009372417
p03486
u068844030
2,000
262,144
Wrong Answer
17
2,940
214
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() s_sort = "".join(sorted(s)) t_sort = "".join(sorted(t,reverse=True)) print("yes" if s_sort < t_sort else "No")
s917491103
Accepted
18
2,940
222
##82_B s = input() t = input() s_sort = "".join(sorted(s)) t_sort = "".join(sorted(t,reverse=True)) print("Yes" if s_sort < t_sort else "No")
s871917038
p03434
u416758623
2,000
262,144
Wrong Answer
17
3,064
240
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
n = int(input()) a = [int(x) for x in input().split()] sortA = sorted(a, reverse=True) Alice = 0 Bob = 0 print(sortA) for i in range(len(a)): if i % 2 == 0: Alice+=sortA[i] else: Bob+=sortA[i] print(Alice - Bob)
s205055967
Accepted
30
9,184
207
n = int(input()) l = sorted(list(map(int, input().split())), reverse=True) Alice = 0 Bob = 0 for i in range(len(l)): if i % 2 == 0: Alice += l[i] else: Bob += l[i] print(Alice - Bob)
s703950396
p04046
u798316285
2,000
262,144
Wrong Answer
305
18,932
442
We have a large square grid with H rows and W columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell. However, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there are A×B forbidden cells.) There is no restriction on entering the other cells. Find the number of ways she can travel to the bottom-right cell. Since this number can be extremely large, print the number modulo 10^9+7.
N=2*10**5+3 mod=10**9+7 fac=[1]*(N+1) for i in range(1,N+1): fac[i]=fac[i-1]*i%mod inv_fac=[1]*(N+1) inv_fac[N]=pow(fac[N],mod-2,mod) for i in range(N-1,0,-1): inv_fac[i]=inv_fac[i+1]*(i+1)%mod def nCr(n,r): if n<=0 or r<0 or r>n: return 0 return fac[n]*inv_fac[r]%mod*inv_fac[n-r]%mod h,w,a,b=map(int,input().split()) ans=nCr(h+w-2,h-1) for i in range(b): ans=(ans-nCr(h-a+i-1,i)*nCr(a+w-i-2,a-1))%mod print(ans)
s337405092
Accepted
309
18,804
440
N=2*10**5+3 mod=10**9+7 fac=[1]*(N+1) for i in range(1,N+1): fac[i]=fac[i-1]*i%mod inv_fac=[1]*(N+1) inv_fac[N]=pow(fac[N],mod-2,mod) for i in range(N-1,0,-1): inv_fac[i]=inv_fac[i+1]*(i+1)%mod def nCr(n,r): if n<0 or r<0 or r>n: return 0 return fac[n]*inv_fac[r]%mod*inv_fac[n-r]%mod h,w,a,b=map(int,input().split()) ans=nCr(h+w-2,h-1) for i in range(b): ans=(ans-nCr(h-a+i-1,i)*nCr(a+w-i-2,a-1))%mod print(ans)
s850977103
p03501
u853900545
2,000
262,144
Wrong Answer
17
2,940
53
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
n,a,b = map(int,input().split()) print(min((n+a),b))
s102794239
Accepted
17
2,940
53
n,a,b = map(int,input().split()) print(min((n*a),b))
s229204625
p03385
u239375815
2,000
262,144
Wrong Answer
17
2,940
54
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
a = sorted(input()) print("Yes" if a=='abc' else "No")
s674493477
Accepted
17
2,940
69
a = sorted(input()) a = ''.join(a) print("Yes" if a=='abc' else "No")
s008486463
p03129
u496815777
2,000
1,048,576
Wrong Answer
21
3,316
86
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
n, k = map(int, input().split()) if n < 2 * k - 1: print("No") else: print("Yes")
s207767667
Accepted
17
2,940
86
n, k = map(int, input().split()) if n < 2 * k - 1: print("NO") else: print("YES")
s118303797
p03352
u021548497
2,000
1,048,576
Wrong Answer
17
2,940
141
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
from math import sqrt from sys import exit n = int(input()) for i in range(n,0): if sqrt(n).is_integer(): print(i) exit()
s877683305
Accepted
17
3,064
352
from sys import exit n = int(input()) powlist = set() k = 2 chance = True if n == 1: print(1) exit() while chance: for i in range(1, n): key = i**k if key <= n: powlist.add(key) else: k += 1 judge = i break if judge == 2: chance = False print(max(powlist))
s359409584
p02612
u969848070
2,000
1,048,576
Wrong Answer
27
8,936
24
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
print(int(input())%1000)
s280525112
Accepted
29
9,068
64
a = int(input())%1000 if a ==0: print(0) else: print(1000-a)
s872949590
p02578
u667084803
2,000
1,048,576
Wrong Answer
88
25,220
133
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
N = int(input()) A = map(int, input().split()) curr = 0 ans = 0 for a in A: if curr < a: curr = a ans += a-curr print(ans)
s128164657
Accepted
96
25,072
143
N = int(input()) A = map(int, input().split()) curr = 0 ans = 0 for a in A: if curr > a: ans += curr - a else: curr = a print(ans)
s865473733
p02399
u476441153
1,000
131,072
Wrong Answer
30
7,692
81
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
a,b = list(map(int, input().split())) print (int((a/b)) , round(a%b) ,float(a/b))
s339796743
Accepted
20
7,684
107
a,b = list(map(int, input().split())) d = a // b r = a % b f = a / b print('{0} {1} {2:.5f}'.format(d,r,f))
s810334436
p02613
u515128734
2,000
1,048,576
Wrong Answer
144
9,212
361
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()) ct_ac = 0 ct_wa = 0 ct_tle = 0 ct_re = 0 for i in range(n): s = input() if s == 'AC': ct_ac += 1 if s == 'WA': ct_wa += 1 if s == 'TLE': ct_tle += 1 if s == 'RE': ct_re += 1 print('AC × ' + str(ct_ac)) print('WA × ' + str(ct_wa)) print('TLE × ' + str(ct_tle)) print('RE × ' + str(ct_re))
s108386132
Accepted
152
9,236
357
n = int(input()) ct_ac = 0 ct_wa = 0 ct_tle = 0 ct_re = 0 for i in range(n): s = input() if s == 'AC': ct_ac += 1 if s == 'WA': ct_wa += 1 if s == 'TLE': ct_tle += 1 if s == 'RE': ct_re += 1 print('AC x ' + str(ct_ac)) print('WA x ' + str(ct_wa)) print('TLE x ' + str(ct_tle)) print('RE x ' + str(ct_re))
s368551387
p02613
u845847173
2,000
1,048,576
Wrong Answer
167
20,292
391
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 _ in range(N): S.append(input()) AC = [] WA = [] TLE = [] RE = [] for i in range(N): if S[i] == "AC": AC.append(i) elif S[i] == "WA": WA.append(i) elif S[i] == "TLE": TLE.append(i) else: RE.append(i) print("AC", "×", len(AC)) print("WA", "×", len(WA)) print("TLE", "×", len(TLE)) print("RE", "×", len(RE))
s121512141
Accepted
170
20,176
395
N = int(input()) S = [] for _ in range(N): S.append(input()) AC = [] WA = [] TLE = [] RE = [] for i in range(N): if S[i] == "AC": AC.append(i) elif S[i] == "WA": WA.append(i) elif S[i] == "TLE": TLE.append(i) else: RE.append(i) print("AC", "x", len(AC)) print("WA", "x", len(WA)) print("TLE", "x", len(TLE)) print("RE", "x", len(RE))
s378054178
p03544
u440129511
2,000
262,144
Wrong Answer
17
2,940
81
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()) l=[1,2] for i in range(n): l.append(l[-1]+l[-2]) print(l[n-1])
s546743818
Accepted
17
3,064
79
n=int(input()) l=[2,1] for i in range(n): l.append(l[-1]+l[-2]) print(l[n])
s486867299
p03523
u644126199
2,000
262,144
Wrong Answer
17
3,064
453
You are given a string S. Takahashi can insert the character `A` at any position in this string any number of times. Can he change S into `AKIHABARA`?
data =input() data = list(data) deter ="" if len(data) >=9: print("NO") if len(data) >=5 and len(data)<=8: if data[0] !="A": data.insert(0,"A") if data[4] !="A": data.insert(4,"A") if data[6] !="A": data.insert(6,"A") if data[len(data)-1] !="R": print("NO") else: data.append("A") for s in range(len(data)): deter +=data[s] if deter =="AKIHABARA": print("YES") print(deter) if len(data) <=4: print("NO")
s714275943
Accepted
17
3,064
859
data =input() data = list(data) deter ="" cnt2 =0 cnt =[0]*5 cnt3 =0 for t in range(len(data)): if data[t] =="I": cnt[0] +=1 if data[t] =="K": cnt[1] +=1 if data[t] =="H": cnt[2] +=1 if data[t] =="B": cnt[3] +=1 if data[t] =="R": cnt[4] +=1 if cnt[0] ==1 and cnt[1] ==1 and cnt[2] ==1 and cnt[3] ==1 and cnt[4] ==1: cnt2 +=1 if len(data) >9 or cnt2 ==0 : print("NO") cnt3 +=1 if len(data) >=5 and len(data)<=9 and cnt2 ==1: if data[0] !="A": data.insert(0,"A") if data[4] !="A": data.insert(4,"A") if data[6] !="A": data.insert(6,"A") if len(data) ==8: data.append("A") else: if data[8] !="A": data.insert(8,"A") for s in range(len(data)): deter +=data[s] if deter =="AKIHABARA": print("YES") else: print("NO") if len(data) <=4 and cnt3==0: print("NO")
s488139011
p02399
u078042885
1,000
131,072
Wrong Answer
30
7,568
96
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
c=input() a,b=c.split() print("{} {} {}".format(int(int(a)/int(b)),int(a)%int(b),int(a)/int(b)))
s816106235
Accepted
30
7,652
74
(a,b)=(int(i) for i in input().split()) print('%s %s %.5f'%(a//b,a%b,a/b))
s695441839
p02613
u012820749
2,000
1,048,576
Wrong Answer
143
16,160
267
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.
def main(): num = int(input()) result = [] for i in range(num): result.append(input()) print(f'AC X {result.count("AC")}') print(f'WA X {result.count("WA")}') print(f'TLE X {result.count("TLE")}') print(f'RE X {result.count("RE")}') return main()
s224387812
Accepted
143
16,288
267
def main(): num = int(input()) result = [] for i in range(num): result.append(input()) print(f'AC x {result.count("AC")}') print(f'WA x {result.count("WA")}') print(f'TLE x {result.count("TLE")}') print(f'RE x {result.count("RE")}') return main()
s816153893
p03574
u953794676
2,000
262,144
Wrong Answer
30
3,188
609
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
dy = [-1, -1, -1, 0, 0, 1, 1, 1] dx = [-1, 0, 1, -1, 1, -1, 0, 1] field = [] H, W = map(int, input().split()) for _ in range(H): field.append(list(input())) for y in range(H): for x in range(W): if field[y][x] == '#': continue count = 0 for k in range(8): nx = x + dx[k] ny = y + dy[k] if nx < 0 or W <= nx or ny < 0 or H <= ny: continue if field[ny][nx] == '#': count += 1 field[y][x] = str(count) for h in range(H): print(field[h])
s064851153
Accepted
31
3,188
618
dy = [-1, -1, -1, 0, 0, 1, 1, 1] dx = [-1, 0, 1, -1, 1, -1, 0, 1] field = [] H, W = map(int, input().split()) for _ in range(H): field.append(list(input())) for y in range(H): for x in range(W): if field[y][x] == '#': continue count = 0 for k in range(8): nx = x + dx[k] ny = y + dy[k] if nx < 0 or W <= nx or ny < 0 or H <= ny: continue if field[ny][nx] == '#': count += 1 field[y][x] = str(count) for h in range(H): print("".join(field[h]))
s121325431
p03681
u594329566
2,000
262,144
Wrong Answer
2,104
4,616
530
Snuke has N dogs and M monkeys. He wants them to line up in a row. As a Japanese saying goes, these dogs and monkeys are on bad terms. _("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.)_ Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys. How many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that). Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.
import math def ini(): return int(input()) def inli(): return list(map(int, input().split())) def inf(): return float(input()) def inlf(): return list(map(float, input().split())) def inl(): return list(input()) def pli(): return "".join(list(map(str, ans))) a = inli() n=a[0] m=a[1] if n-m ==1 or m-n==1: if n < m: tmp =math.factorial(n) print(tmp * tmp * m) else: tmp = math.factorial(m) print(tmp * tmp *n) elif n==m : tmp =math.factorial(m) print(tmp * tmp) else : print(0)
s215867146
Accepted
400
4,608
571
import math def ini(): return int(input()) def inli(): return list(map(int, input().split())) def inf(): return float(input()) def inlf(): return list(map(float, input().split())) def inl(): return list(input()) def pli(): return "".join(list(map(str, ans))) a = inli() n=a[0] m=a[1] if n-m ==1 or m-n==1: if n < m: tmp =math.factorial(n) print((tmp * tmp * m)%1000000007) else: tmp = math.factorial(m) print((tmp * tmp *n)%1000000007) elif n==m : tmp =math.factorial(m) print((tmp * tmp *2)%1000000007) else : print(0)
s465613018
p03353
u982762220
2,000
1,048,576
Wrong Answer
2,104
6,004
446
You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
S = input() K = int(input()) l = len(S) topk = [] vocab = set() for idx in range(K): ss = S[0:idx + 1] topk.append(ss) vocab.add(ss) for idx in range(1, l): sblen = 0 for sblen in range(1, l - idx): ss = S[idx: idx + sblen] if ss in vocab: continue vocab.add(ss) if ss > topk[-1]: break else: topk[-1] = ss topk.sort() print(topk[K-1])
s549557907
Accepted
38
5,084
227
S = input() K = int(input()) l = len(S) topk = [] a = [] for i in range(l): for j in range(i + 1, i + K + 1): if j > l: break ss = S[i: j] a.append(ss) print(sorted(list(set(a)))[K-1])
s202463886
p03475
u159994501
3,000
262,144
Wrong Answer
65
3,064
296
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated. The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds. Here, it is guaranteed that F_i divides S_i. That is, for each Time t satisfying S_i≤t and t%F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A%B denotes A modulo B, and there will be no other trains. For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.
N = int(input()) tc,ts,tf = 0,0,0 C, S, F, =[], [], [] t = 0 for i in range(N-1): tc,ts,tf = map(int,input().split()) C.append(tc) S.append(ts) F.append(tf) print(C,S,F) for i in range(N-1): t = 0 for j in range(i, N-1): t = max(t,S[j])+C[j] print(t) print(0)
s656034423
Accepted
97
3,188
392
import math N = int(input()) tc,ts,tf = 0,0,0 C, S, F, =[], [], [] t = 0 for i in range(N-1): tc,ts,tf = map(int,input().split()) C.append(tc) S.append(ts) F.append(tf) #print(C,S,F) for i in range(N-1): t = 0 for j in range(i, N-1): if t <= S[j]: t = S[j] + C[j] else: t = math.ceil(t/F[j]) * F[j] + C[j] print(t) print(0)
s620114453
p03386
u372259664
2,000
262,144
Wrong Answer
17
3,060
192
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
temp = input() a,b,k = temp.split() a = int(a) b = int(b) k = int(k) box = [] for i in range(k): box.append(a+i) box.append(b-i) out = set(box) sorted(out) for i in out: print(i)
s679628237
Accepted
17
3,060
254
temp = input() a,b,k = temp.split() a = int(a) b = int(b) k = int(k) box = [] for i in range(k): box.append(a+i) box.append(b-i) out = set(box) out = list(out) out = [i for i in out if i>=a and i<=b] out = sorted(out) for i in out: print(i)
s607937332
p03385
u672898046
2,000
262,144
Wrong Answer
17
2,940
75
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 = input() l = ["a","b","c"] if s in l: print("Yes") else: print("No")
s396796451
Accepted
17
2,940
103
s = input() l = [i for i in s] r = ["a","b", "c"] if sorted(l) == r: print("Yes") else: print("No")
s444559325
p02853
u624613992
2,000
1,048,576
Wrong Answer
30
9,160
149
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen. DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.
x,y = map(int,input().split()) a = [0]*210 a[:3] = [300000, 200000, 100000] if x == y and x == 1: print(400000) else: print(a[x-1] + a[y-1])
s218056648
Accepted
30
9,168
150
x,y = map(int,input().split()) a = [0]*210 a[:3] = [300000, 200000, 100000] if x == y and x == 1: print(1000000) else: print(a[x-1] + a[y-1])
s504785927
p00032
u744114948
1,000
131,072
Wrong Answer
30
6,720
203
機械に辺・対角線の長さのデータを入力し、プラスティック板の型抜きをしている工場があります。この工場では、サイズは様々ですが、平行四辺形の型のみを切り出しています。あなたは、切り出される平行四辺形のうち、長方形とひし形の製造個数を数えるように上司から命じられました。 「機械に入力するデータ」を読み込んで、長方形とひし形の製造個数を出力するプログラムを作成してください。
s=0 n=0 while True: try: a,b,c = map(int, input().split()) except: break if a == b: n+=1 elif c**2 == a**2 + b**2: s+=1 print(str(s) + "\n" + str(n))
s557516157
Accepted
30
6,720
204
s=0 n=0 while True: try: a,b,c = map(int, input().split(",")) except: break if a == b: n+=1 elif c**2 == a**2 + b**2: s+=1 print(str(s) + "\n" + str(n))
s304866174
p03828
u258647915
2,000
262,144
Wrong Answer
23
3,064
280
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
from math import * def divisor(n): res = list() for i in range(1, int(sqrt(n))): if n % i == 0: res.append(i) if i != n // i: res.append(n / i) return res MOD = int(1e9 + 7) n = int(input()) print(len(divisor(factorial(n))) % MOD)
s947249067
Accepted
59
3,064
322
MOD = int(1e9 + 7) n = int(input()) es = [0] * 1010 def div(x): if x == 1: return for i in range(2, x + 1): while x % i == 0: es[i] += 1 x //= i for i in range(1, n + 1): div(i) ans = 1 for i in range(1, n + 1): ans *= es[i] + 1 print(ans % MOD)
s465620586
p02612
u470439462
2,000
1,048,576
Wrong Answer
28
9,092
87
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input()) if N % 1000 == 0: print(0) else: print(N - (N // 1000) * 1000)
s586574925
Accepted
27
8,996
91
N = int(input()) if N % 1000 == 0: print(0) else: print(((N // 1000)+1) * 1000 - N)
s957163170
p02850
u955251526
2,000
1,048,576
Wrong Answer
2,105
56,480
402
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.
n = int(input()) edges = [tuple(map(int, input().split())) for _ in range(n-1)] color = {} forbidden = [set() for _ in range(n+1)] for a, b in sorted(edges): for c in range(n): if c not in forbidden[a] and c not in forbidden[b]: forbidden[a].add(c) forbidden[b].add(c) color[(a, b)] = c break for a, b in edges: print(color[(a, b)] + 1)
s701001866
Accepted
804
64,216
717
n = int(input()) edge = [tuple(map(int, input().split())) for _ in range(n-1)] connect = [set() for _ in range(n)] for a, b in edge: connect[a-1].add(b-1) connect[b-1].add(a-1) ans = {(-1, 0): -1} que = {(-1, 0)} while que: queque = set() for p, v in que: c = 1 for w in connect[v]: if w != p: if c == ans[(p, v)]: c += 1 ans[(v, w)] = c queque.add((v, w)) c += 1 que = queque pri = [0] * (n-1) for i, (a, b) in enumerate(edge): a -= 1 b -= 1 if (a, b) in ans: pri[i] = ans[(a, b)] else: pri[i] = ans[(b, a)] print(max(pri)) for x in pri: print(x)
s742645693
p02865
u812867074
2,000
1,048,576
Wrong Answer
17
2,940
71
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
n = int(input()) if n % 2 == 0: print(n/2 - 1) else: print((n-1)/2)
s845616570
Accepted
17
2,940
81
n = int(input()) if n % 2 == 0: print(int(n/2 - 1)) else: print(int((n-1)/2))
s424591479
p02612
u844590940
2,000
1,048,576
Wrong Answer
27
9,088
71
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
n = input() keta = len(n) ans = int(n[keta - 3:keta]) % 1000 print(ans)
s389508565
Accepted
25
9,080
67
n = int(input()) simosan = n % 1000 print((1000 - simosan) % 1000)
s591068695
p03779
u374802266
2,000
262,144
Wrong Answer
19
3,188
174
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
n=int(input()) l,r=0,10**9 while l+1!=r: m=(l+r)/2 if m*(m+1)//2==n: print(m) exit() elif m*(m+1)//2>n: r=m else: l=m print(r)
s935977278
Accepted
25
2,940
80
n=int(input()) a=0 for i in range(1,10**5): a+=i if a>=n: break print(i)
s164246999
p02613
u934940582
2,000
1,048,576
Wrong Answer
147
16,328
345
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()) result = [input() for _ in range(N)] C_AC,C_TLE,C_WA,C_RE = [0,0,0,0] for i in result: if i == "AC": C_AC += 1 elif i == "WA": C_WA += 1 elif i == "TLE": C_TLE += 1 elif i == "RE": C_RE += 1 print("AC x " + str(C_AC)) print("WA x " + str(C_WA)) print("TLE x " + str(C_TLE)) print("AC x " + str(C_RE))
s429013525
Accepted
147
16,260
345
N = int(input()) result = [input() for _ in range(N)] C_AC,C_TLE,C_WA,C_RE = [0,0,0,0] for i in result: if i == "AC": C_AC += 1 elif i == "WA": C_WA += 1 elif i == "TLE": C_TLE += 1 elif i == "RE": C_RE += 1 print("AC x " + str(C_AC)) print("WA x " + str(C_WA)) print("TLE x " + str(C_TLE)) print("RE x " + str(C_RE))
s939600673
p03673
u667024514
2,000
262,144
Wrong Answer
2,105
20,972
203
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
n = int(input()) lis = [] li = list(map(str,input().split())) if n % 2 == 1: lis.append(li[0]) li.pop(0) for i in range(n//2): lis.append(li[i]) lis.insert(0,li[i+1]) print(" ".join(lis))
s170351704
Accepted
66
27,384
206
n = int(input()) lis = list(map(str,input().split())) li = lis[::2] l = lis[1::2] if n % 2 == 0: l = l[::-1] ans = l+li print(" ".join(ans)) else: li = li[::-1] ans = li+l print(" ".join(ans))
s084701705
p02407
u485986915
1,000
131,072
Wrong Answer
20
5,584
71
Write a program which reads a sequence and prints it in the reverse order.
n = int(input()) a = list(map(int,input().split())) a.sort() print(a)
s826429784
Accepted
20
5,596
122
n = int(input()) a = list(map(int,input().split())) a.reverse() str = "" for d in a: str +="%d "%(d) print(str[:-1])
s398514151
p03587
u698535708
2,000
262,144
Wrong Answer
17
2,940
75
Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not. You are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem prepared by Snuke is accepted to be used; `0` means that the problem is not accepted. How many problems prepared by Snuke are accepted to be used in the contest?
a = input() ans = 0 for i in a: if a=='1': ans += 1 print(ans)
s436395626
Accepted
20
2,940
76
a = input() ans = 0 for i in a: if i=='1': ans += 1 print(ans)
s036281698
p03351
u119578112
2,000
1,048,576
Wrong Answer
17
2,940
171
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
N = list(map(int, input().split())) max_N = max(N) min_N = min(N) if max_N-min_N <= N[3]: print('Yes') elif N[2]-N[0] <= N[3]: print('Yes') else : print('No')
s954143565
Accepted
17
3,060
171
N = list(map(int, input().split())) if abs(N[0]-N[2])<=N[3]: print('Yes') elif abs(N[0]-N[1])<= N[3] and abs(N[1]-N[2])<= N[3]: print('Yes') else: print('No')
s525204113
p03407
u597017430
2,000
262,144
Wrong Answer
17
3,064
95
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 = list(map(int, input().split())) if A[0] + A[1] <= A[2]: print('Yes') exit() print('No')
s876872053
Accepted
17
2,940
96
A = list(map(int, input().split())) if A[0] + A[1] >= A[2]: print('Yes') exit() print('No')
s911469510
p02410
u343251190
1,000
131,072
Wrong Answer
20
7,696
273
Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints their product $Ab$. A column vector with m elements is represented by the following equation. \\[ b = \left( \begin{array}{c} b_1 \\\ b_2 \\\ : \\\ b_m \\\ \end{array} \right) \\] A $n \times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation. \\[ A = \left( \begin{array}{cccc} a_{11} & a_{12} & ... & a_{1m} \\\ a_{21} & a_{22} & ... & a_{2m} \\\ : & : & : & : \\\ a_{n1} & a_{n2} & ... & a_{nm} \\\ \end{array} \right) \\] $i$-th element of a $m \times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$). The product of a $n \times m$ matrix $A$ and a $m \times 1$ column vector $b$ is a $n \times 1$ column vector $c$, and $c_i$ is obtained by the following formula: \\[ c_i = \sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m \\]
n, m = map(int, input().split()) A = [] for i in range(n): A.append(list(map(int, input().split()))) print(A) B = [] for j in range(m): B.append(int(input())) print(B) for k in range(n): x = 0 for l in range(m): x += A[k][l] * B[l] print(x)
s537506644
Accepted
30
7,980
253
n, m = map(int, input().split()) A = [] for i in range(n): A.append(list(map(int, input().split()))) B = [] for j in range(m): B.append(int(input())) for k in range(n): x = 0 for l in range(m): x += A[k][l] * B[l] print(x)
s217718662
p03456
u965337330
2,000
262,144
Wrong Answer
17
2,940
88
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
A=list(map(int, input().split())) if A[0]*A[0]==A[1]: print('Yes') else: print('No')
s906449789
Accepted
18
3,064
243
import math A=list(map(int, input().split())) b=str(A[0])+str(A[1]) c=int(b) #print(round(math.sqrt(int(b)),10)) #c=round(math.sqrt(int(b)),10) d=0 for i in range(10000): if i*i==c: print('Yes') d=1 if d==0: print('No')
s515949289
p02412
u914146430
1,000
131,072
Wrong Answer
30
7,588
322
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
m=0 while True: n, x = list(map(int,input().split())) if n==0 and x==0: break else: for i in range(1,n+1): for j in range(i+1,n+1): for k in range(j+1, n+1): print(i,j,k) if i+j+k==x: m+=1 print(m)
s241761945
Accepted
530
7,600
326
while True: n, x = list(map(int,input().split())) m=0 if n==0 and x==0: break else: for i in range(1,n+1): for j in range(i+1,n+1): for k in range(j+1, n+1): #print(i,j,k) if i+j+k==x: m+=1 print(m)
s457818389
p02612
u566685958
2,000
1,048,576
Wrong Answer
26
8,980
31
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input()) print(N%1000)
s779264961
Accepted
28
9,076
76
N = int(input()) m = N % 1000 if m == 0: print(0) else: print(1000 - m)
s975007088
p03338
u468972478
2,000
1,048,576
Wrong Answer
27
9,124
98
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() t = 0 for i in range(n): if s.count(s[i]) >= 2: t += 1 print(t)
s026655815
Accepted
30
9,172
112
n = int(input()) s = input() a = [] for i in range(1, n): a.append(len(set(s[:i]) & set(s[i:]))) print(max(a))
s910065900
p04044
u090267744
2,000
262,144
Wrong Answer
154
12,420
320
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.
import numpy as np n,l=list(map(int,input().split( ))) s=[] for i in range(n): s.append(input()) S=[] while len(s)>0: a=0 for i in range(n-a): if s[i]==min(s): S.append(s[i]) del s[i] break a+=1 print(S)
s270107076
Accepted
17
3,060
112
n,l=map(int,input().split( )) s=[] for i in range(n): s.append(input()) print(''.join(sorted(s)))
s307658417
p02295
u072053884
1,000
131,072
Wrong Answer
30
7,652
759
For given two segments s1 and s2, print the coordinate of the cross point of them. s1 is formed by end points p0 and p1, and s2 is formed by end points p2 and p3.
def cross(c1, c2): return c1.real * c2.imag - c1.imag * c2.real def print_cross_point(p1, p2, p3, p4): # p1 and p2 are end points of a segment. # p3 and p4 are end points of the other segment. base = p4 - p3 hypo1 = p1 - p3 hypo2 = p2 - p3 d1 = abs(cross(base, hypo1)) / abs(base) d2 = abs(cross(base, hypo2)) / abs(base) cp = p1 + d1 / (d1 + d2) * (p2 - p1) print("{0:.10f}, {1:.10f}".format(cp.real, cp.imag)) import sys file_input = sys.stdin sq = file_input.readline() for line in file_input: x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3 = map(int, line.split()) p0 = x_p0 + y_p0 * 1j p1 = x_p1 + y_p1 * 1j p2 = x_p2 + y_p2 * 1j p3 = x_p3 + y_p3 * 1j print_cross_point(p0, p1, p2, p3)
s750174703
Accepted
30
7,784
758
def cross(c1, c2): return c1.real * c2.imag - c1.imag * c2.real def print_cross_point(p1, p2, p3, p4): # p1 and p2 are end points of a segment. # p3 and p4 are end points of the other segment. base = p4 - p3 hypo1 = p1 - p3 hypo2 = p2 - p3 d1 = abs(cross(base, hypo1)) / abs(base) d2 = abs(cross(base, hypo2)) / abs(base) cp = p1 + d1 / (d1 + d2) * (p2 - p1) print("{0:.10f} {1:.10f}".format(cp.real, cp.imag)) import sys file_input = sys.stdin sq = file_input.readline() for line in file_input: x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3 = map(int, line.split()) p0 = x_p0 + y_p0 * 1j p1 = x_p1 + y_p1 * 1j p2 = x_p2 + y_p2 * 1j p3 = x_p3 + y_p3 * 1j print_cross_point(p0, p1, p2, p3)
s650800154
p03729
u864900001
2,000
262,144
Wrong Answer
17
2,940
123
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
#60 a, b, c = map(str, input().split()) if(a[len(a)-1]==b[0] and b[len(b)-1]==c[0]): print("Yes") else: print("No")
s884332820
Accepted
17
2,940
123
#60 a, b, c = map(str, input().split()) if(a[len(a)-1]==b[0] and b[len(b)-1]==c[0]): print("YES") else: print("NO")
s792027548
p03943
u169221932
2,000
262,144
Wrong Answer
17
3,060
247
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
a,b,c = (int(x) for x in input().split()) candy = [a, b, c] #print(candy) candy.sort() print(candy) max_candy = candy[2] middle_candy = candy[1] min_candy = candy[0] if max_candy == middle_candy + min_candy: print('Yes') else: print('No')
s081918631
Accepted
17
3,060
248
a,b,c = (int(x) for x in input().split()) candy = [a, b, c] #print(candy) candy.sort() #print(candy) max_candy = candy[2] middle_candy = candy[1] min_candy = candy[0] if max_candy == middle_candy + min_candy: print('Yes') else: print('No')
s275504622
p03591
u776189585
2,000
262,144
Wrong Answer
17
3,060
54
Ringo is giving a present to Snuke. Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`.
s = input() print('YES' if s[:4] == 'YAKI' else 'NO')
s917879367
Accepted
17
2,940
53
s = input() print('Yes' if s[:4] == 'YAKI' else 'No')
s288802737
p03385
u128914900
2,000
262,144
Wrong Answer
17
2,940
107
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=input() #sl=["a","b","c"] if s[0]!=s[1] and s[0]!=s[2] and s[2]!=s[2]: print("Yes") else: print("No")
s822828747
Accepted
17
2,940
107
s=input() #sl=["a","b","c"] if s[0]!=s[1] and s[0]!=s[2] and s[1]!=s[2]: print("Yes") else: print("No")
s251405461
p02398
u587193722
1,000
131,072
Wrong Answer
20
7,704
81
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
a, b, c = [int(i) for i in input().split()] bet = c - a ans = bet // b print(ans)
s492889485
Accepted
30
7,704
154
a, b, c = [int(i) for i in input().split()] nums = 0 for i in range(a, b + 1): if c%i == 0: nums = nums + 1 else: pass print(nums)
s472870374
p02742
u652583512
2,000
1,048,576
Wrong Answer
17
2,940
93
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:
H, W = map(int, input().split()) ans = H * W // 2 if H & 1 | W & 1: ans += 1 print(ans)
s701515433
Accepted
17
2,940
135
H, W = map(int, input().split()) ans = H * W // 2 if H == 1 or W == 1: ans = 1 elif (H & 1) and (W & 1): ans += 1 print(ans)
s198641027
p02833
u682271925
2,000
1,048,576
Wrong Answer
17
2,940
132
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
n = int(input()) size = len(str(n)) count = 0 i = 1 while 5 ** i <= n: a = 5 ** i b = n // a count += b i += 1 print(count)
s201427019
Accepted
17
2,940
87
n=int(input()) ans=0 if n%2==0: n//=2 while(n>0): n//=5 ans+=n print(ans)
s479421917
p03759
u130860429
2,000
262,144
Wrong Answer
17
3,060
110
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=input().split() a1=int(a) b1=int(b) c1=int(c) d=b1-a1 e=c1-b1 if d==e: print('yes') else : print('no')
s420818702
Accepted
17
3,060
110
a,b,c=input().split() a1=int(a) b1=int(b) c1=int(c) d=b1-a1 e=c1-b1 if d==e: print('YES') else : print('NO')
s888176680
p03547
u216631280
2,000
262,144
Wrong Answer
17
2,940
50
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?
li = list(input().split()) li.sort() print(li[-1])
s489001103
Accepted
18
2,940
141
li = list(input().split()) if li[0] == li[1]: print('=') else: liTemp = sorted(li) if liTemp[0] == li[0]: print('<') else: print('>')
s872314274
p03337
u144980750
2,000
1,048,576
Wrong Answer
18
2,940
65
You are given two integers A and B. Find the largest value among A+B, A-B and A \times B.
a,b=map(int,input().split()) c=[a-b,b-a,a*b] c.sort() print(c[2])
s027414798
Accepted
17
2,940
65
a,b=map(int,input().split()) c=[a+b,a-b,a*b] c.sort() print(c[2])
s557858242
p00354
u737311644
1,000
262,144
Wrong Answer
20
5,584
402
The 9th day of September 2017 is Saturday. Then, what day of the week is the X-th of September 2017? Given a day in September 2017, write a program to report what day of the week it is.
a=int(input()) if a==1 or a==8 or a==15 or a==22 or a==29: print("mon") if a==2 or a==9 or a==16 or a==23 or a==30: print("tue") if a==3 or a==10 or a==17 or a==24: print("wed") if a==4 or a==11 or a==18 or a==25: print("thu") if a==5 or a==12 or a==19 or a==26: print("fri") if a==6 or a==13 or a==20 or a==27: print("sat") if a==7 or a==14 or a==21 or a==28: print("sun")
s346440164
Accepted
20
5,592
211
a=int(input()) if a%7==1: print("fri") if a%7==2: print("sat") if a%7==3: print("sun") if a%7==4: print("mon") if a%7==5: print("tue") if a%7==6: print("wed") if a%7==0: print("thu")
s463951589
p04029
u997530672
2,000
262,144
Wrong Answer
17
2,940
65
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
n = int(input()) ans = 0 for i in range(n): ans += i print(ans)
s976804415
Accepted
17
2,940
67
n = int(input()) ans = 0 for i in range(n): ans += i+1 print(ans)
s127643324
p03377
u942868002
2,000
262,144
Wrong Answer
17
2,940
76
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()) print("Yes" if a<=x and (a+b)>=x else "No")
s154462933
Accepted
18
2,940
76
a,b,x = map(int,input().split()) print("YES" if a<=x and (a+b)>=x else "NO")
s574023086
p02600
u886571850
2,000
1,048,576
Wrong Answer
31
9,184
360
M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have?
a = int(input()) if 400 <= a and 599 <= a: print(8) elif 600 <= a and 799 <= a: print(7) elif 800 <= a and 999 <= a: print(6) elif 1000 <= a and 1199 <= a: print(5) elif 1200 <= a and 1399 <= a: print(4) elif 1400 <= a and 1599 <= a: print(3) elif 1600 <= a and 1799 <= a: print(2) elif 1800 <= a and 1999 <= a: print(1)
s458824088
Accepted
28
9,188
359
a = int(input()) if 400 <= a and a <= 599: print(8) elif 600 <= a and a <= 799: print(7) elif 800 <= a and a <= 999: print(6) elif 1000 <= a and a <= 1199: print(5) elif 1200 <= a and a <= 1399: print(4) elif 1400 <= a and a <= 1599: print(3) elif 1600 <= a and a <= 1799: print(2) elif 1800 <= a and a <= 1999: print(1)
s902367156
p03360
u978313283
2,000
262,144
Wrong Answer
17
2,940
84
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?
A,B,C=map(int,input().split()) K=int(input()) M=max(max(A,B),C) print(M**K+A+B+C-M)
s161107018
Accepted
17
2,940
88
A,B,C=map(int,input().split()) K=int(input()) M=max(max(A,B),C) print(M*(2**K)+A+B+C-M)
s979160912
p02401
u435158342
1,000
131,072
Wrong Answer
20
5,560
92
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
while True: a=input() if '?' in a: break eval('print({0})'.format(a))
s337259236
Accepted
20
5,556
137
ans=[] while True: a=input() if '?' in a: break eval('ans.append(int({0}))'.format(a)) for a in ans: print(a)