description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
from sys import stdin input = lambda: stdin.readline().rstrip("\r\n") for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) if sorted(a)[::2] == sorted(a[::2]): print("YES") else: print("NO")
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) a[::2] = sorted(a[::2]) a[1::2] = sorted(a[1::2]) if a == sorted(a): print("Yes") else: print("No")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRIN...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
def vec_add(el1, el2): return [el1[0] + el2[0], el1[1] + el2[1]] for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = sorted(a) d = {} for i in range(len(a)): if a[i] in d: if i % 2 == 0: d[a[i]] = vec_add(d[a[i]], [1, 0]) ...
FUNC_DEF RETURN LIST BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
ans = [] for _ in range(int(input())): n = int(input()) u = list(map(int, input().split())) s = sorted(u) t0 = [0] * (10**5 + 1) t1 = [0] * (10**5 + 1) for i in range(n): if i % 2 == 0: t0[s[i]] += 1 else: t1[s[i]] += 1 for i in range(n): if i ...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUM...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
def solve(): n = int(input()) a = [int(i) for i in input().split()] b = sorted(a) even = {i: (0) for i in b} odd = {i: (0) for i in b} for i in range(len(b)): if i % 2: odd[b[i]] += 1 else: even[b[i]] += 1 for i in range(len(a)): if i % 2: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
def strangesort(n, arr): tab = [(arr[i], i) for i in range(n)] tab = sorted(tab, key=lambda x: x[0]) cur_count = [0, 0] prev = -1 for x in range(n): if tab[x][0] != prev: if cur_count[0] != cur_count[1]: print("NO") return cur_count[0] ...
FUNC_DEF ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUM...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
import sys from sys import stdin tt = int(stdin.readline()) ANS = [] for loop in range(tt): n = int(stdin.readline()) a = list(map(int, stdin.readline().split())) o = [] e = [] for i in range(n): if i % 2 == 0: e.append(a[i]) else: o.append(a[i]) e.sort()...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CAL...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
t = int(input()) for i in range(t): n = int(input()) arr = list(map(int, input().split())) s = sorted(arr) v = {} for i in range(n): if arr[i] in v: v[arr[i]][i % 2] += 1 else: v[arr[i]] = [0, 0] v[arr[i]][i % 2] += 1 ans = "YES" flag = Fal...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR LIST NU...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
import sys input = lambda: sys.stdin.readline() int_arr = lambda: list(map(int, input().split())) str_arr = lambda: list(map(str, input().split())) get_str = lambda: map(str, input().split()) get_int = lambda: map(int, input().split()) get_flo = lambda: map(float, input().split()) mod = 1000000007 def solve(n, a, b)...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) arr = [] for i in range(max(a) + 1): arr.append([0, 0]) for i in range(n): arr[a[i]][i % 2] += 1 b = a.copy() b.sort() ver = True for i in range(n): if arr[b[i]][i % 2] > 0: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) dp = [(0) for x in range(10**5 + 2)] for i in range(n): if i % 2 == 0: dp[a[i]] += 1 a.sort() for i in range(n): if i % 2 == 0: dp[a[i]] -= 1 flag = True for k in dp...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR F...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
for _ in range(int(input().strip())): n = int(input().strip()) arr = list(map(int, input().strip().split())) flag = 0 c = max(arr) cnt = [[0, 0] for i in range(c + 1)] for i in range(0, n): cnt[arr[i]][i % 2] += 1 arr.sort() for i in range(0, n): cnt[arr[i]][i % 2] -= 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) ans = "YES" even, odd = [], [] for i in range(n): if i & 1: odd.append(a[i]) else: even.append(a[i]) arr = [0] * n even.sort() odd.sort() for i in range(0, n, 2)...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LI...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
def count(n, A, odd, even): for i in range(n): if i % 2 == 0: even[A[i]] += 1 else: odd[A[i]] += 1 def checker(n, A, odd, even): status = True for i in range(n): if i % 2 == 0: if even[A[i]] == 0: status = False else: ...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
def pro(arr): dic = {} n = len(arr) for i in range(n): if arr[i] in dic: if i % 2 == 0: dic[arr[i]][0] += 1 else: dic[arr[i]][1] += 1 elif i % 2 == 0: dic[arr[i]] = [1, 0] else: dic[arr[i]] = [0, 1] a...
FUNC_DEF ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER NUMBER VAR VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR LIST NUMBER NUMBER ASSIGN VAR VAR VAR LIST NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
t = int(input()) ans = [] for _ in range(t): n = int(input()) a = [int(i) for i in input().split()] b = sorted(a) f1 = [0] * (10**5 + 1) f2 = [0] * (10**5 + 1) for i in range(0, n, 2): f1[a[i]] += 1 f2[b[i]] += 1 if f1 == f2: ans.append("YES") else: ans.ap...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBE...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
t = int(input()) for i in range(t): n = int(input()) w = [int(k) for k in input().split()] c = sorted(w) a, b = {}, {} for j in range(n): if c[j] in a: a[c[j]][j % 2] += 1 else: a[c[j]] = [0, 0] a[c[j]][j % 2] += 1 if w[j] in b: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR DICT DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR LIST NUM...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
t = int(input()) for _ in range(t): n = int(input()) l = [int(x) for x in input().split(" ")] le = [] lo = [] so = [] se = [] a = sorted(l) for i in range(n): if i & 1: lo.append(l[i]) so.append(a[i]) else: le.append(l[i]) s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CA...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
for _ in range(int(input())): tt = int(input()) arr = list(map(int, input().split())) if tt == 1: print("YES") continue crr = sorted(arr) odl = list(arr[::2]) evl = list(arr[1::2]) odl.sort() evl.sort() ct1 = 0 ct2 = 0 flag = 1 for x in range(tt): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL V...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
import sys def main(): for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) memo = {i: [0, 0] for i in list(set(arr))} for i, a in enumerate(arr): memo[a][i % 2] += 1 for i, a in enumerate(sorted(arr)): memo[a][i % 2] ...
IMPORT FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER FOR VAR VAR FUN...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
def process(A): d = {} n = len(A) for i in range(n): c = A[i] if c not in d: d[c] = [[], []] d[c][0].append(i) A = sorted(A) for i in range(n): c = A[i] d[c][1].append(i) for c in d: a = [0, 0, 0, 0] for i in d[c][0]: ...
FUNC_DEF ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR VAR LIST LIST LIST EXPR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR FOR VAR VAR ASSIGN VAR LIST NUMBER NUM...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
l = [] k = [] for _ in range(int(input())): n = int(input()) d = {} l = list(map(int, input().split())) for i in range(n): if i % 2 == 0: if l[i] in d: d[l[i]] += 1 else: d[l[i]] = 1 elif -l[i] in d: d[-l[i]] += 1 ...
ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
t = int(input()) for i in range(t): n = int(input()) s = input().strip().split(" ") a = [int(x) for x in s] num_of_odd_indexes = {} for j in range(n): if j % 2 == 1 and a[j] not in num_of_odd_indexes: num_of_odd_indexes[a[j]] = 1 elif j % 2 == 1: num_of_odd_in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF BIN_OP VAR NUMBE...
AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right. AquaMoon can make some operations on friends. On each operation,...
for _ in range(int(input())): n = int(input()) A = list(map(int, input().split())) B = sorted(A) hashmap_A = {} hashmap_B = {} for i in range(n): if A[i] not in hashmap_A: hashmap_A[A[i]] = [0, 0] if B[i] not in hashmap_B: hashmap_B[B[i]] = [0, 0] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR LIST NUMBER NUMBER IF VAR VAR VAR ASSIGN VA...
Given a sentenceΒ text (AΒ sentenceΒ is a string of space-separated words) in the following format: First letter is in upper case. Each word in text are separated by a single space. Your task is to rearrange the words in text such thatΒ all words are rearranged in an increasing order of their lengths. If two words have t...
class Solution: def arrangeWords(self, text: str) -> str: if not text: return text words = text.lower().split(" ") words = sorted(words, key=lambda x: len(x)) words[0] = words[0][0].upper() + words[0][1:] return " ".join(words)
CLASS_DEF FUNC_DEF VAR IF VAR RETURN VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER NUMBER VAR NUMBER NUMBER RETURN FUNC_CALL STRING VAR VAR
Given a sentenceΒ text (AΒ sentenceΒ is a string of space-separated words) in the following format: First letter is in upper case. Each word in text are separated by a single space. Your task is to rearrange the words in text such thatΒ all words are rearranged in an increasing order of their lengths. If two words have t...
class Solution: def arrangeWords(self, text: str) -> str: dic = collections.OrderedDict() for word in text.split(): n = len(word) dic[n] = dic.get(n, []) + [word.lower()] res = [] for key, val in sorted(dic.items()): res += val return " "....
CLASS_DEF FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR LIST LIST FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL FUNC_CALL STRING VAR VAR
Given a sentenceΒ text (AΒ sentenceΒ is a string of space-separated words) in the following format: First letter is in upper case. Each word in text are separated by a single space. Your task is to rearrange the words in text such thatΒ all words are rearranged in an increasing order of their lengths. If two words have t...
class Solution: def arrangeWords(self, text: str) -> str: p = text.split(" ") final = "" j = sorted(p, key=len) temp = " ".join(j) if temp[0] >= "a" and temp[0] <= "z": s = temp[0].swapcase() final = final + s[0] else: final = fina...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR IF VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VA...
Given a sentenceΒ text (AΒ sentenceΒ is a string of space-separated words) in the following format: First letter is in upper case. Each word in text are separated by a single space. Your task is to rearrange the words in text such thatΒ all words are rearranged in an increasing order of their lengths. If two words have t...
class Solution: def arrangeWords(self, text: str) -> str: res = [] res_t = "" for idx, word in enumerate(text.split()): res.append((len(word), idx, word.lower())) res.sort() for l, _, word in res: if res_t == "": res_t += word[0].upper...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR LIST ASSIGN VAR STRING FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR VAR VAR VAR IF VAR STRING VAR BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER VAR BIN_OP STRING VAR RETURN VAR VAR
Given a sentenceΒ text (AΒ sentenceΒ is a string of space-separated words) in the following format: First letter is in upper case. Each word in text are separated by a single space. Your task is to rearrange the words in text such thatΒ all words are rearranged in an increasing order of their lengths. If two words have t...
class Solution: def arrangeWords(self, text: str) -> str: text = text[0].lower() + text[1:] words = [] word = "" word_len = 0 for char in text: if char == " ": words.append((word_len, word)) word = "" word_len = 0 ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRIN...
Given a sentenceΒ text (AΒ sentenceΒ is a string of space-separated words) in the following format: First letter is in upper case. Each word in text are separated by a single space. Your task is to rearrange the words in text such thatΒ all words are rearranged in an increasing order of their lengths. If two words have t...
class K: def __init__(self, obj): self.obj = obj def __lt__(self, other): return len(self.obj) < len(other.obj) class Solution: def arrangeWords(self, text: str) -> str: l = text.split() l[0] = l[0].lower() l = sorted(l, key=K) l[0] = l[0].title() ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR CLASS_DEF FUNC_DEF VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FUNC_CALL VAR NUMBER RETURN FUNC_CALL STRING VAR VAR
Given a sentenceΒ text (AΒ sentenceΒ is a string of space-separated words) in the following format: First letter is in upper case. Each word in text are separated by a single space. Your task is to rearrange the words in text such thatΒ all words are rearranged in an increasing order of their lengths. If two words have t...
class Solution: def arrangeWords(self, text: str) -> str: counter = 0 current_word = "" words_map = {} for i in range(0, len(text)): ch = text[i].lower() if ch == " " or i == len(text) - 1: if i == len(text) - 1: counter +=...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR STRING ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR IF VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR ASS...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
def eulid(p, q): A = [1, 0] B = [0, 1] while p != 1 and q != 1: if q < 0: q = -q B[0] = -B[0] B[1] = -B[1] if p < 0: p = -p A[0] = -A[0] A[1] = -A[1] if q < p: p, q = q, p A, B = B, A ...
FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR ...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
for _ in range(int(input())): x, y, p, q = [int(x) for x in input().split(" ")] if y * p == x * q: print(0) continue m1 = -1 m2 = -1 if p == 0: m1 = -1 elif x % p: m1 = x // p + 1 else: m1 = x // p if p == q: m2 = -1 elif (y - x) % (q -...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VA...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
import sys def solve(): t = int(sys.stdin.readline()) for ti in range(t): x, y, p, q = map(int, sys.stdin.readline().split()) if p == 0: if x == 0: print(0) else: print(-1) continue if p == q: if x == y: ...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR BI...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
n = int(input()) for _ in range(n): x, y, p, q = map(int, input().split()) if p == 0 and x != 0: print(-1) elif p == q and x != y: print(-1) elif p * y == q * x: print(0) else: print(q * max((x + p - 1) // p, (y - x + q - p - 1) // (q - p)) - y)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VA...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
for _ in range(int(input())): x, y, p, q = map(int, input().split()) l, r, res = 0, 10**18, -1 while l <= r: mid = (l + r) // 2 a, b = p * mid - x, q * mid - y if a <= b and a > -1 and b > -1: res = b r = mid - 1 else: l = mid + 1 print...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER BIN_OP NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR NUMBER VAR NUMB...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
def gcd(a, b): while a != 0 and b != 0: if a > b: a = a % b else: b = b % a return a + b def check(x, y, p, q, m): num = p * m den = q * m return num - x >= 0 and den - y - (num - x) >= 0 def count(x, y, p, q, m): num = p * m den = q * m return...
FUNC_DEF WHILE VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RET...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
t = int(input()) for zz in range(t): x, y, p, q = [int(i) for i in input().split()] if x * q == y * p: print(0) elif p == 0 and x != 0 or p == q and x != y: print(-1) else: sel1 = y - x sel2 = q - p kalr = x // p + (0, 1)[x % p != 0] kalr = max(kalr, sel1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN V...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
tests = int(input()) def generate(x, y, p, q): min_a = -1 max_a = 10**18 while max_a - min_a > 1: mid_a = (max_a + min_a) // 2 if (x + mid_a) * q < (y + mid_a) * p: min_a = mid_a else: max_a = mid_a return max_a for test in range(tests): x, y, p, q...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
def check(k1, k2, rr): k3 = p * k2 - rr return k3 >= 0 and k2 * q + k1 >= k3 def binary_search(k1, rr): r = 1 while not check(k1, r, rr): r *= 2 l = -1 while l + 1 < r: m = (l + r) // 2 if check(k1, m, rr): r = m else: l = m return r ...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR ...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
T = int(input()) for case in range(T): x, y, p, q = map(int, input().strip().split()) l = int(0) r = int(10000000000.0) ans = 1 << 30 while l <= r: mid = int((l + r) / 2) A = mid * p - x B = mid * q - y if A >= 0 and B >= 0 and A <= B: ans = min(ans, mid) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_O...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
t = int(input()) for i in range(t): x, y, p, q = map(int, input().split()) if p == q and x != y: print(-1) elif not p: if x: print(-1) else: print(0) else: r = max((y + q - 1) // q, (x + p - 1) // p) if r * p > x + r * q - y: if...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR IF VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP ...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
def gcd(a, b): if a == 0: return b return gcd(b % a, a) def get(x, y, p, q): low, high, mid, best = 1, 1 << 65, 0, -1 while low <= high: mid = low + high + 1 >> 1 tp = p * mid tq = q * mid if tq >= y and x <= tp <= x + tq - y: best = mid ...
FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR NUMBER BIN_OP NUMBER NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN ...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
def Ans(k): x, y, p, q = k[0], k[1], k[2], k[3] if p / q == 1 and x != y or p == 0 and x != 0: print(-1) elif p == 0 and x == 0: print(0) else: up = 10**9 down = 1 dy = y - x while up > down + 1: mid = (up + down) // 2 qf = q * mid ...
FUNC_DEF ASSIGN VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR BIN_OP VAR NUMBER ASSIGN V...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
tc = int(input()) for i in range(tc): x, y, p, q = map(int, input().split()) if p == 0: if x == 0: print("0") else: print("-1") elif p == q: if y > x: print("-1") else: print("0") elif p * y == x * q: print("0") ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING IF BIN_OP VAR VAR BIN_OP VAR VAR EXP...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
t = int(input()) for _ in range(t): x, y, a, b = map(int, input().split()) if a == 0: if x == 0: print(0) else: print(-1) continue lo = max(-(-x // a), -(-y // b)) hi = 10**18 while lo < hi: k = lo + (hi - lo) // 2 if k * (a - b) <= x -...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VA...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
t = int(input()) for i in range(t): x, y, p, q = map(int, input().split()) if p == 1 and q == 1 and x // y != 1 or p == 0 and x != 0: z = -1 else: start = 0 stop = 10**9 while start <= stop - 2: mid = (start + stop) // 2 if mid * q - y + x >= mid * p a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP ...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
t = int(input()) for _ in range(t): x, y, p, q = map(int, input().split()) if p == q: print(0 if x == y else -1) elif p == 0: print(0 if x == 0 else -1) elif x * q == y * p: print(0) else: l = 0 r = 2**64 cnt = 0 while l + 1 < r: cn...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASS...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
def mp(): return map(int, input().split()) def lt(): return list(map(int, input().split())) def pt(x): print(x) def ip(): return input() def it(): return int(input()) def sl(x): return [t for t in x] def spl(x): return x.split() def aj(liste, item): liste.append(item) def...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VA...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
MAXN = int(2e18) def check(n, x, y, p, q): np, nq = n * p, n * q if nq < y: return False diff = nq - y return x <= np <= x + diff def solve(): x, y, p, q = map(int, input().split()) l, r = 1, int(MAXN) while l != r: m = (l + r) // 2 if not check(m, x, y, p, q): ...
ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP ...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
def ceil(x, y): return x // y + (x % y != 0) for _ in range(int(input())): x, y, p, q = map(int, input().split()) if p == 0: print(0 if x == 0 else -1) elif p == q: print(0 if x == y else -1) else: k = max(ceil(y * q - q * x, q * (q - p)), ceil(x, p)) a = k * p - x ...
FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL ...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
def solve(x, y, p, q): if p == q: if x == y: return 0 else: return -1 if p == 0: if x == 0: return 0 else: return -1 k1 = (y - x) // (q - p) if k1 * (q - p) < y - x: k1 += 1 k2 = y // q if k2 * q < y: ...
FUNC_DEF IF VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
def ext_gcd(a, b): if a == 0: return b, 0, 1 else: g, x, y = ext_gcd(b % a, a) return g, y - b // a * x, x def multinv(b, n): g, x, trash = ext_gcd(b, n) return x % n def solve(): x, y, p, q = map(int, input().split(" ")) if p == q: if x == y: retu...
FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR IF V...
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite rational number in the [0;1] range is p / q. Now you wonder: what is the s...
for _ in range(int(input())): x, y, p, q = map(int, input().split()) d = q * int(1000000000.0) c = p * int(1000000000.0) if not (c >= x and d - y >= c - x): print(-1) continue i = -1 j = int(1000000000.0) while j - i > 1: m = (i + j) // 2 d = q * m c =...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR NUMBER IF VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER WH...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
class intersection: def __init__(self, x, y): self.x = x self.y = y def __lt__(self, other): if self.x < other.x or self.x == other.x and self.y < other.y: return True else: return False a = [] x = [] y = [] for i in range(8): m, n = list(map(int, ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF IF VAR VAR VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CAL...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
class point: def __init__(self, x, y): self.x = x self.y = y def __lt__(self, other): return self.x < other.x or self.x == other.x and self.y < other.y p = [] for i in range(8): x, y = map(int, input().split()) p.append(point(x, y)) p.sort() if ( p[0].x == p[1].x and ...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
class Point: def __init__(self, x, y): self.x = x self.y = y def __lt__(self, other): return self.x < other.x or self.x == other.x and self.y <= other.y p = [] for i in range(8): a, b = map(int, input().split()) p.append(Point(a, b)) p.sort() ugly = False for i in range(1, 3)...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR ...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
def Slove(): A = sorted(tuple(map(int, input().split())) for _ in range(8)) if ( A[0][0] == A[1][0] == A[2][0] < A[3][0] == A[4][0] < A[5][0] == A[6][0] == A[7][0] and A[0][1] == A[3][1] == A[5][1] < A[1][1] ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR ...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
Q = sorted S = set I = S() X = S() Y = S() T = S() for _ in "0" * 8: x, y = map(int, input().split()) I.add((x, y)) X.add(x) Y.add(y) X = Q(X) Y = Q(Y) print( ["ugly", "respectable"][ len(X) == len(Y) == 3 and set([(x, y) for x in X for y in Y if x != X[1] or y != Y[1]]) == I ] )
ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR BIN_OP STRING NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR AS...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
x = [] y = [] all = [] for i in range(8): xx, yy = map(int, input().split()) x.append(xx) y.append(yy) all.append((xx, yy)) sx = set(x) sy = set(y) if len(sx) % 3 != 0 or len(sy) % 3 != 0: print("ugly") else: sx = sorted(list(sx)) sy = sorted(list(sy)) for i in range(3): for j in...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER BIN_OP FUNC_C...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
lines = [tuple(map(int, input().split())) for i in range(8)] x_set = set() y_set = set() for x, y in lines: x_set.add(x) y_set.add(y) if len(x_set) == len(y_set) == 3: flag = False x_sort, y_sort = sorted(x_set), sorted(y_set) for x in x_sort: for y in y_sort: if (x, y) != (x_sor...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR F...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
(a, b), (c, d), (e, f), (g, h), (i, j), (k, l), (m, n), (o, p) = sorted( tuple(map(int, input().split())) for _ in range(8) ) print( ("ugly", "respectable")[ a == c == e < g == i < k == m == o and b == h == l < d == n < f == j == p ] )
ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING STRING VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
l = [] for i in range(8): x, y = [int(x) for x in input().split()] l.append((x, y)) l.sort() lx = [] lx.append(l[0][0]) lx.append(l[3][0]) lx.append(l[6][0]) ly = [] ly.append(l[0][1]) ly.append(l[1][1]) ly.append(l[2][1]) eps = [(x, y) for x in lx for y in ly] eps.pop(4) if ( l == eps and lx[0] != lx[1...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NU...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
n = 8 p = [] xs = [] ys = [] for i in range(n): x, y = map(int, input().split()) p.append((x, y)) xs.append(x) ys.append(y) xs = list(sorted(list(set(xs)))) ys = list(sorted(list(set(ys)))) p.sort() if len(xs) != 3 or len(ys) != 3: print("ugly") elif p == [ (xs[0], ys[0]), (xs[0], ys[1]), ...
ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FU...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
def f(p): if len(set(p)) < 8: return False x, y = sorted({pi[0] for pi in p}), sorted({pi[1] for pi in p}) return len(x) == 3 and len(y) == 3 and (x[1], y[1]) not in p print( "respectable" if f([tuple(map(int, input().split())) for i in range(8)]) else "ugly" )
FUNC_DEF IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR RETURN FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VA...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
x = [] y = [] for i in range(8): xi, yi = map(int, input().split()) x.append(xi) y.append(yi) xtmp = sorted(x) ytmp = sorted(y) xdist_list = [xtmp[0]] ydist_list = [ytmp[0]] for i in range(1, 8): if xtmp[i] != xtmp[i - 1]: xdist_list.append(xtmp[i]) if ytmp[i] != ytmp[i - 1]: ydist_l...
ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR V...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
fre_x = [False] * (10**6 + 5) fre_y = [False] * (10**6 + 5) unique_x = [] unique_y = [] points = [] for _ in range(8): x, y = map(int, input().split()) points.append((x, y)) if not fre_x[x]: fre_x[x] = True unique_x.append(x) if not fre_y[y]: fre_y[y] = True unique_y.appe...
ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NUM...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
v = [] for i in range(0, 8): x, y = map(int, input().split()) v.append((x, y)) v.sort() if ( v[0][0] == v[1][0] == v[2][0] and v[3][0] == v[4][0] and v[5][0] == v[6][0] == v[7][0] and v[0][1] == v[3][1] == v[5][1] and v[1][1] == v[6][1] and v[2][1] == v[4][1] == v[7][1] and v[0][0] !...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER ...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
x = [] y = [] arr = [] for i in range(8): xi, yi = map(int, input().split()) arr.append((xi, yi)) if xi not in x: x.append(xi) if yi not in y: y.append(yi) if len(x) == 3 and len(y) == 3: x = sorted(x) y = sorted(y) ugly = False for i in range(3): for j in range(3...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VA...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
a = [] def f(n): return n[0] def ff(n): return n[1] for i in range(8): x, y = map(int, input().split()) if [x, y] in a: print("ugly") exit() a.append([x, y]) a.sort(key=f) k = 0 if a[0][0] == a[1][0] and a[1][0] == a[2][0]: k += 1 if a[2][0] != a[3][0]: if a[3][...
ASSIGN VAR LIST FUNC_DEF RETURN VAR NUMBER FUNC_DEF RETURN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF LIST VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER NUMBER VAR N...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
u = set() v = set() w = set() s = set() def work(): nonlocal u, v if len(u) < 3 or len(v) < 3: return 0 u = sorted(list(u)) v = sorted(list(v)) for i in range(3): for j in range(3): if i != 1 or j != 1: w.add((u[i], v[j])) return w == s for i in ra...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
x = [] y = [] p = [] for i in range(8): a, b = [int(x) for x in input().split()] x.append(a) y.append(b) l = [a, b] p.append(l) sx = list(set(x)) sy = list(set(y)) jud = 0 if len(sx) != 3 or len(sy) != 3: print("ugly") jud = 1 if jud == 0: sx.sort() sy.sort() pp = [] for i in...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASS...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
import sys from itertools import * fin = sys.stdin points = [] for i in range(8): x, y = map(int, fin.readline().split()) points += [(x, y)] def CheckPoints(p): if not p[0][0] == p[1][0] == p[2][0]: return False x1 = p[0][0] if not p[3][0] == p[4][0]: return False x2 = p[3][0]...
IMPORT ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST VAR VAR FUNC_DEF IF VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR VAR NU...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
class Coordinate: def __init__(self, x, y): self.x = x self.y = y def __lt__(self, other): if self.x < other.x: return True if self.x == other.x and self.y < other.y: return True return False a = [] for i in range(8): x, y = map(int, input(...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR NUM...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
def eight_point_sets_2(s): x = list(set([a[0] for a in s])) x.sort() y = list(set([b[1] for b in s])) y.sort() test = True if len(x) != 3 or len(y) != 3: test = False return test for i in range(0, 3): for j in range(0, 3): if i != 1 or j != 1: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
s = set() w = set() d = dict() for _ in range(8): l = list(map(int, input().split())) s.add(l[0]) w.add(l[1]) if l[0] in d: d[l[0]].append(l[1]) d[l[0]].sort() else: d[l[0]] = list() d[l[0]].append(l[1]) if len(d) > 3: print("ugly") exit() if len(s...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
def components(lst, a, b): if len(a) != 3 or len(b) != 3: return "ugly" for x in range(3): for y in range(3): if x == y == 1: continue if [a[x], b[y]] not in lst: return "ugly" return "respectable" arr = [[int(c) for c in input().spli...
FUNC_DEF IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN STRING FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER IF LIST VAR VAR VAR VAR VAR RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
x = [None] * 10 y = [None] * 10 t = [] xc = [] yc = [] f = False for i in range(8): x[i], y[i] = list(map(int, input().split())) if (x[i], y[i]) in t: f = True t.append((x[i], y[i])) if not x[i] in xc: xc.append(x[i]) if y[i] not in yc: yc.append(y[i]) if len(xc) != 3 or len(...
ASSIGN VAR BIN_OP LIST NONE NUMBER ASSIGN VAR BIN_OP LIST NONE NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR ...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
lists = [] dicts = {} sets = set() for i in range(8): lists.append(tuple(input().split())) for x in lists: sets.add(x) if len(sets) == 8: for x in range(8): count = dicts.get(int(lists[x][0]), 0) dicts[int(lists[x][0])] = count + 1 if len(dicts.keys()) == 3: temp = sorted(dicts.i...
ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
class Point: def __init__(self, x=0, y=0): self.x = x self.y = y arr_point = [] for i in range(8): tmp_x, tmp_y = map(int, input().split()) arr_point.append(Point(tmp_x, tmp_y)) for i in range(8): for j in range(i + 1, 8): if arr_point[i].x == arr_point[j].x and arr_point[i].y...
CLASS_DEF FUNC_DEF NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR VAR VAR VAR VAR VAR EXP...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
def solve(): S = set() x = [-1] * 3 y = [-1] * 3 xc = [0] * 3 yc = [0] * 3 i = 0 for i in range(8): xi, yi = list(map(int, input().split())) if str([xi, yi]) in S: return 0 S.add(str([xi, yi])) j = 0 while j < 3: if x[j] == -1: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR LIS...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
xx = set() yy = set() l = set() for i in range(8): a = list(map(int, input().split())) x, y = a[0], a[1] l.add((x, y)) xx.add(x) yy.add(y) ok = 1 if len(xx) != 3 or len(yy) != 3 or len(l) != 8: ok = 0 else: ax = list(xx) ay = list(yy) ax.sort() ay.sort() if (ax[1], ay[1]) in ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR ...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
n = 8 group = 3 middle = 1 dx = {} dy = {} pairs = set() isUgly = False for i in range(n): x, y = map(int, input().split()) if x in dx: dx[x] += 1 if dx[x] > group: isUgly = True else: dx[x] = 1 if y in dy: dy[y] += 1 if dy[y] > group: isUg...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER I...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
a = [] b = [] c = [] for i in range(8): x, y = map(int, input().split()) a.append(x) b.append(y) c.append([x, y]) unique_c = [c[0]] set_a = list(set(a)) set_b = list(set(b)) set_a.sort() set_b.sort() result = "respectable" for i in range(1, len(c)): if c[i] not in unique_c: unique_c.append(c...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
X = dict() Y = dict() A = set() for i in range(8): x, y = list(map(int, input().split())) if (x, y) in A: print("ugly") return else: A.add((x, y)) if x in X: X[x] += 1 else: X[x] = 1 if y in Y: Y[y] += 1 else: Y[y] = 1 X = [(i, X[i]) fo...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR VAR VAR NUM...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
a = [0] * 8 for i in range(8): a[i] = list(map(int, input().split(" "))) x = [] y = [] for i in range(8): if a[i][0] not in x: x.append(a[i][0]) if a[i][1] not in y: y.append(a[i][1]) if len(x) != 3 or len(y) != 3: print("ugly") exit() x.sort() y.sort() l = [0] * 8 index = 0 for i in...
ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF ...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
a = [] xDistinct = [] yDistinct = [] for i in range(0, 8): [n1, n2] = map(int, input().split()) a.append([n1, n2]) if n1 not in xDistinct: xDistinct.append(n1) if n2 not in yDistinct: yDistinct.append(n2) countDistinctX = len(xDistinct) countDistinctY = len(yDistinct) if countDistinctX !...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN LIST VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VA...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
import sys pair = [] xs = [] ys = [] for i in range(8): x, y = map(int, input().split()) pair.append((x, y)) if x not in xs: xs.append(x) if y not in ys: ys.append(y) if len(xs) != 3 or len(ys) != 3: print("ugly") else: xs.sort() ys.sort() for i in range(len(xs)): ...
IMPORT ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR ...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
X = [] Y = [] Points = [] k = False for i in range(8): x, y = map(int, input().split()) X.append(x) Y.append(y) if [x, y] in Points: k = True Points.append([x, y]) X.sort() Y.sort() if len(set(X)) != 3 or len(set(Y)) != 3 or k: print("ugly") elif X.count(X[0]) != 3 or X.count(X[3]) != 2 ...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF LIST VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR IF FUNC_CALL V...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
x = [] y = [] for _ in range(8): point = input().split() x.append(int(point[0])) y.append(int(point[1])) unique = [] for i in range(8): if (x[i], y[i]) in unique: print("ugly") quit() else: unique.append((x[i], y[i])) x.sort() if ( x[0] == x[1] == x[2] and x[2] != x[3...
ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
lis = [] for i in range(8): a, b = map(int, input().split()) s = a, b if s in lis: print("ugly") exit() lis.append(s) lis = sorted(lis) arr = [[], [], []] for i in range(8): p = lis[i] if i < 3: arr[0].append(p) elif i < 5: arr[1].append(p) else: a...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST LIST LIST LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBE...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
class point: def __init__(self, x=0, y=0): self.x = x self.y = y x = [] y = [] a = [] for i in range(8): u, v = map(int, input().split()) a.append(point(u, v)) if u not in x: x.append(u) if v not in y: y.append(v) if len(x) != 3 or len(y) != 3: print("ugly") ...
CLASS_DEF FUNC_DEF NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL V...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
def check(x): iks = [] ygrek = [] for i in x: if i[0] not in iks: iks.append(i[0]) if i[1] not in ygrek: ygrek.append(i[1]) if len(iks) != 3 or len(ygrek) != 3: return False iks.sort() ygrek.sort() for i in range(8): if x[i] == (iks[1],...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER RETU...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
d = [{}, {}] t = [] for i in range(8): x, y = [int(x) for x in input().split()] if [x, y] in t: print("ugly") exit() t.append([x, y]) if x not in d[0]: d[0][x] = 1 else: d[0][x] += 1 if y not in d[1]: d[1][y] = 1 else: d[1][y] += 1 if len(d[0])...
ASSIGN VAR LIST DICT DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF LIST VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR NUMBER ASSI...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
class point: def __init__(self, x, y): self.x = x self.y = y def _input(): N = 8 point_sets = [] for i in range(0, N): x, y = map(int, input().split()) point_sets.append(point(x, y)) return point_sets def eight_point_sets(point_sets): t = point_sets[:] t....
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER FUNC_CALL VAR ...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
from sys import stderr a = [tuple(map(int, input().split())) for i in range(8)] x = sorted(list(set([i[0] for i in a]))) y = sorted(list(set([i[1] for i in a]))) print(a, file=stderr) print(x, y, file=stderr) if len(x) != 3 or len(y) != 3: print("ugly") else: ans = "respectable" for i in x: for j i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBE...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
points_set = [] for i in range(8): points_set.append([int(i) for i in input().split()]) x_list = [] y_list = [] x_count = 0 y_count = 0 points_set.sort(key=lambda x: (x[0], x[1])) for i in points_set: if i[0] not in x_list: x_list.append(i[0]) x_count += 1 if i[1] not in y_list: y_li...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CA...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
from sys import stdin, stdout nmbr = lambda: int(stdin.readline()) lst = lambda: list(map(int, stdin.readline().split())) for _ in range(1): mp = {} sx = set() sy = set() f = 1 for i in range(8): a, b = lst() sx.add(a) sy.add(b) mp[a, b] = 1 if len(sx) != 3 or le...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR V...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
import sys a = [] b = [] for i in range(8): x, y = [int(k) for k in input().split()] a.append(x) b.append(y) seta = set(a) setb = set(b) if len(seta) == 3 and len(setb) == 3: x = sorted(seta) y = sorted(setb) point = [] for i in range(8): point.append((a[i], b[i])) if (x[1], y[1...
IMPORT ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIG...
Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, except for the average of these nine points. In other words, there must be three int...
class Point: def __init__(self, x=0, y=0): self.x = x self.y = y points = [] xs = [] ys = [] is_exist = False for _ in range(8): x, y = map(int, input().split()) xs.append(x) ys.append(y) for point in points: if point.x == x and point.y == y: is_exist = True ...
CLASS_DEF FUNC_DEF NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASS...