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
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the...
instruction
0
103,357
14
206,714
No
output
1
103,357
14
206,715
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the...
instruction
0
103,358
14
206,716
No
output
1
103,358
14
206,717
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the...
instruction
0
103,359
14
206,718
No
output
1
103,359
14
206,719
Provide tags and a correct Python 3 solution for this coding contest problem. Alice and Bonnie are sisters, but they don't like each other very much. So when some old family photos were found in the attic, they started to argue about who should receive which photos. In the end, they decided that they would take turns ...
instruction
0
103,360
14
206,720
Tags: games, greedy Correct Solution: ``` num_stacks = int(input()) answer = 0 array = [] for i in range(num_stacks): a1, b1, a2, b2 = map(int, input().split(' ')) if a1 + b1 >= a2 + b2: answer += a1 + a2 array.append(a2 + b2) array.append(a1 + b1) elif a1 > b2: answe...
output
1
103,360
14
206,721
Provide tags and a correct Python 3 solution for this coding contest problem. Alice and Bonnie are sisters, but they don't like each other very much. So when some old family photos were found in the attic, they started to argue about who should receive which photos. In the end, they decided that they would take turns ...
instruction
0
103,361
14
206,722
Tags: games, greedy Correct Solution: ``` num_stacks = int(input()) answer = 0 array = [] for i in range(num_stacks): a1, b1, a2, b2 = input().split(' ') a1 = int(a1) a2 = int(a2) b1 = int(b1) b2 = int(b2) if a1 + b1 >= a2 + b2: answer += a1 + a2 array.append(a2 + b2) ...
output
1
103,361
14
206,723
Provide a correct Python 3 solution for this coding contest problem. There is a very long bench. The bench is divided into M sections, where M is a very large integer. Initially, the bench is vacant. Then, M people come to the bench one by one, and perform the following action: * We call a section comfortable if the...
instruction
0
103,488
14
206,976
"Correct Solution: ``` #参考URL #https://qiita.com/ageprocpp/items/104c051b2ec2086f5a9b mod=10**9+7 def value(obj): if type(obj)==modint: tmp=obj.number else: tmp=obj return tmp%mod class modint(): number=0 def __init__(self,num): self.number=num%mod def __add__(self,other...
output
1
103,488
14
206,977
Provide a correct Python 3 solution for this coding contest problem. There is a very long bench. The bench is divided into M sections, where M is a very large integer. Initially, the bench is vacant. Then, M people come to the bench one by one, and perform the following action: * We call a section comfortable if the...
instruction
0
103,489
14
206,978
"Correct Solution: ``` #!/usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from bisect import bisect_left, bisect_right import sys, random, itertools, math sys.setrecursionlimit(10**5) input = sys.stdin.readline sqrt = math.sqrt def LI(): return list(map(int, input().spl...
output
1
103,489
14
206,979
Provide a correct Python 3 solution for this coding contest problem. There is a very long bench. The bench is divided into M sections, where M is a very large integer. Initially, the bench is vacant. Then, M people come to the bench one by one, and perform the following action: * We call a section comfortable if the...
instruction
0
103,490
14
206,980
"Correct Solution: ``` from copy import * N=int(input()) S=input() DP=[[[[0]*2 for i in range(2)] for j in range(2)] for k in range(N)] mod=10**9+7 for i in range(N): for j in range(2): for k in range(2): for l in range(2): DP[i][j][k][l]=[[],[],0] if S[0]=='X': DP[0][0][1][0]=[[],[],1] else: DP...
output
1
103,490
14
206,981
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a very long bench. The bench is divided into M sections, where M is a very large integer. Initially, the bench is vacant. Then, M people come to the bench one by one, and perform the f...
instruction
0
103,491
14
206,982
No
output
1
103,491
14
206,983
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a very long bench. The bench is divided into M sections, where M is a very large integer. Initially, the bench is vacant. Then, M people come to the bench one by one, and perform the f...
instruction
0
103,492
14
206,984
No
output
1
103,492
14
206,985
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a very long bench. The bench is divided into M sections, where M is a very large integer. Initially, the bench is vacant. Then, M people come to the bench one by one, and perform the f...
instruction
0
103,493
14
206,986
No
output
1
103,493
14
206,987
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There is a very long bench. The bench is divided into M sections, where M is a very large integer. Initially, the bench is vacant. Then, M people come to the bench one by one, and perform the f...
instruction
0
103,494
14
206,988
No
output
1
103,494
14
206,989
Provide a correct Python 3 solution for this coding contest problem. There are N persons, conveniently numbered 1 through N. They will take 3y3s Challenge for N-1 seconds. During the challenge, each person must look at each of the N-1 other persons for 1 seconds, in some order. If any two persons look at each other ...
instruction
0
103,559
14
207,118
"Correct Solution: ``` n = int(input()) if n==2: print(-1) else: for i in range(1,n+1): num = 0 if i%2==1: for j in range(1,n+1): if i!=j and num!=n-2: print(j,end=" ") num += 1 elif i!=j: print(j) break else: if i==n: print(n-1,end=" ") else: print(n,end=" ") for j in ran...
output
1
103,559
14
207,119
Provide a correct Python 3 solution for this coding contest problem. There are N persons, conveniently numbered 1 through N. They will take 3y3s Challenge for N-1 seconds. During the challenge, each person must look at each of the N-1 other persons for 1 seconds, in some order. If any two persons look at each other ...
instruction
0
103,560
14
207,120
"Correct Solution: ``` n = int(input()) if n == 2: print(-1) exit() if n % 2 == 1: for i in range(n): print(" ".join([str((item + i + 1) % n + 1) for item in range(n-1)])) else: for i in range(n): ans = [(item + i + 1) % n + 1 for item in range(n-1) if item != n // 2 - 1] ans.ins...
output
1
103,560
14
207,121
Provide tags and a correct Python 3 solution for this coding contest problem. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the debate as a spectator. Each person is described by ...
instruction
0
103,699
14
207,398
Tags: greedy Correct Solution: ``` if __name__=="__main__": n = int(input()) supporters = {} supporters[0]=[] supporters[1]=[] supporters[10]=[] supporters[11]=[] for i in range(n): [x,y] = [int(x) for x in input().split()] supporters[x].append(y) #print(x,y) for...
output
1
103,699
14
207,399
Provide tags and a correct Python 3 solution for this coding contest problem. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the debate as a spectator. Each person is described by ...
instruction
0
103,700
14
207,400
Tags: greedy Correct Solution: ``` from collections import defaultdict c = defaultdict(int) m = defaultdict(list) n = int(input()) for i in range(n): s,a = input().split() m[s].append(int(a)) c[s]+=1 ali = c['10'] bob = c['01'] co = c['11'] no = c['00'] if(ali==0 or bob==0) and (co==0): print(0) else: ...
output
1
103,700
14
207,401
Provide tags and a correct Python 3 solution for this coding contest problem. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the debate as a spectator. Each person is described by ...
instruction
0
103,701
14
207,402
Tags: greedy Correct Solution: ``` from math import ceil n, A = int(input()), [] a = b = ab = ab_ = ans = 0 for _ in range(n): t, tt = input().split() tt = int(tt) if t != '11': A.append([t, tt]) if t == '10': a += 1 elif t == '01': b += 1 else: ...
output
1
103,701
14
207,403
Provide tags and a correct Python 3 solution for this coding contest problem. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the debate as a spectator. Each person is described by ...
instruction
0
103,702
14
207,404
Tags: greedy Correct Solution: ``` from collections import defaultdict n = int(input()) a=defaultdict(list) for i in range(n): h,m=list(map(int,input().split())) a[h].append(m) k=sum(a[11]) a[10].sort() a[1].sort() a[0].sort() g=0 if len(a[1])>len(a[10]): z=len(a[10]) g=1 else: g=10 z=len(a[1]...
output
1
103,702
14
207,405
Provide tags and a correct Python 3 solution for this coding contest problem. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the debate as a spectator. Each person is described by ...
instruction
0
103,703
14
207,406
Tags: greedy Correct Solution: ``` n = int(input()) t_11=[] t_10=[] t_01=[] t_00=[] for x in range(n): tmp=list(input().split()) supp = str(tmp[0]) m = int(tmp[1]) t_tmp = [supp, m] if supp == '11': t_11.append(t_tmp) elif supp == '01': t_01.append(t_tmp) elif supp == '10': ...
output
1
103,703
14
207,407
Provide tags and a correct Python 3 solution for this coding contest problem. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the debate as a spectator. Each person is described by ...
instruction
0
103,704
14
207,408
Tags: greedy Correct Solution: ``` import math as ma import sys from sys import exit from decimal import Decimal as dec from itertools import permutations def li(): return list(map(int , input().split())) def num(): return map(int , input().split()) def nu(): return int(input()) def find_gcd(x , y): while (y): ...
output
1
103,704
14
207,409
Provide tags and a correct Python 3 solution for this coding contest problem. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the debate as a spectator. Each person is described by ...
instruction
0
103,705
14
207,410
Tags: greedy Correct Solution: ``` import math n=int(input()) d={} d['00']=[] d['01']=[] d['10']=[] d['11']=[] count={'00':0,'01':0,'10':0,'11':0} ans=0 length=0 if(n==1): x,y=input().split() if(x=='00'): print(0) elif(x=='11'): print(int(y)) else: print(0) else: for i in range(...
output
1
103,705
14
207,411
Provide tags and a correct Python 3 solution for this coding contest problem. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the debate as a spectator. Each person is described by ...
instruction
0
103,706
14
207,412
Tags: greedy Correct Solution: ``` n=int(input()) a=[];b=[];c=[];d=[] for i in range(n): opt,num=[int(x) for x in input().split()] if opt==0: a.append(num) if opt==10: b.append(num) if opt==1: c.append(num) if opt==11: d.append(num) ans=sum(d) b.sort(reverse=True) # f...
output
1
103,706
14
207,413
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the deba...
instruction
0
103,707
14
207,414
Yes
output
1
103,707
14
207,415
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the deba...
instruction
0
103,708
14
207,416
Yes
output
1
103,708
14
207,417
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the deba...
instruction
0
103,709
14
207,418
Yes
output
1
103,709
14
207,419
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the deba...
instruction
0
103,710
14
207,420
Yes
output
1
103,710
14
207,421
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the deba...
instruction
0
103,711
14
207,422
No
output
1
103,711
14
207,423
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the deba...
instruction
0
103,712
14
207,424
No
output
1
103,712
14
207,425
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the deba...
instruction
0
103,713
14
207,426
No
output
1
103,713
14
207,427
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Elections in Berland are coming. There are only two candidates β€” Alice and Bob. The main Berland TV channel plans to show political debates. There are n people who want to take part in the deba...
instruction
0
103,714
14
207,428
No
output
1
103,714
14
207,429
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his talk with the exam...
instruction
0
103,780
14
207,560
Tags: constructive algorithms, implementation, sortings Correct Solution: ``` num_problems, num_cards = map(int, input().split()) card_size = num_problems // num_cards skill = [ 0 ] + list(map(int, input().split())) seen = (num_problems + 1) * [ False ] num_queries = int(input()) low = 100 high = 0 for i in range(num_q...
output
1
103,780
14
207,561
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his talk with the exam...
instruction
0
103,781
14
207,562
Tags: constructive algorithms, implementation, sortings Correct Solution: ``` n, k = map(int, input().split(" ")) a = list(map(int, input().split(" "))) temp = [0 for i in range(n)] b = [] min = 10000000 max = 0 q = int(input()) for i in range(q): ls = list(map(int, input().split(" "))) tmp = 0 for j in ls: tmp +=...
output
1
103,781
14
207,563
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his talk with the exam...
instruction
0
103,782
14
207,564
Tags: constructive algorithms, implementation, sortings Correct Solution: ``` n, k = map(int, input().split(" ")) a = list(map(int, input().split(" "))) temp = [0 for i in range(n)] b = [] min = 10000000 max = 0 q = int(input()) for i in range(q): ls = list(map(int, input().split(" "))) tmp = 0 for j in ls: tmp +=...
output
1
103,782
14
207,565
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his talk with the exam...
instruction
0
103,783
14
207,566
Tags: constructive algorithms, implementation, sortings Correct Solution: ``` n,k = map(int, input().split()) a = list(map(int, input().split())) ansMin, ansMax = 10**10, -10**10 were = [0]*n sz = n//k for i in range(int(input())): cur = 0.0 t = map(int, input().split()) for x in t: were[x-1]=1 ...
output
1
103,783
14
207,567
Provide tags and a correct Python 3 solution for this coding contest problem. Vasya is about to take his first university exam in about several minutes. And it's not just some ordinary exam, it's on mathematical analysis. Of course, right now Vasya can only think of one thing: what the result of his talk with the exam...
instruction
0
103,784
14
207,568
Tags: constructive algorithms, implementation, sortings Correct Solution: ``` n, m = map(int, input().split()) a = [0] + list(map(int, input().split())) p, t, k = [], [True] * (n + 1), n // m u, v = 10001, -1 for i in range(int(input())): q = list(map(int, input().split())) if t[q[0]]: for i in q: t[i] ...
output
1
103,784
14
207,569
Provide tags and a correct Python 3 solution for this coding contest problem. Everyone knows that hobbits love to organize all sorts of parties and celebrations. There are n hobbits living in the Shire. They decided to organize the Greatest Party (GP) that would last for several days. Next day the hobbits wrote a gues...
instruction
0
103,815
14
207,630
Tags: constructive algorithms, greedy Correct Solution: ``` ''' Author : thekushalghosh Team : CodeDiggers ''' n = int(input()) q = int(0.5 + (1 + 8*n)**0.5 / 2) w = 1 qw = [[] for _ in range(q)] for i in range(q): j = i + 1 while len(qw[i]) < q - 1: qw[i].append(str(w)) qw[j].append...
output
1
103,815
14
207,631
Provide tags and a correct Python 3 solution for this coding contest problem. Everyone knows that hobbits love to organize all sorts of parties and celebrations. There are n hobbits living in the Shire. They decided to organize the Greatest Party (GP) that would last for several days. Next day the hobbits wrote a gues...
instruction
0
103,816
14
207,632
Tags: constructive algorithms, greedy Correct Solution: ``` n=int(input()) res=1 while((res*(res+1)//2)<=n):res+=1 ns=[[] for _ in range(res+1)] cur=1 for i in range(1,res+1): for j in range(i+1,res+1): ns[i].append(cur) ns[j].append(cur) cur+=1 print(res) for e in ns[1:]: print(*e) ```
output
1
103,816
14
207,633
Provide tags and a correct Python 3 solution for this coding contest problem. Everyone knows that hobbits love to organize all sorts of parties and celebrations. There are n hobbits living in the Shire. They decided to organize the Greatest Party (GP) that would last for several days. Next day the hobbits wrote a gues...
instruction
0
103,817
14
207,634
Tags: constructive algorithms, greedy Correct Solution: ``` n=int(input()) x=1 while x*(x-1)//2<=n: x+=1 x-=1 print(x) z=x*(x-1)//2 a=[] z=0 for i in range(x-1): a.append(z-i+1) z+=x-i for i in range(x): j=i for k in range(i): print(a[k],end=' ') a[k]+=1 j=a[i] if i!=x-1 else 0 ...
output
1
103,817
14
207,635
Provide tags and a correct Python 3 solution for this coding contest problem. Everyone knows that hobbits love to organize all sorts of parties and celebrations. There are n hobbits living in the Shire. They decided to organize the Greatest Party (GP) that would last for several days. Next day the hobbits wrote a gues...
instruction
0
103,818
14
207,636
Tags: constructive algorithms, greedy Correct Solution: ``` n = int(input()) d = int(0.5 + (1 + 8*n)**0.5 / 2) curr = 1 res = [[] for _ in range(d)] for i in range(d): j = i + 1 while len(res[i]) < d - 1: res[i].append(str(curr)) res[j].append(str(curr)) curr += 1 j += 1 print(d...
output
1
103,818
14
207,637
Provide tags and a correct Python 3 solution for this coding contest problem. Everyone knows that hobbits love to organize all sorts of parties and celebrations. There are n hobbits living in the Shire. They decided to organize the Greatest Party (GP) that would last for several days. Next day the hobbits wrote a gues...
instruction
0
103,819
14
207,638
Tags: constructive algorithms, greedy Correct Solution: ``` N = int(input()) k = 1 while 1: if k * (k - 1) // 2 > N: k -= 1 print(k) D = [[]] for i in range (k): D.append ([]) p = 1 for i in range(k): for j in range(i + 1, k): D[i].append (p) D [j].append (p) p += 1 for i in D: for ...
output
1
103,819
14
207,639
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Everyone knows that hobbits love to organize all sorts of parties and celebrations. There are n hobbits living in the Shire. They decided to organize the Greatest Party (GP) that would last for ...
instruction
0
103,820
14
207,640
No
output
1
103,820
14
207,641
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Everyone knows that hobbits love to organize all sorts of parties and celebrations. There are n hobbits living in the Shire. They decided to organize the Greatest Party (GP) that would last for ...
instruction
0
103,821
14
207,642
No
output
1
103,821
14
207,643
Provide tags and a correct Python 3 solution for this coding contest problem. As Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and numbered them from 1 to n. After th...
instruction
0
103,939
14
207,878
Tags: constructive algorithms, data structures, implementation Correct Solution: ``` from sys import stdin, stdout n, m = map(int, stdin.readline().split()) cntf = [0 for i in range(n + 1)] cnts = [0 for i in range(n + 1)] challengers = [] for i in range(n): s = stdin.readline().strip() challengers.append(s) ...
output
1
103,939
14
207,879
Provide tags and a correct Python 3 solution for this coding contest problem. As Sherlock Holmes was investigating a crime, he identified n suspects. He knows for sure that exactly one of them committed the crime. To find out which one did it, the detective lines up the suspects and numbered them from 1 to n. After th...
instruction
0
103,940
14
207,880
Tags: constructive algorithms, data structures, implementation Correct Solution: ``` """ Brandt Smith, Lemuel Gorion and Peter Haddad codeforces.com Problem 156B """ import sys n, m = map(int, input().split(' ')) inp = [] guess = [0] * (n + 1) for i in range(n): temp = int(input()) inp.append(temp) if...
output
1
103,940
14
207,881
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once upon a time there lived a good fairy A. One day a fine young man B came to her and asked to predict his future. The fairy looked into her magic ball and said that soon the fine young man wi...
instruction
0
103,942
14
207,884
No
output
1
103,942
14
207,885
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once upon a time there lived a good fairy A. One day a fine young man B came to her and asked to predict his future. The fairy looked into her magic ball and said that soon the fine young man wi...
instruction
0
103,943
14
207,886
No
output
1
103,943
14
207,887
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Once upon a time there lived a good fairy A. One day a fine young man B came to her and asked to predict his future. The fairy looked into her magic ball and said that soon the fine young man wi...
instruction
0
103,944
14
207,888
No
output
1
103,944
14
207,889
Provide tags and a correct Python 3 solution for this coding contest problem. As it has been found out recently, all the Berland's current economical state can be described using a simple table n Γ— m in size. n β€” the number of days in each Berland month, m β€” the number of months. Thus, a table cell corresponds to a da...
instruction
0
104,010
14
208,020
Tags: combinatorics Correct Solution: ``` # METO Bot 0.9.9 n,m=map(int,input().split()) k=int(input()) A=[[] for i in range(max(n,m))] for i in range(k): a,b,c=map(int,input().split()) A[b-1 if n<m else a-1].append(c==-1) p=int(input()) if n%2!=m%2: print(0) else: r=k for i in A: if len(i)>=min(n,m): if sum(...
output
1
104,010
14
208,021
Provide tags and a correct Python 3 solution for this coding contest problem. As it has been found out recently, all the Berland's current economical state can be described using a simple table n Γ— m in size. n β€” the number of days in each Berland month, m β€” the number of months. Thus, a table cell corresponds to a da...
instruction
0
104,011
14
208,022
Tags: combinatorics Correct Solution: ``` import itertools import math n, m = [int(x) for x in input().split()] if n%2 != m%2: print(0) else: k = int(input()) S = [[] for i in range(max(n,m))] for i in range(k): a, b, c = [int(x) for x in input().split()] if n<m: S[b-1].appe...
output
1
104,011
14
208,023
Provide tags and a correct Python 3 solution for this coding contest problem. As it has been found out recently, all the Berland's current economical state can be described using a simple table n Γ— m in size. n β€” the number of days in each Berland month, m β€” the number of months. Thus, a table cell corresponds to a da...
instruction
0
104,012
14
208,024
Tags: combinatorics Correct Solution: ``` n,m=map(int,input().split()) k=int(input()) A=[[] for i in range(max(n,m))] for i in range(k): a,b,c=map(int,input().split()) A[b-1 if n<m else a-1].append(c==-1) p=int(input()) if n%2!=m%2: print(0) else: r=k for i in A: if len(i)>=min(n,m): if sum(i)%2: r-=1 ...
output
1
104,012
14
208,025