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
s642779924
p03605
u867826040
2,000
262,144
Wrong Answer
17
2,940
40
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?
print(["No","Yes"][int("7" in input())])
s765784199
Accepted
17
2,940
40
print(["No","Yes"][int("9" in input())])
s662557455
p03387
u743281086
2,000
262,144
Wrong Answer
17
2,940
104
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
ls = list(map(int, input().split())) ans = sum(ls) - max(ls) print(ans//2 if ans%2 == 0 else (ans+3)//2)
s885986968
Accepted
17
2,940
106
ls = list(map(int, input().split())) ans = max(ls)*3 - sum(ls) print(ans//2 if ans%2 == 0 else (ans+3)//2)
s558476375
p03759
u147571984
2,000
262,144
Wrong Answer
18
3,188
79
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()) print('%s' % 'Yes' if b-a == c-b else 'No')
s035210360
Accepted
17
2,940
79
a, b, c = map(int, input().split()) print('%s' % 'YES' if b-a == c-b else 'NO')
s995392318
p02238
u539803218
1,000
131,072
Wrong Answer
30
7,760
580
Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving the vertex from which $v$ was discovered. This process continues until all the vertices that are reachable from the original source vertex have been discovered. If any undiscovered vertices remain, then one of them is selected as a new source and the search is repeated from that source. DFS timestamps each vertex as follows: * $d[v]$ records when $v$ is first discovered. * $f[v]$ records when the search finishes examining $v$’s adjacency list. Write a program which reads a directed graph $G = (V, E)$ and demonstrates DFS on the graph based on the following rules: * $G$ is given in an adjacency-list. Vertices are identified by IDs $1, 2,... n$ respectively. * IDs in the adjacency list are arranged in ascending order. * The program should report the discover time and the finish time for each vertex. * When there are several candidates to visit during DFS, the algorithm should select the vertex with the smallest ID. * The timestamp starts with 1.
graph={} num = int(input()) Adj = [[0 for i in range(num)] for i in range(num)] for i in range(num): l = list(map(int,input().split())) graph[str(l[0])]=l[2:] color = [0] * num d = [0] * num f = [0] * num t = 0 def dfs(u): global t color[u - 1] = 1 t += 1 d[u - 1] = t for i in range(1, num+1): if Adj[u - 1][i - 1] == 1 and color[i - 1] == 0: dfs(i) color[u - 1] = 2 t += 1 f[u - 1] = t for i in range(1, num+1): if color[i-1] == 0: dfs(i) for i in range(num): print("{} {} {}".format(i+1,d[i],f[i]))
s735292327
Accepted
30
7,748
542
# coding: utf-8 def depth(i, adj, Dep, Arr, times): if Dep[i-1]: return times Dep[i-1]=times times+=1 # t=[depth(j, adj, Dep, f, times) j in adj[i-1]] for j in adj[i-1]: times=depth(j, adj, Dep, Arr, times) Arr[i - 1]=times times+=1 return times n=int(input()) adj=[list(map(int, input().split()))[2:] for i in range(n)] d,f=[0]*n,[0]*n t=1 dlist=[i for i in range(n) if d[i]==0] for i in dlist: t = depth(i + 1, adj, d, f, t) for i, df in enumerate(zip(d, f)): print(i + 1, *df)
s518305215
p03476
u201660334
2,000
262,144
Time Limit Exceeded
2,106
37,632
695
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
Q = int(input()) a = [] for i in range(Q): a.append(list(map(int, input().split()))) number_list = [] for i in range(1,100000): number_list.append(i+1) number_list_set = set(number_list) prime_number_list = [] while True: try: prime_number_list.append(min(number_list_set)) synthesis_number = {x for x in number_list if x % min(number_list_set) == 0} number_list_set = number_list_set - synthesis_number except: break for i in range(Q): like_2017 = [] for j in range(a[i][0], a[i][1] + 1, 2): if (j in prime_number_list) and (int((j + 1) / 2) in prime_number_list): like_2017.append(j) print(len(like_2017))
s021654500
Accepted
484
10,644
621
def prime(n): p = [] flag = [True] * (n - 1) for i in range(n - 1): if flag[i] == True: p.append(i + 2) num = i while num <= n - 2: flag[num] = False num += i + 2 return set(p) p1 = prime(10 ** 5) p2 = [0] for i in range(10 ** 5): if i % 2 == 1: p2.append(p2[-1]) continue else: if i + 1 in p1 and (i + 2) // 2 in p1: p2.append(p2[-1] + 1) else: p2.append(p2[-1]) q = int(input()) for i in range(q): l, r = map(int, input().split()) print(p2[r] - p2[l -1])
s123042720
p03449
u772180901
2,000
262,144
Wrong Answer
18
3,064
297
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()) ans = 0 tmp = 0 arr = [ list(map(int,input().split())) for i in range(2)] for i in range(n): if i == 0: tmp += arr[0][0] else: tmp += sum(arr[0][:i+1]) tmp += sum(arr[1][i:n]) print(i,n-i) if ans < tmp: ans = tmp tmp = 0 print(ans)
s421232994
Accepted
18
3,064
280
n = int(input()) ans = 0 tmp = 0 arr = [ list(map(int,input().split())) for i in range(2)] for i in range(n): if i == 0: tmp += arr[0][0] else: tmp += sum(arr[0][:i+1]) tmp += sum(arr[1][i:n]) if ans < tmp: ans = tmp tmp = 0 print(ans)
s080368177
p03860
u646336933
2,000
262,144
Wrong Answer
17
2,940
28
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.
print("A"+(input())[0]+"C")
s874423371
Accepted
17
2,940
49
s = input().split() t = s[1] print("A"+t[0]+"C")
s665604286
p02694
u083874202
2,000
1,048,576
Wrong Answer
22
9,168
513
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?
import math I = int(input()) #N, M = map(int, input().split()) #N = input() #list = list(N) #list = list(map(int, input().split())) X = 100 cnt = 0 while(X <= I): X = math.floor(X * 1.01) cnt += 1 print(cnt)
s870682470
Accepted
20
9,096
542
import math I = int(input()) #N, M = map(int, input().split()) #N = input() #list = list(N) #list = list(map(int, input().split())) X = 100 cnt = 0 while(X < I): X = math.floor(X * 1.01) cnt += 1 if I <= 100: cnt = 0 print(cnt)
s906808625
p02600
u382740487
2,000
1,048,576
Wrong Answer
30
8,868
35
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?
num = input() print(type(num), num)
s015279254
Accepted
32
9,064
308
if __name__=="__main__": num = int(input()) if num < 400: pass elif num<600: print(8) elif num<800: print(7) elif num<1000: print(6) elif num<1200: print(5) elif num<1400: print(4) elif num<1600: print(3) elif num<1800: print(2) elif num<2000: print(1)
s582919070
p02393
u831971779
1,000
131,072
Wrong Answer
40
7,560
72
Write a program which reads three integers, and prints them in ascending order.
a,b,c = map(int,input().split()) list = [a,b,c] list.sort() print(list)
s756426881
Accepted
20
7,716
62
a,b,c = sorted([int(i) for i in input().split()]) print(a,b,c)
s802029223
p03998
u267300160
2,000
262,144
Time Limit Exceeded
2,104
3,064
500
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
A_cards = list(input()) B_cards = list(input()) C_cards = list(input()) who = "a" while(True): if(who == "a"): if(len(A_cards)==0): print("A") exit() else: who = A_cards[0] del A_cards[0] elif(who == "b"): if(len(B_cards)==0): print("B") exit() else: who = B_cards[0] del B_cards[0] else: if(len(C_cards)==0): print("C") exit()
s488215882
Accepted
17
3,064
583
A_cards = list(input()) B_cards = list(input()) C_cards = list(input()) who = "a" while(True): if(who == "a"): if(len(A_cards)==0): print("A") exit() else: who = A_cards[0] del A_cards[0] if(who == "b"): if(len(B_cards)==0): print("B") exit() else: who = B_cards[0] del B_cards[0] if(who == "c"): if(len(C_cards)==0): print("C") exit() else: who = C_cards[0] del C_cards[0]
s316516747
p03547
u330176731
2,000
262,144
Wrong Answer
17
3,060
98
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 min(x,y) == x: print('>') elif min(x,y) == y: print('<') else: print('=')
s941369726
Accepted
17
3,060
105
x,y = input().split() if x == y: print('=') elif min(x,y) == x: print('<') elif min(x,y) == y: print('>')
s548467243
p02389
u069789944
1,000
131,072
Wrong Answer
40
6,720
72
Write a program which calculates the area and perimeter of a given rectangle.
a_b = input().split(' ') a = int(a_b[0]) b = int(a_b[1]) print(a * b)
s003412291
Accepted
30
6,720
64
s,n=map(int,input().split()) print("{} {}".format(s*n, (s+n)*2))
s950091922
p03434
u143903328
2,000
262,144
Wrong Answer
18
3,060
215
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 = list(map(int,input().split())) alice = 0 bob = 0 a.sort() a.reverse() for i in range (0,n): if i % 2: bob += a[i] else: alice += a[i] print(alice - bob) print(a)
s983819240
Accepted
17
3,060
203
n = int(input()) a = list(map(int,input().split())) alice = 0 bob = 0 a.sort() a.reverse() for i in range (0,n): if i % 2: bob += a[i] else: alice += a[i] print(alice - bob)
s570689533
p03090
u844902298
2,000
1,048,576
Wrong Answer
25
3,700
251
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
n = int(input()) a = [[0]*(n+1) for i in range(n+1)] np = (n//2)*2 for i in range(0,np//2): a[i+1][np-i] = -1 for i in range(1,n+1): for j in range(i+1,n+1): if a[i][j] == -1: continue else: print(i,j)
s563037062
Accepted
24
3,700
281
n = int(input()) a = [[0]*(n+1) for i in range(n+1)] np = (n//2)*2 for i in range(0,np//2): a[i+1][np-i] = -1 print(int(n*(n-1)/2-(n//2))) for i in range(1,n+1): for j in range(i+1,n+1): if a[i][j] == -1: continue else: print(i,j)
s588294133
p02409
u058433718
1,000
131,072
Wrong Answer
40
7,712
925
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
import sys def make_room_data(): room_data = [] for i in range(4): one_house = [] for j in range(3): one_floor = [] for k in range(10): one_floor.append(0) one_house.append(one_floor) room_data.append(one_house) return room_data def main(): room_data = make_room_data() n = int(sys.stdin.readline().strip()) for _ in range(n): data = sys.stdin.readline().strip().split(' ') b, f, r, v = [int(i) for i in data] room_data[b-1][f-1][r-1] += v for i in range(4): for j in range(3): for k in range(10): print(' %d' % (room_data[i][j][k]), end='') print('') if i != 3: print('*' * 20) if __name__ == '__main__': main()
s555194189
Accepted
30
7,748
925
import sys def make_room_data(): room_data = [] for i in range(4): one_house = [] for j in range(3): one_floor = [] for k in range(10): one_floor.append(0) one_house.append(one_floor) room_data.append(one_house) return room_data def main(): room_data = make_room_data() n = int(sys.stdin.readline().strip()) for _ in range(n): data = sys.stdin.readline().strip().split(' ') b, f, r, v = [int(i) for i in data] room_data[b-1][f-1][r-1] += v for i in range(4): for j in range(3): for k in range(10): print(' %d' % (room_data[i][j][k]), end='') print('') if i != 3: print('#' * 20) if __name__ == '__main__': main()
s019364953
p03501
u504715104
2,000
262,144
Wrong Answer
17
2,940
65
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.
moji=[] moji=input().split() max_1=min(moji) print(max_1)
s919024606
Accepted
17
2,940
236
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Oct 18 17:04:29 2017 @author: goto """ int1,int2,int3=map(int, input().split()) t=int1*int2 if t<int3: minmoji=t else: minmoji=int3 print(minmoji)
s449018688
p03434
u556657484
2,000
262,144
Wrong Answer
17
2,940
91
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 = sorted(map(int, input().split())) print(sum(A[0::2]) - sum(A[1::2]))
s178679544
Accepted
17
2,940
105
N = int(input()) A = sorted(map(int, input().split()), reverse=True) print(sum(A[0::2]) - sum(A[1::2]))
s113354916
p03455
u178317679
2,000
262,144
Wrong Answer
17
2,940
93
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
def calc(a, b): if (a * b) % 2 == 0: print('Even') else: print('Odd')
s704513422
Accepted
17
2,940
90
a, b = map(int, input().split()) if a*b % 2 == 0: print("Even") else: print("Odd")
s302359765
p02613
u690419532
2,000
1,048,576
Wrong Answer
150
16,280
260
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()) l = [] for i in range(N): l.append(input()) AC = l.count('AC') WA = l.count('WA') TLE = l.count('TLE') RE = l.count('RE') print("AC × {}".format(AC)) print("WA × {}".format(WA)) print("TLE × {}".format(TLE)) print("RE × {}".format(RE))
s134733814
Accepted
148
9,116
340
N = int(input()) AC = 0 WA = 0 TLE = 0 RE = 0 for i in range(N): test = input() if test == 'AC': AC += 1 elif test == 'WA': WA += 1 elif test == 'TLE': TLE += 1 else: RE += 1 print('AC x {}'.format(AC)) print('WA x {}'.format(WA)) print('TLE x {}'.format(TLE)) print('RE x {}'.format(RE))
s450518910
p02842
u285443936
2,000
1,048,576
Wrong Answer
34
3,060
142
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
import math N = int(input()) for i in range(50001): if math.floor(i*1.08) == N: print(math.floor(i*1.08)) exit() else: print(":(")
s503721283
Accepted
33
3,060
127
import math N = int(input()) for i in range(1,50001): if math.floor(i*1.08) == N: print(i) exit() else: print(":(")
s384623115
p03448
u256106029
2,000
262,144
Wrong Answer
52
3,060
266
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()) count = 0 for i in range(a): for j in range(b): for k in range(c): total = 500 * i + 100 * j + 50 * k if total == x: count += 1 print(count)
s099063138
Accepted
55
3,064
278
a = int(input()) b = int(input()) c = int(input()) x = int(input()) count = 0 for i in range(a + 1): for j in range(b + 1): for k in range(c + 1): total = 500 * i + 100 * j + 50 * k if total == x: count += 1 print(count)
s076000868
p03386
u849229491
2,000
262,144
Wrong Answer
17
3,060
185
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()) ans = [] for i in range(k): t1 = a+i t2 = b-i ans.append(t1) ans.append(t2) A = list(set(ans)) for i in range(len(A)): print(A[i])
s431352586
Accepted
17
3,064
265
import sys a,b,k = map(int,input().split()) ans = [] if k > b-a: for i in range(a,b+1): print(i) sys.exit() for i in range(k): t1 = a+i t2 = b-i ans.append(t1) ans.append(t2) A = list(set(ans)) A.sort() for i in A: print(i)
s983613509
p03643
u366959492
2,000
262,144
Wrong Answer
17
2,940
29
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=str(input()) print("ABC",n)
s034829564
Accepted
17
2,940
25
n=input() print("ABC"+n)
s953420471
p02422
u130834228
1,000
131,072
Wrong Answer
30
7,700
389
Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
str1 = list(input()) q = int(input()) for i in range(q): order = [str(x) for x in input().split()] if order[0] == 'replace': str1[int(order[1]):int(order[2])+1] = list(order[3]) print(str1) elif order[0] == 'reverse': str2 = str1[int(order[1]):int(order[2])+1] str1[int(order[1]):int(order[2])+1] = reversed(str2) else: #print print(str1[int(order[1]):int(order[2])+1])
s704152050
Accepted
20
7,792
399
str1 = list(input()) q = int(input()) for i in range(q): order = [str(x) for x in input().split()] if order[0] == 'replace': str1[int(order[1]):int(order[2])+1] = list(order[3]) #print(str1) elif order[0] == 'reverse': str2 = str1[int(order[1]):int(order[2])+1] str1[int(order[1]):int(order[2])+1] = reversed(str2) else: #print print(*str1[int(order[1]):int(order[2])+1], sep='')
s862838134
p02608
u503111914
2,000
1,048,576
Time Limit Exceeded
2,206
8,960
217
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()) for l in range(1,N+1): ans = 0 for i in range(1,101): for j in range(1,101): for k in range(1,101): f = i*i+j*j+k*k+i*j+j*k+k*i if f == l: ans += 1 print(ans)
s549271072
Accepted
503
9,308
231
N = int(input()) ans = [0 for _ in range(10050)] for i in range(1,105): for j in range(1,105): for k in range(1,105): v = i*i+j*j+k*k+i*j+j*k+k*i; if v<10050: ans[v]+=1 for l in range(N): print(ans[l+1])
s216612864
p02842
u721425712
2,000
1,048,576
Wrong Answer
17
2,940
102
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
n = int(input()) import math x = math.ceil(n/1.08) if x == n*1.08: print(x) else: print(':(')
s115281695
Accepted
17
3,060
108
n = int(input()) import math x = math.ceil(n/1.08) if n == math.floor(x*1.08): print(x) else: print(':(')
s796684936
p03385
u121732701
2,000
262,144
Wrong Answer
17
2,940
93
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(input()) A = ["a","b","c"] if set(S) == A: print("Yes") else: print("No")
s943309008
Accepted
17
2,940
90
S = input() if "a" in S and "b" in S and "c" in S: print("Yes") else: print("No")
s158370212
p03693
u669382434
2,000
262,144
Wrong Answer
18
2,940
96
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=[int(i) for i in input().split()] if 100*r+10*g+b%4==0: print("YES") else: print("NO")
s782446478
Accepted
17
2,940
98
r,g,b=[int(i) for i in input().split()] if (100*r+10*g+b)%4==0: print("YES") else: print("NO")
s780127279
p03476
u001769145
2,000
262,144
Wrong Answer
229
27,060
425
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
# 69 import itertools q = int(input()) lr_l = [[int(x) for x in input().split()] for y in range(q)] n_max = max(itertools.chain.from_iterable(lr_l)) isp_l = [True] * (n_max+1) isp_l[0] = False isp_l[1] = False for i in range(2, int(n_max ** 0.5 + 2)): if not isp_l[i]: continue for j in range(i * 2, n_max + 1, i): isp_l[j] = False p_l = [int(x) for x in range(n_max+1) if isp_l[x]] print(p_l)
s792042672
Accepted
1,205
27,268
651
# 69 import itertools import bisect q = int(input()) lr_l = [[int(x) for x in input().split()] for y in range(q)] n_max = max(itertools.chain.from_iterable(lr_l)) isp_l = [True] * (n_max+1) isp_l[0] = False isp_l[1] = False for i in range(2, int(n_max ** 0.5 + 2)): if not isp_l[i]: continue for j in range(i * 2, n_max + 1, i): isp_l[j] = False p_l = [int(x) for x in range(n_max+1) if isp_l[x]] l_l = [] for i in range(len(p_l)): if (p_l[i]+1)//2 in p_l: l_l.append(p_l[i]) for i in range(q): _l,_r = lr_l[i] _s = bisect.bisect_left(l_l, _l) _e = bisect.bisect_right(l_l, _r) print(_e-_s)
s480457504
p04011
u370429695
2,000
262,144
Wrong Answer
17
2,940
136
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
total = int(input()) limit = int(input()) first = int(input()) second = int(input()) print(limit * first + (total - limit + 1) * second)
s991408434
Accepted
17
2,940
181
total = int(input()) limit = int(input()) first = int(input()) second = int(input()) if total > limit: print(limit * first + (total - limit) * second) else: print(total * first)
s835040128
p03623
u869265610
2,000
262,144
Wrong Answer
17
2,940
71
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|.
a,b,c=map(int,input().split()) print("A" if abs(a-b)>abs(a-c) else "B")
s136055409
Accepted
18
2,940
72
a,b,c=map(int,input().split()) print("A" if abs(a-b)<abs(a-c) else "B")
s202941085
p03853
u011062360
2,000
262,144
Wrong Answer
24
3,828
155
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
h, w = map(int, input().split()) list_score = [ list(input()) for _ in range(h) ] for l in list_score: print(*l) for l in list_score: print(*l)
s711000156
Accepted
18
3,060
143
h, w = map(int, input().split()) list_score = [ input() for _ in range(h) ] for l in list_score: print("".join(l)) print("".join(l))
s214795889
p04043
u886902015
2,000
262,144
Wrong Answer
27
9,068
116
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.
li=a,b,c=list(map(int,input().split())) if li.count(7)==2 and li.count(5)==1: print("YES") else: print("NO")
s414424552
Accepted
25
8,980
117
li=a,b,c=list(map(int,input().split())) if li.count(7)==1 and li.count(5)==2: print("YES") else: print("NO")
s970006215
p03911
u952165951
2,000
262,144
Wrong Answer
491
61,116
253
On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M. For _CODE FESTIVAL 20XX_ held on this planet, N participants gathered from all over the planet. The i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}. Two participants A and B can _communicate_ with each other if and only if one of the following conditions is satisfied: * There exists a language that both A and B can speak. * There exists a participant X that both A and B can communicate with. Determine whether all N participants can communicate with all other participants.
from numpy import* from scipy.sparse import* (n,m),*p=[map(int,o.split())for o in open(0)] e,*f=array([(i,j+n-1,1)for i,q in enumerate(p)for j in list(q)[1:]]).T[:3] print("YNEOS"[1in csgraph.connected_components(csr_matrix(((e,f)),[n+m]*2))[1][:n]::2])
s927475137
Accepted
249
29,476
1,198
#!/usr/bin/env python3 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 size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) (n, m), *LL = [[*map(int,o.split())] for o in open(0)] UF = UnionFind(n + m) for e, (k, *L) in enumerate(LL): for l in L: UF.union(e, l + n - 1) print("YES" if len([*filter(lambda i: i < n, UF.roots())]) == 1 else "NO")
s039480809
p03192
u255499778
2,000
1,048,576
Wrong Answer
17
2,940
48
You are given an integer N that has exactly four digits in base ten. How many times does `2` occur in the base-ten representation of N?
n = list(map(int, input())) print(n.count("2"))
s346737033
Accepted
18
2,940
37
n = list(input()) print(n.count("2"))
s659222114
p02409
u669360983
1,000
131,072
Wrong Answer
30
6,716
338
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
import sys n=int(input()) data={} for i in range(1,5): for j in range(1,4): for k in range(1,11): data[(i,j,k)]=0 for i in range(1,n+1): b,r,f,v=map(int,input().split()) data[(b,r,f)]+=v for i in range(1,5): for j in range(1,4): for k in range(1,11): sys.stdout.write(str(data[(i,j,k)])+' ') print('') print('#'*20)
s737060818
Accepted
30
6,724
348
import sys n=int(input()) data={} for i in range(1,5): for j in range(1,4): for k in range(1,11): data[(i,j,k)]=0 for i in range(1,n+1): b,r,f,v=map(int,input().split()) data[(b,r,f)]+=v for i in range(1,5): for j in range(1,4): for k in range(1,11): sys.stdout.write(' '+str(data[(i,j,k)])) print('') if i<4: print('#'*20)
s220748387
p02854
u469953228
2,000
1,048,576
Wrong Answer
101
26,764
177
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length.
n=int(input()) A=list(map(int,input().split())) L=sum(A) l=0 for i in range(n): l+=A[i] if l >= L/2: r=l-A[i] break print(l,r) print(min(abs((L-r)-r),abs((L-l)-l)))
s714174082
Accepted
102
26,764
166
n=int(input()) A=list(map(int,input().split())) L=sum(A) l=0 for i in range(n): l+=A[i] if l >= L/2: r=l-A[i] break print(min(abs((L-r)-r),abs((L-l)-l)))
s949451000
p02842
u353548710
2,000
1,048,576
Wrong Answer
26
9,168
208
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
import math n = int(input()) x = n/1.08 x1, x2 = math.floor( x ), math.ceil( x ) print(x1, x2) if n == math.floor( x1 * 1.08 ) : print(x1) elif n == math.floor( x2 * 1.08 ): print(x2) else: print(':(')
s643922755
Accepted
26
9,036
194
import math n = int(input()) x = n/1.08 x1, x2 = math.floor( x ), math.ceil( x ) if n == math.floor( x1 * 1.08 ) : print(x1) elif n == math.floor( x2 * 1.08 ): print(x2) else: print(':(')
s879327354
p03416
u587213169
2,000
262,144
Wrong Answer
76
2,940
157
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.
a, b =map(int, input().split()) count=0 for i in range(a,b): m = list(str(i)) if m[0]==m[3]: if m[1]==m[2]: count+=1 print(count)
s434924208
Accepted
77
2,940
159
a, b =map(int, input().split()) count=0 for i in range(a,b+1): m = list(str(i)) if m[0]==m[4]: if m[1]==m[3]: count+=1 print(count)
s563417314
p02261
u935329231
1,000
131,072
Wrong Answer
20
7,832
1,416
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 bubble_sort(cards, num): for left in range(num-1): for right in range(left+1, num): if cards[right][1] < cards[left][1]: cards[left], cards[right] = cards[right], cards[left] print(list_to_str(cards)) def selection_sort(cards, num): for head in range(num): min_i = head for target in range(head+1, num): if cards[target][1] < cards[min_i][1]: min_i = target cards[head], cards[min_i] = cards[min_i], cards[head] print(list_to_str(cards)) def is_stable(before, after, num): for i in range(num): for j in range(i+1, num): for a in range(num): for b in range(a+1, num): if before[i][1] == before[j][1]\ and before[i] == after[b]\ and before[j] == after[a]: print('Not stable') print('Stable') def list_to_str(l, delimiter=' '): # The default delimiter is one space. return delimiter.join([str(v) for v in l]) if __name__ == '__main__': num = int(input()) cards = input().split() cards_for_bubble = cards.copy() cards_for_selection = cards.copy() bubble_sort(cards_for_bubble, num) is_stable(cards, cards_for_bubble, num) selection_sort(cards_for_selection, num) is_stable(cards, cards_for_selection, num)
s938324727
Accepted
120
7,856
1,462
# -*- coding: utf-8 -*- def bubble_sort(cards, num): for tail in range(num-1, 0, -1): for right in range(0, tail): left = right + 1 if cards[left][1] < cards[right][1]: cards[right], cards[left] = cards[left], cards[right] print(list_to_str(cards)) def selection_sort(cards, num): for head in range(num): min_i = head for target in range(head+1, num): if cards[target][1] < cards[min_i][1]: min_i = target cards[head], cards[min_i] = cards[min_i], cards[head] print(list_to_str(cards)) def is_stable(before, after, num): for i in range(num): for j in range(i+1, num): for a in range(num): for b in range(a+1, num): if before[i][1] == before[j][1]\ and before[i] == after[b]\ and before[j] == after[a]: return 'Not stable' return 'Stable' def list_to_str(l, delimiter=' '): # The default delimiter is one space. return delimiter.join([str(v) for v in l]) if __name__ == '__main__': num = int(input()) cards = input().split() cards_for_bubble = cards.copy() cards_for_selection = cards.copy() bubble_sort(cards_for_bubble, num) print(is_stable(cards, cards_for_bubble, num)) selection_sort(cards_for_selection, num) print(is_stable(cards, cards_for_selection, num))
s854833401
p03997
u295961023
2,000
262,144
Wrong Answer
17
2,940
135
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.
def main(): a, b, h = [int(input()) for _ in range(3)] s = (a + b) * h / 2 print(s) if __name__ == "__main__": main()
s225332016
Accepted
17
2,940
140
def main(): a, b, h = [int(input()) for _ in range(3)] s = (a + b) * h / 2 print(int(s)) if __name__ == "__main__": main()
s530008718
p03385
u243159381
2,000
262,144
Wrong Answer
28
9,008
69
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() if sorted(s)=='abc': print('Yes') else: print('No')
s350065729
Accepted
26
9,064
78
s=input() if ''.join(sorted(s))=='abc': print('Yes') else: print('No')
s092572033
p03457
u381068238
2,000
262,144
Wrong Answer
337
3,064
669
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.
_ = int(input()) bef_time = 0 bef_x = 0 bef_y = 0 ans = True for i in range(_): next = input().split() next_time = int(next[0]) next_x = int(next[1]) next_y = int(next[2]) range = abs((next_x - bef_x) + (next_y - bef_y)) if (next_time - bef_time) >= range: if (next_time - bef_time) % 2 == 0: if range % 2 != 0: ans = False break else: if range % 2 == 0: ans = False break else: ans = False break bef_time = next_time bef_y = next_y bef_x = next_x if ans == True: print('YES') else: print('NO')
s777548413
Accepted
352
3,064
645
_ = int(input()) bef_time = 0 bef_x = 0 bef_y = 0 ans = True for i in range(_): next = input().split() next_time = int(next[0]) next_x = int(next[1]) next_y = int(next[2]) time = next_time - bef_time range = abs(next_x - bef_x) + abs(next_y - bef_y) if (next_time - bef_time) < range: ans = False break if time % 2 == 0: if range % 2 != 0: ans = False break else: if range % 2 == 0 or range == 0: ans = False break bef_time = next_time bef_y = next_y bef_x = next_x if ans == True: print('Yes') else: print('No')
s192414133
p03227
u310466455
2,000
1,048,576
Wrong Answer
17
2,940
83
You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.
a = input() if len(a) == 2: print(a) else: new_str = ''.join(list(reversed(a)))
s277583418
Accepted
17
2,940
100
a = input() if len(a) == 2: print(a) else: new_str = ''.join(list(reversed(a))) print(new_str)
s390509534
p03719
u732491892
2,000
262,144
Wrong Answer
17
2,940
90
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(' ')) print("YES") if c >= a and c <= b else print("NO")
s977337334
Accepted
17
2,940
90
a, b, c = map(int, input().split(' ')) print("Yes") if c >= a and c <= b else print("No")
s328310560
p02393
u302561071
1,000
131,072
Wrong Answer
20
7,328
94
Write a program which reads three integers, and prints them in ascending order.
data = input().split() data.sort print(str(data[0]) + " " + str(data[1]) + " " + str(data[2]))
s514526649
Accepted
20
7,452
96
data = input().split() data.sort() print(str(data[0]) + " " + str(data[1]) + " " + str(data[2]))
s512105099
p03795
u821251381
2,000
262,144
Wrong Answer
17
2,940
36
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 = int(input()) print(N*800-N//15)
s611977038
Accepted
17
2,940
41
N = int(input()) print(N*800-N//15 *200)
s588873035
p02694
u740267532
2,000
1,048,576
Wrong Answer
25
9,180
127
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()) a, b = 100, 1 while 1: a += a * 0.01 if a >= X: print(b) break b += 1 print(a)
s775754891
Accepted
22
9,168
119
X = int(input()) a, b = 100, 1 while 1: a += int(a * 0.01) if a >= X: print(b) break b += 1
s827406079
p03494
u288786530
2,000
262,144
Wrong Answer
17
2,940
199
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.
l = list() n = int(input()) original_list = list(range(1,n)) for x in original_list: ans = 0 while x % 2 == 0: x = x / 2 ans = ans + 1 l.append(ans) print(max(l))
s554088204
Accepted
19
2,940
147
n = int(input()) a = list(map(int, input().split())) l = [] for i in a: s = 0 while i % 2 == 0: i = i/2 s += 1 l.append(s) print(min(l))
s349849200
p03694
u744898490
2,000
262,144
Wrong Answer
17
2,940
89
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.
a= input().split(' ') a = [int(x) for x in a] mi = min(a) ma = max(a) print(int(ma- mi))
s604729391
Accepted
17
2,940
101
w = input() a= input().split(' ') a = [int(x) for x in a] mi = min(a) ma = max(a) print(int(ma- mi))
s784227664
p03658
u518064858
2,000
262,144
Wrong Answer
17
2,940
118
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
n,k=map(int,input().split()) l=sorted(list(map(int,input().split())),reverse=True) s=0 for i in range(k): s+=l[i]
s798487151
Accepted
18
2,940
129
n,k=map(int,input().split()) l=sorted(list(map(int,input().split())),reverse=True) s=0 for i in range(k): s+=l[i] print(s)
s974045464
p03449
u918601425
2,000
262,144
Wrong Answer
18
2,940
184
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()) lsa=[int(s) for s in input().split()] lsb=[int(s) for s in input().split()] ls=[lsa[0]+max(lsb)] for i in range(1,N): ls.append(ls[-1]+lsa[i]-lsb[i-1]) print(max(ls))
s839427238
Accepted
17
2,940
184
N=int(input()) lsa=[int(s) for s in input().split()] lsb=[int(s) for s in input().split()] ls=[lsa[0]+sum(lsb)] for i in range(1,N): ls.append(ls[-1]+lsa[i]-lsb[i-1]) print(max(ls))
s979605742
p03644
u212328220
2,000
262,144
Wrong Answer
26
9,028
82
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
n = int(input()) x = 1 cnt = 1 while x < n: x = 2 ** cnt cnt += 1 print(x)
s754855450
Accepted
28
9,028
83
n = int(input()) x = 1 cnt = 1 while x <= n: x = 2 ** cnt cnt += 1 print(x//2)
s291570959
p03777
u045408189
2,000
262,144
Wrong Answer
17
2,940
100
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or Dishonest_. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`, AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that TopCoDeer is dishonest. Given this information, determine whether TopCoDeer is honest.
a,b=input().split() if a=='H': print('b') else: if b=='H': print('D') else: print('H')
s973665733
Accepted
17
2,940
99
a,b=input().split() if a=='H': print(b) else: if b=='H': print('D') else: print('H')
s717366316
p03494
u879870653
2,000
262,144
Wrong Answer
18
3,064
399
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.
N = int(input()) A = list(map(int,input().split())) B = [] answer = 0 for i in range(N) : if A[i] % 2 == 0 : B.append(A[i]) if len(B) == 0 : print(1) else : for i in range(N) : ans = 0 for j in range(1,10) : if A[i] % 2**j == 0 : ans += 1 else : answer = max(answer,ans) break print(answer)
s671382675
Accepted
18
3,060
261
N = int(input()) A = list(map(int,input().split())) P = [2**i for i in range(30)] P = sorted(P,reverse = True) ans = 100 for i in range(N) : for j in range(len(P)) : if A[i] % P[j] == 0 : ans = min(ans,29-j) break print(ans)
s721074057
p02612
u598684283
2,000
1,048,576
Wrong Answer
30
9,040
74
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.
input1 = int(input()) while input1 > 999: input1 -= 1000 print(input1)
s622389053
Accepted
30
9,044
82
input1 = int(input()) while input1 > 1000: input1 -= 1000 print(1000 - input1)
s015956762
p03434
u698919163
2,000
262,144
Wrong Answer
17
3,060
215
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 = list(map(int,input().split())) a.sort(reverse=True) print(a) Alice = 0 Bob = 0 for i in range(N): if i%2 == 0: Alice += a[i] else: Bob += a[i] print(Alice-Bob)
s048811078
Accepted
18
3,060
206
N = int(input()) a = list(map(int,input().split())) a.sort(reverse=True) Alice = 0 Bob = 0 for i in range(N): if i%2 == 0: Alice += a[i] else: Bob += a[i] print(Alice-Bob)
s979224619
p02694
u021849254
2,000
1,048,576
Wrong Answer
30
9,008
67
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?
a=int(input()) c=100 x=0 while c<=a: c=c+c//100 x=x+1 print(x)
s204679178
Accepted
31
8,996
66
a=int(input()) c=100 x=0 while c<a: c=c+c//100 x=x+1 print(x)
s771717192
p03401
u988402778
2,000
262,144
Wrong Answer
243
13,920
618
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(int(i) for i in input().split()) sum = 0 for k in range(N): if k == 0: sum += abs(a[k]) elif k == (N-1): sum += abs(a[k]) print(k) print(sum) else: sum += abs(a[k] - a[k-1]) print(sum) for j in range(N): if j == 0: if (a[j+1] - a[j]) * (a[j] -0) > 0: print(sum) else: print(sum - 2 * abs(a[j])) elif j == N-1: if (a[j] - a[j-1]) * (0 - a[j]) > 0: print(sum) else: print(sum - 2 * abs(a[j])) else: if (a[j] - a[j-1] ) * (a[j+1] - a[j]) > 0: print(sum) else: print(sum - 2 * abs(a[j]))
s867939389
Accepted
279
13,928
670
N = int(input()) a = list(int(i) for i in input().split()) sum = 0 for k in range(N): if k == 0: sum += abs(a[k]) elif k == (N-1): sum += abs(a[k] - a[k-1]) + abs(a[k]) else: sum += abs(a[k] - a[k-1]) for j in range(N): if j == 0: if (a[j+1] - a[j]) * (a[j] -0) >= 0: print(sum) else: print(sum - 2 * min(abs(a[j]),abs(a[j]-a[j+1]))) elif j == N-1: if (a[j] - a[j-1]) * (0 - a[j]) >= 0: print(sum) else: print(sum - 2 * min(abs(a[j]-a[j-1]),abs(a[j]))) else: if (a[j] - a[j-1] ) * (a[j+1] - a[j]) >= 0: print(sum) else: print(sum - 2 * min(abs(a[j]-a[j-1]),abs(a[j+1]-a[j])))
s184093003
p02399
u606989659
1,000
131,072
Wrong Answer
20
7,504
89
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 = map(int,input().split()) d = a / b r = a % b f = float(a) / float(b) print(d, r, f)
s328653823
Accepted
20
7,588
100
a,b = map(int,input().split()) d = a // b r = a % b f = a / b print('{0} {1} {2:.5f}'.format(d,r,f))
s078224962
p00077
u075836834
1,000
131,072
Wrong Answer
50
7,548
276
文字列が連続した場合、ある規則で文字を置き換え文字列を短くすることができます。たとえば、AAAA という文字列の場合、@4A と表現すれば 1 文字分圧縮されます。この規則で圧縮された文字列を入力してもとの文字列に復元するプログラムを作成してください。ただし、復元した文字列に@文字は出現しないものとします。 また、原文の文字列は英大文字、英小文字、数字、記号であり 100 文字以内、連続する文字は 9 文字以内です。
while True: try: line=list(map(str,input())) string="" for i in range(len(line)): if (line[i]!='@' and line[i-1]!='@'): string+=line[i] elif line[i]=='@': string+=line[i+2]*int(line[i+1]) else: pass print(string) except EOFError: break
s980554386
Accepted
30
7,592
295
while True: try: line=list(map(str,input())) string="" for i in range(len(line)): if (line[i]!='@' and line[i-1]!='@' and line[i-2]!='@'): string+=line[i] elif line[i]=='@': string+=line[i+2]*int(line[i+1]) else: pass print(string) except EOFError: break
s058770699
p03759
u187516587
2,000
262,144
Wrong Answer
17
2,940
106
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.
l=input().split() a,b,c=int(l[0]),int(l[1]),int(l[2]) if a-b==b-c: print("Yes") else: print("No")
s204273192
Accepted
17
2,940
106
l=input().split() a,b,c=int(l[0]),int(l[1]),int(l[2]) if a-b==b-c: print("YES") else: print("NO")
s795198105
p03564
u319818856
2,000
262,144
Wrong Answer
18
3,060
537
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
def addition_and_multiplication(N: int, K: int)->int: min_d = float('inf') for i in range(1 << N): d = 1 for _ in range(N): if i & 1: d = d * 2 else: d = d + K min_d = min(d, min_d) return min_d if __name__ == "__main__": N = int(input()) K = int(input()) ans = addition_and_multiplication(N, K) print(ans)
s793328508
Accepted
19
3,060
557
def addition_and_multiplication(N: int, K: int)->int: min_d = float('inf') for i in range(1 << N): d = 1 for _ in range(N): if i & 1: d = d * 2 else: d = d + K i >>= 1 min_d = min(d, min_d) return min_d if __name__ == "__main__": N = int(input()) K = int(input()) ans = addition_and_multiplication(N, K) print(ans)
s847284050
p02613
u486074261
2,000
1,048,576
Wrong Answer
59
23,072
238
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 sys import stdin n, *s = (x.rstrip() for x in stdin.readlines()) ac = s.count('AC') wa = s.count('WA') tle = s.count('TLE') re = s.count('RE') print(f'AC × {ac}') print(f'WA × {wa}') print(f'TLE × {tle}') print(f'RE × {re}')
s006625136
Accepted
57
23,128
234
from sys import stdin n, *s = (x.rstrip() for x in stdin.readlines()) ac = s.count('AC') wa = s.count('WA') tle = s.count('TLE') re = s.count('RE') print(f'AC x {ac}') print(f'WA x {wa}') print(f'TLE x {tle}') print(f'RE x {re}')
s253399842
p03379
u253952966
2,000
262,144
Wrong Answer
310
25,624
212
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()) an = list(map(int, input().split())) an.sort() a, b = an[n//2-1:n//2+1] if a == b: for _ in range(n): print(n) else: for ai in an: if ai <= a: print(b) else: print(a)
s422575252
Accepted
304
26,180
222
n = int(input()) xn = list(map(int, input().split())) xsort = sorted(xn) a, b = xsort[n//2-1:n//2+1] if a == b: for _ in range(n): print(a) else: for x in xn: if x <= a: print(b) else: print(a)
s506426211
p03698
u644907318
2,000
262,144
Wrong Answer
18
2,940
78
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
if len(set(list(input().strip())))==26: print("yes") else: print("no")
s726489720
Accepted
17
2,940
94
S = input().strip() n = len(S) if len(set(list(S)))==n: print("yes") else: print("no")
s966249965
p02747
u277920185
2,000
1,048,576
Wrong Answer
18
2,940
76
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.
s=input() s.replace('hi', '') if s == '': print('Yes') else: print('No')
s896228912
Accepted
17
2,940
81
s=input() x=len(s) // 2 a=x*'hi' if a == s: print('Yes') else: print('No')
s388561476
p03693
u737321654
2,000
262,144
Wrong Answer
17
2,940
121
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?
x = list(map(int, input().split())) num = x[0] + x[1] + x[2] if int(num) % 4 == 0: print('YES') else: print('No')
s819960501
Accepted
17
2,940
106
x = input().split() num = x[0] + x[1] + x[2] if int(num) % 4 == 0: print('YES') else: print('NO')
s112205933
p03194
u636311816
2,000
1,048,576
Wrong Answer
17
2,940
68
There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P. Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
n,p= map(int,input().split()) if n==1: print(p) else :print(1)
s137870419
Accepted
312
2,940
119
n,p= map(int,input().split()) for i in range(round(p**(1/n)),0,-1): if p%(i**n)==0: print(i) exit()
s680109881
p03623
u266171694
2,000
262,144
Wrong Answer
17
2,940
96
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()) if abs(x - a) > abs(x - b): print("A") else: print("B")
s024651712
Accepted
18
2,940
96
x, a, b = map(int, input().split()) if abs(x - a) > abs(x - b): print("B") else: print("A")
s923668605
p02409
u201482750
1,000
131,072
Wrong Answer
20
5,628
386
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
n=int(input()) room=[[[ 0 for i in range(10)] for j in range(3)] for k in range(4)] for i in range(n) : b,f,r,v=map(int,input().split()) room[b-1][f-1][r-1]+=v for i in range(4) : for j in range(3) : for k in range(10) : print(" {}".format(room[i][j][k]),end="") print("") if i!=3 : for l in range(20) : print("#",end="")
s477002314
Accepted
20
5,628
409
room=[ [ [ 0 for k in range(10) ] for j in range(3) ] for i in range(4)] n=int(input()) for i in range(n) : b,f,r,v=map(int,input().split()) room[b-1][f-1][r-1]+=v for i in range(4) : for j in range(3) : for k in range(10) : print(" {}".format(room[i][j][k]),end="") print("") if i!=3 : for l in range(20) : print("#",end="") print("")
s676701095
p03386
u370331385
2,000
262,144
Wrong Answer
2,104
26,704
280
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()) ans = [] if(K <= A-B+1): for i in range(A,A+K): ans.append(i) for j in range(B-K+1,B+1): ans.append(j) ans = set(ans) ans = list(ans) ans.sort() for i in range(len(ans)): print(ans[i]) else: for i in range(A,B+1): print(i)
s664205655
Accepted
18
3,060
250
A,B,K = map(int,input().split()) ans = [] for i in range(A,A+K): if(A<= i<= B): ans.append(i) for j in range(B-K+1,B+1): if(A<= j<= B): ans .append(j) ans = set(ans) ans = list(ans) ans.sort() for i in range(len(ans)): print(ans[i])
s979781744
p04025
u703890795
2,000
262,144
Wrong Answer
25
3,316
165
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
N = int(input()) A = list(map(int, input().split())) s = 0 m = 100000000 for j in range(-100,101): for i in range(N): s += (A[i]-j)**2 m = min(m, s) print(m)
s549332313
Accepted
25
2,940
173
N = int(input()) A = list(map(int, input().split())) s = 0 m = 100000000 for j in range(-100,101): for i in range(N): s += (A[i]-j)**2 m = min(m, s) s = 0 print(m)
s649120913
p02647
u470560351
2,000
1,048,576
Wrong Answer
2,206
51,588
335
We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i. Each bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row: * For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i. Find the intensity of each bulb after the K operations.
import numpy as np N,K = map(int, input().split()) A =list(map(int, input().split())) ans = np.array(A, np.int8) for i in range(K): k = np.array([0]*N, np.int8) for n in range(N): k[max(0, n - ans[n]):min(N, n + ans[n])+1] += 1 ans = k for i in ans: print(min(i, N))
s044906316
Accepted
892
125,032
378
import numpy as np from numba import njit N,K = map(int, input().split()) A = np.array(list(map(int, input().split()))) @njit def main(N, K, A): for _ in range(min(K, 42)): A_ = np.zeros_like(A) for n in range(N): A_[max(0, n - A[n])] += 1 if n + A[n] + 1 < N: A_[n + A[n] + 1] -= 1 A = A_.cumsum() return A print(*main(N, K, A))
s736528728
p00050
u990228206
1,000
131,072
Wrong Answer
20
5,552
329
福島県は果物の産地としても有名で、その中でも特に桃とりんごは全国でも指折りの生産量を誇っています。ところで、ある販売用の英文パンフレットの印刷原稿を作ったところ、手違いでりんごに関する記述と桃に関する記述を逆に書いてしまいました。 あなたは、apple と peach を修正する仕事を任されましたが、なにぶん面倒です。1行の英文を入力して、そのなかの apple という文字列を全て peach に、peach という文字列を全てapple に交換した英文を出力するプログラムを作成してください。
w=str(input()) print(len(w)) for i in range(len(w)): if i>len(w):break if w[i]=="a" and w[i+1]=="p" and w[i+2]=="p" and w[i+3]=="l" and w[i+4]=="e": w=w[:i]+"peach"+w[i+5:] continue if w[i]=="p" and w[i+1]=="e" and w[i+2]=="a" and w[i+3]=="c" and w[i+4]=="h": w=w[:i]+"apple"+w[i+5:] print(w)
s361441134
Accepted
20
5,556
315
w=str(input()) for i in range(len(w)): if i>len(w):break if w[i]=="a" and w[i+1]=="p" and w[i+2]=="p" and w[i+3]=="l" and w[i+4]=="e": w=w[:i]+"peach"+w[i+5:] continue if w[i]=="p" and w[i+1]=="e" and w[i+2]=="a" and w[i+3]=="c" and w[i+4]=="h": w=w[:i]+"apple"+w[i+5:] print(w)
s307937579
p03485
u274907892
2,000
262,144
Wrong Answer
17
2,940
59
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(float, input().split()) print(round((a+b)/2, 0))
s895201203
Accepted
17
2,940
77
import math a, b = map(float, input().split()) print(int(math.ceil((a+b)/2)))
s407101120
p03623
u357751375
2,000
262,144
Wrong Answer
17
3,060
257
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|.
s = list(input()) s = set(s) s = sorted(s) m = 'abcdefghijklmnopqrstuvwxyz' for i in range(len(m)): if s[i] != m[i]: print(m[i]) exit(0) if i + 1 != len(m) and i + 1 == len(s): print(m[i + 1]) exit(0) print('None')
s606295237
Accepted
17
2,940
97
x,a,b = map(int,input().split()) if abs(x - a) > abs(x - b): print('B') else: print('A')
s172777091
p03854
u441253420
2,000
262,144
Wrong Answer
20
3,188
162
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() Mozi = ["dreamer","eraser","dream","erase"] for i in Mozi: T = S.replace(i,"X") S = T if S not in "X": print("No") else: print("Yes")
s113525391
Accepted
19
3,188
156
S = input() Mozi = ["resare","esare","remaerd","maerd"] S = S[::-1] for i in Mozi: S = S.replace(i,"") if not S: print("YES") else: print("NO")
s733894968
p03659
u026102659
2,000
262,144
Wrong Answer
145
24,952
322
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.
import sys input = sys.stdin.readline N = int(input()) nums = list(map(int, input().split())) s = sum(nums) x = 0 y = 0 for i in range(N): a = nums[i] if x + a <= s//2: x += a else: y = x + a break print(x) if x == 0: x = nums[0] if y == s: y = 0 print(min(s-2*x, 2*y-2))
s246800830
Accepted
208
23,780
260
import sys input = sys.stdin.readline n = int(input()) A = list(map(int, input().split())) x = 0 s = sum(A) ab = -1 for i in range(n-1): a = A[i] x += a if ab == -1: ab = abs(s - 2*x) else: ab = min(ab, abs(s - 2*x)) print(ab)
s016782334
p03024
u691018832
2,000
1,048,576
Wrong Answer
17
2,940
153
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
# sys.stdin.readline() import sys input = sys.stdin.readline s = input() if 15-len(s)+s.count('o') >= 8: ans = 'YES' else: ans = 'NO' print(ans)
s330967918
Accepted
17
2,940
91
s = input() if 15-len(s)+s.count('o') >= 8: ans = 'YES' else: ans = 'NO' print(ans)
s476085695
p03251
u190406011
2,000
1,048,576
Wrong Answer
18
3,064
312
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
N, M, X, Y = [int(i) for i in input().split()] x_ls = [int(i) for i in input().split()] y_ls = [int(i) for i in input().split()] max_x = max(x_ls) min_y = min(y_ls) flg = 0 for z in range(int(X + 0.00001), int(Y)): if max_x < z <= min_y: flg = 1 if flg > 0: print("War") else: print("No War")
s132030479
Accepted
18
3,064
335
import math N, M, X, Y = [int(i) for i in input().split()] x_ls = [int(i) for i in input().split()] y_ls = [int(i) for i in input().split()] max_x = max(x_ls) min_y = min(y_ls) flg = 0 for z in range(int(math.ceil(X + 0.00001)), int(Y)): if max_x < z <= min_y: flg = 1 if flg > 0: print("No War") else: print("War")
s647697359
p03860
u294385082
2,000
262,144
Wrong Answer
17
2,940
28
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("A"+s+"C")
s824089841
Accepted
17
2,940
33
st = input() print("A"+st[8]+"C")
s409028822
p03860
u865826312
2,000
262,144
Wrong Answer
17
2,940
41
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.
a,b,c=input().split() print("a"+b[0]+"c")
s298326898
Accepted
17
2,940
43
a,b,c=input().split() print(a[0]+b[0]+c[0])
s643170399
p03860
u665598835
2,000
262,144
Wrong Answer
17
2,940
47
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().split(" ") print([i[0] for i in S])
s450074413
Accepted
17
2,940
56
S = input().split(" ") print("".join([i[0] for i in S]))
s582209181
p02608
u185948224
2,000
1,048,576
Wrong Answer
106
9,452
262
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]*(N+1) for i in range(1, int(N**0.5)+1): for j in range(1, 101 - i): for k in range(1, 101 - i - j): f = i*i + j*j + k*k +i*j + j*k + k*i if f <= N: ans[f] += 1 print(*ans, sep='\n')
s418496941
Accepted
453
9,528
274
N = int(input()) ans = [0]*(N+1) for i in range(1, int(N**0.5)+1): for j in range(1, int(N**0.5)+2): for k in range(1, int(N**0.5)+2): f = i*i + j*j + k*k +i*j + j*k + k*i if f <= N: ans[f] += 1 print(*ans[1:], sep='\n')
s485491323
p03457
u858523893
2,000
262,144
Wrong Answer
388
11,840
509
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()) t, x, y = [], [], [] for i in range(N) : _t, _x, _y = map(int, input().split()) t.append(_t) x.append(_x) y.append(_y) cur_x, cur_y = 0, 0 cur_t = 0 flg_impossible = "YES" for i in range(N) : dloc = (x[i] - cur_x) + (y[i] - cur_y) dt = t[i] - cur_t if ((dloc % 2 == 0 and dt % 2 == 0) or (dloc % 2 != 0 and dt % 2 != 0)) and dloc <= dt : cur_x, cur_y, cur_t = x[i], y[i], t[i] else : flg_impossible = "NO" print(flg_impossible)
s408934656
Accepted
410
11,728
551
N = int(input()) t, x, y = [], [], [] for i in range(N) : _t, _x, _y = map(int, input().split()) t.append(_t) x.append(_x) y.append(_y) cur_x = 0 cur_y = 0 cur_time = 0 flg_possible = True for i in range(N) : min_dist = abs(x[i] - cur_x) + abs(y[i] - cur_y) if min_dist > t[i] or not((t[i] - cur_time) % 2 == min_dist % 2): print("No") flg_possible = False break else : cur_x, cur_y, cur_time = x[i], y[i], t[i] if flg_possible == True : print("Yes")
s724934407
p03456
u551109821
2,000
262,144
Wrong Answer
17
2,940
125
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,b = map(int,input().split()) for i in range(100): if int(a+b) == i**2: print('Yes') exit() print('No')
s434713932
Accepted
82
2,940
130
a,b = map(str,input().split()) for i in range(1,100100): if int(a+b) == i**2: print('Yes') exit() print('No')
s007265677
p02975
u326744360
2,000
1,048,576
Wrong Answer
2,108
64,436
393
Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No`. * The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself. What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non- negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.
a = [input() for i in range(2)] N = int(a[0]) data = a[1].split(' ') data = [int(i) for i in data] result = [] for i in range(N): for j in range(N): if i <= j: continue result.append(data[i] ^ data[j]) sorted_data = data.sort() sorted_result = result.sort() if sorted_data == sorted_result: print('Yes') print('No')
s915231055
Accepted
61
14,980
223
a = [input() for i in range(2)] N = int(a[0]) data = a[1].split(' ') data = [int(i) for i in data] result = [] a = 0 for i in range(N): a = a ^ data[i] if a == 0: print('Yes') exit() print('No')
s769496278
p03400
u172823566
2,000
262,144
Wrong Answer
19
3,316
308
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
N = int(input()) D, X = map(int, input().split()) a_list = list(map(int, [input() for i in range(N)])) counter = 0 for a in a_list: counter += 1 base = 1 for i in range(1, D): base = (i * a + 1) print(base) if base <= D: counter += 1 else: break counter += X print(counter)
s192800369
Accepted
18
3,064
292
N = int(input()) D, X = map(int, input().split()) a_list = list(map(int, [input() for i in range(N)])) counter = 0 for a in a_list: counter += 1 base = 1 for i in range(1, D): base = (i * a + 1) if base <= D: counter += 1 else: break counter += X print(counter)
s688084366
p03130
u930480241
2,000
1,048,576
Wrong Answer
17
2,940
202
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.
array = [0] * 4 for i in range(3): thisData = list(map(int, input().split())) for j in thisData: array[j - 1] += 1 print(array) if max(array) == 3: print("NO") else: print("YES")
s197116669
Accepted
17
2,940
190
array = [0] * 4 for i in range(3): thisData = list(map(int, input().split())) for j in thisData: array[j - 1] += 1 if max(array) == 3: print("NO") else: print("YES")
s182171460
p03456
u940516059
2,000
262,144
Wrong Answer
17
3,060
160
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,b = [int(x) for x in input().split()] s = str(a) + str(b) for n in range(1, 101): if int(s) % n*n ==0: print("Yes") else: print("No")
s290228612
Accepted
18
2,940
154
import math a,b = [int(x) for x in input().split()] s = str(a) + str(b) if math.sqrt(int(s)).is_integer() == True: print("Yes") else: print("No")
s344886511
p02260
u148477094
1,000
131,072
Wrong Answer
20
5,596
220
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.
n=int(input()) a=list(map(int,input().split())) b=0 for i in a: minj=i for j in range(i,n-1): if a[minj]>a[j]: a[minj],a[j]=a[j],a[minj] minj=j b+=1 print(*a) print(b)
s490647033
Accepted
20
5,604
233
n=int(input()) a=list(map(int,input().split())) b=0 for i in range(n): minj=i for j in range(i,n): if a[minj]>a[j]: minj=j if i!=minj: a[i],a[minj]=a[minj],a[i] b+=1 print(*a) print(b)
s975443200
p03612
u343675824
2,000
262,144
Wrong Answer
68
10,612
148
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two **adjacent** elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
N = int(input()) A = map(int, input().split()) ans = -1 for i, a in enumerate(A): if a == i+1: ans += 1 ans = max((ans, 0)) print(ans)
s199611765
Accepted
80
14,008
237
N = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(N-1): if i < N-1 and a[i] == i+1: ans += 1 a[i], a[i+1] = a[i+1], a[i] if a[-1] == N: ans += 1 a[-1], a[-2] = a[-2], a[-1] print(ans)
s966178447
p04043
u697386253
2,000
262,144
Wrong Answer
17
2,940
115
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 = list(map(int, input().split())) if a.count(5) == 2 and a.count(7) == 1: print('Yes') else: print('No')
s616484020
Accepted
17
2,940
115
a = list(map(int, input().split())) if a.count(5) == 2 and a.count(7) == 1: print('YES') else: print('NO')
s403870273
p03386
u701318346
2,000
262,144
Wrong Answer
2,190
1,464,484
135
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()) S = list(i for i in range(A, B + 1)) S = S[:K] + S[-K:] ans = list(set(S)) for i in ans: print(i)
s540562601
Accepted
17
3,060
202
A, B, K = map(int, input().split()) S1 = [i for i in range(A, min(A + K, B + 1))] S2 = [i for i in range(max(A, B - K + 1),B + 1)] S = list(set(S1 + S2)) S.sort() for i in range(len(S)): print(S[i])
s104305521
p03592
u170183831
2,000
262,144
Wrong Answer
407
3,060
237
We have a grid with N rows and M columns of squares. Initially, all the squares are white. There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa. When a button attached to a column is pressed, the colors of all the squares in that column are inverted. Takahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.
n, m, k = map(int, input().split()) exists = False for i in range(n): for j in range(m): if (i + 1) * m + (j + 1) * n - (i + 1) * (j + 1) == k: exists = True break if exists: break print('Yes' if exists else 'No')
s053214948
Accepted
342
3,060
225
n, m, k = map(int, input().split()) exists = False for i in range(n + 1): for j in range(m + 1): if i * m + j * n - 2 * i * j == k: exists = True break if exists: break print('Yes' if exists else 'No')
s007682528
p02742
u992622610
2,000
1,048,576
Wrong Answer
17
2,940
109
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()) if H * W % 2 == 0: print( (H * W) /2 ) else: print((H * W) / 2 + 1)
s607753378
Accepted
18
3,188
181
import math H,W = map(int, input().split()) if H == 1 or W == 1: print(1) elif H * W % 2 == 0: print( math.floor((H * W) /2 )) else: print(math.floor((H * W) / 2) + 1)
s731231225
p03719
u591287669
2,000
262,144
Wrong Answer
17
2,940
86
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")
s138371740
Accepted
17
2,940
86
a,b,c=map(int,input().split()) if a <= c <= b: print("Yes") else: print("No")
s725086407
p04011
u357751375
2,000
262,144
Wrong Answer
31
3,316
332
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
N = input() K = input() X = input() Y = input() S = 1 while S <= int(K): print(str(S)+'泊目は'+X+'円') S = S + 1 while S <= int(N): print(str(S)+'泊目は'+Y+'円') S = S + 1
s039302921
Accepted
24
3,060
573
N = input() K = input() X = input() Y = input() S = 1 P = 0 if int(N) >= int(K): while S <= int(K): P = P + int(X) S = S + 1 while S <= int(N): P = P + int(Y) S = S + 1 else : while S <= int(N): P = P + int(X) S = S + 1 print(P)