Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a=[]
b=[]
nums=[]
ans="No"

for i in range(3):
    l=list(map(int,input().split()))
    a.append(l)

n=int(input())

for i in range(n):
    s=int(input())
    b.append(s)

for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i]==a[j][k]:
                a[j][k]=0
                num=10*(j+1)+k+1
                nums.append(num)

nums.sort()


if A[0][0]==A[0][1]==A[0][2]==0:
    ans="Yes"
if A[1][0]==A[1][1]==A[1][2]==0:
        ans="Yes"
if A[2][0]==A[2][1]==A[2][2]==0:
    ans="Yes"
if A[0][0]==A[1][0]==A[2][0]==0:
    ans="Yes"
if A[0][1]==A[1][1]==A[2][1]==0:
        ans="Yes"
if A[0][2]==A[1][2]==A[2][2]==0:
    ans="Yes"
        
if 11 in nums and 22 in nums and 33 in nums:
    ans="Yes"

if 13 in nums and 22 in nums and 31 in nums:
    ans="Yes"
    
print(ans)

Fixed submission:
a=[]
b=[]
nums=[]
ans="No"

for i in range(3):
    l=list(map(int,input().split()))
    a.append(l)

n=int(input())

for i in range(n):
    s=int(input())
    b.append(s)

for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i]==a[j][k]:
                a[j][k]=0
                num=10*(j+1)+k+1
                nums.append(num)

nums.sort()


if a[0][0]==a[0][1]==a[0][2]==0:
    ans="Yes"
if a[1][0]==a[1][1]==a[1][2]==0:
        ans="Yes"
if a[2][0]==a[2][1]==a[2][2]==0:
    ans="Yes"
if a[0][0]==a[1][0]==a[2][0]==0:
    ans="Yes"
if a[0][1]==a[1][1]==a[2][1]==0:
        ans="Yes"
if a[0][2]==a[1][2]==a[2][2]==0:
    ans="Yes"
        
if 11 in nums and 22 in nums and 33 in nums:
    ans="Yes"

if 13 in nums and 22 in nums and 31 in nums:
    ans="Yes"
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
n=n//2+1
ans="YES"
for i in range(n):
  num=a[i]
  if a.count(num)!=1:
    ans="NO"
    break
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans="YES"
for i in range(n-1):
  if a[i]==a[i+1]:
    ans="NO"
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())
cnt=len(s)
s1=s[1]
for i in range(1,n):
    if s[i]==s1:
        cnt-=1
    s1=s[i]
print(cnt)

Fixed submission:
n=int(input())
s=list(input())
cnt=1
s1=s[0]
for i in range(n-1):
    if s[i]!=s[i+1]:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
cnt=0
ls=[]
i=0
while len(h)!=1:
    if h[i]>=h[i+1]:
        cnt+=1
        i+=1
        if i==len(h)-1:
          ls.append(cnt)
          cnt=0
          h.pop(0)
          i=0
          
    else:
        ls.append(cnt)
        cnt=0
        h.pop(0)
        i=0
print(max(ls))

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
cnt=0
ls=[0]*n
for i in range(n-1):
    if h[i]>=h[i+1]:
        cnt+=1
    else:
        ls[i]=cnt
        cnt=0
ls[-1]=cnt
print(max(ls))
Buggy python submission (verdict: Runtime Error):
import fractions
a,b,c,d=map(int,input().split())

s=c*d//fractions.gcd(c, d)
bk=0
ak=0
ans=0
bc=b//c
ac=a//c    
bd=b//d
ad=a//d
bsa=b//s
asa=a//s
bk=b-bc-bd+bsa
ak=a-ac-ad+asa
ans=bk-ak
if a%c!=0 or a%d!=0 or a%s!=0:
    ans+=1
elif:
  b%c==0 or b%d==0 or b%s==0
else:
  ans=ans
print(ans)

Fixed submission:
import fractions
a,b,c,d=map(int,input().split())
 
