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
s983923449
p03698
u519939795
2,000
262,144
Wrong Answer
17
2,940
159
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
import sys s=input() for i in range(len(s)+1): for j in range(len(s)+1): if s[i]==s[j]: print('no') sys.exit() print('yes')
s962151455
Accepted
17
2,940
134
#ABC063.B S = input() cnt = 0 for i in S: if S.count(i) != 1: cnt +=1 if cnt == 0: print('yes') else: print('no')
s446686574
p03836
u848173626
2,000
262,144
Wrong Answer
19
3,064
530
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement ...
from sys import stdin SX, SY, TX, TY = map(int, stdin.readline().rstrip().split()) # S->T print('U' * (TY - SY), end='') print('R' * (TX - SX), end='') # T->S print('D' * (TY - SY), end='') print('L' * (TX - SX), end='') print('L', end='') print('U' * (TY - SY + 1), end='') print('R' * (TX - SX + 1), end='') pr...
s576167548
Accepted
17
3,064
522
from sys import stdin SX, SY, TX, TY = map(int, stdin.readline().rstrip().split()) # S->T print('U' * (TY - SY), end='') print('R' * (TX - SX), end='') # T->S print('D' * (TY - SY), end='') print('L' * (TX - SX), end='') print('L', end='') print('U' * (TY - SY + 1), end='') print('R' * (TX - SX + 1), end='') pr...
s017670845
p02262
u286589639
6,000
131,072
Wrong Answer
20
5,600
454
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+...
def insertion_sort(A ,N, g): for i in range(g, N): v = A[i] j = i - g while j>=0 and A[j]>v: A[j+g] = A[j] j = j - g A[j+g] = v def shell_sort(A, N): cnt = 0 m = N//2 G = [i for i in reversed(range(1, m, 2))] for g in G: insertion_sort(A, N, g) N = int(input()) A = [int(input()) for i in range(...
s128961482
Accepted
22,860
45,516
497
def insertion_sort(A ,N, g): global cnt for i in range(g, N): v = A[i] j = i - g while j>=0 and A[j]>v: A[j+g] = A[j] j = j - g cnt += 1 A[j+g] = v def shell_sort(A, N): global cnt cnt = 0 G = [] h = 1 while h<=len(A): G.append(h) h = 3*h+1 G.reverse() m = len(G) print(m) print(' '.jo...
s839819775
p02390
u586792237
1,000
131,072
Wrong Answer
20
5,580
138
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
x = int(input()) h = x // 3600 m = (x - (h*3600))//60 s = x-((h*3600)+(m*60)) print(h, ':', m, ':', s) print(h, ':', m, ':', s, sep='')
s985973005
Accepted
20
5,588
114
x = int(input()) h = x // 3600 m = (x - (h*3600))//60 s = x-((h*3600)+(m*60)) print(h, ':', m, ':', s, sep='')
s560826771
p02578
u625864724
2,000
1,048,576
Wrong Answer
2,206
32,188
284
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a ...
n = int(input()) lst = list(map(int,input().split())) ans = 0 for i in range(n): tall = 0 for j in range(i): if (lst[j] > tall): tall = lst[j] print (i, tall) if (lst[i] < tall): sa = tall - lst[i] print(i,sa) ans = ans + sa lst[i] = tall print(ans)
s883303435
Accepted
161
32,144
210
n = int(input()) lst = list(map(int,input().split())) ans = 0 for i in range(n - 1): if (lst[i] > lst[i + 1]): sa = lst[i] - lst[i + 1] ans = ans + sa lst[i + 1] = lst[i] print(ans)
s946480299
p03360
u597047658
2,000
262,144
Wrong Answer
18
3,060
224
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after...
import heapq A = list(map(int, input().split())) A = [-a for a in A] K = int(input()) heapq.heapify(A) print(A) for i in range(K): max_val = heapq.heappop(A) heapq.heappush(A, 2*max_val) print(sum([-a for a in A]))
s237517291
Accepted
17
3,060
215
import heapq A = list(map(int, input().split())) A = [-a for a in A] K = int(input()) heapq.heapify(A) for i in range(K): max_val = heapq.heappop(A) heapq.heappush(A, 2*max_val) print(sum([-a for a in A]))
s951949203
p01102
u196653484
8,000
262,144
Wrong Answer
30
5,584
414
The programming contest named _Concours de Programmation Comtemporaine Interuniversitaire_ (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the ...
results=[] while True: a=input() if a==".": break b=input() count=0 for i,j in zip(a,b): if(a!=b): count+=1 if count==0: results.append(0) elif count==1: results.append(1) else: results.append(2) for i in results: if i==0: p...
s622750504
Accepted
30
5,596
1,019
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") count1=0 count2=0 if len(a) != len(b): results.append(2) else: for i in range(len(a)): if(i%2==1): if len(a[i]) != len(b[i]): count1+...
s787192434
p03377
u513081876
2,000
262,144
Wrong Answer
17
2,940
98
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 <= X and X <= A+B: print('Yes') else: print('No')
s962694027
Accepted
17
2,940
98
A, B, X = map(int, input().split()) if A <= X and X <= A+B: print('YES') else: print('NO')
s208362457
p03612
u955125992
2,000
262,144
Wrong Answer
51
14,008
127
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two **adjacent** elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
n = int(input()) p = list(map(int, input().split())) ans = 0 for i in range(n): if i == p[i]: ans += 1 print(ans)
s342132612
Accepted
73
14,004
206
n = int(input()) p = list(map(int, input().split())) ans = 0 for i in range(n-1): if i+1 == p[i]: p[i], p[i+1] = p[i+1], p[i] ans += 1 if p[n-1] == n: ans += 1 print(ans)
s202800417
p03457
u727551259
2,000
262,144
Wrong Answer
450
11,816
478
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...
n = int(input()) ti,xi,yi = [0],[0],[0] ans = 'NO' for ni in range(n): t,x,y = [int(x) for x in input().split()] ti.append(t) xi.append(x) yi.append(y) for i in range(n): dt = ti[i+1] - ti[i] dx = xi[i+1] - xi[i] dy = yi[i+1] - yi[i] if dt < abs(dx)+abs(dy): break odev1 = (xi[i]+yi[i])%2 odev2 =...
s044920149
Accepted
441
11,728
478
n = int(input()) ti,xi,yi = [0],[0],[0] ans = 'No' for ni in range(n): t,x,y = [int(x) for x in input().split()] ti.append(t) xi.append(x) yi.append(y) for i in range(n): dt = ti[i+1] - ti[i] dx = xi[i+1] - xi[i] dy = yi[i+1] - yi[i] if dt < abs(dx)+abs(dy): break odev1 = (xi[i]+yi[i])%2 odev2 =...
s060851670
p03637
u239375815
2,000
262,144
Wrong Answer
75
14,252
233
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()) a = list(map(int,input().split())) a_n4 = a_4 = [x for x in a if x%4!=0] a_4 = [x for x in a if x%4==0] a_2 = [x for x in a if x%4!=0 and x%2==0] print("Yes "if (len(a_n4)-1-(int(len(a_2)/2))<=len(a_4)) else "No")
s865007864
Accepted
60
15,020
278
N = int(input()) a = list(map(int, input().split())) c = [0,0,0,0] for x in a: c[x % 4] += 1 # if (c[1]==0) and (c[3]==0): # print('Yes') if c[1] + c[3] < c[0] + 1: print('Yes') elif (c[1] + c[3] == c[0] + 1)and(c[2] == 0): print('Yes') else: print('No')
s398507147
p03449
u905203728
2,000
262,144
Wrong Answer
19
3,064
308
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You ...
n=int(input()) box=[list(map(int,input().split())) for i in range(2)] count=box[0][0] point=-1 add=0 for j in range(n): for i in range(n): if add<=i: count +=box[1][i] else: count +=box[0][i] point=max(point,count) count=box[0][0] add +=1 print(point)
s547577492
Accepted
20
3,064
310
n=int(input()) box=[list(map(int,input().split())) for i in range(2)] count=box[0][0] point=-1 add=0 for j in range(n): for i in range(n): if add<=i: count +=box[1][i] else: count +=box[0][i+1] point=max(point,count) count=box[0][0] add +=1 print(point)
s014761454
p02602
u038216098
2,000
1,048,576
Wrong Answer
2,206
31,548
234
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the m...
N,K=map(int,input().split()) A=list(map(int,input().split())) point=[1]*N for i in range(K-1,N): for j in range(K): point[i]*=A[i-j] for i in range(N-K-2,N-1): if(point[i]>=point[i+1]): print("No") else: print("Yes")
s066100657
Accepted
147
31,756
155
N,K=map(int,input().split()) A=list(map(int,input().split())) point=[1]*N for i in range(N-K): if(A[K+i]>A[i]): print("Yes") else: print("No")
s348347758
p03844
u533039576
2,000
262,144
Wrong Answer
17
2,940
13
Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
eval(input())
s285055337
Accepted
17
2,940
21
print(eval(input()))
s828260923
p02795
u575101291
2,000
1,048,576
Wrong Answer
20
3,316
104
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all t...
h = int(input()) w = int(input()) n = int(input()) if h < w: t = n / w else: t = n / h print(int(t))
s090362995
Accepted
17
3,060
123
import math h = int(input()) w = int(input()) n = int(input()) if h < w: t = n / w else: t = n / h print(math.ceil(t))
s035435965
p03860
u331464808
2,000
262,144
Wrong Answer
17
2,940
40
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 uppe...
s = input() print("A" + str(s[0]) + "C")
s521662914
Accepted
17
2,940
53
a,x,c=map(str,input().split()) print('A'+ x[0] + 'C')
s891786161
p03674
u075012704
2,000
262,144
Wrong Answer
2,109
32,380
561
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 s...
from statistics import mode from scipy.misc import comb N = int(input()) A = list(map(int, input().split())) MOD = 10 ** 9 C = mode(A) C_indexes = [i for i, x in enumerate(A) if x == C] outside = C_indexes[0] + len(A) - C_indexes[1] - 1 for k in range(1, len(A)+1): if k > outside + 1: print(comb((N+1)...
s744882268
Accepted
305
31,324
796
N = int(input()) A = list(map(int, input().split())) MOD = 10 ** 9 + 7 duplicate_x = None checked = set() for a in A: if a in checked: duplicate_x = a checked.add(a) x_l_index = A.index(duplicate_x) x_r_index = N + 1 - A[::-1].index(duplicate_x) - 1 factorial = [1, 1] inverse = [1, 1] invere_base...
s460658553
p02261
u294922877
1,000
131,072
Wrong Answer
20
5,612
1,199
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 Bubbl...
def bubble_sort(n, key=0): c = 0 r = [x if isinstance(x, list) else [x] for x in n[:]] l = len(r) - 1 for i in range(0, l): for j in range(l, i, -1): if r[j][key] < r[j-1][key]: r[j], r[j-1] = r[j-1], r[j] c += 1 r = [x[0] if len(x) == 1 else x for...
s960394481
Accepted
20
5,616
1,201
def bubble_sort(n, key=0): c = 0 r = [x if isinstance(x, list) else [x] for x in n[:]] l = len(r) - 1 for i in range(0, l): for j in range(l, i, -1): if r[j][key] < r[j-1][key]: r[j], r[j-1] = r[j-1], r[j] c += 1 r = [x[0] if len(x) == 1 else x for...
s941733337
p03548
u756988562
2,000
262,144
Wrong Answer
17
3,060
197
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two...
input_lines = input().split(" ") X = int(input_lines[0]) Y = int(input_lines[1]) Z = int(input_lines[2]) judge = X//(Y) if judge*(Y+Z)>=Z: print(str(X//(Y+Z)-1)) else: print(str(X//(Y+Z)))
s047206028
Accepted
17
2,940
202
input_lines = input().split(" ") X = int(input_lines[0]) Y = int(input_lines[1]) Z = int(input_lines[2]) judge = X//(Y+Z) if judge*(Y+Z)+Z>X: print(str(X//(Y+Z)-1)) else: print(str(X//(Y+Z)))
s925754360
p03369
u948911484
2,000
262,144
Wrong Answer
25
8,884
29
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 ...
print(700+input().count("o"))
s870511309
Accepted
24
9,028
41
print([7,8,9,10][input().count("o")]*100)
s426114435
p02397
u042882066
1,000
131,072
Wrong Answer
60
7,652
109
Write a program which reads two integers x and y, and prints them in ascending order.
while True: x, y = map(int, input().split(" ")) if x == 0 and y == 0: break print(x, y)
s986515807
Accepted
60
7,612
181
# -*- coding: utf-8 -*- while True: x, y = map(int, input().split(" ")) if x == 0 and y == 0: break elif x <= y: print(x, y) elif x >= y: print(y, x)
s844267679
p03007
u606045429
2,000
1,048,576
Wrong Answer
232
13,964
617
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...
N = int(input()) A = [int(i) for i in input().split()] A.sort() L = [a for a in A if a <= 0] R = [a for a in A if a > 0] if L != [] and R != []: low = L[0] for r in R[:-1]: print(low, r) low -= r up = R[-1] for l in L[1:]: print(up, l) up -= l print(up, low) ...
s106425612
Accepted
307
24,016
746
N = int(input()) A = [int(i) for i in input().split()] A.sort() L = [a for a in A if a <= 0] R = [a for a in A if a > 0] ans = [] if L != [] and R != []: low = L[0] for r in R[:-1]: ans.append([low, r]) low -= r up = R[-1] for l in L[1:]: ans.append([up, l]) up -= l ...
s707729913
p02407
u853619096
1,000
131,072
Wrong Answer
20
7,524
81
Write a program which reads a sequence and prints it in the reverse order.
n=input() n=int(n) a=input().split() a=a[::-1] for i in a: print(" ".join(a))
s541308233
Accepted
20
7,636
76
n=int(input()) a=list(map(str,input().split())) a=a[::-1] print(" ".join(a))
s201514092
p02612
u878473776
2,000
1,048,576
Wrong Answer
26
9,164
95
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input("")) if N % 1000 == 0: N1 = N // 1000 else: N1 = N // 1000 + 1 print(N1)
s384324305
Accepted
31
9,124
106
N = int(input("")) if N % 1000 == 0: N1 = N // 1000 else: N1 = N // 1000 + 1 print(N1 * 1000 - N)
s180342043
p04044
u022871813
2,000
262,144
Wrong Answer
17
3,060
132
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 sm...
n, l = map(int,input().split()) list = [] for i in range(n): a = input() list.append(a) for i in sorted(list): print(i)
s377386699
Accepted
17
3,060
125
n, l = map(int,input().split()) list = [] for i in range(n): a = input() list.append(a) print(''.join(sorted(list)))
s881254886
p03574
u637551956
2,000
262,144
Wrong Answer
24
3,188
1,667
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 con...
H,W = map(int, input().split()) S = [list(input()) for i in range(H)] S=[[0 if j == "." else "#" for j in i] for i in S] for i in range(H): for j in range(W): if S[i][j]=='#': try:S[i-1][j-1] except IndexError:pass else: if i-1...
s863312092
Accepted
25
3,572
1,692
H,W = map(int, input().split()) S = [list(input()) for i in range(H)] S=[[0 if j == "." else "#" for j in i] for i in S] for i in range(H): for j in range(W): if S[i][j]=='#': try:S[i-1][j-1] except IndexError:pass else: if i-1...
s873417098
p02409
u092736322
1,000
131,072
Wrong Answer
20
5,608
409
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth fl...
n=int(input()) S=[] for i in range(1200): S.append(0) for i in range(n): k=input().split() b=int(k[0]) f=int(k[1]) r=int(k[2]) v=int(k[3]) S[(b-1)*30+(f-1)*10+r-1]+=v for i in range(4): for j in range(3): msg="" for t in range(9): msg+=str(S[i*30+j*10+t])+" ...
s965441481
Accepted
20
5,604
393
n=int(input()) S=[] for i in range(1200): S.append(0) for i in range(n): k=input().split() b=int(k[0]) f=int(k[1]) r=int(k[2]) v=int(k[3]) S[(b-1)*30+(f-1)*10+r-1]+=v for i in range(4): for j in range(3): msg="" for t in range(10): msg+=" "+str(S[i*30+j*10+t...
s397470814
p03644
u865413330
2,000
262,144
Wrong Answer
17
2,940
210
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...
n = int(input()) count = 0 currCount = 0 for i in range(n): currCount = 0 while i % 2 != 0: i = int(i / 2) currCount += 1 if count < currCount: count = currCount print(count)
s956216876
Accepted
17
3,060
296
n = int(input()) count = 0 currCount = 0 ans = 0 for i in range(n+1): currCount = 0 currNum = i while (i % 2) == 0: if i == 0: break i = int(i / 2) currCount += 1 if count <= currCount: count = currCount ans = currNum print(ans)
s177911106
p03597
u717626627
2,000
262,144
Wrong Answer
17
2,940
49
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
a = int(input()) b = int(input()) print(a^2 - b)
s734445527
Accepted
17
2,940
49
a = int(input()) b = int(input()) print(a*a - b)
s749504771
p03474
u056486147
2,000
262,144
Wrong Answer
18
3,060
326
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
a, b = map(int, input().split()) s = list(input()) print(s) print(len(s), a+b+1) flag = True if len(s) == a+b+1: if s[a] == "-": s.pop(a) for i in s: if i == "-": flag = False else: flag = False else: flag = False if flag: print("Yes") else: print(...
s068371991
Accepted
18
2,940
319
import sys a, b = map(int, input().split()) s = list(input()) if len(s) == a+b+1: if s[a] == "-": s.pop(a) for i in s: if i == "-": print("No") sys.exit() else: print("No") sys.exit() else: print("No") sys.exit() print("Yes")
s927786355
p03370
u253952966
2,000
262,144
Wrong Answer
18
2,940
141
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams o...
n, x = map(int, input().split()) mn = [] for _ in range(n): mi = int(input()) mn.append(mi) mn.sort() x -= sum(mn) print(n + (x % mn[0]))
s725284889
Accepted
18
2,940
142
n, x = map(int, input().split()) mn = [] for _ in range(n): mi = int(input()) mn.append(mi) mn.sort() x -= sum(mn) print(n + (x // mn[0]))
s445656750
p03485
u374146618
2,000
262,144
Wrong Answer
17
2,940
66
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()] x = (a+b)/2 print(x//1+1)
s456911962
Accepted
17
2,940
110
a, b = [int(x) for x in input().split()] x = (a+b)/2 if x%1==0: print(int(x)) else: print(int(x//1+1))
s034344095
p03456
u762474234
2,000
262,144
Wrong Answer
17
2,940
172
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
import math a, b = input().split() c = int(a + b) square_root = math.sqrt(c) # print(c/square_root, square_root) print('YES') if square_root.is_integer() else print('NO')
s669032642
Accepted
17
2,940
172
import math a, b = input().split() c = int(a + b) square_root = math.sqrt(c) # print(c/square_root, square_root) print('Yes') if square_root.is_integer() else print('No')
s337216561
p04043
u518958552
2,000
262,144
Wrong Answer
17
2,940
221
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 ...
a, b, c = map(int,input().split()) if a == 5 and b == 7 and c == 5: print("Yes") elif a == 5 and b == 5 and c == 7: print("Yes") elif a == 7 and b == 5 and c == 5: print("Yes") else: print("No")
s240913636
Accepted
17
2,940
132
a, b, c = map(int,input().split()) d = [a, b, c] if d.count(5) == 2 and d.count(7) == 1: print("YES") else: print("NO")
s880785767
p03943
u842696304
2,000
262,144
Wrong Answer
17
2,940
126
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Not...
x = list(input().split()) x.sort() if int(x[0]) + int(x[1]) == int(x[2]): print('YES') else: print('FALSE') print(x)
s341185995
Accepted
17
2,940
119
a, b, c = map(int, input().split()) if a + b == c or b + c == a or c + a == b: print("Yes") else: print("No")
s466541235
p02288
u357267874
2,000
131,072
Wrong Answer
30
5,604
773
A binary heap which satisfies max-heap property is called max-heap. In a max- heap, for every node $i$ other than the root, $A Write a program which reads an array and constructs a max-heap from the array based on the following pseudo code. $maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tr...
def get_left_index(A, i): if len(A) > 2 * i: return 2 * i else: return None def get_right_index(A, i): if len(A) > 2 * i + 1: return 2 * i + 1 else: return None def max_heapfy(A, i): left = get_left_index(A, i) right = get_right_index(A, i) largest = i i...
s635196351
Accepted
1,200
64,160
756
def get_left_index(A, i): if len(A) > 2 * i: return 2 * i else: return None def get_right_index(A, i): if len(A) > 2 * i + 1: return 2 * i + 1 else: return None def max_heapfy(A, i): left = get_left_index(A, i) right = get_right_index(A, i) largest = i i...
s772676751
p02865
u448751328
2,000
1,048,576
Wrong Answer
21
3,316
85
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
N = int(input()) if N % 2 == 0: ans = N / 2 - 1 else: ans = (N -1) / 2 print(ans)
s020301845
Accepted
18
3,064
71
N=int(input()) if N%2==0: print(N//2-1) else: print((N+1)//2-1)
s141688080
p03543
u565380863
2,000
262,144
Wrong Answer
17
2,940
4
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
1234
s663789335
Accepted
17
2,940
106
#-*- coding: utf-8 -*- N = input() print('Yes' if N[0] == N[1] == N[2] or N[1] == N[2] == N[3] else 'No')
s848553784
p03401
u143492911
2,000
262,144
Wrong Answer
2,104
19,808
281
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...
n=int(input()) a=list(map(int,input().split())) ans=[] a.sort() cnt=0 for i in range(n): v=a[i] a[i]=0 a.sort() for j in range(1,n): cnt+=a[j]-a[j-1] print(cnt) ans.append(cnt+(max(a)-min(a))) cnt=0 a[i]=v for i in ans: print(i)
s859810469
Accepted
216
14,048
223
n=int(input()) a=list(map(int,input().split())) a.insert(0,0) a.insert(n+1,0) total=0 for i in range(n+1): total+=abs(a[i+1]-a[i]) for i in range(n): print(total-abs(a[i+1]-a[i])-abs(a[i+2]-a[i+1])+abs(a[i+2]-a[i]))
s700654759
p03759
u629709614
2,000
262,144
Wrong Answer
17
2,940
86
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
a, b, c = map(int, input().split()) if b-a == c-a: print("YES") else: print("NO")
s812293212
Accepted
17
2,940
86
a, b, c = map(int, input().split()) if b-a == c-b: print("YES") else: print("NO")
s335110353
p03854
u899395423
2,000
262,144
Wrong Answer
80
3,188
345
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
s = input() s = s[::-1] words = ["dream", "dreamer", "erase", "eraser"] words = [w[::-1] for w in words] lens = [len(w) for w in words] while True: for l, w in zip(lens, words): if s[:l] == w: s = s[l:] break else: print("No") break if len(s) == 0: p...
s496662948
Accepted
83
3,316
345
s = input() s = s[::-1] words = ["dream", "dreamer", "erase", "eraser"] words = [w[::-1] for w in words] lens = [len(w) for w in words] while True: for l, w in zip(lens, words): if s[:l] == w: s = s[l:] break else: print("NO") break if len(s) == 0: p...
s346474431
p03657
u717626627
2,000
262,144
Wrong Answer
17
2,940
128
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them ca...
a, b = map(int, input().split()) if a % 3 == 0 or b % 3 == 0 or a + b % 3 == 0: print('Possible') else: print('Impossible')
s677877937
Accepted
17
2,940
130
a, b = map(int, input().split()) if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0: print('Possible') else: print('Impossible')
s193860091
p03637
u219607170
2,000
262,144
Wrong Answer
69
15,020
208
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()) A = list(map(int, input().split())) four, odd = 0, 0 for a in A: if a%4 == 0: four += 1 elif a%2 == 1: odd += 1 result = 'No' if four > odd else 'Yes' print('result')
s653363903
Accepted
65
15,020
257
N = int(input()) A = list(map(int, input().split())) four, two, odd = 0, 0, 0 for a in A: if a%4 == 0: four += 1 elif a%2 == 0: two += 1 else: odd += 1 result = 'Yes' if four + 1 >= odd + bool(two) else 'No' print(result)
s132657025
p03737
u702786238
2,000
262,144
Wrong Answer
17
2,940
83
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
s = input() s.upper().split(" ") print("{}{}{}".format(s[0][0], s[1][0], s[2][0]))
s129069150
Accepted
17
2,940
88
s = input() s = s.upper().split(" ") print("{}{}{}".format(s[0][0], s[1][0], s[2][0]))
s272715292
p03737
u363836311
2,000
262,144
Wrong Answer
17
2,940
95
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
s1,s2,s3=map(str, input().split()) S1=list(s1) S2=list(s2) S3=list(s3) print(S1[0]+S2[0]+S3[0])
s918920961
Accepted
17
2,940
135
s1,s2,s3=map(str, input().split()) S1=list(s1) S2=list(s2) S3=list(s3) print(chr(ord(S1[0])-32)+chr(ord(S2[0])-32)+chr(ord(S3[0])-32))
s557740880
p03657
u798260206
2,000
262,144
Wrong Answer
26
9,164
168
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them ca...
a,b = map(int,input().split()) Flag = "Impossible" if a%3==0: Flag = "Possible" elif b%3 ==0: Flag="Possible" elif (a+b)%3: Flag = "Possible" print(Flag)
s695192039
Accepted
22
9,132
172
a,b = map(int,input().split()) Flag = "Impossible" if a%3==0: Flag = "Possible" elif b%3 ==0: Flag="Possible" elif (a+b)%3==0: Flag = "Possible" print(Flag)
s509203331
p03475
u581187895
3,000
262,144
Wrong Answer
113
3,188
548
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i t...
import math N = int(input()) CSF = [list(map(int, input().split())) for _ in range(N-1)] for i in range(N): t = 0 for j in range(i, N-1): c, s, f = CSF[j] if t <= s: t = s+c else: t += math.ceil(t / f) * f + c print(t)
s846190009
Accepted
88
3,188
547
import math N = int(input()) CSF = [list(map(int, input().split())) for _ in range(N-1)] for i in range(N): t = 0 for j in range(i, N-1): c, s, f = CSF[j] if t <= s: t = s+c else: t = math.ceil(t / f) * f + c print(t)
s504075519
p03645
u257974487
2,000
262,144
Wrong Answer
2,106
52,620
374
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
N, M = map(int,input().split()) P = [list(map(int,input().split())) for _ in range(M)] P.sort() Q = [] s = 0 ans = ("IMPOSSIBLE") for i in range (M): if P[i][0] == 1: Q.append(P[i][1]) else: s = i - 1 break if s > 0: for j in range(s, M): if P[j][1] == N: if P[j][...
s301061127
Accepted
1,174
52,616
639
N, M = map(int,input().split()) P = [list(map(int,input().split())) for _ in range(M)] P.sort() q = -1 ans = ("IMPOSSIBLE") for i in range (M): if P[i][0] == 1: p = P[i][1] if q < 0: if i > 0: q = i - 1 else: q = 0 for j in range(q, M):...
s552954041
p03416
u201234972
2,000
262,144
Wrong Answer
111
3,740
143
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
A,B = map(int,input().split()) ans = 0 for x in range(A,B+1): x = str(x) print(x) if x[:1] == x[:2:-1]: ans += 1 print(ans)
s508432199
Accepted
65
2,940
130
A,B = map(int,input().split()) ans = 0 for x in range(A,B+1): x = str(x) if x[:2] == x[:2:-1]: ans += 1 print(ans)
s372490203
p02608
u111652094
2,000
1,048,576
Wrong Answer
2,031
9,216
548
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
import math N=int(input()) for i in range(1,N+1): ans=0 if i<=5: print(0) else: ma=int(math.sqrt(i)/6) for x in range(1,ma): for y in range(x,ma): for z in range(y,ma): if x**2+y**2+z**2+x*y+y*z+z*x==i: if x=...
s022472906
Accepted
198
9,348
474
import math N=int(input()) anslist=[0]*(N+1) ma=int(math.sqrt(N))+1 for x in range(1,ma): for y in range(x,ma): for z in range(y,ma): n=x**2+y**2+z**2+x*y+y*z+z*x if n <=N: if x==y and y==z: anslist[n]+=1 elif x==y or y==z or z...
s933019076
p03599
u136090046
3,000
262,144
Wrong Answer
17
3,064
413
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 bea...
ABCDEF = input() split_ABCDEF = ABCDEF.split() int_split_ABCDEF = [int(i) for i in split_ABCDEF] A = int_split_ABCDEF[0]*100 B = int_split_ABCDEF[1]*100 C = int_split_ABCDEF[2] D = int_split_ABCDEF[3] E = int_split_ABCDEF[4] F = int_split_ABCDEF[5] if A > B: sugar = int((B / 100) * E) print("{} {}".format(sug...
s864454293
Accepted
340
39,648
840
def solve(): A, B, C, D, E, F = map(int, input().split()) memo = {} for a in range(31): for b in range(31): for c in range(101): for d in range(101): w = (100 * A) * a + (100 * B) * b s = C * c + D * d if w == 0...
s354467169
p03080
u317587743
2,000
1,048,576
Wrong Answer
17
2,940
120
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
N = int(input()) s = list(input()) r = s.count('R') b = s.count('B') if r > b: print('YES') else: print('NO')
s635286887
Accepted
17
2,940
120
N = int(input()) s = list(input()) r = s.count('R') b = s.count('B') if r > b: print('Yes') else: print('No')
s054437622
p02659
u297651868
2,000
1,048,576
Wrong Answer
23
9,164
81
Compute A \times B, truncate its fractional part, and print the result as an integer.
a,b=map(float,input().split()) left=a//100*b right=a%100*b print(int(left+right))
s944073948
Accepted
27
9,752
74
from decimal import Decimal a,b=map(Decimal,input().split()) print(a*b//1)
s983429924
p02613
u165436807
2,000
1,048,576
Wrong Answer
150
16,024
214
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`,...
n = int(input()) s = [0]*n for i in range(n): s[i] = input() ac = s.count('AC') wa = s.count('WA') tle = s.count('TLE') re = s.count('RE') print('AC x',ac) print('WA x',wa) print('TLE x',tle) print('Re x',re)
s569081540
Accepted
147
16,088
214
n = int(input()) s = [0]*n for i in range(n): s[i] = input() ac = s.count('AC') wa = s.count('WA') tle = s.count('TLE') re = s.count('RE') print('AC x',ac) print('WA x',wa) print('TLE x',tle) print('RE x',re)
s685373556
p03471
u616522759
2,000
262,144
Wrong Answer
2,104
3,060
328
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 situat...
N, Y = map(int, input().split()) ans = '-1 -1 -1' for i in range(N + 1): if ans != '-1 -1 -1': break for j in range(N + 1): for k in range(N + 1): if Y == 10000 * i + 5000 * j + 1000 * k \ and i + j + k <= N: ans = str(i) + ' ' + str(j) + ' ' + str(k) pr...
s967599352
Accepted
1,365
3,060
299
N, Y = map(int, input().split()) ans = '-1 -1 -1' for i in range(N + 1): for j in range(N + 1): if Y == 10000 * i + 5000 * j + 1000 * (N - i - j)\ and i + j + (N - i - j) <= N\ and N - i - j >= 0: ans = str(i) + ' ' + str(j) + ' ' + str(N - i - j) print(ans)
s425499607
p02389
u435300817
1,000
131,072
Wrong Answer
20
7,592
111
Write a program which calculates the area and perimeter of a given rectangle.
input_height_width = input() height, width = [int(x) for x in input_height_width.split()] print(height * width)
s098961731
Accepted
20
7,644
112
values = input() height, width = [int(x) for x in values.split()] print(height * width, height * 2 + width * 2)
s790941918
p02392
u192877548
1,000
131,072
Wrong Answer
30
7,636
146
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
# coding: utf-8 a,b,c = map(int,input().split()) if a < b: if b < c: print("YES") else: print("NO") else: print("NO")
s233321890
Accepted
20
7,640
156
# coding: utf-8 a,b,c = map(int,input().split()) if a < b and a < c: if b < c: print("Yes") else: print("No") else: print("No")
s696765142
p02388
u630518143
1,000
131,072
Wrong Answer
20
5,596
322
Write a program which calculates the cube of a given integer x.
x = int(input("整数xを入力してください。(0<=x<=100):")) while not(0<=x and x<=100): print("0<=x<=100を満たす整数を入力してください。") x = int(input("整数xを入力してください。(0<=x<=100):")) x = x ** 3 print(str(x) + "の3乗は" + str(x) + "です。")
s925347446
Accepted
20
5,576
35
x = int(input()) x = x**3 print(x)
s216104514
p02578
u724088399
2,000
1,048,576
Wrong Answer
29
9,176
155
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a ...
A = list(map(int,input().split())) sm = 0 now = A[0] for num in A: if num < now: sm += now-num elif num > now: now = num print(sm)
s079866888
Accepted
104
32,220
172
N = int(input()) A = list(map(int,input().split())) sm = 0 now = A[0] for num in A: if num < now: sm += now-num elif num > now: now = num print(sm)
s508245986
p03478
u840310460
2,000
262,144
Wrong Answer
17
3,060
262
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 = [int(i) for i in input().split()] def func_10(x): ans = 0 while x/10 != 0: ans += x % 10 x = x//10 return ans ans = 0 for i in (1, N+1): if A <= func_10(i) <= B: ans += i print(ans)
s995689448
Accepted
29
2,940
235
N, A, B = [int(i) for i in input().split()] def func_de(n): ans = 0 while n/10 != 0: ans += n % 10 n //= 10 return ans ANS = 0 for i in range(N+1): if A <= func_de(i) <= B: ANS += i print(ANS)
s447342192
p02390
u822442916
1,000
131,072
Wrong Answer
20
7,680
73
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
S=int(input()) h=S/3600 k=S//3600 m=k/60 s=k-m print("%d:%d:%d" %(h,m,s))
s704594958
Accepted
40
7,684
73
S=int(input()) h=S/3600 k=S%3600 m=k/60 s=k%60 print("%d:%d:%d" %(h,m,s))
s373533578
p03455
u747602774
2,000
262,144
Wrong Answer
17
2,940
119
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
import math s=list(input()) X=int(s[0]+s[1]) root=math.sqrt(X) a=root//1 if a**2!=X: print('No') else: print('Yes')
s381465032
Accepted
17
2,940
81
x,y = map(int,input().split()) if x*y%2==0: print('Even') else: print('Odd')
s145951453
p03861
u633450100
2,000
262,144
Wrong Answer
17
2,940
115
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 = [int(i) for i in input().split()] if (b-a) % x == 0: print((b-a) // x) else: print((b-a) // x + 1)
s312378485
Accepted
17
2,940
127
a,b,x = [int(i) for i in input().split()] if a % x == 0: A = a // x else: A = a // x + 1 B = b // x print(B - A + 1)
s644017821
p03457
u871867619
2,000
262,144
Wrong Answer
700
29,584
523
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...
import numpy as np N = int(input()) travel_list = [np.array([0, 0, 0])] add_list = [np.array([int(i) for i in input().split()]) for i in range(N)] travel_list.extend(add_list) def is_travel(arr1, arr2): dt, dx, dy = abs(arr2 - arr1) if dt <= dx + dy: return False elif dt % 2 != (dx + dy) % 2: ...
s045849113
Accepted
1,406
29,564
539
import numpy as np N = int(input()) travel_list = [np.array([0, 0, 0])] add_list = [np.array([int(i) for i in input().split()]) for i in range(N)] travel_list.extend(add_list) def is_travel(arr1, arr2): dt, dx, dy = abs(arr2 - arr1) if dt < dx + dy: return False elif dt % 2 != (dx + dy) % 2: ...
s729307755
p03612
u513434790
2,000
262,144
Wrong Answer
168
14,008
428
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two **adjacent** elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
N = int(input()) p = tuple(map(int, input().split())) a = list(p) b = list(p) c = 0 for i in range(N): if i+1 == a[i] and i == N-1: c += 1 elif i+1 == a[i]: a[i], a[i+1] = a[i+1], a[i] c += 1 cc = 0 for i in range(N)[::-1]: if i+1 == b[i] and i == 0: cc += 1 elif...
s372502019
Accepted
130
14,132
411
N = int(input()) p = tuple(map(int, input().split())) a = list(p) b = list(p) c = 0 for i in range(N): if i+1 == a[i] and i == N-1: c += 1 elif i+1 == a[i]: a[i], a[i+1] = a[i+1], a[i] c += 1 cc = 0 for i in range(N)[::-1]: if i+1 == b[i] and i == 0: cc += 1 elif...
s083368030
p02865
u929585607
2,000
1,048,576
Wrong Answer
17
2,940
22
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
print(int(input())//2)
s902358224
Accepted
17
2,940
26
print((int(input())-1)//2)
s560147228
p03049
u228223940
2,000
1,048,576
Wrong Answer
38
3,828
561
Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
import re N = int(input()) s = [input() for _ in range(N)] tmp = 0 print(s[1],s[1][-1:],s[1][0:1]) B_A = 0 B_any = 0 any_A = 0 for i in range(N): tmp = tmp + s[i].count("AB") if s[i][0:1] == "B": if s[i][-1:] == "A": B_A = B_A + 1 else: B_any = B_any + 1 elif s[i...
s467543949
Accepted
38
3,956
469
import re N = int(input()) s = [input() for _ in range(N)] tmp = 0 B_A = 0 B_any = 0 any_A = 0 for i in range(N): tmp = tmp + s[i].count("AB") if s[i][0:1] == "B": if s[i][-1:] == "A": B_A = B_A + 1 else: B_any = B_any + 1 elif s[i][-1:] == "A": any_A = an...
s577738630
p03693
u896741788
2,000
262,144
Wrong Answer
17
2,940
75
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 i...
a,s,d=map(int,input().split()) print("YES") if 10*s+d%4==0 else print("NO")
s069314628
Accepted
17
2,940
77
a,s,d=map(int,input().split()) print("YES") if (10*s+d)%4==0 else print("NO")
s803813019
p02845
u535236942
2,000
1,048,576
Wrong Answer
2,108
14,396
201
N people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green. The person numbered i says: * "In front of me, exactly A_i people are wearing hats with the same color as mine." Assuming that all these statements are correct, find the number of p...
n = int(input()) a = list(map(int,input().split())) ans = 1 for i in range(n): if a[:i].count(a[i]) == 2: ans = ans*3%1000000007 if a[:i].count(a[i]) == 1: ans = ans*2%1000000007 print(ans)
s089389363
Accepted
194
14,396
412
n = int(input()) a = list(map(int,input().split())) mod = 1000000007 ans = 1 l = [] for i in range(n): if a[i] == 0: l.append(0) ans = ans*(4-len(l))%mod else: id = -1 count = 0 for j in range(len(l)): if l[j] == a[i] - 1: count += 1 id = j if id == -1: ans = 0 ...
s578341497
p03457
u335973735
2,000
262,144
Wrong Answer
453
39,456
482
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...
N = int(input()) z_t = []*N t0 = 0 x0 = 0 y0 = 0 ans = 'NO' for i in range(N): s = input().rstrip().split() z_t.append(s) print(z_t) for i in range(N): dt = int(z_t[i][0]) - t0 dx = int(z_t[i][1]) - x0 dy = int(z_t[i][2]) - y0 extra_t = dt - (dx+dy) if extra_t >= 0 and extra_t%2 == 0: ...
s168546270
Accepted
412
32,144
478
N = int(input()) z_t = []*N t0 = 0 x0 = 0 y0 = 0 ans = 'No' for i in range(N): s = input().rstrip().split() z_t.append(s) for i in range(N): dt = int(z_t[i][0]) - t0 dx = abs(int(z_t[i][1]) - x0) dy = abs(int(z_t[i][2]) - y0) extra_t = dt - (dx+dy) if extra_t >= 0 and extra_t%2 == 0: ...
s498857940
p03696
u580225095
2,000
262,144
Wrong Answer
17
3,060
250
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of...
# -*- coding: utf-8 -*- x = int(input()) y = input() z = y while z.find("()") != -1: z = z.replace("()","") a = z.count("(") b = z.count(")") ans = z for i in range(a): ans = ans + ")" for i in range(b): ans = "(" + ans print(ans)
s543302317
Accepted
17
3,060
250
# -*- coding: utf-8 -*- x = int(input()) y = input() z = y while z.find("()") != -1: z = z.replace("()","") a = z.count("(") b = z.count(")") ans = y for i in range(a): ans = ans + ")" for i in range(b): ans = "(" + ans print(ans)
s098490102
p03547
u202877219
2,000
262,144
Wrong Answer
18
3,060
104
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`,...
a,b = map(str, input().split()) if a>b: print (">") elif b<a: print ("<") else: print ("=")
s085563504
Accepted
17
2,940
108
x,y = map(str, input().split()) if x>y: print (">") elif x < y: print ("<") else: print ("=")
s692279587
p03471
u350049649
2,000
262,144
Wrong Answer
765
3,060
202
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 situat...
N,Y=map(int,input().split()) a1=-1 a2=-1 a3=-1 for a in range(N+1): for b in range(N-a,N+1): c=N-a-b if a*10000+b*5000+c*1000==Y: a1=a a2=b a3=c break print(a1,a2,a3)
s520515793
Accepted
759
3,060
200
N,Y=map(int,input().split()) a1=-1 a2=-1 a3=-1 for a in range(N+1): for b in range(N-a+1): c=N-a-b if a*10000+b*5000+c*1000==Y: a1=a a2=b a3=c break print(a1,a2,a3)
s844743716
p03168
u589303510
2,000
1,048,576
Wrong Answer
1,627
222,760
463
Let N be a positive odd number. There are N coins, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), when Coin i is tossed, it comes up heads with probability p_i and tails with probability 1 - p_i. Taro has tossed all the N coins. Find the probability of having more heads than tails.
def coins(n,prob): dp = [[0]*(n+1) for _ in range(n+1)] dp[0][0] = 1 for i in range(1,n+1): for j in range(i+1): if j == 0: dp[i][j] = dp[i-1][j]*prob[i-1] else: dp[i][j] = dp[i-1][j]*(1-prob[i-1])+dp[i-1][j-1]*prob[i-1] total = 0 for ...
s254566404
Accepted
1,607
222,560
467
def coins(n,prob): dp = [[0]*(n+1) for _ in range(n+1)] dp[0][0] = 1 for i in range(1,n+1): for j in range(i+1): if j == 0: dp[i][j] = dp[i-1][j]*(1-prob[i-1]) else: dp[i][j] = dp[i-1][j]*(1-prob[i-1])+dp[i-1][j-1]*prob[i-1] total = 0 ...
s195933623
p03847
u786020649
2,000
262,144
Wrong Answer
30
9,188
441
You are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusive OR. Since it can be extremely large, compute the answer modulo 10^9+7.
import sys p=10**9+7 dthbit=lambda d,n: (n>>d)&1 def main(n): dp=[[0 for _ in range(3)] for _ in range(64)] dp[63][0]=1 for d in range(62,-1,-1): b=dthbit(d,n) s=dp[d+1][:] dp[d][0]=dp[d+1][0]+(1^b)*dp[d+1][1] % p dp[d][1]=b*dp[d+1][0]+dp[d+1][1] % p dp[d][2]=(1+b)*...
s843596843
Accepted
29
9,176
408
import sys p=10**9+7 dthbit=lambda d,n: (n>>d)&1 def main(n): dp=[[0 for _ in range(3)] for _ in range(64)] dp[63][0]=1 for d in range(62,-1,-1): b=dthbit(d,n) s=dp[d+1][:] dp[d][0]=dp[d+1][0]+(1^b)*dp[d+1][1] % p dp[d][1]=b*dp[d+1][0]+dp[d+1][1] % p dp[d][2]=(1+b)*...
s261826424
p03352
u802772880
2,000
1,048,576
Wrong Answer
17
3,064
229
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
X=int(input()) l2=[1,2,4,8,16,32,64,128,256,512] l3=[3,9,27,81,243,729] l5=[5,25,125,625] l6=[6,36,216] l7=[7,49,343] l10=[10,100,1000] le=[n*n for n in range(11,32)] l=l2+l3+l5+l6+l7+l10+le m=max([i for i in l if i<=X]) print(m)
s148607886
Accepted
18
2,940
151
X=int(input()) Y=1 for b in range(1,X): for p in range(2,X): if b**p<=X: Y=max(Y,b**p) else: break print(Y)
s981577920
p03069
u528005130
2,000
1,048,576
Wrong Answer
78
12,836
455
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so t...
# coding: utf-8 # Your code here! N = int(input()) S = [x for x in input()] cum_white = [] count = 0 for i, s in enumerate(S): if s == '.': count += 1 cum_white.append(count) if len(cum_white) == 0 or len(cum_white) == N: print(0) else: min_num = int(1e10) for i, n_white in enumerate(...
s158393411
Accepted
180
12,396
385
# coding: utf-8 # Your code here! N = int(input()) S = ['.'] + [x for x in input()] + ['#'] cum_white = [] count = 0 for i, s in enumerate(S): if s == '#': count += 1 cum_white.append(count) min_num = int(1e10) for i, n_white in enumerate(cum_white): num = n_white + (N + 1 - i - (cum_white[-1...
s816832679
p02393
u731896389
1,000
131,072
Wrong Answer
20
7,304
36
Write a program which reads three integers, and prints them in ascending order.
n= input().split() n.sort() print(n)
s281758227
Accepted
30
7,644
63
a=list(map(int,input().split())) a.sort() print(a[0],a[1],a[2])
s919249252
p03644
u475675023
2,000
262,144
Wrong Answer
19
2,940
75
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...
n=int(input()) for i in range(9): if 2**i >= n: print(2**i) break
s048486483
Accepted
17
2,940
64
n=int(input()) m=1 while 2**m<=n: m+=1 else: print(2**(m-1))
s946659324
p03369
u023229441
2,000
262,144
Wrong Answer
17
2,940
37
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 ...
print(700+(input().count("○"))*100)
s342247335
Accepted
17
2,940
36
print(700+(input().count("o"))*100)
s792245876
p03493
u284363684
2,000
262,144
Wrong Answer
30
9,020
52
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.
# input S = list(input()) print(S.count(1))
s127624880
Accepted
25
8,996
54
# input S = list(input()) print(S.count("1"))
s880213233
p03474
u187516587
2,000
262,144
Wrong Answer
17
3,060
323
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
p=input().split() A=int(p[0]) B=int(p[1]) S=input() if S[A]=="-": t=S.split('-') if len(t)==2: a,b=int(t[0]),int(t[1]) print(a) if 10**(A-1)<=a<10**A and 10**(B-1)<=b<10**B: print("Yes") else: print("No") else: print("No") else: print("No...
s891752581
Accepted
17
3,060
175
p=input().split() A=int(p[0]) B=int(p[1]) S=input() if S[A]=="-": t=S.split('-') if len(t)==2: print("Yes") else: print("No") else: print("No")
s356867701
p03407
u077075933
2,000
262,144
Wrong Answer
17
2,940
68
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
A, B, C = map(int, input().split()) print("YES" if C<+A+B else "NO")
s986739614
Accepted
17
2,940
68
A, B, C = map(int, input().split()) print("Yes" if C<=A+B else "No")
s577240503
p02601
u005569385
2,000
1,048,576
Wrong Answer
30
9,136
293
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successfu...
A,B,C = map(int,input().split()) K = int(input()) for i in range(0,K+1): A = A*(2*i) for j in range(0,K+1): B = B*(2*j) for h in range(0,K+1): C = C*(2*h) if (i+j+h) <= K and C>B>A: print("Yes") exit() print("No")
s961739469
Accepted
31
9,192
252
A,B,C = map(int,input().split()) K = int(input()) for i in range(0,K+1): for j in range(0,K+1): for h in range(0,K+1): if A*(2**i)<B*(2**j)<C*(2**h) and (i+j+h)<=K: print("Yes") exit() print("No")
s360254824
p03759
u394482932
2,000
262,144
Wrong Answer
17
2,940
43
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.
for s in input().split():print(s[0],end='')
s822734946
Accepted
17
2,940
58
a,b,c=map(int,input().split());print('YNEOS'[b-a!=c-b::2])
s862093787
p03658
u492030100
2,000
262,144
Wrong Answer
17
2,940
135
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
N, K = map(int, input().split()) L = [l for l in range(N)] L.sort(reverse=True) ans = 0 for i in range(K): ans += L[i] print(ans)
s041152239
Accepted
18
2,940
147
N, K = map(int, input().split()) L = [int(l) for l in input().split()] L.sort(reverse=True) ans = 0 for i in range(K): ans += L[i] print(ans)
s575734686
p02842
u671211357
2,000
1,048,576
Wrong Answer
17
3,060
266
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer)....
import math N = int(input()) kari = N*100/108 hako = math.ceil(kari) ans = math.floor(kari) if hako*108/100==N or ans*108/100==N: print(kari) elif math.floor(hako*108/100)==N: print(hako) elif math.floor(ans*108/100)==N: print(ans) else: print(":(")
s102884812
Accepted
17
3,060
378
import math N = int(input()) kari = N*100/108 hako = math.ceil(kari) ans = math.floor(kari) if hako*108/100==N or ans*108/100==N: print(math.floor(kari)) elif math.floor(hako*108/100)==N: print(hako) elif math.floor(ans*108/100)==N: print(ans) # print(hako) # print(ans) else: print(":(")
s193631754
p03469
u498575211
2,000
262,144
Wrong Answer
17
2,940
31
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 col...
S = input() print("2018"+S[5:])
s820371018
Accepted
17
2,940
31
S = input() print("2018"+S[4:])
s101841550
p02613
u377989038
2,000
1,048,576
Wrong Answer
143
16,612
213
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`,...
from collections import Counter as ct n = int(input()) s = ct([input() for _ in range(n)]) print("AC x " + str(s["AC"])) print("WA x " + str(s["wA"])) print("TLE x " + str(s["TLE"])) print("RE x " + str(s["RE"]))
s139659295
Accepted
143
16,508
213
from collections import Counter as ct n = int(input()) s = ct([input() for _ in range(n)]) print("AC x " + str(s["AC"])) print("WA x " + str(s["WA"])) print("TLE x " + str(s["TLE"])) print("RE x " + str(s["RE"]))
s147743229
p03486
u239528020
2,000
262,144
Wrong Answer
25
9,092
208
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) s = list(str(input())) t = str(input()) s.sort() s = "".join(s) ans = sorted([s, t]) if ans[0] == t: print("No") else: print("Yes")
s058066570
Accepted
30
9,072
263
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) s = list(str(input())) t = list(str(input())) s.sort() t.sort(reverse=True) s = "".join(s) t = "".join(t) ans = sorted([s, t]) # print(ans) if ans[0] == t: print("No") else: print("Yes")
s606374258
p04029
u824147251
2,000
262,144
Wrong Answer
37
3,064
33
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
n = int(input()) print((n+1)*n/2)
s378277987
Accepted
42
3,444
34
n = int(input()) print((n+1)*n//2)
s204546982
p02255
u734765925
1,000
131,072
Wrong Answer
20
7,628
229
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 ...
n = int(input()) A = list(map(int,input().split())) temp = 0 for i in range(1,n): temp = A[i] j = i -1 while j >=0 and A[j] > temp : A[j+1]=A[j] j-=1 A[j+1] = temp print(" ".join(map(str,A)))
s331689025
Accepted
30
7,660
256
n = int(input()) A = list(map(int,input().split())) temp = 0 print(" ".join(map(str,A))) for i in range(1,n): temp = A[i] j = i -1 while j >=0 and A[j] > temp : A[j+1]=A[j] j-=1 A[j+1] = temp print(" ".join(map(str,A)))
s070782881
p03048
u902468164
2,000
1,048,576
Wrong Answer
890
3,060
163
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g...
r,g,b,n=[int(i) for i in input().split(" ")] res = 0 for i in range(0,n+1,r): for j in range(i,n+1,g): if j % b == 0: res += 1 print(res)
s141532350
Accepted
958
2,940
169
r,g,b,n=[int(i) for i in input().split(" ")] res = 0 for i in range(0,n+1,r): for j in range(i,n+1,g): if (n-j) % b == 0: res += 1 print(res)
s648067977
p03457
u780675733
2,000
262,144
Wrong Answer
435
27,380
422
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...
N = int(input()) Input = [] for i in range(N): Input.append(list(map(int,input().split()))) x = 0 y = 0 t = 0 for i in Input: dif_x = abs(x - i[1]) dif_y = abs(y - i[2]) dif_t = abs(t - i[0]) if dif_x + dif_y <= dif_t and (dif_x + dif_y)%2 == dif_t%2: x = i[1] y = i[2] t ...
s227703883
Accepted
442
27,380
394
N = int(input()) Input = [] for i in range(N): Input.append(list(map(int,input().split()))) x = 0 y = 0 t = 0 for i in Input: dif_x = abs(x - i[1]) dif_y = abs(y - i[2]) dif_t = abs(t - i[0]) if dif_x + dif_y <= dif_t and (dif_x + dif_y)%2 == dif_t%2: x = i[1] y = i[2] t ...
s365086804
p03643
u301823349
2,000
262,144
Wrong Answer
17
2,940
118
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
N = int(input()) p = 0 while True: if N < 2**p: print(2**(p-1)) break else: p=p+1
s688066500
Accepted
17
2,940
28
N = input() print("ABC" + N)
s936772673
p03162
u469953228
2,000
1,048,576
Wrong Answer
959
50,332
304
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...
N = int(input()) dp = [[0] * 3 for _ in range(N+1)] A = [list(map(int,input().split())) for _ in range(N)] for i in range(N): for j in range(3): for k in range(3): if j == k: continue dp[i+1][k] = max(dp[i+1][k], dp[i][k] + A[i][j]) print(max(dp[N]))
s996135608
Accepted
980
50,336
304
N = int(input()) dp = [[0] * 3 for _ in range(N+1)] A = [list(map(int,input().split())) for _ in range(N)] for i in range(N): for j in range(3): for k in range(3): if j == k: continue dp[i+1][k] = max(dp[i+1][k], dp[i][j] + A[i][k]) print(max(dp[N]))
s050432332
p02608
u388971072
2,000
1,048,576
Wrong Answer
31
9,244
243
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
N = int(input()) N_list = [0]*(N+1) for i in range(1,11): for j in range(1,11): for k in range(1,11): if(i**2+j**2+k**2+i*j+j*k+k*i<=N): N_list[i**2+j**2+k**2+i*j+j*k+k*i]+=1 for i in N_list: print(i)
s116003770
Accepted
1,027
9,292
250
N = int(input()) N_list = [0]*(N+1) for i in range(1,101): for j in range(1,101): for k in range(1,101): if(i**2+j**2+k**2+i*j+j*k+k*i<=N): N_list[i**2+j**2+k**2+i*j+j*k+k*i]+=1 for i in N_list[1:]: print(i)
s037132831
p02393
u255164080
1,000
131,072
Wrong Answer
30
6,720
46
Write a program which reads three integers, and prints them in ascending order.
nums = input().split() nums.sort() print(nums)
s419016480
Accepted
30
6,724
224
nums = input().split() a = int(nums[0]) b = int(nums[1]) c = int(nums[2]) if a > b: tmp = a a = b b = tmp if b > c: tmp = b b = c c = tmp if a > b: tmp = a a = b b = tmp print(a, b, c)
s739158398
p02613
u068844030
2,000
1,048,576
Wrong Answer
136
16,160
234
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`,...
n = int(input()) s = [input() for i in range(n)] AC = s.count("AC") WA = s.count("WA") TLE = s.count("TLE") RE = s.count("RE") print("AC × " + str(AC)) print("WA × " + str(WA)) print("TLE × " + str(TLE)) print("RE × " + str(RE))
s983307635
Accepted
146
16,052
293
n = int(input()) s = [input() for i in range(n)] AC = s.count("AC") WA = s.count("WA") TLE = s.count("TLE") RE = s.count("RE") AC2 = "AC x " + str(AC) WA2 = "WA x " + str(WA) TLE2 = "TLE x " + str(TLE) RE2 = "RE x " + str(RE) list = [AC2,WA2,TLE2,RE2] list_n = "\n".join(list) print(list_n)
s152640402
p03160
u830054172
2,000
1,048,576
Wrong Answer
2,104
109,972
243
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...
n = int(input()) a = list(map(int, input().split())) dp = [0]*n for i in range(n): if i >= 2: dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2]+abs(a[i]-a[i-2])) elif i == 1: dp[i] = a[i]-a[i-1] print(dp) print(dp[-1])
s105303366
Accepted
181
13,928
264
N = int(input()) h = list(map(int, input().split())) + [0]*100010 dp = [float("inf")]*100010 dp[0] = 0 for i in range(N): dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i])) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i])) # print(dp) print(dp[N-1])