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:
import sys
input = sys.stdin.readline


N,Q=map(int,input().split())
EDGE=[list(map(int,input().split())) for i in range(N-1)]
PLUS=[list(map(int,input().split())) for i in range(Q)]

SCORE=[0]*(N+1)
for p,x in PLUS:
    SCORE[p]+=x

ELIST=[[] for i in range(N+1)]

for x,y in EDGE:
    ELIST[x].append(y)
    ELIST[y].append(x)
#print(ELIST)

from collections import deque
Q=deque([1])

USED=[0]*(N+1)
USED[1]=1
#USED = [0, 1, 0, 0, 0] Ex1
#SCORE = [0, 100, 10, 1, 0] Ex1
#ELIST = [[], [2], [1, 3, 4], [2], [2]] Ex1

while Q:
    x=Q.pop()

    for to in ELIST[x]:
        if USED[to]==0:
            USED[to]=1
            SCORE[to]+=SCORE[x]
            Q.append(to)

print(*SCORE[1:])

Submission status: Runtime Error

Solution code:

import sys
from collections import deque, defaultdict
import copy
import bisect
#input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq

for i in range(N - 1):
	print(i*10000, end = "")
	print(" ", end = "")
print(0)

Submission status: Runtime Error

Solution code:

import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq


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

for i in range(N - 1):
	a, b = list(map(int, input().split()))

for i in range(Q):
	p, x = list(map(int, input().split()))

Submission status: Runtime Error

Solution code:

import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
#sys.setrecursionlimit(10 ** 9)
import math
import heapq


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

for i in range(N - 1):
	a, b = list(map(int, input().split()))

for i in range(Q):
	p, x = list(map(int, input().split()))

Submission status: Runtime Error

Solution code:
from collections import deque
import sys
def main():
  a,b=map(int,sys.stdin.readline().split())
  e=[[]for i in range(a)]

  for i in range(a-1):
    c1,c2=map(int,sys.stdin.readline().split())
    e[c1-1].append(c2-1)
    e[c2-1].append(c1-1)

  g=[[]for i in range(a)]
  f=deque([(0,-1)])
  ans=[0 for _ in range(a)]
  for i in range(b):
    ten,p=map(int,input().split())
    ans[ten-1]+=p
  i=0
  while len(f)!=0:
    i,fr=f.pop()
    for j in e[i]:
      if j==fr:
        continue
      else:
        ans[j]+=ans[i]
        f.append((j,i)) 
  print(*ans)
if __name__ == '__main__':  
  main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
l, r = map(int, input().split())
import math

ans = 0
inf = math.ceil(math.log(l, 2))
sup = math.floor(math.log(r+1, 2)) - 1
for i in range(inf, sup+1):
  ans += 3 ** i

for i in range(l, 2 ** inf):
  n = bin(i).count('0') - 1
  ans += 2 ** n

for i in range(2 ** (sup + 1), r + 1):
  n = bin(i).count('1') - 1
  ans += 2 ** n
print(ans % int(10**9+7))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import sys

sys.setrecursionlimit(20000)

def forward(matrix, plus, pos, counter):
    for i in range(pos+1,N):
        val = matrix[pos,i]
        if val == 1:
            counter[i] += plus
            save = pos
            forward(matrix, plus, i, counter)

if __name__ == '__main__':
    N, Q = map(int, input().split())

    matrix = np.zeros((N,N))
    counter = []
    for i in range(N):
        counter.append(0)

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

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

    for p, x in zip(P,X):
        counter[p] += x
        forward(matrix, x, p, counter)

    out = str(counter[0])
    for i in range(len(counter)-1):
        out = out + ' ' + str(counter[i+1])

    print(out)

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:
import sys

stdin = sys.stdin
na = lambda: map(int, stdin.readline().split())

def main():
  N, Q = na()

  ab = []
  for _ in range(N-1):
    a, b = na()
    ab.append([a, b])
  ab.sort()

  counter = [0] * (N+1)
  for _ in range(Q):
    p, x = na()
    counter[p] += x
  for i in range(N - 1):
    counter[ab[i][1]] += counter[ab[i][0]]
  print(*counter[1:])

