Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]

a,b = MI()

if a % 2 == 0:
    if b % 2 == 0:
        if (b-a) % 4 == 2:
            print(b + 1)
        else:
            print(b)
    else:
        if (b-a) % 4 == 1:
            print(1)
        else:
            print(0)
else:
    if b % 2 == 0:
        if (b-a) % 4 == 1:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):

                    anst += bst[2+i]
            for i in range(len(ast) -2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:],2)
            print(aa)

        else:
            print(aa+1)
    else:
        if (b-a) % 4 == 2:
            print(a-1)
        else:
            print(a)

Fixed submission:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]

a,b = MI()

if a % 2 == 0:
    if b % 2 == 0:
        if (b-a) % 4 == 2:
            print(b + 1)
        else:
            print(b)
    else:
        if (b-a) % 4 == 1:
            print(1)
        else:
            print(0)
else:
    if b % 2 == 0:
        if (b-a) % 4 == 1:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):

                    anst += bst[2+i]
            for i in range(len(ast) -2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:],2)
            print(aa)

        else:
            bst = bin(b)
            ast = bin(a)
            anst = '0b'
            if len(bst) - len(ast) > 0:
                for i in range(len(bst) - len(ast)):
                    anst += bst[2 + i]
            for i in range(len(ast) - 2):
                if ast[-len(ast) + 2 + i] == bst[-len(ast) + 2 + i]:
                    anst += '0'
                else:
                    anst += '1'
                aa = int(anst[2:], 2)
            print(aa - 1)
    else:
        if (b-a) % 4 == 2:
            print(a-1)
        else:
            print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [0 for j in range(S + 1)]
dp[0] = 1
for i in range(N) : 
    for j in range(S, -1, -1) : 
        if j + A[i] <= S : 
            dp[j + A[i]] += dp[j]
            dp[j + A[i]] %= mod
        dp[j] *= 2
        dp[j] %= mod 
        
print(dp[S])

Fixed submission:
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [0 for j in range(S + 1)]
dp[0] = 1
for i in range(N) : 
    for j in range(S, -1, -1) : 
        if j + A[i] <= S : 
            dp[j + A[i]] += dp[j]
            dp[j + A[i]] %= mod
        dp[j] *= 2
        dp[j] %= mod 
        
print(dp[S])
Buggy python submission (verdict: Runtime Error):
import copy
D = int( input() )
c = list( map( int, input().split() ) )
s = []
for _ in range( D ):
    s_i = list( map( int, input().split() ) )
    s.append( s_i )

def next_satisfy( d, c, s, next_t, last,  pre_satisfy ):
    ans = pre_satisfy + s[ d ][ next_t ]
    last_d = copy.deepcopy( last[ -1 ] )
    last_d[ next_t ] = d
    last.append( last_d )
    for i in range( 26 ):
        ans -= c[ i ] * ( d - last[ d ][ i ] )
    return ans

t = []
last = [ [ -1 for _ in range( 26 ) ] ]
last_i = [ -1 for _ in range( 26 ) ]
for d in range( D ):
    max_satisfy = - 10 ** 10
    next_t = -1
    for i in range( 26 ):
        satisfy_i = next_satisfy( d, c, s, i, last, 0 )
        if max_satisfy < satisfy_i:
            max_satisfy = satisfy_i
            next_t = i
    last_i[ d ] = next_t
    last.append( copy.deepcopy( last_i ) )
    t.append( next_t + 1 )

for t_i in t:
    print( t_i )
    

Fixed submission:
import copy
D = int( input() )
c = list( map( int, input().split() ) )
s = []
for _ in range( D ):
    s_i = list( map( int, input().split() ) )
    s.append( s_i )

def next_satisfy( d, c, s, next_t, last,  pre_satisfy ):
    ans = pre_satisfy + s[ d ][ next_t ]
    last_d = copy.deepcopy( last[ -1 ] )
    last_d[ next_t ] = d
    last.append( last_d )
    for i in range( 26 ):
        ans -= c[ i ] * ( d - last[ d ][ i ] )
    return ans