s=c*d//fractions.gcd(c, d)
bk=0
ak=0
ans=0
bc=b//c
ac=a//c    
bd=b//d
ad=a//d
bsa=b//s
asa=a//s
bk=b-bc-bd+bsa
ak=a-ac-ad+asa
ans=bk-ak
if a%c==0 or a%d==0 or a%s==0:
    ans=ans
else:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
if 10*int(s[2])+int(s[3])>=13:
  if int(s[0])+int(s[1])==0 or 10*int(s[0])+int(s[1])>=13:
    print("NA")
  else:
    print("MMYY")
if 10*int(s[0])+int(s[1])>=13:
  if int(s[2])+int(s[3])==0 or 10*int(s[2])+int(s[3])>=13:
    print("NA")
  else:
    print("YYMM")
if 10*int(s[2])+int(s[3])<=12 and 10*int(s[0])+int(s[1])<=12:
  print("AMBIGUOUS")
  else:
    print("NA")

Fixed submission:
s=input()
if 10*int(s[0])+int(s[1])<=12 and int(s[0])+int(s[1])!=0:
  if 10*int(s[2])+int(s[3])<=12 and int(s[2])+int(s[3])!=0:
    print("AMBIGUOUS")
  else:
    print("MMYY")
if 10*int(s[0])+int(s[1])>=13 or int(s[0])+int(s[1])==0:
  if 10*int(s[2])+int(s[3])<=12 and int(s[2])+int(s[3])!=0:
    print("YYMM")
  else:
    print("NA")
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
lst=[]
for _ in range(h):
    lst.append(input())
hl=[0]*h
wl=[0]*w
for i in range(h):
    for j in range(w):
        if lst[i][j]=="#":
            hl[i]=1
            wl[j]=1
            if hl[i]==1 and wl[j]==1:
                print(lst[i][j],end="")
    print("")

Fixed submission:
n=int(input())
p=[]
for _ in range(n):
    p.append(int(input()))