if __name__ == "__main__":
  main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, q = map(int,input().split())
tree = [[] for i in range(n)]
v = [0]*n
for i in range(n-1):
    a1,b1 = [int(i) for i in input().split()]
    tree[a1-1].append(b1)
for i in range(q):
    p1,x1 = [int(i) for i in input().split()]
    v[p1 - 1] += x1
for i in range(n):
    for j in range(len(tree[i])):
        v[tree[i][j]-1] += v[i]
for i in range(n):
    print(str(v[i]) +" ",end="")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

print s if a > 3200 else 'red'

Submission status: Runtime Error

Solution code:
# a integer 2800 < a < 5000
# s string that is lowercase
# a >= 3200 print "s" string
# a < 3200 print 'red'

# 
# string length 1, 2..., 10

# if (a >= 3200 and 2800 < a < 5000):
  #print(s)  
  
if (s.isLower() and 2800 < a < 5000):
  if ( a>=3200 ):
    print(s)
  else if ( a < 3200):
    print('red')
return False

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:
N=int(input())
a =list(map(int,input().split()))
def myFunction(int i):
    if (i == N-2):
        print((a[i-1]+a[i])/2)
    a[i] = (a[i-1]+a[i])/2
    myFunction(i+1)    
a.sort()
myFunction(1)

Submission status: Runtime Error

Solution code:
n = int(input())
v = [int(i) for i in input().split()]
v.sort()
ans = v[0]
for i in range(1, len(v)):
    ans = (ans + v[i]) / 2
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**7)
 
N,Q = (int(i) for i in input().split())
hen = {}
value = [0] * N

for _ in range(0,N-1):
    a,b = (int(i) for i in input().split())
    if a in hen:
        hen[a].append(b)
    else:
        hen[a] = [b]

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

def add(p,x):
        for node in hen[p]:
            value[node-1] = value[node-1] + x
            if node in hen:
                add(node,value[node-1])

#add(1,value[0])
for i in range(0,n):
    if i+1 in hen:
        for node in hen[i+1]:
            value[node-1] += value[i]

print(' '.join(map(str,value)))

Submission status: Runtime Error

Solution code:
N, Q = map(int, input().split())
to = [[] for _ in range(N)]

def dfs(v, p = -1):
    for u in to[v]:
        ans[u] += ans[v]
        dfs(u, v)

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

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

dfs(0)
for i in range(N):
    print(ans[i], end=' ')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, q = map(int,input().split())
top_list = [list(map(int,input().split())) for i in range(n - 1)]
ope_list = [list(map(int,input().split())) for i in range(q)]
ans = [0] * n

"""
for i in ope_list:
    ans[i[0] - 1] += i[1]

for j in range(n):
    for k in top_list:
        if j + 1 == k[1]:
            ans[j] += ans[k[0] - 1]
"""

print(*ans)

Submission status: Runtime Error

Solution code:
n = int(input())

a = input().split()

sum_a_rev = 0

for i in range(n):
    sum_a_rev = sum_a_rev + 1/int(a[i])

res = 1/sum_a_rev

print("{}".format(res))

Submission status: Runtime Error

Solution code:
N = int(input())
A = input()
A = A.split()
s = 0
for i in range(0,len(A)):
  s = s + 1/int(A[i])

