Problem:


Score : 100 points

Problem Statement

You will be given an integer a and a string s consisting of lowercase English letters as input.

Write a program that prints s if a is not less than 3200 and prints red if a is less than 3200.

Constraints

2800 \leq a < 5000

s is a string of length between 1 and 10 (inclusive).

Each character of s is a lowercase English letter.

Input

Input is given from Standard Input in the following format:

a
s

Output

If a is not less than 3200, print s; if a is less than 3200, print red.

Sample Input 1

3200
pink

Sample Output 1

pink

a = 3200 is not less than 3200, so we print s = pink.

Sample Input 2

3199
pink

Sample Output 2

red

a = 3199 is less than 3200, so we print red.

Sample Input 3

4049
red

Sample Output 3

red

a = 4049 is not less than 3200, so we print s = red.



Sample input:
3200
pink


Sample output:
pink

Submission status: Runtime Error

Solution code:
n = int(input())
a = map(int, input().split)

sum = 0.0
for x in a:
  sum = sum + 1 / x

print(1/sum)

Submission status: Runtime Error

Solution code:
a = int(input())
s = input()

if (a >= 3200):
  print s
else:
  print('red')

Submission status: Runtime Error

Solution code:
a = input()
s = input()

if (a >= 3200):
  print s
else:
  print('red')

Submission status: Runtime Error

Solution code:
a = input()
s = input()

print(s if (a >= 3200) else 'red')

Submission status: Runtime Error

Solution code:
n1 = int(input())
n2 = int(input())

if n1 >= 3200:
    print(n2)
else:
    print("red")

Submission status: Runtime Error

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

a = int(input())
s = input()

if a => 3200:
    print(s)

elif:
    print("red")

Submission status: Runtime Error

Solution code:
a = int(input())
s = input()

if a => 3200:
    print(s)

elif:
    print("red")

Submission status: Runtime Error

Solution code:
N = int(input())
A = map(int,input().split())
print('{:.16g}'.format(1 / sum(1 /x for x in A)))

Submission status: Runtime Error

Solution code:
a = input()
b = input()
if 2800 <= a and a<3200:
    print("red")
elif 3200 <=a and a <=5000:
    print(b)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
if 2800 <= a and a<3200:
    print("red")
elif 3200 <=a and a <=5000:
    print(b)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
if 2800 <= a and a<3200:
    print("red")
else if 3200 <=a and a <=5000:
    print(b)

Submission status: Runtime Error

Solution code:
a = input()
b = input()
if a<3200:
    print("red")
else:
    print(b)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
if 2800<=a and a<3200:
    print("red")
else:
    print(b)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
if 2800<=a and a<3200:
    print("red")
else  
    print(b)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
if 2800<=a and a<3200:
    print("red")
else if 3200 <= a and a <= 5000:
    print(b)

Submission status: Runtime Error

Solution code:
a,s = int(input()),input()
if a <= 3200:
  print(s)
else
  print('red')

Submission status: Runtime Error

Solution code:
a,s = int(input()),input()
if a >= 3200:
  print(s)
else
  print('red')

Submission status: Runtime Error

Solution code:
if 3200 <= a:
  print(s)
else:
  print('red')

Submission status: Runtime Error

Solution code:
from heapq import heappush, heappop, heapify

n = int(input())
values = list(map(int, input().split()))

heapify(values)

while len(values) > 1:
  a = heappop(values)
  b = heappop(values)
  heappush(values, (a+b) / 2)
  
print(values[0])

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    N, Q = map(int, input().split())
    ans = [[0, deque()] for _ in range(N)]

    for _ in range(N - 1):
        p, c = map(int, input().split())
        ans[p-1][1].append(c-1)
        ans[c-1][1].append(p-1)

    for _ in range(Q):
        p, v = map(int, input().split())
        ans[p-1][0] += v

    def add_value(node, parent):
        val = ans[node][0]
        children = ans[node][1]
        for child in children:
            if child == parent:
                continue
            ans[child][0] += val
            add_value(child, node)

    add_value(0, -1)

    print(' '.join([str(x[0]) for x in ans]))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline


