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. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digit...
instruction
0
26,783
14
53,566
Yes
output
1
26,783
14
53,567
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digit...
instruction
0
26,784
14
53,568
Yes
output
1
26,784
14
53,569
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digit...
instruction
0
26,785
14
53,570
Yes
output
1
26,785
14
53,571
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digit...
instruction
0
26,786
14
53,572
No
output
1
26,786
14
53,573
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digit...
instruction
0
26,787
14
53,574
No
output
1
26,787
14
53,575
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digit...
instruction
0
26,788
14
53,576
No
output
1
26,788
14
53,577
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Winters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order a pizza and call girls. The phone numbers in the city consist of three pairs of digit...
instruction
0
26,789
14
53,578
No
output
1
26,789
14
53,579
Provide tags and a correct Python 3 solution for this coding contest problem. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another. ...
instruction
0
26,844
14
53,688
Tags: brute force, dfs and similar Correct Solution: ``` import sys input=sys.stdin.readline from collections import defaultdict class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: ...
output
1
26,844
14
53,689
Provide tags and a correct Python 3 solution for this coding contest problem. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another. ...
instruction
0
26,845
14
53,690
Tags: brute force, dfs and similar Correct Solution: ``` import sys sys.setrecursionlimit(100000) def solve(): n, x, = rv() x -= 1 a, = rl(1) a = [val - 1 for val in a] nxt = [True] * n index = [-1] * n for i in range(len(a)): index[i] = get(i, a, nxt) curindex = index[x] - 1 ...
output
1
26,845
14
53,691
Provide tags and a correct Python 3 solution for this coding contest problem. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another. ...
instruction
0
26,846
14
53,692
Tags: brute force, dfs and similar Correct Solution: ``` import math import sys from bisect import bisect_right, bisect_left, insort_right from collections import Counter, defaultdict from heapq import heappop, heappush from itertools import accumulate, permutations from sys import stdout R = lambda: map(int, input()....
output
1
26,846
14
53,693
Provide tags and a correct Python 3 solution for this coding contest problem. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another. ...
instruction
0
26,847
14
53,694
Tags: brute force, dfs and similar Correct Solution: ``` n, x = map(int, input().split()) link1 = list(map(int, input().split())) link2 = [0] * (n + 1) for i, v in enumerate(link1, 1): if v != 0: link2[v] = i table = [False] * n table[0] = True for i, v in enumerate(link1, 1): if v == 0: len =...
output
1
26,847
14
53,695
Provide tags and a correct Python 3 solution for this coding contest problem. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another. ...
instruction
0
26,848
14
53,696
Tags: brute force, dfs and similar Correct Solution: ``` #!/usr/bin/env python3 # -*- coding: utf-8 -*- import collections def find(parents, i): if parents[i] == i: return i result = find(parents, parents[i]) parents[i] = result return result def union(parents, i, j): i, j = find(paren...
output
1
26,848
14
53,697
Provide tags and a correct Python 3 solution for this coding contest problem. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another. ...
instruction
0
26,849
14
53,698
Tags: brute force, dfs and similar Correct Solution: ``` import sys sys.setrecursionlimit(100000) def solve(): n, x, = rv() x -= 1 a, = rl(1) a = [val - 1 for val in a] nxt = [True] * n index = [-1] * n for i in range(len(a)): index[i] = get(i, a, nxt) curindex = index[x] - 1 ...
output
1
26,849
14
53,699
Provide tags and a correct Python 3 solution for this coding contest problem. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another. ...
instruction
0
26,850
14
53,700
Tags: brute force, dfs and similar Correct Solution: ``` def f(x, p): q = [] while x: q.append(x) x = p[x] return q from collections import defaultdict n, k = map(int, input().split()) t = list(map(int, input().split())) p = [0] * (n + 1) for i, j in enumerate(t, 1): p[j] = i p = [f(i, p...
output
1
26,850
14
53,701
Provide tags and a correct Python 3 solution for this coding contest problem. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in the clinic, running from one queue to another. ...
instruction
0
26,851
14
53,702
Tags: brute force, dfs and similar Correct Solution: ``` def put(): return map(int, input().split()) n,x = put() a = list(put()) parent = list(range(n+1)) for i in range(n): if a[i]!=0: parent[a[i]] = i+1 cnt = [] z = 0 #print(parent) for i in range(n): if a[i]==0: j = i+1 c = 1 ...
output
1
26,851
14
53,703
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in t...
instruction
0
26,852
14
53,704
Yes
output
1
26,852
14
53,705
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in t...
instruction
0
26,853
14
53,706
Yes
output
1
26,853
14
53,707
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in t...
instruction
0
26,854
14
53,708
No
output
1
26,854
14
53,709
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in t...
instruction
0
26,855
14
53,710
No
output
1
26,855
14
53,711
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in t...
instruction
0
26,856
14
53,712
No
output
1
26,856
14
53,713
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In the rush of modern life, people often forget how beautiful the world is. The time to enjoy those around them is so little that some even stand in queues to several rooms at the same time in t...
instruction
0
26,857
14
53,714
No
output
1
26,857
14
53,715
Provide tags and a correct Python 3 solution for this coding contest problem. Anya loves to fold and stick. Today she decided to do just that. Anya has n cubes lying in a line and numbered from 1 to n from left to right, with natural numbers written on them. She also has k stickers with exclamation marks. We know tha...
instruction
0
26,916
14
53,832
Tags: binary search, bitmasks, brute force, dp, math, meet-in-the-middle Correct Solution: ``` fact = [ 1 ] for i in range( 1, 20, 1 ): fact.append( fact[ i - 1 ] * i ) from collections import defaultdict N, K, S = map( int, input().split() ) A = list( map( int, input().split() ) ) ldp = [ [ defaultdict( int ) for...
output
1
26,916
14
53,833
Provide tags and a correct Python 3 solution for this coding contest problem. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too. Each shark will grow some number of flowers ...
instruction
0
26,969
14
53,938
Tags: combinatorics, math, number theory, probabilities Correct Solution: ``` n,m=map(int,input().split()) def f(): a,b=map(int,input().split()) return(b//m-(a-1)//m)/(b-a+1) a=[f() for _ in range(n)] r=0 for i in range(n): r+=1-(1-a[i])*(1-a[(i+1)%n]) print(r*2000) ```
output
1
26,969
14
53,939
Provide tags and a correct Python 3 solution for this coding contest problem. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too. Each shark will grow some number of flowers ...
instruction
0
26,970
14
53,940
Tags: combinatorics, math, number theory, probabilities Correct Solution: ``` N, p = map(int, input().split()) l = [0 for i in range(N+1)] r = [0 for i in range(N+1)] for i in range(N): lx, rx = map(int, input().split()) l[i] = lx; r[i] = rx l[N] = l[0]; r[N] = r[0] a1 = r[0] // p - (l[0] - 1) // p n1 = r[0] -...
output
1
26,970
14
53,941
Provide tags and a correct Python 3 solution for this coding contest problem. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too. Each shark will grow some number of flowers ...
instruction
0
26,971
14
53,942
Tags: combinatorics, math, number theory, probabilities Correct Solution: ``` from math import floor,ceil def mults(a,b,n): return max(floor(b/n)-ceil(a/n)+1,0) def prob(a,b,n): return 1-(mults(a,b,n))/(b-a+1) ans=0 n,p=(map(int,input().split())) firststart,firstend=(map(int,input().split())) prevstart=firststa...
output
1
26,971
14
53,943
Provide tags and a correct Python 3 solution for this coding contest problem. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too. Each shark will grow some number of flowers ...
instruction
0
26,972
14
53,944
Tags: combinatorics, math, number theory, probabilities Correct Solution: ``` n,p=map(int,input().split()) z=1 a=[] b=[] for i in range(0,n): x,y=map(int,input().split()) a.append(int(y/p)-int((x-1)/p)) b.append(y-x+1) ans=0 for i in range (0,n): pz=a[(i+1)%n] z=b[(i+1)%n] py=a[i] y=b[i] ...
output
1
26,972
14
53,945
Provide tags and a correct Python 3 solution for this coding contest problem. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too. Each shark will grow some number of flowers ...
instruction
0
26,973
14
53,946
Tags: combinatorics, math, number theory, probabilities Correct Solution: ``` n, p = [int(x) for x in input().split()] Arr = [] for i in range(n): tmp1, tmp2 = [int(x) for x in input().split()] cnt = tmp2 // p - (tmp1 - 1) // p Arr.append(cnt / (tmp2 - tmp1 + 1)) Arr.append(Arr[0]) ans = 0.0 for i in range(n...
output
1
26,973
14
53,947
Provide tags and a correct Python 3 solution for this coding contest problem. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too. Each shark will grow some number of flowers ...
instruction
0
26,974
14
53,948
Tags: combinatorics, math, number theory, probabilities Correct Solution: ``` n, p = map(int, input().split()) def prob(l, r, p): a = l % p b = r % p n = (r - l) // p if a > b or a == 0 or b == 0: n += 1 return n / (r - l + 1) pr = list() for i in range(n): l, r = map(int, input().sp...
output
1
26,974
14
53,949
Provide tags and a correct Python 3 solution for this coding contest problem. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too. Each shark will grow some number of flowers ...
instruction
0
26,975
14
53,950
Tags: combinatorics, math, number theory, probabilities Correct Solution: ``` #!/usr/bin/env python3 # 621C_flowers.py - Codeforces.com/problemset/problem/621/C by Sergey 2016 import unittest import sys ############################################################################### # Flowers Class (Main Program) ####...
output
1
26,975
14
53,951
Provide tags and a correct Python 3 solution for this coding contest problem. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too. Each shark will grow some number of flowers ...
instruction
0
26,976
14
53,952
Tags: combinatorics, math, number theory, probabilities Correct Solution: ``` n, p = map(int, input().split()) prob = [0.0] * n for i in range(n): l, r = map(int, input().split()) prob[i] = 1.0 - (r // p - (l - 1) // p) / (r - l + 1) ans = 0.0 for i in range(n-1): ans += (1.0 - prob[i] * prob[i+1]) * 2000 ans +=...
output
1
26,976
14
53,953
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too...
instruction
0
26,977
14
53,954
Yes
output
1
26,977
14
53,955
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too...
instruction
0
26,978
14
53,956
Yes
output
1
26,978
14
53,957
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too...
instruction
0
26,979
14
53,958
Yes
output
1
26,979
14
53,959
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too...
instruction
0
26,980
14
53,960
Yes
output
1
26,980
14
53,961
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too...
instruction
0
26,981
14
53,962
No
output
1
26,981
14
53,963
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too...
instruction
0
26,982
14
53,964
No
output
1
26,982
14
53,965
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too...
instruction
0
26,983
14
53,966
No
output
1
26,983
14
53,967
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i and i + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too...
instruction
0
26,984
14
53,968
No
output
1
26,984
14
53,969
Provide tags and a correct Python 3 solution for this coding contest problem. Arpa is researching the Mexican wave. There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. * At time 1, the first spectator stands. * At time 2, the second spectator stands. * ... * ...
instruction
0
27,065
14
54,130
Tags: implementation, math Correct Solution: ``` n, k, t = (int(x) for x in input().split()) if t <= k: print(t) elif t >= n: print(n + k - t) else: print(k) ```
output
1
27,065
14
54,131
Provide tags and a correct Python 3 solution for this coding contest problem. Arpa is researching the Mexican wave. There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. * At time 1, the first spectator stands. * At time 2, the second spectator stands. * ... * ...
instruction
0
27,066
14
54,132
Tags: implementation, math Correct Solution: ``` # -*- coding: utf-8 -*- """ Created on Thu Sep 19 16:14:03 2019 @author: sihan """ n,k,t=map(int,input().split()) print(min(t,n)-max(0,t-k)) ```
output
1
27,066
14
54,133
Provide tags and a correct Python 3 solution for this coding contest problem. Arpa is researching the Mexican wave. There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. * At time 1, the first spectator stands. * At time 2, the second spectator stands. * ... * ...
instruction
0
27,067
14
54,134
Tags: implementation, math Correct Solution: ``` n,k,t=map(int,input().split()) if(t<k): print(t) elif(t<n): print(k) else: print(k-(t-n)) ```
output
1
27,067
14
54,135
Provide tags and a correct Python 3 solution for this coding contest problem. Arpa is researching the Mexican wave. There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. * At time 1, the first spectator stands. * At time 2, the second spectator stands. * ... * ...
instruction
0
27,068
14
54,136
Tags: implementation, math Correct Solution: ``` n,k,t = map(int, input().split()) print(t if t<=k else k if t<=n else k-(t%n)) ```
output
1
27,068
14
54,137
Provide tags and a correct Python 3 solution for this coding contest problem. Arpa is researching the Mexican wave. There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. * At time 1, the first spectator stands. * At time 2, the second spectator stands. * ... * ...
instruction
0
27,069
14
54,138
Tags: implementation, math Correct Solution: ``` import sys def num_spectators_standing(n,k,t): #print(n,k,t) if n>=t>=k: return k if t<k: return t if t>n: return k-(t-n) def main(): n,k,t = map(int, sys.stdin.readline().strip().split(' ')) print(num_spectators_standing(n,k,t)) assert num_...
output
1
27,069
14
54,139
Provide tags and a correct Python 3 solution for this coding contest problem. Arpa is researching the Mexican wave. There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. * At time 1, the first spectator stands. * At time 2, the second spectator stands. * ... * ...
instruction
0
27,070
14
54,140
Tags: implementation, math Correct Solution: ``` l = input().split() n = int(l[0]) k = int(l[1]) t = int(l[2]) stand = 0 if t <= k: stand = t elif t > k and t <= n: stand = k else: stand = k - (t - n) print(stand) ```
output
1
27,070
14
54,141
Provide tags and a correct Python 3 solution for this coding contest problem. Arpa is researching the Mexican wave. There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. * At time 1, the first spectator stands. * At time 2, the second spectator stands. * ... * ...
instruction
0
27,071
14
54,142
Tags: implementation, math Correct Solution: ``` n , k , t = list(map(int,input().split())) if t<=k: print(t) elif k<=t<=n: print(k) elif n<=t<n+k: print(n+k-t) ```
output
1
27,071
14
54,143
Provide tags and a correct Python 3 solution for this coding contest problem. Arpa is researching the Mexican wave. There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. * At time 1, the first spectator stands. * At time 2, the second spectator stands. * ... * ...
instruction
0
27,072
14
54,144
Tags: implementation, math Correct Solution: ``` [n, k, t] = [int(x) for x in input().split()] if t <= k: print(t) elif k <= t <= n: print(k) else: print(k+n-t) ```
output
1
27,072
14
54,145
Provide tags and a correct Python 3 solution for this coding contest problem. Petya sometimes has to water his field. To water the field, Petya needs a tank with exactly V ml of water. Petya has got N tanks, i-th of them initially containing ai ml of water. The tanks are really large, any of them can contain any amou...
instruction
0
27,091
14
54,182
Tags: dp, greedy, implementation Correct Solution: ``` import sys n, k, v = map(int, input().split()) a = list(map(int, input().split())) total = sum(a) if total < v: print('NO') exit() dp = [[0]*k for _ in range(n+1)] prev = [[-1]*(k+1) for _ in range(n+1)] dp[0][0] = 1 for i in range(n): for j in range...
output
1
27,091
14
54,183
Provide a correct Python 3 solution for this coding contest problem. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will a...
instruction
0
27,218
14
54,436
"Correct Solution: ``` n, s = int(input()), input() ans, e, w = n, s.count('E'), 0 for i in s: if i == 'E': e -= 1 ans = min(ans, e + w) if i == 'W': w += 1 print(ans) ```
output
1
27,218
14
54,437
Provide a correct Python 3 solution for this coding contest problem. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will a...
instruction
0
27,219
14
54,438
"Correct Solution: ``` n = int(input()) s = list(input()) c = s[1:].count("E") ans = c for i in range(1, n): c -= (1 if s[i] == "E" else 0) c += (1 if s[i - 1] == "W" else 0) ans = min(c, ans) print(ans) ```
output
1
27,219
14
54,439
Provide a correct Python 3 solution for this coding contest problem. There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will a...
instruction
0
27,221
14
54,442
"Correct Solution: ``` n = int(input()) s = str(input()) W = [0] for i in range(n): if s[i] == "W": W.append(W[-1]+1) else: W.append(W[-1]) ans = n for i in range(n+1): ans = min(ans,W[i] + (n-i)-(W[-1] - W[i])) print(ans) ```
output
1
27,221
14
54,443