Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from math import factorial

N, K = map(int, input().split())

if N-K+1 > K:
    p = K
    for i in range(1, p+1):
        a = factorial(N-K+1) / factorial(N-K+1-i) / factorial(i) * factorial(K-1) / factorial(K-i) / factorial(i-1)
        print(int(a%1000000007))
        
else:
    p = N-K+1
    for i in range(1, p+1):
        a = factorial(N-K+1) / factorial(N-K+1-i) / factorial(i) * factorial(K-1) / factorial(K-i) / factorial(i-1)
        print(int(a%1000000007))
    
    for i in range(N-K+2, K+1):
        print(0)


Fixed submission:

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N, K = map(int, input().split())

if N-K+1 > K:
    p = K
    for i in range(1, p+1):
        a = cmb(N-K+1, i) * cmb(K-1, i-1)
        print(int(a%1000000007))
else:
    p = N-K+1
    for i in range(1, p+1):
        a = cmb(N-K+1, i) * cmb(K-1, i-1)
        print(int(a%1000000007))
            
    for i in range(N-K+2, K+1):
        print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
h = list(map(int,input().split()))
inf = float("inf")
dp = [0]+[inf]*(n-1)

for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(abs(h[i]-h[j])+dp[j], dp[i])

print(dp[n-1])    

Fixed submission:
n, k = map(int,input().split())
h = list(map(int,input().split()))
inf = float("inf")
dp = [0]+[inf]*(n-1)

for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(abs(h[i]-h[j])+dp[j], dp[i])

print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n, k = map(int,input().split())
h = list(map(int,input().split()))
inf = float("inf")
dp = [inf]*(n+1)
if n == 2:
    print(abs(h[1]-h[0]))
    sys.exit()

for i in range(1, k+1):
    dp[i] = abs(h[i]-h[0])

for i in range(2,n):
    for j in range(k+1):
        dp[i] = min(abs(h[i]-h[i-j])+dp[i-j], dp[i])

print(dp[n-1]) 

Fixed submission:
n, k = map(int,input().split())
h = list(map(int,input().split()))
inf = float("inf")
dp = [0]+[inf]*(n-1)

for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(abs(h[i]-h[j])+dp[j], dp[i])

print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, w = map(int,input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w+1) for _ in range(n+1)]

for i in range(1, n+1):
    for j in range(1, w+1):
        if wv[i-1][0] <= j:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i-1][0]] + wv[i-1][1])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[n][w])

Fixed submission:
n, w = map(int,input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w+1) for _ in range(n+1)]

for i in range(1, n+1):
    for j in range(1, w+1):
        if wv[i-1][0] <= j:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i-1][0]] + wv[i-1][1])
        else:
            dp[i][j] = dp[i-1][j]
print(dp[n][w])
Buggy python submission (verdict: Runtime Error):
N, M = map(int,input().split())
path = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a].append(b)

dp = [-1] * N

def chdp(x):
    if dp[x] != -1:
        return(dp[x]) 
    dp[x] = 0
    for t in path[x]:
        dp[x] = max(dp[x], chdp(t)+1)
    return(dp[x])

for i in range(N):
    chdp(i)

print(max(dp))

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 7)
N, M = map(int,input().split())
path = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    path[a].append(b)

dp = [-1] * N

def chdp(x):
    if dp[x] != -1:
        return(dp[x]) 
    dp[x] = 0
    for t in path[x]:
        dp[x] = max(dp[x], chdp(t)+1)
    return(dp[x])

for i in range(N):
    chdp(i)

print(max(dp))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
A = list(map(int,input().split()))
Acc = list(itertools.accumulate(A))
ans = 0
for i, j in itertools.combinations(Acc, 2):
    if i == j:
        ans += 1
for i in Acc:
    if i == 0:
        ans += 1
print(ans)

Fixed submission:
import itertools
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
Acc = list(itertools.accumulate(A))
ans = 0
for i in Counter([0]+Acc).values():
    ans += i*(i-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
A = list(map(int,input().split()))
Acc = list(itertools.accumulate(A))
ans = 0
for i, j in itertools.combinations(Acc, 2):
    if i == j:
        ans += 1
for i in Acc:
    if i == 0:
        ans += 1
print(ans)

Fixed submission:
import itertools
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
Acc = list(itertools.accumulate(A))
ans = 0
for i in Counter([0]+Acc).values():
    ans += i*(i-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split())) 

