message
stringlengths
2
48.6k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
318
108k
cluster
float64
8
8
__index_level_0__
int64
636
217k
Provide tags and a correct Python 3 solution for this coding contest problem. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in hi...
instruction
0
106,482
8
212,964
Tags: brute force Correct Solution: ``` ##import math a,b = map(int, input().split()) lis = list(map(int, input().split())) lis.sort() c = 0 for i in range(len(lis)): #print (i) for ii in range(len(lis)): if(i == ii): continue if abs(lis[i]-lis[ii]) <= b: c += 1 ...
output
1
106,482
8
212,965
Provide tags and a correct Python 3 solution for this coding contest problem. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in hi...
instruction
0
106,483
8
212,966
Tags: brute force Correct Solution: ``` ''' Amirhossein Alimirzaei Telegram : @HajLorenzo Instagram : amirhossein_alimirzaei University of Bojnourd ''' # Be Kasif tarin halat momken neveshtam hal kon :DDDD N = list(map(int, input().split())) L = sorted(list(map(int, input().split()))) C = 0 for _ in range(N[0] - 1):...
output
1
106,483
8
212,967
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most ...
instruction
0
106,484
8
212,968
Yes
output
1
106,484
8
212,969
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most ...
instruction
0
106,485
8
212,970
Yes
output
1
106,485
8
212,971
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most ...
instruction
0
106,486
8
212,972
Yes
output
1
106,486
8
212,973
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most ...
instruction
0
106,487
8
212,974
Yes
output
1
106,487
8
212,975
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most ...
instruction
0
106,488
8
212,976
No
output
1
106,488
8
212,977
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most ...
instruction
0
106,489
8
212,978
No
output
1
106,489
8
212,979
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most ...
instruction
0
106,490
8
212,980
No
output
1
106,490
8
212,981
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most ...
instruction
0
106,491
8
212,982
No
output
1
106,491
8
212,983
Provide tags and a correct Python 3 solution for this coding contest problem. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV ...
instruction
0
107,031
8
214,062
Tags: math Correct Solution: ``` def uscln(u, v): if u == v: return u elif u == 0: return v elif v == 0: return u elif u & 1 == 0: if v & 1 == 0: return 2*uscln(u >> 1, v >> 1) else: return uscln(u >> 1, v) elif u & 1 != 0: ...
output
1
107,031
8
214,063
Provide tags and a correct Python 3 solution for this coding contest problem. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV ...
instruction
0
107,032
8
214,064
Tags: math Correct Solution: ``` def HOD(a, b): while (b > 0): a, b = b, a % b return a a, b, x, y = map(int, input().split()) d = HOD(x, y) x //= d y //= d # w * y = h * x # W % x == 0 # H % y == 0 #w / x = h / y maxw = (a // x) * x maxw1 = a // x * y maxh = (b // y) * y maxh1 = b // y * x if (maxw1 ...
output
1
107,032
8
214,065
Provide tags and a correct Python 3 solution for this coding contest problem. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV ...
instruction
0
107,034
8
214,068
Tags: math Correct Solution: ``` import math a,b,c,d=map(int,input().split()) divisor=math.gcd(c,d) c//=divisor d//=divisor print(min(a//c,b//d)) ```
output
1
107,034
8
214,069
Provide tags and a correct Python 3 solution for this coding contest problem. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV ...
instruction
0
107,037
8
214,074
Tags: math Correct Solution: ``` a,b,x,y=map(int,input().split()) def computeGCD(x, y): while(y): x, y = y, x % y return x z=computeGCD(x,y) x=x/z y=y/z print(int(min(a//x,b//y))) ```
output
1
107,037
8
214,075
Provide tags and a correct Python 3 solution for this coding contest problem. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height not greater than b. Monocarp is also used to TV ...
instruction
0
107,038
8
214,076
Tags: math Correct Solution: ``` import math a, b, x, y = map(int, input().split()) lcm = int(x*y/math.gcd(x, y)) v1 = a*y - (a*y)%lcm v2 = lcm ans = max(0, int(1+(v1-v2)/lcm)) v1 = b*x - (b*x)%lcm ans = min(ans, int(1+(v1-v2)/lcm)) ans = max(0, ans) print(ans) ```
output
1
107,038
8
214,077
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height n...
instruction
0
107,039
8
214,078
Yes
output
1
107,039
8
214,079
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height n...
instruction
0
107,040
8
214,080
Yes
output
1
107,040
8
214,081
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height n...
instruction
0
107,041
8
214,082
Yes
output
1
107,041
8
214,083
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height n...
instruction
0
107,042
8
214,084
Yes
output
1
107,042
8
214,085
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height n...
instruction
0
107,043
8
214,086
No
output
1
107,043
8
214,087
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height n...
instruction
0
107,044
8
214,088
No
output
1
107,044
8
214,089
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height n...
instruction
0
107,045
8
214,090
No
output
1
107,045
8
214,091
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than a and screen height n...
instruction
0
107,046
8
214,092
No
output
1
107,046
8
214,093
Provide tags and a correct Python 3 solution for this coding contest problem. Masha has three sticks of length a, b and c centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks. What is the minimum number of minutes she ...
instruction
0
107,049
8
214,098
Tags: brute force, geometry, math Correct Solution: ``` def ok(arr1): arr1.sort() if arr1[2]-arr1[0]-arr1[1]<0: return 0 else: return arr1[2]-arr1[0]-arr1[1]+1 arr1=list(map(int,input().split())) print(ok(arr1)) ```
output
1
107,049
8
214,099
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once upon a time, when the world was more beautiful, the sun shone brighter, the grass was greener and the sausages tasted better Arlandia was the most powerful country. And its capital was the ...
instruction
0
107,323
8
214,646
No
output
1
107,323
8
214,647
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once upon a time, when the world was more beautiful, the sun shone brighter, the grass was greener and the sausages tasted better Arlandia was the most powerful country. And its capital was the ...
instruction
0
107,324
8
214,648
No
output
1
107,324
8
214,649
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once upon a time, when the world was more beautiful, the sun shone brighter, the grass was greener and the sausages tasted better Arlandia was the most powerful country. And its capital was the ...
instruction
0
107,325
8
214,650
No
output
1
107,325
8
214,651
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once upon a time, when the world was more beautiful, the sun shone brighter, the grass was greener and the sausages tasted better Arlandia was the most powerful country. And its capital was the ...
instruction
0
107,326
8
214,652
No
output
1
107,326
8
214,653
Provide a correct Python 3 solution for this coding contest problem. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. I...
instruction
0
107,455
8
214,910
"Correct Solution: ``` n,m = map(int,input().split()) c = [] for i in range(n): a = list(input()) l = 0 for i in range(len(a)-1): if(a[i]=='B' and a[i+1]=='.'): l+=1 if(a[-1]=='B'): l+=1 print(l) ```
output
1
107,455
8
214,911
Provide a correct Python 3 solution for this coding contest problem. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. I...
instruction
0
107,456
8
214,912
"Correct Solution: ``` n, m = map(int, input().split()) a = '' for _ in range(n): a = input() ans = 0 i = 0 while i < m: if 'B' == a[i]: ans += 1 while i < m and 'B' == a[i]: i += 1 else: i += 1 print(ans) ```
output
1
107,456
8
214,913
Provide a correct Python 3 solution for this coding contest problem. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. I...
instruction
0
107,457
8
214,914
"Correct Solution: ``` R, C = map(int, input().split()) line = '.' * (C+2) wall = [line] for _ in range(R): wall.append('.' + input() + '.') wall.append(line) vs = set() ans = 0 def visit(r, c): q = [(r, c)] while q: r, c = q.pop() if (r, c) in vs: continue vs.add((r, ...
output
1
107,457
8
214,915
Provide a correct Python 3 solution for this coding contest problem. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. I...
instruction
0
107,458
8
214,916
"Correct Solution: ``` r,c = [int(s) for s in input().split()] w =[] for i in range(r): w.append(input()) count = 0 def isEmpty(i): for j in range(r): if(w[j][i] == 'B'): return False return True started = False for i in range(c): if not (isEmpty(i) or started): started =...
output
1
107,458
8
214,917
Provide a correct Python 3 solution for this coding contest problem. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. I...
instruction
0
107,459
8
214,918
"Correct Solution: ``` n, k = map(int, input().split()) rows = [] for row in range(n): rows.append(input()) seg = [] ind = [] for i in range(n): for j in range(k): if rows[i][j] == 'B': ind.append(j) for i in range(min(ind), max(ind)+1): c = 0 for j in rows: if j[i] == ".":...
output
1
107,459
8
214,919
Provide a correct Python 3 solution for this coding contest problem. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. I...
instruction
0
107,460
8
214,920
"Correct Solution: ``` read = lambda: map(int, input().split()) n, m = read() a = [input() for i in range(n)] s = a[n - 1].split('.') cnt = len(s) - s.count('') print(cnt) ```
output
1
107,460
8
214,921
Provide a correct Python 3 solution for this coding contest problem. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. I...
instruction
0
107,461
8
214,922
"Correct Solution: ``` r, c = input().split() for q in range(int(r)): s = input() + "." print(s.count("B.")) ```
output
1
107,461
8
214,923
Provide a correct Python 3 solution for this coding contest problem. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the North. Its protection is failing, and cracks are showing. I...
instruction
0
107,462
8
214,924
"Correct Solution: ``` r,c=list(map(int,input().split())) a=[] for i in range(r): a.append(input()) b=[] for i in range(c): e=0 for j in range(r): if a[j][i]=="B": e=1 b.append(e) d=0 e=0 for i in range(c): if b[i]==1: d+=1 if b[i]==0 and d!=0: d=0 e+=...
output
1
107,462
8
214,925
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the Nor...
instruction
0
107,463
8
214,926
Yes
output
1
107,463
8
214,927
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the Nor...
instruction
0
107,464
8
214,928
Yes
output
1
107,464
8
214,929
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the Nor...
instruction
0
107,465
8
214,930
Yes
output
1
107,465
8
214,931
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the Nor...
instruction
0
107,466
8
214,932
Yes
output
1
107,466
8
214,933
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the Nor...
instruction
0
107,467
8
214,934
No
output
1
107,467
8
214,935
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the Nor...
instruction
0
107,468
8
214,936
No
output
1
107,468
8
214,937
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the Nor...
instruction
0
107,469
8
214,938
No
output
1
107,469
8
214,939
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. "The zombies are lurking outside. Waiting. Moaning. And when they come..." "When they come?" "I hope the Wall is high enough." Zombie attacks have hit the Wall, our line of defense in the Nor...
instruction
0
107,470
8
214,940
No
output
1
107,470
8
214,941
Provide a correct Python 3 solution for this coding contest problem. Mr. Frugal bought a new house. He feels deeply in love with his new house because it has a comfortable living room in which he can put himself completely at ease. He thinks his new house is a really good buy. But, to his disappointment, the floor of...
instruction
0
107,811
8
215,622
"Correct Solution: ``` def solve(): from itertools import combinations from sys import stdin file_input = stdin while True: W, H = map(int, file_input.readline().split()) if W == 0: break carpets = [] state = 0 # Largest Square a...
output
1
107,811
8
215,623
Provide a correct Python 3 solution for this coding contest problem. Mr. Frugal bought a new house. He feels deeply in love with his new house because it has a comfortable living room in which he can put himself completely at ease. He thinks his new house is a really good buy. But, to his disappointment, the floor of...
instruction
0
107,812
8
215,624
"Correct Solution: ``` import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): W, H = map(int, readline().split()) if W == 0: return False MP = [list(map(int, input().split())) for i in range(H)] C = [[0]*W for i in range(H)] for j in range(W): cur = 0 ...
output
1
107,812
8
215,625
Provide a correct Python 3 solution for this coding contest problem. Problem statement Jota made a scale as shown in the figure below using a stick with a length of $ 2L $. <image> The rods are evenly spaced with $ 2L + 1 $ holes, from left to right: $ -L, -L + 1, \ cdots, -1, 0, 1, \ cdots, L-1, L $. It is numbere...
instruction
0
107,822
8
215,644
"Correct Solution: ``` l = int(input()) n = int(input()) mom = 0 for _ in range(n): x, w = map(int, input().split()) mom += x * w weight = [] while mom: if mom < 0: add_weight = min(-mom, 50000) mom += add_weight weight.append((1, add_weight)) elif mom > 0: add_weight = min(mom, 50000) mom ...
output
1
107,822
8
215,645
Provide a correct Python 3 solution for this coding contest problem. Problem statement Jota made a scale as shown in the figure below using a stick with a length of $ 2L $. <image> The rods are evenly spaced with $ 2L + 1 $ holes, from left to right: $ -L, -L + 1, \ cdots, -1, 0, 1, \ cdots, L-1, L $. It is numbere...
instruction
0
107,823
8
215,646
"Correct Solution: ``` #!/usr/bin/env python3 # -*- coding: utf-8 -*- def solve(l, n, jota_weights): jota_torque = sum(x * w for x, w in jota_weights) if jota_torque == 0: return (0, []) else: max_w = 50000 sign = -1 if jota_torque > 0 else 1 ritsuko_weights = [] ri...
output
1
107,823
8
215,647
Provide a correct Python 3 solution for this coding contest problem. Problem statement Jota made a scale as shown in the figure below using a stick with a length of $ 2L $. <image> The rods are evenly spaced with $ 2L + 1 $ holes, from left to right: $ -L, -L + 1, \ cdots, -1, 0, 1, \ cdots, L-1, L $. It is numbere...
instruction
0
107,824
8
215,648
"Correct Solution: ``` input() s=sum(x*w for x,w in [map(int,input().split()) for _ in range(int(input()))]) print('1\n%d %d'%([1,-1][s>0],abs(s)) if s else 0) ```
output
1
107,824
8
215,649
Provide a correct Python 3 solution for this coding contest problem. Problem statement Jota made a scale as shown in the figure below using a stick with a length of $ 2L $. <image> The rods are evenly spaced with $ 2L + 1 $ holes, from left to right: $ -L, -L + 1, \ cdots, -1, 0, 1, \ cdots, L-1, L $. It is numbere...
instruction
0
107,825
8
215,650
"Correct Solution: ``` L = int(input()) N = int(input()) s = 0 for i in range(N): x, w = map(int, input().split()) s += x * w if(s == 0): print(0) elif(s < 0): print(1) print(1, -s) else: print(1) print(-1, s) ```
output
1
107,825
8
215,651