Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for i in range(N)]
maxa=max(A)
for i in range(N):
  if A[i]==maxa:
    tmp=max(A[:i]+A[i+1:])
    print(tmp)
  else:
    print(maxa)

Fixed submission:
N=int(input())
A=[int(input()) for i in range(N)]
maxa=max(A)
id=A.index(maxa)
for i in range(N):
  if i==id:
    tmp=max(A[:i]+A[i+1:])
    print(tmp)
  else:
    print(maxa)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import sys
input = sys.stdin.readline
N = int(input())
A = [int(input()) for i in range(N)]
B = [A[0]]
tmp = [0]*N
ans = 1
for i in range(1, N):
    id = bisect.bisect_left(B, A[i])
    if id == 0:
        bisect.insort_left(B, A[i])
    else:
        B[id-1] = A[i]
print(len(B))


Fixed submission:
import bisect
import sys
import collections
input = sys.stdin.readline
N = int(input())
A = [int(input()) for i in range(N)]
B = [A[0]]
B = collections.deque(B)
tmp = [0]*N
ans = 1
for i in range(1, N):
    id = bisect.bisect_left(B, A[i])
    if id == 0:
        B.appendleft(A[i])
    else:
        B[id-1] = A[i]
print(len(B))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
A = [int(input()) for i in range(N)]
B = [A[0]]
tmp = [0]*N
ans = 1
for i in range(1, N):
    id = bisect.bisect_left(B, A[i])
    if id == 0:
        bisect.insort_left(B, A[i])
    else:
        B[id-1] = A[i]
print(len(B))


Fixed submission:
import bisect
import sys
import collections
input = sys.stdin.readline
N = int(input())
A = [int(input()) for i in range(N)]
B = [A[0]]
B = collections.deque(B)
tmp = [0]*N
ans = 1
for i in range(1, N):
    id = bisect.bisect_left(B, A[i])
    if id == 0:
        B.appendleft(A[i])
    else:
        B[id-1] = A[i]
print(len(B))
Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)

for i in range(1, N):
    table[a[i]] = i

ans = [-1]*N
ans[0] = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] != i:
        ans[1] = a[0] ^ a[i]
        ans[2] = a[i]
        del(table[ans[1]])
        del(table[ans[2]])
        break
if ans[1] == -1:
    print("No")
    exit(0)

for i in range(3, N):
    if (ans[i-1] ^ ans[i-2]) in table and table[ans[i-1] ^ ans[i-2]] != i-2 and table[ans[i-1] ^ ans[i-2]] != i-1:
        ans[i] = ans[i-1] ^ ans[i-2]
        del(table[ans[i]])
    else:
        print("No")
        exit(0)
print("Yes")


Fixed submission:
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)

for i in range(1, N):
    table[a[i]] += 1

ans = [-1]*N
ans[0] = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] >= 1:
        if a[0] == 0:
            if table[a[i]] == 1:
                continue
        ans[1] = (a[0] ^ a[i])
        ans[2] = a[i]
        table[ans[1]] -= 1
        table[ans[2]] -= 1
        break

if ans[1] == -1:
    print("No")
    exit(0)

for i in range(3, N):
    if (ans[i-1] ^ ans[i-2]) in table and table[ans[i-1] ^ ans[i-2]] >= 1 and table[ans[i-1] ^ ans[i-2]] >= 1:

        ans[i] = ans[i-1] ^ ans[i-2]
        table[ans[i]] -= 1
    else:
        print("No")
        exit(0)
print("Yes")

Buggy python submission (verdict: Runtime Error):
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)
for i in range(1, N):
    table[a[i]] += 2
a.sort()
prev = a[0]
now = a[0]
last = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] > 0:
        table[a[0] ^ a[i]] -= 1
        last = a[i]
        now = a[0] | a[i]
        break
	if i == N-1:
      print("No")
      exit(0)
for i in range(2, N-2):
    if prev ^ now in table and table[now ^ prev] > 0:
        prev = now
        now = now ^ prev
        table[now ^ prev] -= 1
    else:
        print("No")
        exit(0)
if (last ^ now) == a[0]:
    print("Yes")
else:
    print("No")


Fixed submission:
import collections
N = int(input())
a = list(map(int, input().split()))
A = set()
table = collections.defaultdict(int)

