Problem:


Score : 100 points

Problem Statement

Snuke is giving cookies to his three goats.

He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).

Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.

Constraints

1 \leq A,B \leq 100

Both A and B are integers.

Input

Input is given from Standard Input in the following format:

A B

Output

If it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.

Sample Input 1

4 5

Sample Output 1

Possible

If Snuke gives nine cookies, each of the three goats can have three cookies.

Sample Input 2

1 1

Sample Output 2

Impossible

Since there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.



Sample input:
4 5


Sample output:
Possible

Submission status: Runtime Error

Solution code:
N,K=map(int,input().split())
st=list(map(int,input().split()))
len=0
st.sort()
st.reverse()
for x in range(K):
    len=len+st[x]
print(len)

Submission status: Runtime Error

Solution code:
a, b = input().split(' ')
c = int(a) + int(b)
if a%3==0 or b%3==0 or c%3==0:
  print("Possible")
else:
  print("Impossible")

Submission status: Runtime Error

Solution code:
a, b = input().split(' ')
c = int(a) + int(b)
if (a%3==0 and a > 3) or (b%3==0 and b>3) or (c%3==0 and c>3):
  print("Possible")
else:
  print("Impossible")

Submission status: Runtime Error

Solution code:
a, b = input().split(' ')
c = int(a) + int(b)
if (a%3==0 and a > 3) or (b%3==0&&b>3) or (c%3==0 &&c>3):
  print("Possible")
else:
  print("Impossible")

Submission status: Runtime Error

Solution code:
A B = map(int,input()split())

res = 'POSSIBLE'

if A%3 != 0:
  if B%3 != 0:
    if (A+B)%3 != 0:
      res = 'IMPOSSIBLE'
print(res)

Submission status: Runtime Error

Solution code:
import numpy as np

def splitting_pile():
	n = int(raw_input())
	nums = list(map(int, raw_input().split(" ")))
	ans = np.inf
	for i in range(1, n):
		ans = min(ans, abs(sum(nums[:i])-sum(nums[i:])))
	print ans


if __name__ == "__main__":
	splitting_pile()

Submission status: Runtime Error

Solution code:
a = input()
card_list = list(map((int),input().split(' ')))

sum_card = sum(card_list)
score = []
sunuke = 0

for i in range(int(a)-1):
    
    sunuke += card_list[i]
    score.append(abs(sum_card-2*sunuke))

print(min(score))

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
 
x=input()
a=int(x.split(" ")[0])
b=int(x.split(" ")[1])
y=input()
c=y.split(" ")
c=sorted(c,reverse=True)
sum = 0
for i in range(b):
    sum += int(c[i])
print (sum)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
N=int(input())
b=input()
c=b.split(" ")
d=map(int,c)
a=list(d)
sum_a=abs(sum(a))
ans=sum_a%2
if sum_a==0:
    A=map(abs,a)
    B=list(A)
    ans2=min(B)
    print(ans2*2)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
a=input()
b=a.split(" ")
A=b[0]
B=b[1]

C=A+B
if C%3==0 or A%3==0 or B%3==0:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
a = input().split(' ')
b = list(map((int), a))
sum = sum(b)
A = sum[0]
B = sum[1]

if sum % 3 == 0 || A % 3 == 0 || B % 3 == 0:
    print('Possible')

else:
    print('Impossible')

Submission status: Runtime Error

Solution code:
# coding: utf-8
a=input()
b=a.split(" ")
A=b[0]
B=b[1]
C=A+B
print(b)
if C%3==0:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
a=input()
b=a.split(" ")
A=b[0]
B=b[1]

C=A+B
if C%3==0:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
a=input()
a=[2,3]
b=a.split(",")
A=b[0]
B=b[1]

C=A+B
if C%3==0:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Here your code !
a=input()
b=a.split(" ")
A=b[0]
B=b[1]

C=A+B
if C%3==0:
    print("Possible")
elif:
    print("Impossible")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys

c = map[int, input().split()]
c[0] = c[0] % 3
c[1] = c[1] % 3

if c[0] % 3 == 0 || c[1]%3 == 0 || (c[0] + c[1])%3 == 0:
    print "Possible "
else:
    print "Impossible"

Submission status: Runtime Error

Solution code:
l = input()
a, b = l.split(" ")
if (a + b) % 3 == 0:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split(" "))
ls = list(map(int, input().split(" ")))

ls.sort()

print(ls[:k].sum())

Submission status: Runtime Error

Solution code:
a, b = input().split()

if (a+b) %3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
a, b = input().split(" ")

if (a+b) %3 == 0:
    print("Possible")