t = []
last = [ [ -1 for _ in range( 26 ) ] ]
last_i = [ -1 for _ in range( 26 ) ]
for d in range( D ):
    max_satisfy = - 10 ** 10
    next_t = -1
    for i in range( 26 ):
        satisfy_i = next_satisfy( d, c, s, i, last, 0 )
        if max_satisfy < satisfy_i:
            max_satisfy = satisfy_i
            next_t = i
    last_i[ next_t ] = d
    last.append( copy.deepcopy( last_i ) )
    t.append( next_t + 1 )

for t_i in t:
    print( t_i )
Buggy python submission (verdict: Time Limit Exceeded):
n = int( input() )
a = list( map( int, input().split() ) )

a.sort()
p = []
k = set()

while a:
    prime = a[ 0 ]

    p.append( prime )

    i = 0
    flag = 0
    while i < len( a ):
        if a[ i ] == prime and flag == 1:
            k.add( prime )
        flag = 1
        if a[ i ] % prime == 0:
            a.pop( i )
            continue
        i += 1

# print( p, k )
print( len( p ) - len( k ) )


Fixed submission:
# 以下カンニング
n = int( input() )
a = list( map( int, input().split() ) )

max_a = max( a )

c = {} # c[ a_i ] = aに含まれるa_iの個数
d = {} # d[ a_i ] = aにa_iの約数( < a_i )があるか(bool)
for a_i in a:
    try:
        c[ a_i ] += 1
    except KeyError:
        c[ a_i ] = 1
        d[ a_i ] = False # 初期値

for a_i in a:
    if c[ a_i ] > 0:
        tmp = 2 * a_i
        while tmp <= max_a:
            d[ tmp ] = True
            tmp += a_i

ans = 0
for a_i in a:
    if c[ a_i ] == 1 and d[ a_i ] == False:
        ans += 1

print( ans )

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

a.sort()
p = []
k = set()

while a:
    prime = a[ 0 ]

    p.append( prime )

    i = 0
    flag = 0
    while i < len( a ):
        if a[ i ] == prime and flag == 1:
            k.add( prime )
        flag = 1
        if a[ i ] % prime == 0:
            a.pop( i )
            continue
        i += 1

# print( p, k )
print( len( p ) - len( k ) )


Fixed submission:
# 以下カンニング
n = int( input() )
a = list( map( int, input().split() ) )

max_a = max( a )

c = {} # c[ a_i ] = aに含まれるa_iの個数
d = {} # d[ a_i ] = aにa_iの約数( < a_i )があるか(bool)
for a_i in a:
    try:
        c[ a_i ] += 1
    except KeyError:
        c[ a_i ] = 1
        d[ a_i ] = False # 初期値

for a_i in a:
    if c[ a_i ] > 0:
        tmp = 2 * a_i
        while tmp <= max_a:
            d[ tmp ] = True
            tmp += a_i

ans = 0
for a_i in a:
    if c[ a_i ] == 1 and d[ a_i ] == False:
        ans += 1

print( ans )

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

a.sort()
p = []
k = set()
while a:
    prime = min( a )

    p.append( prime )

    i = 0
    flag = 0
    while i < len( a ):
        if a[ i ] == prime and flag == 1:
            k.add( prime )
        flag = 1
        if a[ i ] % prime == 0:
            a.pop( i )
            continue
        i += 1

# print( p, k )
print( len( p ) - len( k ) )

Fixed submission:
# 以下カンニング
n = int( input() )
a = list( map( int, input().split() ) )

max_a = max( a )

c = {} # c[ a_i ] = aに含まれるa_iの個数
d = {} # d[ a_i ] = aにa_iの約数( < a_i )があるか(bool)
for a_i in a:
    try:
        c[ a_i ] += 1
    except KeyError:
        c[ a_i ] = 1
        d[ a_i ] = False # 初期値

for a_i in a:
    if c[ a_i ] > 0:
        tmp = 2 * a_i
        while tmp <= max_a:
            d[ tmp ] = True
            tmp += a_i

ans = 0
for a_i in a:
    if c[ a_i ] == 1 and d[ a_i ] == False:
        ans += 1

print( ans )
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map( int, input().split() )
a = list( map( int, input().split() ) )