def main():
    N, Q = map(int, input().split())
    ans = deque([0] * N)
    con = [[] for i in range(N)]

    for _ in range(N - 1):
        p, c = map(int, input().split())
        con[p-1].append(c-1)
        con[c-1].append(p-1)

    for _ in range(Q):
        p, v = map(int, input().split())
        ans[p-1] += v

    stacks = deque()
    stacks.append((0, -1))

    while stacks:
        stack = stacks.pop()
        node, parent = stack[0], stack[1]

        children = con[node]
        for child in children:
            if child == parent:
                continue
            ans[child] += ans[node]
            stacks.append((child, node))

    print(*ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline


def main():
    N, Q = map(int, input().split())
    ans = deque([0] * N)
    con = deque([[] for _ in range(N)])

    for _ in range(N - 1):
        p, c = map(int, input().split())
        con[p-1].append(c-1)
        con[c-1].append(p-1)

    for _ in range(Q):
        p, v = map(int, input().split())
        ans[p-1] += v

    stacks = deque()
    stacks.append((0, -1))

    while stacks:
        stack = stacks.pop()
        node, parent = stack[0], stack[1]

        children = con[node]
        for child in children:
            if child == parent:
                continue
            ans[child] += ans[node]
            stacks.append((child, node))

    print(*ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline


def main():
    N, Q = map(int, input().split())
    con = [[] for i in range(N)]
    ans = [0] * N

    for _ in range(N - 1):
        p, c = map(int, input().split())
        con[p-1].append(c-1)
        con[c-1].append(p-1)

    for _ in range(Q):
        p, v = map(int, input().split())
        ans[p-1] += v

    stacks = deque()
    stacks.append((0, -1))

    while stacks:
        stack = stacks.pop()
        node, parent = stack[0], stack[1]

        children = con[node]
        for child in children:
            if child == parent:
                continue
            ans[child] += ans[node]
            stacks.append((child, node))

    print(*ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from collections import deque


def main():
    N, Q = map(int, input().split())
    ans = deque([0] * N)
    con = deque([[] for _ in range(N)])

    for _ in range(N - 1):
        p, c = map(int, input().split())
        con[p-1].append(c-1)
        con[c-1].append(p-1)

    for _ in range(Q):
        p, v = map(int, input().split())
        ans[p-1] += v

    stacks = deque()
    stacks.append((0, -1))

    while stacks:
        stack = stacks.pop()
        node, parent = stack[0], stack[1]

        children = con[node]
        for child in children:
            if child == parent:
                continue
            ans[child] += ans[node]
            stacks.append((child, node))

    print(*ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline


def main():
    N, Q = map(int, input().split())
    ans = deque([0] * N)
    con = deque([[] for _ in range(N)])

    for _ in range(N - 1):
        p, c = map(int, input().split())
        con[p-1].append(c-1)
        con[c-1].append(p-1)

    for _ in range(Q):
        p, v = map(int, input().split())
        ans[p-1] += v

    stacks = deque()
    stacks.append((0, -1))

    while stacks:
        stack = stacks.pop()
        node, parent = stack[0], stack[1]

        children = con[node]
        if children:
            for child in children:
                if child == parent:
                    continue
                ans[child] += ans[node]
                stacks.append((child, node))

    print(*ans, sep=' ')


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
a=int(input())
s=input()

if a>=3200:
    input(s)
else:
    input("red")

Submission status: Runtime Error

Solution code:
a=int(input())
s=str(input())

if a>=3200:
    input(s)
else:
    input("red")

Submission status: Runtime Error

Solution code:
a = int(input())
s = input()

res = a >= 3200 ? s : "red"
print(res)

Submission status: Runtime Error

Solution code:
n,q = map(int,input().split())
a,b = [],[]
for i in range(n-1):
    a1,b1=[int(i) for i in input().split()]
    a.append(a1)
    b.append(b1)
p,x = [],[]
for j in range(q):
    p1,x1=[int(j) for j in input().split()]
    p.append(p1)
    x.append(x1)
    
z = [0]*n
for k in range(q):
  z[p[k]-1] = z[p[k]-1] + x[k]
for l in range(n-1):
  z[b[l]-1] = z[b[l]-1] + z[a[l]-1]    
print(*z)

Submission status: Runtime Error

Solution code:
n = int(input())
a = map(int,input().split())
print('{:.16g}'.format(1/sum(1/x for x in a)))

Submission status: Runtime Error

Solution code:
if(a>3199,s,'red')

Submission status: Runtime Error

Solution code:
P, n = map(int, input().split())
struct = [list(map(int, input().split())) for x in range(P-1)]
act = [list(map(int, input().split())) for y in range(n)]

A = []


def add_val(action):
    idx = action[0]
    val = action[1]

    A[idx][0] += val

    if A[idx][1]:
        for r in A[idx][1]:
            add_val([r, val])


for a in range(P + 1):
    A.append(list([0, []]))

for z in struct:
    p = z[0]
    p_ = z[1]
    A[p][1].append(p_)

for _ in act:
    add_val(_)


As = []
for _ in range(1, len(A)):
    As.append(A[_][0])

print(*As, sep=' ')

Submission status: Runtime Error

Solution code:
N = int(input())
v = list(map(int, input().split()))
i = 0

v.sort

for i in range(N - 1):
    v[i + 1] = (v[i] + v[i + 1]) / 2
    
print(v[-1])

Submission status: Runtime Error

Solution code:
$file=Get-ChildItem C:\work\*.txt -Name

foreach($list in $file){
	$list2 = $list -replace ".txt",""
	Rename-Item $list -newName $list2#mae.txt
}




$f = (Get-Content aaa.txt) -as [string[]]
foreach ($l in $f) {
    if ($l -like "*#"){
	$ll = $l
	$ll = $ll -replace "#",".txt"
	Rename-Item aaa.txt -newName $ll
    }
}

Submission status: Runtime Error

Solution code:
a,s=input().split('\n')
a=int(a)
if a<=3200:
  print(s)
else:
  print(s)

Submission status: Runtime Error

Solution code:
def dfs(v,p):
    for i in tree[v]:
        if i==p:
            continue
        res[i]+=res[v]
        dfs(i,v)

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

res = [0]*n
for i in range(q):
    p,x = map(int,input().split())
    res[p-1] += x

dfs(0,-1)
print(*res)

Submission status: Runtime Error

Solution code:
a = input()
s = input()
if a < 3200:
  print("red")
else:
  print(s)

Submission status: Runtime Error

Solution code:
# -*- coding utf-8 -*-
MOD = 10 ** 9 + 7

a = int(input())
b = input()

if a >= 3200:
    print(s)
else:
    print('red')

Submission status: Runtime Error

Solution code:
def main():
	import sys
	sys.setrecursionlimit(700000)
	N, Q = map(int, input().split())
	d = [[] for i in range(N)]

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

	ans = [0]*N

	for i in range(Q):
		p, x = map(int, input().split())
		p -= 1
		ans[p] += x

	def dfs(cur, parent):
		for child in d[cur]:
			if child != parent:
				ans[child] += ans[cur]
				dfs(child,cur)
	dfs(0,-1) 
	print(*ans)
    
main()

Submission status: Runtime Error

Solution code:
n = int(input())
numbers = []
i = 0
while i <= n:
  numbers.append(int(input()))
  i += 1

j = 0
s = 0
while n >= j:
  s += 1/numbers[j]
  i += 1

print(1/s)

Submission status: Runtime Error

Solution code:
n = int(input())
v = list(map(int,input().split()))
kati = 0

v.sort()
kati = (v[0] + v[1]) / 2

if n == 2:
  print(kati)
else:
  for i in range(2,n):
    kati = (kati + v[i]) / 2
  print(kati)

Submission status: Runtime Error

Solution code:
a = int(input())
s = input()
if a >= 3200:
  print(S)
else:
  print('red')

Submission status: Runtime Error

Solution code:
a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print(red)

Submission status: Runtime Error

Solution code:
a=int(input())
s=input()

if a>=3200:
    print(s)
else if a<3200:
    print("red")

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(2*10**5)
n,q=map(int,input().split())
graph=[[] for _ in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  graph[a-1].append(b-1)
  graph[b-1].append(a-1)
counter=[0]*n
for _ in range(q):
  p,x=map(int,input().split())
  counter[p-1]+=x
score=[0]*(n+1)
stack=[(0,-1)]
while stack!=[]:
  node,prev=stack.pop()
  score[node]=score[prev]+counter[node]
  for i in graph[node]:
    if i!=prev:
      stack.append((i,node))
print(*score[:-1])

Submission status: Runtime Error

Solution code:
a = int(input())
s =input()
if a >=3200:
  print(S)
else:
  print("red")

Submission status: Runtime Error

Solution code:
if a >= 3200:
  print(s)
else:
  print("red")

Submission status: Runtime Error

Solution code:
n,q = input().split()
#print(str(n))
#print(str(q))

n = int(n)
q = int(q)
a = [0] * (n-1)
b = [0] * (n-1)
p = [0] * q
x = [0] * q
counter = [0] * n
children = []
parent = [-1] * n

for c in range(n):
  children.append(str(c+1))
#print(children)

for i in range(n-1):
  a[i],b[i] = input().split()
  parent[int(b[i]) - 1] = int(a[i])-1#親の配列インデックス
  children[int(a[i])-1]+=(" "+b[i])
  children[parent[int(a[i])-1]] += (" "+b[i])

for j in range(q):
  p[j],x[j] = input().split()
  list = children[int(p[j])-1].split()
  #print(list)
  for aa in list:
    counter[int(aa)-1] += int(x[j])
for bb in counter:
  print(bb, end="")
  print(" ", end="")

Submission status: Runtime Error

Solution code:
n,q = input().split()
#print(str(n))
#print(str(q))
 
n = int(n)
q = int(q)
a = [0] * (n-1)
b = [0] * (n-1)
p = [0] * q
x = [0] * q
counter = [0] * n
children = []
parent = [-1] * n
 
for c in range(n):
  children.append(str(c+1))
#print(children)
 
for i in range(n-1):
  a[i],b[i] = input().split()
  parent[int(b[i]) - 1] = int(a[i])-1#親の配列インデックス
  children[int(a[i])-1]+=(" "+b[i])
  children[parent[int(a[i])-1]] += (" "+b[i])
 
for j in range(q):
  p[j],x[j] = input().split()
  list = children[int(p[j])-1].split()
  #print(list)
  for aa in list:
    counter[int(aa)-1] += int(x[j])
for bb in counter:
  print(bb, end="")
  print(" ", end="")

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)
n,q = map(int,input().split())
a=[[] for i in range(n)]
p=[]*n
l=[0]*n
ans=[0]*n

def dfs(parent,current,value):
    value += l[current]
    ans[current] = value
    for i in a[current]:
        if i == parent:
            continue
        dfs(current,i,value)


for i in range(n-1):
    t1,t2 = map(int,input().split())
    a[t1-1].append(t2-1)
    a[t2-1].append(t1-1)
    
for i in range(q):
    t1,t2 = map(int,input().split())
    l[t1-1]+=t2
dfs(-1,0,0)

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

Submission status: Runtime Error

Solution code:
a = int(input())
s = input()

if a < 3200:
  print('red')
 else:
  print(s)

Submission status: Runtime Error

Solution code:
from operator import itemgetter

i, q = [int(x) for x in input().split(' ')]

root = Node(1)
for idx in range(i-1):
    a, b = [int(x) for x in input().split(' ')]
    root.add_child(a, b)

for _ in range(q):
    p, x = [int(x) for x in input().split(' ')]
    root.set_count(p, x)

root.add_count()

counts = sorted(root.get_counts(), key=itemgetter(0))
print(' '.join([str(x[1]) for x in counts]))


class Node:
    def __init__(self, id):
        self.id = id
        self.count = 0
        self.children = []

    def add_child(self, parent_id, child_id):
        if parent_id < self.id:
            return

        if parent_id == self.id:
            # 追加
            self.children.append(Node(child_id))
            return

        for child in self.children:
            child.add_child(parent_id, child_id)
        return

    def set_count(self, target_id, num, is_count=False):
        # if target_id == self.id:
        #     is_count = True

        # if is_count:
        #     self.count += num

        # for child in self.children:
        #     child.add_count(target_id, num, is_count)
        if target_id < self.id:
            return
        if target_id == self.id:
            self.count += num
            return
        for child in self.children:
            child.set_count(target_id, num, is_count)
        return

    def add_count(self, num=0):
        self.count += num
        for child in self.children:
            child.add_count(self.count)
        return

    def get_counts(self):
        res = [(self.id, self.count)]
        # print(self.id, self.count)
        for child in self.children:
            res += child.get_counts()
        return res

Submission status: Runtime Error

Solution code:
# input
n, q = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(n-1)]
PX = [tuple(map(int, input().split())) for _ in range(q)]

# other_setting
child = [0] * n
parent = [0] * n
value = [0] * n

for i in range(n) : 
    child[i] = []

for a, b in AB : 
    child[a-1].append(b)
    parent[b-1] = a

# op_function
def op(a) : 
    if a != 1 : 
        value[a-1] += value[parent[a-1]-1]

    if child[a-1] != [] : 
        for c in child[a-1] : 
            op(c)
            
# initial_state(value)
for p, x in PX : 
    value[p-1] += x
    
# exe
op(1)

print(*value)

Submission status: Runtime Error

Solution code:
if a >= 3200:
  print(s)
else:
  print('red')

Submission status: Runtime Error

Solution code:
a = int(input)
s = input()
if a >= 3200:
  print(s)
else:
  print("red")

Submission status: Runtime Error

Solution code:
a=int(input())
s=input()
if a >= 3200:
  proint("red")
else:
  print(s)

Submission status: Runtime Error

Solution code:
a = int(input()
b = input()    
if (a) < 3200):
  print("red")
else:
  print(b)

Submission status: Runtime Error

Solution code:
n = int(input())
m = list(map(int,input().split()))
o = []
c  = 0
for i in m:
  o.append(1/m[c])
  c += 1
s = sum(o)
print(1/s)

Submission status: Runtime Error

Solution code:
n = int(input())
m = list(map(int,input().split()))
o = []
for i in m:
  o.append(float(1/m[i]))
p = sum(o) 
print(1/p)

Submission status: Runtime Error

Solution code:
n = int(input())
m = list(map(int,input().split()))
o = []
for i in m:
  o.append(float(1/a[i]))
p = sum(o) 
print(1/p)

Submission status: Runtime Error

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

def ave(c1,c2):
  av = (c1 + c2)/2
  return av

for i in range(N-1):
  for j in range(i+1,N):
    if a[j] <= a[i]:
      tmp = a[i]
      a[i] = a[j]
      a[j] =tmp
print(a)

for i in range(N-1):
  average = ave(a[0],a[1])
  a.pop(0)
  a.pop(0)
  a.insert(0,average)

print(int(a[0]))

Submission status: Runtime Error

Solution code:
a = input()
s = input() if a < 3200 else 'red'
print(s)

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter
from collections import defaultdict
sys.setrecursionlimit(10**8)
input = lambda: sys.stdin.readline()[:-1]
cnt=Counter()
data=defaultdict(set)
visited=Counter()
n,q=map(int,input().split())
ab=[tuple(map(int,input().split())) for i in range(n-1)]
px=[tuple(map(int,input().split())) for i in range(q)]
ab.sort(key=lambda tup:(tup[0],tup[1]))
for i in ab:
	data[i[0]].add(i[1])
	data[i[1]].add(i[0])
for j in px:
	cnt[j[0]]+=j[1]

def plus(now,value):
	for i in data[now]:
		if not visited[i]:
			cnt[i]+=value
			visited[i]=1
			print(cnt)	
			plus(i,cnt[i])
		
		
cnt[1]+=0
visited[1]=1
plus(1,cnt[1])
print(cnt)

ans=list(cnt.items())
ans.sort(key=lambda tup:tup[0])
ans =[str(i[1]) for i in ans]
print(' '.join(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
s = input()

if N >= 3200:
  print(s)
else:
  print(red)

Submission status: Runtime Error

Solution code:
a = int(input())
s = input()
if a >= 3200:
  print(s)
else:
  print(red)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N-1)]
PX = [list(map(int, input().split())) for _ in range(Q)]
 
g = [[] for _ in range(N+1)]
for a,b in AB:
    g[a].append(b)
    g[b].append(a)
    
cnt = [0] * (N+1)
for p,x in PX:
    cnt[p] += x

# v: node, p: parent node, add: parent value
def dfs(v, p, add):
    cnt[v] += add
    for nv in g[v]:
        if nv == p:
            continue
        dfs(nv, v, cnt[v])
 
dfs(1, 0, 0)

print(' '.join(map(str, cnt[1:])))

Submission status: Runtime Error

Solution code:
from collections import deque
import sys
input = sys.stdin.readline

def main():
    N, Q = map(int, input().split())
    edges = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        edges[b-1].append(a-1)
        edges[a-1].append(b-1)

    counts = [0]*N
    for _ in range(Q):
        p, x = map(int, input().split())
        counts[p-1] += x

    parent_nodes = deque()
    parent_nodes.append(0)
    visited_nodes = set()
    while parent_nodes:
        parent = parent_nodes.popleft()
        if parent in visited_nodes:
            continue
        visited_nodes.add(parent)
        for child in edges[parent]:
            if child in visited_nodes:
                continue
            counts[child] += counts[parent]
            parent_nodes.append(child)

    print(' '.join(list(map(str, counts))))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
a = int(input())
s = input()
if a < 3200:
  print('red')
else:
  print(s

Submission status: Runtime Error

Solution code:
n, q = map(int, input().split())

stack = [[] for _ in range(n+1)]
stack[0].append(1)
for i in range(n-1):
  a,b = map(int, input().split())
  stack[a].append(b)

ans = [0] * n
pool = {}
def dfs(cur, num):
	ans[cur-1] += num
	if len(stack[cur]) <= 0:
		return
	for c in stack[cur]:
		dfs(c, num)

for i in range(q):
  p, x = map(int, input().split())
  pool[p] = pool.get(p, 0) + x
for k, v in pool.items():
  dfs(k, v)
print(*ans)

Submission status: Runtime Error

Solution code:
N,Q=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N-1)]
A.sort()
 
cost=[0]*(N+1)
 
for _ in range(Q):
	a,b=map(int,input().split())
	cost[a]+=b
 
for a in A:
	cost[a[1]] += cost[a[0]]
print(*cost[1:])
N,Q=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(N-1)]
A.sort()

cost=[0]*(N+1)

for _ in range(Q):
	a,b=map(int,input().split())
	cost[a]+=b

for a in A:
	cost[a[1]] += cost[a[0]]
print(*cost[1:])

Submission status: Runtime Error

Solution code:
N,Q = map(int, input().split())

score = [0 for _ in range(N)]
 
# 子頂点番号:親頂点番号のdictを生成する
d = {}
for i in range(1,N):
  a,b = map(int,input().split())
  d[b] = a
      
# スコア加算処理
for i in range(1,Q+1):
  p,x = map(int,input().split())
  score[p-1] = x  
for i in range(1,len(score)):
  addScore = score[d[i+1]-1]
  score[i] += addScore
print(*score)

Submission status: Runtime Error

Solution code:
n, q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n-1)]
PX = [list(map(int, input().split())) for _ in range(q)]

