├── 2844.py ├── 2874.py ├── 2813.py ├── 2058.py ├── 2839.py ├── 2443.py ├── 2374.py ├── 2413.py ├── 2753.py ├── 2791.py ├── 2408.py ├── 2423.py ├── 2787.py ├── 2679.py ├── 2841.py ├── 2510.py ├── 2160.py ├── 2581.py ├── 2802.py ├── 2861.py ├── 1708.py ├── 2766.py ├── 2651.py ├── natal2018 ├── a.py ├── b.py ├── e.py ├── f.py ├── c.py └── d.py ├── 1986.py ├── 2339.py ├── 1631.py ├── 2668.py ├── 2780.py ├── 2826.py ├── 1593.py ├── 1807.py ├── 2172.py ├── 2232.py ├── 2437.py ├── 2454.py ├── 2295.py ├── 2345.py ├── 2410.py ├── 2469.py ├── 2418.py ├── 2587.py ├── 1492.py ├── 2409.py ├── 2460.py ├── 2500.py ├── 2755.py ├── 1609.py ├── 2176.py ├── 2598.py ├── 2717.py ├── 2729.py ├── 1958.py ├── 2375.py ├── 2395.py ├── 2840.py ├── 1173.py ├── 2166.py ├── 2217.py ├── 2161.py ├── 2334.py ├── 2427.py ├── 2867.py ├── 1235.py ├── 1308.py ├── 2424.py ├── 1120.py ├── 1837.py ├── 2174.py ├── 2218.py ├── 2394.py ├── 2591.py ├── 2765.py ├── 2497.py ├── 2866.py ├── 2903.py ├── 2779.py ├── 2862.py ├── 1871.py ├── 2381.py ├── 2653.py ├── 2760.py ├── 2896.py ├── 1323.py ├── 1393.py ├── 2252.py ├── 2776.py ├── 2157.py ├── 2251.py ├── 2355.py ├── 2373.py ├── 2453.py ├── 2455.py ├── 2456.py ├── 1890.py ├── 2023.py ├── 2315.py ├── 2344.py ├── 2434.py ├── 2702.py ├── 2167.py ├── 2435.py ├── 2457.py ├── 2473.py ├── 2756.py ├── 2782.py ├── 2803.py ├── 1321.py ├── 1715.py ├── 2444.py ├── 2829.py ├── 1962.py ├── 2544.py ├── 2722.py ├── 2762.py ├── 2808.py ├── 2242.py ├── 2369.py ├── 2401.py ├── 2815.py ├── 1199.py ├── 1556.py ├── 1980.py ├── 2311.py ├── 2322.py ├── 2138.py ├── 2351.py ├── 2763.py ├── 2864.py ├── 2582.py ├── 1429.py ├── 1540.py ├── 1893.py ├── 2342.py ├── 2356.py ├── 2663.py ├── 1213.py ├── 2003.py ├── 2062.py ├── 2150.py ├── 2807.py ├── 1244.py ├── 2548.py ├── 2650.py ├── 2670.py ├── 2714.py ├── 1553.py ├── 2694.py ├── 2846.py ├── 1512.py ├── 2516.py ├── 1983.py ├── 2175.py ├── 2523.py ├── 1940.py ├── 2137.py ├── 2515.py ├── 2747.py ├── 1029.py ├── 1241.py ├── 2518.py ├── 2049.py ├── 2540.py ├── 1237.py ├── 1532.py ├── 1581.py ├── 2764.py ├── 2863.py ├── 1285.py ├── 1632.py ├── 1755.py ├── 1943.py ├── 2238.py ├── 2415.py ├── 2682.py ├── 2686.py ├── 2916.py ├── 1901.py ├── 2378.py ├── 2482.py ├── 2869.py ├── 1247.py ├── 1515.py ├── 2029.py ├── 2084.py ├── 2495.py ├── 2757.py ├── 1410.py ├── 2718.py ├── 1307.py ├── 1533.py ├── 1619.py ├── 2162.py ├── 2547.py ├── 2761.py ├── 1276.py ├── 2149.py ├── 2247.py ├── 2514.py ├── 2343.py ├── 2479.py ├── 1371.py ├── 2170.py ├── 2533.py ├── 2543.py ├── 2189.py ├── 2235.py ├── 1548.py ├── 2108.py ├── 2143.py ├── 2708.py ├── 1228.py ├── 2692.py ├── 2748.py ├── 2812.py ├── 1987.py ├── 2168.py ├── 1034.py ├── 1196.py ├── 2588.py ├── 2693.py ├── 2850.py ├── 1074.py ├── 2397.py ├── 2845.py ├── 2847.py ├── 2868.py ├── 1104.py ├── 2203.py ├── 2690.py ├── 2771.py ├── 1259.py ├── 1768.py ├── 1873.py ├── 2727.py ├── 1030.py ├── 1089.py ├── 1291.py ├── 2534.py ├── 2754.py ├── 2770.py ├── 1129.py ├── 2569.py ├── 1869.py ├── 2496.py ├── 2590.py ├── 2600.py ├── 1457.py ├── 1973.py ├── 2158.py ├── 2715.py ├── 1162.py ├── 1441.py ├── 2719.py ├── README.md ├── 1105.py ├── 1364.py ├── 2248.py ├── 1281.py ├── 2685.py ├── 1267.py ├── 1845.py ├── 2633.py ├── 2828.py ├── 1682.py ├── 2025.py ├── 2630.py ├── 1068.py ├── 1549.py ├── 1554.py ├── 2180.py ├── 2152.py ├── 1263.py ├── 1248.py ├── 2222.py ├── 2596.py ├── 2153.py ├── 2126.py ├── 2187.py ├── 1261.py ├── 1471.py ├── 1296.py ├── 1306.py ├── 1861.py ├── 2227.py ├── 2136.py ├── 2549.py ├── 2221.py ├── 2286.py ├── 2154.py ├── 1676.py ├── 1025.py ├── 1430.py ├── 2520.py ├── 2557.py ├── 2773.py ├── 1110.py ├── 1558.py ├── 2059.py ├── 2292.py ├── 1516.py ├── 2640.py ├── 1785.py ├── 2310.py ├── 2027.py ├── 2484.py ├── 2542.py ├── 2087.py ├── 2583.py ├── 1847.py ├── 1953.py ├── 1256.py ├── 2535.py ├── 1309.py ├── 1383.py ├── 2478.py ├── 1867.py ├── 1310.py ├── 1448.py ├── 2530.py ├── 2486.py ├── 2710.py ├── 2751.py ├── 1278.py ├── 2774.py ├── 1629.py ├── 2134.py ├── 2570.py ├── 2028.py ├── 1219.py ├── 1218.py ├── 1292.py ├── 1786.py ├── 1661.py ├── 1367.py ├── 1262.py ├── 1093.py ├── 1295.py ├── 1566.py ├── 2920.py ├── 1193.py ├── 1222.py ├── 1277.py ├── 1279.py ├── 1212.py ├── 2031.py ├── 2749.py ├── 1022.py ├── 2144.py ├── 2712.py ├── 2508.py ├── 2140.py ├── 1304.py ├── 2139.py ├── 2551.py ├── 2135.py ├── 1031.py ├── 1124.py ├── 1239.py ├── 2674.py ├── 1827.py ├── 2728.py ├── 2253.py ├── 1451.py ├── 1287.py ├── 2338.py ├── 2567.py ├── 1875.py ├── 2040.py ├── 1311.py ├── 1763.py ├── 2750.py ├── 1243.py ├── 1514.py ├── 2678.py └── 2163.py /2844.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2874.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2813.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | -------------------------------------------------------------------------------- /2058.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | print(n-2) -------------------------------------------------------------------------------- /2839.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | print(n+1) 3 | -------------------------------------------------------------------------------- /2443.py: -------------------------------------------------------------------------------- 1 | a, b, c, d = [int(x) for x in input().split()] 2 | -------------------------------------------------------------------------------- /2374.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | m = int(input()) 3 | print(n-m) -------------------------------------------------------------------------------- /2413.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | t = t * 2 * 2 3 | print(t) 4 | -------------------------------------------------------------------------------- /2753.py: -------------------------------------------------------------------------------- 1 | for i in range(97, 123): 2 | print('%d e %c'%(i, chr(i))) -------------------------------------------------------------------------------- /2791.py: -------------------------------------------------------------------------------- 1 | feijao = input().split() 2 | print(feijao.index('1')+1) 3 | -------------------------------------------------------------------------------- /2408.py: -------------------------------------------------------------------------------- 1 | p = [int(x) for x in input().split()] 2 | print(sorted(p)[1]) 3 | -------------------------------------------------------------------------------- /2423.py: -------------------------------------------------------------------------------- 1 | a, b, c = [int(x) for x in input().split()] 2 | print(min(a//2, b//3, c//5)) 3 | -------------------------------------------------------------------------------- /2787.py: -------------------------------------------------------------------------------- 1 | l = int(input()) % 2 2 | c = int(input()) % 2 3 | 4 | print(int(l == c)) 5 | -------------------------------------------------------------------------------- /2679.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | if n % 2 == 0: 3 | print(n+2) 4 | else: 5 | print(n+1) -------------------------------------------------------------------------------- /2841.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | anim = 0 3 | anim = sum(int(x) for x in input().split()) 4 | -------------------------------------------------------------------------------- /2510.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | n -= 1 4 | c = input() 5 | print('Y') -------------------------------------------------------------------------------- /2160.py: -------------------------------------------------------------------------------- 1 | nome = input() 2 | 3 | if(len(nome) < 81): 4 | print('YES') 5 | else: 6 | print('NO') -------------------------------------------------------------------------------- /2581.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | for i in range(0, n): 3 | input() 4 | print("I am Toorg!") 5 | -------------------------------------------------------------------------------- /2802.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | n = ((n/24.0)*(n*n*n - 6*n*n + 23*n - 18)) + 1 3 | print("%.0f" % n) 4 | -------------------------------------------------------------------------------- /2861.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | c = input() 4 | print('gzuz') 5 | n -= 1 6 | -------------------------------------------------------------------------------- /1708.py: -------------------------------------------------------------------------------- 1 | import math 2 | x, y = input().split() 3 | x = int(y)-int(x) 4 | x = math.ceil(int(y)/x) 5 | print(x) -------------------------------------------------------------------------------- /2766.py: -------------------------------------------------------------------------------- 1 | l = [] 2 | for i in range(10): 3 | l.append(input()) 4 | print(l[2]) 5 | print(l[6]) 6 | print(l[8]) -------------------------------------------------------------------------------- /2651.py: -------------------------------------------------------------------------------- 1 | c = input() 2 | if 'zelda' in c.lower(): 3 | print('Link Bolado') 4 | else: 5 | print('Link Tranquilo') -------------------------------------------------------------------------------- /natal2018/a.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | a = 'Ent' + 'a' * n + 'o eh N' + 'a' * n + 't' + 'a' * n + 'l!' 3 | print(a) 4 | -------------------------------------------------------------------------------- /1986.py: -------------------------------------------------------------------------------- 1 | n = input() 2 | m = '' 3 | e = ''.join(input().split()) 4 | m = (''.join(chr(i) for i in e)) 5 | 6 | print(m) 7 | -------------------------------------------------------------------------------- /2339.py: -------------------------------------------------------------------------------- 1 | c, p, f = input().split() 2 | if(int(c) * int(f) <= int(p)): 3 | print('S') 4 | else: 5 | print('N') 6 | -------------------------------------------------------------------------------- /1631.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n = int(input()) 3 | if n == 0: 4 | break 5 | for i in range(n): 6 | 7 | -------------------------------------------------------------------------------- /2668.py: -------------------------------------------------------------------------------- 1 | from math import sqrt, pow 2 | a, b, n, k = [int(x) for x in input().split()] 3 | x = (a + sqrt(b))**n 4 | print(x) 5 | -------------------------------------------------------------------------------- /2780.py: -------------------------------------------------------------------------------- 1 | d = int(input()) 2 | if d <= 800: 3 | print(1) 4 | elif d <= 1400: 5 | print(2) 6 | else: 7 | print(3) 8 | -------------------------------------------------------------------------------- /2826.py: -------------------------------------------------------------------------------- 1 | a = input() 2 | b = input() 3 | l = [] 4 | l.append(a) 5 | l.append(b) 6 | l.sort() 7 | for x in l: 8 | print(x) 9 | -------------------------------------------------------------------------------- /1593.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | while t: 3 | t -= 1 4 | i = input() 5 | qt = bin(int(i)).count('1') 6 | print(qt) 7 | -------------------------------------------------------------------------------- /1807.py: -------------------------------------------------------------------------------- 1 | r = int(input()) 2 | # r = (3**r)%2147483647 3 | # r = power(3, r)%2147483647 4 | r = pow(3, r, 2147483647) 5 | print(r) 6 | -------------------------------------------------------------------------------- /2172.py: -------------------------------------------------------------------------------- 1 | while True: 2 | x, m = input().split() 3 | if(x == '0' and m == '0'): 4 | break 5 | print(int(x)*int(m)) -------------------------------------------------------------------------------- /2232.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | while t: 3 | t -= 1 4 | n = int(input()) 5 | soma = (1 << n) - 1 6 | print(soma) 7 | -------------------------------------------------------------------------------- /2437.py: -------------------------------------------------------------------------------- 1 | x1, y1, x2, y2 = input().split() 2 | distancia = (abs(int(x2) - int(x1))) + (abs(int(y2) - int(y1))) 3 | print(distancia) 4 | -------------------------------------------------------------------------------- /2454.py: -------------------------------------------------------------------------------- 1 | n, m = input().split() 2 | if n == '0': 3 | print('C') 4 | elif m == '0': 5 | print('B') 6 | else: 7 | print('A') -------------------------------------------------------------------------------- /2295.py: -------------------------------------------------------------------------------- 1 | a, g, ra, rg = [float(x) for x in input().split()] 2 | if (ra/a) <= (rg/g): 3 | print('G') 4 | else: 5 | print('A') 6 | -------------------------------------------------------------------------------- /2345.py: -------------------------------------------------------------------------------- 1 | jog = [int(x) for x in input().split()] 2 | jog.sort() 3 | dif = abs((jog[0] + jog[3]) - (jog[1] + jog[2])) 4 | print(dif) 5 | -------------------------------------------------------------------------------- /2410.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | l = [] 3 | while n: 4 | n -= 1 5 | l.append(int(input())) 6 | 7 | l = set(l) 8 | print(len(l)) 9 | -------------------------------------------------------------------------------- /2469.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | notas = input().split() 4 | maiscomum = max(set(notas), key=notas.count) 5 | 6 | print(maiscomum) 7 | -------------------------------------------------------------------------------- /2418.py: -------------------------------------------------------------------------------- 1 | nota = [float(x) for x in input().split()] 2 | nota.sort() 3 | final = sum(nota) - nota[0] - nota[-1] 4 | print("%.1f" % final) 5 | -------------------------------------------------------------------------------- /2587.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | for i in range(n): 4 | a1 = input() 5 | a2 = input() 6 | ans = input() 7 | print(a1, a2, ans) -------------------------------------------------------------------------------- /1492.py: -------------------------------------------------------------------------------- 1 | from collections import Counter 2 | a, b = [int(x) for x in input().split()] 3 | b1 = bin(a) 4 | b2 = bin(b) 5 | print(b1) 6 | print(b2) 7 | -------------------------------------------------------------------------------- /2409.py: -------------------------------------------------------------------------------- 1 | colc = sort([int(i) for i in input().split()]) 2 | porta = sort([int(i) for i in input().split()]) 3 | if colc[2] <= porta[1] and colc 4 | -------------------------------------------------------------------------------- /2460.py: -------------------------------------------------------------------------------- 1 | n = input() 2 | f = input().split() 3 | m = input() 4 | s = input().split() 5 | for p in s: 6 | f.remove(p) 7 | print(' '.join(f)) 8 | -------------------------------------------------------------------------------- /2500.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n, m, k = [int(x) for x in input().split()] 3 | if n == m == k == 0: 4 | break 5 | s = [] 6 | 7 | -------------------------------------------------------------------------------- /2755.py: -------------------------------------------------------------------------------- 1 | print('"Ro\'b\'er\tto\\/"') 2 | print('(._.) ( l: ) ( .-. ) ( :l ) (._.)') 3 | print('(^_-) (-_-) (-_^)') 4 | print('("_") (\'.\')') 5 | -------------------------------------------------------------------------------- /1609.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | while t > 0: 3 | t -= 1 4 | n = int(input()) 5 | c = [int(x) for x in input().split()] 6 | print(len(set(c))) -------------------------------------------------------------------------------- /2176.py: -------------------------------------------------------------------------------- 1 | message = input() 2 | one = 0 3 | 4 | for i in message: 5 | if i == '1': 6 | one += 1 7 | 8 | print(message + str(one % 2)) 9 | -------------------------------------------------------------------------------- /2598.py: -------------------------------------------------------------------------------- 1 | import math 2 | c = int(input()) 3 | 4 | while(c > 0): 5 | c -= 1 6 | n, m = input().split() 7 | print(math.ceil(float(n)/float(m))) -------------------------------------------------------------------------------- /2717.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | a, b = input().split() 3 | if(int(a)+int(b) <= n): 4 | print('Farei hoje!') 5 | else: 6 | print('Deixa para amanha!') -------------------------------------------------------------------------------- /2729.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | for i in range(n): 3 | a = input().split() 4 | a = sorted(set(a)) 5 | print(' '.join(str(j) for j in a)) 6 | -------------------------------------------------------------------------------- /1958.py: -------------------------------------------------------------------------------- 1 | from decimal import Decimal 2 | a = input() 3 | if Decimal(a) >= 0 and a[0] != '-': 4 | print('+', end='') 5 | 6 | print('%.4E' % Decimal(a)) -------------------------------------------------------------------------------- /2375.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | a, b, c = input().split() 3 | if n <= int(a) and n <= int(b) and n <= int(c): 4 | print('S') 5 | else: 6 | print('N') 7 | -------------------------------------------------------------------------------- /2395.py: -------------------------------------------------------------------------------- 1 | a, b, c = [int(i) for i in input().split()] 2 | x, y, z = [int(i) for i in input().split()] 3 | n = int(x/a) * int(y/b) * int(z/c) 4 | print(n) 5 | -------------------------------------------------------------------------------- /2840.py: -------------------------------------------------------------------------------- 1 | import math 2 | pi = 3.1415 3 | r, l = input().split() 4 | r = float(r) 5 | volume = ((4.0*pi*r*r*r)/3.0) 6 | print(math.floor(float(l)/volume)) 7 | -------------------------------------------------------------------------------- /1173.py: -------------------------------------------------------------------------------- 1 | n = [] 2 | v = int(input()) 3 | n.append([v*x*2 for x in range(1,11)]) 4 | print(n) 5 | for i in range(len(n)): 6 | print('N[%d] = %d' % (i, n[i])) 7 | -------------------------------------------------------------------------------- /2166.py: -------------------------------------------------------------------------------- 1 | def r2(n): 2 | if n == 0: 3 | return 2 4 | x = 2+1/r2(n-1) 5 | return x 6 | 7 | n = int(input()) 8 | x = r2(n)-1 9 | print('%.10f' % x) -------------------------------------------------------------------------------- /2217.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | n -= 1 4 | m = int(input()) 5 | if m % 2 == 0: 6 | print(1) 7 | else: 8 | print(9) -------------------------------------------------------------------------------- /2161.py: -------------------------------------------------------------------------------- 1 | def r10(n): 2 | if n == 0: 3 | return 6 4 | x = 6+1/r10(n-1) 5 | return x 6 | 7 | n = int(input()) 8 | x = r10(n)-3 9 | print('%.10f' % x) -------------------------------------------------------------------------------- /2334.py: -------------------------------------------------------------------------------- 1 | while True: 2 | i = int(input()) 3 | if i == -1: 4 | break 5 | if i == 0: 6 | print(0) 7 | else: 8 | print(i - 1) 9 | -------------------------------------------------------------------------------- /2427.py: -------------------------------------------------------------------------------- 1 | l = float(input()) 2 | n = 1 3 | i = 1 4 | while l >= 2.0: 5 | print(l) 6 | l /= 2 7 | n += i 8 | i += 1 9 | 10 | print(2**n) 11 | -------------------------------------------------------------------------------- /2867.py: -------------------------------------------------------------------------------- 1 | c = int(input()) 2 | while c: 3 | c -= 1 4 | n, m = [int(x) for x in input().split()] 5 | n = str(n ** m) 6 | print(n) 7 | print(len(n)) 8 | -------------------------------------------------------------------------------- /1235.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | while(n > 0): 4 | n -= 1 5 | c = input() 6 | m = int(len(c)/2) -1 7 | out = c[m::-1] + c[len(c)-1:m:-1] 8 | print(out) -------------------------------------------------------------------------------- /1308.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | n = int(input()) 3 | 4 | while n: 5 | n -= 1 6 | m = int(input()) 7 | m = int((sqrt(1 + 8*m) - 1) / 2) 8 | print(m) 9 | -------------------------------------------------------------------------------- /2424.py: -------------------------------------------------------------------------------- 1 | x, y = input().split() 2 | x = int(x) 3 | y = int(y) 4 | if x >= 0 and y >= 0 and x < 433 and y < 469: 5 | print('dentro') 6 | else: 7 | print('fora') 8 | -------------------------------------------------------------------------------- /1120.py: -------------------------------------------------------------------------------- 1 | while(True): 2 | d, n = input().split() 3 | if(d == '0' and n == '0'): 4 | break 5 | n = '0' + n 6 | val = int(n.replace(d,'')) 7 | print(val) -------------------------------------------------------------------------------- /1837.py: -------------------------------------------------------------------------------- 1 | a, b = [int(x) for x in input().split()] 2 | for r in range(abs(b)): 3 | if ((a - r) % b) == 0: 4 | q = int((a - r)/b) 5 | break 6 | print(q, r) 7 | -------------------------------------------------------------------------------- /2174.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | pom = [] 3 | for i in range(n): 4 | pom.append(input()) 5 | 6 | pom = set(pom) 7 | l = 151 - len(pom) 8 | print('Falta(m) %d pomekon(s).' % l) -------------------------------------------------------------------------------- /2218.py: -------------------------------------------------------------------------------- 1 | f = [1] 2 | for i in range(1, 2**16): 3 | f.append(i+f[i-1]) 4 | 5 | n = int(input()) 6 | 7 | for i in range(n): 8 | m = int(input()) 9 | print(f[m]) -------------------------------------------------------------------------------- /2394.py: -------------------------------------------------------------------------------- 1 | n, m = [int(i) for i in input().split()] 2 | j = [] 3 | while n: 4 | n -= 1 5 | j.append(sum([int(i) for i in input().split()])) 6 | print(j.index(min(j))+1) 7 | -------------------------------------------------------------------------------- /2591.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | n -= 1 4 | c = input().split('me') 5 | a = (c[0].count('a') * c[1].count('a')) * 'a' 6 | print('k%s' % a) 7 | -------------------------------------------------------------------------------- /2765.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | c = input() 4 | c = c.split(',') 5 | for i in c: 6 | print(i) 7 | except EOFError: 8 | break -------------------------------------------------------------------------------- /2497.py: -------------------------------------------------------------------------------- 1 | n = 1 2 | while(True): 3 | i = int(input()) 4 | if(i == -1): 5 | break 6 | i //= 2 7 | print('Experiment %d: %d full cycle(s)' % (n, i)) 8 | n += 1 -------------------------------------------------------------------------------- /2866.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | n -= 1 4 | c = input() 5 | saida = ''.join(s for s in c if s.islower()) 6 | saida = saida[::-1] 7 | print(saida) 8 | -------------------------------------------------------------------------------- /2903.py: -------------------------------------------------------------------------------- 1 | r = float(input()) 2 | i = 1 3 | if 360 % (i * r) != 0: 4 | while (i * r) % 360 != 0: 5 | i += 1 6 | else: 7 | i = int(360/r) 8 | 9 | print(i) 10 | -------------------------------------------------------------------------------- /2779.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | m = int(input()) 3 | fig = [0] * n 4 | while m: 5 | m -= 1 6 | fig[int(input()) - 1] = 1 7 | 8 | falta = fig.count(0) 9 | print(falta) 10 | -------------------------------------------------------------------------------- /2862.py: -------------------------------------------------------------------------------- 1 | c = int(input()) 2 | while c > 0: 3 | c -= 1 4 | n = int(input()) 5 | if n > 8000: 6 | print('Mais de 8000!') 7 | else: 8 | print('Inseto!') 9 | -------------------------------------------------------------------------------- /1871.py: -------------------------------------------------------------------------------- 1 | while(True): 2 | m, n = input().split() 3 | if(m == '0' and n == '0'): 4 | break 5 | m = int(m) + int(n) 6 | val = int(str(m).replace('0','')) 7 | print(val) -------------------------------------------------------------------------------- /2381.py: -------------------------------------------------------------------------------- 1 | n, k = [int(x) for x in input().split()] 2 | alunos = [] 3 | 4 | while n: 5 | n -= 1 6 | alunos.append(input()) 7 | 8 | alunos.sort() 9 | print(alunos[k - 1]) 10 | -------------------------------------------------------------------------------- /2653.py: -------------------------------------------------------------------------------- 1 | l = [] 2 | 3 | while True: 4 | try: 5 | l.append(input()) 6 | 7 | except EOFError: 8 | break 9 | 10 | l = set(l) 11 | print(len(l)) -------------------------------------------------------------------------------- /2760.py: -------------------------------------------------------------------------------- 1 | a = input() 2 | b = input() 3 | c = input() 4 | print('%s%s%s' %(a, b, c)) 5 | print('%s%s%s' %(b, c, a)) 6 | print('%s%s%s' %(c, a, b)) 7 | print('%s%s%s'%(a[:10], b[:10], c[:10])) 8 | -------------------------------------------------------------------------------- /2896.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | while t > 0: 3 | t -= 1 4 | n, k = input().split() 5 | n = int(n) 6 | k = int(k) 7 | total = int(int(n % k) + int(n / k)) 8 | print(total) 9 | -------------------------------------------------------------------------------- /1323.py: -------------------------------------------------------------------------------- 1 | sq = [0] 2 | for i in range(1, 101): 3 | sq.append(i*i+sq[i-1]) 4 | 5 | while(True): 6 | n = int(input()) 7 | if(n == 0): 8 | break 9 | print(sq[n]) 10 | -------------------------------------------------------------------------------- /1393.py: -------------------------------------------------------------------------------- 1 | f = [0, 1] 2 | for i in range(2,42): 3 | f.append(f[i-1]+f[i-2]) 4 | f.pop(0) 5 | 6 | while True: 7 | n = int(input()) 8 | if n == 0: 9 | break 10 | print(f[n]) -------------------------------------------------------------------------------- /2252.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | v = input().split() 5 | r = v.sort() 6 | print(v) 7 | 8 | except EOFError: 9 | break 10 | -------------------------------------------------------------------------------- /2776.py: -------------------------------------------------------------------------------- 1 | n, m = [int(x) for x in input().split()] 2 | q = v = [] 3 | while n > 0: 4 | n -= 1 5 | entrada = input().split() 6 | q.append(int(entrada[0])) 7 | q.append(int(entrada[1])) 8 | -------------------------------------------------------------------------------- /2157.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while(n > 0): 3 | n -= 1 4 | b, e = input().split() 5 | s = '' 6 | for i in range(int(b), int(e)+1): 7 | s += str(i) 8 | s += s[::-1] 9 | print(s) -------------------------------------------------------------------------------- /2251.py: -------------------------------------------------------------------------------- 1 | teste = 1 2 | while True: 3 | n = int(input()) 4 | if n == 0: 5 | break 6 | print('Teste %d' % teste) 7 | print((2**n) - 1) 8 | print() 9 | teste += 1 10 | -------------------------------------------------------------------------------- /2355.py: -------------------------------------------------------------------------------- 1 | import math 2 | while True: 3 | n = int(input()) 4 | if n == 0: 5 | break 6 | bra = n/90 7 | ale = math.ceil((n*7)/90) 8 | print('Brasil %d x Alemanha %d' % (bra, ale)) 9 | -------------------------------------------------------------------------------- /2373.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | quebrados = 0 3 | while n > 0: 4 | n -= 1 5 | l, c = input().split() 6 | if int(c) < int(l): 7 | quebrados += int(c) 8 | 9 | print(quebrados) 10 | -------------------------------------------------------------------------------- /2453.py: -------------------------------------------------------------------------------- 1 | p = input() 2 | mensagem = '' 3 | for palavra in p.split(): 4 | for letra in range(1, len(palavra), 2): 5 | mensagem += palavra[letra] 6 | mensagem += ' ' 7 | print(mensagem[:-1]) 8 | -------------------------------------------------------------------------------- /2455.py: -------------------------------------------------------------------------------- 1 | p1, c1, p2, c2 = input().split() 2 | p1 = int(p1) * int(c1) 3 | p2 = int(p2) * int(c2) 4 | if p1 == p2: 5 | print(0) 6 | elif p1 > p2: 7 | print(-1) 8 | else: 9 | print(1) 10 | -------------------------------------------------------------------------------- /2456.py: -------------------------------------------------------------------------------- 1 | cartas = [int(x) for x in input().split()] 2 | 3 | if cartas == sorted(cartas): 4 | print('C') 5 | elif cartas == sorted(cartas, reverse=True): 6 | print('D') 7 | else: 8 | print('N') 9 | -------------------------------------------------------------------------------- /1890.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | while t: 3 | t -= 1 4 | c, d = [int(x) for x in input().split()] 5 | placas = (26**c) * (10**d) 6 | if placas == 1: 7 | placas = 0 8 | print(placas) 9 | -------------------------------------------------------------------------------- /2023.py: -------------------------------------------------------------------------------- 1 | l = [] 2 | while True: 3 | try: 4 | l.append(input()) 5 | 6 | except EOFError: 7 | break 8 | 9 | l = sorted(l, key=lambda s: s.lower()) 10 | print(l[len(l)-1]) -------------------------------------------------------------------------------- /2315.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | d0 = input().split() 3 | d1 = input().split() 4 | d0 = date(2007, int(d0[1]), int(d0[0])) 5 | d1 = date(2007, int(d1[1]), int(d1[0])) 6 | dif = d1 - d0 7 | print(dif.days) 8 | -------------------------------------------------------------------------------- /2344.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | if n == 0: 3 | print('E') 4 | elif n < 36: 5 | print('D') 6 | elif n < 61: 7 | print('C') 8 | elif n < 86: 9 | print('B') 10 | else: 11 | print('A') 12 | -------------------------------------------------------------------------------- /2434.py: -------------------------------------------------------------------------------- 1 | n, s = [int(x) for x in input().split()] 2 | menor = 1001 3 | 4 | while n: 5 | n -= 1 6 | s += int(input()) 7 | if s < menor: 8 | menor = s 9 | 10 | 11 | print(menor) 12 | -------------------------------------------------------------------------------- /2702.py: -------------------------------------------------------------------------------- 1 | d = [int(x) for x in input().split()] 2 | r = [int(x) for x in input().split()] 3 | 4 | i = 0 5 | for x in range(3): 6 | j = r[x] - d[x] 7 | if j > 0: 8 | i += j 9 | 10 | print(i) -------------------------------------------------------------------------------- /2167.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | r = [] 3 | r = input().split() 4 | q = 0 5 | 6 | for i in range(1, n): 7 | if (int(r[i-1]) > int(r[i])): 8 | q = i + 1 9 | break 10 | 11 | print(q) -------------------------------------------------------------------------------- /2435.py: -------------------------------------------------------------------------------- 1 | n1, d1, v1 = [int(x) for x in input().split()] 2 | n2, d2, v2 = [int(x) for x in input().split()] 3 | t1 = float(d1/v1) 4 | t2 = float(d2/v2) 5 | if t1 < t2: 6 | print(n1) 7 | else: 8 | print(n2) 9 | -------------------------------------------------------------------------------- /2457.py: -------------------------------------------------------------------------------- 1 | letra = input() 2 | palavra = input().split() 3 | total = 0.0 4 | for l in palavra: 5 | if letra in l: 6 | total += 1 7 | 8 | total /= len(palavra)/100 9 | 10 | print('%.1f' % total) 11 | -------------------------------------------------------------------------------- /2473.py: -------------------------------------------------------------------------------- 1 | flavinho = input().split() 2 | sorteado = input().split() 3 | resultado = ['azar', 'azar', 'azar', 'terno', 'quadra', 'quina', 'sena'] 4 | print(resultado[len(list(set(flavinho).intersection(sorteado)))]) 5 | -------------------------------------------------------------------------------- /2756.py: -------------------------------------------------------------------------------- 1 | print(' A') 2 | print(' B B') 3 | print(' C C') 4 | print(' D D') 5 | print(' E E') 6 | print(' D D') 7 | print(' C C') 8 | print(' B B') 9 | print(' A') -------------------------------------------------------------------------------- /2782.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | lista = [int(x) for x in input().split()] 3 | total = 1 4 | for x in range(2, n): 5 | if lista[x] - lista[x-1] != lista[x-1] - lista[x-2]: 6 | total += 1 7 | print(total) 8 | -------------------------------------------------------------------------------- /2803.py: -------------------------------------------------------------------------------- 1 | norte = ['roraima', 'acre', 'amapa', 'amazonas', 'para', 'rondonia', 'tocantins'] 2 | estado = input().lower() 3 | if estado in norte: 4 | print('Regiao Norte') 5 | else: 6 | print('Outra regiao') 7 | -------------------------------------------------------------------------------- /1321.py: -------------------------------------------------------------------------------- 1 | while True: 2 | a, b, c, x, y = [int(i) for i in input().split()] 3 | if a == b == c == x == y == 0: 4 | break 5 | p1 = sorted([a, b, c]) 6 | p2 = sorted([x, y]) 7 | print(p1, p2) 8 | -------------------------------------------------------------------------------- /1715.py: -------------------------------------------------------------------------------- 1 | n, m = [int(x) for x in input().split()] 2 | total = 0 3 | while n: 4 | n -= 1 5 | gol = input().split() 6 | if gol.count('0') == 0: 7 | total += 1 8 | 9 | print(total) 10 | -------------------------------------------------------------------------------- /2444.py: -------------------------------------------------------------------------------- 1 | v, t = [int(x) for x in input().split()] 2 | t = input().split() 3 | for a in t: 4 | v += int(a) 5 | if v > 100: 6 | v = 100 7 | elif v < 0: 8 | v = 0 9 | 10 | print(v) 11 | -------------------------------------------------------------------------------- /2829.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | palavras = [] 3 | while n: 4 | n -= 1 5 | palavras.append(input()) 6 | 7 | palavras = sorted(sorted(palavras), key=str.lower) 8 | 9 | for i in palavras: 10 | print(i) 11 | -------------------------------------------------------------------------------- /1962.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | while(n): 4 | i = int(input()) 5 | i = 2015 - i 6 | if(i < 1): 7 | i = abs(i-1) 8 | print(i,"A.C.") 9 | else: 10 | print(i,"D.C.") 11 | n -= 1 -------------------------------------------------------------------------------- /2544.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | i = 0 5 | while(n > 1): 6 | n //= 2 7 | i += 1 8 | print(i) 9 | except EOFError: 10 | break -------------------------------------------------------------------------------- /2722.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n: 3 | n -= 1 4 | p1 = input() 5 | p2 = input() 6 | nome = '' 7 | for d in range(0, len(p1) - 1, 2): 8 | nome += p1[d:d+2] + p2[d:d+2] 9 | print(nome) 10 | -------------------------------------------------------------------------------- /2762.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | c = [int (x) for x in input().split('.')] 4 | c = c[::-1] 5 | c = '.'.join(str(x) for x in c) 6 | print(c) 7 | 8 | except EOFError: 9 | break -------------------------------------------------------------------------------- /2808.py: -------------------------------------------------------------------------------- 1 | i, d = input().split() 2 | col = abs(ord(i[0]) - ord(d[0])) 3 | lin = abs(int(i[1]) - int(d[1])) 4 | 5 | if (col == 1 and lin == 2) or (col == 2 and lin == 1): 6 | print('VALIDO') 7 | else: 8 | print('INVALIDO') 9 | -------------------------------------------------------------------------------- /2242.py: -------------------------------------------------------------------------------- 1 | r = input() 2 | comp = '' 3 | vowel = ['a', 'e', 'i', 'o', 'u'] 4 | for i in range(len(r)): 5 | if r[i] in vowel: 6 | comp += r[i] 7 | if(comp == comp[::-1]): 8 | print('S') 9 | else: 10 | print('N') -------------------------------------------------------------------------------- /2369.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | consumo = 7 3 | if n >= 101: 4 | consumo += (n - 100) * 5 + 160 5 | elif n >= 31: 6 | consumo += (n - 30) * 2 + 20 7 | elif n >= 11: 8 | consumo += n - 10 9 | 10 | print(consumo) 11 | -------------------------------------------------------------------------------- /2401.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | r = 1.0 3 | while n: 4 | n -= 1 5 | c = input().split() 6 | if c[1] == '*': 7 | r *= int(c[0]) 8 | elif c[1] == '/': 9 | r /= int(c[0]) 10 | 11 | print(int(r)) 12 | -------------------------------------------------------------------------------- /2815.py: -------------------------------------------------------------------------------- 1 | texto = input().split() 2 | for i in range(len(texto)): 3 | if len(texto[i]) > 3: 4 | if texto[i][0:1] == texto[i][2:3]: 5 | texto[i] = texto[i][2:] 6 | 7 | texto = ' '.join(texto) 8 | print(texto) 9 | -------------------------------------------------------------------------------- /1199.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n = input() 3 | if n == '-1': 4 | break 5 | if n.isdigit(): 6 | n = hex(int(n)) 7 | n = n[:2] + n[2:].upper() 8 | else: 9 | n = int(n, 16) 10 | print(n) 11 | -------------------------------------------------------------------------------- /1556.py: -------------------------------------------------------------------------------- 1 | from itertools import permutations 2 | while True: 3 | try: 4 | letras = input() 5 | possiveis = [''.join(p) for p in permutations(letras)] 6 | print(possiveis) 7 | except EOFError: 8 | break 9 | -------------------------------------------------------------------------------- /1980.py: -------------------------------------------------------------------------------- 1 | fat = [0, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000] 2 | 3 | while True: 4 | n = input() 5 | if n == '0': 6 | break 7 | print(fat[len(n)]) 8 | -------------------------------------------------------------------------------- /2311.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n: 3 | n -= 1 4 | nome = input() 5 | gd = float(input()) 6 | nota = [float(x) for x in input().split()] 7 | nota = sum(sorted(nota)[1:6]) * gd 8 | print('%s %.2f' % (nome, nota)) 9 | -------------------------------------------------------------------------------- /2322.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | lista = [int(x) for x in input().split()] 3 | lista.sort() 4 | for i in range(len(lista)): 5 | if lista[i] != (i + 1): 6 | break 7 | if lista[i] == (i + 1): 8 | i += 1 9 | print(i + 1) 10 | -------------------------------------------------------------------------------- /2138.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = input() 4 | m = [0] * 10 5 | for i in n: 6 | m[int(i)] += 1 7 | 8 | print(9 - m[::-1].index(max(m))) 9 | except EOFError: 10 | break 11 | -------------------------------------------------------------------------------- /2351.py: -------------------------------------------------------------------------------- 1 | n, k = [int(i) for i in input().split()] 2 | rooms = [int(i) for i in input().split()] 3 | rooms.sort(reverse=True) 4 | n = n//(k+1) 5 | k = sum(rooms[n:]) 6 | print(rooms[:n],'AAAAAAAAAAAAAAAAAAA', rooms[n:]) 7 | print(len(rooms[:n])) 8 | -------------------------------------------------------------------------------- /2763.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | cpf = input() 4 | cpf = cpf.replace('-', '.') 5 | cpf = cpf.split('.') 6 | for i in cpf: 7 | print(i) 8 | 9 | except EOFError: 10 | break -------------------------------------------------------------------------------- /2864.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | n -= 1 4 | a, b, c = input().split() 5 | a = int(a) 6 | b = int(b) 7 | c = int(c) 8 | x = - ( b / ( 2 * a ) ) 9 | y = a*x*x + b*x + c 10 | print("%.2f" % y) 11 | -------------------------------------------------------------------------------- /2582.py: -------------------------------------------------------------------------------- 1 | song = ['PROXYCITY','P.Y.N.G.','DNSUEY!','SERVERS','HOST!','CRIPTONIZE','OFFLINE DAY', 'SALT','ANSWER!','RAR?','WIFI ANTENNAS'] 2 | n = int(input()) 3 | while(n>0): 4 | n -= 1 5 | x, y = input().split() 6 | print(song[int(x)+int(y)]) -------------------------------------------------------------------------------- /1429.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | while(True): 4 | a = input() 5 | acm = 0 6 | if(a == '0'): 7 | break 8 | a = a[::-1] 9 | for i, j in enumerate(a): 10 | acm += int(j) * int(math.factorial(i+1)) 11 | print(acm) -------------------------------------------------------------------------------- /1540.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n: 3 | n -= 1 4 | a, b, c, d = [int(x) for x in input().split()] 5 | taxa = float((d-b)/(c-a)) 6 | taxa = str('%.3f' % taxa).replace('.', ',') 7 | taxa = taxa[:len(taxa) - 1] 8 | print((taxa)) 9 | -------------------------------------------------------------------------------- /1893.py: -------------------------------------------------------------------------------- 1 | n, m = input().split() 2 | n = int(n) 3 | m = int(m) 4 | if(m <= 2 and m >= 0): 5 | print('nova') 6 | elif(m <= 100 and m >= 97): 7 | print('cheia') 8 | elif(m > n): 9 | print('crescente') 10 | else: 11 | print('minguante') -------------------------------------------------------------------------------- /2342.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | p = input().split() 3 | if p[1] == '+': 4 | resultado = int(p[0]) + int(p[2]) 5 | else: 6 | resultado = int(p[0]) * int(p[2]) 7 | 8 | if resultado > n: 9 | print('OVERFLOW') 10 | else: 11 | print('OK') 12 | -------------------------------------------------------------------------------- /2356.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | d = input() 4 | s = input() 5 | if s in d: 6 | print('Resistente') 7 | else: 8 | print('Nao resistente') 9 | 10 | except EOFError: 11 | break -------------------------------------------------------------------------------- /2663.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | k = int(input()) 3 | competidor = [int(input()) for x in range(n)] 4 | competidor.sort(reverse=True) 5 | total = k 6 | while total < n and competidor[total] == competidor[k-1]: 7 | total += 1 8 | 9 | print(total) 10 | -------------------------------------------------------------------------------- /natal2018/b.py: -------------------------------------------------------------------------------- 1 | a, c, x, y = [int(x) for x in input().split()] 2 | q = c - a - x - y - 1 3 | if q < 0: 4 | if x > y/2: 5 | print('Caio, a culpa eh sua!') 6 | else: 7 | print('Igor bolado!') 8 | else: 9 | print('Igor feliz!') 10 | -------------------------------------------------------------------------------- /1213.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = input() 4 | l = 1 5 | c = 1 6 | while l % int(n) != 0: 7 | l = (10 * l + 1) % int(n) 8 | c += 1 9 | print(c) 10 | 11 | except EOFError: 12 | break 13 | -------------------------------------------------------------------------------- /2003.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | hora = input().split(':') 4 | n = int(hora[0])*60 + int(hora[1]) - 420 5 | if n < 0: 6 | n = 0 7 | print('Atraso maximo: %d' % n) 8 | 9 | except EOFError: 10 | break -------------------------------------------------------------------------------- /2062.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | w = input().split() 3 | 4 | for ind, i in enumerate(w): 5 | if(i[0:2]=='UR' and len(i)==3): 6 | w[ind] = 'URI' 7 | if(i[0:2]=='OB' and len(i)==3): 8 | w[ind] = 'OBI' 9 | 10 | i = ' '.join(w) 11 | print(i) -------------------------------------------------------------------------------- /2150.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | vogal = input() 4 | frase = input() 5 | total = 0 6 | for letra in vogal: 7 | total += frase.count(letra) 8 | print(total) 9 | 10 | except EOFError: 11 | break 12 | -------------------------------------------------------------------------------- /2807.py: -------------------------------------------------------------------------------- 1 | fib = [1, 1] 2 | for x in range(2, 41): 3 | fib.append(fib[x-1]+fib[x-2]) 4 | fib.sort(reverse=True) 5 | n = int(input()) 6 | palavra = '' 7 | for x in fib[41-n:]: 8 | palavra += str(x) + ' ' 9 | 10 | palavra = palavra[:-1] 11 | print(palavra) 12 | -------------------------------------------------------------------------------- /1244.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | n -= 1 4 | c = input().split() 5 | c.sort(key=len, reverse=True) 6 | for i in range(len(c)): 7 | print(c[i], end = '') 8 | if i != len(c)-1: 9 | print(' ', end = '') 10 | print() -------------------------------------------------------------------------------- /2548.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | l = [] 4 | n, m = input().split() 5 | l = [int(x) for x in input().split()] 6 | total = sum(l[int(n)-int(m):]) 7 | print(total) 8 | 9 | 10 | except EOFError: 11 | break -------------------------------------------------------------------------------- /2650.py: -------------------------------------------------------------------------------- 1 | n, w = [int(x) for x in input().split()] 2 | gigantes = [] 3 | 4 | while n: 5 | n -= 1 6 | entrada = input().split() 7 | if int(entrada[-1]) > w: 8 | gigantes.append(' '.join(entrada[:-1])) 9 | 10 | for g in gigantes: 11 | print(g) 12 | -------------------------------------------------------------------------------- /2670.py: -------------------------------------------------------------------------------- 1 | predio = [int(input()) for andar in range(3)] 2 | tempo_gasto = [] 3 | tempo_gasto.append(predio[0]*4 + predio[1]*2) 4 | tempo_gasto.append(predio[0]*2 + predio[2]*2) 5 | tempo_gasto.append(predio[1]*2 + predio[2]*4) 6 | 7 | tempo_gasto.sort() 8 | print(tempo_gasto[0]) 9 | -------------------------------------------------------------------------------- /2714.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | n -= 1 4 | ra = input() 5 | saida = 'INVALID DATA' 6 | if len(ra) == 20: 7 | if ra[0:2] == 'RA': 8 | if ra[2:].isdigit(): 9 | saida = int(ra[2:]) 10 | print(saida) 11 | -------------------------------------------------------------------------------- /1553.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n, k = input().split() 3 | if n == '0' and k == '0': 4 | break 5 | p = [int(i) for i in input().split()] 6 | total = 0 7 | for i in set(p): 8 | if p.count(i) >= int(k): 9 | total += 1 10 | print(total) -------------------------------------------------------------------------------- /2694.py: -------------------------------------------------------------------------------- 1 | import re 2 | n = int(input()) 3 | while n > 0: 4 | n -= 1 5 | c = input() 6 | c = re.sub('a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|x|y|z|w', ' ', c.lower()).split() 7 | c = [int(x) for x in c] 8 | r = c[0] + c[1] + c[2] 9 | 10 | print(r) 11 | -------------------------------------------------------------------------------- /2846.py: -------------------------------------------------------------------------------- 1 | def fibonot(n): 2 | a = 1 3 | b = 2 4 | c = 3 5 | while n > 0: 6 | a = b 7 | b = c 8 | c = a + b 9 | n -= (c - b - 1) 10 | n += (c - b - 1) 11 | return b + n 12 | 13 | n = int(input()) 14 | print(fibonot(n)) 15 | -------------------------------------------------------------------------------- /1512.py: -------------------------------------------------------------------------------- 1 | from fractions import gcd 2 | 3 | while True: 4 | n, a, b = [int(x) for x in input().split()] 5 | if n == a == b == 0: 6 | break 7 | 8 | total = 0 9 | lcm = (a * b) // gcd(a, b) 10 | total = n//a + n//b - n//lcm 11 | 12 | print(total) 13 | -------------------------------------------------------------------------------- /2516.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | s, va, vb = input().split() 4 | if(int(va) <= int(vb)): 5 | print('impossivel') 6 | else: 7 | t = int(s)/(int(va)-int(vb)) 8 | print('%.2f' % t) 9 | except EOFError: 10 | break -------------------------------------------------------------------------------- /1983.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | m = 0.0 3 | al = 0 4 | while(n > 0): 5 | n -= 1 6 | a, b = input().split() 7 | if float(b) > m: 8 | m = float(b) 9 | al = int(a) 10 | 11 | if m >= 8: 12 | print(al) 13 | else: 14 | print("Minimum note not reached") -------------------------------------------------------------------------------- /2175.py: -------------------------------------------------------------------------------- 1 | n = input().split() 2 | saida = "Otavio" 3 | max = n[0] 4 | if n[1] < max: 5 | saida = "Bruno" 6 | max = n[1] 7 | if n[2] < max: 8 | saida = "Ian" 9 | max = n[2] 10 | if n[0] == n[1] or n[1] == n[2] or n[2] == n[0]: 11 | saida = "Empate" 12 | 13 | print(saida) -------------------------------------------------------------------------------- /2523.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | c = input() 4 | n = int(input()) 5 | l = [int(x) for x in input().split()] 6 | n = '' 7 | for x in l: 8 | n += c[x-1] 9 | print(n) 10 | 11 | except EOFError: 12 | break -------------------------------------------------------------------------------- /1940.py: -------------------------------------------------------------------------------- 1 | j, r = [int(x) for x in input().split()] 2 | entrada = list(map(int, input().split())) 3 | 4 | pontos = [0] * j 5 | 6 | for k in range(j): 7 | pontos[k] = sum(entrada[k::j]) 8 | 9 | pontos = pontos[::-1] 10 | vencedor = j - pontos.index(max(pontos)) 11 | print(vencedor) 12 | -------------------------------------------------------------------------------- /2137.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | l = [] 5 | while(n > 0): 6 | n -= 1 7 | l.append(input()) 8 | l.sort() 9 | for n in l: 10 | print(n) 11 | 12 | except EOFError: 13 | break -------------------------------------------------------------------------------- /2515.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | pacote = [int(x) for x in input().split()] 3 | l = 0 4 | r = sum(pacote) 5 | b = 0 6 | print(r, l) 7 | while l < r and b < (n-1): 8 | l += pacote[b] 9 | r -= pacote[b] 10 | b += 1 11 | 12 | if l < r: 13 | l, r = r, l 14 | 15 | print(r, l) 16 | -------------------------------------------------------------------------------- /2747.py: -------------------------------------------------------------------------------- 1 | for i in range(38): 2 | print('-', end = "") 3 | print('-') 4 | 5 | for i in range(5): 6 | print('|', end = "") 7 | for j in range(37): 8 | print(' ', end = "") 9 | print('|') 10 | 11 | for i in range(38): 12 | print('-', end = "") 13 | print('-') -------------------------------------------------------------------------------- /1029.py: -------------------------------------------------------------------------------- 1 | call = [1, 1] 2 | f = [0, 1] 3 | for i in range(2, 41): 4 | call.append(call[i-1] + call[i-2] + 1) 5 | f.append(f[i-1] + f[i-2]) 6 | 7 | t = int(input()) 8 | while(t > 0): 9 | n = int(input()) 10 | print("fib(%d) = %d calls = %d" %(n, call[n]-1, f[n])) 11 | t -= 1 -------------------------------------------------------------------------------- /1241.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | while(n > 0): 4 | n -= 1 5 | a, b = input().split() 6 | if(len(a) < len(b)): 7 | print('nao encaixa') 8 | else: 9 | if(a[len(a)-len(b)::] == b): 10 | print('encaixa') 11 | else: 12 | print('nao encaixa') -------------------------------------------------------------------------------- /2518.py: -------------------------------------------------------------------------------- 1 | import math 2 | while True: 3 | try: 4 | deg = int(input()) 5 | h, c, l = input().split() 6 | 7 | hip = math.sqrt((int(c)**2)+(int(h)**2)) 8 | hip *= (int(l)/100*int(deg))/100 9 | print('%.4f'%hip) 10 | 11 | except EOFError: 12 | break -------------------------------------------------------------------------------- /2049.py: -------------------------------------------------------------------------------- 1 | i = 1 2 | while True: 3 | a = input() 4 | if a == '0': 5 | break 6 | if i != 1: 7 | print() 8 | painel = input() 9 | print('Instancia %d' % i) 10 | i += 1 11 | if a in painel: 12 | print('verdadeira') 13 | else: 14 | print('falsa') 15 | -------------------------------------------------------------------------------- /2540.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | v = input().split() 5 | v = v.count('1') 6 | if v/n >= 2/3: 7 | print('impeachment') 8 | else: 9 | print('acusacao arquivada') 10 | 11 | except EOFError: 12 | break -------------------------------------------------------------------------------- /1237.py: -------------------------------------------------------------------------------- 1 | from difflib import SequenceMatcher 2 | while True: 3 | try: 4 | pa = input() 5 | pb = input() 6 | sub = SequenceMatcher(None, pa, pb) 7 | m = sub.find_longest_match(0, len(pa), 0, len(pb)) 8 | print(m.size) 9 | 10 | except EOFError: 11 | break 12 | -------------------------------------------------------------------------------- /1532.py: -------------------------------------------------------------------------------- 1 | pontos = [[]] * 31 2 | for i in range(1, 31): 3 | for j in range(1, i): 4 | pontos[i].append(i * j) 5 | 6 | print(pontos[5]) 7 | 8 | while True: 9 | n, v = input().split() 10 | if n == v == '0': 11 | break 12 | for i in range(int(v), 0, -1): 13 | print('') 14 | -------------------------------------------------------------------------------- /1581.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while(n > 0): 3 | n -= 1 4 | l = [] 5 | m = int(input()) 6 | while(m > 0): 7 | m -= 1 8 | l.append(input()) 9 | main = l[0] 10 | for m in l: 11 | if m != main: 12 | main = 'ingles' 13 | break 14 | print(main) -------------------------------------------------------------------------------- /2764.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | c = input() 4 | c = c.split('/') 5 | x = c[0] 6 | print('%s/%s/%s' %(c[1], c[0], c[2])) 7 | print('%s/%s/%s' %(c[2], c[1], c[0])) 8 | print('%s-%s-%s' %(c[0], c[1], c[2])) 9 | 10 | except EOFError: 11 | break -------------------------------------------------------------------------------- /2863.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | tempo = 100.0 5 | while n > 0: 6 | t = float(input()) 7 | if t < tempo: 8 | tempo = t 9 | n -= 1 10 | print(tempo) 11 | 12 | except EOFError: 13 | break 14 | -------------------------------------------------------------------------------- /1285.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n, m = input().split() 4 | qt = 0 5 | for x in range(int(n), int(m)+1): 6 | if len(set(list(str(x)))) == len(str(x)): 7 | qt += 1 8 | print(qt) 9 | 10 | 11 | except EOFError: 12 | break -------------------------------------------------------------------------------- /1632.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | let = ['a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 's', 'S'] 3 | 4 | while n > 0: 5 | n -= 1 6 | c = input() 7 | var = 1 8 | for i in range(len(c)): 9 | if c[i] in let: 10 | var *= 3 11 | else: 12 | var *= 2 13 | 14 | print(var) -------------------------------------------------------------------------------- /1755.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | while t > 0: 3 | t -= 1 4 | d, n = input().split() 5 | troco = 0.0 6 | preco = input().split() 7 | for x in preco: 8 | if troco < (float(d) % float(x)) and float(x) < float(d): 9 | troco = (float(d) % float(x)) 10 | print("%.2f" % troco) 11 | -------------------------------------------------------------------------------- /1943.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | print('Top ', end = '') 3 | if n <= 1: 4 | print('1') 5 | elif n <= 3: 6 | print('3') 7 | elif n <= 5: 8 | print('5') 9 | elif n <= 10: 10 | print('10') 11 | elif n <= 25: 12 | print('25') 13 | elif n <= 50: 14 | print('50') 15 | elif n <= 100: 16 | print('100') -------------------------------------------------------------------------------- /2238.py: -------------------------------------------------------------------------------- 1 | from math import sqrt, ceil 2 | 3 | a, b, c, d = [int(x) for x in input().split()] 4 | 5 | l = int(ceil(sqrt(c))) 6 | n = a 7 | for n in range(a, l, a): 8 | if (n % b != 0) and (c % n == 0) and (d % n != 0): 9 | break 10 | 11 | if n > c: 12 | print('-1') 13 | else: 14 | print(n) 15 | -------------------------------------------------------------------------------- /2415.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | v = input().split() 3 | pontos = 1 4 | seq = 1 5 | for i in range(1, n): 6 | if v[i] == v[i - 1]: 7 | seq += 1 8 | else: 9 | if seq > pontos: 10 | pontos = seq 11 | seq = 1 12 | 13 | if seq > pontos: 14 | pontos = seq 15 | print(pontos) 16 | -------------------------------------------------------------------------------- /2682.py: -------------------------------------------------------------------------------- 1 | maior = 0 2 | ant = 0 3 | 4 | while True: 5 | try: 6 | n = int(input()) 7 | if ant > n and maior == 0: 8 | maior = ant + 1 9 | ant = n 10 | 11 | except EOFError: 12 | break 13 | 14 | if maior == 0: 15 | maior = ant + 1 16 | print(maior) -------------------------------------------------------------------------------- /2686.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | m = float(input()) 4 | mensagem = '' 5 | m *= 86400 6 | hora = m/3600 7 | m = float(m % 3600) 8 | minuto = m/60 9 | m = int(m % 60) 10 | print(hora, minuto, m) 11 | 12 | except EOFError: 13 | break 14 | -------------------------------------------------------------------------------- /2916.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n, k = [int(x) for x in input().split()] 4 | notas = [int(x) for x in input().split()] 5 | notas.sort() 6 | maior = 0 7 | maior = sum(notas[n-k:n]) 8 | print(maior%1000000007) 9 | 10 | except EOFError: 11 | break 12 | -------------------------------------------------------------------------------- /1901.py: -------------------------------------------------------------------------------- 1 | f = [] 2 | b = [] 3 | n = int(input()) 4 | for i in range(n): 5 | f.append(input().split()) 6 | for j in range(n): 7 | f[i][j] = int(f[i][j]) 8 | 9 | for i in range(n*2): 10 | x, y = input().split() 11 | b.append(f[int(x)-1][int(y)-1]) 12 | b = set(b) 13 | 14 | print(len(b)) -------------------------------------------------------------------------------- /2378.py: -------------------------------------------------------------------------------- 1 | n, c = [int(x) for x in input().split()] 2 | pessoas = 0 3 | exc = 0 4 | 5 | while n: 6 | n -= 1 7 | s, e = [int(x) for x in input().split()] 8 | pessoas += e 9 | pessoas -= s 10 | if pessoas > c: 11 | exc = 1 12 | 13 | if exc: 14 | print('S') 15 | else: 16 | print('N') 17 | -------------------------------------------------------------------------------- /2482.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | dict = {} 3 | while n: 4 | n -= 1 5 | lingua = input() 6 | trad = input() 7 | dict[lingua] = trad 8 | 9 | m = int(input()) 10 | while m: 11 | m -= 1 12 | pessoa = input() 13 | lingua = input() 14 | print(pessoa) 15 | print(dict[lingua]) 16 | print() 17 | -------------------------------------------------------------------------------- /2869.py: -------------------------------------------------------------------------------- 1 | c = int(input()) 2 | while c > 0: 3 | c -= 1 4 | n = int(input()) 5 | for i in range(1, 1000000000000000000): 6 | l = [] 7 | for j in range(1, i+1): 8 | if i % j == 0: 9 | l.append(j) 10 | if len(l) == n: 11 | break 12 | print(i) 13 | -------------------------------------------------------------------------------- /1247.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | while True: 3 | try: 4 | d, vf, vg = [int(x) for x in input().split()] 5 | vg = (sqrt(144 + (d * d)))/vg 6 | vf = 12/vf 7 | if vg > vf: 8 | print('N') 9 | else: 10 | print('S') 11 | except EOFError: 12 | break 13 | -------------------------------------------------------------------------------- /1515.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n = int(input()) 3 | if n == 0: 4 | break 5 | menor = 9999 6 | prim = '' 7 | while n > 0: 8 | n -= 1 9 | p, a, d = input().split() 10 | if menor > int(a)-int(d): 11 | menor = int(a)-int(d) 12 | prim = p 13 | print(prim) 14 | -------------------------------------------------------------------------------- /2029.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | v = float(input()) 4 | d = float(input()) 5 | r = d/2 6 | area = 3.14*r*r 7 | alt = v/(r*r*3.14) 8 | print('ALTURA = %.2f' % alt) 9 | print('AREA = %.2f' % area) 10 | 11 | except EOFError: 12 | break 13 | -------------------------------------------------------------------------------- /2084.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | v = input().split() 3 | 4 | for i in range(len(v)): 5 | v[i] = int(v[i]) 6 | 7 | votos = sum(v) 8 | razao = sorted([x/votos for x in v], reverse=True) 9 | 10 | if (razao[0] >= 0.45) or ((razao[0] >= 0.4) and (razao[0] - razao[1] >= 0.1)): 11 | print(1) 12 | else: 13 | print(2) 14 | -------------------------------------------------------------------------------- /2495.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | caneta = [i for i in range(1, n+1)] 5 | print(caneta) 6 | for i in range(1, n): 7 | entrada = input() 8 | caneta.remove(int(entrada)) 9 | print(caneta) 10 | 11 | except EOFError: 12 | break 13 | -------------------------------------------------------------------------------- /2757.py: -------------------------------------------------------------------------------- 1 | a = int(input()) 2 | b = int(input()) 3 | c = int(input()) 4 | 5 | print('A = %d, B = %d, C = %d' % (a, b, c)) 6 | print('A = %10.0d, B = %10d, C = %10d' % (a, b, c)) 7 | print('A = %s, B = %s, C = %s' % (str(a).zfill(10), str(b).zfill(10), str(c).zfill(10))) 8 | print('A = {:<10}, B = {:<10}, C = {:<10}'.format(a, b, c)) 9 | -------------------------------------------------------------------------------- /1410.py: -------------------------------------------------------------------------------- 1 | while True: 2 | a, d = [int(x) for x in input().split()] 3 | if not (a or d): 4 | break 5 | b = [int(x) for x in input().split()] 6 | c = [int(x) for x in input().split()] 7 | b.sort() 8 | c.sort() 9 | if (b[0] >= c[1]): 10 | print('N') 11 | else: 12 | print('Y') 13 | -------------------------------------------------------------------------------- /2718.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | n -= 1 4 | l = bin(int(input())) 5 | l = l[2:] 6 | m = 0 7 | aux = 0 8 | for i in l: 9 | if i == '1': 10 | aux += 1 11 | else: 12 | aux = 0 13 | if aux > m: 14 | m = aux 15 | 16 | print(m) -------------------------------------------------------------------------------- /1307.py: -------------------------------------------------------------------------------- 1 | from fractions import gcd 2 | 3 | n = int(input()) 4 | for i in range(1, n + 1): 5 | s1 = int(input(), 2) 6 | s2 = int(input(), 2) 7 | if gcd(s1, s2) != 1: 8 | s1 = 'All you need is love!' 9 | else: 10 | s1 = 'Love is not all you need!' 11 | 12 | print('Pair #%d: %s' % (i, s1)) 13 | -------------------------------------------------------------------------------- /1533.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n = int(input()) 3 | if(n == 0): 4 | break 5 | l = input().split() 6 | for i in range(n): 7 | l[i] = int(l[i]) 8 | 9 | r = sorted(l, key=int) 10 | for ind, i in enumerate(l): 11 | if i == r[n-2]: 12 | print(ind+1) 13 | break 14 | -------------------------------------------------------------------------------- /1619.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | 3 | n = int(input()) 4 | while n: 5 | n -= 1 6 | 7 | a1, a2 = input().split() 8 | a1, m1, d1 = [int(x) for x in a1.split('-')] 9 | a2, m2, d2 = [int(x) for x in a2.split('-')] 10 | a1 = date(a1, m1, d1) 11 | a2 = date(a2, m2, d2) 12 | 13 | print(abs(a1 - a2).days) 14 | -------------------------------------------------------------------------------- /2162.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | h = [int(x) for x in input().split()] 3 | if n == 2 and h[0] == h[1]: 4 | pico = 0 5 | else: 6 | pico = 1 7 | for i in range(1, n-1): 8 | if not ((h[i] < h[i-1] and h[i] < h[i+1]) or (h[i] > h[i-1] and h[i] > h[i+1])): 9 | pico = 0 10 | break 11 | print(pico) 12 | -------------------------------------------------------------------------------- /2547.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n, amin, amax = [int(x) for x in input().split()] 4 | t = 0 5 | while n: 6 | n -= 1 7 | i = int(input()) 8 | if i >= amin and i <= amax: 9 | t += 1 10 | print(t) 11 | 12 | except EOFError: 13 | break 14 | -------------------------------------------------------------------------------- /2761.py: -------------------------------------------------------------------------------- 1 | entrada = input().split() 2 | inteiro = int(entrada[0]) 3 | real = float(entrada[1]) 4 | caracter = entrada[2] 5 | frase = ' '.join(entrada[3:]) 6 | tudo = ''.join(entrada) 7 | print('%s' % tudo) 8 | print('%d\t%f\t%c\t%s' % (inteiro, real, caracter, frase)) 9 | print('%10d%10.6f%10c%10s' % (inteiro, real, caracter, frase)) 10 | -------------------------------------------------------------------------------- /1276.py: -------------------------------------------------------------------------------- 1 | import string 2 | 3 | while True: 4 | try: 5 | palavra = sorted(set(input())) 6 | alfabeto = string.ascii_lowercase 7 | faixa = [] 8 | for letra in palavra: 9 | print() 10 | print(alfabeto) 11 | print(palavra) 12 | 13 | 14 | except EOFError: 15 | break 16 | -------------------------------------------------------------------------------- /2149.py: -------------------------------------------------------------------------------- 1 | fib = [0, 1, 1, 1, 2, 2] 2 | for i in range(6, 20): 3 | if(((i-1) % 2) == 0): 4 | fib.append(fib[i-1]*fib[i-2]) 5 | else: 6 | fib.append(fib[i-1]+fib[i-2]) 7 | 8 | 9 | while True: 10 | try: 11 | n = int(input()) 12 | print(fib[n-1]) 13 | 14 | except EOFError: 15 | break -------------------------------------------------------------------------------- /2247.py: -------------------------------------------------------------------------------- 1 | teste = 1 2 | while True: 3 | n = int(input()) 4 | if n == 0: 5 | break 6 | valor = 0 7 | print('Teste %d' % teste) 8 | teste += 1 9 | while n: 10 | n -= 1 11 | j, z = [int(x) for x in input().split()] 12 | valor += (j - z) 13 | print(valor) 14 | 15 | print() 16 | -------------------------------------------------------------------------------- /2514.py: -------------------------------------------------------------------------------- 1 | from math import gcd 2 | while True: 3 | try: 4 | m = int(input()) 5 | l = [int(x) for x in input().split()] 6 | mmc = l[0] 7 | for i in l[1:]: 8 | mmc = ( (mmc * i) // (gcd(mmc, i)) ) 9 | mmc -= m 10 | print(mmc) 11 | 12 | except EOFError: 13 | break 14 | -------------------------------------------------------------------------------- /2343.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | raio = 0 3 | i = 502 4 | quad = [[0] * i for x in range(i)] 5 | 6 | while n: 7 | n -= 1 8 | x, y = [int(i) for i in input().split()] 9 | if not raio: 10 | if quad[int(x)][int(y)] == 0: 11 | quad[int(x)][int(y)] = 1 12 | else: 13 | raio = 1 14 | 15 | print(raio) 16 | -------------------------------------------------------------------------------- /2479.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | lista = [] 4 | bom = 0 5 | while n > 0: 6 | n -= 1 7 | c, nome = input().split() 8 | lista.append(nome) 9 | if c == '+': 10 | bom += 1 11 | 12 | lista.sort() 13 | for i in lista: 14 | print(i) 15 | 16 | print('Se comportaram: %d | Nao se comportaram: %d'%(bom, len(lista)-bom)) -------------------------------------------------------------------------------- /1371.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n = int(input()) 3 | if n == 0: 4 | break 5 | l = [] 6 | i = 1 7 | while(i**2 <= n): 8 | l.append(i**2) 9 | i += 1 10 | 11 | for i in range(len(l)): 12 | if i < len(l)-1: 13 | print('%d ' %l[i], end='') 14 | else: 15 | print('%d' %l[i]) -------------------------------------------------------------------------------- /2170.py: -------------------------------------------------------------------------------- 1 | n = 1 2 | 3 | while True: 4 | try: 5 | x, y = input().split() 6 | 7 | juros = 100*((float(y)/float(x))-1) 8 | 9 | print("Projeto %d:" % n) 10 | print("Percentual dos juros da aplicacao: %.2f %%" % juros) 11 | print() 12 | 13 | n += 1 14 | 15 | except EOFError: 16 | break 17 | -------------------------------------------------------------------------------- /2533.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | t = int(input()) 4 | n = 0 5 | c = 0 6 | 7 | for i in range(t): 8 | m1, m2 = input().split() 9 | c += int(m2) 10 | n += int(m1)*int(m2) 11 | 12 | ira = n/(c*100) 13 | print('%.4f' % ira) 14 | except EOFError: 15 | break -------------------------------------------------------------------------------- /2543.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n, iden = input().split() 4 | qt = 0 5 | n = int(n) 6 | while n > 0: 7 | n -= 1 8 | j, g = input().split() 9 | if j == iden and g == '0': 10 | qt += 1 11 | print(qt) 12 | 13 | except EOFError: 14 | break -------------------------------------------------------------------------------- /2189.py: -------------------------------------------------------------------------------- 1 | teste = 1 2 | while True: 3 | n = int(input()) 4 | if n == 0: 5 | break 6 | 7 | participantes = [int(x) for x in input().split()] 8 | vencedor = [participantes[x] for x in range(n) if participantes[x] == (x + 1)] 9 | 10 | print('Teste %d' % teste) 11 | teste += 1 12 | print(vencedor[0]) 13 | print() 14 | -------------------------------------------------------------------------------- /2235.py: -------------------------------------------------------------------------------- 1 | a, b, c = input().split() 2 | a = int(a) 3 | b = int(b) 4 | c = int(c) 5 | if((a-b == 0) or (a-c == 0) or (b-c == 0)): 6 | print('S') 7 | else: 8 | if((a+b-c == 0) or (b-a+c == 0) or (c-a+b == 0)): 9 | print('S') 10 | elif((a-b-c == 0) or (b-a-c == 0) or (c-a-b == 0)): 11 | print('S') 12 | else: 13 | print('N') -------------------------------------------------------------------------------- /1548.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | n -= 1 4 | m = int(input()) 5 | a = input().split() 6 | for ind, i in enumerate(a): 7 | a[ind] = int(a[ind]) 8 | b = sorted(a) 9 | b.reverse() 10 | total = 0 11 | for ind, i in enumerate(a): 12 | if (a[ind] == b[ind]): 13 | total +=1 14 | print(total) -------------------------------------------------------------------------------- /2108.py: -------------------------------------------------------------------------------- 1 | s = 0 2 | while True: 3 | l = input().split() 4 | sizes = [] 5 | if l == ['0']: 6 | break 7 | for i in l: 8 | sizes.append(str(len(i))) 9 | if len(i) >= s: 10 | s = len(i) 11 | b = i 12 | p = '-'.join(sizes) 13 | print(p) 14 | 15 | print() 16 | print('The biggest word: %s' % b) 17 | -------------------------------------------------------------------------------- /2143.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n = int(input()) 3 | if not n: 4 | break 5 | pessoas = [] 6 | while n: 7 | n -= 1 8 | x = int(input()) 9 | if x % 2 == 0: 10 | pessoas.append((2 * x) - 2) 11 | else: 12 | pessoas.append((2 * x) - 1) 13 | for i in pessoas: 14 | print(i) 15 | -------------------------------------------------------------------------------- /2708.py: -------------------------------------------------------------------------------- 1 | turistas = 0 2 | jipes = 0 3 | while True: 4 | entrada = input().split() 5 | if entrada[0] == 'ABEND': 6 | break 7 | if entrada[0] == 'SALIDA': 8 | jipes += 1 9 | turistas += int(entrada[1]) 10 | else: 11 | jipes -= 1 12 | turistas -= int(entrada[1]) 13 | 14 | print(turistas) 15 | print(jipes) 16 | -------------------------------------------------------------------------------- /1228.py: -------------------------------------------------------------------------------- 1 | t = 3 2 | 3 | while t: 4 | t -= 1 5 | n = int(input()) 6 | l = [int(x) for x in input().split()] 7 | c = [int(x) for x in input().split()] 8 | ult = 0 9 | for i in range(n): 10 | for j in range(i, n): 11 | if (l[i] == c[j]): 12 | ult += (j - i) 13 | break 14 | print(ult) 15 | -------------------------------------------------------------------------------- /2692.py: -------------------------------------------------------------------------------- 1 | n, m = [int(x) for x in input().split()] 2 | troc_e = troc_s = [] 3 | 4 | while n: 5 | n -= 1 6 | e, s = input().split() 7 | troc_e.append(e) 8 | troc_s.append(s) 9 | 10 | while m: 11 | m -= 1 12 | palavra = input() 13 | for i in range(len(palavra)): 14 | if palavra[i] in troc_e: 15 | palavra[i].replace() 16 | -------------------------------------------------------------------------------- /2748.py: -------------------------------------------------------------------------------- 1 | print('---------------------------------------') 2 | print('| Roberto |') 3 | print('| |') 4 | print('| 5786 |') 5 | print('| |') 6 | print('| UNIFEI |') 7 | print('---------------------------------------') 8 | -------------------------------------------------------------------------------- /2812.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | n -= 1 4 | m = int(input()) 5 | lista = sorted(input().split()) 6 | impares = [] 7 | for x in lista: 8 | if int(x) % 2 == 1: 9 | impares.append(x) 10 | m = len(impares)-1 11 | lista = [] 12 | for x in range(m/2): 13 | lista.append() 14 | print(lista) 15 | -------------------------------------------------------------------------------- /1987.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n, m = input().split() 4 | r = 0 5 | for i in range(len(m)): 6 | r += int(m[i]) 7 | m = str(r) 8 | print(m, end=' ') 9 | if int(m) % 3 == 0: 10 | print('sim') 11 | else: 12 | print('nao') 13 | 14 | except EOFError: 15 | break -------------------------------------------------------------------------------- /2168.py: -------------------------------------------------------------------------------- 1 | quadras = int(input()) 2 | camera = [input().split() for x in range(quadras+1)] 3 | 4 | for x in range(quadras): 5 | for y in range(quadras): 6 | if(int(camera[x][y]) + int(camera[x][y+1]) + int(camera[x+1][y]) + int(camera[x+1][y+1]) < 2): 7 | print("U", end="") 8 | else: 9 | print("S", end="") 10 | print() 11 | -------------------------------------------------------------------------------- /natal2018/e.py: -------------------------------------------------------------------------------- 1 | e, d = [int(x) for x in input().split()] 2 | if d < e: 3 | print('Eu odeio a professora!') 4 | elif d - e >= 3: 5 | print('Muito bem! Apresenta antes do Natal!') 6 | else: 7 | print('Parece o trabalho do meu filho!') 8 | if e + 2 < 24: 9 | print('TCC Apresentado!') 10 | else: 11 | print('Fail! Entao eh nataaaaal!') 12 | -------------------------------------------------------------------------------- /1034.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | while t > 0: 3 | t -= 1 4 | n, m = input().split() 5 | blocos = [int(x) for x in input().split()] 6 | blocos.sort() 7 | qt = 0 8 | n = int(n)-1 9 | m = int(m) 10 | while m > 0: 11 | while m < blocos[n]: 12 | n -= 1 13 | m -= blocos[n] 14 | qt += 1 15 | print(qt) 16 | -------------------------------------------------------------------------------- /1196.py: -------------------------------------------------------------------------------- 1 | keyb = '`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;\'ZXCVBNM,./' 2 | while True: 3 | try: 4 | frase = input() 5 | decod = '' 6 | for c in frase: 7 | if c == ' ': 8 | decod += c 9 | else: 10 | decod += keyb[keyb.index(c)-1] 11 | print(decod) 12 | except EOFError: 13 | break -------------------------------------------------------------------------------- /2588.py: -------------------------------------------------------------------------------- 1 | from collections import Counter 2 | while True: 3 | try: 4 | palavra = input() 5 | letras = Counter(palavra) 6 | total = 0 7 | for i in palavra: 8 | print(i, letras[i]) 9 | if (letras[i] % 2 == 1): 10 | total += 1 11 | print(total) 12 | 13 | except EOFError: 14 | break 15 | -------------------------------------------------------------------------------- /2693.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | q = int(input()) 4 | a = [] 5 | while q: 6 | q -= 1 7 | a.append(input().split()) 8 | a[-1][2] = int(a[-1][2]) 9 | a.sort(key=lambda x: (x[2], x[1], x[0])) 10 | for nome in a: 11 | print(nome[0]) 12 | 13 | except EOFError: 14 | break 15 | -------------------------------------------------------------------------------- /2850.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | c = input() 4 | if c == 'esquerda': 5 | print('ingles') 6 | elif c == 'direita': 7 | print('frances') 8 | elif c == 'nenhuma': 9 | print('portugues') 10 | elif c == 'as duas': 11 | print('caiu') 12 | 13 | except EOFError: 14 | break 15 | -------------------------------------------------------------------------------- /1074.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | saida = '' 4 | n -= 1 5 | i = int(input()) 6 | if i == 0: 7 | saida += 'NULL' 8 | elif i % 2 == 0: 9 | saida += 'EVEN ' 10 | elif i % 2 == 1: 11 | saida += 'ODD ' 12 | if i > 0: 13 | saida += 'POSITIVE' 14 | if i < 0: 15 | saida += 'NEGATIVE' 16 | print(saida) -------------------------------------------------------------------------------- /2397.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | 3 | t = [int(x) for x in input().split()] 4 | t.sort() 5 | if (t[0] + t[1]) <= t[2] or (t[0] + t[2]) <= t[1] or (t[1] + t[2]) <= t[0]: 6 | print('n') 7 | else: 8 | raiz = sqrt(t[0]**2 + t[1]**2) 9 | if raiz > t[2]: 10 | print('a') 11 | elif raiz == t[2]: 12 | print('r') 13 | else: 14 | print('o') 15 | -------------------------------------------------------------------------------- /2845.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | duende = input().split() 3 | for x in range(n): 4 | duende[x] = int(duende[x]) 5 | duende.sort() 6 | maior = int(duende[n-1]) + 1 7 | while True: 8 | for x in range(n): 9 | if (maior % duende[x]) == 0 and duende[x] != 1: 10 | maior += 1 11 | break 12 | if x == n-1: 13 | break 14 | print(maior) 15 | -------------------------------------------------------------------------------- /2847.py: -------------------------------------------------------------------------------- 1 | iloveyou = [0] * 8 2 | 3 | frase = input() 4 | 5 | iloveyou[0] = frase.count('I') 6 | iloveyou[1] = frase.count('l') 7 | iloveyou[2] = int(frase.count('o')/2) 8 | iloveyou[3] = frase.count('v') 9 | iloveyou[4] = frase.count('e') 10 | iloveyou[5] = frase.count('y') 11 | iloveyou[6] = frase.count('u') 12 | iloveyou[7] = frase.count('!') 13 | 14 | print(min(iloveyou)) 15 | -------------------------------------------------------------------------------- /2868.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n: 3 | n -= 1 4 | 5 | n1, op, n2, lixo, res = input().split() 6 | n1, n2 = int(n1), int(n2) 7 | 8 | if op == '+': 9 | real = n1 + n2 10 | elif op == '-': 11 | real = n1 - n2 12 | else: 13 | real = n1 * n2 14 | 15 | rr = 'r' * abs(real - int(res)) 16 | print('E{}ou!'.format(rr)) 17 | -------------------------------------------------------------------------------- /1104.py: -------------------------------------------------------------------------------- 1 | while True: 2 | a, b = input().split() 3 | if a == b == '0': 4 | break 5 | fa = [int(x) for x in input().split()] 6 | fb = [int(x) for x in input().split()] 7 | a = set(fa) 8 | b = set(fb) 9 | c = b 10 | f = 0 11 | if len(a) < len(b): 12 | c = a 13 | a = b 14 | c = [x for x in c if x not in a] 15 | print(len(c)) -------------------------------------------------------------------------------- /2203.py: -------------------------------------------------------------------------------- 1 | from math import sqrt, pow 2 | 3 | while True: 4 | try: 5 | xf, yf, xi, yi, vi, r1, r2 = [int(x) for x in input().split()] 6 | distancia = sqrt(pow((xf - xi), 2) + pow((yf - yi), 2)) 7 | if (r1 + r2) >= (distancia) + 1.5 * vi: 8 | print('Y') 9 | else: 10 | print('N') 11 | except EOFError: 12 | break 13 | -------------------------------------------------------------------------------- /2690.py: -------------------------------------------------------------------------------- 1 | lista = ['GQaku', 'ISblv', 'EOYcmw', 'FPZdnx', 'JTeoy', 'DNXfpz', 'AKUgq', 'CMWhr', 'BLVis', 'HRjt'] 2 | 3 | n = int(input()) 4 | 5 | while n: 6 | n -= 1 7 | senha = input() 8 | cripto = '' 9 | for letra in senha: 10 | if letra != ' ': 11 | cripto+= str([i for i, new in enumerate(lista) if letra in new][0]) 12 | 13 | print(cripto) 14 | -------------------------------------------------------------------------------- /2771.py: -------------------------------------------------------------------------------- 1 | 1.0 radixsort 2 | 2.0 lesd mesd 3 | 2.1 complexidade 4 | 2.2 lógica 5 | 3.0 ordenação digital 6 | 4.0 implementação 7 | 4.1 gerando arquivos 8 | 4.2 ler arquivos 9 | 4.3 ordenar utilizando orde digital 10 | 5.0 resultados 11 | tamanhos 5, 10, 25, 100 12 | gráficos 13 | referencias 14 | n copia 15 | 6.0 comparaçao com o quick sort 16 | 7.0 conclusao geral 17 | 8.0 bibliografias -------------------------------------------------------------------------------- /1259.py: -------------------------------------------------------------------------------- 1 | f = [] 2 | par = [] 3 | impar = [] 4 | n = int(input()) 5 | 6 | while(n > 0): 7 | i = int(input()) 8 | if(i % 2 == 0): 9 | par.append(i) 10 | else: 11 | impar.append(i) 12 | n -= 1 13 | 14 | par.sort() 15 | impar.sort(reverse=True) 16 | for i in par: 17 | f.append(i) 18 | for i in impar: 19 | f.append(i) 20 | 21 | for i in f: 22 | print(i) -------------------------------------------------------------------------------- /1768.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | for i in range(1, n+1, 2): 5 | print((n-i)//2 * ' ', end='') 6 | print('*'*i) 7 | 8 | print(n//2*' ', end = '') 9 | print('*') 10 | print(((n//2)-1)*' ', end = '') 11 | print('***') 12 | print() 13 | 14 | except EOFError: 15 | break -------------------------------------------------------------------------------- /1873.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | game = ['tesoura','pedra','spock','papel','lagarto'] 3 | 4 | while(n > 0): 5 | n -= 1 6 | s, r = input().split() 7 | while(game[2] != s): 8 | game = [game[-1]] + game[:-1] 9 | s = 2-game.index(r) 10 | if(s > 0): 11 | print('rajesh') 12 | elif(s < 0): 13 | print('sheldon') 14 | else: 15 | print('empate') -------------------------------------------------------------------------------- /2727.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | alf = 'abcdefghijklmnopqrstuvwxyz' 4 | n = int(input()) 5 | saida = '' 6 | while n > 0: 7 | l = input().split() 8 | pos = len(l[0]) + 3*(len(l)-1) 9 | saida += alf[pos-1] 10 | n -= 1 11 | for n in saida: 12 | print(n) 13 | except EOFError: 14 | break -------------------------------------------------------------------------------- /1030.py: -------------------------------------------------------------------------------- 1 | from collections import deque 2 | def jos(k, j): 3 | d = deque(k) 4 | while len(d) > 1: 5 | d.rotate(-j) 6 | d.pop() 7 | return(d.pop()) 8 | 9 | 10 | n = int(input()) 11 | for i in range(n): 12 | k, j = input().split() 13 | k = [x for x in range(1, int(k)+1)] 14 | j = int(j) 15 | result = jos(k, j) 16 | print('Case %d: %d'%(i+1, result)) 17 | -------------------------------------------------------------------------------- /1089.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n = int(input()) 3 | if n == 0: 4 | break 5 | h = [int(x) for x in input().split()] 6 | h.append(h[0]) 7 | h.append(h[1]) 8 | picos = 0 9 | for i in range(1, n+1): 10 | if h[i] < h[i-1] and h[i] < h[i+1]: 11 | picos += 1 12 | elif h[i] > h[i-1] and h[i] > h[i+1]: 13 | picos += 1 14 | print(picos) -------------------------------------------------------------------------------- /1291.py: -------------------------------------------------------------------------------- 1 | from math import pi, sqrt 2 | 3 | while True: 4 | try: 5 | lado = float(input()) 6 | borda = (- lado) * lado * (3 * (sqrt(3) - 4) + 2 * pi) / 3 7 | estrela = 4 * (lado * lado * (1 - pi/4) - (borda) / 2) 8 | centro = lado * lado - estrela - borda 9 | print('%.3f %.3f %.3f' % (centro, estrela, borda)) 10 | except EOFError: 11 | break 12 | -------------------------------------------------------------------------------- /2534.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n, q = [int(x) for x in input().split()] 4 | cid = [] 5 | while n: 6 | n -= 1 7 | cid.append(int(input())) 8 | cid.sort(reverse=True) 9 | while q: 10 | q -= 1 11 | p = input() 12 | print(cid[int(p) - 1]) 13 | 14 | 15 | except EOFError: 16 | break 17 | -------------------------------------------------------------------------------- /2754.py: -------------------------------------------------------------------------------- 1 | from decimal import Decimal 2 | 3 | i = 234.345 4 | j = 45.698 5 | 6 | print('%.6f - %.6f'%(i, j)) 7 | print('%.0f - %.0f'%(i, j)) 8 | print('%.1f - %.1f'%(i, j)) 9 | print('%.2f - %.2f'%(i, j)) 10 | print('%.3f - %.3f'%(i, j)) 11 | print('%.6e - %.6e' % (Decimal(i), Decimal(j))) 12 | print('%.6E - %.6E' % (Decimal(i), Decimal(j))) 13 | print('%g - %g'%(i, j)) 14 | print('%g - %g'%(i, j)) -------------------------------------------------------------------------------- /2770.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | x, y, m = [int(i) for i in input().split()] 4 | while m: 5 | m -= 1 6 | xi, yi = [int(i) for i in input().split()] 7 | if (xi <= x and yi <= y) or (xi <= y and yi <= x): 8 | print('Sim') 9 | else: 10 | print('Nao') 11 | 12 | except EOFError: 13 | break 14 | -------------------------------------------------------------------------------- /1129.py: -------------------------------------------------------------------------------- 1 | r = 'ABCDE*' 2 | while True: 3 | n = int(input()) 4 | if n == 0: 5 | break 6 | for i in range(n): 7 | p = -1 8 | l = [int(x) for x in input().split()] 9 | for j in range(len(l)): 10 | if l[j] <= 127: 11 | if p != -1: 12 | p = 5 13 | break 14 | p = j 15 | print(r[p]) -------------------------------------------------------------------------------- /2569.py: -------------------------------------------------------------------------------- 1 | def rem7(word): 2 | n = '' 3 | for i in range(len(word)): 4 | if word[i] == '7': 5 | n += '0' 6 | else: 7 | n += word[i] 8 | return int(n) 9 | 10 | a, op, b = input().split() 11 | 12 | a = rem7(a) 13 | b = rem7(b) 14 | 15 | if op == '+': 16 | a += b 17 | else: 18 | a *= b 19 | 20 | a = str(a) 21 | a = rem7(a) 22 | 23 | print(a) -------------------------------------------------------------------------------- /1869.py: -------------------------------------------------------------------------------- 1 | b = [] 2 | for i in range(32): 3 | if(i<10): 4 | b.append(i) 5 | else: 6 | b.append(chr(i+55)) 7 | 8 | while(True): 9 | n = int(input()) 10 | ans = '' 11 | while(n > 31): 12 | i = int(n%32) 13 | ans += str(b[i]) 14 | n /= 32 15 | ans += str(b[int(n)]) 16 | ans = ans[::-1] 17 | print(ans) 18 | if(n == 0): 19 | break 20 | -------------------------------------------------------------------------------- /2496.py: -------------------------------------------------------------------------------- 1 | m = int(input()) 2 | alph = [] 3 | for i in range(65, 91): 4 | alph.append(chr(i)) 5 | 6 | for j in range(m): 7 | total = 0 8 | n = int(input()) 9 | a = input() 10 | for i in range(n): 11 | if(a[i] != alph[i]): 12 | total += 1 13 | if(total < 3): 14 | print("There are the chance.") 15 | else: 16 | print("There aren't the chance.") 17 | -------------------------------------------------------------------------------- /2590.py: -------------------------------------------------------------------------------- 1 | def mod(n): 2 | saida = 0 3 | tam = len(n) 4 | for i in range(0, tam): 5 | saida = (saida * 10 + int(n[i])) % 4 6 | return saida 7 | 8 | t = int(input()) 9 | while t: 10 | t -= 1 11 | n = mod(input()) 12 | if n == 0: 13 | print(1) 14 | elif n == 1: 15 | print(7) 16 | elif n == 2: 17 | print(9) 18 | else: 19 | print(3) 20 | -------------------------------------------------------------------------------- /2600.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | dado = [1, 2, 3, 4, 5, 6] 3 | while n > 0: 4 | n -= 1 5 | c = [] 6 | c.append(int(input())) 7 | x = input().split() 8 | for i in x: 9 | c.append(int(i)) 10 | c.append(int(input())) 11 | d = sorted(c) 12 | if (d != dado) or (c[0]+c[5] != 7) or (c[1]+c[3]!=7) or (c[2]+c[4] != 7): 13 | print('NAO') 14 | else: 15 | print('SIM') -------------------------------------------------------------------------------- /1457.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | 3 | while t > 0: 4 | t -= 1 5 | f = input() 6 | n = '' 7 | k = 0 8 | 9 | while True: 10 | if(f[k] != '!'): 11 | n += f[k] 12 | k += 1 13 | else: 14 | n = int(n) 15 | k = len(f) - k 16 | break 17 | 18 | f = 1 19 | for i in range(n, 1, -k): 20 | f *= i 21 | print(f) -------------------------------------------------------------------------------- /1973.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | x = [int(i) for i in input().split()] 3 | total = sum(x) 4 | atacadas = [0] * n 5 | i = 0 6 | 7 | while i >= 0 and i < n: 8 | lado = x[i] % 2 9 | if x[i] > 0: 10 | x[i] -= 1 11 | atacadas[i] = 1 12 | total -= 1 13 | if lado: 14 | i += 1 15 | else: 16 | i -= 1 17 | 18 | atacadas = atacadas.count(1) 19 | print(atacadas, total) 20 | -------------------------------------------------------------------------------- /2158.py: -------------------------------------------------------------------------------- 1 | c = 1 2 | while True: 3 | try: 4 | fp, fh = input().split() 5 | lig = (5*int(fp)+6*int(fh))//2 6 | ato = (5*int(fp)+6*int(fh))//3 7 | ato = 2 + lig - int(fp) - int(fh) 8 | print('Molecula #%d.:.' % c) 9 | print('Possui %d atomos e %d ligacoes' % (ato, lig)) 10 | print() 11 | c += 1 12 | 13 | except EOFError: 14 | break -------------------------------------------------------------------------------- /2715.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | t = [int(x) for x in input().split()] 5 | i = 2 6 | dif = sum(t[i:]) - sum(t[:i]) 7 | while(True): 8 | i += 1 9 | new = sum(t[i:]) - sum(t[:i]) 10 | if new < 0: 11 | break; 12 | dif = new 13 | print(dif) 14 | except EOFError: 15 | break -------------------------------------------------------------------------------- /1162.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n > 0: 3 | n -= 1 4 | l = int(input()) 5 | vagao = input().split() 6 | 7 | swap = 0 8 | for i in range(l): 9 | for j in range(i + 1, l): 10 | if (int(vagao[i]) > int(vagao[j])): 11 | vagao[i], vagao[j] = vagao[j], vagao[i] 12 | swap += 1 13 | 14 | print('Optimal train swapping takes %d swaps.' % swap) 15 | -------------------------------------------------------------------------------- /1441.py: -------------------------------------------------------------------------------- 1 | def is_power2(num): 2 | return num != 0 and ((num & (num - 1)) == 0) 3 | 4 | while True: 5 | n = int(input()) 6 | if n == 0: 7 | break 8 | m = 0 9 | while is_power2(n) != True: 10 | if n > m: 11 | m = n 12 | if n % 2 == 0: 13 | n = int(n/2) 14 | else: 15 | n = n*3 + 1 16 | if n > m: 17 | m = n 18 | print(m) -------------------------------------------------------------------------------- /2719.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | while t: 3 | t -= 1 4 | n, m = [int(i) for i in input().split()] 5 | p = [int(i) for i in input().split()] 6 | viagem = 1 7 | i = 1 8 | peso = p[0] 9 | while i < n: 10 | if peso + p[i] > m: 11 | viagem += 1 12 | peso = p[i] 13 | else: 14 | peso += p[i] 15 | 16 | i += 1 17 | 18 | print(viagem) 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # uri-python 2 | Repository to store URI online judge python solutions. 3 | 4 | [My profile](https://www.urionlinejudge.com.br/judge/pt/profile/30360) 5 | 6 | --- 7 | 8 | Eu não uso mais o URI, mas sinta-se livre para deixar sugestões/ajustes ou usar os exercícios para aprender/praticar. 9 | 10 | I do not use URI anymore, but feel free to leave suggestions or use the exercises to practice. 11 | -------------------------------------------------------------------------------- /1105.py: -------------------------------------------------------------------------------- 1 | while True: 2 | b, n = input().split() 3 | if b == n == '0': 4 | break 5 | r = [int(x) for x in input().split()] 6 | for i in range(int(n)): 7 | d, c, v = input().split() 8 | r[int(d)-1] -= int(v) 9 | r[int(c)-1] += int(v) 10 | saida = 'S' 11 | for i in r: 12 | if int(i) < 0: 13 | saida = 'N' 14 | break 15 | print(saida) 16 | -------------------------------------------------------------------------------- /1364.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n, m = input().split() 3 | emote = [] 4 | qt = 0 5 | if n == '0' and m == '0': 6 | break 7 | for i in range(int(n)): 8 | emote.append(input()) 9 | for i in range(int(m)): 10 | c = input() 11 | print(emote) 12 | print(c) 13 | for x in emote: 14 | qt += c.count(x) 15 | c = c.replace(x, ' ') 16 | print(qt) -------------------------------------------------------------------------------- /2248.py: -------------------------------------------------------------------------------- 1 | turma = 1 2 | while True: 3 | n = int(input()) 4 | if n == 0: 5 | break 6 | 7 | c = [] 8 | while n: 9 | n -= 1 10 | c.append([int(x) for x in input().split()]) 11 | 12 | maior = max([x[1] for x in c]) 13 | estagio = [str(x[0]) for x in c if x[1] == maior] 14 | 15 | print('Turma %d' % turma) 16 | print(' '.join(estagio), '') 17 | print() 18 | turma += 1 19 | -------------------------------------------------------------------------------- /1281.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n: 3 | n -= 1 4 | feira = {} 5 | final = 0.0 6 | 7 | m = int(input()) 8 | while m: 9 | m -= 1 10 | item, valor = input().split() 11 | feira[item] = float(valor) 12 | 13 | p = int(input()) 14 | while p: 15 | p -= 1 16 | item, qt = input().split() 17 | final += feira[item] * int(qt) 18 | 19 | print('R$ %.2f' % final) 20 | -------------------------------------------------------------------------------- /2685.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | if ((n >= 0 and n < 90) or n == 360): 5 | print('Bom Dia!!') 6 | elif (n >=90 and n < 180): 7 | print('Boa Tarde!!') 8 | elif (n >= 180 and n < 270): 9 | print('Boa Noite!!') 10 | elif (n >= 270 and n < 360): 11 | print('De Madrugada!!') 12 | 13 | except EOFError: 14 | break 15 | -------------------------------------------------------------------------------- /1267.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n, d = input().split() 3 | if n == '0' and d == '0': 4 | break 5 | l = [] 6 | s = 'no' 7 | jantar = [0] * int(n) 8 | for i in range(int(d)): 9 | l.append([int(x) for x in input().split()]) 10 | for j in range(int(n)): 11 | if l[i][j] == 1: 12 | jantar[j] += 1 13 | if jantar.count(int(d)) > 0: 14 | s = 'yes' 15 | print(s) 16 | -------------------------------------------------------------------------------- /1845.py: -------------------------------------------------------------------------------- 1 | maior = 'BJPSVXZ' 2 | menor = 'bjpsvxz' 3 | 4 | while True: 5 | try: 6 | c = input() 7 | efit = '' 8 | for i in range(len(c)): 9 | if c[i] in maior: 10 | efit += 'F' 11 | elif c[i] in menor: 12 | efit += 'f' 13 | else: 14 | efit += c[i] 15 | print(efit) 16 | 17 | except EOFError: 18 | break -------------------------------------------------------------------------------- /2633.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | total = {} 5 | while n: 6 | n -= 1 7 | peca = input().split() 8 | total[peca[0]] = int(peca[1]) 9 | 10 | # ordenar o dicionario 11 | total = {k: v for k, v in sorted(total.items(), key=lambda x: x[1])} 12 | 13 | print(' '.join(total)) 14 | 15 | except EOFError: 16 | break 17 | -------------------------------------------------------------------------------- /2828.py: -------------------------------------------------------------------------------- 1 | from math import factorial 2 | 3 | big = 10**9 + 7 4 | palavra = input() 5 | 6 | occ = {} 7 | for c in palavra: 8 | if c in occ: 9 | occ[c] += 1 10 | else: 11 | occ[c] = 1 12 | 13 | cima = 0 14 | baixo = 1 15 | 16 | for c in occ: 17 | cima += occ[c] 18 | baixo *= factorial(occ[c]) 19 | 20 | resultado = factorial(cima)//baixo 21 | resultado = pow(resultado, 1, big) 22 | 23 | print(resultado) 24 | -------------------------------------------------------------------------------- /1682.py: -------------------------------------------------------------------------------- 1 | c = 'NON' 2 | for i in range(3, 5001): 3 | p = c + 'N' 4 | for j in range(3, i): 5 | if c[:j] in p: 6 | p = c + 'O' 7 | break 8 | for j in range(3, i): 9 | if c[:j] in p: 10 | p = c + 'P' 11 | break 12 | c = p 13 | 14 | 15 | 16 | while True: 17 | n = int(input()) 18 | if n == 0: 19 | break 20 | print(c[:n]) 21 | -------------------------------------------------------------------------------- /2025.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | while n: 4 | n -= 1 5 | texto = input().split() 6 | 7 | for palavra in texto: 8 | 9 | if ('oulupukk' in palavra): 10 | 11 | if len(palavra) == 10: 12 | texto[texto.index(palavra)] = 'Joulupukki' 13 | if len(palavra) == 11: 14 | texto[texto.index(palavra)] = 'Joulupukki.' 15 | 16 | texto = ' '.join(texto) 17 | print(texto) 18 | -------------------------------------------------------------------------------- /2630.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | 3 | for i in range(t): 4 | t -= 1 5 | conv = input() 6 | r, g, b = [int(x) for x in input().split()] 7 | if conv == 'eye': 8 | p = int(r*0.30 + g*0.59 + b*0.11) 9 | elif conv == 'mean': 10 | p = int((r + g + b) / 3) 11 | elif conv == 'max': 12 | p = max(r, g, b) 13 | elif conv == 'min': 14 | p = min(r, g, b) 15 | 16 | print('Caso #%d: %d' % (i+1, p)) 17 | -------------------------------------------------------------------------------- /1068.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | p = input() 4 | d = 0 5 | for i in range(len(p)): 6 | if(p[i]=='('): 7 | d += 1 8 | elif(p[i]==')'): 9 | d -= 1 10 | if(d < 0): 11 | break 12 | if(d != 0): 13 | print('incorrect') 14 | else: 15 | print('correct') 16 | 17 | except EOFError: 18 | break -------------------------------------------------------------------------------- /natal2018/f.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | c, k = [int(x) for x in input().split()] 4 | comb = [[] * c] 5 | print(comb) 6 | p = [] 7 | 8 | for i in range(c): 9 | p.append(input()) 10 | s = int(input()) 11 | for j in range(s): 12 | comb[i].append[input()] 13 | 14 | print(p) 15 | print(comb) 16 | 17 | except EOFError: 18 | break 19 | -------------------------------------------------------------------------------- /1549.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | pi = 3.14 3 | while t > 0: 4 | t -= 1 5 | n, l = input().split() 6 | bme, bma, h = input().split() 7 | bme = int(bme)/2 8 | bma = int(bma)/2 9 | print(bme, bma, n) 10 | # CALCULO DO VOLUME MAXIMO 11 | v = ((pi*int(h)/3)*(bme**2+bme*bma+bma**2)) 12 | # CALCULO DO VOLUME QUE SOBRA 13 | n = (int(l)/int(n))-v 14 | print(n, v) 15 | h = (3*n)/(pi*(bme**2+bme*bma+bma**2)) 16 | print(h) -------------------------------------------------------------------------------- /1554.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | 3 | c = int(input()) 4 | while c: 5 | c -= 1 6 | n = int(input()) 7 | x, y = [int(i) for i in input().split()] 8 | perto = 999999999 9 | 10 | for cont in range(n): 11 | n -= 1 12 | xb, yb = [int(i) for i in input().split()] 13 | d = sqrt(abs(x - xb)**2 + abs(y - yb)**2) 14 | if d < perto: 15 | perto = d 16 | pos = cont + 1 17 | 18 | print(pos) 19 | -------------------------------------------------------------------------------- /2180.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | 3 | peso = int(input()) 4 | prim = [] 5 | 6 | for i in range(peso, 64000): 7 | p = 1 8 | for j in range(2, int(sqrt(i)) + 1 ): 9 | if i % j == 0: 10 | p = 0 11 | break 12 | if p: 13 | prim.append(i) 14 | if len(prim) == 10: 15 | break 16 | 17 | kmh = sum(prim) 18 | print(kmh, 'km/h') 19 | h = int(60000000/kmh) 20 | d = int(h/24) 21 | print(h, 'h /', d, 'd') 22 | -------------------------------------------------------------------------------- /natal2018/c.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | pulos = 0 3 | gelo = [] 4 | while n: 5 | n -= 1 6 | gelo.append(input()) 7 | 8 | espaco = 0 9 | for i in gelo: 10 | if i[0] == '.': 11 | espaco += 1 12 | if espaco > 2: 13 | pulos = 'N' 14 | espaco = 0 15 | break 16 | elif i[0] == '-' and espaco > 0: 17 | espaco = 0 18 | pulos += 1 19 | if espaco > 0: 20 | pulos += 1 21 | print(pulos) 22 | -------------------------------------------------------------------------------- /2152.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while(n > 0): 3 | n -= 1 4 | h, m, o = input().split() 5 | r = '' 6 | if((int(h) < 10) and (len(h) == 1)): 7 | r = '0' + h 8 | else: 9 | r = h 10 | r += ':' 11 | if((int(m) < 10) and (len(m) == 1)): 12 | r += '0' + m 13 | else: 14 | r += m 15 | r += ' - A porta ' 16 | if(o == '0'): 17 | r += 'fechou!' 18 | else: 19 | r += 'abriu!' 20 | print(r) -------------------------------------------------------------------------------- /1263.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | c = [] 4 | c = (input().lower()).split() 5 | t = 0 6 | y = 0 7 | for i, j in enumerate(c): 8 | c[i] = j[0] 9 | if c[i] == c[i-1] and y == 0: 10 | y = 1 11 | t += 1 12 | elif c[i] != c[i-1]: 13 | y = 0 14 | 15 | print(t) 16 | 17 | 18 | except EOFError: 19 | break -------------------------------------------------------------------------------- /1248.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | while n: 4 | n -= 1 5 | dieta = input() 6 | cafe = input() 7 | almoco = input() 8 | almoco += cafe 9 | for letra in range(len(almoco)): 10 | if almoco[letra] not in dieta: 11 | dieta = 'CHEATER' 12 | break 13 | else: 14 | dieta = dieta.replace(almoco[letra], '') 15 | 16 | if dieta != 'CHEATER': 17 | dieta = ''.join(sorted(dieta)) 18 | print(dieta) 19 | -------------------------------------------------------------------------------- /2222.py: -------------------------------------------------------------------------------- 1 | for t in range(int(input())): 2 | conjunto = [] 3 | for n in range(int(input())): 4 | conjunto.append(set(input().split()[1:])) 5 | 6 | for q in range(int(input())): 7 | op = [int(x) for x in input().split()] 8 | if op[0] == 1: 9 | resultado = conjunto[op[1] - 1] & conjunto[op[2] - 1] 10 | elif op[0] == 2: 11 | resultado = conjunto[op[1] - 1] | conjunto[op[2] - 1] 12 | print(len(resultado)) 13 | -------------------------------------------------------------------------------- /2596.py: -------------------------------------------------------------------------------- 1 | div = [] 2 | isok = [] 3 | 4 | for i in range(1001): 5 | div.append(0) 6 | isok.append(0) 7 | tot = 0 8 | for j in range(i, 0, -1): 9 | if(i % j == 0): 10 | tot += 1 11 | if(tot % 2 != 0): 12 | div[i] = 1 13 | for j in range(i, 0, -1): 14 | if(div[j] == 0): 15 | isok[i] += 1 16 | 17 | 18 | n = int(input()) 19 | while(n > 0): 20 | n -= 1 21 | i = int(input()) 22 | print(isok[i]) -------------------------------------------------------------------------------- /2153.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | palavra = input() 4 | rev = palavra[len(palavra)-1::-1] 5 | j = 1 6 | for i in range(1 , int(len(rev)/2)): 7 | print('PALAVRAS = ', rev[:i], rev[i:i+j]) 8 | if (rev[:i] == rev[i:i+j]): 9 | rev = rev[i:] 10 | break 11 | j += 1 12 | palavra = rev[len(rev)-1::-1] 13 | print(palavra) 14 | 15 | except EOFError: 16 | break 17 | -------------------------------------------------------------------------------- /2126.py: -------------------------------------------------------------------------------- 1 | caso = 1 2 | while True: 3 | try: 4 | n1 = input() 5 | n2 = input() 6 | print('Caso #%d:' % caso) 7 | qt = n2.count(n1) 8 | if qt == 0: 9 | print('Nao existe subsequencia') 10 | else: 11 | print('Qtd.Subsequencias: %d' % qt) 12 | qt = n2.rfind(n1) 13 | print('Pos: %d' % (int(qt)+1)) 14 | print() 15 | caso += 1 16 | 17 | except EOFError: 18 | break -------------------------------------------------------------------------------- /2187.py: -------------------------------------------------------------------------------- 1 | teste = 1 2 | while True: 3 | v = int(input()) 4 | if v == 0: 5 | break 6 | bits = ['0'] * 4 7 | if v >= 50: 8 | bits[0] = str(v // 50) 9 | v = v % 50 10 | if v >= 10: 11 | bits[1] = str(v // 10) 12 | v = v % 10 13 | if v >= 5: 14 | bits[2] = str(v // 5) 15 | v = v % 5 16 | bits[3] = str(v) 17 | print('Teste %d' % teste) 18 | print(' '.join(bits)) 19 | print() 20 | teste += 1 21 | -------------------------------------------------------------------------------- /1261.py: -------------------------------------------------------------------------------- 1 | hay_point = {} 2 | 3 | m, n = [int(x) for x in input().split()] 4 | 5 | while m: 6 | m -= 1 7 | cargo, salario = input().split() 8 | hay_point[cargo] = int(salario) 9 | 10 | while n: 11 | n -= 1 12 | salario = 0 13 | descricao = input().split() 14 | ponto = input() 15 | for palavra in descricao: 16 | try: 17 | salario += hay_point[palavra] 18 | except KeyError: 19 | continue 20 | 21 | print(salario) 22 | -------------------------------------------------------------------------------- /1471.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n, r = input().split() 4 | m = [x for x in range(1, int(n)+1)] 5 | l = [int(x) for x in input().split()] 6 | s = [x for x in m if x not in l] 7 | if s == []: 8 | s = '*' 9 | if s != '*': 10 | for x in range(len(s)): 11 | print(s[x], end=' ') 12 | print('') 13 | else: 14 | print(s) 15 | 16 | except EOFError: 17 | break -------------------------------------------------------------------------------- /1296.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | 3 | while True: 4 | try: 5 | m1, m2, m3 = [float(x) for x in input().split()] 6 | # Area em funcao das medianas # 7 | sm = (m1 + m2 + m3) / 2.0 8 | try: 9 | area = 4 * sqrt(sm * (sm - m1) * (sm - m2) * (sm - m3)) / 3.0 10 | except ValueError: 11 | area = -1.0 12 | if area == 0: 13 | area = -1.0 14 | print('%.3f' % area) 15 | except EOFError: 16 | break 17 | -------------------------------------------------------------------------------- /1306.py: -------------------------------------------------------------------------------- 1 | i = 1 2 | while True: 3 | r, n = [int(x) for x in input().split()] 4 | check = 1 5 | if n == r == 0: 6 | break 7 | 8 | if n >= r: 9 | print('Case %d: 0' % i) 10 | 11 | else: 12 | for j in range(1, 27): 13 | if n * (j + 1) >= r: 14 | print('Case %d: %d' % (i, j)) 15 | check = 0 16 | break 17 | if check: 18 | print('Case %d: impossible' % i) 19 | 20 | i += 1 21 | -------------------------------------------------------------------------------- /1861.py: -------------------------------------------------------------------------------- 1 | murd = {} 2 | ered = [] 3 | 4 | while True: 5 | try: 6 | kill, dead = input().split() 7 | if kill in murd: 8 | murd[kill] += 1 9 | ered.append(dead) 10 | else: 11 | murd[kill] = 1 12 | ered.append(dead) 13 | 14 | 15 | except EOFError: 16 | break 17 | 18 | 19 | for i in ered: 20 | murd.pop(i, None) 21 | 22 | print('HALL OF MURDERERS') 23 | 24 | for i, v in sorted(murd.items()): 25 | print(i, v) 26 | -------------------------------------------------------------------------------- /2227.py: -------------------------------------------------------------------------------- 1 | teste = 1 2 | while True: 3 | a, v = [int(i) for i in input().split()] 4 | if a == v == 0: 5 | break 6 | 7 | aero = [0] * a 8 | while v: 9 | v -= 1 10 | x, y = [int(i) for i in input().split()] 11 | aero[x-1] += 1 12 | aero[y-1] += 1 13 | 14 | m = max(aero) 15 | maior = [str(i + 1) for i in range(len(aero)) if aero[i] == m] 16 | print('Teste %d' % teste) 17 | teste += 1 18 | print(' '.join(maior), '') 19 | print() 20 | -------------------------------------------------------------------------------- /2136.py: -------------------------------------------------------------------------------- 1 | inscritos = [] 2 | vencedor = '' 3 | tam_venc = 0 4 | 5 | while True: 6 | entrada = input().split() 7 | if entrada[0] == 'FIM': 8 | break 9 | inscritos.append(entrada[0]) 10 | tam_nome = len(entrada[0]) 11 | if tam_nome > tam_venc: 12 | vencedor = entrada[0] 13 | tam_venc = len(vencedor) 14 | 15 | inscritos = set(inscritos) 16 | 17 | for nome in sorted(inscritos): 18 | print(nome) 19 | 20 | print() 21 | print('Amigo do Habay:') 22 | print(vencedor) 23 | -------------------------------------------------------------------------------- /2549.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n, a = input().split() 4 | n = int(n) 5 | lista = [] 6 | for aluno in range(n): 7 | nome = input().split() 8 | inicial = '' 9 | for i in nome: 10 | inicial += i[0] 11 | inicial += a 12 | if inicial not in lista: 13 | lista.append(inicial) 14 | fora = n - len(lista) 15 | print(fora) 16 | 17 | except EOFError: 18 | break 19 | -------------------------------------------------------------------------------- /2221.py: -------------------------------------------------------------------------------- 1 | t = int(input()) 2 | while t: 3 | t -= 1 4 | b = int(input()) 5 | ad, dd, ld = [int(x) for x in input().split()] 6 | ag, dg, lg = [int(x) for x in input().split()] 7 | golped = (ad + dd)/2.0 8 | golpeg = (ag + dg)/2.0 9 | if ld % 2 == 0: 10 | golped += b 11 | if lg % 2 == 0: 12 | golpeg += b 13 | 14 | if golped > golpeg: 15 | print('Dabriel') 16 | elif golpeg > golped: 17 | print('Guarte') 18 | else: 19 | print('Empate') 20 | -------------------------------------------------------------------------------- /2286.py: -------------------------------------------------------------------------------- 1 | teste = 1 2 | while True: 3 | n = int(input()) 4 | if n == 0: 5 | break 6 | j1 = input() 7 | j2 = input() 8 | resultado = [] 9 | while n: 10 | n -= 1 11 | a, b = [int(x) for x in input().split()] 12 | if (a + b) % 2 == 0: 13 | resultado.append(j1) 14 | else: 15 | resultado.append(j2) 16 | 17 | print('Teste %d' % teste) 18 | teste += 1 19 | for nome in resultado: 20 | print(nome) 21 | print() 22 | -------------------------------------------------------------------------------- /2154.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | t = int(input()) 4 | pol = input().split(' + ') 5 | der = [] 6 | for i in pol: 7 | x = i.split('x') 8 | valor = int(x[0]) * int(x[1]) 9 | if (int(x[1]) - 1) != 1: 10 | der.append(str(valor) + 'x' + str(int(x[1]) - 1)) 11 | else: 12 | der.append(str(valor) + 'x') 13 | der = ' + '.join(der) 14 | print(der) 15 | 16 | except EOFError: 17 | break 18 | -------------------------------------------------------------------------------- /1676.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | 3 | # Crivo de Erastotenes (adaptado) para gerar os primeiros 3000 4 | # primos rapidamente 5 | 6 | p = [2, 3] 7 | i = 5 8 | while len(p) < 3000: 9 | j = 0 10 | k = sqrt(i) 11 | 12 | while p[j] < k and i % p[j]: 13 | j += 1 14 | 15 | if p[j] > k: 16 | p += [i] 17 | 18 | if i % 3 == 2: 19 | i += 2 20 | else: 21 | i += 4 22 | 23 | while True: 24 | n = int(input()) 25 | if n == 0: 26 | break 27 | print(p[n - 1]) 28 | -------------------------------------------------------------------------------- /1025.py: -------------------------------------------------------------------------------- 1 | caso = 0 2 | while True: 3 | n, q = [int(x) for x in input().split()] 4 | if n == q == 0: 5 | break 6 | caso += 1 7 | marmore = [0] 8 | while n > 0: 9 | n -= 1 10 | marmore.append(int(input())) 11 | marmore.sort() 12 | print('CASE# %d:' % (caso)) 13 | while q > 0: 14 | q -= 1 15 | n = int(input()) 16 | if n in marmore: 17 | print('%d found at %d' %(n, marmore.index(n))) 18 | else: 19 | print('%d not found' % n) 20 | -------------------------------------------------------------------------------- /1430.py: -------------------------------------------------------------------------------- 1 | nota = {'W' : 1, 'H' : 1/2, 'Q' : 1/4, 'E' : 1/8, 'S' : 1/16, 'T' : 1/32, 'X' : 1/64} 2 | 3 | while True: 4 | compasso = input() 5 | if compasso == '*': 6 | break 7 | compasso = [x for x in compasso.split('/') if x] 8 | total = 0 9 | 10 | for conjunto in compasso: 11 | dur = 0 12 | for iden in conjunto: 13 | dur += nota[iden] 14 | if dur > 1: 15 | break 16 | if dur == 1: 17 | total += 1 18 | 19 | print(total) 20 | -------------------------------------------------------------------------------- /2520.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n, m = [int(x) for x in input().split()] 4 | matriz = [] 5 | for i in range(n): 6 | matriz.append(input().split()) 7 | 8 | a = [(index, j.index('2')) for index, j in enumerate(matriz) if '2' in j] 9 | b = [(index, j.index('1')) for index, j in enumerate(matriz) if '1' in j] 10 | 11 | x = (abs(a[0][0] - b[0][0])) 12 | y = (abs(a[0][1] - b[0][1])) 13 | print(x + y) 14 | 15 | except EOFError: 16 | break 17 | -------------------------------------------------------------------------------- /2557.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | conta = input() 4 | conta = conta.replace('=','+') 5 | conta = conta.split('+') 6 | if conta[0].isdigit() == False: 7 | resultado = int(conta[2]) - int(conta[1]) 8 | elif conta[1].isdigit() == False: 9 | resultado = int(conta[2]) - int(conta[0]) 10 | elif conta[2].isdigit() == False: 11 | resultado = int(conta[0]) + int(conta[1]) 12 | print(resultado) 13 | 14 | except EOFError: 15 | break 16 | -------------------------------------------------------------------------------- /2773.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | 3 | while True: 4 | try: 5 | xi, yi, xf, yf, v = [int(x) for x in input().split()] 6 | xl, yl, xr, yr = [int(x) for x in input().split()] 7 | ximenor = min(abs(xi - xl), abs(xi - xr)) 8 | yimenor = min(abs(yi - yl), abs(yi - yr)) 9 | xfmenor = min(abs(xf - xl), abs(xf - xr)) 10 | yfmenor = min(abs(yf - yl), abs(yf - yr)) 11 | print(ximenor, yimenor) 12 | print(xfmenor, yfmenor) 13 | 14 | except EOFError: 15 | break 16 | -------------------------------------------------------------------------------- /1110.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n = int(input()) 3 | if n == 0: 4 | break 5 | l = [] 6 | for i in range(n): 7 | l.append(i+1) 8 | res = [] 9 | while(len(l) > 1): 10 | res.append(l[0]) 11 | l.pop(0) 12 | l.append(l[0]) 13 | l.pop(0) 14 | 15 | print('Discarded cards: ', end='') 16 | for i in range(n-1): 17 | print(res[i], end='') 18 | if(i != n-2): 19 | print(', ', end='') 20 | print() 21 | print('Remaining card:', l[0]) -------------------------------------------------------------------------------- /1558.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | quad = [0] * 11001 3 | for i in range(int(sqrt(11000)) + 1): 4 | for j in range(i, int(sqrt(11000)) + 1): 5 | if(i * i + j * j) > 11000: 6 | break 7 | quad[i*i + j*j] = 1 8 | 9 | while True: 10 | try: 11 | n = int(input()) 12 | if n < 0: 13 | print('NO') 14 | else: 15 | if quad[n]: 16 | print('YES') 17 | else: 18 | print('NO') 19 | 20 | except EOFError: 21 | break 22 | -------------------------------------------------------------------------------- /2059.py: -------------------------------------------------------------------------------- 1 | p, j1, j2, r, a = input().split() 2 | 3 | resultado = (int(j1) + int(j2)) % 2 4 | 5 | if((r == '1') and (a == '1')): 6 | print('Jogador 2 ganha!') 7 | 8 | elif((r == '1') or (a == '1')): 9 | print('Jogador 1 ganha!') 10 | 11 | else: 12 | if(resultado == 0): 13 | if(p == '1'): 14 | print('Jogador 1 ganha!') 15 | else: 16 | print('Jogador 2 ganha!') 17 | elif(resultado == int(p)): 18 | print('Jogador 2 ganha!') 19 | else: 20 | print('Jogador 1 ganha!') 21 | -------------------------------------------------------------------------------- /2292.py: -------------------------------------------------------------------------------- 1 | 2 | for i in range(int(input())): 3 | stat, n = input().split() 4 | binario = '' 5 | for led in stat: 6 | if led == 'X': 7 | binario += '0' 8 | else: 9 | binario += '1' 10 | binario = bin(int(binario[::-1], 2) + int(n)) 11 | print(binario) 12 | binario = str(binario)[:1:-1] 13 | saida = '' 14 | for led in range(len(stat)): 15 | if binario[led] == '1': 16 | saida += 'O' 17 | else: 18 | saida += 'X' 19 | print(saida) 20 | -------------------------------------------------------------------------------- /1516.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n, m = input().split() 3 | if n == m == '0': 4 | break 5 | 6 | linha = [] 7 | for x in range(int(n)): 8 | linha.append(input()) 9 | a, b = input().split() 10 | a = int(int(a)/int(n)) 11 | b = int(int(b)/int(m)) 12 | redim = [] 13 | 14 | for x in linha: 15 | r = '' 16 | for y in x: 17 | r += y * b 18 | for y in range(int(a)): 19 | redim.append(r) 20 | 21 | for x in redim: 22 | print(x) 23 | 24 | print() 25 | -------------------------------------------------------------------------------- /2640.py: -------------------------------------------------------------------------------- 1 | r, c = [int(x) for x in input().split()] 2 | caixas = [] 3 | linha_index = [] 4 | roubadas = 0 5 | 6 | for linha in range(r): 7 | caixas.append([int(x) for x in input().split()]) 8 | roubadas += sum([(x - 1) for x in caixas[linha] if x != 0 and x != 1]) 9 | maior = max(caixas[linha]) 10 | roubadas -= maior 11 | linha_index.append([x for x, y in enumerate(caixas[linha]) if y == maior]) 12 | 13 | print(linha_index) 14 | 15 | for col in range(c): 16 | colunas = [x[col] for x in caixas] 17 | 18 | print(roubadas) 19 | -------------------------------------------------------------------------------- /1785.py: -------------------------------------------------------------------------------- 1 | def kaprekar(x): 2 | if x[0] == x[1] == x[2] == x[3]: 3 | return -1 4 | c = 0 5 | while x != '6174': 6 | maior = int(''.join(sorted(x, reverse=True))) 7 | menor = int(''.join(sorted(x))) 8 | x = str(maior - menor) 9 | while len(x) < 4: 10 | x = '0' + x 11 | c += 1 12 | return c 13 | 14 | n = int(input()) 15 | for i in range(n): 16 | x = input() 17 | while len(x) < 4: 18 | x = '0' + x 19 | x = kaprekar(x) 20 | print('Caso #%d: %d' % (i+1, x)) 21 | -------------------------------------------------------------------------------- /2310.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | t = [0, 0, 0] 3 | s = [0, 0, 0] 4 | while n > 0: 5 | n -= 1 6 | c = input() 7 | for i in range(1): 8 | l = [int(x) for x in input().split()] 9 | for x in range(3): 10 | t[x] += l[x] 11 | l = [int(x) for x in input().split()] 12 | for x in range(3): 13 | s[x] += l[x] 14 | 15 | print('Pontos de Saque: %.2f %%.' % (100*(s[0]/t[0]))) 16 | print('Pontos de Bloqueio: %.2f %%.' % (100*(s[1]/t[1]))) 17 | print('Pontos de Ataque: %.2f %%.' % (100*(s[2]/t[2]))) -------------------------------------------------------------------------------- /2027.py: -------------------------------------------------------------------------------- 1 | def GCDsimp (n, d): 2 | if d > 0: 3 | return GCDsimp (d, n % d) 4 | return n 5 | 6 | cont = 0 7 | apostas = [] 8 | while True: 9 | try: 10 | n, d = input().split() 11 | apostas.append(GCDsimp(int(n), int(d))) 12 | if apostas[cont] > 5: 13 | print('Noel') 14 | else: 15 | print('Gnomos') 16 | 17 | cont += 1 18 | 19 | 20 | 21 | except EOFError: 22 | break 23 | 24 | for i in range(cont-1, -1, -1): 25 | print(apostas[i], end = ' ') 26 | print() 27 | -------------------------------------------------------------------------------- /2484.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | word = input() 4 | l = [] 5 | for i in word: 6 | l.append(i) 7 | n = len(l) 8 | for i in range(0, len(l)): 9 | for j in range(i): 10 | print('', end=' ') 11 | for j in range(n): 12 | print(l[j], end='') 13 | if(j != n-1): 14 | print(' ', end='') 15 | print('') 16 | n -= 1 17 | print('') 18 | 19 | except EOFError: 20 | break -------------------------------------------------------------------------------- /2542.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | m, l = [int(x) for x in input().split()] 3 | 4 | marcos = [] 5 | leo = [] 6 | for i in range(m): 7 | marcos.append([int(x) for x in input().split()]) 8 | for i in range(l): 9 | leo.append([int(x) for x in input().split()]) 10 | 11 | cm, cl = [int(x) for x in input().split()] 12 | a = int(input()) 13 | 14 | marcos, leo = marcos[cm-1][a-1], leo[cl-1][a-1] 15 | print(marcos, leo) 16 | 17 | if marcos > leo: 18 | print('Marcos') 19 | elif leo > marcos: 20 | print('Leonardo') 21 | else: 22 | print('Empate') 23 | -------------------------------------------------------------------------------- /2087.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n = int(input()) 3 | if n == 0: 4 | break 5 | conjunto = [] 6 | prefixo = 0 7 | while n: 8 | n -= 1 9 | conjunto.append(input()) 10 | if not prefixo: 11 | for palavra in range(len(conjunto) - 1): 12 | if (conjunto[-1] in conjunto[palavra]) or (conjunto[palavra] in conjunto[-1]): 13 | prefixo = 1 14 | break 15 | 16 | if prefixo: 17 | print('Conjunto Ruim') 18 | else: 19 | print('Conjunto Bom') 20 | -------------------------------------------------------------------------------- /2583.py: -------------------------------------------------------------------------------- 1 | c = int(input()) 2 | while c > 0: 3 | c -= 1 4 | total = [] 5 | n = int(input()) 6 | 7 | while n > 0: 8 | n -= 1 9 | palavra = input().split() 10 | if palavra[1] == 'chirrin': 11 | if palavra[0] not in total: 12 | total.append(palavra[0]) 13 | elif palavra[1] == 'chirrion': 14 | if palavra[0] in total: 15 | total.remove(palavra[0]) 16 | 17 | total.sort() 18 | print('TOTAL') 19 | for tausfo_tem in total: 20 | print(tausfo_tem) 21 | -------------------------------------------------------------------------------- /1847.py: -------------------------------------------------------------------------------- 1 | a, b, c = input().split() 2 | a = int(a) 3 | b = int(b) 4 | c = int(c) 5 | 6 | if(a > b): 7 | if c > b: 8 | print(':)') 9 | else: 10 | if(b-c < a-b): 11 | print(':)') 12 | else: 13 | print(':(') 14 | 15 | 16 | elif(a < b): 17 | if c < b: 18 | print(':(') 19 | else: 20 | if(b-c > a-b): 21 | print(':(') 22 | else: 23 | print(':)') 24 | 25 | else: 26 | if c > a: 27 | print(':)') 28 | else: 29 | print(':(') -------------------------------------------------------------------------------- /1953.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | epr = 0 5 | ehd = 0 6 | intruso = 0 7 | for i in range(n): 8 | l, curso = input().split() 9 | if curso == 'EPR': 10 | epr += 1 11 | elif curso == 'EHD': 12 | ehd += 1 13 | else: 14 | intruso += 1 15 | 16 | print('EPR: %d' % epr) 17 | print('EHD: %d' % ehd) 18 | print('INTRUSOS: %d' % intruso) 19 | 20 | except EOFError: 21 | break -------------------------------------------------------------------------------- /1256.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | check = 0 3 | 4 | while n: 5 | n -= 1 6 | m, c = [int(x) for x in input().split()] 7 | hash = {str(x) : [] for x in range(m)} 8 | entrada = [int(x) for x in input().split()] 9 | 10 | if check: 11 | print() 12 | 13 | for i in entrada: 14 | resto = i % m 15 | hash[str(resto)].append(int(i)) 16 | 17 | for i in hash: 18 | print('%d -> ' % int(i), end = '') 19 | for j in hash[i]: 20 | print('%d -> ' % j, end = '') 21 | print('\\') 22 | 23 | check = 1 24 | -------------------------------------------------------------------------------- /2535.py: -------------------------------------------------------------------------------- 1 | 2 | while True: 3 | try: 4 | n = int(input()) 5 | filhotes = 0 6 | while n > 0: 7 | n -= 1 8 | especie = input() 9 | raca = input() 10 | nome = input().split() 11 | input() 12 | if (len(nome) > 1) and (especie == 'cachorro'): 13 | for i in nome: 14 | if i[0] == raca[0]: 15 | filhotes +=1 16 | break 17 | 18 | print(filhotes) 19 | 20 | except EOFError: 21 | break 22 | -------------------------------------------------------------------------------- /1309.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | mon = '$' 4 | temp = '' 5 | dolar = input() 6 | j = 1 7 | for t, i in enumerate(reversed(dolar)): 8 | temp += i 9 | if(((t+1)%3 == 0) and (t != len(dolar)-1)): 10 | temp += ',' 11 | j += 1 12 | mon += temp[::-1] 13 | cent = input() 14 | if(len(cent) < 2): 15 | cent += '0' 16 | cent = cent[::-1] 17 | mon += '.' + cent 18 | print(mon) 19 | 20 | except EOFError: 21 | break -------------------------------------------------------------------------------- /1383.py: -------------------------------------------------------------------------------- 1 | def is_sudoku(matriz): 2 | 3 | for linha in matriz: 4 | check = [0] * 9 5 | for elemento in linha: 6 | check[elemento - 1] += 1 7 | if check[elemento - 1] > 1: 8 | return 'NAO' 9 | return 'SIM' 10 | 11 | 12 | 13 | n = int(input()) 14 | for i in range(n): 15 | sudoku = [] 16 | for linha in range(9): 17 | sudoku.append([int(x) for x in input().split()]) 18 | print(sudoku) 19 | saida = is_sudoku(sudoku) 20 | print('Instancia %d' % (i+1)) 21 | print(saida) 22 | print() 23 | -------------------------------------------------------------------------------- /2478.py: -------------------------------------------------------------------------------- 1 | x = int(input()) 2 | partic = {} 3 | while x: 4 | x -= 1 5 | entrada = input().split() 6 | partic[entrada[0]] = [entrada[1], entrada[2], entrada[3]] 7 | 8 | while True: 9 | try: 10 | pessoa, presente = input().split() 11 | if pessoa in partic: 12 | if presente in partic[pessoa]: 13 | print('Uhul! Seu amigo secreto vai adorar o/') 14 | else: 15 | print('Tente Novamente!') 16 | else: 17 | print('Tente Novamente!') 18 | 19 | except EOFError: 20 | break 21 | -------------------------------------------------------------------------------- /1867.py: -------------------------------------------------------------------------------- 1 | n = '1' 2 | m = '1' 3 | 4 | while(True): 5 | n, m = input().split() 6 | # print(n,m) 7 | if(n == '0' and m =='0'): 8 | break 9 | 10 | while (len(n) > 1): 11 | n0 = 0 12 | for i in n: 13 | n0 += int(i) 14 | n = str(n0) 15 | 16 | while (len(m) > 1): 17 | m0 = 0 18 | for i in m: 19 | m0 += int(i) 20 | m = str(m0) 21 | 22 | if(int(n) == int(m)): 23 | print(0) 24 | elif(int(n) > int(m)): 25 | print(1) 26 | elif(int(n) < int(m)): 27 | print(2) -------------------------------------------------------------------------------- /1310.py: -------------------------------------------------------------------------------- 1 | def maior_lucro(dia): 2 | max_menor = max_maior = dia[0] 3 | for i in dia[1:]: 4 | max_menor = max(i, max_menor + i) 5 | max_maior = max(max_maior, max_menor) 6 | return max_maior 7 | 8 | while True: 9 | try: 10 | n = int(input()) 11 | custo = int(input()) 12 | dia = [] 13 | while n: 14 | n -= 1 15 | dia.append(int(input()) - custo) 16 | lucro = maior_lucro(dia) 17 | if lucro < 0: 18 | lucro = 0 19 | print(lucro) 20 | 21 | except EOFError: 22 | break 23 | -------------------------------------------------------------------------------- /1448.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | for i in range(n): 3 | frase = input() 4 | p1 = p2 = 0 5 | time1 = input() 6 | time2 = input() 7 | tam = len(frase) 8 | for letra in range(tam): 9 | if (letra < len(time1)) and (frase[letra] == time1[letra]): 10 | p1 += 1 11 | if (letra < len(time2)) and (frase[letra] == time2[letra]): 12 | p2 += 1 13 | 14 | print('Instancia %d' % (i + 1)) 15 | if p1 > p2: 16 | print('time 1') 17 | elif p2 > p1: 18 | print('time 2') 19 | else: 20 | print('empate') 21 | print() 22 | -------------------------------------------------------------------------------- /2530.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n, m = [int(i) for i in input().split()] 4 | juan = [int(i) for i in input().split()] 5 | ric = [int(i) for i in input().split()] 6 | i = j = 0 7 | colou = 0 8 | while j < n: 9 | if juan[j] == ric[i]: 10 | i += 1 11 | if i == m: 12 | colou = 1 13 | break 14 | j += 1 15 | if colou: 16 | print('sim') 17 | else: 18 | print('nao') 19 | 20 | except EOFError: 21 | break 22 | -------------------------------------------------------------------------------- /2486.py: -------------------------------------------------------------------------------- 1 | c = {'suco de laranja':120, 'morango fresco':85, 'mamao':85, 'goiaba vermelha':70, 'manga': 56, 'laranja':50, 'brocolis':34} 2 | 3 | while True: 4 | n = int(input()) 5 | if n == 0: 6 | break 7 | vitamina = 0 8 | for i in range(n): 9 | w = input().split() 10 | qt = int(w[0]) 11 | fruta = ' '.join(w[1:]) 12 | vitamina += c[fruta]*qt 13 | if vitamina < 110: 14 | print('Mais %d mg' % (110-vitamina)) 15 | elif vitamina > 130: 16 | print('Menos %d mg' % (vitamina-130)) 17 | else: 18 | print('%d mg' % (vitamina)) -------------------------------------------------------------------------------- /2710.py: -------------------------------------------------------------------------------- 1 | # Fill 2 | m = [[0 for x in range(500)] for y in range(500)] 3 | 4 | q = int(input()) 5 | while q: 6 | q -= 1 7 | 8 | try: 9 | entrada = input().split() 10 | u = entrada[0] 11 | x = int(entrada[1]) - 1 12 | y = int(entrada[2]) - 1 13 | z = int(entrada[3]) 14 | w = int(entrada[4]) 15 | v = int(entrada[5]) 16 | except IndexError: 17 | pass 18 | 19 | if u == 'U': 20 | for i in range(x, z): 21 | for j in range(y, w): 22 | m[i][j] += v 23 | elif u == 'A': 24 | print(m[x][y]) 25 | -------------------------------------------------------------------------------- /2751.py: -------------------------------------------------------------------------------- 1 | a = 15 2 | b = a//2 3 | c = 15.456 4 | d = c / 7.0 5 | print('Valores de b:') 6 | print('-------------') 7 | print('1) b = %d' % b) 8 | print('2) b = %20d' % b) 9 | print('3) b = %020d' % b) 10 | print('4) b = {:<20}'.format(b)) 11 | print('5) b = %d%%' % b) 12 | print() 13 | print('Valores de d:') 14 | print('-------------') 15 | print('1) d = %f' % d) 16 | print('2) d = %.0f' % d) 17 | print('3) d = %.1f' % d) 18 | print('4) d = %.2f' % d) 19 | print('5) d = %.3f' % d) 20 | print('6) d = %20.3f' % d) 21 | print('7) d = %020.3f' % d) 22 | print('8) d = {:<20.4}'.format(d)) 23 | print('9) d = %.2f%%' % d) 24 | -------------------------------------------------------------------------------- /1278.py: -------------------------------------------------------------------------------- 1 | # file = open('teste.txt', 'w') 2 | check = 0 3 | while True: 4 | n = int(input()) 5 | if n == 0: 6 | break 7 | if check == 1: 8 | print() 9 | # file.write('\n') 10 | l = [] 11 | for i in range(n): 12 | l.append(' '.join(input().split())) 13 | m = max(len(i) for i in l) 14 | 15 | for i in range(len(l)): 16 | for j in range(m-len(l[i])): 17 | print('', end=' ') 18 | # file.write(' ') 19 | print(l[i]) 20 | # file.write(l[i]) 21 | # file.write('\n') 22 | 23 | check = 1 24 | 25 | # file.close() 26 | -------------------------------------------------------------------------------- /2774.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | 3 | def precisao(qt, lista, media): 4 | somatorio = 0 5 | for caso in range(qt): 6 | somatorio += (lista[caso] - media)**2 7 | resultado = sqrt( (somatorio) / (qt - 1) ) 8 | return resultado 9 | 10 | while True: 11 | try: 12 | 13 | h, m = input().split() 14 | medidas = [float(x) for x in input().split()] 15 | casos = (int(h) * 60) // int(m) 16 | media = sum(medidas) / casos 17 | resultado = precisao(casos, medidas, media) 18 | 19 | print('%.5f' % resultado) 20 | 21 | except EOFError: 22 | break 23 | -------------------------------------------------------------------------------- /1629.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n = int(input()) 3 | if n == 0: 4 | break 5 | while n > 0: 6 | n -= 1 7 | um = 0 8 | zero = 0 9 | linha = input() 10 | for i in range(len(linha)): 11 | if i % 2 == 0: 12 | zero += int(linha[i]) 13 | else: 14 | um += int(linha[i]) 15 | resultado = 0 16 | while (zero): 17 | resultado += (zero % 10) 18 | zero = int(zero/10) 19 | while (um): 20 | resultado += (um % 10) 21 | um = int(um/10) 22 | print(resultado) 23 | -------------------------------------------------------------------------------- /2134.py: -------------------------------------------------------------------------------- 1 | instancia = 1 2 | while True: 3 | try: 4 | n = int(input()) 5 | menor = 11 6 | repr = '' 7 | while n: 8 | n -= 1 9 | nome, nota = input().split() 10 | if int(nota) == menor and repr < nome: 11 | repr = nome 12 | menor = int(nota) 13 | elif int(nota) < menor: 14 | repr = nome 15 | menor = int(nota) 16 | 17 | print('Instancia %d' % instancia) 18 | print(repr) 19 | print() 20 | instancia += 1 21 | 22 | except EOFError: 23 | break 24 | -------------------------------------------------------------------------------- /2570.py: -------------------------------------------------------------------------------- 1 | l, c, n = [int(x) for x in input().split()] 2 | 3 | game = [[0]*(l+1) for x in range(c+1)] 4 | 5 | ponto = 1 6 | for i in range(n): 7 | j, k = input().split() 8 | k = int(k) 9 | if j == 'L': 10 | for h in range(l+1): 11 | game[k-1][h] = ponto 12 | else: 13 | for h in range(l+1): 14 | game[h][k-1] = ponto 15 | ponto += 1 16 | if ponto == 5: 17 | ponto = 1 18 | 19 | ponto = [0, 0, 0, 0, 0, 0] 20 | for i in range(l): 21 | for j in range(c): 22 | ponto[game[i][j]] += 1 23 | 24 | print('R%d H%d C%d P%d' % (ponto[1], ponto[2], ponto[3], ponto[4])) -------------------------------------------------------------------------------- /2028.py: -------------------------------------------------------------------------------- 1 | cases = 1 2 | while True: 3 | try: 4 | n = int(input()) 5 | f = ['0'] 6 | for i in range(n+1): 7 | for j in range(i): 8 | f.append(i) 9 | print('Caso %d: %d numero'%(cases, len(f)), end ='') 10 | if(n != 0): 11 | print('s', end='') 12 | print() 13 | for i in range(len(f)): 14 | print(f[i], end = '') 15 | if(i != len(f)-1): 16 | print(' ', end = '') 17 | else: 18 | print() 19 | print() 20 | cases += 1 21 | 22 | except EOFError: 23 | break -------------------------------------------------------------------------------- /1219.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | pi = 3.1415926535897 3 | 4 | while True: 5 | try: 6 | a, b, c = [int(x) for x in input().split()] 7 | p = (a + b + c)/2 8 | triangulo = sqrt(p * (p - a) * (p - b) * (p - c)) 9 | raio = sqrt(((p - a) * (p - b) * (p - c))/p) 10 | rosas = pi * raio**2 11 | 12 | raio = (a * b * c) / sqrt((a + b + c) * (b + c - a) * (c + a - b) * (a + b - c)) 13 | girassois = (pi * raio**2) - triangulo 14 | violetas = triangulo - rosas 15 | 16 | print('%.4f %.4f %.4f' % (girassois, violetas, rosas)) 17 | 18 | except EOFError: 19 | break 20 | -------------------------------------------------------------------------------- /1218.py: -------------------------------------------------------------------------------- 1 | cont = 1 2 | while True: 3 | try: 4 | n = input() 5 | calc = input().split() 6 | if cont > 1: 7 | print() 8 | f = m = pares = 0 9 | for i in range(0, len(calc), 2): 10 | if calc[i] == n: 11 | pares += 1 12 | if calc[i + 1] == 'F': 13 | f += 1 14 | else: 15 | m += 1 16 | 17 | print('Caso %d:' % cont) 18 | print('Pares Iguais: %d' % pares) 19 | print('F: %d' % f) 20 | print('M: %d' % m) 21 | cont += 1 22 | 23 | except EOFError: 24 | break 25 | -------------------------------------------------------------------------------- /1292.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | while True: 4 | try: 5 | l = float(input()) 6 | x = l*(math.sin(0.6*math.pi)/math.sin(0.35*math.pi)) 7 | # raio do pentagono circunscrito 8 | # h = l/(2*math.tan(0.2*math.pi)) 9 | # print('Apotema: ', h) 10 | 11 | # apotema do pentagono 12 | # l = math.sqrt(h**2 + (l/2)**2) 13 | # print('Raio: ', l) 14 | 15 | # diagonal do quadrado 16 | # l += h 17 | 18 | # lado do quadrado 19 | # l = l/math.sqrt(2) 20 | 21 | print('%.10f'%x) 22 | 23 | except EOFError: 24 | break -------------------------------------------------------------------------------- /1786.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = input() 4 | c = '' 5 | b1 = 0 6 | b2 = 0 7 | for i in range(9): 8 | if i%3 == 0 and i > 0: 9 | c += '.' 10 | c += n[i] 11 | b1 += int(n[i]) * (i+1) 12 | b2 += int(n[i]) * (9-i) 13 | c += '-' 14 | b1 = b1 % 11 15 | b2 = b2 % 11 16 | if b1 == 10: 17 | b1 = 0 18 | if b2 == 10: 19 | b2 = 0 20 | 21 | c += str(b1) + str(b2) 22 | 23 | print(c) 24 | 25 | 26 | except EOFError: 27 | break -------------------------------------------------------------------------------- /1661.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n = int(input()) 3 | if n == 0: 4 | break 5 | a = [int(x) for x in input().split()] 6 | total = 0 7 | aux = 0 8 | i = 0 9 | while (a[i] != 0) or (a.count(0) == n): 10 | print(a) 11 | for j in range(i, n): 12 | if j != i: 13 | if (a[i] > 0 and a[j] < 0) or (a[i] < 0 and a[j] > 0): 14 | total += (j - i) * a[i] 15 | aux = a[i] 16 | a[i] += a[j] 17 | a[j] += aux 18 | if(a[i] == 0): 19 | i += 1 20 | print(a) 21 | print(total) 22 | -------------------------------------------------------------------------------- /1367.py: -------------------------------------------------------------------------------- 1 | # Well this is interesting 2 | 3 | while True: 4 | 5 | prob = [0] * 26 6 | dorm = [0] * 26 7 | total = 0 8 | ponto = 0 9 | 10 | n = int(input()) 11 | if not n: 12 | break 13 | 14 | while n: 15 | n -= 1 16 | p, t, j = input().split() 17 | pos = ord(p) - 65 18 | 19 | if j == 'correct': 20 | total += 1 21 | ponto += int(t) 22 | prob[pos] = 1 23 | if j == 'incorrect': 24 | dorm[pos] += 20 25 | 26 | for pos in range(len(prob)): 27 | if prob[pos]: 28 | ponto += dorm[pos] 29 | 30 | print(total, ponto) 31 | -------------------------------------------------------------------------------- /1262.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | while True: 4 | try: 5 | w = input() 6 | n = int(input()) 7 | tot = 0 8 | check = n 9 | for i in range(len(w)): 10 | if w[i] == 'R': 11 | 12 | if check == n: 13 | tot += 1 14 | 15 | if(check == 0): 16 | check = n 17 | tot += 1 18 | 19 | check -= 1 20 | elif w[i] == 'W': 21 | tot += 1 22 | check = n 23 | print(tot) 24 | 25 | 26 | except EOFError: 27 | break -------------------------------------------------------------------------------- /natal2018/d.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | pilha = [] 3 | menor = [-1] 4 | 5 | while n: 6 | n -= 1 7 | try: 8 | acao = input().split() 9 | acao, v = acao[0], acao[1] 10 | pilha.append(int(v)) 11 | for i in range(len(menor) + 1): 12 | if menor[i] < int(v): 13 | menor.insert(i, int(v)) 14 | break 15 | except IndexError: 16 | if len(pilha) > 0: 17 | if acao[0] == 'MIN': 18 | print(menor[-2]) 19 | elif acao[0] == 'POP': 20 | menor.remove(pilha[-1]) 21 | pilha.pop() 22 | 23 | else: 24 | print('EMPTY') 25 | -------------------------------------------------------------------------------- /1093.py: -------------------------------------------------------------------------------- 1 | while True: 2 | ev1, ev2, at, d = [int(x) for x in input().split()] 3 | if ev1 == ev2 == at == d == 0: 4 | break 5 | 6 | # Gambler's Ruin 7 | # https://en.wikipedia.org/wiki/Gambler's_ruin 8 | # 9 | # idk it just works 10 | 11 | c, ev1 = ev1, 0 12 | while c > 0: 13 | c -= d 14 | ev1 += 1 15 | 16 | c, ev2 = ev2, 0 17 | while c > 0: 18 | c -= d 19 | ev2 += 1 20 | 21 | if at == 3: 22 | ev1 /= (ev1 + ev2) 23 | else: 24 | qp = (1 - (6 - at)/ 6) 25 | qp = (1 - qp) / qp 26 | ev1 = (1 - qp**ev1) / (1 - qp**(ev1 + ev2)) 27 | 28 | print('%.1f' % (ev1 * 100)) 29 | -------------------------------------------------------------------------------- /1295.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | 3 | def distancia (x1, y1, x2, y2): 4 | return sqrt((x1 - x2)**2 + (y1 - y2)**2) 5 | 6 | while True: 7 | n = int(input()) 8 | if n == 0: 9 | break 10 | pontos = [] 11 | while n: 12 | n -= 1 13 | x, y = input().split() 14 | pontos.append([int(x), int(y)]) 15 | 16 | distancias = [] 17 | for i in range(len(pontos)): 18 | for j in range(i + 1, len(pontos)): 19 | distancias.append(distancia(pontos[i][0], pontos[i][1], pontos[j][0], pontos[j][1])) 20 | 21 | d = min(distancias) 22 | if d < 10000: 23 | print('%.4f' % d) 24 | else: 25 | print('INFINITY') 26 | -------------------------------------------------------------------------------- /1566.py: -------------------------------------------------------------------------------- 1 | # Counting sort has O(n + k), which is the fastest 2 | # (that I could find) 3 | def count_sort(vetor, maior): 4 | n = len(vetor) 5 | m = maior + 1 6 | count = [0] * m 7 | for i in vetor: 8 | count[i] += 1 9 | j = 0 10 | for i in range(m): 11 | for k in range(count[i]): 12 | vetor[j] = i 13 | j += 1 14 | return vetor 15 | 16 | nc = int(input()) 17 | while nc: 18 | nc -= 1 19 | n = int(input()) 20 | vetor = input().split() 21 | for i in range(len(vetor)): 22 | vetor[i] = int(vetor[i]) 23 | 24 | vetor = count_sort(vetor, max(vetor)) 25 | 26 | print(' '.join(str(x) for x in vetor)) 27 | -------------------------------------------------------------------------------- /2920.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | k, n = input().split() 4 | n = int(n) 5 | temp = [0] * len(k) 6 | while n > 0: 7 | for x in range(9,-1, -1): 8 | for y in range(len(k)): 9 | if k[y] == str(x): 10 | temp[y] = 1 11 | n -= 1 12 | if n < 1: 13 | break 14 | if n < 1: 15 | break 16 | menor = '' 17 | for x in range(len(temp)): 18 | if temp[x] == 0: 19 | menor += str(k[x]) 20 | print(menor) 21 | 22 | except EOFError: 23 | break 24 | -------------------------------------------------------------------------------- /1193.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | for i in range(1, n+1): 4 | m, c = input().split() 5 | 6 | if c == 'bin': 7 | a = int(m, 2) 8 | b = hex(int(m, 2)) 9 | b = b[2::] 10 | ca = 'dec' 11 | cb = 'hex' 12 | elif c == 'dec': 13 | a = hex(int(m)) 14 | a = a[2::] 15 | b = bin(int(m)) 16 | b = b[2::] 17 | ca = 'hex' 18 | cb = 'bin' 19 | elif c == 'hex': 20 | a = int(m, 16) 21 | b = bin(int(m, 16)) 22 | b = b[2::] 23 | ca = 'dec' 24 | cb = 'bin' 25 | 26 | print('Case %s:' % i) 27 | print('%s %s' % (a, ca)) 28 | print('%s %s' % (b, cb)) 29 | print() -------------------------------------------------------------------------------- /1222.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n, l, c = [int(x) for x in input().split()] 4 | w = input() 5 | page = 1 6 | line = 0 7 | ch = 0 8 | tam = len(w) 9 | i = 0 10 | 11 | while i < tam: 12 | while w[i] == ' ' and (ch == 0 or ch == c): 13 | i += 1 14 | # print(w[i], ' --- ', i, page, line, ch) 15 | if ch == c: 16 | line += 1 17 | ch = 0 18 | if line == l: 19 | page += 1 20 | line = 0 21 | i += 1 22 | ch += 1 23 | 24 | print(page) 25 | 26 | except EOFError: 27 | break 28 | -------------------------------------------------------------------------------- /1277.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | 3 | while(n > 0): 4 | n -= 1 5 | a = int(input()) 6 | l = input().split() 7 | p = input().split() 8 | for ind, a in enumerate(p): 9 | a = a.replace('M', '') 10 | old = len(a) 11 | a = a.replace('A', '') 12 | new = len(a) 13 | try: 14 | new /= old 15 | if(new >= 0.75): 16 | l[ind] = '-' 17 | except ZeroDivisionError: 18 | l[ind] = '-' 19 | 20 | l = [a for a in l if a is not '-'] 21 | for ind, a in enumerate(l): 22 | print(a, end='') 23 | if(ind != len(l)-1): 24 | print(' ', end='') 25 | print() 26 | -------------------------------------------------------------------------------- /1279.py: -------------------------------------------------------------------------------- 1 | pula = 0 2 | while True: 3 | try: 4 | ano = int(input()) 5 | b = 0 6 | ord = 1 7 | if pula: 8 | print('') 9 | pula = 1 10 | 11 | if (ano % 4 == 0) and (not (ano % 100 == 0) or (ano % 400 == 0)): 12 | print('This is leap year.') 13 | b = 1 14 | ord = 0 15 | if (ano % 15 == 0): 16 | print('This is huluculu festival year.') 17 | ord = 0 18 | if (ano % 55 == 0) and b: 19 | print('This is bulukulu festival year.') 20 | 21 | if ord: 22 | print('This is an ordinary year.') 23 | 24 | 25 | except EOFError: 26 | break 27 | -------------------------------------------------------------------------------- /1212.py: -------------------------------------------------------------------------------- 1 | while(True): 2 | a, b = input().split() 3 | carry = 0 4 | c = 0 5 | if((a == '0') and (b == '0')): 6 | break 7 | 8 | while(len(a) < len(b)): 9 | a = '0' + a 10 | while(len(b) < len(a)): 11 | b = '0' + b 12 | 13 | for i in reversed(range(0, len(a))): 14 | if ((int(a[i]) + int(b[i]) > 9) or ((int(a[i]) + int(b[i]) + c)) > 9): 15 | carry += 1 16 | c = 1 17 | else: 18 | c = 0 19 | 20 | if(carry == 0): 21 | print("No carry operation.") 22 | elif(carry == 1): 23 | print("1 carry operation.") 24 | else: 25 | print("%d carry operations." % carry) 26 | -------------------------------------------------------------------------------- /2031.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while(n > 0): 3 | n -= 1 4 | j1 = input() 5 | j2 = input() 6 | if(j1 == 'ataque'): 7 | if(j2 == 'ataque'): 8 | print('Aniquilacao mutua') 9 | else: 10 | print('Jogador 1 venceu') 11 | elif(j1 == 'papel'): 12 | if((j2 == 'ataque') or (j2 == 'pedra')): 13 | print('Jogador 2 venceu') 14 | else: 15 | print('Ambos venceram') 16 | elif(j1 == 'pedra'): 17 | if(j2 == 'papel'): 18 | print('Jogador 1 venceu') 19 | if(j2 == 'ataque'): 20 | print('Jogador 2 venceu') 21 | elif(j2 == 'pedra'): 22 | print('Sem ganhador') 23 | -------------------------------------------------------------------------------- /2749.py: -------------------------------------------------------------------------------- 1 | tam = 39 2 | for i in range(tam): 3 | print('-', end = '') 4 | print() 5 | 6 | print('|x = 35', end = '') 7 | for i in range(tam-8): 8 | print(' ', end = '') 9 | print('|') 10 | 11 | print('|', end = '') 12 | for i in range(tam-2): 13 | print(' ', end = '') 14 | print('|') 15 | 16 | print('| x = 35', end = '') 17 | for i in range(tam-23): 18 | print(' ', end = '') 19 | print('|') 20 | 21 | print('|', end = '') 22 | for i in range(tam-2): 23 | print(' ', end = '') 24 | print('|') 25 | 26 | 27 | print('|', end = '') 28 | for i in range(tam-8): 29 | print(' ', end = '') 30 | print('x = 35|') 31 | 32 | for i in range(tam): 33 | print('-', end = '') 34 | print() -------------------------------------------------------------------------------- /1022.py: -------------------------------------------------------------------------------- 1 | def gcd(n, m): 2 | if m == 0: 3 | return n 4 | else: 5 | return gcd(m, n % m) 6 | 7 | n = int(input()) 8 | while n: 9 | n -= 1 10 | n1, lixo1, d1, op, n2, lixo2, d2 = input().split() 11 | n1, d1, n2, d2 = int(n1), int(d1), int(n2), int(d2) 12 | 13 | if op == '+': 14 | num = (n1 * d2 + n2 * d1) 15 | den = (d1 * d2) 16 | elif op == '-': 17 | num = (n1 * d2 - n2 * d1) 18 | den = (d1 * d2) 19 | elif op == '*': 20 | num = (n1 * n2) 21 | den = (d1 * d2) 22 | elif op == '/': 23 | num = (n1 * d2) 24 | den = (n2 * d1) 25 | 26 | print('%d/%d = %d/%d' % (num, den, num/gcd(num, den), den/gcd(num, den))) 27 | -------------------------------------------------------------------------------- /2144.py: -------------------------------------------------------------------------------- 1 | final = 0.0 2 | total = 0 3 | while True: 4 | w1, w2, r = [int(x) for x in input().split()] 5 | if w1 == w2 == r == 0: 6 | break 7 | media = float(((w1 * (1 + r/30))+(w2 * (1 + r/30))))/2.0 8 | final += media 9 | total += 1 10 | if media < 13: 11 | print('Nao vai da nao') 12 | elif media < 14: 13 | print('E 13') 14 | elif media < 40: 15 | print('Bora, hora do show! BIIR!') 16 | elif media < 60: 17 | print('Ta saindo da jaula o monstro!') 18 | else: 19 | print('AQUI E BODYBUILDER!!') 20 | 21 | final = final/float(total) 22 | if final > 40: 23 | print() 24 | print('Aqui nois constroi fibra rapaz! Nao e agua com musculo!') 25 | -------------------------------------------------------------------------------- /2712.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | while n: 3 | n -= 1 4 | placa = input().split('-') 5 | if (len(placa) == 2) and (len(placa[0]) == 3) and (len(placa[1]) == 4) and (placa[0] == placa[0].upper()): 6 | try: 7 | check = int(placa[1]) 8 | r = int(placa[1][3]) 9 | if r > 8 or r == 0: 10 | print('FRIDAY') 11 | elif r > 6: 12 | print('THURSDAY') 13 | elif r > 4: 14 | print('WEDNESDAY') 15 | elif r > 2: 16 | print('TUESDAY') 17 | else: 18 | print('MONDAY') 19 | except: 20 | print('FAILURE') 21 | else: 22 | print('FAILURE') 23 | -------------------------------------------------------------------------------- /2508.py: -------------------------------------------------------------------------------- 1 | import string 2 | letras = list(string.ascii_lowercase) 3 | l1 = letras[:9] 4 | l2 = letras[9:18] 5 | l3 = letras[18:] 6 | while True: 7 | try: 8 | nome = input().lower() 9 | valor = 0 10 | for x in nome: 11 | if x in l1: 12 | valor += l1.index(x) + 1 13 | elif x in l2: 14 | valor += l2.index(x) + 1 15 | elif x in l3: 16 | valor += l3.index(x) + 1 17 | 18 | valor = str(valor) 19 | while len(valor) > 1: 20 | total = 0 21 | for x in valor: 22 | total += int(x) 23 | valor = str(total) 24 | print(valor) 25 | except EOFError: 26 | break 27 | -------------------------------------------------------------------------------- /2140.py: -------------------------------------------------------------------------------- 1 | notas = [2, 5, 10, 20, 50, 100] 2 | while True: 3 | n, m = input().split() 4 | if(n == '0' and m == '0'): 5 | break 6 | n = int(n) 7 | m = int(m) 8 | m -= n 9 | total = 0 10 | 11 | for i in notas: 12 | if(m == i*2): 13 | print('possible') 14 | total = 2 15 | break 16 | 17 | if total == 0: 18 | for i in range(len(notas)-1, -1, -1): 19 | if total == 3: 20 | break 21 | if m - notas[i] >= 0: 22 | m -= notas[i] 23 | total += 1 24 | if (m == 0 and total == 2): 25 | print('possible') 26 | else: 27 | print('impossible') 28 | -------------------------------------------------------------------------------- /1304.py: -------------------------------------------------------------------------------- 1 | distancia = 0 2 | check = 0 3 | v_ant = 0 4 | while True: 5 | try: 6 | tempo = input().split(':') 7 | # if len(tempo[2]) > 2: 8 | try: 9 | tempo[2], v = tempo[2].split(' ') 10 | 11 | except: 12 | pass 13 | 14 | if check: 15 | tempo_ant = h + m + s 16 | 17 | h, m, s= [float(x) for x in tempo] 18 | m /= 60 19 | s /= 3600 20 | tempo_fin = h + m + s 21 | 22 | if check: 23 | tempo_fin -= tempo_ant 24 | distancia += float(v) * tempo_fin 25 | print('%s:%s:%s %.2f km' % (tempo[0], tempo[1], tempo[2], distancia)) 26 | 27 | 28 | check = 1 29 | 30 | except EOFError: 31 | break 32 | -------------------------------------------------------------------------------- /2139.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime, timedelta 2 | while True: 3 | try: 4 | m, d = input().split() 5 | if len(m) == 1: 6 | m = '0' + m 7 | if len(d) == 1: 8 | d = '0' + d 9 | data = '2016' + m + d 10 | natal = '20161225' 11 | data = datetime.strptime(data, '%Y%m%d') 12 | natal = datetime.strptime(natal, '%Y%m%d') 13 | dias = (natal - data).days 14 | if dias == 0: 15 | print('E natal!') 16 | elif dias == 1: 17 | print('E vespera de natal!') 18 | elif dias < 0: 19 | print('Ja passou!') 20 | else: 21 | print('Faltam %d dias para o natal!' % dias) 22 | 23 | except EOFError: 24 | break 25 | -------------------------------------------------------------------------------- /2551.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | treino = [] 5 | recorde = [] 6 | while n: 7 | n -= 1 8 | treino.append([int(x) for x in input().split()]) 9 | if len(treino) == 1: 10 | media = treino[0][1]/treino[0][0] 11 | recorde.append(1) 12 | else: 13 | if treino[-1][1] / treino[-1][0] > media: 14 | media = treino[-1][1] / treino[-1][0] 15 | recorde.append(1) 16 | else: 17 | recorde.append(0) 18 | for i in range(len(recorde)): 19 | if recorde[i] == 1: 20 | print(i + 1) 21 | 22 | except EOFError: 23 | break 24 | -------------------------------------------------------------------------------- /2135.py: -------------------------------------------------------------------------------- 1 | num = 0 2 | while True: 3 | num += 1 4 | try: 5 | n = int(input()) 6 | p = [] 7 | inst = [] 8 | k = -1 9 | p = list(map(int, input().split())) 10 | inst.append(0) 11 | if(inst[0] == int(p[0])): 12 | k = 0 13 | else: 14 | for i in range(1, n): 15 | inst.append(int(p[i-1])+inst[i-1]) 16 | if((inst[i] == int(p[i])) and (k == -1)): 17 | k = int(p[i]) 18 | print("Instancia", num) 19 | if(k != -1): 20 | print(k) 21 | else: 22 | print("nao achei") 23 | print() 24 | p.clear() 25 | inst.clear() 26 | 27 | 28 | except EOFError: 29 | break -------------------------------------------------------------------------------- /1031.py: -------------------------------------------------------------------------------- 1 | from collections import deque 2 | 3 | def jos(k, j): 4 | d = deque(k) 5 | i = 0 6 | while len(d) > 1: 7 | d.rotate(-j[i]) 8 | d.pop() 9 | i += 1 10 | if i == len(j): 11 | i = 0 12 | return(d.pop()) 13 | 14 | def gen_prime(n): 15 | p = [2, 3, 5, 7] 16 | i = 11 17 | while len(p) < n: 18 | for j in p: 19 | if i % j == 0: 20 | break 21 | if j == p[len(p) - 1]: 22 | p.append(i) 23 | i += 1 24 | return p[0:n] 25 | 26 | 27 | primos = gen_prime(3501) 28 | 29 | while True: 30 | k = int(input()) 31 | if not k: 32 | break 33 | k = [x for x in range(1, int(k)+1)] 34 | resultado = jos(k, primos) 35 | print(resultado) 36 | -------------------------------------------------------------------------------- /1124.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | while True: 4 | l, c, r1, r2 = [int(x) for x in input().split()] 5 | if (l == 0 and c == 0 and r1 == 0 and r2 == 0): 6 | break 7 | 8 | lc = (r1 + r1) * 2 9 | r1, r2 = r1 * 2, r2 * 2 10 | 11 | if l > c: 12 | if (l >= lc) and ((c >= r1) or (c >= r1)): 13 | print('S') 14 | else: 15 | print('N') 16 | 17 | elif c > l: 18 | print(c, lc, l, r1, r2) 19 | if (c >= lc) and ((l >= r1) or (l >= r2)): 20 | print('S') 21 | else: 22 | print('N') 23 | 24 | else: 25 | if (l >= lc) and ((c >= r1) or (c >= r2)): 26 | print('S') 27 | elif (c >= lc) and ((l >= r1) or (l >= r2)): 28 | print('S') 29 | else: 30 | print('N') 31 | -------------------------------------------------------------------------------- /1239.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | ph = input() 4 | i = 0 5 | b = 0 6 | res = '' 7 | for j in range(len(ph)): 8 | 9 | if(ph[j] == '_'): 10 | if(i == 0): 11 | res += '' 12 | i = 1 13 | else: 14 | res += '' 15 | i = 0 16 | 17 | elif(ph[j] == '*'): 18 | if(b == 0): 19 | res += '' 20 | b = 1 21 | else: 22 | res += '' 23 | b = 0 24 | 25 | else: 26 | res += ph[j] 27 | 28 | print(res) 29 | 30 | except EOFError: 31 | break -------------------------------------------------------------------------------- /2674.py: -------------------------------------------------------------------------------- 1 | from math import sqrt 2 | 3 | def primo(n): 4 | if (n == 2): 5 | return 1 6 | if (n == 0 or n == 1 or (n % 2 == 0)): 7 | return 0 8 | for i in range(3, int(sqrt(n)) + 2): 9 | if (n % i == 0): 10 | return 0 11 | return 1 12 | 13 | def super(n): 14 | while n >= 10: 15 | s = n % 10 16 | n = int(n / 10) 17 | if not primo(s): 18 | return 0 19 | if(n == 2 or n == 3 or n == 5 or n == 7): 20 | return 1 21 | else: 22 | return 0 23 | 24 | while True: 25 | try: 26 | n = int(input()) 27 | if not primo(n): 28 | print('Nada') 29 | else: 30 | if super(n): 31 | print('Super') 32 | else: 33 | print('Primo') 34 | 35 | except EOFError: 36 | break 37 | -------------------------------------------------------------------------------- /1827.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | n = int(input()) 4 | s = int(n/3) 5 | e = n-s 6 | 7 | # FILL WITH 0 8 | m = [[0 for i in range(n)] for j in range(n)] 9 | 10 | # FILL WITH 2 11 | for i in range(n): 12 | m[i][i] = 2 13 | 14 | # FILL WITH 3 15 | j = 0 16 | for i in range(n-1,-1,-1): 17 | m[j][i] = 3 18 | j += 1 19 | 20 | # FILL MIDDLE WITH 1 21 | for i in range(s, e): 22 | for j in range(s, e): 23 | m[i][j] = 1 24 | 25 | m[int(n/2)][int(n/2)] = 4 26 | 27 | for i in range(n): 28 | for j in range(n): 29 | print(m[j][i], end='') 30 | print() 31 | print() 32 | 33 | except EOFError: 34 | break -------------------------------------------------------------------------------- /2728.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | texto = input().split('-') 4 | cobol = '' 5 | for palavra in texto: 6 | i = palavra[0].lower() 7 | f = palavra[len(palavra) - 1].lower() 8 | if len(cobol) == 0 and (i == 'c' or f == 'c'): 9 | cobol += 'c' 10 | elif len(cobol) == 1 and (i == 'o' or f == 'o'): 11 | cobol += 'o' 12 | elif len(cobol) == 2 and (i == 'b' or f == 'b'): 13 | cobol += 'b' 14 | elif len(cobol) == 3 and (i == 'o' or f == 'o'): 15 | cobol += 'o' 16 | elif len(cobol) == 4 and (i == 'l' or f == 'l'): 17 | cobol += 'l' 18 | 19 | if cobol == 'cobol': 20 | print('GRACE HOPPER') 21 | else: 22 | print('BUG') 23 | except EOFError: 24 | break 25 | -------------------------------------------------------------------------------- /2253.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | s = input() 4 | t = len(s) 5 | mi = False 6 | ma = False 7 | nu = False 8 | if((t > 32) or (t < 6)): 9 | print('Senha invalida.') 10 | else: 11 | for i in range(t): 12 | if(((ord(s[i]))>64) and ((ord(s[i]))<91)): 13 | ma = True 14 | elif(((ord(s[i]))>96) and ((ord(s[i]))<123)): 15 | mi = True 16 | elif(((ord(s[i]))>47) and ((ord(s[i]))<58)): 17 | nu = True 18 | else: 19 | ma = False 20 | break 21 | 22 | if(ma and mi and nu): 23 | print('Senha valida.') 24 | else: 25 | print('Senha invalida.') 26 | 27 | except EOFError: 28 | break -------------------------------------------------------------------------------- /1451.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | texto = input() 4 | tam = len(texto) 5 | ponto = 1 6 | palavra = '' 7 | temp = '' 8 | for letra in range(tam): 9 | ch = texto[letra] 10 | if ch != '[' and ch != ']': 11 | if ponto: 12 | palavra += ch 13 | else: 14 | temp += ch 15 | if ch == '[': 16 | if ponto: 17 | ponto = 0 18 | else: 19 | palavra = temp + palavra 20 | temp = '' 21 | elif ch == ']': 22 | ponto = 1 23 | palavra = temp + palavra 24 | temp = '' 25 | 26 | if temp: 27 | palavra = temp + palavra 28 | print(palavra) 29 | 30 | 31 | except EOFError: 32 | break 33 | -------------------------------------------------------------------------------- /1287.py: -------------------------------------------------------------------------------- 1 | def strtoint(palavra): 2 | inteiro = '' 3 | lista_int = '1234567890' 4 | check = 0 5 | for letra in palavra: 6 | if letra in lista_int: 7 | inteiro += letra 8 | else: 9 | if letra == 'l': 10 | inteiro += '1' 11 | elif letra == 'o' or letra == 'O': 12 | inteiro += '0' 13 | elif letra != ',' and letra != ' ': 14 | check = 1 15 | break 16 | 17 | try: 18 | inteiro = int(inteiro) 19 | if inteiro > 2147483647: 20 | check = 1 21 | except ValueError: 22 | inteiro = 'error' 23 | 24 | if check: 25 | inteiro = 'error' 26 | 27 | return inteiro 28 | 29 | while True: 30 | try: 31 | entrada = input() 32 | entrada = strtoint(entrada) 33 | print(entrada) 34 | except EOFError: 35 | break 36 | -------------------------------------------------------------------------------- /2338.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | morse = ['=.===', '===.=.=.=', '===.=.===.=', '===.=.=', '=', '=.=.===.=', '===.===.=', 3 | '=.=.=.=', '=.=', '=.===.===.===', '===.=.===', '=.===.=.=', '===.===', '===.=', 4 | '===.===.===', '=.===.===.=', '===.===.=.===', '=.===.=', '=.=.=', '===', '=.=.===', 5 | '=.=.=.===', '=.===.===', '===.=.=.===', '===.=.===.===', '===.===.=.=', ' '] 6 | 7 | dicionario = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 8 | 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', ' '] 9 | 10 | while n: 11 | n -= 1 12 | palavra = input() 13 | palavra = palavra.replace('.....', '1') 14 | resultado = '' 15 | print(palavra) 16 | for letra in palavra: 17 | letra = letra.split('...') 18 | for i in letra: 19 | resultado += dicionario[morse.index(i)] 20 | print(resultado) 21 | -------------------------------------------------------------------------------- /2567.py: -------------------------------------------------------------------------------- 1 | def maxDistance(array): 2 | 3 | # max and min variables as described 4 | # in algorithm. 5 | max1 = -2147483648 6 | min1 = +2147483647 7 | max2 = -2147483648 8 | min2 = +2147483647 9 | 10 | for i in range(len(array)): 11 | 12 | 13 | # Updating max and min variables 14 | # as described in algorithm. 15 | max1 = max(max1, array[i] + i) 16 | min1 = min(min1, array[i] + i) 17 | max2 = max(max2, array[i] - i) 18 | min2 = min(min2, array[i] - i) 19 | 20 | 21 | # Calculating maximum absolute difference. 22 | return max(max1 - min1, max2 - min2) 23 | 24 | 25 | # Driver program to 26 | # test above function 27 | 28 | array = [ 17, 55, 3, 53, 23, 19, 27, 76, 93, 53, 42, 3, 32, 45, 95, 0, 48, 90, 20, 68, 7, 9, 67, 57, 4, 45, 66, 70, 28, 61, 56, 22, 25, 52, 89, 17, 89, 19, 49, 65, 40, 90, 54, 25, 34, 70, 29 | 51 ] 30 | 31 | print(maxDistance(array)) 32 | -------------------------------------------------------------------------------- /1875.py: -------------------------------------------------------------------------------- 1 | c = int(input()) 2 | while c: 3 | c -= 1 4 | p = int(input()) 5 | g = b = r = 0 6 | while p: 7 | p -= 1 8 | m, s = input().split() 9 | 10 | # GOLS # 11 | if m == 'G': 12 | if s == 'B': 13 | g += 2 14 | else: 15 | g += 1 16 | 17 | elif m == 'B': 18 | if s == 'R': 19 | b += 2 20 | else: 21 | b += 1 22 | 23 | elif m == 'R': 24 | if s == 'G': 25 | r += 2 26 | else: 27 | r += 1 28 | 29 | #------# 30 | 31 | if g == b == r: 32 | print('trempate') 33 | elif (g > b) and (g > r): 34 | print('green') 35 | elif (b > r) and (b > g): 36 | print('blue') 37 | elif (r > g) and (r > b): 38 | print('red') 39 | elif (g == r) or (r == b) or (b == g): 40 | print('empate') 41 | -------------------------------------------------------------------------------- /2040.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n = int(input()) 3 | if n == 0: 4 | break 5 | time = {} 6 | for i in range(n): 7 | entrada = input().split() 8 | time[entrada[0]] = int(entrada[1]) 9 | for i in range(n//2): 10 | jogo = input().split() 11 | ponto = [int(i)*3 for i in jogo[1].split('-')] 12 | if ponto[0] > ponto[1]: 13 | a = 5 14 | b = 0 15 | elif ponto[0] < ponto[1]: 16 | a = 0 17 | b = 5 18 | else: 19 | a = b = 1 20 | time[jogo[0]] += ponto[0] + a 21 | time[jogo[2]] += ponto[1] + b 22 | 23 | vencedor = [max(time, key=time.get), max(time.values())] 24 | if vencedor[0] == 'Sport': 25 | print('O Sport foi o campeao com %d pontos :D' % vencedor[1]) 26 | else: 27 | print('O Sport nao foi o campeao. O time campeao foi o % com %d pontos :(' % (vencedor[0], vencedor[1])) 28 | print() 29 | -------------------------------------------------------------------------------- /1311.py: -------------------------------------------------------------------------------- 1 | while True: 2 | s, b = [int(x) for x in input().split()] 3 | if s == b == 0: 4 | break 5 | dir = 0 6 | esq = s+1 7 | while b: 8 | b -= 1 9 | l, r = [int(i) for i in input().split()] 10 | l -= 1 11 | r += 1 12 | 13 | if (dir != '*') and (r > dir): 14 | dir = r 15 | if dir > s: 16 | dir = '*' 17 | 18 | if (esq != '*') and (l < esq): 19 | esq = l 20 | if esq < 1: 21 | esq = '*' 22 | 23 | print(esq, dir) 24 | ''' 25 | l -= 1 26 | sold = sold[:l] + [0] * (r - l) + sold[r:] 27 | while l >= 0 and sold[l] == 0: 28 | l -= 1 29 | while r < s and sold[r] == 0: 30 | r += 1 31 | l += 1 32 | r += 1 33 | if l <= 0: 34 | l = '*' 35 | if r > s: 36 | r = '*' 37 | ''' 38 | print('-') 39 | -------------------------------------------------------------------------------- /1763.py: -------------------------------------------------------------------------------- 1 | feliz_natal = {'brasil' : 'Feliz Natal!', 'alemanha' : 'Frohliche Weihnachten!', 'austria' : 'Frohe Weihnacht!', 'coreia' : 'Chuk Sung Tan!', 'espanha' : 'Feliz Navidad!', 'grecia' : 'Kala Christougena!', 'estados-unidos' : 'Merry Christmas!', 'inglaterra' : 'Merry Christmas!', 'australia' : 'Merry Christmas!', 'portugal' : 'Feliz Natal!', 'suecia' : 'God Jul!', 'turquia' : 'Mutlu Noeller', 'argentina' : 'Feliz Navidad!', 'chile' : 'Feliz Navidad!', 'mexico' : 'Feliz Navidad!', 'antardida' : 'Merry Christmas!', 'canada' : 'Merry Christmas!', 'irlanda' : 'Nollaig Shona Dhuit!', 'belgica' : 'Zalig Kerstfeest!', 'italia' : 'Buon Natale!', 'libia' : 'Buon Natale!', 'siria' : 'Milad Mubarak!', 'marrocos' : 'Milad Mubarak!', 'japao' : 'Merii Kurisumasu!'} 2 | 3 | while True: 4 | try: 5 | pais = input() 6 | if pais in feliz_natal.keys(): 7 | print(feliz_natal[pais]) 8 | else: 9 | print('--- NOT FOUND ---') 10 | 11 | except EOFError: 12 | break 13 | -------------------------------------------------------------------------------- /2750.py: -------------------------------------------------------------------------------- 1 | print('---------------------------------------') 2 | print('| decimal | octal | Hexadecimal |') 3 | print('---------------------------------------') 4 | print('| 0 | 0 | 0 |') 5 | print('| 1 | 1 | 1 |') 6 | print('| 2 | 2 | 2 |') 7 | print('| 3 | 3 | 3 |') 8 | print('| 4 | 4 | 4 |') 9 | print('| 5 | 5 | 5 |') 10 | print('| 6 | 6 | 6 |') 11 | print('| 7 | 7 | 7 |') 12 | print('| 8 | 10 | 8 |') 13 | print('| 9 | 11 | 9 |') 14 | print('| 10 | 12 | A |') 15 | print('| 11 | 13 | B |') 16 | print('| 12 | 14 | C |') 17 | print('| 13 | 15 | D |') 18 | print('| 14 | 16 | E |') 19 | print('| 15 | 17 | F |') 20 | print('---------------------------------------') 21 | -------------------------------------------------------------------------------- /1243.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | enunciado = input().split() 4 | 5 | palavra = 0 6 | while palavra < len(enunciado): 7 | 8 | if any(ch.isdigit() for ch in enunciado[palavra]): 9 | del enunciado[palavra] 10 | palavra -= 1 11 | elif enunciado[palavra].count('.') > 1: 12 | del enunciado[palavra] 13 | palavra -= 1 14 | 15 | palavra += 1 16 | 17 | comprimento = 0 18 | for palavra in enunciado: 19 | if (palavra.count('.') == 0) or (palavra.index('.') == len(palavra) - 1): 20 | comprimento += len(palavra) 21 | if '.' in palavra: 22 | comprimento -= 1 23 | 24 | if len(enunciado): 25 | comprimento = comprimento//len(enunciado) 26 | 27 | if comprimento <= 3: 28 | pontos = 250 29 | elif comprimento <= 5: 30 | pontos = 500 31 | else: 32 | pontos = 1000 33 | 34 | print(pontos) 35 | 36 | except EOFError: 37 | break 38 | -------------------------------------------------------------------------------- /1514.py: -------------------------------------------------------------------------------- 1 | while True: 2 | n, m = input().split() 3 | n, m = int(n), int(m) 4 | if n == m == 0: 5 | break 6 | carac = 4 7 | competidor = [] 8 | for i in range(n): 9 | competidor.append([int(x) for x in input().split()]) 10 | 11 | # Caracteristica 1 12 | # Ninguem resolveu todos 13 | for i in range(n): 14 | p = competidor[i].count(1) 15 | if p == m: 16 | carac -= 1 17 | break 18 | 19 | # Caracteristica 2 20 | # Todo problema foi resolvido por pelo menos 1 21 | problema = [0] * m 22 | for i in range(n): 23 | for j in range(m): 24 | if competidor[i][j] == 1: 25 | problema[j] += 1 26 | if problema.count(0) > 0: 27 | carac -= 1 28 | 29 | # Caracteristica 3 30 | # Nao ha nenhum problema resolvido por todos 31 | 32 | for j in range(m): 33 | if problema[j] == n: 34 | carac -= 1 35 | break 36 | 37 | # Caracteristica 4 38 | # Todos resolveram pelo menos 1 39 | 40 | for i in range(n): 41 | p = competidor[i].count(0) 42 | if p == m: 43 | carac -= 1 44 | break 45 | 46 | print(carac) 47 | -------------------------------------------------------------------------------- /2678.py: -------------------------------------------------------------------------------- 1 | while True: 2 | try: 3 | numero = input().upper() 4 | # numero = (' '.join(numero)).upper() 5 | saida = '' 6 | listanumeros = '0123456789*#' 7 | for digito in numero: 8 | if digito in listanumeros: 9 | saida += digito 10 | elif digito == 'A' or digito == 'B' or digito == 'C': 11 | saida += '2' 12 | elif digito == 'D' or digito == 'E' or digito == 'F': 13 | saida += '3' 14 | elif digito == 'G' or digito == 'H' or digito == 'I': 15 | saida += '4' 16 | elif digito == 'J' or digito == 'K' or digito == 'L': 17 | saida += '5' 18 | elif digito == 'M' or digito == 'N' or digito == 'O': 19 | saida += '6' 20 | elif digito == 'P' or digito == 'Q' or digito == 'R' or digito == 'S': 21 | saida += '7' 22 | elif digito == 'T' or digito == 'U' or digito == 'V': 23 | saida += '8' 24 | elif digito == 'X' or digito == 'Y' or digito == 'W' or digito == 'Z': 25 | saida += '9' 26 | 27 | 28 | print(saida) 29 | 30 | except EOFError: 31 | break 32 | -------------------------------------------------------------------------------- /2163.py: -------------------------------------------------------------------------------- 1 | n, m = [int(x) for x in input().split()] 2 | t = [] 3 | possibleX = [] 4 | possibleY = [] 5 | 6 | for i in range(n): 7 | t.append([int(x) for x in input().split()]) 8 | if (i > 0) and (i < n - 1) and (42 in t[i]): 9 | indexes = [index for index, x in enumerate(t[i]) if x == 42] 10 | possibleX.extend([i] * len(indexes)) 11 | possibleY.extend(indexes) 12 | 13 | x = y = 0 14 | 15 | for i in range(0, len(possibleX)): 16 | if (possibleX[i] > 0) and (possibleX[i] < n-1) and (possibleY[i] > 0) and (possibleY[i] < m-1): 17 | soma = 0 18 | for i2 in range(possibleX[i]-1, possibleX[i] + 2): 19 | for j2 in range(possibleY[i] - 1, possibleY[i] + 2): 20 | soma += t[i2][j2] 21 | if soma == 98: 22 | x = possibleX[i] + 1 23 | y = possibleY[i] + 1 24 | break 25 | 26 | print(x, y) 27 | 28 | ''' 29 | if t[possibleX[i]-1][possibleY[i]-1] == t[possibleX[i]-1][possibleY[i]] == t[possibleX[i]-1][possibleY[i]+1] == 7: 30 | if t[possibleX[i]][possibleY[i]-1] == t[possibleX[i]+1][possibleY[i]-1] == t[possibleX[i]+1][possibleY[i]] == 7: 31 | if t[possibleX[i]+1][possibleY[i]+1] == t[possibleX[i]][possibleY[i]+1] == 7: 32 | x = possibleX[i] + 1 33 | y = possibleY[i] + 1 34 | ''' 35 | --------------------------------------------------------------------------------