# 以下カンニング
for _ in range( min( k, 41 ) ):
    b = [ 0 ] * n

    for i in range( n ):
        l = max( 0, i - a[ i ] )
        r = min( n - 1, i + a[ i ] )
        b[ l ] += 1
        if r + 1 < n:
            b[ r + 1 ] -= 1

    for i in range( 1, n ):
        b[ i ] += b[ i - 1 ]

    a = b

print( " ".join( list( map( str, a ) ) ) )

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

# 以下カンニング
for _ in range( min( k, 41 ) ): # 41 ~ log( 2 * 10 ** 5 )
    b = [ 0 ] * n

    for i in range( n ):
        l = max( 0, i - a[ i ] )
        r = min( n - 1, i + a[ i ] )
        b[ l ] += 1
        if r + 1 < n:
            b[ r + 1 ] -= 1

    for i in range( 1, n ):
        b[ i ] += b[ i - 1 ]

    a = b

print( " ".join( list( map( str, a ) ) ) )

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map( int, input().split() )
a = list( map( int, input().split() ) )

# 以下カンニング
for _ in range( min( k, 41 ) ):
    b = [ 0 for _ in range( n ) ]

    for i in range( n ):
        l = max( 0, i - a[ i ] )
        r = min( n - 1, i + a[ i ] )
        b[ l ] += 1
        if r + 1 < n:
            b[ r + 1 ] -= 1

    for i in range( 1, n ):
        b[ i ] += b[ i - 1 ]

    a = b

print( " ".join( list( map( str, a ) ) ) )

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

# 以下カンニング
for _ in range( min( k, 41 ) ): # 41 ~ log( 2 * 10 ** 5 )
    b = [ 0 ] * n

    for i in range( n ):
        l = max( 0, i - a[ i ] )
        r = min( n - 1, i + a[ i ] )
        b[ l ] += 1
        if r + 1 < n:
            b[ r + 1 ] -= 1

    for i in range( 1, n ):
        b[ i ] += b[ i - 1 ]

    a = b

print( " ".join( list( map( str, a ) ) ) )

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n, k = map( int, input().split() )
a = list( map( int, input().split() ) )

# 以下カンニング
for _ in range( min( k, 42 ) ):
    b = [ 0 for _ in range( n ) ]

    for i in range( n ):
        l = max( 0, i - a[ i ] )
        r = min( n - 1, i + a[ i ] )
        b[ l ] += 1
        if r + 1 < n:
            b[ r + 1 ] -= 1

    for i in range( 1, n ):
        b[ i ] += b[ i - 1 ]

    a = copy.deepcopy( b )

print( " ".join( list( map( str, a ) ) ) )

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

# 以下カンニング
for _ in range( min( k, 41 ) ): # 41 ~ log( 2 * 10 ** 5 )
    b = [ 0 ] * n

    for i in range( n ):
        l = max( 0, i - a[ i ] )
        r = min( n - 1, i + a[ i ] )
        b[ l ] += 1
        if r + 1 < n:
            b[ r + 1 ] -= 1

    for i in range( 1, n ):
        b[ i ] += b[ i - 1 ]

    a = b

print( " ".join( list( map( str, a ) ) ) )
Buggy python submission (verdict: Runtime Error):
#include <stdio.h>

int main(){
    double a, b;
    long m;
    scanf("%lf %lf", &a, &b );
    m = a * b;
    printf("%ld\n", m);
    return 0;
}

Fixed submission:
a, b = input().split()
a = int( a )
b = int( 1000 * float( b ) )
m = a * b
m = m // 1000

print( m )
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
N = len(s)
array = [0]*2019
array[0] += 1
count = 0
d = 0
for i in reversed(range(0, N)):
    x = s[i:N]
    y = int(x)
    d = ( d + int( s[i] ) * 10 ** ( N - i - 1 ) % 2019 ) % 2019
    array[d] += 1
for i in array:
    count += i*(i-1)/2
print(int(count))

Fixed submission:
s = str(input())
N = len(s)
array = [0]*2019
array[0] += 1
count = 0
d = 1
r = 0
for i in reversed(range(0, N)):
    #x = s[i:N]
    #y = int(x)
    r = ( r + int( s[i] ) * d ) % 2019
    d = d * 10 % 2019
    array[r] += 1
for i in array:
    count += i*(i-1)/2
print(int(count))

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
N = len(s)
array = [0]*2019
array[0] += 1
count = 0
for i in reversed(range(0, N)):
    x = s[i:N]
    y = int(x)
    array[y%2019] += 1