stack = [[] for _ in range(n+1)]
stack[0].append(1)
for i in range(n-1):
	stack[AB[i][0]].append(AB[i][1])

ans = [0] * n
pool = {}
def dfs(cur, num):
	ans[cur-1] += num
	if len(stack[cur]) <= 0:
		return
	for c in stack[cur]:
		dfs(c, num)

for px in PX:
	pool[px[0]] = pool.get(px[0], 0) + px[1]
for k, v in pool.items():
  	dfs(k, v)
print(*ans)

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<string>
using namespace std;

int main(){
    int i;
    string s;
    cin >> i;
    cin >> s;
    if(i < 32000){
        cout << "red" << endl;
    }
    else{
        cout << s << endl;
    }
}

Submission status: Runtime Error

Solution code:
n, q = map(int, input().split())
# tree = [list(map(int, input().split())) for i in range(n-1)]
edges = [set() for i in range(n)]
for _ in range(n-1):
    a, b= map(int,input().split())
    edges[a-1].add(b-1)
cnt = [0] * n

for _ in range(q):
    p, x = map(int, input().split())
    cnt[p-1] += x

l = [[0, cnt[0]]]
while len(l) != 0:
    a, b = l.pop()
    if a != 0:
        cnt[a] += b
    for i in edges[a]:
        l.append((i, cnt[a]))
