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
s452894294
p03386
u385309449
2,000
262,144
Wrong Answer
17
3,060
172
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
a,b,k = map(int,input().split()) aa = [i for i in range(a,a+k+1) if i <= b] bb = [i for i in range(b-k+1,b+1) if i >= a] c = list(sorted(set(aa+bb))) for i in c: print(i)
s930121978
Accepted
17
3,060
170
a,b,k = map(int,input().split()) aa = [i for i in range(a,a+k) if i <= b] bb = [i for i in range(b-k+1,b+1) if i >= a] c = list(sorted(set(aa+bb))) for i in c: print(i)
s831426262
p02407
u661284763
1,000
131,072
Wrong Answer
20
7,340
73
Write a program which reads a sequence and prints it in the reverse order.
input() a = input().split() a.reverse() for b in a: print(b, end='_')
s984230832
Accepted
50
7,452
58
input() a = input().split() a.reverse() print(" ".join(a))
s914920600
p03779
u064963667
2,000
262,144
Wrong Answer
114
3,960
101
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
x = int(input()) num = 1 while num**2+num < 2*x: print(num,num**2-num) num += 1 print(num)
s332212356
Accepted
39
2,940
88
import math x = int(input()) num = 1 while num**2+num < 2*x: num += 1 print(num)
s515527188
p03089
u720829795
2,000
1,048,576
Wrong Answer
17
3,064
458
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
N = int(input()) tmp = input().split() b = [] for i in range(N): b.append(tmp[i]) for index, item in enumerate(b): if int(item) > index+1: print('-1') exit() idx_top = 0 idx_bottom = len(b)-1 print(b[idx_top]) idx_top += 1 for i in range(len(b)-1): if b[idx_top] >= b[idx_bottom]: print(b[idx_top]) if idx_top < idx_bottom: idx_top += 1 else: print(b[idx_bottom]) if idx_bottom > idx_top: idx_bottom -= 1
s867756645
Accepted
17
3,064
292
N = int(input()) tmp = input().split() b = [] ans = [] for i in range(N): b.append(tmp[i]) for index, item in enumerate(b): if int(item) > index+1: print('-1') exit() dist = index + 1 - int(item) ans.insert(index-dist, int(item)) for i in range(len(ans)): print(ans[i])
s519204929
p02742
u771007149
2,000
1,048,576
Wrong Answer
17
2,940
260
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
h,w = map(int,input().split()) if h%2 == 0 or w%2 == 0: if h%2 == 0: result = (h/2) * w print(result) else: result = (w/2) * h print(result) else: result = h//2 * (w//2) + (h-h//2) * (w -w//2) print(result)
s842520054
Accepted
18
3,064
299
h,w = map(int,input().split()) if h == 1 or w == 1: print(1) elif h%2 == 0 or w%2 == 0: if h%2 == 0: result = (h//2) * w print(result) else: result = (w//2) * h print(result) else: result = (h//2) * (w//2) + (h - h//2) * (w - w//2) print(result)
s659181129
p03816
u311442150
2,000
262,144
Wrong Answer
38
16,484
88
Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written. He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept. Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.
n=int(input()) a=list(input().split()) ans=len(set(a)) if ans%2==0: ans-1 print(ans)
s111957400
Accepted
37
16,312
93
n=int(input()) a=list(input().split()) ans=len(set(a)) if ans%2 == 0: ans -= 1 print(ans)
s680402166
p03698
u374082254
2,000
262,144
Wrong Answer
16
2,940
128
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
S = input() a = [] result = "Yes" for s in S: if s in a: result = "No" break a.append(s) print(result)
s879811663
Accepted
18
2,940
128
S = input() a = [] result = "yes" for s in S: if s in a: result = "no" break a.append(s) print(result)
s210559509
p03957
u579299997
1,000
262,144
Wrong Answer
22
3,064
223
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters.
s = input() print(s) state = 0 for c in s: if c == 'C': if state == 0: state = 1 if c == 'F': if state == 1: state = 2 if state == 2: print('Yes') else: print('No')
s674766059
Accepted
22
3,064
214
s = input() state = 0 for c in s: if c == 'C': if state == 0: state = 1 if c == 'F': if state == 1: state = 2 if state == 2: print('Yes') else: print('No')
s814897077
p03067
u733774002
2,000
1,048,576
Wrong Answer
17
2,940
107
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
a, b, c = map(int, input().split()) if(a <= b <= c or c <= b <= a): print("Yes") else: print("No")
s619152046
Accepted
17
2,940
107
a, b, c = map(int, input().split()) if(a <= c <= b or b <= c <= a): print("Yes") else: print("No")
s964602332
p03369
u945065638
2,000
262,144
Wrong Answer
30
8,904
55
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().split() s = s.count('o') print(700 + 100*s)
s523004078
Accepted
25
8,864
47
s = input() s = s.count('o') print(700 + 100*s)
s681587947
p02747
u399481362
2,000
1,048,576
Wrong Answer
17
2,940
12
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
print(input)
s012358443
Accepted
17
2,940
209
s = input() isEmpty = False if 'hi' not in s: print("No") isEmpty = True s = s.split('hi') s = set(s) if not isEmpty: if '' in s and len(s) == 1: print("Yes") else: print("No")
s518818221
p03860
u355661029
2,000
262,144
Wrong Answer
17
2,940
47
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
s = input().split(' ') print('A' + s[0] + 'C')
s677653395
Accepted
21
2,940
50
s = input().split(' ') print('A' + s[1][0] + 'C')
s638716085
p03251
u063052907
2,000
1,048,576
Wrong Answer
17
3,060
246
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.
# coding: utf-8 import sys input = sys.stdin.readline _, _, X, Y = map(int, input().split()) lst_x = list(map(int, input().split())) lst_y = list(map(int, input().split())) if max(lst_x) < min(lst_y): print("No war") else: print("War")
s397304783
Accepted
18
3,060
206
# coding: utf-8 N, M, X, Y = map(int, input().split()) x = max(list(map(int, input().split())) + [X]) y = min(list(map(int, input().split())) + [Y]) ans = "War" if x < y: ans = "No War" print(ans)
s861016067
p02422
u328199937
1,000
131,072
Wrong Answer
20
5,604
629
Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
def Reverse(str, A, B): a = int(A) b = int(B) str = str[0:a] + str[b::-1] + str[b + 1:] print(str) return str def Replace(str, a, b, c): str2 = '' Str = list(str) for i in range(int(b) - int(a) + 1): Str[i + int(a)] = c[i] for i in range(len(Str)): str2 += Str[i] return str2 str = input() n = int(input()) for i in range(n): a = input() A = a.split() if A[0] == 'print': print(str[int(A[1]):int(A[2]) + 1]) elif A[0] == 'reverse': str = Reverse(str, A[1], A[2]) elif A[0] == 'replace': str = Replace(str, A[1], A[2], A[3])
s187858381
Accepted
20
5,624
696
def Reverse(str, A, B): a = int(A) b = int(B) if a == 0: str = str[0:a] + str[b::-1] + str[b + 1:] else: str = str[0:a] + str[b:a - 1:-1] + str[b + 1:] return str def Replace(str, a, b, c): str2 = '' Str = list(str) for i in range(int(b) - int(a) + 1): Str[i + int(a)] = c[i] for i in range(len(Str)): str2 += Str[i] return str2 str = input() n = int(input()) for i in range(n): a = input() A = a.split() if A[0] == 'print': print(str[int(A[1]):int(A[2]) + 1]) elif A[0] == 'reverse': str = Reverse(str, A[1], A[2]) elif A[0] == 'replace': str = Replace(str, A[1], A[2], A[3])
s576082538
p03854
u581603131
2,000
262,144
Wrong Answer
2,104
3,188
228
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`.
#9 S = input() while len(S)!=0: if S[0:5] == 'dream' or S[0:5] == 'erase': S = S[5:] elif S[0:6] == 'eraser': S = S[6:] elif S[0:7] == 'dreamer': S = S[7:] print('Yes' if len(S)==0 else 'No')
s245201523
Accepted
69
3,188
273
#9 S = input()[::-1] for i in range(0, len(S)//5+1): if S[0:5] == 'maerd' or S[0:5] == 'esare': S = S[5:] elif S[0:6] == 'resare': S = S[6:] elif S[0:7] == 'remaerd': S = S[7:] else: break print('YES' if len(S)==0 else 'NO')
s683395017
p03555
u073139376
2,000
262,144
Wrong Answer
17
2,940
43
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.
print(['No','Yes'][input()==input()[::-1]])
s023120040
Accepted
17
2,940
43
print(['NO','YES'][input()==input()[::-1]])
s537742420
p03549
u078349616
2,000
262,144
Wrong Answer
17
2,940
77
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
N, M = map(int, input().split()) ans = pow(2, M) * (1900 * M + 100 * (N - M))
s156446288
Accepted
17
2,940
79
N, M = map(int, input().split()) print(pow(2, M) * (1900 * M + 100 * (N - M)))
s511563962
p03730
u371467115
2,000
262,144
Wrong Answer
18
2,940
87
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
a,b,c=map(int,input().split()) if abs(b-c)%a==0: print("YES") else: print("NO")
s375427207
Accepted
17
2,940
139
a,b,c=map(int,input().split()) for i in range(1,b+1): if (a*i)%b==c: print("YES") break else: print("NO")
s739054504
p03251
u958612488
2,000
1,048,576
Wrong Answer
18
3,060
183
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
n,m,x,y=list(map(int,input().split(" "))) X=list(map(int,input().split(" "))) Y=list(map(int,input().split(" "))) if x<y and max(X)<min(Y): print("War") else: print("No War")
s537985414
Accepted
18
3,060
209
n,m,x,y=list(map(int,input().split(" "))) X=list(map(int,input().split(" "))) Y=list(map(int,input().split(" "))) if x<y and max(X)<min(Y) and max(X)<y and x<min(Y): print("No War") else: print("War")
s145263383
p03494
u661983922
2,000
262,144
Wrong Answer
17
2,940
54
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 = input() lst = map(int,input().split()) print(lst)
s572916027
Accepted
19
2,940
201
N = input() lst = list(map(int,input().split())) counter = 0 while all([x%2 == 0 for x in lst]): counter += 1 for k in range(int(N)): a = lst[k] / 2 lst[k] = a print(counter)
s152537072
p03386
u706695185
2,000
262,144
Wrong Answer
21
3,316
782
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.
from collections import deque a, b, c = map(int, input().split()) def bfs(a, b, c): cnt = 0 queue = deque([[a, b, c, cnt]]) while queue: a, b, c, cnt = queue.popleft() if a == b and b == c: return cnt if a >= 52 or b >= 52 or c >= 52: return cnt if b > a and b > c: queue.append([a+1, b, c+1, cnt+1]) elif a > b and a > b: queue.append([a, b+1, c+1, cnt+1]) elif c > a and c > b: queue.append([a+1, b+1, c, cnt+1]) elif a < b or a < c: queue.append([a+2, b, c, cnt+1]) elif b < a or b < c: queue.append([a, b+2, c, cnt+1]) elif c < a or c < b: queue.append([a, b, c+2, cnt+1]) print(bfs(a, b, c))
s911026121
Accepted
17
3,060
235
A, B, K = map(int, input().split()) if B - A < K*2: for i in range(A, B+1): print(i) else: for a in range(A, A+K): if a > B: break print(a) for b in range(B-K+1, B+1): print(b)
s167464412
p03759
u583507988
2,000
262,144
Wrong Answer
18
2,940
96
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 abs(b-a) == abs(c-b): print("Yes") else: print("No")
s394997340
Accepted
24
9,128
86
a, b, c = map(int, input().split()) if b-a == c-b: print('YES') else: print('NO')
s153266278
p03337
u989326345
2,000
1,048,576
Wrong Answer
18
3,064
121
You are given two integers A and B. Find the largest value among A+B, A-B and A \times B.
A,B=map(int,input().split()) S=A+B T=A-B U=A*B if S>T & S>U: print(S) elif T>S & T>U: print(T) else: print(U)
s264700457
Accepted
18
3,060
133
A,B=map(int,input().split()) S=A+B T=A-B U=A*B if (S>=T) & (S>=U): print(S) elif (T>=S) & (T>=U): print(T) else: print(U)
s134361279
p04029
u993161647
2,000
262,144
Wrong Answer
17
2,940
88
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('Input N > ')) list_N = [ x for x in range(1, N+1) ] print( sum(list_N) )
s026314676
Accepted
17
3,064
75
N = int(input()) list_N = [ x for x in range(1, N+1) ] print( sum(list_N) )
s894212047
p02262
u316584871
6,000
131,072
Wrong Answer
20
5,608
908
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+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
def insertionSort(A, n, g): cnti = 0 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 -= g cnti += 1 A[j+g] = v return cnti def shellSort(A,n): cnt = 0 G = [] for k in range(int((n+2)/3)): h = 3*k + 1 if (h < n and len(G) <= 100): G.append(h) elif(len(G) > 100): break m = len(G) for i in range(m): cnt += insertionSort(A, n, G[m-1-i]) print(m) for i in range(m): if (i == m-1): print('{}'.format(G[i]), end = '') else: print('{}'.format(G[i]), end = ' ') return cnt n = int(input()) nlist = [] for i in range(n): x = int(input()) nlist.append(x) c = shellSort(nlist,n) print() print(c) for i in nlist: print(i)
s270458733
Accepted
18,410
45,532
1,034
def insertionSort(A, n, g): cnti = 0 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 -= g cnti += 1 A[j+g] = v return cnti def shellSort(A,n): cnt = 0 G = [1] h = 1 for k in range(int(n**0.33333333)+1): h = 3*h + 1 if (h <= n and len(G) < 100): G.append(h) elif(len(G) == 100): break G.reverse() m = len(G) for i in range(m): cnt += insertionSort(A, n, G[i]) print(m) for i in range(m): if (i == m-1): print('{}'.format(G[i]), end = '') else: print('{}'.format(G[i]), end = ' ') return cnt n = int(input()) nlist = [] for i in range(n): x = int(input()) nlist.append(x) c = shellSort(nlist,n) print() print(c) for i in nlist: print(i)
s045656727
p03139
u325264482
2,000
1,048,576
Wrong Answer
17
2,940
104
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
N, A, B = list(map(int, input().split())) ans1 = min(A, B) ans2 = max(N - A - B, 0) print(ans1, ans2)
s274555189
Accepted
17
2,940
80
N, A, B = list(map(int, input().split())) print(min(A, B), max(- N + A + B, 0))
s062140962
p03435
u652081898
2,000
262,144
Wrong Answer
18
3,064
466
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
x = [] for i in range(3): x.append(list(map(int, input().split()))) cond1 = bool(x[0][1]-x[0][0] == x[0][2]-x[0][1]) cond2 = bool(x[1][1]-x[1][0] == x[1][2]-x[1][1]) cond3 = bool(x[2][1]-x[2][0] == x[2][2]-x[2][1]) cond4 = bool(x[1][0]-x[0][0] == x[2][0]-x[1][0]) cond5 = bool(x[1][1]-x[0][1] == x[2][1]-x[1][1]) cond6 = bool(x[1][2]-x[0][2] == x[2][2]-x[1][2]) if cond1 and cond2 and cond3 and cond4 and cond5 and cond6: print("Yes") else: print("No")
s570269783
Accepted
18
3,064
525
x = [] for i in range(3): x.append(list(map(int, input().split()))) A = x[0][1]-x[0][0] B = x[1][1]-x[1][0] C = x[2][1]-x[2][0] D = x[0][2]-x[0][1] E = x[1][2]-x[1][1] F = x[2][2]-x[2][1] G = x[1][0]-x[0][0] H = x[1][1]-x[0][1] I = x[1][2]-x[0][2] J = x[2][0]-x[1][0] K = x[2][1]-x[1][1] L = x[2][2]-x[1][2] cond1 = bool(A == B and B == C) cond2 = bool(D == E and E == F) cond3 = bool(G == H and H == I) cond4 = bool(J == K and K == L) if cond1 and cond2 and cond3 and cond4: print("Yes") else: print("No")
s958156222
p03448
u561992253
2,000
262,144
Wrong Answer
49
3,060
204
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()) v = int(input()) ans = 0 for i in range(a): for j in range(b): for k in range(c): if 500*a + 100*b + 50*c == v: ans += 1 print(ans)
s204444626
Accepted
52
3,060
210
a = int(input()) b = int(input()) c = int(input()) v = int(input()) ans = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if 500*i + 100*j + 50*k == v: ans += 1 print(ans)
s120290229
p03351
u933341648
2,000
1,048,576
Wrong Answer
17
2,940
115
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(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d) else 'No')
s551956347
Accepted
17
2,940
115
a, b, c, d = map(int, input().split()) print('Yes' if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d) else 'No')
s537550796
p02850
u151625340
2,000
1,048,576
Wrong Answer
2,106
37,044
481
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.
N = int(input()) 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) import copy ans = [0]*N def dfs(i,visited_i,color): ans[i] = color visited = copy.deepcopy(visited_i) visited[i] += 1 c = 1 for j in G[i]: if visited[j]: continue if c==color: c += 1 dfs(j,visited,c) c += 1 dfs(0,[0]*N,1) for i in range(N): print(ans[i])
s029220727
Accepted
443
80,628
696
import sys, copy, math, heapq, bisect from itertools import accumulate from collections import deque, defaultdict, Counter input = sys.stdin.readline sys.setrecursionlimit(500000) N = int(input()) G = [dict() for i in range(N)] for i in range(N-1): a,b = map(int,input().split()) G[a-1][b-1] = i G[b-1][a-1] = i ans = [0]*(N-1) visited = [0]*N def dfs(i,color): visited[i] += 1 c = 1 for j in G[i]: if visited[j]: continue if c==color: c += 1 ans[G[i][j]] = c dfs(j,c) c += 1 dfs(0,0) print(max(ans)) for i in range(N-1): print(ans[i])
s564052572
p03729
u973108807
2,000
262,144
Wrong Answer
17
2,940
94
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
a,b,c = input().split() if a[-1] == b[0] and b[-1] == c[0]: print('Yes') else: print('No')
s158098243
Accepted
17
2,940
94
a,b,c = input().split() if a[-1] == b[0] and b[-1] == c[0]: print('YES') else: print('NO')
s299357422
p02396
u138628845
1,000
131,072
Wrong Answer
90
5,908
215
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.
v = 0 i = 0 x = [] while v == 0: a = input() if 0 == int(a): v = 1 else: x.append(int(a)) i = int(i) + 1 for j in range(int(i)): print('case %d: %d' % (int(j)+1,x[int(j)] ))
s247774483
Accepted
90
5,904
215
v = 0 i = 0 a = [] while v == 0: x = input() if 0 == int(x): v = 1 else: a.append(int(x)) i = int(i) + 1 for j in range(int(i)): print('Case %d: %d' % (int(j)+1,a[int(j)] ))
s990407849
p03413
u596276291
2,000
262,144
Wrong Answer
28
4,204
2,220
You have an integer sequence of length N: a_1, a_2, ..., a_N. You repeatedly perform the following operation until the length of the sequence becomes 1: * First, choose an element of the sequence. * If that element is at either end of the sequence, delete the element. * If that element is not at either end of the sequence, replace the element with the sum of the two elements that are adjacent to it. Then, delete those two elements. You would like to maximize the final element that remains in the sequence. Find the maximum possible value of the final element, and the way to achieve it.
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys.setrecursionlimit(10000) INF = float("inf") YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0] dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1] def inside(y, x, H, W): return 0 <= y < H and 0 <= x < W def ceil(a, b): return (a + b - 1) // b def check(A, operations): for o in operations: if o == 1: A = A[1:] elif o == len(A): A = A[:len(A) - 1] else: o -= 1 A = A[:o - 1] + [A[o - 1] + A[o + 1]] + A[o + 2:] print(A) assert(len(A) == 1) return A[0] def main(): N = int(input()) A = list(map(int, input().split())) ans1 = 0 del1 = [] ok1 = False for i in range(0, N, 2): if A[i] >= 0: ans1 += A[i] ok1 = True else: del1.append(i + 1) ans2 = 0 del2 = [1] ok2 = False for i in range(1, N, 2): if A[i] >= 0: ans2 += A[i] ok2 = True else: del2.append(i + 1) del1 = del1[::-1] del2 = del2[::-1] ans, dele = None, None if ok1 and ok2: if ans1 > ans2: ans, dele = ans1, del1 else: ans, dele = ans2, del2 elif ok1: ans, dele = ans1, del1 elif ok2: ans, dele = ans2, del2 if not ok1 and not ok2: ans = max(A) idx = A.index(ans) print(ans) a = [] for i in range(N, 0, -1): if i != idx + 1: a.append(i) print(len(a)) print(*a, sep="\n") else: print(ans) e = int(1 in dele) + int(N in dele) for i in range((N - (len(dele) - e) * 2 - e) // 2): dele.append(2) print(len(dele)) print(*dele, sep="\n") if __name__ == '__main__': main()
s510372810
Accepted
28
4,204
2,362
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys.setrecursionlimit(10000) INF = float("inf") YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0] dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1] def inside(y, x, H, W): return 0 <= y < H and 0 <= x < W def ceil(a, b): return (a + b - 1) // b def check(A, operations): c = A[:] for o in operations: if o == 1: A = A[1:] elif o == len(A): A = A[:len(A) - 1] else: o -= 1 A = A[:o - 1] + [A[o - 1] + A[o + 1]] + A[o + 2:] if len(A) != 1: print(c) print(operations) assert(len(A) == 1) return A[0] def solve(N, A): if max(A) < 0: ans = max(A) idx = A.index(ans) operations = [] for i in range(N, idx + 1, -1): operations.append(i) for i in range(1, idx + 1): operations.append(1) return ans, operations ans = 0 middle = [] start, end = None, None for i in range(0, N, 2): if A[i] >= 0: ans += A[i] if start is None: start = i end = i else: if start is not None: middle.append(i) operations = [] num = 0 for i in range(end + 1, N): operations.append(N - num) num += 1 for i in middle[::-1]: if start < i < end: operations.append(i + 1) num += 2 for i in range(start): operations.append(1) num += 1 for i in range((N - num) // 2): operations.append(2) return ans, operations def main(): N = int(input()) A = list(map(int, input().split())) ans1, ope1 = solve(N, A[:]) ans2, ope2 = solve(N - 1, A[1:]) ope2 = [1] + ope2 if ans1 > ans2: print(ans1) print(len(ope1)) print(*ope1, sep="\n") else: print(ans2) print(len(ope2)) print(*ope2, sep="\n") if __name__ == '__main__': main()
s567938705
p02394
u556014061
1,000
131,072
Wrong Answer
40
7,532
120
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
W, H, r, x, y = map(int, input().split()) if r <= x <= W - r and r <= y <= H - r: print("Yes") else: print("No")
s034879945
Accepted
20
7,676
112
w,h,x,y,r = map(int, input().split()) if r <= x <= w-r and r <= y <= h-r: print("Yes") else: print("No")
s959689406
p02690
u129898499
2,000
1,048,576
Wrong Answer
22
9,444
250
Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X.
X = int(input()) d = int(X**(1/5))+2 list = [0]*d for i in range(d): list[i] = i**5 for i in range(d): for j in range(i,d): if list[j]-list[i] == X: print(i,j) break elif list[i]+list[j] == X: print(i,-j) break
s258053525
Accepted
157
9,200
235
X = int(input()) d= 10**3 list = [0]*d for i in range(d): list[i] = i**5 for i in range(d): for j in range(i,d): if list[j]-list[i] == X: print(j,i) break elif list[i]+list[j] == X: print(j,-i) break
s380009759
p02831
u772816188
2,000
1,048,576
Wrong Answer
18
3,060
320
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.
import sys input = sys.stdin.readline sys.setrecursionlimit(10000) A, B = map(int, input().split()) tmp_a, tmp_b = A, B print(tmp_a, tmp_b) while tmp_a % tmp_b != 0: tmp_a, tmp_b = tmp_b, tmp_a % tmp_b # temp = B # B = A % B # A = temp print(int(A * B / tmp_b))
s929837312
Accepted
17
3,060
254
import sys input = sys.stdin.readline sys.setrecursionlimit(10000) A, B = map(int, input().split()) tmp_a, tmp_b = A, B while tmp_a % tmp_b != 0: tmp_a, tmp_b = tmp_b, tmp_a % tmp_b print(int(A * B / tmp_b))
s035565203
p03599
u127499732
3,000
262,144
Wrong Answer
3,159
3,064
783
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.
def main(): a, b, c, d, e, f = map(int, input().split()) a, b = min(a, c), max(a, b) c, d = min(c, d), max(c, d) ans = (0, 0) p = 0 for w in range(1, f + 1): for s in range(1, f - w + 1): x = fnc(100 * a, 100 * b, w) y = fnc(c, d, s) z = s * 100 <= e * w if x and y and z: q = 100 * s / (s + w) if p <= q: p = q ans = (s+w, s) print(ans) def fnc(x, y, z): if z % x == 0: return True if z % y == 0: return True n = z // x for i in range(1, n + 1): rem = z - x * i if rem % y == 0: return True else: return False if __name__ == '__main__': main()
s558077021
Accepted
2,883
24,400
694
def main(): from itertools import combinations a, b, c, d, e, f = map(int, input().split()) a *= 100 b *= 100 water = [a * i + b * j for i in range(f // a + 1) for j in range(f // b + 1)] sugar = [c * i + d * j for i in range(f // c + 1) for j in range(f // d + 1)] water.sort() sugar.sort(reverse=True) tmp = 0 x, y = 0, 0 for w in water: if w == 0: continue for s in sugar: if s + w > f: continue if s * 100 <= e * w and tmp <= s / (s + w): tmp = s / (s + w) x = s + w y = s print(x,y) if __name__ == '__main__': main()
s886724868
p03044
u644778646
2,000
1,048,576
Wrong Answer
697
85,756
398
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
import sys sys.setrecursionlimit(1000000) N = int(input()) e = [ [] for i in range(N+1)] for i in range(N-1): u, v, w = map(int, input().split()) e[u].append((v,w)) e[v].append((u,w)) col = [ -1 for i in range(N+1)] def dfs(x,c): col[x] = c for v,w in e[x]: if col[v] == -1: dfs(v , c+w) dfs(1,0) print(col) for i in range(1,N+1): print(col[i] % 2)
s448289872
Accepted
689
82,300
388
import sys sys.setrecursionlimit(1000000) N = int(input()) e = [ [] for i in range(N+1)] for i in range(N-1): u, v, w = map(int, input().split()) e[u].append((v,w)) e[v].append((u,w)) col = [ -1 for i in range(N+1)] def dfs(x,c): col[x] = c for v,w in e[x]: if col[v] == -1: dfs(v , c+w) dfs(1,0) for i in range(1,N+1): print(col[i] % 2)
s248618168
p03377
u317711717
2,000
262,144
Wrong Answer
19
3,060
89
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.
import math a,b,c=map(int,input().split()) print("Yes" if a<=c and c<=a+b else "No" )
s722498062
Accepted
19
3,060
83
import math a,b,c=map(int,input().split()) print("YES" if a<=c<=a+b else "NO" )
s476860557
p03251
u554954744
2,000
1,048,576
Wrong Answer
18
3,060
198
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
N,M,X,Y=map(int,input().split()) x=list(map(int,input().split())) y=list(map(int,input().split())) x.sort(reverse=True) y.sort(reverse=True) if x[0]<y[-1]: print('War') else: print('No War')
s038484135
Accepted
18
3,060
183
N,M,X,Y=map(int,input().split()) x=list(map(int,input().split())) y=list(map(int,input().split())) x.append(X) y.append(Y) if max(x)<min(y): print('No War') else: print('War')
s589143636
p03605
u050708958
2,000
262,144
Wrong Answer
17
2,940
53
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
s = input() print('yes') if '9' in s else print('no')
s165366053
Accepted
17
2,940
53
s = input() print('Yes') if '9' in s else print('No')
s391407545
p03862
u705418271
2,000
262,144
Wrong Answer
107
19,960
202
There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes contain at most x candies in total. Find the minimum number of operations required to achieve the objective.
N,x=map(int,input().split()) A=list(map(int,input().split())) ans=0 if A[0]>x: ans+=A[0]-x A[0]=x for i in range(1,N): if A[i]+A[i-1]>x: ans+-A[i]+A[i-1]-x A[i]-=A[i]+A[i-1]-x print(ans)
s957835425
Accepted
111
20,124
242
N, x = map(int, input().split()) A = list(map(int, input().split())) ans = 0 if A[0] > x: ans += A[0] - x A[0] = x for i in range(1, N): if A[i]+A[i-1] > x: ans += A[i]+A[i-1]-x A[i] -= A[i]+A[i-1]-x print(ans)
s540018041
p03546
u442877951
2,000
262,144
Wrong Answer
37
3,444
585
Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive). You are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows: * If A_{i,j}≠-1, the square contains a digit A_{i,j}. * If A_{i,j}=-1, the square does not contain a digit. Find the minimum total amount of MP required to turn every digit on this wall into 1 in the end.
def warshall_floyd(c,d): for k in range(10): for i in range(10): for j in range(10): c[j][k] = min(c[j][k],c[j][i] + c[i][k]) if k == 1: d[j] = c[j][k] return d H,W = map(int,input().split()) c = [list(map(int,input().split())) for _ in range(10)] A = [list(map(int,input().split())) for _ in range(H)] d_list = [0]*10 ans = 0 warshall_floyd(c,d_list) for i in range(H): for j in range(W): if A[i][j] != -1: ans += d_list[A[i][j]] print(ans)
s620283084
Accepted
37
3,444
585
def warshall_floyd(c,d): for i in range(10): for j in range(10): for k in range(10): c[j][k] = min(c[j][k],c[j][i] + c[i][k]) if k == 1: d[j] = c[j][k] return d H,W = map(int,input().split()) c = [list(map(int,input().split())) for _ in range(10)] A = [list(map(int,input().split())) for _ in range(H)] d_list = [0]*10 ans = 0 warshall_floyd(c,d_list) for i in range(H): for j in range(W): if A[i][j] != -1: ans += d_list[A[i][j]] print(ans)
s008178012
p03478
u075628913
2,000
262,144
Wrong Answer
38
3,060
252
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).
inputs = input().split() n, a, b = list(map(int, inputs)) print(n,a,b) count=0 for num in range(n+1): num_str = str(num) all = 0 for i in range(len(num_str)): all += int(num_str[i]) if a <= all <= b: count+=num print(count)
s537611808
Accepted
37
3,060
239
inputs = input().split() n, a, b = list(map(int, inputs)) count=0 for num in range(n+1): num_str = str(num) all = 0 for i in range(len(num_str)): all += int(num_str[i]) if a <= all <= b: count+=num print(count)
s925304378
p03338
u735008991
2,000
1,048,576
Wrong Answer
17
2,940
95
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
N = int(input()) S = input() print(max([len(set(S[:i])) + len(set(S[i:])) for i in range(N)]))
s152584338
Accepted
17
2,940
102
N = int(input()) S = input() print(max([len(set(S[:i]).intersection(set(S[i:]))) for i in range(N)]))
s079062257
p03658
u127499732
2,000
262,144
Wrong Answer
17
2,940
81
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()) s=sum( sorted(list(map(int,input().split())))[-k:] )
s203179429
Accepted
17
2,940
85
n,k=map(int,input().split()) print(sum(sorted(list(map(int,input().split())))[-k:] ))
s329167098
p02613
u282103490
2,000
1,048,576
Wrong Answer
138
9,124
259
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.
import math def main(): mp = { "AC": 0, "TLE": 0, "WA": 0, "RE": 0 } n = int(input()) for _ in range(n): s = input() mp[s]+=1 for key in mp.keys(): print(key, "x", mp[key]) main()
s407328896
Accepted
138
9,168
259
import math def main(): mp = { "AC": 0, "WA": 0, "TLE": 0, "RE": 0 } n = int(input()) for _ in range(n): s = input() mp[s]+=1 for key in mp.keys(): print(key, "x", mp[key]) main()
s399444408
p02612
u767797498
2,000
1,048,576
Wrong Answer
26
9,124
24
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
print(int(input())%1000)
s506088964
Accepted
28
9,124
48
a=int(input())%1000 print(0 if a==0 else 1000-a)
s467690208
p02406
u144068724
1,000
131,072
Wrong Answer
20
7,672
128
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
n = int(input()) result = "" for i in range(n+1): if i % 3 == 0 or i % 10 == 3: result += " " + str(i) print(result)
s448030252
Accepted
20
7,684
266
n = int(input()) result = "" for i in range(1,n+1): if i % 3 == 0 or i % 10 == 3: result += " " + str(i) continue x = i while(x): if x % 10 == 3: result += " " + str(i) break x //= 10 print(result)
s341676945
p03852
u533084327
2,000
262,144
Wrong Answer
17
3,064
662
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
S = input() str_list = ['dream', 'erase', 'dreamer', 'eraser'] start = 0 success_flag = False continue_flag = False def reverse_str(var: str): return ''.join(list(reversed(var))) reverse_S = reverse_str(S) while True: for str_name in str_list: if reverse_S[start:start + len(str_name)] == reverse_str(str_name): if len(S) == start + len(str_name): success_flag = True break start += len(str_name) continue_flag = True if success_flag: print('YES') break if not continue_flag: print('NO') break else: continue_flag = False
s174987025
Accepted
270
20,448
130
import numpy as np c = input() boin_list = ['a','e','i','o','u'] if c in boin_list: print ('vowel') else: print ('consonant')
s978489096
p03997
u553070631
2,000
262,144
Wrong Answer
21
3,316
62
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)
s078312586
Accepted
17
2,940
69
a=int(input()) b=int(input()) h=int(input()) print(int(((a+b)*h/2)))
s272134256
p04029
u823885866
2,000
262,144
Wrong Answer
30
9,100
32
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?
a=int(input()) print(a*(a-1)//2)
s568322725
Accepted
26
9,156
33
print(sum(range(int(input())+1)))
s143634738
p03679
u175590965
2,000
262,144
Wrong Answer
17
2,940
129
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
x,a,b = map(int,input().split()) if x < b : print("delicious") elif x + a > b: print("safe") else: print("dangerous")
s742710333
Accepted
17
2,940
131
x,a,b = map(int,input().split()) if b <= a : print("delicious") elif x + a >= b: print("safe") else: print("dangerous")
s645370228
p03449
u446531810
2,000
262,144
Wrong Answer
21
3,064
350
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
N=int(input()) row_1=list(map(lambda x:int(x),input().split())) row_2=list(map(lambda x:int(x),input().split())) max_value=0 for i in range(1,N): sum_row_1=sum(row_1[0:i]) sum_row_2=sum(row_2[i-1:N]) print(row_1[0:i],row_2[i-1:N],sum_row_1,sum_row_2) if max_value<sum_row_1+sum_row_2:max_value=sum_row_1+sum_row_2 print(max_value)
s043262864
Accepted
18
3,060
293
N=int(input()) row_1=list(map(lambda x:int(x),input().split())) row_2=list(map(lambda x:int(x),input().split())) max_value=0 for i in range(N): sum_row_1=sum(row_1[0:i+1]) sum_row_2=sum(row_2[i:N]) if max_value<sum_row_1+sum_row_2:max_value=sum_row_1+sum_row_2 print(max_value)
s800703666
p03455
u846652026
2,000
262,144
Wrong Answer
17
2,940
95
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
i = list(map(int, input().split())) if (i[0] * i[1]) % 2: print("Even") else: print("Odd")
s313705867
Accepted
17
2,940
100
i = list(map(int, input().split())) if (i[0] * i[1]) % 2 == 0: print("Even") else: print("Odd")
s569152621
p02843
u244416763
2,000
1,048,576
Wrong Answer
29
3,060
111
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
x = int(input()) for i in range(100000): if(100*i <= x and 105*i >= x): print(1) else: print(0)
s423034839
Accepted
29
3,060
126
x = int(input()) for i in range(100000): if(100*i <= x and 105*i >= x): print(1) exit() else: print(0)
s164334785
p03854
u005899289
2,000
262,144
Wrong Answer
40
9,184
341
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`.
a = input() b = a[::-1] i = 0 while i < len(b): if b[i:i+5] == "esare": i += 5 elif b[i:i+5] == "maerd": i += 5 elif b[i:i+6] == "resare": i += 6 elif b[i:i+7] == "remaerd": i += 7 else: ans = "No" break if i == len(b): ans = "Yes" else: ans = "No" print(ans)
s014829818
Accepted
37
9,120
341
a = input() b = a[::-1] i = 0 while i < len(b): if b[i:i+5] == "esare": i += 5 elif b[i:i+5] == "maerd": i += 5 elif b[i:i+6] == "resare": i += 6 elif b[i:i+7] == "remaerd": i += 7 else: ans = "NO" break if i == len(b): ans = "YES" else: ans = "NO" print(ans)
s029392864
p03861
u940342887
2,000
262,144
Wrong Answer
17
3,060
128
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 = map(float, input().split()) import math c = a//x d = b//x print(d) if a%x == 0: print(d-c+1) else: print(d-c)
s724001874
Accepted
17
2,940
117
a, b, x = map(int, input().split()) import math c = a//x d = b//x if a%x == 0: print(d-c+1) else: print(d-c)
s905337480
p03590
u333945892
2,000
262,144
Wrong Answer
1,184
4,584
551
_Seisu-ya_ , a store specializing in non-negative integers, sells N non- negative integers. The i-th integer is A_i and has a _utility_ of B_i. There may be multiple equal integers with different utilities. Takahashi will buy some integers in this store. He can buy a combination of integers whose _bitwise OR_ is less than or equal to K. He wants the sum of utilities of purchased integers to be as large as possible. Find the maximum possible sum of utilities of purchased integers.
from collections import defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue,datetime sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 def inpl(): return list(map(int, input().split())) def inpls(): return list(input().split()) N,K = inpl() L = K.bit_length() print(bin(K)) koho = [K] tmp = 0 for b in reversed(range(L)): if (K>>b) & 1: print(b) tmp += (1<<b) koho.append(tmp-1) nums = [0]*len(koho) for _ in range(N): A,B = inpl() for i,k in enumerate(koho): if k|A == k: nums[i] += B print(max(nums))
s630778410
Accepted
1,017
4,336
526
from collections import defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue,datetime sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 def inpl(): return list(map(int, input().split())) def inpls(): return list(input().split()) N,K = inpl() L = K.bit_length() koho = [K] tmp = 0 for b in reversed(range(L)): if (K>>b) & 1: tmp += (1<<b) koho.append(tmp-1) nums = [0]*len(koho) for _ in range(N): A,B = inpl() for i,k in enumerate(koho): if k|A == k: nums[i] += B print(max(nums))
s206654622
p03644
u292810930
2,000
262,144
Wrong Answer
19
2,940
47
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 = bin(int(input()))[::-1] print(N.find('1'))
s045299128
Accepted
17
2,940
42
N = bin(int(input())) print(2**(len(N)-3))
s463928314
p02235
u063056051
1,000
131,072
Wrong Answer
20
5,608
336
For given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subsequence of both $X$ and $Y$. For example, if $X = \\{a,b,c,b,d,a,b\\}$ and $Y = \\{b,d,c,a,b,a\\}$, the sequence $\\{b,c,a\\}$ is a common subsequence of both $X$ and $Y$. On the other hand, the sequence $\\{b,c,a\\}$ is not a longest common subsequence (LCS) of $X$ and $Y$, since it has length 3 and the sequence $\\{b,c,b,a\\}$, which is also common to both $X$ and $Y$, has length 4. The sequence $\\{b,c,b,a\\}$ is an LCS of $X$ and $Y$, since there is no common subsequence of length 5 or greater. Write a program which finds the length of LCS of given two sequences $X$ and $Y$. The sequence consists of alphabetical characters.
import sys n=int(input()) for _ in range(n): x=sys.stdin.readline().rstrip('\r\n') y=sys.stdin.readline().rstrip('\r\n') list=[0] for z in y: for i in range(len(list)-1,-1,-1): tmp=x.find(z,list[i]) if tmp+1: if i+1<len(list): list[i+1]=min(tmp+1,list[i+1]) else: list.append(tmp+1) print(len(list)-1)
s453401954
Accepted
2,880
5,616
294
def f(x,y): list=[0] for z in y: for i in range(len(list)-1,-1,-1): tmp=x.find(z,list[i])+1 if tmp: if i+1 < len(list): list[i+1]=min(list[i+1],tmp) else: list.append(tmp) return len(list)-1 n=int(input()) for i in range(n): x=input() y=input() print(f(x,y))
s008162341
p04030
u218843509
2,000
262,144
Wrong Answer
17
2,940
185
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_list = list(input()) ans_list = [] for s in s_list: if s == "1" or s == "0": ans_list.append(s) elif ans_list != []: ans_list.pop() "".join(ans_list)
s313767659
Accepted
17
2,940
192
s_list = list(input()) ans_list = [] for s in s_list: if s == "1" or s == "0": ans_list.append(s) elif ans_list != []: ans_list.pop() print("".join(ans_list))
s194916983
p03760
u234631479
2,000
262,144
Wrong Answer
17
2,940
121
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions. You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.
A = input() B = input() print(A,B) S = list(A) for i in range(len(B)): S.insert(i*2+1,B[i]) print(''.join(map(str, S)))
s936131332
Accepted
17
3,064
110
A = input() B = input() S = list(A) for i in range(len(B)): S.insert(i*2+1,B[i]) print(''.join(map(str, S)))
s388058637
p03090
u785773061
2,000
1,048,576
Wrong Answer
17
3,064
613
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
#b # n = int(input()) n = 3 pairs = [] if n % 2 == 0: for x in range(1, int(n/2) + 1): pairs.append([x, n-x + 1]) else: for x in range(1, int((n-1)/2) +1): pairs.append([x, int((n-1))-x+1]) pairs.append([n]) # connect nodes edges = [] for x in range(1, n+1): for p in pairs: # print(f'x: {x}, p: {p}') if x in p: break for node in p: edges.append(sorted([x, node])) # print(f'edges >>>>> {edges}') for e in edges: print(' '.join([str(i) for i in e]))
s190756532
Accepted
28
3,860
623
#b n = int(input()) pairs = [] if n % 2 == 0: for x in range(1, int(n/2) + 1): pairs.append([x, n-x + 1]) else: for x in range(1, int((n-1)/2) +1): pairs.append([x, int((n-1))-x+1]) pairs.append([n]) # connect nodes edges = [] for x in range(1, n+1): for p in pairs: # print(f'x: {x}, p: {p}') if x in p: break for node in p: edges.append(sorted([x, node])) # print(f'edges >>>>> {edges}') print(len(edges)) for e in edges: print(' '.join([str(i) for i in e]))
s796735561
p03385
u585604152
2,000
262,144
Wrong Answer
20
3,316
158
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
S = list(input()) import collections count = collections.Counter(S) if count["a"]==1 and count["b"]==1 and count["c"]==1: print('YES') else: print('NO')
s155357093
Accepted
21
3,316
158
S = list(input()) import collections count = collections.Counter(S) if count["a"]==1 and count["b"]==1 and count["c"]==1: print('Yes') else: print('No')
s225711159
p02612
u454524105
2,000
1,048,576
Wrong Answer
27
9,100
24
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
print(int(input())%1000)
s766735351
Accepted
33
9,084
58
m = int(input()) % 1000 print(1000 - m) if m else print(0)
s141857996
p02608
u808280993
2,000
1,048,576
Wrong Answer
842
9,264
459
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 >= 6 import math N = int(input()) ans = [0] * N lim = int(math.sqrt(N)) for x in range(1, lim): for y in range(1, lim): for z in range(1, lim): #calc = ((x+y)**2 + (y+z)**2 + (x+z)**2) /2 calc = x**2 + y**2 + z**2 + x*y + y*z + z*x if calc <= N: ans[calc -1] += 1 print(ans)
s220362885
Accepted
814
9,144
488
# n >= 6 import math N = int(input()) ans = [0] * N lim = int(math.sqrt(N)) for x in range(1, lim): for y in range(1, lim): for z in range(1, lim): #calc = ((x+y)**2 + (y+z)**2 + (x+z)**2) /2 calc = x**2 + y**2 + z**2 + x*y + y*z + z*x if calc <= N: ans[calc -1] += 1 #print(ans) for a in ans: print(a)
s209265859
p04043
u368882459
2,000
262,144
Wrong Answer
16
2,940
120
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.
ary = list(map(int, input().split())) if ary.count(5) == 2 and ary.count(7) == 1: print('Yes') else: print('No')
s815379525
Accepted
17
2,940
120
ary = list(map(int, input().split())) if ary.count(5) == 2 and ary.count(7) == 1: print('YES') else: print('NO')
s194076410
p03920
u426108351
2,000
262,144
Wrong Answer
22
3,316
184
The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him. Determine the set of problems that should be solved.
N = int(input()) n = N now = 0 count = 0 while n > 0: n -= count now += count count += 1 ignore = now - N for i in range(1, count+1): if i == ignore: continue print(i)
s672884860
Accepted
22
3,316
183
N = int(input()) n = N now = 0 count = 0 while n > 0: n -= count now += count count += 1 ignore = now - N for i in range(1, count): if i == ignore: continue print(i)
s318790301
p03861
u731368968
2,000
262,144
Wrong Answer
17
2,940
52
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 = map(int, input().split()) print(a//x-b//x)
s170158591
Accepted
17
2,940
56
a, b, x = map(int, input().split()) print(b//x-(a-1)//x)
s361289177
p02646
u189513668
2,000
1,048,576
Wrong Answer
23
9,180
162
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) b = abs(A - B) + W*T a = V*T if a < b: print("No") else: print("Yes")
s605222525
Accepted
24
9,180
162
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) b = abs(A - B) + W*T a = V*T if a < b: print("NO") else: print("YES")
s878416691
p03408
u869919400
2,000
262,144
Wrong Answer
21
3,316
291
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
n = int(input()) blues = [input() for _ in range(n)] m = int(input()) reds = [input() for _ in range(m)] words = set(blues) _max = 0 for w in words: score = 0 score += blues.count(w) score -= reds.count(w) print(w, score) if _max < score: _max = score print(_max)
s692170400
Accepted
17
3,064
271
n = int(input()) blues = [input() for _ in range(n)] m = int(input()) reds = [input() for _ in range(m)] words = set(blues) _max = 0 for w in words: score = 0 score += blues.count(w) score -= reds.count(w) if _max < score: _max = score print(_max)
s480705666
p00015
u886122084
1,000
131,072
Wrong Answer
20
5,596
309
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".
# python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline n = int(input()) ans = [] for _ in range(n): a = int(input()) b = int(input()) s = a+b if s >= 10**79: ans.append("overflow") else: ans.append(str(s)) print("\n".join(ans))
s736807739
Accepted
20
5,600
310
# python template for atcoder1 import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline n = int(input()) ans = [] for _ in range(n): a = int(input()) b = int(input()) s = a+b if s > 10**80-1: ans.append("overflow") else: ans.append(str(s)) print("\n".join(ans))
s699601909
p02694
u135265051
2,000
1,048,576
Wrong Answer
28
9,148
186
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
#a = list(map(int,input().split())) #b = list(map(int,input().split())) a = int(input()) x = int(100) count= 0 while a >= x: x += int(x/100) count+=1 print(count) print(type(x))
s131857908
Accepted
29
9,140
166
#a = list(map(int,input().split())) #b = list(map(int,input().split())) a = int(input()) x = int(100) count= 0 while a > x: count+=1 x += x//100 print(count)
s094381936
p03998
u595893956
2,000
262,144
Time Limit Exceeded
2,104
3,064
517
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
s=input() t=input() u=input() a=b=c=0 now = 0 while 1: if now == 0: if s[a] == 'a': now = 0 elif s[a] == 'b': now = 1 else: now = 2 if a==len(s): print('A') break elif now == 1: if s[b] == 'a': now = 0 elif s[b] == 'b': now = 1 else: now = 2 if b==len(t): print('B') break else: if s[c] == 'a': now = 0 elif s[c] == 'b': now = 1 else: now = 2 if c==len(u): print('C') break
s436153931
Accepted
18
3,064
540
s=input() t=input() u=input() a=b=c=0 now = 0 while 1: if now == 0: if a==len(s): print('A') break if s[a] == 'a': now = 0 elif s[a] == 'b': now = 1 else: now = 2 a+=1 elif now == 1: if b==len(t): print('B') break if t[b]=='a': now = 0 elif t[b]== 'b': now = 1 else: now = 2 b+=1 else: if c==len(u): print('C') break if u[c]== 'a': now = 0 elif u[c]== 'b': now = 1 else: now = 2 c+=1
s683756298
p03471
u498575211
2,000
262,144
Wrong Answer
2,104
3,064
343
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()) nn = Y // 10000 mm = Y // 5000 ll = Y // 1000 p = [] ans = "-1, -1, -1" for i in range(nn): for j in range(mm): if i + j >= N: break for k in range(ll): if i + j + k >= N: break if i * 10000 + j * 5000 + k * 1000 == Y: ans = str(i)+", "+str(j)+", "+str(k) print(ans)
s410594351
Accepted
1,009
3,188
406
N, Y = map(int, input().split()) nn = Y // 10000 if (Y // 10000) < N else N mm = Y // 5000 if (Y // 5000) < N else N ll = Y // 1000 if (Y // 1000) < N else N ans = "-1 -1 -1" for i in range(nn+1): for j in range(mm+1): if i + j > N: break if (i * 10000 + j * 5000 + (N-i-j) * 1000) == Y: ans = str(i)+" "+str(j)+" "+str(N-i-j) break print(ans)
s999386228
p03945
u296518383
2,000
262,144
Wrong Answer
45
3,188
84
Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is `B`, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is `W`, it means that the color of the corresponding stone is white. Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.
S=input() res=0 for i in range(len(S)-1): if S[i]!=S[i+1]: res+=res print(res)
s581793818
Accepted
70
13,300
218
def run_length(s) -> list: res = [[s[0], 1]] for i in range(1, len(s)): if res[-1][0] == s[i]: res[-1][1] += 1 else: res.append([s[i], 1]) return res R = run_length(input()) print(len(R) - 1)
s610239326
p02542
u102461423
2,000
1,048,576
Wrong Answer
377
57,708
942
There is a board with N rows and M columns. The information of this board is represented by N strings S_1,S_2,\ldots,S_N. Specifically, the state of the square at the i-th row from the top and the j-th column from the left is represented as follows: * S_{i,j}=`.` : the square is empty. * S_{i,j}=`#` : an obstacle is placed on the square. * S_{i,j}=`o` : a piece is placed on the square. Yosupo repeats the following operation: * Choose a piece and move it to its right adjecent square or its down adjacent square. Moving a piece to squares with another piece or an obstacle is prohibited. Moving a piece out of the board is also prohibited. Yosupo wants to perform the operation as many times as possible. Find the maximum possible number of operations.
import sys import networkx as nx import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines H, W = map(int, readline().split()) S = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W].astype('U1') INF = 1 << 32 total_o = (S == 'o').sum() G = nx.DiGraph() sink = 'sink' G.add_node(sink, demand=total_o) for i in range(H): for j in range(W): if S[i, j] == '#': continue if S[i, j] == 'o': G.add_node((i, j), demand=-1) G.add_edge((i, j), sink, capacity=1, weight=0) elif S[i, j] == '.': G.add_node((i, j), demand=0) G.add_edge((i, j), sink, capacity=1, weight=0) if i + 1 < H and S[i + 1, j] != '#': G.add_edge((i, j), (i + 1, j), capacity=INF, weight=-1) if j + 1 < W and S[i, j + 1] != '#': G.add_edge((i, j), (i, j + 1), capacity=INF, weight=-1)
s552155751
Accepted
930
60,600
997
import sys import networkx as nx import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines H, W = map(int, readline().split()) S = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W].astype('U1') INF = 1 << 32 total_o = (S == 'o').sum() G = nx.DiGraph() sink = 'sink' G.add_node(sink, demand=total_o) for i in range(H): for j in range(W): if S[i, j] == '#': continue if S[i, j] == 'o': G.add_node((i, j), demand=-1) G.add_edge((i, j), sink, capacity=1, weight=0) elif S[i, j] == '.': G.add_node((i, j), demand=0) G.add_edge((i, j), sink, capacity=1, weight=0) if i + 1 < H and S[i + 1, j] != '#': G.add_edge((i, j), (i + 1, j), capacity=INF, weight=-1) if j + 1 < W and S[i, j + 1] != '#': G.add_edge((i, j), (i, j + 1), capacity=INF, weight=-1) mcfc = nx.min_cost_flow_cost(G) ans = -mcfc print(ans)
s787236523
p03719
u556477263
2,000
262,144
Wrong Answer
24
9,068
90
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a,b,c = map(int,input().split()) if a<=b and b<=c: print('Yes') else: print('No')
s001730283
Accepted
30
9,120
91
a,b,c = map(int,input().split()) if a<= c and b>=c: print('Yes') else: print('No')
s089146968
p03605
u117193815
2,000
262,144
Wrong Answer
17
2,940
67
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
n=input() if n[0]==9 or n[1]==9: print("Yes") else: print("No")
s302510986
Accepted
16
2,940
71
n=input() if n[0]=="9" or n[1]=="9": print("Yes") else: print("No")
s108994945
p02260
u672822075
1,000
131,072
Wrong Answer
30
6,720
224
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.
cnt = 0 n = int(input()) a = list(map(int,input().split())) for i in range(0,n): mini = i for j in range(i,n): if a[j]<a[mini]: mini = j cnt += 1 a[j],a[mini] = a[mini],a[j] print(" ".join(map(str,a))) print(cnt)
s370331437
Accepted
30
6,724
236
cnt = 0 n = int(input()) a = list(map(int,input().split())) for i in range(0,n): mini = i for j in range(i,n): if a[j]<a[mini]: mini = j a[i],a[mini] = a[mini],a[i] if i!=mini: cnt += 1 print(" ".join(map(str,a))) print(cnt)
s283815106
p03836
u993435350
2,000
262,144
Wrong Answer
17
3,064
452
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 must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
sx,sy,tx,ty = map(int,input().split()) dx = abs(tx - sx) dy = abs(ty - sy) move_x = "R" * dx move_y = "U" * dy f_move = move_x + move_y if "R" in f_move: s_move = f_move.replace("R","L") if "U" in s_move: s_move = s_move.replace("U","D") t_move = "L" + "U" + f_move + "D" if "R" in t_move: ff_move = t_move.replace("R","L") if "U" in s_move: ff_move = ff_move.replace("U","D") total = f_move + s_move + t_move + ff_move print(total)
s158681236
Accepted
17
3,064
390
sx,sy,tx,ty = map(int,input().split()) dx = abs(tx - sx) dy = abs(ty - sy) move_x = "R" * dx move_y = "U" * dy f_move = move_y + move_x if "R" in f_move: s_move = f_move.replace("R","L") if "U" in s_move: s_move = s_move.replace("U","D") t_move = "L" + "U" + f_move + "R" + "D" ff_move = "R" + "D" + s_move + "L" + "U" total = f_move + s_move + t_move + ff_move print(total)
s369028461
p03448
u170183831
2,000
262,144
Wrong Answer
17
3,064
603
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.
def solve(a, b, c, x): count_all_50yen = x // 50 # 50 print(count_all_50yen) count_50yen_pattern = min(c, count_all_50yen) count_100yen_pattern = min(b, count_all_50yen // 2) count_500yen_pattern = min(a, count_all_50yen // 10) print(count_50yen_pattern, count_100yen_pattern, count_500yen_pattern) return count_50yen_pattern + count_100yen_pattern + count_500yen_pattern _a = int(input()) _b = int(input()) _c = int(input()) _x = int(input()) print(solve(_a, _b, _c, _x))
s862893798
Accepted
49
3,060
303
def solve(a, b, c, x): return sum( x == 500 * i + 100 * j + 50 * k for i in range(a + 1) for j in range(b + 1) for k in range(c + 1) ) _a = int(input()) _b = int(input()) _c = int(input()) _x = int(input()) print(solve(_a, _b, _c, _x))
s381043651
p01315
u286751622
8,000
131,072
Wrong Answer
70
6,056
1,154
You are passionate about the popular web game "Moonlight Ranch". The purpose of this game is to grow crops in the fields, sell them to earn income, and use the income to grow the ranch. You wanted to grow your field quickly. Therefore, we decided to start by arranging the crops that can be grown in the game based on their income efficiency per hour. You have to buy seeds to grow crops. Here the species name of crop i is given by Li and the price by Pi. When a seed is planted in a field, it sprouts after time Ai. Young leaves emerge after time Bi from the emergence of buds. Leaves grow thick after time Ci from the emergence of young leaves. After the time Di has passed since the leaves grow thick, the flowers bloom. After the time Ei after the flower blooms, the fruit is formed. One seed produces Fi seeds, and each of these seeds can be sold at a price of Si. Some crops are multi-season crops and produce Mi crops in total. Mi = 1 for single cropping. Multi-season crops return to leaves after fruiting until Mi th fruiting. The income for a seed is the amount of money sold for all the fruit of that seed minus the price of the seed. In addition, the income efficiency of the seed is the value obtained by dividing the income by the time from planting the seed until all fruits are produced. Your task is to write a program that takes the input crop information and sorts it in descending order of income efficiency.
resultss = [] while True: N = int(input()) if N == 0: break B = [list(map(str, input().split())) for _ in range(N)] results = [] for i in range(N): A = [] name = B[i][0] B[i][0] = B[i][1] for j in range(10): A.append(int(B[i][j])) if A[-1] == 1: time = A[2] + A[3] + A[4] + A[5] + A[6] money = A[7] * A[8] res = money - A[1] res /= time else: time = A[2] + A[3] + A[4] + A[5] + A[6] + (A[5] + A[6]) * (A[-1] - 1) money = A[7] * A[8] * A[-1] res = money - A[1] res /= time results.append([res, name]) tmp = results[0][0] flag =False for i in range(len(results)): if results[i][0] != tmp: flag = True if flag: results.sort() else: results = sorted(results, key=lambda x: x[1], reverse=True) resultss.append(results) for i in range(len(resultss)): for j in range(len(resultss[i])): print(resultss[i][-j-1][1]) print('#')
s930958619
Accepted
60
6,060
1,039
resultss = [] while True: N = int(input()) if N == 0: break B = [list(map(str, input().split())) for _ in range(N)] results = [] for i in range(N): A = [] name = B[i][0] B[i][0] = B[i][1] for j in range(10): A.append(int(B[i][j])) if A[-1] == 1: time = A[2] + A[3] + A[4] + A[5] + A[6] money = A[7] * A[8] res = money - A[1] res /= time else: time = A[2] + A[3] + A[4] + A[5] + A[6] + (A[5] + A[6]) * (A[-1] - 1) money = A[7] * A[8] * A[-1] res = money - A[1] res /= time results.append([res, name]) results = sorted(results, key=lambda x: x[1], reverse = True) results = sorted(results, key=lambda x: x[0]) resultss.append(results) for i in range(len(resultss)): for j in range(len(resultss[i])): print(resultss[i][-j-1][1]) print('#')
s295390120
p03494
u829094246
2,000
262,144
Wrong Answer
21
3,060
225
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()) An=list(map(int, input().rstrip().split())) cnt=0 while True: if len(list(filter(lambda a:(a+1)%2, An))) < len(An): break An=list(map(lambda a:int(a/2), An)) print(An) cnt+=1 print(cnt)
s097675307
Accepted
19
2,940
211
N=int(input()) An=list(map(int, input().rstrip().split())) cnt=0 while True: if len(list(filter(lambda a:(a+1)%2, An))) < len(An): break An=list(map(lambda a:int(a/2), An)) cnt+=1 print(cnt)
s628713346
p02398
u933096856
1,000
131,072
Wrong Answer
30
7,696
97
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
a,b,c=map(int, input().split()) d=0 for i in range(a+1,b+1): if c%i==0: d+=1 print(d)
s883015764
Accepted
50
7,704
95
a,b,c=map(int, input().split()) d=0 for i in range(a,b+1): if c%i==0: d+=1 print(d)
s217387343
p03385
u382431597
2,000
262,144
Wrong Answer
17
2,940
97
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
s=input() s = s.replace("a","").replace("b","").replace("c","") print("Yes" if s == 0 else "No")
s694362201
Accepted
18
2,940
85
s=input() print("Yes" if s.count("a") == s.count("b") == s.count("c") == 1 else "No")
s472885368
p03943
u396391104
2,000
262,144
Wrong Answer
17
2,940
99
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
a,b,c = map(int,input().split()) d = (a+b+c)//2 print("Yes") if d==a | d==b | d==c else print("No")
s955700012
Accepted
18
2,940
99
a,b,c = map(int,input().split()) if a==b+c or b==c+a or c==a+b: print("Yes") else: print("No")
s986113668
p03501
u797016134
2,000
262,144
Wrong Answer
17
2,940
88
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
n,a,b = map(int, input().split()) if a*n >= b: print(a*n) if a*n <= b: print(b)
s397507361
Accepted
17
3,064
99
n,a,b = map(int, input().split()) if a*n >= b: print(b) exit() if a*n <= b: print(a*n)
s833175402
p02608
u690781906
2,000
1,048,576
Wrong Answer
2,211
201,556
238
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).
from collections import defaultdict ans = defaultdict(int) N = int(input()) for i in range(1, N): for j in range(1, N): for k in range(1, N): ans[i*i+j*j+k*k+i*j+j*k+k*i] += 1 for i in range(N): print(ans[i])
s297719981
Accepted
506
11,640
246
from collections import defaultdict ans = defaultdict(int) N = int(input()) for i in range(1, 100): for j in range(1, 100): for k in range(1, 100): ans[i*i+j*j+k*k+i*j+j*k+k*i] += 1 for i in range(N): print(ans[i+1])
s309499212
p03006
u125545880
2,000
1,048,576
Wrong Answer
219
9,208
793
There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i). We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation: * Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1. Find the minimum total cost required to collect all the balls when we optimally choose p and q.
import itertools def main(): N = int(input()) z = [] ans = 51 for i in range(N): z.append(tuple(map(int, input().split()))) z.sort(key=lambda x: x[0]) for i, j in itertools.combinations(range(N), 2): p = z[i][0] - z[j][0] q = z[i][1] - z[j][1] ans = min(ans, solve(N, z, p, q)) print(ans) def solve(N, z, p, q): if p < 0: p, q = -p, -q passlist = set() cnt = 0 for i in range(N): if z[i] in passlist: continue x, y = z[i][0], z[i][1] for j in range(N): s, t = x-p, y-q if (s, t) not in z: cnt += 1 break passlist.add((s, t)) x, y = s, t return cnt if __name__ == "__main__": main()
s960413677
Accepted
114
9,264
854
import itertools def main(): N = int(input()) z = [] ans = 51 for i in range(N): z.append(tuple(map(int, input().split()))) z.sort(key=lambda x: x[1]) z.sort(key=lambda x: x[0], reverse=True) if len(z) == 1: print(1) return for i, j in itertools.combinations(range(N), 2): p = z[i][0] - z[j][0] q = z[i][1] - z[j][1] ans = min(ans, solve(N, z, p, q)) print(ans) def solve(N, z, p, q): passlist = set() cnt = 0 for i in range(N): if z[i] in passlist: continue x, y = z[i][0], z[i][1] for j in range(N): s, t = x-p, y-q if (s, t) not in z: cnt += 1 break passlist.add((s, t)) x, y = s, t return cnt if __name__ == "__main__": main()
s917616858
p03861
u045939752
2,000
262,144
Wrong Answer
23
3,064
64
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 = map(int, input().split()) print ((b // x) - (a // x))
s538584551
Accepted
25
3,064
70
a, b, x = map(int, input().split()) a -= 1 print((b // x) - (a // x))
s771242470
p03080
u296518383
2,000
1,048,576
Wrong Answer
18
2,940
92
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=input() if S.count("r")-S.count("b")>0: print("Yes") else: print("No")
s701995581
Accepted
17
2,940
72
N,S=input(),input() print("Yes" if S.count("R")>S.count("B") else "No")
s582630314
p02271
u564398841
5,000
131,072
Wrong Answer
20
7,700
764
Write a program which reads a sequence _A_ of _n_ elements and an integer _M_ , and outputs "yes" if you can make _M_ by adding elements in _A_ , otherwise "no". You can use an element only once. You are given the sequence _A_ and _q_ questions where each question contains _M i_.
class Solver(): def __init__(self, A: [int]): self.A = A self.max_depth = len(A) def solve(self, tgt): self.tgt = tgt return self._rec_solve(0, 0) def _rec_solve(self, _sum, index): if index >= self.max_depth or _sum > self.tgt: return False elif _sum == self.tgt: return True else: return self._rec_solve(_sum + self.A[index], index + 1) or self._rec_solve(_sum, index + 1) if __name__ == '__main__': n = int(input()) A = [int(i) for i in input().rstrip().split()] print(A) q = int(input()) m_ary = [int(i) for i in input().rstrip().split()] print(m_ary) s = Solver(A) for i in m_ary: print(s.solve(i))
s132586952
Accepted
1,420
8,396
1,172
class Solver(): def __init__(self, A: [int]): self.A = A self.max_depth = len(A) def solve(self, tgt): self.tgt = tgt self.history = (self.max_depth+1)*[4000 * [None]] self.history = [[None for i in range(4000)] for x in range(self.max_depth + 1)] if self._rec_solve(0, 0): return 'yes' else: return 'no' def _rec_solve(self, _sum, index): if self.history[index][_sum] is not None: return self.history[index][_sum] if _sum == self.tgt: self.history[index][_sum] = True return True if index >= self.max_depth or _sum > self.tgt: self.history[index][_sum] = False return False self.history[index][_sum] = self._rec_solve(_sum + self.A[index], index + 1) or self._rec_solve(_sum, index + 1) return self.history[index][_sum] if __name__ == '__main__': n = int(input()) A = [int(i) for i in input().rstrip().split()] q = int(input()) m_ary = [int(i) for i in input().rstrip().split()] s = Solver(A) for val in m_ary: print(s.solve(val))
s540814510
p04011
u517630860
2,000
262,144
Wrong Answer
17
2,940
93
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
# -*- coding: utf-8 -*- w = input() print(['Yes', 'No'][any(w.count(c) % 2 for c in set(w))])
s369948746
Accepted
17
2,940
178
# -*- coding: utf-8 -*- N = int(input()) K = int(input()) X = int(input()) Y = int(input()) total = X * (N if N <= K else K) total += Y * (0 if N <= K else N - K) print(total)
s019050165
p03435
u075012704
2,000
262,144
Wrong Answer
249
3,064
415
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
C = [list(map(int, input().split())) for i in range(3)] for a1 in range(101): for a2 in range(101): for a3 in range(101): if (C[0][0]-a1) == (C[1][0]-a2) == (C[2][0]-a3): if (C[0][1]-a1) == (C[1][1]-a2) == (C[2][1]-a3): if (C[0][2] - a1) == (C[1][2] - a2) == (C[2][2] - a3): print("YES") exit() print("NO")
s691238505
Accepted
261
3,064
415
C = [list(map(int, input().split())) for i in range(3)] for a1 in range(101): for a2 in range(101): for a3 in range(101): if (C[0][0]-a1) == (C[1][0]-a2) == (C[2][0]-a3): if (C[0][1]-a1) == (C[1][1]-a2) == (C[2][1]-a3): if (C[0][2] - a1) == (C[1][2] - a2) == (C[2][2] - a3): print("Yes") exit() print("No")
s562111107
p03493
u686485517
2,000
262,144
Wrong Answer
17
2,940
80
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() c = 0 for i in range(3): if s[i] == "1": c += 1 print("c")
s679932210
Accepted
17
2,940
78
s=input() c = 0 for i in range(3): if s[i] == "1": c += 1 print(c)
s438464525
p02406
u435158342
1,000
131,072
Wrong Answer
20
5,584
79
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
a=int(input()) b=3 while True: if b>a: break print(b) b+=3
s900459252
Accepted
20
5,872
104
a=int(input()) for i in range(1, a+1): if i%3==0 or '3' in str(i):print(' '+ str(i),end='') print()
s024224919
p02393
u074747865
1,000
131,072
Wrong Answer
20
5,580
78
Write a program which reads three integers, and prints them in ascending order.
li=list(map(int,input().split())) li.sort() for i in li: print("i", sep=" ")
s854552212
Accepted
20
5,576
47
li=sorted(map(int,input().split())) print(*li)
s781052527
p02389
u838759969
1,000
131,072
Wrong Answer
20
7,592
172
Write a program which calculates the area and perimeter of a given rectangle.
__author__= 'CIPHER' str = input() numList = str.split(' ') numList = [ int(x) for x in numList] #print(numList) result = 1 for x in numList: result *= x print(result)
s328764652
Accepted
30
7,668
209
__author__= 'CIPHER' str = input() numList = str.split(' ') numList = [ int(x) for x in numList] #print(numList) result = 1 length = 0 for x in numList: result *= x length += x print(result,2*length)