print(sum(p)-max(p)//2)
Buggy python submission (verdict: Runtime Error):
N=int(input())
if N%10==0:
    print(10)
else:
    ans = 0
    for i in range(len(N)):
        ans+= int(N[i])
        print(ans)

Fixed submission:
N=input()
if int(N)%10==0:
    print(10)
else:
    ans = 0
    for i in range(len(N)):
        ans+= int(N[i])
    print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
ans=[]

if N%10==0:
    print(10)
else:
    ans = 0
    for i in range(len(N)):
        ans+= int(N[i])
        print(ans)


Fixed submission:
N=input()
if int(N)%10==0:
    print(10)
else:
    ans = 0
    for i in range(len(N)):
        ans+= int(N[i])
    print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()

for i in range(0,len(s)):
    if s[i] == "A":
        a = i
        break
for i in range(a,len(s)):
    if s[i] == "Z":
        z = i
        break
print(len(s[a:z+1])


Fixed submission:
s=input()

a=s.find('A')

for i in range(a,len(s)):
    if s[i] == "Z":
        z=i
print(z-a+1)
Buggy python submission (verdict: Time Limit Exceeded):
K,S= map(int,input().split())

ans=0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z ==S:
                ans+=1
print(ans)

Fixed submission:
K,S= map(int,input().split())

ans=0

for x in range(K+1):
    for y in range(K+1):
        if 0 <= S-x-y <= K:
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10


# N個の部屋とM本の通路
N, M = [int(x) for x in stdin.readline().rstrip().split()]

route = [[] for _ in range(M+1)]

for _ in range(M):
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    route[A].append(B)
    route[B].append(A)


kyori_to_1 = [INF for _ in range(N+1)]
kyori_to_1[1] = 0

miti = [0 for _ in range(N+1)]
miti[0] = -1
miti[1] = -1

is_visited = [False for _ in range(N+1)]

# 幅優先探索
# 試すべき位置をキューで管理
que = deque([1])

# キューが空じゃなければ
while len(que) != 0:
    now = que.popleft()
    
    if is_visited[now]:
        continue

    is_visited[now] = True

    for place in route[now]:
        que.append(place)

        if kyori_to_1[now]+1 < kyori_to_1[place]:
            kyori_to_1[place] = kyori_to_1[now]+1
            miti[place] = now

if 0 in miti:
    print("No")
else:
    for i in range(1, N+1):
        if i == 1:
            print("Yes")
        else:
            print(miti[i])


Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10


# N個の部屋とM本の通路
N, M = [int(x) for x in stdin.readline().rstrip().split()]

route = [[] for _ in range(N+1)]

for _ in range(M):
    A, B = [int(x) for x in stdin.readline().rstrip().split()]
    route[A].append(B)
    route[B].append(A)


kyori_to_1 = [INF for _ in range(N+1)]
kyori_to_1[1] = 0

miti = [0 for _ in range(N+1)]
miti[0] = -1
miti[1] = -1

is_visited = [False for _ in range(N+1)]

# 幅優先探索
# 試すべき位置をキューで管理
que = deque([1])

# キューが空じゃなければ
while len(que) != 0:
    now = que.popleft()
    
    if is_visited[now]:
        continue

    is_visited[now] = True

    for place in route[now]:
        que.append(place)

        if kyori_to_1[now]+1 < kyori_to_1[place]:
            kyori_to_1[place] = kyori_to_1[now]+1
            miti[place] = now

if 0 in miti:
    print("No")
else:
    for i in range(1, N+1):
        if i == 1:
            print("Yes")
        else:
            print(miti[i])
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, M, X  = [int(x) for x in stdin.readline().rstrip().split()]
CA = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

nums = [0, 1]
buy_or_not = list(itertools.product(nums, repeat=N))

knowledge_list = []
money_list = []

for bn in buy_or_not:
    knowledge = [0 for _ in range(M)]
    money = 0
    for i in range(M):
        if bn[i] == 1:
            money += CA[i][0]
            knowledge = [a + b for a, b in zip(knowledge, CA[i][1:])]

    knowledge_list.append(knowledge)
    money_list.append(money)

ans = INF

for i in range(len(money_list)):
    if min(knowledge_list[i]) >= X:
        ans = min(ans, money_list[i])

if ans != INF:
    print(ans)
else:
    print(-1)


Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, M, X  = [int(x) for x in stdin.readline().rstrip().split()]

CA = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

knowledge_list = [[0 for _ in range(M)]]
money_list = [0]

for i in range(N):
    C = CA[i][0]
    A = CA[i][1:]

    # 購入する場合
    tmp2 = []
    for i, knowledge in enumerate(knowledge_list):
        tmp = []
        for k in range(len(knowledge)):
            tmp.append(knowledge[k] + A[k])
        
        tmp2.append(tmp)
        money_list.append(money_list[i]+C)

    knowledge_list = knowledge_list + tmp2

ans = INF
for i in range(len(money_list)):
    if min(knowledge_list[i]) >= X:
        ans = min(ans, money_list[i])

if ans != INF:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque
import collections
import itertools

INF = 10 ** 10


# N個のボールがあり、i番目のボールは(xi, yi)にある
N = int(stdin.readline().rstrip())
xy = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

data = []

for i in range(N):
    for j in range(i+1, N):
        x_diff = abs(xy[i][0] - xy[j][0])
        y_diff = abs(xy[i][1] - xy[j][1])

        data.append("{0},{1}".format(x_diff, y_diff))

c = collections.Counter(data)

print(N - c.most_common()[0][1])


Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque
import collections
import itertools

INF = 10 ** 10


# N個のボールがあり、i番目のボールは(xi, yi)にある
N = int(stdin.readline().rstrip())
xy = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

data = []

if N == 1:
    print(1)
    exit()

for i in range(N):
    for j in range(i+1, N):
        x_diff = xy[i][0] - xy[j][0]
        y_diff = xy[i][1] - xy[j][1]
        data.append("{0},{1}".format(x_diff, y_diff))
        data.append("{0},{1}".format(-x_diff, -y_diff))

c = collections.Counter(data)

print(N - c.most_common()[0][1])
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque

WHITE = 0
BLACK = 1

N = int(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]

# 根から頂点までの距離
# 根は適当な頂点を選べば良いので、u_0とする
dist = [None] * (N+1)
dist[data[0][0]] = 0

# 根からの距離を算出
for u, v, w in data:
    # 木構造なので、どちらか一方はすでに求まっているはず
    if dist[u] != None:
        dist[v] = dist[u] + w
    else:
        dist[u] = dist[v] + w

# distが偶数の頂点には白で、奇数の頂点には黒で塗ることとする
for i in range(1, N+1):
    if dist[i] % 2 == 0:
        print(WHITE)
    else:
        print(BLACK)


Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque

WHITE = 0
BLACK = 1

N = int(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]

# 木の繋がりと長さ
connect = [[] for _ in range(N+1)]
for u, v, w in data:
    connect[u].append([v,w])
    connect[v].append([u,w])

# 根から頂点までの距離
# 根は適当な頂点を選べば良いので、u_0とする
dist = [None] * (N+1)
dist[data[0][0]] = 0

que = deque([])
que.append(data[0][0])
is_visited = [False] * (N+1)

# BFSで根からの距離を求めていく
while len(que) != 0:
    u = que.popleft()

    if is_visited[u] == True:
        continue

    is_visited[u] = True

    for v, w in connect[u]:
        que.append(v)
        if dist[v] == None:
            dist[v] = dist[u] + w

# distが偶数の頂点には白で、奇数の頂点には黒で塗ることとする
for i in range(1, N+1):
    if dist[i] % 2 == 0:
        print(WHITE)
    else:
        print(BLACK)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math
import fractions
from collections import deque

WHITE = 0
BLACK = 1

N = int(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]

# 根から頂点までの距離
# 根は適当な頂点を選べば良いので、u_0とする
dist = [None] * (N+1)
dist[data[0][0]] = 0

# 根からの距離を算出
for u, v, w in data:
    # 木構造なので、どちらか一方はすでに求まっているはず
    if dist[u] != None:
        dist[v] = dist[u] + w
    else:
        dist[u] = dist[v] + w

# distが偶数の頂点には白で、奇数の頂点には黒で塗ることとする
for i in range(1, N+1):
    if dist[i] % 2 == 0:
        print(WHITE)
    else:
        print(BLACK)

Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque

WHITE = 0
BLACK = 1

N = int(stdin.readline().rstrip())
data = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N-1)]