print(*cnt)

Submission status: Runtime Error

Solution code:
N, Q = map(int, input().split())
lst = []
cnt = []
ans = [0]*N
for i in range(N-1):
    lst.append(sorted(list(map(int, input().split()))))
lst = sorted(lst)
print(lst)
for j in range(Q):
    cnt.append(list(map(int, input().split())))
               
for k in cnt:
    ans[k[0]-1] += k[1]
for i in lst:
    ans[i[1]-1] += ans[i[0]-1]
for a in ans:
    print(a, end=" ")

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)
 
def resolve():
    def dfs(num, p=-1):
        for i in to[num]:
            if p == i:
                continue
            ns[i] += ns[num]
            dfs(i, num)
 
    n, q = map(int, input().split())
 
    to = [[] for _ in range(n)]
 
    for _ in range(n-1):
        a,b = map(int, input().split())
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)
 
    ns = [0 for _ in range(n)]
    for _ in range(q):
        p, x = map(int, input().split())
        p -= 1
        ns[p] += x
 
    dfs(0)
    print(*ns)
resolve()

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
sys.setrecursionlimit(500000)
input=sys.stdin.readline
n,q=map(int,input().split())
edge=[[] for i in range(n)]
cost=[0]*n
for i in range(n-1):
  p,s=map(int,input().split())
  p-=1;s-=1
  edge[p].append(s)
  edge[s].append(p)