print(1/s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = int(input())
s = 'pink'
a > 3199 = s
a < 3200 = 'red'

Submission status: Runtime Error

Solution code:
n=int(input())
v=input().split()
w=sorted(v)
a=1
x=int(w[0])
while a<=n-1:
  y=int(w[a])
  z=float(x)+float(y)
  x=float(z)/float(2)
  a=a+1
print(x)

Submission status: Runtime Error

Solution code:
class Node:
    def __init__(self, parent, num):
        self.parent = parent
        self.num = num
        self.score = 0

    def add_score(self, score):
        self.score += score

class Tree:
    @classmethod
    def calc_sum(cls, node):
        if node.parent:
            return node.score + cls.calc_sum(node.parent)
        else:
            return node.score

N, Q = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(1, N):
    A[i], B[i] = map(int, input().split())

P = [0] * (Q+1)
X = [0] * (Q+1)
for i in range(1, Q+1):
    P[i], X[i] = map(int, input().split())

nodes = [0] * (N+1)
nodes[1] = Node(None, 1)

for i in range(1, N):
    nodes[B[i]] = Node(nodes[A[i]], B[i])

for i in range(1, Q+1):
    nodes[P[i]].add_score(X[i])

for i in range(1, N+1):
    sum_score = Tree.calc_sum(nodes[i])
    print(sum_score, end=' ')

Submission status: Runtime Error

Solution code:
n = int(input())
a = sorted([int(i) for i in input().split()])
c = a[0]
for i in a[1:]:
  c = (c + i) / 2
print(c)

Submission status: Runtime Error

Solution code:
input_line = list(map(int,input().split()))
tree_info = []
for i in range(input_line[0]-1):
    info = list(input().split())
    tree_info.append(info)
counter = [0] * input_line[0]
for i in range(input_line[1]):
    count_info = list(map(int, input().split()))
    counter[count_info[0]-1] += count_info[1]
for i in range(1,len(counter)):
    counter[i] += counter[int(tree_info[i-1][0])-1]
print(" ".join(list(map(str,counter))))

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:
n,q=map(int,input().split())
d = {}
ans = [0]*(n+1)
for i in range(n-1):
    sta,gol = map(int,input().split())
    d[gol] = sta

for i in range(q):
    sta,val = map(int,input().split())
    ans[sta]+=val
    

for i in range(n):
    gol = i+1
    if gol in d:
        ans[gol]+=ans[d[gol]]
    

anss = ""
for i in range(n):
    anss = anss+str(ans[i+1])+" "
print(anss)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(2*10**5)
def parent(array,count,index,root):
    array[index-1].remove(root)
    count[index-1]+=count[root-1]
    for i in array[index-1]:
        parent(array,count,i,index)
num,q=map(int,input().split())
counter=[0 for _ in range(num)]
roots=[set() for _ in range(num)]
for _ in range(num-1):
    a,b=map(int,input().split())
    roots[a-1].add(b)
    roots[b-1].add(a)
for _ in range(q):
    p,x=map(int,input().split())
    counter[p-1]+=x
for ele in roots[0]:
    parent(roots,counter,ele,1)
print(" ".join([str(counter[i]) for i in range(num)]))

Submission status: Runtime Error

Solution code:
import sys

def add_count(addnum, relations, counters, nodelist):
  new_nodelist = []
  for node in nodelist:
    if node not in relations:
      continue
    else:
      new_nodelist = new_nodelist + relations[node]
      for child in relations[node]:
        counters[child-1] += addnum
  
  if len(new_nodelist) == 0:
    return counters
  else:
    return add_count(addnum, relations, counters, new_nodelist)

N, Q = map(int, sys.stdin.readline().split())
alist = list(list(map(int, sys.stdin.readline().split())) for i in range(N-1))
qlist = list(list(map(int, sys.stdin.readline().split())) for i in range(Q))

counters = [0 for i in range(N)]
relations = {}
for a in alist:
  if a[0] not in relations:
    relations[a[0]] = [a[1]]
  else:
    relations[a[0]].append(a[1])
    
for q in qlist:
  counters[q[0]-1] += q[1]
  counters = add_count(q[1], relations, counters, [q[0]])

print(' '.join(map(str,counters)))

Submission status: Runtime Error

Solution code:
def discrimination(a, s):
  if 2800 <= a <5000:
    if 3200 >= a:
      print (a + '\n'  + s)
    elif a < 3200:
      print (a + '\n'  + 'red')
      
print('a ')
a = int(input())
print('s ')
s = input()

def ss(s):
  s = s.lower()
  if 1 <= len(s) < 10:
    return s

  
discrimination(a, ss(s))

Submission status: Runtime Error

Solution code:
from collections import defaultdict

def dfs(graph, start):
    stack = [start]
    visited = []
    while stack:
        label = stack.pop(0)
        if label not in visited:
            visited.append(label)
            stack = graph.get(label, []) + stack
    return visited
  
tree = defaultdict(list)
N,Q = map(int, input().split())

lst1 = [list(map(int, input().split())) for i in range(N-1)]
lst2 = [list(map(int, input().split())) for i in range(Q)]
for i in range(N):
  dict(tree)[i+1] = []
for i in lst1:
  tree[i[0]].append(i[1])
ans = [0] * N
memo = {}
for i in lst2:
  start = i[0]
  visited = []
  if (start == 1):
      ans = list(map(lambda x: x + i[1], ans))
  else:
    if start not in memo.keys():
      memo[start] = dfs(dict(tree), start)
    for j in memo[start]:
      if (start <= j):
        ans[j-1] += i[1]
print(" ".join(list(map(str,ans))))

Submission status: Runtime Error

Solution code:
N=int(input())
List=list(map(int,input().split()))
List.sort()
a= List[0]
for i in range(len(List)):
  a= (a+List[i])/2
print(a)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(ll)>
using namespace std;
#define All(v) (v).begin(),(v).end()
typedef long long ll;
const ll mod = 1000000007;
const ll inf = mod*mod;
const ll d5 = 114514;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);
int main(){
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200)cout<<s<<endl;
    else cout<<"red"<<endl;
}