b = list(accumulate(a))
ma = b[-1]
mi = 10**10
for sunuke in b:
    arai = ma - sunuke
    if abs(sunuke - arai) < mi:
        mi = abs(sunuke - arai)
print(mi)

Fixed submission:
from itertools import accumulate

N = int(input())
a = list(map(int, input().split())) 

b = list(accumulate(a))
ma = b[-1]
mi = 10**10
for sunuke in b[:N-1]:
    arai = ma - sunuke
    if abs(sunuke - arai) < mi:
        mi = abs(sunuke - arai)
print(mi)

Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split())) 

b = list(accumulate(a))
ma = b[-1]
mi = 10**10
for sunuke in b:
    arai = ma - sunuke
    if abs(sunuke - arai) < mi:
        mi = abs(sunuke - arai)
print(mi)

Fixed submission:
from itertools import accumulate

N = int(input())
a = list(map(int, input().split())) 

b = list(accumulate(a))
ma = b[-1]
mi = 10**10
for sunuke in b[:N-1]:
    arai = ma - sunuke
    if abs(sunuke - arai) < mi:
        mi = abs(sunuke - arai)
print(mi)
Buggy python submission (verdict: Time Limit Exceeded):
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:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
N, K, L = map(int, input().split())
road = UnionFind(N)
train = UnionFind(N)
ans = []
for i in range(K):
    p, q = map(int, input().split())
    road.union(p-1, q-1)
for i in range(L):
    r, s = map(int, input().split())
    train.union(r-1, s-1)
for i in range(N):
    ans.append(len(set(road.members(i)) & set(train.members(i))))
print(*ans)

Fixed submission:
import collections
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:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
N, K, L = map(int, input().split())
road = UnionFind(N)
train = UnionFind(N)
pair = []
ans = []
for i in range(K):
    p, q = map(int, input().split())
    road.union(p-1, q-1)
for i in range(L):
    r, s = map(int, input().split())
    train.union(r-1, s-1)
for i in range(N):
    pair.append((road.find(i), train.find(i)))
c = collections.Counter(pair)
for i in range(N):
    ans.append(c[(road.find(i), train.find(i))])
print(*ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))

m = 1000
k = 0

for i in range(n):
    if A[i] <= m and A[i] == min(A) and i != n-1:
        # 全体で最安なら買い
        k = m//A[i]
        m = m- A[i]*k
    elif A[i] < m and A[i] < max(A[i::]) and i != n-1:
        # 今後、現在の株価より高い株価があれば買い
        k = m//A[i]
        m = m - A[i]*k
    elif 0 < k and A[i] == max(A):
        # 全体で最高なら売り
        m = m + A[i]*k
        k = 0
    elif 0 < k and A[i] != min(A[i::]):
        # 今後、現在の株価より安い株価があれば売り
        m = m + A[i]*k
        k = 0
    elif 0 < k and A[i] == max(A[i::])
        # 今後、現在より高い株価がなければ売り
        m = m + A[i]*k
        k = 0
    else:
        pass

print (m)


Fixed submission:
n = int(input())
A = list(map(int,input().split()))
l = []

m = 1000
k = 0

for i in range(n):
    if i == n-1: # 最後ながら全部売る
        m = m + A[i]*k
    elif A[i] <= m and A[i] < A[i+1]: #お金あって明日上がるなら買う
        k = m//A[i]
        m = m - A[i]*k
    elif 0 < k and A[i+1] < A[i]: #株があって明日下がるなら売る
        m = m + A[i]*k
        k = 0
    else:
        pass

print (m)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

for x in range(1,n+1):
    ans = 0
    found = []
    for i in range(1,33):
        if i in found:
            break
        for j in range(i,33):
            for k in range(j,33):
                if i**2 + j**2 + k**2 + i*j + j*k + k*i == x:
                    ans += 3**(len(set([i,j,k]))-1)
                    found.append(i)
                    found.append(j)
                    found.append(k)

                elif x < i**2 + j**2 + k**2 + i*j + j*k + k*i:
                    break
                else:
                    pass
    print (ans)


Fixed submission:
n = int(input())

