message stringlengths 2 65.1k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 0 108k | cluster float64 14 14 | __index_level_0__ int64 0 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Chanek is currently participating in a science fair that is popular in town. He finds an exciting puzzle in the fair and wants to solve it.
There are N atoms numbered from 1 to N. These atoms are especially quirky. Initially, each atom ... | instruction | 0 | 70,917 | 14 | 141,834 |
Tags: greedy, implementation
Correct Solution:
```
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))
if k == 0:
best = 0
curr = sum(a)
for i in range(n):
best = max(best, curr - d[i])
curr -= a[i]
print(best)
elif k == 1:
best =... | output | 1 | 70,917 | 14 | 141,835 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Chanek is currently participating in a science fair that is popular in town. He finds an exciting puzzle in the fair and wants to solve it.
There are N atoms numbered from 1 to N. These atoms are especially quirky. Initially, each atom ... | instruction | 0 | 70,918 | 14 | 141,836 |
Tags: greedy, implementation
Correct Solution:
```
import sys
n, k = list(map(int, input().split(' ')))
activate = list(map(int, input().split(' ')))
deactivate = list(map(int, input().split(' ')))
presum = [0 for _ in range(n + 2)]
for i in range(1, n + 1):
presum[i] = presum[i - 1] + activate[i - 1]
ret = 0
... | output | 1 | 70,918 | 14 | 141,837 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Chanek is currently participating in a science fair that is popular in town. He finds an exciting puzzle in the fair and wants to solve it.
There are N atoms numbered from 1 to N. These atoms are especially quirky. Initially, each atom ... | instruction | 0 | 70,919 | 14 | 141,838 |
Tags: greedy, implementation
Correct Solution:
```
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))
pref=[0]
for i in range(n):
pref.append(pref[-1]+a[i])
if k==0:
ans=0
for i in range(1,n+1):
ans=max(ans,pref[-1]-pref[i-1]-d[i-1])
print(a... | output | 1 | 70,919 | 14 | 141,839 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Mr. Chanek is currently participating in a science fair that is popular in town. He finds an exciting puzzle in the fair and wants to solve it.
There are N atoms numbered from 1 to N. These atoms are especially quirky. Initially, each atom ... | instruction | 0 | 70,920 | 14 | 141,840 |
Tags: greedy, implementation
Correct Solution:
```
n, k = map(int, input().split())
r = list(map(int, input().split()))
c = list(map(int, input().split()))
z = max(r[-1]-c[-1], 0)
if k == 0:
best = z
acc = 0
for i in range(n-1, -1, -1):
acc += r[i]
best = max(best, acc-c[i])
print(best)
... | output | 1 | 70,920 | 14 | 141,841 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, ... | instruction | 0 | 71,103 | 14 | 142,206 |
Tags: implementation, math, sortings
Correct Solution:
```
# Made By Mostafa_Khaled
bot = True
n, m = map(int, input().split())
s, p = 0, [[] for i in range(n + 1)]
t = list(map(int, input().split()))
for i in range(m - 1):
if t[i] != t[i + 1]:
p[t[i + 1]].append(t[i])
p[t[i]].append(t[i + 1... | output | 1 | 71,103 | 14 | 142,207 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, ... | instruction | 0 | 71,104 | 14 | 142,208 |
Tags: implementation, math, sortings
Correct Solution:
```
input()
a = input().split()
a = [int(x) for x in a]
neighbours = dict()
for x in a:
neighbours[x] = []
cost = 0
for i in range(len(a) - 1):
if a[i] != a[i+1]:
neighbours[a[i]].append(a[i+1])
neighbours[a[i+1]].append(a[i])
cost +... | output | 1 | 71,104 | 14 | 142,209 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, ... | instruction | 0 | 71,105 | 14 | 142,210 |
Tags: implementation, math, sortings
Correct Solution:
```
import sys
from collections import defaultdict
read = lambda t=int: list(map(t,sys.stdin.readline().split()))
n, m = read()
ar = read()
price = sum(abs(a-b) for a,b in zip(ar,ar[1:]))
xss = defaultdict(list)
for a,b in zip(ar,ar[1:]):
if a != b:
xss... | output | 1 | 71,105 | 14 | 142,211 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, ... | instruction | 0 | 71,106 | 14 | 142,212 |
Tags: implementation, math, sortings
Correct Solution:
```
n, m = map(int, input().split())
arr = list(map(int, input().split()))
price = sum(abs(a - b) for a, b in zip(arr, arr[1:]))
from collections import defaultdict
adj = defaultdict(list)
for a,b in zip(arr, arr[1:]):
if a != b:
adj[a].append(b)
... | output | 1 | 71,106 | 14 | 142,213 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, ... | instruction | 0 | 71,107 | 14 | 142,214 |
Tags: implementation, math, sortings
Correct Solution:
```
from collections import defaultdict
LIM = 10 ** 5 + 123
n, m = map(int, input().split())
occ = [[] for i in range(LIM)]
add = [0 for i in range(LIM)]
a = list(map(int, input().split()))
base_ans = 0
for i in range(1, m):
if a[i] != a[i - 1]:
oc... | output | 1 | 71,107 | 14 | 142,215 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, ... | instruction | 0 | 71,108 | 14 | 142,216 |
Tags: implementation, math, sortings
Correct Solution:
```
n, m = map(int, input().split())
s, p = 0, [[] for i in range(n + 1)]
t = list(map(int, input().split()))
for i in range(m - 1):
if t[i] != t[i + 1]:
p[t[i + 1]].append(t[i])
p[t[i]].append(t[i + 1])
for i, q in enumerate(p):
if q:
... | output | 1 | 71,108 | 14 | 142,217 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, ... | instruction | 0 | 71,109 | 14 | 142,218 |
Tags: implementation, math, sortings
Correct Solution:
```
def median(a):
if len(a) == 0:
return 0
if len(a) % 2 == 1:
return a[len(a) // 2]
else:
return (a[len(a) // 2] + a[(len(a) // 2) - 1]) // 2
def profit(a, old_val):
a.sort()
med = median(a)
sum_old = 0
sum_ne... | output | 1 | 71,109 | 14 | 142,219 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, ... | instruction | 0 | 71,110 | 14 | 142,220 |
Tags: implementation, math, sortings
Correct Solution:
```
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = {}
for ai in a:
b[ai] = []
amt = 0
for i in range(1, len(a)):
amt += abs(a[i]-a[i-1])
if a[i]-a[i-1]:
b[a[i]] += [a[i-1]]
b[a[i-1]] += [a[i]]
diff = 0
for bi in... | output | 1 | 71,110 | 14 | 142,221 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes wha... | instruction | 0 | 71,111 | 14 | 142,222 |
Yes | output | 1 | 71,111 | 14 | 142,223 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes wha... | instruction | 0 | 71,112 | 14 | 142,224 |
Yes | output | 1 | 71,112 | 14 | 142,225 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes wha... | instruction | 0 | 71,113 | 14 | 142,226 |
Yes | output | 1 | 71,113 | 14 | 142,227 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes wha... | instruction | 0 | 71,114 | 14 | 142,228 |
Yes | output | 1 | 71,114 | 14 | 142,229 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes wha... | instruction | 0 | 71,115 | 14 | 142,230 |
No | output | 1 | 71,115 | 14 | 142,231 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes wha... | instruction | 0 | 71,116 | 14 | 142,232 |
No | output | 1 | 71,116 | 14 | 142,233 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes wha... | instruction | 0 | 71,117 | 14 | 142,234 |
No | output | 1 | 71,117 | 14 | 142,235 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes wha... | instruction | 0 | 71,118 | 14 | 142,236 |
No | output | 1 | 71,118 | 14 | 142,237 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Girl Lena likes it when everything is in order, and looks for order everywhere. Once she was getting ready for the University and noticed that the room was in a mess — all the objects from her handbag were thrown about the room. Of course, s... | instruction | 0 | 71,330 | 14 | 142,660 |
Tags: bitmasks, dp
Correct Solution:
```
import sys
def main():
BITS = [1 << sh for sh in range(24)]
B2N = {v: u for u, v in enumerate(BITS)}
def getPt():
return tuple(map(int, input().split()))
def dist(ptA, ptB):
return sum(((u - v) ** 2 for u, v in zip(ptA, ptB)))
def getBits... | output | 1 | 71,330 | 14 | 142,661 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Girl Lena likes it when everything is in order, and looks for order everywhere. Once she was getting ready for the University and noticed that the room was in a mess — all the objects from her handbag were thrown about the room. Of course, s... | instruction | 0 | 71,335 | 14 | 142,670 |
Tags: bitmasks, dp
Correct Solution:
```
from itertools import chain
from time import time
def main():
BITS = [1 << sh for sh in range(24)]
B2N = {v: u for u, v in enumerate(BITS)}
def getPt():
return tuple(map(int, input().split()))
def dist(ptA, ptB):
return sum(((u-v)**2 for u, v ... | output | 1 | 71,335 | 14 | 142,671 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 71,356 | 14 | 142,712 |
Tags: implementation
Correct Solution:
```
#!/usr/bin/python3
n, m, a, b = map(int, input().split())
a -= 1
b -= 1
if a // m == b // m:
print(1)
elif a % m == 0 and (b + 1) % m == 0:
print(1)
elif a % m == 0 and b + 1 == n:
print(1)
elif b + 1 == n:
print(2)
elif a % m == 0 or (b + 1) % m == 0:
pr... | output | 1 | 71,356 | 14 | 142,713 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 71,357 | 14 | 142,714 |
Tags: implementation
Correct Solution:
```
n, m, a, b = map(int, input().split())
if m == 1:
print("1")
elif (a - 1) // m == (b - 1) // m:
print("1")
elif abs((a - 1) // m - (b - 1) // m) == 1 and a % m != 1:
print("2")
elif b == n or b % m == 0:
if a % m == 1:
print("1")
else:
p... | output | 1 | 71,357 | 14 | 142,715 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 71,358 | 14 | 142,716 |
Tags: implementation
Correct Solution:
```
import sys
from array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
n, m, a, b = map(int, input().split())
a, b = a - 1, b - 1
if b + 1 == n:
b = (b // m + 1) * m - 1
if a // m == b // m:
print(1)
elif a % m == 0 an... | output | 1 | 71,358 | 14 | 142,717 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 71,359 | 14 | 142,718 |
Tags: implementation
Correct Solution:
```
#------------------------------warmup----------------------------
# *******************************
# * AUTHOR: RAJDEEP GHOSH *
# * NICK : Rajdeep2k *
# * INSTITUTION: IIEST, SHIBPUR *
# *******************************
import os
import sys
from io import... | output | 1 | 71,359 | 14 | 142,719 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 71,360 | 14 | 142,720 |
Tags: implementation
Correct Solution:
```
readints=lambda:map(int, input().strip('\n').split())
n,m,a,b=readints()
a-=1
b-=1 # 0-index
ra=a//m
rb=b//m
ia=a%m
ib=b%m
if (ra==rb) or (ia==0 and b==n-1) or (ia==0 and ib==m-1):
print(1)
elif (ia==0 and ib<m-1 and b!=n-1) or (ia>0 and (ib==m-1 or b==n-1)) or (ra+1... | output | 1 | 71,360 | 14 | 142,721 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 71,361 | 14 | 142,722 |
Tags: implementation
Correct Solution:
```
import math
n,m,a,b=map(int,input().split())
if (a-1)//m==(b-1)//m:
print(1)
elif (a-1)%m==0 and b%m==0:
print(1)
elif (a-1)%m==0 and b==n or m==1:
print(1)
elif (a-1)%m==0 or b%m==0 or b==n:
print(2)
elif abs((a-1)//m - (b-1)//m)==1 or m==2:
print(2)
elif... | output | 1 | 71,361 | 14 | 142,723 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new h... | instruction | 0 | 71,362 | 14 | 142,724 |
Tags: implementation
Correct Solution:
```
n, m, a, b = map(int, input().split())
r1, r2, c1, c2 = (a - 1) // m, (b - 1) // m, (a - 1) % m, m - 1 if b == n else (b - 1) % m
if r1 == r2 or c1 == 0 and c2 == m - 1:
print(1)
elif r2 == r1 + 1 or c1 == 0 or c2 == m - 1 or c1 == c2 + 1:
print(2)
else:
pri... | output | 1 | 71,362 | 14 | 142,725 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.
He looks at the first two students and gives more toffees to ... | instruction | 0 | 72,121 | 14 | 144,242 |
Tags: dp, graphs, greedy, implementation
Correct Solution:
```
import sys
from math import log2,floor,ceil,sqrt,gcd
import bisect
# from collections import deque
sys.setrecursionlimit(10**5)
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
def input(): return sys... | output | 1 | 72,121 | 14 | 144,243 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.
He looks at the first two students and gives more toffees to ... | instruction | 0 | 72,122 | 14 | 144,244 |
Tags: dp, graphs, greedy, implementation
Correct Solution:
```
n=int(input())
r=[1]*n
s=input()
y=1
while y:
y=0
for i in range(n-1):
if s[i]=='=' and r[i]!=r[i+1]:r[i]=r[i+1]=max(r[i:i+2]);y=1
if s[i]=='L' and r[i]<=r[i+1]:r[i]=r[i+1]+1;y=1
if s[i]=='R' and r[i]>=r[i+1]:r[i+1]=r[i]+1;y=... | output | 1 | 72,122 | 14 | 144,245 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.
He looks at the first two students and gives more toffees to ... | instruction | 0 | 72,123 | 14 | 144,246 |
Tags: dp, graphs, greedy, implementation
Correct Solution:
```
n=int(input())
s=input()
w=[1]*n
for i in range(n-1):
if s[i]=='=':
w[i+1]=w[i]
elif s[i]=='R':
if w[i+1]<=w[i]:
w[i+1]=w[i]+1
else:
if w[i]<=w[i+1]:
w[i]=w[i+1]+1
for i in range(n-2,-1,-1):
if... | output | 1 | 72,123 | 14 | 144,247 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.
He looks at the first two students and gives more toffees to ... | instruction | 0 | 72,124 | 14 | 144,248 |
Tags: dp, graphs, greedy, implementation
Correct Solution:
```
n=int(input())
r=[1]*n
s=input()
y=1
while y:
y=0
for i in range(n-1):
if s[i]=='=' and r[i]!=r[i+1]:r[i]=r[i+1]=max(r[i:i+2]);y=1
if s[i]=='L' and r[i]<=r[i+1]:r[i]=r[i+1]+1;y=1
if s[i]=='R' and r[i]>=r[i+1]:r[i+1]=r[i]+1;y=... | output | 1 | 72,124 | 14 | 144,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.
He looks at the first two students and gives more toffees to ... | instruction | 0 | 72,125 | 14 | 144,250 |
Tags: dp, graphs, greedy, implementation
Correct Solution:
```
n = int(input())
p = 'R' + input() + 'R'
t = [0] * n
i = t[0] = l = r = 1
L = R = 0
while i < n + 1:
if p[i] == 'L':
if r > 1:
t[R] = r
L, r = i, 1
l += 1
elif p[i] == 'R':
if l > 1:
... | output | 1 | 72,125 | 14 | 144,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.
He looks at the first two students and gives more toffees to ... | instruction | 0 | 72,126 | 14 | 144,252 |
Tags: dp, graphs, greedy, implementation
Correct Solution:
```
import math
from collections import Counter, defaultdict
from itertools import accumulate
R = lambda: map(int, input().split())
n = int(input())
s = input()
dp = [[0] * 1005 for i in range(n + 1)]
for i in range(1, 1001):
dp[0][i] = i
dp[0][1001] = mat... | output | 1 | 72,126 | 14 | 144,253 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.
He looks at the first two students and gives more toffees to ... | instruction | 0 | 72,127 | 14 | 144,254 |
Tags: dp, graphs, greedy, implementation
Correct Solution:
```
n=int(input())
s=input()
a=[1]*n
flag=True
while flag:
flag=False
for i in range(n-1):
if s[i]=='=':
if a[i]!=a[i+1]:
z=max(a[i],a[i+1])
a[i],a[i+1]=z,z
flag=True
elif s[i]=... | output | 1 | 72,127 | 14 | 144,255 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.
He looks at the first two students and gives more toffees to ... | instruction | 0 | 72,128 | 14 | 144,256 |
Tags: dp, graphs, greedy, implementation
Correct Solution:
```
n = int(input())
s = input()
ans = [1] * n
t = True
while t:
t = False
for i in range(n - 1):
if s[i] == '=' and ans[i] != ans[i + 1]:
ans[i] = ans[i + 1] = max(ans[i], ans[i + 1])
t = True
elif s[i] == 'R' a... | output | 1 | 72,128 | 14 | 144,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A teacher decides to give toffees to his students. He asks n students to stand in a queue. Since the teacher is very partial, he follows the following rule to distribute toffees.
He looks at th... | instruction | 0 | 72,131 | 14 | 144,262 |
Yes | output | 1 | 72,131 | 14 | 144,263 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three friends are going to meet each other. Initially, the first friend stays at the position x = a, the second friend stays at the position x = b and the third friend stays at the position x = c on the coordinate axis Ox.
In one minute eac... | instruction | 0 | 73,426 | 14 | 146,852 |
Tags: brute force, greedy, math, sortings
Correct Solution:
```
t = int(input())
for _ in range(t):
a, b, c = map(int, input().split())
ans = abs(a - b) + abs(a - c) + abs(b - c)
ans = max(0, ans - 4)
print(ans)
``` | output | 1 | 73,426 | 14 | 146,853 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three friends are going to meet each other. Initially, the first friend stays at the position x = a, the second friend stays at the position x = b and the third friend stays at the position x = c on the coordinate axis Ox.
In one minute eac... | instruction | 0 | 73,427 | 14 | 146,854 |
Tags: brute force, greedy, math, sortings
Correct Solution:
```
import math
q = int(input())
def len_equal(array):
if len(set(array)) == 1:
return True
return False
def calc(array):
return math.fabs(array[0] - array[1]) + math.fabs(array[1] - array[2]) + math.fabs(array[0] - array[2])
for x in ra... | output | 1 | 73,427 | 14 | 146,855 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three friends are going to meet each other. Initially, the first friend stays at the position x = a, the second friend stays at the position x = b and the third friend stays at the position x = c on the coordinate axis Ox.
In one minute eac... | instruction | 0 | 73,428 | 14 | 146,856 |
Tags: brute force, greedy, math, sortings
Correct Solution:
```
t=int(input())
for i in range(t):
d=[int(x) for x in input().split()]
d.sort()
a,b,c=d[0],d[1],d[2]
if a==b==c:
print(0)
elif a==b or b==c:
res=abs(a-b)+abs(b-c)+abs(a-c)-4
print(max(0,res))
elif abs(a-b)>=ab... | output | 1 | 73,428 | 14 | 146,857 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three friends are going to meet each other. Initially, the first friend stays at the position x = a, the second friend stays at the position x = b and the third friend stays at the position x = c on the coordinate axis Ox.
In one minute eac... | instruction | 0 | 73,429 | 14 | 146,858 |
Tags: brute force, greedy, math, sortings
Correct Solution:
```
Q=int(input())
for q in range(0,Q):
a,b,c=map(int, input().split())
if a==b and b==c:
print(0)
else:
A=[]
if a>b:
A.append(a-b)
else:
A.append(b-a)
if b>c:
A.append(b-c... | output | 1 | 73,429 | 14 | 146,859 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three friends are going to meet each other. Initially, the first friend stays at the position x = a, the second friend stays at the position x = b and the third friend stays at the position x = c on the coordinate axis Ox.
In one minute eac... | instruction | 0 | 73,430 | 14 | 146,860 |
Tags: brute force, greedy, math, sortings
Correct Solution:
```
import math
for _ in range(int(input())):
a , b , c = [int(x) for x in input().split()]
k = (a+b+c)/3
k_c = math.ceil(k)
k_f= math.floor(k)
if k - k_f <.5:
k = k_f
else:
k = k_c
if a>k:
a-=1
elif... | output | 1 | 73,430 | 14 | 146,861 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three friends are going to meet each other. Initially, the first friend stays at the position x = a, the second friend stays at the position x = b and the third friend stays at the position x = c on the coordinate axis Ox.
In one minute eac... | instruction | 0 | 73,431 | 14 | 146,862 |
Tags: brute force, greedy, math, sortings
Correct Solution:
```
from math import *
t=int(input())
for _ in range(t):
a,b,c =map(int,input().split())
l=[a,b,c]
l.sort()
s=0
if l[0]==l[1] and l[1]==l[2]:
pass
elif l[0]!=l[1] and l[1]!=l[2]:
l[0]=l[0]+1
l[2]=l[2]-1
elif ... | output | 1 | 73,431 | 14 | 146,863 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three friends are going to meet each other. Initially, the first friend stays at the position x = a, the second friend stays at the position x = b and the third friend stays at the position x = c on the coordinate axis Ox.
In one minute eac... | instruction | 0 | 73,432 | 14 | 146,864 |
Tags: brute force, greedy, math, sortings
Correct Solution:
```
q = int(input())
for i in range(q):
a, b, c = map(int, input().split())
minimum = min(a, b, c)
maximum = max(a, b, c)
if maximum - minimum < 2:
print(0)
else:
print(((maximum - 1) - (minimum + 1)) * 2)
``` | output | 1 | 73,432 | 14 | 146,865 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Three friends are going to meet each other. Initially, the first friend stays at the position x = a, the second friend stays at the position x = b and the third friend stays at the position x = c on the coordinate axis Ox.
In one minute eac... | instruction | 0 | 73,433 | 14 | 146,866 |
Tags: brute force, greedy, math, sortings
Correct Solution:
```
def main():
q = int(input())
for i in range(q):
nums = list(map(int,input().split()))
nums.sort()
if nums[-1] == nums[1] and nums[0] != nums[1]:
nums[-1] -= 1
nums[1] -= 1
if nums[0] == nums[1... | output | 1 | 73,433 | 14 | 146,867 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has ... | instruction | 0 | 73,474 | 14 | 146,948 |
Tags: binary search, greedy, math, sortings, two pointers
Correct Solution:
```
t = int(input())
def fun(x,y,z):
return (x-y)**2+(y-z)**2+(z-x)**2
def partialbest(red, green, blue):
ind_green_maggiore = 0
ind_blue_maggiore_l = 0
ind_blue_maggiore_r = 0
min_value = fun(red[0],green[0],blue[0])
for j in range(len(... | output | 1 | 73,474 | 14 | 146,949 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has ... | instruction | 0 | 73,475 | 14 | 146,950 |
Tags: binary search, greedy, math, sortings, two pointers
Correct Solution:
```
import bisect
ans=10000000000000000000
def tempCalc(r,b,g):
return (r-b)**2 +(r-g)**2+(b-g)**2
def getLow(p, x ):
l = 0
r = len(p)
while r-l>1:
m = (l + r) // 2
if p[m] <= x:
l = m
else... | output | 1 | 73,475 | 14 | 146,951 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has ... | instruction | 0 | 73,476 | 14 | 146,952 |
Tags: binary search, greedy, math, sortings, two pointers
Correct Solution:
```
from bisect import bisect_left
from itertools import permutations
import sys
input = sys.stdin.readline
def calc(aa, bb, cc):
i = j = 0
ans = float('inf')
while j < len(bb):
while i+1 < len(aa) and aa[i+1] <= bb[j]:
... | output | 1 | 73,476 | 14 | 146,953 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Xenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.
<image>
Recently Xenia has bought n_r red gems, n_g green gems and n_b blue gems. Each of the gems has ... | instruction | 0 | 73,477 | 14 | 146,954 |
Tags: binary search, greedy, math, sortings, two pointers
Correct Solution:
```
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buf... | output | 1 | 73,477 | 14 | 146,955 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.