for i in range(q):
  x,c=map(int,input().split())
  x-=1
  cost[x]+=c
visited=[False]*n
queue=deque([0])
visited[0]=True
while len(queue)!=0:
  a=queue.popleft()
  for i in edge[a]:
    if visited[i]==True:continue
    queue.append(i)
    visited[i]=True
    cost[i]+=cost[a]
for i in range(n):
  cost[i]=str(cost[i])
print(" ".join(cost))

Submission status: Runtime Error

Solution code:
a = int(input())
s = input()

if >= 3200:
  print(s)
else:
  print('red')

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  string s;
  
  cin >> n >> s;
  
  if (n >= 3200){
    cout << s << endl;
  }else{
    cout << "red" << endl;
  }
}

Submission status: Runtime Error

Solution code:
a = int(input())
s = str(input())

if a >= 3200:
    print(s)
else:
    print(red)

Submission status: Runtime Error

Solution code:
a=

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(v, p):
    for u in link[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v)

N, Q = map(int, input().split())
link = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

ans = [0] * N
for i in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

dfs(0, -1)

print(*ans)

Submission status: Runtime Error

Solution code:
a=input()
s=input()

if a>=3200:
    print(s)

else:
    print('red')

Submission status: Runtime Error

Solution code:
a=input()
s=input()

