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. The Looksery company, consisting of n staff members, is planning another big party. Every employee has his phone number and the phone numbers of his friends in the phone book. Everyone who comes to the party, sends messages to his contacts a...
instruction
0
50,893
14
101,786
Tags: constructive algorithms, dfs and similar, graphs, greedy Correct Solution: ``` import sys input = sys.stdin.readline def solve(): n = int(input()) b = [input() for i in range(n)] a = list(map(int,input().split())) c = [None]*n w = [False]*n h = [0]*n for i in range(n): c[i] = (a[i], i) c.sort() r = [...
output
1
50,893
14
101,787
Provide tags and a correct Python 3 solution for this coding contest problem. The Looksery company, consisting of n staff members, is planning another big party. Every employee has his phone number and the phone numbers of his friends in the phone book. Everyone who comes to the party, sends messages to his contacts a...
instruction
0
50,894
14
101,788
Tags: constructive algorithms, dfs and similar, graphs, greedy Correct Solution: ``` n=int(input().strip()) a=[] for i in range(n): s=input().strip() a.append(s) b=list(map(int,input().strip().split())) c=[] while (True): k=-1 for i in range(n): if (b[i]==0): k=i break ...
output
1
50,894
14
101,789
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Looksery company, consisting of n staff members, is planning another big party. Every employee has his phone number and the phone numbers of his friends in the phone book. Everyone who comes...
instruction
0
50,895
14
101,790
No
output
1
50,895
14
101,791
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Looksery company, consisting of n staff members, is planning another big party. Every employee has his phone number and the phone numbers of his friends in the phone book. Everyone who comes...
instruction
0
50,896
14
101,792
No
output
1
50,896
14
101,793
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Looksery company, consisting of n staff members, is planning another big party. Every employee has his phone number and the phone numbers of his friends in the phone book. Everyone who comes...
instruction
0
50,897
14
101,794
No
output
1
50,897
14
101,795
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Looksery company, consisting of n staff members, is planning another big party. Every employee has his phone number and the phone numbers of his friends in the phone book. Everyone who comes...
instruction
0
50,898
14
101,796
No
output
1
50,898
14
101,797
Provide tags and a correct Python 3 solution for this coding contest problem. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li and the finish time ri (li ≤ ri). Restaurant man...
instruction
0
50,915
14
101,830
Tags: dp, greedy, sortings Correct Solution: ``` if __name__=='__main__': n = int(input()) orders = [] for _ in range(n): a,b = map(int,input().split()) orders.append((b,a)) sorders = sorted(orders) cnt = 0 now = 1 for i in range(0,len(sorders)): #print(now) ...
output
1
50,915
14
101,831
Provide tags and a correct Python 3 solution for this coding contest problem. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li and the finish time ri (li ≤ ri). Restaurant man...
instruction
0
50,916
14
101,832
Tags: dp, greedy, sortings Correct Solution: ``` s = d = 0 t = [list(map(int, input().split())) for i in range(int(input()))] for l, r in sorted(t, key=lambda q: q[1]): if l > d: s, d = s + 1, r print(s) # Made By Mostafa_Khaled ```
output
1
50,916
14
101,833
Provide tags and a correct Python 3 solution for this coding contest problem. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li and the finish time ri (li ≤ ri). Restaurant man...
instruction
0
50,917
14
101,834
Tags: dp, greedy, sortings Correct Solution: ``` orders = [] for _ in range(int(input())): l, r = map(int, input().split()) orders.append([l, r]) orders.sort() count = 0 while len(orders) > 1: if orders[-2][0] == orders[-1][0]: orders.pop(-2) if orders[-2][1] > orders[-1][1] else orders.pop(-1) ...
output
1
50,917
14
101,835
Provide tags and a correct Python 3 solution for this coding contest problem. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li and the finish time ri (li ≤ ri). Restaurant man...
instruction
0
50,918
14
101,836
Tags: dp, greedy, sortings Correct Solution: ``` a=int(input()) b=[] total=0 for i in range(a): x,y=map(int,input().split()) b.append([x,y]) b.sort(key=lambda x: x[1]) ending=0 for i in b: if i[0]>ending: total+=1 ending=i[1] print(total) ```
output
1
50,918
14
101,837
Provide tags and a correct Python 3 solution for this coding contest problem. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li and the finish time ri (li ≤ ri). Restaurant man...
instruction
0
50,919
14
101,838
Tags: dp, greedy, sortings Correct Solution: ``` # by the authority of GOD author: manhar singh sachdev # import os,sys from io import BytesIO, IOBase def main(): n = int(input()) tup = sorted([tuple(map(int,input().split())) for _ in range(n)],key=lambda xx:xx[1]) ans,j = [0]*(n+1),0 for ind,i in...
output
1
50,919
14
101,839
Provide tags and a correct Python 3 solution for this coding contest problem. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li and the finish time ri (li ≤ ri). Restaurant man...
instruction
0
50,920
14
101,840
Tags: dp, greedy, sortings Correct Solution: ``` #!/usr/bin/env python3 n = int(input()) t = [list(map(int, input().split(" "))) for i in range(n)] last = 0 count = 0 for i in sorted(t, key=lambda x: x[1]): if last < i[0]: last = i[1] count += 1 print(count) ```
output
1
50,920
14
101,841
Provide tags and a correct Python 3 solution for this coding contest problem. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li and the finish time ri (li ≤ ri). Restaurant man...
instruction
0
50,921
14
101,842
Tags: dp, greedy, sortings Correct Solution: ``` def main(): tt = list(tuple(map(int, input().split())) for _ in range(int(input()))) tt.sort(key=lambda e: e.__getitem__(1)) res = t = 0 for l, r in tt: if t < l: t = r res += 1 print(res) if __name__ == '__main__': ...
output
1
50,921
14
101,843
Provide tags and a correct Python 3 solution for this coding contest problem. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li and the finish time ri (li ≤ ri). Restaurant man...
instruction
0
50,922
14
101,844
Tags: dp, greedy, sortings Correct Solution: ``` n = int(input()) a = [] for i in range(n): l,r = map(int,input().split()) a.append([l,r]) a.sort(key=lambda x:x[1]) tmp = a[0][1] tot = 1 for i in range(1,len(a)): if (tmp < a[i][0]): tot += 1 tmp = a[i][1] print(tot) ```
output
1
50,922
14
101,845
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li an...
instruction
0
50,923
14
101,846
Yes
output
1
50,923
14
101,847
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li an...
instruction
0
50,924
14
101,848
Yes
output
1
50,924
14
101,849
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li an...
instruction
0
50,925
14
101,850
Yes
output
1
50,925
14
101,851
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li an...
instruction
0
50,926
14
101,852
Yes
output
1
50,926
14
101,853
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li an...
instruction
0
50,927
14
101,854
No
output
1
50,927
14
101,855
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li an...
instruction
0
50,928
14
101,856
No
output
1
50,928
14
101,857
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li an...
instruction
0
50,929
14
101,858
No
output
1
50,929
14
101,859
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A restaurant received n orders for the rental. Each rental order reserve the restaurant for a continuous period of time, the i-th order is characterized by two time values — the start time li an...
instruction
0
50,930
14
101,860
No
output
1
50,930
14
101,861
Provide a correct Python 3 solution for this coding contest problem. Heidi got one brain, thumbs up! But the evening isn't over yet and one more challenge awaits our dauntless agent: after dinner, at precisely midnight, the N attendees love to play a very risky game... Every zombie gets a number ni (1 ≤ ni ≤ N) writt...
instruction
0
50,952
14
101,904
"Correct Solution: ``` def main(): T = int(input()) for _ in range(T): n, r = readints() nums = readints() print(sol(nums, r, n)) def readints(): return [int(fld) for fld in input().strip().split()] def sol(nums, r, n): ans = 1 + (r - sum(nums)) % n return ans ...
output
1
50,952
14
101,905
Provide a correct Python 3 solution for this coding contest problem. Heidi got one brain, thumbs up! But the evening isn't over yet and one more challenge awaits our dauntless agent: after dinner, at precisely midnight, the N attendees love to play a very risky game... Every zombie gets a number ni (1 ≤ ni ≤ N) writt...
instruction
0
50,953
14
101,906
"Correct Solution: ``` T = int(input()) for t in range(T): N, R = map(int, input().split()) print(1 + (R - sum(map(int, input().split()))) % N) ```
output
1
50,953
14
101,907
Provide a correct Python 3 solution for this coding contest problem. Heidi got one brain, thumbs up! But the evening isn't over yet and one more challenge awaits our dauntless agent: after dinner, at precisely midnight, the N attendees love to play a very risky game... Every zombie gets a number ni (1 ≤ ni ≤ N) writt...
instruction
0
50,954
14
101,908
"Correct Solution: ``` t = int(input()) for _ in range(t): n, r = map(int, input().split()) s = sum(map(int, input().split())) x = 1 while (s + x + r) % n != 0: x += 1 print(x) ```
output
1
50,954
14
101,909
Provide a correct Python 3 solution for this coding contest problem. Heidi got one brain, thumbs up! But the evening isn't over yet and one more challenge awaits our dauntless agent: after dinner, at precisely midnight, the N attendees love to play a very risky game... Every zombie gets a number ni (1 ≤ ni ≤ N) writt...
instruction
0
50,955
14
101,910
"Correct Solution: ``` t = int(input()) for i in range(t): n, r = map(int, input().split()) l = list(map(int, input().split())) if r == 1: s = sum(l) % n if s == 0: s = n print(s) else: s = 2 * l[0] - r + 1 - sum(l) s = s % n if s == 0: ...
output
1
50,955
14
101,911
Provide a correct Python 3 solution for this coding contest problem. Heidi got one brain, thumbs up! But the evening isn't over yet and one more challenge awaits our dauntless agent: after dinner, at precisely midnight, the N attendees love to play a very risky game... Every zombie gets a number ni (1 ≤ ni ≤ N) writt...
instruction
0
50,956
14
101,912
"Correct Solution: ``` def main(): T = int(input()) for _ in range(T): n, r = readints() nums = readints() print(sol(nums, r, n)) def readints(): return [int(fld) for fld in input().strip().split()] def sol(nums, r, n): ans = 1 + (r - sum(nums) + 1) % n return a...
output
1
50,956
14
101,913
Provide a correct Python 3 solution for this coding contest problem. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not....
instruction
0
51,123
14
102,246
"Correct Solution: ``` def main(): import sys input=sys.stdin.readline n=int(input()) A=[list(map(int,input().split())) for i in range(n)] mod=10**9+7 dp=[0]*(1<<n) dp[0]=1 for s in range(1<<n): i=format(s,'b').count('1') for j in range(n): if (s>>j)&1 and A[...
output
1
51,123
14
102,247
Provide a correct Python 3 solution for this coding contest problem. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not....
instruction
0
51,124
14
102,248
"Correct Solution: ``` def main(): n = int(input()) A = [list(map(int, input().split())) for i in range(n)] p = 10**9+7 DP = [0 for s in range(1 << n)] DP[0] = 1 for s in range(1, 1 << n): l = bin(s).count('1') for i in range(n): if ((1 << i) & s) * A[l-1][i]: ...
output
1
51,124
14
102,249
Provide a correct Python 3 solution for this coding contest problem. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not....
instruction
0
51,125
14
102,250
"Correct Solution: ``` import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) MOD = 10 ** 9 + 7 N = int(input()) A = [[int(x) for x in input().split()] for _ in range(N)] bit_count = [0] for _ in range(N): bit_count += [x+1 for x in bit_count] dp = [0] * (1<<N) dp[0] = 1 for i in range((1<<N)-...
output
1
51,125
14
102,251
Provide a correct Python 3 solution for this coding contest problem. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not....
instruction
0
51,126
14
102,252
"Correct Solution: ``` def countSetBits(n): count = 0 while (n): n &= (n - 1) count += 1 return count N=10**9 + 7 n=int(input()) ar = [list(map(int,input().split())) for _ in range(n)] total=1<<n bits=[[]for _ in range(n+1)] dp=[[0]*(total+5) for j in range(n+5)] for i in range(n): ...
output
1
51,126
14
102,253
Provide a correct Python 3 solution for this coding contest problem. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not....
instruction
0
51,127
14
102,254
"Correct Solution: ``` MOD = 10**9 + 7 N = int(input()) As = [int(input().replace(' ', ''), 2) for _ in range(N)] patWsList = [[] for _ in range(N+1)] for patW in range(2**N): num1 = sum([(patW >> i) & 1 for i in range(N)]) patWsList[num1].append(patW) dp = [0] * (2**N) dp[-1] = 1 for iM, (A, patWs) in enume...
output
1
51,127
14
102,255
Provide a correct Python 3 solution for this coding contest problem. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not....
instruction
0
51,128
14
102,256
"Correct Solution: ``` N = int(input()) A = [[int(a) for a in input().split()] for _ in range(N)] mod = 10**9+7 dp = [0]*(2**N) dp[0] = 1 POPCOUNT_TABLE16 = [0] * 2**16 for index in range(len(POPCOUNT_TABLE16)): POPCOUNT_TABLE16[index] = (index & 1) + POPCOUNT_TABLE16[index >> 1] def popcnt(v): return (POPC...
output
1
51,128
14
102,257
Provide a correct Python 3 solution for this coding contest problem. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not....
instruction
0
51,129
14
102,258
"Correct Solution: ``` # coding: utf-8 # Your code here! import sys input = sys.stdin.readline def itercomb(n,k): _a = (1<<k)-1 yield _a while 1: _x = _a & -_a _y = _a + _x _a = (((_a & ~_y) // _x) >> 1) | _y if _a >= _ALL: break yield _a n=int(input()) A= [[int(i) ...
output
1
51,129
14
102,259
Provide a correct Python 3 solution for this coding contest problem. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i and Woman j are compatible; if a_{i, j} = 0, they are not....
instruction
0
51,130
14
102,260
"Correct Solution: ``` N = int(input()) A = [list(map(int, input().split())) for i in range(N)] MOD = 10 ** 9 + 7 dp = [0] * (1<<N) dp[0] = 1 for i in range(1, 1<<N): cnt = 0 for j in range(N+1):cnt += (i>>j)&1 for j in range(N): if (i>>j)&1 == 0: continue dp[i] += dp[i - (1<<j)] * A[cnt-1][...
output
1
51,130
14
102,261
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i an...
instruction
0
51,131
14
102,262
Yes
output
1
51,131
14
102,263
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i an...
instruction
0
51,132
14
102,264
Yes
output
1
51,132
14
102,265
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i an...
instruction
0
51,133
14
102,266
Yes
output
1
51,133
14
102,267
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i an...
instruction
0
51,134
14
102,268
Yes
output
1
51,134
14
102,269
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i an...
instruction
0
51,135
14
102,270
No
output
1
51,135
14
102,271
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i an...
instruction
0
51,136
14
102,272
No
output
1
51,136
14
102,273
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i an...
instruction
0
51,137
14
102,274
No
output
1
51,137
14
102,275
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N men and N women, both numbered 1, 2, \ldots, N. For each i, j (1 \leq i, j \leq N), the compatibility of Man i and Woman j is given as an integer a_{i, j}. If a_{i, j} = 1, Man i an...
instruction
0
51,138
14
102,276
No
output
1
51,138
14
102,277
Provide tags and a correct Python 3 solution for this coding contest problem. Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, ...
instruction
0
51,304
14
102,608
Tags: math, number theory Correct Solution: ``` from sys import stdin, stdout from math import gcd def main(): l_a, r_a, t_a = readline() l_b, r_b, t_b = readline() lucky_days_a = r_a - l_a + 1 # Total de dias de suerte de Alicia por periodo lucky_days_b = r_b - l_b + 1 # Total de dias de suerte de ...
output
1
51,304
14
102,609
Provide tags and a correct Python 3 solution for this coding contest problem. Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, ...
instruction
0
51,305
14
102,610
Tags: math, number theory Correct Solution: ``` from math import gcd def solve(la, ra, ta, lb, rb, tb): if la > lb: la, ra, ta, lb, rb, tb = lb, rb, tb, la, ra, ta da = ra-la db = rb-lb ans = 0 dist = lb - la g = gcd(ta, tb) dist %= g if dist == 0: return min(da+1, db+1...
output
1
51,305
14
102,611
Provide tags and a correct Python 3 solution for this coding contest problem. Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, ...
instruction
0
51,306
14
102,612
Tags: math, number theory Correct Solution: ``` # -*- coding:utf-8 -*- """ created by shuangquan.huang at 11/13/18 mt19937 mrand(random_device{} ()); int rnd(int x) { return mrand() % x; } void precalc() { } int gcd(int a, int b) { return (b ? gcd(b, a % b) : a); } int la, ra, ta; int lb, rb, tb; int read() ...
output
1
51,306
14
102,613
Provide tags and a correct Python 3 solution for this coding contest problem. Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, ...
instruction
0
51,307
14
102,614
Tags: math, number theory Correct Solution: ``` '''input 7 13 18 2 6 12 ''' import math def solve(): l1,r1,t1 = list(map(int,input().split())) l2,r2,t2 = list(map(int,input().split())) # diff = l1-l2+k1*t1-k2*t2 # diff = l1-l2 + K*gcd(t1,t2) # l2-l1 / gcd(t1,t2) = K g = math.gcd(t1,t2) K1 = (l2-l1)//g K2 = (...
output
1
51,307
14
102,615
Provide tags and a correct Python 3 solution for this coding contest problem. Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, ...
instruction
0
51,308
14
102,616
Tags: math, number theory Correct Solution: ``` def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return list(mi()) import math la, ra, ta = mi() lb, rb, tb = mi() if la > lb: la, ra, ta, lb, rb, tb = lb, rb, tb, la, ra, ta lb -= la ra -= la rb -= la dif = math.gcd(ta, ...
output
1
51,308
14
102,617
Provide tags and a correct Python 3 solution for this coding contest problem. Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, ...
instruction
0
51,309
14
102,618
Tags: math, number theory Correct Solution: ``` from math import gcd lA,rA,tA=map(int,input().split()) lB,rB,tB=map(int,input().split()) rA+=1 rB+=1 move=gcd(tA,tB) if(lA>lB): lA,rA,tA,lB,rB,tB=lB,rB,tB,lA,rA,tA d=(lB-lA)//move lA+=(d*move) rA+=(d*move) first=min(rA,rB)-max(lA,lB) lA+=move rA+=move second=min(rA,rB...
output
1
51,309
14
102,619
Provide tags and a correct Python 3 solution for this coding contest problem. Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, ...
instruction
0
51,310
14
102,620
Tags: math, number theory Correct Solution: ``` from math import gcd r = lambda: list(map(int, input().split())) a, b = r(), r() c = b[0] > a[0] la, ra, ta = a if c else b lb, rb, tb = b if c else a g = gcd(ta, tb) lna, lnb = ra - la + 1, rb - lb + 1 d = lb - la - (lb - la) // g * g print(max(0, min(lna - d, lnb), mi...
output
1
51,310
14
102,621