for i in array:
    count += i*(i-1)/2
print(int(count))



Fixed submission:
s = str(input())
N = len(s)
array = [0]*2019
array[0] += 1
count = 0
d = 1
r = 0
for i in reversed(range(0, N)):
    #x = s[i:N]
    #y = int(x)
    r = ( r + int( s[i] ) * d ) % 2019
    d = d * 10 % 2019
    array[r] += 1
for i in array:
    count += i*(i-1)/2
print(int(count))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

cnt = 0

for i in range( len(s) ):
    for j in range( i+3, len(s)+1 ):
        d = int( s[i:j] )
        if d % 2019 == 0:
            cnt += 1

print( cnt )

Fixed submission:
s = str(input())
N = len(s)
array = [0]*2019
array[0] += 1
count = 0
d = 1
r = 0
for i in reversed(range(0, N)):
    #x = s[i:N]
    #y = int(x)
    r = ( r + int( s[i] ) * d ) % 2019
    d = d * 10 % 2019
    array[r] += 1
for i in array:
    count += i*(i-1)/2
print(int(count))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

cnt = 0
#for c in range( int(s) // 2019 ):
#    d = ( c + 1 ) * 2019
#    print( d )
#    for n in range( len( str(s) ) - len( str(d) ) ):
#        if str( d ) in str( s )[n:]:
#            cnt += 1

for i in range( len(s) ):
    for j in range( i+3, len(s)+1 ):
        d = int( s[i:j] )
        if d % 2019 == 0:
            cnt += 1
            #print(i,j)

print( cnt )

Fixed submission:
s = str(input())
N = len(s)
array = [0]*2019
array[0] += 1
count = 0
d = 1
r = 0
for i in reversed(range(0, N)):
    #x = s[i:N]
    #y = int(x)
    r = ( r + int( s[i] ) * d ) % 2019
    d = d * 10 % 2019
    array[r] += 1
for i in array:
    count += i*(i-1)/2
print(int(count))
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
a = input().split()

for i in range( int(n) ):
    print( a.count(str(i+1)) )

Fixed submission:
n = input()
a = input().split()
out = [0] * int(n)

#for i in range( int(n) ):
#    print( a.count(str(i+1)) )

for a_i in a:
    a_i = int(a_i)
    out[a_i-1] += 1

for out_i in out:
    print( out_i )

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
a = input().split()

for i in range( int(n) ):
    cnt = 0
    for a_i in a:
        if int(a_i) == i+1 :
            cnt += 1
    print(cnt)

Fixed submission:
n = input()
a = input().split()
out = [0] * int(n)

#for i in range( int(n) ):
#    print( a.count(str(i+1)) )

for a_i in a:
    a_i = int(a_i)
    out[a_i-1] += 1

for out_i in out:
    print( out_i )
Buggy python submission (verdict: Time Limit Exceeded):
import math

k = int( input() )
out_sum = 0

for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            out_sum += math.gcd( a, math.gcd(b,c) )

print( out_sum )

Fixed submission:
import math

k = int( input() )
out_sum = 0

# a==b and b==c
for a in range(1, k+1):
    out_sum += a

# a==b and b!=c
for a in range(2, k+1):
    for b in range(1, a):
        out_sum += 6 * math.gcd(a,b)

# a!=b and b!=c
for a in range(3, k+1):
    for b in range(2, a):
        for c in range(1, b):
            out_sum += 6 * math.gcd( a, math.gcd(b,c) )

print( out_sum )
Buggy python submission (verdict: Time Limit Exceeded):
n = int( input() )
s = list( input() )
r = []
g = []
b = []

for i in range(n):
    if s[i] == "R":
        r.append(i)
    elif s[i] == "G":
        g.append(i)
    elif s[i] == "B":
        b.append(i) 

cnt = 0
for i in r:
    for j in g:
        for k in b:
            if (i+j)/2==k or (j+k)/2==i or (k+i)/2==j:
                cnt += 1

print( len(r) * len(g) * len(b) - cnt )

Fixed submission:
n = int( input() )
s = list( input() )
r = []
g = []
b = []