ans = [0 for _ in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if v < 10050:
                ans[v] += 1

for i in range(n):
    print (ans[i+1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
s = sum(A)
Q = int(input())
for _ in range(Q):
    B,C = map(int,input().split())
    if B in A:
        c = A.count(B)
        A = [C if i == B else i for i in A]
        s = s-((B-C)*c)

    print (s)


Fixed submission:
n = int(input())
A = {}
a = list(map(int,input().split()))
for i in a:
    if not i in A:
        A[i] = 1
    else:
        A[i] += 1

s = 0
for k,v in A.items():
    s += k*v

Q = int(input())
for _ in range(Q):
    b,c = map(int,input().split())
    if b in A:
        s = s-(b-c)*A[b]
        if not c in A:
            A[c] = A[b]
        else:
            A[c] += A[b]
        A[b] = 0

    print (s)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
Q = int(input())
for _ in range(Q):
    B,C = map(int,input().split())
    A = [C if i == B else i for i in A]
    print (sum(A))


Fixed submission:
n = int(input())
A = {}
a = list(map(int,input().split()))
for i in a:
    if not i in A:
        A[i] = 1
    else:
        A[i] += 1

s = 0
for k,v in A.items():
    s += k*v

Q = int(input())
for _ in range(Q):
    b,c = map(int,input().split())
    if b in A:
        s = s-(b-c)*A[b]
        if not c in A:
            A[c] = A[b]
        else:
            A[c] += A[b]
        A[b] = 0

    print (s)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
for i in range(1,n+1):
    print (A.count(i))


Fixed submission:
n = int(input())
A = sorted(list(map(int,input().split())))
d = {}
for i in range(1,n+1):
    d[i] = 0

for v in A:
    d[v] += 1

for v in d.values():
    print (v)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())

import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

total = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            total += gcd(a,b,c)
print (total)


Fixed submission:
k = int(input())

import math
#from functools import reduce
#def gcd(*numbers):
#    return reduce(math.gcd, numbers)

total = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        tmp = math.gcd(a,b)
        for c in range(1,k+1):
            total += math.gcd(tmp,c)
print (total)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    total = 0
    x = a.copy()
    del x[i]
    x = collections.Counter(x)
    for v in x.values():
        total += v*(v-1)//2
    print (total)


Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
l = [0]*n
ans = 0

for k,v in collections.Counter(a).items():
    l[k-1] = v
    ans += v*(v-1)//2

for i in range(n):
    print (ans-l[a[i]-1]+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b = map(int,input().split())
l = []
while True:
    for _ in range(a):
        l.append("r")
    for _ in range(b):
        l.append("b")

    if len(l) >= n:
        print(l[0:n].count("r"))
        exit ()

Fixed submission:
n,a,b = map(int,input().split())
x = -(-n//(a+b))
total = (a+b)*(x-1)
total_a = a*(x-1)
if n - total >= a:
    print (total_a + a)
else:
    print (total_a + (n-total))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1
ans = [k for k, v in d.items() if v == max(d.values())]
print('\n'.join(map(str, sorted(ans))))


Fixed submission:
n = int(input())
d = {}
for _ in range(n):
    s = input()
    if not s in d:
        d[s] = 1
    else:
        d[s] += 1
d_max = max(d.values())
ans = [k for k, v in d.items() if v == d_max]
for a in sorted(ans):
    print (a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = [int(e) for e in input().split()]
count=0
p_min=p[0]

for i in range(n):
    if p[i] <= p_min:
        count+=1
        p_min=min(p[0:i+1])

print (count)

Fixed submission:
n = int(input())
p = [int(e) for e in input().split()]
count=0
p_min=p[0]

for i in range(n):
    if p[i] <= p_min:
        count+=1
#        p_min=min(p[0:i+1])
        p_min=p[i]

print (count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = [int(e) for e in input().split()]
count=0

for i in range(n):
    ng=True
    for j in range(i):
        if p[i] > p[j]:
            ng=False
            break

    if ng:
        count+=1

print (count)

Fixed submission:
n = int(input())
p = [int(e) for e in input().split()]
count=0
p_min=p[0]

for i in range(n):
    if p[i] <= p_min:
        count+=1
#        p_min=min(p[0:i+1])
        p_min=p[i]

print (count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))	
count=0

for i in range(n):
    if p[i] <= min(p[0:i+1]):
        count+=1

print (count)


Fixed submission:
n = int(input())
p = [int(e) for e in input().split()]
count=0
p_min=p[0]

for i in range(n):
    if p[i] <= p_min:
        count+=1
#        p_min=min(p[0:i+1])
        p_min=p[i]

print (count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))	
count=0

for i in range(n):
    ng=True
    for j in range(i+1):
        if p[j] < p[i]:
            ng=False
            break
    if ng:
        count+=1
        continue

print (count)

Fixed submission:
n = int(input())
p = [int(e) for e in input().split()]
count=0
p_min=p[0]

for i in range(n):
    if p[i] <= p_min:
        count+=1
#        p_min=min(p[0:i+1])
        p_min=p[i]

print (count)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int, input().split())
l=[]
for _ in range (0,m):
    l.append(input())
wa_total=0
ac_total=0
ac_list=[]

for value in l:
    if str(value.split()[1]) == "AC":
        if not str(value.split()[0]) in ac_list:
            ac_list.append(str(value.split()[0]))
            for i in range(0,l.index(value)):
                if l[i].split()[0] == value.split()[0]:
                    if l[i].split()[1] == "WA":
                        wa_total+=1
            l.remove(value)

print (len(ac_list), wa_total)

Fixed submission:
n,m = map(int,input().split())
ac = 0
wa = 0
wa_d = {}
ac_d = {}
for i in range(1,n+1):
    ac_d[str(i)] = False
    wa_d[str(i)] = 0

for _ in range(m):
    p,s = input().split()
    if s == "AC":
        if ac_d[p]:
            pass
        else:
            wa += wa_d[p]
            ac += 1
            ac_d[p] = True 
    else:
        wa_d[p] += 1

print (ac,wa)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
l=[]
for _ in range (0,m):
    l.append(input())
if m == 0:
    print ("0 0")
    exit (0)

wa_total=0
ac_total=0
ac_list=[]

for i in range(0,m):
    if str(l[i].split()[1]) == "AC":
        if not str(l[i].split()[0]) in ac_list:
            ac_list.append(str(l[i].split()[0]))
            ac_total+=1
            for j in range(0,i):
                if int(l[j].split()[0]) == int(l[i].split()[0]):
                    if str(l[j].split()[1]) == "WA":
                        wa_total+=1

print (ac_total, wa_total)

Fixed submission:
n,m = map(int,input().split())
ac = 0
wa = 0
wa_d = {}
ac_d = {}
for i in range(1,n+1):
    ac_d[str(i)] = False
    wa_d[str(i)] = 0

for _ in range(m):
    p,s = input().split()
    if s == "AC":
        if ac_d[p]:
            pass
        else:
            wa += wa_d[p]
            ac += 1
            ac_d[p] = True 
    else:
        wa_d[p] += 1

print (ac,wa)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import OrderedDict
n,m = map(int, input().split())
p=OrderedDict()
s=OrderedDict()
for i in range (0,m):
    p[i], s[i] = map(str, input().split())

if m == 0:
    print ("0 0")
    exit (0)

wa_total=0
ac_total=0
ac_list=[]
for i in range(0,m):
    if s[i] == "AC":
        if not p[i] in ac_list:
            ac_list.append(p[i])
            ac_total+=1
            for j in range(0,i):
                if p[j] == p[i]:
                    if s[j] == "WA":
                        wa_total+=1

print (ac_total, wa_total)

Fixed submission:
n,m = map(int,input().split())
ac = 0
wa = 0
wa_d = {}
ac_d = {}
for i in range(1,n+1):
    ac_d[str(i)] = False
    wa_d[str(i)] = 0

for _ in range(m):
    p,s = input().split()
    if s == "AC":
        if ac_d[p]:
            pass
        else:
            wa += wa_d[p]
            ac += 1
            ac_d[p] = True 
    else:
        wa_d[p] += 1

print (ac,wa)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
count = 0
for i in range(0,n):
    if s[i] == "A":
        if i+2 <= n:
            if s[i+1] == "B" and s[i+2] == "C":
                count += 1
print (count)

Fixed submission:
n = int(input())
s = str(input())
count = 0
for i in range(0,n):
    if s[i] == "A":
        if i+2 <= n-1:
            if s[i+1] == "B" and s[i+2] == "C":
                count += 1
print (count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
count = 0
for i in range(0,len(s)):
    if s[i] == "A":
        if i+2 <= len(s):
            if s[i+1] == "B" and s[i+2] == "C":
                count += 1
print (count)

Fixed submission:
n = int(input())
s = str(input())
count = 0
for i in range(0,n):
    if s[i] == "A":
        if i+2 <= n-1:
            if s[i+1] == "B" and s[i+2] == "C":
                count += 1
print (count)
Buggy python submission (verdict: Runtime Error):
print (int(input)**2)


Fixed submission:
print(int(input())**2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = sorted(list(map(int,input().split())),reverse=True)
#print (l)

ans = 0
for i in range(n-1):
    for j in range(i+1,n):
#        print (l[i],l[j],l[j+1::],[x for x in l[j+1::] if x < l[i]+l[j] and l[i] < x+l[j] and l[j] < x+l[i]])
        ans += len([x for x in l[j+1::] if x < l[i]+l[j] and l[i] < x+l[j] and l[j] < x+l[i]])


print (ans)


Fixed submission:
import bisect
n = int(input())
l = sorted(list(map(int,input().split())))

ans = 0
for i in range(n-1,1,-1):
    for j in range(i-1,0,-1):
        x = j - bisect.bisect(l,l[i]-l[j])
        if x>0:
            ans += x

print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
l = list(map(int,input().split()))
ans = 0

p = itertools.combinations(l,3)
for v in p:
    if v[0] < v[1] + v[2] and v[1] < v[0] + v[2] and v[2] < v[0] + v[1]:
        ans += 1

print (ans)


Fixed submission:
import bisect
n = int(input())
l = sorted(list(map(int,input().split())))

ans = 0
for i in range(n-1,1,-1):
    for j in range(i-1,0,-1):
        x = j - bisect.bisect(l,l[i]-l[j])
        if x>0:
            ans += x

print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(1,n+1):
    ans.append(A.index(i)+1)

print(' '.join(map(str, ans)))


Fixed submission:
n = int(input())
A = list(map(int,input().split()))
d = {}
for i,a in zip(range(1,n+1),A):
    d[a] = i
d = sorted(d.items())

for t in d:
    print (t[1], end=" ")
Buggy python submission (verdict: Runtime Error):
s = input()
if s[0] = "S":
    print ("Cloudy")
elif s[0] = "C":
    print ("Rainy")
else:
    print ("Sunny")


Fixed submission:
s = input()
if s[0] == "S":
    print ("Cloudy")
elif s[0] == "C":
    print ("Rainy")
else:
    print ("Sunny")
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
d = {}
for i in range(1,n+1):
    d[i] = k

def s (x:int):
    for k,v in d.items():
        if k == x:
            pass
        else:
            d[k] = v-1

for _ in range(q):
    a = int(input())
    s (a)

for v in d.values():
    if 0 < v:
        print ("Yes")
    else:
        print ("No")


Fixed submission:
n,k,q = map(int,input().split())

d = {}
for _ in range(q):
    a = int(input())
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

for i in range(1,n+1):
    if not i in d:
        if q < k:
            print ("Yes")
        else:
            print ("No")
    else:
        if k <= q-d[i]:
            print ("No")
        else:
            print ("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
for _ in range(q):
    l,r = map(int,input().split())
    print (s[l-1:r].count('AC'))


Fixed submission:
n,q = map(int,input().split())
s = input()

t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)

#print (t)

for _ in range(q):
    l,r = map(int,input().split())
    print (t[r-1]-t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q = map(int,input().split())
s = input()
for _ in range(q):
    l,r = map(int,input().split())
    print (s[l-1:r].count("AC"))


Fixed submission:
n,q = map(int,input().split())
s = input()

t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2] == 'AC' else 0)

#print (t)

for _ in range(q):
    l,r = map(int,input().split())
    print (t[r-1]-t[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0

while True:
    p_len_s = len(s)
    for i in range(len(s)):
        if i == 0:
            pass
        else:
            if (s[i] == '0' and s[i-1] == '1') or (s[i] == '1' and s[i-1] == '0'):
                s = s[0:i-1] + s[i+1::]
                ans += 2

                if len(s) < 2:
                    print (ans)
                    exit ()

                if s == '10' or s == '01':
                    print (ans+2)
                    exit ()

                break

    a_len_s = len(s)
    if p_len_s == a_len_s:
        print (ans)
        exit ()


Fixed submission:
s = list(input())
print (min(s.count('0'), s.count('1'))*2)