problem_id
stringlengths
3
7
contestId
stringclasses
660 values
problem_index
stringclasses
27 values
programmingLanguage
stringclasses
3 values
testset
stringclasses
5 values
incorrect_passedTestCount
float64
0
146
incorrect_timeConsumedMillis
float64
15
4.26k
incorrect_memoryConsumedBytes
float64
0
271M
incorrect_submission_id
stringlengths
7
9
incorrect_source
stringlengths
10
27.7k
correct_passedTestCount
float64
2
360
correct_timeConsumedMillis
int64
30
8.06k
correct_memoryConsumedBytes
int64
0
475M
correct_submission_id
stringlengths
7
9
correct_source
stringlengths
28
21.2k
contest_name
stringclasses
664 values
contest_type
stringclasses
3 values
contest_start_year
int64
2.01k
2.02k
time_limit
float64
0.5
15
memory_limit
float64
64
1.02k
title
stringlengths
2
54
description
stringlengths
35
3.16k
input_format
stringlengths
67
1.76k
output_format
stringlengths
18
1.06k
interaction_format
null
note
stringclasses
840 values
examples
stringlengths
34
1.16k
rating
int64
800
3.4k
tags
stringclasses
533 values
testset_size
int64
2
360
official_tests
stringlengths
44
19.7M
official_tests_complete
bool
1 class
input_mode
stringclasses
1 value
generated_checker
stringclasses
231 values
executable
bool
1 class
113/A
113
A
Python 3
TESTS
136
92
102,400
212181856
a=input().split() i=0 n=len(a) while i<n and (len(a[i])>=4 and a[i][len(a[i])-4:]=="lios"): i+=1 i1=i while i<n and (len(a[i])>=3 and a[i][len(a[i])-3:]=="etr"): i+=1 if i-i1!=1 and i!=0 and n>1: print("NO") exit() while i<n and (len(a[i])>=6 and a[i][len(a[i])-6:]=="initis"): i+=1 #print(i) if i==0...
360
78
307,200
4075975
s=input().split() if(len(s)==1): if(s[0].endswith("lios") or s[0].endswith("etr") or s[0].endswith("liala") or s[0].endswith("etra") or s[0].endswith("inites") or s[0].endswith("initis")): print("YES") else: print("NO") elif(s[0].endswith("lios") or s[0].endswith("etr")): n=len(s) i=...
Codeforces Beta Round 86 (Div. 1 Only)
CF
2,011
5
256
Grammar Lessons
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules: - There are three parts of spee...
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105. It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible tha...
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
null
null
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
1,600
["implementation", "strings"]
360
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "...
false
stdio
null
true
113/A
113
A
Python 3
TESTS
65
92
102,400
151378536
def isPetyaLanguage(): read = input().split() if len(read) == 1: if read[0].endswith('lios') or read[0].endswith('lialia') or read[0].endswith('etr') or read[0].endswith('etra') or read[0].endswith('initis') or read[0].endswith('inites'): print('YES') return else: ...
360
92
102,400
151322401
def isPetyaLanguage(): words = input().split() if len(words) == 1: if words[0].endswith("etr") or words[0].endswith("etra") or words[0].endswith("lios") or words[0].endswith("liala") or words[0].endswith("initis") or words[0].endswith("inites"): print("YES") return else: ...
Codeforces Beta Round 86 (Div. 1 Only)
CF
2,011
5
256
Grammar Lessons
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules: - There are three parts of spee...
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105. It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible tha...
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
null
null
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
1,600
["implementation", "strings"]
360
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "...
false
stdio
null
true
113/A
113
A
PyPy 3-64
TESTS
146
156
716,800
171980063
from collections import defaultdict as dc words=input().split() ends=['lios','liala','etr','etra','initis','inites'] adjm,adjf,verbm,verbf,nounm,nounf,=set(),set(),set(),set(),set(),set() for s in words: n=len(s) for i in ends: idx=len(s)-len(i) if idx<0:continue j,flag=0,0 while...
360
92
102,400
214687216
from sys import stdin, stdout x = stdin.readline().replace("\n","") lst = x.split(' ') genderLst = [] typeLst = [] valid = 1 for x in lst: if x.endswith("lios") or x.endswith("etr") or x.endswith("initis"): genderLst.append(1) elif x.endswith("liala") or x.endswith("etra") or x.endswith("inites"...
Codeforces Beta Round 86 (Div. 1 Only)
CF
2,011
5
256
Grammar Lessons
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules: - There are three parts of spee...
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105. It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible tha...
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
null
null
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
1,600
["implementation", "strings"]
360
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "...
false
stdio
null
true
113/A
113
A
PyPy 3-64
TESTS
101
124
204,800
212179196
def get_type(slovo): slovo = slovo[::-1] slovo += '#######' if slovo[:4] == 'soil': return [0, 0] if slovo[:5] == 'alail': return [0, 1] if slovo[:3] == 'rte': return [1, 0] if slovo[:4] == 'arte': return [1, 1] if slovo[:6] == 'sitini': return [2, 0] ...
360
92
102,400
227284427
# LUOGU_RID: 128399015 a = input().split() c = 5 #设置一个变量,记录当前的状态 for b in a: if c == 5: if len(a) == 1: if b[-4:] == 'lios' or b[-5:] == 'liala' or b[-3:] == 'etr' or b[-4:] == 'etra' or b[-6:] == 'initis' or b[-6:] == 'inites': #输入只有一个任意合法单词时也特判为合法 c = 0 elif b[-4:] == ...
Codeforces Beta Round 86 (Div. 1 Only)
CF
2,011
5
256
Grammar Lessons
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules: - There are three parts of spee...
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105. It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible tha...
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
null
null
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
1,600
["implementation", "strings"]
360
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "...
false
stdio
null
true
113/A
113
A
PyPy 3-64
TESTS
7
124
614,400
171980252
from collections import defaultdict as dc words=input().split() ends=['lios','liala','etr','etra','initis','inites'] adjm,adjf,verbm,verbf,nounm,nounf,=set(),set(),set(),set(),set(),set() frq=dc(lambda:0) for s in words: n=len(s) for i in ends: idx=len(s)-len(i) if idx<0:continue j,flag=...
360
122
4,710,400
157359820
n = input().split() w = 0 x=y=z=0 r=s=t=0 while w<len(n): if n[w][-4:]=="lios" or n[w][-5:]=="liala": if n[w][-4:]=="lios": x+=1 w+=1 else: r+=1 w+=1 else: break while w<len(n): if n[w][-3:]=="etr" or n[w][-4:]=="etra": if n[w][...
Codeforces Beta Round 86 (Div. 1 Only)
CF
2,011
5
256
Grammar Lessons
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules: - There are three parts of spee...
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105. It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible tha...
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
null
null
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
1,600
["implementation", "strings"]
360
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "...
false
stdio
null
true
113/A
113
A
PyPy 3
TESTS
7
184
0
11937161
def pos(w): if len(w) < 3: return False if w == 'etr' or w[-3:] == 'etr': return 'MN' if len(w) == 3: return False if w == 'lios' or w[-4:] == 'lios': return 'MA' if w == 'etra' or w[-4:] == 'etra': return 'FN' if len(w) == 4: return False if w...
360
124
102,400
151380136
''' def isPetyaLanguage(): read = input().split(' ') if len(read) == 1: if read[0].endswith('lios') or read[0].endswith('lialia') or read[0].endswith('etr') or read[0].endswith('etra') or read[0].endswith('initis') or read[0].endswith('inites'): print('YES') return else: ...
Codeforces Beta Round 86 (Div. 1 Only)
CF
2,011
5
256
Grammar Lessons
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules: - There are three parts of spee...
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105. It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible tha...
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
null
null
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
1,600
["implementation", "strings"]
360
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "...
false
stdio
null
true
113/A
113
A
Python 3
TESTS
7
186
307,200
91305797
s=list(map(str,input().split(' '))) g=[['lios','liala'],['etr','etra'],['initis','inites']] if len(s)==1: n=len(s[0]) if s[0][n-len(g[0][0]):]==g[0][0] or s[0][n-len(g[0][1]):]==g[0][1] or s[0][n-len(g[1][0]):]==g[1][0] or s[0][n-len(g[1][1]):]==g[1][1] or s[0][n-len(g[2][0]):]==g[2][0] or s[0][n-len(g[2][1]):]...
360
124
204,800
208405599
class Context: def __init__(self, words): self.words = words self.index = 0 def get_token(self): return self.words[self.index] def next(self): self.index += 1 def end(self): return self.index == len(self.words) def dump(self): return self.index ...
Codeforces Beta Round 86 (Div. 1 Only)
CF
2,011
5
256
Grammar Lessons
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules: - There are three parts of spee...
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105. It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible tha...
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
null
null
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
1,600
["implementation", "strings"]
360
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "...
false
stdio
null
true
113/A
113
A
Python 3
TESTS
66
156
204,800
22654372
ms = input().split() al = [['lios','etr','initis'],['liala','etra','inites']] s = ms[0] i=0; ans = True; if s.endswith(al[0][0]) or s.endswith(al[0][1]): fs = 0; elif s.endswith(al[1][0]) or s.endswith(al[1][1]): fs = 1; else: ans=False; if ans==True: for s in ms: if i==0: if s...
360
124
614,400
162396833
import re;t=input();p=[r'([^ ]*lios )*([^ ]*etr)( [^ ]*initis)*',r'([^ ]*liala )*([^ ]*etra)( [^ ]*inites)*',r'[^ ]*(li(os|ala)|etra?|init[ie]s)'];print(['NO','YES'][any(re.fullmatch(q,t)for q in p)])
Codeforces Beta Round 86 (Div. 1 Only)
CF
2,011
5
256
Grammar Lessons
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules: - There are three parts of spee...
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105. It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible tha...
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
null
null
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
1,600
["implementation", "strings"]
360
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "...
false
stdio
null
true
113/A
113
A
Python 3
TESTS
66
216
8,396,800
127696390
import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush from math import * from collections import defaultdict as dd, deque, Counter as C from itertools import combinations as comb, permutations as perm from bisect import bisect_left as bl, bisect_right as br, bisect, ...
360
154
204,800
15182995
s, n, m, f = input().split(), False, False, False def cc(w, me, fe): global m, f if w.endswith(me): m = True return True elif w.endswith(fe): f = True return True else: return False def ad(w): return cc(w, 'lios', 'liala') def nn(w): return cc(w, 'etr', 'etra') de...
Codeforces Beta Round 86 (Div. 1 Only)
CF
2,011
5
256
Grammar Lessons
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules: - There are three parts of spee...
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105. It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible tha...
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
null
null
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
1,600
["implementation", "strings"]
360
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "...
false
stdio
null
true
113/A
113
A
Python 3
TESTS
66
218
614,400
99499790
lista = input().split() passadj = False passsub = False gender = -1 can = True # verificando os generos das palavras for i in range(0,len(lista)): if (len(lista[i]) >= 3 and lista[i][len(lista[i])-3::] == "etr") or (len(lista[i]) >= 4 and lista[i][len(lista[i])-4::] == "lios") or (len(lista[i]) >= 6 and lista[i][le...
360
216
716,800
15383496
#!/usr/bin/python3 import re al = re.compile(r'^1*23*$') def getType(word): if word.endswith("lios"): return 1 elif word.endswith("liala"): return -1 elif word.endswith("etr"): return 2 elif word.endswith("etra"): return -2 elif word.endswith("initis"):return 3 elif word.endswith("inites"): return -3 else: retur...
Codeforces Beta Round 86 (Div. 1 Only)
CF
2,011
5
256
Grammar Lessons
Petya got interested in grammar on his third year in school. He invented his own language called Petya's. Petya wanted to create a maximally simple language that would be enough to chat with friends, that's why all the language's grammar can be described with the following set of rules: - There are three parts of spee...
The first line contains one or more words consisting of lowercase Latin letters. The overall number of characters (including letters and spaces) does not exceed 105. It is guaranteed that any two consecutive words are separated by exactly one space and the input data do not contain any other spaces. It is possible tha...
If some word of the given text does not belong to the Petya's language or if the text contains more that one sentence, print "NO" (without the quotes). Otherwise, print "YES" (without the quotes).
null
null
[{"input": "petr", "output": "YES"}, {"input": "etis atis animatis etis atis amatis", "output": "NO"}, {"input": "nataliala kataliala vetra feinites", "output": "YES"}]
1,600
["implementation", "strings"]
360
[{"input": "petr\r\n", "output": "YES\r\n"}, {"input": "etis atis animatis etis atis amatis\r\n", "output": "NO\r\n"}, {"input": "nataliala kataliala vetra feinites\r\n", "output": "YES\r\n"}, {"input": "qweasbvflios\r\n", "output": "YES\r\n"}, {"input": "lios lios petr initis qwe\r\n", "output": "NO\r\n"}, {"input": "...
false
stdio
null
true
818/C
818
C
Python 3
TESTS
16
763
26,828,800
28155256
from sys import stdin, stdout k = int(stdin.readline()) n, m = map(int, stdin.readline().split()) left, right, down, up = [], [], [], [] challengers = [] for i in range(k): x1, y1, x2, y2 = map(int, stdin.readline().split()) if x1 == x2: if y1 < y2: challengers.append((x1, y1, x2, y2,...
212
482
40,140,800
170725525
import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline d = int(input()) n, m = map(int, input().split()) L = [] R = [] T = [] B = [] XY = [] for i in range(d): x1, y1, x2, y2 = map(int, input().split()) L.append((min(x1, x2))) R.append(-max(x1, x2)) T.append(min(y1, y2))...
Educational Codeforces Round 24
ICPC
2,017
1
256
Sofa Thief
Yet another round on DecoForces is coming! Grandpa Maks wanted to participate in it but someone has stolen his precious sofa! And how can one perform well with such a major loss? Fortunately, the thief had left a note for Grandpa Maks. This note got Maks to the sofa storehouse. Still he had no idea which sofa belongs ...
The first line contains one integer number d (1 ≤ d ≤ 105) — the number of sofas in the storehouse. The second line contains two integer numbers n, m (1 ≤ n, m ≤ 105) — the size of the storehouse. Next d lines contains four integer numbers x1, y1, x2, y2 (1 ≤ x1, x2 ≤ n, 1 ≤ y1, y2 ≤ m) — coordinates of the i-th sofa...
Print the number of the sofa for which all the conditions are met. Sofas are numbered 1 through d as given in input. If there is no such sofa then print -1.
null
Let's consider the second example. - The first sofa has 0 to its left, 2 sofas to its right ((1, 1) is to the left of both (5, 5) and (5, 4)), 0 to its top and 2 to its bottom (both 2nd and 3rd sofas are below). - The second sofa has cntl = 2, cntr = 1, cntt = 2 and cntb = 0. - The third sofa has cntl = 2, cntr = 1, c...
[{"input": "2\n3 2\n3 1 3 2\n1 2 2 2\n1 0 0 1", "output": "1"}, {"input": "3\n10 10\n1 2 1 1\n5 5 6 5\n6 4 5 4\n2 1 2 0", "output": "2"}, {"input": "2\n2 2\n2 1 1 1\n1 2 2 2\n1 0 0 0", "output": "-1"}]
2,000
["brute force", "implementation"]
212
[{"input": "2\r\n3 2\r\n3 1 3 2\r\n1 2 2 2\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "3\r\n10 10\r\n1 2 1 1\r\n5 5 6 5\r\n6 4 5 4\r\n2 1 2 0\r\n", "output": "2\r\n"}, {"input": "2\r\n2 2\r\n2 1 1 1\r\n1 2 2 2\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n1 2\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, ...
false
stdio
null
true
818/C
818
C
PyPy 3
TESTS
8
841
33,689,600
142736287
import sys input = sys.stdin.readline d = int(input()) n, m = map(int, input().split()) xl = [[] for _ in range(n + 2)] xr = [[] for _ in range(n + 2)] yt = [[] for _ in range(m + 2)] yb = [[] for _ in range(m + 2)] for i in range(1, d + 1): x1, y1, x2, y2 = map(int, input().split()) if x1 > x2: x1, x2...
212
498
17,305,600
93759517
import sys try: fin=open('in') except: fin=sys.stdin input=fin.readline d = int(input()) n, m = map(int, input().split()) x1, y1, x2, y2 = [], [], [], [] T=[] for _ in range(d): u, v, w, x = map(int, input().split()) if u>w:u,w=w,u if v>x:v,x=x,v x1.append(u) y1.append(v) x2.append(-w)#...
Educational Codeforces Round 24
ICPC
2,017
1
256
Sofa Thief
Yet another round on DecoForces is coming! Grandpa Maks wanted to participate in it but someone has stolen his precious sofa! And how can one perform well with such a major loss? Fortunately, the thief had left a note for Grandpa Maks. This note got Maks to the sofa storehouse. Still he had no idea which sofa belongs ...
The first line contains one integer number d (1 ≤ d ≤ 105) — the number of sofas in the storehouse. The second line contains two integer numbers n, m (1 ≤ n, m ≤ 105) — the size of the storehouse. Next d lines contains four integer numbers x1, y1, x2, y2 (1 ≤ x1, x2 ≤ n, 1 ≤ y1, y2 ≤ m) — coordinates of the i-th sofa...
Print the number of the sofa for which all the conditions are met. Sofas are numbered 1 through d as given in input. If there is no such sofa then print -1.
null
Let's consider the second example. - The first sofa has 0 to its left, 2 sofas to its right ((1, 1) is to the left of both (5, 5) and (5, 4)), 0 to its top and 2 to its bottom (both 2nd and 3rd sofas are below). - The second sofa has cntl = 2, cntr = 1, cntt = 2 and cntb = 0. - The third sofa has cntl = 2, cntr = 1, c...
[{"input": "2\n3 2\n3 1 3 2\n1 2 2 2\n1 0 0 1", "output": "1"}, {"input": "3\n10 10\n1 2 1 1\n5 5 6 5\n6 4 5 4\n2 1 2 0", "output": "2"}, {"input": "2\n2 2\n2 1 1 1\n1 2 2 2\n1 0 0 0", "output": "-1"}]
2,000
["brute force", "implementation"]
212
[{"input": "2\r\n3 2\r\n3 1 3 2\r\n1 2 2 2\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "3\r\n10 10\r\n1 2 1 1\r\n5 5 6 5\r\n6 4 5 4\r\n2 1 2 0\r\n", "output": "2\r\n"}, {"input": "2\r\n2 2\r\n2 1 1 1\r\n1 2 2 2\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n1 2\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, ...
false
stdio
null
true
797/C
797
C
Python 3
TESTS
32
467
1,331,200
111796189
from collections import deque s = input() t = deque([]) u = "" ind = [-1]*26 for i, ss in enumerate(s): ind[ord(ss)-97] = i for i,ss in enumerate(s): now = ord(ss)-97 for j in range(0,now): if ind[j] > i: t.append(ss) break else: while t: now =...
189
93
14,336,000
196924702
from collections import Counter, deque s = input() n = len(s) mn = ['z'] * (n + 1) for i in range(n - 1, -1, -1): mn[i] = min(mn[i + 1], s[i]) t, u = [], [] for i in range(n): while t and t[-1] <= mn[i]: u.append(t.pop()) if s[i] == mn[i]: u.append(s[i]) else: ...
Educational Codeforces Round 19
ICPC
2,017
1
256
Minimal string
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: - Extract the first character of s and append t with this character. - Extract the last character of t and append u with this chara...
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
Print resulting string u.
null
null
[{"input": "cab", "output": "abc"}, {"input": "acdb", "output": "abdc"}]
1,700
["data structures", "greedy", "strings"]
189
[{"input": "cab\r\n", "output": "abc\r\n"}, {"input": "acdb\r\n", "output": "abdc\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "ab\r\n", "output": "ab\r\n"}, {"input": "ba\r\n", "output": "ab\r\n"}, {"input": "dijee\r\n", "output": "deeji\r\n"}, {"input": "bhrmc\r\n", "output": "bcmrh\r\n"}, {"input": "aaaaa...
false
stdio
null
true
691/B
691
B
Python 3
TESTS
11
46
0
172134941
s = input() mu = ['A','H','I','M','O','o','T','U','V','v','W','w','X','x','Y'] slen = len(s) flag = 1 for i in range(slen): if s[i]==s[-i-1] and s[i] in mu: pass elif (s[i]=='b' and s[-i-1]=='d') or (s[i]=='d' and s[-i-1]=='b'): pass else: flag = 0 if flag == 1: print("TAK") else: print("NIE")
168
46
0
158963335
t = input() k = len(t) // 2 + 1 p = zip(t[:k], t[-k:][::-1]) u, v = 'AHIMOoTUVvWwXxY', 'bd db pq qp' s = all(a in u and a == b or a + b in v for a, b in p) print(['NIE', 'TAK'][s])
Educational Codeforces Round 14
ICPC
2,016
1
256
s-palindrome
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half. English alphabet You are given a string ...
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
null
null
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
1,600
["implementation", "strings"]
168
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "v...
false
stdio
null
true
691/B
691
B
Python 3
TESTS
11
62
307,200
109822485
chars = { 'A': {'A'}, 'b': {'d'}, 'd': {'b'}, 'H': {'H'}, 'M':{'M'}, 'O':{'O'}, 'o':{'o'}, 'T':{'T'}, 'U':{'U'}, 'V':{'V'}, 'v':{'v'}, 'W':{'W'}, 'w':{'w'}, 'X':{'X'}, 'x': {'x'}, 'Y':{'Y'}, } s = input() ans = True for i in range(len(s)//2): if s[...
168
46
0
185154340
s=input() p='AbdHIMOopqTUVvWwXxY' p1='AdbHIMOoqpTUVvWwXxY' j=1 n=len(s) for i in range(n): if s[i] not in p: j=0 break elif p1[p.index(s[i])]!=s[n-i-1]: j=0 break if j==1: print('TAK') else: print('NIE')
Educational Codeforces Round 14
ICPC
2,016
1
256
s-palindrome
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half. English alphabet You are given a string ...
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
null
null
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
1,600
["implementation", "strings"]
168
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "v...
false
stdio
null
true
691/B
691
B
PyPy 3
TESTS
11
62
19,968,000
36211090
symmetric_letters = ['A', 'H', 'I', 'M', 'O', 'o', 'U', 'V', 'v', 'W', 'w', 'X', 'x', 'Y'] letter_trans = { 'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p', } for letter in symmetric_letters: letter_trans[letter] = letter word = input() if all([x in letter_trans for x in word]) and \...
168
62
0
19079997
d = "AHIMOoTUVvWwXxY" s = input() for i in range(len(s) // 2 + 1): if not ((s[i] in d) and (s[i] == s[-i-1])) and not ((s[i] + s[-i-1]) in ["bd", "db", "pq", "qp"]): print("NIE") break else: print("TAK")
Educational Codeforces Round 14
ICPC
2,016
1
256
s-palindrome
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half. English alphabet You are given a string ...
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
null
null
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
1,600
["implementation", "strings"]
168
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "v...
false
stdio
null
true
691/B
691
B
Python 3
TESTS
11
46
0
171744136
a='AAHHMMTTUUVVWWXXYYOOMMbddboovvxxww' a1=[] for i in range(0,len(a),2): a1.append(a[i]+a[i+1]) s=input() t='AHMTUVWMXYOMoxvw' x=True if len(s)%2==1: if s[len(s)//2] in t: for i in range(len(s)//2): if s[i]+s[len(s)-i-1] in a1: x=True else: x=False...
168
62
0
19080023
s = input() p = 'aBCcDEeFfGghiJjKkLlmNnPQRrSstuyZz' for c in s: if c in p: print('NIE') exit() def trans(c): d = { 'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p', } if c in d: return d[c] return c t = ''.join(map(trans, s[::-1])) if t == s: pri...
Educational Codeforces Round 14
ICPC
2,016
1
256
s-palindrome
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half. English alphabet You are given a string ...
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
null
null
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
1,600
["implementation", "strings"]
168
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "v...
false
stdio
null
true
797/C
797
C
PyPy 3
TESTS
20
140
29,900,800
123806207
import sys import heapq def get_string(): return sys.stdin.readline().strip() # Output for list # sys.stdout.write(" ".join(map(str, final)) + "\n") # Output for int or str # sys.stdout.write(str(best) + "\n") def solve(s): length = len(s) current = 97 final = [] start = 0 end = length - 1 extra = [] ...
189
93
14,540,800
175279224
from collections import defaultdict from collections import Counter def parse(): return(int(input())) def parse2(): return(list(map(int,input().split()))) def parsestr(): return input() def solve(): s = parsestr() n = len(s) best = [0]*(n+1) best[-1] = 'z' for i in range...
Educational Codeforces Round 19
ICPC
2,017
1
256
Minimal string
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: - Extract the first character of s and append t with this character. - Extract the last character of t and append u with this chara...
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
Print resulting string u.
null
null
[{"input": "cab", "output": "abc"}, {"input": "acdb", "output": "abdc"}]
1,700
["data structures", "greedy", "strings"]
189
[{"input": "cab\r\n", "output": "abc\r\n"}, {"input": "acdb\r\n", "output": "abdc\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "ab\r\n", "output": "ab\r\n"}, {"input": "ba\r\n", "output": "ab\r\n"}, {"input": "dijee\r\n", "output": "deeji\r\n"}, {"input": "bhrmc\r\n", "output": "bcmrh\r\n"}, {"input": "aaaaa...
false
stdio
null
true
797/C
797
C
Python 3
TESTS
20
639
921,600
136697802
s = list(input()) #s = ['a']*100000 u = [] index = 0 while(len(s)!= 0): for j in range(index, len(s)): if(len(u) != 0 and s[j] == u[len(u)-1]): index = j break if(s[j] < s[index]): index = j u.append(s.pop(index)) index = max(0, index-1) ...
189
108
14,131,200
220321279
stack = input() n = len(stack) aux = [0] * n aux[-1] = stack[-1] for i in range(n - 2, -1, -1): aux[i] = min(aux[i + 1], stack[i]) second_stack = [] result_stack = [] for i in range(n): if not second_stack: second_stack.append(stack[i]) else: while second_stack: if second_sta...
Educational Codeforces Round 19
ICPC
2,017
1
256
Minimal string
Petya recieved a gift of a string s with length up to 105 characters for his birthday. He took two more empty strings t and u and decided to play a game. This game has two possible moves: - Extract the first character of s and append t with this character. - Extract the last character of t and append u with this chara...
First line contains non-empty string s (1 ≤ |s| ≤ 105), consisting of lowercase English letters.
Print resulting string u.
null
null
[{"input": "cab", "output": "abc"}, {"input": "acdb", "output": "abdc"}]
1,700
["data structures", "greedy", "strings"]
189
[{"input": "cab\r\n", "output": "abc\r\n"}, {"input": "acdb\r\n", "output": "abdc\r\n"}, {"input": "a\r\n", "output": "a\r\n"}, {"input": "ab\r\n", "output": "ab\r\n"}, {"input": "ba\r\n", "output": "ab\r\n"}, {"input": "dijee\r\n", "output": "deeji\r\n"}, {"input": "bhrmc\r\n", "output": "bcmrh\r\n"}, {"input": "aaaaa...
false
stdio
null
true
691/B
691
B
Python 3
TESTS
24
62
4,505,600
134395076
s = input() f = 1 if len(s) % 2 == 1: k = len(s) // 2 if s[k] != 'H' and s[k] != 'A' and s[k] != 'I' and s[k] != 'M' and s[k] != 'O' and s[k] != 'o' \ and s[k] != 'T' and s[k] != 'V' and s[k] != 'v' and s[k] != 'W' and s[k] != 'w' \ and s[k] != 'X' and s[k] != 'x' and s[k] != 'Y' and s[k...
168
62
0
19080106
midsym = 'AHIMOoTUVvWwXxY' sym = 'pqbd' s = input() if len(s) % 2 == 1: t = len(s) // 2 if s[t] not in midsym: print('NIE') exit() s = s[:t] + s[t+1:] #print(s) f = s[:int(len(s)/2)] l = s[int(len(s)/2):] l = l[::-1] for k in range(len(f)): if f[k] not in midsym and f[k] not in sym: print('NIE') exit()...
Educational Codeforces Round 14
ICPC
2,016
1
256
s-palindrome
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half. English alphabet You are given a string ...
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
null
null
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
1,600
["implementation", "strings"]
168
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "v...
false
stdio
null
true
691/B
691
B
PyPy 3
TESTS
24
124
23,244,800
20033974
#!/usr/bin/env python3 def check(s): chars = 'AHIMOoTUVvWwXxY' sr = list(reversed(s)) for i in range(len(s)): if s[i] not in chars + 'dbpq': return False for a, b in [('d', 'b'), ('b', 'd'), ('q', 'p'), ('p', 'q')]: if s[i] == a and sr[i] != b: ...
168
62
0
19084773
s = str(input()) n = len(s) ss = ['A', 'H', 'I', 'M', 'O','o','T','U','V','v','W','w','X','x','Y'] ss2 = [('d','b'),('q','p'),('p','q'),('b','d')] for i in range(0, n//2): if s[i]==s[n-1-i]: if not (s[i] in ss): print("NIE") exit() else: if not ((s[i],s[n-1-i]) in ss2)...
Educational Codeforces Round 14
ICPC
2,016
1
256
s-palindrome
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half. English alphabet You are given a string ...
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
null
null
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
1,600
["implementation", "strings"]
168
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "v...
false
stdio
null
true
858/E
858
E
Python 3
TESTS
1
46
204,800
30971427
n = int(input()) top = set() bottom = set() for i in range(n): name, type = input().split() if type == '1': top.add(name) else: bottom.add(name) a = len(top) b = len(bottom) sa = set(str(i) for i in range(1, a + 1)) q = sa & top sa -= q top -= q sb = set(str(i) for i in range(a + 1, b + a +...
165
295
27,136,000
230751905
n = int(input()) t = [1] + [0] * n b, a = d = [], [] h, s = [], [] for i in range(n): f, k = input().split() d[int(k)].append(f) m = len(a) for i in a: if i.isdigit() and i[0] != '0': j = int(i) if 0 < j <= m: t[j] = 1 elif m < j <= n: t[j] = -1 else...
Технокубок 2018 - Отборочный Раунд 1
CF
2,017
2
256
Tests Renumeration
The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website. Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic. Vladimir wants to re...
The first line contains single integer n (1 ≤ n ≤ 105) — the number of files with tests. n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. ...
In the first line print the minimum number of lines in Vladimir's script file. After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" — is a string of digits and small English letters with length from 1 to 6.
null
null
[{"input": "5\n01 0\n2 1\n2extra 0\n3 1\n99 0", "output": "4\nmove 3 1\nmove 01 5\nmove 2extra 4\nmove 99 3"}, {"input": "2\n1 0\n2 1", "output": "3\nmove 1 3\nmove 2 1\nmove 3 2"}, {"input": "5\n1 0\n11 1\n111 0\n1111 1\n11111 0", "output": "5\nmove 1 5\nmove 11 1\nmove 1111 2\nmove 111 4\nmove 11111 3"}]
2,200
["greedy", "implementation"]
165
[{"input": "5\r\n01 0\r\n2 1\r\n2extra 0\r\n3 1\r\n99 0\r\n", "output": "4\r\nmove 3 1\r\nmove 01 5\r\nmove 2extra 4\r\nmove 99 3\r\n"}, {"input": "2\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 1 dytuig\r\nmove 2 1\r\nmove dytuig 2\r\n"}, {"input": "5\r\n1 0\r\n11 1\r\n111 0\r\n1111 1\r\n11111 0\r\n", "output": "5\r\nmove...
false
stdio
import sys def main(): input_path = sys.argv[1] output_path = sys.argv[2] submission_path = sys.argv[3] with open(input_path) as f: n = int(f.readline()) files = [] type1_count = 0 for _ in range(n): line = f.readline().strip() name, typ = line.s...
true
691/B
691
B
PyPy 3
TESTS
38
93
0
110982063
s = input() d = {"b" : "d","d":"b","l":"l","o":"o","p":"q","q":"p","v":"v","w":"w","x":"x","A":"A","H":"H","I":"I","M":"M","O":"O","T":"T","U":"U","V":"V","W":"W","X":"X","Y":"Y"} n = len(s)//2 flag = 0 l = [] if len(s)%2 == 0: i = n-1 j = n else: i = n j = n while i > -1: if s[i] not in d: ...
168
62
0
19099266
''' Created on Jul 14, 2016 @author: Md. Rezwanul Haque ''' s = input() D = {'A': 'A', 'b': 'd', 'd': 'b', 'H': 'H', 'I': 'I', 'M': 'M', 'O': 'O', 'o': 'o', 'p': 'q', 'q': 'p', 'T': 'T', 'U': 'U', 'V': 'V', 'v': 'v', 'W': 'W', 'w': 'w', 'X': 'X', 'x': 'x', 'Y': 'Y'} for(c1,c2) in zip(s, s[::-1]): if(D.get(...
Educational Codeforces Round 14
ICPC
2,016
1
256
s-palindrome
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half. English alphabet You are given a string ...
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
null
null
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
1,600
["implementation", "strings"]
168
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "v...
false
stdio
null
true
792/C
792
C
Python 3
TESTS
37
140
7,987,200
25858647
import sys s = list(input()) digsum = 0 rem = [0 for i in range(len(s))] for i in range(0, len(s)): dig = ord(s[i]) - ord('0'); digsum += dig rem[i] = dig % 3 currem = digsum % 3 if currem == 0: print(''.join(s)) sys.exit() if len(s) == 1: print(-1) sys.exit() inds1 = [] inds2 = [] for i...
162
77
6,860,800
26445505
import re s = input() t = s.translate(str.maketrans("0123456789", "0120120120")) x = (t.count('1') + t.count('2') * 2) % 3 if x: res = [''] l = t.rsplit("12"[x == 2], 1) if len(l) == 2: a = len(l[0]) res.append((s[:a], s[a + 1:])) l = t.rsplit("12"[x == 1], 2) if len(l) == 3: ...
Educational Codeforces Round 18
ICPC
2,017
1
256
Divide by Three
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible. The number is called beautiful if it consists of at least one digit, doesn't have leading zer...
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
null
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
2,000
["dp", "greedy", "math", "number theory"]
162
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": ...
false
stdio
import sys def is_subsequence(s, t): t_iter = iter(t) try: for c in s: while next(t_iter) != c: pass return True except StopIteration: return False def is_beautiful(s): if not s: return False if s[0] == '0' and len(s) > 1: return ...
true
818/C
818
C
Python 3
TESTS
6
61
5,632,000
34566012
def main(): # import sys d = int(input()) n, m = [int(x) for x in input().split()] point = [] for x in range(d): point.append([int(x) for x in input().split()]) point[-1].append(x+1) q = [int(x) for x in input().split()] def cntl(n): # print(max(n[0],n[2])) retu...
212
560
17,920,000
93166980
import sys from bisect import bisect_left, bisect_right d = int(sys.stdin.buffer.readline().decode('utf-8')) n, m = map(int, sys.stdin.buffer.readline().decode('utf-8').split()) a = [list(map(int, sys.stdin.buffer.readline().decode('utf-8').split())) for _ in range(d)] cnt = list(map(int, sys.stdin.buffer.readlin...
Educational Codeforces Round 24
ICPC
2,017
1
256
Sofa Thief
Yet another round on DecoForces is coming! Grandpa Maks wanted to participate in it but someone has stolen his precious sofa! And how can one perform well with such a major loss? Fortunately, the thief had left a note for Grandpa Maks. This note got Maks to the sofa storehouse. Still he had no idea which sofa belongs ...
The first line contains one integer number d (1 ≤ d ≤ 105) — the number of sofas in the storehouse. The second line contains two integer numbers n, m (1 ≤ n, m ≤ 105) — the size of the storehouse. Next d lines contains four integer numbers x1, y1, x2, y2 (1 ≤ x1, x2 ≤ n, 1 ≤ y1, y2 ≤ m) — coordinates of the i-th sofa...
Print the number of the sofa for which all the conditions are met. Sofas are numbered 1 through d as given in input. If there is no such sofa then print -1.
null
Let's consider the second example. - The first sofa has 0 to its left, 2 sofas to its right ((1, 1) is to the left of both (5, 5) and (5, 4)), 0 to its top and 2 to its bottom (both 2nd and 3rd sofas are below). - The second sofa has cntl = 2, cntr = 1, cntt = 2 and cntb = 0. - The third sofa has cntl = 2, cntr = 1, c...
[{"input": "2\n3 2\n3 1 3 2\n1 2 2 2\n1 0 0 1", "output": "1"}, {"input": "3\n10 10\n1 2 1 1\n5 5 6 5\n6 4 5 4\n2 1 2 0", "output": "2"}, {"input": "2\n2 2\n2 1 1 1\n1 2 2 2\n1 0 0 0", "output": "-1"}]
2,000
["brute force", "implementation"]
212
[{"input": "2\r\n3 2\r\n3 1 3 2\r\n1 2 2 2\r\n1 0 0 1\r\n", "output": "1\r\n"}, {"input": "3\r\n10 10\r\n1 2 1 1\r\n5 5 6 5\r\n6 4 5 4\r\n2 1 2 0\r\n", "output": "2\r\n"}, {"input": "2\r\n2 2\r\n2 1 1 1\r\n1 2 2 2\r\n1 0 0 0\r\n", "output": "-1\r\n"}, {"input": "1\r\n1 2\r\n1 1 1 2\r\n0 0 0 0\r\n", "output": "1\r\n"}, ...
false
stdio
null
true
691/B
691
B
PyPy 3
TESTS
28
109
20,480,000
127190638
from collections import defaultdict import sys input = sys.stdin.readline d = defaultdict(lambda : "?") for i in list("AHIMmOoTUVvWwXxY"): d[i] = i d["b"] = "d" d["d"] = "b" d["p"] = "q" d["q"] = "p" s = list(input().rstrip()) n = len(s) ans = "TAK" for i in range(n): if not d[s[i]] == s[n - i - 1]: an...
168
62
0
19110383
import sys pairs = [ 'AA', 'HH', 'II', 'MM', 'OO', 'TT', 'UU', 'VV', 'WW', 'XX', 'YY', 'bd', 'db', 'oo', 'pq', 'qp', 'vv', 'ww', 'xx' ] s = input() l, r = 0, len(s) - 1 while l <= r: if s[l] + s[r] not in pairs: print("NIE") sys.exit(0) l += 1 r -= 1 print("TAK")
Educational Codeforces Round 14
ICPC
2,016
1
256
s-palindrome
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half. English alphabet You are given a string ...
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
null
null
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
1,600
["implementation", "strings"]
168
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "v...
false
stdio
null
true
691/B
691
B
PyPy 3
TESTS
28
140
20,172,800
80008474
def f(s): i=0 n=len(s) j = int(n)-1 S = {'A','H','I','M','m','O','o','T','U','V','v','W','w','X','x','Y'} while(i<=j): if((s[i]=='b' and s[j]=='d') or (s[i]=='d' and s[j]=='b')): i+=1 j-=1 continue if((s[i]=='p' and s[j]=='q') or (s[i]=='q' and s[j...
168
62
0
148521856
s = input() print(all([ s[i] + s[-i-1] in "AA.HH.II.MM.OO.oo.TT.UU.VV.vv.WW.ww.XX.xx.YY.bd.db.pq.qp" for i in range(len(s)) ]) and "TAK" or "NIE")
Educational Codeforces Round 14
ICPC
2,016
1
256
s-palindrome
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half. English alphabet You are given a string ...
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
null
null
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
1,600
["implementation", "strings"]
168
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "v...
false
stdio
null
true
792/C
792
C
PyPy 3
TESTS
36
139
30,208,000
26737037
def f(n, r, k): tmp = n for t in range(k): for i in range(len(tmp) - 1, -1, -1): if int(tmp[i]) % 3 == r: tmp = tmp[:i] + tmp[i + 1:] break for i in range(len(tmp) - 1): if int(tmp[i]) != 0: return ''.join(tmp[i:]) if len(tmp) == 0 ...
162
109
6,246,400
28276110
n = list(input()) leng = 0 mp=[0,0,0] for x in n: leng += 1 mp[int(x)%3]+=1 tot = (mp[1]+2*mp[2])%3 if tot == 0: print("".join(n)) exit() if mp[tot] == 0: do = tot ^ 3 cnt = 2 else: if mp[tot] == 1 and int(n[0])%3==tot and n[1:3] == ['0','0']: do =tot^3 cnt = 2 if mp[do] == 0: do = tot cnt = 1 else:...
Educational Codeforces Round 18
ICPC
2,017
1
256
Divide by Three
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible. The number is called beautiful if it consists of at least one digit, doesn't have leading zer...
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
null
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
2,000
["dp", "greedy", "math", "number theory"]
162
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": ...
false
stdio
import sys def is_subsequence(s, t): t_iter = iter(t) try: for c in s: while next(t_iter) != c: pass return True except StopIteration: return False def is_beautiful(s): if not s: return False if s[0] == '0' and len(s) > 1: return ...
true
691/B
691
B
Python 3
TESTS
23
109
307,200
55610602
d = {'o': 'o', 'I': 'I', 'H': 'H', 'i': 'i', 'b': 'd', 'x': 'x', 'X': 'X', 'V': 'V', 'v': 'v', 'U': 'U', 'W': 'W', 'w': 'w', 'M': 'M', 'A': 'A', 'Y': 'Y', 'T': 'T', 'p': 'q', 'q': 'p', 'd': 'b', 'O': 'O'} c = ['U', 'I', 'O', 'T', 'H', 'i', 'X', 'x', 'o', 'M', 'A', 'W', 'w', 'V', 'v', 'Y', ] s = in...
168
62
4,608,000
19725920
def check(s): p='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' q='A HI M O TUVWXY d b oqp vwx ' for i in range(len(s)): if q[ p.find(s[i]) ]!=s[-i-1]: return False return True print('TAK' if check(input()) else 'NIE')
Educational Codeforces Round 14
ICPC
2,016
1
256
s-palindrome
Let's call a string "s-palindrome" if it is symmetric about the middle of the string. For example, the string "oHo" is "s-palindrome", but the string "aa" is not. The string "aa" is not "s-palindrome", because the second half of it is not a mirror reflection of the first half. English alphabet You are given a string ...
The only line contains the string s (1 ≤ |s| ≤ 1000) which consists of only English letters.
Print "TAK" if the string s is "s-palindrome" and "NIE" otherwise.
null
null
[{"input": "oXoxoXo", "output": "TAK"}, {"input": "bod", "output": "TAK"}, {"input": "ER", "output": "NIE"}]
1,600
["implementation", "strings"]
168
[{"input": "oXoxoXo\r\n", "output": "TAK\r\n"}, {"input": "bod\r\n", "output": "TAK\r\n"}, {"input": "ER\r\n", "output": "NIE\r\n"}, {"input": "o\r\n", "output": "TAK\r\n"}, {"input": "a\r\n", "output": "NIE\r\n"}, {"input": "opo\r\n", "output": "NIE\r\n"}, {"input": "HCMoxkgbNb\r\n", "output": "NIE\r\n"}, {"input": "v...
false
stdio
null
true
792/C
792
C
Python 3
TESTS
59
140
9,523,200
37535803
#!/usr/bin/env python3 # solution after hint:( sn = input().strip() n = len(sn) def rem3(sn): return sum(map(int, sn)) % 3 def buildn(sn, com, start=0): return ''.join(sn[start + i] for i in com) def subminbeau2(sn, start=0): n = len(sn) r3 = rem3(sn[start:]) nums = set(sn[1 + start:]) nums3 = set((int(i) % ...
162
109
6,553,600
25896991
def sumstr(s): sums = 0 for i in range(len(s)): sums += int(s[i]) return sums def mod3(s): sums = sumstr(s) return sums % 3 def onlyzeros(s): i = 0 while i < len(s): if s[i] != '0': return False i += 1 return True def lastin(s, s1): maxf = -1 #d = '-' for d in s1: f = s.rfind(d) #print(d, f,...
Educational Codeforces Round 18
ICPC
2,017
1
256
Divide by Three
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible. The number is called beautiful if it consists of at least one digit, doesn't have leading zer...
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
null
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
2,000
["dp", "greedy", "math", "number theory"]
162
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": ...
false
stdio
import sys def is_subsequence(s, t): t_iter = iter(t) try: for c in s: while next(t_iter) != c: pass return True except StopIteration: return False def is_beautiful(s): if not s: return False if s[0] == '0' and len(s) > 1: return ...
true
837/B
837
B
Python 3
TESTS
107
77
4,915,200
29204823
N, M = map(int, input().split()) flag = [input() for n in range(N)] def get_rect_of_color(color): rect_points = [] for i, row in enumerate(flag): first = True tmp = [None] * 4 for j, char in enumerate(row): if char == color: if first: fir...
153
46
0
188298470
# First of all, we should validate the input by checking the eligibilities in a function called 'validate_flag' def validate_flag(field: list) -> bool: # First, we validate the number of colors in the field total_colors = set() for row in field: total_colors.update(row) # If it is not exac...
Educational Codeforces Round 26
ICPC
2,017
1
256
Flag of Berland
The flag of Berland is such rectangular field n × m that satisfies following conditions: - Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. - Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. - Each c...
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field. Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
null
The field in the third example doesn't have three parralel stripes. Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
1,600
["brute force", "implementation"]
153
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nG...
false
stdio
null
true
837/B
837
B
Python 3
TESTS
127
93
5,120,000
29167646
import re n,m =map(int,input().split()) data = [ input() for _ in range(n)] temp = ''.join([data[i][0] for i in range(n)]) f1=False count={} i=0 mark=temp[0] while i<n and temp[i]==mark: i+=1 count[mark]=i j=i if j<n: mark=temp[j] while j<n and temp[j]==mark : j+=1 count[mark]=j-i if j<n...
153
61
4,608,000
29264658
def c(f, n, m): if n % 3 != 0:return 0 s=n//3;s=f[0],f[s],f[2*s] if set(s)!=set(map(lambda x:x*m,'RGB')):return 0 for i in range(n): if f[i] != s[i*3 // n]:return 0 return 1 n,m=map(int, input().split()) f=[input() for _ in range(n)] print('Yes'if c(f,n,m) or c([''.join(f[j][i] for j in rang...
Educational Codeforces Round 26
ICPC
2,017
1
256
Flag of Berland
The flag of Berland is such rectangular field n × m that satisfies following conditions: - Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. - Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. - Each c...
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field. Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
null
The field in the third example doesn't have three parralel stripes. Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
1,600
["brute force", "implementation"]
153
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nG...
false
stdio
null
true
837/B
837
B
PyPy 3
TESTS
127
234
3,174,400
81700781
import math as mt import sys,string input=sys.stdin.readline from collections import defaultdict L=lambda : list(map(int,input().split())) Ls=lambda : list(input().split()) M=lambda : map(int,input().split()) I=lambda :int(input()) n,m=M() l=[] flag=0 for i in range(n): s=input().strip() x=set([]) for j i...
153
62
0
30220071
def solve_h(lines): ''' >>> solve_h(['R', 'G', 'B']) True >>> solve_h(['RRR', 'GGG', 'BBB']) True >>> solve_h(['RRR', 'RRR', 'GGG', 'GGG', 'BBB', 'BBB']) True >>> solve_h(['RRR', 'RRR', 'RRR', 'GGG', 'BBB', 'BBB']) False >>> solve_h(['R', 'G', 'A']) False ''' if len(l...
Educational Codeforces Round 26
ICPC
2,017
1
256
Flag of Berland
The flag of Berland is such rectangular field n × m that satisfies following conditions: - Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. - Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. - Each c...
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field. Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
null
The field in the third example doesn't have three parralel stripes. Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
1,600
["brute force", "implementation"]
153
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nG...
false
stdio
null
true
837/B
837
B
Python 3
TESTS
113
124
0
40912880
n,m=list(map(int,input().split())) l=[0]*n for i in range(n): l[i]=input() types=['B','G','R'] first=[] second=[] third=[] counter=0 container=0 ans=[] ans1=[] if l[0].count('B')==l[0].count('R') and l[0].count('B')==l[0].count('G') : first.append(l[0][0]) types.remove(first[0]) for i in range(len(l[...
153
62
307,200
31198872
import sys #sys.stdin = open("input2","r") n,m = map(int,input().split()) s = [] for i in range(n): string = input() s.append(string) no = 0 # row mix check r_mix = 0 for i in range(n): cnt_r = s[i].count('R') cnt_b = s[i].count('B') cnt_g = s[i].count('G') if ((cnt_r and cnt_b) or (cnt_b and ...
Educational Codeforces Round 26
ICPC
2,017
1
256
Flag of Berland
The flag of Berland is such rectangular field n × m that satisfies following conditions: - Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. - Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. - Each c...
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field. Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
null
The field in the third example doesn't have three parralel stripes. Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
1,600
["brute force", "implementation"]
153
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nG...
false
stdio
null
true
792/C
792
C
Python 3
TESTS
34
155
9,318,400
26250901
def checkBeauty (digi): total = 0 for i in range(0,len(digi)): total += int(digi[i]) return total % 3 def modThree (digi): zero = [] one = [] two = [] for i in range(0,len(digi)): if int(digi[i]) % 3 == 0: zero.append(i) elif int(digi[i]) % 3 == 1: one.append(i) else: two.append(i) modResult =...
162
109
7,168,000
32921983
import re f = lambda t: re.sub(r'^0+(\d)', r'\1', t) g = lambda k: n - p.index(s, k) t = input() n = len(t) - 1 p = [int(q) % 3 for q in t][::-1] s = sum(p) % 3 if s == 0: print(t) exit() u = v = '' if s in p: i = g(0) u = f(t[:i] + t[i + 1:]) s = 3 - s if p.count(s) > 1: i = g(0) j = g(n - ...
Educational Codeforces Round 18
ICPC
2,017
1
256
Divide by Three
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible. The number is called beautiful if it consists of at least one digit, doesn't have leading zer...
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
null
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
2,000
["dp", "greedy", "math", "number theory"]
162
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": ...
false
stdio
import sys def is_subsequence(s, t): t_iter = iter(t) try: for c in s: while next(t_iter) != c: pass return True except StopIteration: return False def is_beautiful(s): if not s: return False if s[0] == '0' and len(s) > 1: return ...
true
807/A
807
A
Python 3
TESTS
43
109
102,400
47254713
n=int(input()) x,y=[],[] for i in range(n): a,b=map(int,input().split()) x.append(a) y.append(b) z=x[:] z.sort() z.reverse() if z==y: print("maybe") exit() if x==y: print("unrated") exit() if x!=y: print("rated")
150
46
0
131984875
t=int(input()) c=0 l=[] for i in range(t): a,b=map(int,input().split()) l.append(b) if a==b: c=c+1 if c!=t: print("rated") else: r=l[:] r.sort(reverse=True) if l==r: print("maybe") else: print("unrated")
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
CF
2,017
2
256
Is it rated?
Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before ...
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of th...
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
null
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated. In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, som...
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
900
["implementation", "sortings"]
150
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\...
false
stdio
null
true
598/C
598
C
Python 3
TESTS
113
841
22,016,000
116184762
import sys from math import atan2, degrees from decimal import Decimal sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): n = int(input()) XY = [] for i in range(n): x, y = map(int, input().split()) theta = Decimal(degrees(atan2...
163
779
41,369,600
175306822
from sys import stdin input=lambda :stdin.readline()[:-1] def compare(a,b): # 比較関数 (a<=b) # 偏角ソート ax, ay = a[:2] bx, by = b[:2] if ay < 0: return by >= 0 or ax * by - ay * bx > 0 if ay == 0: return ax >= 0 and (by > 0 or (by == 0 and bx < 0)) return by >= 0 and (ax * by - ay * bx) > 0 def me...
Educational Codeforces Round 1
ICPC
2,015
2
256
Nearest vectors
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them. Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 ...
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors. The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed t...
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
null
null
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
2,300
["geometry", "sortings"]
163
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\...
false
stdio
import sys import math def read_vectors(input_path): with open(input_path) as f: n = int(f.readline()) vectors = [] for i in range(n): x, y = map(int, f.readline().split()) vectors.append( (x, y, i+1) ) return vectors def compute_angle(x, y): return math.at...
true
837/B
837
B
PyPy 3-64
TESTS
17
77
2,969,600
210295461
import sys input = lambda: sys.stdin.readline().rstrip() N,M = map(int, input().split()) S = [] for _ in range(N): S.append(input()) INF = float('inf') A = [[INF,INF,-1,-1],[INF,INF,-1,-1],[INF,INF,-1,-1]] for i in range(N): for j in range(M): if S[i][j]=='R': A[0][0] = min(A[0][0],i) ...
153
62
307,200
110106847
def rotate_90_degree_anticlckwise(matrix): new_matrix = [] for i in range(len(matrix[0]), 0, -1): new_matrix.append(list(map(lambda x: x[i-1], matrix))) return new_matrix n,m = map(int,input().split()) mat = [] for i in range(n): temp = input() mat.append([i for i in temp]) horiz, verti = Fa...
Educational Codeforces Round 26
ICPC
2,017
1
256
Flag of Berland
The flag of Berland is such rectangular field n × m that satisfies following conditions: - Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. - Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. - Each c...
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field. Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
null
The field in the third example doesn't have three parralel stripes. Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
1,600
["brute force", "implementation"]
153
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nG...
false
stdio
null
true
807/A
807
A
PyPy 3
TESTS
69
233
2,150,400
97199173
from sys import maxsize, stdout, stdin, stderr # mod = int(1e9 + 7) import re # can use multiple splits tup = lambda: map(int, stdin.readline().split()) I = lambda: int(stdin.readline()) lint = lambda: [int(x) for x in stdin.readline().split()] S = lambda: stdin.readline().replace('\n', '').strip() def grid(r, c): ret...
150
46
0
132422536
a=int(input()) d=[] e=[] f=[] for i in range(a): b,c=map(int,input().split()) if b==c: d.append(b) e.append(b) e.sort() d=d[::-1] if len(d)!=a: print("rated") else: for j in range(len(d)): if e[j]==d[j]: f.append(e[j]) if len(f)==a: print("maybe") else...
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
CF
2,017
2
256
Is it rated?
Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before ...
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of th...
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
null
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated. In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, som...
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
900
["implementation", "sortings"]
150
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\...
false
stdio
null
true
598/C
598
C
PyPy 3-64
TESTS
118
483
17,715,200
147382716
import sys,math input = lambda: sys.stdin.readline()[:-1] get_int = lambda: int(input()) get_int_iter = lambda: map(int,input().split()) get_int_list = lambda: list(map(int,input().split())) n = get_int() vectors = [] mod = math.pi * 2 for i in range(1,n+1): x,y = get_int_iter() if x != 0: vectors.appe...
163
1,060
35,328,000
154855646
from math import atan2 s = lambda a, b: a[0] * b[0] + a[1] * b[1] v = lambda a, b: a[0] * b[1] - a[1] * b[0] p = [] for i in range(int(input())): x, y = map(int, input().split()) p.append((atan2(x, y), (x, y), i + 1)) p.sort() d = [(s(a, b), abs(v(a, b)), i, j) for (x, a, i), (y, b, j) in zip(p, p[1:] + p...
Educational Codeforces Round 1
ICPC
2,015
2
256
Nearest vectors
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them. Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 ...
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors. The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed t...
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
null
null
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
2,300
["geometry", "sortings"]
163
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\...
false
stdio
import sys import math def read_vectors(input_path): with open(input_path) as f: n = int(f.readline()) vectors = [] for i in range(n): x, y = map(int, f.readline().split()) vectors.append( (x, y, i+1) ) return vectors def compute_angle(x, y): return math.at...
true
598/C
598
C
Python 3
TESTS
113
530
8,704,000
173893303
import math def nearest_vec(L): L.sort() L.append(L[0]) min_val = float('inf') values = [-1, -1] for r in range(1, len(L)): x = L[r][0] - L[r - 1][0] if x < 0: x += 360 if x < min_val: min_val = x values[0] = L[r][1] values[1]...
163
1,153
20,992,000
112977689
from math import atan2 inner = lambda a, b: a[0] * b[0] + a[1] * b[1] outer = lambda a, b: a[0] * b[1] - a[1] * b[0] N = int(input()) vectors = [] for i in range(N): x, y = map(int, input().split()) vectors.append((atan2(y, x), (x, y), i + 1)) vectors.sort() diff = [] for i in range(N): diff.append([inne...
Educational Codeforces Round 1
ICPC
2,015
2
256
Nearest vectors
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them. Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 ...
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors. The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed t...
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
null
null
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
2,300
["geometry", "sortings"]
163
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\...
false
stdio
import sys import math def read_vectors(input_path): with open(input_path) as f: n = int(f.readline()) vectors = [] for i in range(n): x, y = map(int, f.readline().split()) vectors.append( (x, y, i+1) ) return vectors def compute_angle(x, y): return math.at...
true
598/C
598
C
Python 3
TESTS
117
483
9,932,800
111295171
""" You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them. Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always betwee...
163
1,185
29,696,000
197816661
from functools import cmp_to_key def is_top(vector): return vector[1] > 0 or vector[1] == 0 and vector[0] > 0 def cross(first, second): return first[0] * second[1] - second[0] * first[1] def dot(first, second): return first[0]*second[0] + first[1]*second[1] def polar_cmp(first, second): if is_to...
Educational Codeforces Round 1
ICPC
2,015
2
256
Nearest vectors
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them. Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 ...
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors. The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed t...
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
null
null
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
2,300
["geometry", "sortings"]
163
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\...
false
stdio
import sys import math def read_vectors(input_path): with open(input_path) as f: n = int(f.readline()) vectors = [] for i in range(n): x, y = map(int, f.readline().split()) vectors.append( (x, y, i+1) ) return vectors def compute_angle(x, y): return math.at...
true
598/C
598
C
Python 3
TESTS
117
764
14,540,800
118716539
import math class vector: def __init__(self, X, Y, P) -> None: self.v = math.atan2(X, Y) self.p = P def work(v) -> float: while v < 0: v += math.pi * 2 while v > math.pi * 2: v -= math.pi * 2 return min(v, math.pi * 2 - v) n = int(input()) a = list() for i in range(...
163
1,201
23,347,200
112976028
from math import atan2 inner = lambda a, b: a[0] * b[0] + a[1] * b[1] outer = lambda a, b: a[0] * b[1] - a[1] * b[0] vectors = [] for i in range(int(input())): x, y = map(int, input().split()) vectors.append((atan2(y, x), (x, y), i + 1)) vectors.sort() diff = [(inner(vec1, vec2), abs(outer(vec1, vec2)), i, ...
Educational Codeforces Round 1
ICPC
2,015
2
256
Nearest vectors
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them. Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 ...
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors. The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed t...
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
null
null
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
2,300
["geometry", "sortings"]
163
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\...
false
stdio
import sys import math def read_vectors(input_path): with open(input_path) as f: n = int(f.readline()) vectors = [] for i in range(n): x, y = map(int, f.readline().split()) vectors.append( (x, y, i+1) ) return vectors def compute_angle(x, y): return math.at...
true
858/E
858
E
Python 3
PRETESTS
0
46
0
30438694
n = int(input()) tasks = [] e = 0 for i in range(n): s = input().split() if s[0].isdigit(): s[0] = int(s[0]) a = [s[0], int(s[1])] tasks.append(a) if a[1]: e += 1 tasks.sort(key=lambda x: -x[1]) newSet = set(range(1, e + 1)) goodSet = set() for i in range(e): if tasks[i][0] in ne...
165
295
27,136,000
230751905
n = int(input()) t = [1] + [0] * n b, a = d = [], [] h, s = [], [] for i in range(n): f, k = input().split() d[int(k)].append(f) m = len(a) for i in a: if i.isdigit() and i[0] != '0': j = int(i) if 0 < j <= m: t[j] = 1 elif m < j <= n: t[j] = -1 else...
Технокубок 2018 - Отборочный Раунд 1
CF
2,017
2
256
Tests Renumeration
The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website. Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic. Vladimir wants to re...
The first line contains single integer n (1 ≤ n ≤ 105) — the number of files with tests. n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. ...
In the first line print the minimum number of lines in Vladimir's script file. After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" — is a string of digits and small English letters with length from 1 to 6.
null
null
[{"input": "5\n01 0\n2 1\n2extra 0\n3 1\n99 0", "output": "4\nmove 3 1\nmove 01 5\nmove 2extra 4\nmove 99 3"}, {"input": "2\n1 0\n2 1", "output": "3\nmove 1 3\nmove 2 1\nmove 3 2"}, {"input": "5\n1 0\n11 1\n111 0\n1111 1\n11111 0", "output": "5\nmove 1 5\nmove 11 1\nmove 1111 2\nmove 111 4\nmove 11111 3"}]
2,200
["greedy", "implementation"]
165
[{"input": "5\r\n01 0\r\n2 1\r\n2extra 0\r\n3 1\r\n99 0\r\n", "output": "4\r\nmove 3 1\r\nmove 01 5\r\nmove 2extra 4\r\nmove 99 3\r\n"}, {"input": "2\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 1 dytuig\r\nmove 2 1\r\nmove dytuig 2\r\n"}, {"input": "5\r\n1 0\r\n11 1\r\n111 0\r\n1111 1\r\n11111 0\r\n", "output": "5\r\nmove...
false
stdio
import sys def main(): input_path = sys.argv[1] output_path = sys.argv[2] submission_path = sys.argv[3] with open(input_path) as f: n = int(f.readline()) files = [] type1_count = 0 for _ in range(n): line = f.readline().strip() name, typ = line.s...
true
598/C
598
C
PyPy 3-64
TESTS
117
1,045
16,588,800
142613751
from math import atan2 arr = [] n = int(input()) for j in range(n): x, y = [int(i) for i in input().split()] arr += [(atan2(x, y), j)] arr = sorted(arr) gap = 10 for x, y in zip(arr, arr[1:] + [(arr[0][0] + 2*3.1415926, arr[0][1])]): if abs(x[0] - y[0]) < gap: gap = abs(x[0] - y[0]) ans =...
163
1,699
26,009,600
154838623
import math class Point: def __init__(self, x, y): self.x = x self.y = y def quad(self): return self.y > 0 or (self.y == 0 and self.x > 0) def len(self): return self.x * self.x + self.y * self.y def __lt__(self, other): if self.quad() != other.quad(): ...
Educational Codeforces Round 1
ICPC
2,015
2
256
Nearest vectors
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them. Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 ...
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors. The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed t...
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
null
null
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
2,300
["geometry", "sortings"]
163
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\...
false
stdio
import sys import math def read_vectors(input_path): with open(input_path) as f: n = int(f.readline()) vectors = [] for i in range(n): x, y = map(int, f.readline().split()) vectors.append( (x, y, i+1) ) return vectors def compute_angle(x, y): return math.at...
true
598/C
598
C
PyPy 3
TESTS
113
483
10,547,200
168322502
import sys readline=sys.stdin.readline import math class Vector2(): def __init__(self,x,y): self.x=x self.y=y def __lt__(self,other): if (other.y,other.x)<(0,0)<(self.y,self.x): return True if (self.y,self.x)<(0,0)<(other.y,other.x): return False ...
163
779
41,369,600
175306822
from sys import stdin input=lambda :stdin.readline()[:-1] def compare(a,b): # 比較関数 (a<=b) # 偏角ソート ax, ay = a[:2] bx, by = b[:2] if ay < 0: return by >= 0 or ax * by - ay * bx > 0 if ay == 0: return ax >= 0 and (by > 0 or (by == 0 and bx < 0)) return by >= 0 and (ax * by - ay * bx) > 0 def me...
Educational Codeforces Round 1
ICPC
2,015
2
256
Nearest vectors
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them. Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 ...
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors. The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed t...
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
null
null
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
2,300
["geometry", "sortings"]
163
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\...
false
stdio
import sys import math def read_vectors(input_path): with open(input_path) as f: n = int(f.readline()) vectors = [] for i in range(n): x, y = map(int, f.readline().split()) vectors.append( (x, y, i+1) ) return vectors def compute_angle(x, y): return math.at...
true
598/C
598
C
PyPy 3-64
TESTS
118
1,419
14,950,400
202054936
# https://codeforces.com/contest/598/problem/C from math import atan2, pi def diff(angle1, angle2): delta = abs(angle1 - angle2) return delta if delta <= pi else 2 * pi - delta n = int(input()) vecs = [] for i in range(1, n + 1): x, y = map(int, input().split()) angle = atan2(y, x) if angle < 0: ...
163
1,060
35,328,000
154855646
from math import atan2 s = lambda a, b: a[0] * b[0] + a[1] * b[1] v = lambda a, b: a[0] * b[1] - a[1] * b[0] p = [] for i in range(int(input())): x, y = map(int, input().split()) p.append((atan2(x, y), (x, y), i + 1)) p.sort() d = [(s(a, b), abs(v(a, b)), i, j) for (x, a, i), (y, b, j) in zip(p, p[1:] + p...
Educational Codeforces Round 1
ICPC
2,015
2
256
Nearest vectors
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them. Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 ...
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors. The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed t...
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
null
null
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
2,300
["geometry", "sortings"]
163
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\...
false
stdio
import sys import math def read_vectors(input_path): with open(input_path) as f: n = int(f.readline()) vectors = [] for i in range(n): x, y = map(int, f.readline().split()) vectors.append( (x, y, i+1) ) return vectors def compute_angle(x, y): return math.at...
true
598/C
598
C
PyPy 3-64
TESTS
144
904
24,678,400
136345958
import math def dot_product(ax, ay, bx, by): return ax * bx + ay * by def cross_product(ax, ay, bx, by): return ax * by - ay * bx n = int(input()) A = [] for i in range(n): a, b = map(int, input().split()) A.append((a, b, i)) A.sort(key=lambda x: math.atan2(cross_product(x[0], x[1], 1, 0), dot_prod...
163
1,153
20,992,000
112977689
from math import atan2 inner = lambda a, b: a[0] * b[0] + a[1] * b[1] outer = lambda a, b: a[0] * b[1] - a[1] * b[0] N = int(input()) vectors = [] for i in range(N): x, y = map(int, input().split()) vectors.append((atan2(y, x), (x, y), i + 1)) vectors.sort() diff = [] for i in range(N): diff.append([inne...
Educational Codeforces Round 1
ICPC
2,015
2
256
Nearest vectors
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them. Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 ...
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors. The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed t...
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
null
null
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
2,300
["geometry", "sortings"]
163
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\...
false
stdio
import sys import math def read_vectors(input_path): with open(input_path) as f: n = int(f.readline()) vectors = [] for i in range(n): x, y = map(int, f.readline().split()) vectors.append( (x, y, i+1) ) return vectors def compute_angle(x, y): return math.at...
true
598/C
598
C
PyPy 3
TESTS
113
389
10,035,200
205154019
import math import sys, os, io input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline n = int(input()) z = [] for i in range(n): x, y = map(int, input().split()) u = math.degrees(math.atan2(y, x)) z.append((u, i + 1)) z.sort() mi = 360 for i in range(n): x1, u = z[i] x2, v = z[(i + 1) % n] ...
163
1,185
29,696,000
197816661
from functools import cmp_to_key def is_top(vector): return vector[1] > 0 or vector[1] == 0 and vector[0] > 0 def cross(first, second): return first[0] * second[1] - second[0] * first[1] def dot(first, second): return first[0]*second[0] + first[1]*second[1] def polar_cmp(first, second): if is_to...
Educational Codeforces Round 1
ICPC
2,015
2
256
Nearest vectors
You are given the set of vectors on the plane, each of them starting at the origin. Your task is to find a pair of vectors with the minimal non-oriented angle between them. Non-oriented angle is non-negative value, minimal between clockwise and counterclockwise direction angles. Non-oriented angle is always between 0 ...
First line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of vectors. The i-th of the following n lines contains two integers xi and yi (|x|, |y| ≤ 10 000, x2 + y2 > 0) — the coordinates of the i-th vector. Vectors are numbered from 1 to n in order of appearing in the input. It is guaranteed t...
Print two integer numbers a and b (a ≠ b) — a pair of indices of vectors with the minimal non-oriented angle. You can print the numbers in any order. If there are many possible answers, print any.
null
null
[{"input": "4\n-1 0\n0 -1\n1 0\n1 1", "output": "3 4"}, {"input": "6\n-1 0\n0 -1\n1 0\n1 1\n-4 -5\n-4 -6", "output": "6 5"}]
2,300
["geometry", "sortings"]
163
[{"input": "4\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n", "output": "3 4\r\n"}, {"input": "6\r\n-1 0\r\n0 -1\r\n1 0\r\n1 1\r\n-4 -5\r\n-4 -6\r\n", "output": "5 6\r\n"}, {"input": "10\r\n8 6\r\n-7 -3\r\n9 8\r\n7 10\r\n-3 -8\r\n3 7\r\n6 -8\r\n-9 8\r\n9 2\r\n6 7\r\n", "output": "1 3\r\n"}, {"input": "20\r\n-9 8\r\n-7 3\r\n0 10\r\...
false
stdio
import sys import math def read_vectors(input_path): with open(input_path) as f: n = int(f.readline()) vectors = [] for i in range(n): x, y = map(int, f.readline().split()) vectors.append( (x, y, i+1) ) return vectors def compute_angle(x, y): return math.at...
true
837/B
837
B
Python 3
TESTS
79
124
307,200
56131685
altura, largura = map(int, input().split()) band = [input() for i in range(altura)] new_bandeira = [''.join(coluna) for coluna in zip(*band)] def confere(bandeira, altura): flag = True for linha in bandeira: cor = linha[0] if cor * len(linha) != linha: flag = False brea...
153
62
4,608,000
29234268
#! /usr/bin/python3 import sys def verifyFlag(flagList, row, column): if row%3 != 0: return False q = row // 3 #since there are 3 equal parts u = [flagList[(0 * q)], flagList[(1 * q)], flagList[(2 * q)]] us = set(u) #removes duplicates patternToMatch = set() for color in ['R', 'G', 'B...
Educational Codeforces Round 26
ICPC
2,017
1
256
Flag of Berland
The flag of Berland is such rectangular field n × m that satisfies following conditions: - Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. - Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. - Each c...
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field. Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
null
The field in the third example doesn't have three parralel stripes. Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
1,600
["brute force", "implementation"]
153
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nG...
false
stdio
null
true
807/A
807
A
Python 3
TESTS
28
46
0
188425791
def is_it_rated(): n = int(input()) before, after = list(), list() for i in range(n): b, a = map(int, input().split()) before.append(b) after.append(a) maybe = False for i in range(n): if before[i] != after[i]: return "rated" max_till = before[0] for i in range(1,n): if before[i] <= max_till: ...
150
46
0
141227803
l=[];l1=[] t=int(input()) for i in range(t): a,b=map(int,input().split()) l.append(a);l1.append(b) p=l x=[i-j for (i,j) in zip(l,l1)] y=sorted(p,reverse=True) if x.count(0)!=t: print("rated") elif x.count(0)==t and y!=l: print("unrated") else: print("maybe")
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
CF
2,017
2
256
Is it rated?
Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before ...
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of th...
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
null
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated. In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, som...
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
900
["implementation", "sortings"]
150
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\...
false
stdio
null
true
807/A
807
A
Python 3
TESTS
28
46
0
145144892
n=int(input()) a,b=0,0 counter=0 List=[] for i in range(n): a,b=map(int,input().split()) if a!=b: counter+=1 List.append([a,b]) if counter!=0: print("rated") else: minValue=min(List) if minValue !=List[len(List)-1]: print("unrated") else: print("maybe")
150
46
0
144055840
w=int(input()) l=[] flag=0 for i in range(w): t=list(map(int,input().split())) if t[0]!=t[1]: flag=1 else: l.append(t[0]) if flag!=1: y=list(l) y.sort(reverse=True) if y==l: print('maybe') else: print('unrated') else: print('rated')
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
CF
2,017
2
256
Is it rated?
Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before ...
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of th...
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
null
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated. In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, som...
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
900
["implementation", "sortings"]
150
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\...
false
stdio
null
true
837/B
837
B
PyPy 3
TESTS
24
186
4,403,200
118945367
import sys #import random from bisect import bisect_left as lb from collections import deque #sys.setrecursionlimit(10**8) from queue import PriorityQueue as pq from math import * input_ = lambda: sys.stdin.readline().strip("\r\n") ii = lambda : int(input_()) il = lambda : list(map(int, input_().split())) ilf = lambda ...
153
62
4,915,200
29161993
import sys def main(): n, m = map(int, sys.stdin.readline().split()) if n % 3 != 0 and m % 3 != 0: print("NO") return f = [] for i in range(n): f.append(sys.stdin.readline()) ok = True if f[0][0] == f[n - 1][0]: # vertical if m % 3 != 0: ok = False...
Educational Codeforces Round 26
ICPC
2,017
1
256
Flag of Berland
The flag of Berland is such rectangular field n × m that satisfies following conditions: - Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. - Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. - Each c...
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field. Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
null
The field in the third example doesn't have three parralel stripes. Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
1,600
["brute force", "implementation"]
153
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nG...
false
stdio
null
true
837/B
837
B
Python 3
TESTS
24
61
4,915,200
29167831
n, m = map(int, input().split()) f = [] for i in range(n): f.append(input()) #flag rf1 = [] #real flag rez = True if (n % 3 == 0) or (m % 3 == 0): if n % 3 == 0: for i in range(n // 3): rf1.append('R' * m) for i in range(n // 3): rf1.append('B' * m) for i in range...
153
62
4,915,200
29162004
n, m = map(int, input().split()) flag = [] def letterwidth(i): res = flag[i][0] for item in flag[i]: if item != res: return None return res def letterheight(i): res = flag[0][i] for j in range(n): if flag[j][i] != res: return None return res for i in ra...
Educational Codeforces Round 26
ICPC
2,017
1
256
Flag of Berland
The flag of Berland is such rectangular field n × m that satisfies following conditions: - Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. - Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. - Each c...
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field. Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
null
The field in the third example doesn't have three parralel stripes. Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
1,600
["brute force", "implementation"]
153
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nG...
false
stdio
null
true
807/A
807
A
Python 3
TESTS
21
46
0
225697559
n=int(input()) before_round=[] after_round=[] sum_before=0 sum_after=0 for i in range(n): before,after=map(int,input().split()) sum_before+=before sum_after+=after before_round.append(before) after_round.append(after) if(sum_before!=sum_after): print("rated") else: if(before_round!=s...
150
46
0
144294915
a = [] b = [] for i in range(int(input())): input2 = list(map(int,input().split())) if input2[0] < input2[1]: a.append(input2[0]) b.append(input2[1]) break else: a.append(input2[0]) b.append(input2[1]) if a != b: print("rated") else: a.sort() a = ...
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
CF
2,017
2
256
Is it rated?
Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before ...
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of th...
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
null
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated. In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, som...
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
900
["implementation", "sortings"]
150
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\...
false
stdio
null
true
837/B
837
B
Python 3
TESTS
62
62
4,915,200
29204655
N, M = map(int, input().split()) flag = [input() for n in range(N)] def get_rect_of_color(color): rect_points = [] for i, row in enumerate(flag): first = True tmp = [None] * 4 for j, char in enumerate(row): if char == color: if first: fir...
153
62
4,915,200
29164140
a, b = map(int, input().split()) rows = [list(input()) for x in range(a)] columns = [[x[y] for x in rows] for y in range(b)] def check(l): line = [] for x in l: p = x[0] for y in x: if y != p: break else: line.append(p) continue ...
Educational Codeforces Round 26
ICPC
2,017
1
256
Flag of Berland
The flag of Berland is such rectangular field n × m that satisfies following conditions: - Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. - Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. - Each c...
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field. Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
null
The field in the third example doesn't have three parralel stripes. Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
1,600
["brute force", "implementation"]
153
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nG...
false
stdio
null
true
837/B
837
B
Python 3
TESTS
24
62
4,915,200
29273806
'''input 4 4 RRRR RRRR BBBB GGGG ''' n, m = map(int, input().split()) if (n*m) % 3 != 0: print("NO") else: f = [input() for _ in range(n)] if n % 3 == 0: for x in f: if len(set(x)) != 1: print("NO") break else: if any(len(set(f[(n*(i-1))//3:(n*i)//3])) != 1 for i in range(1, 3)): print("NO") ...
153
62
4,915,200
29165939
def check(n, m, fl, count): global flag, tr_flag if count == 3: return 'NO' num = n // 3 is_ok = set() for k in range(0, n, num): new_check = set() for i in range(k, k + num): new_check = new_check | set(fl[i]) if len(new_check) != 1: flag, tr_flag = tr_flag, flag if m % 3 ==...
Educational Codeforces Round 26
ICPC
2,017
1
256
Flag of Berland
The flag of Berland is such rectangular field n × m that satisfies following conditions: - Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. - Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. - Each c...
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field. Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
null
The field in the third example doesn't have three parralel stripes. Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
[{"input": "6 5\nRRRRR\nRRRRR\nBBBBB\nBBBBB\nGGGGG\nGGGGG", "output": "YES"}, {"input": "4 3\nBRG\nBRG\nBRG\nBRG", "output": "YES"}, {"input": "6 7\nRRRGGGG\nRRRGGGG\nRRRGGGG\nRRRBBBB\nRRRBBBB\nRRRBBBB", "output": "NO"}, {"input": "4 4\nRRRR\nRRRR\nBBBB\nGGGG", "output": "NO"}]
1,600
["brute force", "implementation"]
153
[{"input": "6 5\r\nRRRRR\r\nRRRRR\r\nBBBBB\r\nBBBBB\r\nGGGGG\r\nGGGGG\r\n", "output": "YES\r\n"}, {"input": "4 3\r\nBRG\r\nBRG\r\nBRG\r\nBRG\r\n", "output": "YES\r\n"}, {"input": "6 7\r\nRRRGGGG\r\nRRRGGGG\r\nRRRGGGG\r\nRRRBBBB\r\nRRRBBBB\r\nRRRBBBB\r\n", "output": "NO\r\n"}, {"input": "4 4\r\nRRRR\r\nRRRR\r\nBBBB\r\nG...
false
stdio
null
true
99/B
99
B
PyPy 3
TESTS
136
139
1,433,600
110947011
n = int(input()) d = {} for i in range(n): s = int(input()) if s in d: d[s] += [i + 1] else: d[s] = [i + 1] if len(d) == 1: print("Exemplary pages.") exit() mx = max(d) mn = min(d) if len(d) > 3 or len(d[mx]) != 1 or len(d[mn]) != 1: print("Unrecoverable configuration.") ...
200
46
0
136745255
n=int(input()) a=[0]*n for i in range(n): a[i]=int(input()) avg=sum(a) if avg%n!=0: print('Unrecoverable configuration.') exit(0) avg=avg//n x=[] for i in range(n): if a[i]!=avg: x.append(i) if len(x)==0: print('Exemplary pages.') elif len(x)==2: if (a[x[0]]+a[x[1]])//2==avg: ...
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
0.5
256
Help Chef Gerasim
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup...
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the...
null
null
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
1,300
["implementation", "sortings"]
200
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\...
false
stdio
null
true
99/B
99
B
Python 3
TESTS
136
77
512,000
111230120
from operator import itemgetter import functools as ft if __name__ == '__main__': n = int(input()) s = lambda v, a, b: "%s ml. from cup #%s to cup #%s." % (v, a, b) a, d, ans = list(), dict(), ["Exemplary pages.", "Unrecoverable configuration."] for i in range(n): k = int(input()) a.ap...
200
46
0
144160247
n = int(input()) a = [] for i in range(n): a.append(int(input())) if(sum(a)%n != 0): print("Unrecoverable configuration.") else: k = sum(a)//n res = [] flag = 0 for i in range(n): if(a[i] != k): flag = 1 res.append([a[i],i]) if(flag == 0): print("Exemplary pages.") else: if(len(res) == 2): res....
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
0.5
256
Help Chef Gerasim
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup...
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the...
null
null
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
1,300
["implementation", "sortings"]
200
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\...
false
stdio
null
true
807/A
807
A
Python 3
TESTS
34
62
307,200
106524131
n=int(input()) a=[0]*n flag=-1 for i in range(n): if flag==1:continue p, q=[int(y) for y in input().split()] a[i]=p-q if i==0: temp1 = p temp2 = a[i] else: if temp2!=a[i]: flag=1 elif temp1<p: flag=0 else: temp1=p if flag==...
150
46
0
145145439
n=int(input()) a,b=0,0 counter=0 List=[] for i in range(n): a,b=map(int,input().split()) if a!=b: counter+=1 List.append([a,b]) if counter!=0: List.clear() print("rated") else : check=False for i in range(1,len(List)): if List[i][0]>List[i-1][0]: print("unrated...
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
CF
2,017
2
256
Is it rated?
Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before ...
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of th...
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
null
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated. In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, som...
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
900
["implementation", "sortings"]
150
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\...
false
stdio
null
true
792/C
792
C
Python 3
TESTS
32
202
1,740,800
89772717
# i dont understand this either def countremove(n, mod): res = 0 for i in range(len(n)): if mod[len(n)-1-i] == 3: continue if n[i] == '0': res += 1 else: break return res n = input() mod = [int(x)%3 for x in n][::-1] excess = sum(mod) % 3 ones = mod.count(1) twos = mod.count(2) if excess == 1: remo...
162
124
6,860,800
105961030
import sys n = list(input("")) l = [int(c)%3 for c in n][::-1] d = sum(l)%3 if (len(n) == 1): if (n == ['3']): print(3) else: print(-1) sys.exit(0) def li(x): global n del n[len(n)-1-l.index(x)] del l[l.index(x)] def cond(x): x = x.lstrip('0') if (len(x) == 0): return "0" return x if (d == 0): pass e...
Educational Codeforces Round 18
ICPC
2,017
1
256
Divide by Three
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible. The number is called beautiful if it consists of at least one digit, doesn't have leading zer...
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
null
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
2,000
["dp", "greedy", "math", "number theory"]
162
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": ...
false
stdio
import sys def is_subsequence(s, t): t_iter = iter(t) try: for c in s: while next(t_iter) != c: pass return True except StopIteration: return False def is_beautiful(s): if not s: return False if s[0] == '0' and len(s) > 1: return ...
true
99/B
99
B
PyPy 3
TESTS
8
77
307,200
149628016
from collections import defaultdict import sys, os, io input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline n = int(input()) x = [int(input()) for _ in range(n)] cnt = defaultdict(lambda : 0) for i in x: cnt[i] += 1 c = list(cnt.keys()) c.sort() if len(c) == 1: ans = "Exemplary pages." elif len(c) == 3...
200
77
307,200
106310001
n=int(input()) ar=[int(input()) for i in range(n)] if(len(set(ar))==1): print("Exemplary pages.") quit() mn=min(ar) mx=max(ar) mni=ar.index(mn) mxi=ar.index(mx) vl=(mx-mn)//2 ar[mni]+=vl ar[mxi]-=vl if(len(set(ar))==1): print(str(vl)+" ml. from cup #"+str(mni+1)+" to cup #"+str(mxi+1)+".") quit() else: ...
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
0.5
256
Help Chef Gerasim
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup...
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the...
null
null
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
1,300
["implementation", "sortings"]
200
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\...
false
stdio
null
true
99/B
99
B
Python 3
TESTS
8
46
0
146841297
l=[] n=int(input()) for z in range(n): l.append(int(input())) ma,mi=max(l),min(l) um=-1 for i in range(min(n,3)): if l.count(l[i])==n-2 and l[i] not in (ma,mi): um=l[i] break if l.count(l[0])==n: print("Exemplary pages.") elif um>-1 and (ma-mi)%2==0: print((ma-mi)//2,"ml. from cup #"+str...
200
92
6,963,200
128839381
def help_chef(): count = int(input()) volumes = [] total = 0 for _ in range(count): volume = int(input()) volumes.append(volume) total += volume if total % count != 0: print("Unrecoverable configuration.") elif len(set(volumes)) == 1: print("Exemplary pages.") else: diffs = [] vol = None sourc...
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
0.5
256
Help Chef Gerasim
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup...
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the...
null
null
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
1,300
["implementation", "sortings"]
200
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\...
false
stdio
null
true
99/B
99
B
Python 3
TESTS
8
46
0
151407236
n=int(input()) s=[] for i in range(n): s.append(int(input())) x=list(set(s)) if len(x)==1: print("Exemplary pages.") elif len(x)==3: x.sort() if s.count(x[0])==1 and s.count(x[2])==1 and (x[0]+x[2])/2==sum(s)/len(s): print(f"{x[1]-x[0]} ml. from cup #{s.index(min(x))+1} to cup #{s.index(max(x))+1}.") else: pri...
200
109
307,200
93070393
n=int(input()) l=[] for i in range(n): l.append(int(input())) a=set(l) if(len(a)==1): print("Exemplary pages.") else: m=min(l) n=max(l) r=(n-m)//2 q=l.index(n) w=l.index(m) l[q]-=r l[w]+=r b=set(l) if(len(b)==1): print(str(r)+" ml. from cup #"+str(w+1)+" to cup #"+str...
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
0.5
256
Help Chef Gerasim
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup...
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the...
null
null
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
1,300
["implementation", "sortings"]
200
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\...
false
stdio
null
true
99/B
99
B
Python 3
TESTS
8
31
0
151408789
n = int(input()) list = [0 for j in range(n)] list2 = [0 for J in range(n)] list3 = [0 for K in range(4)] for i in range(n): list[i] = int(input()) list1 = sorted(list) result = 0 x = S = 0 num = int(list1[n // 2]) for j in range(n): if int(list[j]) != num: result += 1 list2[j] = num - int(list[...
200
109
1,433,600
106359561
n=int(input()) s=[] for i in range(n): s.append(int(input())) x=list(set(s)) x.sort() if len(x)==1: print('Exemplary pages.') elif len(s)==2 and sum(x)%2==0: print('{} ml. from cup #{} to cup #{}.'.format((x[1]-x[0])//2,s.index(x[0])+1,s.index(x[1])+1)) elif len(x)==3 and s.count(x[0])==1 and s.count(x[2])==1 and...
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
0.5
256
Help Chef Gerasim
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup...
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the...
null
null
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
1,300
["implementation", "sortings"]
200
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\...
false
stdio
null
true
807/A
807
A
Python 3
TESTS
35
46
0
173044894
l1=[] l2=[] for _ in range(int(input())): a,b=map(int,input().split()) l1.append(a) l2.append(b) cnt=0 c=0 c2=0 for i in range(len(l1)-1): if l1[i]!=l2[i]: cnt+=1 elif l1[i]<l1[i+1]: c+=1 else: c2+=1 if cnt!=0: print('rated') elif c!=0: print('unrated') else: print('maybe')
150
46
0
145487418
n = int(input()) p = {1:"rated", 2:"unrated", 3:"maybe"} d = [] t = 2 noninc = True for i in range(n): a,b = map(int, input().split()) if a == b and t != 1: if len(d) > 0 and noninc: if d[-1] >= a: t = 3 else: noninc = False t = 2 ...
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
CF
2,017
2
256
Is it rated?
Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before ...
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of th...
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
null
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated. In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, som...
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
900
["implementation", "sortings"]
150
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\...
false
stdio
null
true
807/A
807
A
Python 3
TESTS
35
61
0
173533502
a=int(input()) arr=[] for i in range(a): sub=list(map(int,input().split())) arr.append(sub) c=0 j=0 for i in range(a-1): if arr[i][0]>arr[i][1] or arr[i][0]<arr[i][1]: c=c+1 if arr[i][0]<arr[i+1][0]: j=j+1 if c>0: print('rated') elif j>0: print('unrated') else: print('ma...
150
46
0
145885952
n = int(input()) f,l=0,[] for i in range(n): h,k = map(int,input().split()) l.append(h) if h!=k: f=1 l1 = list(l) l.sort(reverse=True) if f==0 : print(['unrated','maybe'][l1==l]) else: print("rated")
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
CF
2,017
2
256
Is it rated?
Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before ...
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of th...
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
null
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated. In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, som...
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
900
["implementation", "sortings"]
150
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\...
false
stdio
null
true
792/C
792
C
Python 3
TESTS
27
93
7,372,800
26228548
s = list(input()) def db3(n,sm): new = n.copy() sm %= 3 if sm==0: return ''.join(new) else: if sm==2: for j in range(1,len(new)): if int(new[j])%3==2: new[j] = '' return ''.join(new) for j in range(1,len(new)): if int(new[j])%3==1: new[j]='' sm-=1 if sm==0: return ''.join(n...
162
140
5,529,600
25861795
s = input() def rm(s,m): if s == None or len(s) == 1: return None i = len(s) - 1 while i >= 0: if int(s[i]) % 3 == m: break i -= 1 if i == -1: return None else: if i == 0: k = i+1 while k < len(s) and s[k] == "0": ...
Educational Codeforces Round 18
ICPC
2,017
1
256
Divide by Three
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible. The number is called beautiful if it consists of at least one digit, doesn't have leading zer...
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
null
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
2,000
["dp", "greedy", "math", "number theory"]
162
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": ...
false
stdio
import sys def is_subsequence(s, t): t_iter = iter(t) try: for c in s: while next(t_iter) != c: pass return True except StopIteration: return False def is_beautiful(s): if not s: return False if s[0] == '0' and len(s) > 1: return ...
true
807/A
807
A
Python 3
TESTS
35
109
6,963,200
84974838
n = int(input()) ls = [] res = '' for i in range(n): ls.append(list(map(int,input().split()))) for i in range(n-1): if ls[i][0]!=ls[i][1]: res = "rated" break if res != 'rated': for i in range(n-1): if ls[i][1]<ls[i+1][1]: res = "unrated" break else: res = "maybe" print(res)
150
46
0
146642324
n = int(input()) f_r = 0 f_u = 0 before_list = [] after_list = [] for i in range(n): before, after = map(int, input().split()) if before != after: f_r = 1 elif len(before_list) and before > before_list[-1]: f_u = 1 before_list.append(before) after_list.append(after) if f_r: prin...
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
CF
2,017
2
256
Is it rated?
Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before ...
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of th...
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
null
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated. In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, som...
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
900
["implementation", "sortings"]
150
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\...
false
stdio
null
true
807/A
807
A
Python 3
TESTS
35
109
6,963,200
86453139
a=int(input()) n1=[] m1=[] for i in range(a): n,m=map(int, input().split()) n1.append(n) m1.append(m) ans=0 cnt=1 i=0 while i<(a-1): if n1[i]!=m1[i]: ans=1 print("rated") break elif n1[i]>=n1[i+1]: cnt+=1 i=i+1 if cnt!=a and ans==0: print('unrated') elif cnt==...
150
46
0
146977522
n =int(input()) l=[] res='maybe' for x in range(n): b,a=map(int,input().split()) l.append([b,a]) if a!=b: res='rated' if res!='rated' : c=0 while c<len(l)-1 : if l[c][0]<l[c+1][0] : res='unrated' break c+=1 print(res)
Codeforces Round 412 (rated, Div. 2, base on VK Cup 2017 Round 3)
CF
2,017
2
256
Is it rated?
Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it. Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before ...
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of th...
If the round is rated for sure, print "rated". If the round is unrated for sure, print "unrated". If it's impossible to determine whether the round is rated or not, print "maybe".
null
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated. In the second example, no one's rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, som...
[{"input": "6\n3060 3060\n2194 2194\n2876 2903\n2624 2624\n3007 2991\n2884 2884", "output": "rated"}, {"input": "4\n1500 1500\n1300 1300\n1200 1200\n1400 1400", "output": "unrated"}, {"input": "5\n3123 3123\n2777 2777\n2246 2246\n2246 2246\n1699 1699", "output": "maybe"}]
900
["implementation", "sortings"]
150
[{"input": "6\r\n3060 3060\r\n2194 2194\r\n2876 2903\r\n2624 2624\r\n3007 2991\r\n2884 2884\r\n", "output": "rated\r\n"}, {"input": "4\r\n1500 1500\r\n1300 1300\r\n1200 1200\r\n1400 1400\r\n", "output": "unrated\r\n"}, {"input": "5\r\n3123 3123\r\n2777 2777\r\n2246 2246\r\n2246 2246\r\n1699 1699\r\n", "output": "maybe\...
false
stdio
null
true
99/B
99
B
PyPy 3-64
TESTS
62
62
0
228951081
n = int(input()) volumes = [int(input()) for _ in range(n)] total_volume = sum(volumes) if total_volume % n == 0: target_volume = total_volume // n pour_from = None pour_to = None for i, volume in enumerate(volumes): diff = target_volume - volume if diff > 0: if pour_from i...
200
124
307,200
73945356
n = int(input()) a = [] sum = 0 for i in range(n): x = int(input()) sum += x a.append(x) ave = sum / n if int(ave) == ave: ave = int(ave) b = set() cnt = 0 for i in range(n): if abs(ave - a[i])!=0: b.add(abs(ave - a[i])) t = ave - a[i] if t > 0: ...
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
0.5
256
Help Chef Gerasim
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup...
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the...
null
null
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
1,300
["implementation", "sortings"]
200
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\...
false
stdio
null
true
858/E
858
E
PyPy 3
TESTS
0
61
0
155070236
import sys input = sys.stdin.buffer.readline def process(A): """ 6 options: 1. test is already type 1 and from 1 <= x <= m1 no moves needed. 2. test is type 1 and from m1+1 <= x <= m1+m2 move needed but NOTE 3. test is type 1 and neither. move needed. 4. t...
165
295
27,136,000
230751905
n = int(input()) t = [1] + [0] * n b, a = d = [], [] h, s = [], [] for i in range(n): f, k = input().split() d[int(k)].append(f) m = len(a) for i in a: if i.isdigit() and i[0] != '0': j = int(i) if 0 < j <= m: t[j] = 1 elif m < j <= n: t[j] = -1 else...
Технокубок 2018 - Отборочный Раунд 1
CF
2,017
2
256
Tests Renumeration
The All-Berland National Olympiad in Informatics has just ended! Now Vladimir wants to upload the contest from the Olympiad as a gym to a popular Codehorses website. Unfortunately, the archive with Olympiad's data is a mess. For example, the files with tests are named arbitrary without any logic. Vladimir wants to re...
The first line contains single integer n (1 ≤ n ≤ 105) — the number of files with tests. n lines follow, each describing a file with test. Each line has a form of "name_i type_i", where "name_i" is the filename, and "type_i" equals "1", if the i-th file contains an example test, and "0" if it contains a regular test. ...
In the first line print the minimum number of lines in Vladimir's script file. After that print the script file, each line should be "move file_1 file_2", where "file_1" is an existing at the moment of this line being run filename, and "file_2" — is a string of digits and small English letters with length from 1 to 6.
null
null
[{"input": "5\n01 0\n2 1\n2extra 0\n3 1\n99 0", "output": "4\nmove 3 1\nmove 01 5\nmove 2extra 4\nmove 99 3"}, {"input": "2\n1 0\n2 1", "output": "3\nmove 1 3\nmove 2 1\nmove 3 2"}, {"input": "5\n1 0\n11 1\n111 0\n1111 1\n11111 0", "output": "5\nmove 1 5\nmove 11 1\nmove 1111 2\nmove 111 4\nmove 11111 3"}]
2,200
["greedy", "implementation"]
165
[{"input": "5\r\n01 0\r\n2 1\r\n2extra 0\r\n3 1\r\n99 0\r\n", "output": "4\r\nmove 3 1\r\nmove 01 5\r\nmove 2extra 4\r\nmove 99 3\r\n"}, {"input": "2\r\n1 0\r\n2 1\r\n", "output": "3\r\nmove 1 dytuig\r\nmove 2 1\r\nmove dytuig 2\r\n"}, {"input": "5\r\n1 0\r\n11 1\r\n111 0\r\n1111 1\r\n11111 0\r\n", "output": "5\r\nmove...
false
stdio
import sys def main(): input_path = sys.argv[1] output_path = sys.argv[2] submission_path = sys.argv[3] with open(input_path) as f: n = int(f.readline()) files = [] type1_count = 0 for _ in range(n): line = f.readline().strip() name, typ = line.s...
true
792/C
792
C
Python 3
TESTS
28
93
5,734,400
25896525
def sumstr(s): sums = 0 for i in range(len(s)): sums += int(s[i]) return sums def mod3(s): sums = sumstr(s) return sums % 3 def onlyzeros(s): i = 0 while i < len(s): if s[i] != '0': return False i += 1 return True def lastin(s, s1): maxf = -1 #d = '-' for d in s1: f = s.find(d) if f > maxf: ...
162
140
28,262,400
32921730
def f(t): i, n = 0, len(t) - 1 while i < n and t[i] == '0': i += 1 return t[i:] t = input() n = len(t) - 1 p = [int(q) % 3 for q in t][::-1] s = sum(p) % 3 if s == 0: print(t) exit() u = v = '' if s in p: i = n - p.index(s) u = f(t[:i] + t[i + 1:]) s = 3 - s if p.count(s) > 1: i = n - p....
Educational Codeforces Round 18
ICPC
2,017
1
256
Divide by Three
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible. The number is called beautiful if it consists of at least one digit, doesn't have leading zer...
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
null
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
2,000
["dp", "greedy", "math", "number theory"]
162
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": ...
false
stdio
import sys def is_subsequence(s, t): t_iter = iter(t) try: for c in s: while next(t_iter) != c: pass return True except StopIteration: return False def is_beautiful(s): if not s: return False if s[0] == '0' and len(s) > 1: return ...
true
750/B
750
B
PyPy 3-64
TESTS
28
62
0
197427400
n = int(input()) dis=[] direc = [] for j in range(n): a,s = map(str,input().split()) dis.append(int(a)) direc.append(s) if(direc[0]!='South'): print('NO') else: lenght=0 flag=0 for k in range(n): if(lenght<=20000): if(direc[k]=='South'): lenght =...
140
46
0
213825326
n = int(input()) k1 = 0 k2 = 0 for i in range(n): s = input().split() a = int(s[0]) b = s[1] if k1 == 0 and b != 'South': k2 = 1 if k1 == 20000 and b != 'North': k2 = 1 if b =='South': k1 += a if b == 'North': k1 -= a if k1 > 20000 or k1 < 0: k2 = ...
Good Bye 2016
CF
2,016
2
256
New Year and North Pole
In this problem we assume the Earth to be a completely round ball and its surface a perfect sphere. The length of the equator and any meridian is considered to be exactly 40 000 kilometers. Thus, travelling from North Pole to South Pole or vice versa takes exactly 20 000 kilometers. Limak, a polar bear, lives on the N...
The first line of the input contains a single integer n (1 ≤ n ≤ 50). The i-th of next n lines contains an integer ti and a string diri (1 ≤ ti ≤ 106, $${ dir } _ { i } \in \{ \mathrm { N o r t h, ~ S o u t h, ~ W e s t, ~ E a s t } \}$$) — the length and the direction of the i-th part of the journey, according to the...
Print "YES" if the description satisfies the three conditions, otherwise print "NO", both without the quotes.
null
Drawings below show how Limak's journey would look like in first two samples. In the second sample the answer is "NO" because he doesn't end on the North Pole.
[{"input": "5\n7500 South\n10000 East\n3500 North\n4444 West\n4000 North", "output": "YES"}, {"input": "2\n15000 South\n4000 East", "output": "NO"}, {"input": "5\n20000 South\n1000 North\n1000000 West\n9000 North\n10000 North", "output": "YES"}, {"input": "3\n20000 South\n10 East\n20000 North", "output": "NO"}, {"input...
1,300
["geometry", "implementation"]
140
[{"input": "5\r\n7500 South\r\n10000 East\r\n3500 North\r\n4444 West\r\n4000 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n15000 South\r\n4000 East\r\n", "output": "NO\r\n"}, {"input": "5\r\n20000 South\r\n1000 North\r\n1000000 West\r\n9000 North\r\n10000 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n20000 Sout...
false
stdio
null
true
99/B
99
B
PyPy 3
TESTS
50
140
0
60445506
__author__ = 'Esfandiar' n = int(input()) a = list() for i in range(n): a.append([int(input()),i+1]) a.sort() j = a[0][0] f = 1 s = j for i in range(1,n): if a[i][0] != j: f = 0 s+=a[i][0] if f == 1: print('Exemplary pages.') exit() yy = s/n if int(yy) != yy: print('Unrecoverable config...
200
124
307,200
82599994
n=int(input()) x=[] for i in range(n): x.append(int(input())) y=sorted(x) z=sorted(x,reverse=True) if y==z:print('Exemplary pages.') else: z=y.copy();t=[] while(y[n-1]>0): y[0]+=1;y[n-1]-=1 if y[0]==y[n-1]:break y.sort();t=sorted(y,reverse=True) if y==t:print('%d ml. from cup #%d to ...
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
0.5
256
Help Chef Gerasim
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup...
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the...
null
null
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
1,300
["implementation", "sortings"]
200
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\...
false
stdio
null
true
792/C
792
C
Python 3
TESTS
28
139
11,673,600
25889964
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 def LI(): return [int(x) 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().spl...
162
171
6,041,600
57314819
def find(s): if len(s)==1: if int(s)%3==0: return s return -1 digit=[[] for i in range(3)] zeros=[] for i in range(len(s)): digit[int(s[i])%3]+=[i] if s[i]=="0": zeros+=[i] total=(len(digit[1])*1+len(digit[2])*2)%3 if total==0: ...
Educational Codeforces Round 18
ICPC
2,017
1
256
Divide by Three
A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible. The number is called beautiful if it consists of at least one digit, doesn't have leading zer...
The first line of input contains n — a positive integer number without leading zeroes (1 ≤ n < 10100000).
Print one number — any beautiful number obtained by erasing as few as possible digits. If there is no answer, print - 1.
null
In the first example it is enough to erase only the first digit to obtain a multiple of 3. But if we erase the first digit, then we obtain a number with a leading zero. So the minimum number of digits to be erased is two.
[{"input": "1033", "output": "33"}, {"input": "10", "output": "0"}, {"input": "11", "output": "-1"}]
2,000
["dp", "greedy", "math", "number theory"]
162
[{"input": "1033\r\n", "output": "33\r\n"}, {"input": "10\r\n", "output": "0\r\n"}, {"input": "11\r\n", "output": "-1\r\n"}, {"input": "3\r\n", "output": "3\r\n"}, {"input": "1\r\n", "output": "-1\r\n"}, {"input": "117\r\n", "output": "117\r\n"}, {"input": "518\r\n", "output": "18\r\n"}, {"input": "327\r\n", "output": ...
false
stdio
import sys def is_subsequence(s, t): t_iter = iter(t) try: for c in s: while next(t_iter) != c: pass return True except StopIteration: return False def is_beautiful(s): if not s: return False if s[0] == '0' and len(s) > 1: return ...
true
99/B
99
B
Python 3
TESTS
8
31
0
167498988
n = int(input()) s = list() s1 = set() for _ in range(n): enter = int(input()) s.append(enter) s1.add(enter) if len(s1) == 1: print("Exemplary pages.") elif len(s1) == 3: s1 = list(s1) for i in range(3): if s.count(s1[i]) > 1: x = s1[(i + 1) % 3] y = s1[(i - 1) % ...
200
124
307,200
90197114
n=int(input()) a=[] for i in range(1,n+1): a.append(int(input())) mina,maxa=min(a),max(a) minai,maxai=a.index(mina),a.index(maxa) if (maxa-mina)%2!=0: print("Unrecoverable configuration.") elif mina==maxa: print("Exemplary pages.") else: mid=(maxa-mina)//2 a[maxai]-=mid a[minai]+=mid if len(set(...
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
0.5
256
Help Chef Gerasim
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup...
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the...
null
null
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
1,300
["implementation", "sortings"]
200
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\...
false
stdio
null
true
818/E
818
E
PyPy 3
TESTS
13
93
1,843,200
106262915
n,k=map(int,input().split()) l=list(map(int,input().split())) ans=0 last=0 now=1 for i in range(len(l)): now=now*l[i] while now%k==0 and last<=i: ans+=n-i now/=l[last] last+=1 print(ans)
135
77
13,414,400
170114604
R,G=lambda:map(int,input().split()),range n,k=R();a=[0]+[*R()];z,l,p=0,1,1 for r in G(1,n+1): p=p*a[r]%k if p==0: p=1;i=r while p*a[i]%k:p=p*a[i]%k;i-=1 z+=(n-r+1)*(i-l+1);l=i+1 print(z)
Educational Codeforces Round 24
ICPC
2,017
2
256
Card Game Again
Vova again tries to play some computer card game. The rules of deck creation in this game are simple. Vova is given an existing deck of n cards and a magic number k. The order of the cards in the deck is fixed. Each card has a number written on it; number ai is written on the i-th card in the deck. After receiving th...
The first line contains two integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 109). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the numbers written on the cards.
Print the number of ways to choose x and y so the resulting deck is valid.
null
In the first example the possible values of x and y are: 1. x = 0, y = 0; 2. x = 1, y = 0; 3. x = 2, y = 0; 4. x = 0, y = 1.
[{"input": "3 4\n6 2 8", "output": "4"}, {"input": "3 6\n9 1 14", "output": "1"}]
1,900
["binary search", "data structures", "number theory", "two pointers"]
135
[{"input": "3 4\r\n6 2 8\r\n", "output": "4\r\n"}, {"input": "3 6\r\n9 1 14\r\n", "output": "1\r\n"}, {"input": "5 1\r\n1 3 1 3 1\r\n", "output": "15\r\n"}, {"input": "5 1\r\n5 5 5 5 5\r\n", "output": "15\r\n"}, {"input": "5 1\r\n5 4 4 4 4\r\n", "output": "15\r\n"}, {"input": "100 1\r\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
false
stdio
null
true
99/B
99
B
PyPy 3-64
TESTS
39
77
614,400
149230725
import math,sys;input=sys.stdin.readline;S=lambda:input().rstrip();I=lambda:int(S());M=lambda:map(int,S().split());L=lambda:list(M());mod1=1000000007;mod2=998244353 from collections import defaultdict arr = [] sm = 0 n = I() for _ in range(n): t = I() sm+=t arr.append(t) each = sm//n over_under = [0]*(n) ...
200
124
307,200
103664743
n = int(input()) a = [] sum = 0 for i in range(n): a.append(int(input())) sum+=a[i] c = sum//n fro = 0 to = 0 cou = 0 for i in range(n): if c<a[i]: to = i+1 cou+=1 elif c>a[i]: fro = i+1 cou+=1 amt = (a[to-1]-a[fro-1])//2 a[to-1]-=amt a[fro-1]+=amt if fro == to: print...
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
0.5
256
Help Chef Gerasim
In a far away kingdom young pages help to set the table for the King. As they are terribly mischievous, one needs to keep an eye on the control whether they have set everything correctly. This time the royal chef Gerasim had the impression that the pages have played a prank again: they had poured the juice from one cup...
The first line contains integer n — the number of cups on the royal table (1 ≤ n ≤ 1000). Next n lines contain volumes of juice in each cup — non-negative integers, not exceeding 104.
If the pages didn't pour the juice, print "Exemplary pages." (without the quotes). If you can determine the volume of juice poured during exactly one juice pouring, print "v ml. from cup #a to cup #b." (without the quotes), where v represents the volume of poured juice, a represents the number of the cup from which the...
null
null
[{"input": "5\n270\n250\n250\n230\n250", "output": "20 ml. from cup #4 to cup #1."}, {"input": "5\n250\n250\n250\n250\n250", "output": "Exemplary pages."}, {"input": "5\n270\n250\n249\n230\n250", "output": "Unrecoverable configuration."}]
1,300
["implementation", "sortings"]
200
[{"input": "5\r\n270\r\n250\r\n250\r\n230\r\n250\r\n", "output": "20 ml. from cup #4 to cup #1.\r\n"}, {"input": "5\r\n250\r\n250\r\n250\r\n250\r\n250\r\n", "output": "Exemplary pages.\r\n"}, {"input": "5\r\n270\r\n250\r\n249\r\n230\r\n250\r\n", "output": "Unrecoverable configuration.\r\n"}, {"input": "4\r\n200\r\n190\...
false
stdio
null
true
99/A
99
A
Python 3
TESTS
134
154
6,963,200
124043707
n = input() num = n.split(".") the_num = int(num[0]) dec_part = int(num[1]) p = (len(num[1])) the_dec_part = int(num[1])/pow(10, p) if(the_num%10 == 9): print('GOTO Vasilisa.') elif(the_num%10 != 9 and the_dec_part<0.5): print(the_num) elif(the_num%10 != 9 and the_dec_part>=0.5): print(the_num+1)
150
92
0
4701450
t = input() k = t.find('.') if k < 0: print(int(t)) elif t[k - 1] == '9': print('GOTO Vasilisa.') else: print(int(t[:k]) + int(t[k + 1] > '4'))
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
2
256
Help Far Away Kingdom
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki...
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empt...
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
null
null
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output...
800
["strings"]
150
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "12345678...
false
stdio
null
true
99/A
99
A
Python 3
TESTS
134
124
0
116240399
def f(s): i=s.index(".") if s[i-1]=="9": return "GOTO Vasilisa." if float(s[i:])<0.5: return s[:i] else: return int(s[:i])+1 s=input() print(f(s))
150
92
0
136128059
a = input() for i in range(len(a)): if a[i] == "." and a[i-1] == "9": print("GOTO Vasilisa.") break if a[i] == "." and a[i+1] >= "5": print(int(a[:i])+1) break if a[i] == "." and a[i+1] <= "5": print(a[:i]) break
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
2
256
Help Far Away Kingdom
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki...
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empt...
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
null
null
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output...
800
["strings"]
150
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "12345678...
false
stdio
null
true
99/A
99
A
PyPy 3-64
TESTS
134
124
0
195444322
s = input() pos = s.find('.') i = int(s[0:pos]) dec = float(s[pos::]) if(i%10 != 9) and(dec<0.5): print(i) elif(i%10 != 9) and(dec>=0.5): print(i+1) else: print("GOTO Vasilisa.")
150
92
0
139120426
m,n= input().split(".") if m[-1]=="9": print("GOTO Vasilisa.") else: l=n[0]>"4" print(int(m)+l)
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
2
256
Help Far Away Kingdom
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki...
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empt...
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
null
null
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output...
800
["strings"]
150
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "12345678...
false
stdio
null
true
99/A
99
A
Python 3
TESTS
134
122
0
186991953
n = input() if '.' not in n: print(n) exit() else: m = n.split('.') if m[0][-1] == "9": print("GOTO Vasilisa.") exit() elif float("0." + m[1]) < 0.5: print(int(m[0])) elif float("0." + m[1]) >= 0.5: print(int(m[0]) + 1)
150
92
0
142060203
i, j=map(str,input().split(".")) print(["GOTO Vasilisa.", int(i)+(j[0]>'4')][i[-1]<'9']) # Sun Jan 09 2022 08:29:38 GMT+0000 (Coordinated Universal Time)
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
2
256
Help Far Away Kingdom
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki...
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empt...
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
null
null
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output...
800
["strings"]
150
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "12345678...
false
stdio
null
true
99/A
99
A
Python 3
TESTS
134
92
307,200
4816627
number = input() int_part = '' i=0 while number[i] != '.': int_part += number[i] i=i+1 fraction_part = number[i:] if int_part[-1] != '9' and float(fraction_part) < 0.5: round_no = int_part elif int_part[-1] != '9' and float(fraction_part) >= 0.5: round_no = int_part[0:-1] + str(int(int_part[-1])+1) el...
150
92
0
144267071
s = input() if s[s.index(".")-1] == '9': print("GOTO Vasilisa.") else: if int(s[s.index(".")+1]) < 5: print(s[:s.index(".")]) else: print(int(s[:s.index(".")])+1)
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
2
256
Help Far Away Kingdom
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki...
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empt...
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
null
null
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output...
800
["strings"]
150
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "12345678...
false
stdio
null
true
99/A
99
A
Python 3
TESTS
134
92
0
225653365
x, y = map(str, input(). split(".")) if x[-1] == "9" or x == "9": print("GOTO Vasilisa.") elif float("0." + y) < 0.5: print(int(x)) else: print(int(x)+1)
150
92
0
145548415
s = input() nuqta = s.index(".") butun_qism = int(s[0:nuqta]) kasr_qism = int(s[nuqta+1:]) if(butun_qism%10 == 9): print("GOTO Vasilisa.") else: if(int(s[nuqta+1]) >= 5): print(butun_qism+1) else: print(butun_qism)
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
2
256
Help Far Away Kingdom
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki...
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empt...
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
null
null
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output...
800
["strings"]
150
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "12345678...
false
stdio
null
true
99/A
99
A
Python 3
TESTS
134
92
0
165454011
i, d = tuple(input().split(".")) if i[-1] == "9": print("GOTO Vasilisa.") elif float(f"0.{d}") < 0.5: print(int(i)) elif float(f"0.{d}") >= 0.5: print(int(i) + 1)
150
92
0
146844916
a = input() if int(a[a.index(".")-1]) == 9: print("GOTO Vasilisa.") elif int(a[a.index(".")+1]) < 5: print(int(a[:a.index(".")])) else: print(int(a[:a.index(".")])+1)
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
2
256
Help Far Away Kingdom
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki...
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empt...
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
null
null
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output...
800
["strings"]
150
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "12345678...
false
stdio
null
true
99/A
99
A
Python 3
TESTS
134
92
0
169353780
n=input() if "." not in n: print(int(n)) else: p=n.index(".") if n[p-1]=="9": print("GOTO Vasilisa.") else: s=n[:p] x="0."+n[p+1:] if float(x)>=0.5: print(int(s)+1) else: print(int(s))
150
92
0
149005367
s=list(input());r=s.index('.') if s[r-1]=='9':print('GOTO Vasilisa.') else: if s[r+1]>='5':s[r-1]=str(int(s[r-1])+1) print(''.join(s[:r]))
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
2
256
Help Far Away Kingdom
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki...
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empt...
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
null
null
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output...
800
["strings"]
150
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "12345678...
false
stdio
null
true
99/A
99
A
PyPy 3
TESTS
134
218
0
114531778
number = input() integer, decimal = number.split('.') if int(integer) % 10 == 9: print('GOTO Vasilisa.') else: decimal = '0.' + decimal if float(decimal) >= 0.5: print(int(integer) + 1) else: print(int(integer))
150
92
0
160042145
number = input().split('.') if int(number[1][0]) >= 5 and int(number[0][-1]) < 9: print(int(number[0]) + 1) elif int(number[1][0]) < 5 and int(number[0][-1]) < 9: print(int(number[0])) else: print('GOTO Vasilisa.')
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
2
256
Help Far Away Kingdom
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki...
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empt...
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
null
null
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output...
800
["strings"]
150
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "12345678...
false
stdio
null
true
99/A
99
A
Python 3
TESTS
134
92
0
170905104
s=input() k=s.split('.') p=k[0] p=p[::-1] if p[0]=='9': print('GOTO Vasilisa.') else: q='0.'+k[1] if float(q)<0.5: print(int(k[0])) else: print(int(k[0])+1)
150
92
0
165274022
n=input() n=n.split('.') if n[0][-1]=='9': print("GOTO Vasilisa.") elif n[1][0]<'5': print(n[0]) else: print(int(n[0])+1)
Codeforces Beta Round 78 (Div. 2 Only)
CF
2,011
2
256
Help Far Away Kingdom
In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there. Most damage those strange creatures inflicted upon the kingdom was that they loved high precision numbers. As a result, the Ki...
The first line contains a single number to round up — the integer part (a non-empty set of decimal digits that do not start with 0 — with the exception of a case when the set consists of a single digit — in this case 0 can go first), then follows character «.» (a dot), and then follows the fractional part (any non-empt...
If the last number of the integer part is not equal to 9, print the rounded-up number without leading zeroes. Otherwise, print the message "GOTO Vasilisa." (without the quotes).
null
null
[{"input": "0.0", "output": "0"}, {"input": "1.49", "output": "1"}, {"input": "1.50", "output": "2"}, {"input": "2.71828182845904523536", "output": "3"}, {"input": "3.14159265358979323846", "output": "3"}, {"input": "12345678901234567890.1", "output": "12345678901234567890"}, {"input": "123456789123456789.999", "output...
800
["strings"]
150
[{"input": "0.0\r\n", "output": "0"}, {"input": "1.49\r\n", "output": "1"}, {"input": "1.50\r\n", "output": "2"}, {"input": "2.71828182845904523536\r\n", "output": "3"}, {"input": "3.14159265358979323846\r\n", "output": "3"}, {"input": "12345678901234567890.1\r\n", "output": "12345678901234567890"}, {"input": "12345678...
false
stdio
null
true
750/B
750
B
Python 3
TESTS
8
46
0
211954607
c=True x=20000 n= int(input()) for i in range(n): t,d=map(str,input().split()) if d != 'South' and i==0: c=False elif d != 'North' and i == (n-1): c=False else: if d == 'South' and x != 0: x-=int(t) elif x==20000 and d=='North': c=False eli...
140
62
0
232602852
ll=[] x=int(input()) n,s=20000,0 for _ in range(x): i,j=input().split() i=int(i) if (n==20000 or s==20000) and (j=="West"or j=="East"): print("NO") exit() elif (j=="South" and i+s>20000) or (j=="North" and i+n>20000): print("NO") exit() else: if j=="South": ...
Good Bye 2016
CF
2,016
2
256
New Year and North Pole
In this problem we assume the Earth to be a completely round ball and its surface a perfect sphere. The length of the equator and any meridian is considered to be exactly 40 000 kilometers. Thus, travelling from North Pole to South Pole or vice versa takes exactly 20 000 kilometers. Limak, a polar bear, lives on the N...
The first line of the input contains a single integer n (1 ≤ n ≤ 50). The i-th of next n lines contains an integer ti and a string diri (1 ≤ ti ≤ 106, $${ dir } _ { i } \in \{ \mathrm { N o r t h, ~ S o u t h, ~ W e s t, ~ E a s t } \}$$) — the length and the direction of the i-th part of the journey, according to the...
Print "YES" if the description satisfies the three conditions, otherwise print "NO", both without the quotes.
null
Drawings below show how Limak's journey would look like in first two samples. In the second sample the answer is "NO" because he doesn't end on the North Pole.
[{"input": "5\n7500 South\n10000 East\n3500 North\n4444 West\n4000 North", "output": "YES"}, {"input": "2\n15000 South\n4000 East", "output": "NO"}, {"input": "5\n20000 South\n1000 North\n1000000 West\n9000 North\n10000 North", "output": "YES"}, {"input": "3\n20000 South\n10 East\n20000 North", "output": "NO"}, {"input...
1,300
["geometry", "implementation"]
140
[{"input": "5\r\n7500 South\r\n10000 East\r\n3500 North\r\n4444 West\r\n4000 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n15000 South\r\n4000 East\r\n", "output": "NO\r\n"}, {"input": "5\r\n20000 South\r\n1000 North\r\n1000000 West\r\n9000 North\r\n10000 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n20000 Sout...
false
stdio
null
true
750/B
750
B
Python 3
TESTS
1
30
0
210218600
n = int(input()) journey_parts = [] for _ in range(n): ti, diri = input().split() journey_parts.append((int(ti), diri)) current_latitude = 0 for ti, diri in journey_parts: if diri == "North": current_latitude -= ti elif diri == "South": current_latitude += ti if current_latitude ...
140
62
4,608,000
23437510
import math n = int(input()) fi = 0 theta = 0 flag = True for n in range(n): row = [x for x in input().split()] dist = int(row[0]) napr = row[1] if (fi == 0 and napr != 'South') or fi < 0: flag = False break if (fi == 20000 and napr != 'North') or fi > 20000: flag = Fals...
Good Bye 2016
CF
2,016
2
256
New Year and North Pole
In this problem we assume the Earth to be a completely round ball and its surface a perfect sphere. The length of the equator and any meridian is considered to be exactly 40 000 kilometers. Thus, travelling from North Pole to South Pole or vice versa takes exactly 20 000 kilometers. Limak, a polar bear, lives on the N...
The first line of the input contains a single integer n (1 ≤ n ≤ 50). The i-th of next n lines contains an integer ti and a string diri (1 ≤ ti ≤ 106, $${ dir } _ { i } \in \{ \mathrm { N o r t h, ~ S o u t h, ~ W e s t, ~ E a s t } \}$$) — the length and the direction of the i-th part of the journey, according to the...
Print "YES" if the description satisfies the three conditions, otherwise print "NO", both without the quotes.
null
Drawings below show how Limak's journey would look like in first two samples. In the second sample the answer is "NO" because he doesn't end on the North Pole.
[{"input": "5\n7500 South\n10000 East\n3500 North\n4444 West\n4000 North", "output": "YES"}, {"input": "2\n15000 South\n4000 East", "output": "NO"}, {"input": "5\n20000 South\n1000 North\n1000000 West\n9000 North\n10000 North", "output": "YES"}, {"input": "3\n20000 South\n10 East\n20000 North", "output": "NO"}, {"input...
1,300
["geometry", "implementation"]
140
[{"input": "5\r\n7500 South\r\n10000 East\r\n3500 North\r\n4444 West\r\n4000 North\r\n", "output": "YES\r\n"}, {"input": "2\r\n15000 South\r\n4000 East\r\n", "output": "NO\r\n"}, {"input": "5\r\n20000 South\r\n1000 North\r\n1000000 West\r\n9000 North\r\n10000 North\r\n", "output": "YES\r\n"}, {"input": "3\r\n20000 Sout...
false
stdio
null
true
979/B
979
B
Python 3
TESTS
137
187
7,782,400
38270585
n = int(input()) s1 = input() s2 = input() s3 = input() s = len(s1) d1, d2, d3 = dict(), dict(), dict() for i in s1: if i not in d1: d1[i] = 1 else: d1[i] += 1 for i in s2: if i not in d2: d2[i] = 1 else: d2[i] += 1 for i in s3: if i not in d3: d3[i] = 1 else: d3[i] += 1 max1, max2, max3 = 0, 0, 0 for...
184
93
2,969,600
217007184
from collections import Counter n = int(input()) total = [0] * 3 for i in range(3): s = input() a = Counter(s) MAX = max(a.values()) if MAX == len(s) and n == 1: MAX = len(s) - 1 else: MAX += n MAX = min(MAX, len(s)) total[i] = MAX max = max(total) if total.count(max) >...
Codeforces Round 482 (Div. 2)
CF
2,018
1
256
Treasure Hunt
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her. The three friends are very smart so they passed all the challenges very quickly and finally reached the destination...
The first line contains an integer $$$n$$$ ($$$0 \leq n \leq 10^{9}$$$) — the number of turns. Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than $$$10^{5}$$$ uppercase and lowercase Latin letters and is not empty. It is guaranteed th...
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
null
In the first example, after $$$3$$$ turns, Kuro can change his ribbon into ooooo, which has the beauty of $$$5$$$, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most $$$4$$$, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon int...
[{"input": "3\nKuroo\nShiro\nKatie", "output": "Kuro"}, {"input": "7\ntreasurehunt\nthreefriends\nhiCodeforces", "output": "Shiro"}, {"input": "1\nabcabc\ncbabac\nababca", "output": "Katie"}, {"input": "15\nfoPaErcvJ\nmZaxowpbt\nmkuOlaHRE", "output": "Draw"}]
1,800
["greedy"]
184
[{"input": "3\r\nKuroo\r\nShiro\r\nKatie\r\n", "output": "Kuro\r\n"}, {"input": "7\r\ntreasurehunt\r\nthreefriends\r\nhiCodeforces\r\n", "output": "Shiro\r\n"}, {"input": "1\r\nabcabc\r\ncbabac\r\nababca\r\n", "output": "Katie\r\n"}, {"input": "15\r\nfoPaErcvJ\r\nmZaxowpbt\r\nmkuOlaHRE\r\n", "output": "Draw\r\n"}, {"in...
false
stdio
null
true
979/B
979
B
Python 3
TESTS
98
124
8,601,600
38261709
from collections import Counter names = ["Kuro", "Shiro", "Katie"] def solve(s, n): d = Counter(s) if len(d) == 1 and n == 1: return n - 1 m = max(d.values()) return min(m+n,len(s)) n = int(input()) p = [] for _ in range(3): p.append(input()) l = sorted([ (solve(p[i],n),i) for i in range...
184
93
4,505,600
176881870
import sys, os, io input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline n = int(input()) x = [0] * 3 for i in range(3): s = list(input().rstrip()) cnt = [0] * 130 for j in s: cnt[j] += 1 m = max(cnt) c = min(m + n, len(s)) if m == len(s) and n == 1: c = m - 1 x[i] = ...
Codeforces Round 482 (Div. 2)
CF
2,018
1
256
Treasure Hunt
After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her. The three friends are very smart so they passed all the challenges very quickly and finally reached the destination...
The first line contains an integer $$$n$$$ ($$$0 \leq n \leq 10^{9}$$$) — the number of turns. Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than $$$10^{5}$$$ uppercase and lowercase Latin letters and is not empty. It is guaranteed th...
Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".
null
In the first example, after $$$3$$$ turns, Kuro can change his ribbon into ooooo, which has the beauty of $$$5$$$, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most $$$4$$$, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon int...
[{"input": "3\nKuroo\nShiro\nKatie", "output": "Kuro"}, {"input": "7\ntreasurehunt\nthreefriends\nhiCodeforces", "output": "Shiro"}, {"input": "1\nabcabc\ncbabac\nababca", "output": "Katie"}, {"input": "15\nfoPaErcvJ\nmZaxowpbt\nmkuOlaHRE", "output": "Draw"}]
1,800
["greedy"]
184
[{"input": "3\r\nKuroo\r\nShiro\r\nKatie\r\n", "output": "Kuro\r\n"}, {"input": "7\r\ntreasurehunt\r\nthreefriends\r\nhiCodeforces\r\n", "output": "Shiro\r\n"}, {"input": "1\r\nabcabc\r\ncbabac\r\nababca\r\n", "output": "Katie\r\n"}, {"input": "15\r\nfoPaErcvJ\r\nmZaxowpbt\r\nmkuOlaHRE\r\n", "output": "Draw\r\n"}, {"in...
false
stdio
null
true
797/B
797
B
PyPy 3
TESTS
16
124
20,172,800
79682834
a=int(input()) z=list(map(int,input().split())) oddp=[] eve=[] oddn=[] for i in range(len(z)): if(z[i]%2==0 and z[i]>0): eve.append(z[i]) elif(z[i]%2==1): if(z[i]>0): oddp.append(z[i]) else: oddn.append(z[i]) if(len(oddp)==0): print(max(oddn)+sum(eve)) else: ...
126
78
10,547,200
228848341
input() total_sum, min_odd = 0, 10**4 for num in map(int, input().split()): if num > 0: total_sum += num if num % 2 != 0: min_odd = min(abs(num), min_odd) if total_sum % 2 != 1: total_sum -= min_odd print(total_sum)
Educational Codeforces Round 19
ICPC
2,017
1
256
Odd sum
You are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum. Subsequence is a sequence that can be derived from another sequence by deletin...
The first line contains integer number n (1 ≤ n ≤ 105). The second line contains n integer numbers a1, a2, ..., an ( - 104 ≤ ai ≤ 104). The sequence contains at least one subsequence with odd sum.
Print sum of resulting subseqeuence.
null
In the first example sum of the second and the fourth elements is 3.
[{"input": "4\n-2 2 -3 1", "output": "3"}, {"input": "3\n2 -5 -3", "output": "-1"}]
1,400
["dp", "greedy", "implementation"]
126
[{"input": "4\r\n-2 2 -3 1\r\n", "output": "3\r\n"}, {"input": "3\r\n2 -5 -3\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "15\r\n-6004 4882 9052 413 6056 4306 9946 -4616 -6135 906 -1718 5252 -2866 9061 4046\r\n", "output": "53507\r\n"}, {...
false
stdio
null
true
815/A
815
A
PyPy 3
TESTS
16
155
5,324,800
112037896
n, m = map(int, input().split()) g = [list(map(int, input().split())) for _ in range(n)] a = [0] * n b = [0] * m a[0] = min(g[0]) if a[0] > 0: for j in range(m): g[0][j] -= a[0] b[j] = g[0][j] good = True for i in range(n): for j in range(m): g[i][j] -= b[j] if min(g[i]) < 0 or ...
177
108
3,788,800
27849257
import sys #sys.stdin=open("data.txt") input=sys.stdin.readline n,m=map(int,input().split()) realg=[list(map(int,input().split())) for _ in range(n)] g=[[0]*m for _ in range(n)] ans=[] # get differences f1=min([realg[0][i] for i in range(m)]) for i in range(m): for _ in range(realg[0][i]-f1): ans.append...
Codeforces Round 419 (Div. 1)
CF
2,017
2
512
Karen and Game
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column. To ...
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must b...
null
In the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is required...
[{"input": "3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "output": "4\nrow 1\nrow 1\ncol 4\nrow 3"}, {"input": "3 3\n0 0 0\n0 1 0\n0 0 0", "output": "-1"}, {"input": "3 3\n1 1 1\n1 1 1\n1 1 1", "output": "3\nrow 1\nrow 2\nrow 3"}]
1,700
["brute force", "greedy", "implementation"]
177
[{"input": "3 5\r\n2 2 2 3 2\r\n0 0 0 1 0\r\n1 1 1 2 1\r\n", "output": "4\r\nrow 1\r\nrow 1\r\ncol 4\r\nrow 3\r\n"}, {"input": "3 3\r\n0 0 0\r\n0 1 0\r\n0 0 0\r\n", "output": "-1\r\n"}, {"input": "3 3\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "3\r\nrow 1\r\nrow 2\r\nrow 3\r\n"}, {"input": "3 5\r\n2 4 2 2 3\r\n0 2 0 0 ...
false
stdio
import sys def main(): input_path = sys.argv[1] output_path = sys.argv[2] submission_path = sys.argv[3] with open(input_path, 'r') as f: n, m = map(int, f.readline().split()) grid = [list(map(int, f.readline().split())) for _ in range(n)] possible = True g1_1 = grid[0][0] if n...
true
797/B
797
B
Python 3
TESTS
16
124
409,600
77743956
from collections import Counter,defaultdict,deque import heapq as hq from itertools import count, islice #alph = 'abcdefghijklmnopqrstuvwxyz' #from math import factorial as fact import math import sys input=sys.stdin.readline #print=sys.stdout.write #tt = int(input()) #total=0 #n = int(input()) #n,m,k = [int(x) for x ...
126
92
13,721,600
219660805
def main(): n = int(input()) a = list(map(int, input().split())) sum_ = 0 for i in range(n): if a[i] > 0: sum_ += a[i] if sum_ % 2 == 1: return sum_ min_pos = sum_ max_neg = sum_ for i in range(n): if a[i] > 0 and a[i] % 2 == 1: min_pos = m...
Educational Codeforces Round 19
ICPC
2,017
1
256
Odd sum
You are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum. Subsequence is a sequence that can be derived from another sequence by deletin...
The first line contains integer number n (1 ≤ n ≤ 105). The second line contains n integer numbers a1, a2, ..., an ( - 104 ≤ ai ≤ 104). The sequence contains at least one subsequence with odd sum.
Print sum of resulting subseqeuence.
null
In the first example sum of the second and the fourth elements is 3.
[{"input": "4\n-2 2 -3 1", "output": "3"}, {"input": "3\n2 -5 -3", "output": "-1"}]
1,400
["dp", "greedy", "implementation"]
126
[{"input": "4\r\n-2 2 -3 1\r\n", "output": "3\r\n"}, {"input": "3\r\n2 -5 -3\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "15\r\n-6004 4882 9052 413 6056 4306 9946 -4616 -6135 906 -1718 5252 -2866 9061 4046\r\n", "output": "53507\r\n"}, {...
false
stdio
null
true
797/B
797
B
PyPy 3
TESTS
37
233
10,752,000
84147165
n=int(input()) l=sorted([int(i) for i in input().split()]) s=0 c=-1 c1=0 c2=0 for i in range(n): if(l[i]>=0): s+=l[i] else: c=i if(c<n-1): if(s%2==1): print(s) else: for i in range(c,-1,-1): if(l[i]%2==1): k=l[i] c1=1 ...
126
93
6,758,400
160946235
n = int(input()) a = list(map(int, input().split())) maximal = sum(x for x in a if x > 0) if maximal % 2 == 1: print(maximal) else: INF = 1e9 print(max( maximal - min((x for x in a if x > 0 and x & 1), default=INF), maximal + max((x for x in a if x < 0 and x & 1), default=-INF), ))
Educational Codeforces Round 19
ICPC
2,017
1
256
Odd sum
You are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum. Subsequence is a sequence that can be derived from another sequence by deletin...
The first line contains integer number n (1 ≤ n ≤ 105). The second line contains n integer numbers a1, a2, ..., an ( - 104 ≤ ai ≤ 104). The sequence contains at least one subsequence with odd sum.
Print sum of resulting subseqeuence.
null
In the first example sum of the second and the fourth elements is 3.
[{"input": "4\n-2 2 -3 1", "output": "3"}, {"input": "3\n2 -5 -3", "output": "-1"}]
1,400
["dp", "greedy", "implementation"]
126
[{"input": "4\r\n-2 2 -3 1\r\n", "output": "3\r\n"}, {"input": "3\r\n2 -5 -3\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "15\r\n-6004 4882 9052 413 6056 4306 9946 -4616 -6135 906 -1718 5252 -2866 9061 4046\r\n", "output": "53507\r\n"}, {...
false
stdio
null
true
797/B
797
B
PyPy 3
TESTS
37
170
11,878,400
160947060
n = int(input()) nums = [int(x) for x in input().split()] posi = [] nega = [] odd = [] sum = 0 for x in nums: if x >= 0: posi.append(x) else: nega.append(x) sort = sorted(posi, reverse=True) + sorted(nega, reverse = True) ans = [] for x in range(len(sort)): sum += sort[x] ans.append(sum)...
126
93
7,270,400
132354899
def solution(n, a): oddMin = 10**4 isOdd = False sum = 0 for i in range(n): if (a[i] > 0): sum = sum+a[i] if (a[i]%2 !=0): isOdd = True if (oddMin > abs(a[i])): oddMin = abs(a[i]) if (isOdd == False): return -1 if (sum...
Educational Codeforces Round 19
ICPC
2,017
1
256
Odd sum
You are given sequence a1, a2, ..., an of integer numbers of length n. Your task is to find such subsequence that its sum is odd and maximum among all such subsequences. It's guaranteed that given sequence contains subsequence with odd sum. Subsequence is a sequence that can be derived from another sequence by deletin...
The first line contains integer number n (1 ≤ n ≤ 105). The second line contains n integer numbers a1, a2, ..., an ( - 104 ≤ ai ≤ 104). The sequence contains at least one subsequence with odd sum.
Print sum of resulting subseqeuence.
null
In the first example sum of the second and the fourth elements is 3.
[{"input": "4\n-2 2 -3 1", "output": "3"}, {"input": "3\n2 -5 -3", "output": "-1"}]
1,400
["dp", "greedy", "implementation"]
126
[{"input": "4\r\n-2 2 -3 1\r\n", "output": "3\r\n"}, {"input": "3\r\n2 -5 -3\r\n", "output": "-1\r\n"}, {"input": "1\r\n1\r\n", "output": "1\r\n"}, {"input": "1\r\n-1\r\n", "output": "-1\r\n"}, {"input": "15\r\n-6004 4882 9052 413 6056 4306 9946 -4616 -6135 906 -1718 5252 -2866 9061 4046\r\n", "output": "53507\r\n"}, {...
false
stdio
null
true
815/A
815
A
PyPy 3
TESTS
11
171
4,812,800
58700504
a,b=map(int,input().split()) m=[] for i in range(a): m.append(list(map(int,input().split()))) r=[] if a <= b: for i in range(a): mn=min(m[i]) for j in range(b): m[i][j]-=mn for j in range(mn): r.append('row ' + str(i+1)) for i in range(b): mn=502 ...
177
124
1,843,200
48908067
n,m=map(int,input().split()) L=[list(map(int,input().split())) for i in range(n)] s="row" s1="col" if n>m : L1=[[0 for i in range(n)] for j in range(m)] for i in range(n) : for j in range(m) : L1[j][i]=L[i][j] L=L1 n,m=m,n s,s1=s1,s w=[0 for i in range(n)] w1=[0 for ...
Codeforces Round 419 (Div. 1)
CF
2,017
2
512
Karen and Game
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and m columns. Each cell originally contains the number 0. One move consists of choosing one row or column, and adding 1 to all of the cells in that row or column. To ...
The first line of input contains two integers, n and m (1 ≤ n, m ≤ 100), the number of rows and the number of columns in the grid, respectively. The next n lines each contain m integers. In particular, the j-th integer in the i-th of these rows contains gi, j (0 ≤ gi, j ≤ 500).
If there is an error and it is actually not possible to beat the level, output a single integer -1. Otherwise, on the first line, output a single integer k, the minimum number of moves necessary to beat the level. The next k lines should each contain one of the following, describing the moves in the order they must b...
null
In the first test case, Karen has a grid with 3 rows and 5 columns. She can perform the following 4 moves to beat the level: In the second test case, Karen has a grid with 3 rows and 3 columns. It is clear that it is impossible to beat the level; performing any move will create three 1s on the grid, but it is required...
[{"input": "3 5\n2 2 2 3 2\n0 0 0 1 0\n1 1 1 2 1", "output": "4\nrow 1\nrow 1\ncol 4\nrow 3"}, {"input": "3 3\n0 0 0\n0 1 0\n0 0 0", "output": "-1"}, {"input": "3 3\n1 1 1\n1 1 1\n1 1 1", "output": "3\nrow 1\nrow 2\nrow 3"}]
1,700
["brute force", "greedy", "implementation"]
177
[{"input": "3 5\r\n2 2 2 3 2\r\n0 0 0 1 0\r\n1 1 1 2 1\r\n", "output": "4\r\nrow 1\r\nrow 1\r\ncol 4\r\nrow 3\r\n"}, {"input": "3 3\r\n0 0 0\r\n0 1 0\r\n0 0 0\r\n", "output": "-1\r\n"}, {"input": "3 3\r\n1 1 1\r\n1 1 1\r\n1 1 1\r\n", "output": "3\r\nrow 1\r\nrow 2\r\nrow 3\r\n"}, {"input": "3 5\r\n2 4 2 2 3\r\n0 2 0 0 ...
false
stdio
import sys def main(): input_path = sys.argv[1] output_path = sys.argv[2] submission_path = sys.argv[3] with open(input_path, 'r') as f: n, m = map(int, f.readline().split()) grid = [list(map(int, f.readline().split())) for _ in range(n)] possible = True g1_1 = grid[0][0] if n...
true
370/D
370
D
Python 3
TESTS
40
390
52,019,200
5414654
#!/usr/bin/python3 def readln(): return list(map(int, input().split())) import sys def exit(): print(-1) sys.exit() n, m = readln() mon = [list(input()) for _ in range(n)] hor = [i for i in range(n) if mon[i] != ['.'] * m] rmon = list(zip(*mon)) ver = [j for j in range(m) if rmon[j] != ('.',) * n] mini = hor[...
125
1,465
35,123,200
139630574
from itertools import chain def draw_square(ans, square_a, ymin, xmin) -> list: for i in range(square_a + 1): if(ans[ymin][xmin + i] != 'w'): ans[ymin] = ans[ymin][:xmin + i] + '+' + ans[ymin][xmin + i + 1:] if(ans[ymin + square_a][xmin + i] != 'w'): ans[ymin + square_a] = an...
Codeforces Round 217 (Div. 2)
CF
2,013
2
256
Broken Monitor
Innocentius has a problem — his computer monitor has broken. Now some of the pixels are "dead", that is, they are always black. As consequence, Innocentius can't play the usual computer games. He is recently playing the following game with his younger brother Polycarpus. Innocentius is touch-typing a program that pain...
The first line contains the resolution of the monitor as a pair of integers n, m (1 ≤ n, m ≤ 2000). The next n lines contain exactly m characters each — the state of the monitor pixels at the moment of the game. Character "." (period, ASCII code 46) corresponds to the black pixel, and character "w" (lowercase English l...
Print the monitor screen. Represent the sought frame by characters "+" (the "plus" character). The pixels that has become white during the game mustn't be changed. Print them as "w". If there are multiple possible ways to position the frame of the minimum size, print any of them. If the required frame doesn't exist, t...
null
In the first sample the required size of the optimal frame equals 4. In the second sample the size of the optimal frame equals 3. In the third sample, the size of the optimal frame is 1. In the fourth sample, the required frame doesn't exist.
[{"input": "4 8\n..w..w..\n........\n........\n..w..w..", "output": "..w++w..\n..+..+..\n..+..+..\n..w++w.."}, {"input": "5 6\n......\n.w....\n......\n..w...\n......", "output": "......\n+w+...\n+.+...\n++w...\n......"}, {"input": "2 4\n....\n.w..", "output": "....\n.w.."}, {"input": "2 6\nw..w.w\n...w..", "output": "-...
2,100
["brute force", "constructive algorithms", "greedy", "implementation"]
125
[{"input": "4 8\r\n..w..w..\r\n........\r\n........\r\n..w..w..\r\n", "output": "..w++w..\r\n..+..+..\r\n..+..+..\r\n..w++w..\r\n"}, {"input": "5 6\r\n......\r\n.w....\r\n......\r\n..w...\r\n......\r\n", "output": "......\r\n+w+...\r\n+.+...\r\n++w...\r\n......\r\n"}, {"input": "2 4\r\n....\r\n.w..\r\n", "output": "......
false
stdio
import sys def read_grid(file_path, n): with open(file_path) as f: return [list(line.strip()) for line in f.readlines()[:n]] def main(input_path, output_path, submission_path): with open(input_path) as f: n, m = map(int, f.readline().split()) input_grid = [list(line.strip()) for line i...
true