message stringlengths 2 43.5k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 853 107k | cluster float64 24 24 | __index_level_0__ int64 1.71k 214k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. His current rating is r units.
Some very rich ... | instruction | 0 | 46,312 | 24 | 92,624 |
Tags: dp, greedy
Correct Solution:
```
'''input
5 20
45 -6
34 -15
10 34
1 27
40 -45
'''
import sys
from collections import defaultdict as dd
mod=10**9+7
def ri(flag=0):
if flag==0:
return [int(i) for i in sys.stdin.readline().split()]
else:
return int(sys.stdin.readline())
n, r = ri()
eventspos = []
events... | output | 1 | 46,312 | 24 | 92,625 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. His current rating is r units.
Some very rich ... | instruction | 0 | 46,313 | 24 | 92,626 |
Tags: dp, greedy
Correct Solution:
```
# Enter your code here. Read input from STDIN. Print output to STDOUT# ===============================================================================================
# importing some useful libraries.
from __future__ import division, print_function
from fractions import Fraction
... | output | 1 | 46,313 | 24 | 92,627 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. His current rating is r units.
Some very rich ... | instruction | 0 | 46,314 | 24 | 92,628 |
Tags: dp, greedy
Correct Solution:
```
from functools import reduce
def doProject(r, proj, nproj):
count=0
for i in range(len(proj)):
if(proj[i][0]<=r):
r+=proj[i][1]
count+=1
else:
pass
dp=[[0 for j in range(r+1)] for i in range(len(nproj)+1)]
dp[0]... | output | 1 | 46,314 | 24 | 92,629 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. His current rating is r units.
Some very rich ... | instruction | 0 | 46,315 | 24 | 92,630 |
Tags: dp, greedy
Correct Solution:
```
import sys
input = sys.stdin.readline
n, r = map(int, input().split())
l = []
for _ in range(n):
l.append(list(map(int, input().split())))
p = 0
ans = 0
while (p < n):
if l[p][0] <= r and l[p][1] >= 0:
r += l[p][1]
l = l[:p] + l[p + 1:]
p = 0
n -= 1
ans += 1
else:
... | output | 1 | 46,315 | 24 | 92,631 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. His current rating is r units.
Some very rich ... | instruction | 0 | 46,316 | 24 | 92,632 |
Tags: dp, greedy
Correct Solution:
```
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 9 11:12:02 2020
@author: Rodro
"""
inp = str(input()).split()
size = int(inp[0])
r = int(inp[1])
pos = []
neg = []
for i in range(size):
inp = str(input()).split()
a = int(inp[0])
b = int(inp[1])
if b >= 0: pos.app... | output | 1 | 46,316 | 24 | 92,633 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. His current rating is r units.
Some very rich ... | instruction | 0 | 46,317 | 24 | 92,634 |
Tags: dp, greedy
Correct Solution:
```
#https://codeforces.com/contest/1203/problem/F2
n, r = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(n)]
def solve1(cur, arr):
cnt=0
while len(arr) > 0:
max_inc = -9999
choose = None
for a, b in arr:
... | output | 1 | 46,317 | 24 | 92,635 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. His current rating is r units.
Some very rich ... | instruction | 0 | 46,318 | 24 | 92,636 |
Tags: dp, greedy
Correct Solution:
```
n, r = map(int, input().split())
a = []
cnt = 0
for i in range(n):
a.append([int(j) for j in input().split()])
flag = True
while flag:
flag = False
for i in a:
if r >= i[0] and i[1] >= 0:
flag = True
r += i[1]
cnt += 1
... | output | 1 | 46,318 | 24 | 92,637 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. ... | instruction | 0 | 46,319 | 24 | 92,638 |
Yes | output | 1 | 46,319 | 24 | 92,639 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. ... | instruction | 0 | 46,320 | 24 | 92,640 |
Yes | output | 1 | 46,320 | 24 | 92,641 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. ... | instruction | 0 | 46,321 | 24 | 92,642 |
Yes | output | 1 | 46,321 | 24 | 92,643 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. ... | instruction | 0 | 46,322 | 24 | 92,644 |
Yes | output | 1 | 46,322 | 24 | 92,645 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. ... | instruction | 0 | 46,323 | 24 | 92,646 |
No | output | 1 | 46,323 | 24 | 92,647 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. ... | instruction | 0 | 46,324 | 24 | 92,648 |
No | output | 1 | 46,324 | 24 | 92,649 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. ... | instruction | 0 | 46,325 | 24 | 92,650 |
No | output | 1 | 46,325 | 24 | 92,651 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is that you should complete all the projects in easy version but this is not necessary in hard version.
Polycarp is a very famous freelancer. ... | instruction | 0 | 46,326 | 24 | 92,652 |
No | output | 1 | 46,326 | 24 | 92,653 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.
He wants to know how many subse... | instruction | 0 | 46,657 | 24 | 93,314 |
Tags: binary search, data structures, dp
Correct Solution:
```
import collections
maxa = 10**9
def main():
n, k = [int(s) for s in input().split()]
alist = [int(s) for s in input().split()]
if k == 1:
a_ct = collections.Counter(alist)
print(sum(c*(c-1)*(c-2)//6 for a,c in a_ct.items(... | output | 1 | 46,657 | 24 | 93,315 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.
He wants to know how many subse... | instruction | 0 | 46,658 | 24 | 93,316 |
Tags: binary search, data structures, dp
Correct Solution:
```
n, k = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
D = {}
amount = 0
for x in a:
if not x in D:
D[x] = [0, 0]
t = D[x//k] if x%k == 0 and x//k in D else [0,0]
D[x][1] += t[0]
D[x][0] += 1
if x != 0 : a... | output | 1 | 46,658 | 24 | 93,317 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.
He wants to know how many subse... | instruction | 0 | 46,659 | 24 | 93,318 |
Tags: binary search, data structures, dp
Correct Solution:
```
# -*- coding: utf-8 -*-
# Baqir Khan
# Software Engineer (Backend)
from collections import defaultdict
from sys import stdin
inp = stdin.readline
n, k = map(int, inp().split())
a = list(map(int, inp().split()))
left = [0] * n
freq_left = defaultdict(int... | output | 1 | 46,659 | 24 | 93,319 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.
He wants to know how many subse... | instruction | 0 | 46,660 | 24 | 93,320 |
Tags: binary search, data structures, dp
Correct Solution:
```
from collections import Counter
from collections import defaultdict
def mp(): return map(int,input().split())
def lt(): return list(map(int,input().split()))
def pt(x): print(x)
def ip(): return input()
def it(): return int(input())
def sl(x): return ... | output | 1 | 46,660 | 24 | 93,321 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.
He wants to know how many subse... | instruction | 0 | 46,661 | 24 | 93,322 |
Tags: binary search, data structures, dp
Correct Solution:
```
from collections import defaultdict
import time
if __name__ == "__main__":
n , k = [int(x) for x in input().split()]
nums = [int(x) for x in input().split()]
#n , k = 200000 , 1
#nums = [1 for i in range(n)]
#t1 = time.time()
le... | output | 1 | 46,661 | 24 | 93,323 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.
He wants to know how many subse... | instruction | 0 | 46,662 | 24 | 93,324 |
Tags: binary search, data structures, dp
Correct Solution:
```
from collections import Counter
n,k=map(int, input().split())
a=list(map(int, input().split()))
left={}
ans=0
right=Counter(a)
for i in range(n):
if right[a[i]]>0:
right[a[i]]-=1
if a[i]%k==0:
t1=a[i]//k
t2=a[i]*k
... | output | 1 | 46,662 | 24 | 93,325 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.
He wants to know how many subse... | instruction | 0 | 46,663 | 24 | 93,326 |
Tags: binary search, data structures, dp
Correct Solution:
```
from collections import Counter
def solve(n, k, arr):
c1 = Counter()
c2 = Counter()
total = 0
for a in reversed(arr):
total += c2[a*k]
c2[a] += c1[a*k]
c1[a] += 1
return total
n, k = map(int, input().split())
ar... | output | 1 | 46,663 | 24 | 93,327 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.
He wants to know how many subse... | instruction | 0 | 46,664 | 24 | 93,328 |
Tags: binary search, data structures, dp
Correct Solution:
```
l=input().split()
n=int(l[0])
k=int(l[1])
l=input().split()
li=[int(i) for i in l]
hashipref=dict()
hashisuff=dict()
for i in range(n-1,0,-1):
if(li[i] not in hashisuff):
hashisuff[li[i]]=1
else:
hashisuff[li[i]]+=1
ans=0
for i in ra... | output | 1 | 46,664 | 24 | 93,329 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting ... | instruction | 0 | 46,665 | 24 | 93,330 |
Yes | output | 1 | 46,665 | 24 | 93,331 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting ... | instruction | 0 | 46,666 | 24 | 93,332 |
Yes | output | 1 | 46,666 | 24 | 93,333 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting ... | instruction | 0 | 46,667 | 24 | 93,334 |
Yes | output | 1 | 46,667 | 24 | 93,335 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting ... | instruction | 0 | 46,668 | 24 | 93,336 |
Yes | output | 1 | 46,668 | 24 | 93,337 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting ... | instruction | 0 | 46,669 | 24 | 93,338 |
No | output | 1 | 46,669 | 24 | 93,339 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting ... | instruction | 0 | 46,670 | 24 | 93,340 |
No | output | 1 | 46,670 | 24 | 93,341 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting ... | instruction | 0 | 46,671 | 24 | 93,342 |
No | output | 1 | 46,671 | 24 | 93,343 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting ... | instruction | 0 | 46,672 | 24 | 93,344 |
No | output | 1 | 46,672 | 24 | 93,345 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the evening Polycarp decided to analyze his today's travel expenses on public transport.
The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediat... | instruction | 0 | 47,599 | 24 | 95,198 |
Tags: greedy, implementation, sortings
Correct Solution:
```
n, a, b, k, f = map(int, input().split())
slov = dict()
temp = input().split()
slov[frozenset(temp)] = a
for i in range(1, n):
temp2 = input().split()
try:
if temp2[0] == temp[1]:
slov[frozenset(temp2)] += b
else:
... | output | 1 | 47,599 | 24 | 95,199 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the evening Polycarp decided to analyze his today's travel expenses on public transport.
The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediat... | instruction | 0 | 47,600 | 24 | 95,200 |
Tags: greedy, implementation, sortings
Correct Solution:
```
n, a, b, k, f = list(map(int, input().split()))
totalCost = {}
lastStop = ''
total = 0
for i in range(n):
s1, s2 = input().split()
cost = a if lastStop != s1 else b
key = (min(s1, s2), max(s1, s2))
if key not in totalCost:
totalCost[ke... | output | 1 | 47,600 | 24 | 95,201 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the evening Polycarp decided to analyze his today's travel expenses on public transport.
The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediat... | instruction | 0 | 47,601 | 24 | 95,202 |
Tags: greedy, implementation, sortings
Correct Solution:
```
n,a,b,k,f = [int(i) for i in input().split()]
pred = "_"
d = dict()
for i in range(n):
s1, s2 = [i for i in input().split()]
pr = a
if s1 == pred:
pr = b
if (s1, s2) in d.keys():
d[(s1, s2)] += pr
elif (s2, s1) in d.keys()... | output | 1 | 47,601 | 24 | 95,203 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the evening Polycarp decided to analyze his today's travel expenses on public transport.
The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediat... | instruction | 0 | 47,602 | 24 | 95,204 |
Tags: greedy, implementation, sortings
Correct Solution:
```
n, a, b, k, f = [int(i) for i in input().split()]
stops = dict()
prev = ""
ans = 0
for i in range(n):
x, y = [i for i in input().split()]
price = a
if x == prev:
price = b
prev = y
p, q = (min(x,y), max(x,y))
if (p, q) in stops... | output | 1 | 47,602 | 24 | 95,205 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the evening Polycarp decided to analyze his today's travel expenses on public transport.
The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediat... | instruction | 0 | 47,603 | 24 | 95,206 |
Tags: greedy, implementation, sortings
Correct Solution:
```
import heapq
import sys
num_trips, a, b, k, f = sys.stdin.readline().strip().split(" ")
a, b, k, f = int(a), int(b), int(k), int(f)
#print(a, b, k, f)
trips = []
for line in sys.stdin:
trips.append(line.strip().split(" "))
"""
a = 5
b = 3
k = 1
f = 8
t... | output | 1 | 47,603 | 24 | 95,207 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In the evening Polycarp decided to analyze his today's travel expenses on public transport.
The bus system in the capital of Berland is arranged in such a way that each bus runs along the route between two stops. Each bus has no intermediat... | instruction | 0 | 47,604 | 24 | 95,208 |
Tags: greedy, implementation, sortings
Correct Solution:
```
def main():
trips, reg, cheap, cards, card_cost = map(int, input().split())
costs = []
indexes = {}
total = 0
last = ""
for i in range(trips):
a, b = input().split()
pair = (min(a, b), max(a, b))
if pair in indexes:
index = in... | output | 1 | 47,604 | 24 | 95,209 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In the evening Polycarp decided to analyze his today's travel expenses on public transport.
The bus system in the capital of Berland is arranged in such a way that each bus runs along the route... | instruction | 0 | 47,605 | 24 | 95,210 |
No | output | 1 | 47,605 | 24 | 95,211 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i β₯ 1). Here a, b, m are constants, fixed for the given realizatio... | instruction | 0 | 48,167 | 24 | 96,334 |
Tags: *special, implementation, number theory
Correct Solution:
```
ABMR = list(map(int, input().split()))
# print(ABMR)
a = ABMR[0]
b = ABMR[1]
m = ABMR[2]
r0 = ABMR[3]
h = {}
i = 0
prev_r = r0
while True:
cur_r = ( a * prev_r + b ) % m
# print(cur_r)
if h.get(cur_r, 0) != 0:
print(i - h[cur_r]... | output | 1 | 48,167 | 24 | 96,335 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i β₯ 1). Here a, b, m are constants, fixed for the given realizatio... | instruction | 0 | 48,168 | 24 | 96,336 |
Tags: *special, implementation, number theory
Correct Solution:
```
a, b, m, r0 = map(int, input().split())
numbers = {}
counter = 0
period = 0
r = r0
while True:
r1 = (a*r + b)%m
counter += 1
if r1 in numbers:
period = counter - numbers[r1]
break
else:
numbers[r1] = counter
... | output | 1 | 48,168 | 24 | 96,337 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i β₯ 1). Here a, b, m are constants, fixed for the given realizatio... | instruction | 0 | 48,169 | 24 | 96,338 |
Tags: *special, implementation, number theory
Correct Solution:
```
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def MAP2():return map(float,input().split())
def LIST(): return list(map(int, input().split()))
def STRING(): return input()
import string
impor... | output | 1 | 48,169 | 24 | 96,339 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i β₯ 1). Here a, b, m are constants, fixed for the given realizatio... | instruction | 0 | 48,170 | 24 | 96,340 |
Tags: *special, implementation, number theory
Correct Solution:
```
def rand(a, b, m, r):
return (a * r + b) % m
class CodeforcesTask172BSolution:
def __init__(self):
self.result = ''
self.a_b_m_r = []
def read_input(self):
self.a_b_m_r = [int(x) for x in input().split(" ")]
... | output | 1 | 48,170 | 24 | 96,341 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i β₯ 1). Here a, b, m are constants, fixed for the given realizatio... | instruction | 0 | 48,171 | 24 | 96,342 |
Tags: *special, implementation, number theory
Correct Solution:
```
a,b,m,r=map(int,input().split())
l,s=[],set()
while r not in s:
s.add(r)
l.append(r)
r=(a*r + b)%m
print(len(l)-l.index(r))
``` | output | 1 | 48,171 | 24 | 96,343 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i β₯ 1). Here a, b, m are constants, fixed for the given realizatio... | instruction | 0 | 48,172 | 24 | 96,344 |
Tags: *special, implementation, number theory
Correct Solution:
```
import sys
a, b, m, x = tuple(map(int, input().split()))
z=[0]*(m+1)
cnt=1
z[x]=cnt
while True:
cnt += 1
x = (x*a+b)%m
if z[x] > 0:
print(str(cnt-z[x]))
sys.exit(0)
z[x] = cnt
``` | output | 1 | 48,172 | 24 | 96,345 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i β₯ 1). Here a, b, m are constants, fixed for the given realizatio... | instruction | 0 | 48,173 | 24 | 96,346 |
Tags: *special, implementation, number theory
Correct Solution:
```
a, b, m, r0 = [int(k) for k in input().split(' ') if k]
valueToPos = [-1 for _ in range(m + 1)]
prev = r0
for i in range(m + 1):
prev = (a * prev + b) % m
if valueToPos[prev] != -1:
print(i - valueToPos[prev])
exit()
valueTo... | output | 1 | 48,173 | 24 | 96,347 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i β₯ 1). Here a, b, m are constants, fixed for the given realizatio... | instruction | 0 | 48,174 | 24 | 96,348 |
Tags: *special, implementation, number theory
Correct Solution:
```
import re
import itertools
from collections import Counter, deque
class Task:
a, b, m, r = 0, 0, 0, 0
answer = 0
def getData(self):
self.a, self.b, self.m, self.r = [int(x) for x in input().split(' ')]
#inFile = open('in... | output | 1 | 48,174 | 24 | 96,349 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i β₯ 1). Here a, b, ... | instruction | 0 | 48,175 | 24 | 96,350 |
Yes | output | 1 | 48,175 | 24 | 96,351 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i β₯ 1). Here a, b, ... | instruction | 0 | 48,176 | 24 | 96,352 |
Yes | output | 1 | 48,176 | 24 | 96,353 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i β₯ 1). Here a, b, ... | instruction | 0 | 48,177 | 24 | 96,354 |
Yes | output | 1 | 48,177 | 24 | 96,355 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Polycarpus has recently got interested in sequences of pseudorandom numbers. He learned that many programming languages generate such sequences in a similar way: <image> (for i β₯ 1). Here a, b, ... | instruction | 0 | 48,178 | 24 | 96,356 |
Yes | output | 1 | 48,178 | 24 | 96,357 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.