for i in range(1, N):
    table[a[i]] += 1

ans = [-1]*N
ans[0] = a[0]
for i in range(1, N):
    if (a[0] ^ a[i]) in table and table[a[0] ^ a[i]] >= 1:
        if a[0] == 0:
            if table[a[i]] == 1:
                continue
        ans[1] = (a[0] ^ a[i])
        ans[2] = a[i]
        table[ans[1]] -= 1
        table[ans[2]] -= 1
        break

if ans[1] == -1:
    print("No")
    exit(0)

for i in range(3, N):
    if (ans[i-1] ^ ans[i-2]) in table and table[ans[i-1] ^ ans[i-2]] >= 1 and table[ans[i-1] ^ ans[i-2]] >= 1:

        ans[i] = ans[i-1] ^ ans[i-2]
        table[ans[i]] -= 1
    else:
        print("No")
        exit(0)
print("Yes")
Buggy python submission (verdict: Runtime Error):
N,A,B=map(input().split())
print(max(N*A,B))

Fixed submission:
N,A,B=map(int,input().split())
print(min(N*A,B))
Buggy python submission (verdict: Runtime Error):
N,D=map(int,input().split())
for i in range(N):
  X[i]=list(map(int,input().split()))
count=0
for i in range(N):
  for j in range(i,N):
    dis=0
    for k in range(D):
      dis += pow(X[i][k],2) + pow(X[j][k],2) 
    dis = sqrt(dis)
    if dis==int(dis):
      count+=1
print(count)

Fixed submission:
import math
N,D=map(int,input().split())
X=[0]*N
for i in range(N):
  X[i]=list(map(int,input().split()))
count=0
for i in range(N):
  for j in range(i,N):
    dis=0
    for k in range(D):
      dis += pow(X[i][k]-X[j][k],2) 
    dis = math.sqrt(dis)

    if dis==int(dis) and dis!=0:
      count+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
L,R = map(int,input().split())
ans = 2019
for i in range(L,R+1):
  for j in range(i+1,R+1):
    if (i*j)%2019 < ans:
      ans = (i*j) % 2019
      if ans == 0:
        break
print(ans)

Fixed submission:
L,R = map(int,input().split())
ans = 2019

if R*(R-1)<2019:
  print(R*(R-1))
  exit(0)
else:
  if R == L+1:
    print((R*L)%2019)
    exit(0)
  else:
    r =673 - L % 673
    if L+r <= R:
      print("0")
      exit(0)
    else:
      for i in range(L,R+1):
        for j in range(i+1,R+1):
          if (i*j)%2019 < ans:
            ans = (i*j) % 2019
            if ans == 0:
              break
print(ans)

Buggy python submission (verdict: Runtime Error):
L,R = map(int,input().split())
ans = 2019
for i in range(L,R+1):
  for j in range(i,R+1):
    if (i*j)%2019 < ans:
      ans = (i*J) % 2019
      if ans == 0:
        break
print(ans)

Fixed submission:
L,R = map(int,input().split())
ans = 2019

if R*(R-1)<2019:
  print(R*(R-1))
  exit(0)
else:
  if R == L+1:
    print((R*L)%2019)
    exit(0)
  else:
    r =673 - L % 673
    if L+r <= R:
      print("0")
      exit(0)
    else:
      for i in range(L,R+1):
        for j in range(i+1,R+1):
          if (i*j)%2019 < ans:
            ans = (i*j) % 2019
            if ans == 0:
              break
print(ans)
Buggy python submission (verdict: Runtime Error):
import fractions
import collections
N, K = map(int, input().split())
G = [set() for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)

q = collections.deque()
q.append((0))
ans = K
mod = 10**9+7
r = [True]*N
r[0] = False
while(q):
    x = q.popleft()
    tmp = K - 1
    if x > 0:
        tmp -= 1
    for y in G[x]:
        if r[y]:
            r[y] = False
            q.append(y)
            ans *= tmp
            tmp -= 1
    		ans %= mod
print(ans)