Submission status: Runtime Error

Solution code:
import numpy as np

n,q = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n+q-1)]

matrix = np.zeros((n,n))
ans = np.zeros((n,n))

for i in range(n-1):
  matrix[ab[i][0]-1,ab[i][1]-1] = 1
#  matrix[ab[i][1]-1,ab[i][0]-1] = 1

for l in range(n):
  for m in range(n):
    if matrix[l][m]:
      for o in range(n):
        if matrix[m][o]:
          matrix[l][o] = 1
          
ans = np.zeros((n))

for j in range(n-1,n+q-1):
  ans[ab[j][0]-1] += ab[j][1]
  for k in range(n):
    if matrix[ab[j][0]-1][k] == 1:
      ans[k] += ab[j][1]
  

for p in range(n):
  print(int(ans[p]))

Submission status: Runtime Error

Solution code:
N, Q = map(int, input().split())
edges = [input().split() for _ in range(N-1)]
operations = [input().split() for _ in range(Q)]

tree = {}
counter = [0]*N
result = [0]*N
numbers = []

for o in operations:
    counter[int(o[0])-1] += int(o[1])

result[0] = counter[0]

# print(counter)

for e in edges:
    parent = e[0]
    sun = e[1]
    if sun in numbers:
        sun = e[0]
        parent = e[1]
    else:
        numbers.append(sun)

    if sun in tree:
        tree[sun].append(parent)
    else:
        tree[sun] = [parent]

    if parent in tree:
        tree[sun].extend(tree[parent])


# print(tree)

for k in tree.keys():
    result[int(k)-1] += counter[int(k) - 1]
    for i in tree[k]:
        result[int(k)-1] += counter[int(i)-1]

print(' '.join(map(str, result)))

Submission status: Runtime Error

Solution code:
N,Q = map(int, input().split())
abL = [[int(x) for x in input().split()] for _ in range(N-1)]
tree = [[0]*(N+1) for _ in range(N+1)]
graph = [[] for _ in range(N+1)]
for a,b in abL:
    graph[a].append(b)
 
for a in range(N, 0, -1):
    incL = graph[a]
    for b in incL:
        for i in range(a):
            if a in graph[i]:
                graph[i].append(b)
    graph[a].append(a)
 
pxL = [[int(x) for x in input().split()] for _ in range(Q)]
 
for p,x in pxL:
    tmpL = graph[p]
    for b in tmpL:
        tree[p][b] += x
 
for i in range(1, N+1):
    sum_ = 0
    for j in range(1, N+1):
        sum_ += tree[j][i]
    print(sum_, end=" ")

Submission status: Runtime Error

Solution code:
N = int(input().rstrip())
v = input().rstrip().split(" ")
v.sort()
#print(v)
a = (int(v[0])+int(v[1])) / 2
i = 2
while i <= (N-1):
  a = (a + int(v[i])) / 2
  i += 1