for i in range(n):
    if s[i] == "R":
        r.append(i)
    elif s[i] == "G":
        g.append(i)
    elif s[i] == "B":
        b.append(i) 

cnt = 0
for i in range(n - 2):
    for k in range(i + 2, n):
        if ( i + k ) % 2 != 0:
            continue
        j = ( i + k ) // 2
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            cnt += 1

print( len(r) * len(g) * len(b) - cnt )
Buggy python submission (verdict: Runtime Error):
n, m, k = map( int, input().split() )
friend = [ [] for _ in range( n ) ]

for _ in range( m ):
    a, b = map( int, input().split() )
    friend[ a - 1 ].append( b - 1 )
    friend[ b - 1 ].append( a - 1 )

VISITED = 1
NOT_VISITED = 0
visit = [ NOT_VISITED for _ in range( n ) ]
graph_id = [ -1 for _ in range( n ) ]

def dfs( ver, g_id ):
    if graph_id[ ver ] == -1:
        graph_id[ ver ] = g_id
    else:
        return
    for next_v in friend[ ver ]:
        dfs( next_v, g_id )

g_id = 0
for ver in range( n ):
    if graph_id[ ver ] != -1:
        continue
    dfs( ver, g_id )
    g_id += 1

graph_size = [ 0 for _ in range( n ) ]
for ver in range( n ):
    graph_size[ graph_id[ ver ] ] += 1

ans = [ graph_size[ graph_id[ ver ] ] for ver in range( n ) ]

for _ in range( k ):
    c, d = map( int, input().split() )
    if graph_id[ c - 1 ] == graph_id[ d - 1 ]:
        ans[ c - 1 ] -= 1
        ans[ d - 1 ] -= 1

for ver in range( n ):
    ans[ ver ] = ans[ ver ] - len( friend[ ver ] ) - 1

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

Fixed submission:
import sys
sys.setrecursionlimit(200100)
n, m, k = map( int, input().split() )
friend = [ [] for _ in range( n ) ]

for _ in range( m ):
    a, b = map( int, input().split() )
    friend[ a - 1 ].append( b - 1 )
    friend[ b - 1 ].append( a - 1 )

graph_id = [ -1 for _ in range( n ) ]

def dfs( ver, g_id ):
    if graph_id[ ver ] == -1:
        graph_id[ ver ] = g_id
    else:
        return
    for next_v in friend[ ver ]:
        dfs( next_v, g_id )

g_id = 0
for ver in range( n ):
    if graph_id[ ver ] != -1:
        continue
    dfs( ver, g_id )
    g_id += 1

graph_size = [ 0 for _ in range( n ) ]
for ver in range( n ):
    graph_size[ graph_id[ ver ] ] += 1

ans = [ graph_size[ graph_id[ ver ] ] for ver in range( n ) ]

for _ in range( k ):
    c, d = map( int, input().split() )
    if graph_id[ c - 1 ] == graph_id[ d - 1 ]:
        ans[ c - 1 ] -= 1
        ans[ d - 1 ] -= 1

for ver in range( n ):
    ans[ ver ] = ans[ ver ] - len( friend[ ver ] ) - 1

print( " ".join( map( str, ans ) ) )
Buggy python submission (verdict: Time Limit Exceeded):
h, n = map( int, input().split() )
a = []
b = []
for _ in range( n ):
    a_i, b_i = map( int, input().split() )
    a.append( a_i )
    b.append( b_i )

dp = [ float( "Inf" ) ] * ( h + 1 )
# dp[ d ] = dを与える最小マナ
dp[ 0 ] = 0
for i in range( h ):
    for j in range( n ):
        update_index = min( i + a[ j ], h )
        dp[ update_index ] = min( dp[ update_index ], dp[ i ] + b[ j ] )

print( dp[ h ] )

Fixed submission:
h, n = map( int, input().split() )
a = []
b = []
for _ in range( n ):
    a_i, b_i = map( int, input().split() )
    a.append( a_i )
    b.append( b_i )

dp = [ float( "Inf" ) ] * ( h + 1 )
# dp[ d ] = dを与える最小マナ
dp[ 0 ] = 0
for i in range( h ):
    for j in range( n ):
        update_index = min( i + a[ j ], h )
        dp[ update_index ] = min( dp[ update_index ], dp[ i ] + b[ j ] )