# 木の繋がりと長さ
connect = [[] for _ in range(N+1)]
for u, v, w in data:
    connect[u].append([v,w])
    connect[v].append([u,w])

# 根から頂点までの距離
# 根は適当な頂点を選べば良いので、u_0とする
dist = [None] * (N+1)
dist[data[0][0]] = 0

que = deque([])
que.append(data[0][0])
is_visited = [False] * (N+1)

# BFSで根からの距離を求めていく
while len(que) != 0:
    u = que.popleft()

    if is_visited[u] == True:
        continue

    is_visited[u] = True

    for v, w in connect[u]:
        que.append(v)
        if dist[v] == None:
            dist[v] = dist[u] + w

# distが偶数の頂点には白で、奇数の頂点には黒で塗ることとする
for i in range(1, N+1):
    if dist[i] % 2 == 0:
        print(WHITE)
    else:
        print(BLACK)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

R, G, B, N = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 0
RN = N // R + 1


for i in range(RN):
    GN = (N-R*i) // G + 1
    for j in range(GN):
        BN = (N-R*i-G*j) // B + 1
        for k in range(BN):
            num = R * i + G * j + B * k
            if num == N:
                cnt+=1

print(cnt)

Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

R, G, B, N = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 0
R, G, B = sorted([R, G, B])
RN = N // R + 1
GN = N // G + 1
BN = N // B + 1