print(':.6f'.format(a))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import numpy as np
n,q=list(map(int, input().split()))
result = {i+1:0 for i in range(n)}
ar = np.eye(n)

for i in range(n-1):
    a,b = list(map(int, input().split()))
    ar[0:a,a-1:b] += 1
for i in range(q):
    a,b = list(map(int, input().split()))
    m = ar[a-1]
    for j in range(len(m)):
        if m[j] != 0:
            result[j+1] += b
        else:
            result[j+1] += 0
r = list(result.values())
res = map(str, r)
print(' '.join(res))

Submission status: Runtime Error

Solution code:
N = int(input().rstrip())
v = input().rstrip().split(" ")
v.sort()
#print(v)
a = (int(v[0])+int(v[1])) / 2
i = 2
while i <= (N-1):
  a = (a + int(v[i])) / 2
  i += 1
print(a)

Submission status: Runtime Error

Solution code:
N=int(input())
a=[int(x) for x in input().split()]
b=0
for i in range(N):
    b+=1/a[i]
    
print(1/b)

Submission status: Runtime Error

Solution code:
N, Q = map(int, input().split())
tree = [list(map(int, input().split())) for i in range(N-1)]
process =  [list(map(int, input().split())) for i in range(Q)]

def next_node(node_num):
  next_nodes = []
  for edge in tree:
    if edge[0] == node_num:
      next_nodes.append(edge[1])
  return next_nodes
 
def all_nodes(num):
  x = [] 
  add_nodes = next_node(num)
  while add_nodes != []:
    for i in add_nodes:
      add_nodes += next_node(i) 
      x += add_nodes
      add_nodes = []
  return x


def add(score, procedure):
  "procedure = [p, x]"
  score[procedure[0]-1] += procedure[1]
  for n in all_nodes(procedure[0]):
    score[n-1] += procedure[1]
  return score


score = [0]*N
for procedure in process:
  add(score, procedure)
print(score)

Submission status: Runtime Error

Solution code:
N=int(input())
List=list(map(int,input().split()))
a=0
List.sort()
for i in range(len(List)):
  a= (a+List[i])/2
print(a)

Submission status: Runtime Error

Solution code:
def next_node(node_num):
    next_nodes = []
    for edge in tree:
        if edge[0] == node_num:
            next_nodes.append(edge[1])
    return next_nodes
 
def all_nodes(num):
  x = [] 
  add_nodes = next_node(num)
  while add_nodes != []:
    for i in add_nodes:
      add_nodes += next_node(i) 
      x += add_nodes
      add_nodes = []
  return x
 
 
def add(score, procedure):
  "procedure = [p, x]"
  score[procedure[0]-1] += procedure[1]
  for n in all_nodes(procedure[0]):
    score[n-1] += procedure[1]
  return score
 
 
score = [0]*N
for procedure in process:
    add(score, procedure)
print(score)

Submission status: Runtime Error

Solution code:
n,q=map(int,input().split())
a=[]
b=[]
s=[0]


for i in range(0,n-1):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
    s.append(0)
for i in range(0,q):
    P,X=map(int,input().split())
    s[P-1]=s[P-1]+X


for j in range(0,n-1):
    s[b[j]-1]=s[b[j]-1]+s[a[j]-1]

print(' '.join(map(str,s)))

Submission status: Runtime Error

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

s = input().strip()
t = input().strip()
n = len(s)
m = len(t)
p = 0
q = 0
fold = 0
l = [[] for _ in range(26)]
lim = [0 for _ in range(26)] 
for i, x in enumerate(s):
	l[ord(x) - 97].append(i)
	lim[ord(x) - 97] += 1
r = [0 for _ in range(26)]
cur = -1
while (q < m):
	x = t[q]
	ind = ord(x) - 97
	#print(x, cur)
	if l[ind] == []:
		print(-1)
		exit(0)
	else:
		#print("HERE", r[ind], lim[ind])
		if r[ind] >= lim[ind]:
			fold += 1
			r = [0 for _ in range(26)]
			cur = -1
		else:
			c = l[ind][r[ind]]
			flag = True
			while (c <= cur):
				r[ind] += 1
				if r[ind] >= lim[ind]:
					flag = False
					break
				c = l[ind][r[ind]]
			if flag == False:
				fold += 1
				r = [0 for _ in range(26)]
				cur = -1
			elif c > cur:
				cur = c
				q += 1
				r[ind] += 1
			else:
				fold += 1
				r = [0 for _ in range(26)]
				cur = -1