print( dp[ h ] )
Buggy python submission (verdict: Runtime Error):
def main():
	l,r,d = map(int,input().split())
    total = 0
    for i in range(l,r+1):
      if i%d == 0:
        total += 1
    
    print(total)
  
  
main()

Fixed submission:
def main():
    l,r,d = map(int,input().split())
    total = 0
    for i in range(l,r+1):
        if i%d == 0:
            total += 1

    print(total)
    

main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    arr = list(map(int,input().split()))
    total = 0
    for i in range(1,n+1):
        if arr[i-1]%2 == i%2 and i%2 != 0:
            total += 1

    print(total)
    

main()


Fixed submission:
def main():
    n = int(input())
    arr = list(map(int,input().split()))
    total = 0
    for i in range(1,n+1):
        if arr[i-1]%2 == i%2 and i%2 != 0:
            total += 1

    print(total)
    

main()
Buggy python submission (verdict: Time Limit Exceeded):
def dfs(node,visited,friends,connected_compnts):
    cmpnt = set()
    stack = [node]
    while stack:
        curr = stack.pop()
        if curr not in visited:
            visited.add(curr)
            cmpnt.add(curr)
            for kid in friends[curr]:
                stack.append(kid)

    connected_compnts.append(cmpnt)

def solve(cmpnt,friends,blocks,ans):
    arr = list(cmpnt)
    for node in arr:
        cmpnt.remove(node)
        add = []
        for kid in friends[node]:
            if kid in cmpnt:
                add.append(kid)
                cmpnt.remove(kid)

        blocked = set()
        for block in blocks[node]:
            blocked.add(block)
            
        ans[node] = len(cmpnt.difference(blocked))
        cmpnt.add(node)
        for kid in add:
            cmpnt.add(kid)

def main():
    n,m,k = map(int,input().split())
    friends = {}
    blocks = {}

    for i in range(1,n+1):
        friends[i] = []

    for i in range(1,n+1):
        blocks[i] = []

    for i in range(m):
        a,b = map(int,input().split())
        friends[a].append(b)
        friends[b].append(a)

    for i in range(k):
        a,b = map(int,input().split())
        blocks[a].append(b)
        blocks[b].append(a)

    connected_compnts = []

    visited = set()
    for i in range(1,n+1):
        if i not in visited:
            dfs(i,visited,friends,connected_compnts)

    ans = [0]*(n+1)
    for cmpnt in connected_compnts:
        solve(cmpnt,friends,blocks,ans)

    for i in range(1,n+1):
        print(ans[i],end = ' ')

main()


Fixed submission:
def dfs(node,visited,friends,connected_compnts):
    cmpnt = set()
    stack = [node]
    while stack:
        curr = stack.pop()
        if curr not in visited:
            visited.add(curr)
            cmpnt.add(curr)
            for kid in friends[curr]:
                stack.append(kid)

    connected_compnts.append(cmpnt)

def solve(cmpnt,friends,blocks,ans):
    arr = list(cmpnt)
    for node in arr:
        cmpnt.remove(node)
        add = []
        for kid in friends[node]:
            if kid in cmpnt:
                add.append(kid)
                cmpnt.remove(kid)

        blocked = set()
        for block in blocks[node]:
            blocked.add(block)
            
        ans[node] = len(cmpnt)-len(cmpnt&blocked)
        cmpnt.add(node)
        for kid in add:
            cmpnt.add(kid)

def main():
    n,m,k = map(int,input().split())
    friends = {}
    blocks = {}

    for i in range(1,n+1):
        friends[i] = []

    for i in range(1,n+1):
        blocks[i] = []

    for i in range(m):
        a,b = map(int,input().split())
        friends[a].append(b)
        friends[b].append(a)

    for i in range(k):
        a,b = map(int,input().split())
        blocks[a].append(b)
        blocks[b].append(a)

    connected_compnts = []

    visited = set()
    for i in range(1,n+1):
        if i not in visited:
            dfs(i,visited,friends,connected_compnts)

    ans = [0]*(n+1)
    for cmpnt in connected_compnts:
        solve(cmpnt,friends,blocks,ans)

    for i in range(1,n+1):
        print(ans[i],end = ' ')

main()