elif a%3 == 0:
    print("Possible")
elif b%3 == 0:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

input_line = sys.stdin.readline()

line = input_line.split(' ')
a = int(line[0])
b = int(lint[1])
c = a + b

if c > 2 and c % 3 == 0:
	print('Possible')

if a > 2 and a % 3 == 0:
	print('Possible')
	return

if b > 2 and b % 3 == 0:
	print('Possible')
	return

print('Impossible')

Submission status: Runtime Error

Solution code:
N, M = map(int, raw_input().split())
if (N+M) % 3 == 0:
	print  "Possible"
	return 0

if (N) % 3 == 0:
	print  "Possible"
	return 0

if (M) % 3 == 0:
	print  "Possible"
	return 0

print "Impossible"

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
nums=list(map(int,input().split()))

nums.sort()
nums.reverse()
ans=list()

for v in range(0,k):
    ans.append(nums[v])

print(sum(ans))

Submission status: Runtime Error

Solution code:
m, n = map(int, input().split())
M = list(map(int, input().split()))
M.sort()
M.reverse()
A = []
for i in range(n):
    A.append(M[i])
print(sum(A))

Submission status: Runtime Error

Solution code:
a, b = map(int, input())
print("Possible" if (a+b)%3==0 or a%3==0 or b%3==0 else "Impossible")

Submission status: Runtime Error

Solution code:
N = int(input())
list = input().rstrip().split()
a=[]
for i in range(N):
    a = a + [int(list[i])]
sunuke=0
arai = 0
for i in range(N):
    arai = arai + a[i]
for i in range(N):
    sunuke1 = sunuke + a[i]
    arai1 = arai - a[i]
    if sunuke1 > arai1:
        x = abs(sunuke-arai)
        y = abs(sunuke1-arai1)
        res = min(x,y)
        break
    else:
        sunuke = sunuke1
        arai = arai1
print(res)

Submission status: Runtime Error

Solution code:
a = input() 
b = input()
if (a % 3) * (b % 3) * ((a + b) % 3) == 0:
    print "Possible"
else:
    print "Impossible"

Submission status: Runtime Error

Solution code:
N = int(input())
l = [0] * N
l = list(map(int, input().split()))
sum = 0
a = [0] * N
for i in range(N):
    sum += l[i]
x = 0
result = 1145141919810931931
for i in range(N):
    x += l[i]
    if i + 1 < N:
        result = min((result, abs(sum - 2 * x)))
print(result)

Submission status: Runtime Error

Solution code:
N = int(input())
l = [0] * N
l = list(map(int, input().split()))
sum = 0
a = [0] * N
for i in range(N):
    sum += l[i]
x = 0
result = 1145141919810931931
for i in range(N):
    x += l[i]
    result = min((result, abs(sum - 2 * x)))
print(result)

Submission status: Runtime Error

Solution code:
def solution(a):
    A = a[0]
    B = sum(a) - a[0]
    Min = abs(A - B)
    for i in xrange(1, len(a)-1):
        A += a[i]
        B -= a[i]
        if Min > abs(A- B):
            Min = abs(A - B)
    print Min
import math
N = int(raw_input())
a = map( int, raw_input().split())
solution(a)

Submission status: Runtime Error

Solution code:
def solution(a):
    A = a[0]
    B = sum(a) - a[0]
    Min = abs(A - B)
    for i in xrange(1, len(a)-1):
        A += a[i]
        B -= a[i]
        if Min > abs(A- B):
            Min = abs(A - B)
    print Min
import math
N = int(raw_input())
a = map( int, raw_input().split())
solution(a)

Submission status: Runtime Error

Solution code:
#coding=UTF-8

N=int(input())
moti=list(range(0,N,1))

#initalize
for idx in range(0,N,1):
    moti[idx]=[]

#input
for idx in range(0,N-1,1):
    mozir=input()
    hyo=mozir.split(' ')
    a=int(hyo[0])-1
    b=int(hyo[1])-1

    moti[a].append(b)
    moti[b].append(a)

#path 0 to N-1
#width serach
belong=list(range(0,N,1))
for idx in range(0,N,1):
    belong[idx]=None

belong[0]="F"
belong[N-1]="S"