#print(fold, n, cur)
print(fold * n + cur + 1)

Submission status: Runtime Error

Solution code:
n = int(input())
i = list(map(int, input().split()))
m = n
n -= 1
i.sort()

if i.count(i[0])==m:
    ans = i[0]
else:
    for j in range(n):
        if(j<n-1):
            if(i.count(i[0])>=1):
                tmp = i[j]
            else:
                tmp = (i[j]+i[j+1])/2
            i.append(tmp)
            del i[0:2]
            i.sort()
        ans = (i[0]+i[1])/2

print(ans)

Submission status: Runtime Error

Solution code:

N,Q = (int(i) for i in input().split())
hen = {}
value = [0] * N
flag = [0] * N
for i in range(0,N-1):
    a,b = (int(i) for i in input().split())
    if a in hen:
        hen[a].append(b)
    else:
        hen[a] = [b]
#print(hen)

def add(p,x):
    if p in hen:
        for i in hen[p]:
            value[i-1] = value[i-1] + x
            add(i,value[i-1])

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


add(1,value[0])
print(' '.join(map(str,value)))

Submission status: Runtime Error

Solution code:
n = int(input())
v = list(map(int,input().split()))
i = len(v)-1

for i in range(n-1):
    v.sort()
    print(v)
    new_num = (v[0] + v[1]) / 2
    v[0] = new_num
    v.sort
    v.remove(v[1])
    print(v)

print(new_num)

'''
    for j in range((n-1)-i):
        if j == 0:
            v[j] = new_num
        else:
            v.remove(v[len(v)-1])

'''

Submission status: Runtime Error

Solution code:
from collections import deque
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)]

chil = [[] for _ in range(N+1)]
count = [0]*(N+1)

for ab in AB:
    chil[ab[0]].append(ab[1])
    chil[ab[1]].append(ab[0])

def cleanse(fromN, toN):
    chil[toN].remove(fromN)
    if len(chil[toN])==0:  # leaf
        return
    for node in chil[toN]:
        cleanse(toN, node)

for node in chil[1]:
    cleanse(1, node)

def addition(fromN, toN, value):
    count[toN] += value
    if len(chil[toN])==0:
        return
    for node in chil[toN]:
        addition(toN, node, value)

for px in PX:
    count[px[0]] += px[1]
    for node in chil[px[0]]:
        addition(px[0], node, px[1])

print(*count[1:])

Submission status: Runtime Error

Solution code:
from collections import deque

n, q = map(int, input().split( ))
Edg=[[] for i in range(n+1)]

for i in range(n-1):
    a, b = map(int, input().split( ))
    Edg[a].append(b)
Ans=[0 for i in range(n+1)]
P = [0 for i in range(n+1)]
for i in range(q):
    p, x = map(int, input().split( ))
    P[p]+=x
#print(*P)
Chld=[[] for i in range(n+1)]
for p in range(n+1):
    Task=deque()
    Task.append(p)
    while True:
        try:
            p_=Task.popleft()
            for child in Edg[p_]:
                Chld[p].append(child)
                Task.append(child)
        except:
            break
#print(Chld)
for p in range(n+1):
    tmp = P[p]
    Ans[p]+=tmp
    for c in Chld[p]:
            Ans[c]+=tmp

print(*Ans[1:])

Submission status: Runtime Error

Solution code:
import sys
 
sys.setrecursionlimit(200000000)
 
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)]
 
l = [[] for i in range(n+1)]
for pi in ab:  
    l[pi[0]].append(pi[1])
    l[pi[1]].append(pi[0])
 
def dfs(graph, start, oya):
    if start != 1:
        graph[start].remove(oya)
    if len(graph[start]) == 0:
        return
    else:
        for i in graph[start]:
            dfs(graph, i, start)
 
