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. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and there...
instruction
0
16,503
14
33,006
Tags: binary search, math, sortings Correct Solution: ``` def chtoetodvoichnyupoisk(a, c): r = len(a) l = 0 while r - l > 1: s = (l + r) // 2 if s == len(a): if a[s - 1] >= c: r = s else: l = s if a[s] >= c: r = s ...
output
1
16,503
14
33,007
Provide tags and a correct Python 3 solution for this coding contest problem. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and there...
instruction
0
16,504
14
33,008
Tags: binary search, math, sortings Correct Solution: ``` from sys import stdin, stdout n, k = map(int, stdin.readline().split()) values = list(map(int, stdin.readline().split())) if sum(values) < k: stdout.write('-1') elif sum(values) > k: l = 0 r = k + 1 while (r - l > 1): m = (r + l) // 2...
output
1
16,504
14
33,009
Provide tags and a correct Python 3 solution for this coding contest problem. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and there...
instruction
0
16,505
14
33,010
Tags: binary search, math, sortings Correct Solution: ``` from sys import stdin n,k = [int(x) for x in stdin.readline().split()] a = [int(x) for x in stdin.readline().split()] if sum(a) < k: print(-1) elif sum(a) == k: pass else: diff = 0 kCopy = k sortA = sorted(a, reverse=True) while sortA...
output
1
16,505
14
33,011
Provide tags and a correct Python 3 solution for this coding contest problem. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and there...
instruction
0
16,506
14
33,012
Tags: binary search, math, sortings Correct Solution: ``` read = lambda: map(int, input().split()) n, k = read() a = list(read()) b = sorted([(a[i], i) for i in range(n)]) if sum(a) < k: print(-1) exit() j = 0 x2 = 0 for i in range(n): x = b[i][0] cur = (n - j) * (x - x2) if cur > k: break x2 = ...
output
1
16,506
14
33,013
Provide tags and a correct Python 3 solution for this coding contest problem. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and there...
instruction
0
16,507
14
33,014
Tags: binary search, math, sortings Correct Solution: ``` n, k = map(int, input().split()) a = list(map(int, input().split())) c = len(a) while c and k // c: t = k // c v = 0 for i in range(len(a)): if a[i] == 0: continue v += a[i] - max(0, a[i] - t) a[i] = max(0, a[i] - ...
output
1
16,507
14
33,015
Provide tags and a correct Python 3 solution for this coding contest problem. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and there...
instruction
0
16,508
14
33,016
Tags: binary search, math, sortings Correct Solution: ``` from bisect import bisect_right from itertools import accumulate def rest(k, a, q): return q[k:] + list(filter(lambda x: a[x - 1] > 1, q[:k])) def cycle(a, k): n = len(a) s = sorted(a) sm = list(accumulate(s)) b = [(sm[i - 1] if i > 0 els...
output
1
16,508
14
33,017
Provide tags and a correct Python 3 solution for this coding contest problem. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows all the forest animals perfectly well and there...
instruction
0
16,509
14
33,018
Tags: binary search, math, sortings Correct Solution: ``` n , k = map(int,input().split()) ans = [*map(int,input().split())] a = sum(ans) if a<k: print('-1') elif a>k: lef=0 rig = k+1 while lef+1<rig: mid = (lef+rig)//2 c=0 for i in range(n): c += min(ans[i],mid) ...
output
1
16,509
14
33,019
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows ...
instruction
0
16,510
14
33,020
Yes
output
1
16,510
14
33,021
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows ...
instruction
0
16,511
14
33,022
No
output
1
16,511
14
33,023
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows ...
instruction
0
16,512
14
33,024
No
output
1
16,512
14
33,025
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows ...
instruction
0
16,513
14
33,026
No
output
1
16,513
14
33,027
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n animals in the queue to Dr. Dolittle. When an animal comes into the office, the doctor examines him, gives prescriptions, appoints tests and may appoint extra examination. Doc knows ...
instruction
0
16,514
14
33,028
No
output
1
16,514
14
33,029
Provide a correct Python 3 solution for this coding contest problem. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. The...
instruction
0
16,562
14
33,124
"Correct Solution: ``` N,M = map(int,input().split()) F = [[] for _ in range(N)] for i in range(M): A,B = map(int,input().split()) A -= 1 B -= 1 F[A].append(B) F[B].append(A) a = [1 for _ in range(N)] l = [] b = [0 for _ in range(N)] for j in range(N): mem = 1 a[j] = 0 nex = F[j] whi...
output
1
16,562
14
33,125
Provide a correct Python 3 solution for this coding contest problem. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. The...
instruction
0
16,563
14
33,126
"Correct Solution: ``` import sys sys.setrecursionlimit(10**9) n,m=map(int,input().split()) root=[-1]*(n+1) def r(x): if root[x]<0: return x else: root[x]=r(root[x]) return root[x] def unite(x,y): x=r(x) y=r(y) if x==y: return if x>y: x,y=y,x root[x]+...
output
1
16,563
14
33,127
Provide a correct Python 3 solution for this coding contest problem. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. The...
instruction
0
16,564
14
33,128
"Correct Solution: ``` from collections import deque N, M = map(int, input().split()) friends = [[] for _ in range(N+1)] for __ in range(M): a, b = map(int, input().split()) friends[a].append(b) friends[b].append(a) checked = [0 for ___ in range(N+1)] answer = 1 for i in range(1, N+1): friend = deque(friends[i...
output
1
16,564
14
33,129
Provide a correct Python 3 solution for this coding contest problem. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. The...
instruction
0
16,565
14
33,130
"Correct Solution: ``` n,m = map(int,input().split()) g = [set() for i in range(n)] visited = [False] * n group = [] for i in range(m): a,b = map(int,input().split()) a -= 1 b -= 1 g[a].add(b) g[b].add(a) for i in range(n): if visited[i]: continue s = set() q = [i] while le...
output
1
16,565
14
33,131
Provide a correct Python 3 solution for this coding contest problem. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. The...
instruction
0
16,566
14
33,132
"Correct Solution: ``` N,M=map(int,input().split()) F = [set() for _ in range(N)] for _ in range(M): a,b = map(lambda x: int(x)-1, input().split()) F[a].add(b) F[b].add(a) from collections import deque def bfs(): ans = 1 done = set() for i in range(N): if i in done: continue queue = deque([i]) ...
output
1
16,566
14
33,133
Provide a correct Python 3 solution for this coding contest problem. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. The...
instruction
0
16,567
14
33,134
"Correct Solution: ``` n,m=map(int,input().split()) root=[-1]*n def r(x): #-1の項が何番目かを特定 if root[x]<0: #x番目が-1ならx(>=0)を返す return x else: #x番目が0以上なら-1の項に到達するまで回す root[x]=r(root[x]) return root[x] #-1の項に到達したらその項が何番目かを返す def unite(x,y): x=r(x) y=r(y) if x==y: #同じ項に到達した場合は処理の必要なし return root[x]...
output
1
16,567
14
33,135
Provide a correct Python 3 solution for this coding contest problem. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. The...
instruction
0
16,568
14
33,136
"Correct Solution: ``` import queue n,m=map(int,input().split()) a=[[] for j in range(n)] for i in range(0,m): b,c=map(int,input().split()) a[b-1].append(c-1) a[c-1].append(b-1) re=[0 for i in range(n)] le=[0] for i in range(0,n): if re[i]==0: ans=queue.Queue() ans.put(i) le.appe...
output
1
16,568
14
33,137
Provide a correct Python 3 solution for this coding contest problem. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and Y and Z are friends, then X and Z are also friends. The...
instruction
0
16,569
14
33,138
"Correct Solution: ``` N,M=map(int,input().split()) par=[i for i in range(N+1)] size=[1 for i in range(N+1)] def find(x): if x!=par[x]: par[x]=find(par[x]) return par[x] def union(x,y): if find(x)!=find(y): x, y = par[x], par[y] par[y] = par[x] size[x] += size[y] res=N for i ...
output
1
16,569
14
33,139
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and...
instruction
0
16,570
14
33,140
Yes
output
1
16,570
14
33,141
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and...
instruction
0
16,571
14
33,142
Yes
output
1
16,571
14
33,143
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and...
instruction
0
16,572
14
33,144
Yes
output
1
16,572
14
33,145
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and...
instruction
0
16,573
14
33,146
Yes
output
1
16,573
14
33,147
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and...
instruction
0
16,574
14
33,148
No
output
1
16,574
14
33,149
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and...
instruction
0
16,575
14
33,150
No
output
1
16,575
14
33,151
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and...
instruction
0
16,576
14
33,152
No
output
1
16,576
14
33,153
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N persons called Person 1 through Person N. You are given M facts that "Person A_i and Person B_i are friends." The same fact may be given multiple times. If X and Y are friends, and...
instruction
0
16,577
14
33,154
No
output
1
16,577
14
33,155
Provide tags and a correct Python 3 solution for this coding contest problem. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flowers in a row in the exhibition. Sonya can put eit...
instruction
0
16,812
14
33,624
Tags: constructive algorithms, greedy, implementation, math Correct Solution: ``` print(('01'*99999)[:int(input().split()[0])]) # Made By Mostafa_Khaled ```
output
1
16,812
14
33,625
Provide tags and a correct Python 3 solution for this coding contest problem. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flowers in a row in the exhibition. Sonya can put eit...
instruction
0
16,813
14
33,626
Tags: constructive algorithms, greedy, implementation, math Correct Solution: ``` def calc(s): presum = [0] for ch in s: presum.append(presum[-1]) if ch == '1': presum[-1] += 1 ans = 0 for (l,r) in points: ans += ((r-l+1) - (presum[r] - presum[l-1])) * (presum[r] - presum[l-1]) return ans ...
output
1
16,813
14
33,627
Provide tags and a correct Python 3 solution for this coding contest problem. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flowers in a row in the exhibition. Sonya can put eit...
instruction
0
16,814
14
33,628
Tags: constructive algorithms, greedy, implementation, math Correct Solution: ``` a=int(input().split()[0]) print("10"*(a//2)+'1'*(a%2)) ```
output
1
16,814
14
33,629
Provide tags and a correct Python 3 solution for this coding contest problem. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flowers in a row in the exhibition. Sonya can put eit...
instruction
0
16,815
14
33,630
Tags: constructive algorithms, greedy, implementation, math Correct Solution: ``` n, m = map(int, input().split()) clients = [] for i in range(m): temp_l = list(map(int, input().split())) clients.append(temp_l) print('10' * (n // 2), end='') if n % 2 == 1: print('1') ```
output
1
16,815
14
33,631
Provide tags and a correct Python 3 solution for this coding contest problem. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flowers in a row in the exhibition. Sonya can put eit...
instruction
0
16,816
14
33,632
Tags: constructive algorithms, greedy, implementation, math Correct Solution: ``` n,m = map(int,input().split()) for i in range(m): input() print(n // 2 * "01" + "0" * (n % 2)) ```
output
1
16,816
14
33,633
Provide tags and a correct Python 3 solution for this coding contest problem. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flowers in a row in the exhibition. Sonya can put eit...
instruction
0
16,817
14
33,634
Tags: constructive algorithms, greedy, implementation, math Correct Solution: ``` n, m = map(int, input().split()) result = '' for i in range(n): if i % 2 == 0: result += '0' else: result += '1' print(result) ```
output
1
16,817
14
33,635
Provide tags and a correct Python 3 solution for this coding contest problem. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flowers in a row in the exhibition. Sonya can put eit...
instruction
0
16,818
14
33,636
Tags: constructive algorithms, greedy, implementation, math Correct Solution: ``` n, m = map(int, input().split()) for i in range(m): a, b = map(int, input().split()) ans = [int(i % 2 == 0) for i in range(n)] print("".join(map(str, ans))) ```
output
1
16,818
14
33,637
Provide tags and a correct Python 3 solution for this coding contest problem. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flowers in a row in the exhibition. Sonya can put eit...
instruction
0
16,819
14
33,638
Tags: constructive algorithms, greedy, implementation, math Correct Solution: ``` import math n,k=map(int,input().split()) ans=0 for i in range(1,n+1): if (i%2==1): print("1",end="") else: print("0",end="") ```
output
1
16,819
14
33,639
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flower...
instruction
0
16,820
14
33,640
Yes
output
1
16,820
14
33,641
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flower...
instruction
0
16,821
14
33,642
Yes
output
1
16,821
14
33,643
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flower...
instruction
0
16,822
14
33,644
Yes
output
1
16,822
14
33,645
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flower...
instruction
0
16,823
14
33,646
Yes
output
1
16,823
14
33,647
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flower...
instruction
0
16,824
14
33,648
No
output
1
16,824
14
33,649
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flower...
instruction
0
16,825
14
33,650
No
output
1
16,825
14
33,651
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flower...
instruction
0
16,826
14
33,652
No
output
1
16,826
14
33,653
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Sonya decided to organize an exhibition of flowers. Since the girl likes only roses and lilies, she decided that only these two kinds of flowers should be in this exhibition. There are n flower...
instruction
0
16,827
14
33,654
No
output
1
16,827
14
33,655
Provide tags and a correct Python 3 solution for this coding contest problem. Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put toget...
instruction
0
17,127
14
34,254
Tags: implementation Correct Solution: ``` n=int(input()) ans=0 l='$$' for _ in range(n): s=input() if s!=l: ans+=1 l=s print(ans) ```
output
1
17,127
14
34,255
Provide tags and a correct Python 3 solution for this coding contest problem. Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put toget...
instruction
0
17,128
14
34,256
Tags: implementation Correct Solution: ``` a=int(input()) f=0 p='' for i in range(a): n=input() if i==0: p=n f+=1 elif n!=p: f+=1 p=n print(f) ```
output
1
17,128
14
34,257
Provide tags and a correct Python 3 solution for this coding contest problem. Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put toget...
instruction
0
17,129
14
34,258
Tags: implementation Correct Solution: ``` n = int(input()) L = [] for i in range(n): L.append(input()) k = 1 for i in range(1,n): if L[i] != L[i-1]: k += 1 else: continue print(k) ```
output
1
17,129
14
34,259
Provide tags and a correct Python 3 solution for this coding contest problem. Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put toget...
instruction
0
17,130
14
34,260
Tags: implementation Correct Solution: ``` s = "" p = 0 n = int(input()) for i in range(n): s += input() for i in range(len(s)-1): if s[i]==s[i+1]: p += 1 print(p+1) ```
output
1
17,130
14
34,261
Provide tags and a correct Python 3 solution for this coding contest problem. Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put toget...
instruction
0
17,131
14
34,262
Tags: implementation Correct Solution: ``` qtd = int(input()) count = 1 text = "" for _ in range(qtd): digitado = input() if text: if text[len(text)-1] == digitado[0]: count += 1 text += digitado print(count) ```
output
1
17,131
14
34,263
Provide tags and a correct Python 3 solution for this coding contest problem. Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put toget...
instruction
0
17,132
14
34,264
Tags: implementation Correct Solution: ``` n = int(input()) m = [] for i in range(n): m.append(input()) m = ''.join(m) count = 0 for i in range(0,len(m)-1): if m[i]+m[i+1] == "11" or m[i]+m[i+1] == "00": count+=1 print(count+1) ```
output
1
17,132
14
34,265