cnt = 0
for i in range(RN):
    tmpN = N - R*i
    if tmpN % G == 0:
        cnt += 1
    for j in range(GN):
        tmpN2 = tmpN - G*j
        if tmpN2 > 0 and tmpN2 % B == 0:
            cnt += 1
    

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

R, G, B, N = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 0
RN = N // R + 1
GN = N // G + 1
BN = N // B + 1

for i in range(RN):
    for j in range(GN):
        for k in range(BN):
            num = R * i + G * j + B * k
            if num > N:
                break
            if num == N:
                cnt+=1

print(cnt)

Fixed submission:
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

R, G, B, N = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 0
R, G, B = sorted([R, G, B])
RN = N // R + 1
GN = N // G + 1
BN = N // B + 1

cnt = 0
for i in range(RN):
    tmpN = N - R*i
    if tmpN % G == 0:
        cnt += 1
    for j in range(GN):
        tmpN2 = tmpN - G*j
        if tmpN2 > 0 and tmpN2 % B == 0:
            cnt += 1
    

print(cnt)
Buggy python submission (verdict: Runtime Error):
from sys import stdin

N = int(stdin.readline().rstrip())
H_list = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 1
if H_list[1] >= H_list[0]:
    cnt += 1

for i in range(2, N):
    if H_list[i] >= max(H_list[:i-1]):
        cnt += 1

print(cnt)


Fixed submission:
from sys import stdin

N = int(stdin.readline().rstrip())
H_list = [int(x) for x in stdin.readline().rstrip().split()]

if N == 1:
    print(1)
    exit()

cnt = 1
if H_list[1] >= H_list[0]:
    cnt += 1

for i in range(2, N):
    if H_list[i] >= max(H_list[:i]):
        cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

N = int(stdin.readline().rstrip())
max_ride = [int(stdin.readline().rstrip()) for _ in range(5)]

shima = [N, 0, 0, 0, 0, 0]
shima_next = [0, 0, 0, 0, 0, 0]

res_time = 0
while(shima[5] != N):
    res_time += 1
    for i in range(5, 0, -1):
        if shima[i-1] == 0:
            continue

        if shima[i-1] > max_ride[i-1]:
            shima_next[i-1] = shima[i-1] - max_ride[i-1]
            shima_next[i] += max_ride[i-1]
        else:
            shima_next[i-1] = 0
            shima_next[i] += shima[i-1]
    
    shima = shima_next[:]

print(res_time)

Fixed submission:
from sys import stdin
import math

N = int(stdin.readline().rstrip())
max_ride = [int(stdin.readline().rstrip()) for _ in range(5)]

res_time = math.ceil(N / min(max_ride) + 4)

print(res_time)
Buggy python submission (verdict: Runtime Error):
from sys import stdin

S = stdin.readline().rstrip()

countlist = []

count = 0
for s in S:
    if s == "A" or s == "C" or s == "G" or s == "T":
        count += 1
    else:
        countlist.append(count)
        count = 0

print(max(countlist))

Fixed submission:
from sys import stdin

S = stdin.readline().rstrip()
countlist = []

count = 0
for s in S:
    if s == "A" or s == "C" or s == "G" or s == "T":
        count += 1
    else:
        countlist.append(count)
        count = 0
countlist.append(count)
print(max(countlist))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

result = "0"

for d in range(A, B+1):
    # 排他的論理和
    result = (bin(int(result, 2) ^ d))

print(int(result, 2))

Fixed submission:
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

def isOdd(num):
    if num % 2 == 0:
        return False
    else:
        return True