dfs(l, 1, 1)
 
def dfs_2(graph, start, ans, x):
    ans[start] += x
    if len(graph[start]) == 0:
        return
    else:
        for i in graph[start]:
            dfs_2(graph, i, ans, x)
 
ans = [0 for i in range(n+1)]
for p, x in px:
    dfs_2(l, p, ans, x)
        
for i in range(1, n+1):
    print(ans[i], end=' ')
print()

Submission status: Runtime Error

Solution code:
n=int(input())
string_list=[input() for i in range(n)]
a = int(string_list[0])
if a <= 3200:
  print("red")
else:
  print(a[1])

Submission status: Runtime Error

Solution code:
N=int(input())
A=input().split(" ")
A=[int(i) for i in A]
A.sort()

def act(A):
  if len(A)%2==0:
    A_=[]
    for i in range(int(len(A)/2)):
      A_.append((A[2*i]+A[2*i+1])/2)
    return A_
  
  elif len(A)%2==1:
    A_=[]
    for i in range(int((len(A)-1)/2)):
      A_.append((A[2*i]+A[2*i+1])/2)
    A_.append(A[len(A)-1])
    return A_
    
    
while len(A)>1:
  A=act(A)

print(A[0])

Submission status: Runtime Error

Solution code:
import numpy as np
n,q= map(int,input().split())

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

ans = np.zeros(n)
dp = {i:np.zeros(n) for i in range(1,n+1)}
for i in range(1,n+1):
  dp[i][i-1] = 1
for i in range(n,0,-1):
  for j in edges[i]:
    dp[i] += dp[j]

queries = [0]*(n+1)
for _ in range(q):
  p,x = map(int,input().split())
  queries[p] += x
for i in range(1,n+1):
  ans += queries[i]*dp[i]
    
st = ""
for i in range(n):
  if i != 0:
    st+=" "
  st+= str(int(ans[i]))
print(st)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(float, input().split()))
c = 1
for i in range(n):
    c = c * a[i]
print(float(c) / sum(a))

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(100000)
n,q=map(int,input().split())
g=[[i] for i in range(n+1)]

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

c=[0]*(n+1)
def dfs(p,x):
    for i in g[p]:
        if r[i]:
            r[i]=0
            c[i]+=x
            dfs(i,x)

for _ in range(q):
    r=[1]*(n+1)
    p,x=map(int,input().split())
    dfs(p,x)


print(*c[1:])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
sum = 0.0
for _ in range(N):
    sum += 1 / int(input())
sum = 1 / sum

print(sum)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input().rstrip())
A = input().rstrip().split(" ")
a = 0
for i in range(N):
  a += 1 / int(A[i])
b = 1 / a
print(b)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
input_number = map(int,input())
input_string = input()
if input_number < 3200:
  print(input_number)
else:
  print(input_string)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = int(input())
t = [int(i) for i in input().split()]

x = 0

for i in t:
  x += 1 / i

print(1 / x)

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 str(a) >= 3200:
    print(s)
else:
    print('red')

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())
v = np.array(list(map(int,input().split())))
v_sort = np.sort(v)
temp = 0

for index in range(n-1):
  temp = (v_sort[0]+v_sort[1])/2
  v_sort = np.delete(v_sort,0)
  v_sort = np.delete(v_sort,0)
  v_sort = np.append(v_sort,temp)
  v_sort = np.sort(v_sort)

print(v_sort[0])

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 >= 2300:
  print(s)
  else:
    print("red")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

li = sorted(li)
tmp = li[0]

for i in range(1,N):
  tmp = (tmp + li[i]) / 2

print(tmp)

Submission status: Runtime Error

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

if a >= 3200:
	print(s)

elif a < 3200:
	print("red")

Submission status: Runtime Error

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

if a >= 2300:
  print(s)
  else:
    print(a)

Submission status: Runtime Error

Solution code:
color = input()
num = int(input())
if num >= 3200:
    print(color)
else:
    print('red')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if a >= 2300:
  print(a)
  else:
    print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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