fennec_watch=[0]
sunuke_watch=[N-1]
fennec_haven=1
sunuke_haven=1
fennec_zou=1 #for breaking cond
sunuke_zou=1 #also
Teban="F"
while True:
    if Teban=="F":
        fennec_next=[]
        for mono in fennec_watch:
            kouho=moti[mono]
            for butu in kouho:
                if belong[butu]==None:
                    fennec_next.append(butu)
                    belong[butu]="F"

        fennec_watch=fennec_next
        fennec_zou=len(fennec_next)
        fennec_haven=fennec_haven+fennec_zou
    else:
        sunuke_next=[]
        for mono in sunuke_watch:
            kouho=moti[mono]
            for butu in kouho:
                if belong[butu]==None:
                    sunuke_next.append(butu)
                    belong[butu]="S"

        sunuke_watch=sunuke_next
        sunuke_zou=len(sunuke_next)
        sunuke_haven=sunuke_haven+sunuke_zou
        
    if fennec_zou==0 and sunuke_zou==0:
        break
    Teban='F' if Teban=='S' else 'S'

#when fennec_haven==sunuke_haven==k
#k+1 th turn fennec 33-4
if fennec_haven > sunuke_haven:
    print('Fennec')
else:
    print('Snuke')

Submission status: Runtime Error

Solution code:
N = int(input())
a = map(int, raw_input().split())
x = a[0]
y = sum(a) - a[0]
min = abs(x - y)
for i in range (1,N-1):
    y -= a[i]
    x += a[i]
    dummy = abs(x - y)
    if min > dummy:
        min = dummy
print min

Submission status: Runtime Error

Solution code:
A,B=map(int,input().split())
if A%3==0 pr B%3==0 or (A+B)%3==0:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
Inp = list(map(int, input().split()))
Blist = list(map(int, input().split()))
Blist.sort()

out = 0
for i in range(Imp[0,1]):
    out += Blist[-(i+1)]
    
print(out)

Submission status: Runtime Error

Solution code:
Imp = input()
 
A = int(Imp[0])
B = int(Imp[2])
re = 0
if A % 3 == 0:    
    re = 1
if B % 3 == 0:
    re = 1
if (A+B) % 3 == 0:
        re = 1
        
if re ==1:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
Imp = input()

A = int(Imp[0])
B = int(Imp[2])
re = 0
if A % 3 == 0:    
    re = 1
if B % 3 == 0:
    re = 1
if (A+B) % 3 == 0:
        re = 1
        
if re ==1:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
Imp = int(raw_input())
A = Imp[0]
B = Imp[1]
re = 0
if A % 3 == 0:    
    re = 1
if B % 3 == 0:
    re = 1
if (A+B) % 3 == 0:
        re = 1
        
if re ==1:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
import sys
Imp = [int(i) for i in sys.stdin]
A = Imp[0]
B = Imp[1]
re = 0
if A % 3 == 0:    
    re = 1
if B % 3 == 0:
    re = 1
if (A+B) % 3 == 0:
        re = 1
        
if re ==1:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a,b = I()
    if min(a % 3, b%3, (a+b)%3) == 0:
        return 'Possible'

    return 'Impossible'


print(main())

Submission status: Runtime Error

Solution code:
Imp = raw_input().split()
A = Imp[0]
B = Imp[1]
re = 0
if A % 3 == 0:    
    re = 1
if B % 3 == 0:
    re = 1
if (A+B) % 3 == 0:
        re = 1
        
if re ==1:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
Imp = input().split()
A = Imp[0]
B = Imp[1]
re = 0
if A % 3 == 0:    
    re = 1
if B % 3 == 0:
    re = 1
if (A+B) % 3 == 0:
        re = 1
        
if re ==1:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
Imp = <STDIN>
A = Imp[0]
B = Imp[1]
re = 0
if A % 3 == 0:    
    re = 1
if B % 3 == 0:
    re = 1
if (A+B) % 3 == 0:
        re = 1
        
if re ==1:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
Imp = input()
A = Imp[0]
B = Imp[1]
re = 0
if A % 3 == 0:    
    re = 1
if B % 3 == 0:
    re = 1
if (A+B) % 3 == 0:
        re = 1
        
if re ==1:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
re = 0
    if A % 3 == 0:    
        re = 1
    if B % 3 == 0:
        re = 1
    if (A+B) % 3 == 0:
        re = 1
        
 if re ==1:
    print("Possible")
else:
    print("Impossible")

Submission status: Runtime Error

Solution code:
    re = 0
    if A % 3 == 0:    
        re = 1
    if B % 3 == 0:
        re = 1
    if (A+B) % 3 == 0:
        re = 1
        
    if re ==1:
        return "Possible"
    else:
        return "Impossible"

Submission status: Runtime Error

Solution code:
def sa(_a,_b):
    a = max(_a,_b)
    b = min(_a,_b)
    return a-b