def solve(num):
    if isOdd(num):
        if (num // 2) % 2 == 0:
            return 1
        else:
            return 0
    else:
        return solve(num+1) ^ (num+1) 


print(solve(B) ^ solve(A-1))

Buggy python submission (verdict: Runtime Error):
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

result = "0"

for d in range(A, B+1):
    # 排他的論理和
    result = (bin(int(result) ^ d))

print(int(result, 2))

Fixed submission:
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

def isOdd(num):
    if num % 2 == 0:
        return False
    else:
        return True

def solve(num):
    if isOdd(num):
        if (num // 2) % 2 == 0:
            return 1
        else:
            return 0
    else:
        return solve(num+1) ^ (num+1) 


print(solve(B) ^ solve(A-1))

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

data = [A+i for i in range(B-A+1)]

result = "0"

for d in data:
    # 排他的論理和
    result = (bin(int(result, 2) ^ d))

print(int(result, 2))

Fixed submission:
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

def isOdd(num):
    if num % 2 == 0:
        return False
    else:
        return True

def solve(num):
    if isOdd(num):
        if (num // 2) % 2 == 0:
            return 1
        else:
            return 0
    else:
        return solve(num+1) ^ (num+1) 


print(solve(B) ^ solve(A-1))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]

# 最大公約数
gcd = math.gcd(A, B)

num_list = []

for i in range(1, gcd+1):
    if A % i == 0 and B % i == 0:
        num_list.append(i)

print(num_list[-(K)])

Fixed submission:
from sys import stdin

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]


num_list = []

for i in range(1, min([A, B])+1):
    if A % i == 0 and B % i == 0:
        num_list.append(i)

print(num_list[-(K)])

Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]

# 最大公約数
gcd = math.gcd(A, B)

num_list = []

for i in range(1, gcd+1):
    if A % i == 0 and B % i == 0:
        num_list.append(i)

print(num_list[-(K)])

Fixed submission:
from sys import stdin

A, B, K = [int(x) for x in stdin.readline().rstrip().split()]


num_list = []

for i in range(1, min([A, B])+1):
    if A % i == 0 and B % i == 0:
        num_list.append(i)

print(num_list[-(K)])
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import re

S = stdin.readline().rstrip()

before_S = S

while(True):
    #after_S = S.replace("01", "").replace("10", "")
    after_S = re.sub("(01)+|(10)+", "", S)
    if len(after_S) != len(S):
        S = after_S
    else:
        break

print(len(before_S) - len(S))

Fixed submission:
from sys import stdin

S = stdin.readline().rstrip()

stack = []
count = 0

for s in S:
    # スタックが空なら
    if not stack:
        stack.append(s)
    # スタックの一番上がsでなければ
    elif stack[-1] != s:
        stack.pop()
        count += 2
    else:
        stack.append(s)

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

S = stdin.readline().rstrip()

beforeS = S

while(True):
    after_S = S.replace("01", "").replace("10", "")
    if len(after_S) != len(S):
        S = after_S
    else:
        break

print(len(beforeS) - len(S))

Fixed submission:
from sys import stdin

S = stdin.readline().rstrip()

stack = []
count = 0

for s in S:
    # スタックが空なら
    if not stack:
        stack.append(s)
    # スタックの一番上がsでなければ
    elif stack[-1] != s:
        stack.pop()
        count += 2
    else:
        stack.append(s)

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

S = stdin.readline().rstrip()

count = 0
prev_S = ""
while(True):
    if S == prev_S or S == "":
        break
    prev_S = S
    S = S.replace("01", "").replace("10", "")
    count += len(prev_S) - len(S)

print(count)

Fixed submission:
from sys import stdin

S = stdin.readline().rstrip()

stack = []
count = 0

for s in S:
    # スタックが空なら
    if not stack:
        stack.append(s)
    # スタックの一番上がsでなければ
    elif stack[-1] != s:
        stack.pop()
        count += 2
    else:
        stack.append(s)

print(count)