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
s646435010
p02831
u121176629
2,000
1,048,576
Wrong Answer
2,104
3,060
159
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests.
A,B=map(int,input().split()) cnt = max(A,B) for cnt in range(max(A,B),A*B) : if cnt%A == 0 and cnt%B == 0: break else: cnt == cnt +1 print(cnt)
s097184215
Accepted
96
2,940
172
A,B=map(int,input().split()) cnt = 1 for cnt in range(1,A*B) : if cnt*min(A,B)%A == 0 and cnt*min(A,B)%B == 0: break else: cnt = cnt +1 print(cnt*min(A,B))
s656748883
p00015
u940190657
1,000
131,072
Wrong Answer
30
6,724
183
A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers. If given integers or the sum have more than 80 digits, print "overflow".
def main(): n = int(input()) for i in range(n): val1 = int(input()) val2 = int(input()) print(str(val1 + val2)) if __name__ == '__main__': main()
s856329787
Accepted
30
6,720
245
def main(): n = int(input()) for i in range(n): result = str(int(input()) + int(input())) if len(result) > 80: print("overflow") else: print(result) if __name__ == '__main__': main()
s830888096
p03997
u088488125
2,000
262,144
Wrong Answer
23
9,016
61
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a=int(input()) b=int(input()) h=int(input()) print((a+b)*h/2)
s596638321
Accepted
25
9,092
71
a=int(input()) b=int(input()) h=int(input()) print(round(((a+b)*h)/2))
s547788303
p04044
u896004073
2,000
262,144
Wrong Answer
25
9,084
78
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
N, L, *inputs = input().split() inputs.sort() "".join(inputs) print(inputs);
s433644184
Accepted
30
9,200
119
N, L = input().split() inputs = [input() for i in range(int(N))] inputs.sort() result = "".join(inputs) print(result)
s491662040
p03795
u393086221
2,000
262,144
Wrong Answer
18
2,940
45
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(int(n*800-(n/15)*200))
s919431076
Accepted
17
2,940
46
n = int(input()) print(int(n*800-(n//15)*200))
s229539125
p03719
u721970149
2,000
262,144
Wrong Answer
17
2,940
198
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")
s957988088
Accepted
18
2,940
198
a, b, c = map(int, input().split()) if a <= c <= b : print("Yes") else : print("No")
s414308397
p03565
u732870425
2,000
262,144
Wrong Answer
17
3,064
399
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
s = input() T = input() slen = len(s) Tlen = len(T) ans = "UNRESTORABLE" if slen >= Tlen: for i in range(slen - Tlen + 1)[::-1]: for j in range(Tlen): if not s[i+j] in ("?", T[j]): break else: ans = s ans = ans[:i] + T + ans[i+Tlen:] ans = ans.replace("?", "a") print(ans) break print(ans)
s908877112
Accepted
18
3,064
441
S = input() T = input() flag = False def dfs(x, y): if y >= len(T): global flag flag = True return elif not S[x] in (T[y], '?'): return dfs(x+1, y+1) ans = "UNRESTORABLE" for i in range(len(S) - len(T) + 1)[::-1]: if S[i] in (T[0], '?'): dfs(i, 0) if flag: ans = S[:i] + T + S[i+len(T):] ans = ans.replace('?', 'a') break print(ans)
s313557276
p02238
u564398841
1,000
131,072
Wrong Answer
30
7,668
1,285
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.
def dfs(u, node_info, matrix): colors = [0] * len(matrix) detect_time = [0] * len(matrix) finished_time = [0] * len(matrix) time = 1 stack = list() stack.append(u) colors[u] = 1 detect_time[u] = time while len(stack): for i, val in enumerate(matrix[u]): if val == 1 and colors[i] == 0: time += 1 print('stack: ', i) stack.append(i) colors[i] = 1 detect_time[i] = time u = i break else: time += 1 e = stack.pop() colors[e] = 2 finished_time[e] = time if len(stack): u = stack[-1] for i in range(len(matrix)): print('{} {} {}'.format(i + 1, detect_time[i], finished_time[i])) if __name__ == '__main__': N = int(input()) matrix = [[0] * N for _ in range(N)] color = [0] * N for i in matrix: node_info = [int(i) for i in input().split()] node_i = node_info[0] - 1 if not node_info[1] == 0: for i in node_info[2:]: matrix[node_i][i - 1] = 1 for line in matrix: print(line) dfs(0, None, matrix)
s677210436
Accepted
20
7,876
1,466
def dfs(u, colors, matrix, time, detect_time, finished_time): colors = colors detect_time = detect_time finished_time = finished_time time = time + 1 stack = list() stack.append(u) colors[u] = 1 detect_time[u] = time while len(stack): for i, val in enumerate(matrix[u]): if val == 1 and colors[i] == 0: time += 1 stack.append(i) colors[i] = 1 detect_time[i] = time u = i break else: time += 1 e = stack.pop() colors[e] = 2 finished_time[e] = time if len(stack): u = stack[-1] return time if __name__ == '__main__': N = int(input()) matrix = [[0] * N for _ in range(N)] color = [0] * N for i in matrix: node_info = [int(i) for i in input().split()] node_i = node_info[0] - 1 if not node_info[1] == 0: for i in node_info[2:]: matrix[node_i][i - 1] = 1 colors = [0] * len(matrix) detect_time = [0] * len(matrix) finished_time = [0] * len(matrix) time = 0 for i, val in enumerate(colors): if val == 0: time = dfs(i, colors, matrix, time, detect_time, finished_time) for i in range(len(matrix)): print('{} {} {}'.format(i + 1, detect_time[i], finished_time[i]))
s222849498
p03610
u098613858
2,000
262,144
Wrong Answer
49
3,952
54
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.
s = input() for i in range(0, len(s), 2): print(s[i])
s678750263
Accepted
67
4,596
72
s = input() for i in range(0, len(s), 2): print(s[i], end = '') print()
s069650584
p03827
u117193815
2,000
262,144
Wrong Answer
17
3,064
129
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
n=int(input()) s=list(input()) ans=0 for i in range(n): if s[i]=="I": ans+=1 else: ans-=1 print(ans)
s353560000
Accepted
17
3,060
181
n=int(input()) s=list(input()) ans=0 l=[0,] for i in range(n): if s[i]=="I": ans+=1 l.append(ans) else: ans-=1 l.append(ans) print(max(l))
s364118797
p03673
u437638594
2,000
262,144
Wrong Answer
2,105
26,180
121
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()) a = list(map(int, input().split())) b = [] for i in range(n): b.append(a[i]) b.reverse() print(b)
s793013412
Accepted
152
32,964
283
from collections import deque ans = deque() n = int(input()) al = list(map(int,input().split())) r = True for i in al: if r: r = False ans.append(i) else: r = True ans.appendleft(i) s = [str(i) for i in ans] if len(al) % 2 == 1: s.reverse() print(' '.join(s))
s217199587
p03693
u980492406
2,000
262,144
Wrong Answer
17
2,940
113
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
r,g,b = map(int,input().split()) a = r * 100 + g * 10 + b if a % 4 == 0 : print('Yes') else : print('No')
s822686748
Accepted
17
2,940
126
r,g,b = (int(i) for i in input().split()) r *= 100 g *= 10 if (r + g + b) % 4 == 0 : print('YES') else : print('NO')
s560189214
p02255
u297744593
1,000
131,072
Wrong Answer
30
7,628
303
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.
# 3.2 # input N = int(input()) a = list(map(int, input().split())) for i in range(1, N): tmp = a[i] j = i - 1 while j >= 0 and a[j] > tmp: a[j + 1] = a[j] j -= 1 a[j + 1] = tmp print(' '.join(map(str, a)))
s944767807
Accepted
20
7,640
331
# 3.2 # input N = int(input()) a = list(map(int, input().split())) print(" ".join(map(str, a))) for i in range(1, N): tmp = a[i] j = i - 1 while j >= 0 and a[j] > tmp: a[j + 1] = a[j] j -= 1 a[j + 1] = tmp print(" ".join(map(str, a)))
s232693228
p03674
u392319141
2,000
262,144
Wrong Answer
818
31,116
888
You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n. It is known that each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.
N = int(input()) A = list(map(int, input().split())) MOD = 10**9 + 7 fact = [1 for _ in range(N + 10)] invFact = [1 for _ in range(N + 10)] def modInv(a, MOD=1000000007): b = MOD u = 1 v = 0 while b : t = a // b a -= t * b u -= t * v a, b = b, a u, v = v, u u = u % MOD return u for i in range(1, N + 10): fact[i] = (fact[i - 1] * i) % MOD invFact[i] = modInv(fact[i]) index = [[] for _ in range(N + 1)] for i, a in enumerate(A): index[a].append(i) left = 0 right = 0 for count in index: if len(count) == 2: left = min(count) right = max(count) def comb(n, r): if n < r: return 1 return (fact[n] * invFact[r] % MOD) * invFact[n - r] % MOD les = left + N - right - 1 for k in range(1, N + 1): ans = comb(N + 1, k) - comb(les, k - 1) print(ans % MOD) print('1')
s001184796
Accepted
401
32,424
1,255
from collections import Counter class Combination: def __init__(self, size): self.size = size + 2 self.fact = [1, 1] + [0] * size self.factInv = [1, 1] + [0] * size self.inv = [0, 1] + [0] * size for i in range(2, self.size): self.fact[i] = self.fact[i - 1] * i % MOD self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD def npr(self, n, r): if n < r or n < 0 or r < 0: return 0 return self.fact[n] * self.factInv[n - r] % MOD def ncr(self, n, r): if n < r or n < 0 or r < 0: return 0 return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD def nhr(self, n, r): return self.ncr(n + r - 1, n - 1) N = int(input()) A = list(map(int, input().split())) MOD = 10**9 + 7 comb = Combination(N + 100) cntA = Counter(A) X = [a for a, c in cntA.items() if c == 2][0] l, r = [i for i, a in enumerate(A) if a == X] ans = [N] for leng in range(2, N + 2): M = comb.ncr(N + 1, leng) L = l + (N - r) D = comb.ncr(L, leng - 1) ans.append((M - D) % MOD) print(*ans, sep='\n')
s311324335
p03160
u671976435
2,000
1,048,576
Wrong Answer
138
20,476
414
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
def jumpCost(array): size = len(array) memo = [99999999999] * (size) memo[0] = 0 for i in range(size): j = i+1 while j < i + 2 + 1 and j < size: memo[j] = min(memo[j], memo[i] + abs(array[i] - array[j])) j += 1 return memo[size - 1] if __name__ == '__main__': n = int(input()) a = list(map(int, input().rstrip().split())) jumpCost(a)
s804435071
Accepted
138
20,460
430
def jumpCost(array): size = len(array) memo = [99999999999] * (size) memo[0] = 0 for i in range(size): j = i+1 while j < i + 2 + 1 and j < size: memo[j] = min(memo[j], memo[i] + abs(array[i] - array[j])) j += 1 return memo[size - 1] if __name__ == '__main__': n = int(input()) a = list(map(int, input().rstrip().split())) print(jumpCost(a))
s934808974
p03455
u007764502
2,000
262,144
Wrong Answer
18
2,940
90
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a,b = map(int, input().split()) if (a * b) % 2 == 0: print("Odd") else: print("Even")
s468242561
Accepted
17
2,940
90
a,b = map(int, input().split()) if (a * b) % 2 == 0: print("Even") else: print("Odd")
s184446897
p03162
u152072388
2,000
1,048,576
Wrong Answer
2,108
21,188
515
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
# -*- coding: utf-8 -*- import numpy as np def fnSolv(): iNum = int(input()) naABC = np.zeros((iNum, 3), dtype = int) naDP = [0]*3 #naDP = [10**9, 10**9, 10**9] for iI in range(iNum): naABC[iI] = list(map(int, input().split())) for iA, iB, iC in naABC: naDPa = max([naDP[1] + iA, naDP[2] + iA]) naDPb = max([naDP[2] + iB, naDP[0] + iB]) naDPc = max([naDP[0] + iC, naDP[1] + iC]) naDP = [naDPa, naDPb, naDPc] print(naDP) print(max(naDP)) if __name__ == '__main__': fnSolv()
s691538526
Accepted
1,052
16,456
517
# -*- coding: utf-8 -*- import numpy as np def fnSolv(): iNum = int(input()) naABC = np.zeros((iNum, 3), dtype = int) naDP = [0]*3 #naDP = [10**9, 10**9, 10**9] for iI in range(iNum): naABC[iI] = list(map(int, input().split())) for iA, iB, iC in naABC: naDPa = max([naDP[1] + iA, naDP[2] + iA]) naDPb = max([naDP[2] + iB, naDP[0] + iB]) naDPc = max([naDP[0] + iC, naDP[1] + iC]) naDP = [naDPa, naDPb, naDPc] #print(naDP) print(max(naDP)) if __name__ == '__main__': fnSolv()
s349704861
p03555
u432453907
2,000
262,144
Wrong Answer
27
8,924
122
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
C=[0,0] C[0]=list(map(str,input())) C[1]=list(map(str,input())) ans="No" X=C[0][::-1] if C[1]==X: ans="Yes" print(ans)
s892367564
Accepted
27
9,120
122
C=[0,0] C[0]=list(map(str,input())) C[1]=list(map(str,input())) ans="NO" X=C[0][::-1] if C[1]==X: ans="YES" print(ans)
s187845172
p03671
u255555420
2,000
262,144
Wrong Answer
17
2,940
122
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
S=input() s=S[0:-1] for i in range(len(s)-1,-1,-1): if s[0:i]==s[i:(2*i)]: print(2*i) break
s435061870
Accepted
17
2,940
58
a,b,c =map(int,input().split()) print(min(a+b, a+c, b+c))
s791414271
p03150
u371409687
2,000
1,048,576
Wrong Answer
17
3,064
287
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
s=str(input()) num=len(s)-7 ans="NO" if num==0: if s=="keyence": ans="YES" s=s+"!" s1="" s2=s[0:num] s3=s[num:] for _ in range(8): print(s1,s2,s3) if s1+s3=='keyence!': ans="YES" break s1=s1+s2[0] s2=s2[1:]+s3[0] s3=s3[1:] print(ans)
s344501870
Accepted
17
3,064
267
s=str(input()) num=len(s)-7 ans="NO" if num==0: if s=="keyence": ans="YES" s=s+"!" s1="" s2=s[0:num] s3=s[num:] for _ in range(8): if s1+s3=='keyence!': ans="YES" break s1=s1+s2[0] s2=s2[1:]+s3[0] s3=s3[1:] print(ans)
s982299891
p02396
u641357568
1,000
131,072
Wrong Answer
70
6,352
164
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
a = [] while True: n=input() if n == '0': break a.append(n) print(a) for i,j in zip(range(1,len(a)+1),a): print('Case {}: {}'.format(i,j))
s695428862
Accepted
130
5,564
130
count = 1 while True: i=input() if i == '0': break print('Case {}: {}'.format(count,i)) count = count + 1
s952350405
p03369
u057079894
2,000
262,144
Wrong Answer
17
2,940
73
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
s=input() co=0 for i in s: if s=='o': co+=1 print(700+co*100)
s718027779
Accepted
18
2,940
74
s=input() co=0 for i in s: if i=='o': co+=1 print(700+co*100)
s824838560
p02694
u673922428
2,000
1,048,576
Wrong Answer
23
9,160
201
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 X=int(input()) # a=int(input()) #A,B=map(int,input().split(" ")) #a=[int(_) for _ in input().split(" ")] i=0 t=100 while t <= X: t = math.floor(t * 1.01) i += 1 #print(a,b) print(i)
s893860150
Accepted
22
9,160
200
import math X=int(input()) # a=int(input()) #A,B=map(int,input().split(" ")) #a=[int(_) for _ in input().split(" ")] i=0 t=100 while t < X: t = math.floor(t * 1.01) i += 1 #print(a,b) print(i)
s200339539
p03695
u090406054
2,000
262,144
Wrong Answer
30
9,108
876
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users.
n=int(input()) a=list(map(int,input().split())) color_val=0 bigList=[] for i in range(1,400): if i in a: color_val+=1 break for s in range(400,800): if s in a: color_val+=1 break for t in range(800,1200): if t in a: color_val+=1 break for u in range(1200,1600): if u in a: color_val+=1 break for q in range(1600,2000): if q in a: color_val+=1 break for e in range(2000,2400): if e in a: color_val+=1 break for f in range(2400,2800): if f in a: color_val+=1 break for g in range(2800,3200): if g in a: color_val+=1 break for z in a: if z >=3200: bigList.append(z) if color_val<8: color_val+=len(bigList) if color_val>8: print(color_val-len(bigList),8) else: print(color_val-len(bigList),color_val) else: print(8,8) print(color_val) print(len(bigList))
s396086549
Accepted
31
9,124
751
n=int(input()) a=list(map(int,input().split())) color_val=0 bigList=[] for i in range(1,400): if i in a: color_val+=1 break for s in range(400,800): if s in a: color_val+=1 break for t in range(800,1200): if t in a: color_val+=1 break for u in range(1200,1600): if u in a: color_val+=1 break for q in range(1600,2000): if q in a: color_val+=1 break for e in range(2000,2400): if e in a: color_val+=1 break for f in range(2400,2800): if f in a: color_val+=1 break for g in range(2800,3200): if g in a: color_val+=1 break for z in a: if z >=3200: bigList.append(z) max=color_val+len(bigList) if color_val!=0: print(color_val,max) else: print(1,max)
s579081743
p03495
u845573105
2,000
262,144
Wrong Answer
106
32,184
232
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
N, K = map(int, input().split()) A = list(map(int, input().split())) B = [0 for i in range(N+1)] for a in A: B[a] += 1 nums = [b for b in B if b > 0] nums.sort() n = len(nums) if n <= K: print(0) else: print(sum(nums[:K-n]))
s807096971
Accepted
112
32,204
232
N, K = map(int, input().split()) A = list(map(int, input().split())) B = [0 for i in range(N+1)] for a in A: B[a] += 1 nums = [b for b in B if b > 0] nums.sort() n = len(nums) if n <= K: print(0) else: print(sum(nums[:n-K]))
s483720615
p03433
u821425701
2,000
262,144
Wrong Answer
20
3,316
98
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
n = int(input()) a = int(input()) x = n % 500 if a >= x: print('yes') else: print('no')
s411544808
Accepted
17
2,940
98
n = int(input()) a = int(input()) x = n % 500 if a >= x: print('Yes') else: print('No')
s658439562
p03637
u518042385
2,000
262,144
Wrong Answer
70
15,020
203
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
n=int(input()) l=list(map(int,input().split())) count2=0 count4=0 for i in range(n): if l[i]%4==0: count4+=1 elif l[i]%2==0: count2+=1 if count4*2+count2>n: print("Yes") else: print("No")
s802496244
Accepted
70
15,020
221
n=int(input()) l=list(map(int,input().split())) count2=0 count4=0 for i in range(n): if l[i]%4==0: count4+=1 elif l[i]%2==0: count2+=1 if count4*2+count2>=n or count4*2+1>=n: print("Yes") else: print("No")
s600106335
p02743
u416000511
2,000
1,048,576
Wrong Answer
18
3,060
189
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
in_num = input('') all_num = in_num.split() a = all_num[0] b = all_num[1] c = all_num[2] if(4 * int(a) * int(b) - (int(c) - int(a) - int(b))**2 >0): print("Yes") else: print("No")
s216257627
Accepted
18
3,060
195
s = input() A = s.split(' ') B = [int(i) for i in A] a, b, c = B[0], B[1], B[2] if c-a-b <= 0: print('No') else: L = 4 * a * b R = (c-a-b) ** 2 print('Yes' if (L < R) else 'No')
s345932656
p03469
u485349322
2,000
262,144
Wrong Answer
26
8,832
36
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
S=input() print(S.replace("7","8"))
s828169836
Accepted
24
8,976
41
S=input() print(S.replace("2017","2018"))
s079504004
p03644
u953379577
2,000
262,144
Time Limit Exceeded
2,104
12,616
102
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()) ans = 1 while ans<=n: if ans*2>n: print(ans) else: ans *= 2
s779655718
Accepted
18
2,940
116
n = int(input()) ans = 1 while ans<=n: if ans*2>n: print(ans) break else: ans *= 2
s401171201
p03578
u499259667
2,000
262,144
Wrong Answer
2,108
34,024
215
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems.
N = int(input()) D = list(map(int,input().split())) M = int(input()) T = list(map(int,input().split())) for i in T: if i in D: D.pop(D.index(i)) else: print("No") exit() print("Yes")
s788606951
Accepted
379
35,420
427
N = int(input()) D = list(map(int,input().split())) M = int(input()) T = list(map(int,input().split())) D.sort();T.sort() di = 0 ti = 0 while True: d = D[di];t=T[ti] if d==t: di+=1;ti+=1 elif d>t: print("NO") exit() elif t>d: di+=1 if ti >= len(T): print("YES") exit() if di >= len(D): print(di) print("NO") exit()
s777227041
p03371
u078214750
2,000
262,144
Wrong Answer
2,205
9,044
196
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
A, B, C, X, Y = map(int, input().split()) ans = 0 for i in range(X): for j in range(Y): for k in range(X+Y, 2): if i+k/2==X and j+k/2==Y: ans = min(ans, A*i+B*j+C*k) print(ans)
s962547949
Accepted
129
8,968
196
A, B, C, X, Y = map(int, input().split()) ans = float('INF') for k in range(0, 2*max(X, Y)+1, 2): i = max(0, X - int(k/2)) j = max(0, Y - int(k/2)) ans = min(ans, A*i + B*j + C*k) print(ans)
s351761734
p02612
u666964944
2,000
1,048,576
Wrong Answer
26
9,140
61
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 if n%1000==0 else (n//1000)+1)
s423390774
Accepted
32
9,080
57
n = int(input()) print(0 if n%1000==0 else 1000-(n%1000))
s064542645
p03853
u762540523
2,000
262,144
Wrong Answer
42
4,212
340
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()) c = [] for _ in range(h): c.append(list(input())) d = [[""] * w * 2 for x in range(h * 2)] for i in range(h): for j in range(w): d[i * 2][j * 2] = c[i][j] d[i * 2+1][j * 2] = c[i][j] d[i * 2][j * 2+1] = c[i][j] d[i * 2+1][j * 2+1] = c[i][j] for i in d: print(*i)
s124931663
Accepted
22
3,316
264
h, w = map(int, input().split()) c = [] for _ in range(h): c.append(list(input())) d = [[""] * w for x in range(h * 2)] for i in range(h): for j in range(w): d[i * 2][j] = c[i][j] d[i * 2 + 1][j] = c[i][j] for i in d: print("".join(i))
s671863181
p03712
u840841119
2,000
262,144
Wrong Answer
30
9,060
155
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
H,W = map(int, input().split()) for _ in range(H): Ans = ['#' + input() + '#'] print('#'*(W + 2)) for ans in Ans: print(ans) print('#'*(W + 2))
s057257528
Accepted
26
9,104
169
H,W = map(int, input().split()) Ans = [] for _ in range(H): Ans.append('#' + input() + '#') print('#'*(W + 2)) for ans in Ans: print(ans) print('#'*(W + 2))
s123573385
p03455
u106184985
2,000
262,144
Wrong Answer
21
3,068
87
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = map(int, input().split()) if a*b/2 == 0: print('Even') else: print('Odd')
s089828866
Accepted
17
2,940
90
a, b = map(int, input().split()) if a*b % 2 == 0: print('Even') else: print('Odd')
s222727432
p03485
u804048521
2,000
262,144
Wrong Answer
19
3,060
65
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 = (int(x) for x in input().split()) print(((a + b)/2) // 1 )
s109430813
Accepted
18
2,940
123
a, b = (int(x) for x in input().split()) c = int((a + b) / 2) d = (a + b) / 2 - c if d > 0: print(c + 1) else: print(c)
s890549679
p03351
u165268875
2,000
1,048,576
Wrong Answer
17
2,940
80
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()) print("Yes" if abs(c-a) < d else "No")
s902126363
Accepted
17
2,940
118
a, b, c, d = map(int, input().split()) print("Yes" if abs(c-a) <= d or (abs(b-a) <= d and abs(c-b) <= d) else "No")
s310921727
p03993
u703890795
2,000
262,144
Wrong Answer
65
14,008
125
There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
N = int(input()) A = list(map(int, input().split())) c = 1 for i in range(N): if A[A[i]-1]==i-1: c += 1 print(int(c/2))
s793881613
Accepted
68
13,880
125
N = int(input()) A = list(map(int, input().split())) c = 0 for i in range(N): if A[A[i]-1]==i+1: c += 1 print(int(c/2))
s887727173
p03493
u427984570
2,000
262,144
Wrong Answer
17
2,940
31
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
s = input() print('1'.count(s))
s989475808
Accepted
17
2,940
31
s = input() print(s.count('1'))
s377138578
p03624
u624475441
2,000
262,144
Wrong Answer
18
3,188
114
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
S = input() for c in 'abcdefghijklmnopqrstuvwxyz': if c not in S: print(c) break print('None')
s916167797
Accepted
21
3,188
115
S = input() for c in 'abcdefghijklmnopqrstuvwxyz': if c not in S: print(c) exit() print('None')
s529410600
p03434
u393512980
2,000
262,144
Wrong Answer
17
2,940
95
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()) c = sorted(list(map(int, input().split()))) print(sum(c[0::2]) - sum(c[1::2]))
s312515695
Accepted
18
2,940
113
n = int(input()) c = sorted(list(map(int, input().split())), reverse = True) print(sum(c[0::2]) - sum(c[1::2]))
s931592021
p03963
u391059484
2,000
262,144
Wrong Answer
18
2,940
111
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls.
N,K = map(int, input().split()) colors = int(0) for i in range(N): colors = int(colors * (K-1)) print(colors)
s001701207
Accepted
17
2,940
108
N,K = map(int, input().split()) colors = K for i in range(N-1): colors = colors * (K-1) print(int(colors))
s817728876
p03386
u842950479
2,000
262,144
Wrong Answer
2,103
2,940
187
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().rstrip().split()) output=[] #make list for i in range(A,B+1): if (A<=i and i<A+K) or (B-K<i and i<=B): output.append(i) print(output)
s620757151
Accepted
17
3,060
198
A,B,K=map(int, input().rstrip().split()) work=[] #make list for i in range(0,K): if A+i<=B: print(A+i) for i in range(0,K): if B-K+i+1>=A+K: print(B-K+i+1)
s814542143
p03719
u391533749
2,000
262,144
Wrong Answer
17
2,940
96
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 = list(map(int,input().split())) if c>=a and c<=b: print("YES") else: print("NO")
s063578827
Accepted
17
2,940
96
a,b,c = list(map(int,input().split())) if c>=a and c<=b: print("Yes") else: print("No")
s628029183
p03361
u152671129
2,000
262,144
Wrong Answer
28
3,064
636
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
h, w = map(int, input().split()) grid = [list(input()) for _ in range(h)] dict = ( (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1), ) achievable = True for i in range(h): for j in range(w): count = 0 now = grid[i][j] if now == "#": for dy, dx in dict: y = i + dy x = j + dx if y >= 0 and h > y and x >= 0 and w > x: if grid[y][x] == '#': count += 1 if count == 0: achievable = False print('YES' if achievable else 'No')
s610052188
Accepted
23
3,188
565
h, w = map(int, input().split()) grid = [list(input()) for _ in range(h)] dict = ( (-1, 0), (0, -1), (0, 1), (1, 0), ) achievable = True for i in range(h): for j in range(w): count = 0 if grid[i][j] == "#": for dy, dx in dict: y = i + dy x = j + dx if y >= 0 and h > y and x >= 0 and w > x: if grid[y][x] == '#': count += 1 if count == 0: achievable = False print('Yes' if achievable else 'No')
s716518699
p02613
u455957070
2,000
1,048,576
Wrong Answer
159
16,328
353
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 = [input() for i in range(n)] ac = 0 wa = 0 tle = 0 re = 0 for i in range(n): if(s[i] == 'AC'): ac += 1 elif(s[i] == 'WA'): wa += 1 elif(s[i] == 'TLE'): tle += 1 elif(s[i] == 're'): re += 1 else: re += 0 print('WA x ' + str(ac)) print('WA x '+ str(wa)) print('TLE x '+ str(tle)) print('RE x '+ str(re))
s450274623
Accepted
141
16,288
193
n = int(input()) s = [input() for i in range(n)] print('AC x ' + str(s.count('AC'))) print('WA x '+ str(s.count('WA'))) print('TLE x '+ str(s.count('TLE'))) print('RE x '+ str(s.count('RE')))
s563921361
p02936
u884323674
2,000
1,048,576
Wrong Answer
1,992
116,824
451
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
N, Q = map(int, input().split()) ab = [[int(i) for i in input().split()] for j in range(N-1)] G = [[] for i in range(N)] for i in range(N-1): a, b = ab[i] G[b-1].append(a-1) q = [[int(i) for i in input().split()] for j in range(Q)] count = [0 for i in range(N)] for i in range(Q): p, x = q[i] count[p-1] += x for i in range(N): ans = count[i] if G[i]: ans += count[G[i][0]] print(ans, end=" ") count[i] = ans
s147135785
Accepted
1,586
232,604
555
from collections import deque import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline N, Q = map(int, input().split()) G = [[] for i in range(N)] for i in range(N-1): a, b = map(int, input().split()) G[a-1].append(b-1) G[b-1].append(a-1) count = [0 for i in range(N)] for i in range(Q): p, x = map(int, input().split()) count[p-1] += x def dfs(v, p): if p != -1: count[v] += count[p] for next_v in G[v]: if next_v == p: continue dfs(next_v, v) dfs(0, -1) print(" ".join(map(str, count)))
s325686353
p03623
u411858517
2,000
262,144
Wrong Answer
17
3,064
270
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 = input() S_list = list(set(S)) al = 'abcdefghijklmnopqrstucwxyz' al_list = list(al) S_list.sort() for i in range(len(set(S))): if al_list[i] in S_list: pass else: print(al_list[i]) break if i == len(set(S)) - 1: print('None')
s069307343
Accepted
17
2,940
95
x, a, b = map(int, input().split()) if abs(x-a) < abs(x-b): print('A') else: print('B')
s223903775
p03161
u340475705
2,000
1,048,576
Wrong Answer
2,104
13,980
264
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to one of the following: Stone i + 1, i + 2, \ldots, i + K. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
size, jumps = map(int, input().split()) array = list(map(int, input().split())) dp = [0]* size dp[1]= dp[0] + abs(array[1] - array[0]) for i in range(1,size): for j in range(i ,size): dp[i] = min( dp[j],abs(array[i] - array[j]) ) print(dp[-1])
s662321787
Accepted
1,989
13,924
425
import sys def input(): return sys.stdin.readline().strip() def main(): size, jumps = map(int, input().split()) array = list(map(int, input().split())) dp = [999999999] * size dp[0]= 0 dp[1] = abs(array[0]- array[1]) for i in range(2,size): dp[i] = min(abs(array[i] - array[j]) + dp[j] for j in range(max(0, i - jumps), i)) print(dp[size-1]) if __name__ == "__main__": main()
s952743924
p03854
u075628913
2,000
262,144
Wrong Answer
72
3,188
382
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
def check(s: str): if len(s) >= 5 and s[-5:] in ['dream', 'erase']: return s[:-5] elif len(s) >= 6 and s[-6:] in ['eraser']: return s[:-6] elif len(s) >= 7 and s[-7:] in ['dreamer']: return s[:-7] return None s = input() matched = True while len(s) > 0: s = check(s) if s is None: matched = False break if matched: print('Yes') else: print('No')
s230416215
Accepted
78
3,188
382
def check(s: str): if len(s) >= 5 and s[-5:] in ['dream', 'erase']: return s[:-5] elif len(s) >= 6 and s[-6:] in ['eraser']: return s[:-6] elif len(s) >= 7 and s[-7:] in ['dreamer']: return s[:-7] return None s = input() matched = True while len(s) > 0: s = check(s) if s is None: matched = False break if matched: print('YES') else: print('NO')
s008380488
p02612
u799428010
2,000
1,048,576
Wrong Answer
29
9,148
64
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()) A=N%1000 if A==0: print(0) else: print(A)
s187624576
Accepted
33
9,152
99
import math N=int(input()) A=N/1000 B=math.ceil(A) if A==0: print(0) else: print(B*1000-N)
s157354004
p03455
u142903114
2,000
262,144
Wrong Answer
17
2,940
106
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
i = input() l = i.split(' ') if (int(l[0]) * int(l[1])) %2 == 1: print('Odd') else: print('even')
s926938094
Accepted
18
2,940
95
a, b = map(int, input().split()) if (a * b) % 2 == 1: print('Odd') else: print('Even')
s834867230
p02386
u922112509
1,000
131,072
Wrong Answer
20
5,452
1
Write a program which reads $n$ dices constructed in the same way as [Dice I](description.jsp?id=ITP1_11_A), and determines whether they are all different. For the determination, use the same way as [Dice III](description.jsp?id=ITP1_11_C).
s944032880
Accepted
4,530
8,304
4,678
# Dice I - IV class Dice: def __init__(self, a1, a2, a3, a4, a5, a6): self.face = [a1, a2, a3, a4, a5, a6] self.v = [a5, a1, a2, a6] self.h = [a4, a1, a3, a6] self.det = 1 # print(self.v, self.h) def top(self): return self.v[1] def north(self): newV = [self.v[1], self.v[2], self.v[3], self.v[0]] self.v = newV self.h[1] = self.v[1] self.h[3] = self.v[3] return self.v, self.h def south(self): newV = [self.v[3], self.v[0], self.v[1], self.v[2]] self.v = newV self.h[1] = self.v[1] self.h[3] = self.v[3] return self.v, self.h def east(self): newH = [self.h[3], self.h[0], self.h[1], self.h[2]] self.h = newH self.v[1] = self.h[1] self.v[3] = self.h[3] return self.v, self.h def west(self): newH = [self.h[1], self.h[2], self.h[3], self.h[0]] self.h = newH self.v[1] = self.h[1] self.v[3] = self.h[3] return self.v, self.h def searchFace(self, a): b = 0 for i in range(6): if a == self.face[i]: b = i + 1 return b def detJudge(self, x): y = int(7 / 2 - abs(x - 7 / 2)) if x != y: self.det *= -1 # print(self.det) return y def rightSide(self, top, front): r = 0 if top == 1 and front == 2: r = 3 elif top == 2 and front == 3: r = 1 elif top == 3 and front == 1: r = 2 elif top == 1 and front == 3: r = 5 elif top == 3 and front == 2: r = 6 elif top == 2 and front == 1: r = 4 if self.det == -1: r = 7 - r return r diceAmount = int(input()) dices = [] for i in range(diceAmount): d = [int(j) for j in input().rstrip().split()] dice = Dice(d[0], d[1], d[2], d[3], d[4], d[5]) dices.append(dice) # Dice I # command = list(input().rstrip()) # print(command) # Dice II # for i, a in enumerate(command): # if a == 'N': # elif a == 'S': # elif a == 'E': # elif a == 'W': # # print(a, b) # front = dice1.detJudge(b) # # print(top, front) # position = dice1.rightSide(top, front) # answer = dice1.face[position - 1] # print(answer) # Dice III # import random # yesCount = 0 # while yesCount == 0 and i < 1000: # j = random.randint(0, 3) # if j == 0: # elif j == 1: # elif j == 2: # elif j == 3: # yesCount += 1 # if yesCount >= 1: # print('Yes') # else: # print('No') # Dice IV import random match = 0 diceCount = 1 while match == 0 and diceCount < diceAmount: for d2 in range(1, diceAmount): # print(d2) i = 0 while match == 0 and i < 27: j = random.randint(0, 3) if j == 0: dices[d2].north() elif j == 1: dices[d2].south() elif j == 2: dices[d2].east() elif j == 3: dices[d2].west() for d1 in range(d2): if dices[d1].v == dices[d2].v and dices[d1].h == dices[d2].h: match += 1 i += 1 diceCount += 1 if match >= 1: print('No') else: print('Yes')
s946003200
p03574
u780709476
2,000
262,144
Wrong Answer
28
3,064
720
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.
H, W = map(int, input().split()) s = [] n = [] for i in range(H): s.append(input()) n.append([]) for j in range(W): if s[i][j] == ".": n[i].append(0) else: n[i].append(-1) for i in range(H): for j in range(W): if n[i][j] == -1: for k in range(-1, 2, 1): for l in range(-1, 2, 1): if 0 <= i + k and i + k < H and 0 <= j + l and j + l < W: if k != 0 and j != 0: n[i + k][j + l] += 1 print(n) for i in range(H): ans = "" for j in range(W): if n[i][j] == -1: ans += "#" else: ans += str(n[i][j]) print(ans)
s635977464
Accepted
33
3,064
719
H, W = map(int, input().split()) s = [] n = [] for i in range(H): s.append(input()) n.append([]) for j in range(W): if s[i][j] == ".": n[i].append(0) else: n[i].append(-1) for i in range(H): for j in range(W): if n[i][j] == -1: for k in range(-1, 2, 1): for l in range(-1, 2, 1): if 0 <= i + k and i + k < H and 0 <= j + l and j + l < W: if n[i + k][j + l] != -1: n[i + k][j + l] += 1 for i in range(H): ans = "" for j in range(W): if n[i][j] == -1: ans += "#" else: ans += str(n[i][j]) print(ans)
s379121954
p03694
u213431796
2,000
262,144
Wrong Answer
17
2,940
93
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.
l = list(map(int,input().split())) l_max = max(l) l_min = min(l) print(str(l_max - l_min))
s569369824
Accepted
17
2,940
110
N = int(input()) l = list(map(int,input().split())) l_max = max(l) l_min = min(l) print(str(l_max - l_min))
s696904272
p04012
u832058515
2,000
262,144
Wrong Answer
17
2,940
249
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
st = "abcfcabf" for char in st: print(len(st)) if len(st) == 0: print("YES") break if st.count(char) %2 !=0: print("No") break else: print(st) st = st.replace(char,"") continue
s554194216
Accepted
17
2,940
120
w = input() W = list(set(w)) for c in W: if w.count(c) % 2 != 0: print('No') exit() print('Yes')
s602605348
p03457
u552510302
2,000
262,144
Wrong Answer
371
27,380
316
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.
time = int(input()) jorney = [list(map(int,input().split())) for i in range(time)] flg = True for point in jorney: time = point[0] x = point[1] y = point[2] if time %2 == (x+y)%2 and time>= x+y: continue else: flg=False break if flg: print("YES") else: print("NO")
s020826228
Accepted
438
27,380
510
time = int(input()) jorney = [list(map(int,input().split())) for i in range(time)] flg = True x_before = 0 y_bfefore =0 t_before = 0 for point in jorney: t = point[0] x = point[1] y = point[2] distance = abs(x- x_before) + abs(y - y_bfefore) interval = t - t_before if t %2 == (x+y)%2 and interval >= distance: t_before=t x_before=x y_bfefore=y continue else: flg=False break if flg: print("Yes") else: print("No")
s275613896
p03555
u466105944
2,000
262,144
Wrong Answer
17
2,940
120
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
a = input() b = input() b = ''.join([i for i in reversed(b)]) if a == b: print('Yes') else: print('No')
s412597486
Accepted
17
2,940
120
a = input() b = input() b = ''.join([i for i in reversed(b)]) if a == b: print('YES') else: print('NO')
s705950150
p03485
u956547804
2,000
262,144
Wrong Answer
17
2,940
91
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()) if (a+b)//2==0: print((a+b)/2) else: print((a+b)//2+1)
s316189326
Accepted
17
2,940
100
a,b=map(int,input().split()) if (a+b)%2==0: print(int((a+b)/2)) else: print(int((a+b)//2+1))
s917744424
p03371
u687041133
2,000
262,144
Wrong Answer
129
3,064
584
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
A, B, C, X, Y = map(int, input().split()) AB = A + B num_A = 0 num_B = 0 num_C = 0 ans_cost = 5000 * 2 * 10**5 if 2 * C > AB: num_A = X num_B = Y num_C = 0 ans_cost = int(A*num_A + B*num_B + C*num_C) else: min_C = min(X,Y) *2 max_C = max(X,Y) *2 for i in range(min_C, max_C+1, 2): num_A = X - i / 2 num_B = Y - i / 2 if num_A < 1: num_A = 0 if num_B < 1: num_B = 0 total_cost = int(A*num_A + B*num_B + C*i) if total_cost < ans_cost: ans_cost = total_cost
s049158232
Accepted
18
3,064
550
A, B, C, X, Y = map(int, input().split()) min_cost = 0 if X - Y > 0: temp_cost = 2 * C * Y temp_cost += A * (X - Y) temp_cost2 = 2 * C * X if temp_cost > temp_cost2: min_cost = temp_cost2 else: min_cost = temp_cost else: temp_cost = 2 * C * X temp_cost += B * (Y - X) temp_cost2 = 2 * C * Y if temp_cost > temp_cost2: min_cost = temp_cost2 else: min_cost = temp_cost temp_cost3 = A * X + B *Y if temp_cost3 < min_cost: min_cost = temp_cost3 print(min_cost)
s891256224
p04029
u654558363
2,000
262,144
Wrong Answer
17
2,940
72
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?
if __name__ == "__main__": n = int(input()) print(n * (n + 1)/2)
s085684321
Accepted
17
2,940
73
if __name__ == "__main__": n = int(input()) print(n * (n + 1)//2)
s648856628
p02264
u336705996
1,000
131,072
Wrong Answer
30
6,004
405
_n_ _q_ _name 1 time1_ _name 2 time2_ ... _name n timen_ In the first line the number of processes _n_ and the quantum _q_ are given separated by a single space. In the following _n_ lines, names and times for the _n_ processes are given. _name i_ and _time i_ are separated by a single space.
from collections import deque if __name__ == "__main__": n, q = input().split() n, q = int(n), int(q) s = 0 a = deque([list(map(str,input().split())) for _ in range(n)]) while len(a): x = a.popleft() if int(x[1]) < q: s += int(x[1]) print(x[0],s) else: x[1] = str(int(x[1]) - q) s += q a.append(x)
s681111291
Accepted
480
14,684
410
from collections import deque if __name__ == "__main__": n, q = input().split() n, q = int(n), int(q) s = 0 a = deque([list(map(str,input().split())) for _ in range(n)]) while len(a): x = a.popleft() if int(x[1]) - q <= 0: s += int(x[1]) print(x[0], s) else: x[1] = str(int(x[1]) - q) s += q a.append(x)
s821418626
p03251
u027026942
2,000
1,048,576
Wrong Answer
17
3,060
232
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.
_, _, x, y = map(int, input().split()) x_cities = map(int, input().split()) y_cities = map(int, input().split()) max_x, min_y = max(x_cities), min(y_cities) if max_x < min_y and x < min_y < y: print("No war") else: print("War")
s318252060
Accepted
19
3,060
232
_, _, x, y = map(int, input().split()) x_cities = map(int, input().split()) y_cities = map(int, input().split()) max_x, min_y = max(x_cities), min(y_cities) if max_x < min_y and x < min_y < y: print("No War") else: print("War")
s124191898
p02600
u729133443
2,000
1,048,576
Wrong Answer
28
9,132
26
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?
print(10-int(input())/200)
s391560322
Accepted
33
9,136
27
print(10-int(input())//200)
s662162334
p02261
u153665391
1,000
131,072
Wrong Answer
20
7,752
1,139
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).
n = int(input()) a = list(input().split()) A = [] A1 = [] A2 = [] for i in a: A.append(list(i)) A1.append(list(i)) A2.append(list(i)) # check stable or not def is_stable(A3): for i in range( 1, n ): if int(A3[i-1][1]) == int(A3[i][1]): sm = i-1 bg = i for j in range( n ): if ( A[j][0] == A3[sm][0]) & ( A[j][1] == A3[sm][1]): t1 = j if ( A[j][0] == A3[bg][0]) & ( A[j][1] == A3[bg][1]): t2 = j print(t1) print(t2) if t1 > t2: return "Not stable" return "Stable" for i in range( n ): for j in range( n-1, i, -1 ): if int(A1[j][1]) < int(A1[j-1][1]): t = A1[j-1] A1[j-1] = A1[j] A1[j] = t s = is_stable(A1) print(*A1) print(s) # selection for i in range( n ): minj = i for j in range( i+1, n ): if int(A2[j][1]) < int(A2[minj][1]): minj = j if minj != i: t = A2[i] A2[i] = A2[minj] A2[minj] = t s = is_stable(A2) print(*A2) print(s)
s332816631
Accepted
30
6,344
1,362
import copy N = int(input()) A = list(input().split()) def is_stable(sorted_list): for i in range(len(sorted_list)-1): if sorted_list[i][1] == sorted_list[i+1][1]: for j in range(len(A)): if A[j] == sorted_list[i]: smaller_idx = j if A[j] == sorted_list[i+1]: larger_idx = j if smaller_idx > larger_idx: return False return True def print_stable_or_not(is_stable): if is_stable: print("Stable") else: print("Not stable") def bubble_sort(A1): flg = True while flg: for i in range(N): flg = False for j in range(N-1, i, -1): if int(A1[j-1][1]) > int(A1[j][1]): A1[j-1], A1[j] = A1[j], A1[j-1] flg = True print(" ".join(A1)) print_stable_or_not(is_stable(A1)) def insertion_sort(A2): for i in range(N-1): min_idx = i for j in range(i+1, N): if int(A2[min_idx][1]) > int(A2[j][1]): min_idx = j if min_idx != i: A2[i], A2[min_idx] = A2[min_idx], A2[i] print(" ".join(A2)) print_stable_or_not(is_stable(A2)) if __name__ == '__main__': A1 = copy.deepcopy(A) A2 = copy.deepcopy(A) bubble_sort(A1) insertion_sort(A2)
s161797528
p02613
u821969418
2,000
1,048,576
Wrong Answer
143
9,168
293
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
n = int(input()) c0 = 0 c1 = 0 c2 = 0 c3 = 0 for i in range(n): s = input() if s == "AC": c0 += 1 elif s == "WA": c1 += 1 elif s == "TLE": c2 += 1 else: c3 += 1 print("AC x ", c0) print("WA x ", c1) print("TLE x ", c2) print("RTE x ", c3)
s208881229
Accepted
146
9,064
288
n = int(input()) c0 = 0 c1 = 0 c2 = 0 c3 = 0 for i in range(n): s = input() if s == "AC": c0 += 1 elif s == "WA": c1 += 1 elif s == "TLE": c2 += 1 else: c3 += 1 print("AC x", c0) print("WA x", c1) print("TLE x", c2) print("RE x", c3)
s772914473
p03478
u702582248
2,000
262,144
Wrong Answer
20
2,940
132
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
n,a,b=map(int, input().split()) ret = 0 for i in range(1, n+1): c = n // 10 + n % 10 if a<=c and c <=b: ret += 1 print(ret)
s982103779
Accepted
136
2,940
145
n,a,b=map(int, input().split()) ret = 0 for i in range(1, n+1): c = eval('+'.join(str(i))) if a<=c and c <=b: ret += i print(ret)
s944696592
p02280
u404682284
1,000
131,072
Wrong Answer
20
5,620
2,151
A rooted binary tree is a tree with a root node in which every node has at most two children. Your task is to write a program which reads a rooted binary tree _T_ and prints the following information for each node _u_ of _T_ : * node ID of _u_ * parent of _u_ * sibling of _u_ * the number of children of _u_ * depth of _u_ * height of _u_ * node type (root, internal node or leaf) If two nodes have the same parent, they are **siblings**. Here, if _u_ and _v_ have the same parent, we say _u_ is a sibling of _v_ (vice versa). The height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf. Here, the given binary tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1.
class NullNode(): def __init__(self): self.id = -1 class Node(): def __init__(self, id): self.id = id self.parent = NullNode() self.left = NullNode() self.right = NullNode() self.sibling = NullNode() def __str__(self): return '{} {} {} {} {}'.format(self.id, self.parent.id, self.left.id, self.right.id, self.sibling.id) def getHeight(self, height=0): if self.left.id != -1: height += 1 height = self.left.getHeight(height) elif self.right.id != -1: height += 1 height = self.right.getHeight(height) return height def getDepth(self, depth=0): if self.parent.id != -1: depth += 1 if depth < 5: print(self.parent.id, self.id) depth = self.parent.getDepth(depth) return depth def getDegree(self): degree = 0 if self.left.id != -1: degree += 1 if self.right.id != -1: degree += 1 return degree def getType(self): if self.parent.id == -1: return 'root' elif self.left.id == -1 and self.right.id == -1: return 'leaf' else: return 'internal node' n = int(input()) node_list = [Node(id) for id in range(n)] for i in range(n): [id, left, right] = [int(j) for j in input().split()] i_node = node_list[id] if left != -1: i_node.left = node_list[left] node_list[left].parent = node_list[id] node_list[left].sibling = node_list[right] if right != -1: i_node.right = node_list[right] node_list[right].parent = node_list[id] node_list[right].sibling = node_list[left] for id in range(n): i_node = node_list[id] parent = i_node.parent.id sibling = i_node.sibling.id degree = i_node.getDegree() depth = i_node.getDepth() height = i_node.getHeight() type = i_node.getType() print('node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}'.format(id, parent, sibling, degree, depth, height, type))
s413353602
Accepted
20
5,620
2,236
class NullNode(): def __init__(self): self.id = -1 class Node(): def __init__(self, id): self.id = id self.parent = NullNode() self.left = NullNode() self.right = NullNode() self.sibling = NullNode() def __str__(self): return '{} {} {} {} {}'.format(self.id, self.parent.id, self.left.id, self.right.id, self.sibling.id) def getHeight(self, right_height=0, left_height=0): if self.left.id != -1: left_height += 1 left_height = self.left.getHeight(left_height, left_height) if self.right.id != -1: right_height += 1 right_height = self.right.getHeight(right_height, right_height) return max(left_height, right_height) def getDepth(self, depth=0): if self.parent.id != -1: depth += 1 depth = self.parent.getDepth(depth) return depth def getDegree(self): degree = 0 if self.left.id != -1: degree += 1 if self.right.id != -1: degree += 1 return degree def getType(self): if self.parent.id == -1: return 'root' elif self.left.id == -1 and self.right.id == -1: return 'leaf' else: return 'internal node' n = int(input()) node_list = [Node(id) for id in range(n)] for i in range(n): [id, left, right] = [int(j) for j in input().split()] i_node = node_list[id] if left != -1: i_node.left = node_list[left] node_list[left].parent = node_list[id] if right != -1: node_list[left].sibling = node_list[right] if right != -1: i_node.right = node_list[right] node_list[right].parent = node_list[id] if left != -1: node_list[right].sibling = node_list[left] for id in range(n): i_node = node_list[id] parent = i_node.parent.id sibling = i_node.sibling.id degree = i_node.getDegree() depth = i_node.getDepth() height = i_node.getHeight() type = i_node.getType() print('node {0}: parent = {1}, sibling = {2}, degree = {3}, depth = {4}, height = {5}, {6}'.format(id, parent, sibling, degree, depth, height, type))
s269920237
p00423
u114315703
1,000
131,072
Wrong Answer
150
5,956
1,055
A と B の 2 人のプレーヤーが, 0 から 9 までの数字が書かれたカードを使ってゲームを行う.最初に, 2 人は与えられた n 枚ずつのカードを,裏向きにして横一列に並べる.その後, 2 人は各自の左から 1 枚ずつカードを表向きにしていき,書かれた数字が大きい方のカードの持ち主が,その 2 枚のカードを取る.このとき,その 2 枚のカードに書かれた数字の合計が,カードを取ったプレーヤーの得点となるものとする.ただし,開いた 2 枚のカードに同じ数字が書かれているときには,引き分けとし,各プレーヤーが自分のカードを 1 枚ずつ取るものとする. 例えば, A,B の持ち札が,以下の入力例 1 から 3 のように並べられている場合を考えよう.ただし,入力ファイルは n + 1 行からなり, 1 行目には各プレーヤのカード枚数 n が書かれており, i + 1 行目(i = 1,2,... ,n)には A の左から i 枚目のカードの数字と B の左から i 枚目の カードの数字が,空白を区切り文字としてこの順で書かれている.すなわち,入力ファイルの 2 行目以降は,左側の列が A のカードの並びを,右側の列が B のカードの並びを,それぞれ表している.このとき,ゲーム終了後の A と B の得点は,それぞれ,対応する出力例に示したものとなる. 入力ファイルに対応するゲームが終了したときの A の得点と B の得点を,この順に空白を区切り文字として 1 行に出力するプログラムを作成しなさい.ただし, n ≤ 10000 とする. 入力例1 | 入力例2 | 入力例3 ---|---|--- 3| 3| 3 9 1| 9 1| 9 1 5 4| 5 4| 5 5 0 8| 1 0| 1 8 出力例1 | 出力例2 | 出力例3 19 8| 20 0| 15 14
array_first = [] array_second = [] input_str = input() while True: turns = int(input_str) if turns == 0: break for turn in range(turns): input_str = input() first = '' second = '' flag_space = False for i in range(len(input_str)): if input_str[i] == ' ': flag_space = True continue if not flag_space: first += (input_str[i]) else: second += (input_str[i]) array_first.append(int(first)) array_second.append(int(second)) input_str = input() score_first = 0 score_second = 0 for turn in range(len(array_first)): if array_first[turn] > array_second[turn]: score_first += array_first[turn] + array_second[turn] elif array_first[turn] < array_second[turn]: score_second += array_first[turn] + array_second[turn] else: score_first += array_first[turn] score_second += array_second[turn] print(score_first, ' ', score_second)
s521927098
Accepted
150
5,984
1,523
array_first = [] array_second = [] array_turns = [] input_str = input() while True: turns = int(input_str) if turns == 0: break array_turns.append(turns) for turn in range(turns): input_str = input() first = '' second = '' flag_space = False for i in range(len(input_str)): if input_str[i] == ' ': flag_space = True continue if not flag_space: first += (input_str[i]) else: second += (input_str[i]) array_first.append(int(first)) array_second.append(int(second)) input_str = input() scores_first = [] scores_second = [] passed_turns = 0 for turns in array_turns: score_first = 0 score_second = 0 for turn in range(turns): if array_first[turn + passed_turns] > array_second[turn + passed_turns]: score_first += array_first[turn + passed_turns] + array_second[turn + passed_turns] elif array_first[turn + passed_turns] < array_second[turn + passed_turns]: score_second += array_first[turn + passed_turns] + array_second[turn + passed_turns] else: score_first += array_first[turn + passed_turns] score_second += array_second[turn + passed_turns] scores_first.append(score_first) scores_second.append(score_second) passed_turns += turns for idx, score in enumerate(zip(scores_first, scores_second)): print(score[0], score[1])
s041599734
p03448
u836737505
2,000
262,144
Wrong Answer
28
3,064
208
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()) c =0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if 500*i + 100*j + 50*k == x: c += 1 print(c)
s612435647
Accepted
51
3,060
237
a = int(input()) b = int(input()) c = int(input()) x = int(input()) d =0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if 500 * i + 100 * j + 50 * k == x: d += 1 print(d)
s196633659
p03160
u179169725
2,000
1,048,576
Wrong Answer
518
17,208
1,141
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
import sys read = sys.stdin.readline def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) N = read_a_int() H = read_ints() import numpy as np dp = np.full((N), np.inf, dtype='int64') dp[1] = abs(H[0] - H[1]) for i in range(2, N): dp[i] = min(dp[i - 1] + abs(H[i - 1] - H[i]), dp[i - 2] + abs(H[i] - H[i - 2])) print(dp[-1])
s831663373
Accepted
680
17,156
1,607
import sys read = sys.stdin.readline def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) N = read_a_int() H = read_ints() import numpy as np dp = np.full((N), float('inf')) dp[0] = 0 dp[1] = abs(H[0] - H[1]) # dp[i] = min(dp[i - 1] + abs(H[i - 1] - H[i]), # dp[i - 2] + abs(H[i] - H[i - 2])) # print(dp[-1]) for i in range(0, N-2): dp[i + 1] = min(dp[i] + abs(H[i] - H[i+1]), dp[i+1]) dp[i + 2] = min(dp[i] + abs(H[i] - H[i + 2]), dp[i + 2]) dp[-1] = min(dp[-2] + abs(H[-2] - H[-1]), dp[-1]) print(int(dp[-1]))
s127154250
p03007
u298297089
2,000
1,048,576
Wrong Answer
761
21,944
696
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
from heapq import heappop, heappush, heapify N = int(input()) A = list(map(int, input().split())) p = [] for i in A: if i > 0: tmp = [i, 1] elif i < 0: tmp = [-i, -1] else: N -= 1 continue heappush(p, tmp) for i in range(N-1): x, y = heappop(p), heappop(p) x = x[0] * x[1] y = y[0] * y[1] if p == []: if x-y > y-x: print(x,y) else: print(y,x) continue if p[0][1] > 0: tmp = min(x-y, y-x) else: tmp = max(x-y, y-x) if tmp == y-x: x,y=y,x if tmp > 0: tmp = [tmp, 1] else: tmp = [-tmp, -1] print(x,y) heappush(p, tmp)
s122395443
Accepted
310
24,116
707
n = int(input()) a = list(map(int , input().split())) pos = sorted([i for i in a if i >= 0], reverse=True) neg = sorted([i for i in a if i < 0], reverse=True) ans = [] if len(neg) == 0 and len(pos) == 2: print(pos[0] - pos[1]) print(pos[0], pos[1]) exit() elif len(pos) == 0: tmp = neg[0] for i in range(1,len(neg)): ans.append([tmp, neg[i]]) tmp -= neg[i] print(tmp) [print(*i) for i in ans] exit() elif len(neg) == 0: neg.append(pos.pop()) tmp = neg.pop() while len(pos) > 1: a = pos.pop() ans.append([tmp, a]) tmp -= a neg.append(tmp) tmp = pos[0] for i in neg: ans.append([tmp, i]) tmp -= i print(tmp) [print(*i) for i in ans]
s240071433
p02613
u429029348
2,000
1,048,576
Wrong Answer
143
16,108
176
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 = list(input() for _ in range(n)) print('AC ×', s.count("AC")) print('WA ×', s.count("WA")) print('TLE ×', s.count("TLE")) print('RE ×', s.count("RE"))
s776948985
Accepted
141
16,128
191
n = int(input()) s = list(input() for _ in range(n)) print('AC x', str(s.count("AC"))) print('WA x', str(s.count("WA"))) print('TLE x', str(s.count("TLE"))) print('RE x', str(s.count("RE")))
s330631534
p03644
u221401884
2,000
262,144
Wrong Answer
17
2,940
130
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()) count = 0 while True: if n % 2 == 0: n /= 2 count += 1 else: break print(count)
s095588794
Accepted
17
3,060
375
n = int(input()) count_dict = {} for num in range(1, n + 1): count_dict[num] = 0 tmp = num while True: if tmp % 2 == 0: tmp /= 2 count_dict[num] += 1 else: break max_count = max(count for count in count_dict.values()) result = [k for k, v in count_dict.items() if v == max_count][0] print(result)
s834002991
p02694
u035445296
2,000
1,048,576
Wrong Answer
24
9,028
109
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()) total = 100 cnt = 0 while total <=x: total = total + int(total*0.01) cnt += 1 print(cnt)
s048888948
Accepted
24
9,152
136
x = int(input()) total = 100 cnt = 0 while total <=x: total = total + int(total*0.01) cnt += 1 if total >= x: break print(cnt)
s180170815
p03545
u134712256
2,000
262,144
Wrong Answer
17
3,064
482
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.
abcd = input() bit = 0b1000 ans=int(abcd[0]) op = [-1,-1,-1] str_bit = bin(bit) while bit<16: for i in range(3,6): if str_bit[i]=="1": op[i-3]=1 ans+=int(abcd[i-3]) else: op[i-3]=0 ans-=int(abcd[i-3]) if ans==7: for i in range(len(op)): if op[i]==1: op[i]="+" else: op[i]="-" print(abcd[0],op[0],abcd[1],op[1],abcd[2],op[2],abcd[3],"=7",sep='') exit() ans=int(abcd[0]) bit+=1 str_bit=bin(bit)
s346761184
Accepted
18
3,192
542
abcd=input() a=int(abcd[0]) b=int(abcd[1]) c=int(abcd[2]) d=int(abcd[3]) ans=0 if a+b+c+d==7: print(a,"+",b,"+",c,"+",d,"=7",sep="") elif a+b+c-d==7: print(a,"+",b,"+",c,"-",d,"=7",sep="") elif a+b-c+d==7: print(a,"+",b,"-",c,"+",d,"=7",sep="") elif a+b-c-d==7: print(a,"+",b,"-",c,"-",d,"=7",sep="") elif a-b+c+d==7: print(a,"-",b,"+",c,"+",d,"=7",sep="") elif a-b+c-d==7: print(a,"-",b,"+",c,"-",d,"=7",sep="") elif a-b-c+d==7: print(a,"-",b,"-",c,"+",d,"=7",sep="") elif a-b-c-d==7: print(a,"-",b,"-",c,"-",d,"=7",sep="")
s204814237
p00004
u505912349
1,000
131,072
Wrong Answer
20
7,724
319
Write a program which solve a simultaneous equation: ax + by = c dx + ey = f The program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.
import sys for line in sys.stdin: array = [int(x) for x in line.split()] ar1 = array[0:3] ar2 = array[3:] i = ar1[0] ar1 = [x*ar2[0] for x in ar1] ar2 = [x*i for x in ar2] y = (ar1[2] - ar2[2])/(ar1[1]-ar2[1]) ar1 = array[0:3] x = (ar1[2]-ar1[1]*y)/ar1[0] print("%f %f" % (x,y))
s569065520
Accepted
20
7,424
344
import sys for line in sys.stdin: array = [float(x) for x in line.split()] ar1 = array[0:3] ar2 = array[3:] i = ar1[0] ar1 = [x*ar2[0] for x in ar1] ar2 = [x*i for x in ar2] y = (ar1[2] - ar2[2])/(ar1[1]-ar2[1]) ar1 = array[0:3] x = (ar1[2]-ar1[1]*y)/ar1[0] print('%.3f %.3f' % (round(x,3), round(y,3)))
s009433377
p03455
u984924962
2,000
262,144
Wrong Answer
18
2,940
92
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = map(int, input().split()) if (a*b) % 2 == 0: print("Odd") else: print("Even")
s152561826
Accepted
17
2,940
93
a, b = map(int, input().split()) if (a*b) % 2 != 0: print("Odd") else: print("Even")
s666377267
p03975
u976162616
1,000
262,144
Wrong Answer
17
2,940
218
Summer vacation ended at last and the second semester has begun. You, a Kyoto University student, came to university and heard a rumor that somebody will barricade the entrance of your classroom. The barricade will be built just before the start of the A-th class and removed by Kyoto University students just before the start of the B-th class. All the classes conducted when the barricade is blocking the entrance will be cancelled and you will not be able to attend them. Today you take N classes and class i is conducted in the t_i- th period. You take at most one class in each period. Find the number of classes you can attend.
if __name__ == "__main__": N,A,B = map(int, input().split()) T = list(map(int, input().split())) res = 0 for x in T: if (A <= x and x < B): continue res += 1 print (res)
s536458743
Accepted
17
2,940
257
if __name__ == "__main__": N,A,B = map(int, input().split()) T = [] for x in range(N): x = int(input()) T.append(x) res = 0 for x in T: if (A <= x and x < B): continue res += 1 print (res)
s267736528
p03599
u798818115
3,000
262,144
Wrong Answer
21
3,064
607
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
# coding: utf-8 # Your code here! A,B,C,D,E,F=map(int,input().split()) A=A*100 B=B*100 ans=[] water=set() for i in range(F//(A)+1): for j in range((F-A*i)//B+1): water.add(A*i+B*j) water.remove(0) ans=-1 ans_all=-1 ans_sol=-1 for item in water: for i in range((F-item)//(C)+1): if C*i/item*100>E: break j=min((F-item-C*i)//D,(item*E/100-C*i)//D) if (C*i+D*j)/(item+C*i+D*j)>ans: ans_sol=C*i+D*j ans_all=item+ans_sol ans=ans_sol/ans_all print(ans_all,ans_sol)
s579337929
Accepted
21
3,188
567
# coding: utf-8 # Your code here! A,B,C,D,E,F=map(int,input().split()) A=A*100 B=B*100 ans=[] water=set() for i in range(F//(A)+1): for j in range((F-A*i)//B+1): water.add(A*i+B*j) water.remove(0) ans=-1 ans_all=-1 ans_sol=-1 for item in water: for i in range((F-item)//(C)+1): if C*i/item*100>E: break j=min((F-item-C*i)//D,(item*E/100-C*i)//D) if (C*i+D*j)/(item+C*i+D*j)>ans: ans_sol=C*i+D*j ans_all=item+ans_sol ans=ans_sol/ans_all print(int(ans_all),int(ans_sol))
s271776621
p03759
u316464887
2,000
262,144
Wrong Answer
18
2,940
131
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.
def main(): a,b,c = map(int, input().split()) if b - a == c - b: print('Yes') else: print('No') main()
s998066005
Accepted
18
2,940
131
def main(): a,b,c = map(int, input().split()) if b - a == c - b: print('YES') else: print('NO') main()
s561387047
p04043
u344813796
2,000
262,144
Wrong Answer
17
2,940
144
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.
haiku=list(map(int, input().split())) #a1 a2 a3 haiku.sort() print(haiku) print('YES' if haiku[0]==5 and haiku[1]==5 and haiku[2]==7 else 'NO')
s153112584
Accepted
17
2,940
132
haiku=list(map(int, input().split())) #a1 a2 a3 haiku.sort() print('YES' if haiku[0]==5 and haiku[1]==5 and haiku[2]==7 else 'NO')
s619978325
p03494
u734876600
2,000
262,144
Wrong Answer
21
3,064
104
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())) def f(x): return x//2 S = sum(map(f,a)) print(S)
s692590989
Accepted
19
2,940
165
N = int(input()) a = list(map(int,input().split())) def f(x): ans = 0 while x % 2 == 0: x /= 2 ans += 1 return ans print(min(map(f,a)))
s509784225
p03471
u468206018
2,000
262,144
Wrong Answer
981
3,064
239
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
n, y = map(int, input().split()) A, B, C = -1, -1, -1 for i in range(n): a = i+1 for j in range(n-a): b = j+1 c = n-a-b total = 10000*a + 5000*b + 1000*c if total == y: A = a B = b C = c print(A, B, C)
s454312803
Accepted
899
3,060
222
n, y = map(int, input().split()) A, B, C = -1, -1, -1 for i in range(n+1): for j in range(n-i+1): c = n-i-j total = 10000*i + 5000*j + 1000*c if total == y: A = i B = j C = c print(A, B, C)
s166553950
p03574
u119982147
2,000
262,144
Wrong Answer
33
3,064
590
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.
h, w = map(int, input().split()) masu = [[0]*w for _ in range(h)] for i in range(h): masu[i] = list(input()) for i in range(h): for j in range(w): if masu[i][j] == ".": count = 0 for dx in range(-1, 2): for dy in range(-1, 2): xx = i + dx yy = j + dy if 0 <= xx and xx < w and 0 <= yy and yy < h: if masu[yy][xx] == "#": count += 1 masu[i][j] = count for i in range(h): print("".join(map(str, masu[i])))
s393547070
Accepted
33
3,064
589
h, w = map(int, input().split()) masu = [[0]*w for _ in range(h)] for i in range(h): masu[i] = list(input()) for i in range(h): for j in range(w): if masu[i][j] == ".": count = 0 for dx in range(-1, 2): for dy in range(-1, 2): xx = j + dx yy = i + dy if 0 <= xx and xx < w and 0 <= yy and yy < h: if masu[yy][xx] == "#": count += 1 masu[i][j] = count for i in range(h): print("".join(map(str, masu[i])))
s159663997
p03377
u569272329
2,000
262,144
Wrong Answer
17
2,940
90
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()) if A + B <= X: print("YES") else: print("NO")
s927719172
Accepted
17
2,940
105
A, B, X = map(int, input().split()) if (A <= X) and (A + B >= X): print("YES") else: print("NO")
s050040152
p04030
u226912938
2,000
262,144
Wrong Answer
18
3,064
262
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
s = str(input()) ans = '' for i in range(len(s)): if s[i] == '1': ans = ans + '1' elif s[i] == '0': ans = ans + '0' elif s[i] == 'B': if len(ans) >= 2: ans = ans[:-2] else: ans = '' print(ans)
s360322497
Accepted
18
3,064
262
s = str(input()) ans = '' for i in range(len(s)): if s[i] == '1': ans = ans + '1' elif s[i] == '0': ans = ans + '0' elif s[i] == 'B': if len(ans) >= 2: ans = ans[:-1] else: ans = '' print(ans)
s913217731
p03861
u555947166
2,000
262,144
Wrong Answer
17
2,940
161
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
a, b, x = list(map(int, input().split())) if a % x == 0: m = a // x else: m = a // x if b % x == 0: M = b // x else: M = b // x print((M-m)/x)
s403288926
Accepted
20
2,940
119
a, b, x = list(map(int, input().split())) M = b // x if a % x == 0: m = a // x - 1 else: m = a//x print(M-m)
s009575434
p03860
u643840641
2,000
262,144
Wrong Answer
18
2,940
25
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")
s064845224
Accepted
18
2,940
45
print("".join(s[0] for s in input().split()))
s461910983
p03401
u423585790
2,000
262,144
Wrong Answer
253
13,916
1,189
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.
#!usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys import math import bisect def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return sys.stdin.readline().split() def S(): return list(sys.stdin.readline()) def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] mod = 1000000007 #A """ a = IR(2) b = IR(2) print(min(a)+min(b)) """ #B """ n = I() d, x = LI() a = IR(n) ans = x for i in a: k = 0 while k * i + 1 <= d: ans += 1 k += 1 print(ans) """ #C n = I() a = LI() a.insert(0, 0) a.append(0) ans = 0 for i in range(1, n + 2): ans += abs(a[i] - a[i - 1]) print(ans) for k in range(1, n + 1): if a[k - 1] < a[k]: if a[k] > a[k + 1]: print(ans - 2 * min(abs(a[k] - a[k - 1]), abs(a[k] - a[k + 1]))) else: print(ans) if a[k - 1] > a[k]: if a[k] < a[k + 1]: print(ans - 2 * min(abs(a[k] - a[k - 1]), abs(a[k] - a[k + 1]))) else: print(ans)
s168986134
Accepted
282
13,796
1,234
#!usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys import math import bisect def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS(): return sys.stdin.readline().split() def S(): return list(sys.stdin.readline()) def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] mod = 1000000007 #A """ a = IR(2) b = IR(2) print(min(a)+min(b)) """ #B """ n = I() d, x = LI() a = IR(n) ans = x for i in a: k = 0 while k * i + 1 <= d: ans += 1 k += 1 print(ans) """ #C n = I() a = LI() a.insert(0, 0) a.append(0) ans = 0 for i in range(1, n + 2): ans += abs(a[i] - a[i - 1]) #print(ans) for k in range(1, n + 1): if a[k - 1] < a[k]: if a[k] > a[k + 1]: print(ans - 2 * min(abs(a[k] - a[k - 1]), abs(a[k] - a[k + 1]))) else: print(ans) if a[k - 1] > a[k]: if a[k] < a[k + 1]: print(ans - 2 * min(abs(a[k] - a[k - 1]), abs(a[k] - a[k + 1]))) else: print(ans) if a[k - 1] == a[k]: print(ans)
s655632027
p03400
u404034840
2,000
262,144
Wrong Answer
18
2,940
114
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()) for i in range(N): X += -(-D//int(input())) print(X) print(X)
s323436409
Accepted
19
3,060
103
N = int(input()) D,X = map(int, input().split()) for i in range(N): X += -(-D//int(input())) print(X)
s157156959
p03719
u702018889
2,000
262,144
Wrong Answer
27
9,040
64
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 a<=c>=b else "No")
s112417767
Accepted
25
9,124
64
a,b,c=map(int,input().split()) print("Yes" if a<=c<=b else "No")
s451106005
p03400
u443569380
2,000
262,144
Wrong Answer
17
3,060
204
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()) count = 0 A = [int(input()) for i in range(N)] j = 0 for i in range(N): while j * A[i] + 1 <= D: j += 1 count += 1 print(count + X)
s338505960
Accepted
18
3,060
205
N = int(input()) D,X = map(int,input().split()) count = 0 A = [int(input()) for i in range(N)] for i in range(N): j = 0 while j * A[i] + 1 <= D: j += 1 count += 1 print(count + X)
s491201943
p03377
u482157295
2,000
262,144
Wrong Answer
19
2,940
156
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.
total_sum, cats, animal = map(int,input().split()) if total_sum < cats: print("NO") elif total_sum - cats - animal < 0: print("NO") else: print("YES")
s889959136
Accepted
18
2,940
134
cats, animal, num = map(int,input().split()) if num > cats + animal: print("NO") elif cats > num: print("NO") else: print("YES")
s557312702
p02606
u259755734
2,000
1,048,576
Wrong Answer
28
9,148
56
How many multiples of d are there among the integers between L and R (inclusive)?
a, b, c = map(int, input().split()) print(b//c + a //c)
s725543529
Accepted
25
8,976
112
a, b, c = map(int, input().split()) d = 0 for i in range(a, b+1): if i % c == 0: d += 1 print(d)
s234536540
p03523
u363836311
2,000
262,144
Wrong Answer
18
3,064
351
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`?
S=list(str(input())) for i in range(9): S.append('') c=0 if S[0]!='A': c+=1 if S[1-c]!='K': c+=1 if S[2-c]!='I': c+=1 if S[3-c]!='H': c+=1 if S[4-c]!='A': c+=1 if S[5-c]!='B': c+=1 if S[6-c]!='A': c+=1 if S[7-c]!='R': c+=1 if S[8-c]!='A': c+=1 #print(c) if len(S)+c-9==9: print('Yes') else: print('No')
s149943072
Accepted
18
3,064
574
S=list(str(input())) for i in range(9): S.append('') t='' for i in range(9): if i==0 or i==4 or i==6 or i==8: if S[0]=='A': t+=S.pop(0) else: t+='A' elif i==1: if S[0]=='K': t+=S.pop(0) elif i==2: if S[0]=='I': t+=S.pop(0) elif i==3: if S[0]=='H': t+=S.pop(0) elif i==5: if S[0]=='B': t+=S.pop(0) elif i==7: if S[0]=='R': t+=S.pop(0) if t=='AKIHABARA' and len(S)==9: print('YES') else: print('NO')
s545575351
p02972
u950708010
2,000
1,048,576
Wrong Answer
2,104
7,276
555
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) return divisors def solve(): n = int(input()) a = list(int(i) for i in input().split()) ans = [0]*n for i in range(n-1,-1,-1): if a[i] == 0: continue else: tmp = i+1 div = make_divisors(tmp) for j in div: ans[j-1] = 1^ans[j-1] print(sum(ans)) for i in range(sum(ans)): print(1, end=" ") solve()
s521638136
Accepted
177
12,688
364
import sys input = sys.stdin.readline def main(): n = int(input()) A = [0] + list(int(i) for i in input().split()) for i in range(n//2,0,-1): A[i] = sum(A[i::i]) % 2 ans = [i for i, j in enumerate(A) if j] print(len(ans)) print(*ans) if __name__ == "__main__": main()
s934560251
p03471
u000037600
2,000
262,144
Wrong Answer
1,087
9,200
219
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
a,b=map(int,input().split()) c=-1 d=-1 e=-1 x=b//10000 for i in range(1,x+1,1): y=(b-10000*i)//5000 for j in range(1,y+1,1): k=(b-10000*i-5000*j)//1000 if i+j+k==a: c=i d=y e=k print(c,d,e)
s357144040
Accepted
1,069
9,188
219
a,b=map(int,input().split()) c=-1 d=-1 e=-1 x=b//10000 for i in range(0,x+1,1): y=(b-10000*i)//5000 for j in range(0,y+1,1): k=(b-10000*i-5000*j)//1000 if i+j+k==a: c=i d=j e=k print(c,d,e)
s440247843
p03502
u243699903
2,000
262,144
Wrong Answer
17
2,940
86
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
n = input() fx = 0 for s in n: fx += int(s) print('Yes' if int(n) % fx else 'No')
s060505208
Accepted
17
2,940
89
n = input() fx = 0 for s in n: fx += int(s) print('Yes' if int(n) % fx==0 else 'No')