n = int(input())
l = list(map(int,input().split()))
m = sum(l)
a = l[0]
b = m - a
ans = sa(a,b)
for i in range(1,len(l)-1):
    a += l[i]
    b -= l[i]
    ans = min(ans,sa(a,b))
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(1000000)
n=input()
graph=[[] for i in range(n+1)]
for i in range(n-1):
    v,u=list(map(int,raw_input().split()))
    graph[v].append(u)
    graph[u].append(v)

dist= [-1 for i in range(n+1)]
dist[1]=0
son=[[] for i in range(n+1)]
queue=[1]
father=[0 for i in range(n+1)]
def bfs(u):
    for v in graph[u]:
        if dist[v]==-1:
            dist[v]=dist[u]+1
            son[u].append(v)
            father[v]=u
            queue.append(v)
    queue.pop(0)
    if len(queue)!=0:
        bfs(queue[0])

bfs(1)
road=[n]
tempfather=n
for i in range(dist[n]):
    road.append(father[tempfather])
    tempfather=father[tempfather]

di=len(road)
k=road[(di-2)/2]

def countson(u):
  count=0
  if len(son[u])==0:return 1
  for v in son[u]:
      count+=countson(v)
  return count+1

cs=countson(k)
cf=n-cs

if cs>=cf:print 'Snuke'
else:
    print 'Fennec'

Submission status: Runtime Error

Solution code:
def solution(n, k, l_list):
    l_list.sort(reverse=True)
    result = sum(l_list[:k])
    return result


N, K = [int(value) for value in input().split(' ')]
l_list = [int(value) for value in input().split(' ')]
print(solution(N, K, l_list))

Submission status: Runtime Error

Solution code:
def solution(a, b):
    total = a + b
    if total % 3 == 0:
        print('Possible')
    elif a % 3 == 0:
        print('Possible')
    elif:
        b % 3 == 0:
        print('Possible')
    else:
        print('Impossible')

A, B = input().split(' ')
A, B = int(A), int(B)

solution(A, B)

Submission status: Runtime Error

Solution code:
def solution(a, b):
    total = a + b
    if (total % 3 == 0) and total >= 3:
        print('Possible')
    else:
        print('Impossible')

A, B = raw_input().split(' ')
A, B = int(A), int(B)

solution((A, B))

Submission status: Runtime Error

Solution code:
A=int(input()) % 3
B=int(input()) % 3
C=A + B
 
if  A==0 or B==0 or C==0: print("Possible")
else: print("Impossible")

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
c=a+b
 
if  a%3==0 or b%3==0 or c%3==0: print("Possible")
else: print("Impossible")

Submission status: Runtime Error

Solution code:
a=int(input())
b=int(input())
c=a + b
 
if  a%3==0 or b%3==0 or c%3==0: print("Possible")
else: print("Impossible")

Submission status: Runtime Error

Solution code:
A=int(input())
B=int(input())
C=A + B
 
if  A%3==0 or B%3==0 or C%3==0: print("Possible")
else: print("Impossible")

Submission status: Runtime Error

Solution code:
N=int(input())
an=list(map(int,input().split()))
s = sum(an)
h = s/2
f=int(N/2)
x = sum(an[:f])
y = s - x
z=abs(x-y)
for i in range(f):
    if f+1 >= N:
        break
    t1=x + an[f+1]
    t2=y - an[f+1]
    t3=x - an[f-1]
    t4=y + an[f-1]
    print(t1,t2)
    k1=abs(t1-t2)
    k2=abs(t3-t4)
    p=0
    k = min(k1,k2)
    if k1 > k2:
        p = -1
    else:
        p = 1
    if z > k:
        f = f + p
        z = k
    else:
        break
print(z)

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())

    tree = [[] for i in range(N)]
    for n in range(N-1):
        a, b = map(lambda x: int(x)-1, input().split())
        tree[a].append(b)
        tree[b].append(a)

    # print(np.array(tree))

    Q = [(x, [0, x], 0) for x in tree[0]]
    reached = [1] + [0]*(N-2) + [0]
    while len(Q) > 0:
        new_pos, root, cost = Q.pop()
        reached[new_pos] = 1

        if new_pos == N-1:
            break

        #add to Q
        for p in tree[new_pos]:
            new_root = root[:]
            if reached[p] == 0:
                new_root.append(p)
                Q.append((p, new_root, cost+1))

    l = math.ceil(len(root)/2) - 1
    r = l + 1

    # print(root, l, r)
    tree[root[l]].remove(root[r])
    tree[root[r]].remove(root[l])
    # print(tree, tree)

    F = tree[0]
    S = tree[N-1]

    reached = [1] + [0]*(N-2) + [1]
    while True:
        if len(F) == 0:
            print("Snuke")
            break
        else:
            pos = F.pop()
            reached[pos] = 1
            for p in tree[pos]:
                if reached[p] == 0:
                    F.append(p)

        if len(S) == 0:
            print("Fennec")
            break
        else:
            pos = S.pop()
            reached[pos] = 1
            for p in tree[pos]:
                if reached[p] == 0:
                    S.append(p)



