message
stringlengths 2
39.6k
| message_type
stringclasses 2
values | message_id
int64 0
1
| conversation_id
int64 219
108k
| cluster
float64 11
11
| __index_level_0__
int64 438
217k
|
|---|---|---|---|---|---|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score.
You want to introduce the restaurants in the following order:
* The restaurants are arranged in lexicographical order of the names of their cities.
* If there are multiple restaurants in the same city, they are arranged in descending order of score.
Print the identification numbers of the restaurants in the order they are introduced in the book.
Constraints
* 1 ≤ N ≤ 100
* S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.
* 0 ≤ P_i ≤ 100
* P_i is an integer.
* P_i ≠ P_j (1 ≤ i < j ≤ N)
Input
Input is given from Standard Input in the following format:
N
S_1 P_1
:
S_N P_N
Output
Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.
Examples
Input
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
Output
3
4
6
1
5
2
Input
10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100
Output
10
9
8
7
6
5
4
3
2
1
Submitted Solution:
```
n = int(input())
sp = [input().split() + [i] for i in range(n)]
sp.sort(key = lambda x: (x[0],-int(x[1])))
for _,_,i in sp:
print(i + 1)
```
|
instruction
| 0
| 5,621
| 11
| 11,242
|
Yes
|
output
| 1
| 5,621
| 11
| 11,243
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score.
You want to introduce the restaurants in the following order:
* The restaurants are arranged in lexicographical order of the names of their cities.
* If there are multiple restaurants in the same city, they are arranged in descending order of score.
Print the identification numbers of the restaurants in the order they are introduced in the book.
Constraints
* 1 ≤ N ≤ 100
* S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.
* 0 ≤ P_i ≤ 100
* P_i is an integer.
* P_i ≠ P_j (1 ≤ i < j ≤ N)
Input
Input is given from Standard Input in the following format:
N
S_1 P_1
:
S_N P_N
Output
Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.
Examples
Input
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
Output
3
4
6
1
5
2
Input
10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100
Output
10
9
8
7
6
5
4
3
2
1
Submitted Solution:
```
n = int(input())
d = [input().split() + [i] for i in range(1,n+1)]
d.sort(key=lambda x: (x[0],-int(x[1])))
for i in d:
print(i[2])
```
|
instruction
| 0
| 5,622
| 11
| 11,244
|
Yes
|
output
| 1
| 5,622
| 11
| 11,245
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score.
You want to introduce the restaurants in the following order:
* The restaurants are arranged in lexicographical order of the names of their cities.
* If there are multiple restaurants in the same city, they are arranged in descending order of score.
Print the identification numbers of the restaurants in the order they are introduced in the book.
Constraints
* 1 ≤ N ≤ 100
* S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.
* 0 ≤ P_i ≤ 100
* P_i is an integer.
* P_i ≠ P_j (1 ≤ i < j ≤ N)
Input
Input is given from Standard Input in the following format:
N
S_1 P_1
:
S_N P_N
Output
Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.
Examples
Input
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
Output
3
4
6
1
5
2
Input
10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100
Output
10
9
8
7
6
5
4
3
2
1
Submitted Solution:
```
N = int(input())
L = []
for i in range(N):
s,p = input().split()
L.append([s, 100-int(p), i+1])
L.sort()
for j in L:
print(j[2])
```
|
instruction
| 0
| 5,623
| 11
| 11,246
|
Yes
|
output
| 1
| 5,623
| 11
| 11,247
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score.
You want to introduce the restaurants in the following order:
* The restaurants are arranged in lexicographical order of the names of their cities.
* If there are multiple restaurants in the same city, they are arranged in descending order of score.
Print the identification numbers of the restaurants in the order they are introduced in the book.
Constraints
* 1 ≤ N ≤ 100
* S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.
* 0 ≤ P_i ≤ 100
* P_i is an integer.
* P_i ≠ P_j (1 ≤ i < j ≤ N)
Input
Input is given from Standard Input in the following format:
N
S_1 P_1
:
S_N P_N
Output
Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.
Examples
Input
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
Output
3
4
6
1
5
2
Input
10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100
Output
10
9
8
7
6
5
4
3
2
1
Submitted Solution:
```
n=int(input())
A=[]
for i in range(1,n+1):
S,P=input().split()
A.append((S,-int(P),i))
B=sorted(A)
for f in range(n):
print(B[f][2])
```
|
instruction
| 0
| 5,624
| 11
| 11,248
|
Yes
|
output
| 1
| 5,624
| 11
| 11,249
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score.
You want to introduce the restaurants in the following order:
* The restaurants are arranged in lexicographical order of the names of their cities.
* If there are multiple restaurants in the same city, they are arranged in descending order of score.
Print the identification numbers of the restaurants in the order they are introduced in the book.
Constraints
* 1 ≤ N ≤ 100
* S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.
* 0 ≤ P_i ≤ 100
* P_i is an integer.
* P_i ≠ P_j (1 ≤ i < j ≤ N)
Input
Input is given from Standard Input in the following format:
N
S_1 P_1
:
S_N P_N
Output
Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.
Examples
Input
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
Output
3
4
6
1
5
2
Input
10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100
Output
10
9
8
7
6
5
4
3
2
1
Submitted Solution:
```
n = int(input())
guide = [[i+1, list(int(x) if x.isdigit() else x for x in input().split())] for i in range(n)]
print(guide) ##
guide = sorted(guide, key = lambda x:(x[1][0],-x[1][1]))
for i in range(n):
print(guide[i][0])
```
|
instruction
| 0
| 5,625
| 11
| 11,250
|
No
|
output
| 1
| 5,625
| 11
| 11,251
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score.
You want to introduce the restaurants in the following order:
* The restaurants are arranged in lexicographical order of the names of their cities.
* If there are multiple restaurants in the same city, they are arranged in descending order of score.
Print the identification numbers of the restaurants in the order they are introduced in the book.
Constraints
* 1 ≤ N ≤ 100
* S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.
* 0 ≤ P_i ≤ 100
* P_i is an integer.
* P_i ≠ P_j (1 ≤ i < j ≤ N)
Input
Input is given from Standard Input in the following format:
N
S_1 P_1
:
S_N P_N
Output
Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.
Examples
Input
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
Output
3
4
6
1
5
2
Input
10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100
Output
10
9
8
7
6
5
4
3
2
1
Submitted Solution:
```
n = int(input())
c = list()
num = 0
for i in range(1,n+1):
a,p = [x for x in input().split()]
c.append([a,p,i])
e = list()
c = sorted(c,key=lambda x:(x[0],x[1]))
for i in range(1,len(c)):
if(i == 1 and c[0][0] == c[1][0]):
e.append(c[0][2])
elif(i == 1 and c[0][0] != c[1][0]):
print(c[0][2])
e = list()
if(c[i-1][0] == c[i][0]):
e.append(c[i][2])
else:
for j in reversed(range(0,len(e))):
print(e[j])
e = list()
e.append(c[i][2])
for j in reversed(range(0,len(e))):
print(e[j])
```
|
instruction
| 0
| 5,626
| 11
| 11,252
|
No
|
output
| 1
| 5,626
| 11
| 11,253
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score.
You want to introduce the restaurants in the following order:
* The restaurants are arranged in lexicographical order of the names of their cities.
* If there are multiple restaurants in the same city, they are arranged in descending order of score.
Print the identification numbers of the restaurants in the order they are introduced in the book.
Constraints
* 1 ≤ N ≤ 100
* S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.
* 0 ≤ P_i ≤ 100
* P_i is an integer.
* P_i ≠ P_j (1 ≤ i < j ≤ N)
Input
Input is given from Standard Input in the following format:
N
S_1 P_1
:
S_N P_N
Output
Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.
Examples
Input
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
Output
3
4
6
1
5
2
Input
10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100
Output
10
9
8
7
6
5
4
3
2
1
Submitted Solution:
```
n = int(input())
stack = [['zzzzzzzzzzz', -1]]
for i in range(n):
s, p = input().split()
p = int(p)
stack.append([s, p])
cnt = {0}
for i in range(len(stack)-1):
x = 0
for j in range(1,len(stack)):
if j in cnt:
continue
else:
if stack[x][0] >= stack[j][0] and stack[x][1] < stack[j][1]:
x = j
cnt.add(x)
print(x)
```
|
instruction
| 0
| 5,627
| 11
| 11,254
|
No
|
output
| 1
| 5,627
| 11
| 11,255
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You have decided to write a book introducing good restaurants. There are N restaurants that you want to introduce: Restaurant 1, Restaurant 2, ..., Restaurant N. Restaurant i is in city S_i, and your assessment score of that restaurant on a 100-point scale is P_i. No two restaurants have the same score.
You want to introduce the restaurants in the following order:
* The restaurants are arranged in lexicographical order of the names of their cities.
* If there are multiple restaurants in the same city, they are arranged in descending order of score.
Print the identification numbers of the restaurants in the order they are introduced in the book.
Constraints
* 1 ≤ N ≤ 100
* S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.
* 0 ≤ P_i ≤ 100
* P_i is an integer.
* P_i ≠ P_j (1 ≤ i < j ≤ N)
Input
Input is given from Standard Input in the following format:
N
S_1 P_1
:
S_N P_N
Output
Print N lines. The i-th line (1 ≤ i ≤ N) should contain the identification number of the restaurant that is introduced i-th in the book.
Examples
Input
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40
Output
3
4
6
1
5
2
Input
10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100
Output
10
9
8
7
6
5
4
3
2
1
Submitted Solution:
```
import pandas as pd
import numpy as np
N = input()
N = int(N)
a_np = np.ones((N,1))
a_pd = pd.DataFrame(a_np,columns=['A'])
a_pd['B']=None
a_pd['C']=None
for i in range(0,N):
S, P = map(str, input().split())
P = int(P)
a_pd.loc[i,:] = [i,S,P]
#print(i,S,P)
b_pd = a_pd.sort_values(['B','C'],ascending=[True, False])
b_pd = b_pd.reset_index()
print(b_pd)
c = b_pd.loc[:,'A']
for j in range(0,N):
print(int(c[j]+1))
```
|
instruction
| 0
| 5,628
| 11
| 11,256
|
No
|
output
| 1
| 5,628
| 11
| 11,257
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Almost Identical Programs
The programming contest named Concours de Programmation Comtemporaine Interuniversitaire (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program.
Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such close submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.
Input
The input consists of at most 100 datasets, each in the following format.
s1
s2
Each of s1 and s2 is a string written in a line, with the length between 1 and 200, inclusive. They are the first and the second submitted programs respectively. A program consists of lowercase letters (`a`, `b`, ..., `z`), uppercase letters (`A`, `B`, ..., `Z`), digits (`0`, `1`, ..., `9`), double quotes (`"`), and semicolons (`;`). When double quotes occur in a program, there are always even number of them.
The end of the input is indicated by a line containing one '`.`' (period).
Output
For each dataset, print the judge result in a line.
If the given two programs are identical, print `IDENTICAL`. If two programs differ with only one corresponding string literal, print `CLOSE`. Otherwise, print `DIFFERENT`. A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.
Sample Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output for the Sample Input
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Example
Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Submitted Solution:
```
s1=[]
s2=[]
O=[]
while 1:
A=input().split('"')
if A==["."]:
break
i=0
cnt=0
B=input().split('"')
l1=len(A)
l2=len(B)
if l1==l2:
while i<l1 and i<l2:
if A[i]!=B[i]:
cnt+=1
if i%2==0:
cnt+=2
i+=1
if cnt==0:
O.append("IDENTICAL")
elif cnt==1:
O.append("CLOSE")
else:
O.append("DIFFERENT")
else:
O.append("DIFFERENT")
for i in range(len(O)):
print(O[i])
```
|
instruction
| 0
| 5,761
| 11
| 11,522
|
Yes
|
output
| 1
| 5,761
| 11
| 11,523
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Almost Identical Programs
The programming contest named Concours de Programmation Comtemporaine Interuniversitaire (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program.
Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such close submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.
Input
The input consists of at most 100 datasets, each in the following format.
s1
s2
Each of s1 and s2 is a string written in a line, with the length between 1 and 200, inclusive. They are the first and the second submitted programs respectively. A program consists of lowercase letters (`a`, `b`, ..., `z`), uppercase letters (`A`, `B`, ..., `Z`), digits (`0`, `1`, ..., `9`), double quotes (`"`), and semicolons (`;`). When double quotes occur in a program, there are always even number of them.
The end of the input is indicated by a line containing one '`.`' (period).
Output
For each dataset, print the judge result in a line.
If the given two programs are identical, print `IDENTICAL`. If two programs differ with only one corresponding string literal, print `CLOSE`. Otherwise, print `DIFFERENT`. A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.
Sample Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output for the Sample Input
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Example
Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Submitted Solution:
```
while True:
s1 = input()
if s1 == ".":
break
s2 = input().split("\"")
s1 = s1.split("\"")
if len(s1) != len(s2):
print("DIFFERENT")
else:
fin = False
count = 0
for i in range(len(s1)):
if i%2 == 0:
if s1[i] != s2[i]:
print("DIFFERENT")
fin = True
break
else:
if s1[i] != s2[i]:
count += 1
if count > 1:
print("DIFFERENT")
fin = True
break
if not fin:
if count == 1:
print("CLOSE")
elif count == 0:
print("IDENTICAL")
```
|
instruction
| 0
| 5,762
| 11
| 11,524
|
Yes
|
output
| 1
| 5,762
| 11
| 11,525
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Almost Identical Programs
The programming contest named Concours de Programmation Comtemporaine Interuniversitaire (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program.
Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such close submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.
Input
The input consists of at most 100 datasets, each in the following format.
s1
s2
Each of s1 and s2 is a string written in a line, with the length between 1 and 200, inclusive. They are the first and the second submitted programs respectively. A program consists of lowercase letters (`a`, `b`, ..., `z`), uppercase letters (`A`, `B`, ..., `Z`), digits (`0`, `1`, ..., `9`), double quotes (`"`), and semicolons (`;`). When double quotes occur in a program, there are always even number of them.
The end of the input is indicated by a line containing one '`.`' (period).
Output
For each dataset, print the judge result in a line.
If the given two programs are identical, print `IDENTICAL`. If two programs differ with only one corresponding string literal, print `CLOSE`. Otherwise, print `DIFFERENT`. A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.
Sample Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output for the Sample Input
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Example
Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Submitted Solution:
```
import sys
import re
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
ans = []
while 1:
s1 = input()
if s1 == ".":
break
s2 = input()
if s1 == s2:
ans.append("IDENTICAL")
else:
if s1.count('"') != s2.count('"'):
ans.append("DIFFERENT")
else:
s1 = s1.split('"')
s2 = s2.split('"')
cnt = 0
for i in range(min(len(s1), len(s2))):
if i % 2 == 0 and s1[i] != s2[i]:
ans.append("DIFFERENT")
break
elif i % 2 == 1 and s1[i] != s2[i]:
cnt += 1
if cnt >= 2:
ans.append("DIFFERENT")
break
else:
ans.append("CLOSE")
for i in ans:
print(i)
```
|
instruction
| 0
| 5,763
| 11
| 11,526
|
Yes
|
output
| 1
| 5,763
| 11
| 11,527
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Almost Identical Programs
The programming contest named Concours de Programmation Comtemporaine Interuniversitaire (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program.
Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such close submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.
Input
The input consists of at most 100 datasets, each in the following format.
s1
s2
Each of s1 and s2 is a string written in a line, with the length between 1 and 200, inclusive. They are the first and the second submitted programs respectively. A program consists of lowercase letters (`a`, `b`, ..., `z`), uppercase letters (`A`, `B`, ..., `Z`), digits (`0`, `1`, ..., `9`), double quotes (`"`), and semicolons (`;`). When double quotes occur in a program, there are always even number of them.
The end of the input is indicated by a line containing one '`.`' (period).
Output
For each dataset, print the judge result in a line.
If the given two programs are identical, print `IDENTICAL`. If two programs differ with only one corresponding string literal, print `CLOSE`. Otherwise, print `DIFFERENT`. A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.
Sample Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output for the Sample Input
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Example
Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Submitted Solution:
```
def f(S):
S_not_in_q = []
S_in_q = []
tmp = ''
i = 0
while i < len(S):
if S[i] == '"':
if tmp != '':
S_not_in_q.append(tmp)
tmp = ''
i += 1
while S[i] != '"':
tmp += S[i]
i += 1
else:
S_in_q.append(tmp)
tmp = ''
i += 1
else:
tmp += S[i]
i += 1
else:
if tmp != '':
S_not_in_q.append(tmp)
return S_not_in_q, S_in_q
while True:
S1 = input()
if S1 == '.':
break
S2 = input()
if (S1 == S2):
print('IDENTICAL')
continue
S1_not_in_q, S1_in_q = f(S1)
S2_not_in_q, S2_in_q = f(S2)
if (S1_not_in_q != S2_not_in_q):
print('DIFFERENT')
continue
else:
if len(S1_in_q) != len(S2_in_q):
print('DIFFERENT')
continue
else:
count = 0
for i in range(len(S1_in_q)):
if S1_in_q[i] != S2_in_q[i]:
count += 1
if count < 2:
print("CLOSE")
continue
else:
print("DIFFERENT")
continue
```
|
instruction
| 0
| 5,764
| 11
| 11,528
|
Yes
|
output
| 1
| 5,764
| 11
| 11,529
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Almost Identical Programs
The programming contest named Concours de Programmation Comtemporaine Interuniversitaire (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program.
Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such close submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.
Input
The input consists of at most 100 datasets, each in the following format.
s1
s2
Each of s1 and s2 is a string written in a line, with the length between 1 and 200, inclusive. They are the first and the second submitted programs respectively. A program consists of lowercase letters (`a`, `b`, ..., `z`), uppercase letters (`A`, `B`, ..., `Z`), digits (`0`, `1`, ..., `9`), double quotes (`"`), and semicolons (`;`). When double quotes occur in a program, there are always even number of them.
The end of the input is indicated by a line containing one '`.`' (period).
Output
For each dataset, print the judge result in a line.
If the given two programs are identical, print `IDENTICAL`. If two programs differ with only one corresponding string literal, print `CLOSE`. Otherwise, print `DIFFERENT`. A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.
Sample Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output for the Sample Input
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Example
Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Submitted Solution:
```
results=[]
while True:
a=input().split("\"")
if a[0]==".":
break
b=input().split("\"")
count1=0
count2=0
for i in range(int(len(a))):
if(i%2==1):
for (k,l) in zip(a[i],b[i]):
if(k!=l):
count1+=1
else:
for k,l in zip(a[i],b[i]):
if(k!=l):
count2+=1
if len(a) != len(b):
results.append(2)
else:
if count1==0 and count2==0:
results.append(0)
elif count1==1 and count2==0:
results.append(1)
else:
results.append(2)
for i in results:
if i==0:
print("IDENTICAL")
if i==1:
print("CLOSE")
if i==2:
print("DIFFERENT")
```
|
instruction
| 0
| 5,765
| 11
| 11,530
|
No
|
output
| 1
| 5,765
| 11
| 11,531
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Almost Identical Programs
The programming contest named Concours de Programmation Comtemporaine Interuniversitaire (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program.
Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such close submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.
Input
The input consists of at most 100 datasets, each in the following format.
s1
s2
Each of s1 and s2 is a string written in a line, with the length between 1 and 200, inclusive. They are the first and the second submitted programs respectively. A program consists of lowercase letters (`a`, `b`, ..., `z`), uppercase letters (`A`, `B`, ..., `Z`), digits (`0`, `1`, ..., `9`), double quotes (`"`), and semicolons (`;`). When double quotes occur in a program, there are always even number of them.
The end of the input is indicated by a line containing one '`.`' (period).
Output
For each dataset, print the judge result in a line.
If the given two programs are identical, print `IDENTICAL`. If two programs differ with only one corresponding string literal, print `CLOSE`. Otherwise, print `DIFFERENT`. A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.
Sample Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output for the Sample Input
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Example
Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Submitted Solution:
```
def p(A,s):
i=0
j=0
s=[]
while(len(A)>i):
if A[i]=='"':
list1=A.partition('"')
s.append(list1[0])
A=list1[2]
i=0
j+=1
else:
i+=1
if len(A)==i:
s.append(A)
return s
A=input()
s1=[]
s2=[]
O=[]
while 1:
i=0
cnt=0
B=input()
s1=p(A,s1)
s2=p(B,s2)
l1=len(s1)
l2=len(s2)
while i<l1 and i<l2:
if s1[i]!=s2[i]:
cnt+=1
i+=1
if cnt==0:
O.append("IDENTICAL")
elif cnt==1:
O.append("CLOSE")
else:
O.append("DIFFERENT")
A=input()
if A==".":
break
for i in range(len(O)):
print(O[i])
```
|
instruction
| 0
| 5,766
| 11
| 11,532
|
No
|
output
| 1
| 5,766
| 11
| 11,533
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Almost Identical Programs
The programming contest named Concours de Programmation Comtemporaine Interuniversitaire (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program.
Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such close submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.
Input
The input consists of at most 100 datasets, each in the following format.
s1
s2
Each of s1 and s2 is a string written in a line, with the length between 1 and 200, inclusive. They are the first and the second submitted programs respectively. A program consists of lowercase letters (`a`, `b`, ..., `z`), uppercase letters (`A`, `B`, ..., `Z`), digits (`0`, `1`, ..., `9`), double quotes (`"`), and semicolons (`;`). When double quotes occur in a program, there are always even number of them.
The end of the input is indicated by a line containing one '`.`' (period).
Output
For each dataset, print the judge result in a line.
If the given two programs are identical, print `IDENTICAL`. If two programs differ with only one corresponding string literal, print `CLOSE`. Otherwise, print `DIFFERENT`. A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.
Sample Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output for the Sample Input
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Example
Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Submitted Solution:
```
while(1):
a = input()
if(a == '.'):
break
b = input()
n = len(a)
m = len(b)
l = 0;
flag = 0
idx_dif = 0
error_cou = 0
while(1):
if(l >= n-1 or l+idx_dif >= m-1):
flag = 2
if(flag == 0):
for i in range(l,n):
if(a[i] == '\"'):
for j in range(l+idx_dif,m):
if(b[j] == '\"'):
if(a[l:i] == b[l+idx_dif:j]):
idx_dif = j-i
l = i+1
flag = 1
else:
flag = 2
break
elif(i == n-1):
if(a[l:i] != b[l+idx_dif:m-1]):
flag = 2
else:
l = n-1
break
if(flag != 0):
break
elif(flag == 1):
for i in range(l,n):
if(a[i] == '\"'):
for j in range(l+idx_dif,m):
if(b[j] == '\"'):
if(a[l:i] != b[l+idx_dif:j]):
error_cou += 1
idx_dif = j-i
l = i+1
flag = 0
break
if(j == m-1):
flag = 2
break
if(flag != 1):
break
if(flag == 2):
break
if(l >= n-1 or l+idx_dif >= m-1):
break
if(error_cou >= 2 or flag == 2):
print("DIFFERENT")
elif(error_cou == 1):
print("CLOSE")
elif(error_cou == 0):
print("IDENTICAL")
```
|
instruction
| 0
| 5,767
| 11
| 11,534
|
No
|
output
| 1
| 5,767
| 11
| 11,535
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Almost Identical Programs
The programming contest named Concours de Programmation Comtemporaine Interuniversitaire (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program.
Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such close submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.
Input
The input consists of at most 100 datasets, each in the following format.
s1
s2
Each of s1 and s2 is a string written in a line, with the length between 1 and 200, inclusive. They are the first and the second submitted programs respectively. A program consists of lowercase letters (`a`, `b`, ..., `z`), uppercase letters (`A`, `B`, ..., `Z`), digits (`0`, `1`, ..., `9`), double quotes (`"`), and semicolons (`;`). When double quotes occur in a program, there are always even number of them.
The end of the input is indicated by a line containing one '`.`' (period).
Output
For each dataset, print the judge result in a line.
If the given two programs are identical, print `IDENTICAL`. If two programs differ with only one corresponding string literal, print `CLOSE`. Otherwise, print `DIFFERENT`. A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.
Sample Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output for the Sample Input
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Example
Input
print"hello";print123
print"hello";print123
read"B1input";solve;output;
read"B2";solve;output;
read"C1";solve;output"C1ans";
read"C2";solve;output"C2ans";
""""""""
"""42"""""
slow"program"
fast"code"
"super"fast"program"
"super"faster"program"
X""
X
I"S""CREAM"
I"CE""CREAM"
11"22"11
1"33"111
.
Output
IDENTICAL
CLOSE
DIFFERENT
CLOSE
DIFFERENT
DIFFERENT
DIFFERENT
CLOSE
DIFFERENT
Submitted Solution:
```
while 1:
s1 = input().split('"')
if s1 is '.':
break
s2 = input().split('"')
if len(s1) != len(s2):
print("DIFFERENT")
continue
r = [0]*2
for i in range(len(s1)):
if s1[i] != s2[i]:
r[i%2] += 1
if [0,1]<r:
print("DIFFERENT")
else:
print(["IDENTICAL","CLOSE"][r[1]])
```
|
instruction
| 0
| 5,768
| 11
| 11,536
|
No
|
output
| 1
| 5,768
| 11
| 11,537
|
Provide tags and a correct Python 3 solution for this coding contest problem.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
|
instruction
| 0
| 6,064
| 11
| 12,128
|
Tags: binary search, implementation
Correct Solution:
```
def sum_series (v, k):
power = 0
res = 0
while v // (k ** power) > 1.0e-6:
res += v // (k ** power)
power += 1
return res
n, k = list(map(int, input().split()))
low = 1
high = n
while low <= high:
v = (low + high) // 2
if sum_series(v, k) >= n:
high = v - 1
else:
low = v + 1
print(low)
```
|
output
| 1
| 6,064
| 11
| 12,129
|
Provide tags and a correct Python 3 solution for this coding contest problem.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
|
instruction
| 0
| 6,065
| 11
| 12,130
|
Tags: binary search, implementation
Correct Solution:
```
n, k = (int(x) for x in input().split())
def is_possible(v, n):
i = 0
ans = 0
while int(v/(k**i)) != 0:
ans += int(v/(k**i))
i += 1
if ans >= n:
return True
return ans >= n
l = 0
r = n
while l < r:
med = int((l + r) / 2)
res = is_possible(med, n)
if not res:
l = med + 1
else:
r = med
if is_possible(l, n):
print(l)
else:
print(r)
```
|
output
| 1
| 6,065
| 11
| 12,131
|
Provide tags and a correct Python 3 solution for this coding contest problem.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
|
instruction
| 0
| 6,066
| 11
| 12,132
|
Tags: binary search, implementation
Correct Solution:
```
n,m=map(int,input().split())
l,r=0,n
mins=999999999999
while abs(l-r)!=1:
mid=(l+r)//2
cnt=0
mid_copy=mid
while mid>=1:
cnt+=mid
mid//=m
if n<=cnt:
mins=min(mins,mid_copy)
r=mid_copy
continue
if n==cnt:
print(min_copy)
break
if cnt>n:
r=mid_copy
else:
l=mid_copy
else:
if m>n:
print(n)
else:
mid=(l+r)//2
cnt=0
mid_copy=mid
while mid>=1:
cnt+=mid
mid//=m
if n<=cnt:
mins=min(mins,mid_copy)
r=mid_copy
if n==cnt:
print(mid_copy)
else:
print(mins)
```
|
output
| 1
| 6,066
| 11
| 12,133
|
Provide tags and a correct Python 3 solution for this coding contest problem.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
|
instruction
| 0
| 6,067
| 11
| 12,134
|
Tags: binary search, implementation
Correct Solution:
```
n, k = [int(i) for i in input().split()]
def f(x):
sum = x
i = 1
while k ** i <= x:
sum += int(x / k ** i)
i += 1
return sum
l = 0
r = 10 ** 30
while (r - l > 1):
m = (r + l) // 2
if f(m) >= n:
r = m
else:
l = m
print(r)
```
|
output
| 1
| 6,067
| 11
| 12,135
|
Provide tags and a correct Python 3 solution for this coding contest problem.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
|
instruction
| 0
| 6,068
| 11
| 12,136
|
Tags: binary search, implementation
Correct Solution:
```
import math
n,k = map(int,input().split())
l=1
r=n
while l!= r:
middle= math.floor(l+(r-l)/2)
tempAdder = middle
sum = 0
while tempAdder!= 0:
sum+=tempAdder
tempAdder=math.floor(tempAdder/k)
if sum>=n:
r=middle
else:
l=middle+1
print(l)
```
|
output
| 1
| 6,068
| 11
| 12,137
|
Provide tags and a correct Python 3 solution for this coding contest problem.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
|
instruction
| 0
| 6,069
| 11
| 12,138
|
Tags: binary search, implementation
Correct Solution:
```
n, k = map(int, input().split())
start, end = 1, n
while start != end:
org = mid = (start + end) >> 1
s = 0
while mid != 0:
s += mid
mid //= k
if s >= n:
end = org
else:
start = org + 1
print(start)
```
|
output
| 1
| 6,069
| 11
| 12,139
|
Provide tags and a correct Python 3 solution for this coding contest problem.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
|
instruction
| 0
| 6,070
| 11
| 12,140
|
Tags: binary search, implementation
Correct Solution:
```
def checker(v, k, n):
sum = 0
i = 0
lines = v
while sum < n and lines > 0:
sum += lines
i += 1
lines = int(v/(k**i))
return sum >= n
n, k = input().split(' ')
n = int(n)
k = int(k)
lb = int(n * (1 - (1/k)))
while not checker(lb, k, n):
lb += 1
print(lb)
```
|
output
| 1
| 6,070
| 11
| 12,141
|
Provide tags and a correct Python 3 solution for this coding contest problem.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
|
instruction
| 0
| 6,071
| 11
| 12,142
|
Tags: binary search, implementation
Correct Solution:
```
import sys
def get_lines(v, k):
lines = 0
q = v
while q != 0:
lines += q
q = q // k
return int(lines)
def get_min_v(n, k):
val = n if n % 2 == 0 else n + 1
curr_lines = get_lines(val, k)
# print("before while loop")
# print("val is ", val)
# print("curr lines is ", curr_lines)
while curr_lines >= n:
val = val / 2
curr_lines = get_lines(val, k)
# print("new val is ", val)
# print("new curr_lines is ", curr_lines)
# return int(val * 2)
low = int(val)
high = n
# print("low is ", low)
# print("high is ", high)
while low < high:
# print("low is ", low)
# print("high is ", high)
if high - low == 1:
return int(high)
mid = int(low + (high - low) / 2)
# print("mid is ", mid)
# print("lines is ", get_lines(mid, k))
if get_lines(mid, k) < n:
low = mid
else:
high = mid
f = sys.stdin
n, k = [int(x) for x in f.readline().strip().split(" ")]
print(get_min_v(n, k))
```
|
output
| 1
| 6,071
| 11
| 12,143
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
Submitted Solution:
```
def check(start, k, n):
pages = 0
while(start > 0):
pages += start
start = int(start / k)
return pages >= n
p = list(map(int, input().split(" ")))
n = p[0]
k = p[1]
low = 0
high = n + 1
while(low + 1 < high):
mid = int((low + high) / 2)
if(check(mid, k, n)):
high = mid
else:
low = mid
print(low + 1)
```
|
instruction
| 0
| 6,072
| 11
| 12,144
|
Yes
|
output
| 1
| 6,072
| 11
| 12,145
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
Submitted Solution:
```
import sys
n,k=map(int,input().split())
if n <= k :
print(n)
else:
start = k ; end = n
while end > start :
mid = (start+end)//2
y=1 ; ans = mid
while mid >= (k**y):
ans += mid//(k**y)
y+=1
if ans == n :
print(mid)
sys.exit(0)
elif ans > n :
rr = mid
end = mid
else:
start = mid+1
print(rr)
```
|
instruction
| 0
| 6,073
| 11
| 12,146
|
Yes
|
output
| 1
| 6,073
| 11
| 12,147
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
Submitted Solution:
```
from math import log, floor
def binarysearch(n, k, p):
left = 0
right = n+1
while left < right:
middle = (left + right) // 2
if sum([middle//k**i for i in range(p+1)]) < n:
left = middle + 1
else:
right = middle
return left
n, k = [int(i) for i in input().split()]
p = floor(log(n, k))
y = binarysearch(n, k, p)
print(y)
```
|
instruction
| 0
| 6,074
| 11
| 12,148
|
Yes
|
output
| 1
| 6,074
| 11
| 12,149
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
Submitted Solution:
```
l = input().split(' ')
n, k = int(l[0]), int(l[1])
left, right = 1, n
while left != right:
x = middle = (left + right) // 2
sum = 0
while x != 0:
sum += x
x //= k
if sum >= n:
right = middle
else:
left = middle + 1
print(left)
```
|
instruction
| 0
| 6,075
| 11
| 12,150
|
Yes
|
output
| 1
| 6,075
| 11
| 12,151
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
Submitted Solution:
```
n, k = map(int, input().split())
l, r = 1, int(10e6 + 1)
m = (l + r) // 2
sm = 0
it = 1000
while l < r - 1 and it > 0:
it -= 1
f = 0
m = (l + r) // 2
sm = 0
i = 0
v = int(m / pow(k, i))
while v:
sm += v
i += 1
v = int(m / pow(k, i))
if sm >= n:
r = m
else:
l = m
print(m)
```
|
instruction
| 0
| 6,076
| 11
| 12,152
|
No
|
output
| 1
| 6,076
| 11
| 12,153
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
Submitted Solution:
```
n,m=map(int,input().split())
l,r=0,n
mins=999999999999
while abs(l-r)!=1:
mid=(l+r)//2
cnt=0
mid_copy=mid
while mid>=1:
cnt+=mid
mid//=m
if n<=cnt:
mins=min(mins,mid_copy)
r=mid_copy
continue
if n==cnt:
print(min_copy)
break
if cnt>n:
r=mid_copy
else:
l=mid_copy
else:
if n==1:
print(1)
else:
mid=(l+r)//2
cnt=0
mid_copy=mid
while mid>=1:
cnt+=mid
mid//=m
if n<=cnt:
mins=min(mins,mid_copy)
r=mid_copy
if n==cnt:
print(mid_copy)
else:
print(mins)
```
|
instruction
| 0
| 6,077
| 11
| 12,154
|
No
|
output
| 1
| 6,077
| 11
| 12,155
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
Submitted Solution:
```
import math
def check(n,k,maxi,v):
best=v
v=v+1
while(True):
sumi=0
for i in range(maxi):
sumi+= v/ k**i
if(int(sumi)>=n):
return v
def proB(n,k):
maxi=0
while(k**maxi<=n):
maxi+=1
sumi=0
for i in range(maxi):
sumi+= 1/ k**i
ans=n/sumi
if(int(ans)*sumi==n):
return int(ans)
return check(n,k,maxi,int(ans))
arr1=list(map(int,input().split()))
n,m=arr1[0],arr1[1]
print(proB(n,m))
```
|
instruction
| 0
| 6,078
| 11
| 12,156
|
No
|
output
| 1
| 6,078
| 11
| 12,157
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of tea, then he writes <image> lines and so on: <image>, <image>, <image>, ...
The expression <image> is regarded as the integral part from dividing number a by number b.
The moment the current value <image> equals 0, Vasya immediately falls asleep and he wakes up only in the morning, when the program should already be finished.
Vasya is wondering, what minimum allowable value v can take to let him write not less than n lines of code before he falls asleep.
Input
The input consists of two integers n and k, separated by spaces — the size of the program in lines and the productivity reduction coefficient, 1 ≤ n ≤ 109, 2 ≤ k ≤ 10.
Output
Print the only integer — the minimum value of v that lets Vasya write the program in one night.
Examples
Input
7 2
Output
4
Input
59 9
Output
54
Note
In the first sample the answer is v = 4. Vasya writes the code in the following portions: first 4 lines, then 2, then 1, and then Vasya falls asleep. Thus, he manages to write 4 + 2 + 1 = 7 lines in a night and complete the task.
In the second sample the answer is v = 54. Vasya writes the code in the following portions: 54, 6. The total sum is 54 + 6 = 60, that's even more than n = 59.
Submitted Solution:
```
from sys import stdin
def works(n, v, k):
d = 1
t = 0
while v >= d and t < n:
t += v // d
d *= k
return t >= n
line = stdin.readline().strip().split(" ")
n = int(line[0])
k = int(line[1])
lo = 1
hi = 10 ** 9
while lo + 1 < hi:
mid = (lo + hi) // 2
if works(n, mid, k):
hi = mid
else:
lo = mid
print(hi)
```
|
instruction
| 0
| 6,079
| 11
| 12,158
|
No
|
output
| 1
| 6,079
| 11
| 12,159
|
Provide a correct Python 3 solution for this coding contest problem.
The Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's describe the problem:
You've got some training set of documents. For each document you know its subject. The subject in this problem is an integer from 1 to 3. Each of these numbers has a physical meaning. For instance, all documents with subject 3 are about trade.
You can download the training set of documents at the following link: http://download4.abbyy.com/a2/X2RZ2ZWXBG5VYWAL61H76ZQM/train.zip. The archive contains three directories with names "1", "2", "3". Directory named "1" contains documents on the 1-st subject, directory "2" contains documents on the 2-nd subject, and directory "3" contains documents on the 3-rd subject. Each document corresponds to exactly one file from some directory.
All documents have the following format: the first line contains the document identifier, the second line contains the name of the document, all subsequent lines contain the text of the document. The document identifier is used to make installing the problem more convenient and has no useful information for the participants.
You need to write a program that should indicate the subject for a given document. It is guaranteed that all documents given as input to your program correspond to one of the three subjects of the training set.
Input
The first line contains integer id (0 ≤ id ≤ 106) — the document identifier. The second line contains the name of the document. The third and the subsequent lines contain the text of the document. It is guaranteed that the size of any given document will not exceed 10 kilobytes.
The tests for this problem are divided into 10 groups. Documents of groups 1 and 2 are taken from the training set, but their identifiers will not match the identifiers specified in the training set. Groups from the 3-rd to the 10-th are roughly sorted by the author in ascending order of difficulty (these groups contain documents which aren't present in the training set).
Output
Print an integer from 1 to 3, inclusive — the number of the subject the given document corresponds to.
Examples
|
instruction
| 0
| 6,094
| 11
| 12,188
|
"Correct Solution:
```
print('2')
```
|
output
| 1
| 6,094
| 11
| 12,189
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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.
Constraints
* 1 \leq N \leq 100
* 0 \leq A \leq N
* 0 \leq B \leq N
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A B
Output
Print the maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.
Examples
Input
10 3 5
Output
3 0
Input
10 7 5
Output
5 2
Input
100 100 100
Output
100 100
Submitted Solution:
```
n,x,y=map(int,input().split())
print(min(x,y),max(0,x+y-n))
```
|
instruction
| 0
| 6,437
| 11
| 12,874
|
Yes
|
output
| 1
| 6,437
| 11
| 12,875
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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.
Constraints
* 1 \leq N \leq 100
* 0 \leq A \leq N
* 0 \leq B \leq N
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A B
Output
Print the maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.
Examples
Input
10 3 5
Output
3 0
Input
10 7 5
Output
5 2
Input
100 100 100
Output
100 100
Submitted Solution:
```
N, A, B = tuple(map(int, input().split()))
print(min(A, B), max(0, (A + B) - N))
```
|
instruction
| 0
| 6,438
| 11
| 12,876
|
Yes
|
output
| 1
| 6,438
| 11
| 12,877
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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.
Constraints
* 1 \leq N \leq 100
* 0 \leq A \leq N
* 0 \leq B \leq N
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A B
Output
Print the maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.
Examples
Input
10 3 5
Output
3 0
Input
10 7 5
Output
5 2
Input
100 100 100
Output
100 100
Submitted Solution:
```
n,a,b = list(map(int, input().split()))
mx = min(a,b)
mn = max(a+b-n,0)
print(mx, mn)
```
|
instruction
| 0
| 6,439
| 11
| 12,878
|
Yes
|
output
| 1
| 6,439
| 11
| 12,879
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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.
Constraints
* 1 \leq N \leq 100
* 0 \leq A \leq N
* 0 \leq B \leq N
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A B
Output
Print the maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.
Examples
Input
10 3 5
Output
3 0
Input
10 7 5
Output
5 2
Input
100 100 100
Output
100 100
Submitted Solution:
```
n,a,b = map(int, input().split())
Max = min(a,b)
print(Max, max(a+b-n, 0))
```
|
instruction
| 0
| 6,440
| 11
| 12,880
|
Yes
|
output
| 1
| 6,440
| 11
| 12,881
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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.
Constraints
* 1 \leq N \leq 100
* 0 \leq A \leq N
* 0 \leq B \leq N
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A B
Output
Print the maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.
Examples
Input
10 3 5
Output
3 0
Input
10 7 5
Output
5 2
Input
100 100 100
Output
100 100
Submitted Solution:
```
from sys import stdin
N,A,B=[int(x) for x in stdin.readline().rstrip().split()]
if N==A and A==B and B==N:
print(N,N)
else:
if A>B:
if (A+B)>N:
print(B,A-B)
else:
print(B,0)
else:
if (A+B)>N:
print(A,B-A)
else:
print(A,0)
```
|
instruction
| 0
| 6,441
| 11
| 12,882
|
No
|
output
| 1
| 6,441
| 11
| 12,883
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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.
Constraints
* 1 \leq N \leq 100
* 0 \leq A \leq N
* 0 \leq B \leq N
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A B
Output
Print the maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.
Examples
Input
10 3 5
Output
3 0
Input
10 7 5
Output
5 2
Input
100 100 100
Output
100 100
Submitted Solution:
```
x, y, z = map(int,input().split())
print(min(y,z), max(0, x-y-z))
```
|
instruction
| 0
| 6,442
| 11
| 12,884
|
No
|
output
| 1
| 6,442
| 11
| 12,885
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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.
Constraints
* 1 \leq N \leq 100
* 0 \leq A \leq N
* 0 \leq B \leq N
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A B
Output
Print the maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.
Examples
Input
10 3 5
Output
3 0
Input
10 7 5
Output
5 2
Input
100 100 100
Output
100 100
Submitted Solution:
```
n, a, b = map(int, input().split())
print(min(a, b), (a+b) - n)
```
|
instruction
| 0
| 6,443
| 11
| 12,886
|
No
|
output
| 1
| 6,443
| 11
| 12,887
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
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.
Constraints
* 1 \leq N \leq 100
* 0 \leq A \leq N
* 0 \leq B \leq N
* All values in input are integers.
Input
Input is given from Standard Input in the following format:
N A B
Output
Print the maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.
Examples
Input
10 3 5
Output
3 0
Input
10 7 5
Output
5 2
Input
100 100 100
Output
100 100
Submitted Solution:
```
def main():
N, A, B = map(int, input().split())
if N == A and N == B:
# 全員が両方読んでいる場合
print(N, N)
return
max_result = max([A, B])
min_result = min([A, B])
if A + B > N:
# AとBの合計がNより大きい場合、最大は小さい方の数、最小は大ー小
print(min_result, max_result - min_result)
elif A + B <= N:
# AとBの合計がNより小さい場合、最大は小さい方の数、最小は0
print(min_result, 0)
main()
```
|
instruction
| 0
| 6,444
| 11
| 12,888
|
No
|
output
| 1
| 6,444
| 11
| 12,889
|
Provide a correct Python 3 solution for this coding contest problem.
Example
Input
20
Output
4
|
instruction
| 0
| 6,530
| 11
| 13,060
|
"Correct Solution:
```
def solve():
D = input()
N = len(D)
*DI, = map(int, D)
su = sum(DI)
pd = 1
for d in D:
pd *= int(d) + 1
memo = [{} for i in range(N)]
def dfs0(i, s, p):
key = (s, p)
if i == N:
return s > 0 or (s == 0 and p < pd)
if key in memo[i]:
return memo[i][key]
r = 0
for v in range(min(s, 9)+1):
r += dfs0(i+1, s-v, p*(v+1))
memo[i][key] = r
return r
res1 = dfs0(0, su, 1)
memo1 = [{} for i in range(N)]
def dfs1(i, s, p, m):
key = (s, p, m)
if i == N:
return s == 0 and p == 1
if key in memo1[i]:
return memo1[i][key]
r = 0
b = s - (N-1-i)*9
di = DI[i]
for v in range(max(b, 0), min(s, 9)+1):
if p % (v+1):
continue
if m == 0:
if di < v:
break
r += dfs1(i+1, s-v, p//(v+1), +(v < di))
else:
r += dfs1(i+1, s-v, p//(v+1), 1)
memo1[i][key] = r
return r
res2 = dfs1(0, su, pd, 0) - 1
ans = res1 + res2
print(ans)
solve()
```
|
output
| 1
| 6,530
| 11
| 13,061
|
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and giving each other interesting problems to solve. When it was Alice's turn, she told the number n to Bob and said:
—Shuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.
—No problem! — said Bob and immediately gave her an answer.
Alice said a random number, so she doesn't know whether Bob's answer is correct. Help her to find this out, because impatient brother is waiting for the verdict.
Input
The first line contains one integer n (0 ≤ n ≤ 109) without leading zeroes. The second lines contains one integer m (0 ≤ m ≤ 109) — Bob's answer, possibly with leading zeroes.
Output
Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.
Examples
Input
3310
1033
Output
OK
Input
4
5
Output
WRONG_ANSWER
Submitted Solution:
```
n=input()
m=input()
l=list(n)
l.sort()
x=l.count('0')
d=[]
for i in l:
if(i!='0'):
d.append(i)
d.sort()
if(d==[]):
if(int(n)==int(m)):
print("OK")
else:
print("WRONG_ANSWER")
else:
s=d[0]+'0'*x+''.join(d[1:])
if(int(s)==int(m)):
print("OK")
else:
print("WRONG ANSWER")
```
|
instruction
| 0
| 6,716
| 11
| 13,432
|
No
|
output
| 1
| 6,716
| 11
| 13,433
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
|
instruction
| 0
| 6,862
| 11
| 13,724
|
Tags: brute force
Correct Solution:
```
n=int(input())
a=[int(i) for i in input().split()]
ans=0
big=a[0]
small=a[0]
for i in range(1,n):
if a[i]>big:
big=a[i]
ans+=1
elif a[i]<small:
small=a[i]
ans+=1
print(ans)
```
|
output
| 1
| 6,862
| 11
| 13,725
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
|
instruction
| 0
| 6,863
| 11
| 13,726
|
Tags: brute force
Correct Solution:
```
n = input()
arr = list(map(int, input().split()))
amazing = 0
for i, a in enumerate(arr):
if i == 0:
mx = mn = a
else:
if a > mx:
amazing += 1
mx = a
if a < mn:
amazing += 1
mn = a
print(amazing)
```
|
output
| 1
| 6,863
| 11
| 13,727
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
|
instruction
| 0
| 6,864
| 11
| 13,728
|
Tags: brute force
Correct Solution:
```
n=int(input())
b=input().split()
t=[]
m=[]
score=0
for i in range(1,n+1):
t.append(int(b[i-1]))
if len(t)>1:
if t[-1]>max(m) or t[-1]<min(m):
score=score+1
m.append(int(b[i-1]))
else:
m.append(int(b[i-1]))
else:
m.append(int(b[i-1]))
print(score)
```
|
output
| 1
| 6,864
| 11
| 13,729
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
|
instruction
| 0
| 6,865
| 11
| 13,730
|
Tags: brute force
Correct Solution:
```
n = int(input())
p = list(map(int, input().split()))
amazing = 0
for x in range(1, n):
if p[x] == p[0]:
continue
elif p[x] > p[0]:
for y in range(1, x):
if p[x] <= p[y]:
break
else:
amazing += 1
elif p[x] < p[0]:
for y in range(1, x):
if p[x] >= p[y]:
break
else:
amazing += 1
print(amazing)
```
|
output
| 1
| 6,865
| 11
| 13,731
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
|
instruction
| 0
| 6,866
| 11
| 13,732
|
Tags: brute force
Correct Solution:
```
n=int(input())
l=list(map(int,input().split()))
a=l[0]
b=l[0]
c=0
for i in l:
if i>a:
c=c+1
a=i
for i in l:
if i<b:
c=c+1
b=i
print(c)
```
|
output
| 1
| 6,866
| 11
| 13,733
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
|
instruction
| 0
| 6,867
| 11
| 13,734
|
Tags: brute force
Correct Solution:
```
n=int(input())
lst=list(map(int,input().split()))
MAX=MIN=lst[0]
ans=0
for i in lst[1:]:
if i>MAX:
MAX=i
ans+=1
if i<MIN:
MIN=i
ans+=1
print(ans)
```
|
output
| 1
| 6,867
| 11
| 13,735
|
Provide tags and a correct Python 3 solution for this coding contest problem.
Vasya adores sport programming. He can't write programs but he loves to watch the contests' progress. Vasya even has a favorite coder and Vasya pays special attention to him.
One day Vasya decided to collect the results of all contests where his favorite coder participated and track the progress of his coolness. For each contest where this coder participated, he wrote out a single non-negative number — the number of points his favorite coder earned in the contest. Vasya wrote out the points for the contest in the order, in which the contests run (naturally, no two contests ran simultaneously).
Vasya considers a coder's performance in a contest amazing in two situations: he can break either his best or his worst performance record. First, it is amazing if during the contest the coder earns strictly more points that he earned on each past contest. Second, it is amazing if during the contest the coder earns strictly less points that he earned on each past contest. A coder's first contest isn't considered amazing. Now he wants to count the number of amazing performances the coder had throughout his whole history of participating in contests. But the list of earned points turned out long and Vasya can't code... That's why he asks you to help him.
Input
The first line contains the single integer n (1 ≤ n ≤ 1000) — the number of contests where the coder participated.
The next line contains n space-separated non-negative integer numbers — they are the points which the coder has earned. The points are given in the chronological order. All points do not exceed 10000.
Output
Print the single number — the number of amazing performances the coder has had during his whole history of participating in the contests.
Examples
Input
5
100 50 200 150 200
Output
2
Input
10
4664 6496 5814 7010 5762 5736 6944 4850 3698 7242
Output
4
Note
In the first sample the performances number 2 and 3 are amazing.
In the second sample the performances number 2, 4, 9 and 10 are amazing.
|
instruction
| 0
| 6,868
| 11
| 13,736
|
Tags: brute force
Correct Solution:
```
a=int(input())
b=list(map(int,input().split()))
x=int(1)
m=b[0]
n=b[0]
t=[]
t.append(b[0])
k=int(0)
while x<a:
if b[x]>m or b[x]<n:
k=k+1
t.append(b[x])
m=max(t)
n=min(t)
x=x+1
print(k)
```
|
output
| 1
| 6,868
| 11
| 13,737
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.