if a>=3200:
    print(s)

if a<3200:
    print('red')

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**9)

def addc(p,b):
  for i in e[p]:
    if(i == b):
      continue
    c[i] += c[p]
    addc(i,p)

n,q = map(int,input().split())

e = [ [] for i in range(n + 1)]
c = [0 for i in range(n + 1)]

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

for i in range(q):
  p,x = map(int,input().split())
  c[p] += x

addc(1,-1)

c.pop(0)

print(*c)

Submission status: Runtime Error

Solution code:
import sys
import queue
input = sys.stdin.readline

N, Q = map(int, input().split())
tree = [[] for _ in range(N+1)]
value = [0] * (N+1)
visit = [False] * (N+1)

# make_tree
for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

# make_value
for _ in range(Q):
    p, x = map(int, input().split())
    value[p] += x

# all_value_sum
q = queue.Queue()
q.put(1)
visit[1] = True
while not q.empty():
    now = q.get()
    for next in tree[now]:
        if not visit[next]:
            value[next] += value[now]
            q.put(next)
            visit[next] = True

# output_value
s = " ".join(map(str, value[1:]))
print(s)

Submission status: Runtime Error

Solution code:
import heapq
N = int(input())
V = list(map(int, input().split()))
heapq.heapify(V)
for i in range(N-2):
  heapq.heappush((heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)

Submission status: Runtime Error

Solution code:
a = int(input())
s = string(input())

if a >= 3200:
  print(s)
elif:
  print('red')

Submission status: Runtime Error

Solution code:
a = int(input())
s = int(input())

print(s if a >= 3200 else 'red' )

Submission status: Runtime Error

Solution code:
a = int(input())
s = input()
if a=>3200:
  print(s)
elif a<3200:
  print('red')

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(200005)
n, q = map(int, input().split())

to = [[] for i in range(n+1)]


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

score = [0]*(n+1)
h = [0] * (n+1)
for i in range(q):
    p, x = map(int, input().split())
    h[p] += x


def down_tree(index, parent):
    global score
    score[index] += score[parent] + h[index]
    for i in to[index]:
        if i == parent:
            continue
        down_tree(i, index)
    return


down_tree(1, 1)

print(' '.join(map(str, score[1:])))

Submission status: Runtime Error

Solution code:

n, q = map(int, input().split())

to = [[] for i in range(n)]


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

score = [0]*n

for i in range(q):
    p, x = map(int, input().split())
    score[p-1] += x


def down_tree(index, parent=-1):
    global score
    for i in to[index]:
        if i == parent:
            continue
        score[i] += score[index]
        down_tree(i, index)
    return


down_tree(0)

print(*score)