if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
Roads = []
for i in range(N-1):
    Roads.append(input().split())
black = 0
black_list = []
white = 0
white_list = []

for i in Roads:
    if 1 in i and N not in i:
        black += 1
    if N in i and 1 not in i:
        white += 1


if black > white :
    print("Fennec")
else:
    print("Snuke")

Submission status: Runtime Error

Solution code:
if (a+b)%3 or a%3 or b%3==0:
    print ('Possible')
else: print('Impossible')

Submission status: Runtime Error

Solution code:
if __name__=='__main__':
    alls = int(input())
    num_src = input().split(' ')
    num_cards = []
    ans = 0
    for i in num_src:
        num_cards.append(int(i))
        ans += abs(int(i))
    x = 0
    y = 0
    for i in range(0,alls-1):
        x=0
        y=0
        for j in range(0,alls):
            if j <= i:
                x += num_cards[j]
            else:
                y += num_cards[j]
        if y<x:
            tmp = abs(x-y)
        else:
            tmp = abs(y-x)
        if tmp < ans:
            ans = tmp
    print(ans)

Submission status: Runtime Error

Solution code:
A=int(input())
B=int(input())
C=A + B

if  A % 3 == 0 or B % 3 == 0 or C % 3 == 0:
 print("Possible")
else:
 print("Impossible")

Submission status: Runtime Error

Solution code:
A=int(input())
B=int(input())
C=A + B

if  A % 3 == 0 : print("Possible")
else: print("Impossible")
if B % 3 == 0 : print("Possible")
else: print("Impossible")
if C % 3 == 0 : print("Possible")
else: print("Impossible")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys

c = map[int, input().split()]
if c[0] % 3 == 0 || c[1]%3 == 0 || (c[0] + c[1])%3 == 0:
    print "Possible "
else:
    print "Impossible"

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-

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

SUM_CARD = sum(a)

i=1

diff_sum = 0
sunuke = sum(a[0:i])
diff_sum = abs(sunuke*2-SUM_CARD)
i+=1

while(i<N):
    sunuke = sum(a[0:i])
    diff_sum_new = abs(sunuke*2-SUM_CARD)
    if diff_sum_new<diff_sum:
        diff_sum = diff_sum_new
    i += 1

print(diff_sum)

Submission status: Runtime Error

Solution code:
n= int(input())
card = input().split(' ')
card = [int(s) for s in card]
min_s = 20000000
sum1 = sum(card[:1])
sum2 = sum(card[1:])
for i in range(n - 1):
    dif  = abs(sum1-sum2)

    if dif  < min_s:
        min_s = dif
    sum1 += card[i+1]
    sum2 = sum2 - card[i+1]
print(min_s)

Submission status: Runtime Error

Solution code:
A=int(input())
B=int(input())

if  A % 3 == 0 : print("Possible")
else: print("Impossible")
if B % 3 == 0 : print("Possible")
else: print("Impossible")
if A+B % 3 == 0 : print("Possible")
else: print("Impossible")

Submission status: Runtime Error

Solution code:
n= int(input())
card = input().split(' ')
card = [int(s) for s in card]
min_s = 1000000000000
for i in range(n -1):
    dif  =abs(sum(card[:i+1]) - sum(card[i+1:]))
    if dif  < min_s:
        min_s= dif
    
print(min_s)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
diff = []
for i in range(N-1):
    diff.append(abs(sum(a[:i+1]) - sum(a[i+1:])))
print(min(diff))

Submission status: Runtime Error

Solution code:
n,k=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
l.sort()
a=0
for i in range(k):
  a+=l[n-1-i]
print(a)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python

N,K=map(int,raw_input().split())
l=map(int,raw_input().split())
l.sort()
print sum(l[len(l)-K:len(l)])

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

N, K = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]

l.sort(reverse=True)
print(sum(l[:K]))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys

A, B = map(int, input().split())

C = A + B

if A%3 == 0:
    print('Possible')
else if B%3 == 0:
    print('Possible')
else if C%3 == 0:
    print('Possible')
else:
    print('Impossible')

Submission status: Runtime Error

Solution code:
def main():
    N, K = map(int, input().split())
    L = list(map(int, input().split()))
    L.sort(reverse=True)

    print(sum(L[:K]))

if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()