Fixed submission:
import collections
N,K=map(int,input().split())
G=[set() for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  G[a].add(b)
  G[b].add(a)
m=0
id=9
for i in range(N):
  if len(G[i])>m:
    id=i
    m = len(G[i])
q=collections.deque()
q.append(0)
colored=[False]*N
colored[0]=True
from math import factorial
mod = 10**9 + 7
ans = K
while(q):
  x= q.popleft()
  count=0
  for y in G[x]:
    if colored[y]:
      continue
    else:
      q.append(y)
      colored[y]=True
      count+=1
      
  for i in range(count):
    ans *= K-1-(len(G[x])-count)-i
    ans %= mod
  #print(ans,count,factorial(K-1-(len(G[x])-count)),factorial(count))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N, K = map(int, input().split())
G = [set() for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)

q = collections.deque()
q.append((0))
ans = K
mod = 10**9+7
r = [True]*N
r[0] = False
while(q):
    x = q.popleft()
    tmp = K - 1
    if x > 0:
        tmp -= 1
    for y in G[x]:
        if r[y]:
            r[y] = False
            q.append(y)
            ans *= tmp
            tmp -= 1
    ans %= mod
print(ans)


Fixed submission:
import collections
N,K=map(int,input().split())
G=[set() for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  G[a].add(b)
  G[b].add(a)
m=0
id=9
for i in range(N):
  if len(G[i])>m:
    id=i
    m = len(G[i])
q=collections.deque()
q.append(0)
colored=[False]*N
colored[0]=True
from math import factorial
mod = 10**9 + 7
ans = K
while(q):
  x= q.popleft()
  count=0
  for y in G[x]:
    if colored[y]:
      continue
    else:
      q.append(y)
      colored[y]=True
      count+=1
      
  for i in range(count):
    ans *= K-1-(len(G[x])-count)-i
    ans %= mod
  #print(ans,count,factorial(K-1-(len(G[x])-count)),factorial(count))
print(ans)
Buggy python submission (verdict: Runtime Error):
N,L=map(int,input().split())
if L >= 0:
  print(int((N-1)/2*(L + L + N)))
else:
  if L + N - 1 >= 0: 
    print(int(N / 2 * (L + L + N - 1)))
  else:
    print(int((N - 1)/ 2 * (L + L + N - 2)))


Fixed submission:
S=input()
for i in range(3):
  if S[i]==S[i+1]:
    print("Bad")
    exit(0)
print("Good")
Buggy python submission (verdict: Runtime Error):
(int,input().split())
if L >= 0:
  print(int((N-1)/2*(L + L + N )))
else:
  if L + N - 1 >= 0: 
    print(int(N / 2 * (L + L + N - 1)))
  else:
    print(int((N - 1)/ 2 * (L + L + N - 2)))


Fixed submission:
N,L=map(int,input().split())
if L >= 0:
  print(int((N-1)/2*(L + L + N)))
else:
  if L + N - 1 >= 0: 
    print(int(N / 2 * (L + L + N - 1)))
  else:
    print(int((N - 1)/ 2 * (L + L + N - 2)))

Buggy python submission (verdict: Runtime Error):
N,L=(int,input().split())
if L >= 0:
  print(int((N-1)/2*(L + L + N - 1)))
else:
  if L + N - 1 >= 0: 
    print(int(N / 2 * (L + L + N - 1)))
  else:
    print(int((N - 1)/ 2 * (L + L + N - 2)))


Fixed submission:
N,L=map(int,input().split())
if L >= 0:
  print(int((N-1)/2*(L + L + N)))
else:
  if L + N - 1 >= 0: 
    print(int(N / 2 * (L + L + N - 1)))
  else:
    print(int((N - 1)/ 2 * (L + L + N - 2)))
Buggy python submission (verdict: Runtime Error):
import fractions
A,B,C,D = map(int,input().split())

icm = C*D / fractions.gcd(C,D)
ans = (B - A + 1)
if A != B:
    if A % C == 0:
        ans -= int(B // C - A // C) + 1
    else:
        ans -= int(B // C - A // C)
    if A % D == 0:
        ans -= int(B // D - A // D) + 1
    else:
        ans -= int(B // D - A // D)

    if A % icm == 0:
        ans += int(B // icm - A // icm) + 1
    else:
        ans += int(B // icm - A // icm)
	print(int(ans))
else:
    if A % C == 0 or A % D == 0:
        print(0)
    else:
        print(1)


Fixed submission:
import fractions
A,B,C,D = map(int,input().split())

lcm = int(C*D / fractions.gcd(C,D))
ans_b = B - (B // C) - (B // D) + (B // lcm)
ans_a = A - 1 - ((A - 1)// C) - ((A - 1)// D) + ((A - 1) // lcm)

print(int(ans_b - ans_a))

Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())

icm = C*D / math.gcd(C,D)
ans = (B - A + 1)
if A % C == 0:
    ans -= (B // C - A // C) - 1
else:
    ans -= (B // C - A // C)
if A % D == 0:
    ans -= (B // D - A // D) - 1
else:
    ans -= (B // D - A // D)

if A % icm == 0:
    ans += (B // icm - A // icm) - 1
else:
    ans += (B // icm - A // icm)

print(int(ans))

Fixed submission:
import fractions
A,B,C,D = map(int,input().split())

lcm = int(C*D / fractions.gcd(C,D))
ans_b = B - (B // C) - (B // D) + (B // lcm)
ans_a = A - 1 - ((A - 1)// C) - ((A - 1)// D) + ((A - 1) // lcm)

print(int(ans_b - ans_a))
Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))

D=[0]*(N)

D[0]=0
count=1
for i in range(1,N):
  D[i]=D[i-1]+L[i-1]
  if D[i]<=X:
    count+=1
  else:
    break
print(count)


Fixed submission:
X,A=map(int,input().split())
if X < A:
  print('0')
else:
  print('10')
Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))

D=[0]*(N-1)

D[0]=0
count=1
for i in range(1,N):
  D[i]=D[i-1]+L[i-1]
  if D[i]<=X:
    count+=1
  else:
    break
print(count)

Fixed submission:
N,X=map(int,input().split())
L=list(map(int,input().split()))

D=[0]*(N+1)

D[0]=0
count=1
for i in range(1,N+1):
  D[i]=D[i-1]+L[i-1]
  if D[i]<=X:
    count+=1
  else:
    break
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
H, W = map(int, input().split())
grid = [list(input()) for i in range(H)]

grid2 = [[0]*W for i in range(H)]
grid3 = [[0]*W for i in range(H)]
for i in range(H):
    for j in range(W):
        if grid[i][j] == "#":
            grid2[i][j] = 0
        else:
            if j > 0:
                grid2[i][j] = grid2[i][j-1]+1
            else:
                grid2[i][j] = 1
    for j in reversed(range(W)):
        if grid2[i][j] != 0 and j != W-1:
            grid2[i][j] = max(grid2[i][j], grid2[i][j+1])

for j in range(W):
    for i in range(H):
        if grid[i][j] == "#":
            grid3[i][j] = 0
        else:
            if i > 0:
                grid3[i][j] = grid3[i-1][j]+1
            else:
                grid3[i][j] = 1
    for i in reversed(range(H)):
        if grid3[i][j] != 0 and i != H-1:
            grid3[i][j] = max(grid3[i][j], grid3[i+1][j])
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, grid2[i][j] + grid3[i][j] - 1)

print(ans)



Fixed submission:
H, W = map(int, input().split())
grid = [list(input()) for i in range(H)]

grid2 = [[0]*W for i in range(H)]
grid3 = [[0]*W for i in range(H)]
for i in range(H):
    for j in range(W):
        if grid[i][j] == "#":
            grid2[i][j] = 0
        else:
            if j > 0:
                grid2[i][j] = grid2[i][j-1]+1
            else:
                grid2[i][j] = 1
    for j in reversed(range(W)):
        if grid2[i][j] != 0 and j != W-1:
            grid2[i][j] = max(grid2[i][j], grid2[i][j+1])

for j in range(W):
    for i in range(H):
        if grid[i][j] == "#":
            grid3[i][j] = 0
        else:
            if i > 0:
                grid3[i][j] = grid3[i-1][j]+1
            else:
                grid3[i][j] = 1
    for i in reversed(range(H)):
        if grid3[i][j] != 0 and i != H-1:
            grid3[i][j] = max(grid3[i][j], grid3[i+1][j])
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, grid2[i][j] + grid3[i][j] - 1)

print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq
N = int(input())
ab = [tuple(map(int, input().split())) for i in range(N-1)]
c = list(map(int, input().split()))

print(sum(c) - max(c))
c = list(map(lambda x: x*(-1), c))
heapq.heapify(c)
d = [[0, i] for i in range(N)]
g = [set() for i in range(N)]
for a, b in ab:
    d[a-1][0] += 1
    d[b-1][0] += 1
    g[a-1].add(b-1)
    g[b-1].add(a-1)
d.sort(reverse=True, key=lambda x: x[0])
for i in range(N):
    d[i][0] = -1
d[0][0] = -1 * heapq.heappop(c)


def dfs(start):
    for x in g[start]:

        if d[x][0] == -1:

            d[x][0] = d[x][0] * heapq.heappop(c)

            dfs(x)


dfs(0)
d.sort(key=lambda x: x[1])

ans = [""]*N
for i in range(N):
    ans[i] = str(d[i][0])
print(" ".join(ans))


Fixed submission:
import heapq
import sys
sys.setrecursionlimit(20000)
N = int(input())
ab = [tuple(map(int, input().split())) for i in range(N-1)]
c = list(map(int, input().split()))

print(sum(c) - max(c))
c = list(map(lambda x: x*(-1), c))
heapq.heapify(c)
d = [[0, i] for i in range(N)]
g = [set() for i in range(N)]
for a, b in ab:
    d[a-1][0] += 1
    d[b-1][0] += 1
    g[a-1].add(b-1)
    g[b-1].add(a-1)
d.sort(reverse=True, key=lambda x: x[0])
for i in range(N):
    d[i][0] = -1


ans = ["-1"]*N
ans[d[0][1]] = str(-1 * heapq.heappop(c))


def dfs(start):
    for x in g[start]:
        if ans[x] == "-1":
            ans[x] = str(-1 * heapq.heappop(c))
            dfs(x)


dfs(d[0][1])
d.sort(key=lambda x: x[1])


print(" ".join(ans))
Buggy python submission (verdict: Runtime Error):
import heapq
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for k in range(K+1):
    for i in range(k+1):
        tmp = 0
        tmp2 = []
        heapq.heapify(tmp2)

        for j in range(k-i):
            tmp += V[j]
            if V[j] < 0:
                heapq.heappush(tmp2, V[j])
        for j in range(i):
            tmp += V[N-1-j]
            if V[N-1-j] < 0:

                heapq.heappush(tmp2, V[N-1-j])

        for j in range(min(k, K-k)):
            if len(tmp2) == 0:
                break
            tmp -= heapq.heappop(tmp2)
        ans = max(tmp, ans)


print(ans)


Fixed submission:
import heapq
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for k in range(min(K+1, N+1)):
    for i in range(k+1):
        tmp = 0
        tmp2 = []
        heapq.heapify(tmp2)

        for j in range(k-i):
            tmp += V[j]
            if V[j] < 0:
                heapq.heappush(tmp2, V[j])
        for j in range(i):
            tmp += V[N-1-j]
            if V[N-1-j] < 0:

                heapq.heappush(tmp2, V[N-1-j])

        for j in range(min(k, K-k)):
            if len(tmp2) == 0:
                break
            tmp -= heapq.heappop(tmp2)
        ans = max(tmp, ans)


print(ans)

Buggy python submission (verdict: Runtime Error):
import heapq
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for k in range(K+1):
    for i in range(k+1):
        tmp = 0
        tmp2 = []
        heapq.heapify(tmp2)

        for j in range(k-i):
            tmp += V[j]
            if V[j] < 0:
                heapq.heappush(tmp2, V[j])
        for j in range(i):
            tmp += V[j]
            if V[N-1-j] < 0:

                heapq.heappush(tmp2, V[j])

        for j in range(min(k, K-k)):
            tmp -= heapq.heappop(tmp2)
        ans = max(tmp, ans)


print(ans)


Fixed submission:
import heapq
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for k in range(min(K+1, N+1)):
    for i in range(k+1):
        tmp = 0
        tmp2 = []
        heapq.heapify(tmp2)

        for j in range(k-i):
            tmp += V[j]
            if V[j] < 0:
                heapq.heappush(tmp2, V[j])
        for j in range(i):
            tmp += V[N-1-j]
            if V[N-1-j] < 0:

                heapq.heappush(tmp2, V[N-1-j])

        for j in range(min(k, K-k)):
            if len(tmp2) == 0:
                break
            tmp -= heapq.heappop(tmp2)
        ans = max(tmp, ans)


print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
L=[-1]*M
R=[-1]*M
for i in range(M):
  L[i],R[i] =map(input().split())
  
print(min(R)-max(L)+1)


Fixed submission:
N,M=map(int,input().split())
L=[-1]*M
R=[-1]*M
for i in range(M):
  L[i],R[i] =map(int,input().split())
if min(R) >= max(L):
  print(min(R)-max(L)+1)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [0]*M
C = [0]*M
for i in range(M):
    B[i], C[i] = map(int, input().split())

A.sort()

for i in range(M):
    id = bisect.bisect_left(A, C[i])
    if id >= B[i]:
        A[:id] = A[B[i]:id]+[C[i]]*B[i]
    else:
        A[:id] = [C[i]]*id

print(sum(A))


Fixed submission:
import collections
import bisect
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [0]*M
C = [0]*M
table = collections.defaultdict(int)
for x in A:
    table[x] += 1
for i in range(M):
    B[i], C[i] = map(int, input().split())
    table[C[i]] += B[i]

count = N
ans = 0
table = list(table.items())
table.sort(key=lambda x: x[0], reverse=True)
for x in table:
    if count > x[1]:
        count -= x[1]
        ans += x[0]*x[1]
    else:
        ans += x[0]*count
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=input().split()
S=input()
S[K-1].swapcase()
print(S)


Fixed submission:
N,K=map(int,input().split())
S=input()
S=S[:K-1]+S[K-1].swapcase()+S[K:]
print(S)

Buggy python submission (verdict: Runtime Error):
N,K=input().split()
S=input()
S[K].swapcase()
print(S)


Fixed submission:
N,K=map(int,input().split())
S=input()
S=S[:K-1]+S[K-1].swapcase()+S[K:]
print(S)

Buggy python submission (verdict: Runtime Error):
N,K=input().split()
S=input()
S[K+1].swapcase()
print(S)

Fixed submission:
N,K=map(int,input().split())
S=input()
S=S[:K-1]+S[K-1].swapcase()+S[K:]
print(S)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
xyz=[tuple(map(int,input().split())) for i in range(M)]
class unionFind:
    parent = []

    def __init__(self, N):
        self.parent = [i for i in range(N)]

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            self.parent[x] = self.root(self.parent[x])
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y):
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            return
G=unionFind(N)
for x,y,z in xyz:
  G.unite(x,y)
ans=set()
for i in range(N):
  ans.add(G.root(i))
print(len(ans))

Fixed submission:
N,M=map(int,input().split())
xyz=[tuple(map(int,input().split())) for i in range(M)]
class unionFind:
    parent = []
    num=0
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.num=N
    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            self.parent[x] = self.root(self.parent[x])
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y):
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            self.num-=1
            return
G=unionFind(N)
for x,y,z in xyz:
  G.unite(x,y)
print(G.num)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=map(int,input().split())
ans=0
for i in range(N//R + 1):
  for j in range(N//G + 1):
    if R*i+G*j <= N:
      if (N - (R*i+G*j))%B==0:
        ans+=1
print(ans)

Fixed submission:
R,G,B,N=map(int,input().split())
ans=0
for i in range(N//R + 1):
  for j in range(N//G + 1):
    if R*i+G*j <= N:
      if (N - (R*i+G*j))%B==0:
        ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
R,G,B,N=map(int,input().split())
ans=0
for i in range(N//R + 1):
  for j in range(N//G + 1)
  if R*i+G*j <= N:
    if (N - (R*i+G*j))%B==0:
      ans+=1
print(ans)

Fixed submission:
R,G,B,N=map(int,input().split())
ans=0
for i in range(N//R + 1):
  for j in range(N//G + 1):
    if R*i+G*j <= N:
      if (N - (R*i+G*j))%B==0:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
ans = 0
for i in range(1, int(N**0.5)+1):
    if i == N % (N//i - 1):
        ans += N//i - 1

print(ans)


Fixed submission:
N = int(input())
ans = 0
for i in range(1, int(N**0.5)+1):
    if N // i > 1:
        if i == N % (N//i - 1):
            ans += N//i - 1

print(ans)