Python Code def fibonacci(num): result = 0 if num == 0: result = 0 elif num == 1: result = 1 elif num >= 2: result = fibonacci(num-1) + fibonacci(num-2) ret...
Python Code def factorial(num): result = 1 while num > 1: result = num * result num = num-1 return result n = int(input()) print(factorial(n))
Python Code T = int(input()) for tc in range(1, T+1): x_list = [] y_list = [] resultx = resulty = 0 for _ in range(3): x, y = map(int, input().split()) x_list.append(x)...
Python Code M = int(input()) N = int(input()) result = [] for i in range(M, N+1): flag = 0 if i > 1: for j in range(2, i): if i % j == 0: flag = 1 ...
Python Code N = int(input()) numbers = list(map(int, input().split())) cnt = 0 for i in range(N): flag = 0 if numbers[i] > 1: for j in range(2, numbers[i]): if numbers[i] %...
Python Code import sys sys.stdin = open('input.txt') T = int(input()) for tc in range(1, T+1): A, B, C = map(int, input().split()) if B>=C: print(-1) else: print(int(A/(C-B...
Python Code def solve(a): sum = 0 for i in range(len(a)): sum += a[i] return sum
Python Code T = int(input()) for tc in range(1, T+1): numbers = { 'A': 2, 'B': 2, 'C': 2, 'D': 3, 'E': 3, 'F': 3, 'G': 4, 'H': 4, ...
Python Code T = int(input()) for tc in range(1, T+1): score = list(map(int, input().split())) num = score.pop(0) sum = 0 for i in range(len(score)): sum += score[i] avg = s...
Python Code T = int(input()) for tc in range(1, T+1): alphabet = ['c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z='] word = input() cnt = 0 for i in range(len(alphabet)): if alph...
Python code T = int(input()) for tc in range(1, T+1): N = int(input()) cnt = 0 for i in range(N): word = input() use = [] flag = 1 for i in range(len(word))...
Python Code T = int(input()) for tc in range(1, T+1): string = list(input()) result = [] for i in range(len(string)): if string.count(string[i]) % 2: if string[i] not i...
Python Code import sys N, M = map(int, input().split()) name_dict = {} num_dict = {} num = 1 for _ in range(N): name = str(sys.stdin.readline()).strip() name_dict[num] = name num_dict[name...
Python Code import sys M = int(sys.stdin.readline()) S = set() for _ in range(M): command = sys.stdin.readline().strip().split() if len(comma
Python Code T = int(input()) for tc in range(1, T+1): N = int(input()) time = [] checked = [0 for _ in range(25)] total = 0 for _ in range(N): s, e = map(int, input().split...
Python Code T = int(input()) for tc in range(1, T+1): N = int(input()) time = [] checked = [0 for _ in range(25)] total = 0 for _ in range(N): s, e = map(int, input().split...
Python Code T = int(input()) for tc in range(1, T+1): N, M = map(int, input().split()) box = list(map(int, input().split())) truck = list(map(int, input().split())) box.sort() box....
Python Code password = { '0001101': 0, '0011001': 1, '0010011': 2, '0111101': 3, '0100011': 4, '0110001': 5, '0101111': 6, '0111011': 7, '0110111': 8, '0001011'...
Python code T = int(input()) for tc in range(1, T+1): D, L, N = map(int, input().split()) n = 0 damage = 0 for i in range(N): damage += D * (1 + i * L * 1/100) print('#{} {...